@guihz/trading-vue-editor-tes 0.0.120 → 0.0.121

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,7 +51,7 @@ Example:
51
51
  * Dual licensed under the MIT or GPL Version 2 licenses.
52
52
  **/(function(s,e){(function(t){var r=2e3,n={s:1,n:0,d:1};function i(m,w){if(isNaN(m=parseInt(m,10)))throw _();return m*w}function a(m,w){if(w===0)throw x();var D=Object.create(v.prototype);D.s=m<0?-1:1,m=m<0?-m:m;var C=p(m,w);return D.n=m/C,D.d=w/C,D}function u(m){for(var w={},D=m,C=2,b=4;b<=D;){for(;D%C===0;)D/=C,w[C]=(w[C]||0)+1;b+=1+2*C++}return D!==m?D>1&&(w[D]=(w[D]||0)+1):w[m]=(w[m]||0)+1,w}var f=function(m,w){var D=0,C=1,b=1,F=0,B=0,M=0,O=1,A=1,N=0,I=1,R=1,k=1,z=1e7,L;if(m!=null)if(w!==void 0){if(D=m,C=w,b=D*C,D%1!==0||C%1!==0)throw y()}else switch(typeof m){case"object":{if("d"in m&&"n"in m)D=m.n,C=m.d,"s"in m&&(D*=m.s);else if(0 in m)D=m[0],1 in m&&(C=m[1]);else throw _();b=D*C;break}case"number":{if(m<0&&(b=m,m=-m),m%1===0)D=m;else if(m>0){for(m>=1&&(A=Math.pow(10,Math.floor(1+Math.log(m)/Math.LN10)),m/=A);I<=z&&k<=z;)if(L=(N+R)/(I+k),m===L){I+k<=z?(D=N+R,C=I+k):k>I?(D=R,C=k):(D=N,C=I);break}else m>L?(N+=R,I+=k):(R+=N,k+=I),I>z?(D=R,C=k):(D=N,C=I);D*=A}else(isNaN(m)||isNaN(w))&&(C=D=NaN);break}case"string":{if(I=m.match(/\d+|./g),I===null)throw _();if(I[N]==="-"?(b=-1,N++):I[N]==="+"&&N++,I.length===N+1?B=i(I[N++],b):I[N+1]==="."||I[N]==="."?(I[N]!=="."&&(F=i(I[N++],b)),N++,(N+1===I.length||I[N+1]==="("&&I[N+3]===")"||I[N+1]==="'"&&I[N+3]==="'")&&(B=i(I[N],b),O=Math.pow(10,I[N].length),N++),(I[N]==="("&&I[N+2]===")"||I[N]==="'"&&I[N+2]==="'")&&(M=i(I[N+1],b),A=Math.pow(10,I[N+1].length)-1,N+=3)):I[N+1]==="/"||I[N+1]===":"?(B=i(I[N],b),O=i(I[N+2],1),N+=3):I[N+3]==="/"&&I[N+1]===" "&&(F=i(I[N],b),B=i(I[N+2],b),O=i(I[N+4],1),N+=5),I.length<=N){C=O*A,b=D=M+C*F+A*B;break}}default:throw _()}if(C===0)throw x();n.s=b<0?-1:1,n.n=Math.abs(D),n.d=Math.abs(C)};function c(m,w,D){for(var C=1;w>0;m=m*m%D,w>>=1)w&1&&(C=C*m%D);return C}function h(m,w){for(;w%2===0;w/=2);for(;w%5===0;w/=5);if(w===1)return 0;for(var D=10%w,C=1;D!==1;C++)if(D=D*10%w,C>r)return 0;return C}function d(m,w,D){for(var C=1,b=c(10,D,w),F=0;F<300;F++){if(C===b)return F;C=C*10%w,b=b*10%w}return 0}function p(m,w){if(!m)return w;if(!w)return m;for(;;){if(m%=w,!m)return w;if(w%=m,!w)return m}}function v(m,w){if(f(m,w),this instanceof v)m=p(n.d,n.n),this.s=n.s,this.n=n.n/m,this.d=n.d/m;else return a(n.s*n.n,n.d)}var x=function(){return new Error("Division by Zero")},_=function(){return new Error("Invalid argument")},y=function(){return new Error("Parameters must be integer")};v.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(m,w){return f(m,w),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(m,w){return f(m,w),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(m,w){return f(m,w),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(m,w){return f(m,w),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(m,w){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(m===void 0)return a(this.s*this.n%this.d,1);if(f(m,w),n.n===0&&this.d===0)throw x();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(m,w){return f(m,w),a(p(n.n,this.n)*p(n.d,this.d),n.d*this.d)},lcm:function(m,w){return f(m,w),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,p(n.n,this.n)*p(n.d,this.d))},ceil:function(m){return m=Math.pow(10,m||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):a(Math.ceil(m*this.s*this.n/this.d),m)},floor:function(m){return m=Math.pow(10,m||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):a(Math.floor(m*this.s*this.n/this.d),m)},round:function(m){return m=Math.pow(10,m||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):a(Math.round(m*this.s*this.n/this.d),m)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(m,w){if(f(m,w),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 D=u(this.n),C=u(this.d),b=1,F=1;for(var B in D)if(B!=="1"){if(B==="0"){b=0;break}if(D[B]*=n.n,D[B]%n.d===0)D[B]/=n.d;else return null;b*=Math.pow(B,D[B])}for(var B in C)if(B!=="1"){if(C[B]*=n.n,C[B]%n.d===0)C[B]/=n.d;else return null;F*=Math.pow(B,C[B])}return n.s<0?a(F,b):a(b,F)},equals:function(m,w){return f(m,w),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(m,w){f(m,w);var D=this.s*this.n*n.d-n.s*n.n*this.d;return(0<D)-(D<0)},simplify:function(m){if(isNaN(this.n)||isNaN(this.d))return this;m=m||.001;for(var w=this.abs(),D=w.toContinued(),C=1;C<D.length;C++){for(var b=a(D[C-1],1),F=C-2;F>=0;F--)b=b.inverse().add(D[F]);if(Math.abs(b.sub(w).valueOf())<m)return b.mul(this.s)}return this},divisible:function(m,w){return f(m,w),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(m){var w,D="",C=this.n,b=this.d;return this.s<0&&(D+="-"),b===1?D+=C:(m&&(w=Math.floor(C/b))>0&&(D+=w,D+=" ",C%=b),D+=C,D+="/",D+=b),D},toLatex:function(m){var w,D="",C=this.n,b=this.d;return this.s<0&&(D+="-"),b===1?D+=C:(m&&(w=Math.floor(C/b))>0&&(D+=w,C%=b),D+="\\frac{",D+=C,D+="}{",D+=b,D+="}"),D},toContinued:function(){var m,w=this.n,D=this.d,C=[];if(isNaN(w)||isNaN(D))return C;do C.push(Math.floor(w/D)),m=w%D,w=D,D=m;while(w!==1);return C},toString:function(m){var w=this.n,D=this.d;if(isNaN(w)||isNaN(D))return"NaN";m=m||15;var C=h(w,D),b=d(w,D,C),F=this.s<0?"-":"";if(F+=w/D|0,w%=D,w*=10,w&&(F+="."),C){for(var B=b;B--;)F+=w/D|0,w%=D,w*=10;F+="(";for(var B=C;B--;)F+=w/D|0,w%=D,w*=10;F+=")"}else for(var B=m;w&&B--;)F+=w/D|0,w%=D,w*=10;return F}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,s.exports=v})()})(dc);var Cv=dc.exports,mn=tt(Cv),Fv="Fraction",Bv=[],Mv=xe(Fv,Bv,()=>(Object.defineProperty(mn,"name",{value:"Fraction"}),mn.prototype.constructor=mn,mn.prototype.type="Fraction",mn.prototype.isFraction=!0,mn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},mn.fromJSON=function(s){return new mn(s)},mn),{isClass:!0}),Nv="Matrix",Sv=[],Ov=xe(Nv,Sv,()=>{function s(){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator")}return s.prototype.type="Matrix",s.prototype.isMatrix=!0,s.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},s.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},s.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},s.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},s.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},s.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},s.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},s.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},s.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},s.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},s.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},s.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},s.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},s.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},s.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},s.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},s.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},s},{isClass:!0});function pc(s){return Object.keys(s.signatures||{}).reduce(function(e,t){var r=(t.match(/,/g)||[]).length+1;return Math.max(e,r)},-1)}var Iv="DenseMatrix",Tv=["Matrix"],$v=xe(Iv,Tv,s=>{var{Matrix:e}=s;function t(h,d){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(d&&!un(d))throw new Error("Invalid datatype: "+d);if(mt(h))h.type==="DenseMatrix"?(this._data=ut(h._data),this._size=ut(h._size),this._datatype=d||h._datatype):(this._data=h.toArray(),this._size=h.size(),this._datatype=d||h._datatype);else if(h&&Ct(h.data)&&Ct(h.size))this._data=h.data,this._size=h.size,Ul(this._data,this._size),this._datatype=d||h.datatype;else if(Ct(h))this._data=c(h),this._size=Lt(this._data),Ul(this._data,this._size),this._datatype=d;else{if(h)throw new TypeError("Unsupported type of data ("+Sn(h)+")");this._data=[],this._size=[0],this._datatype=d}}t.prototype=new e,t.prototype.createDenseMatrix=function(h,d){return new t(h,d)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return Ys(this._data,Sn)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(h,d){return new t(h,d)},t.prototype.subset=function(h,d,p){switch(arguments.length){case 1:return r(this,h);case 2:case 3:return i(this,h,d,p);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(h){if(!Ct(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new rt(h.length,this._size.length);for(var d=0;d<h.length;d++)Ft(h[d],this._size[d]);for(var p=this._data,v=0,x=h.length;v<x;v++){var _=h[v];Ft(_,p.length),p=p[_]}return p},t.prototype.set=function(h,d,p){if(!Ct(h))throw new TypeError("Array expected");if(h.length<this._size.length)throw new rt(h.length,this._size.length,"<");var v,x,_,y=h.map(function(w){return w+1});f(this,y,p);var m=this._data;for(v=0,x=h.length-1;v<x;v++)_=h[v],Ft(_,m.length),m=m[_];return _=h[h.length-1],Ft(_,m.length),m[_]=d,this};function r(h,d){if(!Aa(d))throw new TypeError("Invalid index");var p=d.isScalar();if(p)return h.get(d.min());var v=d.size();if(v.length!==h._size.length)throw new rt(v.length,h._size.length);for(var x=d.min(),_=d.max(),y=0,m=h._size.length;y<m;y++)Ft(x[y],h._size[y]),Ft(_[y],h._size[y]);return new t(n(h._data,d,v.length,0),h._datatype)}function n(h,d,p,v){var x=v===p-1,_=d.dimension(v);return x?_.map(function(y){return Ft(y,h.length),h[y]}).valueOf():_.map(function(y){Ft(y,h.length);var m=h[y];return n(m,d,p,v+1)}).valueOf()}function i(h,d,p,v){if(!d||d.isIndex!==!0)throw new TypeError("Invalid index");var x=d.size(),_=d.isScalar(),y;if(mt(p)?(y=p.size(),p=p.valueOf()):y=Lt(p),_){if(y.length!==0)throw new TypeError("Scalar expected");h.set(d.min(),p,v)}else{if(!yi(y,x))try{y.length===0?p=Vl([p],x):p=Vl(p,x),y=Lt(p)}catch{}if(x.length<h._size.length)throw new rt(x.length,h._size.length,"<");if(y.length<x.length){for(var m=0,w=0;x[m]===1&&y[m]===1;)m++;for(;x[m]===1;)w++,m++;p=Hl(p,x.length,w,y)}if(!yi(x,y))throw new rt(x,y,">");var D=d.max().map(function(F){return F+1});f(h,D,v);var C=x.length,b=0;a(h._data,d,p,C,b)}return h}function a(h,d,p,v,x){var _=x===v-1,y=d.dimension(x);_?y.forEach(function(m,w){Ft(m),h[m]=p[w[0]]}):y.forEach(function(m,w){Ft(m),a(h[m],d,p[w[0]],v,x+1)})}t.prototype.resize=function(h,d,p){if(!is(h))throw new TypeError("Array or Matrix expected");var v=h.valueOf().map(_=>Array.isArray(_)&&_.length===1?_[0]:_),x=p?this.clone():this;return u(x,v,d)};function u(h,d,p){if(d.length===0){for(var v=h._data;Ct(v);)v=v[0];return v}return h._size=d.slice(0),h._data=Na(h._data,h._size,p),h}t.prototype.reshape=function(h,d){var p=d?this.clone():this;p._data=Oa(p._data,h);var v=p._size.reduce((x,_)=>x*_);return p._size=Ia(h,v),p};function f(h,d,p){for(var v=h._size.slice(0),x=!1;v.length<d.length;)v.push(0),x=!0;for(var _=0,y=d.length;_<y;_++)d[_]>v[_]&&(v[_]=d[_],x=!0);x&&u(h,v,p)}t.prototype.clone=function(){var h=new t({data:ut(this._data),size:ut(this._size),datatype:this._datatype});return h},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(h){var d=this,p=pc(h),v=function y(m,w){return Ct(m)?m.map(function(D,C){return y(D,w.concat(C))}):p===1?h(m):p===2?h(m,w):h(m,w,d)},x=v(this._data,[]),_=this._datatype!==void 0?Ys(x,Sn):void 0;return new t(x,_)},t.prototype.forEach=function(h){var d=this,p=function v(x,_){Ct(x)?x.forEach(function(y,m){v(y,_.concat(m))}):h(x,_,d)};p(this._data,[])},t.prototype[Symbol.iterator]=function*(){var h=function*d(p,v){if(Ct(p))for(var x=0;x<p.length;x++)yield*d(p[x],v.concat(x));else yield{value:p,index:v}};yield*h(this._data,[])},t.prototype.rows=function(){var h=[],d=this.size();if(d.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var p=this._data;for(var v of p)h.push(new t([v],this._datatype));return h},t.prototype.columns=function(){var h=this,d=[],p=this.size();if(p.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var v=this._data,x=function(m){var w=v.map(D=>[D[m]]);d.push(new t(w,h._datatype))},_=0;_<p[1];_++)x(_);return d},t.prototype.toArray=function(){return ut(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(h){return ct(this._data,h)},t.prototype.toString=function(){return ct(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(h){if(h){if(St(h)&&(h=h.toNumber()),!pt(h)||!bt(h))throw new TypeError("The parameter k must be an integer number")}else h=0;for(var d=h>0?h:0,p=h<0?-h:0,v=this._size[0],x=this._size[1],_=Math.min(v-p,x-d),y=[],m=0;m<_;m++)y[m]=this._data[m+p][m+d];return new t({data:y,size:[_],datatype:this._datatype})},t.diagonal=function(h,d,p,v){if(!Ct(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(B){if(St(B)&&(B=B.toNumber()),!pt(B)||!bt(B)||B<1)throw new Error("Size values must be positive integers");return B}),p){if(St(p)&&(p=p.toNumber()),!pt(p)||!bt(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var x=p>0?p:0,_=p<0?-p:0,y=h[0],m=h[1],w=Math.min(y-_,m-x),D;if(Ct(d)){if(d.length!==w)throw new Error("Invalid value array length");D=function(M){return d[M]}}else if(mt(d)){var C=d.size();if(C.length!==1||C[0]!==w)throw new Error("Invalid matrix length");D=function(M){return d.get([M])}}else D=function(){return d};v||(v=St(D(0))?D(0).mul(0):0);var b=[];if(h.length>0){b=Na(b,h,v);for(var F=0;F<w;F++)b[F+_][F+x]=D(F)}return new t({data:b,size:[y,m]})},t.fromJSON=function(h){return new t(h)},t.prototype.swapRows=function(h,d){if(!pt(h)||!bt(h)||!pt(d)||!bt(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 Ft(h,this._size[0]),Ft(d,this._size[0]),t._swapRows(h,d,this._data),this},t._swapRows=function(h,d,p){var v=p[h];p[h]=p[d],p[d]=v};function c(h){return mt(h)?c(h.valueOf()):Ct(h)?h.map(c):h}return t},{isClass:!0});function Rv(s){var e=s.length,t=s[0].length,r,n,i=[];for(n=0;n<t;n++){var a=[];for(r=0;r<e;r++)a.push(s[r][n]);i.push(a)}return i}function ro(s){for(var e=0;e<s.length;e++)if(is(s[e]))return!0;return!1}function as(s,e){mt(s)&&(s=s.valueOf());for(var t=0,r=s.length;t<r;t++){var n=s[t];Array.isArray(n)?as(n,e):e(n)}}function Jr(s,e,t){return s&&typeof s.map=="function"?s.map(function(r){return Jr(r,e)}):e(s)}function Wa(s,e,t){var r=Array.isArray(s)?Lt(s):s.size();if(e<0||e>=r.length)throw new On(e,r.length);return mt(s)?s.create(no(s.valueOf(),e,t)):no(s,e,t)}function no(s,e,t){var r,n,i,a;if(e<=0)if(Array.isArray(s[0])){for(a=Rv(s),n=[],r=0;r<a.length;r++)n[r]=no(a[r],e-1,t);return n}else{for(i=s[0],r=1;r<s.length;r++)i=t(i,s[r]);return i}else{for(n=[],r=0;r<s.length;r++)n[r]=no(s[r],e-1,t);return n}}var _c="isInteger",Lv=["typed"],Pv=xe(_c,Lv,s=>{var{typed:e}=s;return e(_c,{number:bt,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),vc="number",io="number, number";function gc(s){return Math.abs(s)}gc.signature=vc;function mc(s,e){return s+e}mc.signature=io;function xc(s,e){return s-e}xc.signature=io;function yc(s,e){return s*e}yc.signature=io;function Dc(s){return-s}Dc.signature=vc;function wc(s,e){return s*s<1&&e===1/0||s*s>1&&e===-1/0?0:Math.pow(s,e)}wc.signature=io;var bc="number";function Ec(s){return s===0}Ec.signature=bc;function Ac(s){return Number.isNaN(s)}Ac.signature=bc;var Cc="isNumeric",kv=["typed"],zv=xe(Cc,kv,s=>{var{typed:e}=s;return e(Cc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),Fc="isZero",qv=["typed"],Uv=xe(Fc,qv,s=>{var{typed:e}=s;return e(Fc,{number:Ec,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:e.referToSelf(t=>r=>e.find(t,r.valueType())(r.value)),"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),Bc="isNaN",Wv=["typed"],Hv=xe(Bc,Wv,s=>{var{typed:e}=s;return e(Bc,{number:Ac,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 Jr(r,Number.isNaN)}})});function so(s,e,t){if(t==null)return s.eq(e);if(s.eq(e))return!0;if(s.isNaN()||e.isNaN())return!1;if(s.isFinite()&&e.isFinite()){var r=s.minus(e).abs();if(r.isZero())return!0;var n=s.constructor.max(s.abs(),e.abs());return r.lte(n.times(t))}return!1}function jv(s,e,t){return ti(s.re,e.re,t)&&ti(s.im,e.im,t)}var oo=xe("compareUnits",["typed"],s=>{var{typed:e}=s;return{"Unit, Unit":e.referToSelf(t=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return e.find(t,[r.valueType(),n.valueType()])(r.value,n.value)})}}),ao="equalScalar",Yv=["typed","config"],Zv=xe(ao,Yv,s=>{var{typed:e,config:t}=s,r=oo({typed:e});return e(ao,{"boolean, boolean":function(i,a){return i===a},"number, number":function(i,a){return ti(i,a,t.epsilon)},"BigNumber, BigNumber":function(i,a){return i.eq(a)||so(i,a,t.epsilon)},"Fraction, Fraction":function(i,a){return i.equals(a)},"Complex, Complex":function(i,a){return jv(i,a,t.epsilon)}},r)});xe(ao,["typed","config"],s=>{var{typed:e,config:t}=s;return e(ao,{"number, number":function(n,i){return ti(n,i,t.epsilon)}})});var Vv="SparseMatrix",Gv=["typed","equalScalar","Matrix"],Kv=xe(Vv,Gv,s=>{var{typed:e,equalScalar:t,Matrix:r}=s;function n(_,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!un(y))throw new Error("Invalid datatype: "+y);if(mt(_))i(this,_,y);else if(_&&Ct(_.index)&&Ct(_.ptr)&&Ct(_.size))this._values=_.values,this._index=_.index,this._ptr=_.ptr,this._size=_.size,this._datatype=y||_.datatype;else if(Ct(_))a(this,_,y);else{if(_)throw new TypeError("Unsupported type of data ("+Sn(_)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function i(_,y,m){y.type==="SparseMatrix"?(_._values=y._values?ut(y._values):void 0,_._index=ut(y._index),_._ptr=ut(y._ptr),_._size=ut(y._size),_._datatype=m||y._datatype):a(_,y.valueOf(),m||y._datatype)}function a(_,y,m){_._values=[],_._index=[],_._ptr=[],_._datatype=m;var w=y.length,D=0,C=t,b=0;if(un(m)&&(C=e.find(t,[m,m])||t,b=e.convert(0,m)),w>0){var F=0;do{_._ptr.push(_._index.length);for(var B=0;B<w;B++){var M=y[B];if(Ct(M)){if(F===0&&D<M.length&&(D=M.length),F<M.length){var O=M[F];C(O,b)||(_._values.push(O),_._index.push(B))}}else F===0&&D<1&&(D=1),C(M,b)||(_._values.push(M),_._index.push(B))}F++}while(F<D)}_._ptr.push(_._index.length),_._size=[w,D]}n.prototype=new r,n.prototype.createSparseMatrix=function(_,y){return new n(_,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Ys(this._values,Sn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(_,y){return new n(_,y)},n.prototype.density=function(){var _=this._size[0],y=this._size[1];return _!==0&&y!==0?this._index.length/(_*y):0},n.prototype.subset=function(_,y,m){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return u(this,_);case 2:case 3:return f(this,_,y,m);default:throw new SyntaxError("Wrong number of arguments")}};function u(_,y){if(!Aa(y))throw new TypeError("Invalid index");var m=y.isScalar();if(m)return _.get(y.min());var w=y.size();if(w.length!==_._size.length)throw new rt(w.length,_._size.length);var D,C,b,F,B=y.min(),M=y.max();for(D=0,C=_._size.length;D<C;D++)Ft(B[D],_._size[D]),Ft(M[D],_._size[D]);var O=_._values,A=_._index,N=_._ptr,I=y.dimension(0),R=y.dimension(1),k=[],z=[];I.forEach(function(ee,te){z[ee]=te[0],k[ee]=!0});var L=O?[]:void 0,G=[],H=[];return R.forEach(function(ee){for(H.push(G.length),b=N[ee],F=N[ee+1];b<F;b++)D=A[b],k[D]===!0&&(G.push(z[D]),L&&L.push(O[b]))}),H.push(G.length),new n({values:L,index:G,ptr:H,size:w,datatype:_._datatype})}function f(_,y,m,w){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var D=y.size(),C=y.isScalar(),b;if(mt(m)?(b=m.size(),m=m.toArray()):b=Lt(m),C){if(b.length!==0)throw new TypeError("Scalar expected");_.set(y.min(),m,w)}else{if(D.length!==1&&D.length!==2)throw new rt(D.length,_._size.length,"<");if(b.length<D.length){for(var F=0,B=0;D[F]===1&&b[F]===1;)F++;for(;D[F]===1;)B++,F++;m=Hl(m,D.length,B,b)}if(!yi(D,b))throw new rt(D,b,">");if(D.length===1){var M=y.dimension(0);M.forEach(function(N,I){Ft(N),_.set([N,0],m[I[0]],w)})}else{var O=y.dimension(0),A=y.dimension(1);O.forEach(function(N,I){Ft(N),A.forEach(function(R,k){Ft(R),_.set([N,R],m[I[0]][k[0]],w)})})}}return _}n.prototype.get=function(_){if(!Ct(_))throw new TypeError("Array expected");if(_.length!==this._size.length)throw new rt(_.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=_[0],m=_[1];Ft(y,this._size[0]),Ft(m,this._size[1]);var w=c(y,this._ptr[m],this._ptr[m+1],this._index);return w<this._ptr[m+1]&&this._index[w]===y?this._values[w]:0},n.prototype.set=function(_,y,m){if(!Ct(_))throw new TypeError("Array expected");if(_.length!==this._size.length)throw new rt(_.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var w=_[0],D=_[1],C=this._size[0],b=this._size[1],F=t,B=0;un(this._datatype)&&(F=e.find(t,[this._datatype,this._datatype])||t,B=e.convert(0,this._datatype)),(w>C-1||D>b-1)&&(p(this,Math.max(w+1,C),Math.max(D+1,b),m),C=this._size[0],b=this._size[1]),Ft(w,C),Ft(D,b);var M=c(w,this._ptr[D],this._ptr[D+1],this._index);return M<this._ptr[D+1]&&this._index[M]===w?F(y,B)?h(M,D,this._values,this._index,this._ptr):this._values[M]=y:F(y,B)||d(M,w,D,y,this._values,this._index,this._ptr),this};function c(_,y,m,w){if(m-y===0)return m;for(var D=y;D<m;D++)if(w[D]===_)return D;return y}function h(_,y,m,w,D){m.splice(_,1),w.splice(_,1);for(var C=y+1;C<D.length;C++)D[C]--}function d(_,y,m,w,D,C,b){D.splice(_,0,w),C.splice(_,0,y);for(var F=m+1;F<b.length;F++)b[F]++}n.prototype.resize=function(_,y,m){if(!is(_))throw new TypeError("Array or Matrix expected");var w=_.valueOf().map(C=>Array.isArray(C)&&C.length===1?C[0]:C);if(w.length!==2)throw new Error("Only two dimensions matrix are supported");w.forEach(function(C){if(!pt(C)||!bt(C)||C<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ct(w)+")")});var D=m?this.clone():this;return p(D,w[0],w[1],y)};function p(_,y,m,w){var D=w||0,C=t,b=0;un(_._datatype)&&(C=e.find(t,[_._datatype,_._datatype])||t,b=e.convert(0,_._datatype),D=e.convert(D,_._datatype));var F=!C(D,b),B=_._size[0],M=_._size[1],O,A,N;if(m>M){for(A=M;A<m;A++)if(_._ptr[A]=_._values.length,F)for(O=0;O<B;O++)_._values.push(D),_._index.push(O);_._ptr[m]=_._values.length}else m<M&&(_._ptr.splice(m+1,M-m),_._values.splice(_._ptr[m],_._values.length),_._index.splice(_._ptr[m],_._index.length));if(M=m,y>B){if(F){var I=0;for(A=0;A<M;A++){_._ptr[A]=_._ptr[A]+I,N=_._ptr[A+1]+I;var R=0;for(O=B;O<y;O++,R++)_._values.splice(N+R,0,D),_._index.splice(N+R,0,O),I++}_._ptr[M]=_._values.length}}else if(y<B){var k=0;for(A=0;A<M;A++){_._ptr[A]=_._ptr[A]-k;var z=_._ptr[A],L=_._ptr[A+1]-k;for(N=z;N<L;N++)O=_._index[N],O>y-1&&(_._values.splice(N,1),_._index.splice(N,1),k++)}_._ptr[A]=_._values.length}return _._size[0]=y,_._size[1]=m,_}n.prototype.reshape=function(_,y){if(!Ct(_))throw new TypeError("Array expected");if(_.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");_.forEach(function(ee){if(!pt(ee)||!bt(ee)||ee<=-2||ee===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+ct(_)+")")});var m=this._size[0]*this._size[1];_=Ia(_,m);var w=_[0]*_[1];if(m!==w)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var D=y?this.clone():this;if(this._size[0]===_[0]&&this._size[1]===_[1])return D;for(var C=[],b=0;b<D._ptr.length;b++)for(var F=0;F<D._ptr[b+1]-D._ptr[b];F++)C.push(b);for(var B=D._values.slice(),M=D._index.slice(),O=0;O<D._index.length;O++){var A=M[O],N=C[O],I=A*D._size[1]+N;C[O]=I%_[1],M[O]=Math.floor(I/_[1])}D._values.length=0,D._index.length=0,D._ptr.length=_[1]+1,D._size=_.slice();for(var R=0;R<D._ptr.length;R++)D._ptr[R]=0;for(var k=0;k<B.length;k++){var z=M[k],L=C[k],G=B[k],H=c(z,D._ptr[L],D._ptr[L+1],D._index);d(H,z,L,G,D._values,D._index,D._ptr)}return D},n.prototype.clone=function(){var _=new n({values:this._values?ut(this._values):void 0,index:ut(this._index),ptr:ut(this._ptr),size:ut(this._size),datatype:this._datatype});return _},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(_,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var m=this,w=this._size[0],D=this._size[1],C=pc(_),b=function(B,M,O){return C===1?_(B):C===2?_(B,[M,O]):_(B,[M,O],m)};return v(this,0,w-1,0,D-1,b,y)};function v(_,y,m,w,D,C,b){var F=[],B=[],M=[],O=t,A=0;un(_._datatype)&&(O=e.find(t,[_._datatype,_._datatype])||t,A=e.convert(0,_._datatype));for(var N=function(Y,Q,pe){Y=C(Y,Q,pe),O(Y,A)||(F.push(Y),B.push(Q))},I=w;I<=D;I++){M.push(F.length);var R=_._ptr[I],k=_._ptr[I+1];if(b)for(var z=R;z<k;z++){var L=_._index[z];L>=y&&L<=m&&N(_._values[z],L-y,I-w)}else{for(var G={},H=R;H<k;H++){var ee=_._index[H];G[ee]=_._values[H]}for(var te=y;te<=m;te++){var j=te in G?G[te]:0;N(j,te-y,I-w)}}}return M.push(F.length),new n({values:F,index:B,ptr:M,size:[m-y+1,D-w+1]})}n.prototype.forEach=function(_,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var m=this,w=this._size[0],D=this._size[1],C=0;C<D;C++){var b=this._ptr[C],F=this._ptr[C+1];if(y)for(var B=b;B<F;B++){var M=this._index[B];_(this._values[B],[M,C],m)}else{for(var O={},A=b;A<F;A++){var N=this._index[A];O[N]=this._values[A]}for(var I=0;I<w;I++){var R=I in O?O[I]:0;_(R,[I,C],m)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var _=this._size[1],y=0;y<_;y++)for(var m=this._ptr[y],w=this._ptr[y+1],D=m;D<w;D++){var C=this._index[D];yield{value:this._values[D],index:[C,y]}}},n.prototype.toArray=function(){return x(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return x(this._values,this._index,this._ptr,this._size,!1)};function x(_,y,m,w,D){var C=w[0],b=w[1],F=[],B,M;for(B=0;B<C;B++)for(F[B]=[],M=0;M<b;M++)F[B][M]=0;for(M=0;M<b;M++)for(var O=m[M],A=m[M+1],N=O;N<A;N++)B=y[N],F[B][M]=_?D?ut(_[N]):_[N]:1;return F}return n.prototype.format=function(_){for(var y=this._size[0],m=this._size[1],w=this.density(),D="Sparse Matrix ["+ct(y,_)+" x "+ct(m,_)+"] density: "+ct(w,_)+`
53
53
  `,C=0;C<m;C++)for(var b=this._ptr[C],F=this._ptr[C+1],B=b;B<F;B++){var M=this._index[B];D+=`
54
- (`+ct(M,_)+", "+ct(C,_)+") ==> "+(this._values?ct(this._values[B],_):"X")}return D},n.prototype.toString=function(){return ct(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(_){if(_){if(St(_)&&(_=_.toNumber()),!pt(_)||!bt(_))throw new TypeError("The parameter k must be an integer number")}else _=0;var y=_>0?_:0,m=_<0?-_:0,w=this._size[0],D=this._size[1],C=Math.min(w-m,D-y),b=[],F=[],B=[];B[0]=0;for(var M=y;M<D&&b.length<C;M++)for(var O=this._ptr[M],A=this._ptr[M+1],N=O;N<A;N++){var I=this._index[N];if(I===M-y+m){b.push(this._values[N]),F[b.length-1]=I-m;break}}return B.push(b.length),new n({values:b,index:F,ptr:B,size:[C,1]})},n.fromJSON=function(_){return new n(_)},n.diagonal=function(_,y,m,w,D){if(!Ct(_))throw new TypeError("Array expected, size parameter");if(_.length!==2)throw new Error("Only two dimensions matrix are supported");if(_=_.map(function(ee){if(St(ee)&&(ee=ee.toNumber()),!pt(ee)||!bt(ee)||ee<1)throw new Error("Size values must be positive integers");return ee}),m){if(St(m)&&(m=m.toNumber()),!pt(m)||!bt(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var C=t,b=0;un(D)&&(C=e.find(t,[D,D])||t,b=e.convert(0,D));var F=m>0?m:0,B=m<0?-m:0,M=_[0],O=_[1],A=Math.min(M-B,O-F),N;if(Ct(y)){if(y.length!==A)throw new Error("Invalid value array length");N=function(te){return y[te]}}else if(mt(y)){var I=y.size();if(I.length!==1||I[0]!==A)throw new Error("Invalid matrix length");N=function(te){return y.get([te])}}else N=function(){return y};for(var R=[],k=[],z=[],L=0;L<O;L++){z.push(R.length);var G=L-F;if(G>=0&&G<A){var H=N(G);C(H,b)||(k.push(G+B),R.push(H))}}return z.push(R.length),new n({values:R,index:k,ptr:z,size:[M,O]})},n.prototype.swapRows=function(_,y){if(!pt(_)||!bt(_)||!pt(y)||!bt(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ft(_,this._size[0]),Ft(y,this._size[0]),n._swapRows(_,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(_,y,m,w,D){for(var C=w[_],b=w[_+1],F=C;F<b;F++)D(m[F],y[F])},n._swapRows=function(_,y,m,w,D,C){for(var b=0;b<m;b++){var F=C[b],B=C[b+1],M=c(_,F,B,D),O=c(y,F,B,D);if(M<B&&O<B&&D[M]===_&&D[O]===y){if(w){var A=w[M];w[M]=w[O],w[O]=A}continue}if(M<B&&D[M]===_&&(O>=B||D[O]!==y)){var N=w?w[M]:void 0;D.splice(O,0,y),w&&w.splice(O,0,N),D.splice(O<=M?M+1:M,1),w&&w.splice(O<=M?M+1:M,1);continue}if(O<B&&D[O]===y&&(M>=B||D[M]!==_)){var I=w?w[O]:void 0;D.splice(M,0,_),w&&w.splice(M,0,I),D.splice(M<=O?O+1:O,1),w&&w.splice(M<=O?O+1:O,1)}}},n},{isClass:!0}),Xv="number",Qv=["typed"];function Jv(s){var e=s.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],r=e[2],n=e[3];return{input:s,radix:t,integerPart:r,fractionalPart:n}}else return null}function eg(s){for(var e=parseInt(s.integerPart,s.radix),t=0,r=0;r<s.fractionalPart.length;r++){var n=parseInt(s.fractionalPart[r],s.radix);t+=n/Math.pow(s.radix,r+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+s.input+'" is not a valid number');return i}var tg=xe(Xv,Qv,s=>{var{typed:e}=s,t=e("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Jv(n);if(i)return eg(i);var a=0,u=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);u&&(a=Number(u[2]),n=u[1]);var f=Number(n);if(isNaN(f))throw new SyntaxError('String "'+n+'" is not a valid number');if(u){if(f>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));f>=2**(a-1)&&(f=f-2**a)}return f},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":e.referToSelf(r=>n=>Jr(n,r))});return t.fromJSON=function(r){return parseFloat(r.value)},t}),rg="bignumber",ng=["typed","BigNumber"],ig=xe(rg,ng,s=>{var{typed:e,BigNumber:t}=s;return e("bignumber",{"":function(){return new t(0)},number:function(n){return new t(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var a=i[2],u=t(i[1]),f=new t(2).pow(Number(a));if(u.gt(f.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var c=new t(2).pow(Number(a)-1);return u.gte(c)?u.sub(f):u}return new t(n)},BigNumber:function(n){return n},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Fraction:function(n){return new t(n.n).div(n.d).times(n.s)},null:function(n){return new t(0)},"Array | Matrix":e.referToSelf(r=>n=>Jr(n,r))})}),sg="fraction",og=["typed","Fraction"],ag=xe(sg,og,s=>{var{typed:e,Fraction:t}=s;return e("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new t(n)},string:function(n){return new t(n)},"number, number":function(n,i){return new t(n,i)},null:function(n){return new t(0)},BigNumber:function(n){return new t(n.toString())},Fraction:function(n){return n},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Object:function(n){return new t(n)},"Array | Matrix":e.referToSelf(r=>n=>Jr(n,r))})}),Mc="matrix",ug=["typed","Matrix","DenseMatrix","SparseMatrix"],lg=xe(Mc,ug,s=>{var{typed:e,Matrix:t,DenseMatrix:r,SparseMatrix:n}=s;return e(Mc,{"":function(){return i([])},string:function(u){return i([],u)},"string, string":function(u,f){return i([],u,f)},Array:function(u){return i(u)},Matrix:function(u){return i(u,u.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(a,u,f){if(u==="dense"||u==="default"||u===void 0)return new r(a,f);if(u==="sparse")return new n(a,f);throw new TypeError("Unknown matrix type "+JSON.stringify(u)+".")}}),Nc="unaryMinus",cg=["typed"],fg=xe(Nc,cg,s=>{var{typed:e}=s;return e(Nc,{number:Dc,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>r=>{var n=r.clone();return n.value=e.find(t,n.valueType())(r.value),n}),"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),Sc="abs",hg=["typed"],dg=xe(Sc,hg,s=>{var{typed:e}=s;return e(Sc,{number:gc,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),Oc="addScalar",pg=["typed"],_g=xe(Oc,pg,s=>{var{typed:e}=s;return e(Oc,{"number, number":mc,"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":e.referToSelf(t=>(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 i=r.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Ic="subtractScalar",vg=["typed"],gg=xe(Ic,vg,s=>{var{typed:e}=s;return e(Ic,{"number, number":xc,"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":e.referToSelf(t=>(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 i=r.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),mg="matAlgo11xS0s",xg=["typed","equalScalar"],Ha=xe(mg,xg,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a,u){var f=n._values,c=n._index,h=n._ptr,d=n._size,p=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=d[0],x=d[1],_,y=t,m=0,w=a;typeof p=="string"&&(_=p,y=e.find(t,[_,_]),m=e.convert(0,_),i=e.convert(i,_),w=e.find(a,[_,_]));for(var D=[],C=[],b=[],F=0;F<x;F++){b[F]=C.length;for(var B=h[F],M=h[F+1],O=B;O<M;O++){var A=c[O],N=u?w(i,f[O]):w(f[O],i);y(N,m)||(C.push(A),D.push(N))}}return b[x]=C.length,n.createSparseMatrix({values:D,index:C,ptr:b,size:[v,x],datatype:_})}}),yg="matAlgo12xSfs",Dg=["typed","DenseMatrix"],Ci=xe(yg,Dg,s=>{var{typed:e,DenseMatrix:t}=s;return function(n,i,a,u){var f=n._values,c=n._index,h=n._ptr,d=n._size,p=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=d[0],x=d[1],_,y=a;typeof p=="string"&&(_=p,i=e.convert(i,_),y=e.find(a,[_,_]));for(var m=[],w=[],D=[],C=0;C<x;C++){for(var b=C+1,F=h[C],B=h[C+1],M=F;M<B;M++){var O=c[M];w[O]=f[M],D[O]=b}for(var A=0;A<v;A++)C===0&&(m[A]=[]),D[A]===b?m[A][C]=u?y(i,w[A]):y(w[A],i):m[A][C]=u?y(i,0):y(0,i)}return new t({data:m,size:[v,x],datatype:_})}}),wg="matAlgo14xDs",bg=["typed"],ja=xe(wg,bg,s=>{var{typed:e}=s;return function(n,i,a,u){var f=n._data,c=n._size,h=n._datatype,d,p=a;typeof h=="string"&&(d=h,i=e.convert(i,d),p=e.find(a,[d,d]));var v=c.length>0?t(p,0,c,c[0],f,i,u):[];return n.createDenseMatrix({data:v,size:ut(c),datatype:d})};function t(r,n,i,a,u,f,c){var h=[];if(n===i.length-1)for(var d=0;d<a;d++)h[d]=c?r(f,u[d]):r(u[d],f);else for(var p=0;p<a;p++)h[p]=t(r,n+1,i,i[n+1],u[p],f,c);return h}}),Eg="matAlgo02xDS0",Ag=["typed","equalScalar"],Cg=xe(Eg,Ag,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a,u){var f=n._data,c=n._size,h=n._datatype||n.getDataType(),d=i._values,p=i._index,v=i._ptr,x=i._size,_=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==x.length)throw new rt(c.length,x.length);if(c[0]!==x[0]||c[1]!==x[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+x+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=c[0],m=c[1],w,D=t,C=0,b=a;typeof h=="string"&&h===_&&h!=="mixed"&&(w=h,D=e.find(t,[w,w]),C=e.convert(0,w),b=e.find(a,[w,w]));for(var F=[],B=[],M=[],O=0;O<m;O++){M[O]=B.length;for(var A=v[O],N=v[O+1],I=A;I<N;I++){var R=p[I],k=u?b(d[I],f[R][O]):b(f[R][O],d[I]);D(k,C)||(B.push(R),F.push(k))}}return M[m]=B.length,i.createSparseMatrix({values:F,index:B,ptr:M,size:[y,m],datatype:h===n._datatype&&_===i._datatype?w:void 0})}}),Fg="matAlgo03xDSf",Bg=["typed"],Fi=xe(Fg,Bg,s=>{var{typed:e}=s;return function(r,n,i,a){var u=r._data,f=r._size,c=r._datatype||r.getDataType(),h=n._values,d=n._index,p=n._ptr,v=n._size,x=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==v.length)throw new rt(f.length,v.length);if(f[0]!==v[0]||f[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+v+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var _=f[0],y=f[1],m,w=0,D=i;typeof c=="string"&&c===x&&c!=="mixed"&&(m=c,w=e.convert(0,m),D=e.find(i,[m,m]));for(var C=[],b=0;b<_;b++)C[b]=[];for(var F=[],B=[],M=0;M<y;M++){for(var O=M+1,A=p[M],N=p[M+1],I=A;I<N;I++){var R=d[I];F[R]=a?D(h[I],u[R][M]):D(u[R][M],h[I]),B[R]=O}for(var k=0;k<_;k++)B[k]===O?C[k][M]=F[k]:C[k][M]=a?D(w,u[k][M]):D(u[k][M],w)}return r.createDenseMatrix({data:C,size:[_,y],datatype:c===r._datatype&&x===n._datatype?m:void 0})}}),Mg="matAlgo05xSfSf",Ng=["typed","equalScalar"],Tc=xe(Mg,Ng,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a){var u=n._values,f=n._index,c=n._ptr,h=n._size,d=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=i._values,v=i._index,x=i._ptr,_=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==_.length)throw new rt(h.length,_.length);if(h[0]!==_[0]||h[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+_+")");var m=h[0],w=h[1],D,C=t,b=0,F=a;typeof d=="string"&&d===y&&d!=="mixed"&&(D=d,C=e.find(t,[D,D]),b=e.convert(0,D),F=e.find(a,[D,D]));var B=u&&p?[]:void 0,M=[],O=[],A=B?[]:void 0,N=B?[]:void 0,I=[],R=[],k,z,L,G;for(z=0;z<w;z++){O[z]=M.length;var H=z+1;for(L=c[z],G=c[z+1];L<G;L++)k=f[L],M.push(k),I[k]=H,A&&(A[k]=u[L]);for(L=x[z],G=x[z+1];L<G;L++)k=v[L],I[k]!==H&&M.push(k),R[k]=H,N&&(N[k]=p[L]);if(B)for(L=O[z];L<M.length;){k=M[L];var ee=I[k],te=R[k];if(ee===H||te===H){var j=ee===H?A[k]:b,X=te===H?N[k]:b,Y=F(j,X);C(Y,b)?M.splice(L,1):(B.push(Y),L++)}}}return O[w]=M.length,n.createSparseMatrix({values:B,index:M,ptr:O,size:[m,w],datatype:d===n._datatype&&y===i._datatype?D:void 0})}}),Sg="matAlgo13xDD",Og=["typed"],Ig=xe(Sg,Og,s=>{var{typed:e}=s;return function(n,i,a){var u=n._data,f=n._size,c=n._datatype,h=i._data,d=i._size,p=i._datatype,v=[];if(f.length!==d.length)throw new rt(f.length,d.length);for(var x=0;x<f.length;x++){if(f[x]!==d[x])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");v[x]=f[x]}var _,y=a;typeof c=="string"&&c===p&&(_=c,y=e.find(a,[_,_]));var m=v.length>0?t(y,0,v,v[0],u,h):[];return n.createDenseMatrix({data:m,size:v,datatype:_})};function t(r,n,i,a,u,f){var c=[];if(n===i.length-1)for(var h=0;h<a;h++)c[h]=r(u[h],f[h]);else for(var d=0;d<a;d++)c[d]=t(r,n+1,i,i[n+1],u[d],f[d]);return c}}),Tg="broadcast",$g=["concat"],Rg=xe(Tg,$g,s=>{var{concat:e}=s;return function(n,i){var a=Math.max(n._size.length,i._size.length);if(n._size.length===i._size.length&&n._size.every((x,_)=>x===i._size[_]))return[n,i];for(var u=t(n._size,a,0),f=t(i._size,a,0),c=[],h=0;h<a;h++)c[h]=Math.max(u[h],f[h]);Zs(u,c),Zs(f,c);var d=n.clone(),p=i.clone();d._size.length<a?d.reshape(t(d._size,a,1)):p._size.length<a&&p.reshape(t(p._size,a,1));for(var v=0;v<a;v++)d._size[v]<c[v]&&(d=r(d,c[v],v)),p._size[v]<c[v]&&(p=r(p,c[v],v));return[d,p]};function t(n,i,a){return[...Array(i-n.length).fill(a),...n]}function r(n,i,a){return e(...Array(i).fill(n),a)}}),Lg="matrixAlgorithmSuite",Pg=["typed","matrix","concat"],ri=xe(Lg,Pg,s=>{var{typed:e,matrix:t,concat:r}=s,n=Ig({typed:e}),i=ja({typed:e}),a=Rg({concat:r});return function(f){var c=f.elop,h=f.SD||f.DS,d;c?(d={"DenseMatrix, DenseMatrix":(_,y)=>n(...a(_,y),c),"Array, Array":(_,y)=>n(...a(t(_),t(y)),c).valueOf(),"Array, DenseMatrix":(_,y)=>n(...a(t(_),y),c),"DenseMatrix, Array":(_,y)=>n(...a(_,t(y)),c)},f.SS&&(d["SparseMatrix, SparseMatrix"]=(_,y)=>f.SS(...a(_,y),c,!1)),f.DS&&(d["DenseMatrix, SparseMatrix"]=(_,y)=>f.DS(...a(_,y),c,!1),d["Array, SparseMatrix"]=(_,y)=>f.DS(...a(t(_),y),c,!1)),h&&(d["SparseMatrix, DenseMatrix"]=(_,y)=>h(...a(y,_),c,!0),d["SparseMatrix, Array"]=(_,y)=>h(...a(t(y),_),c,!0))):(d={"DenseMatrix, DenseMatrix":e.referToSelf(_=>(y,m)=>n(...a(y,m),_)),"Array, Array":e.referToSelf(_=>(y,m)=>n(...a(t(y),t(m)),_).valueOf()),"Array, DenseMatrix":e.referToSelf(_=>(y,m)=>n(...a(t(y),m),_)),"DenseMatrix, Array":e.referToSelf(_=>(y,m)=>n(...a(y,t(m)),_))},f.SS&&(d["SparseMatrix, SparseMatrix"]=e.referToSelf(_=>(y,m)=>f.SS(...a(y,m),_,!1))),f.DS&&(d["DenseMatrix, SparseMatrix"]=e.referToSelf(_=>(y,m)=>f.DS(...a(y,m),_,!1)),d["Array, SparseMatrix"]=e.referToSelf(_=>(y,m)=>f.DS(...a(t(y),m),_,!1))),h&&(d["SparseMatrix, DenseMatrix"]=e.referToSelf(_=>(y,m)=>h(...a(m,y),_,!0)),d["SparseMatrix, Array"]=e.referToSelf(_=>(y,m)=>h(...a(t(m),y),_,!0))));var p=f.scalar||"any",v=f.Ds||f.Ss;v&&(c?(d["DenseMatrix,"+p]=(_,y)=>i(_,y,c,!1),d[p+", DenseMatrix"]=(_,y)=>i(y,_,c,!0),d["Array,"+p]=(_,y)=>i(t(_),y,c,!1).valueOf(),d[p+", Array"]=(_,y)=>i(t(y),_,c,!0).valueOf()):(d["DenseMatrix,"+p]=e.referToSelf(_=>(y,m)=>i(y,m,_,!1)),d[p+", DenseMatrix"]=e.referToSelf(_=>(y,m)=>i(m,y,_,!0)),d["Array,"+p]=e.referToSelf(_=>(y,m)=>i(t(y),m,_,!1).valueOf()),d[p+", Array"]=e.referToSelf(_=>(y,m)=>i(t(m),y,_,!0).valueOf())));var x=f.sS!==void 0?f.sS:f.Ss;return c?(f.Ss&&(d["SparseMatrix,"+p]=(_,y)=>f.Ss(_,y,c,!1)),x&&(d[p+", SparseMatrix"]=(_,y)=>x(y,_,c,!0))):(f.Ss&&(d["SparseMatrix,"+p]=e.referToSelf(_=>(y,m)=>f.Ss(y,m,_,!1))),x&&(d[p+", SparseMatrix"]=e.referToSelf(_=>(y,m)=>x(m,y,_,!0)))),c&&c.signatures&&Fl(d,c.signatures),d}}),kg="matAlgo01xDSid",zg=["typed"],$c=xe(kg,zg,s=>{var{typed:e}=s;return function(r,n,i,a){var u=r._data,f=r._size,c=r._datatype||r.getDataType(),h=n._values,d=n._index,p=n._ptr,v=n._size,x=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==v.length)throw new rt(f.length,v.length);if(f[0]!==v[0]||f[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+v+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var _=f[0],y=f[1],m=typeof c=="string"&&c!=="mixed"&&c===x?c:void 0,w=m?e.find(i,[m,m]):i,D,C,b=[];for(D=0;D<_;D++)b[D]=[];var F=[],B=[];for(C=0;C<y;C++){for(var M=C+1,O=p[C],A=p[C+1],N=O;N<A;N++)D=d[N],F[D]=a?w(h[N],u[D][C]):w(u[D][C],h[N]),B[D]=M;for(D=0;D<_;D++)B[D]===M?b[D][C]=F[D]:b[D][C]=u[D][C]}return r.createDenseMatrix({data:b,size:[_,y],datatype:c===r._datatype&&x===n._datatype?m:void 0})}}),qg="matAlgo04xSidSid",Ug=["typed","equalScalar"],Wg=xe(qg,Ug,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a){var u=n._values,f=n._index,c=n._ptr,h=n._size,d=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=i._values,v=i._index,x=i._ptr,_=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==_.length)throw new rt(h.length,_.length);if(h[0]!==_[0]||h[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+_+")");var m=h[0],w=h[1],D,C=t,b=0,F=a;typeof d=="string"&&d===y&&d!=="mixed"&&(D=d,C=e.find(t,[D,D]),b=e.convert(0,D),F=e.find(a,[D,D]));var B=u&&p?[]:void 0,M=[],O=[],A=u&&p?[]:void 0,N=u&&p?[]:void 0,I=[],R=[],k,z,L,G,H;for(z=0;z<w;z++){O[z]=M.length;var ee=z+1;for(G=c[z],H=c[z+1],L=G;L<H;L++)k=f[L],M.push(k),I[k]=ee,A&&(A[k]=u[L]);for(G=x[z],H=x[z+1],L=G;L<H;L++)if(k=v[L],I[k]===ee){if(A){var te=F(A[k],p[L]);C(te,b)?I[k]=null:A[k]=te}}else M.push(k),R[k]=ee,N&&(N[k]=p[L]);if(A&&N)for(L=O[z];L<M.length;)k=M[L],I[k]===ee?(B[L]=A[k],L++):R[k]===ee?(B[L]=N[k],L++):M.splice(L,1)}return O[w]=M.length,n.createSparseMatrix({values:B,index:M,ptr:O,size:[m,w],datatype:d===n._datatype&&y===i._datatype?D:void 0})}}),Hg="matAlgo10xSids",jg=["typed","DenseMatrix"],Rc=xe(Hg,jg,s=>{var{typed:e,DenseMatrix:t}=s;return function(n,i,a,u){var f=n._values,c=n._index,h=n._ptr,d=n._size,p=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=d[0],x=d[1],_,y=a;typeof p=="string"&&(_=p,i=e.convert(i,_),y=e.find(a,[_,_]));for(var m=[],w=[],D=[],C=0;C<x;C++){for(var b=C+1,F=h[C],B=h[C+1],M=F;M<B;M++){var O=c[M];w[O]=f[M],D[O]=b}for(var A=0;A<v;A++)C===0&&(m[A]=[]),D[A]===b?m[A][C]=u?y(i,w[A]):y(w[A],i):m[A][C]=i}return new t({data:m,size:[v,x],datatype:_})}}),Yg="multiplyScalar",Zg=["typed"],Vg=xe(Yg,Zg,s=>{var{typed:e}=s;return e("multiplyScalar",{"number, number":yc,"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":(t,r)=>r.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,r)=>t.multiply(r)})}),Lc="multiply",Gg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Kg=xe(Lc,Gg,s=>{var{typed:e,matrix:t,addScalar:r,multiplyScalar:n,equalScalar:i,dot:a}=s,u=Ha({typed:e,equalScalar:i}),f=ja({typed:e});function c(b,F){switch(b.length){case 1:switch(F.length){case 1:if(b[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(b[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+b[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(b[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+b[1]+") must match Vector length ("+F[0]+")");break;case 2:if(b[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+b[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 "+b.length+" dimensions)")}}function h(b,F,B){if(B===0)throw new Error("Cannot multiply two empty vectors");return a(b,F)}function d(b,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return p(b,F)}function p(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._data,N=F._size,I=F._datatype||F.getDataType(),R=M[0],k=N[1],z,L=r,G=n;O&&I&&O===I&&typeof O=="string"&&O!=="mixed"&&(z=O,L=e.find(r,[z,z]),G=e.find(n,[z,z]));for(var H=[],ee=0;ee<k;ee++){for(var te=G(B[0],A[0][ee]),j=1;j<R;j++)te=L(te,G(B[j],A[j][ee]));H[ee]=te}return b.createDenseMatrix({data:H,size:[k],datatype:O===b._datatype&&I===F._datatype?z:void 0})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":_,"SparseMatrix, any":w}),x=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":m,"SparseMatrix, DenseMatrix":D,"SparseMatrix, SparseMatrix":C});function _(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._data,N=F._datatype||F.getDataType(),I=M[0],R=M[1],k,z=r,L=n;O&&N&&O===N&&typeof O=="string"&&O!=="mixed"&&(k=O,z=e.find(r,[k,k]),L=e.find(n,[k,k]));for(var G=[],H=0;H<I;H++){for(var ee=B[H],te=L(ee[0],A[0]),j=1;j<R;j++)te=z(te,L(ee[j],A[j]));G[H]=te}return b.createDenseMatrix({data:G,size:[I],datatype:O===b._datatype&&N===F._datatype?k:void 0})}function y(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._data,N=F._size,I=F._datatype||F.getDataType(),R=M[0],k=M[1],z=N[1],L,G=r,H=n;O&&I&&O===I&&typeof O=="string"&&O!=="mixed"&&O!=="mixed"&&(L=O,G=e.find(r,[L,L]),H=e.find(n,[L,L]));for(var ee=[],te=0;te<R;te++){var j=B[te];ee[te]=[];for(var X=0;X<z;X++){for(var Y=H(j[0],A[0][X]),Q=1;Q<k;Q++)Y=G(Y,H(j[Q],A[Q][X]));ee[te][X]=Y}}return b.createDenseMatrix({data:ee,size:[R,z],datatype:O===b._datatype&&I===F._datatype?L:void 0})}function m(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._values,N=F._index,I=F._ptr,R=F._size,k=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!A)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var z=M[0],L=R[1],G,H=r,ee=n,te=i,j=0;O&&k&&O===k&&typeof O=="string"&&O!=="mixed"&&(G=O,H=e.find(r,[G,G]),ee=e.find(n,[G,G]),te=e.find(i,[G,G]),j=e.convert(0,G));for(var X=[],Y=[],Q=[],pe=F.createSparseMatrix({values:X,index:Y,ptr:Q,size:[z,L],datatype:O===b._datatype&&k===F._datatype?G:void 0}),De=0;De<L;De++){Q[De]=Y.length;var we=I[De],be=I[De+1];if(be>we)for(var Oe=0,Fe=0;Fe<z;Fe++){for(var nt=Fe+1,Ye=void 0,Ie=we;Ie<be;Ie++){var Re=N[Ie];Oe!==nt?(Ye=ee(B[Fe][Re],A[Ie]),Oe=nt):Ye=H(Ye,ee(B[Fe][Re],A[Ie]))}Oe===nt&&!te(Ye,j)&&(Y.push(Fe),X.push(Ye))}}return Q[L]=Y.length,pe}function w(b,F){var B=b._values,M=b._index,O=b._ptr,A=b._datatype||b._data===void 0?b._datatype:b.getDataType();if(!B)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var N=F._data,I=F._datatype||F.getDataType(),R=b._size[0],k=F._size[0],z=[],L=[],G=[],H,ee=r,te=n,j=i,X=0;A&&I&&A===I&&typeof A=="string"&&A!=="mixed"&&(H=A,ee=e.find(r,[H,H]),te=e.find(n,[H,H]),j=e.find(i,[H,H]),X=e.convert(0,H));var Y=[],Q=[];G[0]=0;for(var pe=0;pe<k;pe++){var De=N[pe];if(!j(De,X))for(var we=O[pe],be=O[pe+1],Oe=we;Oe<be;Oe++){var Fe=M[Oe];Q[Fe]?Y[Fe]=ee(Y[Fe],te(De,B[Oe])):(Q[Fe]=!0,L.push(Fe),Y[Fe]=te(De,B[Oe]))}}for(var nt=L.length,Ye=0;Ye<nt;Ye++){var Ie=L[Ye];z[Ye]=Y[Ie]}return G[1]=L.length,b.createSparseMatrix({values:z,index:L,ptr:G,size:[R,1],datatype:A===b._datatype&&I===F._datatype?H:void 0})}function D(b,F){var B=b._values,M=b._index,O=b._ptr,A=b._datatype||b._data===void 0?b._datatype:b.getDataType();if(!B)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var N=F._data,I=F._datatype||F.getDataType(),R=b._size[0],k=F._size[0],z=F._size[1],L,G=r,H=n,ee=i,te=0;A&&I&&A===I&&typeof A=="string"&&A!=="mixed"&&(L=A,G=e.find(r,[L,L]),H=e.find(n,[L,L]),ee=e.find(i,[L,L]),te=e.convert(0,L));for(var j=[],X=[],Y=[],Q=b.createSparseMatrix({values:j,index:X,ptr:Y,size:[R,z],datatype:A===b._datatype&&I===F._datatype?L:void 0}),pe=[],De=[],we=0;we<z;we++){Y[we]=X.length;for(var be=we+1,Oe=0;Oe<k;Oe++){var Fe=N[Oe][we];if(!ee(Fe,te))for(var nt=O[Oe],Ye=O[Oe+1],Ie=nt;Ie<Ye;Ie++){var Re=M[Ie];De[Re]!==be?(De[Re]=be,X.push(Re),pe[Re]=H(Fe,B[Ie])):pe[Re]=G(pe[Re],H(Fe,B[Ie]))}}for(var xt=Y[we],Ut=X.length,Et=xt;Et<Ut;Et++){var lr=X[Et];j[Et]=pe[lr]}}return Y[z]=X.length,Q}function C(b,F){var B=b._values,M=b._index,O=b._ptr,A=b._datatype||b._data===void 0?b._datatype:b.getDataType(),N=F._values,I=F._index,R=F._ptr,k=F._datatype||F._data===void 0?F._datatype:F.getDataType(),z=b._size[0],L=F._size[1],G=B&&N,H,ee=r,te=n;A&&k&&A===k&&typeof A=="string"&&A!=="mixed"&&(H=A,ee=e.find(r,[H,H]),te=e.find(n,[H,H]));for(var j=G?[]:void 0,X=[],Y=[],Q=b.createSparseMatrix({values:j,index:X,ptr:Y,size:[z,L],datatype:A===b._datatype&&k===F._datatype?H:void 0}),pe=G?[]:void 0,De=[],we,be,Oe,Fe,nt,Ye,Ie,Re,xt=0;xt<L;xt++){Y[xt]=X.length;var Ut=xt+1;for(nt=R[xt],Ye=R[xt+1],Fe=nt;Fe<Ye;Fe++)if(Re=I[Fe],G)for(be=O[Re],Oe=O[Re+1],we=be;we<Oe;we++)Ie=M[we],De[Ie]!==Ut?(De[Ie]=Ut,X.push(Ie),pe[Ie]=te(N[Fe],B[we])):pe[Ie]=ee(pe[Ie],te(N[Fe],B[we]));else for(be=O[Re],Oe=O[Re+1],we=be;we<Oe;we++)Ie=M[we],De[Ie]!==Ut&&(De[Ie]=Ut,X.push(Ie));if(G)for(var Et=Y[xt],lr=X.length,Lr=Et;Lr<lr;Lr++){var cr=X[Lr];j[Lr]=pe[cr]}}return Y[L]=X.length,Q}return e(Lc,n,{"Array, Array":e.referTo("Matrix, Matrix",b=>(F,B)=>{c(Lt(F),Lt(B));var M=b(t(F),t(B));return mt(M)?M.valueOf():M}),"Matrix, Matrix":function(F,B){var M=F.size(),O=B.size();return c(M,O),M.length===1?O.length===1?h(F,B,M[0]):d(F,B):O.length===1?v(F,B):x(F,B)},"Matrix, Array":e.referTo("Matrix,Matrix",b=>(F,B)=>b(F,t(B))),"Array, Matrix":e.referToSelf(b=>(F,B)=>b(t(F,B.storage()),B)),"SparseMatrix, any":function(F,B){return u(F,B,n,!1)},"DenseMatrix, any":function(F,B){return f(F,B,n,!1)},"any, SparseMatrix":function(F,B){return u(B,F,n,!0)},"any, DenseMatrix":function(F,B){return f(B,F,n,!0)},"Array, any":function(F,B){return f(t(F),B,n,!1).valueOf()},"any, Array":function(F,B){return f(t(B),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(b=>(F,B,M)=>{for(var O=b(F,B),A=0;A<M.length;A++)O=b(O,M[A]);return O})})}),Pc="subtract",Xg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Qg=xe(Pc,Xg,s=>{var{typed:e,matrix:t,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:u}=s,f=$c({typed:e}),c=Fi({typed:e}),h=Tc({typed:e,equalScalar:r}),d=Rc({typed:e,DenseMatrix:a}),p=Ci({typed:e,DenseMatrix:a}),v=ri({typed:e,matrix:t,concat:u});return e(Pc,{"any, any":n},v({elop:n,SS:h,DS:f,SD:c,Ss:p,sS:d}))}),Jg="matAlgo07xSSf",em=["typed","DenseMatrix"],uo=xe(Jg,em,s=>{var{typed:e,DenseMatrix:t}=s;return function(i,a,u){var f=i._size,c=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=a._size,d=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(f.length!==h.length)throw new rt(f.length,h.length);if(f[0]!==h[0]||f[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+h+")");var p=f[0],v=f[1],x,_=0,y=u;typeof c=="string"&&c===d&&c!=="mixed"&&(x=c,_=e.convert(0,x),y=e.find(u,[x,x]));var m,w,D=[];for(m=0;m<p;m++)D[m]=[];var C=[],b=[],F=[],B=[];for(w=0;w<v;w++){var M=w+1;for(r(i,w,F,C,M),r(a,w,B,b,M),m=0;m<p;m++){var O=F[m]===M?C[m]:_,A=B[m]===M?b[m]:_;D[m][w]=y(O,A)}}return new t({data:D,size:[p,v],datatype:c===i._datatype&&d===a._datatype?x:void 0})};function r(n,i,a,u,f){for(var c=n._values,h=n._index,d=n._ptr,p=d[i],v=d[i+1];p<v;p++){var x=h[p];a[x]=f,u[x]=c[p]}}}),kc="conj",tm=["typed"],rm=xe(kc,tm,s=>{var{typed:e}=s;return e(kc,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),zc="concat",nm=["typed","matrix","isInteger"],im=xe(zc,nm,s=>{var{typed:e,matrix:t,isInteger:r}=s;return e(zc,{"...Array | Matrix | number | BigNumber":function(i){var a,u=i.length,f=-1,c,h=!1,d=[];for(a=0;a<u;a++){var p=i[a];if(mt(p)&&(h=!0),pt(p)||St(p)){if(a!==u-1)throw new Error("Dimension must be specified as last argument");if(c=f,f=p.valueOf(),!r(f))throw new TypeError("Integer number expected for dimension");if(f<0||a>0&&f>c)throw new On(f,c+1)}else{var v=ut(p).valueOf(),x=Lt(v);if(d[a]=v,c=f,f=x.length-1,a>0&&f!==c)throw new rt(c+1,f+1)}}if(d.length===0)throw new SyntaxError("At least one matrix expected");for(var _=d.shift();d.length;)_=Zl(_,d.shift(),f);return h?t(_):_},"...string":function(i){return i.join("")}})}),qc="count",sm=["typed","size","prod"],om=xe(qc,sm,s=>{var{typed:e,size:t,prod:r}=s;return e(qc,{string:function(i){return i.length},"Matrix | Array":function(i){return r(t(i))}})}),Uc="identity",am=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],um=xe(Uc,am,s=>{var{typed:e,config:t,matrix:r,BigNumber:n,DenseMatrix:i,SparseMatrix:a}=s;return e(Uc,{"":function(){return t.matrix==="Matrix"?r([]):[]},string:function(h){return r(h)},"number | BigNumber":function(h){return f(h,h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,d){return f(h,h,d)},"number | BigNumber, number | BigNumber":function(h,d){return f(h,d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,d,p){return f(h,d,p)},Array:function(h){return u(h)},"Array, string":function(h,d){return u(h,d)},Matrix:function(h){return u(h.valueOf(),h.storage())},"Matrix, string":function(h,d){return u(h.valueOf(),d)}});function u(c,h){switch(c.length){case 0:return h?r(h):[];case 1:return f(c[0],c[0],h);case 2:return f(c[0],c[1],h);default:throw new Error("Vector containing two values expected")}}function f(c,h,d){var p=St(c)||St(h)?n:null;if(St(c)&&(c=c.toNumber()),St(h)&&(h=h.toNumber()),!bt(c)||c<1)throw new Error("Parameters in function identity must be positive integers");if(!bt(h)||h<1)throw new Error("Parameters in function identity must be positive integers");var v=p?new n(1):1,x=p?new p(0):0,_=[c,h];if(d){if(d==="sparse")return a.diagonal(_,v,0,x);if(d==="dense")return i.diagonal(_,v,0,x);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}for(var y=Na([],_,x),m=c<h?c:h,w=0;w<m;w++)y[w][w]=v;return y}}),Wc="kron",lm=["typed","matrix","multiplyScalar"],cm=xe(Wc,lm,s=>{var{typed:e,matrix:t,multiplyScalar:r}=s;return e(Wc,{"Matrix, Matrix":function(a,u){return t(n(a.toArray(),u.toArray()))},"Matrix, Array":function(a,u){return t(n(a.toArray(),u))},"Array, Matrix":function(a,u){return t(n(a,u.toArray()))},"Array, Array":n});function n(i,a){if(Lt(i).length===1&&(i=[i]),Lt(a).length===1&&(a=[a]),Lt(i).length>2||Lt(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(a.length)+")");var u=[],f=[];return i.map(function(c){return a.map(function(h){return f=[],u.push(f),c.map(function(d){return h.map(function(p){return f.push(r(d,p))})})})})&&u}});function fm(){throw new Error('No "bignumber" implementation available')}function hm(){throw new Error('No "fraction" implementation available')}function dm(){throw new Error('No "matrix" implementation available')}var Hc="reshape",pm=["typed","isInteger","matrix"],_m=xe(Hc,pm,s=>{var{typed:e,isInteger:t}=s;return e(Hc,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(a){if(!t(a))throw new TypeError("Invalid size for dimension: "+a)}),Oa(n,i)}})}),jc="size",vm=["typed","config","?matrix"],gm=xe(jc,vm,s=>{var{typed:e,config:t,matrix:r}=s;return e(jc,{Matrix:function(i){return i.create(i.size())},Array:Lt,string:function(i){return t.matrix==="Array"?[i.length]:r([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return t.matrix==="Array"?[]:r?r([]):dm()}})}),Yc="transpose",mm=["typed","matrix"],xm=xe(Yc,mm,s=>{var{typed:e,matrix:t}=s;return e(Yc,{Array:a=>r(t(a)).valueOf(),Matrix:r,any:ut});function r(a){var u=a.size(),f;switch(u.length){case 1:f=a.clone();break;case 2:{var c=u[0],h=u[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+ct(u)+")");switch(a.storage()){case"dense":f=n(a,c,h);break;case"sparse":f=i(a,c,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+ct(u)+")")}return f}function n(a,u,f){for(var c=a._data,h=[],d,p=0;p<f;p++){d=h[p]=[];for(var v=0;v<u;v++)d[v]=ut(c[v][p])}return a.createDenseMatrix({data:h,size:[f,u],datatype:a._datatype})}function i(a,u,f){for(var c=a._values,h=a._index,d=a._ptr,p=c?[]:void 0,v=[],x=[],_=[],y=0;y<u;y++)_[y]=0;var m,w,D;for(m=0,w=h.length;m<w;m++)_[h[m]]++;for(var C=0,b=0;b<u;b++)x.push(C),C+=_[b],_[b]=x[b];for(x.push(C),D=0;D<f;D++)for(var F=d[D],B=d[D+1],M=F;M<B;M++){var O=_[h[M]]++;v[O]=D,c&&(p[O]=ut(c[M]))}return a.createSparseMatrix({values:p,index:v,ptr:x,size:[f,u],datatype:a._datatype})}}),Zc="ctranspose",ym=["typed","transpose","conj"],Dm=xe(Zc,ym,s=>{var{typed:e,transpose:t,conj:r}=s;return e(Zc,{any:function(i){return r(t(i))}})}),Vc="mode",wm=["typed","isNaN","isNumeric"],bm=xe(Vc,wm,s=>{var{typed:e,isNaN:t,isNumeric:r}=s;return e(Vc,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(i){i=Ta(i.valueOf());var a=i.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var u={},f=[],c=0,h=0;h<i.length;h++){var d=i[h];if(r(d)&&t(d))throw new Error("Cannot calculate mode of an array containing NaN values");d in u||(u[d]=0),u[d]++,u[d]===c?f.push(d):u[d]>c&&(c=u[d],f=[d])}return f}});function Ln(s,e,t){var r;return String(s).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+Sn(t)+", value: "+JSON.stringify(t)+")":" (type: "+s.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+r)):String(s).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+Sn(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+r)):s}var Gc="prod",Em=["typed","config","multiplyScalar","numeric"],Am=xe(Gc,Em,s=>{var{typed:e,config:t,multiplyScalar:r,numeric:n}=s;return e(Gc,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(u,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(u){return i(u)}});function i(a){var u;if(as(a,function(f){try{u=u===void 0?f:r(u,f)}catch(c){throw Ln(c,"prod",f)}}),typeof u=="string"&&(u=n(u,t.number)),u===void 0)throw new Error("Cannot calculate prod of an empty array");return u}}),Cm="numeric",Fm=["number","?bignumber","?fraction"],Bm=xe(Cm,Fm,s=>{var{number:e,bignumber:t,fraction:r}=s,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:a=>e(a),BigNumber:t?a=>t(a):fm,Fraction:r?a=>r(a):hm};return function(u){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",c=arguments.length>2?arguments[2]:void 0;if(c!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var h=Sn(u);if(!(h in n))throw new TypeError("Cannot convert "+u+' of type "'+h+'"; valid input types are '+Object.keys(n).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+u+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===h?u:i[f](u)}}),Kc="divideScalar",Mm=["typed","numeric"],Nm=xe(Kc,Mm,s=>{var{typed:e,numeric:t}=s;return e(Kc,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),Xc="pow",Sm=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Om=xe(Xc,Sm,s=>{var{typed:e,config:t,identity:r,multiply:n,matrix:i,inv:a,number:u,fraction:f,Complex:c}=s;return e(Xc,{"number, number":h,"Complex, Complex":function(x,_){return x.pow(_)},"BigNumber, BigNumber":function(x,_){return _.isInteger()||x>=0||t.predictable?x.pow(_):new c(x.toNumber(),0).pow(_.toNumber(),0)},"Fraction, Fraction":function(x,_){var y=x.pow(_);if(y!=null)return y;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return h(x.valueOf(),_.valueOf())},"Array, number":d,"Array, BigNumber":function(x,_){return d(x,_.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(x,_){return p(x,_.toNumber())},"Unit, number | BigNumber":function(x,_){return x.pow(_)}});function h(v,x){if(t.predictable&&!bt(x)&&v<0)try{var _=f(x),y=u(_);if((x===y||Math.abs((x-y)/x)<1e-14)&&_.d%2===1)return(_.n%2===0?1:-1)*Math.pow(-v,x)}catch{}return t.predictable&&(v<-1&&x===1/0||v>-1&&v<0&&x===-1/0)?NaN:bt(x)||v>=0||t.predictable?wc(v,x):v*v<1&&x===1/0||v*v>1&&x===-1/0?0:new c(v,0).pow(x,0)}function d(v,x){if(!bt(x))throw new TypeError("For A^b, b must be an integer (value is "+x+")");var _=Lt(v);if(_.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+_.length+" dimensions)");if(_[0]!==_[1])throw new Error("For A^b, A must be square (size is "+_[0]+"x"+_[1]+")");if(x<0)try{return d(a(v),-x)}catch(w){throw w.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 "+x+")"):w}for(var y=r(_[0]).valueOf(),m=v;x>=1;)(x&1)===1&&(y=n(m,y)),x>>=1,m=n(m,m);return y}function p(v,x){return i(d(v.valueOf(),x))}}),Qc="dotDivide",Im=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Tm=xe(Qc,Im,s=>{var{typed:e,matrix:t,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,u=Cg({typed:e,equalScalar:r}),f=Fi({typed:e}),c=uo({typed:e,DenseMatrix:i}),h=Ha({typed:e,equalScalar:r}),d=Ci({typed:e,DenseMatrix:i}),p=ri({typed:e,matrix:t,concat:a});return e(Qc,p({elop:n,SS:c,DS:f,SD:u,Ss:h,sS:d}))}),lo="compare",$m=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],Rm=xe(lo,$m,s=>{var{typed:e,config:t,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:u,concat:f}=s,c=Fi({typed:e}),h=Tc({typed:e,equalScalar:r}),d=Ci({typed:e,DenseMatrix:u}),p=ri({typed:e,matrix:n,concat:f}),v=oo({typed:e});return e(lo,Lm({typed:e,config:t}),{"boolean, boolean":function(_,y){return _===y?0:_>y?1:-1},"BigNumber, BigNumber":function(_,y){return so(_,y,t.epsilon)?new i(0):new i(_.cmp(y))},"Fraction, Fraction":function(_,y){return new a(_.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,p({SS:h,DS:c,Ss:d}))}),Lm=xe(lo,["typed","config"],s=>{var{typed:e,config:t}=s;return e(lo,{"number, number":function(n,i){return ti(n,i,t.epsilon)?0:n>i?1:-1}})}),co="equal",Pm=["typed","matrix","equalScalar","DenseMatrix","concat"],km=xe(co,Pm,s=>{var{typed:e,matrix:t,equalScalar:r,DenseMatrix:n,concat:i}=s,a=Fi({typed:e}),u=uo({typed:e,DenseMatrix:n}),f=Ci({typed:e,DenseMatrix:n}),c=ri({typed:e,matrix:t,concat:i});return e(co,zm({typed:e,equalScalar:r}),c({elop:r,SS:u,DS:a,Ss:f}))}),zm=xe(co,["typed","equalScalar"],s=>{var{typed:e,equalScalar:t}=s;return e(co,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:t(n,i)}})}),fo="smaller",qm=["typed","config","matrix","DenseMatrix","concat"],Um=xe(fo,qm,s=>{var{typed:e,config:t,matrix:r,DenseMatrix:n,concat:i}=s,a=Fi({typed:e}),u=uo({typed:e,DenseMatrix:n}),f=Ci({typed:e,DenseMatrix:n}),c=ri({typed:e,matrix:r,concat:i}),h=oo({typed:e});return e(fo,Wm({typed:e,config:t}),{"boolean, boolean":(d,p)=>d<p,"BigNumber, BigNumber":function(p,v){return p.lt(v)&&!so(p,v,t.epsilon)},"Fraction, Fraction":(d,p)=>d.compare(p)===-1,"Complex, Complex":function(p,v){throw new TypeError("No ordering relation is defined for complex numbers")}},h,c({SS:u,DS:a,Ss:f}))}),Wm=xe(fo,["typed","config"],s=>{var{typed:e,config:t}=s;return e(fo,{"number, number":function(n,i){return n<i&&!ti(n,i,t.epsilon)}})}),ho="larger",Hm=["typed","config","matrix","DenseMatrix","concat"],jm=xe(ho,Hm,s=>{var{typed:e,config:t,matrix:r,DenseMatrix:n,concat:i}=s,a=Fi({typed:e}),u=uo({typed:e,DenseMatrix:n}),f=Ci({typed:e,DenseMatrix:n}),c=ri({typed:e,matrix:r,concat:i}),h=oo({typed:e});return e(ho,Ym({typed:e,config:t}),{"boolean, boolean":(d,p)=>d>p,"BigNumber, BigNumber":function(p,v){return p.gt(v)&&!so(p,v,t.epsilon)},"Fraction, Fraction":(d,p)=>d.compare(p)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,c({SS:u,DS:a,Ss:f}))}),Ym=xe(ho,["typed","config"],s=>{var{typed:e,config:t}=s;return e(ho,{"number, number":function(n,i){return n>i&&!ti(n,i,t.epsilon)}})}),Jc="deepEqual",Zm=["typed","equal"],Vm=xe(Jc,Zm,s=>{var{typed:e,equal:t}=s;return e(Jc,{"any, any":function(i,a){return r(i.valueOf(),a.valueOf())}});function r(n,i){if(Array.isArray(n))if(Array.isArray(i)){var a=n.length;if(a!==i.length)return!1;for(var u=0;u<a;u++)if(!r(n[u],i[u]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),ef="partitionSelect",Gm=["typed","isNumeric","isNaN","compare"],Km=xe(ef,Gm,s=>{var{typed:e,isNumeric:t,isNaN:r,compare:n}=s,i=n,a=(c,h)=>-n(c,h);return e(ef,{"Array | Matrix, number":function(h,d){return u(h,d,i)},"Array | Matrix, number, string":function(h,d,p){if(p==="asc")return u(h,d,i);if(p==="desc")return u(h,d,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":u});function u(c,h,d){if(!bt(h)||h<0)throw new Error("k must be a non-negative integer");if(mt(c)){var p=c.size();if(p.length>1)throw new Error("Only one dimensional matrices supported");return f(c.valueOf(),h,d)}if(Array.isArray(c))return f(c,h,d)}function f(c,h,d){if(h>=c.length)throw new Error("k out of bounds");for(var p=0;p<c.length;p++)if(t(c[p])&&r(c[p]))return c[p];for(var v=0,x=c.length-1;v<x;){for(var _=v,y=x,m=c[Math.floor(Math.random()*(x-v+1))+v];_<y;)if(d(c[_],m)>=0){var w=c[y];c[y]=c[_],c[_]=w,--y}else++_;d(c[_],m)>0&&--_,h<=_?x=_:v=_+1}return c[h]}}),tf="max",Xm=["typed","config","numeric","larger"],Qm=xe(tf,Xm,s=>{var{typed:e,config:t,numeric:r,larger:n}=s;return e(tf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(f,c){return Wa(f,c.valueOf(),i)},"...":function(f){if(ro(f))throw new TypeError("Scalar values expected in function max");return a(f)}});function i(u,f){try{return n(u,f)?u:f}catch(c){throw Ln(c,"max",f)}}function a(u){var f;if(as(u,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||n(c,f))&&(f=c)}catch(h){throw Ln(h,"max",c)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=r(f,t.number)),f}}),rf="min",Jm=["typed","config","numeric","smaller"],ex=xe(rf,Jm,s=>{var{typed:e,config:t,numeric:r,smaller:n}=s;return e(rf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(f,c){return Wa(f,c.valueOf(),i)},"...":function(f){if(ro(f))throw new TypeError("Scalar values expected in function min");return a(f)}});function i(u,f){try{return n(u,f)?u:f}catch(c){throw Ln(c,"min",f)}}function a(u){var f;if(as(u,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||n(c,f))&&(f=c)}catch(h){throw Ln(h,"min",c)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=r(f,t.number)),f}}),nf="add",tx=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],rx=xe(nf,tx,s=>{var{typed:e,matrix:t,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:u}=s,f=$c({typed:e}),c=Wg({typed:e,equalScalar:n}),h=Rc({typed:e,DenseMatrix:i}),d=ri({typed:e,matrix:t,concat:u});return e(nf,{"any, any":r,"any, any, ...any":e.referToSelf(p=>(v,x,_)=>{for(var y=p(v,x),m=0;m<_.length;m++)y=p(y,_[m]);return y})},d({elop:r,DS:f,SS:c,Ss:h}))}),sf="dot",nx=["typed","addScalar","multiplyScalar","conj","size"],ix=xe(sf,nx,s=>{var{typed:e,addScalar:t,multiplyScalar:r,conj:n,size:i}=s;return e(sf,{"Array | DenseMatrix, Array | DenseMatrix":u,"SparseMatrix, SparseMatrix":f});function a(h,d){var p=c(h),v=c(d),x,_;if(p.length===1)x=p[0];else if(p.length===2&&p[1]===1)x=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(v.length===1)_=v[0];else if(v.length===2&&v[1]===1)_=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(x!==_)throw new RangeError("Vectors must have equal length ("+x+" != "+_+")");if(x===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return x}function u(h,d){var p=a(h,d),v=mt(h)?h._data:h,x=mt(h)?h._datatype||h.getDataType():void 0,_=mt(d)?d._data:d,y=mt(d)?d._datatype||d.getDataType():void 0,m=c(h).length===2,w=c(d).length===2,D=t,C=r;if(x&&y&&x===y&&typeof x=="string"&&x!=="mixed"){var b=x;D=e.find(t,[b,b]),C=e.find(r,[b,b])}if(!m&&!w){for(var F=C(n(v[0]),_[0]),B=1;B<p;B++)F=D(F,C(n(v[B]),_[B]));return F}if(!m&&w){for(var M=C(n(v[0]),_[0][0]),O=1;O<p;O++)M=D(M,C(n(v[O]),_[O][0]));return M}if(m&&!w){for(var A=C(n(v[0][0]),_[0]),N=1;N<p;N++)A=D(A,C(n(v[N][0]),_[N]));return A}if(m&&w){for(var I=C(n(v[0][0]),_[0][0]),R=1;R<p;R++)I=D(I,C(n(v[R][0]),_[R][0]));return I}}function f(h,d){a(h,d);for(var p=h._index,v=h._values,x=d._index,_=d._values,y=0,m=t,w=r,D=0,C=0;D<p.length&&C<x.length;){var b=p[D],F=x[C];if(b<F){D++;continue}if(b>F){C++;continue}b===F&&(y=m(y,w(v[D],_[C])),D++,C++)}return y}function c(h){return mt(h)?h.size():i(h)}}),sx="trace",ox=["typed","matrix","add"],ax=xe(sx,ox,s=>{var{typed:e,matrix:t,add:r}=s;return e("trace",{Array:function(u){return n(t(u))},SparseMatrix:i,DenseMatrix:n,any:ut});function n(a){var u=a._size,f=a._data;switch(u.length){case 1:if(u[0]===1)return ut(f[0]);throw new RangeError("Matrix must be square (size: "+ct(u)+")");case 2:{var c=u[0],h=u[1];if(c===h){for(var d=0,p=0;p<c;p++)d=r(d,f[p][p]);return d}else throw new RangeError("Matrix must be square (size: "+ct(u)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(u)+")")}}function i(a){var u=a._values,f=a._index,c=a._ptr,h=a._size,d=h[0],p=h[1];if(d===p){var v=0;if(u.length>0)for(var x=0;x<p;x++)for(var _=c[x],y=c[x+1],m=_;m<y;m++){var w=f[m];if(w===x){v=r(v,u[m]);break}if(w>x)break}return v}throw new RangeError("Matrix must be square (size: "+ct(h)+")")}}),of="det",ux=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],lx=xe(of,ux,s=>{var{typed:e,matrix:t,subtractScalar:r,multiply:n,divideScalar:i,isZero:a,unaryMinus:u}=s;return e(of,{any:function(h){return ut(h)},"Array | Matrix":function(h){var d;switch(mt(h)?d=h.size():Array.isArray(h)?(h=t(h),d=h.size()):d=[],d.length){case 0:return ut(h);case 1:if(d[0]===1)return ut(h.valueOf()[0]);if(d[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+ct(d)+")");case 2:{var p=d[0],v=d[1];if(p===v)return f(h.clone().valueOf(),p);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+ct(d)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(d)+")")}}});function f(c,h,d){if(h===1)return ut(c[0][0]);if(h===2)return r(n(c[0][0],c[1][1]),n(c[1][0],c[0][1]));for(var p=!1,v=new Array(h).fill(0).map((B,M)=>M),x=0;x<h;x++){var _=v[x];if(a(c[_][x])){var y=void 0;for(y=x+1;y<h;y++)if(!a(c[v[y]][x])){_=v[y],v[y]=v[x],v[x]=_,p=!p;break}if(y===h)return c[_][x]}for(var m=c[_][x],w=x===0?1:c[v[x-1]][x-1],D=x+1;D<h;D++)for(var C=v[D],b=x+1;b<h;b++)c[C][b]=i(r(n(c[C][b],m),n(c[C][x],c[_][b])),w)}var F=c[v[h-1]][h-1];return p?u(F):F}}),af="inv",cx=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],fx=xe(af,cx,s=>{var{typed:e,matrix:t,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:u,identity:f,abs:c}=s;return e(af,{"Array | Matrix":function(p){var v=mt(p)?p.size():Lt(p);switch(v.length){case 1:if(v[0]===1)return mt(p)?t([r(1,p.valueOf()[0])]):[r(1,p[0])];throw new RangeError("Matrix must be square (size: "+ct(v)+")");case 2:{var x=v[0],_=v[1];if(x===_)return mt(p)?t(h(p.valueOf(),x,_),p.storage()):h(p,x,_);throw new RangeError("Matrix must be square (size: "+ct(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(v)+")")}},any:function(p){return r(1,p)}});function h(d,p,v){var x,_,y,m,w;if(p===1){if(m=d[0][0],m===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,m)]]}else if(p===2){var D=u(d);if(D===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(d[1][1],D),r(a(d[0][1]),D)],[r(a(d[1][0]),D),r(d[0][0],D)]]}else{var C=d.concat();for(x=0;x<p;x++)C[x]=C[x].concat();for(var b=f(p).valueOf(),F=0;F<v;F++){var B=c(C[F][F]),M=F;for(x=F+1;x<p;)c(C[x][F])>B&&(B=c(C[x][F]),M=x),x++;if(B===0)throw Error("Cannot calculate inverse, determinant is zero");x=M,x!==F&&(w=C[F],C[F]=C[x],C[x]=w,w=b[F],b[F]=b[x],b[x]=w);var O=C[F],A=b[F];for(x=0;x<p;x++){var N=C[x],I=b[x];if(x!==F){if(N[F]!==0){for(y=r(a(N[F]),O[F]),_=F;_<v;_++)N[_]=n(N[_],i(y,O[_]));for(_=0;_<v;_++)I[_]=n(I[_],i(y,A[_]))}}else{for(y=O[F],_=F;_<v;_++)N[_]=r(N[_],y);for(_=0;_<v;_++)I[_]=r(I[_],y)}}}return b}}}),uf="pinv",hx=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],dx=xe(uf,hx,s=>{var{typed:e,matrix:t,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:u,ctranspose:f,divideScalar:c,multiply:h,add:d,Complex:p}=s;return e(uf,{"Array | Matrix":function(D){var C=mt(D)?D.size():Lt(D);switch(C.length){case 1:return m(D)?f(D):C[0]===1?r(D):a(f(D),u(D,D));case 2:{if(m(D))return f(D);var b=C[0],F=C[1];if(b===F)try{return r(D)}catch(B){if(!(B instanceof Error&&B.message.match(/Cannot calculate inverse, determinant is zero/)))throw B}return mt(D)?t(v(D.valueOf(),b,F),D.storage()):v(D,b,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(C)+")")}},any:function(D){return i(D,0)?ut(D):c(1,D)}});function v(w,D,C){var{C:b,F}=_(w,D,C),B=h(r(h(f(b),b)),f(b)),M=h(f(F),r(h(F,f(F))));return h(M,B)}function x(w,D,C){for(var b=ut(w),F=0,B=0;B<D;B++){if(C<=F)return b;for(var M=B;y(b[M][F]);)if(M++,D===M&&(M=B,F++,C===F))return b;[b[M],b[B]]=[b[B],b[M]];for(var O=b[B][F],A=0;A<C;A++)b[B][A]=a(b[B][A],O);for(var N=0;N<D;N++)if(N!==B){O=b[N][F];for(var I=0;I<C;I++)b[N][I]=d(b[N][I],h(-1,h(O,b[B][I])))}F++}return b}function _(w,D,C){var b=x(w,D,C),F=w.map((M,O)=>M.filter((A,N)=>N<D&&!y(u(b[N],b[N])))),B=b.filter((M,O)=>!y(u(b[O],b[O])));return{C:F,F:B}}function y(w){return i(d(w,p(1,1)),d(0,p(1,1)))}function m(w){return n(d(w,p(1,1)),d(h(w,0),p(1,1)))}}),px="divide",_x=["typed","matrix","multiply","equalScalar","divideScalar","inv"],vx=xe(px,_x,s=>{var{typed:e,matrix:t,multiply:r,equalScalar:n,divideScalar:i,inv:a}=s,u=Ha({typed:e,equalScalar:n}),f=ja({typed:e});return e("divide",Fl({"Array | Matrix, Array | Matrix":function(h,d){return r(h,a(d))},"DenseMatrix, any":function(h,d){return f(h,d,i,!1)},"SparseMatrix, any":function(h,d){return u(h,d,i,!1)},"Array, any":function(h,d){return f(t(h),d,i,!1).valueOf()},"any, Array | Matrix":function(h,d){return r(h,a(d))}},i.signatures))}),lf="sum",gx=["typed","config","add","numeric"],mx=xe(lf,gx,s=>{var{typed:e,config:t,add:r,numeric:n}=s;return e(lf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(f){if(ro(f))throw new TypeError("Scalar values expected in function sum");return i(f)}});function i(u){var f;return as(u,function(c){try{f=f===void 0?c:r(f,c)}catch(h){throw Ln(h,"sum",c)}}),f===void 0&&(f=n(0,t.number)),typeof f=="string"&&(f=n(f,t.number)),f}function a(u,f){try{var c=Wa(u,f,r);return c}catch(h){throw Ln(h,"sum")}}}),cf="median",xx=["typed","add","divide","compare","partitionSelect"],yx=xe(cf,xx,s=>{var{typed:e,add:t,divide:r,compare:n,partitionSelect:i}=s;function a(c){try{c=Ta(c.valueOf());var h=c.length;if(h===0)throw new Error("Cannot calculate median of an empty array");if(h%2===0){for(var d=h/2-1,p=i(c,d+1),v=c[d],x=0;x<d;++x)n(c[x],v)>0&&(v=c[x]);return f(v,p)}else{var _=i(c,(h-1)/2);return u(_)}}catch(y){throw Ln(y,"median")}}var u=e({"number | BigNumber | Complex | Unit":function(h){return h}}),f=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,d){return r(t(h,d),2)}});return e(cf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,d){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(ro(h))throw new TypeError("Scalar values expected in function median");return a(h)}})}),Dx={},wx=Object.freeze({__proto__:null,default:Dx}),bx=Mt(wx),po=Dv({config:Er}),Ya=Av({}),Za=Mv({}),Va=Ov({}),cn=$v({Matrix:Va}),Te=E_({BigNumber:po,Complex:Ya,DenseMatrix:cn,Fraction:Za}),Ex=dg({typed:Te}),_o=_g({typed:Te}),Ax=ig({BigNumber:po,typed:Te}),ff=rm({typed:Te}),Pn=Zv({config:Er,typed:Te}),vo=Pv({typed:Te}),Cx=Uv({typed:Te}),go=Vg({typed:Te}),hf=tg({typed:Te}),Ga=Kv({Matrix:Va,equalScalar:Pn,typed:Te}),df=gg({typed:Te}),pf=Hv({typed:Te}),Ka=fg({typed:Te}),_f=ag({Fraction:Za,typed:Te}),vf=zv({typed:Te}),Pt=lg({DenseMatrix:cn,Matrix:Va,SparseMatrix:Ga,typed:Te}),gf=bm({isNaN:pf,isNumeric:vf,typed:Te}),us=Bm({bignumber:Ax,fraction:_f,number:hf}),Fx=Am({config:Er,multiplyScalar:go,numeric:us,typed:Te}),Bx=_m({isInteger:vo,matrix:Pt,typed:Te}),mf=gm({matrix:Pt,config:Er,typed:Te}),xf=xm({matrix:Pt,typed:Te}),ni=im({isInteger:vo,matrix:Pt,typed:Te}),Mx=om({prod:Fx,size:mf,typed:Te}),Nx=Dm({conj:ff,transpose:xf,typed:Te}),ls=Nm({numeric:us,typed:Te}),Sx=Tm({DenseMatrix:cn,concat:ni,divideScalar:ls,equalScalar:Pn,matrix:Pt,typed:Te}),yf=km({DenseMatrix:cn,concat:ni,equalScalar:Pn,matrix:Pt,typed:Te}),Df=um({BigNumber:po,DenseMatrix:cn,SparseMatrix:Ga,config:Er,matrix:Pt,typed:Te}),Ox=cm({matrix:Pt,multiplyScalar:go,typed:Te}),Ix=Um({DenseMatrix:cn,concat:ni,config:Er,matrix:Pt,typed:Te}),Tx=Qg({DenseMatrix:cn,concat:ni,equalScalar:Pn,matrix:Pt,subtractScalar:df,typed:Te,unaryMinus:Ka}),cs=rx({DenseMatrix:cn,SparseMatrix:Ga,addScalar:_o,concat:ni,equalScalar:Pn,matrix:Pt,typed:Te}),wf=Rm({BigNumber:po,DenseMatrix:cn,Fraction:Za,concat:ni,config:Er,equalScalar:Pn,matrix:Pt,typed:Te}),$x=Vm({equal:yf,typed:Te}),bf=ix({addScalar:_o,conj:ff,multiplyScalar:go,size:mf,typed:Te}),Rx=jm({DenseMatrix:cn,concat:ni,config:Er,matrix:Pt,typed:Te}),Xa=ex({config:Er,numeric:us,smaller:Ix,typed:Te}),Bi=Kg({addScalar:_o,dot:bf,equalScalar:Pn,matrix:Pt,multiplyScalar:go,typed:Te}),Lx=Km({compare:wf,isNaN:pf,isNumeric:vf,typed:Te}),Px=mx({add:cs,config:Er,numeric:us,typed:Te}),kx=ax({add:cs,matrix:Pt,typed:Te}),Ef=lx({divideScalar:ls,isZero:Cx,matrix:Pt,multiply:Bi,subtractScalar:df,typed:Te,unaryMinus:Ka}),zx=Qm({config:Er,larger:Rx,numeric:us,typed:Te}),mo=fx({abs:Ex,addScalar:_o,det:Ef,divideScalar:ls,identity:Df,matrix:Pt,multiply:Bi,typed:Te,unaryMinus:Ka}),qx=dx({Complex:Ya,add:cs,ctranspose:Nx,deepEqual:$x,divideScalar:ls,dot:bf,dotDivide:Sx,equal:yf,inv:mo,matrix:Pt,multiply:Bi,typed:Te}),Ux=Om({Complex:Ya,config:Er,fraction:_f,identity:Df,inv:mo,matrix:Pt,multiply:Bi,number:hf,typed:Te}),Wx=vx({divideScalar:ls,equalScalar:Pn,inv:mo,matrix:Pt,multiply:Bi,typed:Te}),Af=yx({add:cs,compare:wf,divide:Wx,partitionSelect:Lx,typed:Te});class Hx{constructor(e,t,r){U(this,"_cacheData");U(this,"_variables");U(this,"_math");U(this,"_timeframe");this._cacheData={},this._variables=e,this._math=t,this._timeframe=r}alma({series:e,length:t,offset:r,sigma:n,floor:i},a){if(t===void 0||r===void 0||n===void 0)return;const u=this._cacheDataList(e,t,`alma_${a}`);if(u===void 0)return;let f=r*(t-1);i&&(f=Math.floor(f));const c=t/n;let h=0,d=0;for(let p=0;p<=t-1;p++){const v=Math.exp(-1*Math.pow(p-f,2)/(2*Math.pow(c,2)));h+=v,d+=u[u.length-1-(t-p-1)]*v}return d/h}sma({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;let n=0;const i=this._cacheDataList(e,t,`sma_${r}`);if(i===void 0)return;const a=i.slice(-t);return n=Px(...a)/t,n}rma({source:e,length:t},r){if(e===void 0||t===void 0||isNaN(e))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=e,this._cacheData[`sma_${r}`]=n;const{sum:i}=this._cacheData[`rma_${r}`]||{},a=1/t,u=i===void 0?this.sma({source:e,length:t},r):a*e+(1-a)*(i||0);return this._cacheDataHandle(`rma_${r}`,{sum:u}),u}atr({length:e},t){const{high:r,close:n}=this._cacheData[`atr_${t}`]||{},{high:i,close:a,low:u}=this._variables,f=r===void 0?i-u:Math.max(Math.max(i-u,Math.abs(i-n)),Math.abs(u-n));return this._cacheDataHandle(`atr_${t}`,{high:i,close:a}),this.rma({source:f,length:e},t)}barssince({condition:e},t){let{count:r}=this._cacheData[`barssince_${t}`]||{};if(e)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${t}`,{count:r}),r}stdev({source:e,length:t,biased:r=!0},n){if(e===void 0||isNaN(e)||t===void 0)return;const i=this._cacheDataList(e,t,`stdev_${n}`),a=this.sma({source:e,length:t},n);if(i===void 0)return;let u=0;for(let f=0;f<t;f++){const c=this._sum(i[i.length-1-f],-(a||0));u+=c*c}return r||t<=1?Math.sqrt(u/t):Math.sqrt(u/(t-1))}_sum(e,t){let n=e+t;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:e,length:t,mult:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return[];const i=this.sma({source:e,length:t},n),a=this.stdev({source:e,length:t},n);if(i===void 0||a===void 0)return[];const u=r*a;return[i,i+u,i-u]}bbw({series:e,length:t,mult:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const i=this.sma({source:e,length:t},n),a=this.stdev({source:e,length:t},n);if(i===void 0||a===void 0)return;const u=r*a;return(i+u-(i-u))/i}cci({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.sma({source:e,length:t},r),i=this.dev({source:e,length:t},r);if(!(n===void 0||i===void 0))return(e-n)/(.015*i)}change({source:e,length:t=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=e,this._cacheData[`change_${r}`]=n;const i=n[n.length-1-t];if(!(e===void 0||isNaN(e)))return i===void 0?i:typeof e=="boolean"?i!==e:e-i}cmo({series:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.change({source:e},r);if(n===void 0)return;const i=this._math.sum({source:n>=0?n:0,length:t},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:t},`sm2_${r}`);if(!(i===void 0||a===void 0))return 100*(i-a)/(i+a)}cog({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this._cacheDataList(e,t,`cog_${r}`),i=this._math.sum({source:e,length:t},r);if(i===void 0||n===void 0)return;let a=0;for(let u=0;u<t;u++){const f=n[n.length-1-u];a+=f*(u+1)}return-a/i}correlation({source1:e,source2:t,length:r},n){if(e===void 0||isNaN(e)||t===void 0||isNaN(t)||r===void 0)return;const i=this._cacheDataList([e,t],r,`correlation_${n}`),a=this.sma({source:e,length:r},`sma1_${n}`),u=this.sma({source:t,length:r},`sma2_${n}`);if(a===void 0||u===void 0||i===void 0)return;let f=0,c=0,h=0;for(let p=0;p<r;p++){const[v,x]=i[i.length-1-p],_=v-a,y=x-u;f+=_*y,c+=_*_,h+=y*y}return isNaN(c)||isNaN(f)||isNaN(h)?void 0:f/Math.sqrt(c*h)}cross({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n>=i&&e<t||n<=i&&e>t}crossover({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n<=i&&e>t}crossunder({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n>=i&&e<t}cum({source:e=0},t){e=isNaN(e)?0:e;let{sum:r}=this._cacheData[`cum_${t}`]||{};return r=r||0,r+=e,this._cacheDataHandle(`cum_${t}`,{sum:r}),r}dev({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.sma({source:e,length:t},r);let i=0;const a=this._cacheDataList(e,t,`dev_${r}`);if(!(!a||n===void 0)){for(let u=0;u<t;u++){const f=a[a.length-1-u];i+=Math.abs(f-n)}return i/t}}dmi({diLength:e,adxSmoothing:t},r){if(e===void 0||t===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:i,high:a,close:u,PDMS:f,NDMS:c,TRS:h,ADX:d,count:p=0}=this._cacheData[n]||{},{low:v,high:x,close:_}=this._variables;if(i===void 0||a===void 0||u===void 0)return this._cacheData[n]={low:v,high:x,close:_,PDMS:f,NDMS:c,TRS:x-v,count:1},[void 0,void 0,void 0];let y=x-a,m=i-v;y=y>m&&y>0?y:0,m=m>y&&m>0?m:0,y===m&&(y=m=0);const w=Math.max(x-v,Math.abs(x-u),Math.abs(v-u));if(p<e)return this._cacheDataHandle(n,{low:v,high:x,close:_,PDMS:(f||0)+y,NDMS:(c||0)+m,TRS:(h||0)+w,count:p+1}),[void 0,void 0,void 0];{const D=f-f/e+y,C=c-c/e+m,b=h-h/e+w,F=D/b*100,B=C/b*100,M=Math.abs((F-B)/(F+B))*100;let O=M,A=[F,B,void 0];if(p+1-e<t){const N=p+1-e;O=((d||0)*(N-1)+M)/N}else O=(d*(t-1)+M)/t,A=[F,B,O];return this._cacheDataHandle(n,{low:v,high:x,close:_,PDMS:D,NDMS:C,TRS:b,ADX:O,count:p+1}),A}}ema({source:e,length:t},r){if(e===void 0||t===void 0||isNaN(e))return;let{sum:n,count:i=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:e,length:t},r);if(i>t){const u=2/(t+1);n=n===void 0?e:u*e+(1-u)*(n||0)}else n=a;return i+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:i}),n}falling({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return!1;const{source:n,fallings:i=[]}=this._cacheData[`falling_${r}`]||{};i.push(n>e);const a=i.slice(-t);return this._cacheDataHandle(`falling_${r}`,{source:e,fallings:a}),a.length<t?!1:a.every(u=>u)}rising({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return!1;const{source:n,risings:i=[]}=this._cacheData[`rising_${r}`]||{};i.push(n<e);const a=i.slice(-t);return this._cacheDataHandle(`rising_${r}`,{source:e,risings:a}),a.length<t?!1:a.every(u=>u)}highest({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`highest_${r}`]||[],{high:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`highest_${r}`]=n;const u=n.filter(()=>!0);if(!(u.length<t))return Math.max(...u.slice(-t))}highestbars({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`highestbars_${r}`]=n;const u=n.filter(()=>!0);return u.length<t?void 0:u.slice(-t).reduce((c,h,d,p)=>h>=p[c]?d:c,0)-t+1}wma({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`wma_${r}`);if(!n)return;let i=0,a=0;for(let u=0;u<t;u++){const f=(t-u)*t;i+=f,a+=n[n.length-1-u]*f}return a/i}hma({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this.wma({source:e,length:t},r),i=this.wma({source:e,length:Math.round(t/2)},r);return n===void 0||i===void 0?void 0:this.wma({source:2*i-n,length:Math.floor(Math.sqrt(t))},`hma_${r}`)}kc({series:e,length:t,mult:r,useTrueRange:n=!0},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:e,length:t},i),{ta:u,high:f,low:c}=this._variables,h=n?u.tr:f-c,d=this.ema({source:h,length:t},`range_${i}`);return[a,a+d*r,a-d*r]}kcw({series:e,length:t,mult:r,useTrueRange:n=!0},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const a=this.ema({source:e,length:t},i),{ta:u,high:f,low:c}=this._variables,h=n?u.tr:f-c,d=this.ema({source:h,length:t},`range_${i}`);return(a+d*r-(a-d*r))/a}linreg({source:e,length:t,offset:r},n){if(t===void 0||r===void 0)return;const i=this._cacheDataList(e,t,`dev_${n}`);if(!i)return;const a=i.slice(-t).filter(v=>v!==void 0);let u=0,f=0,c=0,h=0;for(const[v,x]of a.entries())u+=v,f+=x,c+=v*x,h+=v*v;const d=(t*c-u*f)/(t*h-u*u);return(f-d*u)/t+d*(t-1-r)}lowest({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`lowest_${r}`]=n;const u=n.filter(()=>!0);if(!(u.length<t))return Math.min(...u.slice(-t))}lowestbars({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`lowestbars_${r}`]=n;const u=n.filter(()=>!0);return u.length<t?void 0:u.slice(-t).reduce((c,h,d,p)=>h<=p[c]?d:c,0)-t+1}macd({source:e,fastlen:t,slowlen:r,siglen:n},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:e,length:t},`ema1_${i}`),u=this.ema({source:e,length:r},`ema2_${i}`);if(a===void 0||u===void 0)return[void 0,void 0,void 0];const f=a-u,c=this.ema({source:f,length:n},`macd_${i}`);if(c===void 0)return[f,c,void 0];const h=f-c;return[f,c,h]}max({source:e},t){if(e===void 0||isNaN(e))return;let r=this._cacheData[`max_${t}`]||0;return e>r&&(r=e),this._cacheData[`max_${t}`]=r,r}min({source:e},t){if(e===void 0||isNaN(e))return;let r=this._cacheData[`min_${t}`]||1/0;return e<r&&(r=e),this._cacheData[`min_${t}`]=r,r}median({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`dev_${r}`);if(n)return Af(n.slice(-t))}mfi({series:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const{volume:n}=this._variables,i=this.change({source:e},r),a=this._math.sum({source:n*(i>=0?0:e),length:t},`lower_${r}`),u=this._math.sum({source:n*(i<=0?0:e),length:t},`upper_${r}`);if(!(u===void 0||a===void 0))return 100-100/(1+u/a)}mode({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`mode_${r}`);if(n)return Xa(gf(n.slice(-t)))}mom({source:e,length:t},r){if(t===void 0||t<0)return;const n=`mom_${r}`,i=this._cacheData[n]||[];if(i[this._variables.bar_index]=e,this._cacheData[n]=i,i.length<=t||e===void 0||isNaN(e))return;let a=i.length-t-1,u;for(;u===void 0&&a>=0;)u=i[a],a--;return u===void 0?u:e-u}percentile_linear_interpolation({source:e,length:t,percentage:r},n){if(t===void 0||r===void 0||t<0||r<0||r>100)return;const i=this._cacheDataList(e,t+1,`percentile_linear_interpolation_${n}`);if(!i)return;const a=this._sort(i.slice(-(t+1))),u=a.length;r/=100;const f=1/(u*2);if(r<=f)return a[0];if(r>=1-1/(u*2))return a[u-1];for(const[c,h]of a.entries()){const d=a[c-1];if(r<(c+.5)/u)return d===void 0||h===void 0?void 0:d+(h-d)*(r-(c-.5)/u)/(1/u)}}percentile_nearest_rank({source:e,length:t,percentage:r},n){if(t===void 0||r===void 0||e===void 0||isNaN(e)||t<0||r<0||r>100)return;const i=this._cacheDataList(e,t,`percentile_nearest_rank_${n}`);if(!i)return;const a=this._sort(i.slice(-t)),u=r/100*a.length,f=Math.ceil(u)-1;return a[f>=a.length?a.length-1:f]}percentrank({source:e,length:t},r){if(t===void 0||t<0)return;const n=this._cacheDataList(e,t+1,`percentile_nearest_rank_${r}`);if(!n)return;const i=n.slice(-(t+1)),a=e;if(a===void 0)return;let u=0;for(let f=0;f<i.length;f++)i[f]!==void 0&&(i[f]<a||i[f]===a&&f<t)&&u++;return u/(i.length-1)*100}pivot_point_levels({type:e,anchor:t,developing:r},n){const i=new it;let{close:a,open:u,low:f,high:c}=this._variables;const h=`pivot_point_levels_${n}`,{close:d,low:p,high:v,open:x,result:_}=this._cacheData[h]||{};if(!t&&(v&&p&&(c=Math.max(v,c),f=Math.min(p,f)),this._cacheDataHandle(h,{close:a,open:u,low:f,high:c,result:_}),!r))return i._value=_||[],i;const y={close:a,open:u,low:f,high:c};t===!0&&!r&&(a=d,u=x,f=p,c=v);const m=this._getPivotPointLevels(c,f,a,u,r,e);return this._cacheDataHandle(h,{...y,result:m}),i._value=m,i}_getPivotPointLevels(e,t,r,n,i,a){if(r===void 0||n===void 0||t===void 0||e===void 0)return[];switch(a){case ei.traditional:return this._traditional(e,t,r);case ei.fibonacci:return this._fibonacci(e,t,r);case ei.woodie:return i?[]:this._woodie(e,t);case ei.classic:return this._classic(e,t,r);case ei.dm:return this._DM(e,t,r,n);case ei.camarilla:return this._camarilla(e,t,r);default:return[]}}_traditional(e,t,r){const n=(e+t+r)/3,i=n*2-t,a=n+(e-t),u=n*2+(e-2*t),f=n*3+(e-3*t),c=n*4+(e-4*t),h=n*2-e,d=n-(e-t),p=n*2-(2*e-t),v=n*3-(3*e-t),x=n*4-(4*e-t);return[n,i,h,a,d,u,p,f,v,c,x]}_fibonacci(e,t,r){const n=(e+t+r)/3,i=n+.382*(e-t),a=n-.382*(e-t),u=n+.618*(e-t),f=n-.618*(e-t),c=n+(e-t),h=n-(e-t);return[n,i,a,u,f,c,h]}_woodie(e,t){const{open:r}=this._variables,n=(e+t+2*r)/4,i=2*n-t,a=2*n-e,u=n+(e-t),f=n-(e-t),c=e+2*(n-t),h=t-2*(e-n),d=c+(e-t),p=h-(e-t);return[n,i,a,u,f,c,h,d,p]}_classic(e,t,r){const n=(e+t+r)/3,i=2*n-t,a=2*n-e,u=n+(e-t),f=n-(e-t),c=n+2*(e-t),h=n-2*(e-t),d=n+3*(e-t),p=n-3*(e-t);return[n,i,a,u,f,c,h,d,p]}_DM(e,t,r,n){let i;n===r?i=e+t+2*r:r>n?i=2*e+t+r:i=2*t+e+r;const a=i/4,u=i/2-t,f=i/2-e;return[a,u,f]}_camarilla(e,t,r){const n=(e+t+r)/3,i=r+1.1*(e-t)/12,a=r-1.1*(e-t)/12,u=r+1.1*(e-t)/6,f=r-1.1*(e-t)/6,c=r+1.1*(e-t)/4,h=r-1.1*(e-t)/4,d=r+1.1*(e-t)/2,p=r-1.1*(e-t)/2,v=e/t*r,x=r-(v-r);return[n,i,a,u,f,c,h,d,p,v,x]}pivothigh({source:e=this._variables.high,leftbars:t,rightbars:r},n){if(t===void 0||r===void 0||t<0||r<0)return;const i=this._cacheDataList(e,t+r+1,`pivothigh_${n}`);if(!i)return;const a=i.slice(-(t+r+1)),u=a[t];return Math.max(...a)===u?u:void 0}pivotlow({source:e=this._variables.low,leftbars:t,rightbars:r},n){if(t===void 0||r===void 0||t<0||r<0)return;const i=this._cacheDataList(e,t+r+1,`pivotlow_${n}`);if(!i)return;const a=i.slice(-(t+r+1)),u=a[t];return Math.min(...a)===u?u:void 0}range({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<0)return;const n=this._cacheDataList(e,t,`range_${r}`);if(!n)return;const i=n.filter(f=>f!==void 0).slice(-t),a=Math.max(...i),u=Math.min(...i);return a-u}roc({source:e,length:t},r){if(t===void 0||t<0)return;const n=this._cacheDataList(e,t+1,`roc_${r}`),i=this.change({source:e,length:t},r);if(n)return 100*i/n[n.length-1-t]}rsi({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},i=Math.max(e-n,0),a=Math.max(n-e,0),u=this.rma({source:i,length:t},`rma1_${r}`),f=this.rma({source:a,length:t},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:e}),!(u===void 0||f===void 0))return 100-100/(1+u/f)}sar({start:e,inc:t,max:r},n){if(e===void 0||t===void 0||r===void 0)return;const{close:i,low:a,high:u,preLow:f,preHigh:c,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:d,maxMin:p,acceleration:v,isBelow:x}=h,_=!1;const{close:y,low:m,high:w,bar_index:D}=this._variables;return D===1&&(y>i?(x=!0,p=w,d=a):(x=!1,p=m,d=u),_=!0,v=e),d=d+v*(p-d),x?d>m&&(_=!0,x=!1,d=Math.max(w,p||0),p=m,v=e):d<w&&(_=!0,x=!0,d=Math.min(m,p||0),p=w,v=e),_||(x?w>(p||0)&&(p=w,v=Math.min((v||0)+t,r)):m<(p||0)&&(p=m,v=Math.min((v||0)+t,r))),x?(d=Math.min(d,a),D>1&&(d=Math.min(d,f))):(d=Math.max(d,u),D>1&&(d=Math.max(d,c))),this._cacheDataHandle(`sar_${n}`,{high:w,close:y,low:m,preLow:a,preHigh:u,data:Object.assign(h,{result:d,maxMin:p,acceleration:v,isBelow:x})}),d}stoch({source:e,high:t,low:r,length:n},i){if(n===void 0||t===void 0||r===void 0||e===void 0||isNaN(e)||n<0)return;const a=this.lowest({source:r,length:n},i),u=this.highest({source:t,length:n},i);if(!(a===void 0||u===void 0))return 100*(this._variables.close-a)/(u-a)}supertrend({factor:e,atrPeriod:t},r){if(e===void 0||t===void 0)return[void 0,void 0];const{hl2:n,close:i}=this._variables,a=`supertrend_${r}`,{upperBand:u,lowerBand:f,superTrend:c,atr:h,close:d}=this._cacheData[a]||{},p=this.atr({length:t},r);if(p===void 0)return this._cacheDataHandle(a,{close:i}),[void 0,void 0];let v=n+e*p,x=n-e*p;const _=u||0,y=f||0;x=x>y||d<y?x:y,v=v<_||d>_?v:_;let m;h===void 0?m=1:c===_?m=i>v?-1:1:m=i<x?1:-1;const w=m===-1?x:v;return this._cacheDataHandle(a,{upperBand:v,lowerBand:x,superTrend:w,atr:p,close:i}),[w,m]}swma({source:e},t){let{list:r}=this._cacheData[`swma_${t}`]||{};if(r||(r=[]),r.push(e),r=r.slice(-4),this._cacheDataHandle(`swma_${t}`,{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:e=!1},t){const{close:r,low:n,high:i}=this._variables,{close:a}=this._cacheData[`tr_${t}`]||{};return this._cacheDataHandle(`tr_${t}`,{close:r}),a===void 0?e?i-n:void 0:Math.max(i-n,Math.abs(i-a),Math.abs(n-a))}tsi({source:e,short_length:t,long_length:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const i=this.change({source:e},n);if(i===void 0)return;const a=this.ema({source:Math.abs(i),length:t},`absema1_${n}`),u=this.ema({source:i,length:t},`ema1_${n}`);if(u===void 0)return;const f=this.ema({source:u,length:r},`ema2_${n}`),c=this.ema({source:a,length:t},`absema2_${n}`);if(f!==void 0)return f/c}valuewhen({condition:e,source:t,occurrence:r},n){if(t===void 0||r===void 0||r<0)return;let{list:i}=this._cacheData[`valuewhen_${n}`]||{};return i||(i=[]),e&&i.push(t),this._cacheDataHandle(`valuewhen_${n}`,{list:i}),i[i.length-1-r]}variance({source:e,length:t,biased:r=!0},n){if(e===void 0||isNaN(e)||t===void 0||t<0)return;const i=this.sma({source:e,length:t},n),a=this._cacheDataList(e,t,`mode_${n}`);if(!a||i===void 0)return;const u=a.filter(c=>c!==void 0&&!isNaN(c)).slice(-t);if(u.length<t)return;const f=u.reduce((c,h)=>c+Math.pow(h-i,2),0);if(f!==void 0)return r||t<=1?f/t:f/(t-1)}vwap({source:e,anchor:t,stdev_mult:r},n){if(e===void 0)return;t=t===void 0?this._timeframe.change({timeframe:"1D"},n):t;const{volume:i}=this._variables;let{sum:a=0,sumV:u=0,count:f=0,isReset:c,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(t&&(a=u=f=h=0,c=!0),!c)return r!==void 0?[]:void 0;const d=e*i+a,p=i+u,v=d/p;return f++,r!==void 0?(h=i*Math.pow(e,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:d,sumV:p,count:f,isReset:c,sumS:h}),this._computeBands(h,p,r,v)):(this._cacheDataHandle(`vwap_${n}`,{sum:d,sumV:p,count:f,isReset:c}),v)}_computeBands(e,t,r,n){let i=e/t-Math.pow(n,2);i=i<0?0:i;const a=Math.sqrt(i),u=a!==void 0&&!isNaN(a)?n+r*a:void 0,f=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,u,f]}vwma({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0||t<=0)return;const{volume:n}=this._variables,i=this.sma({source:e*n,length:t},`sma1_${r}`),a=this.sma({source:n,length:t},`sma2_${r}`);if(!(i===void 0||a===void 0))return i/a}wpr({length:e},t){if(e===void 0||e<=0)return;const r=this.highest({length:e},t),n=this.lowest({length:e},t),{close:i}=this._variables;if(!(r===void 0||n===void 0))return(r-i)/(r-n)*-100}_sort(e){const t=e.length;for(let r=0;r<t;r++){let n={};for(let i=0;i<t-r;i++){const{currentVal:a,currentIndex:u}=n,f=e[i];if(f!==void 0){if(a!==void 0&&f<a){e.splice(i,1),e.splice(u,0,f),n={currentIndex:u+1,currentVal:a};continue}n={currentIndex:i,currentVal:f}}}}return e}_cacheDataList(e,t,r){const n=this._cacheData[r]||[];n[this._variables.bar_index]=e,this._cacheData[r]=n;const i=n.filter(()=>!0);if(!(i.length<t))return i}_cacheDataHandle(e,t){const{barIndex:r}=this._cacheData[e]||{};r!==this._variables.bar_index&&(this._cacheData[e]=Object.assign(t,{barIndex:this._variables.bar_index}))}}const Kt={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:"$keyword '$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",typeFieldErr:"In a type declaration, all fields without a default value must be explicitly typified.",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 na 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.",importMultipleErr:"Cannot import a library more than once",importNotExitErr:"The user '$username' does not have a published library titled '$libraryName'",importNameRepeatErr:"More than one import uses the same alias: $name. Previous usage at line: $line",exportFuncHasInputErr:"The exported function '$func' depends on the '$name' input variable, which is not allowed.",libraryTitleIsKeywordErr:"Invalid argument 'title' in 'library' call. Token: '$name' can't be used as library title.",exportFuncUseGlobalVarErr:"Cannot use global variables in exported functions. Function: $func",loopRuntimeErr:"Loop takes too long to execute (> 500 ms)",paramsErr:"Invalid value '$value' for '$param' parameter of the '$func' function. Possible values: $targetVal",displayErr:"Invalid argument 'display' in '$func' call. Possible values: $values",exportFuncUseReqErr:"Cannot use `request.*()` call in exported function `$name()`",requestExprErr:"Type series $type cannot be used in $name 'expression' argument",argDefaultErr:"The default value assigned to a parameter must be either a literal value (e.g., `5`) or a built-in variable (e.g., `close`)",overloadFuncErr:"Cannot use global variables or any values qualified as 'input' in the local scopes of overloaded functions or methods. Remove any global variables or inputs from the scopes of all '$name()' overloads.",againAssignErr:"Unable to determine the object for the field assignment. Try putting the object into a separate variable before assigning values to its fields.",requestUserInLoopErr:"Cannot use `request.*()` call within loops or conditional structures.",enumVarNameErr:"Invalid enum name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumVarNameBuiltinErr:"Invalid object name: $name. Namespaces of built-ins cannot be used.",typeNameErr:"Invalid user-defined type name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumUseErr:"Cannot use the '$name' as a value. Use one of the enum's fields instead.",conditionalErr:"'$name' conditional expression must be of a bool type!",fortoErr:'The value of the "for" loop must be a number.',indicatorUseStrategyFuncErr:"You cannot use strategy $type ($name) in indicator script."};an.SERIES,an.SIMPLE,an.INPUT,an.CONST,an.INT,an.FLOAT,an.BOOL,an.COLOR,an.STRING;const jx=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Yx=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Zx=["linefill","polyline","matrix","series","simple","string","array","color","const","float","label","table","bool","line","box","int","map","continue","for","varip","var","in","export","import","method","switch","break","while","else","type","and","for","not","as","by","if","in","or","to"];class Vx{constructor(e,t,r){U(this,"_cacheData");U(this,"_variables");U(this,"_errorListener");U(this,"_historyInputs");U(this,"_name");this._cacheData={},this._variables=e,this._errorListener=t,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(e){for(const t of e){const r=t.id;this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...t,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${t.index}`,{modifyDefval:t.sourceTypeName||t.defval})}}input(e,t){return this._cacheHandle(e,t)}int(e,t){return this._cacheHandle(e,t,ur.INT)}bool(e,t){return this._cacheHandle(e,t,ur.BOOL)}color(e,t){return this._cacheHandle(e,t,ur.COLOR)}time(e,t){return this._cacheHandle(e,t,ur.TIME)}float(e,t){return this._cacheHandle(e,t,ur.FLOAT)}price(e,t){return this._cacheHandle(e,t,ur.PRICE)}source(e,t){return this._cacheHandle(e,t,ur.SOURCE)}string(e,t){return this._cacheHandle(e,t,ur.STRING)}symbol(e,t){return this._cacheHandle(e,t,ur.SYMBOL)}session(e,t){return this._cacheHandle(e,t,ur.SESSION)}text_area(e,t){return this._cacheHandle(e,t,ur.TEXT_AREA)}timeframe(e,t){return this._cacheHandle(e,t,ur.TIMEFRAME)}enum(e,t){return this._cacheHandle(e,t,ur.ENUM)}_cacheHandle(e,t,r){if(t.startsWith("export"))return e.defval;const n=`${r||"input"}_${t}`,i=this._cacheData[n];if(e.defval===void 0&&this._errorListener.addError(Kt.inputDefvalErr,t,Ve.Error),i)i.isModify?i.sourceTypeName&&(this._cacheData[n].defval=this._variables[i.sourceTypeName]):Object.assign(this._cacheData[n],e);else{const{defval:a,display:u}=e;this._displayVerify(t,u),e={inputType:r,...e},this._cacheData[n]=e,this._judgeHistoryInputs(e),(r||e.inputType)===ur.SOURCE?this._cacheData[n].options=jx:e.options&&!e.options.includes(a)&&this._errorListener.addError(`input's defval should be in options, but '${a}' is not in [${e.options.toString()}]`,t,Ve.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_judgeHistoryInputs(e){const{defval:t,sourceTypeName:r,index:n}=e;let i=r||t;const a=`in_${n}`,u=this._historyInputs[a];if(!u)self.workerStorage.setValue(this._name,a,{defval:i});else{const{defval:f,modifyDefval:c}=u;f===i?i=c||i:self.workerStorage.setValue(this._name,a,{defval:i})}r?e.sourceTypeName=i:e.defval=i}_displayVerify(e,t){!t||!t.length||t.includes(Zt.dataWindow)||t.includes(Zt.statusLine)||this._errorListener.addError(or(Kt.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),e,Ve.Error)}getInputs(){const e=Object.keys(this._cacheData),t=[];for(const r of e){const n=this._cacheData[r];n.id=r,t.push(n)}return t.sort((r,n)=>(r.index||0)-(n.index||0))}}class Gx{color({x:e}){return e}new({color:e,transp:t=100}){me(t)&&(t=100);const r=(100-t)/100,{r:n,g:i,b:a}=this._parseColor(e||"");return`rgba(${Math.round(n)}, ${Math.round(i)}, ${Math.round(a)}, ${r})`}rgb({red:e=0,green:t=0,blue:r=0,transp:n=0}){return me(n)&&(n=0),me(e)&&(e=0),me(t)&&(t=0),me(r)&&(r=0),`rgba(${e}, ${t}, ${r}, ${(100-n)/100})`}g({color:e}){return e?this._parseColor(e).g:0}r({color:e}){return e?this._parseColor(e).r:0}b({color:e}){return e?this._parseColor(e).b:0}t({color:e}){return e?Math.round(this._parseColor(e).a*100):0}from_gradient({value:e,bottom_value:t,top_value:r,bottom_color:n,top_color:i}){if(me(e)||me(t)||me(r))return"rgba(0,0,0,1)";const a=(e-t)/(r-t),u=Math.min(Math.max(a,0),1),{r:f,g:c,b:h,a:d}=this._parseColor(n||"rgba(0,0,0,0)"),{r:p,g:v,b:x,a:_}=this._parseColor(i||"rgba(0,0,0,0)"),y=f+u*(p-f),m=c+u*(v-c),w=h+u*(x-h),D=d+u*(_-d);return`rgba(${Math.round(y)}, ${Math.round(m)}, ${Math.round(w)}, ${D.toFixed(2)})`}_parseColor(e){let t,r,n,i;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);const a=e.substring(7);a?i=(255-parseInt(a,16))/255:i=1}else{const a=this._parserRgbColor(e);t=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:t,g:r,b:n,a:i}}_parserRgbColor(e){var t;return((t=e.match(/\d+/g))==null?void 0:t.map(Number))||[]}}var We={};const Kx=Object.prototype.toString;function fs(s){const e=Kx.call(s);return e.endsWith("Array]")&&!e.includes("Big")}var Xx=Object.freeze({__proto__:null,isAnyArray:fs}),Qx=Mt(Xx);function Jx(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!fs(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],u=r+1;u<i;u++)s[u]>a&&(a=s[u]);return a}function ey(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!fs(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],u=r+1;u<i;u++)s[u]<a&&(a=s[u]);return a}function ty(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(fs(s)){if(s.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(e.output!==void 0){if(!fs(e.output))throw new TypeError("output option must be an array if specified");t=e.output}else t=new Array(s.length);var r=ey(s),n=Jx(s);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=e.min,a=i===void 0?e.autoMinMax?r:0:i,u=e.max,f=u===void 0?e.autoMinMax?n:1:u;if(a>=f)throw new RangeError("min option must be smaller than max option");for(var c=(f-a)/(n-r),h=0;h<s.length;h++)t[h]=(s[h]-r)*c+a;return t}var ry=Object.freeze({__proto__:null,default:ty}),ny=Mt(ry);Object.defineProperty(We,"__esModule",{value:!0});var gr=Qx,Cf=ny;const xo=" ".repeat(2),Ff=" ".repeat(4);function iy(){return Bf(this)}function Bf(s,e={}){const{maxRows:t=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=e;return`${s.constructor.name} {
54
+ (`+ct(M,_)+", "+ct(C,_)+") ==> "+(this._values?ct(this._values[B],_):"X")}return D},n.prototype.toString=function(){return ct(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(_){if(_){if(St(_)&&(_=_.toNumber()),!pt(_)||!bt(_))throw new TypeError("The parameter k must be an integer number")}else _=0;var y=_>0?_:0,m=_<0?-_:0,w=this._size[0],D=this._size[1],C=Math.min(w-m,D-y),b=[],F=[],B=[];B[0]=0;for(var M=y;M<D&&b.length<C;M++)for(var O=this._ptr[M],A=this._ptr[M+1],N=O;N<A;N++){var I=this._index[N];if(I===M-y+m){b.push(this._values[N]),F[b.length-1]=I-m;break}}return B.push(b.length),new n({values:b,index:F,ptr:B,size:[C,1]})},n.fromJSON=function(_){return new n(_)},n.diagonal=function(_,y,m,w,D){if(!Ct(_))throw new TypeError("Array expected, size parameter");if(_.length!==2)throw new Error("Only two dimensions matrix are supported");if(_=_.map(function(ee){if(St(ee)&&(ee=ee.toNumber()),!pt(ee)||!bt(ee)||ee<1)throw new Error("Size values must be positive integers");return ee}),m){if(St(m)&&(m=m.toNumber()),!pt(m)||!bt(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var C=t,b=0;un(D)&&(C=e.find(t,[D,D])||t,b=e.convert(0,D));var F=m>0?m:0,B=m<0?-m:0,M=_[0],O=_[1],A=Math.min(M-B,O-F),N;if(Ct(y)){if(y.length!==A)throw new Error("Invalid value array length");N=function(te){return y[te]}}else if(mt(y)){var I=y.size();if(I.length!==1||I[0]!==A)throw new Error("Invalid matrix length");N=function(te){return y.get([te])}}else N=function(){return y};for(var R=[],k=[],z=[],L=0;L<O;L++){z.push(R.length);var G=L-F;if(G>=0&&G<A){var H=N(G);C(H,b)||(k.push(G+B),R.push(H))}}return z.push(R.length),new n({values:R,index:k,ptr:z,size:[M,O]})},n.prototype.swapRows=function(_,y){if(!pt(_)||!bt(_)||!pt(y)||!bt(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ft(_,this._size[0]),Ft(y,this._size[0]),n._swapRows(_,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(_,y,m,w,D){for(var C=w[_],b=w[_+1],F=C;F<b;F++)D(m[F],y[F])},n._swapRows=function(_,y,m,w,D,C){for(var b=0;b<m;b++){var F=C[b],B=C[b+1],M=c(_,F,B,D),O=c(y,F,B,D);if(M<B&&O<B&&D[M]===_&&D[O]===y){if(w){var A=w[M];w[M]=w[O],w[O]=A}continue}if(M<B&&D[M]===_&&(O>=B||D[O]!==y)){var N=w?w[M]:void 0;D.splice(O,0,y),w&&w.splice(O,0,N),D.splice(O<=M?M+1:M,1),w&&w.splice(O<=M?M+1:M,1);continue}if(O<B&&D[O]===y&&(M>=B||D[M]!==_)){var I=w?w[O]:void 0;D.splice(M,0,_),w&&w.splice(M,0,I),D.splice(M<=O?O+1:O,1),w&&w.splice(M<=O?O+1:O,1)}}},n},{isClass:!0}),Xv="number",Qv=["typed"];function Jv(s){var e=s.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],r=e[2],n=e[3];return{input:s,radix:t,integerPart:r,fractionalPart:n}}else return null}function eg(s){for(var e=parseInt(s.integerPart,s.radix),t=0,r=0;r<s.fractionalPart.length;r++){var n=parseInt(s.fractionalPart[r],s.radix);t+=n/Math.pow(s.radix,r+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+s.input+'" is not a valid number');return i}var tg=xe(Xv,Qv,s=>{var{typed:e}=s,t=e("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Jv(n);if(i)return eg(i);var a=0,u=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);u&&(a=Number(u[2]),n=u[1]);var f=Number(n);if(isNaN(f))throw new SyntaxError('String "'+n+'" is not a valid number');if(u){if(f>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));f>=2**(a-1)&&(f=f-2**a)}return f},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":e.referToSelf(r=>n=>Jr(n,r))});return t.fromJSON=function(r){return parseFloat(r.value)},t}),rg="bignumber",ng=["typed","BigNumber"],ig=xe(rg,ng,s=>{var{typed:e,BigNumber:t}=s;return e("bignumber",{"":function(){return new t(0)},number:function(n){return new t(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var a=i[2],u=t(i[1]),f=new t(2).pow(Number(a));if(u.gt(f.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var c=new t(2).pow(Number(a)-1);return u.gte(c)?u.sub(f):u}return new t(n)},BigNumber:function(n){return n},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Fraction:function(n){return new t(n.n).div(n.d).times(n.s)},null:function(n){return new t(0)},"Array | Matrix":e.referToSelf(r=>n=>Jr(n,r))})}),sg="fraction",og=["typed","Fraction"],ag=xe(sg,og,s=>{var{typed:e,Fraction:t}=s;return e("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new t(n)},string:function(n){return new t(n)},"number, number":function(n,i){return new t(n,i)},null:function(n){return new t(0)},BigNumber:function(n){return new t(n.toString())},Fraction:function(n){return n},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Object:function(n){return new t(n)},"Array | Matrix":e.referToSelf(r=>n=>Jr(n,r))})}),Mc="matrix",ug=["typed","Matrix","DenseMatrix","SparseMatrix"],lg=xe(Mc,ug,s=>{var{typed:e,Matrix:t,DenseMatrix:r,SparseMatrix:n}=s;return e(Mc,{"":function(){return i([])},string:function(u){return i([],u)},"string, string":function(u,f){return i([],u,f)},Array:function(u){return i(u)},Matrix:function(u){return i(u,u.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(a,u,f){if(u==="dense"||u==="default"||u===void 0)return new r(a,f);if(u==="sparse")return new n(a,f);throw new TypeError("Unknown matrix type "+JSON.stringify(u)+".")}}),Nc="unaryMinus",cg=["typed"],fg=xe(Nc,cg,s=>{var{typed:e}=s;return e(Nc,{number:Dc,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>r=>{var n=r.clone();return n.value=e.find(t,n.valueType())(r.value),n}),"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),Sc="abs",hg=["typed"],dg=xe(Sc,hg,s=>{var{typed:e}=s;return e(Sc,{number:gc,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),Oc="addScalar",pg=["typed"],_g=xe(Oc,pg,s=>{var{typed:e}=s;return e(Oc,{"number, number":mc,"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":e.referToSelf(t=>(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 i=r.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Ic="subtractScalar",vg=["typed"],gg=xe(Ic,vg,s=>{var{typed:e}=s;return e(Ic,{"number, number":xc,"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":e.referToSelf(t=>(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 i=r.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),mg="matAlgo11xS0s",xg=["typed","equalScalar"],Ha=xe(mg,xg,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a,u){var f=n._values,c=n._index,h=n._ptr,d=n._size,p=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=d[0],x=d[1],_,y=t,m=0,w=a;typeof p=="string"&&(_=p,y=e.find(t,[_,_]),m=e.convert(0,_),i=e.convert(i,_),w=e.find(a,[_,_]));for(var D=[],C=[],b=[],F=0;F<x;F++){b[F]=C.length;for(var B=h[F],M=h[F+1],O=B;O<M;O++){var A=c[O],N=u?w(i,f[O]):w(f[O],i);y(N,m)||(C.push(A),D.push(N))}}return b[x]=C.length,n.createSparseMatrix({values:D,index:C,ptr:b,size:[v,x],datatype:_})}}),yg="matAlgo12xSfs",Dg=["typed","DenseMatrix"],Ci=xe(yg,Dg,s=>{var{typed:e,DenseMatrix:t}=s;return function(n,i,a,u){var f=n._values,c=n._index,h=n._ptr,d=n._size,p=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=d[0],x=d[1],_,y=a;typeof p=="string"&&(_=p,i=e.convert(i,_),y=e.find(a,[_,_]));for(var m=[],w=[],D=[],C=0;C<x;C++){for(var b=C+1,F=h[C],B=h[C+1],M=F;M<B;M++){var O=c[M];w[O]=f[M],D[O]=b}for(var A=0;A<v;A++)C===0&&(m[A]=[]),D[A]===b?m[A][C]=u?y(i,w[A]):y(w[A],i):m[A][C]=u?y(i,0):y(0,i)}return new t({data:m,size:[v,x],datatype:_})}}),wg="matAlgo14xDs",bg=["typed"],ja=xe(wg,bg,s=>{var{typed:e}=s;return function(n,i,a,u){var f=n._data,c=n._size,h=n._datatype,d,p=a;typeof h=="string"&&(d=h,i=e.convert(i,d),p=e.find(a,[d,d]));var v=c.length>0?t(p,0,c,c[0],f,i,u):[];return n.createDenseMatrix({data:v,size:ut(c),datatype:d})};function t(r,n,i,a,u,f,c){var h=[];if(n===i.length-1)for(var d=0;d<a;d++)h[d]=c?r(f,u[d]):r(u[d],f);else for(var p=0;p<a;p++)h[p]=t(r,n+1,i,i[n+1],u[p],f,c);return h}}),Eg="matAlgo02xDS0",Ag=["typed","equalScalar"],Cg=xe(Eg,Ag,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a,u){var f=n._data,c=n._size,h=n._datatype||n.getDataType(),d=i._values,p=i._index,v=i._ptr,x=i._size,_=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==x.length)throw new rt(c.length,x.length);if(c[0]!==x[0]||c[1]!==x[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+x+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=c[0],m=c[1],w,D=t,C=0,b=a;typeof h=="string"&&h===_&&h!=="mixed"&&(w=h,D=e.find(t,[w,w]),C=e.convert(0,w),b=e.find(a,[w,w]));for(var F=[],B=[],M=[],O=0;O<m;O++){M[O]=B.length;for(var A=v[O],N=v[O+1],I=A;I<N;I++){var R=p[I],k=u?b(d[I],f[R][O]):b(f[R][O],d[I]);D(k,C)||(B.push(R),F.push(k))}}return M[m]=B.length,i.createSparseMatrix({values:F,index:B,ptr:M,size:[y,m],datatype:h===n._datatype&&_===i._datatype?w:void 0})}}),Fg="matAlgo03xDSf",Bg=["typed"],Fi=xe(Fg,Bg,s=>{var{typed:e}=s;return function(r,n,i,a){var u=r._data,f=r._size,c=r._datatype||r.getDataType(),h=n._values,d=n._index,p=n._ptr,v=n._size,x=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==v.length)throw new rt(f.length,v.length);if(f[0]!==v[0]||f[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+v+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var _=f[0],y=f[1],m,w=0,D=i;typeof c=="string"&&c===x&&c!=="mixed"&&(m=c,w=e.convert(0,m),D=e.find(i,[m,m]));for(var C=[],b=0;b<_;b++)C[b]=[];for(var F=[],B=[],M=0;M<y;M++){for(var O=M+1,A=p[M],N=p[M+1],I=A;I<N;I++){var R=d[I];F[R]=a?D(h[I],u[R][M]):D(u[R][M],h[I]),B[R]=O}for(var k=0;k<_;k++)B[k]===O?C[k][M]=F[k]:C[k][M]=a?D(w,u[k][M]):D(u[k][M],w)}return r.createDenseMatrix({data:C,size:[_,y],datatype:c===r._datatype&&x===n._datatype?m:void 0})}}),Mg="matAlgo05xSfSf",Ng=["typed","equalScalar"],Tc=xe(Mg,Ng,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a){var u=n._values,f=n._index,c=n._ptr,h=n._size,d=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=i._values,v=i._index,x=i._ptr,_=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==_.length)throw new rt(h.length,_.length);if(h[0]!==_[0]||h[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+_+")");var m=h[0],w=h[1],D,C=t,b=0,F=a;typeof d=="string"&&d===y&&d!=="mixed"&&(D=d,C=e.find(t,[D,D]),b=e.convert(0,D),F=e.find(a,[D,D]));var B=u&&p?[]:void 0,M=[],O=[],A=B?[]:void 0,N=B?[]:void 0,I=[],R=[],k,z,L,G;for(z=0;z<w;z++){O[z]=M.length;var H=z+1;for(L=c[z],G=c[z+1];L<G;L++)k=f[L],M.push(k),I[k]=H,A&&(A[k]=u[L]);for(L=x[z],G=x[z+1];L<G;L++)k=v[L],I[k]!==H&&M.push(k),R[k]=H,N&&(N[k]=p[L]);if(B)for(L=O[z];L<M.length;){k=M[L];var ee=I[k],te=R[k];if(ee===H||te===H){var j=ee===H?A[k]:b,X=te===H?N[k]:b,Y=F(j,X);C(Y,b)?M.splice(L,1):(B.push(Y),L++)}}}return O[w]=M.length,n.createSparseMatrix({values:B,index:M,ptr:O,size:[m,w],datatype:d===n._datatype&&y===i._datatype?D:void 0})}}),Sg="matAlgo13xDD",Og=["typed"],Ig=xe(Sg,Og,s=>{var{typed:e}=s;return function(n,i,a){var u=n._data,f=n._size,c=n._datatype,h=i._data,d=i._size,p=i._datatype,v=[];if(f.length!==d.length)throw new rt(f.length,d.length);for(var x=0;x<f.length;x++){if(f[x]!==d[x])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");v[x]=f[x]}var _,y=a;typeof c=="string"&&c===p&&(_=c,y=e.find(a,[_,_]));var m=v.length>0?t(y,0,v,v[0],u,h):[];return n.createDenseMatrix({data:m,size:v,datatype:_})};function t(r,n,i,a,u,f){var c=[];if(n===i.length-1)for(var h=0;h<a;h++)c[h]=r(u[h],f[h]);else for(var d=0;d<a;d++)c[d]=t(r,n+1,i,i[n+1],u[d],f[d]);return c}}),Tg="broadcast",$g=["concat"],Rg=xe(Tg,$g,s=>{var{concat:e}=s;return function(n,i){var a=Math.max(n._size.length,i._size.length);if(n._size.length===i._size.length&&n._size.every((x,_)=>x===i._size[_]))return[n,i];for(var u=t(n._size,a,0),f=t(i._size,a,0),c=[],h=0;h<a;h++)c[h]=Math.max(u[h],f[h]);Zs(u,c),Zs(f,c);var d=n.clone(),p=i.clone();d._size.length<a?d.reshape(t(d._size,a,1)):p._size.length<a&&p.reshape(t(p._size,a,1));for(var v=0;v<a;v++)d._size[v]<c[v]&&(d=r(d,c[v],v)),p._size[v]<c[v]&&(p=r(p,c[v],v));return[d,p]};function t(n,i,a){return[...Array(i-n.length).fill(a),...n]}function r(n,i,a){return e(...Array(i).fill(n),a)}}),Lg="matrixAlgorithmSuite",Pg=["typed","matrix","concat"],ri=xe(Lg,Pg,s=>{var{typed:e,matrix:t,concat:r}=s,n=Ig({typed:e}),i=ja({typed:e}),a=Rg({concat:r});return function(f){var c=f.elop,h=f.SD||f.DS,d;c?(d={"DenseMatrix, DenseMatrix":(_,y)=>n(...a(_,y),c),"Array, Array":(_,y)=>n(...a(t(_),t(y)),c).valueOf(),"Array, DenseMatrix":(_,y)=>n(...a(t(_),y),c),"DenseMatrix, Array":(_,y)=>n(...a(_,t(y)),c)},f.SS&&(d["SparseMatrix, SparseMatrix"]=(_,y)=>f.SS(...a(_,y),c,!1)),f.DS&&(d["DenseMatrix, SparseMatrix"]=(_,y)=>f.DS(...a(_,y),c,!1),d["Array, SparseMatrix"]=(_,y)=>f.DS(...a(t(_),y),c,!1)),h&&(d["SparseMatrix, DenseMatrix"]=(_,y)=>h(...a(y,_),c,!0),d["SparseMatrix, Array"]=(_,y)=>h(...a(t(y),_),c,!0))):(d={"DenseMatrix, DenseMatrix":e.referToSelf(_=>(y,m)=>n(...a(y,m),_)),"Array, Array":e.referToSelf(_=>(y,m)=>n(...a(t(y),t(m)),_).valueOf()),"Array, DenseMatrix":e.referToSelf(_=>(y,m)=>n(...a(t(y),m),_)),"DenseMatrix, Array":e.referToSelf(_=>(y,m)=>n(...a(y,t(m)),_))},f.SS&&(d["SparseMatrix, SparseMatrix"]=e.referToSelf(_=>(y,m)=>f.SS(...a(y,m),_,!1))),f.DS&&(d["DenseMatrix, SparseMatrix"]=e.referToSelf(_=>(y,m)=>f.DS(...a(y,m),_,!1)),d["Array, SparseMatrix"]=e.referToSelf(_=>(y,m)=>f.DS(...a(t(y),m),_,!1))),h&&(d["SparseMatrix, DenseMatrix"]=e.referToSelf(_=>(y,m)=>h(...a(m,y),_,!0)),d["SparseMatrix, Array"]=e.referToSelf(_=>(y,m)=>h(...a(t(m),y),_,!0))));var p=f.scalar||"any",v=f.Ds||f.Ss;v&&(c?(d["DenseMatrix,"+p]=(_,y)=>i(_,y,c,!1),d[p+", DenseMatrix"]=(_,y)=>i(y,_,c,!0),d["Array,"+p]=(_,y)=>i(t(_),y,c,!1).valueOf(),d[p+", Array"]=(_,y)=>i(t(y),_,c,!0).valueOf()):(d["DenseMatrix,"+p]=e.referToSelf(_=>(y,m)=>i(y,m,_,!1)),d[p+", DenseMatrix"]=e.referToSelf(_=>(y,m)=>i(m,y,_,!0)),d["Array,"+p]=e.referToSelf(_=>(y,m)=>i(t(y),m,_,!1).valueOf()),d[p+", Array"]=e.referToSelf(_=>(y,m)=>i(t(m),y,_,!0).valueOf())));var x=f.sS!==void 0?f.sS:f.Ss;return c?(f.Ss&&(d["SparseMatrix,"+p]=(_,y)=>f.Ss(_,y,c,!1)),x&&(d[p+", SparseMatrix"]=(_,y)=>x(y,_,c,!0))):(f.Ss&&(d["SparseMatrix,"+p]=e.referToSelf(_=>(y,m)=>f.Ss(y,m,_,!1))),x&&(d[p+", SparseMatrix"]=e.referToSelf(_=>(y,m)=>x(m,y,_,!0)))),c&&c.signatures&&Fl(d,c.signatures),d}}),kg="matAlgo01xDSid",zg=["typed"],$c=xe(kg,zg,s=>{var{typed:e}=s;return function(r,n,i,a){var u=r._data,f=r._size,c=r._datatype||r.getDataType(),h=n._values,d=n._index,p=n._ptr,v=n._size,x=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==v.length)throw new rt(f.length,v.length);if(f[0]!==v[0]||f[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+v+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var _=f[0],y=f[1],m=typeof c=="string"&&c!=="mixed"&&c===x?c:void 0,w=m?e.find(i,[m,m]):i,D,C,b=[];for(D=0;D<_;D++)b[D]=[];var F=[],B=[];for(C=0;C<y;C++){for(var M=C+1,O=p[C],A=p[C+1],N=O;N<A;N++)D=d[N],F[D]=a?w(h[N],u[D][C]):w(u[D][C],h[N]),B[D]=M;for(D=0;D<_;D++)B[D]===M?b[D][C]=F[D]:b[D][C]=u[D][C]}return r.createDenseMatrix({data:b,size:[_,y],datatype:c===r._datatype&&x===n._datatype?m:void 0})}}),qg="matAlgo04xSidSid",Ug=["typed","equalScalar"],Wg=xe(qg,Ug,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a){var u=n._values,f=n._index,c=n._ptr,h=n._size,d=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=i._values,v=i._index,x=i._ptr,_=i._size,y=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==_.length)throw new rt(h.length,_.length);if(h[0]!==_[0]||h[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+_+")");var m=h[0],w=h[1],D,C=t,b=0,F=a;typeof d=="string"&&d===y&&d!=="mixed"&&(D=d,C=e.find(t,[D,D]),b=e.convert(0,D),F=e.find(a,[D,D]));var B=u&&p?[]:void 0,M=[],O=[],A=u&&p?[]:void 0,N=u&&p?[]:void 0,I=[],R=[],k,z,L,G,H;for(z=0;z<w;z++){O[z]=M.length;var ee=z+1;for(G=c[z],H=c[z+1],L=G;L<H;L++)k=f[L],M.push(k),I[k]=ee,A&&(A[k]=u[L]);for(G=x[z],H=x[z+1],L=G;L<H;L++)if(k=v[L],I[k]===ee){if(A){var te=F(A[k],p[L]);C(te,b)?I[k]=null:A[k]=te}}else M.push(k),R[k]=ee,N&&(N[k]=p[L]);if(A&&N)for(L=O[z];L<M.length;)k=M[L],I[k]===ee?(B[L]=A[k],L++):R[k]===ee?(B[L]=N[k],L++):M.splice(L,1)}return O[w]=M.length,n.createSparseMatrix({values:B,index:M,ptr:O,size:[m,w],datatype:d===n._datatype&&y===i._datatype?D:void 0})}}),Hg="matAlgo10xSids",jg=["typed","DenseMatrix"],Rc=xe(Hg,jg,s=>{var{typed:e,DenseMatrix:t}=s;return function(n,i,a,u){var f=n._values,c=n._index,h=n._ptr,d=n._size,p=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=d[0],x=d[1],_,y=a;typeof p=="string"&&(_=p,i=e.convert(i,_),y=e.find(a,[_,_]));for(var m=[],w=[],D=[],C=0;C<x;C++){for(var b=C+1,F=h[C],B=h[C+1],M=F;M<B;M++){var O=c[M];w[O]=f[M],D[O]=b}for(var A=0;A<v;A++)C===0&&(m[A]=[]),D[A]===b?m[A][C]=u?y(i,w[A]):y(w[A],i):m[A][C]=i}return new t({data:m,size:[v,x],datatype:_})}}),Yg="multiplyScalar",Zg=["typed"],Vg=xe(Yg,Zg,s=>{var{typed:e}=s;return e("multiplyScalar",{"number, number":yc,"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":(t,r)=>r.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,r)=>t.multiply(r)})}),Lc="multiply",Gg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Kg=xe(Lc,Gg,s=>{var{typed:e,matrix:t,addScalar:r,multiplyScalar:n,equalScalar:i,dot:a}=s,u=Ha({typed:e,equalScalar:i}),f=ja({typed:e});function c(b,F){switch(b.length){case 1:switch(F.length){case 1:if(b[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(b[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+b[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(b[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+b[1]+") must match Vector length ("+F[0]+")");break;case 2:if(b[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+b[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 "+b.length+" dimensions)")}}function h(b,F,B){if(B===0)throw new Error("Cannot multiply two empty vectors");return a(b,F)}function d(b,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return p(b,F)}function p(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._data,N=F._size,I=F._datatype||F.getDataType(),R=M[0],k=N[1],z,L=r,G=n;O&&I&&O===I&&typeof O=="string"&&O!=="mixed"&&(z=O,L=e.find(r,[z,z]),G=e.find(n,[z,z]));for(var H=[],ee=0;ee<k;ee++){for(var te=G(B[0],A[0][ee]),j=1;j<R;j++)te=L(te,G(B[j],A[j][ee]));H[ee]=te}return b.createDenseMatrix({data:H,size:[k],datatype:O===b._datatype&&I===F._datatype?z:void 0})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":_,"SparseMatrix, any":w}),x=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":m,"SparseMatrix, DenseMatrix":D,"SparseMatrix, SparseMatrix":C});function _(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._data,N=F._datatype||F.getDataType(),I=M[0],R=M[1],k,z=r,L=n;O&&N&&O===N&&typeof O=="string"&&O!=="mixed"&&(k=O,z=e.find(r,[k,k]),L=e.find(n,[k,k]));for(var G=[],H=0;H<I;H++){for(var ee=B[H],te=L(ee[0],A[0]),j=1;j<R;j++)te=z(te,L(ee[j],A[j]));G[H]=te}return b.createDenseMatrix({data:G,size:[I],datatype:O===b._datatype&&N===F._datatype?k:void 0})}function y(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._data,N=F._size,I=F._datatype||F.getDataType(),R=M[0],k=M[1],z=N[1],L,G=r,H=n;O&&I&&O===I&&typeof O=="string"&&O!=="mixed"&&O!=="mixed"&&(L=O,G=e.find(r,[L,L]),H=e.find(n,[L,L]));for(var ee=[],te=0;te<R;te++){var j=B[te];ee[te]=[];for(var X=0;X<z;X++){for(var Y=H(j[0],A[0][X]),Q=1;Q<k;Q++)Y=G(Y,H(j[Q],A[Q][X]));ee[te][X]=Y}}return b.createDenseMatrix({data:ee,size:[R,z],datatype:O===b._datatype&&I===F._datatype?L:void 0})}function m(b,F){var B=b._data,M=b._size,O=b._datatype||b.getDataType(),A=F._values,N=F._index,I=F._ptr,R=F._size,k=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!A)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var z=M[0],L=R[1],G,H=r,ee=n,te=i,j=0;O&&k&&O===k&&typeof O=="string"&&O!=="mixed"&&(G=O,H=e.find(r,[G,G]),ee=e.find(n,[G,G]),te=e.find(i,[G,G]),j=e.convert(0,G));for(var X=[],Y=[],Q=[],pe=F.createSparseMatrix({values:X,index:Y,ptr:Q,size:[z,L],datatype:O===b._datatype&&k===F._datatype?G:void 0}),De=0;De<L;De++){Q[De]=Y.length;var we=I[De],be=I[De+1];if(be>we)for(var Oe=0,Fe=0;Fe<z;Fe++){for(var nt=Fe+1,Ye=void 0,Ie=we;Ie<be;Ie++){var Re=N[Ie];Oe!==nt?(Ye=ee(B[Fe][Re],A[Ie]),Oe=nt):Ye=H(Ye,ee(B[Fe][Re],A[Ie]))}Oe===nt&&!te(Ye,j)&&(Y.push(Fe),X.push(Ye))}}return Q[L]=Y.length,pe}function w(b,F){var B=b._values,M=b._index,O=b._ptr,A=b._datatype||b._data===void 0?b._datatype:b.getDataType();if(!B)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var N=F._data,I=F._datatype||F.getDataType(),R=b._size[0],k=F._size[0],z=[],L=[],G=[],H,ee=r,te=n,j=i,X=0;A&&I&&A===I&&typeof A=="string"&&A!=="mixed"&&(H=A,ee=e.find(r,[H,H]),te=e.find(n,[H,H]),j=e.find(i,[H,H]),X=e.convert(0,H));var Y=[],Q=[];G[0]=0;for(var pe=0;pe<k;pe++){var De=N[pe];if(!j(De,X))for(var we=O[pe],be=O[pe+1],Oe=we;Oe<be;Oe++){var Fe=M[Oe];Q[Fe]?Y[Fe]=ee(Y[Fe],te(De,B[Oe])):(Q[Fe]=!0,L.push(Fe),Y[Fe]=te(De,B[Oe]))}}for(var nt=L.length,Ye=0;Ye<nt;Ye++){var Ie=L[Ye];z[Ye]=Y[Ie]}return G[1]=L.length,b.createSparseMatrix({values:z,index:L,ptr:G,size:[R,1],datatype:A===b._datatype&&I===F._datatype?H:void 0})}function D(b,F){var B=b._values,M=b._index,O=b._ptr,A=b._datatype||b._data===void 0?b._datatype:b.getDataType();if(!B)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var N=F._data,I=F._datatype||F.getDataType(),R=b._size[0],k=F._size[0],z=F._size[1],L,G=r,H=n,ee=i,te=0;A&&I&&A===I&&typeof A=="string"&&A!=="mixed"&&(L=A,G=e.find(r,[L,L]),H=e.find(n,[L,L]),ee=e.find(i,[L,L]),te=e.convert(0,L));for(var j=[],X=[],Y=[],Q=b.createSparseMatrix({values:j,index:X,ptr:Y,size:[R,z],datatype:A===b._datatype&&I===F._datatype?L:void 0}),pe=[],De=[],we=0;we<z;we++){Y[we]=X.length;for(var be=we+1,Oe=0;Oe<k;Oe++){var Fe=N[Oe][we];if(!ee(Fe,te))for(var nt=O[Oe],Ye=O[Oe+1],Ie=nt;Ie<Ye;Ie++){var Re=M[Ie];De[Re]!==be?(De[Re]=be,X.push(Re),pe[Re]=H(Fe,B[Ie])):pe[Re]=G(pe[Re],H(Fe,B[Ie]))}}for(var xt=Y[we],Ut=X.length,Et=xt;Et<Ut;Et++){var lr=X[Et];j[Et]=pe[lr]}}return Y[z]=X.length,Q}function C(b,F){var B=b._values,M=b._index,O=b._ptr,A=b._datatype||b._data===void 0?b._datatype:b.getDataType(),N=F._values,I=F._index,R=F._ptr,k=F._datatype||F._data===void 0?F._datatype:F.getDataType(),z=b._size[0],L=F._size[1],G=B&&N,H,ee=r,te=n;A&&k&&A===k&&typeof A=="string"&&A!=="mixed"&&(H=A,ee=e.find(r,[H,H]),te=e.find(n,[H,H]));for(var j=G?[]:void 0,X=[],Y=[],Q=b.createSparseMatrix({values:j,index:X,ptr:Y,size:[z,L],datatype:A===b._datatype&&k===F._datatype?H:void 0}),pe=G?[]:void 0,De=[],we,be,Oe,Fe,nt,Ye,Ie,Re,xt=0;xt<L;xt++){Y[xt]=X.length;var Ut=xt+1;for(nt=R[xt],Ye=R[xt+1],Fe=nt;Fe<Ye;Fe++)if(Re=I[Fe],G)for(be=O[Re],Oe=O[Re+1],we=be;we<Oe;we++)Ie=M[we],De[Ie]!==Ut?(De[Ie]=Ut,X.push(Ie),pe[Ie]=te(N[Fe],B[we])):pe[Ie]=ee(pe[Ie],te(N[Fe],B[we]));else for(be=O[Re],Oe=O[Re+1],we=be;we<Oe;we++)Ie=M[we],De[Ie]!==Ut&&(De[Ie]=Ut,X.push(Ie));if(G)for(var Et=Y[xt],lr=X.length,Lr=Et;Lr<lr;Lr++){var cr=X[Lr];j[Lr]=pe[cr]}}return Y[L]=X.length,Q}return e(Lc,n,{"Array, Array":e.referTo("Matrix, Matrix",b=>(F,B)=>{c(Lt(F),Lt(B));var M=b(t(F),t(B));return mt(M)?M.valueOf():M}),"Matrix, Matrix":function(F,B){var M=F.size(),O=B.size();return c(M,O),M.length===1?O.length===1?h(F,B,M[0]):d(F,B):O.length===1?v(F,B):x(F,B)},"Matrix, Array":e.referTo("Matrix,Matrix",b=>(F,B)=>b(F,t(B))),"Array, Matrix":e.referToSelf(b=>(F,B)=>b(t(F,B.storage()),B)),"SparseMatrix, any":function(F,B){return u(F,B,n,!1)},"DenseMatrix, any":function(F,B){return f(F,B,n,!1)},"any, SparseMatrix":function(F,B){return u(B,F,n,!0)},"any, DenseMatrix":function(F,B){return f(B,F,n,!0)},"Array, any":function(F,B){return f(t(F),B,n,!1).valueOf()},"any, Array":function(F,B){return f(t(B),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(b=>(F,B,M)=>{for(var O=b(F,B),A=0;A<M.length;A++)O=b(O,M[A]);return O})})}),Pc="subtract",Xg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Qg=xe(Pc,Xg,s=>{var{typed:e,matrix:t,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:u}=s,f=$c({typed:e}),c=Fi({typed:e}),h=Tc({typed:e,equalScalar:r}),d=Rc({typed:e,DenseMatrix:a}),p=Ci({typed:e,DenseMatrix:a}),v=ri({typed:e,matrix:t,concat:u});return e(Pc,{"any, any":n},v({elop:n,SS:h,DS:f,SD:c,Ss:p,sS:d}))}),Jg="matAlgo07xSSf",em=["typed","DenseMatrix"],uo=xe(Jg,em,s=>{var{typed:e,DenseMatrix:t}=s;return function(i,a,u){var f=i._size,c=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=a._size,d=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(f.length!==h.length)throw new rt(f.length,h.length);if(f[0]!==h[0]||f[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+h+")");var p=f[0],v=f[1],x,_=0,y=u;typeof c=="string"&&c===d&&c!=="mixed"&&(x=c,_=e.convert(0,x),y=e.find(u,[x,x]));var m,w,D=[];for(m=0;m<p;m++)D[m]=[];var C=[],b=[],F=[],B=[];for(w=0;w<v;w++){var M=w+1;for(r(i,w,F,C,M),r(a,w,B,b,M),m=0;m<p;m++){var O=F[m]===M?C[m]:_,A=B[m]===M?b[m]:_;D[m][w]=y(O,A)}}return new t({data:D,size:[p,v],datatype:c===i._datatype&&d===a._datatype?x:void 0})};function r(n,i,a,u,f){for(var c=n._values,h=n._index,d=n._ptr,p=d[i],v=d[i+1];p<v;p++){var x=h[p];a[x]=f,u[x]=c[p]}}}),kc="conj",tm=["typed"],rm=xe(kc,tm,s=>{var{typed:e}=s;return e(kc,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>r=>Jr(r,t))})}),zc="concat",nm=["typed","matrix","isInteger"],im=xe(zc,nm,s=>{var{typed:e,matrix:t,isInteger:r}=s;return e(zc,{"...Array | Matrix | number | BigNumber":function(i){var a,u=i.length,f=-1,c,h=!1,d=[];for(a=0;a<u;a++){var p=i[a];if(mt(p)&&(h=!0),pt(p)||St(p)){if(a!==u-1)throw new Error("Dimension must be specified as last argument");if(c=f,f=p.valueOf(),!r(f))throw new TypeError("Integer number expected for dimension");if(f<0||a>0&&f>c)throw new On(f,c+1)}else{var v=ut(p).valueOf(),x=Lt(v);if(d[a]=v,c=f,f=x.length-1,a>0&&f!==c)throw new rt(c+1,f+1)}}if(d.length===0)throw new SyntaxError("At least one matrix expected");for(var _=d.shift();d.length;)_=Zl(_,d.shift(),f);return h?t(_):_},"...string":function(i){return i.join("")}})}),qc="count",sm=["typed","size","prod"],om=xe(qc,sm,s=>{var{typed:e,size:t,prod:r}=s;return e(qc,{string:function(i){return i.length},"Matrix | Array":function(i){return r(t(i))}})}),Uc="identity",am=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],um=xe(Uc,am,s=>{var{typed:e,config:t,matrix:r,BigNumber:n,DenseMatrix:i,SparseMatrix:a}=s;return e(Uc,{"":function(){return t.matrix==="Matrix"?r([]):[]},string:function(h){return r(h)},"number | BigNumber":function(h){return f(h,h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,d){return f(h,h,d)},"number | BigNumber, number | BigNumber":function(h,d){return f(h,d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,d,p){return f(h,d,p)},Array:function(h){return u(h)},"Array, string":function(h,d){return u(h,d)},Matrix:function(h){return u(h.valueOf(),h.storage())},"Matrix, string":function(h,d){return u(h.valueOf(),d)}});function u(c,h){switch(c.length){case 0:return h?r(h):[];case 1:return f(c[0],c[0],h);case 2:return f(c[0],c[1],h);default:throw new Error("Vector containing two values expected")}}function f(c,h,d){var p=St(c)||St(h)?n:null;if(St(c)&&(c=c.toNumber()),St(h)&&(h=h.toNumber()),!bt(c)||c<1)throw new Error("Parameters in function identity must be positive integers");if(!bt(h)||h<1)throw new Error("Parameters in function identity must be positive integers");var v=p?new n(1):1,x=p?new p(0):0,_=[c,h];if(d){if(d==="sparse")return a.diagonal(_,v,0,x);if(d==="dense")return i.diagonal(_,v,0,x);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}for(var y=Na([],_,x),m=c<h?c:h,w=0;w<m;w++)y[w][w]=v;return y}}),Wc="kron",lm=["typed","matrix","multiplyScalar"],cm=xe(Wc,lm,s=>{var{typed:e,matrix:t,multiplyScalar:r}=s;return e(Wc,{"Matrix, Matrix":function(a,u){return t(n(a.toArray(),u.toArray()))},"Matrix, Array":function(a,u){return t(n(a.toArray(),u))},"Array, Matrix":function(a,u){return t(n(a,u.toArray()))},"Array, Array":n});function n(i,a){if(Lt(i).length===1&&(i=[i]),Lt(a).length===1&&(a=[a]),Lt(i).length>2||Lt(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(a.length)+")");var u=[],f=[];return i.map(function(c){return a.map(function(h){return f=[],u.push(f),c.map(function(d){return h.map(function(p){return f.push(r(d,p))})})})})&&u}});function fm(){throw new Error('No "bignumber" implementation available')}function hm(){throw new Error('No "fraction" implementation available')}function dm(){throw new Error('No "matrix" implementation available')}var Hc="reshape",pm=["typed","isInteger","matrix"],_m=xe(Hc,pm,s=>{var{typed:e,isInteger:t}=s;return e(Hc,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(a){if(!t(a))throw new TypeError("Invalid size for dimension: "+a)}),Oa(n,i)}})}),jc="size",vm=["typed","config","?matrix"],gm=xe(jc,vm,s=>{var{typed:e,config:t,matrix:r}=s;return e(jc,{Matrix:function(i){return i.create(i.size())},Array:Lt,string:function(i){return t.matrix==="Array"?[i.length]:r([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return t.matrix==="Array"?[]:r?r([]):dm()}})}),Yc="transpose",mm=["typed","matrix"],xm=xe(Yc,mm,s=>{var{typed:e,matrix:t}=s;return e(Yc,{Array:a=>r(t(a)).valueOf(),Matrix:r,any:ut});function r(a){var u=a.size(),f;switch(u.length){case 1:f=a.clone();break;case 2:{var c=u[0],h=u[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+ct(u)+")");switch(a.storage()){case"dense":f=n(a,c,h);break;case"sparse":f=i(a,c,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+ct(u)+")")}return f}function n(a,u,f){for(var c=a._data,h=[],d,p=0;p<f;p++){d=h[p]=[];for(var v=0;v<u;v++)d[v]=ut(c[v][p])}return a.createDenseMatrix({data:h,size:[f,u],datatype:a._datatype})}function i(a,u,f){for(var c=a._values,h=a._index,d=a._ptr,p=c?[]:void 0,v=[],x=[],_=[],y=0;y<u;y++)_[y]=0;var m,w,D;for(m=0,w=h.length;m<w;m++)_[h[m]]++;for(var C=0,b=0;b<u;b++)x.push(C),C+=_[b],_[b]=x[b];for(x.push(C),D=0;D<f;D++)for(var F=d[D],B=d[D+1],M=F;M<B;M++){var O=_[h[M]]++;v[O]=D,c&&(p[O]=ut(c[M]))}return a.createSparseMatrix({values:p,index:v,ptr:x,size:[f,u],datatype:a._datatype})}}),Zc="ctranspose",ym=["typed","transpose","conj"],Dm=xe(Zc,ym,s=>{var{typed:e,transpose:t,conj:r}=s;return e(Zc,{any:function(i){return r(t(i))}})}),Vc="mode",wm=["typed","isNaN","isNumeric"],bm=xe(Vc,wm,s=>{var{typed:e,isNaN:t,isNumeric:r}=s;return e(Vc,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(i){i=Ta(i.valueOf());var a=i.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var u={},f=[],c=0,h=0;h<i.length;h++){var d=i[h];if(r(d)&&t(d))throw new Error("Cannot calculate mode of an array containing NaN values");d in u||(u[d]=0),u[d]++,u[d]===c?f.push(d):u[d]>c&&(c=u[d],f=[d])}return f}});function Ln(s,e,t){var r;return String(s).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+Sn(t)+", value: "+JSON.stringify(t)+")":" (type: "+s.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+r)):String(s).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+Sn(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+r)):s}var Gc="prod",Em=["typed","config","multiplyScalar","numeric"],Am=xe(Gc,Em,s=>{var{typed:e,config:t,multiplyScalar:r,numeric:n}=s;return e(Gc,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(u,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(u){return i(u)}});function i(a){var u;if(as(a,function(f){try{u=u===void 0?f:r(u,f)}catch(c){throw Ln(c,"prod",f)}}),typeof u=="string"&&(u=n(u,t.number)),u===void 0)throw new Error("Cannot calculate prod of an empty array");return u}}),Cm="numeric",Fm=["number","?bignumber","?fraction"],Bm=xe(Cm,Fm,s=>{var{number:e,bignumber:t,fraction:r}=s,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:a=>e(a),BigNumber:t?a=>t(a):fm,Fraction:r?a=>r(a):hm};return function(u){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",c=arguments.length>2?arguments[2]:void 0;if(c!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var h=Sn(u);if(!(h in n))throw new TypeError("Cannot convert "+u+' of type "'+h+'"; valid input types are '+Object.keys(n).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+u+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===h?u:i[f](u)}}),Kc="divideScalar",Mm=["typed","numeric"],Nm=xe(Kc,Mm,s=>{var{typed:e,numeric:t}=s;return e(Kc,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),Xc="pow",Sm=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Om=xe(Xc,Sm,s=>{var{typed:e,config:t,identity:r,multiply:n,matrix:i,inv:a,number:u,fraction:f,Complex:c}=s;return e(Xc,{"number, number":h,"Complex, Complex":function(x,_){return x.pow(_)},"BigNumber, BigNumber":function(x,_){return _.isInteger()||x>=0||t.predictable?x.pow(_):new c(x.toNumber(),0).pow(_.toNumber(),0)},"Fraction, Fraction":function(x,_){var y=x.pow(_);if(y!=null)return y;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return h(x.valueOf(),_.valueOf())},"Array, number":d,"Array, BigNumber":function(x,_){return d(x,_.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(x,_){return p(x,_.toNumber())},"Unit, number | BigNumber":function(x,_){return x.pow(_)}});function h(v,x){if(t.predictable&&!bt(x)&&v<0)try{var _=f(x),y=u(_);if((x===y||Math.abs((x-y)/x)<1e-14)&&_.d%2===1)return(_.n%2===0?1:-1)*Math.pow(-v,x)}catch{}return t.predictable&&(v<-1&&x===1/0||v>-1&&v<0&&x===-1/0)?NaN:bt(x)||v>=0||t.predictable?wc(v,x):v*v<1&&x===1/0||v*v>1&&x===-1/0?0:new c(v,0).pow(x,0)}function d(v,x){if(!bt(x))throw new TypeError("For A^b, b must be an integer (value is "+x+")");var _=Lt(v);if(_.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+_.length+" dimensions)");if(_[0]!==_[1])throw new Error("For A^b, A must be square (size is "+_[0]+"x"+_[1]+")");if(x<0)try{return d(a(v),-x)}catch(w){throw w.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 "+x+")"):w}for(var y=r(_[0]).valueOf(),m=v;x>=1;)(x&1)===1&&(y=n(m,y)),x>>=1,m=n(m,m);return y}function p(v,x){return i(d(v.valueOf(),x))}}),Qc="dotDivide",Im=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Tm=xe(Qc,Im,s=>{var{typed:e,matrix:t,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,u=Cg({typed:e,equalScalar:r}),f=Fi({typed:e}),c=uo({typed:e,DenseMatrix:i}),h=Ha({typed:e,equalScalar:r}),d=Ci({typed:e,DenseMatrix:i}),p=ri({typed:e,matrix:t,concat:a});return e(Qc,p({elop:n,SS:c,DS:f,SD:u,Ss:h,sS:d}))}),lo="compare",$m=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],Rm=xe(lo,$m,s=>{var{typed:e,config:t,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:u,concat:f}=s,c=Fi({typed:e}),h=Tc({typed:e,equalScalar:r}),d=Ci({typed:e,DenseMatrix:u}),p=ri({typed:e,matrix:n,concat:f}),v=oo({typed:e});return e(lo,Lm({typed:e,config:t}),{"boolean, boolean":function(_,y){return _===y?0:_>y?1:-1},"BigNumber, BigNumber":function(_,y){return so(_,y,t.epsilon)?new i(0):new i(_.cmp(y))},"Fraction, Fraction":function(_,y){return new a(_.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,p({SS:h,DS:c,Ss:d}))}),Lm=xe(lo,["typed","config"],s=>{var{typed:e,config:t}=s;return e(lo,{"number, number":function(n,i){return ti(n,i,t.epsilon)?0:n>i?1:-1}})}),co="equal",Pm=["typed","matrix","equalScalar","DenseMatrix","concat"],km=xe(co,Pm,s=>{var{typed:e,matrix:t,equalScalar:r,DenseMatrix:n,concat:i}=s,a=Fi({typed:e}),u=uo({typed:e,DenseMatrix:n}),f=Ci({typed:e,DenseMatrix:n}),c=ri({typed:e,matrix:t,concat:i});return e(co,zm({typed:e,equalScalar:r}),c({elop:r,SS:u,DS:a,Ss:f}))}),zm=xe(co,["typed","equalScalar"],s=>{var{typed:e,equalScalar:t}=s;return e(co,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:t(n,i)}})}),fo="smaller",qm=["typed","config","matrix","DenseMatrix","concat"],Um=xe(fo,qm,s=>{var{typed:e,config:t,matrix:r,DenseMatrix:n,concat:i}=s,a=Fi({typed:e}),u=uo({typed:e,DenseMatrix:n}),f=Ci({typed:e,DenseMatrix:n}),c=ri({typed:e,matrix:r,concat:i}),h=oo({typed:e});return e(fo,Wm({typed:e,config:t}),{"boolean, boolean":(d,p)=>d<p,"BigNumber, BigNumber":function(p,v){return p.lt(v)&&!so(p,v,t.epsilon)},"Fraction, Fraction":(d,p)=>d.compare(p)===-1,"Complex, Complex":function(p,v){throw new TypeError("No ordering relation is defined for complex numbers")}},h,c({SS:u,DS:a,Ss:f}))}),Wm=xe(fo,["typed","config"],s=>{var{typed:e,config:t}=s;return e(fo,{"number, number":function(n,i){return n<i&&!ti(n,i,t.epsilon)}})}),ho="larger",Hm=["typed","config","matrix","DenseMatrix","concat"],jm=xe(ho,Hm,s=>{var{typed:e,config:t,matrix:r,DenseMatrix:n,concat:i}=s,a=Fi({typed:e}),u=uo({typed:e,DenseMatrix:n}),f=Ci({typed:e,DenseMatrix:n}),c=ri({typed:e,matrix:r,concat:i}),h=oo({typed:e});return e(ho,Ym({typed:e,config:t}),{"boolean, boolean":(d,p)=>d>p,"BigNumber, BigNumber":function(p,v){return p.gt(v)&&!so(p,v,t.epsilon)},"Fraction, Fraction":(d,p)=>d.compare(p)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,c({SS:u,DS:a,Ss:f}))}),Ym=xe(ho,["typed","config"],s=>{var{typed:e,config:t}=s;return e(ho,{"number, number":function(n,i){return n>i&&!ti(n,i,t.epsilon)}})}),Jc="deepEqual",Zm=["typed","equal"],Vm=xe(Jc,Zm,s=>{var{typed:e,equal:t}=s;return e(Jc,{"any, any":function(i,a){return r(i.valueOf(),a.valueOf())}});function r(n,i){if(Array.isArray(n))if(Array.isArray(i)){var a=n.length;if(a!==i.length)return!1;for(var u=0;u<a;u++)if(!r(n[u],i[u]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),ef="partitionSelect",Gm=["typed","isNumeric","isNaN","compare"],Km=xe(ef,Gm,s=>{var{typed:e,isNumeric:t,isNaN:r,compare:n}=s,i=n,a=(c,h)=>-n(c,h);return e(ef,{"Array | Matrix, number":function(h,d){return u(h,d,i)},"Array | Matrix, number, string":function(h,d,p){if(p==="asc")return u(h,d,i);if(p==="desc")return u(h,d,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":u});function u(c,h,d){if(!bt(h)||h<0)throw new Error("k must be a non-negative integer");if(mt(c)){var p=c.size();if(p.length>1)throw new Error("Only one dimensional matrices supported");return f(c.valueOf(),h,d)}if(Array.isArray(c))return f(c,h,d)}function f(c,h,d){if(h>=c.length)throw new Error("k out of bounds");for(var p=0;p<c.length;p++)if(t(c[p])&&r(c[p]))return c[p];for(var v=0,x=c.length-1;v<x;){for(var _=v,y=x,m=c[Math.floor(Math.random()*(x-v+1))+v];_<y;)if(d(c[_],m)>=0){var w=c[y];c[y]=c[_],c[_]=w,--y}else++_;d(c[_],m)>0&&--_,h<=_?x=_:v=_+1}return c[h]}}),tf="max",Xm=["typed","config","numeric","larger"],Qm=xe(tf,Xm,s=>{var{typed:e,config:t,numeric:r,larger:n}=s;return e(tf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(f,c){return Wa(f,c.valueOf(),i)},"...":function(f){if(ro(f))throw new TypeError("Scalar values expected in function max");return a(f)}});function i(u,f){try{return n(u,f)?u:f}catch(c){throw Ln(c,"max",f)}}function a(u){var f;if(as(u,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||n(c,f))&&(f=c)}catch(h){throw Ln(h,"max",c)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=r(f,t.number)),f}}),rf="min",Jm=["typed","config","numeric","smaller"],ex=xe(rf,Jm,s=>{var{typed:e,config:t,numeric:r,smaller:n}=s;return e(rf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(f,c){return Wa(f,c.valueOf(),i)},"...":function(f){if(ro(f))throw new TypeError("Scalar values expected in function min");return a(f)}});function i(u,f){try{return n(u,f)?u:f}catch(c){throw Ln(c,"min",f)}}function a(u){var f;if(as(u,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||n(c,f))&&(f=c)}catch(h){throw Ln(h,"min",c)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=r(f,t.number)),f}}),nf="add",tx=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],rx=xe(nf,tx,s=>{var{typed:e,matrix:t,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:u}=s,f=$c({typed:e}),c=Wg({typed:e,equalScalar:n}),h=Rc({typed:e,DenseMatrix:i}),d=ri({typed:e,matrix:t,concat:u});return e(nf,{"any, any":r,"any, any, ...any":e.referToSelf(p=>(v,x,_)=>{for(var y=p(v,x),m=0;m<_.length;m++)y=p(y,_[m]);return y})},d({elop:r,DS:f,SS:c,Ss:h}))}),sf="dot",nx=["typed","addScalar","multiplyScalar","conj","size"],ix=xe(sf,nx,s=>{var{typed:e,addScalar:t,multiplyScalar:r,conj:n,size:i}=s;return e(sf,{"Array | DenseMatrix, Array | DenseMatrix":u,"SparseMatrix, SparseMatrix":f});function a(h,d){var p=c(h),v=c(d),x,_;if(p.length===1)x=p[0];else if(p.length===2&&p[1]===1)x=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(v.length===1)_=v[0];else if(v.length===2&&v[1]===1)_=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(x!==_)throw new RangeError("Vectors must have equal length ("+x+" != "+_+")");if(x===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return x}function u(h,d){var p=a(h,d),v=mt(h)?h._data:h,x=mt(h)?h._datatype||h.getDataType():void 0,_=mt(d)?d._data:d,y=mt(d)?d._datatype||d.getDataType():void 0,m=c(h).length===2,w=c(d).length===2,D=t,C=r;if(x&&y&&x===y&&typeof x=="string"&&x!=="mixed"){var b=x;D=e.find(t,[b,b]),C=e.find(r,[b,b])}if(!m&&!w){for(var F=C(n(v[0]),_[0]),B=1;B<p;B++)F=D(F,C(n(v[B]),_[B]));return F}if(!m&&w){for(var M=C(n(v[0]),_[0][0]),O=1;O<p;O++)M=D(M,C(n(v[O]),_[O][0]));return M}if(m&&!w){for(var A=C(n(v[0][0]),_[0]),N=1;N<p;N++)A=D(A,C(n(v[N][0]),_[N]));return A}if(m&&w){for(var I=C(n(v[0][0]),_[0][0]),R=1;R<p;R++)I=D(I,C(n(v[R][0]),_[R][0]));return I}}function f(h,d){a(h,d);for(var p=h._index,v=h._values,x=d._index,_=d._values,y=0,m=t,w=r,D=0,C=0;D<p.length&&C<x.length;){var b=p[D],F=x[C];if(b<F){D++;continue}if(b>F){C++;continue}b===F&&(y=m(y,w(v[D],_[C])),D++,C++)}return y}function c(h){return mt(h)?h.size():i(h)}}),sx="trace",ox=["typed","matrix","add"],ax=xe(sx,ox,s=>{var{typed:e,matrix:t,add:r}=s;return e("trace",{Array:function(u){return n(t(u))},SparseMatrix:i,DenseMatrix:n,any:ut});function n(a){var u=a._size,f=a._data;switch(u.length){case 1:if(u[0]===1)return ut(f[0]);throw new RangeError("Matrix must be square (size: "+ct(u)+")");case 2:{var c=u[0],h=u[1];if(c===h){for(var d=0,p=0;p<c;p++)d=r(d,f[p][p]);return d}else throw new RangeError("Matrix must be square (size: "+ct(u)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(u)+")")}}function i(a){var u=a._values,f=a._index,c=a._ptr,h=a._size,d=h[0],p=h[1];if(d===p){var v=0;if(u.length>0)for(var x=0;x<p;x++)for(var _=c[x],y=c[x+1],m=_;m<y;m++){var w=f[m];if(w===x){v=r(v,u[m]);break}if(w>x)break}return v}throw new RangeError("Matrix must be square (size: "+ct(h)+")")}}),of="det",ux=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],lx=xe(of,ux,s=>{var{typed:e,matrix:t,subtractScalar:r,multiply:n,divideScalar:i,isZero:a,unaryMinus:u}=s;return e(of,{any:function(h){return ut(h)},"Array | Matrix":function(h){var d;switch(mt(h)?d=h.size():Array.isArray(h)?(h=t(h),d=h.size()):d=[],d.length){case 0:return ut(h);case 1:if(d[0]===1)return ut(h.valueOf()[0]);if(d[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+ct(d)+")");case 2:{var p=d[0],v=d[1];if(p===v)return f(h.clone().valueOf(),p);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+ct(d)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(d)+")")}}});function f(c,h,d){if(h===1)return ut(c[0][0]);if(h===2)return r(n(c[0][0],c[1][1]),n(c[1][0],c[0][1]));for(var p=!1,v=new Array(h).fill(0).map((B,M)=>M),x=0;x<h;x++){var _=v[x];if(a(c[_][x])){var y=void 0;for(y=x+1;y<h;y++)if(!a(c[v[y]][x])){_=v[y],v[y]=v[x],v[x]=_,p=!p;break}if(y===h)return c[_][x]}for(var m=c[_][x],w=x===0?1:c[v[x-1]][x-1],D=x+1;D<h;D++)for(var C=v[D],b=x+1;b<h;b++)c[C][b]=i(r(n(c[C][b],m),n(c[C][x],c[_][b])),w)}var F=c[v[h-1]][h-1];return p?u(F):F}}),af="inv",cx=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],fx=xe(af,cx,s=>{var{typed:e,matrix:t,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:u,identity:f,abs:c}=s;return e(af,{"Array | Matrix":function(p){var v=mt(p)?p.size():Lt(p);switch(v.length){case 1:if(v[0]===1)return mt(p)?t([r(1,p.valueOf()[0])]):[r(1,p[0])];throw new RangeError("Matrix must be square (size: "+ct(v)+")");case 2:{var x=v[0],_=v[1];if(x===_)return mt(p)?t(h(p.valueOf(),x,_),p.storage()):h(p,x,_);throw new RangeError("Matrix must be square (size: "+ct(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(v)+")")}},any:function(p){return r(1,p)}});function h(d,p,v){var x,_,y,m,w;if(p===1){if(m=d[0][0],m===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,m)]]}else if(p===2){var D=u(d);if(D===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(d[1][1],D),r(a(d[0][1]),D)],[r(a(d[1][0]),D),r(d[0][0],D)]]}else{var C=d.concat();for(x=0;x<p;x++)C[x]=C[x].concat();for(var b=f(p).valueOf(),F=0;F<v;F++){var B=c(C[F][F]),M=F;for(x=F+1;x<p;)c(C[x][F])>B&&(B=c(C[x][F]),M=x),x++;if(B===0)throw Error("Cannot calculate inverse, determinant is zero");x=M,x!==F&&(w=C[F],C[F]=C[x],C[x]=w,w=b[F],b[F]=b[x],b[x]=w);var O=C[F],A=b[F];for(x=0;x<p;x++){var N=C[x],I=b[x];if(x!==F){if(N[F]!==0){for(y=r(a(N[F]),O[F]),_=F;_<v;_++)N[_]=n(N[_],i(y,O[_]));for(_=0;_<v;_++)I[_]=n(I[_],i(y,A[_]))}}else{for(y=O[F],_=F;_<v;_++)N[_]=r(N[_],y);for(_=0;_<v;_++)I[_]=r(I[_],y)}}}return b}}}),uf="pinv",hx=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],dx=xe(uf,hx,s=>{var{typed:e,matrix:t,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:u,ctranspose:f,divideScalar:c,multiply:h,add:d,Complex:p}=s;return e(uf,{"Array | Matrix":function(D){var C=mt(D)?D.size():Lt(D);switch(C.length){case 1:return m(D)?f(D):C[0]===1?r(D):a(f(D),u(D,D));case 2:{if(m(D))return f(D);var b=C[0],F=C[1];if(b===F)try{return r(D)}catch(B){if(!(B instanceof Error&&B.message.match(/Cannot calculate inverse, determinant is zero/)))throw B}return mt(D)?t(v(D.valueOf(),b,F),D.storage()):v(D,b,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(C)+")")}},any:function(D){return i(D,0)?ut(D):c(1,D)}});function v(w,D,C){var{C:b,F}=_(w,D,C),B=h(r(h(f(b),b)),f(b)),M=h(f(F),r(h(F,f(F))));return h(M,B)}function x(w,D,C){for(var b=ut(w),F=0,B=0;B<D;B++){if(C<=F)return b;for(var M=B;y(b[M][F]);)if(M++,D===M&&(M=B,F++,C===F))return b;[b[M],b[B]]=[b[B],b[M]];for(var O=b[B][F],A=0;A<C;A++)b[B][A]=a(b[B][A],O);for(var N=0;N<D;N++)if(N!==B){O=b[N][F];for(var I=0;I<C;I++)b[N][I]=d(b[N][I],h(-1,h(O,b[B][I])))}F++}return b}function _(w,D,C){var b=x(w,D,C),F=w.map((M,O)=>M.filter((A,N)=>N<D&&!y(u(b[N],b[N])))),B=b.filter((M,O)=>!y(u(b[O],b[O])));return{C:F,F:B}}function y(w){return i(d(w,p(1,1)),d(0,p(1,1)))}function m(w){return n(d(w,p(1,1)),d(h(w,0),p(1,1)))}}),px="divide",_x=["typed","matrix","multiply","equalScalar","divideScalar","inv"],vx=xe(px,_x,s=>{var{typed:e,matrix:t,multiply:r,equalScalar:n,divideScalar:i,inv:a}=s,u=Ha({typed:e,equalScalar:n}),f=ja({typed:e});return e("divide",Fl({"Array | Matrix, Array | Matrix":function(h,d){return r(h,a(d))},"DenseMatrix, any":function(h,d){return f(h,d,i,!1)},"SparseMatrix, any":function(h,d){return u(h,d,i,!1)},"Array, any":function(h,d){return f(t(h),d,i,!1).valueOf()},"any, Array | Matrix":function(h,d){return r(h,a(d))}},i.signatures))}),lf="sum",gx=["typed","config","add","numeric"],mx=xe(lf,gx,s=>{var{typed:e,config:t,add:r,numeric:n}=s;return e(lf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(f){if(ro(f))throw new TypeError("Scalar values expected in function sum");return i(f)}});function i(u){var f;return as(u,function(c){try{f=f===void 0?c:r(f,c)}catch(h){throw Ln(h,"sum",c)}}),f===void 0&&(f=n(0,t.number)),typeof f=="string"&&(f=n(f,t.number)),f}function a(u,f){try{var c=Wa(u,f,r);return c}catch(h){throw Ln(h,"sum")}}}),cf="median",xx=["typed","add","divide","compare","partitionSelect"],yx=xe(cf,xx,s=>{var{typed:e,add:t,divide:r,compare:n,partitionSelect:i}=s;function a(c){try{c=Ta(c.valueOf());var h=c.length;if(h===0)throw new Error("Cannot calculate median of an empty array");if(h%2===0){for(var d=h/2-1,p=i(c,d+1),v=c[d],x=0;x<d;++x)n(c[x],v)>0&&(v=c[x]);return f(v,p)}else{var _=i(c,(h-1)/2);return u(_)}}catch(y){throw Ln(y,"median")}}var u=e({"number | BigNumber | Complex | Unit":function(h){return h}}),f=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,d){return r(t(h,d),2)}});return e(cf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,d){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(ro(h))throw new TypeError("Scalar values expected in function median");return a(h)}})}),Dx={},wx=Object.freeze({__proto__:null,default:Dx}),bx=Mt(wx),po=Dv({config:Er}),Ya=Av({}),Za=Mv({}),Va=Ov({}),cn=$v({Matrix:Va}),Te=E_({BigNumber:po,Complex:Ya,DenseMatrix:cn,Fraction:Za}),Ex=dg({typed:Te}),_o=_g({typed:Te}),Ax=ig({BigNumber:po,typed:Te}),ff=rm({typed:Te}),Pn=Zv({config:Er,typed:Te}),vo=Pv({typed:Te}),Cx=Uv({typed:Te}),go=Vg({typed:Te}),hf=tg({typed:Te}),Ga=Kv({Matrix:Va,equalScalar:Pn,typed:Te}),df=gg({typed:Te}),pf=Hv({typed:Te}),Ka=fg({typed:Te}),_f=ag({Fraction:Za,typed:Te}),vf=zv({typed:Te}),Pt=lg({DenseMatrix:cn,Matrix:Va,SparseMatrix:Ga,typed:Te}),gf=bm({isNaN:pf,isNumeric:vf,typed:Te}),us=Bm({bignumber:Ax,fraction:_f,number:hf}),Fx=Am({config:Er,multiplyScalar:go,numeric:us,typed:Te}),Bx=_m({isInteger:vo,matrix:Pt,typed:Te}),mf=gm({matrix:Pt,config:Er,typed:Te}),xf=xm({matrix:Pt,typed:Te}),ni=im({isInteger:vo,matrix:Pt,typed:Te}),Mx=om({prod:Fx,size:mf,typed:Te}),Nx=Dm({conj:ff,transpose:xf,typed:Te}),ls=Nm({numeric:us,typed:Te}),Sx=Tm({DenseMatrix:cn,concat:ni,divideScalar:ls,equalScalar:Pn,matrix:Pt,typed:Te}),yf=km({DenseMatrix:cn,concat:ni,equalScalar:Pn,matrix:Pt,typed:Te}),Df=um({BigNumber:po,DenseMatrix:cn,SparseMatrix:Ga,config:Er,matrix:Pt,typed:Te}),Ox=cm({matrix:Pt,multiplyScalar:go,typed:Te}),Ix=Um({DenseMatrix:cn,concat:ni,config:Er,matrix:Pt,typed:Te}),Tx=Qg({DenseMatrix:cn,concat:ni,equalScalar:Pn,matrix:Pt,subtractScalar:df,typed:Te,unaryMinus:Ka}),cs=rx({DenseMatrix:cn,SparseMatrix:Ga,addScalar:_o,concat:ni,equalScalar:Pn,matrix:Pt,typed:Te}),wf=Rm({BigNumber:po,DenseMatrix:cn,Fraction:Za,concat:ni,config:Er,equalScalar:Pn,matrix:Pt,typed:Te}),$x=Vm({equal:yf,typed:Te}),bf=ix({addScalar:_o,conj:ff,multiplyScalar:go,size:mf,typed:Te}),Rx=jm({DenseMatrix:cn,concat:ni,config:Er,matrix:Pt,typed:Te}),Xa=ex({config:Er,numeric:us,smaller:Ix,typed:Te}),Bi=Kg({addScalar:_o,dot:bf,equalScalar:Pn,matrix:Pt,multiplyScalar:go,typed:Te}),Lx=Km({compare:wf,isNaN:pf,isNumeric:vf,typed:Te}),Px=mx({add:cs,config:Er,numeric:us,typed:Te}),kx=ax({add:cs,matrix:Pt,typed:Te}),Ef=lx({divideScalar:ls,isZero:Cx,matrix:Pt,multiply:Bi,subtractScalar:df,typed:Te,unaryMinus:Ka}),zx=Qm({config:Er,larger:Rx,numeric:us,typed:Te}),mo=fx({abs:Ex,addScalar:_o,det:Ef,divideScalar:ls,identity:Df,matrix:Pt,multiply:Bi,typed:Te,unaryMinus:Ka}),qx=dx({Complex:Ya,add:cs,ctranspose:Nx,deepEqual:$x,divideScalar:ls,dot:bf,dotDivide:Sx,equal:yf,inv:mo,matrix:Pt,multiply:Bi,typed:Te}),Ux=Om({Complex:Ya,config:Er,fraction:_f,identity:Df,inv:mo,matrix:Pt,multiply:Bi,number:hf,typed:Te}),Wx=vx({divideScalar:ls,equalScalar:Pn,inv:mo,matrix:Pt,multiply:Bi,typed:Te}),Af=yx({add:cs,compare:wf,divide:Wx,partitionSelect:Lx,typed:Te});class Hx{constructor(e,t,r){U(this,"_cacheData");U(this,"_variables");U(this,"_math");U(this,"_timeframe");this._cacheData={},this._variables=e,this._math=t,this._timeframe=r}alma({series:e,length:t,offset:r,sigma:n,floor:i},a){if(t===void 0||r===void 0||n===void 0)return;const u=this._cacheDataList(e,t,`alma_${a}`);if(u===void 0)return;let f=r*(t-1);i&&(f=Math.floor(f));const c=t/n;let h=0,d=0;for(let p=0;p<=t-1;p++){const v=Math.exp(-1*Math.pow(p-f,2)/(2*Math.pow(c,2)));h+=v,d+=u[u.length-1-(t-p-1)]*v}return d/h}sma({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;let n=0;const i=this._cacheDataList(e,t,`sma_${r}`);if(i===void 0)return;const a=i.slice(-t);return n=Px(...a)/t,n}rma({source:e,length:t},r){if(e===void 0||t===void 0||isNaN(e))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=e,this._cacheData[`sma_${r}`]=n;const{sum:i}=this._cacheData[`rma_${r}`]||{},a=1/t,u=i===void 0?this.sma({source:e,length:t},r):a*e+(1-a)*(i||0);return this._cacheDataHandle(`rma_${r}`,{sum:u}),u}atr({length:e},t){const{high:r,close:n}=this._cacheData[`atr_${t}`]||{},{high:i,close:a,low:u}=this._variables,f=r===void 0?i-u:Math.max(Math.max(i-u,Math.abs(i-n)),Math.abs(u-n));return this._cacheDataHandle(`atr_${t}`,{high:i,close:a}),this.rma({source:f,length:e},t)}barssince({condition:e},t){let{count:r}=this._cacheData[`barssince_${t}`]||{};if(e)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${t}`,{count:r}),r}stdev({source:e,length:t,biased:r=!0},n){if(e===void 0||isNaN(e)||t===void 0)return;const i=this._cacheDataList(e,t,`stdev_${n}`),a=this.sma({source:e,length:t},n);if(i===void 0)return;let u=0;for(let f=0;f<t;f++){const c=this._sum(i[i.length-1-f],-(a||0));u+=c*c}return r||t<=1?Math.sqrt(u/t):Math.sqrt(u/(t-1))}_sum(e,t){let n=e+t;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:e,length:t,mult:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return[];const i=this.sma({source:e,length:t},n),a=this.stdev({source:e,length:t},n);if(i===void 0||a===void 0)return[];const u=r*a;return[i,i+u,i-u]}bbw({series:e,length:t,mult:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const i=this.sma({source:e,length:t},n),a=this.stdev({source:e,length:t},n);if(i===void 0||a===void 0)return;const u=r*a;return(i+u-(i-u))/i}cci({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.sma({source:e,length:t},r),i=this.dev({source:e,length:t},r);if(!(n===void 0||i===void 0))return(e-n)/(.015*i)}change({source:e,length:t=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=e,this._cacheData[`change_${r}`]=n;const i=n[n.length-1-t];if(!(e===void 0||isNaN(e)))return i===void 0?i:typeof e=="boolean"?i!==e:e-i}cmo({series:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.change({source:e},r);if(n===void 0)return;const i=this._math.sum({source:n>=0?n:0,length:t},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:t},`sm2_${r}`);if(!(i===void 0||a===void 0))return 100*(i-a)/(i+a)}cog({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this._cacheDataList(e,t,`cog_${r}`),i=this._math.sum({source:e,length:t},r);if(i===void 0||n===void 0)return;let a=0;for(let u=0;u<t;u++){const f=n[n.length-1-u];a+=f*(u+1)}return-a/i}correlation({source1:e,source2:t,length:r},n){if(e===void 0||isNaN(e)||t===void 0||isNaN(t)||r===void 0)return;const i=this._cacheDataList([e,t],r,`correlation_${n}`),a=this.sma({source:e,length:r},`sma1_${n}`),u=this.sma({source:t,length:r},`sma2_${n}`);if(a===void 0||u===void 0||i===void 0)return;let f=0,c=0,h=0;for(let p=0;p<r;p++){const[v,x]=i[i.length-1-p],_=v-a,y=x-u;f+=_*y,c+=_*_,h+=y*y}return isNaN(c)||isNaN(f)||isNaN(h)?void 0:f/Math.sqrt(c*h)}cross({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n>=i&&e<t||n<=i&&e>t}crossover({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n<=i&&e>t}crossunder({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n>=i&&e<t}cum({source:e=0},t){e=isNaN(e)?0:e;let{sum:r}=this._cacheData[`cum_${t}`]||{};return r=r||0,r+=e,this._cacheDataHandle(`cum_${t}`,{sum:r}),r}dev({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.sma({source:e,length:t},r);let i=0;const a=this._cacheDataList(e,t,`dev_${r}`);if(!(!a||n===void 0)){for(let u=0;u<t;u++){const f=a[a.length-1-u];i+=Math.abs(f-n)}return i/t}}dmi({diLength:e,adxSmoothing:t},r){if(e===void 0||t===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:i,high:a,close:u,PDMS:f,NDMS:c,TRS:h,ADX:d,count:p=0}=this._cacheData[n]||{},{low:v,high:x,close:_}=this._variables;if(i===void 0||a===void 0||u===void 0)return this._cacheData[n]={low:v,high:x,close:_,PDMS:f,NDMS:c,TRS:x-v,count:1},[void 0,void 0,void 0];let y=x-a,m=i-v;y=y>m&&y>0?y:0,m=m>y&&m>0?m:0,y===m&&(y=m=0);const w=Math.max(x-v,Math.abs(x-u),Math.abs(v-u));if(p<e)return this._cacheDataHandle(n,{low:v,high:x,close:_,PDMS:(f||0)+y,NDMS:(c||0)+m,TRS:(h||0)+w,count:p+1}),[void 0,void 0,void 0];{const D=f-f/e+y,C=c-c/e+m,b=h-h/e+w,F=D/b*100,B=C/b*100,M=Math.abs((F-B)/(F+B))*100;let O=M,A=[F,B,void 0];if(p+1-e<t){const N=p+1-e;O=((d||0)*(N-1)+M)/N}else O=(d*(t-1)+M)/t,A=[F,B,O];return this._cacheDataHandle(n,{low:v,high:x,close:_,PDMS:D,NDMS:C,TRS:b,ADX:O,count:p+1}),A}}ema({source:e,length:t},r){if(e===void 0||t===void 0||isNaN(e))return;let{sum:n,count:i=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:e,length:t},r);if(i>t){const u=2/(t+1);n=n===void 0?e:u*e+(1-u)*(n||0)}else n=a;return i+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:i}),n}falling({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return!1;const{source:n,fallings:i=[]}=this._cacheData[`falling_${r}`]||{};i.push(n>e);const a=i.slice(-t);return this._cacheDataHandle(`falling_${r}`,{source:e,fallings:a}),a.length<t?!1:a.every(u=>u)}rising({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return!1;const{source:n,risings:i=[]}=this._cacheData[`rising_${r}`]||{};i.push(n<e);const a=i.slice(-t);return this._cacheDataHandle(`rising_${r}`,{source:e,risings:a}),a.length<t?!1:a.every(u=>u)}highest({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`highest_${r}`]||[],{high:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`highest_${r}`]=n;const u=n.filter(()=>!0);if(!(u.length<t))return Math.max(...u.slice(-t))}highestbars({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`highestbars_${r}`]=n;const u=n.filter(()=>!0);return u.length<t?void 0:u.slice(-t).reduce((c,h,d,p)=>h>=p[c]?d:c,0)-t+1}wma({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`wma_${r}`);if(!n)return;let i=0,a=0;for(let u=0;u<t;u++){const f=(t-u)*t;i+=f,a+=n[n.length-1-u]*f}return a/i}hma({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this.wma({source:e,length:t},r),i=this.wma({source:e,length:Math.round(t/2)},r);return n===void 0||i===void 0?void 0:this.wma({source:2*i-n,length:Math.floor(Math.sqrt(t))},`hma_${r}`)}kc({series:e,length:t,mult:r,useTrueRange:n=!0},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:e,length:t},i),{ta:u,high:f,low:c}=this._variables,h=n?u.tr:f-c,d=this.ema({source:h,length:t},`range_${i}`);return[a,a+d*r,a-d*r]}kcw({series:e,length:t,mult:r,useTrueRange:n=!0},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const a=this.ema({source:e,length:t},i),{ta:u,high:f,low:c}=this._variables,h=n?u.tr:f-c,d=this.ema({source:h,length:t},`range_${i}`);return(a+d*r-(a-d*r))/a}linreg({source:e,length:t,offset:r},n){if(t===void 0||r===void 0)return;const i=this._cacheDataList(e,t,`dev_${n}`);if(!i)return;const a=i.slice(-t).filter(v=>v!==void 0);let u=0,f=0,c=0,h=0;for(const[v,x]of a.entries())u+=v,f+=x,c+=v*x,h+=v*v;const d=(t*c-u*f)/(t*h-u*u);return(f-d*u)/t+d*(t-1-r)}lowest({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`lowest_${r}`]=n;const u=n.filter(()=>!0);if(!(u.length<t))return Math.min(...u.slice(-t))}lowestbars({source:e,length:t},r){if(t===void 0||t<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:i,bar_index:a}=this._variables;typeof e!="number"?n[a]=i:n[a]=e,this._cacheData[`lowestbars_${r}`]=n;const u=n.filter(()=>!0);return u.length<t?void 0:u.slice(-t).reduce((c,h,d,p)=>h<=p[c]?d:c,0)-t+1}macd({source:e,fastlen:t,slowlen:r,siglen:n},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:e,length:t},`ema1_${i}`),u=this.ema({source:e,length:r},`ema2_${i}`);if(a===void 0||u===void 0)return[void 0,void 0,void 0];const f=a-u,c=this.ema({source:f,length:n},`macd_${i}`);if(c===void 0)return[f,c,void 0];const h=f-c;return[f,c,h]}max({source:e},t){if(e===void 0||isNaN(e))return;let r=this._cacheData[`max_${t}`]||0;return e>r&&(r=e),this._cacheData[`max_${t}`]=r,r}min({source:e},t){if(e===void 0||isNaN(e))return;let r=this._cacheData[`min_${t}`]||1/0;return e<r&&(r=e),this._cacheData[`min_${t}`]=r,r}median({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`dev_${r}`);if(n)return Af(n.slice(-t))}mfi({series:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const{volume:n}=this._variables,i=this.change({source:e},r),a=this._math.sum({source:n*(i>=0?0:e),length:t},`lower_${r}`),u=this._math.sum({source:n*(i<=0?0:e),length:t},`upper_${r}`);if(!(u===void 0||a===void 0))return 100-100/(1+u/a)}mode({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`mode_${r}`);if(n)return Xa(gf(n.slice(-t)))}mom({source:e,length:t},r){if(t===void 0||t<0)return;const n=`mom_${r}`,i=this._cacheData[n]||[];if(i[this._variables.bar_index]=e,this._cacheData[n]=i,i.length<=t||e===void 0||isNaN(e))return;let a=i.length-t-1,u;for(;u===void 0&&a>=0;)u=i[a],a--;return u===void 0?u:e-u}percentile_linear_interpolation({source:e,length:t,percentage:r},n){if(t===void 0||r===void 0||t<0||r<0||r>100)return;const i=this._cacheDataList(e,t+1,`percentile_linear_interpolation_${n}`);if(!i)return;const a=this._sort(i.slice(-(t+1))),u=a.length;r/=100;const f=1/(u*2);if(r<=f)return a[0];if(r>=1-1/(u*2))return a[u-1];for(const[c,h]of a.entries()){const d=a[c-1];if(r<(c+.5)/u)return d===void 0||h===void 0?void 0:d+(h-d)*(r-(c-.5)/u)/(1/u)}}percentile_nearest_rank({source:e,length:t,percentage:r},n){if(t===void 0||r===void 0||e===void 0||isNaN(e)||t<0||r<0||r>100)return;const i=this._cacheDataList(e,t,`percentile_nearest_rank_${n}`);if(!i)return;const a=this._sort(i.slice(-t)),u=r/100*a.length,f=Math.ceil(u)-1;return a[f>=a.length?a.length-1:f]}percentrank({source:e,length:t},r){if(t===void 0||t<0)return;const n=this._cacheDataList(e,t+1,`percentile_nearest_rank_${r}`);if(!n)return;const i=n.slice(-(t+1)),a=e;if(a===void 0)return;let u=0;for(let f=0;f<i.length;f++)i[f]!==void 0&&(i[f]<a||i[f]===a&&f<t)&&u++;return u/(i.length-1)*100}pivot_point_levels({type:e,anchor:t,developing:r},n){const i=new it;let{close:a,open:u,low:f,high:c}=this._variables;const h=`pivot_point_levels_${n}`,{close:d,low:p,high:v,open:x,result:_}=this._cacheData[h]||{};if(!t&&(v&&p&&(c=Math.max(v,c),f=Math.min(p,f)),this._cacheDataHandle(h,{close:a,open:u,low:f,high:c,result:_}),!r))return i._value=_||[],i;const y={close:a,open:u,low:f,high:c};t===!0&&!r&&(a=d,u=x,f=p,c=v);const m=this._getPivotPointLevels(c,f,a,u,r,e);return this._cacheDataHandle(h,{...y,result:m}),i._value=m,i}_getPivotPointLevels(e,t,r,n,i,a){if(r===void 0||n===void 0||t===void 0||e===void 0)return[];switch(a){case ei.traditional:return this._traditional(e,t,r);case ei.fibonacci:return this._fibonacci(e,t,r);case ei.woodie:return i?[]:this._woodie(e,t);case ei.classic:return this._classic(e,t,r);case ei.dm:return this._DM(e,t,r,n);case ei.camarilla:return this._camarilla(e,t,r);default:return[]}}_traditional(e,t,r){const n=(e+t+r)/3,i=n*2-t,a=n+(e-t),u=n*2+(e-2*t),f=n*3+(e-3*t),c=n*4+(e-4*t),h=n*2-e,d=n-(e-t),p=n*2-(2*e-t),v=n*3-(3*e-t),x=n*4-(4*e-t);return[n,i,h,a,d,u,p,f,v,c,x]}_fibonacci(e,t,r){const n=(e+t+r)/3,i=n+.382*(e-t),a=n-.382*(e-t),u=n+.618*(e-t),f=n-.618*(e-t),c=n+(e-t),h=n-(e-t);return[n,i,a,u,f,c,h]}_woodie(e,t){const{open:r}=this._variables,n=(e+t+2*r)/4,i=2*n-t,a=2*n-e,u=n+(e-t),f=n-(e-t),c=e+2*(n-t),h=t-2*(e-n),d=c+(e-t),p=h-(e-t);return[n,i,a,u,f,c,h,d,p]}_classic(e,t,r){const n=(e+t+r)/3,i=2*n-t,a=2*n-e,u=n+(e-t),f=n-(e-t),c=n+2*(e-t),h=n-2*(e-t),d=n+3*(e-t),p=n-3*(e-t);return[n,i,a,u,f,c,h,d,p]}_DM(e,t,r,n){let i;n===r?i=e+t+2*r:r>n?i=2*e+t+r:i=2*t+e+r;const a=i/4,u=i/2-t,f=i/2-e;return[a,u,f]}_camarilla(e,t,r){const n=(e+t+r)/3,i=r+1.1*(e-t)/12,a=r-1.1*(e-t)/12,u=r+1.1*(e-t)/6,f=r-1.1*(e-t)/6,c=r+1.1*(e-t)/4,h=r-1.1*(e-t)/4,d=r+1.1*(e-t)/2,p=r-1.1*(e-t)/2,v=e/t*r,x=r-(v-r);return[n,i,a,u,f,c,h,d,p,v,x]}pivothigh({source:e=this._variables.high,leftbars:t,rightbars:r},n){if(t===void 0||r===void 0||t<0||r<0)return;const i=this._cacheDataList(e,t+r+1,`pivothigh_${n}`);if(!i)return;const a=i.slice(-(t+r+1)),u=a[t];return Math.max(...a)===u?u:void 0}pivotlow({source:e=this._variables.low,leftbars:t,rightbars:r},n){if(t===void 0||r===void 0||t<0||r<0)return;const i=this._cacheDataList(e,t+r+1,`pivotlow_${n}`);if(!i)return;const a=i.slice(-(t+r+1)),u=a[t];return Math.min(...a)===u?u:void 0}range({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<0)return;const n=this._cacheDataList(e,t,`range_${r}`);if(!n)return;const i=n.filter(f=>f!==void 0).slice(-t),a=Math.max(...i),u=Math.min(...i);return a-u}roc({source:e,length:t},r){if(t===void 0||t<0)return;const n=this._cacheDataList(e,t+1,`roc_${r}`),i=this.change({source:e,length:t},r);if(n)return 100*i/n[n.length-1-t]}rsi({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},i=Math.max(e-n,0),a=Math.max(n-e,0),u=this.rma({source:i,length:t},`rma1_${r}`),f=this.rma({source:a,length:t},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:e}),!(u===void 0||f===void 0))return 100-100/(1+u/f)}sar({start:e,inc:t,max:r},n){if(e===void 0||t===void 0||r===void 0)return;const{close:i,low:a,high:u,preLow:f,preHigh:c,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:d,maxMin:p,acceleration:v,isBelow:x}=h,_=!1;const{close:y,low:m,high:w,bar_index:D}=this._variables;return D===1&&(y>i?(x=!0,p=w,d=a):(x=!1,p=m,d=u),_=!0,v=e),d=d+v*(p-d),x?d>m&&(_=!0,x=!1,d=Math.max(w,p||0),p=m,v=e):d<w&&(_=!0,x=!0,d=Math.min(m,p||0),p=w,v=e),_||(x?w>(p||0)&&(p=w,v=Math.min((v||0)+t,r)):m<(p||0)&&(p=m,v=Math.min((v||0)+t,r))),x?(d=Math.min(d,a),D>1&&(d=Math.min(d,f))):(d=Math.max(d,u),D>1&&(d=Math.max(d,c))),this._cacheDataHandle(`sar_${n}`,{high:w,close:y,low:m,preLow:a,preHigh:u,data:Object.assign(h,{result:d,maxMin:p,acceleration:v,isBelow:x})}),d}stoch({source:e,high:t,low:r,length:n},i){if(n===void 0||t===void 0||r===void 0||e===void 0||isNaN(e)||n<0)return;const a=this.lowest({source:r,length:n},i),u=this.highest({source:t,length:n},i);if(!(a===void 0||u===void 0))return 100*(this._variables.close-a)/(u-a)}supertrend({factor:e,atrPeriod:t},r){if(e===void 0||t===void 0)return[void 0,void 0];const{hl2:n,close:i}=this._variables,a=`supertrend_${r}`,{upperBand:u,lowerBand:f,superTrend:c,atr:h,close:d}=this._cacheData[a]||{},p=this.atr({length:t},r);if(p===void 0)return this._cacheDataHandle(a,{close:i}),[void 0,void 0];let v=n+e*p,x=n-e*p;const _=u||0,y=f||0;x=x>y||d<y?x:y,v=v<_||d>_?v:_;let m;h===void 0?m=1:c===_?m=i>v?-1:1:m=i<x?1:-1;const w=m===-1?x:v;return this._cacheDataHandle(a,{upperBand:v,lowerBand:x,superTrend:w,atr:p,close:i}),[w,m]}swma({source:e},t){let{list:r}=this._cacheData[`swma_${t}`]||{};if(r||(r=[]),r.push(e),r=r.slice(-4),this._cacheDataHandle(`swma_${t}`,{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:e=!1},t){const{close:r,low:n,high:i}=this._variables,{close:a}=this._cacheData[`tr_${t}`]||{};return this._cacheDataHandle(`tr_${t}`,{close:r}),a===void 0?e?i-n:void 0:Math.max(i-n,Math.abs(i-a),Math.abs(n-a))}tsi({source:e,short_length:t,long_length:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const i=this.change({source:e},n);if(i===void 0)return;const a=this.ema({source:Math.abs(i),length:t},`absema1_${n}`),u=this.ema({source:i,length:t},`ema1_${n}`);if(u===void 0)return;const f=this.ema({source:u,length:r},`ema2_${n}`),c=this.ema({source:a,length:t},`absema2_${n}`);if(f!==void 0)return f/c}valuewhen({condition:e,source:t,occurrence:r},n){if(t===void 0||r===void 0||r<0)return;let{list:i}=this._cacheData[`valuewhen_${n}`]||{};return i||(i=[]),e&&i.push(t),this._cacheDataHandle(`valuewhen_${n}`,{list:i}),i[i.length-1-r]}variance({source:e,length:t,biased:r=!0},n){if(e===void 0||isNaN(e)||t===void 0||t<0)return;const i=this.sma({source:e,length:t},n),a=this._cacheDataList(e,t,`mode_${n}`);if(!a||i===void 0)return;const u=a.filter(c=>c!==void 0&&!isNaN(c)).slice(-t);if(u.length<t)return;const f=u.reduce((c,h)=>c+Math.pow(h-i,2),0);if(f!==void 0)return r||t<=1?f/t:f/(t-1)}vwap({source:e,anchor:t,stdev_mult:r},n){if(e===void 0)return;t=t===void 0?this._timeframe.change({timeframe:"1D"},n):t;const{volume:i}=this._variables;let{sum:a=0,sumV:u=0,count:f=0,isReset:c,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(t&&(a=u=f=h=0,c=!0),!c)return r!==void 0?[]:void 0;const d=e*i+a,p=i+u,v=d/p;return f++,r!==void 0?(h=i*Math.pow(e,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:d,sumV:p,count:f,isReset:c,sumS:h}),this._computeBands(h,p,r,v)):(this._cacheDataHandle(`vwap_${n}`,{sum:d,sumV:p,count:f,isReset:c}),v)}_computeBands(e,t,r,n){let i=e/t-Math.pow(n,2);i=i<0?0:i;const a=Math.sqrt(i),u=a!==void 0&&!isNaN(a)?n+r*a:void 0,f=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,u,f]}vwma({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0||t<=0)return;const{volume:n}=this._variables,i=this.sma({source:e*n,length:t},`sma1_${r}`),a=this.sma({source:n,length:t},`sma2_${r}`);if(!(i===void 0||a===void 0))return i/a}wpr({length:e},t){if(e===void 0||e<=0)return;const r=this.highest({length:e},t),n=this.lowest({length:e},t),{close:i}=this._variables;if(!(r===void 0||n===void 0))return(r-i)/(r-n)*-100}_sort(e){const t=e.length;for(let r=0;r<t;r++){let n={};for(let i=0;i<t-r;i++){const{currentVal:a,currentIndex:u}=n,f=e[i];if(f!==void 0){if(a!==void 0&&f<a){e.splice(i,1),e.splice(u,0,f),n={currentIndex:u+1,currentVal:a};continue}n={currentIndex:i,currentVal:f}}}}return e}_cacheDataList(e,t,r){const n=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:i}=this._variables;if(n.barIndex<=i&&(n.barIndex===i?n.list[n.list.length-1]=e:n.list.push(e),n.barIndex=i,this._cacheData[r]=n),!(n.list.length<t))return n.list}_cacheDataHandle(e,t){const{barIndex:r}=this._cacheData[e]||{};r!==this._variables.bar_index&&(this._cacheData[e]=Object.assign(t,{barIndex:this._variables.bar_index}))}}const Kt={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:"$keyword '$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",typeFieldErr:"In a type declaration, all fields without a default value must be explicitly typified.",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 na 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.",importMultipleErr:"Cannot import a library more than once",importNotExitErr:"The user '$username' does not have a published library titled '$libraryName'",importNameRepeatErr:"More than one import uses the same alias: $name. Previous usage at line: $line",exportFuncHasInputErr:"The exported function '$func' depends on the '$name' input variable, which is not allowed.",libraryTitleIsKeywordErr:"Invalid argument 'title' in 'library' call. Token: '$name' can't be used as library title.",exportFuncUseGlobalVarErr:"Cannot use global variables in exported functions. Function: $func",loopRuntimeErr:"Loop takes too long to execute (> 500 ms)",paramsErr:"Invalid value '$value' for '$param' parameter of the '$func' function. Possible values: $targetVal",displayErr:"Invalid argument 'display' in '$func' call. Possible values: $values",exportFuncUseReqErr:"Cannot use `request.*()` call in exported function `$name()`",requestExprErr:"Type series $type cannot be used in $name 'expression' argument",argDefaultErr:"The default value assigned to a parameter must be either a literal value (e.g., `5`) or a built-in variable (e.g., `close`)",overloadFuncErr:"Cannot use global variables or any values qualified as 'input' in the local scopes of overloaded functions or methods. Remove any global variables or inputs from the scopes of all '$name()' overloads.",againAssignErr:"Unable to determine the object for the field assignment. Try putting the object into a separate variable before assigning values to its fields.",requestUserInLoopErr:"Cannot use `request.*()` call within loops or conditional structures.",enumVarNameErr:"Invalid enum name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumVarNameBuiltinErr:"Invalid object name: $name. Namespaces of built-ins cannot be used.",typeNameErr:"Invalid user-defined type name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumUseErr:"Cannot use the '$name' as a value. Use one of the enum's fields instead.",conditionalErr:"'$name' conditional expression must be of a bool type!",fortoErr:'The value of the "for" loop must be a number.',indicatorUseStrategyFuncErr:"You cannot use strategy $type ($name) in indicator script."};an.SERIES,an.SIMPLE,an.INPUT,an.CONST,an.INT,an.FLOAT,an.BOOL,an.COLOR,an.STRING;const jx=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Yx=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Zx=["linefill","polyline","matrix","series","simple","string","array","color","const","float","label","table","bool","line","box","int","map","continue","for","varip","var","in","export","import","method","switch","break","while","else","type","and","for","not","as","by","if","in","or","to"];class Vx{constructor(e,t,r){U(this,"_cacheData");U(this,"_variables");U(this,"_errorListener");U(this,"_historyInputs");U(this,"_name");this._cacheData={},this._variables=e,this._errorListener=t,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(e){for(const t of e){const r=t.id;this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...t,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${t.index}`,{modifyDefval:t.sourceTypeName||t.defval})}}input(e,t){return this._cacheHandle(e,t)}int(e,t){return this._cacheHandle(e,t,ur.INT)}bool(e,t){return this._cacheHandle(e,t,ur.BOOL)}color(e,t){return this._cacheHandle(e,t,ur.COLOR)}time(e,t){return this._cacheHandle(e,t,ur.TIME)}float(e,t){return this._cacheHandle(e,t,ur.FLOAT)}price(e,t){return this._cacheHandle(e,t,ur.PRICE)}source(e,t){return this._cacheHandle(e,t,ur.SOURCE)}string(e,t){return this._cacheHandle(e,t,ur.STRING)}symbol(e,t){return this._cacheHandle(e,t,ur.SYMBOL)}session(e,t){return this._cacheHandle(e,t,ur.SESSION)}text_area(e,t){return this._cacheHandle(e,t,ur.TEXT_AREA)}timeframe(e,t){return this._cacheHandle(e,t,ur.TIMEFRAME)}enum(e,t){return this._cacheHandle(e,t,ur.ENUM)}_cacheHandle(e,t,r){if(t.startsWith("export"))return e.defval;const n=`${r||"input"}_${t}`,i=this._cacheData[n];if(e.defval===void 0&&this._errorListener.addError(Kt.inputDefvalErr,t,Ve.Error),i)i.isModify?i.sourceTypeName&&(this._cacheData[n].defval=this._variables[i.sourceTypeName]):Object.assign(this._cacheData[n],e);else{const{defval:a,display:u}=e;this._displayVerify(t,u),e={inputType:r,...e},this._cacheData[n]=e,this._judgeHistoryInputs(e),(r||e.inputType)===ur.SOURCE?this._cacheData[n].options=jx:e.options&&!e.options.includes(a)&&this._errorListener.addError(`input's defval should be in options, but '${a}' is not in [${e.options.toString()}]`,t,Ve.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_judgeHistoryInputs(e){const{defval:t,sourceTypeName:r,index:n}=e;let i=r||t;const a=`in_${n}`,u=this._historyInputs[a];if(!u)self.workerStorage.setValue(this._name,a,{defval:i});else{const{defval:f,modifyDefval:c}=u;f===i?i=c||i:self.workerStorage.setValue(this._name,a,{defval:i})}r?e.sourceTypeName=i:e.defval=i}_displayVerify(e,t){!t||!t.length||t.includes(Zt.dataWindow)||t.includes(Zt.statusLine)||this._errorListener.addError(or(Kt.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),e,Ve.Error)}getInputs(){const e=Object.keys(this._cacheData),t=[];for(const r of e){const n=this._cacheData[r];n.id=r,t.push(n)}return t.sort((r,n)=>(r.index||0)-(n.index||0))}}class Gx{color({x:e}){return e}new({color:e,transp:t=100}){me(t)&&(t=100);const r=(100-t)/100,{r:n,g:i,b:a}=this._parseColor(e||"");return`rgba(${Math.round(n)}, ${Math.round(i)}, ${Math.round(a)}, ${r})`}rgb({red:e=0,green:t=0,blue:r=0,transp:n=0}){return me(n)&&(n=0),me(e)&&(e=0),me(t)&&(t=0),me(r)&&(r=0),`rgba(${e}, ${t}, ${r}, ${(100-n)/100})`}g({color:e}){return e?this._parseColor(e).g:0}r({color:e}){return e?this._parseColor(e).r:0}b({color:e}){return e?this._parseColor(e).b:0}t({color:e}){return e?Math.round(this._parseColor(e).a*100):0}from_gradient({value:e,bottom_value:t,top_value:r,bottom_color:n,top_color:i}){if(me(e)||me(t)||me(r))return"rgba(0,0,0,1)";const a=(e-t)/(r-t),u=Math.min(Math.max(a,0),1),{r:f,g:c,b:h,a:d}=this._parseColor(n||"rgba(0,0,0,0)"),{r:p,g:v,b:x,a:_}=this._parseColor(i||"rgba(0,0,0,0)"),y=f+u*(p-f),m=c+u*(v-c),w=h+u*(x-h),D=d+u*(_-d);return`rgba(${Math.round(y)}, ${Math.round(m)}, ${Math.round(w)}, ${D.toFixed(2)})`}_parseColor(e){let t,r,n,i;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);const a=e.substring(7);a?i=(255-parseInt(a,16))/255:i=1}else{const a=this._parserRgbColor(e);t=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:t,g:r,b:n,a:i}}_parserRgbColor(e){var t;return((t=e.match(/\d+/g))==null?void 0:t.map(Number))||[]}}var We={};const Kx=Object.prototype.toString;function fs(s){const e=Kx.call(s);return e.endsWith("Array]")&&!e.includes("Big")}var Xx=Object.freeze({__proto__:null,isAnyArray:fs}),Qx=Mt(Xx);function Jx(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!fs(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],u=r+1;u<i;u++)s[u]>a&&(a=s[u]);return a}function ey(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!fs(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],u=r+1;u<i;u++)s[u]<a&&(a=s[u]);return a}function ty(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(fs(s)){if(s.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(e.output!==void 0){if(!fs(e.output))throw new TypeError("output option must be an array if specified");t=e.output}else t=new Array(s.length);var r=ey(s),n=Jx(s);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=e.min,a=i===void 0?e.autoMinMax?r:0:i,u=e.max,f=u===void 0?e.autoMinMax?n:1:u;if(a>=f)throw new RangeError("min option must be smaller than max option");for(var c=(f-a)/(n-r),h=0;h<s.length;h++)t[h]=(s[h]-r)*c+a;return t}var ry=Object.freeze({__proto__:null,default:ty}),ny=Mt(ry);Object.defineProperty(We,"__esModule",{value:!0});var gr=Qx,Cf=ny;const xo=" ".repeat(2),Ff=" ".repeat(4);function iy(){return Bf(this)}function Bf(s,e={}){const{maxRows:t=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=e;return`${s.constructor.name} {
55
55
  ${xo}[
56
56
  ${Ff}${sy(s,t,r,n,i)}
57
57
  ${xo}]
@@ -67519,7 +67519,7 @@ function ar(a, n, r) {
67519
67519
  function lh() {
67520
67520
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
67521
67521
  }
67522
- const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-D9ObnG9j.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
67522
+ const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-9FT1SIzf.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
67523
67523
  Fp.onerror = (a) => {
67524
67524
  console.error(a);
67525
67525
  };
@@ -141,7 +141,7 @@ function print() { __p += __j.call(arguments, '') }
141
141
  * @license
142
142
  * Copyright 2019 Google LLC
143
143
  * SPDX-License-Identifier: Apache-2.0
144
- */const _o=Symbol("Comlink.proxy"),nm=Symbol("Comlink.endpoint"),im=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",om={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},lm={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",om],["throw",lm]]);function cm(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(l){if(!l||!l.data)return;if(!cm(s,l.origin)){console.warn(`Invalid origin '${l.origin}' for comlink proxy`);return}const{id:c,type:m,path:_}=Object.assign({path:[]},l.data),g=(l.data.argumentList||[]).map(gr);let b;try{const h=_.slice(0,-1).reduce((P,B)=>P[B],a),T=_.reduce((P,B)=>P[B],a);switch(m){case"GET":b=T;break;case"SET":h[_.slice(-1)[0]]=gr(l.data.value),b=!0;break;case"APPLY":b=T.apply(h,g);break;case"CONSTRUCT":{const P=new T(...g);b=gn(P)}break;case"ENDPOINT":{const{port1:P,port2:B}=new MessageChannel;bo(a,B),b=ym(P,[P])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,P]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:c}),P),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,P]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:c}),P)})}),n.start&&n.start()}function pm(a){return a.constructor.name==="MessagePort"}function xo(a){pm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Lr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function dm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function mm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const l=new Proxy(s,{get(c,m){if(Qs(o),m===im)return()=>{mm(l),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>l};const _=Lr(a,{type:"GET",path:n.map(g=>g.toString())}).then(gr);return _.then.bind(_)}return fn(a,[...n,m])},set(c,m,_){Qs(o);const[g,b]=ea(_);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:g},b).then(gr)},apply(c,m,_){Qs(o);const g=n[n.length-1];if(g===nm)return Lr(a,{type:"ENDPOINT"}).then(gr);if(g==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(_);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(gr)},construct(c,m){Qs(o);const[_,g]=wo(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:_},g).then(gr)}});return dm(l,a),l}function um(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),um(n.map(s=>s[1]))]}const vo=new WeakMap;function ym(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,l]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},l]}return[{type:"RAW",value:a},vo.get(a)||[]]}function gr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const l=_m();a.addEventListener("message",function c(m){!m.data||!m.data.id||m.data.id!==l||(a.removeEventListener("message",c),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:l},n),s)})}function _m(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-D9ObnG9j.js").href:new URL("assets/scriptsRunWorker-D9ObnG9j.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});To.onerror=a=>{console.error(a)};async function Do(a){return await Gs.setInlayHints(a)}const ko=_n(To),Io=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-DhJ8omfR.js").href:new URL("assets/parserTccWorker-DhJ8omfR.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function Ao(a,n=!1){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function fm(a,n){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function gm(a){return await ko.removeScript(a)}function bm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}self.MonacoEnvironment={getWorker(){return new bm({name:"Editor Worker"})}},sn.config({monaco:pp});let Co={};const xm=(a,n)=>{const{height:s,width:o,theme:l,options:c,hasDiff:m,readOnly:_,defaultValue:g,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:P,onActionTrigger:B,onEditorDidMount:R}=a,N=O.useRef(null),W=O.useRef(null);O.useImperativeHandle(n,()=>({setOriginalScript(q){var U;(U=N.current)==null||U.setOriginalScript(q)},setScript(q){var U;(U=N.current)==null||U.setValue(q)},gotoLine(){var q;(q=N.current)==null||q.gotoLine()},getEditorLayout(){var q;return(q=N.current)==null?void 0:q.getEditorLayout()},setPosition(q,U){var j;(j=N.current)==null||j.setPosition({column:q,lineNumber:U})},setModelMarkers(q){var U;(U=N.current)==null||U.setModelMarkers(q)}})),O.useEffect(()=>{var q,U;m?(U=N.current)==null||U.addDiffDecorations():(q=N.current)==null||q.removeDiffDecorations()},[m]),O.useEffect(()=>{var q;(q=N.current)==null||q.updateActionTrigger(B)},[B]),O.useEffect(()=>{var q;h&&((q=N.current)==null||q.addLinkOpenFunc(h))},[h]);function V(q,U){var ae,ye,le;zt.initBuiltinsTrees(),Gs.setEditor(q),N.current=new am(q,U,B),h&&((ae=N.current)==null||ae.addLinkOpenFunc(h)),m&&((ye=N.current)==null||ye.addDiffDecorations()),zd(q),(le=N.current)==null||le.setEditorLayout(Number(s));const j=q.getValue();N.current.onChangeCursorPosition(P),b&&b(j),!_&&G(j),R&&R()}const G=O.useCallback(async q=>{var ht;const U=Date.now(),{errors:j,functions:ae,methods:ye,types:le,variables:xt,overloadsFuncs:St,imports:$e,preParserCode:Be,enums:Q}=await Ao(q),ge=new Map(Object.entries(ae)),Ne=new Map(Object.entries(ye)),Pe=new Map(Object.entries(le)),ct=new Map(Object.entries(xt)),Et=new Map(Object.entries($e)),te=new Map(Object.entries(Q));Er.setUserDefined({functions:ge,methods:Ne,types:Pe,variables:ct,imports:Et,enums:te},St),zt.setUserDefind(ge,Pe,ct,Ne,te);const he=j.map(Ae=>({...Ae,severity:Ae.type||ke.MarkerSeverity.Error}));if(_)return;try{if(!j.length&&Be){const Ae=await qo(Be,{isPreParser:!0});io.isEqual(Ae,Co)||(Co=Ae,T&&T(Ae))}}catch(Ae){console.log(Ae),j.push({message:Ae.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}(ht=N.current)==null||ht.setModelMarkers(he);const Fe=Date.now();console.log((Fe-U)/1e3)},[T,_]),F=O.useMemo(()=>io.debounce(G,1500),[G]);function k(q){var U;if(_){G(q||"");return}Gs.clearInlayHints(),(U=N.current)==null||U.setModelMarkers([]),q!==void 0&&(b&&b(q),F(q))}return O.useEffect(()=>{const q=()=>{window.requestAnimationFrame(()=>{var ae,ye;const j=(ae=W.current)==null?void 0:ae.getBoundingClientRect();(ye=N.current)==null||ye.setEditorLayout((j==null?void 0:j.height)||0,j==null?void 0:j.width)})},U=new ResizeObserver(q);return W.current&&U.observe(W.current),()=>{W.current&&U.unobserve(W.current),U.disconnect()}},[]),L.jsx("div",{ref:W,children:L.jsx(xd,{height:s,width:o||"100%",defaultLanguage:Ee,defaultValue:g||`indicator("我的脚本")
144
+ */const _o=Symbol("Comlink.proxy"),nm=Symbol("Comlink.endpoint"),im=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",om={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},lm={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",om],["throw",lm]]);function cm(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(l){if(!l||!l.data)return;if(!cm(s,l.origin)){console.warn(`Invalid origin '${l.origin}' for comlink proxy`);return}const{id:c,type:m,path:_}=Object.assign({path:[]},l.data),g=(l.data.argumentList||[]).map(gr);let b;try{const h=_.slice(0,-1).reduce((P,B)=>P[B],a),T=_.reduce((P,B)=>P[B],a);switch(m){case"GET":b=T;break;case"SET":h[_.slice(-1)[0]]=gr(l.data.value),b=!0;break;case"APPLY":b=T.apply(h,g);break;case"CONSTRUCT":{const P=new T(...g);b=gn(P)}break;case"ENDPOINT":{const{port1:P,port2:B}=new MessageChannel;bo(a,B),b=ym(P,[P])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,P]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:c}),P),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,P]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:c}),P)})}),n.start&&n.start()}function pm(a){return a.constructor.name==="MessagePort"}function xo(a){pm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Lr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function dm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function mm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const l=new Proxy(s,{get(c,m){if(Qs(o),m===im)return()=>{mm(l),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>l};const _=Lr(a,{type:"GET",path:n.map(g=>g.toString())}).then(gr);return _.then.bind(_)}return fn(a,[...n,m])},set(c,m,_){Qs(o);const[g,b]=ea(_);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:g},b).then(gr)},apply(c,m,_){Qs(o);const g=n[n.length-1];if(g===nm)return Lr(a,{type:"ENDPOINT"}).then(gr);if(g==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(_);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(gr)},construct(c,m){Qs(o);const[_,g]=wo(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:_},g).then(gr)}});return dm(l,a),l}function um(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),um(n.map(s=>s[1]))]}const vo=new WeakMap;function ym(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,l]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},l]}return[{type:"RAW",value:a},vo.get(a)||[]]}function gr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const l=_m();a.addEventListener("message",function c(m){!m.data||!m.data.id||m.data.id!==l||(a.removeEventListener("message",c),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:l},n),s)})}function _m(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-9FT1SIzf.js").href:new URL("assets/scriptsRunWorker-9FT1SIzf.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});To.onerror=a=>{console.error(a)};async function Do(a){return await Gs.setInlayHints(a)}const ko=_n(To),Io=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-DhJ8omfR.js").href:new URL("assets/parserTccWorker-DhJ8omfR.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function Ao(a,n=!1){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function fm(a,n){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function gm(a){return await ko.removeScript(a)}function bm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}self.MonacoEnvironment={getWorker(){return new bm({name:"Editor Worker"})}},sn.config({monaco:pp});let Co={};const xm=(a,n)=>{const{height:s,width:o,theme:l,options:c,hasDiff:m,readOnly:_,defaultValue:g,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:P,onActionTrigger:B,onEditorDidMount:R}=a,N=O.useRef(null),W=O.useRef(null);O.useImperativeHandle(n,()=>({setOriginalScript(q){var U;(U=N.current)==null||U.setOriginalScript(q)},setScript(q){var U;(U=N.current)==null||U.setValue(q)},gotoLine(){var q;(q=N.current)==null||q.gotoLine()},getEditorLayout(){var q;return(q=N.current)==null?void 0:q.getEditorLayout()},setPosition(q,U){var j;(j=N.current)==null||j.setPosition({column:q,lineNumber:U})},setModelMarkers(q){var U;(U=N.current)==null||U.setModelMarkers(q)}})),O.useEffect(()=>{var q,U;m?(U=N.current)==null||U.addDiffDecorations():(q=N.current)==null||q.removeDiffDecorations()},[m]),O.useEffect(()=>{var q;(q=N.current)==null||q.updateActionTrigger(B)},[B]),O.useEffect(()=>{var q;h&&((q=N.current)==null||q.addLinkOpenFunc(h))},[h]);function V(q,U){var ae,ye,le;zt.initBuiltinsTrees(),Gs.setEditor(q),N.current=new am(q,U,B),h&&((ae=N.current)==null||ae.addLinkOpenFunc(h)),m&&((ye=N.current)==null||ye.addDiffDecorations()),zd(q),(le=N.current)==null||le.setEditorLayout(Number(s));const j=q.getValue();N.current.onChangeCursorPosition(P),b&&b(j),!_&&G(j),R&&R()}const G=O.useCallback(async q=>{var ht;const U=Date.now(),{errors:j,functions:ae,methods:ye,types:le,variables:xt,overloadsFuncs:St,imports:$e,preParserCode:Be,enums:Q}=await Ao(q),ge=new Map(Object.entries(ae)),Ne=new Map(Object.entries(ye)),Pe=new Map(Object.entries(le)),ct=new Map(Object.entries(xt)),Et=new Map(Object.entries($e)),te=new Map(Object.entries(Q));Er.setUserDefined({functions:ge,methods:Ne,types:Pe,variables:ct,imports:Et,enums:te},St),zt.setUserDefind(ge,Pe,ct,Ne,te);const he=j.map(Ae=>({...Ae,severity:Ae.type||ke.MarkerSeverity.Error}));if(_)return;try{if(!j.length&&Be){const Ae=await qo(Be,{isPreParser:!0});io.isEqual(Ae,Co)||(Co=Ae,T&&T(Ae))}}catch(Ae){console.log(Ae),j.push({message:Ae.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}(ht=N.current)==null||ht.setModelMarkers(he);const Fe=Date.now();console.log((Fe-U)/1e3)},[T,_]),F=O.useMemo(()=>io.debounce(G,1500),[G]);function k(q){var U;if(_){G(q||"");return}Gs.clearInlayHints(),(U=N.current)==null||U.setModelMarkers([]),q!==void 0&&(b&&b(q),F(q))}return O.useEffect(()=>{const q=()=>{window.requestAnimationFrame(()=>{var ae,ye;const j=(ae=W.current)==null?void 0:ae.getBoundingClientRect();(ye=N.current)==null||ye.setEditorLayout((j==null?void 0:j.height)||0,j==null?void 0:j.width)})},U=new ResizeObserver(q);return W.current&&U.observe(W.current),()=>{W.current&&U.unobserve(W.current),U.disconnect()}},[]),L.jsx("div",{ref:W,children:L.jsx(xd,{height:s,width:o||"100%",defaultLanguage:Ee,defaultValue:g||`indicator("我的脚本")
145
145
  plot(close)
146
146
  `,theme:l||"vs-dark",className:`tvue-script ${l||"vs-dark"}`,options:{colorDecorators:!0,useShadowDOM:!1,matchOnWordStartOnly:!0,automaticLayout:!1,suggest:{filterGraceful:!0},fontSize:13,..._?Rd:{},readOnlyMessage:{value:"该脚本是只读的。它无法被编辑。"},...c},onMount:V,onChange:k})})},hm=O.forwardRef(xm),wm=a=>{const{theme:n,modified:s,original:o,height:l,width:c,renderSideBySide:m=!0}=a,_=O.useCallback((g,b)=>{b.languages.register({id:Ee}),b.editor.defineTheme("vs-dark",cn),b.editor.defineTheme("vs",ln),b.languages.setMonarchTokensProvider(Ee,Nr),b.languages.setLanguageConfiguration(Ee,on)},[]);return L.jsx(yd,{height:l||"90vh",width:c||"100%",theme:n||"vs-dark",options:{readOnly:!0,renderSideBySide:m,scrollBeyondLastLine:!1},language:Ee,modified:s,original:o,onMount:_})};A.VMarkerSeverity=void 0,function(a){a[a.Hint=1]="Hint",a[a.Info=2]="Info",a[a.Warning=4]="Warning",a[a.Error=8]="Error"}(A.VMarkerSeverity||(A.VMarkerSeverity={}));var ta={},vm=function(){var a=document.getSelection();if(!a.rangeCount)return function(){};for(var n=document.activeElement,s=[],o=0;o<a.rangeCount;o++)s.push(a.getRangeAt(o));switch(n.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":n.blur();break;default:n=null;break}return a.removeAllRanges(),function(){a.type==="Caret"&&a.removeAllRanges(),a.rangeCount||s.forEach(function(l){a.addRange(l)}),n&&n.focus()}},Tm=vm,zo={"text/plain":"Text","text/html":"Url",default:"Text"},Dm="Copy to clipboard: #{key}, Enter";function km(a){var n=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,n)}function Im(a,n){var s,o,l,c,m,_,g=!1;n||(n={}),s=n.debug||!1;try{l=Tm(),c=document.createRange(),m=document.getSelection(),_=document.createElement("span"),_.textContent=a,_.ariaHidden="true",_.style.all="unset",_.style.position="fixed",_.style.top=0,_.style.clip="rect(0, 0, 0, 0)",_.style.whiteSpace="pre",_.style.webkitUserSelect="text",_.style.MozUserSelect="text",_.style.msUserSelect="text",_.style.userSelect="text",_.addEventListener("copy",function(h){if(h.stopPropagation(),n.format)if(h.preventDefault(),typeof h.clipboardData>"u"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var T=zo[n.format]||zo.default;window.clipboardData.setData(T,a)}else h.clipboardData.clearData(),h.clipboardData.setData(n.format,a);n.onCopy&&(h.preventDefault(),n.onCopy(h.clipboardData))}),document.body.appendChild(_),c.selectNodeContents(_),m.addRange(c);var b=document.execCommand("copy");if(!b)throw new Error("copy command was unsuccessful");g=!0}catch(h){s&&console.error("unable to copy using execCommand: ",h),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(n.format||"text",a),n.onCopy&&n.onCopy(window.clipboardData),g=!0}catch(T){s&&console.error("unable to copy using clipboardData: ",T),s&&console.error("falling back to prompt"),o=km("message"in n?n.message:Dm),window.prompt(o,a)}}finally{m&&(typeof m.removeRange=="function"?m.removeRange(c):m.removeAllRanges()),_&&document.body.removeChild(_),l()}return g}var Am=Im;function bn(a){"@babel/helpers - typeof";return bn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},bn(a)}Object.defineProperty(ta,"__esModule",{value:!0}),ta.CopyToClipboard=void 0;var ra=So(O),qm=So(Am),Cm=["text","onCopy","options","children"];function So(a){return a&&a.__esModule?a:{default:a}}function Eo(a,n){var s=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);n&&(o=o.filter(function(l){return Object.getOwnPropertyDescriptor(a,l).enumerable})),s.push.apply(s,o)}return s}function No(a){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Eo(Object(s),!0).forEach(function(o){hn(a,o,s[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):Eo(Object(s)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(s,o))})}return a}function zm(a,n){if(a==null)return{};var s=Sm(a,n),o,l;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(a);for(l=0;l<c.length;l++)o=c[l],!(n.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(s[o]=a[o])}return s}function Sm(a,n){if(a==null)return{};var s={},o=Object.keys(a),l,c;for(c=0;c<o.length;c++)l=o[c],!(n.indexOf(l)>=0)&&(s[l]=a[l]);return s}function Em(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function Lo(a,n){for(var s=0;s<n.length;s++){var o=n[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(a,o.key,o)}}function Nm(a,n,s){return n&&Lo(a.prototype,n),s&&Lo(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function Lm(a,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(n&&n.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),n&&xn(a,n)}function xn(a,n){return xn=Object.setPrototypeOf||function(o,l){return o.__proto__=l,o},xn(a,n)}function Mm(a){var n=Om();return function(){var o=sa(a),l;if(n){var c=sa(this).constructor;l=Reflect.construct(o,arguments,c)}else l=o.apply(this,arguments);return Pm(this,l)}}function Pm(a,n){if(n&&(bn(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mo(a)}function Mo(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Om(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sa(a){return sa=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},sa(a)}function hn(a,n,s){return n in a?Object.defineProperty(a,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[n]=s,a}var Po=function(a){Lm(s,a);var n=Mm(s);function s(){var o;Em(this,s);for(var l=arguments.length,c=new Array(l),m=0;m<l;m++)c[m]=arguments[m];return o=n.call.apply(n,[this].concat(c)),hn(Mo(o),"onClick",function(_){var g=o.props,b=g.text,h=g.onCopy,T=g.children,P=g.options,B=ra.default.Children.only(T),R=(0,qm.default)(b,P);h&&h(b,R),B&&B.props&&typeof B.props.onClick=="function"&&B.props.onClick(_)}),o}return Nm(s,[{key:"render",value:function(){var l=this.props;l.text,l.onCopy,l.options;var c=l.children,m=zm(l,Cm),_=ra.default.Children.only(c);return ra.default.cloneElement(_,No(No({},m),{},{onClick:this.onClick}))}}]),s}(ra.default.PureComponent);ta.CopyToClipboard=Po,hn(Po,"defaultProps",{onCopy:void 0,options:void 0});var Rm=ta,wn=Rm.CopyToClipboard;wn.CopyToClipboard=wn;var Fm=wn;const vn=dp(Fm);async function Bm(a,n=0){const s=a[n];if(!s)return;const{name:o,args:l,type:c,desc:m,examples:_,remarks:g,seeAlso:b,syntax:h,detailedDesc:T,fields:P,returns:B}=s,R={name:o};if(a.length>1&&(R.overloads=`${a.length} overloads`),c&&(R.type=c),l&&(R.name=`${o}()`,R.args=l.map(N=>{const{name:W,desc:V,displayType:G}=N;return{label:`${W} (${G})`,desc:V&&br(V)}})),m&&(R.desc=m.map(N=>br(N))),_&&(R.originalExample=_.join(`
147
147
  `),R.examples=await ke.editor.colorize(R.originalExample,Ee,{tabSize:4})),T){R.detailedDesc=[];for(const N of T){const{desc:W,examples:V}=N;let G=W.map(q=>br(q)),F,k;V&&(k=V.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guihz/trading-vue-editor-tes",
3
- "version": "0.0.120",
3
+ "version": "0.0.121",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"