@guihz/trading-vue-editor-tes 0.0.60 → 0.0.62
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-CHJsIhut.js → parserTccWorker-Bw7LmssX.js} +46 -46
- package/lib/assets/{scriptsRunWorker-CWty4DVS.js → scriptsRunWorker-B9aWCoDC.js} +2 -2
- package/lib/components/editor/parseScript/buildInFuncNamespace/input.d.ts +0 -2
- package/lib/components/editor/parseScript/constants.d.ts +1 -0
- package/lib/components/editor/parseScript/parseToJs.d.ts +1 -0
- package/lib/components/editor/parseScript/parseToLibJs.d.ts +1 -0
- package/lib/components/editor/parseScript/visitorParser.d.ts +1 -0
- package/lib/components/editor/type/index.d.ts +1 -0
- package/lib/components/editor/utils/parserTcc.d.ts +29 -0
- package/lib/components/editor/utils/scriptsRunWorker.d.ts +15 -0
- package/lib/trading-vue-editor.js +271 -265
- package/lib/trading-vue-editor.umd.cjs +20 -20
- package/package.json +1 -1
@@ -51,7 +51,7 @@ Example:
|
|
51
51
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
52
52
|
**/(function(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(v,E){if(isNaN(v=parseInt(v,10)))throw m();return v*E}function a(v,E){if(E===0)throw w();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var N=d(v,E);return b.n=v/N,b.d=E/N,b}function l(v){for(var E={},b=v,N=2,x=4;x<=b;){for(;b%N===0;)b/=N,E[N]=(E[N]||0)+1;x+=1+2*N++}return b!==v?b>1&&(E[b]=(E[b]||0)+1):E[v]=(E[v]||0)+1,E}var c=function(v,E){var b=0,N=1,x=1,F=0,M=0,S=0,I=1,C=1,T=0,L=1,U=1,k=1,W=1e7,P;if(v!=null)if(E!==void 0){if(b=v,N=E,x=b*N,b%1!==0||N%1!==0)throw D()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw m();x=b*N;break}case"number":{if(v<0&&(x=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(C=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=C);L<=W&&k<=W;)if(P=(T+U)/(L+k),v===P){L+k<=W?(b=T+U,N=L+k):k>L?(b=U,N=k):(b=T,N=L);break}else v>P?(T+=U,L+=k):(U+=T,k+=L),L>W?(b=U,N=k):(b=T,N=L);b*=C}else(isNaN(v)||isNaN(E))&&(N=b=NaN);break}case"string":{if(L=v.match(/\d+|./g),L===null)throw m();if(L[T]==="-"?(x=-1,T++):L[T]==="+"&&T++,L.length===T+1?M=s(L[T++],x):L[T+1]==="."||L[T]==="."?(L[T]!=="."&&(F=s(L[T++],x)),T++,(T+1===L.length||L[T+1]==="("&&L[T+3]===")"||L[T+1]==="'"&&L[T+3]==="'")&&(M=s(L[T],x),I=Math.pow(10,L[T].length),T++),(L[T]==="("&&L[T+2]===")"||L[T]==="'"&&L[T+2]==="'")&&(S=s(L[T+1],x),C=Math.pow(10,L[T+1].length)-1,T+=3)):L[T+1]==="/"||L[T+1]===":"?(M=s(L[T],x),I=s(L[T+2],1),T+=3):L[T+3]==="/"&&L[T+1]===" "&&(F=s(L[T],x),M=s(L[T+2],x),I=s(L[T+4],1),T+=5),L.length<=T){N=I*C,x=b=S+N*F+C*M;break}}default:throw m()}if(N===0)throw w();n.s=x<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function h(v,E,b){for(var N=1;E>0;v=v*v%b,E>>=1)E&1&&(N=N*v%b);return N}function p(v,E){for(;E%2===0;E/=2);for(;E%5===0;E/=5);if(E===1)return 0;for(var b=10%E,N=1;b!==1;N++)if(b=b*10%E,N>r)return 0;return N}function f(v,E,b){for(var N=1,x=h(10,b,E),F=0;F<300;F++){if(N===x)return F;N=N*10%E,x=x*10%E}return 0}function d(v,E){if(!v)return E;if(!E)return v;for(;;){if(v%=E,!v)return E;if(E%=v,!E)return v}}function g(v,E){if(c(v,E),this instanceof g)v=d(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var w=function(){return new Error("Division by Zero")},m=function(){return new Error("Invalid argument")},D=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,E){return c(v,E),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,E){return c(v,E),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,E){return c(v,E),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,E){return c(v,E),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,E){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,E),n.n===0&&this.d===0)throw w();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,E){return c(v,E),a(d(n.n,this.n)*d(n.d,this.d),n.d*this.d)},lcm:function(v,E){return c(v,E),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,d(n.n,this.n)*d(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,E){if(c(v,E),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=l(this.n),N=l(this.d),x=1,F=1;for(var M in b)if(M!=="1"){if(M==="0"){x=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;x*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;F*=Math.pow(M,N[M])}return n.s<0?a(F,x):a(x,F)},equals:function(v,E){return c(v,E),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,E){c(v,E);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var E=this.abs(),b=E.toContinued(),N=1;N<b.length;N++){for(var x=a(b[N-1],1),F=N-2;F>=0;F--)x=x.inverse().add(b[F]);if(Math.abs(x.sub(E).valueOf())<v)return x.mul(this.s)}return this},divisible:function(v,E){return c(v,E),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,b+=" ",N%=x),b+=N,b+="/",b+=x),b},toLatex:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,N%=x),b+="\\frac{",b+=N,b+="}{",b+=x,b+="}"),b},toContinued:function(){var v,E=this.n,b=this.d,N=[];if(isNaN(E)||isNaN(b))return N;do N.push(Math.floor(E/b)),v=E%b,E=b,b=v;while(E!==1);return N},toString:function(v){var E=this.n,b=this.d;if(isNaN(E)||isNaN(b))return"NaN";v=v||15;var N=p(E,b),x=f(E,b,N),F=this.s<0?"-":"";if(F+=E/b|0,E%=b,E*=10,E&&(F+="."),N){for(var M=x;M--;)F+=E/b|0,E%=b,E*=10;F+="(";for(var M=N;M--;)F+=E/b|0,E%=b,E*=10;F+=")"}else for(var M=v;E&&M--;)F+=E/b|0,E%=b,E*=10;return F}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,i.exports=g})()})(yc);var Z_=yc.exports,tn=Zt(Z_),G_="Fraction",K_=[],H_=mt(G_,K_,()=>(Object.defineProperty(tn,"name",{value:"Fraction"}),tn.prototype.constructor=tn,tn.prototype.type="Fraction",tn.prototype.isFraction=!0,tn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},tn.fromJSON=function(i){return new tn(i)},tn),{isClass:!0}),X_="Matrix",J_=[],Q_=mt(X_,J_,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function Dc(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var V_="DenseMatrix",tm=["Matrix"],em=mt(V_,tm,i=>{var{Matrix:t}=i;function e(p,f){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!Zr(f))throw new Error("Invalid datatype: "+f);if(fe(p))p.type==="DenseMatrix"?(this._data=re(p._data),this._size=re(p._size),this._datatype=f||p._datatype):(this._data=p.toArray(),this._size=p.size(),this._datatype=f||p._datatype);else if(p&&ve(p.data)&&ve(p.size))this._data=p.data,this._size=p.size,Hl(this._data,this._size),this._datatype=f||p.datatype;else if(ve(p))this._data=h(p),this._size=Fe(this._data),Hl(this._data,this._size),this._datatype=f;else{if(p)throw new TypeError("Unsupported type of data ("+mn(p)+")");this._data=[],this._size=[0],this._datatype=f}}e.prototype=new t,e.prototype.createDenseMatrix=function(p,f){return new e(p,f)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return As(this._data,mn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(p,f){return new e(p,f)},e.prototype.subset=function(p,f,d){switch(arguments.length){case 1:return r(this,p);case 2:case 3:return s(this,p,f,d);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(p){if(!ve(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Gt(p.length,this._size.length);for(var f=0;f<p.length;f++)we(p[f],this._size[f]);for(var d=this._data,g=0,w=p.length;g<w;g++){var m=p[g];we(m,d.length),d=d[m]}return d},e.prototype.set=function(p,f,d){if(!ve(p))throw new TypeError("Array expected");if(p.length<this._size.length)throw new Gt(p.length,this._size.length,"<");var g,w,m,D=p.map(function(E){return E+1});c(this,D,d);var v=this._data;for(g=0,w=p.length-1;g<w;g++)m=p[g],we(m,v.length),v=v[m];return m=p[p.length-1],we(m,v.length),v[m]=f,this};function r(p,f){if(!sa(f))throw new TypeError("Invalid index");var d=f.isScalar();if(d)return p.get(f.min());var g=f.size();if(g.length!==p._size.length)throw new Gt(g.length,p._size.length);for(var w=f.min(),m=f.max(),D=0,v=p._size.length;D<v;D++)we(w[D],p._size[D]),we(m[D],p._size[D]);return new e(n(p._data,f,g.length,0),p._datatype)}function n(p,f,d,g){var w=g===d-1,m=f.dimension(g);return w?m.map(function(D){return we(D,p.length),p[D]}).valueOf():m.map(function(D){we(D,p.length);var v=p[D];return n(v,f,d,g+1)}).valueOf()}function s(p,f,d,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var w=f.size(),m=f.isScalar(),D;if(fe(d)?(D=d.size(),d=d.valueOf()):D=Fe(d),m){if(D.length!==0)throw new TypeError("Scalar expected");p.set(f.min(),d,g)}else{if(!ai(D,w))try{D.length===0?d=ec([d],w):d=ec(d,w),D=Fe(d)}catch{}if(w.length<p._size.length)throw new Gt(w.length,p._size.length,"<");if(D.length<w.length){for(var v=0,E=0;w[v]===1&&D[v]===1;)v++;for(;w[v]===1;)E++,v++;d=Jl(d,w.length,E,D)}if(!ai(w,D))throw new Gt(w,D,">");var b=f.max().map(function(F){return F+1});c(p,b,g);var N=w.length,x=0;a(p._data,f,d,N,x)}return p}function a(p,f,d,g,w){var m=w===g-1,D=f.dimension(w);m?D.forEach(function(v,E){we(v),p[v]=d[E[0]]}):D.forEach(function(v,E){we(v),a(p[v],f,d[E[0]],g,w+1)})}e.prototype.resize=function(p,f,d){if(!Ui(p))throw new TypeError("Array or Matrix expected");var g=p.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),w=d?this.clone():this;return l(w,g,f)};function l(p,f,d){if(f.length===0){for(var g=p._data;ve(g);)g=g[0];return g}return p._size=f.slice(0),p._data=ca(p._data,p._size,d),p}e.prototype.reshape=function(p,f){var d=f?this.clone():this;d._data=ha(d._data,p);var g=d._size.reduce((w,m)=>w*m);return d._size=pa(p,g),d};function c(p,f,d){for(var g=p._size.slice(0),w=!1;g.length<f.length;)g.push(0),w=!0;for(var m=0,D=f.length;m<D;m++)f[m]>g[m]&&(g[m]=f[m],w=!0);w&&l(p,g,d)}e.prototype.clone=function(){var p=new e({data:re(this._data),size:re(this._size),datatype:this._datatype});return p},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(p){var f=this,d=Dc(p),g=function D(v,E){return ve(v)?v.map(function(b,N){return D(b,E.concat(N))}):d===1?p(v):d===2?p(v,E):p(v,E,f)},w=g(this._data,[]),m=this._datatype!==void 0?As(w,mn):void 0;return new e(w,m)},e.prototype.forEach=function(p){var f=this,d=function g(w,m){ve(w)?w.forEach(function(D,v){g(D,m.concat(v))}):p(w,m,f)};d(this._data,[])},e.prototype[Symbol.iterator]=function*(){var p=function*f(d,g){if(ve(d))for(var w=0;w<d.length;w++)yield*f(d[w],g.concat(w));else yield{value:d,index:g}};yield*p(this._data,[])},e.prototype.rows=function(){var p=[],f=this.size();if(f.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var d=this._data;for(var g of d)p.push(new e([g],this._datatype));return p},e.prototype.columns=function(){var p=this,f=[],d=this.size();if(d.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,w=function(v){var E=g.map(b=>[b[v]]);f.push(new e(E,p._datatype))},m=0;m<d[1];m++)w(m);return f},e.prototype.toArray=function(){return re(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(p){return oe(this._data,p)},e.prototype.toString=function(){return oe(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(p){if(p){if(xe(p)&&(p=p.toNumber()),!le(p)||!de(p))throw new TypeError("The parameter k must be an integer number")}else p=0;for(var f=p>0?p:0,d=p<0?-p:0,g=this._size[0],w=this._size[1],m=Math.min(g-d,w-f),D=[],v=0;v<m;v++)D[v]=this._data[v+d][v+f];return new e({data:D,size:[m],datatype:this._datatype})},e.diagonal=function(p,f,d,g){if(!ve(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function(M){if(xe(M)&&(M=M.toNumber()),!le(M)||!de(M)||M<1)throw new Error("Size values must be positive integers");return M}),d){if(xe(d)&&(d=d.toNumber()),!le(d)||!de(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var w=d>0?d:0,m=d<0?-d:0,D=p[0],v=p[1],E=Math.min(D-m,v-w),b;if(ve(f)){if(f.length!==E)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(fe(f)){var N=f.size();if(N.length!==1||N[0]!==E)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=xe(b(0))?b(0).mul(0):0);var x=[];if(p.length>0){x=ca(x,p,g);for(var F=0;F<E;F++)x[F+m][F+w]=b(F)}return new e({data:x,size:[D,v]})},e.fromJSON=function(p){return new e(p)},e.prototype.swapRows=function(p,f){if(!le(p)||!de(p)||!le(f)||!de(f))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return we(p,this._size[0]),we(f,this._size[0]),e._swapRows(p,f,this._data),this},e._swapRows=function(p,f,d){var g=d[p];d[p]=d[f],d[f]=g};function h(p){return fe(p)?h(p.valueOf()):ve(p)?p.map(h):p}return e},{isClass:!0});function rm(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(i[r][n]);s.push(a)}return s}function $s(i){for(var t=0;t<i.length;t++)if(Ui(i[t]))return!0;return!1}function Yi(i,t){fe(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?Yi(n,t):t(n)}}function Rr(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Rr(r,t)}):t(i)}function Ea(i,t,e){var r=Array.isArray(i)?Fe(i):i.size();if(t<0||t>=r.length)throw new gn(t,r.length);return fe(i)?i.create(Ls(i.valueOf(),t,e)):Ls(i,t,e)}function Ls(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=rm(i),n=[],r=0;r<a.length;r++)n[r]=Ls(a[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=Ls(i[r],t-1,e);return n}}var bc="isInteger",nm=["typed"],im=mt(bc,nm,i=>{var{typed:t}=i;return t(bc,{number:de,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),Ec="number",Rs="number, number";function xc(i){return Math.abs(i)}xc.signature=Ec;function Ac(i,t){return i+t}Ac.signature=Rs;function Cc(i,t){return i-t}Cc.signature=Rs;function Fc(i,t){return i*t}Fc.signature=Rs;function Mc(i){return-i}Mc.signature=Ec;function Nc(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}Nc.signature=Rs;var Sc="number";function Bc(i){return i===0}Bc.signature=Sc;function Tc(i){return Number.isNaN(i)}Tc.signature=Sc;var Oc="isNumeric",sm=["typed"],om=mt(Oc,sm,i=>{var{typed:t}=i;return t(Oc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),Ic="isZero",am=["typed"],um=mt(Ic,am,i=>{var{typed:t}=i;return t(Ic,{number:Bc,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),$c="isNaN",lm=["typed"],cm=mt($c,lm,i=>{var{typed:t}=i;return t($c,{number:Tc,BigNumber:function(r){return r.isNaN()},Fraction:function(r){return!1},Complex:function(r){return r.isNaN()},Unit:function(r){return Number.isNaN(r.value)},"Array | Matrix":function(r){return Rr(r,Number.isNaN)}})});function Ps(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function fm(i,t,e){return Wn(i.re,t.re,e)&&Wn(i.im,t.im,e)}var zs=mt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),qs="equalScalar",hm=["typed","config"],pm=mt(qs,hm,i=>{var{typed:t,config:e}=i,r=zs({typed:t});return t(qs,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return Wn(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||Ps(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return fm(s,a,e.epsilon)}},r)});mt(qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(qs,{"number, number":function(n,s){return Wn(n,s,e.epsilon)}})});var dm="SparseMatrix",_m=["typed","equalScalar","Matrix"],mm=mt(dm,_m,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(m,D){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(D&&!Zr(D))throw new Error("Invalid datatype: "+D);if(fe(m))s(this,m,D);else if(m&&ve(m.index)&&ve(m.ptr)&&ve(m.size))this._values=m.values,this._index=m.index,this._ptr=m.ptr,this._size=m.size,this._datatype=D||m.datatype;else if(ve(m))a(this,m,D);else{if(m)throw new TypeError("Unsupported type of data ("+mn(m)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=D}}function s(m,D,v){D.type==="SparseMatrix"?(m._values=D._values?re(D._values):void 0,m._index=re(D._index),m._ptr=re(D._ptr),m._size=re(D._size),m._datatype=v||D._datatype):a(m,D.valueOf(),v||D._datatype)}function a(m,D,v){m._values=[],m._index=[],m._ptr=[],m._datatype=v;var E=D.length,b=0,N=e,x=0;if(Zr(v)&&(N=t.find(e,[v,v])||e,x=t.convert(0,v)),E>0){var F=0;do{m._ptr.push(m._index.length);for(var M=0;M<E;M++){var S=D[M];if(ve(S)){if(F===0&&b<S.length&&(b=S.length),F<S.length){var I=S[F];N(I,x)||(m._values.push(I),m._index.push(M))}}else F===0&&b<1&&(b=1),N(S,x)||(m._values.push(S),m._index.push(M))}F++}while(F<b)}m._ptr.push(m._index.length),m._size=[E,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(m,D){return new n(m,D)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return As(this._values,mn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(m,D){return new n(m,D)},n.prototype.density=function(){var m=this._size[0],D=this._size[1];return m!==0&&D!==0?this._index.length/(m*D):0},n.prototype.subset=function(m,D,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,m);case 2:case 3:return c(this,m,D,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(m,D){if(!sa(D))throw new TypeError("Invalid index");var v=D.isScalar();if(v)return m.get(D.min());var E=D.size();if(E.length!==m._size.length)throw new Gt(E.length,m._size.length);var b,N,x,F,M=D.min(),S=D.max();for(b=0,N=m._size.length;b<N;b++)we(M[b],m._size[b]),we(S[b],m._size[b]);var I=m._values,C=m._index,T=m._ptr,L=D.dimension(0),U=D.dimension(1),k=[],W=[];L.forEach(function(Q,tt){W[Q]=tt[0],k[Q]=!0});var P=I?[]:void 0,K=[],G=[];return U.forEach(function(Q){for(G.push(K.length),x=T[Q],F=T[Q+1];x<F;x++)b=C[x],k[b]===!0&&(K.push(W[b]),P&&P.push(I[x]))}),G.push(K.length),new n({values:P,index:K,ptr:G,size:E,datatype:m._datatype})}function c(m,D,v,E){if(!D||D.isIndex!==!0)throw new TypeError("Invalid index");var b=D.size(),N=D.isScalar(),x;if(fe(v)?(x=v.size(),v=v.toArray()):x=Fe(v),N){if(x.length!==0)throw new TypeError("Scalar expected");m.set(D.min(),v,E)}else{if(b.length!==1&&b.length!==2)throw new Gt(b.length,m._size.length,"<");if(x.length<b.length){for(var F=0,M=0;b[F]===1&&x[F]===1;)F++;for(;b[F]===1;)M++,F++;v=Jl(v,b.length,M,x)}if(!ai(b,x))throw new Gt(b,x,">");if(b.length===1){var S=D.dimension(0);S.forEach(function(T,L){we(T),m.set([T,0],v[L[0]],E)})}else{var I=D.dimension(0),C=D.dimension(1);I.forEach(function(T,L){we(T),C.forEach(function(U,k){we(U),m.set([T,U],v[L[0]][k[0]],E)})})}}return m}n.prototype.get=function(m){if(!ve(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Gt(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var D=m[0],v=m[1];we(D,this._size[0]),we(v,this._size[1]);var E=h(D,this._ptr[v],this._ptr[v+1],this._index);return E<this._ptr[v+1]&&this._index[E]===D?this._values[E]:0},n.prototype.set=function(m,D,v){if(!ve(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Gt(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var E=m[0],b=m[1],N=this._size[0],x=this._size[1],F=e,M=0;Zr(this._datatype)&&(F=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(E>N-1||b>x-1)&&(d(this,Math.max(E+1,N),Math.max(b+1,x),v),N=this._size[0],x=this._size[1]),we(E,N),we(b,x);var S=h(E,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===E?F(D,M)?p(S,b,this._values,this._index,this._ptr):this._values[S]=D:F(D,M)||f(S,E,b,D,this._values,this._index,this._ptr),this};function h(m,D,v,E){if(v-D===0)return v;for(var b=D;b<v;b++)if(E[b]===m)return b;return D}function p(m,D,v,E,b){v.splice(m,1),E.splice(m,1);for(var N=D+1;N<b.length;N++)b[N]--}function f(m,D,v,E,b,N,x){b.splice(m,0,E),N.splice(m,0,D);for(var F=v+1;F<x.length;F++)x[F]++}n.prototype.resize=function(m,D,v){if(!Ui(m))throw new TypeError("Array or Matrix expected");var E=m.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(N){if(!le(N)||!de(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+oe(E)+")")});var b=v?this.clone():this;return d(b,E[0],E[1],D)};function d(m,D,v,E){var b=E||0,N=e,x=0;Zr(m._datatype)&&(N=t.find(e,[m._datatype,m._datatype])||e,x=t.convert(0,m._datatype),b=t.convert(b,m._datatype));var F=!N(b,x),M=m._size[0],S=m._size[1],I,C,T;if(v>S){for(C=S;C<v;C++)if(m._ptr[C]=m._values.length,F)for(I=0;I<M;I++)m._values.push(b),m._index.push(I);m._ptr[v]=m._values.length}else v<S&&(m._ptr.splice(v+1,S-v),m._values.splice(m._ptr[v],m._values.length),m._index.splice(m._ptr[v],m._index.length));if(S=v,D>M){if(F){var L=0;for(C=0;C<S;C++){m._ptr[C]=m._ptr[C]+L,T=m._ptr[C+1]+L;var U=0;for(I=M;I<D;I++,U++)m._values.splice(T+U,0,b),m._index.splice(T+U,0,I),L++}m._ptr[S]=m._values.length}}else if(D<M){var k=0;for(C=0;C<S;C++){m._ptr[C]=m._ptr[C]-k;var W=m._ptr[C],P=m._ptr[C+1]-k;for(T=W;T<P;T++)I=m._index[T],I>D-1&&(m._values.splice(T,1),m._index.splice(T,1),k++)}m._ptr[C]=m._values.length}return m._size[0]=D,m._size[1]=v,m}n.prototype.reshape=function(m,D){if(!ve(m))throw new TypeError("Array expected");if(m.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");m.forEach(function(Q){if(!le(Q)||!de(Q)||Q<=-2||Q===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+oe(m)+")")});var v=this._size[0]*this._size[1];m=pa(m,v);var E=m[0]*m[1];if(v!==E)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=D?this.clone():this;if(this._size[0]===m[0]&&this._size[1]===m[1])return b;for(var N=[],x=0;x<b._ptr.length;x++)for(var F=0;F<b._ptr[x+1]-b._ptr[x];F++)N.push(x);for(var M=b._values.slice(),S=b._index.slice(),I=0;I<b._index.length;I++){var C=S[I],T=N[I],L=C*b._size[1]+T;N[I]=L%m[1],S[I]=Math.floor(L/m[1])}b._values.length=0,b._index.length=0,b._ptr.length=m[1]+1,b._size=m.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var k=0;k<M.length;k++){var W=S[k],P=N[k],K=M[k],G=h(W,b._ptr[P],b._ptr[P+1],b._index);f(G,W,P,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var m=new n({values:this._values?re(this._values):void 0,index:re(this._index),ptr:re(this._ptr),size:re(this._size),datatype:this._datatype});return m},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(m,D){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,E=this._size[0],b=this._size[1],N=Dc(m),x=function(M,S,I){return N===1?m(M):N===2?m(M,[S,I]):m(M,[S,I],v)};return g(this,0,E-1,0,b-1,x,D)};function g(m,D,v,E,b,N,x){var F=[],M=[],S=[],I=e,C=0;Zr(m._datatype)&&(I=t.find(e,[m._datatype,m._datatype])||e,C=t.convert(0,m._datatype));for(var T=function(lt,yt,bt){lt=N(lt,yt,bt),I(lt,C)||(F.push(lt),M.push(yt))},L=E;L<=b;L++){S.push(F.length);var U=m._ptr[L],k=m._ptr[L+1];if(x)for(var W=U;W<k;W++){var P=m._index[W];P>=D&&P<=v&&T(m._values[W],P-D,L-E)}else{for(var K={},G=U;G<k;G++){var Q=m._index[G];K[Q]=m._values[G]}for(var tt=D;tt<=v;tt++){var ct=tt in K?K[tt]:0;T(ct,tt-D,L-E)}}}return S.push(F.length),new n({values:F,index:M,ptr:S,size:[v-D+1,b-E+1]})}n.prototype.forEach=function(m,D){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,E=this._size[0],b=this._size[1],N=0;N<b;N++){var x=this._ptr[N],F=this._ptr[N+1];if(D)for(var M=x;M<F;M++){var S=this._index[M];m(this._values[M],[S,N],v)}else{for(var I={},C=x;C<F;C++){var T=this._index[C];I[T]=this._values[C]}for(var L=0;L<E;L++){var U=L in I?I[L]:0;m(U,[L,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var m=this._size[1],D=0;D<m;D++)for(var v=this._ptr[D],E=this._ptr[D+1],b=v;b<E;b++){var N=this._index[b];yield{value:this._values[b],index:[N,D]}}},n.prototype.toArray=function(){return w(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return w(this._values,this._index,this._ptr,this._size,!1)};function w(m,D,v,E,b){var N=E[0],x=E[1],F=[],M,S;for(M=0;M<N;M++)for(F[M]=[],S=0;S<x;S++)F[M][S]=0;for(S=0;S<x;S++)for(var I=v[S],C=v[S+1],T=I;T<C;T++)M=D[T],F[M][S]=m?b?re(m[T]):m[T]:1;return F}return n.prototype.format=function(m){for(var D=this._size[0],v=this._size[1],E=this.density(),b="Sparse Matrix ["+oe(D,m)+" x "+oe(v,m)+"] density: "+oe(E,m)+`
|
53
53
|
`,N=0;N<v;N++)for(var x=this._ptr[N],F=this._ptr[N+1],M=x;M<F;M++){var S=this._index[M];b+=`
|
54
|
-
(`+oe(S,m)+", "+oe(N,m)+") ==> "+(this._values?oe(this._values[M],m):"X")}return b},n.prototype.toString=function(){return oe(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(m){if(m){if(xe(m)&&(m=m.toNumber()),!le(m)||!de(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var D=m>0?m:0,v=m<0?-m:0,E=this._size[0],b=this._size[1],N=Math.min(E-v,b-D),x=[],F=[],M=[];M[0]=0;for(var S=D;S<b&&x.length<N;S++)for(var I=this._ptr[S],C=this._ptr[S+1],T=I;T<C;T++){var L=this._index[T];if(L===S-D+v){x.push(this._values[T]),F[x.length-1]=L-v;break}}return M.push(x.length),new n({values:x,index:F,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,D,v,E,b){if(!ve(m))throw new TypeError("Array expected, size parameter");if(m.length!==2)throw new Error("Only two dimensions matrix are supported");if(m=m.map(function(Q){if(xe(Q)&&(Q=Q.toNumber()),!le(Q)||!de(Q)||Q<1)throw new Error("Size values must be positive integers");return Q}),v){if(xe(v)&&(v=v.toNumber()),!le(v)||!de(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,x=0;Zr(b)&&(N=t.find(e,[b,b])||e,x=t.convert(0,b));var F=v>0?v:0,M=v<0?-v:0,S=m[0],I=m[1],C=Math.min(S-M,I-F),T;if(ve(D)){if(D.length!==C)throw new Error("Invalid value array length");T=function(tt){return D[tt]}}else if(fe(D)){var L=D.size();if(L.length!==1||L[0]!==C)throw new Error("Invalid matrix length");T=function(tt){return D.get([tt])}}else T=function(){return D};for(var U=[],k=[],W=[],P=0;P<I;P++){W.push(U.length);var K=P-F;if(K>=0&&K<C){var G=T(K);N(G,x)||(k.push(K+M),U.push(G))}}return W.push(U.length),new n({values:U,index:k,ptr:W,size:[S,I]})},n.prototype.swapRows=function(m,D){if(!le(m)||!de(m)||!le(D)||!de(D))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return we(m,this._size[0]),we(D,this._size[0]),n._swapRows(m,D,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,D,v,E,b){for(var N=E[m],x=E[m+1],F=N;F<x;F++)b(v[F],D[F])},n._swapRows=function(m,D,v,E,b,N){for(var x=0;x<v;x++){var F=N[x],M=N[x+1],S=h(m,F,M,b),I=h(D,F,M,b);if(S<M&&I<M&&b[S]===m&&b[I]===D){if(E){var C=E[S];E[S]=E[I],E[I]=C}continue}if(S<M&&b[S]===m&&(I>=M||b[I]!==D)){var T=E?E[S]:void 0;b.splice(I,0,D),E&&E.splice(I,0,T),b.splice(I<=S?S+1:S,1),E&&E.splice(I<=S?S+1:S,1);continue}if(I<M&&b[I]===D&&(S>=M||b[S]!==m)){var L=E?E[I]:void 0;b.splice(S,0,m),E&&E.splice(S,0,L),b.splice(S<=I?I+1:I,1),E&&E.splice(S<=I?I+1:I,1)}}},n},{isClass:!0}),gm="number",vm=["typed"];function wm(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function ym(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var Dm=mt(gm,vm,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=wm(n);if(s)return ym(s);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Rr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),bm="bignumber",Em=["typed","BigNumber"],xm=mt(bm,Em,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],l=e(s[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var h=new e(2).pow(Number(a)-1);return l.gte(h)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Rr(n,r))})}),Am="fraction",Cm=["typed","Fraction"],Fm=mt(Am,Cm,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Rr(n,r))})}),Lc="matrix",Mm=["typed","Matrix","DenseMatrix","SparseMatrix"],Nm=mt(Lc,Mm,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(Lc,{"":function(){return s([])},string:function(l){return s([],l)},"string, string":function(l,c){return s([],l,c)},Array:function(l){return s(l)},Matrix:function(l){return s(l,l.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,l,c){if(l==="dense"||l==="default"||l===void 0)return new r(a,c);if(l==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Rc="unaryMinus",Sm=["typed"],Bm=mt(Rc,Sm,i=>{var{typed:t}=i;return t(Rc,{number:Mc,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),Pc="abs",Tm=["typed"],Om=mt(Pc,Tm,i=>{var{typed:t}=i;return t(Pc,{number:xc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),zc="addScalar",Im=["typed"],$m=mt(zc,Im,i=>{var{typed:t}=i;return t(zc,{"number, number":Ac,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),qc="subtractScalar",Lm=["typed"],Rm=mt(qc,Lm,i=>{var{typed:t}=i;return t(qc,{"number, number":Cc,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Pm="matAlgo11xS0s",zm=["typed","equalScalar"],xa=mt(Pm,zm,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,D=e,v=0,E=a;typeof d=="string"&&(m=d,D=t.find(e,[m,m]),v=t.convert(0,m),s=t.convert(s,m),E=t.find(a,[m,m]));for(var b=[],N=[],x=[],F=0;F<w;F++){x[F]=N.length;for(var M=p[F],S=p[F+1],I=M;I<S;I++){var C=h[I],T=l?E(s,c[I]):E(c[I],s);D(T,v)||(N.push(C),b.push(T))}}return x[w]=N.length,n.createSparseMatrix({values:b,index:N,ptr:x,size:[g,w],datatype:m})}}),qm="matAlgo12xSfs",km=["typed","DenseMatrix"],pi=mt(qm,km,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,D=a;typeof d=="string"&&(m=d,s=t.convert(s,m),D=t.find(a,[m,m]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=p[N],M=p[N+1],S=F;S<M;S++){var I=h[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?D(s,E[C]):D(E[C],s):v[C][N]=l?D(s,0):D(0,s)}return new e({data:v,size:[g,w],datatype:m})}}),Um="matAlgo14xDs",Wm=["typed"],Aa=mt(Um,Wm,i=>{var{typed:t}=i;return function(n,s,a,l){var c=n._data,h=n._size,p=n._datatype,f,d=a;typeof p=="string"&&(f=p,s=t.convert(s,f),d=t.find(a,[f,f]));var g=h.length>0?e(d,0,h,h[0],c,s,l):[];return n.createDenseMatrix({data:g,size:re(h),datatype:f})};function e(r,n,s,a,l,c,h){var p=[];if(n===s.length-1)for(var f=0;f<a;f++)p[f]=h?r(c,l[f]):r(l[f],c);else for(var d=0;d<a;d++)p[d]=e(r,n+1,s,s[n+1],l[d],c,h);return p}}),jm="matAlgo02xDS0",Ym=["typed","equalScalar"],Zm=mt(jm,Ym,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._data,h=n._size,p=n._datatype||n.getDataType(),f=s._values,d=s._index,g=s._ptr,w=s._size,m=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==w.length)throw new Gt(h.length,w.length);if(h[0]!==w[0]||h[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+w+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var D=h[0],v=h[1],E,b=e,N=0,x=a;typeof p=="string"&&p===m&&p!=="mixed"&&(E=p,b=t.find(e,[E,E]),N=t.convert(0,E),x=t.find(a,[E,E]));for(var F=[],M=[],S=[],I=0;I<v;I++){S[I]=M.length;for(var C=g[I],T=g[I+1],L=C;L<T;L++){var U=d[L],k=l?x(f[L],c[U][I]):x(c[U][I],f[L]);b(k,N)||(M.push(U),F.push(k))}}return S[v]=M.length,s.createSparseMatrix({values:F,index:M,ptr:S,size:[D,v],datatype:p===n._datatype&&m===s._datatype?E:void 0})}}),Gm="matAlgo03xDSf",Km=["typed"],di=mt(Gm,Km,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Gt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],D=c[1],v,E=0,b=s;typeof h=="string"&&h===w&&h!=="mixed"&&(v=h,E=t.convert(0,v),b=t.find(s,[v,v]));for(var N=[],x=0;x<m;x++)N[x]=[];for(var F=[],M=[],S=0;S<D;S++){for(var I=S+1,C=d[S],T=d[S+1],L=C;L<T;L++){var U=f[L];F[U]=a?b(p[L],l[U][S]):b(l[U][S],p[L]),M[U]=I}for(var k=0;k<m;k++)M[k]===I?N[k][S]=F[k]:N[k][S]=a?b(E,l[k][S]):b(l[k][S],E)}return r.createDenseMatrix({data:N,size:[m,D],datatype:h===r._datatype&&w===n._datatype?v:void 0})}}),Hm="matAlgo05xSfSf",Xm=["typed","equalScalar"],kc=mt(Hm,Xm,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=s._values,g=s._index,w=s._ptr,m=s._size,D=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==m.length)throw new Gt(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],E=p[1],b,N=e,x=0,F=a;typeof f=="string"&&f===D&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=M?[]:void 0,T=M?[]:void 0,L=[],U=[],k,W,P,K;for(W=0;W<E;W++){I[W]=S.length;var G=W+1;for(P=h[W],K=h[W+1];P<K;P++)k=c[P],S.push(k),L[k]=G,C&&(C[k]=l[P]);for(P=w[W],K=w[W+1];P<K;P++)k=g[P],L[k]!==G&&S.push(k),U[k]=G,T&&(T[k]=d[P]);if(M)for(P=I[W];P<S.length;){k=S[P];var Q=L[k],tt=U[k];if(Q===G||tt===G){var ct=Q===G?C[k]:x,vt=tt===G?T[k]:x,lt=F(ct,vt);N(lt,x)?S.splice(P,1):(M.push(lt),P++)}}}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&D===s._datatype?b:void 0})}}),Jm="matAlgo13xDD",Qm=["typed"],Vm=mt(Jm,Qm,i=>{var{typed:t}=i;return function(n,s,a){var l=n._data,c=n._size,h=n._datatype,p=s._data,f=s._size,d=s._datatype,g=[];if(c.length!==f.length)throw new Gt(c.length,f.length);for(var w=0;w<c.length;w++){if(c[w]!==f[w])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[w]=c[w]}var m,D=a;typeof h=="string"&&h===d&&(m=h,D=t.find(a,[m,m]));var v=g.length>0?e(D,0,g,g[0],l,p):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,s,a,l,c){var h=[];if(n===s.length-1)for(var p=0;p<a;p++)h[p]=r(l[p],c[p]);else for(var f=0;f<a;f++)h[f]=e(r,n+1,s,s[n+1],l[f],c[f]);return h}}),tg="broadcast",eg=["concat"],rg=mt(tg,eg,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((w,m)=>w===s._size[m]))return[n,s];for(var l=e(n._size,a,0),c=e(s._size,a,0),h=[],p=0;p<a;p++)h[p]=Math.max(l[p],c[p]);Cs(l,h),Cs(c,h);var f=n.clone(),d=s.clone();f._size.length<a?f.reshape(e(f._size,a,1)):d._size.length<a&&d.reshape(e(d._size,a,1));for(var g=0;g<a;g++)f._size[g]<h[g]&&(f=r(f,h[g],g)),d._size[g]<h[g]&&(d=r(d,h[g],g));return[f,d]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),ng="matrixAlgorithmSuite",ig=["typed","matrix","concat"],jn=mt(ng,ig,i=>{var{typed:t,matrix:e,concat:r}=i,n=Vm({typed:t}),s=Aa({typed:t}),a=rg({concat:r});return function(c){var h=c.elop,p=c.SD||c.DS,f;h?(f={"DenseMatrix, DenseMatrix":(m,D)=>n(...a(m,D),h),"Array, Array":(m,D)=>n(...a(e(m),e(D)),h).valueOf(),"Array, DenseMatrix":(m,D)=>n(...a(e(m),D),h),"DenseMatrix, Array":(m,D)=>n(...a(m,e(D)),h)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,D)=>c.SS(...a(m,D),h,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,D)=>c.DS(...a(m,D),h,!1),f["Array, SparseMatrix"]=(m,D)=>c.DS(...a(e(m),D),h,!1)),p&&(f["SparseMatrix, DenseMatrix"]=(m,D)=>p(...a(D,m),h,!0),f["SparseMatrix, Array"]=(m,D)=>p(...a(e(D),m),h,!0))):(f={"DenseMatrix, DenseMatrix":t.referToSelf(m=>(D,v)=>n(...a(D,v),m)),"Array, Array":t.referToSelf(m=>(D,v)=>n(...a(e(D),e(v)),m).valueOf()),"Array, DenseMatrix":t.referToSelf(m=>(D,v)=>n(...a(e(D),v),m)),"DenseMatrix, Array":t.referToSelf(m=>(D,v)=>n(...a(D,e(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=t.referToSelf(m=>(D,v)=>c.SS(...a(D,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=t.referToSelf(m=>(D,v)=>c.DS(...a(D,v),m,!1)),f["Array, SparseMatrix"]=t.referToSelf(m=>(D,v)=>c.DS(...a(e(D),v),m,!1))),p&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(D,v)=>p(...a(v,D),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(D,v)=>p(...a(e(v),D),m,!0))));var d=c.scalar||"any",g=c.Ds||c.Ss;g&&(h?(f["DenseMatrix,"+d]=(m,D)=>s(m,D,h,!1),f[d+", DenseMatrix"]=(m,D)=>s(D,m,h,!0),f["Array,"+d]=(m,D)=>s(e(m),D,h,!1).valueOf(),f[d+", Array"]=(m,D)=>s(e(D),m,h,!0).valueOf()):(f["DenseMatrix,"+d]=t.referToSelf(m=>(D,v)=>s(D,v,m,!1)),f[d+", DenseMatrix"]=t.referToSelf(m=>(D,v)=>s(v,D,m,!0)),f["Array,"+d]=t.referToSelf(m=>(D,v)=>s(e(D),v,m,!1).valueOf()),f[d+", Array"]=t.referToSelf(m=>(D,v)=>s(e(v),D,m,!0).valueOf())));var w=c.sS!==void 0?c.sS:c.Ss;return h?(c.Ss&&(f["SparseMatrix,"+d]=(m,D)=>c.Ss(m,D,h,!1)),w&&(f[d+", SparseMatrix"]=(m,D)=>w(D,m,h,!0))):(c.Ss&&(f["SparseMatrix,"+d]=t.referToSelf(m=>(D,v)=>c.Ss(D,v,m,!1))),w&&(f[d+", SparseMatrix"]=t.referToSelf(m=>(D,v)=>w(v,D,m,!0)))),h&&h.signatures&&Il(f,h.signatures),f}}),sg="matAlgo01xDSid",og=["typed"],Uc=mt(sg,og,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Gt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],D=c[1],v=typeof h=="string"&&h!=="mixed"&&h===w?h:void 0,E=v?t.find(s,[v,v]):s,b,N,x=[];for(b=0;b<m;b++)x[b]=[];var F=[],M=[];for(N=0;N<D;N++){for(var S=N+1,I=d[N],C=d[N+1],T=I;T<C;T++)b=f[T],F[b]=a?E(p[T],l[b][N]):E(l[b][N],p[T]),M[b]=S;for(b=0;b<m;b++)M[b]===S?x[b][N]=F[b]:x[b][N]=l[b][N]}return r.createDenseMatrix({data:x,size:[m,D],datatype:h===r._datatype&&w===n._datatype?v:void 0})}}),ag="matAlgo04xSidSid",ug=["typed","equalScalar"],lg=mt(ag,ug,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=s._values,g=s._index,w=s._ptr,m=s._size,D=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==m.length)throw new Gt(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],E=p[1],b,N=e,x=0,F=a;typeof f=="string"&&f===D&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=l&&d?[]:void 0,T=l&&d?[]:void 0,L=[],U=[],k,W,P,K,G;for(W=0;W<E;W++){I[W]=S.length;var Q=W+1;for(K=h[W],G=h[W+1],P=K;P<G;P++)k=c[P],S.push(k),L[k]=Q,C&&(C[k]=l[P]);for(K=w[W],G=w[W+1],P=K;P<G;P++)if(k=g[P],L[k]===Q){if(C){var tt=F(C[k],d[P]);N(tt,x)?L[k]=null:C[k]=tt}}else S.push(k),U[k]=Q,T&&(T[k]=d[P]);if(C&&T)for(P=I[W];P<S.length;)k=S[P],L[k]===Q?(M[P]=C[k],P++):U[k]===Q?(M[P]=T[k],P++):S.splice(P,1)}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&D===s._datatype?b:void 0})}}),cg="matAlgo10xSids",fg=["typed","DenseMatrix"],Wc=mt(cg,fg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,D=a;typeof d=="string"&&(m=d,s=t.convert(s,m),D=t.find(a,[m,m]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=p[N],M=p[N+1],S=F;S<M;S++){var I=h[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?D(s,E[C]):D(E[C],s):v[C][N]=s}return new e({data:v,size:[g,w],datatype:m})}}),hg="multiplyScalar",pg=["typed"],dg=mt(hg,pg,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":Fc,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),jc="multiply",_g=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],mg=mt(jc,_g,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,l=xa({typed:t,equalScalar:s}),c=Aa({typed:t});function h(x,F){switch(x.length){case 1:switch(F.length){case 1:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;case 2:switch(F.length){case 1:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+F[0]+")");break;case 2:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function p(x,F,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(x,F)}function f(x,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(x,F)}function d(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,T=F._size,L=F._datatype||F.getDataType(),U=S[0],k=T[1],W,P=r,K=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&(W=I,P=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var G=[],Q=0;Q<k;Q++){for(var tt=K(M[0],C[0][Q]),ct=1;ct<U;ct++)tt=P(tt,K(M[ct],C[ct][Q]));G[Q]=tt}return x.createDenseMatrix({data:G,size:[k],datatype:I===x._datatype&&L===F._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":E}),w=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":D,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,T=F._datatype||F.getDataType(),L=S[0],U=S[1],k,W=r,P=n;I&&T&&I===T&&typeof I=="string"&&I!=="mixed"&&(k=I,W=t.find(r,[k,k]),P=t.find(n,[k,k]));for(var K=[],G=0;G<L;G++){for(var Q=M[G],tt=P(Q[0],C[0]),ct=1;ct<U;ct++)tt=W(tt,P(Q[ct],C[ct]));K[G]=tt}return x.createDenseMatrix({data:K,size:[L],datatype:I===x._datatype&&T===F._datatype?k:void 0})}function D(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,T=F._size,L=F._datatype||F.getDataType(),U=S[0],k=S[1],W=T[1],P,K=r,G=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&I!=="mixed"&&(P=I,K=t.find(r,[P,P]),G=t.find(n,[P,P]));for(var Q=[],tt=0;tt<U;tt++){var ct=M[tt];Q[tt]=[];for(var vt=0;vt<W;vt++){for(var lt=G(ct[0],C[0][vt]),yt=1;yt<k;yt++)lt=K(lt,G(ct[yt],C[yt][vt]));Q[tt][vt]=lt}}return x.createDenseMatrix({data:Q,size:[U,W],datatype:I===x._datatype&&L===F._datatype?P:void 0})}function v(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._values,T=F._index,L=F._ptr,U=F._size,k=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],P=U[1],K,G=r,Q=n,tt=s,ct=0;I&&k&&I===k&&typeof I=="string"&&I!=="mixed"&&(K=I,G=t.find(r,[K,K]),Q=t.find(n,[K,K]),tt=t.find(s,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],yt=[],bt=F.createSparseMatrix({values:vt,index:lt,ptr:yt,size:[W,P],datatype:I===x._datatype&&k===F._datatype?K:void 0}),Bt=0;Bt<P;Bt++){yt[Bt]=lt.length;var Et=L[Bt],ne=L[Bt+1];if(ne>Et)for(var Ot=0,Nt=0;Nt<W;Nt++){for(var se=Nt+1,Vt=void 0,qt=Et;qt<ne;qt++){var Kt=T[qt];Ot!==se?(Vt=Q(M[Nt][Kt],C[qt]),Ot=se):Vt=G(Vt,Q(M[Nt][Kt],C[qt]))}Ot===se&&!tt(Vt,ct)&&(lt.push(Nt),vt.push(Vt))}}return yt[P]=lt.length,bt}function E(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=[],P=[],K=[],G,Q=r,tt=n,ct=s,vt=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(G=C,Q=t.find(r,[G,G]),tt=t.find(n,[G,G]),ct=t.find(s,[G,G]),vt=t.convert(0,G));var lt=[],yt=[];K[0]=0;for(var bt=0;bt<k;bt++){var Bt=T[bt];if(!ct(Bt,vt))for(var Et=I[bt],ne=I[bt+1],Ot=Et;Ot<ne;Ot++){var Nt=S[Ot];yt[Nt]?lt[Nt]=Q(lt[Nt],tt(Bt,M[Ot])):(yt[Nt]=!0,P.push(Nt),lt[Nt]=tt(Bt,M[Ot]))}}for(var se=P.length,Vt=0;Vt<se;Vt++){var qt=P[Vt];W[Vt]=lt[qt]}return K[1]=P.length,x.createSparseMatrix({values:W,index:P,ptr:K,size:[U,1],datatype:C===x._datatype&&L===F._datatype?G:void 0})}function b(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=F._size[1],P,K=r,G=n,Q=s,tt=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(P=C,K=t.find(r,[P,P]),G=t.find(n,[P,P]),Q=t.find(s,[P,P]),tt=t.convert(0,P));for(var ct=[],vt=[],lt=[],yt=x.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,W],datatype:C===x._datatype&&L===F._datatype?P:void 0}),bt=[],Bt=[],Et=0;Et<W;Et++){lt[Et]=vt.length;for(var ne=Et+1,Ot=0;Ot<k;Ot++){var Nt=T[Ot][Et];if(!Q(Nt,tt))for(var se=I[Ot],Vt=I[Ot+1],qt=se;qt<Vt;qt++){var Kt=S[qt];Bt[Kt]!==ne?(Bt[Kt]=ne,vt.push(Kt),bt[Kt]=G(Nt,M[qt])):bt[Kt]=K(bt[Kt],G(Nt,M[qt]))}}for(var Ne=lt[Et],lr=vt.length,Be=Ne;Be<lr;Be++){var nn=vt[Be];ct[Be]=bt[nn]}}return lt[W]=vt.length,yt}function N(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType(),T=F._values,L=F._index,U=F._ptr,k=F._datatype||F._data===void 0?F._datatype:F.getDataType(),W=x._size[0],P=F._size[1],K=M&&T,G,Q=r,tt=n;C&&k&&C===k&&typeof C=="string"&&C!=="mixed"&&(G=C,Q=t.find(r,[G,G]),tt=t.find(n,[G,G]));for(var ct=K?[]:void 0,vt=[],lt=[],yt=x.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,P],datatype:C===x._datatype&&k===F._datatype?G:void 0}),bt=K?[]:void 0,Bt=[],Et,ne,Ot,Nt,se,Vt,qt,Kt,Ne=0;Ne<P;Ne++){lt[Ne]=vt.length;var lr=Ne+1;for(se=U[Ne],Vt=U[Ne+1],Nt=se;Nt<Vt;Nt++)if(Kt=L[Nt],K)for(ne=I[Kt],Ot=I[Kt+1],Et=ne;Et<Ot;Et++)qt=S[Et],Bt[qt]!==lr?(Bt[qt]=lr,vt.push(qt),bt[qt]=tt(T[Nt],M[Et])):bt[qt]=Q(bt[qt],tt(T[Nt],M[Et]));else for(ne=I[Kt],Ot=I[Kt+1],Et=ne;Et<Ot;Et++)qt=S[Et],Bt[qt]!==lr&&(Bt[qt]=lr,vt.push(qt));if(K)for(var Be=lt[Ne],nn=vt.length,xn=Be;xn<nn;xn++){var sn=vt[xn];ct[xn]=bt[sn]}}return lt[P]=vt.length,yt}return t(jc,n,{"Array, Array":t.referTo("Matrix, Matrix",x=>(F,M)=>{h(Fe(F),Fe(M));var S=x(e(F),e(M));return fe(S)?S.valueOf():S}),"Matrix, Matrix":function(F,M){var S=F.size(),I=M.size();return h(S,I),S.length===1?I.length===1?p(F,M,S[0]):f(F,M):I.length===1?g(F,M):w(F,M)},"Matrix, Array":t.referTo("Matrix,Matrix",x=>(F,M)=>x(F,e(M))),"Array, Matrix":t.referToSelf(x=>(F,M)=>x(e(F,M.storage()),M)),"SparseMatrix, any":function(F,M){return l(F,M,n,!1)},"DenseMatrix, any":function(F,M){return c(F,M,n,!1)},"any, SparseMatrix":function(F,M){return l(M,F,n,!0)},"any, DenseMatrix":function(F,M){return c(M,F,n,!0)},"Array, any":function(F,M){return c(e(F),M,n,!1).valueOf()},"any, Array":function(F,M){return c(e(M),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(x=>(F,M,S)=>{for(var I=x(F,M),C=0;C<S.length;C++)I=x(I,S[C]);return I})})}),Yc="subtract",gg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],vg=mt(Yc,gg,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:l}=i,c=Uc({typed:t}),h=di({typed:t}),p=kc({typed:t,equalScalar:r}),f=Wc({typed:t,DenseMatrix:a}),d=pi({typed:t,DenseMatrix:a}),g=jn({typed:t,matrix:e,concat:l});return t(Yc,{"any, any":n},g({elop:n,SS:p,DS:c,SD:h,Ss:d,sS:f}))}),wg="matAlgo07xSSf",yg=["typed","DenseMatrix"],ks=mt(wg,yg,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,l){var c=s._size,h=s._datatype||s._data===void 0?s._datatype:s.getDataType(),p=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==p.length)throw new Gt(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");var d=c[0],g=c[1],w,m=0,D=l;typeof h=="string"&&h===f&&h!=="mixed"&&(w=h,m=t.convert(0,w),D=t.find(l,[w,w]));var v,E,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],x=[],F=[],M=[];for(E=0;E<g;E++){var S=E+1;for(r(s,E,F,N,S),r(a,E,M,x,S),v=0;v<d;v++){var I=F[v]===S?N[v]:m,C=M[v]===S?x[v]:m;b[v][E]=D(I,C)}}return new e({data:b,size:[d,g],datatype:h===s._datatype&&f===a._datatype?w:void 0})};function r(n,s,a,l,c){for(var h=n._values,p=n._index,f=n._ptr,d=f[s],g=f[s+1];d<g;d++){var w=p[d];a[w]=c,l[w]=h[d]}}}),Zc="conj",Dg=["typed"],bg=mt(Zc,Dg,i=>{var{typed:t}=i;return t(Zc,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),Gc="concat",Eg=["typed","matrix","isInteger"],xg=mt(Gc,Eg,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(Gc,{"...Array | Matrix | number | BigNumber":function(s){var a,l=s.length,c=-1,h,p=!1,f=[];for(a=0;a<l;a++){var d=s[a];if(fe(d)&&(p=!0),le(d)||xe(d)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(h=c,c=d.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>h)throw new gn(c,h+1)}else{var g=re(d).valueOf(),w=Fe(g);if(f[a]=g,h=c,c=w.length-1,a>0&&c!==h)throw new Gt(h+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=tc(m,f.shift(),c);return p?e(m):m},"...string":function(s){return s.join("")}})}),Kc="count",Ag=["typed","size","prod"],Cg=mt(Kc,Ag,i=>{var{typed:t,size:e,prod:r}=i;return t(Kc,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Hc="identity",Fg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Mg=mt(Hc,Fg,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(Hc,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(p){return r(p)},"number | BigNumber":function(p){return c(p,p,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(p,f){return c(p,p,f)},"number | BigNumber, number | BigNumber":function(p,f){return c(p,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(p,f,d){return c(p,f,d)},Array:function(p){return l(p)},"Array, string":function(p,f){return l(p,f)},Matrix:function(p){return l(p.valueOf(),p.storage())},"Matrix, string":function(p,f){return l(p.valueOf(),f)}});function l(h,p){switch(h.length){case 0:return p?r(p):[];case 1:return c(h[0],h[0],p);case 2:return c(h[0],h[1],p);default:throw new Error("Vector containing two values expected")}}function c(h,p,f){var d=xe(h)||xe(p)?n:null;if(xe(h)&&(h=h.toNumber()),xe(p)&&(p=p.toNumber()),!de(h)||h<1)throw new Error("Parameters in function identity must be positive integers");if(!de(p)||p<1)throw new Error("Parameters in function identity must be positive integers");var g=d?new n(1):1,w=d?new d(0):0,m=[h,p];if(f){if(f==="sparse")return a.diagonal(m,g,0,w);if(f==="dense")return s.diagonal(m,g,0,w);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var D=ca([],m,w),v=h<p?h:p,E=0;E<v;E++)D[E][E]=g;return D}}),Xc="kron",Ng=["typed","matrix","multiplyScalar"],Sg=mt(Xc,Ng,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Xc,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(s,a){if(Fe(s).length===1&&(s=[s]),Fe(a).length===1&&(a=[a]),Fe(s).length>2||Fe(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return s.map(function(h){return a.map(function(p){return c=[],l.push(c),h.map(function(f){return p.map(function(d){return c.push(r(f,d))})})})})&&l}});function Bg(){throw new Error('No "bignumber" implementation available')}function Tg(){throw new Error('No "fraction" implementation available')}function Og(){throw new Error('No "matrix" implementation available')}var Jc="reshape",Ig=["typed","isInteger","matrix"],$g=mt(Jc,Ig,i=>{var{typed:t,isInteger:e}=i;return t(Jc,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),ha(n,s)}})}),Qc="size",Lg=["typed","config","?matrix"],Rg=mt(Qc,Lg,i=>{var{typed:t,config:e,matrix:r}=i;return t(Qc,{Matrix:function(s){return s.create(s.size())},Array:Fe,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):Og()}})}),Vc="transpose",Pg=["typed","matrix"],zg=mt(Vc,Pg,i=>{var{typed:t,matrix:e}=i;return t(Vc,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:re});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var h=l[0],p=l[1];if(p===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+oe(l)+")");switch(a.storage()){case"dense":c=n(a,h,p);break;case"sparse":c=s(a,h,p);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+oe(l)+")")}return c}function n(a,l,c){for(var h=a._data,p=[],f,d=0;d<c;d++){f=p[d]=[];for(var g=0;g<l;g++)f[g]=re(h[g][d])}return a.createDenseMatrix({data:p,size:[c,l],datatype:a._datatype})}function s(a,l,c){for(var h=a._values,p=a._index,f=a._ptr,d=h?[]:void 0,g=[],w=[],m=[],D=0;D<l;D++)m[D]=0;var v,E,b;for(v=0,E=p.length;v<E;v++)m[p[v]]++;for(var N=0,x=0;x<l;x++)w.push(N),N+=m[x],m[x]=w[x];for(w.push(N),b=0;b<c;b++)for(var F=f[b],M=f[b+1],S=F;S<M;S++){var I=m[p[S]]++;g[I]=b,h&&(d[I]=re(h[S]))}return a.createSparseMatrix({values:d,index:g,ptr:w,size:[c,l],datatype:a._datatype})}}),tf="ctranspose",qg=["typed","transpose","conj"],kg=mt(tf,qg,i=>{var{typed:t,transpose:e,conj:r}=i;return t(tf,{any:function(s){return r(e(s))}})}),ef="mode",Ug=["typed","isNaN","isNumeric"],Wg=mt(ef,Ug,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(ef,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=da(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],h=0,p=0;p<s.length;p++){var f=s[p];if(r(f)&&e(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===h?c.push(f):l[f]>h&&(h=l[f],c=[f])}return c}});function bn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+mn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+mn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var rf="prod",jg=["typed","config","multiplyScalar","numeric"],Yg=mt(rf,jg,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(rf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return s(l)}});function s(a){var l;if(Yi(a,function(c){try{l=l===void 0?c:r(l,c)}catch(h){throw bn(h,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Zg="numeric",Gg=["number","?bignumber","?fraction"],Kg=mt(Zg,Gg,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):Bg,Fraction:r?a=>r(a):Tg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",h=arguments.length>2?arguments[2]:void 0;if(h!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var p=mn(l);if(!(p in n))throw new TypeError("Cannot convert "+l+' of type "'+p+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in s))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(s).join(", "));return c===p?l:s[c](l)}}),nf="divideScalar",Hg=["typed","numeric"],Xg=mt(nf,Hg,i=>{var{typed:t,numeric:e}=i;return t(nf,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),sf="pow",Jg=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Qg=mt(sf,Jg,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:l,fraction:c,Complex:h}=i;return t(sf,{"number, number":p,"Complex, Complex":function(w,m){return w.pow(m)},"BigNumber, BigNumber":function(w,m){return m.isInteger()||w>=0||e.predictable?w.pow(m):new h(w.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(w,m){var D=w.pow(m);if(D!=null)return D;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return p(w.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(w,m){return f(w,m.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(w,m){return d(w,m.toNumber())},"Unit, number | BigNumber":function(w,m){return w.pow(m)}});function p(g,w){if(e.predictable&&!de(w)&&g<0)try{var m=c(w),D=l(m);if((w===D||Math.abs((w-D)/w)<1e-14)&&m.d%2===1)return(m.n%2===0?1:-1)*Math.pow(-g,w)}catch{}return e.predictable&&(g<-1&&w===1/0||g>-1&&g<0&&w===-1/0)?NaN:de(w)||g>=0||e.predictable?Nc(g,w):g*g<1&&w===1/0||g*g>1&&w===-1/0?0:new h(g,0).pow(w,0)}function f(g,w){if(!de(w))throw new TypeError("For A^b, b must be an integer (value is "+w+")");var m=Fe(g);if(m.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+m.length+" dimensions)");if(m[0]!==m[1])throw new Error("For A^b, A must be square (size is "+m[0]+"x"+m[1]+")");if(w<0)try{return f(a(g),-w)}catch(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+w+")"):E}for(var D=r(m[0]).valueOf(),v=g;w>=1;)(w&1)===1&&(D=n(v,D)),w>>=1,v=n(v,v);return D}function d(g,w){return s(f(g.valueOf(),w))}}),of="dotDivide",Vg=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],tv=mt(of,Vg,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,l=Zm({typed:t,equalScalar:r}),c=di({typed:t}),h=ks({typed:t,DenseMatrix:s}),p=xa({typed:t,equalScalar:r}),f=pi({typed:t,DenseMatrix:s}),d=jn({typed:t,matrix:e,concat:a});return t(of,d({elop:n,SS:h,DS:c,SD:l,Ss:p,sS:f}))}),Us="compare",ev=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],rv=mt(Us,ev,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:l,concat:c}=i,h=di({typed:t}),p=kc({typed:t,equalScalar:r}),f=pi({typed:t,DenseMatrix:l}),d=jn({typed:t,matrix:n,concat:c}),g=zs({typed:t});return t(Us,nv({typed:t,config:e}),{"boolean, boolean":function(m,D){return m===D?0:m>D?1:-1},"BigNumber, BigNumber":function(m,D){return Ps(m,D,e.epsilon)?new s(0):new s(m.cmp(D))},"Fraction, Fraction":function(m,D){return new a(m.compare(D))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,d({SS:p,DS:h,Ss:f}))}),nv=mt(Us,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Us,{"number, number":function(n,s){return Wn(n,s,e.epsilon)?0:n>s?1:-1}})}),Ws="equal",iv=["typed","matrix","equalScalar","DenseMatrix","concat"],sv=mt(Ws,iv,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=di({typed:t}),l=ks({typed:t,DenseMatrix:n}),c=pi({typed:t,DenseMatrix:n}),h=jn({typed:t,matrix:e,concat:s});return t(Ws,ov({typed:t,equalScalar:r}),h({elop:r,SS:l,DS:a,Ss:c}))}),ov=mt(Ws,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Ws,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),js="smaller",av=["typed","config","matrix","DenseMatrix","concat"],uv=mt(js,av,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=di({typed:t}),l=ks({typed:t,DenseMatrix:n}),c=pi({typed:t,DenseMatrix:n}),h=jn({typed:t,matrix:r,concat:s}),p=zs({typed:t});return t(js,lv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f<d,"BigNumber, BigNumber":function(d,g){return d.lt(g)&&!Ps(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===-1,"Complex, Complex":function(d,g){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),lv=mt(js,["typed","config"],i=>{var{typed:t,config:e}=i;return t(js,{"number, number":function(n,s){return n<s&&!Wn(n,s,e.epsilon)}})}),Ys="larger",cv=["typed","config","matrix","DenseMatrix","concat"],fv=mt(Ys,cv,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=di({typed:t}),l=ks({typed:t,DenseMatrix:n}),c=pi({typed:t,DenseMatrix:n}),h=jn({typed:t,matrix:r,concat:s}),p=zs({typed:t});return t(Ys,hv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f>d,"BigNumber, BigNumber":function(d,g){return d.gt(g)&&!Ps(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),hv=mt(Ys,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ys,{"number, number":function(n,s){return n>s&&!Wn(n,s,e.epsilon)}})}),af="deepEqual",pv=["typed","equal"],dv=mt(af,pv,i=>{var{typed:t,equal:e}=i;return t(af,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],s[l]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),uf="partitionSelect",_v=["typed","isNumeric","isNaN","compare"],mv=mt(uf,_v,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(h,p)=>-n(h,p);return t(uf,{"Array | Matrix, number":function(p,f){return l(p,f,s)},"Array | Matrix, number, string":function(p,f,d){if(d==="asc")return l(p,f,s);if(d==="desc")return l(p,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(h,p,f){if(!de(p)||p<0)throw new Error("k must be a non-negative integer");if(fe(h)){var d=h.size();if(d.length>1)throw new Error("Only one dimensional matrices supported");return c(h.valueOf(),p,f)}if(Array.isArray(h))return c(h,p,f)}function c(h,p,f){if(p>=h.length)throw new Error("k out of bounds");for(var d=0;d<h.length;d++)if(e(h[d])&&r(h[d]))return h[d];for(var g=0,w=h.length-1;g<w;){for(var m=g,D=w,v=h[Math.floor(Math.random()*(w-g+1))+g];m<D;)if(f(h[m],v)>=0){var E=h[D];h[D]=h[m],h[m]=E,--D}else++m;f(h[m],v)>0&&--m,p<=m?w=m:g=m+1}return h[p]}}),lf="max",gv=["typed","config","numeric","larger"],vv=mt(lf,gv,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(lf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Ea(c,h.valueOf(),s)},"...":function(c){if($s(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(h){throw bn(h,"max",c)}}function a(l){var c;if(Yi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw bn(p,"max",h)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),cf="min",wv=["typed","config","numeric","smaller"],yv=mt(cf,wv,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(cf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Ea(c,h.valueOf(),s)},"...":function(c){if($s(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(h){throw bn(h,"min",c)}}function a(l){var c;if(Yi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw bn(p,"min",h)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),ff="add",Dv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],bv=mt(ff,Dv,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:l}=i,c=Uc({typed:t}),h=lg({typed:t,equalScalar:n}),p=Wc({typed:t,DenseMatrix:s}),f=jn({typed:t,matrix:e,concat:l});return t(ff,{"any, any":r,"any, any, ...any":t.referToSelf(d=>(g,w,m)=>{for(var D=d(g,w),v=0;v<m.length;v++)D=d(D,m[v]);return D})},f({elop:r,DS:c,SS:h,Ss:p}))}),hf="dot",Ev=["typed","addScalar","multiplyScalar","conj","size"],xv=mt(hf,Ev,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(hf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(p,f){var d=h(p),g=h(f),w,m;if(d.length===1)w=d[0];else if(d.length===2&&d[1]===1)w=d[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+d.join(", ")+")");if(g.length===1)m=g[0];else if(g.length===2&&g[1]===1)m=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(w!==m)throw new RangeError("Vectors must have equal length ("+w+" != "+m+")");if(w===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return w}function l(p,f){var d=a(p,f),g=fe(p)?p._data:p,w=fe(p)?p._datatype||p.getDataType():void 0,m=fe(f)?f._data:f,D=fe(f)?f._datatype||f.getDataType():void 0,v=h(p).length===2,E=h(f).length===2,b=e,N=r;if(w&&D&&w===D&&typeof w=="string"&&w!=="mixed"){var x=w;b=t.find(e,[x,x]),N=t.find(r,[x,x])}if(!v&&!E){for(var F=N(n(g[0]),m[0]),M=1;M<d;M++)F=b(F,N(n(g[M]),m[M]));return F}if(!v&&E){for(var S=N(n(g[0]),m[0][0]),I=1;I<d;I++)S=b(S,N(n(g[I]),m[I][0]));return S}if(v&&!E){for(var C=N(n(g[0][0]),m[0]),T=1;T<d;T++)C=b(C,N(n(g[T][0]),m[T]));return C}if(v&&E){for(var L=N(n(g[0][0]),m[0][0]),U=1;U<d;U++)L=b(L,N(n(g[U][0]),m[U][0]));return L}}function c(p,f){a(p,f);for(var d=p._index,g=p._values,w=f._index,m=f._values,D=0,v=e,E=r,b=0,N=0;b<d.length&&N<w.length;){var x=d[b],F=w[N];if(x<F){b++;continue}if(x>F){N++;continue}x===F&&(D=v(D,E(g[b],m[N])),b++,N++)}return D}function h(p){return fe(p)?p.size():s(p)}}),Av="trace",Cv=["typed","matrix","add"],Fv=mt(Av,Cv,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:s,DenseMatrix:n,any:re});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return re(c[0]);throw new RangeError("Matrix must be square (size: "+oe(l)+")");case 2:{var h=l[0],p=l[1];if(h===p){for(var f=0,d=0;d<h;d++)f=r(f,c[d][d]);return f}else throw new RangeError("Matrix must be square (size: "+oe(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(l)+")")}}function s(a){var l=a._values,c=a._index,h=a._ptr,p=a._size,f=p[0],d=p[1];if(f===d){var g=0;if(l.length>0)for(var w=0;w<d;w++)for(var m=h[w],D=h[w+1],v=m;v<D;v++){var E=c[v];if(E===w){g=r(g,l[v]);break}if(E>w)break}return g}throw new RangeError("Matrix must be square (size: "+oe(p)+")")}}),pf="det",Mv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Nv=mt(pf,Mv,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:l}=i;return t(pf,{any:function(p){return re(p)},"Array | Matrix":function(p){var f;switch(fe(p)?f=p.size():Array.isArray(p)?(p=e(p),f=p.size()):f=[],f.length){case 0:return re(p);case 1:if(f[0]===1)return re(p.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+oe(f)+")");case 2:{var d=f[0],g=f[1];if(d===g)return c(p.clone().valueOf(),d);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+oe(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(f)+")")}}});function c(h,p,f){if(p===1)return re(h[0][0]);if(p===2)return r(n(h[0][0],h[1][1]),n(h[1][0],h[0][1]));for(var d=!1,g=new Array(p).fill(0).map((M,S)=>S),w=0;w<p;w++){var m=g[w];if(a(h[m][w])){var D=void 0;for(D=w+1;D<p;D++)if(!a(h[g[D]][w])){m=g[D],g[D]=g[w],g[w]=m,d=!d;break}if(D===p)return h[m][w]}for(var v=h[m][w],E=w===0?1:h[g[w-1]][w-1],b=w+1;b<p;b++)for(var N=g[b],x=w+1;x<p;x++)h[N][x]=s(r(n(h[N][x],v),n(h[N][w],h[m][x])),E)}var F=h[g[p-1]][p-1];return d?l(F):F}}),df="inv",Sv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Bv=mt(df,Sv,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:l,identity:c,abs:h}=i;return t(df,{"Array | Matrix":function(d){var g=fe(d)?d.size():Fe(d);switch(g.length){case 1:if(g[0]===1)return fe(d)?e([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+oe(g)+")");case 2:{var w=g[0],m=g[1];if(w===m)return fe(d)?e(p(d.valueOf(),w,m),d.storage()):p(d,w,m);throw new RangeError("Matrix must be square (size: "+oe(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(g)+")")}},any:function(d){return r(1,d)}});function p(f,d,g){var w,m,D,v,E;if(d===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(d===2){var b=l(f);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(f[1][1],b),r(a(f[0][1]),b)],[r(a(f[1][0]),b),r(f[0][0],b)]]}else{var N=f.concat();for(w=0;w<d;w++)N[w]=N[w].concat();for(var x=c(d).valueOf(),F=0;F<g;F++){var M=h(N[F][F]),S=F;for(w=F+1;w<d;)h(N[w][F])>M&&(M=h(N[w][F]),S=w),w++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");w=S,w!==F&&(E=N[F],N[F]=N[w],N[w]=E,E=x[F],x[F]=x[w],x[w]=E);var I=N[F],C=x[F];for(w=0;w<d;w++){var T=N[w],L=x[w];if(w!==F){if(T[F]!==0){for(D=r(a(T[F]),I[F]),m=F;m<g;m++)T[m]=n(T[m],s(D,I[m]));for(m=0;m<g;m++)L[m]=n(L[m],s(D,C[m]))}}else{for(D=I[F],m=F;m<g;m++)T[m]=r(T[m],D);for(m=0;m<g;m++)L[m]=r(L[m],D)}}}return x}}}),_f="pinv",Tv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Ov=mt(_f,Tv,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:l,ctranspose:c,divideScalar:h,multiply:p,add:f,Complex:d}=i;return t(_f,{"Array | Matrix":function(b){var N=fe(b)?b.size():Fe(b);switch(N.length){case 1:return v(b)?c(b):N[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var x=N[0],F=N[1];if(x===F)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return fe(b)?e(g(b.valueOf(),x,F),b.storage()):g(b,x,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(N)+")")}},any:function(b){return s(b,0)?re(b):h(1,b)}});function g(E,b,N){var{C:x,F}=m(E,b,N),M=p(r(p(c(x),x)),c(x)),S=p(c(F),r(p(F,c(F))));return p(S,M)}function w(E,b,N){for(var x=re(E),F=0,M=0;M<b;M++){if(N<=F)return x;for(var S=M;D(x[S][F]);)if(S++,b===S&&(S=M,F++,N===F))return x;[x[S],x[M]]=[x[M],x[S]];for(var I=x[M][F],C=0;C<N;C++)x[M][C]=a(x[M][C],I);for(var T=0;T<b;T++)if(T!==M){I=x[T][F];for(var L=0;L<N;L++)x[T][L]=f(x[T][L],p(-1,p(I,x[M][L])))}F++}return x}function m(E,b,N){var x=w(E,b,N),F=E.map((S,I)=>S.filter((C,T)=>T<b&&!D(l(x[T],x[T])))),M=x.filter((S,I)=>!D(l(x[I],x[I])));return{C:F,F:M}}function D(E){return s(f(E,d(1,1)),f(0,d(1,1)))}function v(E){return n(f(E,d(1,1)),f(p(E,0),d(1,1)))}}),Iv="divide",$v=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Lv=mt(Iv,$v,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,l=xa({typed:t,equalScalar:n}),c=Aa({typed:t});return t("divide",Il({"Array | Matrix, Array | Matrix":function(p,f){return r(p,a(f))},"DenseMatrix, any":function(p,f){return c(p,f,s,!1)},"SparseMatrix, any":function(p,f){return l(p,f,s,!1)},"Array, any":function(p,f){return c(e(p),f,s,!1).valueOf()},"any, Array | Matrix":function(p,f){return r(p,a(f))}},s.signatures))}),mf="sum",Rv=["typed","config","add","numeric"],Pv=mt(mf,Rv,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(mf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(c){if($s(c))throw new TypeError("Scalar values expected in function sum");return s(c)}});function s(l){var c;return Yi(l,function(h){try{c=c===void 0?h:r(c,h)}catch(p){throw bn(p,"sum",h)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var h=Ea(l,c,r);return h}catch(p){throw bn(p,"sum")}}}),gf="median",zv=["typed","add","divide","compare","partitionSelect"],qv=mt(gf,zv,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(h){try{h=da(h.valueOf());var p=h.length;if(p===0)throw new Error("Cannot calculate median of an empty array");if(p%2===0){for(var f=p/2-1,d=s(h,f+1),g=h[f],w=0;w<f;++w)n(h[w],g)>0&&(g=h[w]);return c(g,d)}else{var m=s(h,(p-1)/2);return l(m)}}catch(D){throw bn(D,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(p){return p}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(p,f){return r(e(p,f),2)}});return t(gf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(p,f){throw new Error("median(A, dim) is not yet supported")},"...":function(p){if($s(p))throw new TypeError("Scalar values expected in function median");return a(p)}})}),Zs=k_({config:ar}),Ca=Y_({}),Fa=H_({}),Ma=Q_({}),Kr=em({Matrix:Ma}),Mt=jd({BigNumber:Zs,Complex:Ca,DenseMatrix:Kr,Fraction:Fa}),kv=Om({typed:Mt}),Gs=$m({typed:Mt}),Uv=xm({BigNumber:Zs,typed:Mt}),vf=bg({typed:Mt}),En=pm({config:ar,typed:Mt}),Ks=im({typed:Mt}),Wv=um({typed:Mt}),Hs=dg({typed:Mt}),wf=Dm({typed:Mt}),Na=mm({Matrix:Ma,equalScalar:En,typed:Mt}),yf=Rm({typed:Mt}),Df=cm({typed:Mt}),Sa=Bm({typed:Mt}),bf=Fm({Fraction:Fa,typed:Mt}),Ef=om({typed:Mt}),Me=Nm({DenseMatrix:Kr,Matrix:Ma,SparseMatrix:Na,typed:Mt}),xf=Wg({isNaN:Df,isNumeric:Ef,typed:Mt}),Zi=Kg({bignumber:Uv,fraction:bf,number:wf}),jv=Yg({config:ar,multiplyScalar:Hs,numeric:Zi,typed:Mt}),Yv=$g({isInteger:Ks,matrix:Me,typed:Mt}),Af=Rg({matrix:Me,config:ar,typed:Mt}),Cf=zg({matrix:Me,typed:Mt}),Yn=xg({isInteger:Ks,matrix:Me,typed:Mt}),Zv=Cg({prod:jv,size:Af,typed:Mt}),Gv=kg({conj:vf,transpose:Cf,typed:Mt}),Gi=Xg({numeric:Zi,typed:Mt}),Kv=tv({DenseMatrix:Kr,concat:Yn,divideScalar:Gi,equalScalar:En,matrix:Me,typed:Mt}),Ff=sv({DenseMatrix:Kr,concat:Yn,equalScalar:En,matrix:Me,typed:Mt}),Mf=Mg({BigNumber:Zs,DenseMatrix:Kr,SparseMatrix:Na,config:ar,matrix:Me,typed:Mt}),Hv=Sg({matrix:Me,multiplyScalar:Hs,typed:Mt}),Xv=uv({DenseMatrix:Kr,concat:Yn,config:ar,matrix:Me,typed:Mt}),Jv=vg({DenseMatrix:Kr,concat:Yn,equalScalar:En,matrix:Me,subtractScalar:yf,typed:Mt,unaryMinus:Sa}),Ki=bv({DenseMatrix:Kr,SparseMatrix:Na,addScalar:Gs,concat:Yn,equalScalar:En,matrix:Me,typed:Mt}),Nf=rv({BigNumber:Zs,DenseMatrix:Kr,Fraction:Fa,concat:Yn,config:ar,equalScalar:En,matrix:Me,typed:Mt}),Qv=dv({equal:Ff,typed:Mt}),Sf=xv({addScalar:Gs,conj:vf,multiplyScalar:Hs,size:Af,typed:Mt}),Vv=fv({DenseMatrix:Kr,concat:Yn,config:ar,matrix:Me,typed:Mt}),Ba=yv({config:ar,numeric:Zi,smaller:Xv,typed:Mt}),_i=mg({addScalar:Gs,dot:Sf,equalScalar:En,matrix:Me,multiplyScalar:Hs,typed:Mt}),t1=mv({compare:Nf,isNaN:Df,isNumeric:Ef,typed:Mt}),e1=Pv({add:Ki,config:ar,numeric:Zi,typed:Mt}),r1=Fv({add:Ki,matrix:Me,typed:Mt}),Bf=Nv({divideScalar:Gi,isZero:Wv,matrix:Me,multiply:_i,subtractScalar:yf,typed:Mt,unaryMinus:Sa}),n1=vv({config:ar,larger:Vv,numeric:Zi,typed:Mt}),Xs=Bv({abs:kv,addScalar:Gs,det:Bf,divideScalar:Gi,identity:Mf,matrix:Me,multiply:_i,typed:Mt,unaryMinus:Sa}),i1=Ov({Complex:Ca,add:Ki,ctranspose:Gv,deepEqual:Qv,divideScalar:Gi,dot:Sf,dotDivide:Kv,equal:Ff,inv:Xs,matrix:Me,multiply:_i,typed:Mt}),s1=Qg({Complex:Ca,config:ar,fraction:bf,identity:Mf,inv:Xs,matrix:Me,multiply:_i,number:wf,typed:Mt}),o1=Lv({divideScalar:Gi,equalScalar:En,inv:Xs,matrix:Me,multiply:_i,typed:Mt}),Tf=qv({add:Ki,compare:Nf,divide:o1,partitionSelect:t1,typed:Mt});class a1{constructor(t,e,r){z(this,"_cacheData");z(this,"_variables");z(this,"_math");z(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);s&&(c=Math.floor(c));const h=e/n;let p=0,f=0;for(let d=0;d<=e-1;d++){const g=Math.exp(-1*Math.pow(d-c,2)/(2*Math.pow(h,2)));p+=g,f+=l[l.length-1-(e-d-1)]*g}return f/p}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=e1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`sma_${r}`]=n;const{sum:s}=this._cacheData[`rma_${r}`]||{},a=1/e,l=s===void 0?this.sma({source:t,length:e},r):a*t+(1-a)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:l}),l}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:a,low:l}=this._variables,c=r===void 0?s-l:Math.max(Math.max(s-l,Math.abs(s-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let l=0;for(let c=0;c<e;c++){const h=this._sum(s[s.length-1-c],-(a||0));l+=h*h}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const l=r*a;return[s,s+l,s-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const l=r*a;return(s+l-(s-l))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||s===void 0)return;let c=0,h=0,p=0;for(let d=0;d<r;d++){const[g,w]=s[s.length-1-d],m=g-a,D=w-l;c+=m*D,h+=m*m,p+=D*D}return isNaN(h)||isNaN(c)||isNaN(p)?void 0:c/Math.sqrt(h*p)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];s+=Math.abs(c-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:a,close:l,PDMS:c,NDMS:h,TRS:p,ADX:f,count:d=0}=this._cacheData[n]||{},{low:g,high:w,close:m}=this._variables;if(s===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:w,close:m,PDMS:c,NDMS:h,TRS:w-g,count:1},[void 0,void 0,void 0];let D=w-a,v=s-g;D=D>v&&D>0?D:0,v=v>D&&v>0?v:0,D===v&&(D=v=0);const E=Math.max(w-g,Math.abs(w-l),Math.abs(g-l));if(d<t)return this._cacheDataHandle(n,{low:g,high:w,close:m,PDMS:(c||0)+D,NDMS:(h||0)+v,TRS:(p||0)+E,count:d+1}),[void 0,void 0,void 0];{const b=c-c/t+D,N=h-h/t+v,x=p-p/t+E,F=b/x*100,M=N/x*100,S=Math.abs((F-M)/(F+M))*100;let I=S,C=[F,M,void 0];if(d+1-t<e){const T=d+1-t;I=((f||0)*(T-1)+S)/T}else I=(f*(e-1)+S)/e,C=[F,M,I];return this._cacheDataHandle(n,{low:g,high:w,close:m,PDMS:b,NDMS:N,TRS:x,ADX:I,count:d+1}),C}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(s>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const a=s.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const a=s.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highest_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.max(...l.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((h,p,f,d)=>p>=d[h]?f:h,0)-e+1}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;s+=c,a+=n[n.length-1-l]*c}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${s}`);return[a,a+f*r,a-f*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${s}`);return(a+f*r-(a-f*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(g=>g!==void 0);let l=0,c=0,h=0,p=0;for(const[g,w]of a.entries())l+=g,c+=w,h+=g*w,p+=g*g;const f=(e*h-l*c)/(e*p-l*l);return(c-f*l)/e+f*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.min(...l.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((h,p,f,d)=>p<=d[h]?f:h,0)-e+1}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),l=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,h=this.ema({source:c,length:n},`macd_${s}`);if(h===void 0)return[c,h,void 0];const p=c-h;return[c,h,p]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Tf(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Ba(xf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e||t===void 0||isNaN(t))return;let a=s.length-e-1,l;for(;l===void 0&&a>=0;)l=s[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[h,p]of a.entries()){const f=a[h-1];if(r<(h+.5)/l)return f===void 0||p===void 0?void 0:f+(p-f)*(r-(h-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<s.length;c++)s[c]!==void 0&&(s[c]<a||s[c]===a&&c<e)&&l++;return l/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Xt;let{close:a,open:l,low:c,high:h}=this._variables;const p=`pivot_point_levels_${n}`,{close:f,low:d,high:g,open:w,result:m}=this._cacheData[p]||{};if(!e&&(g&&d&&(h=Math.max(g,h),c=Math.min(d,c)),this._cacheDataHandle(p,{close:a,open:l,low:c,high:h,result:m}),!r))return s._value=m||[],s;const D={close:a,open:l,low:c,high:h};e===!0&&!r&&(a=f,l=w,c=d,h=g);const v=this._getPivotPointLevels(h,c,a,l,r,t);return this._cacheDataHandle(p,{...D,result:v}),s._value=v,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Un.traditional:return this._traditional(t,e,r);case Un.fibonacci:return this._fibonacci(t,e,r);case Un.woodie:return s?[]:this._woodie(t,e);case Un.classic:return this._classic(t,e,r);case Un.dm:return this._DM(t,e,r,n);case Un.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),h=n*4+(t-4*e),p=n*2-t,f=n-(t-e),d=n*2-(2*t-e),g=n*3-(3*t-e),w=n*4-(4*t-e);return[n,s,p,a,f,l,d,c,g,h,w]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),h=n+(t-e),p=n-(t-e);return[n,s,a,l,c,h,p]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=t+2*(n-e),p=e-2*(t-n),f=h+(t-e),d=p-(t-e);return[n,s,a,l,c,h,p,f,d]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=n+2*(t-e),p=n-2*(t-e),f=n+3*(t-e),d=n-3*(t-e);return[n,s,a,l,c,h,p,f,d]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,l=s/2-e,c=s/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,h=r+1.1*(t-e)/4,p=r-1.1*(t-e)/4,f=r+1.1*(t-e)/2,d=r-1.1*(t-e)/2,g=t/e*r,w=r-(g-r);return[n,s,a,l,c,h,p,f,d,g,w]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`);if(!n)return;const s=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...s),l=Math.min(...s);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:s,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:a,high:l,preLow:c,preHigh:h,data:p={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:d,acceleration:g,isBelow:w}=p,m=!1;const{close:D,low:v,high:E,bar_index:b}=this._variables;return b===1&&(D>s?(w=!0,d=E,f=a):(w=!1,d=v,f=l),m=!0,g=t),f=f+g*(d-f),w?f>v&&(m=!0,w=!1,f=Math.max(E,d||0),d=v,g=t):f<E&&(m=!0,w=!0,f=Math.min(v,d||0),d=E,g=t),m||(w?E>(d||0)&&(d=E,g=Math.min((g||0)+e,r)):v<(d||0)&&(d=v,g=Math.min((g||0)+e,r))),w?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,h))),this._cacheDataHandle(`sar_${n}`,{high:E,close:D,low:v,preLow:a,preHigh:l,data:Object.assign(p,{result:f,maxMin:d,acceleration:g,isBelow:w})}),f}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},s),l=this.highest({source:e,length:n},s);if(!(a===void 0||l===void 0))return 100*(this._variables.close-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:s}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:h,atr:p,close:f}=this._cacheData[a]||{},d=this.atr({length:e},r);if(d===void 0)return this._cacheDataHandle(a,{close:s}),[void 0,void 0];let g=n+t*d,w=n-t*d;const m=l||0,D=c||0;w=w>D||f<D?w:D,g=g<m||f>m?g:m;let v;p===void 0?v=1:h===m?v=s>g?-1:1:v=s<w?1:-1;const E=v===-1?w:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:w,superTrend:E,atr:d,close:s}),[E,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),l=this.ema({source:s,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),h=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/h}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`mode_${n}`);if(!a||s===void 0)return;const l=a.filter(h=>h!==void 0&&!isNaN(h)).slice(-e);if(l.length<e)return;const c=l.reduce((h,p)=>h+Math.pow(p-s,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:h,sumS:p=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=p=0,h=!0),!h)return r!==void 0?[]:void 0;const f=t*s+a,d=s+l,g=f/d;return c++,r!==void 0?(p=s*Math.pow(t,2)+p,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h,sumS:p}),this._computeBands(p,d,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h}),g)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:l}=n,c=t[s];if(c!==void 0){if(a!==void 0&&c<a){t.splice(s,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:s,currentVal:c}}}}return t}_cacheDataList(t,e,r){const n=this._cacheData[r]||[];n[this._variables.bar_index]=t,this._cacheData[r]=n;const s=n.filter(()=>!0);if(!(s.length<e))return s}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}const Of={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeRepeatErr:"type '$name' is already defined.",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an undefined object. The object is 'na'.",buidinAssignErr:"Cannot assign a new value to the built-in variable '$name'.",buidinVarErr:"Cannot shadow the built-in variable `$name` because it has already been used as a built-in.",useNaErr:"Cannot use an `na` value of an unspecified type in the `$name` function.",libraryTitleErr:"Invalid argument 'title' in 'library' call. It cannot contain spaces, special characters or begin with a digit.",exportFuncArgErr:"All exported functions args should be typified",indiRunErr:"An indicator must contain at least one of the following: any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, `alertcondition()`, or any drawing (line, label, box, table, polyline).",libraryExportErr:"A library must contain at least one exported function, method, or type.",strategyRunErr:"A strategy must contain at least one of the following: any `strategy.*()` function that creates orders, any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, or any drawing (line, label, box, table, polyline).",exportUseErr:"Only libraries can contain exported $type."};Wr.SERIES,Wr.SIMPLE,Wr.INPUT,Wr.CONST,Wr.INT,Wr.FLOAT,Wr.BOOL,Wr.COLOR,Wr.STRING;const u1=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"];class l1{constructor(t,e,r){z(this,"_cacheData");z(this,"_variables");z(this,"_errorListener");z(this,"_count");z(this,"_historyInputs");z(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._count=-1,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){for(const e of t){const r=e.id;this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${e.index}`,{modifyDefval:e.sourceTypeName||e.defval})}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,Qe.INT)}bool(t,e){return this._cacheHandle(t,e,Qe.BOOL)}color(t,e){return this._cacheHandle(t,e,Qe.COLOR)}time(t,e){return this._cacheHandle(t,e,Qe.TIME)}float(t,e){return this._cacheHandle(t,e,Qe.FLOAT)}price(t,e){return this._cacheHandle(t,e,Qe.PRICE)}source(t,e){return this._cacheHandle(t,e,Qe.SOURCE)}string(t,e){return this._cacheHandle(t,e,Qe.STRING)}symbol(t,e){return this._cacheHandle(t,e,Qe.SYMBOL)}session(t,e){return this._cacheHandle(t,e,Qe.SESSION)}text_area(t,e){return this._cacheHandle(t,e,Qe.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,Qe.TIMEFRAME)}_cacheHandle(t,e,r){const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(Of.inputDefvalErr,e,Ee.Error),s)s.isModify?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t);else{const{defval:a,display:l}=t;this._displayVerify(e,l),this._count++,t={inputType:r,...t,index:this._count},this._cacheData[n]=t,this._judgeHistoryInputs(t),(r||t.inputType)===Qe.SOURCE?this._cacheData[n].options=u1:t.options&&!t.options.includes(a)&&this._errorListener.addError(`input's defval should be in options, but '${a}' is not in [${t.options.toString()}]`,e,Ee.Error)}return this._cacheData[n].defval}_judgeHistoryInputs(t){const{defval:e,sourceTypeName:r,index:n}=t;let s=r||e;const a=`in_${n}`,l=this._historyInputs[a];if(!l)self.workerStorage.setValue(this._name,a,{defval:s});else{const{defval:c,modifyDefval:h}=l;c===s?s=h||s:self.workerStorage.setValue(this._name,a,{defval:s})}r?t.sourceTypeName=s:t.defval=s}_displayVerify(t,e){!e||!e.length||e.includes(sr.dataWindow)||e.includes(sr.statusLine)||this._errorListener.addError("Invalid argument 'display' in 'input' call. Possible values: [display.none, display.data_window, display.status_line, display.all]",t,Ee.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e}_getGroups(t){const e=[];for(const[r,n]of t)e.push({name:r,inputs:n});return e}}class c1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const{r,g:n,b:s}=this._parseColor(t||"");return`rgba(${Math.round(r)}, ${Math.round(n)}, ${Math.round(s)}, ${(100-e)/100})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){if(_t(t)||_t(e)||_t(r))return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:h,b:p,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:d,g,b:w,a:m}=this._parseColor(s||"rgba(0,0,0,0)"),D=c+l*(d-c),v=h+l*(g-h),E=p+l*(w-p),b=f+l*(m-f);return`rgba(${Math.round(D)}, ${Math.round(v)}, ${Math.round(E)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=(255-parseInt(a,16))/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var zt={};const f1=Object.prototype.toString;function Hi(i){const t=f1.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var h1=Object.freeze({__proto__:null,isAnyArray:Hi}),p1=be(h1);function d1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Hi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]>a&&(a=i[l]);return a}function _1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Hi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]<a&&(a=i[l]);return a}function m1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Hi(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Hi(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=_1(i),n=d1(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var h=(c-a)/(n-r),p=0;p<i.length;p++)e[p]=(i[p]-r)*h+a;return e}var g1=Object.freeze({__proto__:null,default:m1}),v1=be(g1);Object.defineProperty(zt,"__esModule",{value:!0});var tr=p1,If=v1;const Js=" ".repeat(2),$f=" ".repeat(4);function w1(){return Lf(this)}function Lf(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
|
54
|
+
(`+oe(S,m)+", "+oe(N,m)+") ==> "+(this._values?oe(this._values[M],m):"X")}return b},n.prototype.toString=function(){return oe(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(m){if(m){if(xe(m)&&(m=m.toNumber()),!le(m)||!de(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var D=m>0?m:0,v=m<0?-m:0,E=this._size[0],b=this._size[1],N=Math.min(E-v,b-D),x=[],F=[],M=[];M[0]=0;for(var S=D;S<b&&x.length<N;S++)for(var I=this._ptr[S],C=this._ptr[S+1],T=I;T<C;T++){var L=this._index[T];if(L===S-D+v){x.push(this._values[T]),F[x.length-1]=L-v;break}}return M.push(x.length),new n({values:x,index:F,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,D,v,E,b){if(!ve(m))throw new TypeError("Array expected, size parameter");if(m.length!==2)throw new Error("Only two dimensions matrix are supported");if(m=m.map(function(Q){if(xe(Q)&&(Q=Q.toNumber()),!le(Q)||!de(Q)||Q<1)throw new Error("Size values must be positive integers");return Q}),v){if(xe(v)&&(v=v.toNumber()),!le(v)||!de(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,x=0;Zr(b)&&(N=t.find(e,[b,b])||e,x=t.convert(0,b));var F=v>0?v:0,M=v<0?-v:0,S=m[0],I=m[1],C=Math.min(S-M,I-F),T;if(ve(D)){if(D.length!==C)throw new Error("Invalid value array length");T=function(tt){return D[tt]}}else if(fe(D)){var L=D.size();if(L.length!==1||L[0]!==C)throw new Error("Invalid matrix length");T=function(tt){return D.get([tt])}}else T=function(){return D};for(var U=[],k=[],W=[],P=0;P<I;P++){W.push(U.length);var K=P-F;if(K>=0&&K<C){var G=T(K);N(G,x)||(k.push(K+M),U.push(G))}}return W.push(U.length),new n({values:U,index:k,ptr:W,size:[S,I]})},n.prototype.swapRows=function(m,D){if(!le(m)||!de(m)||!le(D)||!de(D))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return we(m,this._size[0]),we(D,this._size[0]),n._swapRows(m,D,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,D,v,E,b){for(var N=E[m],x=E[m+1],F=N;F<x;F++)b(v[F],D[F])},n._swapRows=function(m,D,v,E,b,N){for(var x=0;x<v;x++){var F=N[x],M=N[x+1],S=h(m,F,M,b),I=h(D,F,M,b);if(S<M&&I<M&&b[S]===m&&b[I]===D){if(E){var C=E[S];E[S]=E[I],E[I]=C}continue}if(S<M&&b[S]===m&&(I>=M||b[I]!==D)){var T=E?E[S]:void 0;b.splice(I,0,D),E&&E.splice(I,0,T),b.splice(I<=S?S+1:S,1),E&&E.splice(I<=S?S+1:S,1);continue}if(I<M&&b[I]===D&&(S>=M||b[S]!==m)){var L=E?E[I]:void 0;b.splice(S,0,m),E&&E.splice(S,0,L),b.splice(S<=I?I+1:I,1),E&&E.splice(S<=I?I+1:I,1)}}},n},{isClass:!0}),gm="number",vm=["typed"];function wm(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function ym(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var Dm=mt(gm,vm,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=wm(n);if(s)return ym(s);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Rr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),bm="bignumber",Em=["typed","BigNumber"],xm=mt(bm,Em,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],l=e(s[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var h=new e(2).pow(Number(a)-1);return l.gte(h)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Rr(n,r))})}),Am="fraction",Cm=["typed","Fraction"],Fm=mt(Am,Cm,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Rr(n,r))})}),Lc="matrix",Mm=["typed","Matrix","DenseMatrix","SparseMatrix"],Nm=mt(Lc,Mm,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(Lc,{"":function(){return s([])},string:function(l){return s([],l)},"string, string":function(l,c){return s([],l,c)},Array:function(l){return s(l)},Matrix:function(l){return s(l,l.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,l,c){if(l==="dense"||l==="default"||l===void 0)return new r(a,c);if(l==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Rc="unaryMinus",Sm=["typed"],Bm=mt(Rc,Sm,i=>{var{typed:t}=i;return t(Rc,{number:Mc,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),Pc="abs",Tm=["typed"],Om=mt(Pc,Tm,i=>{var{typed:t}=i;return t(Pc,{number:xc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),zc="addScalar",Im=["typed"],$m=mt(zc,Im,i=>{var{typed:t}=i;return t(zc,{"number, number":Ac,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),qc="subtractScalar",Lm=["typed"],Rm=mt(qc,Lm,i=>{var{typed:t}=i;return t(qc,{"number, number":Cc,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Pm="matAlgo11xS0s",zm=["typed","equalScalar"],xa=mt(Pm,zm,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,D=e,v=0,E=a;typeof d=="string"&&(m=d,D=t.find(e,[m,m]),v=t.convert(0,m),s=t.convert(s,m),E=t.find(a,[m,m]));for(var b=[],N=[],x=[],F=0;F<w;F++){x[F]=N.length;for(var M=p[F],S=p[F+1],I=M;I<S;I++){var C=h[I],T=l?E(s,c[I]):E(c[I],s);D(T,v)||(N.push(C),b.push(T))}}return x[w]=N.length,n.createSparseMatrix({values:b,index:N,ptr:x,size:[g,w],datatype:m})}}),qm="matAlgo12xSfs",km=["typed","DenseMatrix"],pi=mt(qm,km,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,D=a;typeof d=="string"&&(m=d,s=t.convert(s,m),D=t.find(a,[m,m]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=p[N],M=p[N+1],S=F;S<M;S++){var I=h[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?D(s,E[C]):D(E[C],s):v[C][N]=l?D(s,0):D(0,s)}return new e({data:v,size:[g,w],datatype:m})}}),Um="matAlgo14xDs",Wm=["typed"],Aa=mt(Um,Wm,i=>{var{typed:t}=i;return function(n,s,a,l){var c=n._data,h=n._size,p=n._datatype,f,d=a;typeof p=="string"&&(f=p,s=t.convert(s,f),d=t.find(a,[f,f]));var g=h.length>0?e(d,0,h,h[0],c,s,l):[];return n.createDenseMatrix({data:g,size:re(h),datatype:f})};function e(r,n,s,a,l,c,h){var p=[];if(n===s.length-1)for(var f=0;f<a;f++)p[f]=h?r(c,l[f]):r(l[f],c);else for(var d=0;d<a;d++)p[d]=e(r,n+1,s,s[n+1],l[d],c,h);return p}}),jm="matAlgo02xDS0",Ym=["typed","equalScalar"],Zm=mt(jm,Ym,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._data,h=n._size,p=n._datatype||n.getDataType(),f=s._values,d=s._index,g=s._ptr,w=s._size,m=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==w.length)throw new Gt(h.length,w.length);if(h[0]!==w[0]||h[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+w+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var D=h[0],v=h[1],E,b=e,N=0,x=a;typeof p=="string"&&p===m&&p!=="mixed"&&(E=p,b=t.find(e,[E,E]),N=t.convert(0,E),x=t.find(a,[E,E]));for(var F=[],M=[],S=[],I=0;I<v;I++){S[I]=M.length;for(var C=g[I],T=g[I+1],L=C;L<T;L++){var U=d[L],k=l?x(f[L],c[U][I]):x(c[U][I],f[L]);b(k,N)||(M.push(U),F.push(k))}}return S[v]=M.length,s.createSparseMatrix({values:F,index:M,ptr:S,size:[D,v],datatype:p===n._datatype&&m===s._datatype?E:void 0})}}),Gm="matAlgo03xDSf",Km=["typed"],di=mt(Gm,Km,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Gt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],D=c[1],v,E=0,b=s;typeof h=="string"&&h===w&&h!=="mixed"&&(v=h,E=t.convert(0,v),b=t.find(s,[v,v]));for(var N=[],x=0;x<m;x++)N[x]=[];for(var F=[],M=[],S=0;S<D;S++){for(var I=S+1,C=d[S],T=d[S+1],L=C;L<T;L++){var U=f[L];F[U]=a?b(p[L],l[U][S]):b(l[U][S],p[L]),M[U]=I}for(var k=0;k<m;k++)M[k]===I?N[k][S]=F[k]:N[k][S]=a?b(E,l[k][S]):b(l[k][S],E)}return r.createDenseMatrix({data:N,size:[m,D],datatype:h===r._datatype&&w===n._datatype?v:void 0})}}),Hm="matAlgo05xSfSf",Xm=["typed","equalScalar"],kc=mt(Hm,Xm,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=s._values,g=s._index,w=s._ptr,m=s._size,D=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==m.length)throw new Gt(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],E=p[1],b,N=e,x=0,F=a;typeof f=="string"&&f===D&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=M?[]:void 0,T=M?[]:void 0,L=[],U=[],k,W,P,K;for(W=0;W<E;W++){I[W]=S.length;var G=W+1;for(P=h[W],K=h[W+1];P<K;P++)k=c[P],S.push(k),L[k]=G,C&&(C[k]=l[P]);for(P=w[W],K=w[W+1];P<K;P++)k=g[P],L[k]!==G&&S.push(k),U[k]=G,T&&(T[k]=d[P]);if(M)for(P=I[W];P<S.length;){k=S[P];var Q=L[k],tt=U[k];if(Q===G||tt===G){var ct=Q===G?C[k]:x,vt=tt===G?T[k]:x,lt=F(ct,vt);N(lt,x)?S.splice(P,1):(M.push(lt),P++)}}}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&D===s._datatype?b:void 0})}}),Jm="matAlgo13xDD",Qm=["typed"],Vm=mt(Jm,Qm,i=>{var{typed:t}=i;return function(n,s,a){var l=n._data,c=n._size,h=n._datatype,p=s._data,f=s._size,d=s._datatype,g=[];if(c.length!==f.length)throw new Gt(c.length,f.length);for(var w=0;w<c.length;w++){if(c[w]!==f[w])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[w]=c[w]}var m,D=a;typeof h=="string"&&h===d&&(m=h,D=t.find(a,[m,m]));var v=g.length>0?e(D,0,g,g[0],l,p):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,s,a,l,c){var h=[];if(n===s.length-1)for(var p=0;p<a;p++)h[p]=r(l[p],c[p]);else for(var f=0;f<a;f++)h[f]=e(r,n+1,s,s[n+1],l[f],c[f]);return h}}),tg="broadcast",eg=["concat"],rg=mt(tg,eg,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((w,m)=>w===s._size[m]))return[n,s];for(var l=e(n._size,a,0),c=e(s._size,a,0),h=[],p=0;p<a;p++)h[p]=Math.max(l[p],c[p]);Cs(l,h),Cs(c,h);var f=n.clone(),d=s.clone();f._size.length<a?f.reshape(e(f._size,a,1)):d._size.length<a&&d.reshape(e(d._size,a,1));for(var g=0;g<a;g++)f._size[g]<h[g]&&(f=r(f,h[g],g)),d._size[g]<h[g]&&(d=r(d,h[g],g));return[f,d]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),ng="matrixAlgorithmSuite",ig=["typed","matrix","concat"],jn=mt(ng,ig,i=>{var{typed:t,matrix:e,concat:r}=i,n=Vm({typed:t}),s=Aa({typed:t}),a=rg({concat:r});return function(c){var h=c.elop,p=c.SD||c.DS,f;h?(f={"DenseMatrix, DenseMatrix":(m,D)=>n(...a(m,D),h),"Array, Array":(m,D)=>n(...a(e(m),e(D)),h).valueOf(),"Array, DenseMatrix":(m,D)=>n(...a(e(m),D),h),"DenseMatrix, Array":(m,D)=>n(...a(m,e(D)),h)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,D)=>c.SS(...a(m,D),h,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,D)=>c.DS(...a(m,D),h,!1),f["Array, SparseMatrix"]=(m,D)=>c.DS(...a(e(m),D),h,!1)),p&&(f["SparseMatrix, DenseMatrix"]=(m,D)=>p(...a(D,m),h,!0),f["SparseMatrix, Array"]=(m,D)=>p(...a(e(D),m),h,!0))):(f={"DenseMatrix, DenseMatrix":t.referToSelf(m=>(D,v)=>n(...a(D,v),m)),"Array, Array":t.referToSelf(m=>(D,v)=>n(...a(e(D),e(v)),m).valueOf()),"Array, DenseMatrix":t.referToSelf(m=>(D,v)=>n(...a(e(D),v),m)),"DenseMatrix, Array":t.referToSelf(m=>(D,v)=>n(...a(D,e(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=t.referToSelf(m=>(D,v)=>c.SS(...a(D,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=t.referToSelf(m=>(D,v)=>c.DS(...a(D,v),m,!1)),f["Array, SparseMatrix"]=t.referToSelf(m=>(D,v)=>c.DS(...a(e(D),v),m,!1))),p&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(D,v)=>p(...a(v,D),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(D,v)=>p(...a(e(v),D),m,!0))));var d=c.scalar||"any",g=c.Ds||c.Ss;g&&(h?(f["DenseMatrix,"+d]=(m,D)=>s(m,D,h,!1),f[d+", DenseMatrix"]=(m,D)=>s(D,m,h,!0),f["Array,"+d]=(m,D)=>s(e(m),D,h,!1).valueOf(),f[d+", Array"]=(m,D)=>s(e(D),m,h,!0).valueOf()):(f["DenseMatrix,"+d]=t.referToSelf(m=>(D,v)=>s(D,v,m,!1)),f[d+", DenseMatrix"]=t.referToSelf(m=>(D,v)=>s(v,D,m,!0)),f["Array,"+d]=t.referToSelf(m=>(D,v)=>s(e(D),v,m,!1).valueOf()),f[d+", Array"]=t.referToSelf(m=>(D,v)=>s(e(v),D,m,!0).valueOf())));var w=c.sS!==void 0?c.sS:c.Ss;return h?(c.Ss&&(f["SparseMatrix,"+d]=(m,D)=>c.Ss(m,D,h,!1)),w&&(f[d+", SparseMatrix"]=(m,D)=>w(D,m,h,!0))):(c.Ss&&(f["SparseMatrix,"+d]=t.referToSelf(m=>(D,v)=>c.Ss(D,v,m,!1))),w&&(f[d+", SparseMatrix"]=t.referToSelf(m=>(D,v)=>w(v,D,m,!0)))),h&&h.signatures&&Il(f,h.signatures),f}}),sg="matAlgo01xDSid",og=["typed"],Uc=mt(sg,og,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Gt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],D=c[1],v=typeof h=="string"&&h!=="mixed"&&h===w?h:void 0,E=v?t.find(s,[v,v]):s,b,N,x=[];for(b=0;b<m;b++)x[b]=[];var F=[],M=[];for(N=0;N<D;N++){for(var S=N+1,I=d[N],C=d[N+1],T=I;T<C;T++)b=f[T],F[b]=a?E(p[T],l[b][N]):E(l[b][N],p[T]),M[b]=S;for(b=0;b<m;b++)M[b]===S?x[b][N]=F[b]:x[b][N]=l[b][N]}return r.createDenseMatrix({data:x,size:[m,D],datatype:h===r._datatype&&w===n._datatype?v:void 0})}}),ag="matAlgo04xSidSid",ug=["typed","equalScalar"],lg=mt(ag,ug,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=s._values,g=s._index,w=s._ptr,m=s._size,D=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==m.length)throw new Gt(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],E=p[1],b,N=e,x=0,F=a;typeof f=="string"&&f===D&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=l&&d?[]:void 0,T=l&&d?[]:void 0,L=[],U=[],k,W,P,K,G;for(W=0;W<E;W++){I[W]=S.length;var Q=W+1;for(K=h[W],G=h[W+1],P=K;P<G;P++)k=c[P],S.push(k),L[k]=Q,C&&(C[k]=l[P]);for(K=w[W],G=w[W+1],P=K;P<G;P++)if(k=g[P],L[k]===Q){if(C){var tt=F(C[k],d[P]);N(tt,x)?L[k]=null:C[k]=tt}}else S.push(k),U[k]=Q,T&&(T[k]=d[P]);if(C&&T)for(P=I[W];P<S.length;)k=S[P],L[k]===Q?(M[P]=C[k],P++):U[k]===Q?(M[P]=T[k],P++):S.splice(P,1)}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&D===s._datatype?b:void 0})}}),cg="matAlgo10xSids",fg=["typed","DenseMatrix"],Wc=mt(cg,fg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,D=a;typeof d=="string"&&(m=d,s=t.convert(s,m),D=t.find(a,[m,m]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=p[N],M=p[N+1],S=F;S<M;S++){var I=h[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?D(s,E[C]):D(E[C],s):v[C][N]=s}return new e({data:v,size:[g,w],datatype:m})}}),hg="multiplyScalar",pg=["typed"],dg=mt(hg,pg,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":Fc,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),jc="multiply",_g=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],mg=mt(jc,_g,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,l=xa({typed:t,equalScalar:s}),c=Aa({typed:t});function h(x,F){switch(x.length){case 1:switch(F.length){case 1:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;case 2:switch(F.length){case 1:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+F[0]+")");break;case 2:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function p(x,F,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(x,F)}function f(x,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(x,F)}function d(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,T=F._size,L=F._datatype||F.getDataType(),U=S[0],k=T[1],W,P=r,K=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&(W=I,P=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var G=[],Q=0;Q<k;Q++){for(var tt=K(M[0],C[0][Q]),ct=1;ct<U;ct++)tt=P(tt,K(M[ct],C[ct][Q]));G[Q]=tt}return x.createDenseMatrix({data:G,size:[k],datatype:I===x._datatype&&L===F._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":E}),w=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":D,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,T=F._datatype||F.getDataType(),L=S[0],U=S[1],k,W=r,P=n;I&&T&&I===T&&typeof I=="string"&&I!=="mixed"&&(k=I,W=t.find(r,[k,k]),P=t.find(n,[k,k]));for(var K=[],G=0;G<L;G++){for(var Q=M[G],tt=P(Q[0],C[0]),ct=1;ct<U;ct++)tt=W(tt,P(Q[ct],C[ct]));K[G]=tt}return x.createDenseMatrix({data:K,size:[L],datatype:I===x._datatype&&T===F._datatype?k:void 0})}function D(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,T=F._size,L=F._datatype||F.getDataType(),U=S[0],k=S[1],W=T[1],P,K=r,G=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&I!=="mixed"&&(P=I,K=t.find(r,[P,P]),G=t.find(n,[P,P]));for(var Q=[],tt=0;tt<U;tt++){var ct=M[tt];Q[tt]=[];for(var vt=0;vt<W;vt++){for(var lt=G(ct[0],C[0][vt]),yt=1;yt<k;yt++)lt=K(lt,G(ct[yt],C[yt][vt]));Q[tt][vt]=lt}}return x.createDenseMatrix({data:Q,size:[U,W],datatype:I===x._datatype&&L===F._datatype?P:void 0})}function v(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._values,T=F._index,L=F._ptr,U=F._size,k=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],P=U[1],K,G=r,Q=n,tt=s,ct=0;I&&k&&I===k&&typeof I=="string"&&I!=="mixed"&&(K=I,G=t.find(r,[K,K]),Q=t.find(n,[K,K]),tt=t.find(s,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],yt=[],bt=F.createSparseMatrix({values:vt,index:lt,ptr:yt,size:[W,P],datatype:I===x._datatype&&k===F._datatype?K:void 0}),Bt=0;Bt<P;Bt++){yt[Bt]=lt.length;var Et=L[Bt],ne=L[Bt+1];if(ne>Et)for(var Ot=0,Nt=0;Nt<W;Nt++){for(var se=Nt+1,Vt=void 0,qt=Et;qt<ne;qt++){var Kt=T[qt];Ot!==se?(Vt=Q(M[Nt][Kt],C[qt]),Ot=se):Vt=G(Vt,Q(M[Nt][Kt],C[qt]))}Ot===se&&!tt(Vt,ct)&&(lt.push(Nt),vt.push(Vt))}}return yt[P]=lt.length,bt}function E(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=[],P=[],K=[],G,Q=r,tt=n,ct=s,vt=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(G=C,Q=t.find(r,[G,G]),tt=t.find(n,[G,G]),ct=t.find(s,[G,G]),vt=t.convert(0,G));var lt=[],yt=[];K[0]=0;for(var bt=0;bt<k;bt++){var Bt=T[bt];if(!ct(Bt,vt))for(var Et=I[bt],ne=I[bt+1],Ot=Et;Ot<ne;Ot++){var Nt=S[Ot];yt[Nt]?lt[Nt]=Q(lt[Nt],tt(Bt,M[Ot])):(yt[Nt]=!0,P.push(Nt),lt[Nt]=tt(Bt,M[Ot]))}}for(var se=P.length,Vt=0;Vt<se;Vt++){var qt=P[Vt];W[Vt]=lt[qt]}return K[1]=P.length,x.createSparseMatrix({values:W,index:P,ptr:K,size:[U,1],datatype:C===x._datatype&&L===F._datatype?G:void 0})}function b(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=F._size[1],P,K=r,G=n,Q=s,tt=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(P=C,K=t.find(r,[P,P]),G=t.find(n,[P,P]),Q=t.find(s,[P,P]),tt=t.convert(0,P));for(var ct=[],vt=[],lt=[],yt=x.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,W],datatype:C===x._datatype&&L===F._datatype?P:void 0}),bt=[],Bt=[],Et=0;Et<W;Et++){lt[Et]=vt.length;for(var ne=Et+1,Ot=0;Ot<k;Ot++){var Nt=T[Ot][Et];if(!Q(Nt,tt))for(var se=I[Ot],Vt=I[Ot+1],qt=se;qt<Vt;qt++){var Kt=S[qt];Bt[Kt]!==ne?(Bt[Kt]=ne,vt.push(Kt),bt[Kt]=G(Nt,M[qt])):bt[Kt]=K(bt[Kt],G(Nt,M[qt]))}}for(var Ne=lt[Et],lr=vt.length,Be=Ne;Be<lr;Be++){var nn=vt[Be];ct[Be]=bt[nn]}}return lt[W]=vt.length,yt}function N(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType(),T=F._values,L=F._index,U=F._ptr,k=F._datatype||F._data===void 0?F._datatype:F.getDataType(),W=x._size[0],P=F._size[1],K=M&&T,G,Q=r,tt=n;C&&k&&C===k&&typeof C=="string"&&C!=="mixed"&&(G=C,Q=t.find(r,[G,G]),tt=t.find(n,[G,G]));for(var ct=K?[]:void 0,vt=[],lt=[],yt=x.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,P],datatype:C===x._datatype&&k===F._datatype?G:void 0}),bt=K?[]:void 0,Bt=[],Et,ne,Ot,Nt,se,Vt,qt,Kt,Ne=0;Ne<P;Ne++){lt[Ne]=vt.length;var lr=Ne+1;for(se=U[Ne],Vt=U[Ne+1],Nt=se;Nt<Vt;Nt++)if(Kt=L[Nt],K)for(ne=I[Kt],Ot=I[Kt+1],Et=ne;Et<Ot;Et++)qt=S[Et],Bt[qt]!==lr?(Bt[qt]=lr,vt.push(qt),bt[qt]=tt(T[Nt],M[Et])):bt[qt]=Q(bt[qt],tt(T[Nt],M[Et]));else for(ne=I[Kt],Ot=I[Kt+1],Et=ne;Et<Ot;Et++)qt=S[Et],Bt[qt]!==lr&&(Bt[qt]=lr,vt.push(qt));if(K)for(var Be=lt[Ne],nn=vt.length,xn=Be;xn<nn;xn++){var sn=vt[xn];ct[xn]=bt[sn]}}return lt[P]=vt.length,yt}return t(jc,n,{"Array, Array":t.referTo("Matrix, Matrix",x=>(F,M)=>{h(Fe(F),Fe(M));var S=x(e(F),e(M));return fe(S)?S.valueOf():S}),"Matrix, Matrix":function(F,M){var S=F.size(),I=M.size();return h(S,I),S.length===1?I.length===1?p(F,M,S[0]):f(F,M):I.length===1?g(F,M):w(F,M)},"Matrix, Array":t.referTo("Matrix,Matrix",x=>(F,M)=>x(F,e(M))),"Array, Matrix":t.referToSelf(x=>(F,M)=>x(e(F,M.storage()),M)),"SparseMatrix, any":function(F,M){return l(F,M,n,!1)},"DenseMatrix, any":function(F,M){return c(F,M,n,!1)},"any, SparseMatrix":function(F,M){return l(M,F,n,!0)},"any, DenseMatrix":function(F,M){return c(M,F,n,!0)},"Array, any":function(F,M){return c(e(F),M,n,!1).valueOf()},"any, Array":function(F,M){return c(e(M),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(x=>(F,M,S)=>{for(var I=x(F,M),C=0;C<S.length;C++)I=x(I,S[C]);return I})})}),Yc="subtract",gg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],vg=mt(Yc,gg,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:l}=i,c=Uc({typed:t}),h=di({typed:t}),p=kc({typed:t,equalScalar:r}),f=Wc({typed:t,DenseMatrix:a}),d=pi({typed:t,DenseMatrix:a}),g=jn({typed:t,matrix:e,concat:l});return t(Yc,{"any, any":n},g({elop:n,SS:p,DS:c,SD:h,Ss:d,sS:f}))}),wg="matAlgo07xSSf",yg=["typed","DenseMatrix"],ks=mt(wg,yg,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,l){var c=s._size,h=s._datatype||s._data===void 0?s._datatype:s.getDataType(),p=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==p.length)throw new Gt(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");var d=c[0],g=c[1],w,m=0,D=l;typeof h=="string"&&h===f&&h!=="mixed"&&(w=h,m=t.convert(0,w),D=t.find(l,[w,w]));var v,E,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],x=[],F=[],M=[];for(E=0;E<g;E++){var S=E+1;for(r(s,E,F,N,S),r(a,E,M,x,S),v=0;v<d;v++){var I=F[v]===S?N[v]:m,C=M[v]===S?x[v]:m;b[v][E]=D(I,C)}}return new e({data:b,size:[d,g],datatype:h===s._datatype&&f===a._datatype?w:void 0})};function r(n,s,a,l,c){for(var h=n._values,p=n._index,f=n._ptr,d=f[s],g=f[s+1];d<g;d++){var w=p[d];a[w]=c,l[w]=h[d]}}}),Zc="conj",Dg=["typed"],bg=mt(Zc,Dg,i=>{var{typed:t}=i;return t(Zc,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Rr(r,e))})}),Gc="concat",Eg=["typed","matrix","isInteger"],xg=mt(Gc,Eg,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(Gc,{"...Array | Matrix | number | BigNumber":function(s){var a,l=s.length,c=-1,h,p=!1,f=[];for(a=0;a<l;a++){var d=s[a];if(fe(d)&&(p=!0),le(d)||xe(d)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(h=c,c=d.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>h)throw new gn(c,h+1)}else{var g=re(d).valueOf(),w=Fe(g);if(f[a]=g,h=c,c=w.length-1,a>0&&c!==h)throw new Gt(h+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=tc(m,f.shift(),c);return p?e(m):m},"...string":function(s){return s.join("")}})}),Kc="count",Ag=["typed","size","prod"],Cg=mt(Kc,Ag,i=>{var{typed:t,size:e,prod:r}=i;return t(Kc,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Hc="identity",Fg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Mg=mt(Hc,Fg,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(Hc,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(p){return r(p)},"number | BigNumber":function(p){return c(p,p,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(p,f){return c(p,p,f)},"number | BigNumber, number | BigNumber":function(p,f){return c(p,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(p,f,d){return c(p,f,d)},Array:function(p){return l(p)},"Array, string":function(p,f){return l(p,f)},Matrix:function(p){return l(p.valueOf(),p.storage())},"Matrix, string":function(p,f){return l(p.valueOf(),f)}});function l(h,p){switch(h.length){case 0:return p?r(p):[];case 1:return c(h[0],h[0],p);case 2:return c(h[0],h[1],p);default:throw new Error("Vector containing two values expected")}}function c(h,p,f){var d=xe(h)||xe(p)?n:null;if(xe(h)&&(h=h.toNumber()),xe(p)&&(p=p.toNumber()),!de(h)||h<1)throw new Error("Parameters in function identity must be positive integers");if(!de(p)||p<1)throw new Error("Parameters in function identity must be positive integers");var g=d?new n(1):1,w=d?new d(0):0,m=[h,p];if(f){if(f==="sparse")return a.diagonal(m,g,0,w);if(f==="dense")return s.diagonal(m,g,0,w);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var D=ca([],m,w),v=h<p?h:p,E=0;E<v;E++)D[E][E]=g;return D}}),Xc="kron",Ng=["typed","matrix","multiplyScalar"],Sg=mt(Xc,Ng,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Xc,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(s,a){if(Fe(s).length===1&&(s=[s]),Fe(a).length===1&&(a=[a]),Fe(s).length>2||Fe(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return s.map(function(h){return a.map(function(p){return c=[],l.push(c),h.map(function(f){return p.map(function(d){return c.push(r(f,d))})})})})&&l}});function Bg(){throw new Error('No "bignumber" implementation available')}function Tg(){throw new Error('No "fraction" implementation available')}function Og(){throw new Error('No "matrix" implementation available')}var Jc="reshape",Ig=["typed","isInteger","matrix"],$g=mt(Jc,Ig,i=>{var{typed:t,isInteger:e}=i;return t(Jc,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),ha(n,s)}})}),Qc="size",Lg=["typed","config","?matrix"],Rg=mt(Qc,Lg,i=>{var{typed:t,config:e,matrix:r}=i;return t(Qc,{Matrix:function(s){return s.create(s.size())},Array:Fe,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):Og()}})}),Vc="transpose",Pg=["typed","matrix"],zg=mt(Vc,Pg,i=>{var{typed:t,matrix:e}=i;return t(Vc,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:re});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var h=l[0],p=l[1];if(p===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+oe(l)+")");switch(a.storage()){case"dense":c=n(a,h,p);break;case"sparse":c=s(a,h,p);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+oe(l)+")")}return c}function n(a,l,c){for(var h=a._data,p=[],f,d=0;d<c;d++){f=p[d]=[];for(var g=0;g<l;g++)f[g]=re(h[g][d])}return a.createDenseMatrix({data:p,size:[c,l],datatype:a._datatype})}function s(a,l,c){for(var h=a._values,p=a._index,f=a._ptr,d=h?[]:void 0,g=[],w=[],m=[],D=0;D<l;D++)m[D]=0;var v,E,b;for(v=0,E=p.length;v<E;v++)m[p[v]]++;for(var N=0,x=0;x<l;x++)w.push(N),N+=m[x],m[x]=w[x];for(w.push(N),b=0;b<c;b++)for(var F=f[b],M=f[b+1],S=F;S<M;S++){var I=m[p[S]]++;g[I]=b,h&&(d[I]=re(h[S]))}return a.createSparseMatrix({values:d,index:g,ptr:w,size:[c,l],datatype:a._datatype})}}),tf="ctranspose",qg=["typed","transpose","conj"],kg=mt(tf,qg,i=>{var{typed:t,transpose:e,conj:r}=i;return t(tf,{any:function(s){return r(e(s))}})}),ef="mode",Ug=["typed","isNaN","isNumeric"],Wg=mt(ef,Ug,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(ef,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=da(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],h=0,p=0;p<s.length;p++){var f=s[p];if(r(f)&&e(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===h?c.push(f):l[f]>h&&(h=l[f],c=[f])}return c}});function bn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+mn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+mn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var rf="prod",jg=["typed","config","multiplyScalar","numeric"],Yg=mt(rf,jg,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(rf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return s(l)}});function s(a){var l;if(Yi(a,function(c){try{l=l===void 0?c:r(l,c)}catch(h){throw bn(h,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Zg="numeric",Gg=["number","?bignumber","?fraction"],Kg=mt(Zg,Gg,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):Bg,Fraction:r?a=>r(a):Tg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",h=arguments.length>2?arguments[2]:void 0;if(h!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var p=mn(l);if(!(p in n))throw new TypeError("Cannot convert "+l+' of type "'+p+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in s))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(s).join(", "));return c===p?l:s[c](l)}}),nf="divideScalar",Hg=["typed","numeric"],Xg=mt(nf,Hg,i=>{var{typed:t,numeric:e}=i;return t(nf,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),sf="pow",Jg=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Qg=mt(sf,Jg,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:l,fraction:c,Complex:h}=i;return t(sf,{"number, number":p,"Complex, Complex":function(w,m){return w.pow(m)},"BigNumber, BigNumber":function(w,m){return m.isInteger()||w>=0||e.predictable?w.pow(m):new h(w.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(w,m){var D=w.pow(m);if(D!=null)return D;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return p(w.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(w,m){return f(w,m.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(w,m){return d(w,m.toNumber())},"Unit, number | BigNumber":function(w,m){return w.pow(m)}});function p(g,w){if(e.predictable&&!de(w)&&g<0)try{var m=c(w),D=l(m);if((w===D||Math.abs((w-D)/w)<1e-14)&&m.d%2===1)return(m.n%2===0?1:-1)*Math.pow(-g,w)}catch{}return e.predictable&&(g<-1&&w===1/0||g>-1&&g<0&&w===-1/0)?NaN:de(w)||g>=0||e.predictable?Nc(g,w):g*g<1&&w===1/0||g*g>1&&w===-1/0?0:new h(g,0).pow(w,0)}function f(g,w){if(!de(w))throw new TypeError("For A^b, b must be an integer (value is "+w+")");var m=Fe(g);if(m.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+m.length+" dimensions)");if(m[0]!==m[1])throw new Error("For A^b, A must be square (size is "+m[0]+"x"+m[1]+")");if(w<0)try{return f(a(g),-w)}catch(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+w+")"):E}for(var D=r(m[0]).valueOf(),v=g;w>=1;)(w&1)===1&&(D=n(v,D)),w>>=1,v=n(v,v);return D}function d(g,w){return s(f(g.valueOf(),w))}}),of="dotDivide",Vg=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],tv=mt(of,Vg,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,l=Zm({typed:t,equalScalar:r}),c=di({typed:t}),h=ks({typed:t,DenseMatrix:s}),p=xa({typed:t,equalScalar:r}),f=pi({typed:t,DenseMatrix:s}),d=jn({typed:t,matrix:e,concat:a});return t(of,d({elop:n,SS:h,DS:c,SD:l,Ss:p,sS:f}))}),Us="compare",ev=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],rv=mt(Us,ev,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:l,concat:c}=i,h=di({typed:t}),p=kc({typed:t,equalScalar:r}),f=pi({typed:t,DenseMatrix:l}),d=jn({typed:t,matrix:n,concat:c}),g=zs({typed:t});return t(Us,nv({typed:t,config:e}),{"boolean, boolean":function(m,D){return m===D?0:m>D?1:-1},"BigNumber, BigNumber":function(m,D){return Ps(m,D,e.epsilon)?new s(0):new s(m.cmp(D))},"Fraction, Fraction":function(m,D){return new a(m.compare(D))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,d({SS:p,DS:h,Ss:f}))}),nv=mt(Us,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Us,{"number, number":function(n,s){return Wn(n,s,e.epsilon)?0:n>s?1:-1}})}),Ws="equal",iv=["typed","matrix","equalScalar","DenseMatrix","concat"],sv=mt(Ws,iv,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=di({typed:t}),l=ks({typed:t,DenseMatrix:n}),c=pi({typed:t,DenseMatrix:n}),h=jn({typed:t,matrix:e,concat:s});return t(Ws,ov({typed:t,equalScalar:r}),h({elop:r,SS:l,DS:a,Ss:c}))}),ov=mt(Ws,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Ws,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),js="smaller",av=["typed","config","matrix","DenseMatrix","concat"],uv=mt(js,av,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=di({typed:t}),l=ks({typed:t,DenseMatrix:n}),c=pi({typed:t,DenseMatrix:n}),h=jn({typed:t,matrix:r,concat:s}),p=zs({typed:t});return t(js,lv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f<d,"BigNumber, BigNumber":function(d,g){return d.lt(g)&&!Ps(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===-1,"Complex, Complex":function(d,g){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),lv=mt(js,["typed","config"],i=>{var{typed:t,config:e}=i;return t(js,{"number, number":function(n,s){return n<s&&!Wn(n,s,e.epsilon)}})}),Ys="larger",cv=["typed","config","matrix","DenseMatrix","concat"],fv=mt(Ys,cv,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=di({typed:t}),l=ks({typed:t,DenseMatrix:n}),c=pi({typed:t,DenseMatrix:n}),h=jn({typed:t,matrix:r,concat:s}),p=zs({typed:t});return t(Ys,hv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f>d,"BigNumber, BigNumber":function(d,g){return d.gt(g)&&!Ps(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),hv=mt(Ys,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ys,{"number, number":function(n,s){return n>s&&!Wn(n,s,e.epsilon)}})}),af="deepEqual",pv=["typed","equal"],dv=mt(af,pv,i=>{var{typed:t,equal:e}=i;return t(af,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],s[l]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),uf="partitionSelect",_v=["typed","isNumeric","isNaN","compare"],mv=mt(uf,_v,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(h,p)=>-n(h,p);return t(uf,{"Array | Matrix, number":function(p,f){return l(p,f,s)},"Array | Matrix, number, string":function(p,f,d){if(d==="asc")return l(p,f,s);if(d==="desc")return l(p,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(h,p,f){if(!de(p)||p<0)throw new Error("k must be a non-negative integer");if(fe(h)){var d=h.size();if(d.length>1)throw new Error("Only one dimensional matrices supported");return c(h.valueOf(),p,f)}if(Array.isArray(h))return c(h,p,f)}function c(h,p,f){if(p>=h.length)throw new Error("k out of bounds");for(var d=0;d<h.length;d++)if(e(h[d])&&r(h[d]))return h[d];for(var g=0,w=h.length-1;g<w;){for(var m=g,D=w,v=h[Math.floor(Math.random()*(w-g+1))+g];m<D;)if(f(h[m],v)>=0){var E=h[D];h[D]=h[m],h[m]=E,--D}else++m;f(h[m],v)>0&&--m,p<=m?w=m:g=m+1}return h[p]}}),lf="max",gv=["typed","config","numeric","larger"],vv=mt(lf,gv,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(lf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Ea(c,h.valueOf(),s)},"...":function(c){if($s(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(h){throw bn(h,"max",c)}}function a(l){var c;if(Yi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw bn(p,"max",h)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),cf="min",wv=["typed","config","numeric","smaller"],yv=mt(cf,wv,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(cf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Ea(c,h.valueOf(),s)},"...":function(c){if($s(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(h){throw bn(h,"min",c)}}function a(l){var c;if(Yi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw bn(p,"min",h)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),ff="add",Dv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],bv=mt(ff,Dv,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:l}=i,c=Uc({typed:t}),h=lg({typed:t,equalScalar:n}),p=Wc({typed:t,DenseMatrix:s}),f=jn({typed:t,matrix:e,concat:l});return t(ff,{"any, any":r,"any, any, ...any":t.referToSelf(d=>(g,w,m)=>{for(var D=d(g,w),v=0;v<m.length;v++)D=d(D,m[v]);return D})},f({elop:r,DS:c,SS:h,Ss:p}))}),hf="dot",Ev=["typed","addScalar","multiplyScalar","conj","size"],xv=mt(hf,Ev,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(hf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(p,f){var d=h(p),g=h(f),w,m;if(d.length===1)w=d[0];else if(d.length===2&&d[1]===1)w=d[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+d.join(", ")+")");if(g.length===1)m=g[0];else if(g.length===2&&g[1]===1)m=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(w!==m)throw new RangeError("Vectors must have equal length ("+w+" != "+m+")");if(w===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return w}function l(p,f){var d=a(p,f),g=fe(p)?p._data:p,w=fe(p)?p._datatype||p.getDataType():void 0,m=fe(f)?f._data:f,D=fe(f)?f._datatype||f.getDataType():void 0,v=h(p).length===2,E=h(f).length===2,b=e,N=r;if(w&&D&&w===D&&typeof w=="string"&&w!=="mixed"){var x=w;b=t.find(e,[x,x]),N=t.find(r,[x,x])}if(!v&&!E){for(var F=N(n(g[0]),m[0]),M=1;M<d;M++)F=b(F,N(n(g[M]),m[M]));return F}if(!v&&E){for(var S=N(n(g[0]),m[0][0]),I=1;I<d;I++)S=b(S,N(n(g[I]),m[I][0]));return S}if(v&&!E){for(var C=N(n(g[0][0]),m[0]),T=1;T<d;T++)C=b(C,N(n(g[T][0]),m[T]));return C}if(v&&E){for(var L=N(n(g[0][0]),m[0][0]),U=1;U<d;U++)L=b(L,N(n(g[U][0]),m[U][0]));return L}}function c(p,f){a(p,f);for(var d=p._index,g=p._values,w=f._index,m=f._values,D=0,v=e,E=r,b=0,N=0;b<d.length&&N<w.length;){var x=d[b],F=w[N];if(x<F){b++;continue}if(x>F){N++;continue}x===F&&(D=v(D,E(g[b],m[N])),b++,N++)}return D}function h(p){return fe(p)?p.size():s(p)}}),Av="trace",Cv=["typed","matrix","add"],Fv=mt(Av,Cv,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:s,DenseMatrix:n,any:re});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return re(c[0]);throw new RangeError("Matrix must be square (size: "+oe(l)+")");case 2:{var h=l[0],p=l[1];if(h===p){for(var f=0,d=0;d<h;d++)f=r(f,c[d][d]);return f}else throw new RangeError("Matrix must be square (size: "+oe(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(l)+")")}}function s(a){var l=a._values,c=a._index,h=a._ptr,p=a._size,f=p[0],d=p[1];if(f===d){var g=0;if(l.length>0)for(var w=0;w<d;w++)for(var m=h[w],D=h[w+1],v=m;v<D;v++){var E=c[v];if(E===w){g=r(g,l[v]);break}if(E>w)break}return g}throw new RangeError("Matrix must be square (size: "+oe(p)+")")}}),pf="det",Mv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Nv=mt(pf,Mv,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:l}=i;return t(pf,{any:function(p){return re(p)},"Array | Matrix":function(p){var f;switch(fe(p)?f=p.size():Array.isArray(p)?(p=e(p),f=p.size()):f=[],f.length){case 0:return re(p);case 1:if(f[0]===1)return re(p.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+oe(f)+")");case 2:{var d=f[0],g=f[1];if(d===g)return c(p.clone().valueOf(),d);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+oe(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(f)+")")}}});function c(h,p,f){if(p===1)return re(h[0][0]);if(p===2)return r(n(h[0][0],h[1][1]),n(h[1][0],h[0][1]));for(var d=!1,g=new Array(p).fill(0).map((M,S)=>S),w=0;w<p;w++){var m=g[w];if(a(h[m][w])){var D=void 0;for(D=w+1;D<p;D++)if(!a(h[g[D]][w])){m=g[D],g[D]=g[w],g[w]=m,d=!d;break}if(D===p)return h[m][w]}for(var v=h[m][w],E=w===0?1:h[g[w-1]][w-1],b=w+1;b<p;b++)for(var N=g[b],x=w+1;x<p;x++)h[N][x]=s(r(n(h[N][x],v),n(h[N][w],h[m][x])),E)}var F=h[g[p-1]][p-1];return d?l(F):F}}),df="inv",Sv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Bv=mt(df,Sv,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:l,identity:c,abs:h}=i;return t(df,{"Array | Matrix":function(d){var g=fe(d)?d.size():Fe(d);switch(g.length){case 1:if(g[0]===1)return fe(d)?e([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+oe(g)+")");case 2:{var w=g[0],m=g[1];if(w===m)return fe(d)?e(p(d.valueOf(),w,m),d.storage()):p(d,w,m);throw new RangeError("Matrix must be square (size: "+oe(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(g)+")")}},any:function(d){return r(1,d)}});function p(f,d,g){var w,m,D,v,E;if(d===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(d===2){var b=l(f);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(f[1][1],b),r(a(f[0][1]),b)],[r(a(f[1][0]),b),r(f[0][0],b)]]}else{var N=f.concat();for(w=0;w<d;w++)N[w]=N[w].concat();for(var x=c(d).valueOf(),F=0;F<g;F++){var M=h(N[F][F]),S=F;for(w=F+1;w<d;)h(N[w][F])>M&&(M=h(N[w][F]),S=w),w++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");w=S,w!==F&&(E=N[F],N[F]=N[w],N[w]=E,E=x[F],x[F]=x[w],x[w]=E);var I=N[F],C=x[F];for(w=0;w<d;w++){var T=N[w],L=x[w];if(w!==F){if(T[F]!==0){for(D=r(a(T[F]),I[F]),m=F;m<g;m++)T[m]=n(T[m],s(D,I[m]));for(m=0;m<g;m++)L[m]=n(L[m],s(D,C[m]))}}else{for(D=I[F],m=F;m<g;m++)T[m]=r(T[m],D);for(m=0;m<g;m++)L[m]=r(L[m],D)}}}return x}}}),_f="pinv",Tv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Ov=mt(_f,Tv,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:l,ctranspose:c,divideScalar:h,multiply:p,add:f,Complex:d}=i;return t(_f,{"Array | Matrix":function(b){var N=fe(b)?b.size():Fe(b);switch(N.length){case 1:return v(b)?c(b):N[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var x=N[0],F=N[1];if(x===F)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return fe(b)?e(g(b.valueOf(),x,F),b.storage()):g(b,x,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+oe(N)+")")}},any:function(b){return s(b,0)?re(b):h(1,b)}});function g(E,b,N){var{C:x,F}=m(E,b,N),M=p(r(p(c(x),x)),c(x)),S=p(c(F),r(p(F,c(F))));return p(S,M)}function w(E,b,N){for(var x=re(E),F=0,M=0;M<b;M++){if(N<=F)return x;for(var S=M;D(x[S][F]);)if(S++,b===S&&(S=M,F++,N===F))return x;[x[S],x[M]]=[x[M],x[S]];for(var I=x[M][F],C=0;C<N;C++)x[M][C]=a(x[M][C],I);for(var T=0;T<b;T++)if(T!==M){I=x[T][F];for(var L=0;L<N;L++)x[T][L]=f(x[T][L],p(-1,p(I,x[M][L])))}F++}return x}function m(E,b,N){var x=w(E,b,N),F=E.map((S,I)=>S.filter((C,T)=>T<b&&!D(l(x[T],x[T])))),M=x.filter((S,I)=>!D(l(x[I],x[I])));return{C:F,F:M}}function D(E){return s(f(E,d(1,1)),f(0,d(1,1)))}function v(E){return n(f(E,d(1,1)),f(p(E,0),d(1,1)))}}),Iv="divide",$v=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Lv=mt(Iv,$v,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,l=xa({typed:t,equalScalar:n}),c=Aa({typed:t});return t("divide",Il({"Array | Matrix, Array | Matrix":function(p,f){return r(p,a(f))},"DenseMatrix, any":function(p,f){return c(p,f,s,!1)},"SparseMatrix, any":function(p,f){return l(p,f,s,!1)},"Array, any":function(p,f){return c(e(p),f,s,!1).valueOf()},"any, Array | Matrix":function(p,f){return r(p,a(f))}},s.signatures))}),mf="sum",Rv=["typed","config","add","numeric"],Pv=mt(mf,Rv,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(mf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(c){if($s(c))throw new TypeError("Scalar values expected in function sum");return s(c)}});function s(l){var c;return Yi(l,function(h){try{c=c===void 0?h:r(c,h)}catch(p){throw bn(p,"sum",h)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var h=Ea(l,c,r);return h}catch(p){throw bn(p,"sum")}}}),gf="median",zv=["typed","add","divide","compare","partitionSelect"],qv=mt(gf,zv,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(h){try{h=da(h.valueOf());var p=h.length;if(p===0)throw new Error("Cannot calculate median of an empty array");if(p%2===0){for(var f=p/2-1,d=s(h,f+1),g=h[f],w=0;w<f;++w)n(h[w],g)>0&&(g=h[w]);return c(g,d)}else{var m=s(h,(p-1)/2);return l(m)}}catch(D){throw bn(D,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(p){return p}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(p,f){return r(e(p,f),2)}});return t(gf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(p,f){throw new Error("median(A, dim) is not yet supported")},"...":function(p){if($s(p))throw new TypeError("Scalar values expected in function median");return a(p)}})}),Zs=k_({config:ar}),Ca=Y_({}),Fa=H_({}),Ma=Q_({}),Kr=em({Matrix:Ma}),Mt=jd({BigNumber:Zs,Complex:Ca,DenseMatrix:Kr,Fraction:Fa}),kv=Om({typed:Mt}),Gs=$m({typed:Mt}),Uv=xm({BigNumber:Zs,typed:Mt}),vf=bg({typed:Mt}),En=pm({config:ar,typed:Mt}),Ks=im({typed:Mt}),Wv=um({typed:Mt}),Hs=dg({typed:Mt}),wf=Dm({typed:Mt}),Na=mm({Matrix:Ma,equalScalar:En,typed:Mt}),yf=Rm({typed:Mt}),Df=cm({typed:Mt}),Sa=Bm({typed:Mt}),bf=Fm({Fraction:Fa,typed:Mt}),Ef=om({typed:Mt}),Me=Nm({DenseMatrix:Kr,Matrix:Ma,SparseMatrix:Na,typed:Mt}),xf=Wg({isNaN:Df,isNumeric:Ef,typed:Mt}),Zi=Kg({bignumber:Uv,fraction:bf,number:wf}),jv=Yg({config:ar,multiplyScalar:Hs,numeric:Zi,typed:Mt}),Yv=$g({isInteger:Ks,matrix:Me,typed:Mt}),Af=Rg({matrix:Me,config:ar,typed:Mt}),Cf=zg({matrix:Me,typed:Mt}),Yn=xg({isInteger:Ks,matrix:Me,typed:Mt}),Zv=Cg({prod:jv,size:Af,typed:Mt}),Gv=kg({conj:vf,transpose:Cf,typed:Mt}),Gi=Xg({numeric:Zi,typed:Mt}),Kv=tv({DenseMatrix:Kr,concat:Yn,divideScalar:Gi,equalScalar:En,matrix:Me,typed:Mt}),Ff=sv({DenseMatrix:Kr,concat:Yn,equalScalar:En,matrix:Me,typed:Mt}),Mf=Mg({BigNumber:Zs,DenseMatrix:Kr,SparseMatrix:Na,config:ar,matrix:Me,typed:Mt}),Hv=Sg({matrix:Me,multiplyScalar:Hs,typed:Mt}),Xv=uv({DenseMatrix:Kr,concat:Yn,config:ar,matrix:Me,typed:Mt}),Jv=vg({DenseMatrix:Kr,concat:Yn,equalScalar:En,matrix:Me,subtractScalar:yf,typed:Mt,unaryMinus:Sa}),Ki=bv({DenseMatrix:Kr,SparseMatrix:Na,addScalar:Gs,concat:Yn,equalScalar:En,matrix:Me,typed:Mt}),Nf=rv({BigNumber:Zs,DenseMatrix:Kr,Fraction:Fa,concat:Yn,config:ar,equalScalar:En,matrix:Me,typed:Mt}),Qv=dv({equal:Ff,typed:Mt}),Sf=xv({addScalar:Gs,conj:vf,multiplyScalar:Hs,size:Af,typed:Mt}),Vv=fv({DenseMatrix:Kr,concat:Yn,config:ar,matrix:Me,typed:Mt}),Ba=yv({config:ar,numeric:Zi,smaller:Xv,typed:Mt}),_i=mg({addScalar:Gs,dot:Sf,equalScalar:En,matrix:Me,multiplyScalar:Hs,typed:Mt}),t1=mv({compare:Nf,isNaN:Df,isNumeric:Ef,typed:Mt}),e1=Pv({add:Ki,config:ar,numeric:Zi,typed:Mt}),r1=Fv({add:Ki,matrix:Me,typed:Mt}),Bf=Nv({divideScalar:Gi,isZero:Wv,matrix:Me,multiply:_i,subtractScalar:yf,typed:Mt,unaryMinus:Sa}),n1=vv({config:ar,larger:Vv,numeric:Zi,typed:Mt}),Xs=Bv({abs:kv,addScalar:Gs,det:Bf,divideScalar:Gi,identity:Mf,matrix:Me,multiply:_i,typed:Mt,unaryMinus:Sa}),i1=Ov({Complex:Ca,add:Ki,ctranspose:Gv,deepEqual:Qv,divideScalar:Gi,dot:Sf,dotDivide:Kv,equal:Ff,inv:Xs,matrix:Me,multiply:_i,typed:Mt}),s1=Qg({Complex:Ca,config:ar,fraction:bf,identity:Mf,inv:Xs,matrix:Me,multiply:_i,number:wf,typed:Mt}),o1=Lv({divideScalar:Gi,equalScalar:En,inv:Xs,matrix:Me,multiply:_i,typed:Mt}),Tf=qv({add:Ki,compare:Nf,divide:o1,partitionSelect:t1,typed:Mt});class a1{constructor(t,e,r){z(this,"_cacheData");z(this,"_variables");z(this,"_math");z(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);s&&(c=Math.floor(c));const h=e/n;let p=0,f=0;for(let d=0;d<=e-1;d++){const g=Math.exp(-1*Math.pow(d-c,2)/(2*Math.pow(h,2)));p+=g,f+=l[l.length-1-(e-d-1)]*g}return f/p}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=e1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`sma_${r}`]=n;const{sum:s}=this._cacheData[`rma_${r}`]||{},a=1/e,l=s===void 0?this.sma({source:t,length:e},r):a*t+(1-a)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:l}),l}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:a,low:l}=this._variables,c=r===void 0?s-l:Math.max(Math.max(s-l,Math.abs(s-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let l=0;for(let c=0;c<e;c++){const h=this._sum(s[s.length-1-c],-(a||0));l+=h*h}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const l=r*a;return[s,s+l,s-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const l=r*a;return(s+l-(s-l))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||s===void 0)return;let c=0,h=0,p=0;for(let d=0;d<r;d++){const[g,w]=s[s.length-1-d],m=g-a,D=w-l;c+=m*D,h+=m*m,p+=D*D}return isNaN(h)||isNaN(c)||isNaN(p)?void 0:c/Math.sqrt(h*p)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];s+=Math.abs(c-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:a,close:l,PDMS:c,NDMS:h,TRS:p,ADX:f,count:d=0}=this._cacheData[n]||{},{low:g,high:w,close:m}=this._variables;if(s===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:w,close:m,PDMS:c,NDMS:h,TRS:w-g,count:1},[void 0,void 0,void 0];let D=w-a,v=s-g;D=D>v&&D>0?D:0,v=v>D&&v>0?v:0,D===v&&(D=v=0);const E=Math.max(w-g,Math.abs(w-l),Math.abs(g-l));if(d<t)return this._cacheDataHandle(n,{low:g,high:w,close:m,PDMS:(c||0)+D,NDMS:(h||0)+v,TRS:(p||0)+E,count:d+1}),[void 0,void 0,void 0];{const b=c-c/t+D,N=h-h/t+v,x=p-p/t+E,F=b/x*100,M=N/x*100,S=Math.abs((F-M)/(F+M))*100;let I=S,C=[F,M,void 0];if(d+1-t<e){const T=d+1-t;I=((f||0)*(T-1)+S)/T}else I=(f*(e-1)+S)/e,C=[F,M,I];return this._cacheDataHandle(n,{low:g,high:w,close:m,PDMS:b,NDMS:N,TRS:x,ADX:I,count:d+1}),C}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(s>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const a=s.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const a=s.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highest_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.max(...l.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((h,p,f,d)=>p>=d[h]?f:h,0)-e+1}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;s+=c,a+=n[n.length-1-l]*c}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${s}`);return[a,a+f*r,a-f*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${s}`);return(a+f*r-(a-f*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(g=>g!==void 0);let l=0,c=0,h=0,p=0;for(const[g,w]of a.entries())l+=g,c+=w,h+=g*w,p+=g*g;const f=(e*h-l*c)/(e*p-l*l);return(c-f*l)/e+f*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.min(...l.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((h,p,f,d)=>p<=d[h]?f:h,0)-e+1}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),l=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,h=this.ema({source:c,length:n},`macd_${s}`);if(h===void 0)return[c,h,void 0];const p=c-h;return[c,h,p]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Tf(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Ba(xf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e||t===void 0||isNaN(t))return;let a=s.length-e-1,l;for(;l===void 0&&a>=0;)l=s[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[h,p]of a.entries()){const f=a[h-1];if(r<(h+.5)/l)return f===void 0||p===void 0?void 0:f+(p-f)*(r-(h-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<s.length;c++)s[c]!==void 0&&(s[c]<a||s[c]===a&&c<e)&&l++;return l/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Xt;let{close:a,open:l,low:c,high:h}=this._variables;const p=`pivot_point_levels_${n}`,{close:f,low:d,high:g,open:w,result:m}=this._cacheData[p]||{};if(!e&&(g&&d&&(h=Math.max(g,h),c=Math.min(d,c)),this._cacheDataHandle(p,{close:a,open:l,low:c,high:h,result:m}),!r))return s._value=m||[],s;const D={close:a,open:l,low:c,high:h};e===!0&&!r&&(a=f,l=w,c=d,h=g);const v=this._getPivotPointLevels(h,c,a,l,r,t);return this._cacheDataHandle(p,{...D,result:v}),s._value=v,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Un.traditional:return this._traditional(t,e,r);case Un.fibonacci:return this._fibonacci(t,e,r);case Un.woodie:return s?[]:this._woodie(t,e);case Un.classic:return this._classic(t,e,r);case Un.dm:return this._DM(t,e,r,n);case Un.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),h=n*4+(t-4*e),p=n*2-t,f=n-(t-e),d=n*2-(2*t-e),g=n*3-(3*t-e),w=n*4-(4*t-e);return[n,s,p,a,f,l,d,c,g,h,w]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),h=n+(t-e),p=n-(t-e);return[n,s,a,l,c,h,p]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=t+2*(n-e),p=e-2*(t-n),f=h+(t-e),d=p-(t-e);return[n,s,a,l,c,h,p,f,d]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=n+2*(t-e),p=n-2*(t-e),f=n+3*(t-e),d=n-3*(t-e);return[n,s,a,l,c,h,p,f,d]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,l=s/2-e,c=s/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,h=r+1.1*(t-e)/4,p=r-1.1*(t-e)/4,f=r+1.1*(t-e)/2,d=r-1.1*(t-e)/2,g=t/e*r,w=r-(g-r);return[n,s,a,l,c,h,p,f,d,g,w]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`);if(!n)return;const s=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...s),l=Math.min(...s);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:s,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:a,high:l,preLow:c,preHigh:h,data:p={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:d,acceleration:g,isBelow:w}=p,m=!1;const{close:D,low:v,high:E,bar_index:b}=this._variables;return b===1&&(D>s?(w=!0,d=E,f=a):(w=!1,d=v,f=l),m=!0,g=t),f=f+g*(d-f),w?f>v&&(m=!0,w=!1,f=Math.max(E,d||0),d=v,g=t):f<E&&(m=!0,w=!0,f=Math.min(v,d||0),d=E,g=t),m||(w?E>(d||0)&&(d=E,g=Math.min((g||0)+e,r)):v<(d||0)&&(d=v,g=Math.min((g||0)+e,r))),w?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,h))),this._cacheDataHandle(`sar_${n}`,{high:E,close:D,low:v,preLow:a,preHigh:l,data:Object.assign(p,{result:f,maxMin:d,acceleration:g,isBelow:w})}),f}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},s),l=this.highest({source:e,length:n},s);if(!(a===void 0||l===void 0))return 100*(this._variables.close-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:s}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:h,atr:p,close:f}=this._cacheData[a]||{},d=this.atr({length:e},r);if(d===void 0)return this._cacheDataHandle(a,{close:s}),[void 0,void 0];let g=n+t*d,w=n-t*d;const m=l||0,D=c||0;w=w>D||f<D?w:D,g=g<m||f>m?g:m;let v;p===void 0?v=1:h===m?v=s>g?-1:1:v=s<w?1:-1;const E=v===-1?w:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:w,superTrend:E,atr:d,close:s}),[E,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),l=this.ema({source:s,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),h=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/h}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`mode_${n}`);if(!a||s===void 0)return;const l=a.filter(h=>h!==void 0&&!isNaN(h)).slice(-e);if(l.length<e)return;const c=l.reduce((h,p)=>h+Math.pow(p-s,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:h,sumS:p=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=p=0,h=!0),!h)return r!==void 0?[]:void 0;const f=t*s+a,d=s+l,g=f/d;return c++,r!==void 0?(p=s*Math.pow(t,2)+p,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h,sumS:p}),this._computeBands(p,d,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h}),g)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:l}=n,c=t[s];if(c!==void 0){if(a!==void 0&&c<a){t.splice(s,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:s,currentVal:c}}}}return t}_cacheDataList(t,e,r){const n=this._cacheData[r]||[];n[this._variables.bar_index]=t,this._cacheData[r]=n;const s=n.filter(()=>!0);if(!(s.length<e))return s}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}const Of={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeRepeatErr:"type '$name' is already defined.",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an undefined object. The object is 'na'.",buidinAssignErr:"Cannot assign a new value to the built-in variable '$name'.",buidinVarErr:"Cannot shadow the built-in variable `$name` because it has already been used as a built-in.",useNaErr:"Cannot use an `na` value of an unspecified type in the `$name` function.",libraryTitleErr:"Invalid argument 'title' in 'library' call. It cannot contain spaces, special characters or begin with a digit.",exportFuncArgErr:"All exported functions args should be typified",indiRunErr:"An indicator must contain at least one of the following: any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, `alertcondition()`, or any drawing (line, label, box, table, polyline).",libraryExportErr:"A library must contain at least one exported function, method, or type.",strategyRunErr:"A strategy must contain at least one of the following: any `strategy.*()` function that creates orders, any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, or any drawing (line, label, box, table, polyline).",exportUseErr:"Only libraries can contain exported $type.",funcRepeatErr:"The '$name' function has overloads with the same parameters. The type of parameters must be different in overloaded versions of functions."};Wr.SERIES,Wr.SIMPLE,Wr.INPUT,Wr.CONST,Wr.INT,Wr.FLOAT,Wr.BOOL,Wr.COLOR,Wr.STRING;const u1=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"];class l1{constructor(t,e,r){z(this,"_cacheData");z(this,"_variables");z(this,"_errorListener");z(this,"_historyInputs");z(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){for(const e of t){const r=e.id;this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${e.index}`,{modifyDefval:e.sourceTypeName||e.defval})}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,Qe.INT)}bool(t,e){return this._cacheHandle(t,e,Qe.BOOL)}color(t,e){return this._cacheHandle(t,e,Qe.COLOR)}time(t,e){return this._cacheHandle(t,e,Qe.TIME)}float(t,e){return this._cacheHandle(t,e,Qe.FLOAT)}price(t,e){return this._cacheHandle(t,e,Qe.PRICE)}source(t,e){return this._cacheHandle(t,e,Qe.SOURCE)}string(t,e){return this._cacheHandle(t,e,Qe.STRING)}symbol(t,e){return this._cacheHandle(t,e,Qe.SYMBOL)}session(t,e){return this._cacheHandle(t,e,Qe.SESSION)}text_area(t,e){return this._cacheHandle(t,e,Qe.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,Qe.TIMEFRAME)}_cacheHandle(t,e,r){const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(Of.inputDefvalErr,e,Ee.Error),s)s.isModify?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t);else{const{defval:a,display:l}=t;this._displayVerify(e,l),t={inputType:r,...t},this._cacheData[n]=t,this._judgeHistoryInputs(t),(r||t.inputType)===Qe.SOURCE?this._cacheData[n].options=u1:t.options&&!t.options.includes(a)&&this._errorListener.addError(`input's defval should be in options, but '${a}' is not in [${t.options.toString()}]`,e,Ee.Error)}return this._cacheData[n].defval}_judgeHistoryInputs(t){const{defval:e,sourceTypeName:r,index:n}=t;let s=r||e;const a=`in_${n}`,l=this._historyInputs[a];if(!l)self.workerStorage.setValue(this._name,a,{defval:s});else{const{defval:c,modifyDefval:h}=l;c===s?s=h||s:self.workerStorage.setValue(this._name,a,{defval:s})}r?t.sourceTypeName=s:t.defval=s}_displayVerify(t,e){!e||!e.length||e.includes(sr.dataWindow)||e.includes(sr.statusLine)||this._errorListener.addError("Invalid argument 'display' in 'input' call. Possible values: [display.none, display.data_window, display.status_line, display.all]",t,Ee.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e.sort((r,n)=>(r.index||0)-(n.index||0))}}class c1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const{r,g:n,b:s}=this._parseColor(t||"");return`rgba(${Math.round(r)}, ${Math.round(n)}, ${Math.round(s)}, ${(100-e)/100})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){if(_t(t)||_t(e)||_t(r))return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:h,b:p,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:d,g,b:w,a:m}=this._parseColor(s||"rgba(0,0,0,0)"),D=c+l*(d-c),v=h+l*(g-h),E=p+l*(w-p),b=f+l*(m-f);return`rgba(${Math.round(D)}, ${Math.round(v)}, ${Math.round(E)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=(255-parseInt(a,16))/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var zt={};const f1=Object.prototype.toString;function Hi(i){const t=f1.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var h1=Object.freeze({__proto__:null,isAnyArray:Hi}),p1=be(h1);function d1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Hi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]>a&&(a=i[l]);return a}function _1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Hi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]<a&&(a=i[l]);return a}function m1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Hi(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Hi(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=_1(i),n=d1(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var h=(c-a)/(n-r),p=0;p<i.length;p++)e[p]=(i[p]-r)*h+a;return e}var g1=Object.freeze({__proto__:null,default:m1}),v1=be(g1);Object.defineProperty(zt,"__esModule",{value:!0});var tr=p1,If=v1;const Js=" ".repeat(2),$f=" ".repeat(4);function w1(){return Lf(this)}function Lf(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
|
55
55
|
${Js}[
|
56
56
|
${$f}${y1(i,e,r,n,s)}
|
57
57
|
${Js}]
|
@@ -63,4 +63,4 @@ ${$f}`)}function D1(i,t,e){return(i>=0&&e?` ${Rf(i,t-1)}`:Rf(i,t)).padEnd(t)}fun
|
|
63
63
|
* @license
|
64
64
|
* Copyright 2019 Google LLC
|
65
65
|
* SPDX-License-Identifier: Apache-2.0
|
66
|
-
*/const Vf=Symbol("Comlink.proxy"),uy=Symbol("Comlink.endpoint"),ly=Symbol("Comlink.releaseProxy"),za=Symbol("Comlink.finalizer"),oo=Symbol("Comlink.thrown"),th=i=>typeof i=="object"&&i!==null||typeof i=="function",cy={canHandle:i=>th(i)&&i[Vf],serialize(i){const{port1:t,port2:e}=new MessageChannel;return qa(i,t),[e,[e]]},deserialize(i){return i.start(),dy(i)}},fy={canHandle:i=>th(i)&&oo in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},eh=new Map([["proxy",cy],["throw",fy]]);function hy(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function qa(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!hy(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Kn);let h;try{const p=l.slice(0,-1).reduce((d,g)=>d[g],i),f=l.reduce((d,g)=>d[g],i);switch(a){case"GET":h=f;break;case"SET":p[l.slice(-1)[0]]=Kn(n.data.value),h=!0;break;case"APPLY":h=f.apply(p,c);break;case"CONSTRUCT":{const d=new f(...c);h=wy(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;qa(i,g),h=vy(d,[d])}break;case"RELEASE":h=void 0;break;default:return}}catch(p){h={value:p,[oo]:0}}Promise.resolve(h).catch(p=>({value:p,[oo]:0})).then(p=>{const[f,d]=co(p);t.postMessage(Object.assign(Object.assign({},f),{id:s}),d),a==="RELEASE"&&(t.removeEventListener("message",r),rh(t),za in i&&typeof i[za]=="function"&&i[za]())}).catch(p=>{const[f,d]=co({value:new TypeError("Unserializable return value"),[oo]:0});t.postMessage(Object.assign(Object.assign({},f),{id:s}),d)})}),t.start&&t.start()}function py(i){return i.constructor.name==="MessagePort"}function rh(i){py(i)&&i.close()}function dy(i,t){return ka(i,[],t)}function ao(i){if(i)throw new Error("Proxy has been released and is not useable")}function nh(i){return bi(i,{type:"RELEASE"}).then(()=>{rh(i)})}const uo=new WeakMap,lo="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(uo.get(i)||0)-1;uo.set(i,t),t===0&&nh(i)});function _y(i,t){const e=(uo.get(t)||0)+1;uo.set(t,e),lo&&lo.register(i,t,i)}function my(i){lo&&lo.unregister(i)}function ka(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(ao(r),a===ly)return()=>{my(n),nh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=bi(i,{type:"GET",path:t.map(c=>c.toString())}).then(Kn);return l.then.bind(l)}return ka(i,[...t,a])},set(s,a,l){ao(r);const[c,h]=co(l);return bi(i,{type:"SET",path:[...t,a].map(p=>p.toString()),value:c},h).then(Kn)},apply(s,a,l){ao(r);const c=t[t.length-1];if(c===uy)return bi(i,{type:"ENDPOINT"}).then(Kn);if(c==="bind")return ka(i,t.slice(0,-1));const[h,p]=ih(l);return bi(i,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:h},p).then(Kn)},construct(s,a){ao(r);const[l,c]=ih(a);return bi(i,{type:"CONSTRUCT",path:t.map(h=>h.toString()),argumentList:l},c).then(Kn)}});return _y(n,i),n}function gy(i){return Array.prototype.concat.apply([],i)}function ih(i){const t=i.map(co);return[t.map(e=>e[0]),gy(t.map(e=>e[1]))]}const sh=new WeakMap;function vy(i,t){return sh.set(i,t),i}function wy(i){return Object.assign(i,{[Vf]:!0})}function co(i){for(const[t,e]of eh)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},sh.get(i)||[]]}function Kn(i){switch(i.type){case"HANDLER":return eh.get(i.name).deserialize(i.value);case"RAW":return i.value}}function bi(i,t,e){return new Promise(r=>{const n=yy();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function yy(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class Dy{constructor(){z(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function by(i,t,e){const{data:r,isPreParser:n,id:s="default",syminfo:a,interval:l,inputs:c}=t;self.workerStorage||(self.workerStorage=new Dy);let{builtInGather:h,buildinConstants:p,buildInFunctions:f,tradingvueFunc:d}=self.workerStorage.get(s)||{};if(e&&(h=new ty,p=new Lw,f=new ay((a==null?void 0:a.mintick)||1e-4,h,s),d=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:h,buildinConstants:p,buildInFunctions:f,tradingvueFunc:d})),n)d(h,p,f);else if(r&&r.length){const w=r.length-1;h.updateOptions({interval:l}),f.updateOptions({inputs:c});for(const[m,D]of r.entries()){const{barindex:v}=D;h.updateData(Object.assign(D,{barIndex:v||m,lastBarIndex:r[w].bar_index||w,lastBarTime:r[w].time})),f.update({barIndex:v||m}),d(h,p,f),f.endExecution();const E=f.errors;if(E.length&&E.some(b=>b.type===Ee.Error))return{status:1,errors:E}}}const g=f.errors;return g.length&&g.some(w=>w.type===Ee.Error)?{status:1,errors:g}:{status:0,options:{...
|
66
|
+
*/const Vf=Symbol("Comlink.proxy"),uy=Symbol("Comlink.endpoint"),ly=Symbol("Comlink.releaseProxy"),za=Symbol("Comlink.finalizer"),oo=Symbol("Comlink.thrown"),th=i=>typeof i=="object"&&i!==null||typeof i=="function",cy={canHandle:i=>th(i)&&i[Vf],serialize(i){const{port1:t,port2:e}=new MessageChannel;return qa(i,t),[e,[e]]},deserialize(i){return i.start(),dy(i)}},fy={canHandle:i=>th(i)&&oo in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},eh=new Map([["proxy",cy],["throw",fy]]);function hy(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function qa(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!hy(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Kn);let h;try{const p=l.slice(0,-1).reduce((d,g)=>d[g],i),f=l.reduce((d,g)=>d[g],i);switch(a){case"GET":h=f;break;case"SET":p[l.slice(-1)[0]]=Kn(n.data.value),h=!0;break;case"APPLY":h=f.apply(p,c);break;case"CONSTRUCT":{const d=new f(...c);h=wy(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;qa(i,g),h=vy(d,[d])}break;case"RELEASE":h=void 0;break;default:return}}catch(p){h={value:p,[oo]:0}}Promise.resolve(h).catch(p=>({value:p,[oo]:0})).then(p=>{const[f,d]=co(p);t.postMessage(Object.assign(Object.assign({},f),{id:s}),d),a==="RELEASE"&&(t.removeEventListener("message",r),rh(t),za in i&&typeof i[za]=="function"&&i[za]())}).catch(p=>{const[f,d]=co({value:new TypeError("Unserializable return value"),[oo]:0});t.postMessage(Object.assign(Object.assign({},f),{id:s}),d)})}),t.start&&t.start()}function py(i){return i.constructor.name==="MessagePort"}function rh(i){py(i)&&i.close()}function dy(i,t){return ka(i,[],t)}function ao(i){if(i)throw new Error("Proxy has been released and is not useable")}function nh(i){return bi(i,{type:"RELEASE"}).then(()=>{rh(i)})}const uo=new WeakMap,lo="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(uo.get(i)||0)-1;uo.set(i,t),t===0&&nh(i)});function _y(i,t){const e=(uo.get(t)||0)+1;uo.set(t,e),lo&&lo.register(i,t,i)}function my(i){lo&&lo.unregister(i)}function ka(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(ao(r),a===ly)return()=>{my(n),nh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=bi(i,{type:"GET",path:t.map(c=>c.toString())}).then(Kn);return l.then.bind(l)}return ka(i,[...t,a])},set(s,a,l){ao(r);const[c,h]=co(l);return bi(i,{type:"SET",path:[...t,a].map(p=>p.toString()),value:c},h).then(Kn)},apply(s,a,l){ao(r);const c=t[t.length-1];if(c===uy)return bi(i,{type:"ENDPOINT"}).then(Kn);if(c==="bind")return ka(i,t.slice(0,-1));const[h,p]=ih(l);return bi(i,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:h},p).then(Kn)},construct(s,a){ao(r);const[l,c]=ih(a);return bi(i,{type:"CONSTRUCT",path:t.map(h=>h.toString()),argumentList:l},c).then(Kn)}});return _y(n,i),n}function gy(i){return Array.prototype.concat.apply([],i)}function ih(i){const t=i.map(co);return[t.map(e=>e[0]),gy(t.map(e=>e[1]))]}const sh=new WeakMap;function vy(i,t){return sh.set(i,t),i}function wy(i){return Object.assign(i,{[Vf]:!0})}function co(i){for(const[t,e]of eh)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},sh.get(i)||[]]}function Kn(i){switch(i.type){case"HANDLER":return eh.get(i.name).deserialize(i.value);case"RAW":return i.value}}function bi(i,t,e){return new Promise(r=>{const n=yy();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function yy(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class Dy{constructor(){z(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function by(i,t,e){const{data:r,isPreParser:n,id:s="default",syminfo:a,interval:l,inputs:c}=t;self.workerStorage||(self.workerStorage=new Dy);let{builtInGather:h,buildinConstants:p,buildInFunctions:f,tradingvueFunc:d}=self.workerStorage.get(s)||{};if(e&&(h=new ty,p=new Lw,f=new ay((a==null?void 0:a.mintick)||1e-4,h,s),d=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:h,buildinConstants:p,buildInFunctions:f,tradingvueFunc:d})),n)d(h,p,f);else if(r&&r.length){const w=r.length-1;h.updateOptions({interval:l}),f.updateOptions({inputs:c});for(const[m,D]of r.entries()){const{barindex:v}=D;h.updateData(Object.assign(D,{barIndex:v||m,lastBarIndex:r[w].bar_index||w,lastBarTime:r[w].time})),f.update({barIndex:v||m}),d(h,p,f),f.endExecution();const E=f.errors;if(E.length&&E.some(b=>b.type===Ee.Error))return{status:1,errors:E}}}const g=f.errors;return g.length&&g.some(w=>w.type===Ee.Error)?{status:1,errors:g}:{status:0,options:{...f.options,id:s}}}function Ey(i){self==null||self.workerStorage.delete(i),self==null||self.workerStorage.delete(`inputs_${i}`)}qa({runScript:by,removeScript:Ey})})();
|
@@ -25,7 +25,6 @@ declare class Input {
|
|
25
25
|
private _cacheData;
|
26
26
|
private _variables;
|
27
27
|
private _errorListener;
|
28
|
-
private _count;
|
29
28
|
private _historyInputs;
|
30
29
|
private _name;
|
31
30
|
constructor(variables: BuiltInVariables, errorListener: TccErrorListener, id: string);
|
@@ -47,6 +46,5 @@ declare class Input {
|
|
47
46
|
private _judgeHistoryInputs;
|
48
47
|
private _displayVerify;
|
49
48
|
getInputs(): IInputArgs[];
|
50
|
-
private _getGroups;
|
51
49
|
}
|
52
50
|
export default Input;
|
@@ -9,6 +9,7 @@ export default class ParseToJs {
|
|
9
9
|
private _varlist;
|
10
10
|
private _memberIndexList;
|
11
11
|
private _blockCount;
|
12
|
+
private _inputCount;
|
12
13
|
constructor(prefix: string);
|
13
14
|
preParser(values: IKeyObjectValue[]): string | undefined;
|
14
15
|
parser(values: IKeyObjectValue[]): string | undefined;
|