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

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,13 +25,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
25
25
  * Jan Hruby jhruby.web@gmail.com
26
26
  */return n.mode.CTRGladman=function(){var r=n.lib.BlockCipherMode.extend();function a(p){if((p>>24&255)===255){var E=p>>16&255,b=p>>8&255,T=p&255;E===255?(E=0,b===255?(b=0,T===255?T=0:++T):++b):++E,p=0,p+=E<<16,p+=b<<8,p+=T}else p+=1<<24;return p}function c(p){return(p[0]=a(p[0]))===0&&(p[1]=a(p[1])),p}var f=r.Encryptor=r.extend({processBlock:function(p,E){var b=this._cipher,T=b.blockSize,x=this._iv,w=this._counter;x&&(w=this._counter=x.slice(0),this._iv=void 0),c(w);var F=w.slice(0);b.encryptBlock(F,0);for(var R=0;R<T;R++)p[E+R]^=F[R]}});return r.Decryptor=f,r}(),n.mode.CTRGladman})}(ef)),ef.exports}var tf={exports:{}},Yp;function Ry(){return Yp||(Yp=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return n.mode.OFB=function(){var r=n.lib.BlockCipherMode.extend(),a=r.Encryptor=r.extend({processBlock:function(c,f){var p=this._cipher,E=p.blockSize,b=this._iv,T=this._keystream;b&&(T=this._keystream=b.slice(0),this._iv=void 0),p.encryptBlock(T,0);for(var x=0;x<E;x++)c[f+x]^=T[x]}});return r.Decryptor=a,r}(),n.mode.OFB})}(tf)),tf.exports}var nf={exports:{}},Zp;function Fy(){return Zp||(Zp=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return n.mode.ECB=function(){var r=n.lib.BlockCipherMode.extend();return r.Encryptor=r.extend({processBlock:function(a,c){this._cipher.encryptBlock(a,c)}}),r.Decryptor=r.extend({processBlock:function(a,c){this._cipher.decryptBlock(a,c)}}),r}(),n.mode.ECB})}(nf)),nf.exports}var rf={exports:{}},Qp;function Ny(){return Qp||(Qp=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return n.pad.AnsiX923={pad:function(r,a){var c=r.sigBytes,f=a*4,p=f-c%f,E=c+p-1;r.clamp(),r.words[E>>>2]|=p<<24-E%4*8,r.sigBytes+=p},unpad:function(r){var a=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=a}},n.pad.Ansix923})}(rf)),rf.exports}var of={exports:{}},Jp;function Iy(){return Jp||(Jp=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return n.pad.Iso10126={pad:function(r,a){var c=a*4,f=c-r.sigBytes%c;r.concat(n.lib.WordArray.random(f-1)).concat(n.lib.WordArray.create([f<<24],1))},unpad:function(r){var a=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=a}},n.pad.Iso10126})}(of)),of.exports}var af={exports:{}},ed;function Py(){return ed||(ed=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return n.pad.Iso97971={pad:function(r,a){r.concat(n.lib.WordArray.create([2147483648],1)),n.pad.ZeroPadding.pad(r,a)},unpad:function(r){n.pad.ZeroPadding.unpad(r),r.sigBytes--}},n.pad.Iso97971})}(af)),af.exports}var sf={exports:{}},td;function By(){return td||(td=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return n.pad.ZeroPadding={pad:function(r,a){var c=a*4;r.clamp(),r.sigBytes+=c-(r.sigBytes%c||c)},unpad:function(r){for(var a=r.words,c=r.sigBytes-1,c=r.sigBytes-1;c>=0;c--)if(a[c>>>2]>>>24-c%4*8&255){r.sigBytes=c+1;break}}},n.pad.ZeroPadding})}(sf)),sf.exports}var uf={exports:{}},nd;function Ly(){return nd||(nd=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return n.pad.NoPadding={pad:function(){},unpad:function(){}},n.pad.NoPadding})}(uf)),uf.exports}var cf={exports:{}},rd;function My(){return rd||(rd=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),Xn())})(Tt,function(n){return function(r){var a=n,c=a.lib,f=c.CipherParams,p=a.enc,E=p.Hex,b=a.format;b.Hex={stringify:function(T){return T.ciphertext.toString(E)},parse:function(T){var x=E.parse(T);return f.create({ciphertext:x})}}}(),n.format.Hex})}(cf)),cf.exports}var lf={exports:{}},id;function Uy(){return id||(id=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),xo(),So(),uo(),Xn())})(Tt,function(n){return function(){var r=n,a=r.lib,c=a.BlockCipher,f=r.algo,p=[],E=[],b=[],T=[],x=[],w=[],F=[],R=[],v=[],d=[];(function(){for(var O=[],D=0;D<256;D++)D<128?O[D]=D<<1:O[D]=D<<1^283;for(var P=0,L=0,D=0;D<256;D++){var H=L^L<<1^L<<2^L<<3^L<<4;H=H>>>8^H&255^99,p[P]=H,E[H]=P;var M=O[P],G=O[M],N=O[G],K=O[H]*257^H*16843008;b[P]=K<<24|K>>>8,T[P]=K<<16|K>>>16,x[P]=K<<8|K>>>24,w[P]=K;var K=N*16843009^G*65537^M*257^P*16843008;F[H]=K<<24|K>>>8,R[H]=K<<16|K>>>16,v[H]=K<<8|K>>>24,d[H]=K,P?(P=M^O[O[O[N^M]]],L^=O[O[L]]):P=L=1}})();var g=[0,1,2,4,8,16,32,64,128,27,54],A=f.AES=c.extend({_doReset:function(){var O;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var D=this._keyPriorReset=this._key,P=D.words,L=D.sigBytes/4,H=this._nRounds=L+6,M=(H+1)*4,G=this._keySchedule=[],N=0;N<M;N++)N<L?G[N]=P[N]:(O=G[N-1],N%L?L>6&&N%L==4&&(O=p[O>>>24]<<24|p[O>>>16&255]<<16|p[O>>>8&255]<<8|p[O&255]):(O=O<<8|O>>>24,O=p[O>>>24]<<24|p[O>>>16&255]<<16|p[O>>>8&255]<<8|p[O&255],O^=g[N/L|0]<<24),G[N]=G[N-L]^O);for(var K=this._invKeySchedule=[],Y=0;Y<M;Y++){var N=M-Y;if(Y%4)var O=G[N];else var O=G[N-4];Y<4||N<=4?K[Y]=O:K[Y]=F[p[O>>>24]]^R[p[O>>>16&255]]^v[p[O>>>8&255]]^d[p[O&255]]}}},encryptBlock:function(O,D){this._doCryptBlock(O,D,this._keySchedule,b,T,x,w,p)},decryptBlock:function(O,D){var P=O[D+1];O[D+1]=O[D+3],O[D+3]=P,this._doCryptBlock(O,D,this._invKeySchedule,F,R,v,d,E);var P=O[D+1];O[D+1]=O[D+3],O[D+3]=P},_doCryptBlock:function(O,D,P,L,H,M,G,N){for(var K=this._nRounds,Y=O[D]^P[0],ne=O[D+1]^P[1],se=O[D+2]^P[2],re=O[D+3]^P[3],ue=4,ce=1;ce<K;ce++){var Ee=L[Y>>>24]^H[ne>>>16&255]^M[se>>>8&255]^G[re&255]^P[ue++],Te=L[ne>>>24]^H[se>>>16&255]^M[re>>>8&255]^G[Y&255]^P[ue++],_e=L[se>>>24]^H[re>>>16&255]^M[Y>>>8&255]^G[ne&255]^P[ue++],oe=L[re>>>24]^H[Y>>>16&255]^M[ne>>>8&255]^G[se&255]^P[ue++];Y=Ee,ne=Te,se=_e,re=oe}var Ee=(N[Y>>>24]<<24|N[ne>>>16&255]<<16|N[se>>>8&255]<<8|N[re&255])^P[ue++],Te=(N[ne>>>24]<<24|N[se>>>16&255]<<16|N[re>>>8&255]<<8|N[Y&255])^P[ue++],_e=(N[se>>>24]<<24|N[re>>>16&255]<<16|N[Y>>>8&255]<<8|N[ne&255])^P[ue++],oe=(N[re>>>24]<<24|N[Y>>>16&255]<<16|N[ne>>>8&255]<<8|N[se&255])^P[ue++];O[D]=Ee,O[D+1]=Te,O[D+2]=_e,O[D+3]=oe},keySize:256/32});r.AES=c._createHelper(A)}(),n.AES})}(lf)),lf.exports}var ff={exports:{}},od;function Vy(){return od||(od=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),xo(),So(),uo(),Xn())})(Tt,function(n){return function(){var r=n,a=r.lib,c=a.WordArray,f=a.BlockCipher,p=r.algo,E=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],b=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],T=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],x=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],w=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],F=p.DES=f.extend({_doReset:function(){for(var g=this._key,A=g.words,O=[],D=0;D<56;D++){var P=E[D]-1;O[D]=A[P>>>5]>>>31-P%32&1}for(var L=this._subKeys=[],H=0;H<16;H++){for(var M=L[H]=[],G=T[H],D=0;D<24;D++)M[D/6|0]|=O[(b[D]-1+G)%28]<<31-D%6,M[4+(D/6|0)]|=O[28+(b[D+24]-1+G)%28]<<31-D%6;M[0]=M[0]<<1|M[0]>>>31;for(var D=1;D<7;D++)M[D]=M[D]>>>(D-1)*4+3;M[7]=M[7]<<5|M[7]>>>27}for(var N=this._invSubKeys=[],D=0;D<16;D++)N[D]=L[15-D]},encryptBlock:function(g,A){this._doCryptBlock(g,A,this._subKeys)},decryptBlock:function(g,A){this._doCryptBlock(g,A,this._invSubKeys)},_doCryptBlock:function(g,A,O){this._lBlock=g[A],this._rBlock=g[A+1],R.call(this,4,252645135),R.call(this,16,65535),v.call(this,2,858993459),v.call(this,8,16711935),R.call(this,1,1431655765);for(var D=0;D<16;D++){for(var P=O[D],L=this._lBlock,H=this._rBlock,M=0,G=0;G<8;G++)M|=x[G][((H^P[G])&w[G])>>>0];this._lBlock=H,this._rBlock=L^M}var N=this._lBlock;this._lBlock=this._rBlock,this._rBlock=N,R.call(this,1,1431655765),v.call(this,8,16711935),v.call(this,2,858993459),R.call(this,16,65535),R.call(this,4,252645135),g[A]=this._lBlock,g[A+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function R(g,A){var O=(this._lBlock>>>g^this._rBlock)&A;this._rBlock^=O,this._lBlock^=O<<g}function v(g,A){var O=(this._rBlock>>>g^this._lBlock)&A;this._lBlock^=O,this._rBlock^=O<<g}r.DES=f._createHelper(F);var d=p.TripleDES=f.extend({_doReset:function(){var g=this._key,A=g.words;if(A.length!==2&&A.length!==4&&A.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var O=A.slice(0,2),D=A.length<4?A.slice(0,2):A.slice(2,4),P=A.length<6?A.slice(0,2):A.slice(4,6);this._des1=F.createEncryptor(c.create(O)),this._des2=F.createEncryptor(c.create(D)),this._des3=F.createEncryptor(c.create(P))},encryptBlock:function(g,A){this._des1.encryptBlock(g,A),this._des2.decryptBlock(g,A),this._des3.encryptBlock(g,A)},decryptBlock:function(g,A){this._des3.decryptBlock(g,A),this._des2.encryptBlock(g,A),this._des1.decryptBlock(g,A)},keySize:192/32,ivSize:64/32,blockSize:64/32});r.TripleDES=f._createHelper(d)}(),n.TripleDES})}(ff)),ff.exports}var hf={exports:{}},ad;function jy(){return ad||(ad=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),xo(),So(),uo(),Xn())})(Tt,function(n){return function(){var r=n,a=r.lib,c=a.StreamCipher,f=r.algo,p=f.RC4=c.extend({_doReset:function(){for(var T=this._key,x=T.words,w=T.sigBytes,F=this._S=[],R=0;R<256;R++)F[R]=R;for(var R=0,v=0;R<256;R++){var d=R%w,g=x[d>>>2]>>>24-d%4*8&255;v=(v+F[R]+g)%256;var A=F[R];F[R]=F[v],F[v]=A}this._i=this._j=0},_doProcessBlock:function(T,x){T[x]^=E.call(this)},keySize:256/32,ivSize:0});function E(){for(var T=this._S,x=this._i,w=this._j,F=0,R=0;R<4;R++){x=(x+1)%256,w=(w+T[x])%256;var v=T[x];T[x]=T[w],T[w]=v,F|=T[(T[x]+T[w])%256]<<24-R*8}return this._i=x,this._j=w,F}r.RC4=c._createHelper(p);var b=f.RC4Drop=p.extend({cfg:p.cfg.extend({drop:192}),_doReset:function(){p._doReset.call(this);for(var T=this.cfg.drop;T>0;T--)E.call(this)}});r.RC4Drop=c._createHelper(b)}(),n.RC4})}(hf)),hf.exports}var pf={exports:{}},sd;function $y(){return sd||(sd=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),xo(),So(),uo(),Xn())})(Tt,function(n){return function(){var r=n,a=r.lib,c=a.StreamCipher,f=r.algo,p=[],E=[],b=[],T=f.Rabbit=c.extend({_doReset:function(){for(var w=this._key.words,F=this.cfg.iv,R=0;R<4;R++)w[R]=(w[R]<<8|w[R]>>>24)&16711935|(w[R]<<24|w[R]>>>8)&4278255360;var v=this._X=[w[0],w[3]<<16|w[2]>>>16,w[1],w[0]<<16|w[3]>>>16,w[2],w[1]<<16|w[0]>>>16,w[3],w[2]<<16|w[1]>>>16],d=this._C=[w[2]<<16|w[2]>>>16,w[0]&4294901760|w[1]&65535,w[3]<<16|w[3]>>>16,w[1]&4294901760|w[2]&65535,w[0]<<16|w[0]>>>16,w[2]&4294901760|w[3]&65535,w[1]<<16|w[1]>>>16,w[3]&4294901760|w[0]&65535];this._b=0;for(var R=0;R<4;R++)x.call(this);for(var R=0;R<8;R++)d[R]^=v[R+4&7];if(F){var g=F.words,A=g[0],O=g[1],D=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,P=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,L=D>>>16|P&4294901760,H=P<<16|D&65535;d[0]^=D,d[1]^=L,d[2]^=P,d[3]^=H,d[4]^=D,d[5]^=L,d[6]^=P,d[7]^=H;for(var R=0;R<4;R++)x.call(this)}},_doProcessBlock:function(w,F){var R=this._X;x.call(this),p[0]=R[0]^R[5]>>>16^R[3]<<16,p[1]=R[2]^R[7]>>>16^R[5]<<16,p[2]=R[4]^R[1]>>>16^R[7]<<16,p[3]=R[6]^R[3]>>>16^R[1]<<16;for(var v=0;v<4;v++)p[v]=(p[v]<<8|p[v]>>>24)&16711935|(p[v]<<24|p[v]>>>8)&4278255360,w[F+v]^=p[v]},blockSize:128/32,ivSize:64/32});function x(){for(var w=this._X,F=this._C,R=0;R<8;R++)E[R]=F[R];F[0]=F[0]+1295307597+this._b|0,F[1]=F[1]+3545052371+(F[0]>>>0<E[0]>>>0?1:0)|0,F[2]=F[2]+886263092+(F[1]>>>0<E[1]>>>0?1:0)|0,F[3]=F[3]+1295307597+(F[2]>>>0<E[2]>>>0?1:0)|0,F[4]=F[4]+3545052371+(F[3]>>>0<E[3]>>>0?1:0)|0,F[5]=F[5]+886263092+(F[4]>>>0<E[4]>>>0?1:0)|0,F[6]=F[6]+1295307597+(F[5]>>>0<E[5]>>>0?1:0)|0,F[7]=F[7]+3545052371+(F[6]>>>0<E[6]>>>0?1:0)|0,this._b=F[7]>>>0<E[7]>>>0?1:0;for(var R=0;R<8;R++){var v=w[R]+F[R],d=v&65535,g=v>>>16,A=((d*d>>>17)+d*g>>>15)+g*g,O=((v&4294901760)*v|0)+((v&65535)*v|0);b[R]=A^O}w[0]=b[0]+(b[7]<<16|b[7]>>>16)+(b[6]<<16|b[6]>>>16)|0,w[1]=b[1]+(b[0]<<8|b[0]>>>24)+b[7]|0,w[2]=b[2]+(b[1]<<16|b[1]>>>16)+(b[0]<<16|b[0]>>>16)|0,w[3]=b[3]+(b[2]<<8|b[2]>>>24)+b[1]|0,w[4]=b[4]+(b[3]<<16|b[3]>>>16)+(b[2]<<16|b[2]>>>16)|0,w[5]=b[5]+(b[4]<<8|b[4]>>>24)+b[3]|0,w[6]=b[6]+(b[5]<<16|b[5]>>>16)+(b[4]<<16|b[4]>>>16)|0,w[7]=b[7]+(b[6]<<8|b[6]>>>24)+b[5]|0}r.Rabbit=c._createHelper(T)}(),n.Rabbit})}(pf)),pf.exports}var df={exports:{}},ud;function Hy(){return ud||(ud=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),xo(),So(),uo(),Xn())})(Tt,function(n){return function(){var r=n,a=r.lib,c=a.StreamCipher,f=r.algo,p=[],E=[],b=[],T=f.RabbitLegacy=c.extend({_doReset:function(){var w=this._key.words,F=this.cfg.iv,R=this._X=[w[0],w[3]<<16|w[2]>>>16,w[1],w[0]<<16|w[3]>>>16,w[2],w[1]<<16|w[0]>>>16,w[3],w[2]<<16|w[1]>>>16],v=this._C=[w[2]<<16|w[2]>>>16,w[0]&4294901760|w[1]&65535,w[3]<<16|w[3]>>>16,w[1]&4294901760|w[2]&65535,w[0]<<16|w[0]>>>16,w[2]&4294901760|w[3]&65535,w[1]<<16|w[1]>>>16,w[3]&4294901760|w[0]&65535];this._b=0;for(var d=0;d<4;d++)x.call(this);for(var d=0;d<8;d++)v[d]^=R[d+4&7];if(F){var g=F.words,A=g[0],O=g[1],D=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,P=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,L=D>>>16|P&4294901760,H=P<<16|D&65535;v[0]^=D,v[1]^=L,v[2]^=P,v[3]^=H,v[4]^=D,v[5]^=L,v[6]^=P,v[7]^=H;for(var d=0;d<4;d++)x.call(this)}},_doProcessBlock:function(w,F){var R=this._X;x.call(this),p[0]=R[0]^R[5]>>>16^R[3]<<16,p[1]=R[2]^R[7]>>>16^R[5]<<16,p[2]=R[4]^R[1]>>>16^R[7]<<16,p[3]=R[6]^R[3]>>>16^R[1]<<16;for(var v=0;v<4;v++)p[v]=(p[v]<<8|p[v]>>>24)&16711935|(p[v]<<24|p[v]>>>8)&4278255360,w[F+v]^=p[v]},blockSize:128/32,ivSize:64/32});function x(){for(var w=this._X,F=this._C,R=0;R<8;R++)E[R]=F[R];F[0]=F[0]+1295307597+this._b|0,F[1]=F[1]+3545052371+(F[0]>>>0<E[0]>>>0?1:0)|0,F[2]=F[2]+886263092+(F[1]>>>0<E[1]>>>0?1:0)|0,F[3]=F[3]+1295307597+(F[2]>>>0<E[2]>>>0?1:0)|0,F[4]=F[4]+3545052371+(F[3]>>>0<E[3]>>>0?1:0)|0,F[5]=F[5]+886263092+(F[4]>>>0<E[4]>>>0?1:0)|0,F[6]=F[6]+1295307597+(F[5]>>>0<E[5]>>>0?1:0)|0,F[7]=F[7]+3545052371+(F[6]>>>0<E[6]>>>0?1:0)|0,this._b=F[7]>>>0<E[7]>>>0?1:0;for(var R=0;R<8;R++){var v=w[R]+F[R],d=v&65535,g=v>>>16,A=((d*d>>>17)+d*g>>>15)+g*g,O=((v&4294901760)*v|0)+((v&65535)*v|0);b[R]=A^O}w[0]=b[0]+(b[7]<<16|b[7]>>>16)+(b[6]<<16|b[6]>>>16)|0,w[1]=b[1]+(b[0]<<8|b[0]>>>24)+b[7]|0,w[2]=b[2]+(b[1]<<16|b[1]>>>16)+(b[0]<<16|b[0]>>>16)|0,w[3]=b[3]+(b[2]<<8|b[2]>>>24)+b[1]|0,w[4]=b[4]+(b[3]<<16|b[3]>>>16)+(b[2]<<16|b[2]>>>16)|0,w[5]=b[5]+(b[4]<<8|b[4]>>>24)+b[3]|0,w[6]=b[6]+(b[5]<<16|b[5]>>>16)+(b[4]<<16|b[4]>>>16)|0,w[7]=b[7]+(b[6]<<8|b[6]>>>24)+b[5]|0}r.RabbitLegacy=c._createHelper(T)}(),n.RabbitLegacy})}(df)),df.exports}var _f={exports:{}},cd;function Gy(){return cd||(cd=1,function(t,e){(function(n,r,a){t.exports=r(Lt(),xo(),So(),uo(),Xn())})(Tt,function(n){return function(){var r=n,a=r.lib,c=a.BlockCipher,f=r.algo;const p=16,E=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],b=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var T={pbox:[],sbox:[]};function x(d,g){let A=g>>24&255,O=g>>16&255,D=g>>8&255,P=g&255,L=d.sbox[0][A]+d.sbox[1][O];return L=L^d.sbox[2][D],L=L+d.sbox[3][P],L}function w(d,g,A){let O=g,D=A,P;for(let L=0;L<p;++L)O=O^d.pbox[L],D=x(d,O)^D,P=O,O=D,D=P;return P=O,O=D,D=P,D=D^d.pbox[p],O=O^d.pbox[p+1],{left:O,right:D}}function F(d,g,A){let O=g,D=A,P;for(let L=p+1;L>1;--L)O=O^d.pbox[L],D=x(d,O)^D,P=O,O=D,D=P;return P=O,O=D,D=P,D=D^d.pbox[1],O=O^d.pbox[0],{left:O,right:D}}function R(d,g,A){for(let H=0;H<4;H++){d.sbox[H]=[];for(let M=0;M<256;M++)d.sbox[H][M]=b[H][M]}let O=0;for(let H=0;H<p+2;H++)d.pbox[H]=E[H]^g[O],O++,O>=A&&(O=0);let D=0,P=0,L=0;for(let H=0;H<p+2;H+=2)L=w(d,D,P),D=L.left,P=L.right,d.pbox[H]=D,d.pbox[H+1]=P;for(let H=0;H<4;H++)for(let M=0;M<256;M+=2)L=w(d,D,P),D=L.left,P=L.right,d.sbox[H][M]=D,d.sbox[H][M+1]=P;return!0}var v=f.Blowfish=c.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var d=this._keyPriorReset=this._key,g=d.words,A=d.sigBytes/4;R(T,g,A)}},encryptBlock:function(d,g){var A=w(T,d[g],d[g+1]);d[g]=A.left,d[g+1]=A.right},decryptBlock:function(d,g){var A=F(T,d[g],d[g+1]);d[g]=A.left,d[g+1]=A.right},blockSize:64/32,keySize:128/32,ivSize:64/32});r.Blowfish=c._createHelper(v)}(),n.Blowfish})}(_f)),_f.exports}(function(t,e){(function(n,r,a){t.exports=r(Lt(),yu(),by(),Ey(),xo(),xy(),So(),Pp(),jl(),Sy(),Up(),Ty(),Ay(),Cy(),ql(),Dy(),uo(),Xn(),ky(),Oy(),wy(),Ry(),Fy(),Ny(),Iy(),Py(),By(),Ly(),My(),Uy(),Vy(),jy(),$y(),Hy(),Gy())})(Tt,function(n){return n})})(Cp);var ld=Cp.exports;class Ky{constructor(e){I(this,"_nameMap");I(this,"_prefixNameVar");I(this,"_prefixNameFunc");I(this,"_prefixNameConst");I(this,"_userTypes");I(this,"_isInFunc");I(this,"_currentFuncName");I(this,"_varlist");I(this,"_memberIndexList");I(this,"_blockCount");I(this,"_inputCount");I(this,"_count");I(this,"_isSwitch",!1);I(this,"_isInLoop",!1);I(this,"_codesCol");I(this,"_dependsObj");I(this,"_enums");I(this,"_preRunMembers");I(this,"_isInConditionalStmt",!1);I(this,"_preRunMembersFuncs");I(this,"_preRunMemberFuncsCount",0);this._nameMap=new Map,this._prefixNameVar=`${e}_var`,this._prefixNameFunc=`${e}_func`,this._prefixNameConst=`${e}_const`,this._userTypes=[],this._isInFunc=!1,this._varlist=[{}],this._memberIndexList=[{}],this._blockCount=0,this._inputCount=0,this._count=0,this._codesCol=[[]],this._dependsObj={},this._enums=new Map,this._preRunMembers=[],this._preRunMembersFuncs=[]}preParser(e){var r,a;const n=[];for(const c of e){if(!c)return;if(Array.isArray(c)){for(const f of c)if(n.push(this._parserStmt(f)),Ol.includes((a=(r=f.exprs)==null?void 0:r[0])==null?void 0:a.name))return n.join(`;
27
27
  `).replace(/;+/g,";")}else n.push(this._parserStmt(c))}return""}parser(e){const n=[];for(const a of e){if(!a)return;if(Array.isArray(a))for(const c of a)n.push(this._parserStmt(c));else n.push(this._parserStmt(a))}const r=this._memberIndexList[this._blockCount]||{};return n.push(...Object.values(r)),n.join(`;
28
- `).replace(/;+/g,";")}_parserStmt(e,n=!1,r=!1){let a="";switch(e==null?void 0:e.ruleType){case ye.DeclareAssign:a=this._parserDeclareAssign(e);break;case ye.MethodExpression:a=`${this._parserMethodExpression(e)}`;break;case ye.ArrowFunction:a=this._parserArrowFunction(e);break;case ye.ArrowMethod:a=this._parserArrowMethod(e);break;case ye.IfStatement:a=this._parserIfStatement(e,n);break;case ye.WhileStatement:a=this._parserWhileStatement(e,n);break;case ye.SwitchStatement:a=this._parserSwitchStatement(e,n);break;case ye.ForInStatement:a=this._parserForInStatement(e,n);break;case ye.ForToStatement:a=this._parserForToStatement(e,n);break;case ye.AgainAssign:a=this._parserAgainAssign(e);break;case ye.ImportElement:a=e.code||"";break;case ye.TypeStatement:a=this._parserTypeStatement(e);break;case ye.VarBlockStmt:a=this._parserVarBlockStmt(e);break;case ye.FlowStmt:if(this._isSwitch&&e.value==="break"){if(this._isInLoop){a="$$isBreak = true;";break}a="";break}a=`${e.value};`;break;case ye.Brackethesized:a=this._parserBrackethesized(e);break;case ye.EnumStatement:a=this._parserEnumStatement(e);break;default:a=this._parserSingleExpression(e);break}let c="";const f=this._preRunMembersFuncs[this._blockCount];f!=null&&f.length&&(c=f.join(`;
29
- `),this._preRunMembersFuncs[this._blockCount]=[]);const p=this._preRunMembers[this._blockCount];return p!=null&&p.length&&(c=`${c}
30
- ${p.join(`;
31
- `)}`,this._preRunMembers[this._blockCount]=[]),c&&(a=`${c}${n&&r?`
28
+ `).replace(/;+/g,";")}_parserStmt(e,n=!1){let r="";switch(e==null?void 0:e.ruleType){case ye.DeclareAssign:r=this._parserDeclareAssign(e);break;case ye.MethodExpression:r=`${this._parserMethodExpression(e)}`;break;case ye.ArrowFunction:r=this._parserArrowFunction(e);break;case ye.ArrowMethod:r=this._parserArrowMethod(e);break;case ye.IfStatement:r=this._parserIfStatement(e,n);break;case ye.WhileStatement:r=this._parserWhileStatement(e,n);break;case ye.SwitchStatement:r=this._parserSwitchStatement(e,n);break;case ye.ForInStatement:r=this._parserForInStatement(e,n);break;case ye.ForToStatement:r=this._parserForToStatement(e,n);break;case ye.AgainAssign:r=this._parserAgainAssign(e);break;case ye.ImportElement:r=e.code||"";break;case ye.TypeStatement:r=this._parserTypeStatement(e);break;case ye.VarBlockStmt:r=this._parserVarBlockStmt(e);break;case ye.FlowStmt:if(this._isSwitch&&e.value==="break"){if(this._isInLoop){r="$$isBreak = true;";break}r="";break}r=`${e.value};`;break;case ye.Brackethesized:r=this._parserBrackethesized(e);break;case ye.EnumStatement:r=this._parserEnumStatement(e);break;default:r=this._parserSingleExpression(e);break}let a="";const c=this._preRunMembersFuncs[this._blockCount];c!=null&&c.length&&(a=c.join(`;
29
+ `),this._preRunMembersFuncs[this._blockCount]=[]);const f=this._preRunMembers[this._blockCount];return f!=null&&f.length&&(a=`${a}
30
+ ${f.join(`;
31
+ `)}`,this._preRunMembers[this._blockCount]=[]),a&&(r=`${a}${n?`
32
32
  /****/
33
33
  `:`;
34
- `}${a}`),a}_parserEnumStatement(e){let{name:n,fields:r}=e;const a=[],c=[];for(const p of r){const{name:E,value:b}=p,T=b===void 0?`"${E}"`:b;c.push(T),a.push(`${E}: ${T}`)}Nn.includes(n)&&(n=`$${n}`),this._enums.set(n,c);const f=`const ${n} = {${a.join(", ")}}`;return this._codesCol[this._blockCount].push({code:f,varNames:[n],depends:[]}),f}_parserTypeStatement(e){const n=[],r=[];for(const f of e.fields){const{name:p,value:E}=f;f.isVarip&&r.push(`"${p}"`),n.push(`${p}: ${E?this._parserSingleExpression(E):"undefined"}`)}this._userTypes.push(e.name);let a=e.name;Nn.includes(a)&&(a=`$${a}`);const c=`const ${a} = ${this._prefixNameVar}.getTypeInstance({${n.join(", ")}}, [${r.join()}])`;return this._codesCol[this._blockCount].push({code:c,varNames:[a],depends:[]}),c}_parserVarBlockStmt(e){const{nameList:n,value:r}=e;this._addVarList(n);const a=this._parserDeclareAssignNames(n);this._dependsObj[a]=new Map;const c=this._parserStmt(r,!0,!0),f=c.split(`
34
+ `}${r}`),r}_parserEnumStatement(e){let{name:n,fields:r}=e;const a=[],c=[];for(const p of r){const{name:E,value:b}=p,T=b===void 0?`"${E}"`:b;c.push(T),a.push(`${E}: ${T}`)}Nn.includes(n)&&(n=`$${n}`),this._enums.set(n,c);const f=`const ${n} = {${a.join(", ")}}`;return this._codesCol[this._blockCount].push({code:f,varNames:[n],depends:[]}),f}_parserTypeStatement(e){const n=[],r=[];for(const f of e.fields){const{name:p,value:E}=f;f.isVarip&&r.push(`"${p}"`),n.push(`${p}: ${E?this._parserSingleExpression(E):"undefined"}`)}this._userTypes.push(e.name);let a=e.name;Nn.includes(a)&&(a=`$${a}`);const c=`const ${a} = ${this._prefixNameVar}.getTypeInstance({${n.join(", ")}}, [${r.join()}])`;return this._codesCol[this._blockCount].push({code:c,varNames:[a],depends:[]}),c}_parserVarBlockStmt(e){const{nameList:n,value:r}=e;this._addVarList(n);const a=this._parserDeclareAssignNames(n);this._dependsObj[a]=new Map;const c=this._parserStmt(r,!0),f=c.split(`
35
35
  /****/
36
36
  `);let p="";f.length>1?p=`${f[0]}
37
37
  let ${a} = ${f[1]}
@@ -67,7 +67,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
67
67
  ${b}
68
68
  }`),this._isInLoop=f,T=`${F};
69
69
  let ${E} = 0;
70
- ${T}`,n?this._functionalProcess(T):T}_parserAgainAssign(e){const{operator:n,name:r,value:a}=e,{varPos:c,declare:f}=r,p=`$againAssign${this._blockCount}`;this._dependsObj[p]=new Map;const E=this._parserName(r,!0);let b="",T=this._parserStmt(a,!0,!0);const x=T.split(`
70
+ ${T}`,n?this._functionalProcess(T):T}_parserAgainAssign(e){const{operator:n,name:r,value:a}=e,{varPos:c,declare:f}=r,p=`$againAssign${this._blockCount}`;this._dependsObj[p]=new Map;const E=this._parserName(r,!0);let b="",T=this._parserStmt(a,!0);const x=T.split(`
71
71
  /****/
72
72
  `);let w="";x.length>1&&(w=x[0],T=x[1]);const F=`$_tmp_${E.split(".").pop()}`;n===":="&&(w=`${w}
73
73
  var ${F} = ${T}`);let R=`${E} ${n===":="?`= ${F}`:`${n} ${T}`}`;const v=`${c==null?void 0:c.column}_${c==null?void 0:c.lineNumber}`;if(f){const g=this._isInFunc?`$posStr + "_${v}"`:`"${v}"`;b=`;
@@ -114,12 +114,11 @@ ${this._prefixNameVar}.againAssignParse(${E}, ${F});
114
114
  ${a}
115
115
  $$_result = ${this._parserName(e.name,!0)}`;case ye.DeclareAssign:c=this._parserStmt(e),a=`${c}
116
116
  ${this._getMembersCode()}`,r=this._parserDeclareAssignNames(e.nameList);break;case ye.FlowStmt:return this._getMembersCode();case ye.VarBlockStmt:c=this._parserStmt(e),a=`${c}
117
- ${this._getMembersCode()}`,r=this._parserDeclareAssignNames(e.nameList);break;default:r=this._parserStmt(e,!0,n),a=this._getMembersCode()}if(n){const f=r.split(`
117
+ ${this._getMembersCode()}`,r=this._parserDeclareAssignNames(e.nameList);break;default:r=this._parserStmt(e,!0),a=this._getMembersCode();const f=r.split(`
118
118
  /****/
119
- `);return f.length>1?`${a}
120
- ${f[0]}
121
- return ${f[1]}`:`${a}
122
- return ${r}`}return`${a}
119
+ `);f.length>1&&(a=`${a}
120
+ ${f[0]}`,r=f[1]);break}return n?`${a}
121
+ return ${r}`:`${a}
123
122
  $$_result = ${r}`}_getMembersCode(){const e=this._memberIndexList[this._blockCount]||{};return Object.values(e).join(`;
124
123
  `)}_parserArrowMethod(e){let n=`$_${e.name}`;this._nameMap.set(e.name,n);const r=[...e.params],a=e.index?`$${e.index}`:"";e.hasMemberIndex&&r.push({name:`${this._prefixNameVar}_position`}),n=`${n}${a}`,this._currentFuncName=n,this._dependsObj[n]=new Map;const c=this._parserBlock(e.block,!0,!0),f=e.hasRequest?", $paramsExpr":"";let p=`const ${n} = (${this._parserParameters(r)}$posStr${f}) => {
125
124
  ${c}
@@ -130,7 +129,8 @@ ${this._prefixNameVar}.againAssignParse(${E}, ${F});
130
129
  })
131
130
  `}return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:p}),p}_parserArrowFunction(e){let n=`$_${e.name}`;this._nameMap.set(e.name,n);const r=[...e.params];e.hasMemberIndex&&r.push({name:`${this._prefixNameVar}_position`}),n=`${n}${e.index?`$${e.index}`:""}`,this._currentFuncName=n,this._dependsObj[n]=new Map;const a=e.hasRequest?", $paramsExpr":"",c=`const ${n} = (${this._parserParameters(r)}$posStr${a}) => {
132
131
  ${this._parserBlock(e.block,!0,!0)}
133
- }`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:c}),c}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:a}=n;let c=r;if(a){const f=this._parserSingleExpression(a);c=`${c} = ${f}`}return c}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){const n=this._varlist[this._blockCount]||{};if(e.names)for(const[r,a]of e.names.entries())n[a]=e.posList[r];else n[e.name]=e.pos;this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var E;const{nameList:n,value:r}=e;if(n.name==="_")return"";const a=this._parserDeclareAssignNames(n);this._addVarList(n);const c={code:"",varNames:a.replace(/[\[\]]/g,"").split(", "),depends:[]};this._dependsObj[a]=new Map;const f=this._parserSingleExpression(r);let p=`let ${a} = ${f}`;if(n.declare){const b=`${n.pos.column}_${n.pos.lineNumber}`,T=this._isInFunc?`$posStr + "_${b}"`:`"${b}"`;p=`let ${a} = ${this._prefixNameVar}.getVarValue("${a}", ${T}, "${n.declare}") || ${this._prefixNameVar}.setVarValue("${a}", ${T}, ${f}, "${n.declare}")`}return c.code=p,c.depends=this._getDepends(a),(E=this._codesCol[this._blockCount])==null||E.push(c),p}_parserDeclareAssignNames(e){switch(e==null?void 0:e.ruleType){case"VarMultiple":return`[${e.names.map(n=>Nn.includes(n)?`$${n}`:n).join(", ")}]`;case"VarSingle":return Nn.includes(e.name)?`$${e.name}`:e.name}return""}_parserSingleExpression(e){if(!e)return"";const{exprs:n,operator:r}=e;let a="",c=this._isInConditionalStmt;switch(e.ruleType){case ye.MemberIndexExpression:return this._parserMemberIndexExpression(e);case ye.MethodExpression:return this._parserMethodExpression(e);case ye.UnaryExpression:return`${r}${this._parserSingleExpression(n[0])}`;case ye.NotExpression:return`!${this._parserSingleExpression(n[0])}`;case ye.AdditiveExpression:return this._parserAdditiveExpression(e);case ye.MultiplicativeExpression:case ye.RelationalExpression:case ye.EqualityExpression:return`${this._parserSingleExpression(n[0])} ${r} ${this._parserSingleExpression(n[1])}`;case ye.LogicalAndExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} && ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.LogicalOrExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} || ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.TernaryExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} ? ${this._parserSingleExpression(n[1])} : ${this._parserSingleExpression(n[2])}`,this._isInConditionalStmt=c,a;case ye.Name:return this._parserName(e);case ye.Literal:return this._parseLiteral(e);case ye.ParenthesizedExpression:return`(${this._parserSingleExpression(e.exprs)})`;default:return e.name||""}}_parserAdditiveExpression(e){const{exprs:n,operator:r}=e,a=this._parserSingleExpression(n[0]),c=this._parserSingleExpression(n[1]);return r==="-"?`${this._prefixNameVar}.sub(${a}, ${c})`:`${this._prefixNameVar}.add(${a}, ${c})`}_parserMemberIndexExpression(e){const{exprs:n,isInFunc:r,ctx:a}=e,c=n[0],f=this._parserSingleExpression(n[1]),p=this._parserSingleExpression(c),E=a.start.tokenIndex,b=r?`${this._prefixNameVar}_position`:E;if(c.ruleType===ye.Name&&!c.hasMethod){let T=this._blockCount;const x=c.name;for(c.isBuiltIn||this._setDepend({name:x,scope:c.varScope});T>=0;){const w=this._varlist[T]||{},F=w[x];if(F)return this._getUserVarMemberIndexs(F,x,T,f,r);if(c.isBuiltIn){const R=this._memberIndexList[0]||{};return R[x]=`${this._prefixNameVar}.setCacheData("${x}", ${p})`,`${this._prefixNameVar}.getCacheData("${x}", ${f}, ${p})`}if(x.includes(".")){const R=x.split(".")[0],v=w[R];if(v)return this._getUserVarMemberIndexs(v,x,T,f,r)}T--}return this._getOtherVarMemberIndexs(`${x}_${c.varScope||c.scope}`,x,c.varScope||c.scope,f,r)}else{const T=this._preRunMembers[this._blockCount]||[];T.push(`${this._prefixNameVar}.setCacheData("m${E}_" + ${b}, ${p})`),this._preRunMembers[this._blockCount]=T}return`${this._prefixNameVar}.getCacheData("m${E}_" + ${b}, ${f}, ${p})`}_getOtherVarMemberIndexs(e,n,r,a,c){const f=this._memberIndexList[r]||{};return e=c&&r!==0?`"${e}_" + $posStr`:`"${e}"`,f[e]=`${this._prefixNameVar}.setCacheData(${e}, ${n})`,this._memberIndexList[r]=f,`${this._prefixNameVar}.getCacheData(${e}, ${a}, ${n})`}_getUserVarMemberIndexs(e,n,r,a,c){return this._getOtherVarMemberIndexs(`${n}_${e.lineNumber}_${e.column}`,n,r,a,c)}_parseLiteral(e){return e.type.endsWith(z.COLOR)?`"${this._colorToRgba(e.value)}"`:e.value}_colorToRgba(e){if(e.startsWith("#")){let n;const r=parseInt(e.substring(1,3),16),a=parseInt(e.substring(3,5),16),c=parseInt(e.substring(5,7),16),f=e.substring(7);return f?n=(255-parseInt(f,16))/255:n=1,`rgba(${Math.round(r)}, ${Math.round(a)}, ${Math.round(c)}, ${n.toFixed(2)})`}return e}_parserName(e,n=!1){const{exprs:r,varScope:a,hasMethod:c,arg:f}=e,p=r.map(E=>{var w;if(typeof E=="string")return E;const{column:b,line:T}=((w=E==null?void 0:E.ctx)==null?void 0:w.start)||{},x=`${T}_${b}`;return this._parserMethodElement(E,x)});if(e.expr&&p.unshift(`(${this._parserSingleExpression(e.expr)})`),e.isBuiltIn)p.join(".")==="strategy.opentrades"&&p.push("opentrades"),p.unshift(e.isConst?this._prefixNameConst:this._prefixNameVar);else if(Nn.includes(p[0])&&(p[0]=`$${p[0]}`),!c){const E={name:p[0],scope:a||(f==null?void 0:f.varScope)||0,isAgainAssign:n,isArg:f==null?void 0:f.isArg,functionName:this._currentFuncName};this._setDepend(E)}return p.join(".")}_setDepend(e){const n=e.name;for(const r of Object.values(this._dependsObj)){const a=r.get(n),c={...e};a&&a.isAgainAssign&&(c.isAgainAssign=!0),r.set(n,c)}}_parserMethodExpression(e){const{exprs:n,ctx:r}=e,{column:a,line:c}=r.start,f=`${c}_${a}`;let p=this._isInFunc?`$posStr + "__${f}"`:`"${f}"`;p=this._isInLoop?`$$count${this._count} + ${p}`:p;let E=!1;const T=n.map(x=>(x.hasMemberIndex&&(E=!0),this._parserMethodElement(x,p))).join(".");if(this._isInConditionalStmt&&E){const x=`$$result_${this._preRunMemberFuncsCount}`;this._preRunMemberFuncsCount++;const w=this._preRunMembersFuncs[this._blockCount]||[];return w.push(`const ${x} = ${T}`),this._preRunMembersFuncs[this._blockCount]=w,x}return T}_parserMethodElement(e,n){let r="",a="";const c={...e.args};e.hasMemberIndex&&(a=`${this._prefixNameVar}_position: ${e.position}`),e.expr&&(r=`(${this._parserSingleExpression(e.expr)})`),r=r?`${r}.${e.name}`:this._nameMap.get(e.name)||e.name;let f=!1;if(e.isBuiltIn){if(Sp.includes(r))r=`${r}.${r}`;else if(r==="max_bars_back"){const{name:E,varPos:b}=c.var||c.params[0];a=`var_name: "${b?`${E}_${b.lineNumber}_${b.column}`:E}"`}r.startsWith(z.INPUT)?(a=`index: ${this._inputCount}`,this._inputCount++):r.startsWith("request.")&&(f=!0),r=`${this._prefixNameFunc}.${r}`}else{const E=r.split(".");let b=E[0];Nn.includes(b)&&(b=`$${b}`,r=E.join("."))}if(e.selfArg){const E=r.split("."),b=E.length;Object.assign(c,{[e.selfArg.name]:{name:E.slice(0,b-1).join(".")}}),r=E[b-1],r=this._nameMap.get(r)||r,this._setDepend({name:E[0],scope:e.varScope||0})}r=`${r}${e.index?`$${e.index}`:""}`;const p=this._parserArguments(c,a,n,f,e.hasRequest,r);if(!e.isBuiltIn){const E=r.split(".");if(E.length>1?this._setDepend({name:E[0],scope:e.varScope||0}):this._setDepend({name:r,scope:0,hasRequest:e.hasRequest,isFunc:!0}),e.funcName){const b=this._nameMap.get(e.funcName)||e.funcName;this._setDepend({name:b,originName:r,scope:0,hasRequest:e.hasRequest,isFunc:!0})}}return r+p}_parserArguments(e,n,r,a=!1,c=!1,f){const p=e.params||[];delete e.params;const E=[],b=[];let T=[],x;const w=(R,v)=>{c&&(this._dependsObj[r]=new Map),a&&v==="expression"&&(this._dependsObj[`$arg_${v}${r}`]=new Map);let d=R.ruleType===ye.Brackethesized?this._parserBrackethesized(R):this._parserSingleExpression(R);if(v&&!["arg0, arg1, ...","number0, number1, ..."].includes(v)){R.isSourceType?E.push(`sourceTypeName: "${R.name}"`):v==="defval"&&f===`${this._prefixNameFunc}.input.enum`&&(x=this._enums.get(R.enumName));const g=this._requestParamsHandle(a,v,r,c,d,f);d=(g==null?void 0:g.code)||d,g!=null&&g.paramsExpr&&T.push(g==null?void 0:g.paramsExpr),E.push(`${v}: ${d}`)}else b.push(d)};for(const R of p)w(R,R.originName);for(const R of Object.keys(e))w(e[R],R);a&&this._isInFunc&&E.push("paramsExpr: $paramsExpr"),n&&E.push(n),x&&E.unshift(`options: [${x.join(", ")}]`);const F=T.length?`, [${this._isInFunc?"...$paramsExpr, ":""}${T.join(", ")}]`:"";return b.length?`({${E.join(", ")}}, [${b.join(", ")}], ${r}${F})`:E.length?`({${E.join(", ")}}, ${r}${F})`:`(${r}${F})`}_requestParamsHandle(e,n,r,a,c,f){if(e&&n==="expression"){const p=this._getDepends(`$arg_${n}${r}`),E=this._getExpressionContext(p);return E.push({scope:1,depends:p.map(b=>(b.isArg&&(b.functionName=this._currentFuncName),b)),code:c}),{code:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}else if(a){const p=this._getDepends(r),E=this._getExpressionContext(p);return E.push({scope:2,varNames:n,methodName:f,depends:p,dependSelf:p.some(b=>b.name===n),code:`${n} = ${c}`}),{paramsExpr:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}}_getExpressionContext(e){const n=[],r=[];return this._getDependsCode(e,n,r),n}_getDependsCode(e,n,r){var a,c;for(const f of e)if(!f.isArg){const p=this._codesCol[f.scope||0],E=p.find(T=>{var x;return((x=T.varNames)==null?void 0:x.includes(f.name))||T.funcName===f.name});E&&(r.includes(E)||(r.push(E),E.depends.length&&this._getDependsCode(E.depends,n,r),n.push({scope:f.scope||0,code:E.code,depends:E.depends,funcName:E.funcName,varNames:(a=E.varNames)==null?void 0:a.join(", ")})));const b=p.filter(T=>T.depends.some(x=>x.name===f.name&&x.scope===f.scope&&x.isAgainAssign));for(const T of b)r.includes(T)||(r.push(T),T.depends.length&&this._getDependsCode(T.depends,n,r),n.push({scope:f.scope||0,code:T.code,depends:T.depends,funcName:T.funcName,varNames:(c=T.varNames)==null?void 0:c.join(", ")}))}}_parserBrackethesized(e){return`[${e.exprs.map(r=>this._parserSingleExpression(r)).join(", ")}]`}_functionalProcess(e){return`(function () {
132
+ }`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:c}),c}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:a}=n;let c=r;if(a){const f=this._parserSingleExpression(a);c=`${c} = ${f}`}return c}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){const n=this._varlist[this._blockCount]||{};if(e.names)for(const[r,a]of e.names.entries())n[a]=e.posList[r];else n[e.name]=e.pos;this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var E;const{nameList:n,value:r}=e;if(n.name==="_")return"";const a=this._parserDeclareAssignNames(n);this._addVarList(n);const c={code:"",varNames:a.replace(/[\[\]]/g,"").split(", "),depends:[]};this._dependsObj[a]=new Map;const f=this._parserSingleExpression(r);let p=`let ${a} = ${f}`;if(n.declare){const b=`${n.pos.column}_${n.pos.lineNumber}`,T=this._isInFunc?`$posStr + "_${b}"`:`"${b}"`;p=`let ${a} = ${this._prefixNameVar}.getVarValue("${a}", ${T}, "${n.declare}") || ${this._prefixNameVar}.setVarValue("${a}", ${T}, ${f}, "${n.declare}")`}return c.code=p,c.depends=this._getDepends(a),(E=this._codesCol[this._blockCount])==null||E.push(c),p}_parserDeclareAssignNames(e){switch(e==null?void 0:e.ruleType){case"VarMultiple":return`[${e.names.map(n=>Nn.includes(n)?`$${n}`:n).join(", ")}]`;case"VarSingle":return Nn.includes(e.name)?`$${e.name}`:e.name}return""}_parserSingleExpression(e){if(!e)return"";const{exprs:n,operator:r}=e;let a="",c=this._isInConditionalStmt;switch(e.ruleType){case ye.MemberIndexExpression:return this._parserMemberIndexExpression(e);case ye.MethodExpression:return this._parserMethodExpression(e);case ye.UnaryExpression:return`${r}${this._parserSingleExpression(n[0])}`;case ye.NotExpression:return`!${this._parserSingleExpression(n[0])}`;case ye.AdditiveExpression:return this._parserAdditiveExpression(e);case ye.MultiplicativeExpression:case ye.RelationalExpression:case ye.EqualityExpression:return`${this._parserSingleExpression(n[0])} ${r} ${this._parserSingleExpression(n[1])}`;case ye.LogicalAndExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} && ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.LogicalOrExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} || ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.TernaryExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} ? ${this._parserSingleExpression(n[1])} : ${this._parserSingleExpression(n[2])}`,this._isInConditionalStmt=c,a;case ye.Name:return this._parserName(e);case ye.Literal:return this._parseLiteral(e);case ye.ParenthesizedExpression:return`(${this._parserSingleExpression(e.exprs)})`;default:return e.name||""}}_parserAdditiveExpression(e){const{exprs:n,operator:r}=e,a=this._parserSingleExpression(n[0]),c=this._parserSingleExpression(n[1]);return r==="-"?`${this._prefixNameVar}.sub(${a}, ${c})`:`${this._prefixNameVar}.add(${a}, ${c})`}_parserMemberIndexExpression(e){const{exprs:n,isInFunc:r,ctx:a}=e,c=n[0],f=this._parserSingleExpression(n[1]);let p=this._parserSingleExpression(c);const E=a.start.tokenIndex,b=r?`${this._prefixNameVar}_position`:E;if(c.ruleType===ye.Name&&!c.hasMethod){let T=this._blockCount;const x=c.name;for(c.isBuiltIn||this._setDepend({name:x,scope:c.varScope});T>=0;){const w=this._varlist[T]||{},F=w[x];if(F)return this._getUserVarMemberIndexs(F,x,T,f,r);if(c.isBuiltIn){const R=this._memberIndexList[0]||{};return R[x]=`${this._prefixNameVar}.setCacheData("${x}", ${p})`,`${this._prefixNameVar}.getCacheData("${x}", ${f}, ${p})`}if(x.includes(".")){const R=x.split(".")[0],v=w[R];if(v)return this._getUserVarMemberIndexs(v,x,T,f,r)}T--}return this._getOtherVarMemberIndexs(`${x}_${c.varScope||c.scope}`,x,c.varScope||c.scope,f,r)}else{const T=this._preRunMembers[this._blockCount]||[],x=`m${E}_${b}`;T.push(`const m${E}_${b} = ${p};
133
+ ${this._prefixNameVar}.setCacheData("m${E}_" + ${b}, ${x})`),p=x,this._preRunMembers[this._blockCount]=T}return`${this._prefixNameVar}.getCacheData("m${E}_" + ${b}, ${f}, ${p})`}_getOtherVarMemberIndexs(e,n,r,a,c){const f=this._memberIndexList[r]||{};return e=c&&r!==0?`"${e}_" + $posStr`:`"${e}"`,f[e]=`${this._prefixNameVar}.setCacheData(${e}, ${n})`,this._memberIndexList[r]=f,`${this._prefixNameVar}.getCacheData(${e}, ${a}, ${n})`}_getUserVarMemberIndexs(e,n,r,a,c){return this._getOtherVarMemberIndexs(`${n}_${e.lineNumber}_${e.column}`,n,r,a,c)}_parseLiteral(e){return e.type.endsWith(z.COLOR)?`"${this._colorToRgba(e.value)}"`:e.value}_colorToRgba(e){if(e.startsWith("#")){let n;const r=parseInt(e.substring(1,3),16),a=parseInt(e.substring(3,5),16),c=parseInt(e.substring(5,7),16),f=e.substring(7);return f?n=(255-parseInt(f,16))/255:n=1,`rgba(${Math.round(r)}, ${Math.round(a)}, ${Math.round(c)}, ${n.toFixed(2)})`}return e}_parserName(e,n=!1){const{exprs:r,varScope:a,hasMethod:c,arg:f}=e,p=r.map(E=>{var w;if(typeof E=="string")return E;const{column:b,line:T}=((w=E==null?void 0:E.ctx)==null?void 0:w.start)||{},x=`${T}_${b}`;return this._parserMethodElement(E,x)});if(e.expr&&p.unshift(`(${this._parserSingleExpression(e.expr)})`),e.isBuiltIn)p.join(".")==="strategy.opentrades"&&p.push("opentrades"),p.unshift(e.isConst?this._prefixNameConst:this._prefixNameVar);else if(Nn.includes(p[0])&&(p[0]=`$${p[0]}`),!c){const E={name:p[0],scope:a||(f==null?void 0:f.varScope)||0,isAgainAssign:n,isArg:f==null?void 0:f.isArg,functionName:this._currentFuncName};this._setDepend(E)}return p.join(".")}_setDepend(e){const n=e.name;for(const r of Object.values(this._dependsObj)){const a=r.get(n),c={...e};a&&a.isAgainAssign&&(c.isAgainAssign=!0),r.set(n,c)}}_parserMethodExpression(e){const{exprs:n,ctx:r}=e,{column:a,line:c}=r.start,f=`${c}_${a}`;let p=this._isInFunc?`$posStr + "__${f}"`:`"${f}"`;p=this._isInLoop?`$$count${this._count} + ${p}`:p;let E=!1;const T=n.map(x=>(x.hasMemberIndex&&(E=!0),this._parserMethodElement(x,p))).join(".");if(this._isInConditionalStmt&&E){const x=`$$result_${this._preRunMemberFuncsCount}`;this._preRunMemberFuncsCount++;const w=this._preRunMembersFuncs[this._blockCount]||[];return w.push(`const ${x} = ${T}`),this._preRunMembersFuncs[this._blockCount]=w,x}return T}_parserMethodElement(e,n){let r="",a="";const c={...e.args};e.hasMemberIndex&&(a=`${this._prefixNameVar}_position: ${e.position}`),e.expr&&(r=`(${this._parserSingleExpression(e.expr)})`),r=r?`${r}.${e.name}`:this._nameMap.get(e.name)||e.name;let f=!1;if(e.isBuiltIn){if(Sp.includes(r))r=`${r}.${r}`;else if(r==="max_bars_back"){const{name:E,varPos:b}=c.var||c.params[0];a=`var_name: "${b?`${E}_${b.lineNumber}_${b.column}`:E}"`}r.startsWith(z.INPUT)?(a=`index: ${this._inputCount}`,this._inputCount++):r.startsWith("request.")&&(f=!0),r=`${this._prefixNameFunc}.${r}`}else{const E=r.split(".");let b=E[0];Nn.includes(b)&&(b=`$${b}`,r=E.join("."))}if(e.selfArg){const E=r.split("."),b=E.length;Object.assign(c,{[e.selfArg.name]:{name:E.slice(0,b-1).join(".")}}),r=E[b-1],r=this._nameMap.get(r)||r,this._setDepend({name:E[0],scope:e.varScope||0})}r=`${r}${e.index?`$${e.index}`:""}`;const p=this._parserArguments(c,a,n,f,e.hasRequest,r);if(!e.isBuiltIn){const E=r.split(".");if(E.length>1?this._setDepend({name:E[0],scope:e.varScope||0}):this._setDepend({name:r,scope:0,hasRequest:e.hasRequest,isFunc:!0}),e.funcName){const b=this._nameMap.get(e.funcName)||e.funcName;this._setDepend({name:b,originName:r,scope:0,hasRequest:e.hasRequest,isFunc:!0})}}return r+p}_parserArguments(e,n,r,a=!1,c=!1,f){const p=e.params||[];delete e.params;const E=[],b=[];let T=[],x;const w=(R,v)=>{c&&(this._dependsObj[r]=new Map),a&&v==="expression"&&(this._dependsObj[`$arg_${v}${r}`]=new Map);let d=R.ruleType===ye.Brackethesized?this._parserBrackethesized(R):this._parserSingleExpression(R);if(v&&!["arg0, arg1, ...","number0, number1, ..."].includes(v)){R.isSourceType?E.push(`sourceTypeName: "${R.name}"`):v==="defval"&&f===`${this._prefixNameFunc}.input.enum`&&(x=this._enums.get(R.enumName));const g=this._requestParamsHandle(a,v,r,c,d,f);d=(g==null?void 0:g.code)||d,g!=null&&g.paramsExpr&&T.push(g==null?void 0:g.paramsExpr),E.push(`${v}: ${d}`)}else b.push(d)};for(const R of p)w(R,R.originName);for(const R of Object.keys(e))w(e[R],R);a&&this._isInFunc&&E.push("paramsExpr: $paramsExpr"),n&&E.push(n),x&&E.unshift(`options: [${x.join(", ")}]`);const F=T.length?`, [${this._isInFunc?"...$paramsExpr, ":""}${T.join(", ")}]`:"";return b.length?`({${E.join(", ")}}, [${b.join(", ")}], ${r}${F})`:E.length?`({${E.join(", ")}}, ${r}${F})`:`(${r}${F})`}_requestParamsHandle(e,n,r,a,c,f){if(e&&n==="expression"){const p=this._getDepends(`$arg_${n}${r}`),E=this._getExpressionContext(p);return E.push({scope:1,depends:p.map(b=>(b.isArg&&(b.functionName=this._currentFuncName),b)),code:c}),{code:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}else if(a){const p=this._getDepends(r),E=this._getExpressionContext(p);return E.push({scope:2,varNames:n,methodName:f,depends:p,dependSelf:p.some(b=>b.name===n),code:`${n} = ${c}`}),{paramsExpr:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}}_getExpressionContext(e){const n=[],r=[];return this._getDependsCode(e,n,r),n}_getDependsCode(e,n,r){var a,c;for(const f of e)if(!f.isArg){const p=this._codesCol[f.scope||0],E=p.find(T=>{var x;return((x=T.varNames)==null?void 0:x.includes(f.name))||T.funcName===f.name});E&&(r.includes(E)||(r.push(E),E.depends.length&&this._getDependsCode(E.depends,n,r),n.push({scope:f.scope||0,code:E.code,depends:E.depends,funcName:E.funcName,varNames:(a=E.varNames)==null?void 0:a.join(", ")})));const b=p.filter(T=>T.depends.some(x=>x.name===f.name&&x.scope===f.scope&&x.isAgainAssign));for(const T of b)r.includes(T)||(r.push(T),T.depends.length&&this._getDependsCode(T.depends,n,r),n.push({scope:f.scope||0,code:T.code,depends:T.depends,funcName:T.funcName,varNames:(c=T.varNames)==null?void 0:c.join(", ")}))}}_parserBrackethesized(e){return`[${e.exprs.map(r=>this._parserSingleExpression(r)).join(", ")}]`}_functionalProcess(e){return`(function () {
134
134
  let $$_result=undefined;
135
135
  ${e}
136
136
  return $$_result
@@ -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,14 +67519,14 @@ 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
  };
67526
67526
  async function Rp(a) {
67527
67527
  return await Ja.setInlayHints(a);
67528
67528
  }
67529
- const Bp = Hi(Fp), Kp = Hi(new Worker(new URL("" + new URL("assets/parserTccWorker-Dm4K7reM.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
67529
+ const Bp = Hi(Fp), Kp = Hi(new Worker(new URL("" + new URL("assets/parserTccWorker-DhJ8omfR.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
67530
67530
  async function ch(a, n = !1) {
67531
67531
  const { functions: r, types: o, constants: l, variables: c, methods: m } = bt;
67532
67532
  return await Kp.parseTcc(a, n, ji(Rp), { functions: Object.fromEntries(r), methods: Object.fromEntries(m), types: Object.fromEntries(o), constants: Object.fromEntries(l), variables: Object.fromEntries(c) });
@@ -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-Dm4K7reM.js").href:new URL("assets/parserTccWorker-Dm4K7reM.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.119",
3
+ "version": "0.0.121",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"