@guihz/trading-vue-editor-tes 0.0.237 → 0.0.239
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,9 +5,9 @@ var X2=Object.defineProperty;var Q2=(Vt,Kt,Se)=>Kt in Vt?X2(Vt,Kt,{enumerable:!0
|
|
5
5
|
* Released under MIT license <https://lodash.com/license>
|
6
6
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
7
7
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
8
|
-
*/Kn.exports,function(i,t){(function(){var e,r="4.17.21",n=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",u="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",f=500,d="__lodash_placeholder__",h=1,_=2,g=4,y=1,p=2,w=1,v=2,x=4,b=8,C=16,E=32,A=64,N=128,S=256,I=512,F=30,O="...",L=800,z=16,q=1,W=2,P=3,Z=1/0,Y=9007199254740991,G=17976931348623157e292,X=NaN,ut=4294967295,_t=ut-1,at=ut>>>1,vt=[["ary",N],["bind",w],["bindKey",v],["curry",b],["curryRight",C],["flip",I],["partial",E],["partialRight",A],["rearg",S]],wt="[object Arguments]",Ct="[object Array]",bt="[object AsyncFunction]",re="[object Boolean]",Bt="[object Date]",Nt="[object DOMException]",he="[object Error]",se="[object Function]",qt="[object GeneratorFunction]",Xt="[object Map]",Le="[object Number]",Dr="[object Null]",ze="[object Object]",mn="[object Promise]",Ln="[object Proxy]",gn="[object RegExp]",br="[object Set]",Rn="[object String]",R="[object Symbol]",H="[object Undefined]",K="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ct="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",Qt="[object Int32Array]",oe="[object Uint8Array]",Ee="[object Uint8ClampedArray]",Ye="[object Uint16Array]",qe="[object Uint32Array]",xr=/\b__p \+= '';/g,Er=/\b(__p \+=) '' \+/g,Pn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ui=/&(?:amp|lt|gt|quot|#39);/g,Bo=/[&<>"']/g,fu=RegExp(ui.source),hu=RegExp(Bo.source),du=/<%-([\s\S]+?)%>/g,_u=/<%([\s\S]+?)%>/g,To=/<%=([\s\S]+?)%>/g,pu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,mu=/^\w*$/,gu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fs=/[\\^$.*+?()[\]{}|]/g,vu=RegExp(fs.source),hs=/^\s+/,yu=/\s/,wu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Du=/\{\n\/\* \[wrapped with (.+)\] \*/,bu=/,? & /,xu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Eu=/[()=,{}\[\]\/\s]/,Cu=/\\(\\)?/g,Au=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Io=/\w*$/,Mu=/^[-+]0x[0-9a-f]+$/i,Fu=/^0b[01]+$/i,Nu=/^\[object .+?Constructor\]$/,Su=/^0o[0-7]+$/i,Ou=/^(?:0|[1-9]\d*)$/,Bu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Pi=/($^)/,li=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",er="\\u0300-\\u036f",Tu="\\ufe20-\\ufe2f",ki="\\u20d0-\\u20ff",kn=er+Tu+ki,$o="\\u2700-\\u27bf",Xh="a-z\\xdf-\\xf6\\xf8-\\xff",ZD="\\xac\\xb1\\xd7\\xf7",KD="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",GD="\\u2000-\\u206f",JD=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qh="A-Z\\xc0-\\xd6\\xd8-\\xde",t0="\\ufe0e\\ufe0f",e0=ZD+KD+GD+JD,Iu="['’]",XD="["+Zt+"]",r0="["+e0+"]",Lo="["+kn+"]",n0="\\d+",QD="["+$o+"]",i0="["+Xh+"]",s0="[^"+Zt+e0+n0+$o+Xh+Qh+"]",$u="\\ud83c[\\udffb-\\udfff]",tb="(?:"+Lo+"|"+$u+")",o0="[^"+Zt+"]",Lu="(?:\\ud83c[\\udde6-\\uddff]){2}",Ru="[\\ud800-\\udbff][\\udc00-\\udfff]",zi="["+Qh+"]",a0="\\u200d",u0="(?:"+i0+"|"+s0+")",eb="(?:"+zi+"|"+s0+")",l0="(?:"+Iu+"(?:d|ll|m|re|s|t|ve))?",c0="(?:"+Iu+"(?:D|LL|M|RE|S|T|VE))?",f0=tb+"?",h0="["+t0+"]?",rb="(?:"+a0+"(?:"+[o0,Lu,Ru].join("|")+")"+h0+f0+")*",nb="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ib="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",d0=h0+f0+rb,sb="(?:"+[QD,Lu,Ru].join("|")+")"+d0,ob="(?:"+[o0+Lo+"?",Lo,Lu,Ru,XD].join("|")+")",ab=RegExp(Iu,"g"),ub=RegExp(Lo,"g"),Pu=RegExp($u+"(?="+$u+")|"+ob+d0,"g"),lb=RegExp([zi+"?"+i0+"+"+l0+"(?="+[r0,zi,"$"].join("|")+")",eb+"+"+c0+"(?="+[r0,zi+u0,"$"].join("|")+")",zi+"?"+u0+"+"+l0,zi+"+"+c0,ib,nb,n0,sb].join("|"),"g"),cb=RegExp("["+a0+Zt+kn+t0+"]"),fb=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,hb=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],db=-1,De={};De[ft]=De[ct]=De[ht]=De[lt]=De[Qt]=De[oe]=De[Ee]=De[Ye]=De[qe]=!0,De[wt]=De[Ct]=De[st]=De[re]=De[rt]=De[Bt]=De[he]=De[se]=De[Xt]=De[Le]=De[ze]=De[gn]=De[br]=De[Rn]=De[K]=!1;var ge={};ge[wt]=ge[Ct]=ge[st]=ge[rt]=ge[re]=ge[Bt]=ge[ft]=ge[ct]=ge[ht]=ge[lt]=ge[Qt]=ge[Xt]=ge[Le]=ge[ze]=ge[gn]=ge[br]=ge[Rn]=ge[R]=ge[oe]=ge[Ee]=ge[Ye]=ge[qe]=!0,ge[he]=ge[se]=ge[K]=!1;var _b={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},pb={"&":"&","<":"<",">":">",'"':""","'":"'"},mb={"&":"&","<":"<",">":">",""":'"',"'":"'"},gb={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},vb=parseFloat,yb=parseInt,_0=typeof Vt=="object"&&Vt&&Vt.Object===Object&&Vt,wb=typeof self=="object"&&self&&self.Object===Object&&self,Je=_0||wb||Function("return this")(),ku=t&&!t.nodeType&&t,ci=ku&&!0&&i&&!i.nodeType&&i,p0=ci&&ci.exports===ku,zu=p0&&_0.process,$r=function(){try{var j=ci&&ci.require&&ci.require("util").types;return j||zu&&zu.binding&&zu.binding("util")}catch{}}(),m0=$r&&$r.isArrayBuffer,g0=$r&&$r.isDate,v0=$r&&$r.isMap,y0=$r&&$r.isRegExp,w0=$r&&$r.isSet,D0=$r&&$r.isTypedArray;function Cr(j,Q,J){switch(J.length){case 0:return j.call(Q);case 1:return j.call(Q,J[0]);case 2:return j.call(Q,J[0],J[1]);case 3:return j.call(Q,J[0],J[1],J[2])}return j.apply(Q,J)}function Db(j,Q,J,yt){for(var Tt=-1,ne=j==null?0:j.length;++Tt<ne;){var Ue=j[Tt];Q(yt,Ue,J(Ue),j)}return yt}function Lr(j,Q){for(var J=-1,yt=j==null?0:j.length;++J<yt&&Q(j[J],J,j)!==!1;);return j}function bb(j,Q){for(var J=j==null?0:j.length;J--&&Q(j[J],J,j)!==!1;);return j}function b0(j,Q){for(var J=-1,yt=j==null?0:j.length;++J<yt;)if(!Q(j[J],J,j))return!1;return!0}function zn(j,Q){for(var J=-1,yt=j==null?0:j.length,Tt=0,ne=[];++J<yt;){var Ue=j[J];Q(Ue,J,j)&&(ne[Tt++]=Ue)}return ne}function Ro(j,Q){var J=j==null?0:j.length;return!!J&&qi(j,Q,0)>-1}function qu(j,Q,J){for(var yt=-1,Tt=j==null?0:j.length;++yt<Tt;)if(J(Q,j[yt]))return!0;return!1}function Ce(j,Q){for(var J=-1,yt=j==null?0:j.length,Tt=Array(yt);++J<yt;)Tt[J]=Q(j[J],J,j);return Tt}function qn(j,Q){for(var J=-1,yt=Q.length,Tt=j.length;++J<yt;)j[Tt+J]=Q[J];return j}function Uu(j,Q,J,yt){var Tt=-1,ne=j==null?0:j.length;for(yt&&ne&&(J=j[++Tt]);++Tt<ne;)J=Q(J,j[Tt],Tt,j);return J}function xb(j,Q,J,yt){var Tt=j==null?0:j.length;for(yt&&Tt&&(J=j[--Tt]);Tt--;)J=Q(J,j[Tt],Tt,j);return J}function Wu(j,Q){for(var J=-1,yt=j==null?0:j.length;++J<yt;)if(Q(j[J],J,j))return!0;return!1}var Eb=ju("length");function Cb(j){return j.split("")}function Ab(j){return j.match(xu)||[]}function x0(j,Q,J){var yt;return J(j,function(Tt,ne,Ue){if(Q(Tt,ne,Ue))return yt=ne,!1}),yt}function Po(j,Q,J,yt){for(var Tt=j.length,ne=J+(yt?1:-1);yt?ne--:++ne<Tt;)if(Q(j[ne],ne,j))return ne;return-1}function qi(j,Q,J){return Q===Q?Pb(j,Q,J):Po(j,E0,J)}function Mb(j,Q,J,yt){for(var Tt=J-1,ne=j.length;++Tt<ne;)if(yt(j[Tt],Q))return Tt;return-1}function E0(j){return j!==j}function C0(j,Q){var J=j==null?0:j.length;return J?Vu(j,Q)/J:X}function ju(j){return function(Q){return Q==null?e:Q[j]}}function Yu(j){return function(Q){return j==null?e:j[Q]}}function A0(j,Q,J,yt,Tt){return Tt(j,function(ne,Ue,pe){J=yt?(yt=!1,ne):Q(J,ne,Ue,pe)}),J}function Fb(j,Q){var J=j.length;for(j.sort(Q);J--;)j[J]=j[J].value;return j}function Vu(j,Q){for(var J,yt=-1,Tt=j.length;++yt<Tt;){var ne=Q(j[yt]);ne!==e&&(J=J===e?ne:J+ne)}return J}function Hu(j,Q){for(var J=-1,yt=Array(j);++J<j;)yt[J]=Q(J);return yt}function Nb(j,Q){return Ce(Q,function(J){return[J,j[J]]})}function M0(j){return j&&j.slice(0,O0(j)+1).replace(hs,"")}function Ar(j){return function(Q){return j(Q)}}function Zu(j,Q){return Ce(Q,function(J){return j[J]})}function ds(j,Q){return j.has(Q)}function F0(j,Q){for(var J=-1,yt=j.length;++J<yt&&qi(Q,j[J],0)>-1;);return J}function N0(j,Q){for(var J=j.length;J--&&qi(Q,j[J],0)>-1;);return J}function Sb(j,Q){for(var J=j.length,yt=0;J--;)j[J]===Q&&++yt;return yt}var Ob=Yu(_b),Bb=Yu(pb);function Tb(j){return"\\"+gb[j]}function Ib(j,Q){return j==null?e:j[Q]}function Ui(j){return cb.test(j)}function $b(j){return fb.test(j)}function Lb(j){for(var Q,J=[];!(Q=j.next()).done;)J.push(Q.value);return J}function Ku(j){var Q=-1,J=Array(j.size);return j.forEach(function(yt,Tt){J[++Q]=[Tt,yt]}),J}function S0(j,Q){return function(J){return j(Q(J))}}function Un(j,Q){for(var J=-1,yt=j.length,Tt=0,ne=[];++J<yt;){var Ue=j[J];(Ue===Q||Ue===d)&&(j[J]=d,ne[Tt++]=J)}return ne}function ko(j){var Q=-1,J=Array(j.size);return j.forEach(function(yt){J[++Q]=yt}),J}function Rb(j){var Q=-1,J=Array(j.size);return j.forEach(function(yt){J[++Q]=[yt,yt]}),J}function Pb(j,Q,J){for(var yt=J-1,Tt=j.length;++yt<Tt;)if(j[yt]===Q)return yt;return-1}function kb(j,Q,J){for(var yt=J+1;yt--;)if(j[yt]===Q)return yt;return yt}function Wi(j){return Ui(j)?qb(j):Eb(j)}function Gr(j){return Ui(j)?Ub(j):Cb(j)}function O0(j){for(var Q=j.length;Q--&&yu.test(j.charAt(Q)););return Q}var zb=Yu(mb);function qb(j){for(var Q=Pu.lastIndex=0;Pu.test(j);)++Q;return Q}function Ub(j){return j.match(Pu)||[]}function Wb(j){return j.match(lb)||[]}var jb=function j(Q){Q=Q==null?Je:ji.defaults(Je.Object(),Q,ji.pick(Je,hb));var J=Q.Array,yt=Q.Date,Tt=Q.Error,ne=Q.Function,Ue=Q.Math,pe=Q.Object,Gu=Q.RegExp,Yb=Q.String,Rr=Q.TypeError,zo=J.prototype,Vb=ne.prototype,Yi=pe.prototype,qo=Q["__core-js_shared__"],Uo=Vb.toString,ce=Yi.hasOwnProperty,Hb=0,B0=function(){var o=/[^.]+$/.exec(qo&&qo.keys&&qo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),Wo=Yi.toString,Zb=Uo.call(pe),Kb=Je._,Gb=Gu("^"+Uo.call(ce).replace(fs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),jo=p0?Q.Buffer:e,Wn=Q.Symbol,Yo=Q.Uint8Array,T0=jo?jo.allocUnsafe:e,Vo=S0(pe.getPrototypeOf,pe),I0=pe.create,$0=Yi.propertyIsEnumerable,Ho=zo.splice,L0=Wn?Wn.isConcatSpreadable:e,_s=Wn?Wn.iterator:e,fi=Wn?Wn.toStringTag:e,Zo=function(){try{var o=mi(pe,"defineProperty");return o({},"",{}),o}catch{}}(),Jb=Q.clearTimeout!==Je.clearTimeout&&Q.clearTimeout,Xb=yt&&yt.now!==Je.Date.now&&yt.now,Qb=Q.setTimeout!==Je.setTimeout&&Q.setTimeout,Ko=Ue.ceil,Go=Ue.floor,Ju=pe.getOwnPropertySymbols,tx=jo?jo.isBuffer:e,R0=Q.isFinite,ex=zo.join,rx=S0(pe.keys,pe),We=Ue.max,rr=Ue.min,nx=yt.now,ix=Q.parseInt,P0=Ue.random,sx=zo.reverse,Xu=mi(Q,"DataView"),ps=mi(Q,"Map"),Qu=mi(Q,"Promise"),Vi=mi(Q,"Set"),ms=mi(Q,"WeakMap"),gs=mi(pe,"create"),Jo=ms&&new ms,Hi={},ox=gi(Xu),ax=gi(ps),ux=gi(Qu),lx=gi(Vi),cx=gi(ms),Xo=Wn?Wn.prototype:e,vs=Xo?Xo.valueOf:e,k0=Xo?Xo.toString:e;function B(o){if(Ne(o)&&!It(o)&&!(o instanceof Yt)){if(o instanceof Pr)return o;if(ce.call(o,"__wrapped__"))return zd(o)}return new Pr(o)}var Zi=function(){function o(){}return function(l){if(!Fe(l))return{};if(I0)return I0(l);o.prototype=l;var m=new o;return o.prototype=e,m}}();function Qo(){}function Pr(o,l){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!l,this.__index__=0,this.__values__=e}B.templateSettings={escape:du,evaluate:_u,interpolate:To,variable:"",imports:{_:B}},B.prototype=Qo.prototype,B.prototype.constructor=B,Pr.prototype=Zi(Qo.prototype),Pr.prototype.constructor=Pr;function Yt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ut,this.__views__=[]}function fx(){var o=new Yt(this.__wrapped__);return o.__actions__=hr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=hr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=hr(this.__views__),o}function hx(){if(this.__filtered__){var o=new Yt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function dx(){var o=this.__wrapped__.value(),l=this.__dir__,m=It(o),D=l<0,M=m?o.length:0,T=CE(0,M,this.__views__),k=T.start,U=T.end,V=U-k,tt=D?U:k-1,et=this.__iteratees__,ot=et.length,pt=0,Dt=rr(V,this.__takeCount__);if(!m||!D&&M==V&&Dt==V)return ld(o,this.__actions__);var Mt=[];t:for(;V--&&pt<Dt;){tt+=l;for(var Pt=-1,Ft=o[tt];++Pt<ot;){var Ut=et[Pt],Ht=Ut.iteratee,Nr=Ut.type,ur=Ht(Ft);if(Nr==W)Ft=ur;else if(!ur){if(Nr==q)continue t;break t}}Mt[pt++]=Ft}return Mt}Yt.prototype=Zi(Qo.prototype),Yt.prototype.constructor=Yt;function hi(o){var l=-1,m=o==null?0:o.length;for(this.clear();++l<m;){var D=o[l];this.set(D[0],D[1])}}function _x(){this.__data__=gs?gs(null):{},this.size=0}function px(o){var l=this.has(o)&&delete this.__data__[o];return this.size-=l?1:0,l}function mx(o){var l=this.__data__;if(gs){var m=l[o];return m===c?e:m}return ce.call(l,o)?l[o]:e}function gx(o){var l=this.__data__;return gs?l[o]!==e:ce.call(l,o)}function vx(o,l){var m=this.__data__;return this.size+=this.has(o)?0:1,m[o]=gs&&l===e?c:l,this}hi.prototype.clear=_x,hi.prototype.delete=px,hi.prototype.get=mx,hi.prototype.has=gx,hi.prototype.set=vx;function vn(o){var l=-1,m=o==null?0:o.length;for(this.clear();++l<m;){var D=o[l];this.set(D[0],D[1])}}function yx(){this.__data__=[],this.size=0}function wx(o){var l=this.__data__,m=ta(l,o);if(m<0)return!1;var D=l.length-1;return m==D?l.pop():Ho.call(l,m,1),--this.size,!0}function Dx(o){var l=this.__data__,m=ta(l,o);return m<0?e:l[m][1]}function bx(o){return ta(this.__data__,o)>-1}function xx(o,l){var m=this.__data__,D=ta(m,o);return D<0?(++this.size,m.push([o,l])):m[D][1]=l,this}vn.prototype.clear=yx,vn.prototype.delete=wx,vn.prototype.get=Dx,vn.prototype.has=bx,vn.prototype.set=xx;function yn(o){var l=-1,m=o==null?0:o.length;for(this.clear();++l<m;){var D=o[l];this.set(D[0],D[1])}}function Ex(){this.size=0,this.__data__={hash:new hi,map:new(ps||vn),string:new hi}}function Cx(o){var l=ha(this,o).delete(o);return this.size-=l?1:0,l}function Ax(o){return ha(this,o).get(o)}function Mx(o){return ha(this,o).has(o)}function Fx(o,l){var m=ha(this,o),D=m.size;return m.set(o,l),this.size+=m.size==D?0:1,this}yn.prototype.clear=Ex,yn.prototype.delete=Cx,yn.prototype.get=Ax,yn.prototype.has=Mx,yn.prototype.set=Fx;function di(o){var l=-1,m=o==null?0:o.length;for(this.__data__=new yn;++l<m;)this.add(o[l])}function Nx(o){return this.__data__.set(o,c),this}function Sx(o){return this.__data__.has(o)}di.prototype.add=di.prototype.push=Nx,di.prototype.has=Sx;function Jr(o){var l=this.__data__=new vn(o);this.size=l.size}function Ox(){this.__data__=new vn,this.size=0}function Bx(o){var l=this.__data__,m=l.delete(o);return this.size=l.size,m}function Tx(o){return this.__data__.get(o)}function Ix(o){return this.__data__.has(o)}function $x(o,l){var m=this.__data__;if(m instanceof vn){var D=m.__data__;if(!ps||D.length<n-1)return D.push([o,l]),this.size=++m.size,this;m=this.__data__=new yn(D)}return m.set(o,l),this.size=m.size,this}Jr.prototype.clear=Ox,Jr.prototype.delete=Bx,Jr.prototype.get=Tx,Jr.prototype.has=Ix,Jr.prototype.set=$x;function z0(o,l){var m=It(o),D=!m&&vi(o),M=!m&&!D&&Zn(o),T=!m&&!D&&!M&&Xi(o),k=m||D||M||T,U=k?Hu(o.length,Yb):[],V=U.length;for(var tt in o)(l||ce.call(o,tt))&&!(k&&(tt=="length"||M&&(tt=="offset"||tt=="parent")||T&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||xn(tt,V)))&&U.push(tt);return U}function q0(o){var l=o.length;return l?o[cl(0,l-1)]:e}function Lx(o,l){return da(hr(o),_i(l,0,o.length))}function Rx(o){return da(hr(o))}function tl(o,l,m){(m!==e&&!Xr(o[l],m)||m===e&&!(l in o))&&wn(o,l,m)}function ys(o,l,m){var D=o[l];(!(ce.call(o,l)&&Xr(D,m))||m===e&&!(l in o))&&wn(o,l,m)}function ta(o,l){for(var m=o.length;m--;)if(Xr(o[m][0],l))return m;return-1}function Px(o,l,m,D){return jn(o,function(M,T,k){l(D,M,m(M),k)}),D}function U0(o,l){return o&&an(l,Ve(l),o)}function kx(o,l){return o&&an(l,_r(l),o)}function wn(o,l,m){l=="__proto__"&&Zo?Zo(o,l,{configurable:!0,enumerable:!0,value:m,writable:!0}):o[l]=m}function el(o,l){for(var m=-1,D=l.length,M=J(D),T=o==null;++m<D;)M[m]=T?e:$l(o,l[m]);return M}function _i(o,l,m){return o===o&&(m!==e&&(o=o<=m?o:m),l!==e&&(o=o>=l?o:l)),o}function kr(o,l,m,D,M,T){var k,U=l&h,V=l&_,tt=l&g;if(m&&(k=M?m(o,D,M,T):m(o)),k!==e)return k;if(!Fe(o))return o;var et=It(o);if(et){if(k=ME(o),!U)return hr(o,k)}else{var ot=nr(o),pt=ot==se||ot==qt;if(Zn(o))return hd(o,U);if(ot==ze||ot==wt||pt&&!M){if(k=V||pt?{}:Od(o),!U)return V?mE(o,kx(k,o)):pE(o,U0(k,o))}else{if(!ge[ot])return M?o:{};k=FE(o,ot,U)}}T||(T=new Jr);var Dt=T.get(o);if(Dt)return Dt;T.set(o,k),o_(o)?o.forEach(function(Ft){k.add(kr(Ft,l,m,Ft,o,T))}):i_(o)&&o.forEach(function(Ft,Ut){k.set(Ut,kr(Ft,l,m,Ut,o,T))});var Mt=tt?V?Dl:wl:V?_r:Ve,Pt=et?e:Mt(o);return Lr(Pt||o,function(Ft,Ut){Pt&&(Ut=Ft,Ft=o[Ut]),ys(k,Ut,kr(Ft,l,m,Ut,o,T))}),k}function zx(o){var l=Ve(o);return function(m){return W0(m,o,l)}}function W0(o,l,m){var D=m.length;if(o==null)return!D;for(o=pe(o);D--;){var M=m[D],T=l[M],k=o[M];if(k===e&&!(M in o)||!T(k))return!1}return!0}function j0(o,l,m){if(typeof o!="function")throw new Rr(a);return As(function(){o.apply(e,m)},l)}function ws(o,l,m,D){var M=-1,T=Ro,k=!0,U=o.length,V=[],tt=l.length;if(!U)return V;m&&(l=Ce(l,Ar(m))),D?(T=qu,k=!1):l.length>=n&&(T=ds,k=!1,l=new di(l));t:for(;++M<U;){var et=o[M],ot=m==null?et:m(et);if(et=D||et!==0?et:0,k&&ot===ot){for(var pt=tt;pt--;)if(l[pt]===ot)continue t;V.push(et)}else T(l,ot,D)||V.push(et)}return V}var jn=gd(on),Y0=gd(nl,!0);function qx(o,l){var m=!0;return jn(o,function(D,M,T){return m=!!l(D,M,T),m}),m}function ea(o,l,m){for(var D=-1,M=o.length;++D<M;){var T=o[D],k=l(T);if(k!=null&&(U===e?k===k&&!Fr(k):m(k,U)))var U=k,V=T}return V}function Ux(o,l,m,D){var M=o.length;for(m=Lt(m),m<0&&(m=-m>M?0:M+m),D=D===e||D>M?M:Lt(D),D<0&&(D+=M),D=m>D?0:u_(D);m<D;)o[m++]=l;return o}function V0(o,l){var m=[];return jn(o,function(D,M,T){l(D,M,T)&&m.push(D)}),m}function Xe(o,l,m,D,M){var T=-1,k=o.length;for(m||(m=SE),M||(M=[]);++T<k;){var U=o[T];l>0&&m(U)?l>1?Xe(U,l-1,m,D,M):qn(M,U):D||(M[M.length]=U)}return M}var rl=vd(),H0=vd(!0);function on(o,l){return o&&rl(o,l,Ve)}function nl(o,l){return o&&H0(o,l,Ve)}function ra(o,l){return zn(l,function(m){return En(o[m])})}function pi(o,l){l=Vn(l,o);for(var m=0,D=l.length;o!=null&&m<D;)o=o[un(l[m++])];return m&&m==D?o:e}function Z0(o,l,m){var D=l(o);return It(o)?D:qn(D,m(o))}function or(o){return o==null?o===e?H:Dr:fi&&fi in pe(o)?EE(o):RE(o)}function il(o,l){return o>l}function Wx(o,l){return o!=null&&ce.call(o,l)}function jx(o,l){return o!=null&&l in pe(o)}function Yx(o,l,m){return o>=rr(l,m)&&o<We(l,m)}function sl(o,l,m){for(var D=m?qu:Ro,M=o[0].length,T=o.length,k=T,U=J(T),V=1/0,tt=[];k--;){var et=o[k];k&&l&&(et=Ce(et,Ar(l))),V=rr(et.length,V),U[k]=!m&&(l||M>=120&&et.length>=120)?new di(k&&et):e}et=o[0];var ot=-1,pt=U[0];t:for(;++ot<M&&tt.length<V;){var Dt=et[ot],Mt=l?l(Dt):Dt;if(Dt=m||Dt!==0?Dt:0,!(pt?ds(pt,Mt):D(tt,Mt,m))){for(k=T;--k;){var Pt=U[k];if(!(Pt?ds(Pt,Mt):D(o[k],Mt,m)))continue t}pt&&pt.push(Mt),tt.push(Dt)}}return tt}function Vx(o,l,m,D){return on(o,function(M,T,k){l(D,m(M),T,k)}),D}function Ds(o,l,m){l=Vn(l,o),o=$d(o,l);var D=o==null?o:o[un(qr(l))];return D==null?e:Cr(D,o,m)}function K0(o){return Ne(o)&&or(o)==wt}function Hx(o){return Ne(o)&&or(o)==st}function Zx(o){return Ne(o)&&or(o)==Bt}function bs(o,l,m,D,M){return o===l?!0:o==null||l==null||!Ne(o)&&!Ne(l)?o!==o&&l!==l:Kx(o,l,m,D,bs,M)}function Kx(o,l,m,D,M,T){var k=It(o),U=It(l),V=k?Ct:nr(o),tt=U?Ct:nr(l);V=V==wt?ze:V,tt=tt==wt?ze:tt;var et=V==ze,ot=tt==ze,pt=V==tt;if(pt&&Zn(o)){if(!Zn(l))return!1;k=!0,et=!1}if(pt&&!et)return T||(T=new Jr),k||Xi(o)?Fd(o,l,m,D,M,T):bE(o,l,V,m,D,M,T);if(!(m&y)){var Dt=et&&ce.call(o,"__wrapped__"),Mt=ot&&ce.call(l,"__wrapped__");if(Dt||Mt){var Pt=Dt?o.value():o,Ft=Mt?l.value():l;return T||(T=new Jr),M(Pt,Ft,m,D,T)}}return pt?(T||(T=new Jr),xE(o,l,m,D,M,T)):!1}function Gx(o){return Ne(o)&&nr(o)==Xt}function ol(o,l,m,D){var M=m.length,T=M,k=!D;if(o==null)return!T;for(o=pe(o);M--;){var U=m[M];if(k&&U[2]?U[1]!==o[U[0]]:!(U[0]in o))return!1}for(;++M<T;){U=m[M];var V=U[0],tt=o[V],et=U[1];if(k&&U[2]){if(tt===e&&!(V in o))return!1}else{var ot=new Jr;if(D)var pt=D(tt,et,V,o,l,ot);if(!(pt===e?bs(et,tt,y|p,D,ot):pt))return!1}}return!0}function G0(o){if(!Fe(o)||BE(o))return!1;var l=En(o)?Gb:Nu;return l.test(gi(o))}function Jx(o){return Ne(o)&&or(o)==gn}function Xx(o){return Ne(o)&&nr(o)==br}function Qx(o){return Ne(o)&&ya(o.length)&&!!De[or(o)]}function J0(o){return typeof o=="function"?o:o==null?pr:typeof o=="object"?It(o)?td(o[0],o[1]):Q0(o):y_(o)}function al(o){if(!Cs(o))return rx(o);var l=[];for(var m in pe(o))ce.call(o,m)&&m!="constructor"&&l.push(m);return l}function tE(o){if(!Fe(o))return LE(o);var l=Cs(o),m=[];for(var D in o)D=="constructor"&&(l||!ce.call(o,D))||m.push(D);return m}function ul(o,l){return o<l}function X0(o,l){var m=-1,D=dr(o)?J(o.length):[];return jn(o,function(M,T,k){D[++m]=l(M,T,k)}),D}function Q0(o){var l=xl(o);return l.length==1&&l[0][2]?Td(l[0][0],l[0][1]):function(m){return m===o||ol(m,o,l)}}function td(o,l){return Cl(o)&&Bd(l)?Td(un(o),l):function(m){var D=$l(m,o);return D===e&&D===l?Ll(m,o):bs(l,D,y|p)}}function na(o,l,m,D,M){o!==l&&rl(l,function(T,k){if(M||(M=new Jr),Fe(T))eE(o,l,k,m,na,D,M);else{var U=D?D(Ml(o,k),T,k+"",o,l,M):e;U===e&&(U=T),tl(o,k,U)}},_r)}function eE(o,l,m,D,M,T,k){var U=Ml(o,m),V=Ml(l,m),tt=k.get(V);if(tt){tl(o,m,tt);return}var et=T?T(U,V,m+"",o,l,k):e,ot=et===e;if(ot){var pt=It(V),Dt=!pt&&Zn(V),Mt=!pt&&!Dt&&Xi(V);et=V,pt||Dt||Mt?It(U)?et=U:Be(U)?et=hr(U):Dt?(ot=!1,et=hd(V,!0)):Mt?(ot=!1,et=dd(V,!0)):et=[]:Ms(V)||vi(V)?(et=U,vi(U)?et=l_(U):(!Fe(U)||En(U))&&(et=Od(V))):ot=!1}ot&&(k.set(V,et),M(et,V,D,T,k),k.delete(V)),tl(o,m,et)}function ed(o,l){var m=o.length;if(m)return l+=l<0?m:0,xn(l,m)?o[l]:e}function rd(o,l,m){l.length?l=Ce(l,function(T){return It(T)?function(k){return pi(k,T.length===1?T[0]:T)}:T}):l=[pr];var D=-1;l=Ce(l,Ar(At()));var M=X0(o,function(T,k,U){var V=Ce(l,function(tt){return tt(T)});return{criteria:V,index:++D,value:T}});return Fb(M,function(T,k){return _E(T,k,m)})}function rE(o,l){return nd(o,l,function(m,D){return Ll(o,D)})}function nd(o,l,m){for(var D=-1,M=l.length,T={};++D<M;){var k=l[D],U=pi(o,k);m(U,k)&&xs(T,Vn(k,o),U)}return T}function nE(o){return function(l){return pi(l,o)}}function ll(o,l,m,D){var M=D?Mb:qi,T=-1,k=l.length,U=o;for(o===l&&(l=hr(l)),m&&(U=Ce(o,Ar(m)));++T<k;)for(var V=0,tt=l[T],et=m?m(tt):tt;(V=M(U,et,V,D))>-1;)U!==o&&Ho.call(U,V,1),Ho.call(o,V,1);return o}function id(o,l){for(var m=o?l.length:0,D=m-1;m--;){var M=l[m];if(m==D||M!==T){var T=M;xn(M)?Ho.call(o,M,1):dl(o,M)}}return o}function cl(o,l){return o+Go(P0()*(l-o+1))}function iE(o,l,m,D){for(var M=-1,T=We(Ko((l-o)/(m||1)),0),k=J(T);T--;)k[D?T:++M]=o,o+=m;return k}function fl(o,l){var m="";if(!o||l<1||l>Y)return m;do l%2&&(m+=o),l=Go(l/2),l&&(o+=o);while(l);return m}function kt(o,l){return Fl(Id(o,l,pr),o+"")}function sE(o){return q0(Qi(o))}function oE(o,l){var m=Qi(o);return da(m,_i(l,0,m.length))}function xs(o,l,m,D){if(!Fe(o))return o;l=Vn(l,o);for(var M=-1,T=l.length,k=T-1,U=o;U!=null&&++M<T;){var V=un(l[M]),tt=m;if(V==="__proto__"||V==="constructor"||V==="prototype")return o;if(M!=k){var et=U[V];tt=D?D(et,V,U):e,tt===e&&(tt=Fe(et)?et:xn(l[M+1])?[]:{})}ys(U,V,tt),U=U[V]}return o}var sd=Jo?function(o,l){return Jo.set(o,l),o}:pr,aE=Zo?function(o,l){return Zo(o,"toString",{configurable:!0,enumerable:!1,value:Pl(l),writable:!0})}:pr;function uE(o){return da(Qi(o))}function zr(o,l,m){var D=-1,M=o.length;l<0&&(l=-l>M?0:M+l),m=m>M?M:m,m<0&&(m+=M),M=l>m?0:m-l>>>0,l>>>=0;for(var T=J(M);++D<M;)T[D]=o[D+l];return T}function lE(o,l){var m;return jn(o,function(D,M,T){return m=l(D,M,T),!m}),!!m}function ia(o,l,m){var D=0,M=o==null?D:o.length;if(typeof l=="number"&&l===l&&M<=at){for(;D<M;){var T=D+M>>>1,k=o[T];k!==null&&!Fr(k)&&(m?k<=l:k<l)?D=T+1:M=T}return M}return hl(o,l,pr,m)}function hl(o,l,m,D){var M=0,T=o==null?0:o.length;if(T===0)return 0;l=m(l);for(var k=l!==l,U=l===null,V=Fr(l),tt=l===e;M<T;){var et=Go((M+T)/2),ot=m(o[et]),pt=ot!==e,Dt=ot===null,Mt=ot===ot,Pt=Fr(ot);if(k)var Ft=D||Mt;else tt?Ft=Mt&&(D||pt):U?Ft=Mt&&pt&&(D||!Dt):V?Ft=Mt&&pt&&!Dt&&(D||!Pt):Dt||Pt?Ft=!1:Ft=D?ot<=l:ot<l;Ft?M=et+1:T=et}return rr(T,_t)}function od(o,l){for(var m=-1,D=o.length,M=0,T=[];++m<D;){var k=o[m],U=l?l(k):k;if(!m||!Xr(U,V)){var V=U;T[M++]=k===0?0:k}}return T}function ad(o){return typeof o=="number"?o:Fr(o)?X:+o}function Mr(o){if(typeof o=="string")return o;if(It(o))return Ce(o,Mr)+"";if(Fr(o))return k0?k0.call(o):"";var l=o+"";return l=="0"&&1/o==-Z?"-0":l}function Yn(o,l,m){var D=-1,M=Ro,T=o.length,k=!0,U=[],V=U;if(m)k=!1,M=qu;else if(T>=n){var tt=l?null:wE(o);if(tt)return ko(tt);k=!1,M=ds,V=new di}else V=l?[]:U;t:for(;++D<T;){var et=o[D],ot=l?l(et):et;if(et=m||et!==0?et:0,k&&ot===ot){for(var pt=V.length;pt--;)if(V[pt]===ot)continue t;l&&V.push(ot),U.push(et)}else M(V,ot,m)||(V!==U&&V.push(ot),U.push(et))}return U}function dl(o,l){return l=Vn(l,o),o=$d(o,l),o==null||delete o[un(qr(l))]}function ud(o,l,m,D){return xs(o,l,m(pi(o,l)),D)}function sa(o,l,m,D){for(var M=o.length,T=D?M:-1;(D?T--:++T<M)&&l(o[T],T,o););return m?zr(o,D?0:T,D?T+1:M):zr(o,D?T+1:0,D?M:T)}function ld(o,l){var m=o;return m instanceof Yt&&(m=m.value()),Uu(l,function(D,M){return M.func.apply(M.thisArg,qn([D],M.args))},m)}function _l(o,l,m){var D=o.length;if(D<2)return D?Yn(o[0]):[];for(var M=-1,T=J(D);++M<D;)for(var k=o[M],U=-1;++U<D;)U!=M&&(T[M]=ws(T[M]||k,o[U],l,m));return Yn(Xe(T,1),l,m)}function cd(o,l,m){for(var D=-1,M=o.length,T=l.length,k={};++D<M;){var U=D<T?l[D]:e;m(k,o[D],U)}return k}function pl(o){return Be(o)?o:[]}function ml(o){return typeof o=="function"?o:pr}function Vn(o,l){return It(o)?o:Cl(o,l)?[o]:kd(ae(o))}var cE=kt;function Hn(o,l,m){var D=o.length;return m=m===e?D:m,!l&&m>=D?o:zr(o,l,m)}var fd=Jb||function(o){return Je.clearTimeout(o)};function hd(o,l){if(l)return o.slice();var m=o.length,D=T0?T0(m):new o.constructor(m);return o.copy(D),D}function gl(o){var l=new o.constructor(o.byteLength);return new Yo(l).set(new Yo(o)),l}function fE(o,l){var m=l?gl(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.byteLength)}function hE(o){var l=new o.constructor(o.source,Io.exec(o));return l.lastIndex=o.lastIndex,l}function dE(o){return vs?pe(vs.call(o)):{}}function dd(o,l){var m=l?gl(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.length)}function _d(o,l){if(o!==l){var m=o!==e,D=o===null,M=o===o,T=Fr(o),k=l!==e,U=l===null,V=l===l,tt=Fr(l);if(!U&&!tt&&!T&&o>l||T&&k&&V&&!U&&!tt||D&&k&&V||!m&&V||!M)return 1;if(!D&&!T&&!tt&&o<l||tt&&m&&M&&!D&&!T||U&&m&&M||!k&&M||!V)return-1}return 0}function _E(o,l,m){for(var D=-1,M=o.criteria,T=l.criteria,k=M.length,U=m.length;++D<k;){var V=_d(M[D],T[D]);if(V){if(D>=U)return V;var tt=m[D];return V*(tt=="desc"?-1:1)}}return o.index-l.index}function pd(o,l,m,D){for(var M=-1,T=o.length,k=m.length,U=-1,V=l.length,tt=We(T-k,0),et=J(V+tt),ot=!D;++U<V;)et[U]=l[U];for(;++M<k;)(ot||M<T)&&(et[m[M]]=o[M]);for(;tt--;)et[U++]=o[M++];return et}function md(o,l,m,D){for(var M=-1,T=o.length,k=-1,U=m.length,V=-1,tt=l.length,et=We(T-U,0),ot=J(et+tt),pt=!D;++M<et;)ot[M]=o[M];for(var Dt=M;++V<tt;)ot[Dt+V]=l[V];for(;++k<U;)(pt||M<T)&&(ot[Dt+m[k]]=o[M++]);return ot}function hr(o,l){var m=-1,D=o.length;for(l||(l=J(D));++m<D;)l[m]=o[m];return l}function an(o,l,m,D){var M=!m;m||(m={});for(var T=-1,k=l.length;++T<k;){var U=l[T],V=D?D(m[U],o[U],U,m,o):e;V===e&&(V=o[U]),M?wn(m,U,V):ys(m,U,V)}return m}function pE(o,l){return an(o,El(o),l)}function mE(o,l){return an(o,Nd(o),l)}function oa(o,l){return function(m,D){var M=It(m)?Db:Px,T=l?l():{};return M(m,o,At(D,2),T)}}function Ki(o){return kt(function(l,m){var D=-1,M=m.length,T=M>1?m[M-1]:e,k=M>2?m[2]:e;for(T=o.length>3&&typeof T=="function"?(M--,T):e,k&&ar(m[0],m[1],k)&&(T=M<3?e:T,M=1),l=pe(l);++D<M;){var U=m[D];U&&o(l,U,D,T)}return l})}function gd(o,l){return function(m,D){if(m==null)return m;if(!dr(m))return o(m,D);for(var M=m.length,T=l?M:-1,k=pe(m);(l?T--:++T<M)&&D(k[T],T,k)!==!1;);return m}}function vd(o){return function(l,m,D){for(var M=-1,T=pe(l),k=D(l),U=k.length;U--;){var V=k[o?U:++M];if(m(T[V],V,T)===!1)break}return l}}function gE(o,l,m){var D=l&w,M=Es(o);function T(){var k=this&&this!==Je&&this instanceof T?M:o;return k.apply(D?m:this,arguments)}return T}function yd(o){return function(l){l=ae(l);var m=Ui(l)?Gr(l):e,D=m?m[0]:l.charAt(0),M=m?Hn(m,1).join(""):l.slice(1);return D[o]()+M}}function Gi(o){return function(l){return Uu(g_(m_(l).replace(ab,"")),o,"")}}function Es(o){return function(){var l=arguments;switch(l.length){case 0:return new o;case 1:return new o(l[0]);case 2:return new o(l[0],l[1]);case 3:return new o(l[0],l[1],l[2]);case 4:return new o(l[0],l[1],l[2],l[3]);case 5:return new o(l[0],l[1],l[2],l[3],l[4]);case 6:return new o(l[0],l[1],l[2],l[3],l[4],l[5]);case 7:return new o(l[0],l[1],l[2],l[3],l[4],l[5],l[6])}var m=Zi(o.prototype),D=o.apply(m,l);return Fe(D)?D:m}}function vE(o,l,m){var D=Es(o);function M(){for(var T=arguments.length,k=J(T),U=T,V=Ji(M);U--;)k[U]=arguments[U];var tt=T<3&&k[0]!==V&&k[T-1]!==V?[]:Un(k,V);if(T-=tt.length,T<m)return Ed(o,l,aa,M.placeholder,e,k,tt,e,e,m-T);var et=this&&this!==Je&&this instanceof M?D:o;return Cr(et,this,k)}return M}function wd(o){return function(l,m,D){var M=pe(l);if(!dr(l)){var T=At(m,3);l=Ve(l),m=function(U){return T(M[U],U,M)}}var k=o(l,m,D);return k>-1?M[T?l[k]:k]:e}}function Dd(o){return bn(function(l){var m=l.length,D=m,M=Pr.prototype.thru;for(o&&l.reverse();D--;){var T=l[D];if(typeof T!="function")throw new Rr(a);if(M&&!k&&fa(T)=="wrapper")var k=new Pr([],!0)}for(D=k?D:m;++D<m;){T=l[D];var U=fa(T),V=U=="wrapper"?bl(T):e;V&&Al(V[0])&&V[1]==(N|b|E|S)&&!V[4].length&&V[9]==1?k=k[fa(V[0])].apply(k,V[3]):k=T.length==1&&Al(T)?k[U]():k.thru(T)}return function(){var tt=arguments,et=tt[0];if(k&&tt.length==1&&It(et))return k.plant(et).value();for(var ot=0,pt=m?l[ot].apply(this,tt):et;++ot<m;)pt=l[ot].call(this,pt);return pt}})}function aa(o,l,m,D,M,T,k,U,V,tt){var et=l&N,ot=l&w,pt=l&v,Dt=l&(b|C),Mt=l&I,Pt=pt?e:Es(o);function Ft(){for(var Ut=arguments.length,Ht=J(Ut),Nr=Ut;Nr--;)Ht[Nr]=arguments[Nr];if(Dt)var ur=Ji(Ft),Sr=Sb(Ht,ur);if(D&&(Ht=pd(Ht,D,M,Dt)),T&&(Ht=md(Ht,T,k,Dt)),Ut-=Sr,Dt&&Ut<tt){var Te=Un(Ht,ur);return Ed(o,l,aa,Ft.placeholder,m,Ht,Te,U,V,tt-Ut)}var Qr=ot?m:this,An=pt?Qr[o]:o;return Ut=Ht.length,U?Ht=PE(Ht,U):Mt&&Ut>1&&Ht.reverse(),et&&V<Ut&&(Ht.length=V),this&&this!==Je&&this instanceof Ft&&(An=Pt||Es(An)),An.apply(Qr,Ht)}return Ft}function bd(o,l){return function(m,D){return Vx(m,o,l(D),{})}}function ua(o,l){return function(m,D){var M;if(m===e&&D===e)return l;if(m!==e&&(M=m),D!==e){if(M===e)return D;typeof m=="string"||typeof D=="string"?(m=Mr(m),D=Mr(D)):(m=ad(m),D=ad(D)),M=o(m,D)}return M}}function vl(o){return bn(function(l){return l=Ce(l,Ar(At())),kt(function(m){var D=this;return o(l,function(M){return Cr(M,D,m)})})})}function la(o,l){l=l===e?" ":Mr(l);var m=l.length;if(m<2)return m?fl(l,o):l;var D=fl(l,Ko(o/Wi(l)));return Ui(l)?Hn(Gr(D),0,o).join(""):D.slice(0,o)}function yE(o,l,m,D){var M=l&w,T=Es(o);function k(){for(var U=-1,V=arguments.length,tt=-1,et=D.length,ot=J(et+V),pt=this&&this!==Je&&this instanceof k?T:o;++tt<et;)ot[tt]=D[tt];for(;V--;)ot[tt++]=arguments[++U];return Cr(pt,M?m:this,ot)}return k}function xd(o){return function(l,m,D){return D&&typeof D!="number"&&ar(l,m,D)&&(m=D=e),l=Cn(l),m===e?(m=l,l=0):m=Cn(m),D=D===e?l<m?1:-1:Cn(D),iE(l,m,D,o)}}function ca(o){return function(l,m){return typeof l=="string"&&typeof m=="string"||(l=Ur(l),m=Ur(m)),o(l,m)}}function Ed(o,l,m,D,M,T,k,U,V,tt){var et=l&b,ot=et?k:e,pt=et?e:k,Dt=et?T:e,Mt=et?e:T;l|=et?E:A,l&=~(et?A:E),l&x||(l&=~(w|v));var Pt=[o,l,M,Dt,ot,Mt,pt,U,V,tt],Ft=m.apply(e,Pt);return Al(o)&&Ld(Ft,Pt),Ft.placeholder=D,Rd(Ft,o,l)}function yl(o){var l=Ue[o];return function(m,D){if(m=Ur(m),D=D==null?0:rr(Lt(D),292),D&&R0(m)){var M=(ae(m)+"e").split("e"),T=l(M[0]+"e"+(+M[1]+D));return M=(ae(T)+"e").split("e"),+(M[0]+"e"+(+M[1]-D))}return l(m)}}var wE=Vi&&1/ko(new Vi([,-0]))[1]==Z?function(o){return new Vi(o)}:ql;function Cd(o){return function(l){var m=nr(l);return m==Xt?Ku(l):m==br?Rb(l):Nb(l,o(l))}}function Dn(o,l,m,D,M,T,k,U){var V=l&v;if(!V&&typeof o!="function")throw new Rr(a);var tt=D?D.length:0;if(tt||(l&=~(E|A),D=M=e),k=k===e?k:We(Lt(k),0),U=U===e?U:Lt(U),tt-=M?M.length:0,l&A){var et=D,ot=M;D=M=e}var pt=V?e:bl(o),Dt=[o,l,m,D,M,et,ot,T,k,U];if(pt&&$E(Dt,pt),o=Dt[0],l=Dt[1],m=Dt[2],D=Dt[3],M=Dt[4],U=Dt[9]=Dt[9]===e?V?0:o.length:We(Dt[9]-tt,0),!U&&l&(b|C)&&(l&=~(b|C)),!l||l==w)var Mt=gE(o,l,m);else l==b||l==C?Mt=vE(o,l,U):(l==E||l==(w|E))&&!M.length?Mt=yE(o,l,m,D):Mt=aa.apply(e,Dt);var Pt=pt?sd:Ld;return Rd(Pt(Mt,Dt),o,l)}function Ad(o,l,m,D){return o===e||Xr(o,Yi[m])&&!ce.call(D,m)?l:o}function Md(o,l,m,D,M,T){return Fe(o)&&Fe(l)&&(T.set(l,o),na(o,l,e,Md,T),T.delete(l)),o}function DE(o){return Ms(o)?e:o}function Fd(o,l,m,D,M,T){var k=m&y,U=o.length,V=l.length;if(U!=V&&!(k&&V>U))return!1;var tt=T.get(o),et=T.get(l);if(tt&&et)return tt==l&&et==o;var ot=-1,pt=!0,Dt=m&p?new di:e;for(T.set(o,l),T.set(l,o);++ot<U;){var Mt=o[ot],Pt=l[ot];if(D)var Ft=k?D(Pt,Mt,ot,l,o,T):D(Mt,Pt,ot,o,l,T);if(Ft!==e){if(Ft)continue;pt=!1;break}if(Dt){if(!Wu(l,function(Ut,Ht){if(!ds(Dt,Ht)&&(Mt===Ut||M(Mt,Ut,m,D,T)))return Dt.push(Ht)})){pt=!1;break}}else if(!(Mt===Pt||M(Mt,Pt,m,D,T))){pt=!1;break}}return T.delete(o),T.delete(l),pt}function bE(o,l,m,D,M,T,k){switch(m){case rt:if(o.byteLength!=l.byteLength||o.byteOffset!=l.byteOffset)return!1;o=o.buffer,l=l.buffer;case st:return!(o.byteLength!=l.byteLength||!T(new Yo(o),new Yo(l)));case re:case Bt:case Le:return Xr(+o,+l);case he:return o.name==l.name&&o.message==l.message;case gn:case Rn:return o==l+"";case Xt:var U=Ku;case br:var V=D&y;if(U||(U=ko),o.size!=l.size&&!V)return!1;var tt=k.get(o);if(tt)return tt==l;D|=p,k.set(o,l);var et=Fd(U(o),U(l),D,M,T,k);return k.delete(o),et;case R:if(vs)return vs.call(o)==vs.call(l)}return!1}function xE(o,l,m,D,M,T){var k=m&y,U=wl(o),V=U.length,tt=wl(l),et=tt.length;if(V!=et&&!k)return!1;for(var ot=V;ot--;){var pt=U[ot];if(!(k?pt in l:ce.call(l,pt)))return!1}var Dt=T.get(o),Mt=T.get(l);if(Dt&&Mt)return Dt==l&&Mt==o;var Pt=!0;T.set(o,l),T.set(l,o);for(var Ft=k;++ot<V;){pt=U[ot];var Ut=o[pt],Ht=l[pt];if(D)var Nr=k?D(Ht,Ut,pt,l,o,T):D(Ut,Ht,pt,o,l,T);if(!(Nr===e?Ut===Ht||M(Ut,Ht,m,D,T):Nr)){Pt=!1;break}Ft||(Ft=pt=="constructor")}if(Pt&&!Ft){var ur=o.constructor,Sr=l.constructor;ur!=Sr&&"constructor"in o&&"constructor"in l&&!(typeof ur=="function"&&ur instanceof ur&&typeof Sr=="function"&&Sr instanceof Sr)&&(Pt=!1)}return T.delete(o),T.delete(l),Pt}function bn(o){return Fl(Id(o,e,Wd),o+"")}function wl(o){return Z0(o,Ve,El)}function Dl(o){return Z0(o,_r,Nd)}var bl=Jo?function(o){return Jo.get(o)}:ql;function fa(o){for(var l=o.name+"",m=Hi[l],D=ce.call(Hi,l)?m.length:0;D--;){var M=m[D],T=M.func;if(T==null||T==o)return M.name}return l}function Ji(o){var l=ce.call(B,"placeholder")?B:o;return l.placeholder}function At(){var o=B.iteratee||kl;return o=o===kl?J0:o,arguments.length?o(arguments[0],arguments[1]):o}function ha(o,l){var m=o.__data__;return OE(l)?m[typeof l=="string"?"string":"hash"]:m.map}function xl(o){for(var l=Ve(o),m=l.length;m--;){var D=l[m],M=o[D];l[m]=[D,M,Bd(M)]}return l}function mi(o,l){var m=Ib(o,l);return G0(m)?m:e}function EE(o){var l=ce.call(o,fi),m=o[fi];try{o[fi]=e;var D=!0}catch{}var M=Wo.call(o);return D&&(l?o[fi]=m:delete o[fi]),M}var El=Ju?function(o){return o==null?[]:(o=pe(o),zn(Ju(o),function(l){return $0.call(o,l)}))}:Ul,Nd=Ju?function(o){for(var l=[];o;)qn(l,El(o)),o=Vo(o);return l}:Ul,nr=or;(Xu&&nr(new Xu(new ArrayBuffer(1)))!=rt||ps&&nr(new ps)!=Xt||Qu&&nr(Qu.resolve())!=mn||Vi&&nr(new Vi)!=br||ms&&nr(new ms)!=K)&&(nr=function(o){var l=or(o),m=l==ze?o.constructor:e,D=m?gi(m):"";if(D)switch(D){case ox:return rt;case ax:return Xt;case ux:return mn;case lx:return br;case cx:return K}return l});function CE(o,l,m){for(var D=-1,M=m.length;++D<M;){var T=m[D],k=T.size;switch(T.type){case"drop":o+=k;break;case"dropRight":l-=k;break;case"take":l=rr(l,o+k);break;case"takeRight":o=We(o,l-k);break}}return{start:o,end:l}}function AE(o){var l=o.match(Du);return l?l[1].split(bu):[]}function Sd(o,l,m){l=Vn(l,o);for(var D=-1,M=l.length,T=!1;++D<M;){var k=un(l[D]);if(!(T=o!=null&&m(o,k)))break;o=o[k]}return T||++D!=M?T:(M=o==null?0:o.length,!!M&&ya(M)&&xn(k,M)&&(It(o)||vi(o)))}function ME(o){var l=o.length,m=new o.constructor(l);return l&&typeof o[0]=="string"&&ce.call(o,"index")&&(m.index=o.index,m.input=o.input),m}function Od(o){return typeof o.constructor=="function"&&!Cs(o)?Zi(Vo(o)):{}}function FE(o,l,m){var D=o.constructor;switch(l){case st:return gl(o);case re:case Bt:return new D(+o);case rt:return fE(o,m);case ft:case ct:case ht:case lt:case Qt:case oe:case Ee:case Ye:case qe:return dd(o,m);case Xt:return new D;case Le:case Rn:return new D(o);case gn:return hE(o);case br:return new D;case R:return dE(o)}}function NE(o,l){var m=l.length;if(!m)return o;var D=m-1;return l[D]=(m>1?"& ":"")+l[D],l=l.join(m>2?", ":" "),o.replace(wu,`{
|
8
|
+
*/Kn.exports,function(i,t){(function(){var e,r="4.17.21",n=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",u="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",f=500,d="__lodash_placeholder__",h=1,_=2,g=4,y=1,p=2,w=1,v=2,x=4,b=8,C=16,E=32,A=64,N=128,S=256,I=512,F=30,O="...",L=800,z=16,q=1,W=2,R=3,Z=1/0,Y=9007199254740991,G=17976931348623157e292,Q=NaN,ut=4294967295,_t=ut-1,at=ut>>>1,vt=[["ary",N],["bind",w],["bindKey",v],["curry",b],["curryRight",C],["flip",I],["partial",E],["partialRight",A],["rearg",S]],wt="[object Arguments]",Ct="[object Array]",bt="[object AsyncFunction]",re="[object Boolean]",Bt="[object Date]",Nt="[object DOMException]",he="[object Error]",se="[object Function]",qt="[object GeneratorFunction]",Xt="[object Map]",Le="[object Number]",Dr="[object Null]",ze="[object Object]",mn="[object Promise]",Ln="[object Proxy]",gn="[object RegExp]",br="[object Set]",Rn="[object String]",P="[object Symbol]",H="[object Undefined]",K="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ct="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",Qt="[object Int32Array]",oe="[object Uint8Array]",Ee="[object Uint8ClampedArray]",Ye="[object Uint16Array]",qe="[object Uint32Array]",xr=/\b__p \+= '';/g,Er=/\b(__p \+=) '' \+/g,Pn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ui=/&(?:amp|lt|gt|quot|#39);/g,Bo=/[&<>"']/g,fu=RegExp(ui.source),hu=RegExp(Bo.source),du=/<%-([\s\S]+?)%>/g,_u=/<%([\s\S]+?)%>/g,To=/<%=([\s\S]+?)%>/g,pu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,mu=/^\w*$/,gu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fs=/[\\^$.*+?()[\]{}|]/g,vu=RegExp(fs.source),hs=/^\s+/,yu=/\s/,wu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Du=/\{\n\/\* \[wrapped with (.+)\] \*/,bu=/,? & /,xu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Eu=/[()=,{}\[\]\/\s]/,Cu=/\\(\\)?/g,Au=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Io=/\w*$/,Mu=/^[-+]0x[0-9a-f]+$/i,Fu=/^0b[01]+$/i,Nu=/^\[object .+?Constructor\]$/,Su=/^0o[0-7]+$/i,Ou=/^(?:0|[1-9]\d*)$/,Bu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Pi=/($^)/,li=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",er="\\u0300-\\u036f",Tu="\\ufe20-\\ufe2f",ki="\\u20d0-\\u20ff",kn=er+Tu+ki,$o="\\u2700-\\u27bf",Xh="a-z\\xdf-\\xf6\\xf8-\\xff",ZD="\\xac\\xb1\\xd7\\xf7",KD="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",GD="\\u2000-\\u206f",JD=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qh="A-Z\\xc0-\\xd6\\xd8-\\xde",t0="\\ufe0e\\ufe0f",e0=ZD+KD+GD+JD,Iu="['’]",XD="["+Zt+"]",r0="["+e0+"]",Lo="["+kn+"]",n0="\\d+",QD="["+$o+"]",i0="["+Xh+"]",s0="[^"+Zt+e0+n0+$o+Xh+Qh+"]",$u="\\ud83c[\\udffb-\\udfff]",tb="(?:"+Lo+"|"+$u+")",o0="[^"+Zt+"]",Lu="(?:\\ud83c[\\udde6-\\uddff]){2}",Ru="[\\ud800-\\udbff][\\udc00-\\udfff]",zi="["+Qh+"]",a0="\\u200d",u0="(?:"+i0+"|"+s0+")",eb="(?:"+zi+"|"+s0+")",l0="(?:"+Iu+"(?:d|ll|m|re|s|t|ve))?",c0="(?:"+Iu+"(?:D|LL|M|RE|S|T|VE))?",f0=tb+"?",h0="["+t0+"]?",rb="(?:"+a0+"(?:"+[o0,Lu,Ru].join("|")+")"+h0+f0+")*",nb="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ib="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",d0=h0+f0+rb,sb="(?:"+[QD,Lu,Ru].join("|")+")"+d0,ob="(?:"+[o0+Lo+"?",Lo,Lu,Ru,XD].join("|")+")",ab=RegExp(Iu,"g"),ub=RegExp(Lo,"g"),Pu=RegExp($u+"(?="+$u+")|"+ob+d0,"g"),lb=RegExp([zi+"?"+i0+"+"+l0+"(?="+[r0,zi,"$"].join("|")+")",eb+"+"+c0+"(?="+[r0,zi+u0,"$"].join("|")+")",zi+"?"+u0+"+"+l0,zi+"+"+c0,ib,nb,n0,sb].join("|"),"g"),cb=RegExp("["+a0+Zt+kn+t0+"]"),fb=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,hb=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],db=-1,De={};De[ft]=De[ct]=De[ht]=De[lt]=De[Qt]=De[oe]=De[Ee]=De[Ye]=De[qe]=!0,De[wt]=De[Ct]=De[st]=De[re]=De[rt]=De[Bt]=De[he]=De[se]=De[Xt]=De[Le]=De[ze]=De[gn]=De[br]=De[Rn]=De[K]=!1;var ge={};ge[wt]=ge[Ct]=ge[st]=ge[rt]=ge[re]=ge[Bt]=ge[ft]=ge[ct]=ge[ht]=ge[lt]=ge[Qt]=ge[Xt]=ge[Le]=ge[ze]=ge[gn]=ge[br]=ge[Rn]=ge[P]=ge[oe]=ge[Ee]=ge[Ye]=ge[qe]=!0,ge[he]=ge[se]=ge[K]=!1;var _b={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},pb={"&":"&","<":"<",">":">",'"':""","'":"'"},mb={"&":"&","<":"<",">":">",""":'"',"'":"'"},gb={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},vb=parseFloat,yb=parseInt,_0=typeof Vt=="object"&&Vt&&Vt.Object===Object&&Vt,wb=typeof self=="object"&&self&&self.Object===Object&&self,Je=_0||wb||Function("return this")(),ku=t&&!t.nodeType&&t,ci=ku&&!0&&i&&!i.nodeType&&i,p0=ci&&ci.exports===ku,zu=p0&&_0.process,$r=function(){try{var j=ci&&ci.require&&ci.require("util").types;return j||zu&&zu.binding&&zu.binding("util")}catch{}}(),m0=$r&&$r.isArrayBuffer,g0=$r&&$r.isDate,v0=$r&&$r.isMap,y0=$r&&$r.isRegExp,w0=$r&&$r.isSet,D0=$r&&$r.isTypedArray;function Cr(j,X,J){switch(J.length){case 0:return j.call(X);case 1:return j.call(X,J[0]);case 2:return j.call(X,J[0],J[1]);case 3:return j.call(X,J[0],J[1],J[2])}return j.apply(X,J)}function Db(j,X,J,yt){for(var Tt=-1,ne=j==null?0:j.length;++Tt<ne;){var Ue=j[Tt];X(yt,Ue,J(Ue),j)}return yt}function Lr(j,X){for(var J=-1,yt=j==null?0:j.length;++J<yt&&X(j[J],J,j)!==!1;);return j}function bb(j,X){for(var J=j==null?0:j.length;J--&&X(j[J],J,j)!==!1;);return j}function b0(j,X){for(var J=-1,yt=j==null?0:j.length;++J<yt;)if(!X(j[J],J,j))return!1;return!0}function zn(j,X){for(var J=-1,yt=j==null?0:j.length,Tt=0,ne=[];++J<yt;){var Ue=j[J];X(Ue,J,j)&&(ne[Tt++]=Ue)}return ne}function Ro(j,X){var J=j==null?0:j.length;return!!J&&qi(j,X,0)>-1}function qu(j,X,J){for(var yt=-1,Tt=j==null?0:j.length;++yt<Tt;)if(J(X,j[yt]))return!0;return!1}function Ce(j,X){for(var J=-1,yt=j==null?0:j.length,Tt=Array(yt);++J<yt;)Tt[J]=X(j[J],J,j);return Tt}function qn(j,X){for(var J=-1,yt=X.length,Tt=j.length;++J<yt;)j[Tt+J]=X[J];return j}function Uu(j,X,J,yt){var Tt=-1,ne=j==null?0:j.length;for(yt&&ne&&(J=j[++Tt]);++Tt<ne;)J=X(J,j[Tt],Tt,j);return J}function xb(j,X,J,yt){var Tt=j==null?0:j.length;for(yt&&Tt&&(J=j[--Tt]);Tt--;)J=X(J,j[Tt],Tt,j);return J}function Wu(j,X){for(var J=-1,yt=j==null?0:j.length;++J<yt;)if(X(j[J],J,j))return!0;return!1}var Eb=ju("length");function Cb(j){return j.split("")}function Ab(j){return j.match(xu)||[]}function x0(j,X,J){var yt;return J(j,function(Tt,ne,Ue){if(X(Tt,ne,Ue))return yt=ne,!1}),yt}function Po(j,X,J,yt){for(var Tt=j.length,ne=J+(yt?1:-1);yt?ne--:++ne<Tt;)if(X(j[ne],ne,j))return ne;return-1}function qi(j,X,J){return X===X?Pb(j,X,J):Po(j,E0,J)}function Mb(j,X,J,yt){for(var Tt=J-1,ne=j.length;++Tt<ne;)if(yt(j[Tt],X))return Tt;return-1}function E0(j){return j!==j}function C0(j,X){var J=j==null?0:j.length;return J?Vu(j,X)/J:Q}function ju(j){return function(X){return X==null?e:X[j]}}function Yu(j){return function(X){return j==null?e:j[X]}}function A0(j,X,J,yt,Tt){return Tt(j,function(ne,Ue,pe){J=yt?(yt=!1,ne):X(J,ne,Ue,pe)}),J}function Fb(j,X){var J=j.length;for(j.sort(X);J--;)j[J]=j[J].value;return j}function Vu(j,X){for(var J,yt=-1,Tt=j.length;++yt<Tt;){var ne=X(j[yt]);ne!==e&&(J=J===e?ne:J+ne)}return J}function Hu(j,X){for(var J=-1,yt=Array(j);++J<j;)yt[J]=X(J);return yt}function Nb(j,X){return Ce(X,function(J){return[J,j[J]]})}function M0(j){return j&&j.slice(0,O0(j)+1).replace(hs,"")}function Ar(j){return function(X){return j(X)}}function Zu(j,X){return Ce(X,function(J){return j[J]})}function ds(j,X){return j.has(X)}function F0(j,X){for(var J=-1,yt=j.length;++J<yt&&qi(X,j[J],0)>-1;);return J}function N0(j,X){for(var J=j.length;J--&&qi(X,j[J],0)>-1;);return J}function Sb(j,X){for(var J=j.length,yt=0;J--;)j[J]===X&&++yt;return yt}var Ob=Yu(_b),Bb=Yu(pb);function Tb(j){return"\\"+gb[j]}function Ib(j,X){return j==null?e:j[X]}function Ui(j){return cb.test(j)}function $b(j){return fb.test(j)}function Lb(j){for(var X,J=[];!(X=j.next()).done;)J.push(X.value);return J}function Ku(j){var X=-1,J=Array(j.size);return j.forEach(function(yt,Tt){J[++X]=[Tt,yt]}),J}function S0(j,X){return function(J){return j(X(J))}}function Un(j,X){for(var J=-1,yt=j.length,Tt=0,ne=[];++J<yt;){var Ue=j[J];(Ue===X||Ue===d)&&(j[J]=d,ne[Tt++]=J)}return ne}function ko(j){var X=-1,J=Array(j.size);return j.forEach(function(yt){J[++X]=yt}),J}function Rb(j){var X=-1,J=Array(j.size);return j.forEach(function(yt){J[++X]=[yt,yt]}),J}function Pb(j,X,J){for(var yt=J-1,Tt=j.length;++yt<Tt;)if(j[yt]===X)return yt;return-1}function kb(j,X,J){for(var yt=J+1;yt--;)if(j[yt]===X)return yt;return yt}function Wi(j){return Ui(j)?qb(j):Eb(j)}function Gr(j){return Ui(j)?Ub(j):Cb(j)}function O0(j){for(var X=j.length;X--&&yu.test(j.charAt(X)););return X}var zb=Yu(mb);function qb(j){for(var X=Pu.lastIndex=0;Pu.test(j);)++X;return X}function Ub(j){return j.match(Pu)||[]}function Wb(j){return j.match(lb)||[]}var jb=function j(X){X=X==null?Je:ji.defaults(Je.Object(),X,ji.pick(Je,hb));var J=X.Array,yt=X.Date,Tt=X.Error,ne=X.Function,Ue=X.Math,pe=X.Object,Gu=X.RegExp,Yb=X.String,Rr=X.TypeError,zo=J.prototype,Vb=ne.prototype,Yi=pe.prototype,qo=X["__core-js_shared__"],Uo=Vb.toString,ce=Yi.hasOwnProperty,Hb=0,B0=function(){var o=/[^.]+$/.exec(qo&&qo.keys&&qo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),Wo=Yi.toString,Zb=Uo.call(pe),Kb=Je._,Gb=Gu("^"+Uo.call(ce).replace(fs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),jo=p0?X.Buffer:e,Wn=X.Symbol,Yo=X.Uint8Array,T0=jo?jo.allocUnsafe:e,Vo=S0(pe.getPrototypeOf,pe),I0=pe.create,$0=Yi.propertyIsEnumerable,Ho=zo.splice,L0=Wn?Wn.isConcatSpreadable:e,_s=Wn?Wn.iterator:e,fi=Wn?Wn.toStringTag:e,Zo=function(){try{var o=mi(pe,"defineProperty");return o({},"",{}),o}catch{}}(),Jb=X.clearTimeout!==Je.clearTimeout&&X.clearTimeout,Xb=yt&&yt.now!==Je.Date.now&&yt.now,Qb=X.setTimeout!==Je.setTimeout&&X.setTimeout,Ko=Ue.ceil,Go=Ue.floor,Ju=pe.getOwnPropertySymbols,tx=jo?jo.isBuffer:e,R0=X.isFinite,ex=zo.join,rx=S0(pe.keys,pe),We=Ue.max,rr=Ue.min,nx=yt.now,ix=X.parseInt,P0=Ue.random,sx=zo.reverse,Xu=mi(X,"DataView"),ps=mi(X,"Map"),Qu=mi(X,"Promise"),Vi=mi(X,"Set"),ms=mi(X,"WeakMap"),gs=mi(pe,"create"),Jo=ms&&new ms,Hi={},ox=gi(Xu),ax=gi(ps),ux=gi(Qu),lx=gi(Vi),cx=gi(ms),Xo=Wn?Wn.prototype:e,vs=Xo?Xo.valueOf:e,k0=Xo?Xo.toString:e;function B(o){if(Ne(o)&&!It(o)&&!(o instanceof Yt)){if(o instanceof Pr)return o;if(ce.call(o,"__wrapped__"))return zd(o)}return new Pr(o)}var Zi=function(){function o(){}return function(l){if(!Fe(l))return{};if(I0)return I0(l);o.prototype=l;var m=new o;return o.prototype=e,m}}();function Qo(){}function Pr(o,l){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!l,this.__index__=0,this.__values__=e}B.templateSettings={escape:du,evaluate:_u,interpolate:To,variable:"",imports:{_:B}},B.prototype=Qo.prototype,B.prototype.constructor=B,Pr.prototype=Zi(Qo.prototype),Pr.prototype.constructor=Pr;function Yt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ut,this.__views__=[]}function fx(){var o=new Yt(this.__wrapped__);return o.__actions__=hr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=hr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=hr(this.__views__),o}function hx(){if(this.__filtered__){var o=new Yt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function dx(){var o=this.__wrapped__.value(),l=this.__dir__,m=It(o),D=l<0,M=m?o.length:0,T=CE(0,M,this.__views__),k=T.start,U=T.end,V=U-k,tt=D?U:k-1,et=this.__iteratees__,ot=et.length,pt=0,Dt=rr(V,this.__takeCount__);if(!m||!D&&M==V&&Dt==V)return ld(o,this.__actions__);var Mt=[];t:for(;V--&&pt<Dt;){tt+=l;for(var Pt=-1,Ft=o[tt];++Pt<ot;){var Ut=et[Pt],Ht=Ut.iteratee,Nr=Ut.type,ur=Ht(Ft);if(Nr==W)Ft=ur;else if(!ur){if(Nr==q)continue t;break t}}Mt[pt++]=Ft}return Mt}Yt.prototype=Zi(Qo.prototype),Yt.prototype.constructor=Yt;function hi(o){var l=-1,m=o==null?0:o.length;for(this.clear();++l<m;){var D=o[l];this.set(D[0],D[1])}}function _x(){this.__data__=gs?gs(null):{},this.size=0}function px(o){var l=this.has(o)&&delete this.__data__[o];return this.size-=l?1:0,l}function mx(o){var l=this.__data__;if(gs){var m=l[o];return m===c?e:m}return ce.call(l,o)?l[o]:e}function gx(o){var l=this.__data__;return gs?l[o]!==e:ce.call(l,o)}function vx(o,l){var m=this.__data__;return this.size+=this.has(o)?0:1,m[o]=gs&&l===e?c:l,this}hi.prototype.clear=_x,hi.prototype.delete=px,hi.prototype.get=mx,hi.prototype.has=gx,hi.prototype.set=vx;function vn(o){var l=-1,m=o==null?0:o.length;for(this.clear();++l<m;){var D=o[l];this.set(D[0],D[1])}}function yx(){this.__data__=[],this.size=0}function wx(o){var l=this.__data__,m=ta(l,o);if(m<0)return!1;var D=l.length-1;return m==D?l.pop():Ho.call(l,m,1),--this.size,!0}function Dx(o){var l=this.__data__,m=ta(l,o);return m<0?e:l[m][1]}function bx(o){return ta(this.__data__,o)>-1}function xx(o,l){var m=this.__data__,D=ta(m,o);return D<0?(++this.size,m.push([o,l])):m[D][1]=l,this}vn.prototype.clear=yx,vn.prototype.delete=wx,vn.prototype.get=Dx,vn.prototype.has=bx,vn.prototype.set=xx;function yn(o){var l=-1,m=o==null?0:o.length;for(this.clear();++l<m;){var D=o[l];this.set(D[0],D[1])}}function Ex(){this.size=0,this.__data__={hash:new hi,map:new(ps||vn),string:new hi}}function Cx(o){var l=ha(this,o).delete(o);return this.size-=l?1:0,l}function Ax(o){return ha(this,o).get(o)}function Mx(o){return ha(this,o).has(o)}function Fx(o,l){var m=ha(this,o),D=m.size;return m.set(o,l),this.size+=m.size==D?0:1,this}yn.prototype.clear=Ex,yn.prototype.delete=Cx,yn.prototype.get=Ax,yn.prototype.has=Mx,yn.prototype.set=Fx;function di(o){var l=-1,m=o==null?0:o.length;for(this.__data__=new yn;++l<m;)this.add(o[l])}function Nx(o){return this.__data__.set(o,c),this}function Sx(o){return this.__data__.has(o)}di.prototype.add=di.prototype.push=Nx,di.prototype.has=Sx;function Jr(o){var l=this.__data__=new vn(o);this.size=l.size}function Ox(){this.__data__=new vn,this.size=0}function Bx(o){var l=this.__data__,m=l.delete(o);return this.size=l.size,m}function Tx(o){return this.__data__.get(o)}function Ix(o){return this.__data__.has(o)}function $x(o,l){var m=this.__data__;if(m instanceof vn){var D=m.__data__;if(!ps||D.length<n-1)return D.push([o,l]),this.size=++m.size,this;m=this.__data__=new yn(D)}return m.set(o,l),this.size=m.size,this}Jr.prototype.clear=Ox,Jr.prototype.delete=Bx,Jr.prototype.get=Tx,Jr.prototype.has=Ix,Jr.prototype.set=$x;function z0(o,l){var m=It(o),D=!m&&vi(o),M=!m&&!D&&Zn(o),T=!m&&!D&&!M&&Xi(o),k=m||D||M||T,U=k?Hu(o.length,Yb):[],V=U.length;for(var tt in o)(l||ce.call(o,tt))&&!(k&&(tt=="length"||M&&(tt=="offset"||tt=="parent")||T&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||xn(tt,V)))&&U.push(tt);return U}function q0(o){var l=o.length;return l?o[cl(0,l-1)]:e}function Lx(o,l){return da(hr(o),_i(l,0,o.length))}function Rx(o){return da(hr(o))}function tl(o,l,m){(m!==e&&!Xr(o[l],m)||m===e&&!(l in o))&&wn(o,l,m)}function ys(o,l,m){var D=o[l];(!(ce.call(o,l)&&Xr(D,m))||m===e&&!(l in o))&&wn(o,l,m)}function ta(o,l){for(var m=o.length;m--;)if(Xr(o[m][0],l))return m;return-1}function Px(o,l,m,D){return jn(o,function(M,T,k){l(D,M,m(M),k)}),D}function U0(o,l){return o&&an(l,Ve(l),o)}function kx(o,l){return o&&an(l,_r(l),o)}function wn(o,l,m){l=="__proto__"&&Zo?Zo(o,l,{configurable:!0,enumerable:!0,value:m,writable:!0}):o[l]=m}function el(o,l){for(var m=-1,D=l.length,M=J(D),T=o==null;++m<D;)M[m]=T?e:$l(o,l[m]);return M}function _i(o,l,m){return o===o&&(m!==e&&(o=o<=m?o:m),l!==e&&(o=o>=l?o:l)),o}function kr(o,l,m,D,M,T){var k,U=l&h,V=l&_,tt=l&g;if(m&&(k=M?m(o,D,M,T):m(o)),k!==e)return k;if(!Fe(o))return o;var et=It(o);if(et){if(k=ME(o),!U)return hr(o,k)}else{var ot=nr(o),pt=ot==se||ot==qt;if(Zn(o))return hd(o,U);if(ot==ze||ot==wt||pt&&!M){if(k=V||pt?{}:Od(o),!U)return V?mE(o,kx(k,o)):pE(o,U0(k,o))}else{if(!ge[ot])return M?o:{};k=FE(o,ot,U)}}T||(T=new Jr);var Dt=T.get(o);if(Dt)return Dt;T.set(o,k),o_(o)?o.forEach(function(Ft){k.add(kr(Ft,l,m,Ft,o,T))}):i_(o)&&o.forEach(function(Ft,Ut){k.set(Ut,kr(Ft,l,m,Ut,o,T))});var Mt=tt?V?Dl:wl:V?_r:Ve,Pt=et?e:Mt(o);return Lr(Pt||o,function(Ft,Ut){Pt&&(Ut=Ft,Ft=o[Ut]),ys(k,Ut,kr(Ft,l,m,Ut,o,T))}),k}function zx(o){var l=Ve(o);return function(m){return W0(m,o,l)}}function W0(o,l,m){var D=m.length;if(o==null)return!D;for(o=pe(o);D--;){var M=m[D],T=l[M],k=o[M];if(k===e&&!(M in o)||!T(k))return!1}return!0}function j0(o,l,m){if(typeof o!="function")throw new Rr(a);return As(function(){o.apply(e,m)},l)}function ws(o,l,m,D){var M=-1,T=Ro,k=!0,U=o.length,V=[],tt=l.length;if(!U)return V;m&&(l=Ce(l,Ar(m))),D?(T=qu,k=!1):l.length>=n&&(T=ds,k=!1,l=new di(l));t:for(;++M<U;){var et=o[M],ot=m==null?et:m(et);if(et=D||et!==0?et:0,k&&ot===ot){for(var pt=tt;pt--;)if(l[pt]===ot)continue t;V.push(et)}else T(l,ot,D)||V.push(et)}return V}var jn=gd(on),Y0=gd(nl,!0);function qx(o,l){var m=!0;return jn(o,function(D,M,T){return m=!!l(D,M,T),m}),m}function ea(o,l,m){for(var D=-1,M=o.length;++D<M;){var T=o[D],k=l(T);if(k!=null&&(U===e?k===k&&!Fr(k):m(k,U)))var U=k,V=T}return V}function Ux(o,l,m,D){var M=o.length;for(m=Lt(m),m<0&&(m=-m>M?0:M+m),D=D===e||D>M?M:Lt(D),D<0&&(D+=M),D=m>D?0:u_(D);m<D;)o[m++]=l;return o}function V0(o,l){var m=[];return jn(o,function(D,M,T){l(D,M,T)&&m.push(D)}),m}function Xe(o,l,m,D,M){var T=-1,k=o.length;for(m||(m=SE),M||(M=[]);++T<k;){var U=o[T];l>0&&m(U)?l>1?Xe(U,l-1,m,D,M):qn(M,U):D||(M[M.length]=U)}return M}var rl=vd(),H0=vd(!0);function on(o,l){return o&&rl(o,l,Ve)}function nl(o,l){return o&&H0(o,l,Ve)}function ra(o,l){return zn(l,function(m){return En(o[m])})}function pi(o,l){l=Vn(l,o);for(var m=0,D=l.length;o!=null&&m<D;)o=o[un(l[m++])];return m&&m==D?o:e}function Z0(o,l,m){var D=l(o);return It(o)?D:qn(D,m(o))}function or(o){return o==null?o===e?H:Dr:fi&&fi in pe(o)?EE(o):RE(o)}function il(o,l){return o>l}function Wx(o,l){return o!=null&&ce.call(o,l)}function jx(o,l){return o!=null&&l in pe(o)}function Yx(o,l,m){return o>=rr(l,m)&&o<We(l,m)}function sl(o,l,m){for(var D=m?qu:Ro,M=o[0].length,T=o.length,k=T,U=J(T),V=1/0,tt=[];k--;){var et=o[k];k&&l&&(et=Ce(et,Ar(l))),V=rr(et.length,V),U[k]=!m&&(l||M>=120&&et.length>=120)?new di(k&&et):e}et=o[0];var ot=-1,pt=U[0];t:for(;++ot<M&&tt.length<V;){var Dt=et[ot],Mt=l?l(Dt):Dt;if(Dt=m||Dt!==0?Dt:0,!(pt?ds(pt,Mt):D(tt,Mt,m))){for(k=T;--k;){var Pt=U[k];if(!(Pt?ds(Pt,Mt):D(o[k],Mt,m)))continue t}pt&&pt.push(Mt),tt.push(Dt)}}return tt}function Vx(o,l,m,D){return on(o,function(M,T,k){l(D,m(M),T,k)}),D}function Ds(o,l,m){l=Vn(l,o),o=$d(o,l);var D=o==null?o:o[un(qr(l))];return D==null?e:Cr(D,o,m)}function K0(o){return Ne(o)&&or(o)==wt}function Hx(o){return Ne(o)&&or(o)==st}function Zx(o){return Ne(o)&&or(o)==Bt}function bs(o,l,m,D,M){return o===l?!0:o==null||l==null||!Ne(o)&&!Ne(l)?o!==o&&l!==l:Kx(o,l,m,D,bs,M)}function Kx(o,l,m,D,M,T){var k=It(o),U=It(l),V=k?Ct:nr(o),tt=U?Ct:nr(l);V=V==wt?ze:V,tt=tt==wt?ze:tt;var et=V==ze,ot=tt==ze,pt=V==tt;if(pt&&Zn(o)){if(!Zn(l))return!1;k=!0,et=!1}if(pt&&!et)return T||(T=new Jr),k||Xi(o)?Fd(o,l,m,D,M,T):bE(o,l,V,m,D,M,T);if(!(m&y)){var Dt=et&&ce.call(o,"__wrapped__"),Mt=ot&&ce.call(l,"__wrapped__");if(Dt||Mt){var Pt=Dt?o.value():o,Ft=Mt?l.value():l;return T||(T=new Jr),M(Pt,Ft,m,D,T)}}return pt?(T||(T=new Jr),xE(o,l,m,D,M,T)):!1}function Gx(o){return Ne(o)&&nr(o)==Xt}function ol(o,l,m,D){var M=m.length,T=M,k=!D;if(o==null)return!T;for(o=pe(o);M--;){var U=m[M];if(k&&U[2]?U[1]!==o[U[0]]:!(U[0]in o))return!1}for(;++M<T;){U=m[M];var V=U[0],tt=o[V],et=U[1];if(k&&U[2]){if(tt===e&&!(V in o))return!1}else{var ot=new Jr;if(D)var pt=D(tt,et,V,o,l,ot);if(!(pt===e?bs(et,tt,y|p,D,ot):pt))return!1}}return!0}function G0(o){if(!Fe(o)||BE(o))return!1;var l=En(o)?Gb:Nu;return l.test(gi(o))}function Jx(o){return Ne(o)&&or(o)==gn}function Xx(o){return Ne(o)&&nr(o)==br}function Qx(o){return Ne(o)&&ya(o.length)&&!!De[or(o)]}function J0(o){return typeof o=="function"?o:o==null?pr:typeof o=="object"?It(o)?td(o[0],o[1]):Q0(o):y_(o)}function al(o){if(!Cs(o))return rx(o);var l=[];for(var m in pe(o))ce.call(o,m)&&m!="constructor"&&l.push(m);return l}function tE(o){if(!Fe(o))return LE(o);var l=Cs(o),m=[];for(var D in o)D=="constructor"&&(l||!ce.call(o,D))||m.push(D);return m}function ul(o,l){return o<l}function X0(o,l){var m=-1,D=dr(o)?J(o.length):[];return jn(o,function(M,T,k){D[++m]=l(M,T,k)}),D}function Q0(o){var l=xl(o);return l.length==1&&l[0][2]?Td(l[0][0],l[0][1]):function(m){return m===o||ol(m,o,l)}}function td(o,l){return Cl(o)&&Bd(l)?Td(un(o),l):function(m){var D=$l(m,o);return D===e&&D===l?Ll(m,o):bs(l,D,y|p)}}function na(o,l,m,D,M){o!==l&&rl(l,function(T,k){if(M||(M=new Jr),Fe(T))eE(o,l,k,m,na,D,M);else{var U=D?D(Ml(o,k),T,k+"",o,l,M):e;U===e&&(U=T),tl(o,k,U)}},_r)}function eE(o,l,m,D,M,T,k){var U=Ml(o,m),V=Ml(l,m),tt=k.get(V);if(tt){tl(o,m,tt);return}var et=T?T(U,V,m+"",o,l,k):e,ot=et===e;if(ot){var pt=It(V),Dt=!pt&&Zn(V),Mt=!pt&&!Dt&&Xi(V);et=V,pt||Dt||Mt?It(U)?et=U:Be(U)?et=hr(U):Dt?(ot=!1,et=hd(V,!0)):Mt?(ot=!1,et=dd(V,!0)):et=[]:Ms(V)||vi(V)?(et=U,vi(U)?et=l_(U):(!Fe(U)||En(U))&&(et=Od(V))):ot=!1}ot&&(k.set(V,et),M(et,V,D,T,k),k.delete(V)),tl(o,m,et)}function ed(o,l){var m=o.length;if(m)return l+=l<0?m:0,xn(l,m)?o[l]:e}function rd(o,l,m){l.length?l=Ce(l,function(T){return It(T)?function(k){return pi(k,T.length===1?T[0]:T)}:T}):l=[pr];var D=-1;l=Ce(l,Ar(At()));var M=X0(o,function(T,k,U){var V=Ce(l,function(tt){return tt(T)});return{criteria:V,index:++D,value:T}});return Fb(M,function(T,k){return _E(T,k,m)})}function rE(o,l){return nd(o,l,function(m,D){return Ll(o,D)})}function nd(o,l,m){for(var D=-1,M=l.length,T={};++D<M;){var k=l[D],U=pi(o,k);m(U,k)&&xs(T,Vn(k,o),U)}return T}function nE(o){return function(l){return pi(l,o)}}function ll(o,l,m,D){var M=D?Mb:qi,T=-1,k=l.length,U=o;for(o===l&&(l=hr(l)),m&&(U=Ce(o,Ar(m)));++T<k;)for(var V=0,tt=l[T],et=m?m(tt):tt;(V=M(U,et,V,D))>-1;)U!==o&&Ho.call(U,V,1),Ho.call(o,V,1);return o}function id(o,l){for(var m=o?l.length:0,D=m-1;m--;){var M=l[m];if(m==D||M!==T){var T=M;xn(M)?Ho.call(o,M,1):dl(o,M)}}return o}function cl(o,l){return o+Go(P0()*(l-o+1))}function iE(o,l,m,D){for(var M=-1,T=We(Ko((l-o)/(m||1)),0),k=J(T);T--;)k[D?T:++M]=o,o+=m;return k}function fl(o,l){var m="";if(!o||l<1||l>Y)return m;do l%2&&(m+=o),l=Go(l/2),l&&(o+=o);while(l);return m}function kt(o,l){return Fl(Id(o,l,pr),o+"")}function sE(o){return q0(Qi(o))}function oE(o,l){var m=Qi(o);return da(m,_i(l,0,m.length))}function xs(o,l,m,D){if(!Fe(o))return o;l=Vn(l,o);for(var M=-1,T=l.length,k=T-1,U=o;U!=null&&++M<T;){var V=un(l[M]),tt=m;if(V==="__proto__"||V==="constructor"||V==="prototype")return o;if(M!=k){var et=U[V];tt=D?D(et,V,U):e,tt===e&&(tt=Fe(et)?et:xn(l[M+1])?[]:{})}ys(U,V,tt),U=U[V]}return o}var sd=Jo?function(o,l){return Jo.set(o,l),o}:pr,aE=Zo?function(o,l){return Zo(o,"toString",{configurable:!0,enumerable:!1,value:Pl(l),writable:!0})}:pr;function uE(o){return da(Qi(o))}function zr(o,l,m){var D=-1,M=o.length;l<0&&(l=-l>M?0:M+l),m=m>M?M:m,m<0&&(m+=M),M=l>m?0:m-l>>>0,l>>>=0;for(var T=J(M);++D<M;)T[D]=o[D+l];return T}function lE(o,l){var m;return jn(o,function(D,M,T){return m=l(D,M,T),!m}),!!m}function ia(o,l,m){var D=0,M=o==null?D:o.length;if(typeof l=="number"&&l===l&&M<=at){for(;D<M;){var T=D+M>>>1,k=o[T];k!==null&&!Fr(k)&&(m?k<=l:k<l)?D=T+1:M=T}return M}return hl(o,l,pr,m)}function hl(o,l,m,D){var M=0,T=o==null?0:o.length;if(T===0)return 0;l=m(l);for(var k=l!==l,U=l===null,V=Fr(l),tt=l===e;M<T;){var et=Go((M+T)/2),ot=m(o[et]),pt=ot!==e,Dt=ot===null,Mt=ot===ot,Pt=Fr(ot);if(k)var Ft=D||Mt;else tt?Ft=Mt&&(D||pt):U?Ft=Mt&&pt&&(D||!Dt):V?Ft=Mt&&pt&&!Dt&&(D||!Pt):Dt||Pt?Ft=!1:Ft=D?ot<=l:ot<l;Ft?M=et+1:T=et}return rr(T,_t)}function od(o,l){for(var m=-1,D=o.length,M=0,T=[];++m<D;){var k=o[m],U=l?l(k):k;if(!m||!Xr(U,V)){var V=U;T[M++]=k===0?0:k}}return T}function ad(o){return typeof o=="number"?o:Fr(o)?Q:+o}function Mr(o){if(typeof o=="string")return o;if(It(o))return Ce(o,Mr)+"";if(Fr(o))return k0?k0.call(o):"";var l=o+"";return l=="0"&&1/o==-Z?"-0":l}function Yn(o,l,m){var D=-1,M=Ro,T=o.length,k=!0,U=[],V=U;if(m)k=!1,M=qu;else if(T>=n){var tt=l?null:wE(o);if(tt)return ko(tt);k=!1,M=ds,V=new di}else V=l?[]:U;t:for(;++D<T;){var et=o[D],ot=l?l(et):et;if(et=m||et!==0?et:0,k&&ot===ot){for(var pt=V.length;pt--;)if(V[pt]===ot)continue t;l&&V.push(ot),U.push(et)}else M(V,ot,m)||(V!==U&&V.push(ot),U.push(et))}return U}function dl(o,l){return l=Vn(l,o),o=$d(o,l),o==null||delete o[un(qr(l))]}function ud(o,l,m,D){return xs(o,l,m(pi(o,l)),D)}function sa(o,l,m,D){for(var M=o.length,T=D?M:-1;(D?T--:++T<M)&&l(o[T],T,o););return m?zr(o,D?0:T,D?T+1:M):zr(o,D?T+1:0,D?M:T)}function ld(o,l){var m=o;return m instanceof Yt&&(m=m.value()),Uu(l,function(D,M){return M.func.apply(M.thisArg,qn([D],M.args))},m)}function _l(o,l,m){var D=o.length;if(D<2)return D?Yn(o[0]):[];for(var M=-1,T=J(D);++M<D;)for(var k=o[M],U=-1;++U<D;)U!=M&&(T[M]=ws(T[M]||k,o[U],l,m));return Yn(Xe(T,1),l,m)}function cd(o,l,m){for(var D=-1,M=o.length,T=l.length,k={};++D<M;){var U=D<T?l[D]:e;m(k,o[D],U)}return k}function pl(o){return Be(o)?o:[]}function ml(o){return typeof o=="function"?o:pr}function Vn(o,l){return It(o)?o:Cl(o,l)?[o]:kd(ae(o))}var cE=kt;function Hn(o,l,m){var D=o.length;return m=m===e?D:m,!l&&m>=D?o:zr(o,l,m)}var fd=Jb||function(o){return Je.clearTimeout(o)};function hd(o,l){if(l)return o.slice();var m=o.length,D=T0?T0(m):new o.constructor(m);return o.copy(D),D}function gl(o){var l=new o.constructor(o.byteLength);return new Yo(l).set(new Yo(o)),l}function fE(o,l){var m=l?gl(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.byteLength)}function hE(o){var l=new o.constructor(o.source,Io.exec(o));return l.lastIndex=o.lastIndex,l}function dE(o){return vs?pe(vs.call(o)):{}}function dd(o,l){var m=l?gl(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.length)}function _d(o,l){if(o!==l){var m=o!==e,D=o===null,M=o===o,T=Fr(o),k=l!==e,U=l===null,V=l===l,tt=Fr(l);if(!U&&!tt&&!T&&o>l||T&&k&&V&&!U&&!tt||D&&k&&V||!m&&V||!M)return 1;if(!D&&!T&&!tt&&o<l||tt&&m&&M&&!D&&!T||U&&m&&M||!k&&M||!V)return-1}return 0}function _E(o,l,m){for(var D=-1,M=o.criteria,T=l.criteria,k=M.length,U=m.length;++D<k;){var V=_d(M[D],T[D]);if(V){if(D>=U)return V;var tt=m[D];return V*(tt=="desc"?-1:1)}}return o.index-l.index}function pd(o,l,m,D){for(var M=-1,T=o.length,k=m.length,U=-1,V=l.length,tt=We(T-k,0),et=J(V+tt),ot=!D;++U<V;)et[U]=l[U];for(;++M<k;)(ot||M<T)&&(et[m[M]]=o[M]);for(;tt--;)et[U++]=o[M++];return et}function md(o,l,m,D){for(var M=-1,T=o.length,k=-1,U=m.length,V=-1,tt=l.length,et=We(T-U,0),ot=J(et+tt),pt=!D;++M<et;)ot[M]=o[M];for(var Dt=M;++V<tt;)ot[Dt+V]=l[V];for(;++k<U;)(pt||M<T)&&(ot[Dt+m[k]]=o[M++]);return ot}function hr(o,l){var m=-1,D=o.length;for(l||(l=J(D));++m<D;)l[m]=o[m];return l}function an(o,l,m,D){var M=!m;m||(m={});for(var T=-1,k=l.length;++T<k;){var U=l[T],V=D?D(m[U],o[U],U,m,o):e;V===e&&(V=o[U]),M?wn(m,U,V):ys(m,U,V)}return m}function pE(o,l){return an(o,El(o),l)}function mE(o,l){return an(o,Nd(o),l)}function oa(o,l){return function(m,D){var M=It(m)?Db:Px,T=l?l():{};return M(m,o,At(D,2),T)}}function Ki(o){return kt(function(l,m){var D=-1,M=m.length,T=M>1?m[M-1]:e,k=M>2?m[2]:e;for(T=o.length>3&&typeof T=="function"?(M--,T):e,k&&ar(m[0],m[1],k)&&(T=M<3?e:T,M=1),l=pe(l);++D<M;){var U=m[D];U&&o(l,U,D,T)}return l})}function gd(o,l){return function(m,D){if(m==null)return m;if(!dr(m))return o(m,D);for(var M=m.length,T=l?M:-1,k=pe(m);(l?T--:++T<M)&&D(k[T],T,k)!==!1;);return m}}function vd(o){return function(l,m,D){for(var M=-1,T=pe(l),k=D(l),U=k.length;U--;){var V=k[o?U:++M];if(m(T[V],V,T)===!1)break}return l}}function gE(o,l,m){var D=l&w,M=Es(o);function T(){var k=this&&this!==Je&&this instanceof T?M:o;return k.apply(D?m:this,arguments)}return T}function yd(o){return function(l){l=ae(l);var m=Ui(l)?Gr(l):e,D=m?m[0]:l.charAt(0),M=m?Hn(m,1).join(""):l.slice(1);return D[o]()+M}}function Gi(o){return function(l){return Uu(g_(m_(l).replace(ab,"")),o,"")}}function Es(o){return function(){var l=arguments;switch(l.length){case 0:return new o;case 1:return new o(l[0]);case 2:return new o(l[0],l[1]);case 3:return new o(l[0],l[1],l[2]);case 4:return new o(l[0],l[1],l[2],l[3]);case 5:return new o(l[0],l[1],l[2],l[3],l[4]);case 6:return new o(l[0],l[1],l[2],l[3],l[4],l[5]);case 7:return new o(l[0],l[1],l[2],l[3],l[4],l[5],l[6])}var m=Zi(o.prototype),D=o.apply(m,l);return Fe(D)?D:m}}function vE(o,l,m){var D=Es(o);function M(){for(var T=arguments.length,k=J(T),U=T,V=Ji(M);U--;)k[U]=arguments[U];var tt=T<3&&k[0]!==V&&k[T-1]!==V?[]:Un(k,V);if(T-=tt.length,T<m)return Ed(o,l,aa,M.placeholder,e,k,tt,e,e,m-T);var et=this&&this!==Je&&this instanceof M?D:o;return Cr(et,this,k)}return M}function wd(o){return function(l,m,D){var M=pe(l);if(!dr(l)){var T=At(m,3);l=Ve(l),m=function(U){return T(M[U],U,M)}}var k=o(l,m,D);return k>-1?M[T?l[k]:k]:e}}function Dd(o){return bn(function(l){var m=l.length,D=m,M=Pr.prototype.thru;for(o&&l.reverse();D--;){var T=l[D];if(typeof T!="function")throw new Rr(a);if(M&&!k&&fa(T)=="wrapper")var k=new Pr([],!0)}for(D=k?D:m;++D<m;){T=l[D];var U=fa(T),V=U=="wrapper"?bl(T):e;V&&Al(V[0])&&V[1]==(N|b|E|S)&&!V[4].length&&V[9]==1?k=k[fa(V[0])].apply(k,V[3]):k=T.length==1&&Al(T)?k[U]():k.thru(T)}return function(){var tt=arguments,et=tt[0];if(k&&tt.length==1&&It(et))return k.plant(et).value();for(var ot=0,pt=m?l[ot].apply(this,tt):et;++ot<m;)pt=l[ot].call(this,pt);return pt}})}function aa(o,l,m,D,M,T,k,U,V,tt){var et=l&N,ot=l&w,pt=l&v,Dt=l&(b|C),Mt=l&I,Pt=pt?e:Es(o);function Ft(){for(var Ut=arguments.length,Ht=J(Ut),Nr=Ut;Nr--;)Ht[Nr]=arguments[Nr];if(Dt)var ur=Ji(Ft),Sr=Sb(Ht,ur);if(D&&(Ht=pd(Ht,D,M,Dt)),T&&(Ht=md(Ht,T,k,Dt)),Ut-=Sr,Dt&&Ut<tt){var Te=Un(Ht,ur);return Ed(o,l,aa,Ft.placeholder,m,Ht,Te,U,V,tt-Ut)}var Qr=ot?m:this,An=pt?Qr[o]:o;return Ut=Ht.length,U?Ht=PE(Ht,U):Mt&&Ut>1&&Ht.reverse(),et&&V<Ut&&(Ht.length=V),this&&this!==Je&&this instanceof Ft&&(An=Pt||Es(An)),An.apply(Qr,Ht)}return Ft}function bd(o,l){return function(m,D){return Vx(m,o,l(D),{})}}function ua(o,l){return function(m,D){var M;if(m===e&&D===e)return l;if(m!==e&&(M=m),D!==e){if(M===e)return D;typeof m=="string"||typeof D=="string"?(m=Mr(m),D=Mr(D)):(m=ad(m),D=ad(D)),M=o(m,D)}return M}}function vl(o){return bn(function(l){return l=Ce(l,Ar(At())),kt(function(m){var D=this;return o(l,function(M){return Cr(M,D,m)})})})}function la(o,l){l=l===e?" ":Mr(l);var m=l.length;if(m<2)return m?fl(l,o):l;var D=fl(l,Ko(o/Wi(l)));return Ui(l)?Hn(Gr(D),0,o).join(""):D.slice(0,o)}function yE(o,l,m,D){var M=l&w,T=Es(o);function k(){for(var U=-1,V=arguments.length,tt=-1,et=D.length,ot=J(et+V),pt=this&&this!==Je&&this instanceof k?T:o;++tt<et;)ot[tt]=D[tt];for(;V--;)ot[tt++]=arguments[++U];return Cr(pt,M?m:this,ot)}return k}function xd(o){return function(l,m,D){return D&&typeof D!="number"&&ar(l,m,D)&&(m=D=e),l=Cn(l),m===e?(m=l,l=0):m=Cn(m),D=D===e?l<m?1:-1:Cn(D),iE(l,m,D,o)}}function ca(o){return function(l,m){return typeof l=="string"&&typeof m=="string"||(l=Ur(l),m=Ur(m)),o(l,m)}}function Ed(o,l,m,D,M,T,k,U,V,tt){var et=l&b,ot=et?k:e,pt=et?e:k,Dt=et?T:e,Mt=et?e:T;l|=et?E:A,l&=~(et?A:E),l&x||(l&=~(w|v));var Pt=[o,l,M,Dt,ot,Mt,pt,U,V,tt],Ft=m.apply(e,Pt);return Al(o)&&Ld(Ft,Pt),Ft.placeholder=D,Rd(Ft,o,l)}function yl(o){var l=Ue[o];return function(m,D){if(m=Ur(m),D=D==null?0:rr(Lt(D),292),D&&R0(m)){var M=(ae(m)+"e").split("e"),T=l(M[0]+"e"+(+M[1]+D));return M=(ae(T)+"e").split("e"),+(M[0]+"e"+(+M[1]-D))}return l(m)}}var wE=Vi&&1/ko(new Vi([,-0]))[1]==Z?function(o){return new Vi(o)}:ql;function Cd(o){return function(l){var m=nr(l);return m==Xt?Ku(l):m==br?Rb(l):Nb(l,o(l))}}function Dn(o,l,m,D,M,T,k,U){var V=l&v;if(!V&&typeof o!="function")throw new Rr(a);var tt=D?D.length:0;if(tt||(l&=~(E|A),D=M=e),k=k===e?k:We(Lt(k),0),U=U===e?U:Lt(U),tt-=M?M.length:0,l&A){var et=D,ot=M;D=M=e}var pt=V?e:bl(o),Dt=[o,l,m,D,M,et,ot,T,k,U];if(pt&&$E(Dt,pt),o=Dt[0],l=Dt[1],m=Dt[2],D=Dt[3],M=Dt[4],U=Dt[9]=Dt[9]===e?V?0:o.length:We(Dt[9]-tt,0),!U&&l&(b|C)&&(l&=~(b|C)),!l||l==w)var Mt=gE(o,l,m);else l==b||l==C?Mt=vE(o,l,U):(l==E||l==(w|E))&&!M.length?Mt=yE(o,l,m,D):Mt=aa.apply(e,Dt);var Pt=pt?sd:Ld;return Rd(Pt(Mt,Dt),o,l)}function Ad(o,l,m,D){return o===e||Xr(o,Yi[m])&&!ce.call(D,m)?l:o}function Md(o,l,m,D,M,T){return Fe(o)&&Fe(l)&&(T.set(l,o),na(o,l,e,Md,T),T.delete(l)),o}function DE(o){return Ms(o)?e:o}function Fd(o,l,m,D,M,T){var k=m&y,U=o.length,V=l.length;if(U!=V&&!(k&&V>U))return!1;var tt=T.get(o),et=T.get(l);if(tt&&et)return tt==l&&et==o;var ot=-1,pt=!0,Dt=m&p?new di:e;for(T.set(o,l),T.set(l,o);++ot<U;){var Mt=o[ot],Pt=l[ot];if(D)var Ft=k?D(Pt,Mt,ot,l,o,T):D(Mt,Pt,ot,o,l,T);if(Ft!==e){if(Ft)continue;pt=!1;break}if(Dt){if(!Wu(l,function(Ut,Ht){if(!ds(Dt,Ht)&&(Mt===Ut||M(Mt,Ut,m,D,T)))return Dt.push(Ht)})){pt=!1;break}}else if(!(Mt===Pt||M(Mt,Pt,m,D,T))){pt=!1;break}}return T.delete(o),T.delete(l),pt}function bE(o,l,m,D,M,T,k){switch(m){case rt:if(o.byteLength!=l.byteLength||o.byteOffset!=l.byteOffset)return!1;o=o.buffer,l=l.buffer;case st:return!(o.byteLength!=l.byteLength||!T(new Yo(o),new Yo(l)));case re:case Bt:case Le:return Xr(+o,+l);case he:return o.name==l.name&&o.message==l.message;case gn:case Rn:return o==l+"";case Xt:var U=Ku;case br:var V=D&y;if(U||(U=ko),o.size!=l.size&&!V)return!1;var tt=k.get(o);if(tt)return tt==l;D|=p,k.set(o,l);var et=Fd(U(o),U(l),D,M,T,k);return k.delete(o),et;case P:if(vs)return vs.call(o)==vs.call(l)}return!1}function xE(o,l,m,D,M,T){var k=m&y,U=wl(o),V=U.length,tt=wl(l),et=tt.length;if(V!=et&&!k)return!1;for(var ot=V;ot--;){var pt=U[ot];if(!(k?pt in l:ce.call(l,pt)))return!1}var Dt=T.get(o),Mt=T.get(l);if(Dt&&Mt)return Dt==l&&Mt==o;var Pt=!0;T.set(o,l),T.set(l,o);for(var Ft=k;++ot<V;){pt=U[ot];var Ut=o[pt],Ht=l[pt];if(D)var Nr=k?D(Ht,Ut,pt,l,o,T):D(Ut,Ht,pt,o,l,T);if(!(Nr===e?Ut===Ht||M(Ut,Ht,m,D,T):Nr)){Pt=!1;break}Ft||(Ft=pt=="constructor")}if(Pt&&!Ft){var ur=o.constructor,Sr=l.constructor;ur!=Sr&&"constructor"in o&&"constructor"in l&&!(typeof ur=="function"&&ur instanceof ur&&typeof Sr=="function"&&Sr instanceof Sr)&&(Pt=!1)}return T.delete(o),T.delete(l),Pt}function bn(o){return Fl(Id(o,e,Wd),o+"")}function wl(o){return Z0(o,Ve,El)}function Dl(o){return Z0(o,_r,Nd)}var bl=Jo?function(o){return Jo.get(o)}:ql;function fa(o){for(var l=o.name+"",m=Hi[l],D=ce.call(Hi,l)?m.length:0;D--;){var M=m[D],T=M.func;if(T==null||T==o)return M.name}return l}function Ji(o){var l=ce.call(B,"placeholder")?B:o;return l.placeholder}function At(){var o=B.iteratee||kl;return o=o===kl?J0:o,arguments.length?o(arguments[0],arguments[1]):o}function ha(o,l){var m=o.__data__;return OE(l)?m[typeof l=="string"?"string":"hash"]:m.map}function xl(o){for(var l=Ve(o),m=l.length;m--;){var D=l[m],M=o[D];l[m]=[D,M,Bd(M)]}return l}function mi(o,l){var m=Ib(o,l);return G0(m)?m:e}function EE(o){var l=ce.call(o,fi),m=o[fi];try{o[fi]=e;var D=!0}catch{}var M=Wo.call(o);return D&&(l?o[fi]=m:delete o[fi]),M}var El=Ju?function(o){return o==null?[]:(o=pe(o),zn(Ju(o),function(l){return $0.call(o,l)}))}:Ul,Nd=Ju?function(o){for(var l=[];o;)qn(l,El(o)),o=Vo(o);return l}:Ul,nr=or;(Xu&&nr(new Xu(new ArrayBuffer(1)))!=rt||ps&&nr(new ps)!=Xt||Qu&&nr(Qu.resolve())!=mn||Vi&&nr(new Vi)!=br||ms&&nr(new ms)!=K)&&(nr=function(o){var l=or(o),m=l==ze?o.constructor:e,D=m?gi(m):"";if(D)switch(D){case ox:return rt;case ax:return Xt;case ux:return mn;case lx:return br;case cx:return K}return l});function CE(o,l,m){for(var D=-1,M=m.length;++D<M;){var T=m[D],k=T.size;switch(T.type){case"drop":o+=k;break;case"dropRight":l-=k;break;case"take":l=rr(l,o+k);break;case"takeRight":o=We(o,l-k);break}}return{start:o,end:l}}function AE(o){var l=o.match(Du);return l?l[1].split(bu):[]}function Sd(o,l,m){l=Vn(l,o);for(var D=-1,M=l.length,T=!1;++D<M;){var k=un(l[D]);if(!(T=o!=null&&m(o,k)))break;o=o[k]}return T||++D!=M?T:(M=o==null?0:o.length,!!M&&ya(M)&&xn(k,M)&&(It(o)||vi(o)))}function ME(o){var l=o.length,m=new o.constructor(l);return l&&typeof o[0]=="string"&&ce.call(o,"index")&&(m.index=o.index,m.input=o.input),m}function Od(o){return typeof o.constructor=="function"&&!Cs(o)?Zi(Vo(o)):{}}function FE(o,l,m){var D=o.constructor;switch(l){case st:return gl(o);case re:case Bt:return new D(+o);case rt:return fE(o,m);case ft:case ct:case ht:case lt:case Qt:case oe:case Ee:case Ye:case qe:return dd(o,m);case Xt:return new D;case Le:case Rn:return new D(o);case gn:return hE(o);case br:return new D;case P:return dE(o)}}function NE(o,l){var m=l.length;if(!m)return o;var D=m-1;return l[D]=(m>1?"& ":"")+l[D],l=l.join(m>2?", ":" "),o.replace(wu,`{
|
9
9
|
/* [wrapped with `+l+`] */
|
10
|
-
`)}function SE(o){return It(o)||vi(o)||!!(L0&&o&&o[L0])}function xn(o,l){var m=typeof o;return l=l??Y,!!l&&(m=="number"||m!="symbol"&&Ou.test(o))&&o>-1&&o%1==0&&o<l}function ar(o,l,m){if(!Fe(m))return!1;var D=typeof l;return(D=="number"?dr(m)&&xn(l,m.length):D=="string"&&l in m)?Xr(m[l],o):!1}function Cl(o,l){if(It(o))return!1;var m=typeof o;return m=="number"||m=="symbol"||m=="boolean"||o==null||Fr(o)?!0:mu.test(o)||!pu.test(o)||l!=null&&o in pe(l)}function OE(o){var l=typeof o;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?o!=="__proto__":o===null}function Al(o){var l=fa(o),m=B[l];if(typeof m!="function"||!(l in Yt.prototype))return!1;if(o===m)return!0;var D=bl(m);return!!D&&o===D[0]}function BE(o){return!!B0&&B0 in o}var TE=qo?En:Wl;function Cs(o){var l=o&&o.constructor,m=typeof l=="function"&&l.prototype||Yi;return o===m}function Bd(o){return o===o&&!Fe(o)}function Td(o,l){return function(m){return m==null?!1:m[o]===l&&(l!==e||o in pe(m))}}function IE(o){var l=ga(o,function(D){return m.size===f&&m.clear(),D}),m=l.cache;return l}function $E(o,l){var m=o[1],D=l[1],M=m|D,T=M<(w|v|N),k=D==N&&m==b||D==N&&m==S&&o[7].length<=l[8]||D==(N|S)&&l[7].length<=l[8]&&m==b;if(!(T||k))return o;D&w&&(o[2]=l[2],M|=m&w?0:x);var U=l[3];if(U){var V=o[3];o[3]=V?pd(V,U,l[4]):U,o[4]=V?Un(o[3],d):l[4]}return U=l[5],U&&(V=o[5],o[5]=V?md(V,U,l[6]):U,o[6]=V?Un(o[5],d):l[6]),U=l[7],U&&(o[7]=U),D&N&&(o[8]=o[8]==null?l[8]:rr(o[8],l[8])),o[9]==null&&(o[9]=l[9]),o[0]=l[0],o[1]=M,o}function LE(o){var l=[];if(o!=null)for(var m in pe(o))l.push(m);return l}function RE(o){return Wo.call(o)}function Id(o,l,m){return l=We(l===e?o.length-1:l,0),function(){for(var D=arguments,M=-1,T=We(D.length-l,0),k=J(T);++M<T;)k[M]=D[l+M];M=-1;for(var U=J(l+1);++M<l;)U[M]=D[M];return U[l]=m(k),Cr(o,this,U)}}function $d(o,l){return l.length<2?o:pi(o,zr(l,0,-1))}function PE(o,l){for(var m=o.length,D=rr(l.length,m),M=hr(o);D--;){var T=l[D];o[D]=xn(T,m)?M[T]:e}return o}function Ml(o,l){if(!(l==="constructor"&&typeof o[l]=="function")&&l!="__proto__")return o[l]}var Ld=Pd(sd),As=Qb||function(o,l){return Je.setTimeout(o,l)},Fl=Pd(aE);function Rd(o,l,m){var D=l+"";return Fl(o,NE(D,kE(AE(D),m)))}function Pd(o){var l=0,m=0;return function(){var D=nx(),M=z-(D-m);if(m=D,M>0){if(++l>=L)return arguments[0]}else l=0;return o.apply(e,arguments)}}function da(o,l){var m=-1,D=o.length,M=D-1;for(l=l===e?D:l;++m<l;){var T=cl(m,M),k=o[T];o[T]=o[m],o[m]=k}return o.length=l,o}var kd=IE(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(gu,function(m,D,M,T){l.push(M?T.replace(Cu,"$1"):D||m)}),l});function un(o){if(typeof o=="string"||Fr(o))return o;var l=o+"";return l=="0"&&1/o==-Z?"-0":l}function gi(o){if(o!=null){try{return Uo.call(o)}catch{}try{return o+""}catch{}}return""}function kE(o,l){return Lr(vt,function(m){var D="_."+m[0];l&m[1]&&!Ro(o,D)&&o.push(D)}),o.sort()}function zd(o){if(o instanceof Yt)return o.clone();var l=new Pr(o.__wrapped__,o.__chain__);return l.__actions__=hr(o.__actions__),l.__index__=o.__index__,l.__values__=o.__values__,l}function zE(o,l,m){(m?ar(o,l,m):l===e)?l=1:l=We(Lt(l),0);var D=o==null?0:o.length;if(!D||l<1)return[];for(var M=0,T=0,k=J(Ko(D/l));M<D;)k[T++]=zr(o,M,M+=l);return k}function qE(o){for(var l=-1,m=o==null?0:o.length,D=0,M=[];++l<m;){var T=o[l];T&&(M[D++]=T)}return M}function UE(){var o=arguments.length;if(!o)return[];for(var l=J(o-1),m=arguments[0],D=o;D--;)l[D-1]=arguments[D];return qn(It(m)?hr(m):[m],Xe(l,1))}var WE=kt(function(o,l){return Be(o)?ws(o,Xe(l,1,Be,!0)):[]}),jE=kt(function(o,l){var m=qr(l);return Be(m)&&(m=e),Be(o)?ws(o,Xe(l,1,Be,!0),At(m,2)):[]}),YE=kt(function(o,l){var m=qr(l);return Be(m)&&(m=e),Be(o)?ws(o,Xe(l,1,Be,!0),e,m):[]});function VE(o,l,m){var D=o==null?0:o.length;return D?(l=m||l===e?1:Lt(l),zr(o,l<0?0:l,D)):[]}function HE(o,l,m){var D=o==null?0:o.length;return D?(l=m||l===e?1:Lt(l),l=D-l,zr(o,0,l<0?0:l)):[]}function ZE(o,l){return o&&o.length?sa(o,At(l,3),!0,!0):[]}function KE(o,l){return o&&o.length?sa(o,At(l,3),!0):[]}function GE(o,l,m,D){var M=o==null?0:o.length;return M?(m&&typeof m!="number"&&ar(o,l,m)&&(m=0,D=M),Ux(o,l,m,D)):[]}function qd(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=m==null?0:Lt(m);return M<0&&(M=We(D+M,0)),Po(o,At(l,3),M)}function Ud(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=D-1;return m!==e&&(M=Lt(m),M=m<0?We(D+M,0):rr(M,D-1)),Po(o,At(l,3),M,!0)}function Wd(o){var l=o==null?0:o.length;return l?Xe(o,1):[]}function JE(o){var l=o==null?0:o.length;return l?Xe(o,Z):[]}function XE(o,l){var m=o==null?0:o.length;return m?(l=l===e?1:Lt(l),Xe(o,l)):[]}function QE(o){for(var l=-1,m=o==null?0:o.length,D={};++l<m;){var M=o[l];D[M[0]]=M[1]}return D}function jd(o){return o&&o.length?o[0]:e}function tC(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=m==null?0:Lt(m);return M<0&&(M=We(D+M,0)),qi(o,l,M)}function eC(o){var l=o==null?0:o.length;return l?zr(o,0,-1):[]}var rC=kt(function(o){var l=Ce(o,pl);return l.length&&l[0]===o[0]?sl(l):[]}),nC=kt(function(o){var l=qr(o),m=Ce(o,pl);return l===qr(m)?l=e:m.pop(),m.length&&m[0]===o[0]?sl(m,At(l,2)):[]}),iC=kt(function(o){var l=qr(o),m=Ce(o,pl);return l=typeof l=="function"?l:e,l&&m.pop(),m.length&&m[0]===o[0]?sl(m,e,l):[]});function sC(o,l){return o==null?"":ex.call(o,l)}function qr(o){var l=o==null?0:o.length;return l?o[l-1]:e}function oC(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=D;return m!==e&&(M=Lt(m),M=M<0?We(D+M,0):rr(M,D-1)),l===l?kb(o,l,M):Po(o,E0,M,!0)}function aC(o,l){return o&&o.length?ed(o,Lt(l)):e}var uC=kt(Yd);function Yd(o,l){return o&&o.length&&l&&l.length?ll(o,l):o}function lC(o,l,m){return o&&o.length&&l&&l.length?ll(o,l,At(m,2)):o}function cC(o,l,m){return o&&o.length&&l&&l.length?ll(o,l,e,m):o}var fC=bn(function(o,l){var m=o==null?0:o.length,D=el(o,l);return id(o,Ce(l,function(M){return xn(M,m)?+M:M}).sort(_d)),D});function hC(o,l){var m=[];if(!(o&&o.length))return m;var D=-1,M=[],T=o.length;for(l=At(l,3);++D<T;){var k=o[D];l(k,D,o)&&(m.push(k),M.push(D))}return id(o,M),m}function Nl(o){return o==null?o:sx.call(o)}function dC(o,l,m){var D=o==null?0:o.length;return D?(m&&typeof m!="number"&&ar(o,l,m)?(l=0,m=D):(l=l==null?0:Lt(l),m=m===e?D:Lt(m)),zr(o,l,m)):[]}function _C(o,l){return ia(o,l)}function pC(o,l,m){return hl(o,l,At(m,2))}function mC(o,l){var m=o==null?0:o.length;if(m){var D=ia(o,l);if(D<m&&Xr(o[D],l))return D}return-1}function gC(o,l){return ia(o,l,!0)}function vC(o,l,m){return hl(o,l,At(m,2),!0)}function yC(o,l){var m=o==null?0:o.length;if(m){var D=ia(o,l,!0)-1;if(Xr(o[D],l))return D}return-1}function wC(o){return o&&o.length?od(o):[]}function DC(o,l){return o&&o.length?od(o,At(l,2)):[]}function bC(o){var l=o==null?0:o.length;return l?zr(o,1,l):[]}function xC(o,l,m){return o&&o.length?(l=m||l===e?1:Lt(l),zr(o,0,l<0?0:l)):[]}function EC(o,l,m){var D=o==null?0:o.length;return D?(l=m||l===e?1:Lt(l),l=D-l,zr(o,l<0?0:l,D)):[]}function CC(o,l){return o&&o.length?sa(o,At(l,3),!1,!0):[]}function AC(o,l){return o&&o.length?sa(o,At(l,3)):[]}var MC=kt(function(o){return Yn(Xe(o,1,Be,!0))}),FC=kt(function(o){var l=qr(o);return Be(l)&&(l=e),Yn(Xe(o,1,Be,!0),At(l,2))}),NC=kt(function(o){var l=qr(o);return l=typeof l=="function"?l:e,Yn(Xe(o,1,Be,!0),e,l)});function SC(o){return o&&o.length?Yn(o):[]}function OC(o,l){return o&&o.length?Yn(o,At(l,2)):[]}function BC(o,l){return l=typeof l=="function"?l:e,o&&o.length?Yn(o,e,l):[]}function Sl(o){if(!(o&&o.length))return[];var l=0;return o=zn(o,function(m){if(Be(m))return l=We(m.length,l),!0}),Hu(l,function(m){return Ce(o,ju(m))})}function Vd(o,l){if(!(o&&o.length))return[];var m=Sl(o);return l==null?m:Ce(m,function(D){return Cr(l,e,D)})}var TC=kt(function(o,l){return Be(o)?ws(o,l):[]}),IC=kt(function(o){return _l(zn(o,Be))}),$C=kt(function(o){var l=qr(o);return Be(l)&&(l=e),_l(zn(o,Be),At(l,2))}),LC=kt(function(o){var l=qr(o);return l=typeof l=="function"?l:e,_l(zn(o,Be),e,l)}),RC=kt(Sl);function PC(o,l){return cd(o||[],l||[],ys)}function kC(o,l){return cd(o||[],l||[],xs)}var zC=kt(function(o){var l=o.length,m=l>1?o[l-1]:e;return m=typeof m=="function"?(o.pop(),m):e,Vd(o,m)});function Hd(o){var l=B(o);return l.__chain__=!0,l}function qC(o,l){return l(o),o}function _a(o,l){return l(o)}var UC=bn(function(o){var l=o.length,m=l?o[0]:0,D=this.__wrapped__,M=function(T){return el(T,o)};return l>1||this.__actions__.length||!(D instanceof Yt)||!xn(m)?this.thru(M):(D=D.slice(m,+m+(l?1:0)),D.__actions__.push({func:_a,args:[M],thisArg:e}),new Pr(D,this.__chain__).thru(function(T){return l&&!T.length&&T.push(e),T}))});function WC(){return Hd(this)}function jC(){return new Pr(this.value(),this.__chain__)}function YC(){this.__values__===e&&(this.__values__=a_(this.value()));var o=this.__index__>=this.__values__.length,l=o?e:this.__values__[this.__index__++];return{done:o,value:l}}function VC(){return this}function HC(o){for(var l,m=this;m instanceof Qo;){var D=zd(m);D.__index__=0,D.__values__=e,l?M.__wrapped__=D:l=D;var M=D;m=m.__wrapped__}return M.__wrapped__=o,l}function ZC(){var o=this.__wrapped__;if(o instanceof Yt){var l=o;return this.__actions__.length&&(l=new Yt(this)),l=l.reverse(),l.__actions__.push({func:_a,args:[Nl],thisArg:e}),new Pr(l,this.__chain__)}return this.thru(Nl)}function KC(){return ld(this.__wrapped__,this.__actions__)}var GC=oa(function(o,l,m){ce.call(o,m)?++o[m]:wn(o,m,1)});function JC(o,l,m){var D=It(o)?b0:qx;return m&&ar(o,l,m)&&(l=e),D(o,At(l,3))}function XC(o,l){var m=It(o)?zn:V0;return m(o,At(l,3))}var QC=wd(qd),tA=wd(Ud);function eA(o,l){return Xe(pa(o,l),1)}function rA(o,l){return Xe(pa(o,l),Z)}function nA(o,l,m){return m=m===e?1:Lt(m),Xe(pa(o,l),m)}function Zd(o,l){var m=It(o)?Lr:jn;return m(o,At(l,3))}function Kd(o,l){var m=It(o)?bb:Y0;return m(o,At(l,3))}var iA=oa(function(o,l,m){ce.call(o,m)?o[m].push(l):wn(o,m,[l])});function sA(o,l,m,D){o=dr(o)?o:Qi(o),m=m&&!D?Lt(m):0;var M=o.length;return m<0&&(m=We(M+m,0)),wa(o)?m<=M&&o.indexOf(l,m)>-1:!!M&&qi(o,l,m)>-1}var oA=kt(function(o,l,m){var D=-1,M=typeof l=="function",T=dr(o)?J(o.length):[];return jn(o,function(k){T[++D]=M?Cr(l,k,m):Ds(k,l,m)}),T}),aA=oa(function(o,l,m){wn(o,m,l)});function pa(o,l){var m=It(o)?Ce:X0;return m(o,At(l,3))}function uA(o,l,m,D){return o==null?[]:(It(l)||(l=l==null?[]:[l]),m=D?e:m,It(m)||(m=m==null?[]:[m]),rd(o,l,m))}var lA=oa(function(o,l,m){o[m?0:1].push(l)},function(){return[[],[]]});function cA(o,l,m){var D=It(o)?Uu:A0,M=arguments.length<3;return D(o,At(l,4),m,M,jn)}function fA(o,l,m){var D=It(o)?xb:A0,M=arguments.length<3;return D(o,At(l,4),m,M,Y0)}function hA(o,l){var m=It(o)?zn:V0;return m(o,va(At(l,3)))}function dA(o){var l=It(o)?q0:sE;return l(o)}function _A(o,l,m){(m?ar(o,l,m):l===e)?l=1:l=Lt(l);var D=It(o)?Lx:oE;return D(o,l)}function pA(o){var l=It(o)?Rx:uE;return l(o)}function mA(o){if(o==null)return 0;if(dr(o))return wa(o)?Wi(o):o.length;var l=nr(o);return l==Xt||l==br?o.size:al(o).length}function gA(o,l,m){var D=It(o)?Wu:lE;return m&&ar(o,l,m)&&(l=e),D(o,At(l,3))}var vA=kt(function(o,l){if(o==null)return[];var m=l.length;return m>1&&ar(o,l[0],l[1])?l=[]:m>2&&ar(l[0],l[1],l[2])&&(l=[l[0]]),rd(o,Xe(l,1),[])}),ma=Xb||function(){return Je.Date.now()};function yA(o,l){if(typeof l!="function")throw new Rr(a);return o=Lt(o),function(){if(--o<1)return l.apply(this,arguments)}}function Gd(o,l,m){return l=m?e:l,l=o&&l==null?o.length:l,Dn(o,N,e,e,e,e,l)}function Jd(o,l){var m;if(typeof l!="function")throw new Rr(a);return o=Lt(o),function(){return--o>0&&(m=l.apply(this,arguments)),o<=1&&(l=e),m}}var Ol=kt(function(o,l,m){var D=w;if(m.length){var M=Un(m,Ji(Ol));D|=E}return Dn(o,D,l,m,M)}),Xd=kt(function(o,l,m){var D=w|v;if(m.length){var M=Un(m,Ji(Xd));D|=E}return Dn(l,D,o,m,M)});function Qd(o,l,m){l=m?e:l;var D=Dn(o,b,e,e,e,e,e,l);return D.placeholder=Qd.placeholder,D}function t_(o,l,m){l=m?e:l;var D=Dn(o,C,e,e,e,e,e,l);return D.placeholder=t_.placeholder,D}function e_(o,l,m){var D,M,T,k,U,V,tt=0,et=!1,ot=!1,pt=!0;if(typeof o!="function")throw new Rr(a);l=Ur(l)||0,Fe(m)&&(et=!!m.leading,ot="maxWait"in m,T=ot?We(Ur(m.maxWait)||0,l):T,pt="trailing"in m?!!m.trailing:pt);function Dt(Te){var Qr=D,An=M;return D=M=e,tt=Te,k=o.apply(An,Qr),k}function Mt(Te){return tt=Te,U=As(Ut,l),et?Dt(Te):k}function Pt(Te){var Qr=Te-V,An=Te-tt,w_=l-Qr;return ot?rr(w_,T-An):w_}function Ft(Te){var Qr=Te-V,An=Te-tt;return V===e||Qr>=l||Qr<0||ot&&An>=T}function Ut(){var Te=ma();if(Ft(Te))return Ht(Te);U=As(Ut,Pt(Te))}function Ht(Te){return U=e,pt&&D?Dt(Te):(D=M=e,k)}function Nr(){U!==e&&fd(U),tt=0,D=V=M=U=e}function ur(){return U===e?k:Ht(ma())}function Sr(){var Te=ma(),Qr=Ft(Te);if(D=arguments,M=this,V=Te,Qr){if(U===e)return Mt(V);if(ot)return fd(U),U=As(Ut,l),Dt(V)}return U===e&&(U=As(Ut,l)),k}return Sr.cancel=Nr,Sr.flush=ur,Sr}var wA=kt(function(o,l){return j0(o,1,l)}),DA=kt(function(o,l,m){return j0(o,Ur(l)||0,m)});function bA(o){return Dn(o,I)}function ga(o,l){if(typeof o!="function"||l!=null&&typeof l!="function")throw new Rr(a);var m=function(){var D=arguments,M=l?l.apply(this,D):D[0],T=m.cache;if(T.has(M))return T.get(M);var k=o.apply(this,D);return m.cache=T.set(M,k)||T,k};return m.cache=new(ga.Cache||yn),m}ga.Cache=yn;function va(o){if(typeof o!="function")throw new Rr(a);return function(){var l=arguments;switch(l.length){case 0:return!o.call(this);case 1:return!o.call(this,l[0]);case 2:return!o.call(this,l[0],l[1]);case 3:return!o.call(this,l[0],l[1],l[2])}return!o.apply(this,l)}}function xA(o){return Jd(2,o)}var EA=cE(function(o,l){l=l.length==1&&It(l[0])?Ce(l[0],Ar(At())):Ce(Xe(l,1),Ar(At()));var m=l.length;return kt(function(D){for(var M=-1,T=rr(D.length,m);++M<T;)D[M]=l[M].call(this,D[M]);return Cr(o,this,D)})}),Bl=kt(function(o,l){var m=Un(l,Ji(Bl));return Dn(o,E,e,l,m)}),r_=kt(function(o,l){var m=Un(l,Ji(r_));return Dn(o,A,e,l,m)}),CA=bn(function(o,l){return Dn(o,S,e,e,e,l)});function AA(o,l){if(typeof o!="function")throw new Rr(a);return l=l===e?l:Lt(l),kt(o,l)}function MA(o,l){if(typeof o!="function")throw new Rr(a);return l=l==null?0:We(Lt(l),0),kt(function(m){var D=m[l],M=Hn(m,0,l);return D&&qn(M,D),Cr(o,this,M)})}function FA(o,l,m){var D=!0,M=!0;if(typeof o!="function")throw new Rr(a);return Fe(m)&&(D="leading"in m?!!m.leading:D,M="trailing"in m?!!m.trailing:M),e_(o,l,{leading:D,maxWait:l,trailing:M})}function NA(o){return Gd(o,1)}function SA(o,l){return Bl(ml(l),o)}function OA(){if(!arguments.length)return[];var o=arguments[0];return It(o)?o:[o]}function BA(o){return kr(o,g)}function TA(o,l){return l=typeof l=="function"?l:e,kr(o,g,l)}function IA(o){return kr(o,h|g)}function $A(o,l){return l=typeof l=="function"?l:e,kr(o,h|g,l)}function LA(o,l){return l==null||W0(o,l,Ve(l))}function Xr(o,l){return o===l||o!==o&&l!==l}var RA=ca(il),PA=ca(function(o,l){return o>=l}),vi=K0(function(){return arguments}())?K0:function(o){return Ne(o)&&ce.call(o,"callee")&&!$0.call(o,"callee")},It=J.isArray,kA=m0?Ar(m0):Hx;function dr(o){return o!=null&&ya(o.length)&&!En(o)}function Be(o){return Ne(o)&&dr(o)}function zA(o){return o===!0||o===!1||Ne(o)&&or(o)==re}var Zn=tx||Wl,qA=g0?Ar(g0):Zx;function UA(o){return Ne(o)&&o.nodeType===1&&!Ms(o)}function WA(o){if(o==null)return!0;if(dr(o)&&(It(o)||typeof o=="string"||typeof o.splice=="function"||Zn(o)||Xi(o)||vi(o)))return!o.length;var l=nr(o);if(l==Xt||l==br)return!o.size;if(Cs(o))return!al(o).length;for(var m in o)if(ce.call(o,m))return!1;return!0}function jA(o,l){return bs(o,l)}function YA(o,l,m){m=typeof m=="function"?m:e;var D=m?m(o,l):e;return D===e?bs(o,l,e,m):!!D}function Tl(o){if(!Ne(o))return!1;var l=or(o);return l==he||l==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!Ms(o)}function VA(o){return typeof o=="number"&&R0(o)}function En(o){if(!Fe(o))return!1;var l=or(o);return l==se||l==qt||l==bt||l==Ln}function n_(o){return typeof o=="number"&&o==Lt(o)}function ya(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Y}function Fe(o){var l=typeof o;return o!=null&&(l=="object"||l=="function")}function Ne(o){return o!=null&&typeof o=="object"}var i_=v0?Ar(v0):Gx;function HA(o,l){return o===l||ol(o,l,xl(l))}function ZA(o,l,m){return m=typeof m=="function"?m:e,ol(o,l,xl(l),m)}function KA(o){return s_(o)&&o!=+o}function GA(o){if(TE(o))throw new Tt(s);return G0(o)}function JA(o){return o===null}function XA(o){return o==null}function s_(o){return typeof o=="number"||Ne(o)&&or(o)==Le}function Ms(o){if(!Ne(o)||or(o)!=ze)return!1;var l=Vo(o);if(l===null)return!0;var m=ce.call(l,"constructor")&&l.constructor;return typeof m=="function"&&m instanceof m&&Uo.call(m)==Zb}var Il=y0?Ar(y0):Jx;function QA(o){return n_(o)&&o>=-Y&&o<=Y}var o_=w0?Ar(w0):Xx;function wa(o){return typeof o=="string"||!It(o)&&Ne(o)&&or(o)==Rn}function Fr(o){return typeof o=="symbol"||Ne(o)&&or(o)==R}var Xi=D0?Ar(D0):Qx;function tM(o){return o===e}function eM(o){return Ne(o)&&nr(o)==K}function rM(o){return Ne(o)&&or(o)==nt}var nM=ca(ul),iM=ca(function(o,l){return o<=l});function a_(o){if(!o)return[];if(dr(o))return wa(o)?Gr(o):hr(o);if(_s&&o[_s])return Lb(o[_s]());var l=nr(o),m=l==Xt?Ku:l==br?ko:Qi;return m(o)}function Cn(o){if(!o)return o===0?o:0;if(o=Ur(o),o===Z||o===-Z){var l=o<0?-1:1;return l*G}return o===o?o:0}function Lt(o){var l=Cn(o),m=l%1;return l===l?m?l-m:l:0}function u_(o){return o?_i(Lt(o),0,ut):0}function Ur(o){if(typeof o=="number")return o;if(Fr(o))return X;if(Fe(o)){var l=typeof o.valueOf=="function"?o.valueOf():o;o=Fe(l)?l+"":l}if(typeof o!="string")return o===0?o:+o;o=M0(o);var m=Fu.test(o);return m||Su.test(o)?yb(o.slice(2),m?2:8):Mu.test(o)?X:+o}function l_(o){return an(o,_r(o))}function sM(o){return o?_i(Lt(o),-Y,Y):o===0?o:0}function ae(o){return o==null?"":Mr(o)}var oM=Ki(function(o,l){if(Cs(l)||dr(l)){an(l,Ve(l),o);return}for(var m in l)ce.call(l,m)&&ys(o,m,l[m])}),c_=Ki(function(o,l){an(l,_r(l),o)}),Da=Ki(function(o,l,m,D){an(l,_r(l),o,D)}),aM=Ki(function(o,l,m,D){an(l,Ve(l),o,D)}),uM=bn(el);function lM(o,l){var m=Zi(o);return l==null?m:U0(m,l)}var cM=kt(function(o,l){o=pe(o);var m=-1,D=l.length,M=D>2?l[2]:e;for(M&&ar(l[0],l[1],M)&&(D=1);++m<D;)for(var T=l[m],k=_r(T),U=-1,V=k.length;++U<V;){var tt=k[U],et=o[tt];(et===e||Xr(et,Yi[tt])&&!ce.call(o,tt))&&(o[tt]=T[tt])}return o}),fM=kt(function(o){return o.push(e,Md),Cr(f_,e,o)});function hM(o,l){return x0(o,At(l,3),on)}function dM(o,l){return x0(o,At(l,3),nl)}function _M(o,l){return o==null?o:rl(o,At(l,3),_r)}function pM(o,l){return o==null?o:H0(o,At(l,3),_r)}function mM(o,l){return o&&on(o,At(l,3))}function gM(o,l){return o&&nl(o,At(l,3))}function vM(o){return o==null?[]:ra(o,Ve(o))}function yM(o){return o==null?[]:ra(o,_r(o))}function $l(o,l,m){var D=o==null?e:pi(o,l);return D===e?m:D}function wM(o,l){return o!=null&&Sd(o,l,Wx)}function Ll(o,l){return o!=null&&Sd(o,l,jx)}var DM=bd(function(o,l,m){l!=null&&typeof l.toString!="function"&&(l=Wo.call(l)),o[l]=m},Pl(pr)),bM=bd(function(o,l,m){l!=null&&typeof l.toString!="function"&&(l=Wo.call(l)),ce.call(o,l)?o[l].push(m):o[l]=[m]},At),xM=kt(Ds);function Ve(o){return dr(o)?z0(o):al(o)}function _r(o){return dr(o)?z0(o,!0):tE(o)}function EM(o,l){var m={};return l=At(l,3),on(o,function(D,M,T){wn(m,l(D,M,T),D)}),m}function CM(o,l){var m={};return l=At(l,3),on(o,function(D,M,T){wn(m,M,l(D,M,T))}),m}var AM=Ki(function(o,l,m){na(o,l,m)}),f_=Ki(function(o,l,m,D){na(o,l,m,D)}),MM=bn(function(o,l){var m={};if(o==null)return m;var D=!1;l=Ce(l,function(T){return T=Vn(T,o),D||(D=T.length>1),T}),an(o,Dl(o),m),D&&(m=kr(m,h|_|g,DE));for(var M=l.length;M--;)dl(m,l[M]);return m});function FM(o,l){return h_(o,va(At(l)))}var NM=bn(function(o,l){return o==null?{}:rE(o,l)});function h_(o,l){if(o==null)return{};var m=Ce(Dl(o),function(D){return[D]});return l=At(l),nd(o,m,function(D,M){return l(D,M[0])})}function SM(o,l,m){l=Vn(l,o);var D=-1,M=l.length;for(M||(M=1,o=e);++D<M;){var T=o==null?e:o[un(l[D])];T===e&&(D=M,T=m),o=En(T)?T.call(o):T}return o}function OM(o,l,m){return o==null?o:xs(o,l,m)}function BM(o,l,m,D){return D=typeof D=="function"?D:e,o==null?o:xs(o,l,m,D)}var d_=Cd(Ve),__=Cd(_r);function TM(o,l,m){var D=It(o),M=D||Zn(o)||Xi(o);if(l=At(l,4),m==null){var T=o&&o.constructor;M?m=D?new T:[]:Fe(o)?m=En(T)?Zi(Vo(o)):{}:m={}}return(M?Lr:on)(o,function(k,U,V){return l(m,k,U,V)}),m}function IM(o,l){return o==null?!0:dl(o,l)}function $M(o,l,m){return o==null?o:ud(o,l,ml(m))}function LM(o,l,m,D){return D=typeof D=="function"?D:e,o==null?o:ud(o,l,ml(m),D)}function Qi(o){return o==null?[]:Zu(o,Ve(o))}function RM(o){return o==null?[]:Zu(o,_r(o))}function PM(o,l,m){return m===e&&(m=l,l=e),m!==e&&(m=Ur(m),m=m===m?m:0),l!==e&&(l=Ur(l),l=l===l?l:0),_i(Ur(o),l,m)}function kM(o,l,m){return l=Cn(l),m===e?(m=l,l=0):m=Cn(m),o=Ur(o),Yx(o,l,m)}function zM(o,l,m){if(m&&typeof m!="boolean"&&ar(o,l,m)&&(l=m=e),m===e&&(typeof l=="boolean"?(m=l,l=e):typeof o=="boolean"&&(m=o,o=e)),o===e&&l===e?(o=0,l=1):(o=Cn(o),l===e?(l=o,o=0):l=Cn(l)),o>l){var D=o;o=l,l=D}if(m||o%1||l%1){var M=P0();return rr(o+M*(l-o+vb("1e-"+((M+"").length-1))),l)}return cl(o,l)}var qM=Gi(function(o,l,m){return l=l.toLowerCase(),o+(m?p_(l):l)});function p_(o){return Rl(ae(o).toLowerCase())}function m_(o){return o=ae(o),o&&o.replace(Bu,Ob).replace(ub,"")}function UM(o,l,m){o=ae(o),l=Mr(l);var D=o.length;m=m===e?D:_i(Lt(m),0,D);var M=m;return m-=l.length,m>=0&&o.slice(m,M)==l}function WM(o){return o=ae(o),o&&hu.test(o)?o.replace(Bo,Bb):o}function jM(o){return o=ae(o),o&&vu.test(o)?o.replace(fs,"\\$&"):o}var YM=Gi(function(o,l,m){return o+(m?"-":"")+l.toLowerCase()}),VM=Gi(function(o,l,m){return o+(m?" ":"")+l.toLowerCase()}),HM=yd("toLowerCase");function ZM(o,l,m){o=ae(o),l=Lt(l);var D=l?Wi(o):0;if(!l||D>=l)return o;var M=(l-D)/2;return la(Go(M),m)+o+la(Ko(M),m)}function KM(o,l,m){o=ae(o),l=Lt(l);var D=l?Wi(o):0;return l&&D<l?o+la(l-D,m):o}function GM(o,l,m){o=ae(o),l=Lt(l);var D=l?Wi(o):0;return l&&D<l?la(l-D,m)+o:o}function JM(o,l,m){return m||l==null?l=0:l&&(l=+l),ix(ae(o).replace(hs,""),l||0)}function XM(o,l,m){return(m?ar(o,l,m):l===e)?l=1:l=Lt(l),fl(ae(o),l)}function QM(){var o=arguments,l=ae(o[0]);return o.length<3?l:l.replace(o[1],o[2])}var t2=Gi(function(o,l,m){return o+(m?"_":"")+l.toLowerCase()});function e2(o,l,m){return m&&typeof m!="number"&&ar(o,l,m)&&(l=m=e),m=m===e?ut:m>>>0,m?(o=ae(o),o&&(typeof l=="string"||l!=null&&!Il(l))&&(l=Mr(l),!l&&Ui(o))?Hn(Gr(o),0,m):o.split(l,m)):[]}var r2=Gi(function(o,l,m){return o+(m?" ":"")+Rl(l)});function n2(o,l,m){return o=ae(o),m=m==null?0:_i(Lt(m),0,o.length),l=Mr(l),o.slice(m,m+l.length)==l}function i2(o,l,m){var D=B.templateSettings;m&&ar(o,l,m)&&(l=e),o=ae(o),l=Da({},l,D,Ad);var M=Da({},l.imports,D.imports,Ad),T=Ve(M),k=Zu(M,T),U,V,tt=0,et=l.interpolate||Pi,ot="__p += '",pt=Gu((l.escape||Pi).source+"|"+et.source+"|"+(et===To?Au:Pi).source+"|"+(l.evaluate||Pi).source+"|$","g"),Dt="//# sourceURL="+(ce.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++db+"]")+`
|
10
|
+
`)}function SE(o){return It(o)||vi(o)||!!(L0&&o&&o[L0])}function xn(o,l){var m=typeof o;return l=l??Y,!!l&&(m=="number"||m!="symbol"&&Ou.test(o))&&o>-1&&o%1==0&&o<l}function ar(o,l,m){if(!Fe(m))return!1;var D=typeof l;return(D=="number"?dr(m)&&xn(l,m.length):D=="string"&&l in m)?Xr(m[l],o):!1}function Cl(o,l){if(It(o))return!1;var m=typeof o;return m=="number"||m=="symbol"||m=="boolean"||o==null||Fr(o)?!0:mu.test(o)||!pu.test(o)||l!=null&&o in pe(l)}function OE(o){var l=typeof o;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?o!=="__proto__":o===null}function Al(o){var l=fa(o),m=B[l];if(typeof m!="function"||!(l in Yt.prototype))return!1;if(o===m)return!0;var D=bl(m);return!!D&&o===D[0]}function BE(o){return!!B0&&B0 in o}var TE=qo?En:Wl;function Cs(o){var l=o&&o.constructor,m=typeof l=="function"&&l.prototype||Yi;return o===m}function Bd(o){return o===o&&!Fe(o)}function Td(o,l){return function(m){return m==null?!1:m[o]===l&&(l!==e||o in pe(m))}}function IE(o){var l=ga(o,function(D){return m.size===f&&m.clear(),D}),m=l.cache;return l}function $E(o,l){var m=o[1],D=l[1],M=m|D,T=M<(w|v|N),k=D==N&&m==b||D==N&&m==S&&o[7].length<=l[8]||D==(N|S)&&l[7].length<=l[8]&&m==b;if(!(T||k))return o;D&w&&(o[2]=l[2],M|=m&w?0:x);var U=l[3];if(U){var V=o[3];o[3]=V?pd(V,U,l[4]):U,o[4]=V?Un(o[3],d):l[4]}return U=l[5],U&&(V=o[5],o[5]=V?md(V,U,l[6]):U,o[6]=V?Un(o[5],d):l[6]),U=l[7],U&&(o[7]=U),D&N&&(o[8]=o[8]==null?l[8]:rr(o[8],l[8])),o[9]==null&&(o[9]=l[9]),o[0]=l[0],o[1]=M,o}function LE(o){var l=[];if(o!=null)for(var m in pe(o))l.push(m);return l}function RE(o){return Wo.call(o)}function Id(o,l,m){return l=We(l===e?o.length-1:l,0),function(){for(var D=arguments,M=-1,T=We(D.length-l,0),k=J(T);++M<T;)k[M]=D[l+M];M=-1;for(var U=J(l+1);++M<l;)U[M]=D[M];return U[l]=m(k),Cr(o,this,U)}}function $d(o,l){return l.length<2?o:pi(o,zr(l,0,-1))}function PE(o,l){for(var m=o.length,D=rr(l.length,m),M=hr(o);D--;){var T=l[D];o[D]=xn(T,m)?M[T]:e}return o}function Ml(o,l){if(!(l==="constructor"&&typeof o[l]=="function")&&l!="__proto__")return o[l]}var Ld=Pd(sd),As=Qb||function(o,l){return Je.setTimeout(o,l)},Fl=Pd(aE);function Rd(o,l,m){var D=l+"";return Fl(o,NE(D,kE(AE(D),m)))}function Pd(o){var l=0,m=0;return function(){var D=nx(),M=z-(D-m);if(m=D,M>0){if(++l>=L)return arguments[0]}else l=0;return o.apply(e,arguments)}}function da(o,l){var m=-1,D=o.length,M=D-1;for(l=l===e?D:l;++m<l;){var T=cl(m,M),k=o[T];o[T]=o[m],o[m]=k}return o.length=l,o}var kd=IE(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(gu,function(m,D,M,T){l.push(M?T.replace(Cu,"$1"):D||m)}),l});function un(o){if(typeof o=="string"||Fr(o))return o;var l=o+"";return l=="0"&&1/o==-Z?"-0":l}function gi(o){if(o!=null){try{return Uo.call(o)}catch{}try{return o+""}catch{}}return""}function kE(o,l){return Lr(vt,function(m){var D="_."+m[0];l&m[1]&&!Ro(o,D)&&o.push(D)}),o.sort()}function zd(o){if(o instanceof Yt)return o.clone();var l=new Pr(o.__wrapped__,o.__chain__);return l.__actions__=hr(o.__actions__),l.__index__=o.__index__,l.__values__=o.__values__,l}function zE(o,l,m){(m?ar(o,l,m):l===e)?l=1:l=We(Lt(l),0);var D=o==null?0:o.length;if(!D||l<1)return[];for(var M=0,T=0,k=J(Ko(D/l));M<D;)k[T++]=zr(o,M,M+=l);return k}function qE(o){for(var l=-1,m=o==null?0:o.length,D=0,M=[];++l<m;){var T=o[l];T&&(M[D++]=T)}return M}function UE(){var o=arguments.length;if(!o)return[];for(var l=J(o-1),m=arguments[0],D=o;D--;)l[D-1]=arguments[D];return qn(It(m)?hr(m):[m],Xe(l,1))}var WE=kt(function(o,l){return Be(o)?ws(o,Xe(l,1,Be,!0)):[]}),jE=kt(function(o,l){var m=qr(l);return Be(m)&&(m=e),Be(o)?ws(o,Xe(l,1,Be,!0),At(m,2)):[]}),YE=kt(function(o,l){var m=qr(l);return Be(m)&&(m=e),Be(o)?ws(o,Xe(l,1,Be,!0),e,m):[]});function VE(o,l,m){var D=o==null?0:o.length;return D?(l=m||l===e?1:Lt(l),zr(o,l<0?0:l,D)):[]}function HE(o,l,m){var D=o==null?0:o.length;return D?(l=m||l===e?1:Lt(l),l=D-l,zr(o,0,l<0?0:l)):[]}function ZE(o,l){return o&&o.length?sa(o,At(l,3),!0,!0):[]}function KE(o,l){return o&&o.length?sa(o,At(l,3),!0):[]}function GE(o,l,m,D){var M=o==null?0:o.length;return M?(m&&typeof m!="number"&&ar(o,l,m)&&(m=0,D=M),Ux(o,l,m,D)):[]}function qd(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=m==null?0:Lt(m);return M<0&&(M=We(D+M,0)),Po(o,At(l,3),M)}function Ud(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=D-1;return m!==e&&(M=Lt(m),M=m<0?We(D+M,0):rr(M,D-1)),Po(o,At(l,3),M,!0)}function Wd(o){var l=o==null?0:o.length;return l?Xe(o,1):[]}function JE(o){var l=o==null?0:o.length;return l?Xe(o,Z):[]}function XE(o,l){var m=o==null?0:o.length;return m?(l=l===e?1:Lt(l),Xe(o,l)):[]}function QE(o){for(var l=-1,m=o==null?0:o.length,D={};++l<m;){var M=o[l];D[M[0]]=M[1]}return D}function jd(o){return o&&o.length?o[0]:e}function tC(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=m==null?0:Lt(m);return M<0&&(M=We(D+M,0)),qi(o,l,M)}function eC(o){var l=o==null?0:o.length;return l?zr(o,0,-1):[]}var rC=kt(function(o){var l=Ce(o,pl);return l.length&&l[0]===o[0]?sl(l):[]}),nC=kt(function(o){var l=qr(o),m=Ce(o,pl);return l===qr(m)?l=e:m.pop(),m.length&&m[0]===o[0]?sl(m,At(l,2)):[]}),iC=kt(function(o){var l=qr(o),m=Ce(o,pl);return l=typeof l=="function"?l:e,l&&m.pop(),m.length&&m[0]===o[0]?sl(m,e,l):[]});function sC(o,l){return o==null?"":ex.call(o,l)}function qr(o){var l=o==null?0:o.length;return l?o[l-1]:e}function oC(o,l,m){var D=o==null?0:o.length;if(!D)return-1;var M=D;return m!==e&&(M=Lt(m),M=M<0?We(D+M,0):rr(M,D-1)),l===l?kb(o,l,M):Po(o,E0,M,!0)}function aC(o,l){return o&&o.length?ed(o,Lt(l)):e}var uC=kt(Yd);function Yd(o,l){return o&&o.length&&l&&l.length?ll(o,l):o}function lC(o,l,m){return o&&o.length&&l&&l.length?ll(o,l,At(m,2)):o}function cC(o,l,m){return o&&o.length&&l&&l.length?ll(o,l,e,m):o}var fC=bn(function(o,l){var m=o==null?0:o.length,D=el(o,l);return id(o,Ce(l,function(M){return xn(M,m)?+M:M}).sort(_d)),D});function hC(o,l){var m=[];if(!(o&&o.length))return m;var D=-1,M=[],T=o.length;for(l=At(l,3);++D<T;){var k=o[D];l(k,D,o)&&(m.push(k),M.push(D))}return id(o,M),m}function Nl(o){return o==null?o:sx.call(o)}function dC(o,l,m){var D=o==null?0:o.length;return D?(m&&typeof m!="number"&&ar(o,l,m)?(l=0,m=D):(l=l==null?0:Lt(l),m=m===e?D:Lt(m)),zr(o,l,m)):[]}function _C(o,l){return ia(o,l)}function pC(o,l,m){return hl(o,l,At(m,2))}function mC(o,l){var m=o==null?0:o.length;if(m){var D=ia(o,l);if(D<m&&Xr(o[D],l))return D}return-1}function gC(o,l){return ia(o,l,!0)}function vC(o,l,m){return hl(o,l,At(m,2),!0)}function yC(o,l){var m=o==null?0:o.length;if(m){var D=ia(o,l,!0)-1;if(Xr(o[D],l))return D}return-1}function wC(o){return o&&o.length?od(o):[]}function DC(o,l){return o&&o.length?od(o,At(l,2)):[]}function bC(o){var l=o==null?0:o.length;return l?zr(o,1,l):[]}function xC(o,l,m){return o&&o.length?(l=m||l===e?1:Lt(l),zr(o,0,l<0?0:l)):[]}function EC(o,l,m){var D=o==null?0:o.length;return D?(l=m||l===e?1:Lt(l),l=D-l,zr(o,l<0?0:l,D)):[]}function CC(o,l){return o&&o.length?sa(o,At(l,3),!1,!0):[]}function AC(o,l){return o&&o.length?sa(o,At(l,3)):[]}var MC=kt(function(o){return Yn(Xe(o,1,Be,!0))}),FC=kt(function(o){var l=qr(o);return Be(l)&&(l=e),Yn(Xe(o,1,Be,!0),At(l,2))}),NC=kt(function(o){var l=qr(o);return l=typeof l=="function"?l:e,Yn(Xe(o,1,Be,!0),e,l)});function SC(o){return o&&o.length?Yn(o):[]}function OC(o,l){return o&&o.length?Yn(o,At(l,2)):[]}function BC(o,l){return l=typeof l=="function"?l:e,o&&o.length?Yn(o,e,l):[]}function Sl(o){if(!(o&&o.length))return[];var l=0;return o=zn(o,function(m){if(Be(m))return l=We(m.length,l),!0}),Hu(l,function(m){return Ce(o,ju(m))})}function Vd(o,l){if(!(o&&o.length))return[];var m=Sl(o);return l==null?m:Ce(m,function(D){return Cr(l,e,D)})}var TC=kt(function(o,l){return Be(o)?ws(o,l):[]}),IC=kt(function(o){return _l(zn(o,Be))}),$C=kt(function(o){var l=qr(o);return Be(l)&&(l=e),_l(zn(o,Be),At(l,2))}),LC=kt(function(o){var l=qr(o);return l=typeof l=="function"?l:e,_l(zn(o,Be),e,l)}),RC=kt(Sl);function PC(o,l){return cd(o||[],l||[],ys)}function kC(o,l){return cd(o||[],l||[],xs)}var zC=kt(function(o){var l=o.length,m=l>1?o[l-1]:e;return m=typeof m=="function"?(o.pop(),m):e,Vd(o,m)});function Hd(o){var l=B(o);return l.__chain__=!0,l}function qC(o,l){return l(o),o}function _a(o,l){return l(o)}var UC=bn(function(o){var l=o.length,m=l?o[0]:0,D=this.__wrapped__,M=function(T){return el(T,o)};return l>1||this.__actions__.length||!(D instanceof Yt)||!xn(m)?this.thru(M):(D=D.slice(m,+m+(l?1:0)),D.__actions__.push({func:_a,args:[M],thisArg:e}),new Pr(D,this.__chain__).thru(function(T){return l&&!T.length&&T.push(e),T}))});function WC(){return Hd(this)}function jC(){return new Pr(this.value(),this.__chain__)}function YC(){this.__values__===e&&(this.__values__=a_(this.value()));var o=this.__index__>=this.__values__.length,l=o?e:this.__values__[this.__index__++];return{done:o,value:l}}function VC(){return this}function HC(o){for(var l,m=this;m instanceof Qo;){var D=zd(m);D.__index__=0,D.__values__=e,l?M.__wrapped__=D:l=D;var M=D;m=m.__wrapped__}return M.__wrapped__=o,l}function ZC(){var o=this.__wrapped__;if(o instanceof Yt){var l=o;return this.__actions__.length&&(l=new Yt(this)),l=l.reverse(),l.__actions__.push({func:_a,args:[Nl],thisArg:e}),new Pr(l,this.__chain__)}return this.thru(Nl)}function KC(){return ld(this.__wrapped__,this.__actions__)}var GC=oa(function(o,l,m){ce.call(o,m)?++o[m]:wn(o,m,1)});function JC(o,l,m){var D=It(o)?b0:qx;return m&&ar(o,l,m)&&(l=e),D(o,At(l,3))}function XC(o,l){var m=It(o)?zn:V0;return m(o,At(l,3))}var QC=wd(qd),tA=wd(Ud);function eA(o,l){return Xe(pa(o,l),1)}function rA(o,l){return Xe(pa(o,l),Z)}function nA(o,l,m){return m=m===e?1:Lt(m),Xe(pa(o,l),m)}function Zd(o,l){var m=It(o)?Lr:jn;return m(o,At(l,3))}function Kd(o,l){var m=It(o)?bb:Y0;return m(o,At(l,3))}var iA=oa(function(o,l,m){ce.call(o,m)?o[m].push(l):wn(o,m,[l])});function sA(o,l,m,D){o=dr(o)?o:Qi(o),m=m&&!D?Lt(m):0;var M=o.length;return m<0&&(m=We(M+m,0)),wa(o)?m<=M&&o.indexOf(l,m)>-1:!!M&&qi(o,l,m)>-1}var oA=kt(function(o,l,m){var D=-1,M=typeof l=="function",T=dr(o)?J(o.length):[];return jn(o,function(k){T[++D]=M?Cr(l,k,m):Ds(k,l,m)}),T}),aA=oa(function(o,l,m){wn(o,m,l)});function pa(o,l){var m=It(o)?Ce:X0;return m(o,At(l,3))}function uA(o,l,m,D){return o==null?[]:(It(l)||(l=l==null?[]:[l]),m=D?e:m,It(m)||(m=m==null?[]:[m]),rd(o,l,m))}var lA=oa(function(o,l,m){o[m?0:1].push(l)},function(){return[[],[]]});function cA(o,l,m){var D=It(o)?Uu:A0,M=arguments.length<3;return D(o,At(l,4),m,M,jn)}function fA(o,l,m){var D=It(o)?xb:A0,M=arguments.length<3;return D(o,At(l,4),m,M,Y0)}function hA(o,l){var m=It(o)?zn:V0;return m(o,va(At(l,3)))}function dA(o){var l=It(o)?q0:sE;return l(o)}function _A(o,l,m){(m?ar(o,l,m):l===e)?l=1:l=Lt(l);var D=It(o)?Lx:oE;return D(o,l)}function pA(o){var l=It(o)?Rx:uE;return l(o)}function mA(o){if(o==null)return 0;if(dr(o))return wa(o)?Wi(o):o.length;var l=nr(o);return l==Xt||l==br?o.size:al(o).length}function gA(o,l,m){var D=It(o)?Wu:lE;return m&&ar(o,l,m)&&(l=e),D(o,At(l,3))}var vA=kt(function(o,l){if(o==null)return[];var m=l.length;return m>1&&ar(o,l[0],l[1])?l=[]:m>2&&ar(l[0],l[1],l[2])&&(l=[l[0]]),rd(o,Xe(l,1),[])}),ma=Xb||function(){return Je.Date.now()};function yA(o,l){if(typeof l!="function")throw new Rr(a);return o=Lt(o),function(){if(--o<1)return l.apply(this,arguments)}}function Gd(o,l,m){return l=m?e:l,l=o&&l==null?o.length:l,Dn(o,N,e,e,e,e,l)}function Jd(o,l){var m;if(typeof l!="function")throw new Rr(a);return o=Lt(o),function(){return--o>0&&(m=l.apply(this,arguments)),o<=1&&(l=e),m}}var Ol=kt(function(o,l,m){var D=w;if(m.length){var M=Un(m,Ji(Ol));D|=E}return Dn(o,D,l,m,M)}),Xd=kt(function(o,l,m){var D=w|v;if(m.length){var M=Un(m,Ji(Xd));D|=E}return Dn(l,D,o,m,M)});function Qd(o,l,m){l=m?e:l;var D=Dn(o,b,e,e,e,e,e,l);return D.placeholder=Qd.placeholder,D}function t_(o,l,m){l=m?e:l;var D=Dn(o,C,e,e,e,e,e,l);return D.placeholder=t_.placeholder,D}function e_(o,l,m){var D,M,T,k,U,V,tt=0,et=!1,ot=!1,pt=!0;if(typeof o!="function")throw new Rr(a);l=Ur(l)||0,Fe(m)&&(et=!!m.leading,ot="maxWait"in m,T=ot?We(Ur(m.maxWait)||0,l):T,pt="trailing"in m?!!m.trailing:pt);function Dt(Te){var Qr=D,An=M;return D=M=e,tt=Te,k=o.apply(An,Qr),k}function Mt(Te){return tt=Te,U=As(Ut,l),et?Dt(Te):k}function Pt(Te){var Qr=Te-V,An=Te-tt,w_=l-Qr;return ot?rr(w_,T-An):w_}function Ft(Te){var Qr=Te-V,An=Te-tt;return V===e||Qr>=l||Qr<0||ot&&An>=T}function Ut(){var Te=ma();if(Ft(Te))return Ht(Te);U=As(Ut,Pt(Te))}function Ht(Te){return U=e,pt&&D?Dt(Te):(D=M=e,k)}function Nr(){U!==e&&fd(U),tt=0,D=V=M=U=e}function ur(){return U===e?k:Ht(ma())}function Sr(){var Te=ma(),Qr=Ft(Te);if(D=arguments,M=this,V=Te,Qr){if(U===e)return Mt(V);if(ot)return fd(U),U=As(Ut,l),Dt(V)}return U===e&&(U=As(Ut,l)),k}return Sr.cancel=Nr,Sr.flush=ur,Sr}var wA=kt(function(o,l){return j0(o,1,l)}),DA=kt(function(o,l,m){return j0(o,Ur(l)||0,m)});function bA(o){return Dn(o,I)}function ga(o,l){if(typeof o!="function"||l!=null&&typeof l!="function")throw new Rr(a);var m=function(){var D=arguments,M=l?l.apply(this,D):D[0],T=m.cache;if(T.has(M))return T.get(M);var k=o.apply(this,D);return m.cache=T.set(M,k)||T,k};return m.cache=new(ga.Cache||yn),m}ga.Cache=yn;function va(o){if(typeof o!="function")throw new Rr(a);return function(){var l=arguments;switch(l.length){case 0:return!o.call(this);case 1:return!o.call(this,l[0]);case 2:return!o.call(this,l[0],l[1]);case 3:return!o.call(this,l[0],l[1],l[2])}return!o.apply(this,l)}}function xA(o){return Jd(2,o)}var EA=cE(function(o,l){l=l.length==1&&It(l[0])?Ce(l[0],Ar(At())):Ce(Xe(l,1),Ar(At()));var m=l.length;return kt(function(D){for(var M=-1,T=rr(D.length,m);++M<T;)D[M]=l[M].call(this,D[M]);return Cr(o,this,D)})}),Bl=kt(function(o,l){var m=Un(l,Ji(Bl));return Dn(o,E,e,l,m)}),r_=kt(function(o,l){var m=Un(l,Ji(r_));return Dn(o,A,e,l,m)}),CA=bn(function(o,l){return Dn(o,S,e,e,e,l)});function AA(o,l){if(typeof o!="function")throw new Rr(a);return l=l===e?l:Lt(l),kt(o,l)}function MA(o,l){if(typeof o!="function")throw new Rr(a);return l=l==null?0:We(Lt(l),0),kt(function(m){var D=m[l],M=Hn(m,0,l);return D&&qn(M,D),Cr(o,this,M)})}function FA(o,l,m){var D=!0,M=!0;if(typeof o!="function")throw new Rr(a);return Fe(m)&&(D="leading"in m?!!m.leading:D,M="trailing"in m?!!m.trailing:M),e_(o,l,{leading:D,maxWait:l,trailing:M})}function NA(o){return Gd(o,1)}function SA(o,l){return Bl(ml(l),o)}function OA(){if(!arguments.length)return[];var o=arguments[0];return It(o)?o:[o]}function BA(o){return kr(o,g)}function TA(o,l){return l=typeof l=="function"?l:e,kr(o,g,l)}function IA(o){return kr(o,h|g)}function $A(o,l){return l=typeof l=="function"?l:e,kr(o,h|g,l)}function LA(o,l){return l==null||W0(o,l,Ve(l))}function Xr(o,l){return o===l||o!==o&&l!==l}var RA=ca(il),PA=ca(function(o,l){return o>=l}),vi=K0(function(){return arguments}())?K0:function(o){return Ne(o)&&ce.call(o,"callee")&&!$0.call(o,"callee")},It=J.isArray,kA=m0?Ar(m0):Hx;function dr(o){return o!=null&&ya(o.length)&&!En(o)}function Be(o){return Ne(o)&&dr(o)}function zA(o){return o===!0||o===!1||Ne(o)&&or(o)==re}var Zn=tx||Wl,qA=g0?Ar(g0):Zx;function UA(o){return Ne(o)&&o.nodeType===1&&!Ms(o)}function WA(o){if(o==null)return!0;if(dr(o)&&(It(o)||typeof o=="string"||typeof o.splice=="function"||Zn(o)||Xi(o)||vi(o)))return!o.length;var l=nr(o);if(l==Xt||l==br)return!o.size;if(Cs(o))return!al(o).length;for(var m in o)if(ce.call(o,m))return!1;return!0}function jA(o,l){return bs(o,l)}function YA(o,l,m){m=typeof m=="function"?m:e;var D=m?m(o,l):e;return D===e?bs(o,l,e,m):!!D}function Tl(o){if(!Ne(o))return!1;var l=or(o);return l==he||l==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!Ms(o)}function VA(o){return typeof o=="number"&&R0(o)}function En(o){if(!Fe(o))return!1;var l=or(o);return l==se||l==qt||l==bt||l==Ln}function n_(o){return typeof o=="number"&&o==Lt(o)}function ya(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Y}function Fe(o){var l=typeof o;return o!=null&&(l=="object"||l=="function")}function Ne(o){return o!=null&&typeof o=="object"}var i_=v0?Ar(v0):Gx;function HA(o,l){return o===l||ol(o,l,xl(l))}function ZA(o,l,m){return m=typeof m=="function"?m:e,ol(o,l,xl(l),m)}function KA(o){return s_(o)&&o!=+o}function GA(o){if(TE(o))throw new Tt(s);return G0(o)}function JA(o){return o===null}function XA(o){return o==null}function s_(o){return typeof o=="number"||Ne(o)&&or(o)==Le}function Ms(o){if(!Ne(o)||or(o)!=ze)return!1;var l=Vo(o);if(l===null)return!0;var m=ce.call(l,"constructor")&&l.constructor;return typeof m=="function"&&m instanceof m&&Uo.call(m)==Zb}var Il=y0?Ar(y0):Jx;function QA(o){return n_(o)&&o>=-Y&&o<=Y}var o_=w0?Ar(w0):Xx;function wa(o){return typeof o=="string"||!It(o)&&Ne(o)&&or(o)==Rn}function Fr(o){return typeof o=="symbol"||Ne(o)&&or(o)==P}var Xi=D0?Ar(D0):Qx;function tM(o){return o===e}function eM(o){return Ne(o)&&nr(o)==K}function rM(o){return Ne(o)&&or(o)==nt}var nM=ca(ul),iM=ca(function(o,l){return o<=l});function a_(o){if(!o)return[];if(dr(o))return wa(o)?Gr(o):hr(o);if(_s&&o[_s])return Lb(o[_s]());var l=nr(o),m=l==Xt?Ku:l==br?ko:Qi;return m(o)}function Cn(o){if(!o)return o===0?o:0;if(o=Ur(o),o===Z||o===-Z){var l=o<0?-1:1;return l*G}return o===o?o:0}function Lt(o){var l=Cn(o),m=l%1;return l===l?m?l-m:l:0}function u_(o){return o?_i(Lt(o),0,ut):0}function Ur(o){if(typeof o=="number")return o;if(Fr(o))return Q;if(Fe(o)){var l=typeof o.valueOf=="function"?o.valueOf():o;o=Fe(l)?l+"":l}if(typeof o!="string")return o===0?o:+o;o=M0(o);var m=Fu.test(o);return m||Su.test(o)?yb(o.slice(2),m?2:8):Mu.test(o)?Q:+o}function l_(o){return an(o,_r(o))}function sM(o){return o?_i(Lt(o),-Y,Y):o===0?o:0}function ae(o){return o==null?"":Mr(o)}var oM=Ki(function(o,l){if(Cs(l)||dr(l)){an(l,Ve(l),o);return}for(var m in l)ce.call(l,m)&&ys(o,m,l[m])}),c_=Ki(function(o,l){an(l,_r(l),o)}),Da=Ki(function(o,l,m,D){an(l,_r(l),o,D)}),aM=Ki(function(o,l,m,D){an(l,Ve(l),o,D)}),uM=bn(el);function lM(o,l){var m=Zi(o);return l==null?m:U0(m,l)}var cM=kt(function(o,l){o=pe(o);var m=-1,D=l.length,M=D>2?l[2]:e;for(M&&ar(l[0],l[1],M)&&(D=1);++m<D;)for(var T=l[m],k=_r(T),U=-1,V=k.length;++U<V;){var tt=k[U],et=o[tt];(et===e||Xr(et,Yi[tt])&&!ce.call(o,tt))&&(o[tt]=T[tt])}return o}),fM=kt(function(o){return o.push(e,Md),Cr(f_,e,o)});function hM(o,l){return x0(o,At(l,3),on)}function dM(o,l){return x0(o,At(l,3),nl)}function _M(o,l){return o==null?o:rl(o,At(l,3),_r)}function pM(o,l){return o==null?o:H0(o,At(l,3),_r)}function mM(o,l){return o&&on(o,At(l,3))}function gM(o,l){return o&&nl(o,At(l,3))}function vM(o){return o==null?[]:ra(o,Ve(o))}function yM(o){return o==null?[]:ra(o,_r(o))}function $l(o,l,m){var D=o==null?e:pi(o,l);return D===e?m:D}function wM(o,l){return o!=null&&Sd(o,l,Wx)}function Ll(o,l){return o!=null&&Sd(o,l,jx)}var DM=bd(function(o,l,m){l!=null&&typeof l.toString!="function"&&(l=Wo.call(l)),o[l]=m},Pl(pr)),bM=bd(function(o,l,m){l!=null&&typeof l.toString!="function"&&(l=Wo.call(l)),ce.call(o,l)?o[l].push(m):o[l]=[m]},At),xM=kt(Ds);function Ve(o){return dr(o)?z0(o):al(o)}function _r(o){return dr(o)?z0(o,!0):tE(o)}function EM(o,l){var m={};return l=At(l,3),on(o,function(D,M,T){wn(m,l(D,M,T),D)}),m}function CM(o,l){var m={};return l=At(l,3),on(o,function(D,M,T){wn(m,M,l(D,M,T))}),m}var AM=Ki(function(o,l,m){na(o,l,m)}),f_=Ki(function(o,l,m,D){na(o,l,m,D)}),MM=bn(function(o,l){var m={};if(o==null)return m;var D=!1;l=Ce(l,function(T){return T=Vn(T,o),D||(D=T.length>1),T}),an(o,Dl(o),m),D&&(m=kr(m,h|_|g,DE));for(var M=l.length;M--;)dl(m,l[M]);return m});function FM(o,l){return h_(o,va(At(l)))}var NM=bn(function(o,l){return o==null?{}:rE(o,l)});function h_(o,l){if(o==null)return{};var m=Ce(Dl(o),function(D){return[D]});return l=At(l),nd(o,m,function(D,M){return l(D,M[0])})}function SM(o,l,m){l=Vn(l,o);var D=-1,M=l.length;for(M||(M=1,o=e);++D<M;){var T=o==null?e:o[un(l[D])];T===e&&(D=M,T=m),o=En(T)?T.call(o):T}return o}function OM(o,l,m){return o==null?o:xs(o,l,m)}function BM(o,l,m,D){return D=typeof D=="function"?D:e,o==null?o:xs(o,l,m,D)}var d_=Cd(Ve),__=Cd(_r);function TM(o,l,m){var D=It(o),M=D||Zn(o)||Xi(o);if(l=At(l,4),m==null){var T=o&&o.constructor;M?m=D?new T:[]:Fe(o)?m=En(T)?Zi(Vo(o)):{}:m={}}return(M?Lr:on)(o,function(k,U,V){return l(m,k,U,V)}),m}function IM(o,l){return o==null?!0:dl(o,l)}function $M(o,l,m){return o==null?o:ud(o,l,ml(m))}function LM(o,l,m,D){return D=typeof D=="function"?D:e,o==null?o:ud(o,l,ml(m),D)}function Qi(o){return o==null?[]:Zu(o,Ve(o))}function RM(o){return o==null?[]:Zu(o,_r(o))}function PM(o,l,m){return m===e&&(m=l,l=e),m!==e&&(m=Ur(m),m=m===m?m:0),l!==e&&(l=Ur(l),l=l===l?l:0),_i(Ur(o),l,m)}function kM(o,l,m){return l=Cn(l),m===e?(m=l,l=0):m=Cn(m),o=Ur(o),Yx(o,l,m)}function zM(o,l,m){if(m&&typeof m!="boolean"&&ar(o,l,m)&&(l=m=e),m===e&&(typeof l=="boolean"?(m=l,l=e):typeof o=="boolean"&&(m=o,o=e)),o===e&&l===e?(o=0,l=1):(o=Cn(o),l===e?(l=o,o=0):l=Cn(l)),o>l){var D=o;o=l,l=D}if(m||o%1||l%1){var M=P0();return rr(o+M*(l-o+vb("1e-"+((M+"").length-1))),l)}return cl(o,l)}var qM=Gi(function(o,l,m){return l=l.toLowerCase(),o+(m?p_(l):l)});function p_(o){return Rl(ae(o).toLowerCase())}function m_(o){return o=ae(o),o&&o.replace(Bu,Ob).replace(ub,"")}function UM(o,l,m){o=ae(o),l=Mr(l);var D=o.length;m=m===e?D:_i(Lt(m),0,D);var M=m;return m-=l.length,m>=0&&o.slice(m,M)==l}function WM(o){return o=ae(o),o&&hu.test(o)?o.replace(Bo,Bb):o}function jM(o){return o=ae(o),o&&vu.test(o)?o.replace(fs,"\\$&"):o}var YM=Gi(function(o,l,m){return o+(m?"-":"")+l.toLowerCase()}),VM=Gi(function(o,l,m){return o+(m?" ":"")+l.toLowerCase()}),HM=yd("toLowerCase");function ZM(o,l,m){o=ae(o),l=Lt(l);var D=l?Wi(o):0;if(!l||D>=l)return o;var M=(l-D)/2;return la(Go(M),m)+o+la(Ko(M),m)}function KM(o,l,m){o=ae(o),l=Lt(l);var D=l?Wi(o):0;return l&&D<l?o+la(l-D,m):o}function GM(o,l,m){o=ae(o),l=Lt(l);var D=l?Wi(o):0;return l&&D<l?la(l-D,m)+o:o}function JM(o,l,m){return m||l==null?l=0:l&&(l=+l),ix(ae(o).replace(hs,""),l||0)}function XM(o,l,m){return(m?ar(o,l,m):l===e)?l=1:l=Lt(l),fl(ae(o),l)}function QM(){var o=arguments,l=ae(o[0]);return o.length<3?l:l.replace(o[1],o[2])}var t2=Gi(function(o,l,m){return o+(m?"_":"")+l.toLowerCase()});function e2(o,l,m){return m&&typeof m!="number"&&ar(o,l,m)&&(l=m=e),m=m===e?ut:m>>>0,m?(o=ae(o),o&&(typeof l=="string"||l!=null&&!Il(l))&&(l=Mr(l),!l&&Ui(o))?Hn(Gr(o),0,m):o.split(l,m)):[]}var r2=Gi(function(o,l,m){return o+(m?" ":"")+Rl(l)});function n2(o,l,m){return o=ae(o),m=m==null?0:_i(Lt(m),0,o.length),l=Mr(l),o.slice(m,m+l.length)==l}function i2(o,l,m){var D=B.templateSettings;m&&ar(o,l,m)&&(l=e),o=ae(o),l=Da({},l,D,Ad);var M=Da({},l.imports,D.imports,Ad),T=Ve(M),k=Zu(M,T),U,V,tt=0,et=l.interpolate||Pi,ot="__p += '",pt=Gu((l.escape||Pi).source+"|"+et.source+"|"+(et===To?Au:Pi).source+"|"+(l.evaluate||Pi).source+"|$","g"),Dt="//# sourceURL="+(ce.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++db+"]")+`
|
11
11
|
`;o.replace(pt,function(Ft,Ut,Ht,Nr,ur,Sr){return Ht||(Ht=Nr),ot+=o.slice(tt,Sr).replace(li,Tb),Ut&&(U=!0,ot+=`' +
|
12
12
|
__e(`+Ut+`) +
|
13
13
|
'`),ur&&(V=!0,ot+=`';
|
@@ -24,20 +24,20 @@ __p += '`),Ht&&(ot+=`' +
|
|
24
24
|
function print() { __p += __j.call(arguments, '') }
|
25
25
|
`:`;
|
26
26
|
`)+ot+`return __p
|
27
|
-
}`;var Pt=v_(function(){return ne(T,Dt+"return "+ot).apply(e,k)});if(Pt.source=ot,Tl(Pt))throw Pt;return Pt}function s2(o){return ae(o).toLowerCase()}function o2(o){return ae(o).toUpperCase()}function a2(o,l,m){if(o=ae(o),o&&(m||l===e))return M0(o);if(!o||!(l=Mr(l)))return o;var D=Gr(o),M=Gr(l),T=F0(D,M),k=N0(D,M)+1;return Hn(D,T,k).join("")}function u2(o,l,m){if(o=ae(o),o&&(m||l===e))return o.slice(0,O0(o)+1);if(!o||!(l=Mr(l)))return o;var D=Gr(o),M=N0(D,Gr(l))+1;return Hn(D,0,M).join("")}function l2(o,l,m){if(o=ae(o),o&&(m||l===e))return o.replace(hs,"");if(!o||!(l=Mr(l)))return o;var D=Gr(o),M=F0(D,Gr(l));return Hn(D,M).join("")}function c2(o,l){var m=F,D=O;if(Fe(l)){var M="separator"in l?l.separator:M;m="length"in l?Lt(l.length):m,D="omission"in l?Mr(l.omission):D}o=ae(o);var T=o.length;if(Ui(o)){var k=Gr(o);T=k.length}if(m>=T)return o;var U=m-Wi(D);if(U<1)return D;var V=k?Hn(k,0,U).join(""):o.slice(0,U);if(M===e)return V+D;if(k&&(U+=V.length-U),Il(M)){if(o.slice(U).search(M)){var tt,et=V;for(M.global||(M=Gu(M.source,ae(Io.exec(M))+"g")),M.lastIndex=0;tt=M.exec(et);)var ot=tt.index;V=V.slice(0,ot===e?U:ot)}}else if(o.indexOf(Mr(M),U)!=U){var pt=V.lastIndexOf(M);pt>-1&&(V=V.slice(0,pt))}return V+D}function f2(o){return o=ae(o),o&&fu.test(o)?o.replace(ui,zb):o}var h2=Gi(function(o,l,m){return o+(m?" ":"")+l.toUpperCase()}),Rl=yd("toUpperCase");function g_(o,l,m){return o=ae(o),l=m?e:l,l===e?$b(o)?Wb(o):Ab(o):o.match(l)||[]}var v_=kt(function(o,l){try{return Cr(o,e,l)}catch(m){return Tl(m)?m:new Tt(m)}}),d2=bn(function(o,l){return Lr(l,function(m){m=un(m),wn(o,m,Ol(o[m],o))}),o});function _2(o){var l=o==null?0:o.length,m=At();return o=l?Ce(o,function(D){if(typeof D[1]!="function")throw new Rr(a);return[m(D[0]),D[1]]}):[],kt(function(D){for(var M=-1;++M<l;){var T=o[M];if(Cr(T[0],this,D))return Cr(T[1],this,D)}})}function p2(o){return zx(kr(o,h))}function Pl(o){return function(){return o}}function m2(o,l){return o==null||o!==o?l:o}var g2=Dd(),v2=Dd(!0);function pr(o){return o}function kl(o){return J0(typeof o=="function"?o:kr(o,h))}function y2(o){return Q0(kr(o,h))}function w2(o,l){return td(o,kr(l,h))}var D2=kt(function(o,l){return function(m){return Ds(m,o,l)}}),b2=kt(function(o,l){return function(m){return Ds(o,m,l)}});function zl(o,l,m){var D=Ve(l),M=ra(l,D);m==null&&!(Fe(l)&&(M.length||!D.length))&&(m=l,l=o,o=this,M=ra(l,Ve(l)));var T=!(Fe(m)&&"chain"in m)||!!m.chain,k=En(o);return Lr(M,function(U){var V=l[U];o[U]=V,k&&(o.prototype[U]=function(){var tt=this.__chain__;if(T||tt){var et=o(this.__wrapped__),ot=et.__actions__=hr(this.__actions__);return ot.push({func:V,args:arguments,thisArg:o}),et.__chain__=tt,et}return V.apply(o,qn([this.value()],arguments))})}),o}function x2(){return Je._===this&&(Je._=Kb),this}function ql(){}function E2(o){return o=Lt(o),kt(function(l){return ed(l,o)})}var C2=vl(Ce),A2=vl(b0),M2=vl(Wu);function y_(o){return Cl(o)?ju(un(o)):nE(o)}function F2(o){return function(l){return o==null?e:pi(o,l)}}var N2=xd(),S2=xd(!0);function Ul(){return[]}function Wl(){return!1}function O2(){return{}}function B2(){return""}function T2(){return!0}function I2(o,l){if(o=Lt(o),o<1||o>Y)return[];var m=ut,D=rr(o,ut);l=At(l),o-=ut;for(var M=Hu(D,l);++m<o;)l(m);return M}function $2(o){return It(o)?Ce(o,un):Fr(o)?[o]:hr(kd(ae(o)))}function L2(o){var l=++Hb;return ae(o)+l}var R2=ua(function(o,l){return o+l},0),P2=yl("ceil"),k2=ua(function(o,l){return o/l},1),z2=yl("floor");function q2(o){return o&&o.length?ea(o,pr,il):e}function U2(o,l){return o&&o.length?ea(o,At(l,2),il):e}function W2(o){return C0(o,pr)}function j2(o,l){return C0(o,At(l,2))}function Y2(o){return o&&o.length?ea(o,pr,ul):e}function V2(o,l){return o&&o.length?ea(o,At(l,2),ul):e}var H2=ua(function(o,l){return o*l},1),Z2=yl("round"),K2=ua(function(o,l){return o-l},0);function G2(o){return o&&o.length?Vu(o,pr):0}function J2(o,l){return o&&o.length?Vu(o,At(l,2)):0}return B.after=yA,B.ary=Gd,B.assign=oM,B.assignIn=c_,B.assignInWith=Da,B.assignWith=aM,B.at=uM,B.before=Jd,B.bind=Ol,B.bindAll=d2,B.bindKey=Xd,B.castArray=OA,B.chain=Hd,B.chunk=zE,B.compact=qE,B.concat=UE,B.cond=_2,B.conforms=p2,B.constant=Pl,B.countBy=GC,B.create=lM,B.curry=Qd,B.curryRight=t_,B.debounce=e_,B.defaults=cM,B.defaultsDeep=fM,B.defer=wA,B.delay=DA,B.difference=WE,B.differenceBy=jE,B.differenceWith=YE,B.drop=VE,B.dropRight=HE,B.dropRightWhile=ZE,B.dropWhile=KE,B.fill=GE,B.filter=XC,B.flatMap=eA,B.flatMapDeep=rA,B.flatMapDepth=nA,B.flatten=Wd,B.flattenDeep=JE,B.flattenDepth=XE,B.flip=bA,B.flow=g2,B.flowRight=v2,B.fromPairs=QE,B.functions=vM,B.functionsIn=yM,B.groupBy=iA,B.initial=eC,B.intersection=rC,B.intersectionBy=nC,B.intersectionWith=iC,B.invert=DM,B.invertBy=bM,B.invokeMap=oA,B.iteratee=kl,B.keyBy=aA,B.keys=Ve,B.keysIn=_r,B.map=pa,B.mapKeys=EM,B.mapValues=CM,B.matches=y2,B.matchesProperty=w2,B.memoize=ga,B.merge=AM,B.mergeWith=f_,B.method=D2,B.methodOf=b2,B.mixin=zl,B.negate=va,B.nthArg=E2,B.omit=MM,B.omitBy=FM,B.once=xA,B.orderBy=uA,B.over=C2,B.overArgs=EA,B.overEvery=A2,B.overSome=M2,B.partial=Bl,B.partialRight=r_,B.partition=lA,B.pick=NM,B.pickBy=h_,B.property=y_,B.propertyOf=F2,B.pull=uC,B.pullAll=Yd,B.pullAllBy=lC,B.pullAllWith=cC,B.pullAt=fC,B.range=N2,B.rangeRight=S2,B.rearg=CA,B.reject=hA,B.remove=hC,B.rest=AA,B.reverse=Nl,B.sampleSize=_A,B.set=OM,B.setWith=BM,B.shuffle=pA,B.slice=dC,B.sortBy=vA,B.sortedUniq=wC,B.sortedUniqBy=DC,B.split=e2,B.spread=MA,B.tail=bC,B.take=xC,B.takeRight=EC,B.takeRightWhile=CC,B.takeWhile=AC,B.tap=qC,B.throttle=FA,B.thru=_a,B.toArray=a_,B.toPairs=d_,B.toPairsIn=__,B.toPath=$2,B.toPlainObject=l_,B.transform=TM,B.unary=NA,B.union=MC,B.unionBy=FC,B.unionWith=NC,B.uniq=SC,B.uniqBy=OC,B.uniqWith=BC,B.unset=IM,B.unzip=Sl,B.unzipWith=Vd,B.update=$M,B.updateWith=LM,B.values=Qi,B.valuesIn=RM,B.without=TC,B.words=g_,B.wrap=SA,B.xor=IC,B.xorBy=$C,B.xorWith=LC,B.zip=RC,B.zipObject=PC,B.zipObjectDeep=kC,B.zipWith=zC,B.entries=d_,B.entriesIn=__,B.extend=c_,B.extendWith=Da,zl(B,B),B.add=R2,B.attempt=v_,B.camelCase=qM,B.capitalize=p_,B.ceil=P2,B.clamp=PM,B.clone=BA,B.cloneDeep=IA,B.cloneDeepWith=$A,B.cloneWith=TA,B.conformsTo=LA,B.deburr=m_,B.defaultTo=m2,B.divide=k2,B.endsWith=UM,B.eq=Xr,B.escape=WM,B.escapeRegExp=jM,B.every=JC,B.find=QC,B.findIndex=qd,B.findKey=hM,B.findLast=tA,B.findLastIndex=Ud,B.findLastKey=dM,B.floor=z2,B.forEach=Zd,B.forEachRight=Kd,B.forIn=_M,B.forInRight=pM,B.forOwn=mM,B.forOwnRight=gM,B.get=$l,B.gt=RA,B.gte=PA,B.has=wM,B.hasIn=Ll,B.head=jd,B.identity=pr,B.includes=sA,B.indexOf=tC,B.inRange=kM,B.invoke=xM,B.isArguments=vi,B.isArray=It,B.isArrayBuffer=kA,B.isArrayLike=dr,B.isArrayLikeObject=Be,B.isBoolean=zA,B.isBuffer=Zn,B.isDate=qA,B.isElement=UA,B.isEmpty=WA,B.isEqual=jA,B.isEqualWith=YA,B.isError=Tl,B.isFinite=VA,B.isFunction=En,B.isInteger=n_,B.isLength=ya,B.isMap=i_,B.isMatch=HA,B.isMatchWith=ZA,B.isNaN=KA,B.isNative=GA,B.isNil=XA,B.isNull=JA,B.isNumber=s_,B.isObject=Fe,B.isObjectLike=Ne,B.isPlainObject=Ms,B.isRegExp=Il,B.isSafeInteger=QA,B.isSet=o_,B.isString=wa,B.isSymbol=Fr,B.isTypedArray=Xi,B.isUndefined=tM,B.isWeakMap=eM,B.isWeakSet=rM,B.join=sC,B.kebabCase=YM,B.last=qr,B.lastIndexOf=oC,B.lowerCase=VM,B.lowerFirst=HM,B.lt=nM,B.lte=iM,B.max=q2,B.maxBy=U2,B.mean=W2,B.meanBy=j2,B.min=Y2,B.minBy=V2,B.stubArray=Ul,B.stubFalse=Wl,B.stubObject=O2,B.stubString=B2,B.stubTrue=T2,B.multiply=H2,B.nth=aC,B.noConflict=x2,B.noop=ql,B.now=ma,B.pad=ZM,B.padEnd=KM,B.padStart=GM,B.parseInt=JM,B.random=zM,B.reduce=cA,B.reduceRight=fA,B.repeat=XM,B.replace=QM,B.result=SM,B.round=Z2,B.runInContext=j,B.sample=dA,B.size=mA,B.snakeCase=t2,B.some=gA,B.sortedIndex=_C,B.sortedIndexBy=pC,B.sortedIndexOf=mC,B.sortedLastIndex=gC,B.sortedLastIndexBy=vC,B.sortedLastIndexOf=yC,B.startCase=r2,B.startsWith=n2,B.subtract=K2,B.sum=G2,B.sumBy=J2,B.template=i2,B.times=I2,B.toFinite=Cn,B.toInteger=Lt,B.toLength=u_,B.toLower=s2,B.toNumber=Ur,B.toSafeInteger=sM,B.toString=ae,B.toUpper=o2,B.trim=a2,B.trimEnd=u2,B.trimStart=l2,B.truncate=c2,B.unescape=f2,B.uniqueId=L2,B.upperCase=h2,B.upperFirst=Rl,B.each=Zd,B.eachRight=Kd,B.first=jd,zl(B,function(){var o={};return on(B,function(l,m){ce.call(B.prototype,m)||(o[m]=l)}),o}(),{chain:!1}),B.VERSION=r,Lr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Lr(["drop","take"],function(o,l){Yt.prototype[o]=function(m){m=m===e?1:We(Lt(m),0);var D=this.__filtered__&&!l?new Yt(this):this.clone();return D.__filtered__?D.__takeCount__=rr(m,D.__takeCount__):D.__views__.push({size:rr(m,ut),type:o+(D.__dir__<0?"Right":"")}),D},Yt.prototype[o+"Right"]=function(m){return this.reverse()[o](m).reverse()}}),Lr(["filter","map","takeWhile"],function(o,l){var m=l+1,D=m==q||m==P;Yt.prototype[o]=function(M){var T=this.clone();return T.__iteratees__.push({iteratee:At(M,3),type:m}),T.__filtered__=T.__filtered__||D,T}}),Lr(["head","last"],function(o,l){var m="take"+(l?"Right":"");Yt.prototype[o]=function(){return this[m](1).value()[0]}}),Lr(["initial","tail"],function(o,l){var m="drop"+(l?"":"Right");Yt.prototype[o]=function(){return this.__filtered__?new Yt(this):this[m](1)}}),Yt.prototype.compact=function(){return this.filter(pr)},Yt.prototype.find=function(o){return this.filter(o).head()},Yt.prototype.findLast=function(o){return this.reverse().find(o)},Yt.prototype.invokeMap=kt(function(o,l){return typeof o=="function"?new Yt(this):this.map(function(m){return Ds(m,o,l)})}),Yt.prototype.reject=function(o){return this.filter(va(At(o)))},Yt.prototype.slice=function(o,l){o=Lt(o);var m=this;return m.__filtered__&&(o>0||l<0)?new Yt(m):(o<0?m=m.takeRight(-o):o&&(m=m.drop(o)),l!==e&&(l=Lt(l),m=l<0?m.dropRight(-l):m.take(l-o)),m)},Yt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Yt.prototype.toArray=function(){return this.take(ut)},on(Yt.prototype,function(o,l){var m=/^(?:filter|find|map|reject)|While$/.test(l),D=/^(?:head|last)$/.test(l),M=B[D?"take"+(l=="last"?"Right":""):l],T=D||/^find/.test(l);M&&(B.prototype[l]=function(){var k=this.__wrapped__,U=D?[1]:arguments,V=k instanceof Yt,tt=U[0],et=V||It(k),ot=function(Ut){var Ht=M.apply(B,qn([Ut],U));return D&&pt?Ht[0]:Ht};et&&m&&typeof tt=="function"&&tt.length!=1&&(V=et=!1);var pt=this.__chain__,Dt=!!this.__actions__.length,Mt=T&&!pt,Pt=V&&!Dt;if(!T&&et){k=Pt?k:new Yt(this);var Ft=o.apply(k,U);return Ft.__actions__.push({func:_a,args:[ot],thisArg:e}),new Pr(Ft,pt)}return Mt&&Pt?o.apply(this,U):(Ft=this.thru(ot),Mt?D?Ft.value()[0]:Ft.value():Ft)})}),Lr(["pop","push","shift","sort","splice","unshift"],function(o){var l=zo[o],m=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var M=arguments;if(D&&!this.__chain__){var T=this.value();return l.apply(It(T)?T:[],M)}return this[m](function(k){return l.apply(It(k)?k:[],M)})}}),on(Yt.prototype,function(o,l){var m=B[l];if(m){var D=m.name+"";ce.call(Hi,D)||(Hi[D]=[]),Hi[D].push({name:l,func:m})}}),Hi[aa(e,v).name]=[{name:"wrapper",func:e}],Yt.prototype.clone=fx,Yt.prototype.reverse=hx,Yt.prototype.value=dx,B.prototype.at=UC,B.prototype.chain=WC,B.prototype.commit=jC,B.prototype.next=YC,B.prototype.plant=HC,B.prototype.reverse=ZC,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=KC,B.prototype.first=B.prototype.head,_s&&(B.prototype[_s]=VC),B},ji=jb();ci?((ci.exports=ji)._=ji,ku._=ji):Je._=ji}).call(Vt)}(Kn,Kn.exports);var Wr=Kn.exports;class D_{constructor(t,e){$(this,"_defaultParams");$(this,"_UserTypeFileds");$(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Wr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Wr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){$(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Wr.cloneDeep(this)}}}}var Zl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e=1e3,r=6e4,n=36e5,s="millisecond",a="second",u="minute",c="hour",f="day",d="week",h="month",_="quarter",g="year",y="date",p="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,x={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(q){var W=["th","st","nd","rd"],P=q%100;return"["+q+(W[(P-20)%10]||W[P]||W[0])+"]"}},b=function(q,W,P){var Z=String(q);return!Z||Z.length>=W?q:""+Array(W+1-Z.length).join(P)+q},C={s:b,z:function(q){var W=-q.utcOffset(),P=Math.abs(W),Z=Math.floor(P/60),Y=P%60;return(W<=0?"+":"-")+b(Z,2,"0")+":"+b(Y,2,"0")},m:function q(W,P){if(W.date()<P.date())return-q(P,W);var Z=12*(P.year()-W.year())+(P.month()-W.month()),Y=W.clone().add(Z,h),G=P-Y<0,X=W.clone().add(Z+(G?-1:1),h);return+(-(Z+(P-Y)/(G?Y-X:X-Y))||0)},a:function(q){return q<0?Math.ceil(q)||0:Math.floor(q)},p:function(q){return{M:h,y:g,w:d,d:f,D:y,h:c,m:u,s:a,ms:s,Q:_}[q]||String(q||"").toLowerCase().replace(/s$/,"")},u:function(q){return q===void 0}},E="en",A={};A[E]=x;var N="$isDayjsObject",S=function(q){return q instanceof L||!(!q||!q[N])},I=function q(W,P,Z){var Y;if(!W)return E;if(typeof W=="string"){var G=W.toLowerCase();A[G]&&(Y=G),P&&(A[G]=P,Y=G);var X=W.split("-");if(!Y&&X.length>1)return q(X[0])}else{var ut=W.name;A[ut]=W,Y=ut}return!Z&&Y&&(E=Y),Y||!Z&&E},F=function(q,W){if(S(q))return q.clone();var P=typeof W=="object"?W:{};return P.date=q,P.args=arguments,new L(P)},O=C;O.l=I,O.i=S,O.w=function(q,W){return F(q,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var L=function(){function q(P){this.$L=I(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[N]=!0}var W=q.prototype;return W.parse=function(P){this.$d=function(Z){var Y=Z.date,G=Z.utc;if(Y===null)return new Date(NaN);if(O.u(Y))return new Date;if(Y instanceof Date)return new Date(Y);if(typeof Y=="string"&&!/Z$/i.test(Y)){var X=Y.match(w);if(X){var ut=X[2]-1||0,_t=(X[7]||"0").substring(0,3);return G?new Date(Date.UTC(X[1],ut,X[3]||1,X[4]||0,X[5]||0,X[6]||0,_t)):new Date(X[1],ut,X[3]||1,X[4]||0,X[5]||0,X[6]||0,_t)}}return new Date(Y)}(P),this.init()},W.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},W.$utils=function(){return O},W.isValid=function(){return this.$d.toString()!==p},W.isSame=function(P,Z){var Y=F(P);return this.startOf(Z)<=Y&&Y<=this.endOf(Z)},W.isAfter=function(P,Z){return F(P)<this.startOf(Z)},W.isBefore=function(P,Z){return this.endOf(Z)<F(P)},W.$g=function(P,Z,Y){return O.u(P)?this[Z]:this.set(Y,P)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(P,Z){var Y=this,G=!!O.u(Z)||Z,X=O.p(P),ut=function(Bt,Nt){var he=O.w(Y.$u?Date.UTC(Y.$y,Nt,Bt):new Date(Y.$y,Nt,Bt),Y);return G?he:he.endOf(f)},_t=function(Bt,Nt){return O.w(Y.toDate()[Bt].apply(Y.toDate("s"),(G?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Y)},at=this.$W,vt=this.$M,wt=this.$D,Ct="set"+(this.$u?"UTC":"");switch(X){case g:return G?ut(1,0):ut(31,11);case h:return G?ut(1,vt):ut(0,vt+1);case d:var bt=this.$locale().weekStart||0,re=(at<bt?at+7:at)-bt;return ut(G?wt-re:wt+(6-re),vt);case f:case y:return _t(Ct+"Hours",0);case c:return _t(Ct+"Minutes",1);case u:return _t(Ct+"Seconds",2);case a:return _t(Ct+"Milliseconds",3);default:return this.clone()}},W.endOf=function(P){return this.startOf(P,!1)},W.$set=function(P,Z){var Y,G=O.p(P),X="set"+(this.$u?"UTC":""),ut=(Y={},Y[f]=X+"Date",Y[y]=X+"Date",Y[h]=X+"Month",Y[g]=X+"FullYear",Y[c]=X+"Hours",Y[u]=X+"Minutes",Y[a]=X+"Seconds",Y[s]=X+"Milliseconds",Y)[G],_t=G===f?this.$D+(Z-this.$W):Z;if(G===h||G===g){var at=this.clone().set(y,1);at.$d[ut](_t),at.init(),this.$d=at.set(y,Math.min(this.$D,at.daysInMonth())).$d}else ut&&this.$d[ut](_t);return this.init(),this},W.set=function(P,Z){return this.clone().$set(P,Z)},W.get=function(P){return this[O.p(P)]()},W.add=function(P,Z){var Y,G=this;P=Number(P);var X=O.p(Z),ut=function(vt){var wt=F(G);return O.w(wt.date(wt.date()+Math.round(vt*P)),G)};if(X===h)return this.set(h,this.$M+P);if(X===g)return this.set(g,this.$y+P);if(X===f)return ut(1);if(X===d)return ut(7);var _t=(Y={},Y[u]=r,Y[c]=n,Y[a]=e,Y)[X]||1,at=this.$d.getTime()+P*_t;return O.w(at,this)},W.subtract=function(P,Z){return this.add(-1*P,Z)},W.format=function(P){var Z=this,Y=this.$locale();if(!this.isValid())return Y.invalidDate||p;var G=P||"YYYY-MM-DDTHH:mm:ssZ",X=O.z(this),ut=this.$H,_t=this.$m,at=this.$M,vt=Y.weekdays,wt=Y.months,Ct=Y.meridiem,bt=function(Nt,he,se,qt){return Nt&&(Nt[he]||Nt(Z,G))||se[he].slice(0,qt)},re=function(Nt){return O.s(ut%12||12,Nt,"0")},Bt=Ct||function(Nt,he,se){var qt=Nt<12?"AM":"PM";return se?qt.toLowerCase():qt};return G.replace(v,function(Nt,he){return he||function(se){switch(se){case"YY":return String(Z.$y).slice(-2);case"YYYY":return O.s(Z.$y,4,"0");case"M":return at+1;case"MM":return O.s(at+1,2,"0");case"MMM":return bt(Y.monthsShort,at,wt,3);case"MMMM":return bt(wt,at);case"D":return Z.$D;case"DD":return O.s(Z.$D,2,"0");case"d":return String(Z.$W);case"dd":return bt(Y.weekdaysMin,Z.$W,vt,2);case"ddd":return bt(Y.weekdaysShort,Z.$W,vt,3);case"dddd":return vt[Z.$W];case"H":return String(ut);case"HH":return O.s(ut,2,"0");case"h":return re(1);case"hh":return re(2);case"a":return Bt(ut,_t,!0);case"A":return Bt(ut,_t,!1);case"m":return String(_t);case"mm":return O.s(_t,2,"0");case"s":return String(Z.$s);case"ss":return O.s(Z.$s,2,"0");case"SSS":return O.s(Z.$ms,3,"0");case"Z":return X}return null}(Nt)||X.replace(":","")})},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(P,Z,Y){var G,X=this,ut=O.p(Z),_t=F(P),at=(_t.utcOffset()-this.utcOffset())*r,vt=this-_t,wt=function(){return O.m(X,_t)};switch(ut){case g:G=wt()/12;break;case h:G=wt();break;case _:G=wt()/3;break;case d:G=(vt-at)/6048e5;break;case f:G=(vt-at)/864e5;break;case c:G=vt/n;break;case u:G=vt/r;break;case a:G=vt/e;break;default:G=vt}return Y?G:O.a(G)},W.daysInMonth=function(){return this.endOf(h).$D},W.$locale=function(){return A[this.$L]},W.locale=function(P,Z){if(!P)return this.$L;var Y=this.clone(),G=I(P,Z,!0);return G&&(Y.$L=G),Y},W.clone=function(){return O.w(this.$d,this)},W.toDate=function(){return new Date(this.valueOf())},W.toJSON=function(){return this.isValid()?this.toISOString():null},W.toISOString=function(){return this.$d.toISOString()},W.toString=function(){return this.$d.toUTCString()},q}(),z=L.prototype;return F.prototype=z,[["$ms",s],["$s",a],["$m",u],["$H",c],["$W",f],["$M",h],["$y",g],["$D",y]].forEach(function(q){z[q[1]]=function(W){return this.$g(W,q[0],q[1])}}),F.extend=function(q,W){return q.$i||(q(W,L,F),q.$i=!0),F},F.locale=I,F.isDayjs=S,F.unix=function(q){return F(1e3*q)},F.en=A[E],F.Ls=A,F.p={},F})})(Zl);var b_=Zl.exports,Wt=Kt(b_),Kl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,a,u){var c=a.prototype;u.utc=function(p){var w={date:p,utc:!0,args:arguments};return new a(w)},c.utc=function(p){var w=u(this.toDate(),{locale:this.$L,utc:!0});return p?w.add(this.utcOffset(),e):w},c.local=function(){return u(this.toDate(),{locale:this.$L,utc:!1})};var f=c.parse;c.parse=function(p){p.utc&&(this.$u=!0),this.$utils().u(p.$offset)||(this.$offset=p.$offset),f.call(this,p)};var d=c.init;c.init=function(){if(this.$u){var p=this.$d;this.$y=p.getUTCFullYear(),this.$M=p.getUTCMonth(),this.$D=p.getUTCDate(),this.$W=p.getUTCDay(),this.$H=p.getUTCHours(),this.$m=p.getUTCMinutes(),this.$s=p.getUTCSeconds(),this.$ms=p.getUTCMilliseconds()}else d.call(this)};var h=c.utcOffset;c.utcOffset=function(p,w){var v=this.$utils().u;if(v(p))return this.$u?0:v(this.$offset)?h.call(this):this.$offset;if(typeof p=="string"&&(p=function(E){E===void 0&&(E="");var A=E.match(r);if(!A)return null;var N=(""+A[0]).match(n)||["-",0,0],S=N[0],I=60*+N[1]+ +N[2];return I===0?0:S==="+"?I:-I}(p),p===null))return this;var x=Math.abs(p)<=16?60*p:p,b=this;if(w)return b.$offset=x,b.$u=p===0,b;if(p!==0){var C=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+C,e)).$offset=x,b.$x.$localOffset=C}else b=this.utc();return b};var _=c.format;c.format=function(p){var w=p||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return _.call(this,w)},c.valueOf=function(){var p=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*p},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var g=c.toDate;c.toDate=function(p){return p==="s"&&this.$offset?u(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var y=c.diff;c.diff=function(p,w,v){if(p&&this.$u===p.$u)return y.call(this,p,w,v);var x=this.local(),b=u(p).local();return y.call(x,b,w,v)}}})})(Kl);var x_=Kl.exports,xa=Kt(x_),Gl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,s,a){var u,c=function(_,g,y){y===void 0&&(y={});var p=new Date(_),w=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",C=v+"|"+b,E=r[C];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[C]=E),E}(g,y);return w.formatToParts(p)},f=function(_,g){for(var y=c(_,g),p=[],w=0;w<y.length;w+=1){var v=y[w],x=v.type,b=v.value,C=e[x];C>=0&&(p[C]=parseInt(b,10))}var E=p[3],A=E===24?0:E,N=p[0]+"-"+p[1]+"-"+p[2]+" "+A+":"+p[4]+":"+p[5]+":000",S=+_;return(a.utc(N).valueOf()-(S-=S%1e3))/6e4},d=s.prototype;d.tz=function(_,g){_===void 0&&(_=u);var y=this.utcOffset(),p=this.toDate(),w=p.toLocaleString("en-US",{timeZone:_}),v=Math.round((p-new Date(w))/1e3/60),x=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(p.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(y-b,"minute")}return x.$x.$timezone=_,x},d.offsetName=function(_){var g=this.$x.$timezone||a.tz.guess(),y=c(this.valueOf(),g,{timeZoneName:_}).find(function(p){return p.type.toLowerCase()==="timezonename"});return y&&y.value};var h=d.startOf;d.startOf=function(_,g){if(!this.$x||!this.$x.$timezone)return h.call(this,_,g);var y=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return h.call(y,_,g).tz(this.$x.$timezone,!0)},a.tz=function(_,g,y){var p=y&&g,w=y||g||u,v=f(+a(),w);if(typeof _!="string")return a(_).tz(w);var x=function(A,N,S){var I=A-60*N*1e3,F=f(I,S);if(N===F)return[I,N];var O=f(I-=60*(F-N)*1e3,S);return F===O?[I,F]:[A-60*Math.min(F,O)*1e3,Math.max(F,O)]}(a.utc(_,p).valueOf(),v,w),b=x[0],C=x[1],E=a(b).utcOffset(C);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(_){u=_}}})})(Gl);var E_=Gl.exports,Ea=Kt(E_),Jl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e="week",r="year";return function(n,s,a){var u=s.prototype;u.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var f=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=a(this).startOf(r).add(1,r).date(f),h=a(this).endOf(e);if(d.isBefore(h))return 1}var _=a(this).startOf(r).date(f).startOf(e).subtract(1,"millisecond"),g=this.diff(_,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},u.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Jl);var C_=Jl.exports,A_=Kt(C_);Wt.extend(xa),Wt.extend(Ea);function He(i,t){return i.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function Fs(i){const t=parseInt(i)||1;let e=i.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function M_(i=10){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";const r=t.length;for(let n=0;n<i;n++)e+=t.charAt(Math.floor(Math.random()*r));return e}function F_(i){const t=/([+-])(\d{1,2})(\d{0,2})/,e=i.replace(/GMT|UTC/,"").match(t);if(!e)return 0;const[,r,n,s]=e,a=parseInt(n,10)*60||0,u=parseInt(s,10)||0;return(r==="+"?1:-1)*(a+u)}function mr(i,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?Wt.utc(i).utcOffset(F_(t)):Wt.tz(i,t)}function gr(i,t){const[e,r]=Fs(i);let n=0;switch(r){case"m":n=60;break;case"s":n=1;break;case"M":return N_(t,Number(e))*24*60*60;case"d":n=24*60*60;break;case"w":n=7*24*60*60;break;default:n=60*60;break}return Math.round(Number(e)*n)}function N_(i,t){const e=Wt(i),r=e.month();let n=0;for(;t>0;){t-=1;const s=r+t,a=e.month(s).daysInMonth();n+=a}return n}function mt(i){return typeof i!="number"||isNaN(i)}function ve(i,t){for(const e of t)i!=null&&i.hasOwnProperty(e)&&i[e]===void 0&&(i[e]=null)}function Xl(i){var t=atob(i),e=decodeURI(t);return e}function Ql(i,t){if(!String(i).includes("."))return i;const e=Math.pow(10,t);return Math.floor(i*e)/e}function tc(i,t=5,e=!1){if(i===void 0)return i;const r=String(i),n=r.indexOf(".");if(n===-1)return i;const s=r.length-n-1;if(s<=t)return i;i=Number(r.replace(".",""));let a=s-t;if(a-2>0){const u=Math.pow(10,a-2);i=Math.round(i/u),a=2}return i=i/Math.pow(10,a),(e?Math.ceil(i):Math.floor(i))/Math.pow(10,t)}function ec(i,t){return tc(i,t,!0)}function rc(i,t){return tc(i,t)}function nc(i){const t=parseInt(i);return i.length>1&&t===1?i.replace("1",""):i}var te=(i=>(i.BOOL="bool",i.INT="int",i.FLOAT="float",i.ARRAY="array",i.BOX="box",i.CHART_POINT="chart.point",i.COLOR="color",i.CONST="const",i.LABEL="label",i.LINE="line",i.LINEFILL="linefill",i.MAP="map",i.MATRIX="matrix",i.POLYLINE="polyline",i.SERIES="series",i.SIMPLE="simple",i.STRING="string",i.TABLE="table",i.UNDETERMINED="undetermined type",i.INPUT="input",i.NA="na",i.VOID="void",i.ENUM="enum",i))(te||{}),Ns=(i=>(i.dividends="dividends",i.none="none",i.splits="splits",i))(Ns||{}),jr=(i=>(i.freqAll="freq_all",i.freqOncePerBar="freq_once_per_bar",i.freqOncePerBarClose="freq_once_per_bar_close",i))(jr||{}),ln=(i=>(i.gapsOff="gaps_off",i.gapsOn="gaps_on",i.lookaheadOff="lookahead_off",i.lookaheadOn="lookahead_on",i))(ln||{}),Ze=(i=>(i.all="all",i.dataWindow="data_window",i.none="none",i.pane="pane",i.priceScale="price_scale",i.statusLine="status_line",i))(Ze||{}),Yr=(i=>(i.both="both",i.left="left",i.none="none",i.right="right",i))(Yr||{}),Gt=(i=>(i.inherit="inherit",i.mintick="mintick",i.percent="percent",i.price="price",i.volume="volume",i))(Gt||{}),Ss=(i=>(i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Ss||{}),ye=(i=>(i.styleArrowdown="style_arrowdown",i.styleArrowup="style_arrowup",i.styleCircle="style_circle",i.styleCross="style_cross",i.styleDiamond="style_diamond",i.styleFlag="style_flag",i.styleLabelCenter="style_label_center",i.styleLabelDown="style_label_down",i.styleLabelLeft="style_label_left",i.styleLabelLowerLeft="style_label_lower_left",i.styleLabelLowerRight="style_label_lower_right",i.styleLabelRight="style_label_right",i.styleLabelUp="style_label_up",i.styleLabelUpperLeft="style_label_upper_left",i.styleLabelUpperRight="style_label_upper_right",i.styleNone="style_none",i.styleSquare="style_square",i.styleTextOutline="style_text_outline",i.styleTriangledown="style_triangledown",i.styleTriangleup="style_triangleup",i.styleXcross="style_xcross",i))(ye||{}),Re=(i=>(i.styleArrowBoth="style_arrow_both",i.styleArrowLeft="style_arrow_left",i.styleArrowRight="style_arrow_right",i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Re||{}),cn=(i=>(i.abovebar="abovebar",i.absolute="absolute",i.belowbar="belowbar",i.bottom="bottom",i.top="top",i))(cn||{}),Gn=(i=>(i.ascending="ascending",i.descending="descending",i))(Gn||{}),Or=(i=>(i.styleArea="Area",i.styleAreabr="Area With Breaks",i.styleCircles="Circles",i.styleColumns="Columns",i.styleCross="Cross",i.styleHistogram="Histogram",i.styleLine="Line",i.styleLinebr="Line With Breaks",i.styleStepline="Step Line",i.styleSteplineDiamond="Step Line With Diamonds",i.styleSteplinebr="Step line with Breaks",i))(Or||{}),vr=(i=>(i.bottomCenter="bottom_center",i.bottomLeft="bottom_left",i.bottomRight="bottom_right",i.middleCenter="middle_center",i.middleLeft="middle_left",i.middleRight="middle_right",i.topCenter="top_center",i.topLeft="top_left",i.topRight="top_right",i))(vr||{}),Os=(i=>(i.left="left",i.none="none",i.right="right",i))(Os||{}),Mn=(i=>(i.extended="extended",i.regular="regular",i))(Mn||{}),lr=(i=>(i.arrowdown="arrowdown",i.arrowup="arrowup",i.circle="circle",i.cross="cross",i.diamond="diamond",i.flag="flag",i.labeldown="labeldown",i.labelup="labelup",i.square="square",i.triangledown="triangledown",i.triangleup="triangleup",i.xcross="xcross",i))(lr||{}),ir=(i=>(i.auto="auto",i.huge="huge",i.large="large",i.normal="normal",i.small="small",i.tiny="tiny",i))(ir||{}),Jn=(i=>(i.familyDefault="default",i.familyMonospace="monospace",i))(Jn||{}),Pe=(i=>(i.cash="cash",i.fixed="fixed",i.percentOfEquity="percent_of_equity",i))(Pe||{}),je=(i=>(i.cashPerContract="cash_per_contract",i.cashPerOrder="cash_per_order",i.percent="percent",i))(je||{}),fe=(i=>(i.all="all",i.long="long",i.short="short",i))(fe||{}),fn=(i=>(i.cancel="cancel",i.none="none",i.reduce="reduce",i))(fn||{}),jt=(i=>(i.alignBottom="align_bottom",i.alignCenter="align_center",i.alignLeft="align_left",i.alignRight="align_right",i.alignTop="align_top",i.wrapAuto="wrap_auto",i.wrapNone="wrap_none",i))(jt||{}),be=(i=>(i.bar_index="bar_index",i.bar_time="bar_time",i))(be||{}),Vr=(i=>(i.abovebar="abovebar",i.belowbar="belowbar",i.price="price",i))(Vr||{}),Bs=(i=>(i.actual="actual",i.estimate="estimate",i.standardized="standardized",i))(Bs||{}),Xn=(i=>(i.traditional="Traditional",i.fibonacci="Fibonacci",i.woodie="Woodie",i.classic="Classic",i.dm="DM",i.camarilla="Camarilla",i))(Xn||{}),sr=(i=>(i.INT="int",i.BOOL="bool",i.TIME="time",i.COLOR="color",i.FLOAT="float",i.PRICE="price",i.SOURCE="source",i.STRING="string",i.SYMBOL="symbol",i.SESSION="session",i.TEXT_AREA="text_area",i.TIMEFRAME="timeframe",i.ENUM="enum",i))(sr||{}),ic=(i=>(i.library="library",i.indicator="indicator",i.strategy="strategy",i))(ic||{}),Rt=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(Rt||{});const ie={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.",arrEmptyErr:"Array must not be empty",arrLengthDiffErr:"Arrays have different lengths",arrTypeErr:"Array type error, the 'array.$name' method can only use $type type array.",inputOptErr:"input's defval should be in options, but '$defval' is not in [$args]",mathRandomErr:"min must be less than max",matrixRehapeErr:"New matrix must be of same area as original matrix",strategyExitErr:"strategy.exit must have at least one of the following parameters: 'profit', 'limit', 'loss', 'stop' or one of the following pairs: 'trail_offset' and 'trail_price' / 'trail_points'. To close the position at market price, use 'strategy.close'",arrLenErr:"Invalid array length",mergeCellErr:"error: start_column > end_column or start_row > end_row",minOrMaxErr:"Input's `defval` value must be between `minval` and `maxval`",requestsNumErr:"Exceeded the maximum number of requests 40",undeterminedTypeMethodErr:"Method calls must specify the type, please add the type to '$name'"},S_={repeatVar:"Shadowing variable '$name' which exists in parent scope. Did you want to use the ':=' operator instead of '=' ?",typeMismatch:"The `$index` parameter of the `$operator` function accepts a '$type' argument. To avoid potential unexpected results, pass a '$type' value or expression to this parameter.",moreSameArg:"More than one '$arg' arguments are supplied. Only the first one will be used.",localScopeGetHistory:"The variable '$name' is declared in local scope, which may not be executed at every update. So, obtaining its historical values may lead to unexpected results",localScopeWarning:"The function '$name' should be called on each calculation for consistency. It is recommended to extract the call from this scope",strategyCalcTickWarn:"Strategies without `calc_on_every_tick = true` only calculate on confirmed chart bars. In this case, `barstate.islast` may not initially return `true` on realtime bars, as the last bar is unconfirmed until it closes. If you need to check whether a bar is the latest before it closes, enable `calc_on_every_tick` in the `strategy()` function.",conditionWarning:"The `condition` parameter of the `$name` accepts a 'bool' argument. To avoid potential unexpected results, pass a 'bool' value or expression to this parameter.",lineWidthWarning:"Passing a value below 1 to `linewidth` will be replaced with 1 during compilation.",boolVarNumWarning:"The `$name` variable casts a numeric value to the 'bool' type. To avoid potential unexpected results, assign a 'bool' value to this variable."};te.SERIES,te.SIMPLE,te.INPUT,te.CONST,te.INT,te.FLOAT,te.BOOL,te.COLOR,te.STRING;const O_=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],B_=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],T_=["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 I_{constructor(t){$(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}slice({id:t,index_from:e,index_to:r}){return t==null?void 0:t.slice({index_from:e,index_to:r})}size({id:t}){return t==null?void 0:t.size()}first({id:t}){return t==null?void 0:t.first()}abs({id:t},e){return t==null?void 0:t.abs(e)}avg({id:t},e){return t==null?void 0:t.avg(e)}binary_search({id:t,val:e},r){return t==null?void 0:t.binary_search({val:e},r)}binary_search_leftmost({id:t,val:e},r){return t==null?void 0:t.binary_search_leftmost({val:e},r)}binary_search_rightmost({id:t,val:e},r){return t==null?void 0:t.binary_search_rightmost({val:e},r)}clear({id:t}){t==null||t.clear()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}covariance({id1:t,id2:e,biased:r},n){return t==null?void 0:t.covariance({id2:e,biased:r},n)}every({id:t},e){return t==null?void 0:t.every(e)}from(t,e){const r=new ee(0,void 0,this._errorListener);return r._value=e,r}fill({id:t,value:e,index_from:r,index_to:n}){t==null||t.fill({value:e,index_from:r,index_to:n})}get({id:t,index:e}){return t==null?void 0:t.get({index:e})}includes({id:t,value:e}){return t==null?void 0:t.includes({value:e})}indexof({id:t,value:e}){return t==null?void 0:t.indexof({value:e})}insert({id:t,index:e,value:r}){t==null||t.insert({index:e,value:r})}join({id:t,separator:e},r){return t==null?void 0:t.join({separator:e},r)}last({id:t}){return t==null?void 0:t.last()}lastindexof({id:t,value:e}){return t==null?void 0:t.lastindexof({value:e})}max({id:t,nth:e},r){return t==null?void 0:t.max({nth:e},r)}median({id:t},e){return t==null?void 0:t.median(e)}min({id:t,nth:e},r){return t==null?void 0:t.min({nth:e},r)}mode({id:t},e){return t==null?void 0:t.mode(e)}percentile_linear_interpolation({id:t,percentage:e},r){return t==null?void 0:t.percentile_linear_interpolation({percentage:e},r)}percentile_nearest_rank({id:t,percentage:e},r){return t==null?void 0:t.percentile_nearest_rank({percentage:e},r)}percentrank({id:t,index:e},r){return t==null?void 0:t.percentrank({index:e},r)}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t},e){return t==null?void 0:t.range(e)}remove({id:t,index:e}){return t==null?void 0:t.remove({index:e})}reverse({id:t}){return t==null?void 0:t.reverse()}set({id:t,index:e,value:r}){t==null||t.set({index:e,value:r})}shift({id:t}){return t==null?void 0:t.shift()}some({id:t},e){return t==null?void 0:t.some(e)}sort({id:t,order:e},r){t==null||t.sort({order:e},r)}sort_indices({id:t,order:e},r){return t==null?void 0:t.sort_indices({order:e},r)}standardize({id:t},e){return t==null?void 0:t.standardize(e)}stdev({id:t,biased:e},r){return t==null?void 0:t.stdev({biased:e},r)}sum({id:t},e){return t==null?void 0:t.sum(e)}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e},r){return t==null?void 0:t.variance({biased:e},r)}}class ee{constructor(t=0,e,r){$(this,"_arrInstance");$(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Wr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Wr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new ee(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new ee(0,void 0,this._errorListener);return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(t){const e=new ee(0,void 0,this._errorListener);this._verifySimpleType("number","abs","int/float",t);const r=this._arrInstance.map(n=>Math.abs(n));return e._copyData(r),e}avg(t){return this._verifySimpleType("number","avg","int/float",t),Wr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),mt(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),mt(t)?this._arrInstance.length-1:this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t},e){return this._verifySimpleType("number","binary_search_rightmost","int/float",e),mt(t)?this._arrInstance.length:this._binarySearchRightMost(this._arrInstance,t)}clear(){this._arrInstance=[]}concat({id2:t}){return this._arrInstance=this._arrInstance.concat(t==null?void 0:t._value),this}covariance({id2:t,biased:e},r){return this._verifySimpleType("number","covariance","int/float",r),this._verifySimpleType("number","covariance","int/float",r,t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e,r)}every(t){return this._verifySimpleType("number|boolean","every","int/float/bool",t),this._arrInstance.every(e=>!!e)}fill({value:t,index_from:e=0,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index:t}){if(!mt(t))return this._arrInstance[t]}includes({value:t}){return this._arrInstance.includes(t)}indexof({value:t}){return this._arrInstance.indexOf(t)}insert({index:t,value:e}){mt(t)||this._arrInstance.splice(t,0,e)}join({separator:t}={},e){return this._verifySimpleType("number|string","join","int/float/string",e),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={},e){return this._verifySimpleType("number","max","int/float",e),this._maxNth([...this._arrInstance],t)}median(t){return this._verifySimpleType("number","median","int/float",t),this._median([...this._arrInstance])}min({nth:t}={},e){return this._verifySimpleType("number","min","int/float",e),this._minNth([...this._arrInstance],t)}mode(t){return this._verifySimpleType("number","mode","int/float",t),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t},e){return this._verifySimpleType("number","percentile_linear_interpolation","int/float",e),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t=0},e){var r;if(this._arrInstance.length===0||t<0||t>100||mt(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,Rt.Error);return}return this._verifySimpleType("number","percentile_nearest_rank","int/float",e),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t},e){return this._verifySimpleType("number","percentrank","int/float",e),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(t){var s;if(this._arrInstance.length===0){(s=this._errorListener)==null||s.addError(ie.arrEmptyErr,t,Rt.Error);return}this._verifySimpleType("number","range","int/float",t);const e=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-e}remove({index:t}){if(!mt(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){mt(t)||(this._arrInstance[t]=e)}shift(){return this._arrInstance.shift()}some(t){return this._verifySimpleType("number|boolean","some","int/float/bool",t),this._arrInstance.some(e=>!!e)}sort({order:t}={},e){this._verifySimpleType("number","sort","int/float",e),this._arrInstance.sort((r,n)=>t!==Gn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((s,a)=>a);r.sort((s,a)=>t!==Gn.descending?this._arrInstance[s]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[s]);const n=new ee(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new ee(0,void 0,this._errorListener);return e._copyData(this._standardizeArray([...this._arrInstance])),e}stdev({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ie.arrEmptyErr,e,Rt.Error);return}return this._verifySimpleType("number","stdev","int/float",e),this._calculateStandardDeviations([...this._arrInstance],t)}sum(t){return this._verifySimpleType("number","sum","int/float",t),this._arrInstance.reduce((r,n)=>r+(n||0),0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ie.arrEmptyErr,e,Rt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,u)=>a+(u||0),0)/t.length,n=t.reduce((a,u)=>a+((u||0)-r)**2,0),s=n/t.length;return e?s:t.length>1?n/(t.length-1):s}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,u)=>a+(u||0),0)/t.length,n=t.reduce((a,u)=>{const c=(u||0)-r;return a+c*c},0),s=Math.sqrt(n/t.length);return e?s:t.length>1?Math.sqrt(n/(t.length-1)):s}_standardizeArray(t){const e=t.reduce((s,a)=>s+(a||0),0)/t.length,r=Math.sqrt(t.reduce((s,a)=>s+Math.pow((a||0)-e,2),0)/t.length);return t.map(s=>((s||0)-e)/r)}_getPercentileRank(t,e=0){if(mt(e))return;const r=t[e];let n=0;for(let a=0;a<t.length;a++)(t[a]<r||t[a]===r&&a!=e)&&n++;return n/(t.length-1)*100}_getNearestRankPercentile(t,e=0){const r=t.slice().sort((a,u)=>a-u),n=e/100*r.length,s=Math.ceil(n)-1;return r[s>=r.length?r.length-1:s]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||mt(e))return;t.sort(function(s,a){return s-a});const r=t.length;e/=100;const n=1/(r*2);if(e<=n)return t[0];if(e>=1-1/(r*2))return t[r-1];for(const[s,a]of t.entries()){const u=t[s-1];if(e<(s+.5)/r)return u+(a-u)*(e-(s-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const s of t)e[s]=(e[s]||0)+1,r=Math.max(r,e[s]);for(const s in e)e[s]===r&&n.push(Number(s));return Math.min(...r===1?t:n)}_median(t){t.sort(function(r,n){return r-n});const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}_minNth(t,e=0){return t.sort(function(r,n){return r-n}),t[e]}_maxNth(t,e=0){return t.sort(function(r,n){return n-r}),t[e]}_setElements(t,e,r=0,n){n===void 0&&(n=t.length);for(let s=r;s<n;s++)t[s]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(ie.arrLengthDiffErr,n,Rt.Error);return}t=t.filter(f=>f!==void 0),e=e.filter(f=>f!==void 0);const s=t.reduce((f,d)=>f+d,0)/t.length,a=e.reduce((f,d)=>f+d,0)/e.length;let u=0;for(let f=0;f<t.length;f++)u+=(t[f]-s)*(e[f]-a);return r?u/t.length:u/(t.length-1)}_verifySimpleType(t,e,r,n,s=this._arrInstance){var u;s.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((u=this._errorListener)==null||u.addError(He(ie.arrTypeErr,{name:e,type:r}),n,Rt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const s=Math.floor((r+n)/2);if(t[s]===e)return s;t[s]<e?r=s+1:n=s-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<e?r=a+1:n=a-1}return s.length?Math.min(...s):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<=e?r=a+1:n=a-1}return s.length?Math.max(...s):r}}class $_{constructor(t,e){$(this,"_randomNums");$(this,"_mintick");$(this,"_cacheData");$(this,"_barIndex");$(this,"_errorListener");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0,this._errorListener=e}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){if(!mt(t))return Math.abs(t)}acos({angle:t}){if(mt(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(mt(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(mt(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Wr.mean(e)}ceil({number:t}){if(!mt(t))return Math.ceil(t)}floor({number:t}){if(!mt(t))return Math.floor(t)}cos({angle:t}){if(mt(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(mt(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(mt(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!mt(t))return Math.exp(t)}log({number:t}){if(!mt(t))return Math.log(t)}log10({number:t}){if(!mt(t))return Math.log10(t)}max(t,e){if(!e.some(r=>mt(r)))return Math.max(...e)}min(t,e){if(!e.some(r=>mt(r)))return Math.min(...e)}pow({base:t,exponent:e}){if(!(mt(t)||mt(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(mt(t)&&(t=0),mt(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(ie.mathRandomErr,n,Rt.Error);return}let s;do s=Math.random()*(e-t)+t;while(s===t||s===e);return r&&(this._randomNums[r]=s),s}round({number:t,precision:e}){if(!mt(t))return mt(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!mt(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!mt(t))return t&&Math.sign(t)}sqrt({number:t}){if(!mt(t))return Math.sqrt(t)}sum({source:t,length:e=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=t,this._cacheData[`sum_${r}`]=n;const s=n.filter(a=>!mt(a));if(!(s.length<e))return Wr.sum(s.slice(-e))}todegrees({radians:t}){if(!mt(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!mt(t))return t*(Math.PI/180)}}function Ts(){return Ts=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},Ts.apply(this,arguments)}var sc={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function me(i){return typeof i=="number"}function Oe(i){return!i||typeof i!="object"||typeof i.constructor!="function"?!1:i.isBigNumber===!0&&typeof i.constructor.prototype=="object"&&i.constructor.prototype.isBigNumber===!0||typeof i.constructor.isDecimal=="function"&&i.constructor.isDecimal(i)===!0}function oc(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isComplex===!0||!1}function ac(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isFraction===!0||!1}function uc(i){return i&&i.constructor.prototype.isUnit===!0||!1}function en(i){return typeof i=="string"}var Ae=Array.isArray;function we(i){return i&&i.constructor.prototype.isMatrix===!0||!1}function ts(i){return Array.isArray(i)||we(i)}function L_(i){return i&&i.isDenseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function R_(i){return i&&i.isSparseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function P_(i){return i&&i.constructor.prototype.isRange===!0||!1}function Ca(i){return i&&i.constructor.prototype.isIndex===!0||!1}function k_(i){return typeof i=="boolean"}function z_(i){return i&&i.constructor.prototype.isResultSet===!0||!1}function q_(i){return i&&i.constructor.prototype.isHelp===!0||!1}function U_(i){return typeof i=="function"}function W_(i){return i instanceof Date}function j_(i){return i instanceof RegExp}function Aa(i){return!!(i&&typeof i=="object"&&i.constructor===Object&&!oc(i)&&!ac(i))}function Y_(i){return i===null}function V_(i){return i===void 0}function H_(i){return i&&i.isAccessorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Z_(i){return i&&i.isArrayNode===!0&&i.constructor.prototype.isNode===!0||!1}function K_(i){return i&&i.isAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function G_(i){return i&&i.isBlockNode===!0&&i.constructor.prototype.isNode===!0||!1}function J_(i){return i&&i.isConditionalNode===!0&&i.constructor.prototype.isNode===!0||!1}function X_(i){return i&&i.isConstantNode===!0&&i.constructor.prototype.isNode===!0||!1}function Q_(i){return i&&i.isFunctionAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function tp(i){return i&&i.isFunctionNode===!0&&i.constructor.prototype.isNode===!0||!1}function ep(i){return i&&i.isIndexNode===!0&&i.constructor.prototype.isNode===!0||!1}function rp(i){return i&&i.isNode===!0&&i.constructor.prototype.isNode===!0||!1}function np(i){return i&&i.isObjectNode===!0&&i.constructor.prototype.isNode===!0||!1}function ip(i){return i&&i.isOperatorNode===!0&&i.constructor.prototype.isNode===!0||!1}function sp(i){return i&&i.isParenthesisNode===!0&&i.constructor.prototype.isNode===!0||!1}function op(i){return i&&i.isRangeNode===!0&&i.constructor.prototype.isNode===!0||!1}function ap(i){return i&&i.isRelationalNode===!0&&i.constructor.prototype.isNode===!0||!1}function up(i){return i&&i.isSymbolNode===!0&&i.constructor.prototype.isNode===!0||!1}function lp(i){return i&&i.constructor.prototype.isChain===!0||!1}function Fn(i){var t=typeof i;return t==="object"?i===null?"null":Oe(i)?"BigNumber":i.constructor&&i.constructor.name?i.constructor.name:"Object":t}function ue(i){var t=typeof i;if(t==="number"||t==="string"||t==="boolean"||i===null||i===void 0)return i;if(typeof i.clone=="function")return i.clone();if(Array.isArray(i))return i.map(function(e){return ue(e)});if(i instanceof Date)return new Date(i.valueOf());if(Oe(i))return i;if(Aa(i))return cp(i,ue);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(i,")"))}function cp(i,t){var e={};for(var r in i)es(i,r)&&(e[r]=t(i[r]));return e}function lc(i,t){for(var e in t)es(t,e)&&(i[e]=t[e]);return i}function yi(i,t){var e,r,n;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(r=0,n=i.length;r<n;r++)if(!yi(i[r],t[r]))return!1;return!0}else{if(typeof i=="function")return i===t;if(i instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in i)if(!(e in t)||!yi(i[e],t[e]))return!1;for(e in t)if(!(e in i))return!1;return!0}else return i===t}}function es(i,t){return i&&Object.hasOwnProperty.call(i,t)}function fp(i,t){for(var e={},r=0;r<t.length;r++){var n=t[r],s=i[n];s!==void 0&&(e[n]=s)}return e}var hp=["Matrix","Array"],dp=["number","BigNumber","Fraction"],yr=function(t){if(t)throw new Error(`The global config is readonly.
|
27
|
+
}`;var Pt=v_(function(){return ne(T,Dt+"return "+ot).apply(e,k)});if(Pt.source=ot,Tl(Pt))throw Pt;return Pt}function s2(o){return ae(o).toLowerCase()}function o2(o){return ae(o).toUpperCase()}function a2(o,l,m){if(o=ae(o),o&&(m||l===e))return M0(o);if(!o||!(l=Mr(l)))return o;var D=Gr(o),M=Gr(l),T=F0(D,M),k=N0(D,M)+1;return Hn(D,T,k).join("")}function u2(o,l,m){if(o=ae(o),o&&(m||l===e))return o.slice(0,O0(o)+1);if(!o||!(l=Mr(l)))return o;var D=Gr(o),M=N0(D,Gr(l))+1;return Hn(D,0,M).join("")}function l2(o,l,m){if(o=ae(o),o&&(m||l===e))return o.replace(hs,"");if(!o||!(l=Mr(l)))return o;var D=Gr(o),M=F0(D,Gr(l));return Hn(D,M).join("")}function c2(o,l){var m=F,D=O;if(Fe(l)){var M="separator"in l?l.separator:M;m="length"in l?Lt(l.length):m,D="omission"in l?Mr(l.omission):D}o=ae(o);var T=o.length;if(Ui(o)){var k=Gr(o);T=k.length}if(m>=T)return o;var U=m-Wi(D);if(U<1)return D;var V=k?Hn(k,0,U).join(""):o.slice(0,U);if(M===e)return V+D;if(k&&(U+=V.length-U),Il(M)){if(o.slice(U).search(M)){var tt,et=V;for(M.global||(M=Gu(M.source,ae(Io.exec(M))+"g")),M.lastIndex=0;tt=M.exec(et);)var ot=tt.index;V=V.slice(0,ot===e?U:ot)}}else if(o.indexOf(Mr(M),U)!=U){var pt=V.lastIndexOf(M);pt>-1&&(V=V.slice(0,pt))}return V+D}function f2(o){return o=ae(o),o&&fu.test(o)?o.replace(ui,zb):o}var h2=Gi(function(o,l,m){return o+(m?" ":"")+l.toUpperCase()}),Rl=yd("toUpperCase");function g_(o,l,m){return o=ae(o),l=m?e:l,l===e?$b(o)?Wb(o):Ab(o):o.match(l)||[]}var v_=kt(function(o,l){try{return Cr(o,e,l)}catch(m){return Tl(m)?m:new Tt(m)}}),d2=bn(function(o,l){return Lr(l,function(m){m=un(m),wn(o,m,Ol(o[m],o))}),o});function _2(o){var l=o==null?0:o.length,m=At();return o=l?Ce(o,function(D){if(typeof D[1]!="function")throw new Rr(a);return[m(D[0]),D[1]]}):[],kt(function(D){for(var M=-1;++M<l;){var T=o[M];if(Cr(T[0],this,D))return Cr(T[1],this,D)}})}function p2(o){return zx(kr(o,h))}function Pl(o){return function(){return o}}function m2(o,l){return o==null||o!==o?l:o}var g2=Dd(),v2=Dd(!0);function pr(o){return o}function kl(o){return J0(typeof o=="function"?o:kr(o,h))}function y2(o){return Q0(kr(o,h))}function w2(o,l){return td(o,kr(l,h))}var D2=kt(function(o,l){return function(m){return Ds(m,o,l)}}),b2=kt(function(o,l){return function(m){return Ds(o,m,l)}});function zl(o,l,m){var D=Ve(l),M=ra(l,D);m==null&&!(Fe(l)&&(M.length||!D.length))&&(m=l,l=o,o=this,M=ra(l,Ve(l)));var T=!(Fe(m)&&"chain"in m)||!!m.chain,k=En(o);return Lr(M,function(U){var V=l[U];o[U]=V,k&&(o.prototype[U]=function(){var tt=this.__chain__;if(T||tt){var et=o(this.__wrapped__),ot=et.__actions__=hr(this.__actions__);return ot.push({func:V,args:arguments,thisArg:o}),et.__chain__=tt,et}return V.apply(o,qn([this.value()],arguments))})}),o}function x2(){return Je._===this&&(Je._=Kb),this}function ql(){}function E2(o){return o=Lt(o),kt(function(l){return ed(l,o)})}var C2=vl(Ce),A2=vl(b0),M2=vl(Wu);function y_(o){return Cl(o)?ju(un(o)):nE(o)}function F2(o){return function(l){return o==null?e:pi(o,l)}}var N2=xd(),S2=xd(!0);function Ul(){return[]}function Wl(){return!1}function O2(){return{}}function B2(){return""}function T2(){return!0}function I2(o,l){if(o=Lt(o),o<1||o>Y)return[];var m=ut,D=rr(o,ut);l=At(l),o-=ut;for(var M=Hu(D,l);++m<o;)l(m);return M}function $2(o){return It(o)?Ce(o,un):Fr(o)?[o]:hr(kd(ae(o)))}function L2(o){var l=++Hb;return ae(o)+l}var R2=ua(function(o,l){return o+l},0),P2=yl("ceil"),k2=ua(function(o,l){return o/l},1),z2=yl("floor");function q2(o){return o&&o.length?ea(o,pr,il):e}function U2(o,l){return o&&o.length?ea(o,At(l,2),il):e}function W2(o){return C0(o,pr)}function j2(o,l){return C0(o,At(l,2))}function Y2(o){return o&&o.length?ea(o,pr,ul):e}function V2(o,l){return o&&o.length?ea(o,At(l,2),ul):e}var H2=ua(function(o,l){return o*l},1),Z2=yl("round"),K2=ua(function(o,l){return o-l},0);function G2(o){return o&&o.length?Vu(o,pr):0}function J2(o,l){return o&&o.length?Vu(o,At(l,2)):0}return B.after=yA,B.ary=Gd,B.assign=oM,B.assignIn=c_,B.assignInWith=Da,B.assignWith=aM,B.at=uM,B.before=Jd,B.bind=Ol,B.bindAll=d2,B.bindKey=Xd,B.castArray=OA,B.chain=Hd,B.chunk=zE,B.compact=qE,B.concat=UE,B.cond=_2,B.conforms=p2,B.constant=Pl,B.countBy=GC,B.create=lM,B.curry=Qd,B.curryRight=t_,B.debounce=e_,B.defaults=cM,B.defaultsDeep=fM,B.defer=wA,B.delay=DA,B.difference=WE,B.differenceBy=jE,B.differenceWith=YE,B.drop=VE,B.dropRight=HE,B.dropRightWhile=ZE,B.dropWhile=KE,B.fill=GE,B.filter=XC,B.flatMap=eA,B.flatMapDeep=rA,B.flatMapDepth=nA,B.flatten=Wd,B.flattenDeep=JE,B.flattenDepth=XE,B.flip=bA,B.flow=g2,B.flowRight=v2,B.fromPairs=QE,B.functions=vM,B.functionsIn=yM,B.groupBy=iA,B.initial=eC,B.intersection=rC,B.intersectionBy=nC,B.intersectionWith=iC,B.invert=DM,B.invertBy=bM,B.invokeMap=oA,B.iteratee=kl,B.keyBy=aA,B.keys=Ve,B.keysIn=_r,B.map=pa,B.mapKeys=EM,B.mapValues=CM,B.matches=y2,B.matchesProperty=w2,B.memoize=ga,B.merge=AM,B.mergeWith=f_,B.method=D2,B.methodOf=b2,B.mixin=zl,B.negate=va,B.nthArg=E2,B.omit=MM,B.omitBy=FM,B.once=xA,B.orderBy=uA,B.over=C2,B.overArgs=EA,B.overEvery=A2,B.overSome=M2,B.partial=Bl,B.partialRight=r_,B.partition=lA,B.pick=NM,B.pickBy=h_,B.property=y_,B.propertyOf=F2,B.pull=uC,B.pullAll=Yd,B.pullAllBy=lC,B.pullAllWith=cC,B.pullAt=fC,B.range=N2,B.rangeRight=S2,B.rearg=CA,B.reject=hA,B.remove=hC,B.rest=AA,B.reverse=Nl,B.sampleSize=_A,B.set=OM,B.setWith=BM,B.shuffle=pA,B.slice=dC,B.sortBy=vA,B.sortedUniq=wC,B.sortedUniqBy=DC,B.split=e2,B.spread=MA,B.tail=bC,B.take=xC,B.takeRight=EC,B.takeRightWhile=CC,B.takeWhile=AC,B.tap=qC,B.throttle=FA,B.thru=_a,B.toArray=a_,B.toPairs=d_,B.toPairsIn=__,B.toPath=$2,B.toPlainObject=l_,B.transform=TM,B.unary=NA,B.union=MC,B.unionBy=FC,B.unionWith=NC,B.uniq=SC,B.uniqBy=OC,B.uniqWith=BC,B.unset=IM,B.unzip=Sl,B.unzipWith=Vd,B.update=$M,B.updateWith=LM,B.values=Qi,B.valuesIn=RM,B.without=TC,B.words=g_,B.wrap=SA,B.xor=IC,B.xorBy=$C,B.xorWith=LC,B.zip=RC,B.zipObject=PC,B.zipObjectDeep=kC,B.zipWith=zC,B.entries=d_,B.entriesIn=__,B.extend=c_,B.extendWith=Da,zl(B,B),B.add=R2,B.attempt=v_,B.camelCase=qM,B.capitalize=p_,B.ceil=P2,B.clamp=PM,B.clone=BA,B.cloneDeep=IA,B.cloneDeepWith=$A,B.cloneWith=TA,B.conformsTo=LA,B.deburr=m_,B.defaultTo=m2,B.divide=k2,B.endsWith=UM,B.eq=Xr,B.escape=WM,B.escapeRegExp=jM,B.every=JC,B.find=QC,B.findIndex=qd,B.findKey=hM,B.findLast=tA,B.findLastIndex=Ud,B.findLastKey=dM,B.floor=z2,B.forEach=Zd,B.forEachRight=Kd,B.forIn=_M,B.forInRight=pM,B.forOwn=mM,B.forOwnRight=gM,B.get=$l,B.gt=RA,B.gte=PA,B.has=wM,B.hasIn=Ll,B.head=jd,B.identity=pr,B.includes=sA,B.indexOf=tC,B.inRange=kM,B.invoke=xM,B.isArguments=vi,B.isArray=It,B.isArrayBuffer=kA,B.isArrayLike=dr,B.isArrayLikeObject=Be,B.isBoolean=zA,B.isBuffer=Zn,B.isDate=qA,B.isElement=UA,B.isEmpty=WA,B.isEqual=jA,B.isEqualWith=YA,B.isError=Tl,B.isFinite=VA,B.isFunction=En,B.isInteger=n_,B.isLength=ya,B.isMap=i_,B.isMatch=HA,B.isMatchWith=ZA,B.isNaN=KA,B.isNative=GA,B.isNil=XA,B.isNull=JA,B.isNumber=s_,B.isObject=Fe,B.isObjectLike=Ne,B.isPlainObject=Ms,B.isRegExp=Il,B.isSafeInteger=QA,B.isSet=o_,B.isString=wa,B.isSymbol=Fr,B.isTypedArray=Xi,B.isUndefined=tM,B.isWeakMap=eM,B.isWeakSet=rM,B.join=sC,B.kebabCase=YM,B.last=qr,B.lastIndexOf=oC,B.lowerCase=VM,B.lowerFirst=HM,B.lt=nM,B.lte=iM,B.max=q2,B.maxBy=U2,B.mean=W2,B.meanBy=j2,B.min=Y2,B.minBy=V2,B.stubArray=Ul,B.stubFalse=Wl,B.stubObject=O2,B.stubString=B2,B.stubTrue=T2,B.multiply=H2,B.nth=aC,B.noConflict=x2,B.noop=ql,B.now=ma,B.pad=ZM,B.padEnd=KM,B.padStart=GM,B.parseInt=JM,B.random=zM,B.reduce=cA,B.reduceRight=fA,B.repeat=XM,B.replace=QM,B.result=SM,B.round=Z2,B.runInContext=j,B.sample=dA,B.size=mA,B.snakeCase=t2,B.some=gA,B.sortedIndex=_C,B.sortedIndexBy=pC,B.sortedIndexOf=mC,B.sortedLastIndex=gC,B.sortedLastIndexBy=vC,B.sortedLastIndexOf=yC,B.startCase=r2,B.startsWith=n2,B.subtract=K2,B.sum=G2,B.sumBy=J2,B.template=i2,B.times=I2,B.toFinite=Cn,B.toInteger=Lt,B.toLength=u_,B.toLower=s2,B.toNumber=Ur,B.toSafeInteger=sM,B.toString=ae,B.toUpper=o2,B.trim=a2,B.trimEnd=u2,B.trimStart=l2,B.truncate=c2,B.unescape=f2,B.uniqueId=L2,B.upperCase=h2,B.upperFirst=Rl,B.each=Zd,B.eachRight=Kd,B.first=jd,zl(B,function(){var o={};return on(B,function(l,m){ce.call(B.prototype,m)||(o[m]=l)}),o}(),{chain:!1}),B.VERSION=r,Lr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Lr(["drop","take"],function(o,l){Yt.prototype[o]=function(m){m=m===e?1:We(Lt(m),0);var D=this.__filtered__&&!l?new Yt(this):this.clone();return D.__filtered__?D.__takeCount__=rr(m,D.__takeCount__):D.__views__.push({size:rr(m,ut),type:o+(D.__dir__<0?"Right":"")}),D},Yt.prototype[o+"Right"]=function(m){return this.reverse()[o](m).reverse()}}),Lr(["filter","map","takeWhile"],function(o,l){var m=l+1,D=m==q||m==R;Yt.prototype[o]=function(M){var T=this.clone();return T.__iteratees__.push({iteratee:At(M,3),type:m}),T.__filtered__=T.__filtered__||D,T}}),Lr(["head","last"],function(o,l){var m="take"+(l?"Right":"");Yt.prototype[o]=function(){return this[m](1).value()[0]}}),Lr(["initial","tail"],function(o,l){var m="drop"+(l?"":"Right");Yt.prototype[o]=function(){return this.__filtered__?new Yt(this):this[m](1)}}),Yt.prototype.compact=function(){return this.filter(pr)},Yt.prototype.find=function(o){return this.filter(o).head()},Yt.prototype.findLast=function(o){return this.reverse().find(o)},Yt.prototype.invokeMap=kt(function(o,l){return typeof o=="function"?new Yt(this):this.map(function(m){return Ds(m,o,l)})}),Yt.prototype.reject=function(o){return this.filter(va(At(o)))},Yt.prototype.slice=function(o,l){o=Lt(o);var m=this;return m.__filtered__&&(o>0||l<0)?new Yt(m):(o<0?m=m.takeRight(-o):o&&(m=m.drop(o)),l!==e&&(l=Lt(l),m=l<0?m.dropRight(-l):m.take(l-o)),m)},Yt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Yt.prototype.toArray=function(){return this.take(ut)},on(Yt.prototype,function(o,l){var m=/^(?:filter|find|map|reject)|While$/.test(l),D=/^(?:head|last)$/.test(l),M=B[D?"take"+(l=="last"?"Right":""):l],T=D||/^find/.test(l);M&&(B.prototype[l]=function(){var k=this.__wrapped__,U=D?[1]:arguments,V=k instanceof Yt,tt=U[0],et=V||It(k),ot=function(Ut){var Ht=M.apply(B,qn([Ut],U));return D&&pt?Ht[0]:Ht};et&&m&&typeof tt=="function"&&tt.length!=1&&(V=et=!1);var pt=this.__chain__,Dt=!!this.__actions__.length,Mt=T&&!pt,Pt=V&&!Dt;if(!T&&et){k=Pt?k:new Yt(this);var Ft=o.apply(k,U);return Ft.__actions__.push({func:_a,args:[ot],thisArg:e}),new Pr(Ft,pt)}return Mt&&Pt?o.apply(this,U):(Ft=this.thru(ot),Mt?D?Ft.value()[0]:Ft.value():Ft)})}),Lr(["pop","push","shift","sort","splice","unshift"],function(o){var l=zo[o],m=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var M=arguments;if(D&&!this.__chain__){var T=this.value();return l.apply(It(T)?T:[],M)}return this[m](function(k){return l.apply(It(k)?k:[],M)})}}),on(Yt.prototype,function(o,l){var m=B[l];if(m){var D=m.name+"";ce.call(Hi,D)||(Hi[D]=[]),Hi[D].push({name:l,func:m})}}),Hi[aa(e,v).name]=[{name:"wrapper",func:e}],Yt.prototype.clone=fx,Yt.prototype.reverse=hx,Yt.prototype.value=dx,B.prototype.at=UC,B.prototype.chain=WC,B.prototype.commit=jC,B.prototype.next=YC,B.prototype.plant=HC,B.prototype.reverse=ZC,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=KC,B.prototype.first=B.prototype.head,_s&&(B.prototype[_s]=VC),B},ji=jb();ci?((ci.exports=ji)._=ji,ku._=ji):Je._=ji}).call(Vt)}(Kn,Kn.exports);var Wr=Kn.exports;class D_{constructor(t,e){$(this,"_defaultParams");$(this,"_UserTypeFileds");$(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Wr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Wr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){$(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Wr.cloneDeep(this)}}}}var Zl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e=1e3,r=6e4,n=36e5,s="millisecond",a="second",u="minute",c="hour",f="day",d="week",h="month",_="quarter",g="year",y="date",p="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,x={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(q){var W=["th","st","nd","rd"],R=q%100;return"["+q+(W[(R-20)%10]||W[R]||W[0])+"]"}},b=function(q,W,R){var Z=String(q);return!Z||Z.length>=W?q:""+Array(W+1-Z.length).join(R)+q},C={s:b,z:function(q){var W=-q.utcOffset(),R=Math.abs(W),Z=Math.floor(R/60),Y=R%60;return(W<=0?"+":"-")+b(Z,2,"0")+":"+b(Y,2,"0")},m:function q(W,R){if(W.date()<R.date())return-q(R,W);var Z=12*(R.year()-W.year())+(R.month()-W.month()),Y=W.clone().add(Z,h),G=R-Y<0,Q=W.clone().add(Z+(G?-1:1),h);return+(-(Z+(R-Y)/(G?Y-Q:Q-Y))||0)},a:function(q){return q<0?Math.ceil(q)||0:Math.floor(q)},p:function(q){return{M:h,y:g,w:d,d:f,D:y,h:c,m:u,s:a,ms:s,Q:_}[q]||String(q||"").toLowerCase().replace(/s$/,"")},u:function(q){return q===void 0}},E="en",A={};A[E]=x;var N="$isDayjsObject",S=function(q){return q instanceof L||!(!q||!q[N])},I=function q(W,R,Z){var Y;if(!W)return E;if(typeof W=="string"){var G=W.toLowerCase();A[G]&&(Y=G),R&&(A[G]=R,Y=G);var Q=W.split("-");if(!Y&&Q.length>1)return q(Q[0])}else{var ut=W.name;A[ut]=W,Y=ut}return!Z&&Y&&(E=Y),Y||!Z&&E},F=function(q,W){if(S(q))return q.clone();var R=typeof W=="object"?W:{};return R.date=q,R.args=arguments,new L(R)},O=C;O.l=I,O.i=S,O.w=function(q,W){return F(q,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var L=function(){function q(R){this.$L=I(R.locale,null,!0),this.parse(R),this.$x=this.$x||R.x||{},this[N]=!0}var W=q.prototype;return W.parse=function(R){this.$d=function(Z){var Y=Z.date,G=Z.utc;if(Y===null)return new Date(NaN);if(O.u(Y))return new Date;if(Y instanceof Date)return new Date(Y);if(typeof Y=="string"&&!/Z$/i.test(Y)){var Q=Y.match(w);if(Q){var ut=Q[2]-1||0,_t=(Q[7]||"0").substring(0,3);return G?new Date(Date.UTC(Q[1],ut,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,_t)):new Date(Q[1],ut,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,_t)}}return new Date(Y)}(R),this.init()},W.init=function(){var R=this.$d;this.$y=R.getFullYear(),this.$M=R.getMonth(),this.$D=R.getDate(),this.$W=R.getDay(),this.$H=R.getHours(),this.$m=R.getMinutes(),this.$s=R.getSeconds(),this.$ms=R.getMilliseconds()},W.$utils=function(){return O},W.isValid=function(){return this.$d.toString()!==p},W.isSame=function(R,Z){var Y=F(R);return this.startOf(Z)<=Y&&Y<=this.endOf(Z)},W.isAfter=function(R,Z){return F(R)<this.startOf(Z)},W.isBefore=function(R,Z){return this.endOf(Z)<F(R)},W.$g=function(R,Z,Y){return O.u(R)?this[Z]:this.set(Y,R)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(R,Z){var Y=this,G=!!O.u(Z)||Z,Q=O.p(R),ut=function(Bt,Nt){var he=O.w(Y.$u?Date.UTC(Y.$y,Nt,Bt):new Date(Y.$y,Nt,Bt),Y);return G?he:he.endOf(f)},_t=function(Bt,Nt){return O.w(Y.toDate()[Bt].apply(Y.toDate("s"),(G?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Y)},at=this.$W,vt=this.$M,wt=this.$D,Ct="set"+(this.$u?"UTC":"");switch(Q){case g:return G?ut(1,0):ut(31,11);case h:return G?ut(1,vt):ut(0,vt+1);case d:var bt=this.$locale().weekStart||0,re=(at<bt?at+7:at)-bt;return ut(G?wt-re:wt+(6-re),vt);case f:case y:return _t(Ct+"Hours",0);case c:return _t(Ct+"Minutes",1);case u:return _t(Ct+"Seconds",2);case a:return _t(Ct+"Milliseconds",3);default:return this.clone()}},W.endOf=function(R){return this.startOf(R,!1)},W.$set=function(R,Z){var Y,G=O.p(R),Q="set"+(this.$u?"UTC":""),ut=(Y={},Y[f]=Q+"Date",Y[y]=Q+"Date",Y[h]=Q+"Month",Y[g]=Q+"FullYear",Y[c]=Q+"Hours",Y[u]=Q+"Minutes",Y[a]=Q+"Seconds",Y[s]=Q+"Milliseconds",Y)[G],_t=G===f?this.$D+(Z-this.$W):Z;if(G===h||G===g){var at=this.clone().set(y,1);at.$d[ut](_t),at.init(),this.$d=at.set(y,Math.min(this.$D,at.daysInMonth())).$d}else ut&&this.$d[ut](_t);return this.init(),this},W.set=function(R,Z){return this.clone().$set(R,Z)},W.get=function(R){return this[O.p(R)]()},W.add=function(R,Z){var Y,G=this;R=Number(R);var Q=O.p(Z),ut=function(vt){var wt=F(G);return O.w(wt.date(wt.date()+Math.round(vt*R)),G)};if(Q===h)return this.set(h,this.$M+R);if(Q===g)return this.set(g,this.$y+R);if(Q===f)return ut(1);if(Q===d)return ut(7);var _t=(Y={},Y[u]=r,Y[c]=n,Y[a]=e,Y)[Q]||1,at=this.$d.getTime()+R*_t;return O.w(at,this)},W.subtract=function(R,Z){return this.add(-1*R,Z)},W.format=function(R){var Z=this,Y=this.$locale();if(!this.isValid())return Y.invalidDate||p;var G=R||"YYYY-MM-DDTHH:mm:ssZ",Q=O.z(this),ut=this.$H,_t=this.$m,at=this.$M,vt=Y.weekdays,wt=Y.months,Ct=Y.meridiem,bt=function(Nt,he,se,qt){return Nt&&(Nt[he]||Nt(Z,G))||se[he].slice(0,qt)},re=function(Nt){return O.s(ut%12||12,Nt,"0")},Bt=Ct||function(Nt,he,se){var qt=Nt<12?"AM":"PM";return se?qt.toLowerCase():qt};return G.replace(v,function(Nt,he){return he||function(se){switch(se){case"YY":return String(Z.$y).slice(-2);case"YYYY":return O.s(Z.$y,4,"0");case"M":return at+1;case"MM":return O.s(at+1,2,"0");case"MMM":return bt(Y.monthsShort,at,wt,3);case"MMMM":return bt(wt,at);case"D":return Z.$D;case"DD":return O.s(Z.$D,2,"0");case"d":return String(Z.$W);case"dd":return bt(Y.weekdaysMin,Z.$W,vt,2);case"ddd":return bt(Y.weekdaysShort,Z.$W,vt,3);case"dddd":return vt[Z.$W];case"H":return String(ut);case"HH":return O.s(ut,2,"0");case"h":return re(1);case"hh":return re(2);case"a":return Bt(ut,_t,!0);case"A":return Bt(ut,_t,!1);case"m":return String(_t);case"mm":return O.s(_t,2,"0");case"s":return String(Z.$s);case"ss":return O.s(Z.$s,2,"0");case"SSS":return O.s(Z.$ms,3,"0");case"Z":return Q}return null}(Nt)||Q.replace(":","")})},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(R,Z,Y){var G,Q=this,ut=O.p(Z),_t=F(R),at=(_t.utcOffset()-this.utcOffset())*r,vt=this-_t,wt=function(){return O.m(Q,_t)};switch(ut){case g:G=wt()/12;break;case h:G=wt();break;case _:G=wt()/3;break;case d:G=(vt-at)/6048e5;break;case f:G=(vt-at)/864e5;break;case c:G=vt/n;break;case u:G=vt/r;break;case a:G=vt/e;break;default:G=vt}return Y?G:O.a(G)},W.daysInMonth=function(){return this.endOf(h).$D},W.$locale=function(){return A[this.$L]},W.locale=function(R,Z){if(!R)return this.$L;var Y=this.clone(),G=I(R,Z,!0);return G&&(Y.$L=G),Y},W.clone=function(){return O.w(this.$d,this)},W.toDate=function(){return new Date(this.valueOf())},W.toJSON=function(){return this.isValid()?this.toISOString():null},W.toISOString=function(){return this.$d.toISOString()},W.toString=function(){return this.$d.toUTCString()},q}(),z=L.prototype;return F.prototype=z,[["$ms",s],["$s",a],["$m",u],["$H",c],["$W",f],["$M",h],["$y",g],["$D",y]].forEach(function(q){z[q[1]]=function(W){return this.$g(W,q[0],q[1])}}),F.extend=function(q,W){return q.$i||(q(W,L,F),q.$i=!0),F},F.locale=I,F.isDayjs=S,F.unix=function(q){return F(1e3*q)},F.en=A[E],F.Ls=A,F.p={},F})})(Zl);var b_=Zl.exports,Wt=Kt(b_),Kl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,a,u){var c=a.prototype;u.utc=function(p){var w={date:p,utc:!0,args:arguments};return new a(w)},c.utc=function(p){var w=u(this.toDate(),{locale:this.$L,utc:!0});return p?w.add(this.utcOffset(),e):w},c.local=function(){return u(this.toDate(),{locale:this.$L,utc:!1})};var f=c.parse;c.parse=function(p){p.utc&&(this.$u=!0),this.$utils().u(p.$offset)||(this.$offset=p.$offset),f.call(this,p)};var d=c.init;c.init=function(){if(this.$u){var p=this.$d;this.$y=p.getUTCFullYear(),this.$M=p.getUTCMonth(),this.$D=p.getUTCDate(),this.$W=p.getUTCDay(),this.$H=p.getUTCHours(),this.$m=p.getUTCMinutes(),this.$s=p.getUTCSeconds(),this.$ms=p.getUTCMilliseconds()}else d.call(this)};var h=c.utcOffset;c.utcOffset=function(p,w){var v=this.$utils().u;if(v(p))return this.$u?0:v(this.$offset)?h.call(this):this.$offset;if(typeof p=="string"&&(p=function(E){E===void 0&&(E="");var A=E.match(r);if(!A)return null;var N=(""+A[0]).match(n)||["-",0,0],S=N[0],I=60*+N[1]+ +N[2];return I===0?0:S==="+"?I:-I}(p),p===null))return this;var x=Math.abs(p)<=16?60*p:p,b=this;if(w)return b.$offset=x,b.$u=p===0,b;if(p!==0){var C=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+C,e)).$offset=x,b.$x.$localOffset=C}else b=this.utc();return b};var _=c.format;c.format=function(p){var w=p||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return _.call(this,w)},c.valueOf=function(){var p=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*p},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var g=c.toDate;c.toDate=function(p){return p==="s"&&this.$offset?u(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var y=c.diff;c.diff=function(p,w,v){if(p&&this.$u===p.$u)return y.call(this,p,w,v);var x=this.local(),b=u(p).local();return y.call(x,b,w,v)}}})})(Kl);var x_=Kl.exports,xa=Kt(x_),Gl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,s,a){var u,c=function(_,g,y){y===void 0&&(y={});var p=new Date(_),w=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",C=v+"|"+b,E=r[C];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[C]=E),E}(g,y);return w.formatToParts(p)},f=function(_,g){for(var y=c(_,g),p=[],w=0;w<y.length;w+=1){var v=y[w],x=v.type,b=v.value,C=e[x];C>=0&&(p[C]=parseInt(b,10))}var E=p[3],A=E===24?0:E,N=p[0]+"-"+p[1]+"-"+p[2]+" "+A+":"+p[4]+":"+p[5]+":000",S=+_;return(a.utc(N).valueOf()-(S-=S%1e3))/6e4},d=s.prototype;d.tz=function(_,g){_===void 0&&(_=u);var y=this.utcOffset(),p=this.toDate(),w=p.toLocaleString("en-US",{timeZone:_}),v=Math.round((p-new Date(w))/1e3/60),x=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(p.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(y-b,"minute")}return x.$x.$timezone=_,x},d.offsetName=function(_){var g=this.$x.$timezone||a.tz.guess(),y=c(this.valueOf(),g,{timeZoneName:_}).find(function(p){return p.type.toLowerCase()==="timezonename"});return y&&y.value};var h=d.startOf;d.startOf=function(_,g){if(!this.$x||!this.$x.$timezone)return h.call(this,_,g);var y=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return h.call(y,_,g).tz(this.$x.$timezone,!0)},a.tz=function(_,g,y){var p=y&&g,w=y||g||u,v=f(+a(),w);if(typeof _!="string")return a(_).tz(w);var x=function(A,N,S){var I=A-60*N*1e3,F=f(I,S);if(N===F)return[I,N];var O=f(I-=60*(F-N)*1e3,S);return F===O?[I,F]:[A-60*Math.min(F,O)*1e3,Math.max(F,O)]}(a.utc(_,p).valueOf(),v,w),b=x[0],C=x[1],E=a(b).utcOffset(C);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(_){u=_}}})})(Gl);var E_=Gl.exports,Ea=Kt(E_),Jl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e="week",r="year";return function(n,s,a){var u=s.prototype;u.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var f=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=a(this).startOf(r).add(1,r).date(f),h=a(this).endOf(e);if(d.isBefore(h))return 1}var _=a(this).startOf(r).date(f).startOf(e).subtract(1,"millisecond"),g=this.diff(_,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},u.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Jl);var C_=Jl.exports,A_=Kt(C_);Wt.extend(xa),Wt.extend(Ea);function He(i,t){return i.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function Fs(i){const t=parseInt(i)||1;let e=i.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function M_(i=10){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";const r=t.length;for(let n=0;n<i;n++)e+=t.charAt(Math.floor(Math.random()*r));return e}function F_(i){const t=/([+-])(\d{1,2})(\d{0,2})/,e=i.replace(/GMT|UTC/,"").match(t);if(!e)return 0;const[,r,n,s]=e,a=parseInt(n,10)*60||0,u=parseInt(s,10)||0;return(r==="+"?1:-1)*(a+u)}function mr(i,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?Wt.utc(i).utcOffset(F_(t)):Wt.tz(i,t)}function gr(i,t){const[e,r]=Fs(i);let n=0;switch(r){case"m":n=60;break;case"s":n=1;break;case"M":return N_(t,Number(e))*24*60*60;case"d":n=24*60*60;break;case"w":n=7*24*60*60;break;default:n=60*60;break}return Math.round(Number(e)*n)}function N_(i,t){const e=Wt(i),r=e.month();let n=0;for(;t>0;){t-=1;const s=r+t,a=e.month(s).daysInMonth();n+=a}return n}function mt(i){return typeof i!="number"||isNaN(i)}function ve(i,t){for(const e of t)i!=null&&i.hasOwnProperty(e)&&i[e]===void 0&&(i[e]=null)}function Xl(i){var t=atob(i),e=decodeURI(t);return e}function Ql(i,t){if(!String(i).includes("."))return i;const e=Math.pow(10,t);return Math.floor(i*e)/e}function tc(i,t=5,e=!1){if(i===void 0)return i;const r=String(i),n=r.indexOf(".");if(n===-1)return i;const s=r.length-n-1;if(s<=t)return i;i=Number(r.replace(".",""));let a=s-t;if(a-2>0){const u=Math.pow(10,a-2);i=Math.round(i/u),a=2}return i=i/Math.pow(10,a),(e?Math.ceil(i):Math.floor(i))/Math.pow(10,t)}function ec(i,t){return tc(i,t,!0)}function rc(i,t){return tc(i,t)}function nc(i){const t=parseInt(i);return i.length>1&&t===1?i.replace("1",""):i}var te=(i=>(i.BOOL="bool",i.INT="int",i.FLOAT="float",i.ARRAY="array",i.BOX="box",i.CHART_POINT="chart.point",i.COLOR="color",i.CONST="const",i.LABEL="label",i.LINE="line",i.LINEFILL="linefill",i.MAP="map",i.MATRIX="matrix",i.POLYLINE="polyline",i.SERIES="series",i.SIMPLE="simple",i.STRING="string",i.TABLE="table",i.UNDETERMINED="undetermined type",i.INPUT="input",i.NA="na",i.VOID="void",i.ENUM="enum",i))(te||{}),Ns=(i=>(i.dividends="dividends",i.none="none",i.splits="splits",i))(Ns||{}),jr=(i=>(i.freqAll="freq_all",i.freqOncePerBar="freq_once_per_bar",i.freqOncePerBarClose="freq_once_per_bar_close",i))(jr||{}),ln=(i=>(i.gapsOff="gaps_off",i.gapsOn="gaps_on",i.lookaheadOff="lookahead_off",i.lookaheadOn="lookahead_on",i))(ln||{}),Ze=(i=>(i.all="all",i.dataWindow="data_window",i.none="none",i.pane="pane",i.priceScale="price_scale",i.statusLine="status_line",i))(Ze||{}),Yr=(i=>(i.both="both",i.left="left",i.none="none",i.right="right",i))(Yr||{}),Gt=(i=>(i.inherit="inherit",i.mintick="mintick",i.percent="percent",i.price="price",i.volume="volume",i))(Gt||{}),Ss=(i=>(i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Ss||{}),ye=(i=>(i.styleArrowdown="style_arrowdown",i.styleArrowup="style_arrowup",i.styleCircle="style_circle",i.styleCross="style_cross",i.styleDiamond="style_diamond",i.styleFlag="style_flag",i.styleLabelCenter="style_label_center",i.styleLabelDown="style_label_down",i.styleLabelLeft="style_label_left",i.styleLabelLowerLeft="style_label_lower_left",i.styleLabelLowerRight="style_label_lower_right",i.styleLabelRight="style_label_right",i.styleLabelUp="style_label_up",i.styleLabelUpperLeft="style_label_upper_left",i.styleLabelUpperRight="style_label_upper_right",i.styleNone="style_none",i.styleSquare="style_square",i.styleTextOutline="style_text_outline",i.styleTriangledown="style_triangledown",i.styleTriangleup="style_triangleup",i.styleXcross="style_xcross",i))(ye||{}),Re=(i=>(i.styleArrowBoth="style_arrow_both",i.styleArrowLeft="style_arrow_left",i.styleArrowRight="style_arrow_right",i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Re||{}),cn=(i=>(i.abovebar="abovebar",i.absolute="absolute",i.belowbar="belowbar",i.bottom="bottom",i.top="top",i))(cn||{}),Gn=(i=>(i.ascending="ascending",i.descending="descending",i))(Gn||{}),Or=(i=>(i.styleArea="Area",i.styleAreabr="Area With Breaks",i.styleCircles="Circles",i.styleColumns="Columns",i.styleCross="Cross",i.styleHistogram="Histogram",i.styleLine="Line",i.styleLinebr="Line With Breaks",i.styleStepline="Step Line",i.styleSteplineDiamond="Step Line With Diamonds",i.styleSteplinebr="Step line with Breaks",i))(Or||{}),vr=(i=>(i.bottomCenter="bottom_center",i.bottomLeft="bottom_left",i.bottomRight="bottom_right",i.middleCenter="middle_center",i.middleLeft="middle_left",i.middleRight="middle_right",i.topCenter="top_center",i.topLeft="top_left",i.topRight="top_right",i))(vr||{}),Os=(i=>(i.left="left",i.none="none",i.right="right",i))(Os||{}),Mn=(i=>(i.extended="extended",i.regular="regular",i))(Mn||{}),lr=(i=>(i.arrowdown="arrowdown",i.arrowup="arrowup",i.circle="circle",i.cross="cross",i.diamond="diamond",i.flag="flag",i.labeldown="labeldown",i.labelup="labelup",i.square="square",i.triangledown="triangledown",i.triangleup="triangleup",i.xcross="xcross",i))(lr||{}),ir=(i=>(i.auto="auto",i.huge="huge",i.large="large",i.normal="normal",i.small="small",i.tiny="tiny",i))(ir||{}),Jn=(i=>(i.familyDefault="default",i.familyMonospace="monospace",i))(Jn||{}),Pe=(i=>(i.cash="cash",i.fixed="fixed",i.percentOfEquity="percent_of_equity",i))(Pe||{}),je=(i=>(i.cashPerContract="cash_per_contract",i.cashPerOrder="cash_per_order",i.percent="percent",i))(je||{}),fe=(i=>(i.all="all",i.long="long",i.short="short",i))(fe||{}),fn=(i=>(i.cancel="cancel",i.none="none",i.reduce="reduce",i))(fn||{}),jt=(i=>(i.alignBottom="align_bottom",i.alignCenter="align_center",i.alignLeft="align_left",i.alignRight="align_right",i.alignTop="align_top",i.wrapAuto="wrap_auto",i.wrapNone="wrap_none",i))(jt||{}),be=(i=>(i.bar_index="bar_index",i.bar_time="bar_time",i))(be||{}),Vr=(i=>(i.abovebar="abovebar",i.belowbar="belowbar",i.price="price",i))(Vr||{}),Bs=(i=>(i.actual="actual",i.estimate="estimate",i.standardized="standardized",i))(Bs||{}),Xn=(i=>(i.traditional="Traditional",i.fibonacci="Fibonacci",i.woodie="Woodie",i.classic="Classic",i.dm="DM",i.camarilla="Camarilla",i))(Xn||{}),sr=(i=>(i.INT="int",i.BOOL="bool",i.TIME="time",i.COLOR="color",i.FLOAT="float",i.PRICE="price",i.SOURCE="source",i.STRING="string",i.SYMBOL="symbol",i.SESSION="session",i.TEXT_AREA="text_area",i.TIMEFRAME="timeframe",i.ENUM="enum",i))(sr||{}),ic=(i=>(i.library="library",i.indicator="indicator",i.strategy="strategy",i))(ic||{}),Rt=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(Rt||{});const ie={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.",arrEmptyErr:"Array must not be empty",arrLengthDiffErr:"Arrays have different lengths",arrTypeErr:"Array type error, the 'array.$name' method can only use $type type array.",inputOptErr:"input's defval should be in options, but '$defval' is not in [$args]",mathRandomErr:"min must be less than max",matrixRehapeErr:"New matrix must be of same area as original matrix",strategyExitErr:"strategy.exit must have at least one of the following parameters: 'profit', 'limit', 'loss', 'stop' or one of the following pairs: 'trail_offset' and 'trail_price' / 'trail_points'. To close the position at market price, use 'strategy.close'",arrLenErr:"Invalid array length",mergeCellErr:"error: start_column > end_column or start_row > end_row",minOrMaxErr:"Input's `defval` value must be between `minval` and `maxval`",requestsNumErr:"Exceeded the maximum number of requests 40",undeterminedTypeMethodErr:"Method calls must specify the type, please add the type to '$name'"},S_={repeatVar:"Shadowing variable '$name' which exists in parent scope. Did you want to use the ':=' operator instead of '=' ?",typeMismatch:"The `$index` parameter of the `$operator` function accepts a '$type' argument. To avoid potential unexpected results, pass a '$type' value or expression to this parameter.",moreSameArg:"More than one '$arg' arguments are supplied. Only the first one will be used.",localScopeGetHistory:"The variable '$name' is declared in local scope, which may not be executed at every update. So, obtaining its historical values may lead to unexpected results",localScopeWarning:"The function '$name' should be called on each calculation for consistency. It is recommended to extract the call from this scope",strategyCalcTickWarn:"Strategies without `calc_on_every_tick = true` only calculate on confirmed chart bars. In this case, `barstate.islast` may not initially return `true` on realtime bars, as the last bar is unconfirmed until it closes. If you need to check whether a bar is the latest before it closes, enable `calc_on_every_tick` in the `strategy()` function.",conditionWarning:"The `condition` parameter of the `$name` accepts a 'bool' argument. To avoid potential unexpected results, pass a 'bool' value or expression to this parameter.",lineWidthWarning:"Passing a value below 1 to `linewidth` will be replaced with 1 during compilation.",boolVarNumWarning:"The `$name` variable casts a numeric value to the 'bool' type. To avoid potential unexpected results, assign a 'bool' value to this variable."};te.SERIES,te.SIMPLE,te.INPUT,te.CONST,te.INT,te.FLOAT,te.BOOL,te.COLOR,te.STRING;const O_=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],B_=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],T_=["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 I_{constructor(t){$(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new ee(t,e,this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}slice({id:t,index_from:e,index_to:r}){return t==null?void 0:t.slice({index_from:e,index_to:r})}size({id:t}){return t==null?void 0:t.size()}first({id:t}){return t==null?void 0:t.first()}abs({id:t},e){return t==null?void 0:t.abs(e)}avg({id:t},e){return t==null?void 0:t.avg(e)}binary_search({id:t,val:e},r){return t==null?void 0:t.binary_search({val:e},r)}binary_search_leftmost({id:t,val:e},r){return t==null?void 0:t.binary_search_leftmost({val:e},r)}binary_search_rightmost({id:t,val:e},r){return t==null?void 0:t.binary_search_rightmost({val:e},r)}clear({id:t}){t==null||t.clear()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}covariance({id1:t,id2:e,biased:r},n){return t==null?void 0:t.covariance({id2:e,biased:r},n)}every({id:t},e){return t==null?void 0:t.every(e)}from(t,e){const r=new ee(0,void 0,this._errorListener);return r._value=e,r}fill({id:t,value:e,index_from:r,index_to:n}){t==null||t.fill({value:e,index_from:r,index_to:n})}get({id:t,index:e}){return t==null?void 0:t.get({index:e})}includes({id:t,value:e}){return t==null?void 0:t.includes({value:e})}indexof({id:t,value:e}){return t==null?void 0:t.indexof({value:e})}insert({id:t,index:e,value:r}){t==null||t.insert({index:e,value:r})}join({id:t,separator:e},r){return t==null?void 0:t.join({separator:e},r)}last({id:t}){return t==null?void 0:t.last()}lastindexof({id:t,value:e}){return t==null?void 0:t.lastindexof({value:e})}max({id:t,nth:e},r){return t==null?void 0:t.max({nth:e},r)}median({id:t},e){return t==null?void 0:t.median(e)}min({id:t,nth:e},r){return t==null?void 0:t.min({nth:e},r)}mode({id:t},e){return t==null?void 0:t.mode(e)}percentile_linear_interpolation({id:t,percentage:e},r){return t==null?void 0:t.percentile_linear_interpolation({percentage:e},r)}percentile_nearest_rank({id:t,percentage:e},r){return t==null?void 0:t.percentile_nearest_rank({percentage:e},r)}percentrank({id:t,index:e},r){return t==null?void 0:t.percentrank({index:e},r)}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t},e){return t==null?void 0:t.range(e)}remove({id:t,index:e}){return t==null?void 0:t.remove({index:e})}reverse({id:t}){return t==null?void 0:t.reverse()}set({id:t,index:e,value:r}){t==null||t.set({index:e,value:r})}shift({id:t}){return t==null?void 0:t.shift()}some({id:t},e){return t==null?void 0:t.some(e)}sort({id:t,order:e},r){t==null||t.sort({order:e},r)}sort_indices({id:t,order:e},r){return t==null?void 0:t.sort_indices({order:e},r)}standardize({id:t},e){return t==null?void 0:t.standardize(e)}stdev({id:t,biased:e},r){return t==null?void 0:t.stdev({biased:e},r)}sum({id:t},e){return t==null?void 0:t.sum(e)}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e},r){return t==null?void 0:t.variance({biased:e},r)}}class ee{constructor(t=0,e,r){$(this,"_arrInstance");$(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Wr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Wr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new ee(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new ee(0,void 0,this._errorListener);return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(t){const e=new ee(0,void 0,this._errorListener);this._verifySimpleType("number","abs","int/float",t);const r=this._arrInstance.map(n=>Math.abs(n));return e._copyData(r),e}avg(t){return this._verifySimpleType("number","avg","int/float",t),Wr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),mt(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),mt(t)?this._arrInstance.length-1:this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t},e){return this._verifySimpleType("number","binary_search_rightmost","int/float",e),mt(t)?this._arrInstance.length:this._binarySearchRightMost(this._arrInstance,t)}clear(){this._arrInstance=[]}concat({id2:t}){return this._arrInstance=this._arrInstance.concat(t==null?void 0:t._value),this}covariance({id2:t,biased:e},r){return this._verifySimpleType("number","covariance","int/float",r),this._verifySimpleType("number","covariance","int/float",r,t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e,r)}every(t){return this._verifySimpleType("number|boolean","every","int/float/bool",t),this._arrInstance.every(e=>!!e)}fill({value:t,index_from:e=0,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index:t}){if(!mt(t))return this._arrInstance[t]}includes({value:t}){return this._arrInstance.includes(t)}indexof({value:t}){return this._arrInstance.indexOf(t)}insert({index:t,value:e}){mt(t)||this._arrInstance.splice(t,0,e)}join({separator:t}={},e){return this._verifySimpleType("number|string","join","int/float/string",e),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={},e){return this._verifySimpleType("number","max","int/float",e),this._maxNth([...this._arrInstance],t)}median(t){return this._verifySimpleType("number","median","int/float",t),this._median([...this._arrInstance])}min({nth:t}={},e){return this._verifySimpleType("number","min","int/float",e),this._minNth([...this._arrInstance],t)}mode(t){return this._verifySimpleType("number","mode","int/float",t),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t},e){return this._verifySimpleType("number","percentile_linear_interpolation","int/float",e),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t=0},e){var r;if(this._arrInstance.length===0||t<0||t>100||mt(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,Rt.Error);return}return this._verifySimpleType("number","percentile_nearest_rank","int/float",e),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t},e){return this._verifySimpleType("number","percentrank","int/float",e),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(t){var s;if(this._arrInstance.length===0){(s=this._errorListener)==null||s.addError(ie.arrEmptyErr,t,Rt.Error);return}this._verifySimpleType("number","range","int/float",t);const e=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-e}remove({index:t}){if(!mt(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){mt(t)||(this._arrInstance[t]=e)}shift(){return this._arrInstance.shift()}some(t){return this._verifySimpleType("number|boolean","some","int/float/bool",t),this._arrInstance.some(e=>!!e)}sort({order:t}={},e){this._verifySimpleType("number","sort","int/float",e),this._arrInstance.sort((r,n)=>t!==Gn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((s,a)=>a);r.sort((s,a)=>t!==Gn.descending?this._arrInstance[s]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[s]);const n=new ee(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new ee(0,void 0,this._errorListener);return e._copyData(this._standardizeArray([...this._arrInstance])),e}stdev({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ie.arrEmptyErr,e,Rt.Error);return}return this._verifySimpleType("number","stdev","int/float",e),this._calculateStandardDeviations([...this._arrInstance],t)}sum(t){return this._verifySimpleType("number","sum","int/float",t),this._arrInstance.reduce((r,n)=>r+(n||0),0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ie.arrEmptyErr,e,Rt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,u)=>a+(u||0),0)/t.length,n=t.reduce((a,u)=>a+((u||0)-r)**2,0),s=n/t.length;return e?s:t.length>1?n/(t.length-1):s}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,u)=>a+(u||0),0)/t.length,n=t.reduce((a,u)=>{const c=(u||0)-r;return a+c*c},0),s=Math.sqrt(n/t.length);return e?s:t.length>1?Math.sqrt(n/(t.length-1)):s}_standardizeArray(t){const e=t.reduce((s,a)=>s+(a||0),0)/t.length,r=Math.sqrt(t.reduce((s,a)=>s+Math.pow((a||0)-e,2),0)/t.length);return t.map(s=>((s||0)-e)/r)}_getPercentileRank(t,e=0){if(mt(e))return;const r=t[e];let n=0;for(let a=0;a<t.length;a++)(t[a]<r||t[a]===r&&a!=e)&&n++;return n/(t.length-1)*100}_getNearestRankPercentile(t,e=0){const r=t.slice().sort((a,u)=>a-u),n=e/100*r.length,s=Math.ceil(n)-1;return r[s>=r.length?r.length-1:s]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||mt(e))return;t.sort(function(s,a){return s-a});const r=t.length;e/=100;const n=1/(r*2);if(e<=n)return t[0];if(e>=1-1/(r*2))return t[r-1];for(const[s,a]of t.entries()){const u=t[s-1];if(e<(s+.5)/r)return u+(a-u)*(e-(s-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const s of t)e[s]=(e[s]||0)+1,r=Math.max(r,e[s]);for(const s in e)e[s]===r&&n.push(Number(s));return Math.min(...r===1?t:n)}_median(t){t.sort(function(r,n){return r-n});const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}_minNth(t,e=0){return t.sort(function(r,n){return r-n}),t[e]}_maxNth(t,e=0){return t.sort(function(r,n){return n-r}),t[e]}_setElements(t,e,r=0,n){n===void 0&&(n=t.length);for(let s=r;s<n;s++)t[s]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(ie.arrLengthDiffErr,n,Rt.Error);return}t=t.filter(f=>f!==void 0),e=e.filter(f=>f!==void 0);const s=t.reduce((f,d)=>f+d,0)/t.length,a=e.reduce((f,d)=>f+d,0)/e.length;let u=0;for(let f=0;f<t.length;f++)u+=(t[f]-s)*(e[f]-a);return r?u/t.length:u/(t.length-1)}_verifySimpleType(t,e,r,n,s=this._arrInstance){var u;s.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((u=this._errorListener)==null||u.addError(He(ie.arrTypeErr,{name:e,type:r}),n,Rt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const s=Math.floor((r+n)/2);if(t[s]===e)return s;t[s]<e?r=s+1:n=s-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<e?r=a+1:n=a-1}return s.length?Math.min(...s):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<=e?r=a+1:n=a-1}return s.length?Math.max(...s):r}}class $_{constructor(t,e){$(this,"_randomNums");$(this,"_mintick");$(this,"_cacheData");$(this,"_barIndex");$(this,"_errorListener");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0,this._errorListener=e}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){if(!mt(t))return Math.abs(t)}acos({angle:t}){if(mt(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(mt(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(mt(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Wr.mean(e)}ceil({number:t}){if(!mt(t))return Math.ceil(t)}floor({number:t}){if(!mt(t))return Math.floor(t)}cos({angle:t}){if(mt(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(mt(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(mt(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!mt(t))return Math.exp(t)}log({number:t}){if(!mt(t))return Math.log(t)}log10({number:t}){if(!mt(t))return Math.log10(t)}max(t,e){if(!e.some(r=>mt(r)))return Math.max(...e)}min(t,e){if(!e.some(r=>mt(r)))return Math.min(...e)}pow({base:t,exponent:e}){if(!(mt(t)||mt(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(mt(t)&&(t=0),mt(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(ie.mathRandomErr,n,Rt.Error);return}let s;do s=Math.random()*(e-t)+t;while(s===t||s===e);return r&&(this._randomNums[r]=s),s}round({number:t,precision:e}){if(!mt(t))return mt(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!mt(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!mt(t))return t&&Math.sign(t)}sqrt({number:t}){if(!mt(t))return Math.sqrt(t)}sum({source:t,length:e=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=t,this._cacheData[`sum_${r}`]=n;const s=n.filter(a=>!mt(a));if(!(s.length<e))return Wr.sum(s.slice(-e))}todegrees({radians:t}){if(!mt(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!mt(t))return t*(Math.PI/180)}}function Ts(){return Ts=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},Ts.apply(this,arguments)}var sc={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function me(i){return typeof i=="number"}function Oe(i){return!i||typeof i!="object"||typeof i.constructor!="function"?!1:i.isBigNumber===!0&&typeof i.constructor.prototype=="object"&&i.constructor.prototype.isBigNumber===!0||typeof i.constructor.isDecimal=="function"&&i.constructor.isDecimal(i)===!0}function oc(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isComplex===!0||!1}function ac(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isFraction===!0||!1}function uc(i){return i&&i.constructor.prototype.isUnit===!0||!1}function en(i){return typeof i=="string"}var Ae=Array.isArray;function we(i){return i&&i.constructor.prototype.isMatrix===!0||!1}function ts(i){return Array.isArray(i)||we(i)}function L_(i){return i&&i.isDenseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function R_(i){return i&&i.isSparseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function P_(i){return i&&i.constructor.prototype.isRange===!0||!1}function Ca(i){return i&&i.constructor.prototype.isIndex===!0||!1}function k_(i){return typeof i=="boolean"}function z_(i){return i&&i.constructor.prototype.isResultSet===!0||!1}function q_(i){return i&&i.constructor.prototype.isHelp===!0||!1}function U_(i){return typeof i=="function"}function W_(i){return i instanceof Date}function j_(i){return i instanceof RegExp}function Aa(i){return!!(i&&typeof i=="object"&&i.constructor===Object&&!oc(i)&&!ac(i))}function Y_(i){return i===null}function V_(i){return i===void 0}function H_(i){return i&&i.isAccessorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Z_(i){return i&&i.isArrayNode===!0&&i.constructor.prototype.isNode===!0||!1}function K_(i){return i&&i.isAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function G_(i){return i&&i.isBlockNode===!0&&i.constructor.prototype.isNode===!0||!1}function J_(i){return i&&i.isConditionalNode===!0&&i.constructor.prototype.isNode===!0||!1}function X_(i){return i&&i.isConstantNode===!0&&i.constructor.prototype.isNode===!0||!1}function Q_(i){return i&&i.isFunctionAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function tp(i){return i&&i.isFunctionNode===!0&&i.constructor.prototype.isNode===!0||!1}function ep(i){return i&&i.isIndexNode===!0&&i.constructor.prototype.isNode===!0||!1}function rp(i){return i&&i.isNode===!0&&i.constructor.prototype.isNode===!0||!1}function np(i){return i&&i.isObjectNode===!0&&i.constructor.prototype.isNode===!0||!1}function ip(i){return i&&i.isOperatorNode===!0&&i.constructor.prototype.isNode===!0||!1}function sp(i){return i&&i.isParenthesisNode===!0&&i.constructor.prototype.isNode===!0||!1}function op(i){return i&&i.isRangeNode===!0&&i.constructor.prototype.isNode===!0||!1}function ap(i){return i&&i.isRelationalNode===!0&&i.constructor.prototype.isNode===!0||!1}function up(i){return i&&i.isSymbolNode===!0&&i.constructor.prototype.isNode===!0||!1}function lp(i){return i&&i.constructor.prototype.isChain===!0||!1}function Fn(i){var t=typeof i;return t==="object"?i===null?"null":Oe(i)?"BigNumber":i.constructor&&i.constructor.name?i.constructor.name:"Object":t}function ue(i){var t=typeof i;if(t==="number"||t==="string"||t==="boolean"||i===null||i===void 0)return i;if(typeof i.clone=="function")return i.clone();if(Array.isArray(i))return i.map(function(e){return ue(e)});if(i instanceof Date)return new Date(i.valueOf());if(Oe(i))return i;if(Aa(i))return cp(i,ue);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(i,")"))}function cp(i,t){var e={};for(var r in i)es(i,r)&&(e[r]=t(i[r]));return e}function lc(i,t){for(var e in t)es(t,e)&&(i[e]=t[e]);return i}function yi(i,t){var e,r,n;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(r=0,n=i.length;r<n;r++)if(!yi(i[r],t[r]))return!1;return!0}else{if(typeof i=="function")return i===t;if(i instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in i)if(!(e in t)||!yi(i[e],t[e]))return!1;for(e in t)if(!(e in i))return!1;return!0}else return i===t}}function es(i,t){return i&&Object.hasOwnProperty.call(i,t)}function fp(i,t){for(var e={},r=0;r<t.length;r++){var n=t[r],s=i[n];s!==void 0&&(e[n]=s)}return e}var hp=["Matrix","Array"],dp=["number","BigNumber","Fraction"],yr=function(t){if(t)throw new Error(`The global config is readonly.
|
28
28
|
Please create a mathjs instance if you want to change the default configuration.
|
29
29
|
Example:
|
30
30
|
|
31
31
|
import { create, all } from 'mathjs';
|
32
32
|
const mathjs = create(all);
|
33
33
|
mathjs.config({ number: 'BigNumber' });
|
34
|
-
`);return Object.freeze(sc)};Ts(yr,sc,{MATRIX_OPTIONS:hp,NUMBER_OPTIONS:dp});function cc(){return!0}function Br(){return!1}function wi(){}const fc="Argument is not a typed-function.";function hc(){function i(R){return typeof R=="object"&&R!==null&&R.constructor===Object}const t=[{name:"number",test:function(R){return typeof R=="number"}},{name:"string",test:function(R){return typeof R=="string"}},{name:"boolean",test:function(R){return typeof R=="boolean"}},{name:"Function",test:function(R){return typeof R=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(R){return R instanceof Date}},{name:"RegExp",test:function(R){return R instanceof RegExp}},{name:"Object",test:i},{name:"null",test:function(R){return R===null}},{name:"undefined",test:function(R){return R===void 0}}],e={name:"any",test:cc,isAny:!0};let r,n,s=0,a={createCount:0};function u(R){const H=r.get(R);if(H)return H;let K='Unknown type "'+R+'"';const nt=R.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){K+='. Did you mean "'+st+'" ?';break}throw new TypeError(K)}function c(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const K=H?u(H).index:n.length,nt=[];for(let rt=0;rt<R.length;++rt){if(!R[rt]||typeof R[rt].name!="string"||typeof R[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=R[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:R[rt].test,isAny:R[rt].isAny,index:K+rt,conversionsTo:[]})}const st=n.slice(K);n=n.slice(0,K).concat(nt).concat(st);for(let rt=K+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function f(){r=new Map,n=[],s=0,c([e],!1)}f(),c(t);function d(){let R;for(R of n)r.get(R).conversionsTo=[];s=0}function h(R){const H=n.filter(K=>{const nt=r.get(K);return!nt.isAny&&nt.test(R)});return H.length?H:["any"]}function _(R){return R&&typeof R=="function"&&"_typedFunctionData"in R}function g(R,H,K){if(!_(R))throw new TypeError(fc);const nt=K&&K.exact,st=Array.isArray(H)?H.join(","):H,rt=C(st),ft=w(rt);if(!nt||ft in R.signatures){const Qt=R._typedFunctionData.signatureMap.get(ft);if(Qt)return Qt}const ct=rt.length;let ht;if(nt){ht=[];let Qt;for(Qt in R.signatures)ht.push(R._typedFunctionData.signatureMap.get(Qt))}else ht=R._typedFunctionData.signatures;for(let Qt=0;Qt<ct;++Qt){const oe=rt[Qt],Ee=[];let Ye;for(Ye of ht){const qe=S(Ye.params,Qt);if(!(!qe||oe.restParam&&!qe.restParam)){if(!qe.hasAny){const xr=b(qe);if(oe.types.some(Er=>!xr.has(Er.name)))continue}Ee.push(Ye)}}if(ht=Ee,ht.length===0)break}let lt;for(lt of ht)if(lt.params.length<=ct)return lt;throw new TypeError("Signature not found (signature: "+(R.name||"unnamed")+"("+w(rt,", ")+"))")}function y(R,H,K){return g(R,H,K).implementation}function p(R,H){const K=u(H);if(K.test(R))return R;const nt=K.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+H+" defined.");for(let st=0;st<nt.length;st++)if(u(nt[st].from).test(R))return nt[st].convert(R);throw new Error("Cannot convert "+R+" to "+H)}function w(R){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return R.map(K=>K.name).join(H)}function v(R){const H=R.indexOf("...")===0,nt=(H?R.length>3?R.slice(3):"any":R).split("|").map(ct=>u(ct.trim()));let st=!1,rt=H?"...":"";return{types:nt.map(function(ct){return st=ct.isAny||st,rt+=ct.name+"|",{name:ct.name,typeIndex:ct.index,test:ct.test,isAny:ct.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:H}}function x(R){const H=R.types.map(ft=>ft.name),K=Z(H);let nt=R.hasAny,st=R.name;const rt=K.map(function(ft){const ct=u(ft.from);return nt=ct.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ct.index,test:ct.test,isAny:ct.isAny,conversion:ft,conversionIndex:ft.index}});return{types:R.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:R.restParam}}function b(R){return R.typeSet||(R.typeSet=new Set,R.types.forEach(H=>R.typeSet.add(H.name))),R.typeSet}function C(R){const H=[];if(typeof R!="string")throw new TypeError("Signatures must be strings");const K=R.trim();if(K==="")return H;const nt=K.split(",");for(let st=0;st<nt.length;++st){const rt=v(nt[st].trim());if(rt.restParam&&st!==nt.length-1)throw new SyntaxError('Unexpected rest parameter "'+nt[st]+'": only allowed for the last parameter');if(rt.types.length===0)return null;H.push(rt)}return H}function E(R){const H=Bt(R);return H?H.restParam:!1}function A(R){if(!R||R.types.length===0)return cc;if(R.types.length===1)return u(R.types[0].name).test;if(R.types.length===2){const H=u(R.types[0].name).test,K=u(R.types[1].name).test;return function(st){return H(st)||K(st)}}else{const H=R.types.map(function(K){return u(K.name).test});return function(nt){for(let st=0;st<H.length;st++)if(H[st](nt))return!0;return!1}}}function N(R){let H,K,nt;if(E(R)){H=re(R).map(A);const st=H.length,rt=A(Bt(R)),ft=function(ct){for(let ht=st;ht<ct.length;ht++)if(!rt(ct[ht]))return!1;return!0};return function(ht){for(let lt=0;lt<H.length;lt++)if(!H[lt](ht[lt]))return!1;return ft(ht)&&ht.length>=st+1}}else return R.length===0?function(rt){return rt.length===0}:R.length===1?(K=A(R[0]),function(rt){return K(rt[0])&&rt.length===1}):R.length===2?(K=A(R[0]),nt=A(R[1]),function(rt){return K(rt[0])&&nt(rt[1])&&rt.length===2}):(H=R.map(A),function(rt){for(let ft=0;ft<H.length;ft++)if(!H[ft](rt[ft]))return!1;return rt.length===H.length})}function S(R,H){return H<R.length?R[H]:E(R)?Bt(R):null}function I(R,H){const K=S(R,H);return K?b(K):new Set}function F(R){return R.conversion===null||R.conversion===void 0}function O(R,H){const K=new Set;return R.forEach(nt=>{const st=I(nt.params,H);let rt;for(rt of st)K.add(rt)}),K.has("any")?["any"]:Array.from(K)}function L(R,H,K){let nt,st;const rt=R||"unnamed";let ft=K,ct;for(ct=0;ct<H.length;ct++){const oe=[];if(ft.forEach(Ee=>{const Ye=S(Ee.params,ct),qe=A(Ye);(ct<Ee.params.length||E(Ee.params))&&qe(H[ct])&&oe.push(Ee)}),oe.length===0){if(st=O(ft,ct),st.length>0){const Ee=h(H[ct]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+Ee.join(" | ")+", index: "+ct+")"),nt.data={category:"wrongType",fn:rt,index:ct,actual:Ee,expected:st},nt}}else ft=oe}const ht=ft.map(function(oe){return E(oe.params)?1/0:oe.params.length});if(H.length<Math.min.apply(null,ht))return st=O(ft,ct),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+H.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:H.length,expected:st},nt;const lt=Math.max.apply(null,ht);if(H.length>lt)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+lt+", actual: "+H.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:H.length,expectedLength:lt},nt;const Qt=[];for(let oe=0;oe<H.length;++oe)Qt.push(h(H[oe]).join("|"));return nt=new TypeError('Arguments of type "'+Qt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Qt},nt}function z(R){let H=n.length+1;for(let K=0;K<R.types.length;K++)F(R.types[K])&&(H=Math.min(H,R.types[K].typeIndex));return H}function q(R){let H=s+1;for(let K=0;K<R.types.length;K++)F(R.types[K])||(H=Math.min(H,R.types[K].conversionIndex));return H}function W(R,H){if(R.hasAny){if(!H.hasAny)return 1}else if(H.hasAny)return-1;if(R.restParam){if(!H.restParam)return 1}else if(H.restParam)return-1;if(R.hasConversion){if(!H.hasConversion)return 1}else if(H.hasConversion)return-1;const K=z(R)-z(H);if(K<0)return-1;if(K>0)return 1;const nt=q(R)-q(H);return nt<0?-1:nt>0?1:0}function P(R,H){const K=R.params,nt=H.params,st=Bt(K),rt=Bt(nt),ft=E(K),ct=E(nt);if(ft&&st.hasAny){if(!ct||!rt.hasAny)return 1}else if(ct&&rt.hasAny)return-1;let ht=0,lt=0,Qt;for(Qt of K)Qt.hasAny&&++ht,Qt.hasConversion&&++lt;let oe=0,Ee=0;for(Qt of nt)Qt.hasAny&&++oe,Qt.hasConversion&&++Ee;if(ht!==oe)return ht-oe;if(ft&&st.hasConversion){if(!ct||!rt.hasConversion)return 1}else if(ct&&rt.hasConversion)return-1;if(lt!==Ee)return lt-Ee;if(ft){if(!ct)return 1}else if(ct)return-1;const Ye=(K.length-nt.length)*(ft?-1:1);if(Ye!==0)return Ye;const qe=[];let xr=0;for(let Pn=0;Pn<K.length;++Pn){const ui=W(K[Pn],nt[Pn]);qe.push(ui),xr+=ui}if(xr!==0)return xr;let Er;for(Er of qe)if(Er!==0)return Er;return 0}function Z(R){if(R.length===0)return[];const H=R.map(u);R.length>1&&H.sort((st,rt)=>st.index-rt.index);let K=H[0].conversionsTo;if(R.length===1)return K;K=K.concat([]);const nt=new Set(R);for(let st=1;st<H.length;++st){let rt;for(rt of H[st].conversionsTo)nt.has(rt.from)||(K.push(rt),nt.add(rt.from))}return K}function Y(R,H){let K=H;if(R.some(st=>st.hasConversion)){const st=E(R),rt=R.map(G);K=function(){const ct=[],ht=st?arguments.length-1:arguments.length;for(let lt=0;lt<ht;lt++)ct[lt]=rt[lt](arguments[lt]);return st&&(ct[ht]=arguments[ht].map(rt[ht])),H.apply(this,ct)}}let nt=K;if(E(R)){const st=R.length-1;nt=function(){return K.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function G(R){let H,K,nt,st;const rt=[],ft=[];switch(R.types.forEach(function(ct){ct.conversion&&(rt.push(u(ct.conversion.from).test),ft.push(ct.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return H=rt[0],nt=ft[0],function(ht){return H(ht)?nt(ht):ht};case 2:return H=rt[0],K=rt[1],nt=ft[0],st=ft[1],function(ht){return H(ht)?nt(ht):K(ht)?st(ht):ht};default:return function(ht){for(let lt=0;lt<ft.length;lt++)if(rt[lt](ht))return ft[lt](ht);return ht}}}function X(R){function H(K,nt,st){if(nt<K.length){const rt=K[nt];let ft=[];if(rt.restParam){const ct=rt.types.filter(F);ct.length<rt.types.length&&ft.push({types:ct,name:"..."+ct.map(ht=>ht.name).join("|"),hasAny:ct.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ct){return{types:[ct],name:ct.name,hasAny:ct.isAny,hasConversion:ct.conversion,restParam:!1}});return se(ft,function(ct){return H(K,nt+1,st.concat([ct]))})}else return[st]}return H(R,0,[])}function ut(R,H){const K=Math.max(R.length,H.length);for(let ct=0;ct<K;ct++){const ht=I(R,ct),lt=I(H,ct);let Qt=!1,oe;for(oe of lt)if(ht.has(oe)){Qt=!0;break}if(!Qt)return!1}const nt=R.length,st=H.length,rt=E(R),ft=E(H);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function _t(R){return R.map(H=>ze(H)?Le(H.referToSelf.callback):Dr(H)?Xt(H.referTo.references,H.referTo.callback):H)}function at(R,H,K){const nt=[];let st;for(st of R){let rt=K[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=H[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function vt(R,H,K){const nt=_t(R),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ct=0;ct<nt.length;++ct){if(st[ct])continue;const ht=nt[ct];if(ze(ht))nt[ct]=ht.referToSelf.callback(K),nt[ct].referToSelf=ht.referToSelf,st[ct]=!0,ft=!1;else if(Dr(ht)){const lt=at(ht.referTo.references,nt,H);lt?(nt[ct]=ht.referTo.callback.apply(this,lt),nt[ct].referTo=ht.referTo,st[ct]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function wt(R){const H=/\bthis(\(|\.signatures\b)/;Object.keys(R).forEach(K=>{const nt=R[K];if(H.test(nt.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Ct(R,H){if(a.createCount++,Object.keys(H).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&wt(H);const K=[],nt=[],st={},rt=[];let ft;for(ft in H){if(!Object.prototype.hasOwnProperty.call(H,ft))continue;const Zt=C(ft);if(!Zt)continue;K.forEach(function(kn){if(ut(kn,Zt))throw new TypeError('Conflicting signatures "'+w(kn)+'" and "'+w(Zt)+'".')}),K.push(Zt);const er=nt.length;nt.push(H[ft]);const Tu=Zt.map(x);let ki;for(ki of X(Tu)){const kn=w(ki);rt.push({params:ki,name:kn,fn:er}),ki.every($o=>!$o.hasConversion)&&(st[kn]=er)}}rt.sort(P);const ct=vt(nt,st,li);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ct[st[ht]]);const lt=[],Qt=new Map;for(ht of rt)Qt.has(ht.name)||(ht.fn=ct[ht.fn],lt.push(ht),Qt.set(ht.name,ht));const oe=lt[0]&<[0].params.length<=2&&!E(lt[0].params),Ee=lt[1]&<[1].params.length<=2&&!E(lt[1].params),Ye=lt[2]&<[2].params.length<=2&&!E(lt[2].params),qe=lt[3]&<[3].params.length<=2&&!E(lt[3].params),xr=lt[4]&<[4].params.length<=2&&!E(lt[4].params),Er=lt[5]&<[5].params.length<=2&&!E(lt[5].params),Pn=oe&&Ee&&Ye&&qe&&xr&&Er;for(let Zt=0;Zt<lt.length;++Zt)lt[Zt].test=N(lt[Zt].params);const ui=oe?A(lt[0].params[0]):Br,Bo=Ee?A(lt[1].params[0]):Br,fu=Ye?A(lt[2].params[0]):Br,hu=qe?A(lt[3].params[0]):Br,du=xr?A(lt[4].params[0]):Br,_u=Er?A(lt[5].params[0]):Br,To=oe?A(lt[0].params[1]):Br,pu=Ee?A(lt[1].params[1]):Br,mu=Ye?A(lt[2].params[1]):Br,gu=qe?A(lt[3].params[1]):Br,fs=xr?A(lt[4].params[1]):Br,vu=Er?A(lt[5].params[1]):Br;for(let Zt=0;Zt<lt.length;++Zt)lt[Zt].implementation=Y(lt[Zt].params,lt[Zt].fn);const hs=oe?lt[0].implementation:wi,yu=Ee?lt[1].implementation:wi,wu=Ye?lt[2].implementation:wi,Du=qe?lt[3].implementation:wi,bu=xr?lt[4].implementation:wi,xu=Er?lt[5].implementation:wi,Eu=oe?lt[0].params.length:-1,Cu=Ee?lt[1].params.length:-1,Au=Ye?lt[2].params.length:-1,Io=qe?lt[3].params.length:-1,Mu=xr?lt[4].params.length:-1,Fu=Er?lt[5].params.length:-1,Nu=Pn?6:0,Su=lt.length,Ou=lt.map(Zt=>Zt.test),Bu=lt.map(Zt=>Zt.implementation),Pi=function(){for(let er=Nu;er<Su;er++)if(Ou[er](arguments))return Bu[er].apply(this,arguments);return a.onMismatch(R,arguments,lt)};function li(Zt,er){return arguments.length===Eu&&ui(Zt)&&To(er)?hs.apply(this,arguments):arguments.length===Cu&&Bo(Zt)&&pu(er)?yu.apply(this,arguments):arguments.length===Au&&fu(Zt)&&mu(er)?wu.apply(this,arguments):arguments.length===Io&&hu(Zt)&&gu(er)?Du.apply(this,arguments):arguments.length===Mu&&du(Zt)&&fs(er)?bu.apply(this,arguments):arguments.length===Fu&&_u(Zt)&&vu(er)?xu.apply(this,arguments):Pi.apply(this,arguments)}try{Object.defineProperty(li,"name",{value:R})}catch{}return li.signatures=st,li._typedFunctionData={signatures:lt,signatureMap:Qt},li}function bt(R,H,K){throw L(R,H,K)}function re(R){return Nt(R,0,R.length-1)}function Bt(R){return R[R.length-1]}function Nt(R,H,K){return Array.prototype.slice.call(R,H,K)}function he(R,H){for(let K=0;K<R.length;K++)if(H(R[K]))return R[K]}function se(R,H){return Array.prototype.concat.apply([],R.map(H))}function qt(){const R=re(arguments).map(K=>w(C(K))),H=Bt(arguments);if(typeof H!="function")throw new TypeError("Callback function expected as last argument");return Xt(R,H)}function Xt(R,H){return{referTo:{references:R,callback:H}}}function Le(R){if(typeof R!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:R}}}function Dr(R){return R&&typeof R.referTo=="object"&&Array.isArray(R.referTo.references)&&typeof R.referTo.callback=="function"}function ze(R){return R&&typeof R.referToSelf=="object"&&typeof R.referToSelf.callback=="function"}function mn(R,H){if(!R)return H;if(H&&H!==R){const K=new Error("Function names do not match (expected: "+R+", actual: "+H+")");throw K.data={actual:H,expected:R},K}return R}function Ln(R){let H;for(const K in R)Object.prototype.hasOwnProperty.call(R,K)&&(_(R[K])||typeof R[K].signature=="string")&&(H=mn(H,R[K].name));return H}function gn(R,H){let K;for(K in H)if(Object.prototype.hasOwnProperty.call(H,K)){if(K in R&&H[K]!==R[K]){const nt=new Error('Signature "'+K+'" is defined twice');throw nt.data={signature:K,sourceFunction:H[K],destFunction:R[K]},nt}R[K]=H[K]}}const br=a;a=function(R){const H=typeof R=="string",K=H?1:0;let nt=H?R:"";const st={};for(let rt=K;rt<arguments.length;++rt){const ft=arguments[rt];let ct={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ct[ft.signature]=ft:_(ft)&&(ct=ft.signatures)):i(ft)&&(ct=ft,H||(ht=Ln(ft))),Object.keys(ct).length===0){const lt=new TypeError("Argument to 'typed' at index "+rt+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw lt.data={index:rt,argument:ft},lt}H||(nt=mn(nt,ht)),gn(st,ct)}return Ct(nt||"",st)},a.create=hc,a.createCount=br.createCount,a.onMismatch=bt,a.throwMismatchError=bt,a.createError=L,a.clear=f,a.clearConversions=d,a.addTypes=c,a._findType=u,a.referTo=qt,a.referToSelf=Le,a.convert=p,a.findSignature=g,a.find=y,a.isTypedFunction=_,a.warnAgainstDeprecatedThis=!0,a.addType=function(R,H){let K="any";H!==!1&&r.has("Object")&&(K="Object"),a.addTypes([R],K)};function Rn(R){if(!R||typeof R.from!="string"||typeof R.to!="string"||typeof R.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(R.to===R.from)throw new SyntaxError('Illegal to define conversion from "'+R.from+'" to itself.')}return a.addConversion=function(R){Rn(R);const H=u(R.to);if(H.conversionsTo.every(function(K){return K.from!==R.from}))H.conversionsTo.push({from:R.from,convert:R.convert,index:s++});else throw new Error('There is already a conversion from "'+R.from+'" to "'+H.name+'"')},a.addConversions=function(R){R.forEach(a.addConversion)},a.removeConversion=function(R){Rn(R);const H=u(R.to),K=he(H.conversionsTo,st=>st.from===R.from);if(!K)throw new Error("Attempt to remove nonexistent conversion from "+R.from+" to "+R.to);if(K.convert!==R.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=H.conversionsTo.indexOf(K);H.conversionsTo.splice(nt,1)},a.resolve=function(R,H){if(!_(R))throw new TypeError(fc);const K=R._typedFunctionData.signatures;for(let nt=0;nt<K.length;++nt)if(K[nt].test(H))return K[nt];return null},a}var dc=hc();function xe(i){return typeof i=="boolean"?!0:isFinite(i)?i===Math.round(i):!1}function Ma(i,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!xe(e))throw new Error("size must be an integer");if(i>2**(e-1)-1||i<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!xe(i))throw new Error("Value must be an integer");i<0&&(i=i+2**e),s="i".concat(e)}var a="";return i<0&&(i=-i,a="-"),"".concat(a).concat(n).concat(i.toString(t)).concat(s)}function Fa(i,t){if(typeof t=="function")return t(i);if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(isNaN(i))return"NaN";var{notation:e,precision:r,wordSize:n}=_c(t);switch(e){case"fixed":return pp(i,r);case"exponential":return pc(i,r);case"engineering":return _p(i,r);case"bin":return Ma(i,2,n);case"oct":return Ma(i,8,n);case"hex":return Ma(i,16,n);case"auto":return mp(i,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],a=arguments[4];return s!=="."?s+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function _c(i){var t="auto",e,r;if(i!==void 0)if(me(i))e=i;else if(Oe(i))e=i.toNumber();else if(Aa(i))i.precision!==void 0&&(e=mc(i.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),i.wordSize!==void 0&&(r=mc(i.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),i.notation&&(t=i.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function Is(i){var t=String(i).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+i);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),s=r.indexOf(".");n+=s!==-1?s-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(u){return n-=u.length,""}).replace(/0*$/,"").split("").map(function(u){return parseInt(u)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function _p(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Is(i),r=$s(e,t),n=r.exponent,s=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(me(t))for(;t>s.length||n-a+1>s.length;)s.push(0);else for(var u=Math.abs(n-a)-(s.length-1),c=0;c<u;c++)s.push(0);for(var f=Math.abs(n-a),d=1;f>0;)d++,f--;var h=s.slice(d).join(""),_=me(t)&&h.length||h.match(/[1-9]/)?"."+h:"",g=s.slice(0,d).join("")+_+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function pp(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Is(i),r=typeof t=="number"?$s(e,e.exponent+1+t):e,n=r.coefficients,s=r.exponent+1,a=s+(t||0);return n.length<a&&(n=n.concat(Di(a-n.length))),s<0&&(n=Di(-s+1).concat(n),s=1),s<n.length&&n.splice(s,0,s===0?"0.":"."),r.sign+n.join("")}function pc(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Is(i),r=t?$s(e,t):e,n=r.coefficients,s=r.exponent;n.length<t&&(n=n.concat(Di(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(s>=0?"+":"")+s}function mp(i,t,e){if(isNaN(i)||!isFinite(i))return String(i);var r=gc(e==null?void 0:e.lowerExp,-3),n=gc(e==null?void 0:e.upperExp,5),s=Is(i),a=t?$s(s,t):s;if(a.exponent<r||a.exponent>=n)return pc(i,t);var u=a.coefficients,c=a.exponent;u.length<t&&(u=u.concat(Di(t-u.length))),u=u.concat(Di(c-u.length+1+(u.length<t?t-u.length:0))),u=Di(-c).concat(u);var f=c>0?c:0;return f<u.length-1&&u.splice(f+1,0,"."),a.sign+u.join("")}function $s(i,t){for(var e={sign:i.sign,coefficients:i.coefficients,exponent:i.exponent},r=e.coefficients;t<=0;)r.unshift(0),e.exponent++,t++;if(r.length>t){var n=r.splice(t,r.length-t);if(n[0]>=5){var s=t-1;for(r[s]++;r[s]===10;)r.pop(),s===0&&(r.unshift(0),e.exponent++,s++),s--,r[s]++}}return e}function Di(i){for(var t=[],e=0;e<i;e++)t.push(0);return t}function gp(i){return i.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var vp=Number.EPSILON||2220446049250313e-31;function Qn(i,t,e){if(e==null)return i===t;if(i===t)return!0;if(isNaN(i)||isNaN(t))return!1;if(isFinite(i)&&isFinite(t)){var r=Math.abs(i-t);return r<=vp?!0:r<=Math.max(Math.abs(i),Math.abs(t))*e}return!1}function mc(i,t){if(me(i))return i;if(Oe(i))return i.toNumber();t()}function gc(i,t){return me(i)?i:Oe(i)?i.toNumber():t}function Na(i,t,e){var r=i.constructor,n=new r(2),s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!xe(e))throw new Error("size must be an integer");if(i.greaterThan(n.pow(e-1).sub(1))||i.lessThan(n.pow(e-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!i.isInteger())throw new Error("Value must be an integer");i.lessThan(0)&&(i=i.add(n.pow(e))),s="i".concat(e)}switch(t){case 2:return"".concat(i.toBinary()).concat(s);case 8:return"".concat(i.toOctal()).concat(s);case 16:return"".concat(i.toHexadecimal()).concat(s);default:throw new Error("Base ".concat(t," not supported "))}}function yp(i,t){if(typeof t=="function")return t(i);if(!i.isFinite())return i.isNaN()?"NaN":i.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=_c(t);switch(e){case"fixed":return Dp(i,r);case"exponential":return vc(i,r);case"engineering":return wp(i,r);case"bin":return Na(i,2,n);case"oct":return Na(i,8,n);case"hex":return Na(i,16,n);case"auto":{var s=yc(t==null?void 0:t.lowerExp,-3),a=yc(t==null?void 0:t.upperExp,5);if(i.isZero())return"0";var u,c=i.toSignificantDigits(r),f=c.e;return f>=s&&f<a?u=c.toFixed():u=vc(i,r),u.replace(/((\.\d*?)(0+))($|e)/,function(){var d=arguments[2],h=arguments[4];return d!=="."?d+h:h})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function wp(i,t){var e=i.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=i.mul(Math.pow(10,-r)),s=n.toPrecision(t);if(s.indexOf("e")!==-1){var a=i.constructor;s=new a(s).toFixed()}return s+"e"+(e>=0?"+":"")+r.toString()}function vc(i,t){return t!==void 0?i.toExponential(t-1):i.toExponential()}function Dp(i,t){return i.toFixed(t)}function yc(i,t){return me(i)?i:Oe(i)?i.toNumber():t}function de(i,t){var e=bp(i,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function bp(i,t){if(typeof i=="number")return Fa(i,t);if(Oe(i))return yp(i,t);if(xp(i))return!t||t.fraction!=="decimal"?i.s*i.n+"/"+i.d:i.toString();if(Array.isArray(i))return bc(i,t);if(en(i))return wc(i);if(typeof i=="function")return i.syntax?String(i.syntax):"function";if(i&&typeof i=="object"){if(typeof i.format=="function")return i.format(t);if(i&&i.toString(t)!=={}.toString())return i.toString(t);var e=Object.keys(i).map(r=>wc(r)+": "+de(i[r],t));return"{"+e.join(", ")+"}"}return String(i)}function wc(i){for(var t=String(i),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Dc?Dc[n]:n,r++}return'"'+e+'"'}var Dc={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function bc(i,t){if(Array.isArray(i)){for(var e="[",r=i.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=bc(i[n],t);return e+="]",e}else return de(i,t)}function xp(i){return i&&typeof i=="object"&&typeof i.s=="number"&&typeof i.n=="number"&&typeof i.d=="number"||!1}function Jt(i,t,e){if(!(this instanceof Jt))throw new SyntaxError("Constructor must be called with the new operator");this.actual=i,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(i)?"["+i.join(", ")+"]":i)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Jt.prototype=new RangeError,Jt.prototype.constructor=RangeError,Jt.prototype.name="DimensionError",Jt.prototype.isDimensionError=!0;function Nn(i,t,e){if(!(this instanceof Nn))throw new SyntaxError("Constructor must be called with the new operator");this.index=i,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}Nn.prototype=new RangeError,Nn.prototype.constructor=RangeError,Nn.prototype.name="IndexError",Nn.prototype.isIndexError=!0;function Ie(i){for(var t=[];Array.isArray(i);)t.push(i.length),i=i[0];return t}function xc(i,t,e){var r,n=i.length;if(n!==t[e])throw new Jt(n,t[e]);if(e<t.length-1){var s=e+1;for(r=0;r<n;r++){var a=i[r];if(!Array.isArray(a))throw new Jt(t.length-1,t.length,"<");xc(i[r],t,s)}}else for(r=0;r<n;r++)if(Array.isArray(i[r]))throw new Jt(t.length+1,t.length,">")}function Ec(i,t){var e=t.length===0;if(e){if(Array.isArray(i))throw new Jt(i.length,0)}else xc(i,t,0)}function Me(i,t){if(i!==void 0){if(!me(i)||!xe(i))throw new TypeError("Index must be an integer (value: "+i+")");if(i<0||typeof t=="number"&&i>=t)throw new Nn(i,t)}}function Sa(i,t,e){if(!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(n){if(!me(n)||!xe(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+de(t)+")")}),(me(i)||Oe(i))&&(i=[i]);var r=e!==void 0?e:0;return Oa(i,t,0,r),i}function Oa(i,t,e,r){var n,s,a=i.length,u=t[e],c=Math.min(a,u);if(i.length=u,e<t.length-1){var f=e+1;for(n=0;n<c;n++)s=i[n],Array.isArray(s)||(s=[s],i[n]=s),Oa(s,t,f,r);for(n=c;n<u;n++)s=[],i[n]=s,Oa(s,t,f,r)}else{for(n=0;n<c;n++)for(;Array.isArray(i[n]);)i[n]=i[n][0];for(n=c;n<u;n++)i[n]=r}}function Ba(i,t){var e=Ia(i),r=e.length;if(!Array.isArray(i)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Jt(0,r,"!=");t=Ta(t,r);var n=Cc(t);if(r!==n)throw new Jt(n,r,"!=");try{return Ep(e,t)}catch(s){throw s instanceof Jt?new Jt(n,r,"!="):s}}function Ta(i,t){var e=Cc(i),r=i.slice(),n=-1,s=i.indexOf(n),a=i.indexOf(n,s+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var u=s>=0,c=t%e===0;if(u)if(c)r[s]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function Cc(i){return i.reduce((t,e)=>t*e,1)}function Ep(i,t){for(var e=i,r,n=t.length-1;n>0;n--){var s=t[n];r=[];for(var a=e.length/s,u=0;u<a;u++)r.push(e.slice(u*s,(u+1)*s));e=r}return e}function Ac(i,t,e,r){var n=r||Ie(i);if(e)for(var s=0;s<e;s++)i=[i],n.unshift(1);for(i=Mc(i,t,0);n.length<t;)n.push(1);return i}function Mc(i,t,e){var r,n;if(Array.isArray(i)){var s=e+1;for(r=0,n=i.length;r<n;r++)i[r]=Mc(i[r],t,s)}else for(var a=e;a<t;a++)i=[i];return i}function Ia(i){if(!Array.isArray(i))return i;var t=[];return i.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Ls(i,t){for(var e,r=0,n=0;n<i.length;n++){var s=i[n],a=Array.isArray(s);if(n===0&&a&&(r=s.length),a&&s.length!==r)return;var u=a?Ls(s,t):t(s);if(e===void 0)e=u;else if(e!==u)return"mixed"}return e}function Fc(i,t,e,r){if(r<e){if(i.length!==t.length)throw new Jt(i.length,t.length);for(var n=[],s=0;s<i.length;s++)n[s]=Fc(i[s],t[s],e,r+1);return n}else return i.concat(t)}function Nc(){var i=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(i.length===1)return i[0];if(i.length>1)return i.slice(1).reduce(function(e,r){return Fc(e,r,t,0)},i[0]);throw new Error("Wrong number of arguments in function concat")}function Cp(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];for(var r=t.map(_=>_.length),n=Math.max(...r),s=new Array(n).fill(null),a=0;a<t.length;a++)for(var u=t[a],c=r[a],f=0;f<c;f++){var d=n-c+f;u[f]>s[d]&&(s[d]=u[f])}for(var h=0;h<t.length;h++)Rs(t[h],s);return s}function Rs(i,t){for(var e=t.length,r=i.length,n=0;n<r;n++){var s=e-r+n;if(i[n]<t[s]&&i[n]>1||i[n]>t[s])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(r," with size ").concat(i[n]," to size ").concat(t[s]))}}function Sc(i,t){var e=Ie(i);if(yi(e,t))return i;Rs(e,t);var r=Cp(e,t),n=r.length,s=[...Array(n-e.length).fill(1),...e],a=Mp(i);e.length<n&&(a=Ba(a,s),e=Ie(a));for(var u=0;u<n;u++)e[u]<r[u]&&(a=Ap(a,r[u],u),e=Ie(a));return a}function Ap(i,t,e){return Nc(...Array(t).fill(i),e)}function Mp(i){return Ts([],i)}function gt(i,t,e,r){function n(s){var a=fp(s,t.map(Sp));return Fp(i,t,s),e(a)}return n.isFactory=!0,n.fn=i,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Fp(i,t,e){var r=t.filter(s=>!Np(s)).every(s=>e[s]!==void 0);if(!r){var n=t.filter(s=>e[s]===void 0);throw new Error('Cannot create function "'.concat(i,'", ')+"some dependencies are missing: ".concat(n.map(s=>'"'.concat(s,'"')).join(", "),"."))}}function Np(i){return i&&i[0]==="?"}function Sp(i){return i&&i[0]==="?"?i.slice(1):i}function Op(i,t){if(Bc(i)&&Oc(i,t))return i[t];throw typeof i[t]=="function"&&Ip(i,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Bp(i,t,e){if(Bc(i)&&Oc(i,t))return i[t]=e,e;throw new Error('No access to property "'+t+'"')}function Tp(i,t){return t in i}function Oc(i,t){return!i||typeof i!="object"?!1:es($p,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Ip(i,t){return i==null||typeof i[t]!="function"||es(i,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(i)?!1:es(Lp,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Bc(i){return typeof i=="object"&&i&&i.constructor===Object}var $p={length:!0,name:!0},Lp={toString:!0,valueOf:!0,toLocaleString:!0};class Rp{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Op(this.wrappedObject,t)}set(t,e){return Bp(this.wrappedObject,t,e),this}has(t){return Tp(this.wrappedObject,t)}entries(){return Pp(this.keys(),t=>[t,this.get(t)])}forEach(t){for(var e of this.keys())t(this.get(e),e,this)}delete(t){delete this.wrappedObject[t]}clear(){for(var t of this.keys())this.delete(t)}get size(){return Object.keys(this.wrappedObject).length}}function Pp(i,t){return{next:()=>{var e=i.next();return e.done?e:{value:t(e.value),done:!1}}}}function kp(i){return i?i instanceof Map||i instanceof Rp||typeof i.set=="function"&&typeof i.get=="function"&&typeof i.keys=="function"&&typeof i.has=="function":!1}var Tc=function(){return Tc=dc.create,dc},zp=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],qp=gt("typed",zp,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:s}=t,a=Tc();return a.clear(),a.addTypes([{name:"number",test:me},{name:"Complex",test:oc},{name:"BigNumber",test:Oe},{name:"Fraction",test:ac},{name:"Unit",test:uc},{name:"identifier",test:u=>en&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(u)},{name:"string",test:en},{name:"Chain",test:lp},{name:"Array",test:Ae},{name:"Matrix",test:we},{name:"DenseMatrix",test:L_},{name:"SparseMatrix",test:R_},{name:"Range",test:P_},{name:"Index",test:Ca},{name:"boolean",test:k_},{name:"ResultSet",test:z_},{name:"Help",test:q_},{name:"function",test:U_},{name:"Date",test:W_},{name:"RegExp",test:j_},{name:"null",test:Y_},{name:"undefined",test:V_},{name:"AccessorNode",test:H_},{name:"ArrayNode",test:Z_},{name:"AssignmentNode",test:K_},{name:"BlockNode",test:G_},{name:"ConditionalNode",test:J_},{name:"ConstantNode",test:X_},{name:"FunctionNode",test:tp},{name:"FunctionAssignmentNode",test:Q_},{name:"IndexNode",test:ep},{name:"Node",test:rp},{name:"ObjectNode",test:np},{name:"OperatorNode",test:ip},{name:"ParenthesisNode",test:sp},{name:"RangeNode",test:op},{name:"RelationalNode",test:ap},{name:"SymbolNode",test:up},{name:"Map",test:kp},{name:"Object",test:Aa}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||$a(c),gp(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new e(c)}},{from:"number",to:"Complex",convert:function(c){return r||Ps(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ps(c),new r(c.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(c){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(c){return r||Ps(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){s||La(c);var f=new s(c);if(f.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return f}},{from:"string",to:"number",convert:function(c){var f=Number(c);if(isNaN(f))throw new Error('Cannot convert "'+c+'" to a number');return f}},{from:"string",to:"BigNumber",convert:function(c){e||$a(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){s||La(c);try{return new s(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ps(c);try{return new r(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return e||$a(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return s||La(c),new s(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||Up(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(u,c,f)=>{var d=a.createError(u,c,f);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&ts(c[0])&&f.some(_=>!_.params.includes(","))){var h=new TypeError("Function '".concat(u,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(u,")'."));throw h.data=d.data,h}throw d},a.onMismatch=(u,c,f)=>{var d=a.createError(u,c,f);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&ts(c[0])&&f.some(_=>!_.params.includes(","))){var h=new TypeError("Function '".concat(u,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(u,")'."));throw h.data=d.data,h}throw d},a});function $a(i){throw new Error("Cannot convert value ".concat(i," into a BigNumber: no class 'BigNumber' provided"))}function Ps(i){throw new Error("Cannot convert value ".concat(i," into a Complex number: no class 'Complex' provided"))}function Up(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function La(i){throw new Error("Cannot convert value ".concat(i," into a Fraction, no class 'Fraction' provided."))}/*!
|
34
|
+
`);return Object.freeze(sc)};Ts(yr,sc,{MATRIX_OPTIONS:hp,NUMBER_OPTIONS:dp});function cc(){return!0}function Br(){return!1}function wi(){}const fc="Argument is not a typed-function.";function hc(){function i(P){return typeof P=="object"&&P!==null&&P.constructor===Object}const t=[{name:"number",test:function(P){return typeof P=="number"}},{name:"string",test:function(P){return typeof P=="string"}},{name:"boolean",test:function(P){return typeof P=="boolean"}},{name:"Function",test:function(P){return typeof P=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(P){return P instanceof Date}},{name:"RegExp",test:function(P){return P instanceof RegExp}},{name:"Object",test:i},{name:"null",test:function(P){return P===null}},{name:"undefined",test:function(P){return P===void 0}}],e={name:"any",test:cc,isAny:!0};let r,n,s=0,a={createCount:0};function u(P){const H=r.get(P);if(H)return H;let K='Unknown type "'+P+'"';const nt=P.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){K+='. Did you mean "'+st+'" ?';break}throw new TypeError(K)}function c(P){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const K=H?u(H).index:n.length,nt=[];for(let rt=0;rt<P.length;++rt){if(!P[rt]||typeof P[rt].name!="string"||typeof P[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=P[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:P[rt].test,isAny:P[rt].isAny,index:K+rt,conversionsTo:[]})}const st=n.slice(K);n=n.slice(0,K).concat(nt).concat(st);for(let rt=K+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function f(){r=new Map,n=[],s=0,c([e],!1)}f(),c(t);function d(){let P;for(P of n)r.get(P).conversionsTo=[];s=0}function h(P){const H=n.filter(K=>{const nt=r.get(K);return!nt.isAny&&nt.test(P)});return H.length?H:["any"]}function _(P){return P&&typeof P=="function"&&"_typedFunctionData"in P}function g(P,H,K){if(!_(P))throw new TypeError(fc);const nt=K&&K.exact,st=Array.isArray(H)?H.join(","):H,rt=C(st),ft=w(rt);if(!nt||ft in P.signatures){const Qt=P._typedFunctionData.signatureMap.get(ft);if(Qt)return Qt}const ct=rt.length;let ht;if(nt){ht=[];let Qt;for(Qt in P.signatures)ht.push(P._typedFunctionData.signatureMap.get(Qt))}else ht=P._typedFunctionData.signatures;for(let Qt=0;Qt<ct;++Qt){const oe=rt[Qt],Ee=[];let Ye;for(Ye of ht){const qe=S(Ye.params,Qt);if(!(!qe||oe.restParam&&!qe.restParam)){if(!qe.hasAny){const xr=b(qe);if(oe.types.some(Er=>!xr.has(Er.name)))continue}Ee.push(Ye)}}if(ht=Ee,ht.length===0)break}let lt;for(lt of ht)if(lt.params.length<=ct)return lt;throw new TypeError("Signature not found (signature: "+(P.name||"unnamed")+"("+w(rt,", ")+"))")}function y(P,H,K){return g(P,H,K).implementation}function p(P,H){const K=u(H);if(K.test(P))return P;const nt=K.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+H+" defined.");for(let st=0;st<nt.length;st++)if(u(nt[st].from).test(P))return nt[st].convert(P);throw new Error("Cannot convert "+P+" to "+H)}function w(P){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return P.map(K=>K.name).join(H)}function v(P){const H=P.indexOf("...")===0,nt=(H?P.length>3?P.slice(3):"any":P).split("|").map(ct=>u(ct.trim()));let st=!1,rt=H?"...":"";return{types:nt.map(function(ct){return st=ct.isAny||st,rt+=ct.name+"|",{name:ct.name,typeIndex:ct.index,test:ct.test,isAny:ct.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:H}}function x(P){const H=P.types.map(ft=>ft.name),K=Z(H);let nt=P.hasAny,st=P.name;const rt=K.map(function(ft){const ct=u(ft.from);return nt=ct.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ct.index,test:ct.test,isAny:ct.isAny,conversion:ft,conversionIndex:ft.index}});return{types:P.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:P.restParam}}function b(P){return P.typeSet||(P.typeSet=new Set,P.types.forEach(H=>P.typeSet.add(H.name))),P.typeSet}function C(P){const H=[];if(typeof P!="string")throw new TypeError("Signatures must be strings");const K=P.trim();if(K==="")return H;const nt=K.split(",");for(let st=0;st<nt.length;++st){const rt=v(nt[st].trim());if(rt.restParam&&st!==nt.length-1)throw new SyntaxError('Unexpected rest parameter "'+nt[st]+'": only allowed for the last parameter');if(rt.types.length===0)return null;H.push(rt)}return H}function E(P){const H=Bt(P);return H?H.restParam:!1}function A(P){if(!P||P.types.length===0)return cc;if(P.types.length===1)return u(P.types[0].name).test;if(P.types.length===2){const H=u(P.types[0].name).test,K=u(P.types[1].name).test;return function(st){return H(st)||K(st)}}else{const H=P.types.map(function(K){return u(K.name).test});return function(nt){for(let st=0;st<H.length;st++)if(H[st](nt))return!0;return!1}}}function N(P){let H,K,nt;if(E(P)){H=re(P).map(A);const st=H.length,rt=A(Bt(P)),ft=function(ct){for(let ht=st;ht<ct.length;ht++)if(!rt(ct[ht]))return!1;return!0};return function(ht){for(let lt=0;lt<H.length;lt++)if(!H[lt](ht[lt]))return!1;return ft(ht)&&ht.length>=st+1}}else return P.length===0?function(rt){return rt.length===0}:P.length===1?(K=A(P[0]),function(rt){return K(rt[0])&&rt.length===1}):P.length===2?(K=A(P[0]),nt=A(P[1]),function(rt){return K(rt[0])&&nt(rt[1])&&rt.length===2}):(H=P.map(A),function(rt){for(let ft=0;ft<H.length;ft++)if(!H[ft](rt[ft]))return!1;return rt.length===H.length})}function S(P,H){return H<P.length?P[H]:E(P)?Bt(P):null}function I(P,H){const K=S(P,H);return K?b(K):new Set}function F(P){return P.conversion===null||P.conversion===void 0}function O(P,H){const K=new Set;return P.forEach(nt=>{const st=I(nt.params,H);let rt;for(rt of st)K.add(rt)}),K.has("any")?["any"]:Array.from(K)}function L(P,H,K){let nt,st;const rt=P||"unnamed";let ft=K,ct;for(ct=0;ct<H.length;ct++){const oe=[];if(ft.forEach(Ee=>{const Ye=S(Ee.params,ct),qe=A(Ye);(ct<Ee.params.length||E(Ee.params))&&qe(H[ct])&&oe.push(Ee)}),oe.length===0){if(st=O(ft,ct),st.length>0){const Ee=h(H[ct]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+Ee.join(" | ")+", index: "+ct+")"),nt.data={category:"wrongType",fn:rt,index:ct,actual:Ee,expected:st},nt}}else ft=oe}const ht=ft.map(function(oe){return E(oe.params)?1/0:oe.params.length});if(H.length<Math.min.apply(null,ht))return st=O(ft,ct),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+H.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:H.length,expected:st},nt;const lt=Math.max.apply(null,ht);if(H.length>lt)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+lt+", actual: "+H.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:H.length,expectedLength:lt},nt;const Qt=[];for(let oe=0;oe<H.length;++oe)Qt.push(h(H[oe]).join("|"));return nt=new TypeError('Arguments of type "'+Qt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Qt},nt}function z(P){let H=n.length+1;for(let K=0;K<P.types.length;K++)F(P.types[K])&&(H=Math.min(H,P.types[K].typeIndex));return H}function q(P){let H=s+1;for(let K=0;K<P.types.length;K++)F(P.types[K])||(H=Math.min(H,P.types[K].conversionIndex));return H}function W(P,H){if(P.hasAny){if(!H.hasAny)return 1}else if(H.hasAny)return-1;if(P.restParam){if(!H.restParam)return 1}else if(H.restParam)return-1;if(P.hasConversion){if(!H.hasConversion)return 1}else if(H.hasConversion)return-1;const K=z(P)-z(H);if(K<0)return-1;if(K>0)return 1;const nt=q(P)-q(H);return nt<0?-1:nt>0?1:0}function R(P,H){const K=P.params,nt=H.params,st=Bt(K),rt=Bt(nt),ft=E(K),ct=E(nt);if(ft&&st.hasAny){if(!ct||!rt.hasAny)return 1}else if(ct&&rt.hasAny)return-1;let ht=0,lt=0,Qt;for(Qt of K)Qt.hasAny&&++ht,Qt.hasConversion&&++lt;let oe=0,Ee=0;for(Qt of nt)Qt.hasAny&&++oe,Qt.hasConversion&&++Ee;if(ht!==oe)return ht-oe;if(ft&&st.hasConversion){if(!ct||!rt.hasConversion)return 1}else if(ct&&rt.hasConversion)return-1;if(lt!==Ee)return lt-Ee;if(ft){if(!ct)return 1}else if(ct)return-1;const Ye=(K.length-nt.length)*(ft?-1:1);if(Ye!==0)return Ye;const qe=[];let xr=0;for(let Pn=0;Pn<K.length;++Pn){const ui=W(K[Pn],nt[Pn]);qe.push(ui),xr+=ui}if(xr!==0)return xr;let Er;for(Er of qe)if(Er!==0)return Er;return 0}function Z(P){if(P.length===0)return[];const H=P.map(u);P.length>1&&H.sort((st,rt)=>st.index-rt.index);let K=H[0].conversionsTo;if(P.length===1)return K;K=K.concat([]);const nt=new Set(P);for(let st=1;st<H.length;++st){let rt;for(rt of H[st].conversionsTo)nt.has(rt.from)||(K.push(rt),nt.add(rt.from))}return K}function Y(P,H){let K=H;if(P.some(st=>st.hasConversion)){const st=E(P),rt=P.map(G);K=function(){const ct=[],ht=st?arguments.length-1:arguments.length;for(let lt=0;lt<ht;lt++)ct[lt]=rt[lt](arguments[lt]);return st&&(ct[ht]=arguments[ht].map(rt[ht])),H.apply(this,ct)}}let nt=K;if(E(P)){const st=P.length-1;nt=function(){return K.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function G(P){let H,K,nt,st;const rt=[],ft=[];switch(P.types.forEach(function(ct){ct.conversion&&(rt.push(u(ct.conversion.from).test),ft.push(ct.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return H=rt[0],nt=ft[0],function(ht){return H(ht)?nt(ht):ht};case 2:return H=rt[0],K=rt[1],nt=ft[0],st=ft[1],function(ht){return H(ht)?nt(ht):K(ht)?st(ht):ht};default:return function(ht){for(let lt=0;lt<ft.length;lt++)if(rt[lt](ht))return ft[lt](ht);return ht}}}function Q(P){function H(K,nt,st){if(nt<K.length){const rt=K[nt];let ft=[];if(rt.restParam){const ct=rt.types.filter(F);ct.length<rt.types.length&&ft.push({types:ct,name:"..."+ct.map(ht=>ht.name).join("|"),hasAny:ct.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ct){return{types:[ct],name:ct.name,hasAny:ct.isAny,hasConversion:ct.conversion,restParam:!1}});return se(ft,function(ct){return H(K,nt+1,st.concat([ct]))})}else return[st]}return H(P,0,[])}function ut(P,H){const K=Math.max(P.length,H.length);for(let ct=0;ct<K;ct++){const ht=I(P,ct),lt=I(H,ct);let Qt=!1,oe;for(oe of lt)if(ht.has(oe)){Qt=!0;break}if(!Qt)return!1}const nt=P.length,st=H.length,rt=E(P),ft=E(H);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function _t(P){return P.map(H=>ze(H)?Le(H.referToSelf.callback):Dr(H)?Xt(H.referTo.references,H.referTo.callback):H)}function at(P,H,K){const nt=[];let st;for(st of P){let rt=K[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=H[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function vt(P,H,K){const nt=_t(P),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ct=0;ct<nt.length;++ct){if(st[ct])continue;const ht=nt[ct];if(ze(ht))nt[ct]=ht.referToSelf.callback(K),nt[ct].referToSelf=ht.referToSelf,st[ct]=!0,ft=!1;else if(Dr(ht)){const lt=at(ht.referTo.references,nt,H);lt?(nt[ct]=ht.referTo.callback.apply(this,lt),nt[ct].referTo=ht.referTo,st[ct]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function wt(P){const H=/\bthis(\(|\.signatures\b)/;Object.keys(P).forEach(K=>{const nt=P[K];if(H.test(nt.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Ct(P,H){if(a.createCount++,Object.keys(H).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&wt(H);const K=[],nt=[],st={},rt=[];let ft;for(ft in H){if(!Object.prototype.hasOwnProperty.call(H,ft))continue;const Zt=C(ft);if(!Zt)continue;K.forEach(function(kn){if(ut(kn,Zt))throw new TypeError('Conflicting signatures "'+w(kn)+'" and "'+w(Zt)+'".')}),K.push(Zt);const er=nt.length;nt.push(H[ft]);const Tu=Zt.map(x);let ki;for(ki of Q(Tu)){const kn=w(ki);rt.push({params:ki,name:kn,fn:er}),ki.every($o=>!$o.hasConversion)&&(st[kn]=er)}}rt.sort(R);const ct=vt(nt,st,li);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ct[st[ht]]);const lt=[],Qt=new Map;for(ht of rt)Qt.has(ht.name)||(ht.fn=ct[ht.fn],lt.push(ht),Qt.set(ht.name,ht));const oe=lt[0]&<[0].params.length<=2&&!E(lt[0].params),Ee=lt[1]&<[1].params.length<=2&&!E(lt[1].params),Ye=lt[2]&<[2].params.length<=2&&!E(lt[2].params),qe=lt[3]&<[3].params.length<=2&&!E(lt[3].params),xr=lt[4]&<[4].params.length<=2&&!E(lt[4].params),Er=lt[5]&<[5].params.length<=2&&!E(lt[5].params),Pn=oe&&Ee&&Ye&&qe&&xr&&Er;for(let Zt=0;Zt<lt.length;++Zt)lt[Zt].test=N(lt[Zt].params);const ui=oe?A(lt[0].params[0]):Br,Bo=Ee?A(lt[1].params[0]):Br,fu=Ye?A(lt[2].params[0]):Br,hu=qe?A(lt[3].params[0]):Br,du=xr?A(lt[4].params[0]):Br,_u=Er?A(lt[5].params[0]):Br,To=oe?A(lt[0].params[1]):Br,pu=Ee?A(lt[1].params[1]):Br,mu=Ye?A(lt[2].params[1]):Br,gu=qe?A(lt[3].params[1]):Br,fs=xr?A(lt[4].params[1]):Br,vu=Er?A(lt[5].params[1]):Br;for(let Zt=0;Zt<lt.length;++Zt)lt[Zt].implementation=Y(lt[Zt].params,lt[Zt].fn);const hs=oe?lt[0].implementation:wi,yu=Ee?lt[1].implementation:wi,wu=Ye?lt[2].implementation:wi,Du=qe?lt[3].implementation:wi,bu=xr?lt[4].implementation:wi,xu=Er?lt[5].implementation:wi,Eu=oe?lt[0].params.length:-1,Cu=Ee?lt[1].params.length:-1,Au=Ye?lt[2].params.length:-1,Io=qe?lt[3].params.length:-1,Mu=xr?lt[4].params.length:-1,Fu=Er?lt[5].params.length:-1,Nu=Pn?6:0,Su=lt.length,Ou=lt.map(Zt=>Zt.test),Bu=lt.map(Zt=>Zt.implementation),Pi=function(){for(let er=Nu;er<Su;er++)if(Ou[er](arguments))return Bu[er].apply(this,arguments);return a.onMismatch(P,arguments,lt)};function li(Zt,er){return arguments.length===Eu&&ui(Zt)&&To(er)?hs.apply(this,arguments):arguments.length===Cu&&Bo(Zt)&&pu(er)?yu.apply(this,arguments):arguments.length===Au&&fu(Zt)&&mu(er)?wu.apply(this,arguments):arguments.length===Io&&hu(Zt)&&gu(er)?Du.apply(this,arguments):arguments.length===Mu&&du(Zt)&&fs(er)?bu.apply(this,arguments):arguments.length===Fu&&_u(Zt)&&vu(er)?xu.apply(this,arguments):Pi.apply(this,arguments)}try{Object.defineProperty(li,"name",{value:P})}catch{}return li.signatures=st,li._typedFunctionData={signatures:lt,signatureMap:Qt},li}function bt(P,H,K){throw L(P,H,K)}function re(P){return Nt(P,0,P.length-1)}function Bt(P){return P[P.length-1]}function Nt(P,H,K){return Array.prototype.slice.call(P,H,K)}function he(P,H){for(let K=0;K<P.length;K++)if(H(P[K]))return P[K]}function se(P,H){return Array.prototype.concat.apply([],P.map(H))}function qt(){const P=re(arguments).map(K=>w(C(K))),H=Bt(arguments);if(typeof H!="function")throw new TypeError("Callback function expected as last argument");return Xt(P,H)}function Xt(P,H){return{referTo:{references:P,callback:H}}}function Le(P){if(typeof P!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:P}}}function Dr(P){return P&&typeof P.referTo=="object"&&Array.isArray(P.referTo.references)&&typeof P.referTo.callback=="function"}function ze(P){return P&&typeof P.referToSelf=="object"&&typeof P.referToSelf.callback=="function"}function mn(P,H){if(!P)return H;if(H&&H!==P){const K=new Error("Function names do not match (expected: "+P+", actual: "+H+")");throw K.data={actual:H,expected:P},K}return P}function Ln(P){let H;for(const K in P)Object.prototype.hasOwnProperty.call(P,K)&&(_(P[K])||typeof P[K].signature=="string")&&(H=mn(H,P[K].name));return H}function gn(P,H){let K;for(K in H)if(Object.prototype.hasOwnProperty.call(H,K)){if(K in P&&H[K]!==P[K]){const nt=new Error('Signature "'+K+'" is defined twice');throw nt.data={signature:K,sourceFunction:H[K],destFunction:P[K]},nt}P[K]=H[K]}}const br=a;a=function(P){const H=typeof P=="string",K=H?1:0;let nt=H?P:"";const st={};for(let rt=K;rt<arguments.length;++rt){const ft=arguments[rt];let ct={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ct[ft.signature]=ft:_(ft)&&(ct=ft.signatures)):i(ft)&&(ct=ft,H||(ht=Ln(ft))),Object.keys(ct).length===0){const lt=new TypeError("Argument to 'typed' at index "+rt+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw lt.data={index:rt,argument:ft},lt}H||(nt=mn(nt,ht)),gn(st,ct)}return Ct(nt||"",st)},a.create=hc,a.createCount=br.createCount,a.onMismatch=bt,a.throwMismatchError=bt,a.createError=L,a.clear=f,a.clearConversions=d,a.addTypes=c,a._findType=u,a.referTo=qt,a.referToSelf=Le,a.convert=p,a.findSignature=g,a.find=y,a.isTypedFunction=_,a.warnAgainstDeprecatedThis=!0,a.addType=function(P,H){let K="any";H!==!1&&r.has("Object")&&(K="Object"),a.addTypes([P],K)};function Rn(P){if(!P||typeof P.from!="string"||typeof P.to!="string"||typeof P.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(P.to===P.from)throw new SyntaxError('Illegal to define conversion from "'+P.from+'" to itself.')}return a.addConversion=function(P){Rn(P);const H=u(P.to);if(H.conversionsTo.every(function(K){return K.from!==P.from}))H.conversionsTo.push({from:P.from,convert:P.convert,index:s++});else throw new Error('There is already a conversion from "'+P.from+'" to "'+H.name+'"')},a.addConversions=function(P){P.forEach(a.addConversion)},a.removeConversion=function(P){Rn(P);const H=u(P.to),K=he(H.conversionsTo,st=>st.from===P.from);if(!K)throw new Error("Attempt to remove nonexistent conversion from "+P.from+" to "+P.to);if(K.convert!==P.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=H.conversionsTo.indexOf(K);H.conversionsTo.splice(nt,1)},a.resolve=function(P,H){if(!_(P))throw new TypeError(fc);const K=P._typedFunctionData.signatures;for(let nt=0;nt<K.length;++nt)if(K[nt].test(H))return K[nt];return null},a}var dc=hc();function xe(i){return typeof i=="boolean"?!0:isFinite(i)?i===Math.round(i):!1}function Ma(i,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!xe(e))throw new Error("size must be an integer");if(i>2**(e-1)-1||i<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!xe(i))throw new Error("Value must be an integer");i<0&&(i=i+2**e),s="i".concat(e)}var a="";return i<0&&(i=-i,a="-"),"".concat(a).concat(n).concat(i.toString(t)).concat(s)}function Fa(i,t){if(typeof t=="function")return t(i);if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(isNaN(i))return"NaN";var{notation:e,precision:r,wordSize:n}=_c(t);switch(e){case"fixed":return pp(i,r);case"exponential":return pc(i,r);case"engineering":return _p(i,r);case"bin":return Ma(i,2,n);case"oct":return Ma(i,8,n);case"hex":return Ma(i,16,n);case"auto":return mp(i,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],a=arguments[4];return s!=="."?s+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function _c(i){var t="auto",e,r;if(i!==void 0)if(me(i))e=i;else if(Oe(i))e=i.toNumber();else if(Aa(i))i.precision!==void 0&&(e=mc(i.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),i.wordSize!==void 0&&(r=mc(i.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),i.notation&&(t=i.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function Is(i){var t=String(i).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+i);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),s=r.indexOf(".");n+=s!==-1?s-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(u){return n-=u.length,""}).replace(/0*$/,"").split("").map(function(u){return parseInt(u)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function _p(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Is(i),r=$s(e,t),n=r.exponent,s=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(me(t))for(;t>s.length||n-a+1>s.length;)s.push(0);else for(var u=Math.abs(n-a)-(s.length-1),c=0;c<u;c++)s.push(0);for(var f=Math.abs(n-a),d=1;f>0;)d++,f--;var h=s.slice(d).join(""),_=me(t)&&h.length||h.match(/[1-9]/)?"."+h:"",g=s.slice(0,d).join("")+_+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function pp(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Is(i),r=typeof t=="number"?$s(e,e.exponent+1+t):e,n=r.coefficients,s=r.exponent+1,a=s+(t||0);return n.length<a&&(n=n.concat(Di(a-n.length))),s<0&&(n=Di(-s+1).concat(n),s=1),s<n.length&&n.splice(s,0,s===0?"0.":"."),r.sign+n.join("")}function pc(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Is(i),r=t?$s(e,t):e,n=r.coefficients,s=r.exponent;n.length<t&&(n=n.concat(Di(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(s>=0?"+":"")+s}function mp(i,t,e){if(isNaN(i)||!isFinite(i))return String(i);var r=gc(e==null?void 0:e.lowerExp,-3),n=gc(e==null?void 0:e.upperExp,5),s=Is(i),a=t?$s(s,t):s;if(a.exponent<r||a.exponent>=n)return pc(i,t);var u=a.coefficients,c=a.exponent;u.length<t&&(u=u.concat(Di(t-u.length))),u=u.concat(Di(c-u.length+1+(u.length<t?t-u.length:0))),u=Di(-c).concat(u);var f=c>0?c:0;return f<u.length-1&&u.splice(f+1,0,"."),a.sign+u.join("")}function $s(i,t){for(var e={sign:i.sign,coefficients:i.coefficients,exponent:i.exponent},r=e.coefficients;t<=0;)r.unshift(0),e.exponent++,t++;if(r.length>t){var n=r.splice(t,r.length-t);if(n[0]>=5){var s=t-1;for(r[s]++;r[s]===10;)r.pop(),s===0&&(r.unshift(0),e.exponent++,s++),s--,r[s]++}}return e}function Di(i){for(var t=[],e=0;e<i;e++)t.push(0);return t}function gp(i){return i.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var vp=Number.EPSILON||2220446049250313e-31;function Qn(i,t,e){if(e==null)return i===t;if(i===t)return!0;if(isNaN(i)||isNaN(t))return!1;if(isFinite(i)&&isFinite(t)){var r=Math.abs(i-t);return r<=vp?!0:r<=Math.max(Math.abs(i),Math.abs(t))*e}return!1}function mc(i,t){if(me(i))return i;if(Oe(i))return i.toNumber();t()}function gc(i,t){return me(i)?i:Oe(i)?i.toNumber():t}function Na(i,t,e){var r=i.constructor,n=new r(2),s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!xe(e))throw new Error("size must be an integer");if(i.greaterThan(n.pow(e-1).sub(1))||i.lessThan(n.pow(e-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!i.isInteger())throw new Error("Value must be an integer");i.lessThan(0)&&(i=i.add(n.pow(e))),s="i".concat(e)}switch(t){case 2:return"".concat(i.toBinary()).concat(s);case 8:return"".concat(i.toOctal()).concat(s);case 16:return"".concat(i.toHexadecimal()).concat(s);default:throw new Error("Base ".concat(t," not supported "))}}function yp(i,t){if(typeof t=="function")return t(i);if(!i.isFinite())return i.isNaN()?"NaN":i.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=_c(t);switch(e){case"fixed":return Dp(i,r);case"exponential":return vc(i,r);case"engineering":return wp(i,r);case"bin":return Na(i,2,n);case"oct":return Na(i,8,n);case"hex":return Na(i,16,n);case"auto":{var s=yc(t==null?void 0:t.lowerExp,-3),a=yc(t==null?void 0:t.upperExp,5);if(i.isZero())return"0";var u,c=i.toSignificantDigits(r),f=c.e;return f>=s&&f<a?u=c.toFixed():u=vc(i,r),u.replace(/((\.\d*?)(0+))($|e)/,function(){var d=arguments[2],h=arguments[4];return d!=="."?d+h:h})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function wp(i,t){var e=i.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=i.mul(Math.pow(10,-r)),s=n.toPrecision(t);if(s.indexOf("e")!==-1){var a=i.constructor;s=new a(s).toFixed()}return s+"e"+(e>=0?"+":"")+r.toString()}function vc(i,t){return t!==void 0?i.toExponential(t-1):i.toExponential()}function Dp(i,t){return i.toFixed(t)}function yc(i,t){return me(i)?i:Oe(i)?i.toNumber():t}function de(i,t){var e=bp(i,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function bp(i,t){if(typeof i=="number")return Fa(i,t);if(Oe(i))return yp(i,t);if(xp(i))return!t||t.fraction!=="decimal"?i.s*i.n+"/"+i.d:i.toString();if(Array.isArray(i))return bc(i,t);if(en(i))return wc(i);if(typeof i=="function")return i.syntax?String(i.syntax):"function";if(i&&typeof i=="object"){if(typeof i.format=="function")return i.format(t);if(i&&i.toString(t)!=={}.toString())return i.toString(t);var e=Object.keys(i).map(r=>wc(r)+": "+de(i[r],t));return"{"+e.join(", ")+"}"}return String(i)}function wc(i){for(var t=String(i),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Dc?Dc[n]:n,r++}return'"'+e+'"'}var Dc={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function bc(i,t){if(Array.isArray(i)){for(var e="[",r=i.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=bc(i[n],t);return e+="]",e}else return de(i,t)}function xp(i){return i&&typeof i=="object"&&typeof i.s=="number"&&typeof i.n=="number"&&typeof i.d=="number"||!1}function Jt(i,t,e){if(!(this instanceof Jt))throw new SyntaxError("Constructor must be called with the new operator");this.actual=i,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(i)?"["+i.join(", ")+"]":i)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Jt.prototype=new RangeError,Jt.prototype.constructor=RangeError,Jt.prototype.name="DimensionError",Jt.prototype.isDimensionError=!0;function Nn(i,t,e){if(!(this instanceof Nn))throw new SyntaxError("Constructor must be called with the new operator");this.index=i,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}Nn.prototype=new RangeError,Nn.prototype.constructor=RangeError,Nn.prototype.name="IndexError",Nn.prototype.isIndexError=!0;function Ie(i){for(var t=[];Array.isArray(i);)t.push(i.length),i=i[0];return t}function xc(i,t,e){var r,n=i.length;if(n!==t[e])throw new Jt(n,t[e]);if(e<t.length-1){var s=e+1;for(r=0;r<n;r++){var a=i[r];if(!Array.isArray(a))throw new Jt(t.length-1,t.length,"<");xc(i[r],t,s)}}else for(r=0;r<n;r++)if(Array.isArray(i[r]))throw new Jt(t.length+1,t.length,">")}function Ec(i,t){var e=t.length===0;if(e){if(Array.isArray(i))throw new Jt(i.length,0)}else xc(i,t,0)}function Me(i,t){if(i!==void 0){if(!me(i)||!xe(i))throw new TypeError("Index must be an integer (value: "+i+")");if(i<0||typeof t=="number"&&i>=t)throw new Nn(i,t)}}function Sa(i,t,e){if(!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(n){if(!me(n)||!xe(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+de(t)+")")}),(me(i)||Oe(i))&&(i=[i]);var r=e!==void 0?e:0;return Oa(i,t,0,r),i}function Oa(i,t,e,r){var n,s,a=i.length,u=t[e],c=Math.min(a,u);if(i.length=u,e<t.length-1){var f=e+1;for(n=0;n<c;n++)s=i[n],Array.isArray(s)||(s=[s],i[n]=s),Oa(s,t,f,r);for(n=c;n<u;n++)s=[],i[n]=s,Oa(s,t,f,r)}else{for(n=0;n<c;n++)for(;Array.isArray(i[n]);)i[n]=i[n][0];for(n=c;n<u;n++)i[n]=r}}function Ba(i,t){var e=Ia(i),r=e.length;if(!Array.isArray(i)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Jt(0,r,"!=");t=Ta(t,r);var n=Cc(t);if(r!==n)throw new Jt(n,r,"!=");try{return Ep(e,t)}catch(s){throw s instanceof Jt?new Jt(n,r,"!="):s}}function Ta(i,t){var e=Cc(i),r=i.slice(),n=-1,s=i.indexOf(n),a=i.indexOf(n,s+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var u=s>=0,c=t%e===0;if(u)if(c)r[s]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function Cc(i){return i.reduce((t,e)=>t*e,1)}function Ep(i,t){for(var e=i,r,n=t.length-1;n>0;n--){var s=t[n];r=[];for(var a=e.length/s,u=0;u<a;u++)r.push(e.slice(u*s,(u+1)*s));e=r}return e}function Ac(i,t,e,r){var n=r||Ie(i);if(e)for(var s=0;s<e;s++)i=[i],n.unshift(1);for(i=Mc(i,t,0);n.length<t;)n.push(1);return i}function Mc(i,t,e){var r,n;if(Array.isArray(i)){var s=e+1;for(r=0,n=i.length;r<n;r++)i[r]=Mc(i[r],t,s)}else for(var a=e;a<t;a++)i=[i];return i}function Ia(i){if(!Array.isArray(i))return i;var t=[];return i.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Ls(i,t){for(var e,r=0,n=0;n<i.length;n++){var s=i[n],a=Array.isArray(s);if(n===0&&a&&(r=s.length),a&&s.length!==r)return;var u=a?Ls(s,t):t(s);if(e===void 0)e=u;else if(e!==u)return"mixed"}return e}function Fc(i,t,e,r){if(r<e){if(i.length!==t.length)throw new Jt(i.length,t.length);for(var n=[],s=0;s<i.length;s++)n[s]=Fc(i[s],t[s],e,r+1);return n}else return i.concat(t)}function Nc(){var i=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(i.length===1)return i[0];if(i.length>1)return i.slice(1).reduce(function(e,r){return Fc(e,r,t,0)},i[0]);throw new Error("Wrong number of arguments in function concat")}function Cp(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];for(var r=t.map(_=>_.length),n=Math.max(...r),s=new Array(n).fill(null),a=0;a<t.length;a++)for(var u=t[a],c=r[a],f=0;f<c;f++){var d=n-c+f;u[f]>s[d]&&(s[d]=u[f])}for(var h=0;h<t.length;h++)Rs(t[h],s);return s}function Rs(i,t){for(var e=t.length,r=i.length,n=0;n<r;n++){var s=e-r+n;if(i[n]<t[s]&&i[n]>1||i[n]>t[s])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(r," with size ").concat(i[n]," to size ").concat(t[s]))}}function Sc(i,t){var e=Ie(i);if(yi(e,t))return i;Rs(e,t);var r=Cp(e,t),n=r.length,s=[...Array(n-e.length).fill(1),...e],a=Mp(i);e.length<n&&(a=Ba(a,s),e=Ie(a));for(var u=0;u<n;u++)e[u]<r[u]&&(a=Ap(a,r[u],u),e=Ie(a));return a}function Ap(i,t,e){return Nc(...Array(t).fill(i),e)}function Mp(i){return Ts([],i)}function gt(i,t,e,r){function n(s){var a=fp(s,t.map(Sp));return Fp(i,t,s),e(a)}return n.isFactory=!0,n.fn=i,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Fp(i,t,e){var r=t.filter(s=>!Np(s)).every(s=>e[s]!==void 0);if(!r){var n=t.filter(s=>e[s]===void 0);throw new Error('Cannot create function "'.concat(i,'", ')+"some dependencies are missing: ".concat(n.map(s=>'"'.concat(s,'"')).join(", "),"."))}}function Np(i){return i&&i[0]==="?"}function Sp(i){return i&&i[0]==="?"?i.slice(1):i}function Op(i,t){if(Bc(i)&&Oc(i,t))return i[t];throw typeof i[t]=="function"&&Ip(i,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Bp(i,t,e){if(Bc(i)&&Oc(i,t))return i[t]=e,e;throw new Error('No access to property "'+t+'"')}function Tp(i,t){return t in i}function Oc(i,t){return!i||typeof i!="object"?!1:es($p,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Ip(i,t){return i==null||typeof i[t]!="function"||es(i,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(i)?!1:es(Lp,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Bc(i){return typeof i=="object"&&i&&i.constructor===Object}var $p={length:!0,name:!0},Lp={toString:!0,valueOf:!0,toLocaleString:!0};class Rp{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Op(this.wrappedObject,t)}set(t,e){return Bp(this.wrappedObject,t,e),this}has(t){return Tp(this.wrappedObject,t)}entries(){return Pp(this.keys(),t=>[t,this.get(t)])}forEach(t){for(var e of this.keys())t(this.get(e),e,this)}delete(t){delete this.wrappedObject[t]}clear(){for(var t of this.keys())this.delete(t)}get size(){return Object.keys(this.wrappedObject).length}}function Pp(i,t){return{next:()=>{var e=i.next();return e.done?e:{value:t(e.value),done:!1}}}}function kp(i){return i?i instanceof Map||i instanceof Rp||typeof i.set=="function"&&typeof i.get=="function"&&typeof i.keys=="function"&&typeof i.has=="function":!1}var Tc=function(){return Tc=dc.create,dc},zp=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],qp=gt("typed",zp,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:s}=t,a=Tc();return a.clear(),a.addTypes([{name:"number",test:me},{name:"Complex",test:oc},{name:"BigNumber",test:Oe},{name:"Fraction",test:ac},{name:"Unit",test:uc},{name:"identifier",test:u=>en&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(u)},{name:"string",test:en},{name:"Chain",test:lp},{name:"Array",test:Ae},{name:"Matrix",test:we},{name:"DenseMatrix",test:L_},{name:"SparseMatrix",test:R_},{name:"Range",test:P_},{name:"Index",test:Ca},{name:"boolean",test:k_},{name:"ResultSet",test:z_},{name:"Help",test:q_},{name:"function",test:U_},{name:"Date",test:W_},{name:"RegExp",test:j_},{name:"null",test:Y_},{name:"undefined",test:V_},{name:"AccessorNode",test:H_},{name:"ArrayNode",test:Z_},{name:"AssignmentNode",test:K_},{name:"BlockNode",test:G_},{name:"ConditionalNode",test:J_},{name:"ConstantNode",test:X_},{name:"FunctionNode",test:tp},{name:"FunctionAssignmentNode",test:Q_},{name:"IndexNode",test:ep},{name:"Node",test:rp},{name:"ObjectNode",test:np},{name:"OperatorNode",test:ip},{name:"ParenthesisNode",test:sp},{name:"RangeNode",test:op},{name:"RelationalNode",test:ap},{name:"SymbolNode",test:up},{name:"Map",test:kp},{name:"Object",test:Aa}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||$a(c),gp(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new e(c)}},{from:"number",to:"Complex",convert:function(c){return r||Ps(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ps(c),new r(c.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(c){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(c){return r||Ps(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){s||La(c);var f=new s(c);if(f.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return f}},{from:"string",to:"number",convert:function(c){var f=Number(c);if(isNaN(f))throw new Error('Cannot convert "'+c+'" to a number');return f}},{from:"string",to:"BigNumber",convert:function(c){e||$a(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){s||La(c);try{return new s(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ps(c);try{return new r(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return e||$a(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return s||La(c),new s(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||Up(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(u,c,f)=>{var d=a.createError(u,c,f);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&ts(c[0])&&f.some(_=>!_.params.includes(","))){var h=new TypeError("Function '".concat(u,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(u,")'."));throw h.data=d.data,h}throw d},a.onMismatch=(u,c,f)=>{var d=a.createError(u,c,f);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&ts(c[0])&&f.some(_=>!_.params.includes(","))){var h=new TypeError("Function '".concat(u,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(u,")'."));throw h.data=d.data,h}throw d},a});function $a(i){throw new Error("Cannot convert value ".concat(i," into a BigNumber: no class 'BigNumber' provided"))}function Ps(i){throw new Error("Cannot convert value ".concat(i," into a Complex number: no class 'Complex' provided"))}function Up(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function La(i){throw new Error("Cannot convert value ".concat(i," into a Fraction, no class 'Fraction' provided."))}/*!
|
35
35
|
* decimal.js v10.4.3
|
36
36
|
* An arbitrary-precision Decimal type for JavaScript.
|
37
37
|
* https://github.com/MikeMcl/decimal.js
|
38
38
|
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
|
39
39
|
* MIT Licence
|
40
|
-
*/var bi=9e15,Sn=1e9,Ra="0123456789abcdef",ks="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",zs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Pa={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-bi,maxE:bi,crypto:!1},Ic,hn,Ot=!0,qs="[DecimalError] ",On=qs+"Invalid argument: ",$c=qs+"Precision limit exceeded",Lc=qs+"crypto unavailable",Rc="[object Decimal]",Qe=Math.floor,ke=Math.pow,Wp=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,jp=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Yp=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Pc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Hr=1e7,Et=7,Vp=9007199254740991,Hp=ks.length-1,ka=zs.length-1,it={toStringTag:Rc};it.absoluteValue=it.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),xt(i)},it.ceil=function(){return xt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(i,t){var e,r=this,n=r.constructor;if(i=new n(i),t=new n(t),!i.s||!t.s)return new n(NaN);if(i.gt(t))throw Error(On+t);return e=r.cmp(i),e<0?i:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(i){var t,e,r,n,s=this,a=s.d,u=(i=new s.constructor(i)).d,c=s.s,f=i.s;if(!a||!u)return!c||!f?NaN:c!==f?c:a===u?0:!a^c<0?1:-1;if(!a[0]||!u[0])return a[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==i.e)return s.e>i.e^c<0?1:-1;for(r=a.length,n=u.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==u[t])return a[t]>u[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var i,t,e=this,r=e.constructor;return e.d?e.d[0]?(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Zp(r,jc(r,e)),r.precision=i,r.rounding=t,xt(hn==2||hn==3?e.neg():e,i,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var i,t,e,r,n,s,a,u,c,f,d=this,h=d.constructor;if(!d.isFinite()||d.isZero())return new h(d);for(Ot=!1,s=d.s*ke(d.s*d,1/3),!s||Math.abs(s)==1/0?(e=Ke(d.d),i=d.e,(s=(i-e.length+1)%3)&&(e+=s==1||s==-2?"0":"00"),s=ke(e,1/3),i=Qe((i+1)/3)-(i%3==(i<0?-1:2)),s==1/0?e="5e"+i:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),r=new h(e),r.s=d.s):r=new h(s.toString()),a=(i=h.precision)+3;;)if(u=r,c=u.times(u).times(u),f=c.plus(d),r=_e(f.plus(d).times(u),f.plus(c),a+2,1),Ke(u.d).slice(0,a)===(e=Ke(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(xt(u,i+1,0),u.times(u).times(u).eq(d))){r=u;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(xt(r,i+1,1),t=!r.times(r).times(r).eq(d));break}return Ot=!0,xt(r,i,h.rounding,t)},it.decimalPlaces=it.dp=function(){var i,t=this.d,e=NaN;if(t){if(i=t.length-1,e=(i-Qe(this.e/Et))*Et,i=t[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(i){return _e(this,new this.constructor(i))},it.dividedToIntegerBy=it.divToInt=function(i){var t=this,e=t.constructor;return xt(_e(t,new e(i),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(i){return this.cmp(i)===0},it.floor=function(){return xt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(i){return this.cmp(i)>0},it.greaterThanOrEqualTo=it.gte=function(i){var t=this.cmp(i);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var i,t,e,r,n,s=this,a=s.constructor,u=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return u;e=a.precision,r=a.rounding,a.precision=e+Math.max(s.e,s.sd())+4,a.rounding=1,n=s.d.length,n<32?(i=Math.ceil(n/3),t=(1/Ys(4,i)).toString()):(i=16,t="2.3283064365386962890625e-10"),s=xi(a,1,s.times(t),new a(1),!0);for(var c,f=i,d=new a(8);f--;)c=s.times(s),s=u.minus(c.times(d.minus(c.times(d))));return xt(s,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var i,t,e,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<3)n=xi(s,2,n,n,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,n=n.times(1/Ys(5,i)),n=xi(s,2,n,n,!0);for(var a,u=new s(5),c=new s(16),f=new s(20);i--;)a=n.times(n),n=n.times(u.plus(a.times(c.times(a).plus(f))))}return s.precision=t,s.rounding=e,xt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+7,r.rounding=1,_e(e.sinh(),e.cosh(),r.precision=i,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var i,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,s=e.rounding;return r!==-1?r===0?t.isNeg()?Zr(e,n,s):new e(0):new e(NaN):t.isZero()?Zr(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),i=Zr(e,n+4,s).times(.5),e.precision=n,e.rounding=s,i.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var i,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(i=r.precision,t=r.rounding,r.precision=i+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,Ot=!1,e=e.times(e).minus(1).sqrt().plus(e),Ot=!0,r.precision=i,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var i,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,Ot=!1,e=e.times(e).plus(1).sqrt().plus(e),Ot=!0,r.precision=i,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var i,t,e,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(i=s.precision,t=s.rounding,r=n.sd(),Math.max(r,i)<2*-n.e-1?xt(new s(n),i,t,!0):(s.precision=e=r-n.e,n=_e(n.plus(1),new s(1).minus(n),e+i,1),s.precision=i+4,s.rounding=1,n=n.ln(),s.precision=i,s.rounding=t,n.times(.5))):new s(NaN)},it.inverseSine=it.asin=function(){var i,t,e,r,n=this,s=n.constructor;return n.isZero()?new s(n):(t=n.abs().cmp(1),e=s.precision,r=s.rounding,t!==-1?t===0?(i=Zr(s,e+4,r).times(.5),i.s=n.s,i):new s(NaN):(s.precision=e+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var i,t,e,r,n,s,a,u,c,f=this,d=f.constructor,h=d.precision,_=d.rounding;if(f.isFinite()){if(f.isZero())return new d(f);if(f.abs().eq(1)&&h+4<=ka)return a=Zr(d,h+4,_).times(.25),a.s=f.s,a}else{if(!f.s)return new d(NaN);if(h+4<=ka)return a=Zr(d,h+4,_).times(.5),a.s=f.s,a}for(d.precision=u=h+10,d.rounding=1,e=Math.min(28,u/Et+2|0),i=e;i;--i)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(Ot=!1,t=Math.ceil(u/Et),r=1,c=f.times(f),a=new d(f),n=f;i!==-1;)if(n=n.times(c),s=a.minus(n.div(r+=2)),n=n.times(c),a=s.plus(n.div(r+=2)),a.d[t]!==void 0)for(i=t;a.d[i]===s.d[i]&&i--;);return e&&(a=a.times(2<<e-1)),Ot=!0,xt(a,d.precision=h,d.rounding=_,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Qe(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(i){return this.cmp(i)<0},it.lessThanOrEqualTo=it.lte=function(i){return this.cmp(i)<1},it.logarithm=it.log=function(i){var t,e,r,n,s,a,u,c,f=this,d=f.constructor,h=d.precision,_=d.rounding,g=5;if(i==null)i=new d(10),t=!0;else{if(i=new d(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new d(NaN);t=i.eq(10)}if(e=f.d,f.s<0||!e||!e[0]||f.eq(1))return new d(e&&!e[0]?-1/0:f.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)s=!0;else{for(n=e[0];n%10===0;)n/=10;s=n!==1}if(Ot=!1,u=h+g,a=Tn(f,u),r=t?js(d,u+10):Tn(i,u),c=_e(a,r,u,1),rs(c.d,n=h,_))do if(u+=10,a=Tn(f,u),r=t?js(d,u+10):Tn(i,u),c=_e(a,r,u,1),!s){+Ke(c.d).slice(n+1,n+15)+1==1e14&&(c=xt(c,h+1,0));break}while(rs(c.d,n+=10,_));return Ot=!0,xt(c,h,_)},it.minus=it.sub=function(i){var t,e,r,n,s,a,u,c,f,d,h,_,g=this,y=g.constructor;if(i=new y(i),!g.d||!i.d)return!g.s||!i.s?i=new y(NaN):g.d?i.s=-i.s:i=new y(i.d||g.s!==i.s?g:NaN),i;if(g.s!=i.s)return i.s=-i.s,g.plus(i);if(f=g.d,_=i.d,u=y.precision,c=y.rounding,!f[0]||!_[0]){if(_[0])i.s=-i.s;else if(f[0])i=new y(g);else return new y(c===3?-0:0);return Ot?xt(i,u,c):i}if(e=Qe(i.e/Et),d=Qe(g.e/Et),f=f.slice(),s=d-e,s){for(h=s<0,h?(t=f,s=-s,a=_.length):(t=_,e=d,a=f.length),r=Math.max(Math.ceil(u/Et),a)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=f.length,a=_.length,h=r<a,h&&(a=r),r=0;r<a;r++)if(f[r]!=_[r]){h=f[r]<_[r];break}s=0}for(h&&(t=f,f=_,_=t,i.s=-i.s),a=f.length,r=_.length-a;r>0;--r)f[a++]=0;for(r=_.length;r>s;){if(f[--r]<_[r]){for(n=r;n&&f[--n]===0;)f[n]=Hr-1;--f[n],f[r]+=Hr}f[r]-=_[r]}for(;f[--a]===0;)f.pop();for(;f[0]===0;f.shift())--e;return f[0]?(i.d=f,i.e=Ws(f,e),Ot?xt(i,u,c):i):new y(c===3?-0:0)},it.modulo=it.mod=function(i){var t,e=this,r=e.constructor;return i=new r(i),!e.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||e.d&&!e.d[0]?xt(new r(e),r.precision,r.rounding):(Ot=!1,r.modulo==9?(t=_e(e,i.abs(),0,3,1),t.s*=i.s):t=_e(e,i,0,r.modulo,1),t=t.times(i),Ot=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return za(this)},it.naturalLogarithm=it.ln=function(){return Tn(this)},it.negated=it.neg=function(){var i=new this.constructor(this);return i.s=-i.s,xt(i)},it.plus=it.add=function(i){var t,e,r,n,s,a,u,c,f,d,h=this,_=h.constructor;if(i=new _(i),!h.d||!i.d)return!h.s||!i.s?i=new _(NaN):h.d||(i=new _(i.d||h.s===i.s?h:NaN)),i;if(h.s!=i.s)return i.s=-i.s,h.minus(i);if(f=h.d,d=i.d,u=_.precision,c=_.rounding,!f[0]||!d[0])return d[0]||(i=new _(h)),Ot?xt(i,u,c):i;if(s=Qe(h.e/Et),r=Qe(i.e/Et),f=f.slice(),n=s-r,n){for(n<0?(e=f,n=-n,a=d.length):(e=d,r=s,a=f.length),s=Math.ceil(u/Et),a=s>a?s+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=f.length,n=d.length,a-n<0&&(n=a,e=d,d=f,f=e),t=0;n;)t=(f[--n]=f[n]+d[n]+t)/Hr|0,f[n]%=Hr;for(t&&(f.unshift(t),++r),a=f.length;f[--a]==0;)f.pop();return i.d=f,i.e=Ws(f,r),Ot?xt(i,u,c):i},it.precision=it.sd=function(i){var t,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(On+i);return e.d?(t=kc(e.d),i&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var i=this,t=i.constructor;return xt(new t(i),i.e+1,t.rounding)},it.sine=it.sin=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Gp(r,jc(r,e)),r.precision=i,r.rounding=t,xt(hn>2?e.neg():e,i,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var i,t,e,r,n,s,a=this,u=a.d,c=a.e,f=a.s,d=a.constructor;if(f!==1||!u||!u[0])return new d(!f||f<0&&(!u||u[0])?NaN:u?a:1/0);for(Ot=!1,f=Math.sqrt(+a),f==0||f==1/0?(t=Ke(u),(t.length+c)%2==0&&(t+="0"),f=Math.sqrt(t),c=Qe((c+1)/2)-(c<0||c%2),f==1/0?t="5e"+c:(t=f.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new d(t)):r=new d(f.toString()),e=(c=d.precision)+3;;)if(s=r,r=s.plus(_e(a,s,e+2,1)).times(.5),Ke(s.d).slice(0,e)===(t=Ke(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(xt(s,c+1,0),s.times(s).eq(a))){r=s;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(xt(r,c+1,1),i=!r.times(r).eq(a));break}return Ot=!0,xt(r,c,d.rounding,i)},it.tangent=it.tan=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+10,r.rounding=1,e=e.sin(),e.s=1,e=_e(e,new r(1).minus(e.times(e)).sqrt(),i+10,0),r.precision=i,r.rounding=t,xt(hn==2||hn==4?e.neg():e,i,t,!0)):new r(NaN)},it.times=it.mul=function(i){var t,e,r,n,s,a,u,c,f,d=this,h=d.constructor,_=d.d,g=(i=new h(i)).d;if(i.s*=d.s,!_||!_[0]||!g||!g[0])return new h(!i.s||_&&!_[0]&&!g||g&&!g[0]&&!_?NaN:!_||!g?i.s/0:i.s*0);for(e=Qe(d.e/Et)+Qe(i.e/Et),c=_.length,f=g.length,c<f&&(s=_,_=g,g=s,a=c,c=f,f=a),s=[],a=c+f,r=a;r--;)s.push(0);for(r=f;--r>=0;){for(t=0,n=c+r;n>r;)u=s[n]+g[r]*_[n-r-1]+t,s[n--]=u%Hr|0,t=u/Hr|0;s[n]=(s[n]+t)%Hr|0}for(;!s[--a];)s.pop();return t?++e:s.shift(),i.d=s,i.e=Ws(s,e),Ot?xt(i,h.precision,h.rounding):i},it.toBinary=function(i,t){return Ua(this,2,i,t)},it.toDecimalPlaces=it.toDP=function(i,t){var e=this,r=e.constructor;return e=new r(e),i===void 0?e:(cr(i,0,Sn),t===void 0?t=r.rounding:cr(t,0,8),xt(e,i+e.e+1,t))},it.toExponential=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,!0):(cr(i,0,Sn),t===void 0?t=n.rounding:cr(t,0,8),r=xt(new n(r),i+1,t),e=rn(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(i,t){var e,r,n=this,s=n.constructor;return i===void 0?e=rn(n):(cr(i,0,Sn),t===void 0?t=s.rounding:cr(t,0,8),r=xt(new s(n),i+n.e+1,t),e=rn(r,!1,i+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(i){var t,e,r,n,s,a,u,c,f,d,h,_,g=this,y=g.d,p=g.constructor;if(!y)return new p(g);if(f=e=new p(1),r=c=new p(0),t=new p(r),s=t.e=kc(y)-g.e-1,a=s%Et,t.d[0]=ke(10,a<0?Et+a:a),i==null)i=s>0?t:f;else{if(u=new p(i),!u.isInt()||u.lt(f))throw Error(On+u);i=u.gt(t)?s>0?t:f:u}for(Ot=!1,u=new p(Ke(y)),d=p.precision,p.precision=s=y.length*Et*2;h=_e(u,t,0,1,1),n=e.plus(h.times(r)),n.cmp(i)!=1;)e=r,r=n,n=f,f=c.plus(h.times(n)),c=n,n=t,t=u.minus(h.times(n)),u=n;return n=_e(i.minus(e),r,0,1,1),c=c.plus(n.times(f)),e=e.plus(n.times(r)),c.s=f.s=g.s,_=_e(f,r,s,1).minus(g).abs().cmp(_e(c,e,s,1).minus(g).abs())<1?[f,r]:[c,e],p.precision=d,Ot=!0,_},it.toHexadecimal=it.toHex=function(i,t){return Ua(this,16,i,t)},it.toNearest=function(i,t){var e=this,r=e.constructor;if(e=new r(e),i==null){if(!e.d)return e;i=new r(1),t=r.rounding}else{if(i=new r(i),t===void 0?t=r.rounding:cr(t,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(Ot=!1,e=_e(e,i,0,t,1).times(i),Ot=!0,xt(e)):(i.s=e.s,e=i),e},it.toNumber=function(){return+this},it.toOctal=function(i,t){return Ua(this,8,i,t)},it.toPower=it.pow=function(i){var t,e,r,n,s,a,u=this,c=u.constructor,f=+(i=new c(i));if(!u.d||!i.d||!u.d[0]||!i.d[0])return new c(ke(+u,f));if(u=new c(u),u.eq(1))return u;if(r=c.precision,s=c.rounding,i.eq(1))return xt(u,r,s);if(t=Qe(i.e/Et),t>=i.d.length-1&&(e=f<0?-f:f)<=Vp)return n=zc(c,u,e,r),i.s<0?new c(1).div(n):xt(n,r,s);if(a=u.s,a<0){if(t<i.d.length-1)return new c(NaN);if(i.d[t]&1||(a=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=a,u}return e=ke(+u,f),t=e==0||!isFinite(e)?Qe(f*(Math.log("0."+Ke(u.d))/Math.LN10+u.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(Ot=!1,c.rounding=u.s=1,e=Math.min(12,(t+"").length),n=za(i.times(Tn(u,r+e)),r),n.d&&(n=xt(n,r+5,1),rs(n.d,r,s)&&(t=r+10,n=xt(za(i.times(Tn(u,t+e)),t),t+5,1),+Ke(n.d).slice(r+1,r+15)+1==1e14&&(n=xt(n,r+1,0)))),n.s=a,Ot=!0,c.rounding=s,xt(n,r,s))},it.toPrecision=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(cr(i,1,Sn),t===void 0?t=n.rounding:cr(t,0,8),r=xt(new n(r),i,t),e=rn(r,i<=r.e||r.e<=n.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(i,t){var e=this,r=e.constructor;return i===void 0?(i=r.precision,t=r.rounding):(cr(i,1,Sn),t===void 0?t=r.rounding:cr(t,0,8)),xt(new r(e),i,t)},it.toString=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return xt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()?"-"+e:e};function Ke(i){var t,e,r,n=i.length-1,s="",a=i[0];if(n>0){for(s+=a,t=1;t<n;t++)r=i[t]+"",e=Et-r.length,e&&(s+=Bn(e)),s+=r;a=i[t],r=a+"",e=Et-r.length,e&&(s+=Bn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}function cr(i,t,e){if(i!==~~i||i<t||i>e)throw Error(On+i)}function rs(i,t,e,r){var n,s,a,u;for(s=i[0];s>=10;s/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),s=ke(10,Et-t),u=i[n]%s|0,r==null?t<3?(t==0?u=u/100|0:t==1&&(u=u/10|0),a=e<4&&u==99999||e>3&&u==49999||u==5e4||u==0):a=(e<4&&u+1==s||e>3&&u+1==s/2)&&(i[n+1]/s/100|0)==ke(10,t-2)-1||(u==s/2||u==0)&&(i[n+1]/s/100|0)==0:t<4?(t==0?u=u/1e3|0:t==1?u=u/100|0:t==2&&(u=u/10|0),a=(r||e<4)&&u==9999||!r&&e>3&&u==4999):a=((r||e<4)&&u+1==s||!r&&e>3&&u+1==s/2)&&(i[n+1]/s/1e3|0)==ke(10,t-3)-1,a}function Us(i,t,e){for(var r,n=[0],s,a=0,u=i.length;a<u;){for(s=n.length;s--;)n[s]*=t;for(n[0]+=Ra.indexOf(i.charAt(a++)),r=0;r<n.length;r++)n[r]>e-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/e|0,n[r]%=e)}return n.reverse()}function Zp(i,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ys(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i.precision+=e,t=xi(i,1,t.times(n),new i(1));for(var s=e;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return i.precision-=e,t}var _e=function(){function i(r,n,s){var a,u=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+u,r[c]=a%s|0,u=a/s|0;return u&&r.unshift(u),r}function t(r,n,s,a){var u,c;if(s!=a)c=s>a?1:-1;else for(u=c=0;u<s;u++)if(r[u]!=n[u]){c=r[u]>n[u]?1:-1;break}return c}function e(r,n,s,a){for(var u=0;s--;)r[s]-=u,u=r[s]<n[s]?1:0,r[s]=u*a+r[s]-n[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,s,a,u,c){var f,d,h,_,g,y,p,w,v,x,b,C,E,A,N,S,I,F,O,L,z=r.constructor,q=r.s==n.s?1:-1,W=r.d,P=n.d;if(!W||!W[0]||!P||!P[0])return new z(!r.s||!n.s||(W?P&&W[0]==P[0]:!P)?NaN:W&&W[0]==0||!P?q*0:q/0);for(c?(g=1,d=r.e-n.e):(c=Hr,g=Et,d=Qe(r.e/g)-Qe(n.e/g)),O=P.length,I=W.length,v=new z(q),x=v.d=[],h=0;P[h]==(W[h]||0);h++);if(P[h]>(W[h]||0)&&d--,s==null?(A=s=z.precision,a=z.rounding):u?A=s+(r.e-n.e)+1:A=s,A<0)x.push(1),y=!0;else{if(A=A/g+2|0,h=0,O==1){for(_=0,P=P[0],A++;(h<I||_)&&A--;h++)N=_*c+(W[h]||0),x[h]=N/P|0,_=N%P|0;y=_||h<I}else{for(_=c/(P[0]+1)|0,_>1&&(P=i(P,_,c),W=i(W,_,c),O=P.length,I=W.length),S=O,b=W.slice(0,O),C=b.length;C<O;)b[C++]=0;L=P.slice(),L.unshift(0),F=P[0],P[1]>=c/2&&++F;do _=0,f=t(P,b,O,C),f<0?(E=b[0],O!=C&&(E=E*c+(b[1]||0)),_=E/F|0,_>1?(_>=c&&(_=c-1),p=i(P,_,c),w=p.length,C=b.length,f=t(p,b,w,C),f==1&&(_--,e(p,O<w?L:P,w,c))):(_==0&&(f=_=1),p=P.slice()),w=p.length,w<C&&p.unshift(0),e(b,p,C,c),f==-1&&(C=b.length,f=t(P,b,O,C),f<1&&(_++,e(b,O<C?L:P,C,c))),C=b.length):f===0&&(_++,b=[0]),x[h++]=_,f&&b[0]?b[C++]=W[S]||0:(b=[W[S]],C=1);while((S++<I||b[0]!==void 0)&&A--);y=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=d,Ic=y;else{for(h=1,_=x[0];_>=10;_/=10)h++;v.e=h+d*g-1,xt(v,u?s+v.e+1:s,a,y)}return v}}();function xt(i,t,e,r){var n,s,a,u,c,f,d,h,_,g=i.constructor;t:if(t!=null){if(h=i.d,!h)return i;for(n=1,u=h[0];u>=10;u/=10)n++;if(s=t-n,s<0)s+=Et,a=t,d=h[_=0],c=d/ke(10,n-a-1)%10|0;else if(_=Math.ceil((s+1)/Et),u=h.length,_>=u)if(r){for(;u++<=_;)h.push(0);d=c=0,n=1,s%=Et,a=s-Et+1}else break t;else{for(d=u=h[_],n=1;u>=10;u/=10)n++;s%=Et,a=s-Et+n,c=a<0?0:d/ke(10,n-a-1)%10|0}if(r=r||t<0||h[_+1]!==void 0||(a<0?d:d%ke(10,n-a-1)),f=e<4?(c||r)&&(e==0||e==(i.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(s>0?a>0?d/ke(10,n-a):0:h[_-1])%10&1||e==(i.s<0?8:7)),t<1||!h[0])return h.length=0,f?(t-=i.e+1,h[0]=ke(10,(Et-t%Et)%Et),i.e=-t||0):h[0]=i.e=0,i;if(s==0?(h.length=_,u=1,_--):(h.length=_+1,u=ke(10,Et-s),h[_]=a>0?(d/ke(10,n-a)%ke(10,a)|0)*u:0),f)for(;;)if(_==0){for(s=1,a=h[0];a>=10;a/=10)s++;for(a=h[0]+=u,u=1;a>=10;a/=10)u++;s!=u&&(i.e++,h[0]==Hr&&(h[0]=1));break}else{if(h[_]+=u,h[_]!=Hr)break;h[_--]=0,u=1}for(s=h.length;h[--s]===0;)h.pop()}return Ot&&(i.e>g.maxE?(i.d=null,i.e=NaN):i.e<g.minE&&(i.e=0,i.d=[0])),i}function rn(i,t,e){if(!i.isFinite())return Wc(i);var r,n=i.e,s=Ke(i.d),a=s.length;return t?(e&&(r=e-a)>0?s=s.charAt(0)+"."+s.slice(1)+Bn(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i.e<0?"e":"e+")+i.e):n<0?(s="0."+Bn(-n-1)+s,e&&(r=e-a)>0&&(s+=Bn(r))):n>=a?(s+=Bn(n+1-a),e&&(r=e-n-1)>0&&(s=s+"."+Bn(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(s+="."),s+=Bn(r))),s}function Ws(i,t){var e=i[0];for(t*=Et;e>=10;e/=10)t++;return t}function js(i,t,e){if(t>Hp)throw Ot=!0,e&&(i.precision=e),Error($c);return xt(new i(ks),t,1,!0)}function Zr(i,t,e){if(t>ka)throw Error($c);return xt(new i(zs),t,e,!0)}function kc(i){var t=i.length-1,e=t*Et+1;if(t=i[t],t){for(;t%10==0;t/=10)e--;for(t=i[0];t>=10;t/=10)e++}return e}function Bn(i){for(var t="";i--;)t+="0";return t}function zc(i,t,e,r){var n,s=new i(1),a=Math.ceil(r/Et+4);for(Ot=!1;;){if(e%2&&(s=s.times(t),Yc(s.d,a)&&(n=!0)),e=Qe(e/2),e===0){e=s.d.length-1,n&&s.d[e]===0&&++s.d[e];break}t=t.times(t),Yc(t.d,a)}return Ot=!0,s}function qc(i){return i.d[i.d.length-1]&1}function Uc(i,t,e){for(var r,n=new i(t[0]),s=0;++s<t.length;)if(r=new i(t[s]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function za(i,t){var e,r,n,s,a,u,c,f=0,d=0,h=0,_=i.constructor,g=_.rounding,y=_.precision;if(!i.d||!i.d[0]||i.e>17)return new _(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(t==null?(Ot=!1,c=y):c=t,u=new _(.03125);i.e>-2;)i=i.times(u),h+=5;for(r=Math.log(ke(2,h))/Math.LN10*2+5|0,c+=r,e=s=a=new _(1),_.precision=c;;){if(s=xt(s.times(i),c,1),e=e.times(++d),u=a.plus(_e(s,e,c,1)),Ke(u.d).slice(0,c)===Ke(a.d).slice(0,c)){for(n=h;n--;)a=xt(a.times(a),c,1);if(t==null)if(f<3&&rs(a.d,c-r,g,f))_.precision=c+=10,e=s=u=new _(1),d=0,f++;else return xt(a,_.precision=y,g,Ot=!0);else return _.precision=y,a}a=u}}function Tn(i,t){var e,r,n,s,a,u,c,f,d,h,_,g=1,y=10,p=i,w=p.d,v=p.constructor,x=v.rounding,b=v.precision;if(p.s<0||!w||!w[0]||!p.e&&w[0]==1&&w.length==1)return new v(w&&!w[0]?-1/0:p.s!=1?NaN:w?0:p);if(t==null?(Ot=!1,d=b):d=t,v.precision=d+=y,e=Ke(w),r=e.charAt(0),Math.abs(s=p.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)p=p.times(i),e=Ke(p.d),r=e.charAt(0),g++;s=p.e,r>1?(p=new v("0."+e),s++):p=new v(r+"."+e.slice(1))}else return f=js(v,d+2,b).times(s+""),p=Tn(new v(r+"."+e.slice(1)),d-y).plus(f),v.precision=b,t==null?xt(p,b,x,Ot=!0):p;for(h=p,c=a=p=_e(p.minus(1),p.plus(1),d,1),_=xt(p.times(p),d,1),n=3;;){if(a=xt(a.times(_),d,1),f=c.plus(_e(a,new v(n),d,1)),Ke(f.d).slice(0,d)===Ke(c.d).slice(0,d))if(c=c.times(2),s!==0&&(c=c.plus(js(v,d+2,b).times(s+""))),c=_e(c,new v(g),d,1),t==null)if(rs(c.d,d-y,x,u))v.precision=d+=y,f=a=p=_e(h.minus(1),h.plus(1),d,1),_=xt(p.times(p),d,1),n=u=1;else return xt(c,v.precision=b,x,Ot=!0);else return v.precision=b,c;c=f,n+=2}}function Wc(i){return String(i.s*i.s/0)}function qa(i,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,i.e=e=e-r-1,i.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&i.d.push(+t.slice(0,r)),n-=Et;r<n;)i.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";i.d.push(+t),Ot&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function Kp(i,t){var e,r,n,s,a,u,c,f,d;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Pc.test(t))return qa(i,t)}else if(t==="Infinity"||t==="NaN")return+t||(i.s=NaN),i.e=NaN,i.d=null,i;if(jp.test(t))e=16,t=t.toLowerCase();else if(Wp.test(t))e=2;else if(Yp.test(t))e=8;else throw Error(On+t);for(s=t.search(/p/i),s>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),a=s>=0,r=i.constructor,a&&(t=t.replace(".",""),u=t.length,s=u-s,n=zc(r,new r(e),s,s*2)),f=Us(t,e,Hr),d=f.length-1,s=d;f[s]===0;--s)f.pop();return s<0?new r(i.s*0):(i.e=Ws(f,d),i.d=f,Ot=!1,a&&(i=_e(i,n,u*4)),c&&(i=i.times(Math.abs(c)<54?ke(2,c):Ei.pow(2,c))),Ot=!0,i)}function Gp(i,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:xi(i,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ys(5,e)),t=xi(i,2,t,t);for(var n,s=new i(5),a=new i(16),u=new i(20);e--;)n=t.times(t),t=t.times(s.plus(n.times(a.times(n).minus(u))));return t}function xi(i,t,e,r,n){var s,a,u,c,f=i.precision,d=Math.ceil(f/Et);for(Ot=!1,c=e.times(e),u=new i(r);;){if(a=_e(u.times(c),new i(t++*t++),f,1),u=n?r.plus(a):r.minus(a),r=_e(a.times(c),new i(t++*t++),f,1),a=u.plus(r),a.d[d]!==void 0){for(s=d;a.d[s]===u.d[s]&&s--;);if(s==-1)break}s=u,u=r,r=a,a=s}return Ot=!0,a.d.length=d+1,a}function Ys(i,t){for(var e=i;--t;)e*=i;return e}function jc(i,t){var e,r=t.s<0,n=Zr(i,i.precision,1),s=n.times(.5);if(t=t.abs(),t.lte(s))return hn=r?4:1,t;if(e=t.divToInt(n),e.isZero())hn=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(s))return hn=qc(e)?r?2:3:r?4:1,t;hn=qc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Ua(i,t,e,r){var n,s,a,u,c,f,d,h,_,g=i.constructor,y=e!==void 0;if(y?(cr(e,1,Sn),r===void 0?r=g.rounding:cr(r,0,8)):(e=g.precision,r=g.rounding),!i.isFinite())d=Wc(i);else{for(d=rn(i),a=d.indexOf("."),y?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(d=d.replace(".",""),_=new g(1),_.e=d.length-a,_.d=Us(rn(_),10,n),_.e=_.d.length),h=Us(d,10,n),s=c=h.length;h[--c]==0;)h.pop();if(!h[0])d=y?"0p+0":"0";else{if(a<0?s--:(i=new g(i),i.d=h,i.e=s,i=_e(i,_,e,r,0,n),h=i.d,s=i.e,f=Ic),a=h[e],u=n/2,f=f||h[e+1]!==void 0,f=r<4?(a!==void 0||f)&&(r===0||r===(i.s<0?3:2)):a>u||a===u&&(r===4||f||r===6&&h[e-1]&1||r===(i.s<0?8:7)),h.length=e,f)for(;++h[--e]>n-1;)h[e]=0,e||(++s,h.unshift(1));for(c=h.length;!h[c-1];--c);for(a=0,d="";a<c;a++)d+=Ra.charAt(h[a]);if(y){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)d+="0";for(h=Us(d,n,t),c=h.length;!h[c-1];--c);for(a=1,d="1.";a<c;a++)d+=Ra.charAt(h[a])}else d=d.charAt(0)+"."+d.slice(1);d=d+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)d="0"+d;d="0."+d}else if(++s>c)for(s-=c;s--;)d+="0";else s<c&&(d=d.slice(0,s)+"."+d.slice(s))}d=(t==16?"0x":t==2?"0b":t==8?"0o":"")+d}return i.s<0?"-"+d:d}function Yc(i,t){if(i.length>t)return i.length=t,!0}function Jp(i){return new this(i).abs()}function Xp(i){return new this(i).acos()}function Qp(i){return new this(i).acosh()}function tm(i,t){return new this(i).plus(t)}function em(i){return new this(i).asin()}function rm(i){return new this(i).asinh()}function nm(i){return new this(i).atan()}function im(i){return new this(i).atanh()}function sm(i,t){i=new this(i),t=new this(t);var e,r=this.precision,n=this.rounding,s=r+4;return!i.s||!t.s?e=new this(NaN):!i.d&&!t.d?(e=Zr(this,s,1).times(t.s>0?.25:.75),e.s=i.s):!t.d||i.isZero()?(e=t.s<0?Zr(this,r,n):new this(0),e.s=i.s):!i.d||t.isZero()?(e=Zr(this,s,1).times(.5),e.s=i.s):t.s<0?(this.precision=s,this.rounding=1,e=this.atan(_e(i,t,s,1)),t=Zr(this,s,1),this.precision=r,this.rounding=n,e=i.s<0?e.minus(t):e.plus(t)):e=this.atan(_e(i,t,s,1)),e}function om(i){return new this(i).cbrt()}function am(i){return xt(i=new this(i),i.e+1,2)}function um(i,t,e){return new this(i).clamp(t,e)}function lm(i){if(!i||typeof i!="object")throw Error(qs+"Object expected");var t,e,r,n=i.defaults===!0,s=["precision",1,Sn,"rounding",0,8,"toExpNeg",-bi,0,"toExpPos",0,bi,"maxE",0,bi,"minE",-bi,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],n&&(this[e]=Pa[e]),(r=i[e])!==void 0)if(Qe(r)===r&&r>=s[t+1]&&r<=s[t+2])this[e]=r;else throw Error(On+e+": "+r);if(e="crypto",n&&(this[e]=Pa[e]),(r=i[e])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(Lc);else this[e]=!1;else throw Error(On+e+": "+r);return this}function cm(i){return new this(i).cos()}function fm(i){return new this(i).cosh()}function Vc(i){var t,e,r;function n(s){var a,u,c,f=this;if(!(f instanceof n))return new n(s);if(f.constructor=n,Hc(s)){f.s=s.s,Ot?!s.d||s.e>n.maxE?(f.e=NaN,f.d=null):s.e<n.minE?(f.e=0,f.d=[0]):(f.e=s.e,f.d=s.d.slice()):(f.e=s.e,f.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){f.s=1/s<0?-1:1,f.e=0,f.d=[0];return}if(s<0?(s=-s,f.s=-1):f.s=1,s===~~s&&s<1e7){for(a=0,u=s;u>=10;u/=10)a++;Ot?a>n.maxE?(f.e=NaN,f.d=null):a<n.minE?(f.e=0,f.d=[0]):(f.e=a,f.d=[s]):(f.e=a,f.d=[s]);return}else if(s*0!==0){s||(f.s=NaN),f.e=NaN,f.d=null;return}return qa(f,s.toString())}else if(c!=="string")throw Error(On+s);return(u=s.charCodeAt(0))===45?(s=s.slice(1),f.s=-1):(u===43&&(s=s.slice(1)),f.s=1),Pc.test(s)?qa(f,s):Kp(f,s)}if(n.prototype=it,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=lm,n.clone=Vc,n.isDecimal=Hc,n.abs=Jp,n.acos=Xp,n.acosh=Qp,n.add=tm,n.asin=em,n.asinh=rm,n.atan=nm,n.atanh=im,n.atan2=sm,n.cbrt=om,n.ceil=am,n.clamp=um,n.cos=cm,n.cosh=fm,n.div=hm,n.exp=dm,n.floor=_m,n.hypot=pm,n.ln=mm,n.log=gm,n.log10=ym,n.log2=vm,n.max=wm,n.min=Dm,n.mod=bm,n.mul=xm,n.pow=Em,n.random=Cm,n.round=Am,n.sign=Mm,n.sin=Fm,n.sinh=Nm,n.sqrt=Sm,n.sub=Om,n.sum=Bm,n.tan=Tm,n.tanh=Im,n.trunc=$m,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)i.hasOwnProperty(e=r[t++])||(i[e]=this[e]);return n.config(i),n}function hm(i,t){return new this(i).div(t)}function dm(i){return new this(i).exp()}function _m(i){return xt(i=new this(i),i.e+1,3)}function pm(){var i,t,e=new this(0);for(Ot=!1,i=0;i<arguments.length;)if(t=new this(arguments[i++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return Ot=!0,new this(1/0);e=t}return Ot=!0,e.sqrt()}function Hc(i){return i instanceof Ei||i&&i.toStringTag===Rc||!1}function mm(i){return new this(i).ln()}function gm(i,t){return new this(i).log(t)}function vm(i){return new this(i).log(2)}function ym(i){return new this(i).log(10)}function wm(){return Uc(this,arguments,"lt")}function Dm(){return Uc(this,arguments,"gt")}function bm(i,t){return new this(i).mod(t)}function xm(i,t){return new this(i).mul(t)}function Em(i,t){return new this(i).pow(t)}function Cm(i){var t,e,r,n,s=0,a=new this(1),u=[];if(i===void 0?i=this.precision:cr(i,1,Sn),r=Math.ceil(i/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)n=t[s],n>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)n=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,s):(u.push(n%1e7),s+=4);s=r/4}else throw Error(Lc);else for(;s<r;)u[s++]=Math.random()*1e7|0;for(r=u[--s],i%=Et,r&&i&&(n=ke(10,Et-i),u[s]=(r/n|0)*n);u[s]===0;s--)u.pop();if(s<0)e=0,u=[0];else{for(e=-1;u[0]===0;e-=Et)u.shift();for(r=1,n=u[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=u,a}function Am(i){return xt(i=new this(i),i.e+1,this.rounding)}function Mm(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Fm(i){return new this(i).sin()}function Nm(i){return new this(i).sinh()}function Sm(i){return new this(i).sqrt()}function Om(i,t){return new this(i).sub(t)}function Bm(){var i=0,t=arguments,e=new this(t[i]);for(Ot=!1;e.s&&++i<t.length;)e=e.plus(t[i]);return Ot=!0,xt(e,this.precision,this.rounding)}function Tm(i){return new this(i).tan()}function Im(i){return new this(i).tanh()}function $m(i){return xt(i=new this(i),i.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var Ei=it.constructor=Vc(Pa);ks=new Ei(ks),zs=new Ei(zs);var Lm="BigNumber",Rm=["?on","config"],Pm=gt(Lm,Rm,i=>{var{on:t,config:e}=i,r=Ei.clone({precision:e.precision,modulo:Ei.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},t&&t("config",function(n,s){n.precision!==s.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),Zc={exports:{}};/**
|
40
|
+
*/var bi=9e15,Sn=1e9,Ra="0123456789abcdef",ks="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",zs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Pa={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-bi,maxE:bi,crypto:!1},Ic,hn,Ot=!0,qs="[DecimalError] ",On=qs+"Invalid argument: ",$c=qs+"Precision limit exceeded",Lc=qs+"crypto unavailable",Rc="[object Decimal]",Qe=Math.floor,ke=Math.pow,Wp=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,jp=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Yp=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Pc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Hr=1e7,Et=7,Vp=9007199254740991,Hp=ks.length-1,ka=zs.length-1,it={toStringTag:Rc};it.absoluteValue=it.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),xt(i)},it.ceil=function(){return xt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(i,t){var e,r=this,n=r.constructor;if(i=new n(i),t=new n(t),!i.s||!t.s)return new n(NaN);if(i.gt(t))throw Error(On+t);return e=r.cmp(i),e<0?i:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(i){var t,e,r,n,s=this,a=s.d,u=(i=new s.constructor(i)).d,c=s.s,f=i.s;if(!a||!u)return!c||!f?NaN:c!==f?c:a===u?0:!a^c<0?1:-1;if(!a[0]||!u[0])return a[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==i.e)return s.e>i.e^c<0?1:-1;for(r=a.length,n=u.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==u[t])return a[t]>u[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var i,t,e=this,r=e.constructor;return e.d?e.d[0]?(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Zp(r,jc(r,e)),r.precision=i,r.rounding=t,xt(hn==2||hn==3?e.neg():e,i,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var i,t,e,r,n,s,a,u,c,f,d=this,h=d.constructor;if(!d.isFinite()||d.isZero())return new h(d);for(Ot=!1,s=d.s*ke(d.s*d,1/3),!s||Math.abs(s)==1/0?(e=Ke(d.d),i=d.e,(s=(i-e.length+1)%3)&&(e+=s==1||s==-2?"0":"00"),s=ke(e,1/3),i=Qe((i+1)/3)-(i%3==(i<0?-1:2)),s==1/0?e="5e"+i:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),r=new h(e),r.s=d.s):r=new h(s.toString()),a=(i=h.precision)+3;;)if(u=r,c=u.times(u).times(u),f=c.plus(d),r=_e(f.plus(d).times(u),f.plus(c),a+2,1),Ke(u.d).slice(0,a)===(e=Ke(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(xt(u,i+1,0),u.times(u).times(u).eq(d))){r=u;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(xt(r,i+1,1),t=!r.times(r).times(r).eq(d));break}return Ot=!0,xt(r,i,h.rounding,t)},it.decimalPlaces=it.dp=function(){var i,t=this.d,e=NaN;if(t){if(i=t.length-1,e=(i-Qe(this.e/Et))*Et,i=t[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(i){return _e(this,new this.constructor(i))},it.dividedToIntegerBy=it.divToInt=function(i){var t=this,e=t.constructor;return xt(_e(t,new e(i),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(i){return this.cmp(i)===0},it.floor=function(){return xt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(i){return this.cmp(i)>0},it.greaterThanOrEqualTo=it.gte=function(i){var t=this.cmp(i);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var i,t,e,r,n,s=this,a=s.constructor,u=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return u;e=a.precision,r=a.rounding,a.precision=e+Math.max(s.e,s.sd())+4,a.rounding=1,n=s.d.length,n<32?(i=Math.ceil(n/3),t=(1/Ys(4,i)).toString()):(i=16,t="2.3283064365386962890625e-10"),s=xi(a,1,s.times(t),new a(1),!0);for(var c,f=i,d=new a(8);f--;)c=s.times(s),s=u.minus(c.times(d.minus(c.times(d))));return xt(s,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var i,t,e,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<3)n=xi(s,2,n,n,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,n=n.times(1/Ys(5,i)),n=xi(s,2,n,n,!0);for(var a,u=new s(5),c=new s(16),f=new s(20);i--;)a=n.times(n),n=n.times(u.plus(a.times(c.times(a).plus(f))))}return s.precision=t,s.rounding=e,xt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+7,r.rounding=1,_e(e.sinh(),e.cosh(),r.precision=i,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var i,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,s=e.rounding;return r!==-1?r===0?t.isNeg()?Zr(e,n,s):new e(0):new e(NaN):t.isZero()?Zr(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),i=Zr(e,n+4,s).times(.5),e.precision=n,e.rounding=s,i.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var i,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(i=r.precision,t=r.rounding,r.precision=i+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,Ot=!1,e=e.times(e).minus(1).sqrt().plus(e),Ot=!0,r.precision=i,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var i,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,Ot=!1,e=e.times(e).plus(1).sqrt().plus(e),Ot=!0,r.precision=i,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var i,t,e,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(i=s.precision,t=s.rounding,r=n.sd(),Math.max(r,i)<2*-n.e-1?xt(new s(n),i,t,!0):(s.precision=e=r-n.e,n=_e(n.plus(1),new s(1).minus(n),e+i,1),s.precision=i+4,s.rounding=1,n=n.ln(),s.precision=i,s.rounding=t,n.times(.5))):new s(NaN)},it.inverseSine=it.asin=function(){var i,t,e,r,n=this,s=n.constructor;return n.isZero()?new s(n):(t=n.abs().cmp(1),e=s.precision,r=s.rounding,t!==-1?t===0?(i=Zr(s,e+4,r).times(.5),i.s=n.s,i):new s(NaN):(s.precision=e+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var i,t,e,r,n,s,a,u,c,f=this,d=f.constructor,h=d.precision,_=d.rounding;if(f.isFinite()){if(f.isZero())return new d(f);if(f.abs().eq(1)&&h+4<=ka)return a=Zr(d,h+4,_).times(.25),a.s=f.s,a}else{if(!f.s)return new d(NaN);if(h+4<=ka)return a=Zr(d,h+4,_).times(.5),a.s=f.s,a}for(d.precision=u=h+10,d.rounding=1,e=Math.min(28,u/Et+2|0),i=e;i;--i)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(Ot=!1,t=Math.ceil(u/Et),r=1,c=f.times(f),a=new d(f),n=f;i!==-1;)if(n=n.times(c),s=a.minus(n.div(r+=2)),n=n.times(c),a=s.plus(n.div(r+=2)),a.d[t]!==void 0)for(i=t;a.d[i]===s.d[i]&&i--;);return e&&(a=a.times(2<<e-1)),Ot=!0,xt(a,d.precision=h,d.rounding=_,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Qe(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(i){return this.cmp(i)<0},it.lessThanOrEqualTo=it.lte=function(i){return this.cmp(i)<1},it.logarithm=it.log=function(i){var t,e,r,n,s,a,u,c,f=this,d=f.constructor,h=d.precision,_=d.rounding,g=5;if(i==null)i=new d(10),t=!0;else{if(i=new d(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new d(NaN);t=i.eq(10)}if(e=f.d,f.s<0||!e||!e[0]||f.eq(1))return new d(e&&!e[0]?-1/0:f.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)s=!0;else{for(n=e[0];n%10===0;)n/=10;s=n!==1}if(Ot=!1,u=h+g,a=Tn(f,u),r=t?js(d,u+10):Tn(i,u),c=_e(a,r,u,1),rs(c.d,n=h,_))do if(u+=10,a=Tn(f,u),r=t?js(d,u+10):Tn(i,u),c=_e(a,r,u,1),!s){+Ke(c.d).slice(n+1,n+15)+1==1e14&&(c=xt(c,h+1,0));break}while(rs(c.d,n+=10,_));return Ot=!0,xt(c,h,_)},it.minus=it.sub=function(i){var t,e,r,n,s,a,u,c,f,d,h,_,g=this,y=g.constructor;if(i=new y(i),!g.d||!i.d)return!g.s||!i.s?i=new y(NaN):g.d?i.s=-i.s:i=new y(i.d||g.s!==i.s?g:NaN),i;if(g.s!=i.s)return i.s=-i.s,g.plus(i);if(f=g.d,_=i.d,u=y.precision,c=y.rounding,!f[0]||!_[0]){if(_[0])i.s=-i.s;else if(f[0])i=new y(g);else return new y(c===3?-0:0);return Ot?xt(i,u,c):i}if(e=Qe(i.e/Et),d=Qe(g.e/Et),f=f.slice(),s=d-e,s){for(h=s<0,h?(t=f,s=-s,a=_.length):(t=_,e=d,a=f.length),r=Math.max(Math.ceil(u/Et),a)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=f.length,a=_.length,h=r<a,h&&(a=r),r=0;r<a;r++)if(f[r]!=_[r]){h=f[r]<_[r];break}s=0}for(h&&(t=f,f=_,_=t,i.s=-i.s),a=f.length,r=_.length-a;r>0;--r)f[a++]=0;for(r=_.length;r>s;){if(f[--r]<_[r]){for(n=r;n&&f[--n]===0;)f[n]=Hr-1;--f[n],f[r]+=Hr}f[r]-=_[r]}for(;f[--a]===0;)f.pop();for(;f[0]===0;f.shift())--e;return f[0]?(i.d=f,i.e=Ws(f,e),Ot?xt(i,u,c):i):new y(c===3?-0:0)},it.modulo=it.mod=function(i){var t,e=this,r=e.constructor;return i=new r(i),!e.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||e.d&&!e.d[0]?xt(new r(e),r.precision,r.rounding):(Ot=!1,r.modulo==9?(t=_e(e,i.abs(),0,3,1),t.s*=i.s):t=_e(e,i,0,r.modulo,1),t=t.times(i),Ot=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return za(this)},it.naturalLogarithm=it.ln=function(){return Tn(this)},it.negated=it.neg=function(){var i=new this.constructor(this);return i.s=-i.s,xt(i)},it.plus=it.add=function(i){var t,e,r,n,s,a,u,c,f,d,h=this,_=h.constructor;if(i=new _(i),!h.d||!i.d)return!h.s||!i.s?i=new _(NaN):h.d||(i=new _(i.d||h.s===i.s?h:NaN)),i;if(h.s!=i.s)return i.s=-i.s,h.minus(i);if(f=h.d,d=i.d,u=_.precision,c=_.rounding,!f[0]||!d[0])return d[0]||(i=new _(h)),Ot?xt(i,u,c):i;if(s=Qe(h.e/Et),r=Qe(i.e/Et),f=f.slice(),n=s-r,n){for(n<0?(e=f,n=-n,a=d.length):(e=d,r=s,a=f.length),s=Math.ceil(u/Et),a=s>a?s+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=f.length,n=d.length,a-n<0&&(n=a,e=d,d=f,f=e),t=0;n;)t=(f[--n]=f[n]+d[n]+t)/Hr|0,f[n]%=Hr;for(t&&(f.unshift(t),++r),a=f.length;f[--a]==0;)f.pop();return i.d=f,i.e=Ws(f,r),Ot?xt(i,u,c):i},it.precision=it.sd=function(i){var t,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(On+i);return e.d?(t=kc(e.d),i&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var i=this,t=i.constructor;return xt(new t(i),i.e+1,t.rounding)},it.sine=it.sin=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Gp(r,jc(r,e)),r.precision=i,r.rounding=t,xt(hn>2?e.neg():e,i,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var i,t,e,r,n,s,a=this,u=a.d,c=a.e,f=a.s,d=a.constructor;if(f!==1||!u||!u[0])return new d(!f||f<0&&(!u||u[0])?NaN:u?a:1/0);for(Ot=!1,f=Math.sqrt(+a),f==0||f==1/0?(t=Ke(u),(t.length+c)%2==0&&(t+="0"),f=Math.sqrt(t),c=Qe((c+1)/2)-(c<0||c%2),f==1/0?t="5e"+c:(t=f.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new d(t)):r=new d(f.toString()),e=(c=d.precision)+3;;)if(s=r,r=s.plus(_e(a,s,e+2,1)).times(.5),Ke(s.d).slice(0,e)===(t=Ke(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(xt(s,c+1,0),s.times(s).eq(a))){r=s;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(xt(r,c+1,1),i=!r.times(r).eq(a));break}return Ot=!0,xt(r,c,d.rounding,i)},it.tangent=it.tan=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+10,r.rounding=1,e=e.sin(),e.s=1,e=_e(e,new r(1).minus(e.times(e)).sqrt(),i+10,0),r.precision=i,r.rounding=t,xt(hn==2||hn==4?e.neg():e,i,t,!0)):new r(NaN)},it.times=it.mul=function(i){var t,e,r,n,s,a,u,c,f,d=this,h=d.constructor,_=d.d,g=(i=new h(i)).d;if(i.s*=d.s,!_||!_[0]||!g||!g[0])return new h(!i.s||_&&!_[0]&&!g||g&&!g[0]&&!_?NaN:!_||!g?i.s/0:i.s*0);for(e=Qe(d.e/Et)+Qe(i.e/Et),c=_.length,f=g.length,c<f&&(s=_,_=g,g=s,a=c,c=f,f=a),s=[],a=c+f,r=a;r--;)s.push(0);for(r=f;--r>=0;){for(t=0,n=c+r;n>r;)u=s[n]+g[r]*_[n-r-1]+t,s[n--]=u%Hr|0,t=u/Hr|0;s[n]=(s[n]+t)%Hr|0}for(;!s[--a];)s.pop();return t?++e:s.shift(),i.d=s,i.e=Ws(s,e),Ot?xt(i,h.precision,h.rounding):i},it.toBinary=function(i,t){return Ua(this,2,i,t)},it.toDecimalPlaces=it.toDP=function(i,t){var e=this,r=e.constructor;return e=new r(e),i===void 0?e:(cr(i,0,Sn),t===void 0?t=r.rounding:cr(t,0,8),xt(e,i+e.e+1,t))},it.toExponential=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,!0):(cr(i,0,Sn),t===void 0?t=n.rounding:cr(t,0,8),r=xt(new n(r),i+1,t),e=rn(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(i,t){var e,r,n=this,s=n.constructor;return i===void 0?e=rn(n):(cr(i,0,Sn),t===void 0?t=s.rounding:cr(t,0,8),r=xt(new s(n),i+n.e+1,t),e=rn(r,!1,i+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(i){var t,e,r,n,s,a,u,c,f,d,h,_,g=this,y=g.d,p=g.constructor;if(!y)return new p(g);if(f=e=new p(1),r=c=new p(0),t=new p(r),s=t.e=kc(y)-g.e-1,a=s%Et,t.d[0]=ke(10,a<0?Et+a:a),i==null)i=s>0?t:f;else{if(u=new p(i),!u.isInt()||u.lt(f))throw Error(On+u);i=u.gt(t)?s>0?t:f:u}for(Ot=!1,u=new p(Ke(y)),d=p.precision,p.precision=s=y.length*Et*2;h=_e(u,t,0,1,1),n=e.plus(h.times(r)),n.cmp(i)!=1;)e=r,r=n,n=f,f=c.plus(h.times(n)),c=n,n=t,t=u.minus(h.times(n)),u=n;return n=_e(i.minus(e),r,0,1,1),c=c.plus(n.times(f)),e=e.plus(n.times(r)),c.s=f.s=g.s,_=_e(f,r,s,1).minus(g).abs().cmp(_e(c,e,s,1).minus(g).abs())<1?[f,r]:[c,e],p.precision=d,Ot=!0,_},it.toHexadecimal=it.toHex=function(i,t){return Ua(this,16,i,t)},it.toNearest=function(i,t){var e=this,r=e.constructor;if(e=new r(e),i==null){if(!e.d)return e;i=new r(1),t=r.rounding}else{if(i=new r(i),t===void 0?t=r.rounding:cr(t,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(Ot=!1,e=_e(e,i,0,t,1).times(i),Ot=!0,xt(e)):(i.s=e.s,e=i),e},it.toNumber=function(){return+this},it.toOctal=function(i,t){return Ua(this,8,i,t)},it.toPower=it.pow=function(i){var t,e,r,n,s,a,u=this,c=u.constructor,f=+(i=new c(i));if(!u.d||!i.d||!u.d[0]||!i.d[0])return new c(ke(+u,f));if(u=new c(u),u.eq(1))return u;if(r=c.precision,s=c.rounding,i.eq(1))return xt(u,r,s);if(t=Qe(i.e/Et),t>=i.d.length-1&&(e=f<0?-f:f)<=Vp)return n=zc(c,u,e,r),i.s<0?new c(1).div(n):xt(n,r,s);if(a=u.s,a<0){if(t<i.d.length-1)return new c(NaN);if(i.d[t]&1||(a=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=a,u}return e=ke(+u,f),t=e==0||!isFinite(e)?Qe(f*(Math.log("0."+Ke(u.d))/Math.LN10+u.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(Ot=!1,c.rounding=u.s=1,e=Math.min(12,(t+"").length),n=za(i.times(Tn(u,r+e)),r),n.d&&(n=xt(n,r+5,1),rs(n.d,r,s)&&(t=r+10,n=xt(za(i.times(Tn(u,t+e)),t),t+5,1),+Ke(n.d).slice(r+1,r+15)+1==1e14&&(n=xt(n,r+1,0)))),n.s=a,Ot=!0,c.rounding=s,xt(n,r,s))},it.toPrecision=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(cr(i,1,Sn),t===void 0?t=n.rounding:cr(t,0,8),r=xt(new n(r),i,t),e=rn(r,i<=r.e||r.e<=n.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(i,t){var e=this,r=e.constructor;return i===void 0?(i=r.precision,t=r.rounding):(cr(i,1,Sn),t===void 0?t=r.rounding:cr(t,0,8)),xt(new r(e),i,t)},it.toString=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return xt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()?"-"+e:e};function Ke(i){var t,e,r,n=i.length-1,s="",a=i[0];if(n>0){for(s+=a,t=1;t<n;t++)r=i[t]+"",e=Et-r.length,e&&(s+=Bn(e)),s+=r;a=i[t],r=a+"",e=Et-r.length,e&&(s+=Bn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}function cr(i,t,e){if(i!==~~i||i<t||i>e)throw Error(On+i)}function rs(i,t,e,r){var n,s,a,u;for(s=i[0];s>=10;s/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),s=ke(10,Et-t),u=i[n]%s|0,r==null?t<3?(t==0?u=u/100|0:t==1&&(u=u/10|0),a=e<4&&u==99999||e>3&&u==49999||u==5e4||u==0):a=(e<4&&u+1==s||e>3&&u+1==s/2)&&(i[n+1]/s/100|0)==ke(10,t-2)-1||(u==s/2||u==0)&&(i[n+1]/s/100|0)==0:t<4?(t==0?u=u/1e3|0:t==1?u=u/100|0:t==2&&(u=u/10|0),a=(r||e<4)&&u==9999||!r&&e>3&&u==4999):a=((r||e<4)&&u+1==s||!r&&e>3&&u+1==s/2)&&(i[n+1]/s/1e3|0)==ke(10,t-3)-1,a}function Us(i,t,e){for(var r,n=[0],s,a=0,u=i.length;a<u;){for(s=n.length;s--;)n[s]*=t;for(n[0]+=Ra.indexOf(i.charAt(a++)),r=0;r<n.length;r++)n[r]>e-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/e|0,n[r]%=e)}return n.reverse()}function Zp(i,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ys(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i.precision+=e,t=xi(i,1,t.times(n),new i(1));for(var s=e;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return i.precision-=e,t}var _e=function(){function i(r,n,s){var a,u=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+u,r[c]=a%s|0,u=a/s|0;return u&&r.unshift(u),r}function t(r,n,s,a){var u,c;if(s!=a)c=s>a?1:-1;else for(u=c=0;u<s;u++)if(r[u]!=n[u]){c=r[u]>n[u]?1:-1;break}return c}function e(r,n,s,a){for(var u=0;s--;)r[s]-=u,u=r[s]<n[s]?1:0,r[s]=u*a+r[s]-n[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,s,a,u,c){var f,d,h,_,g,y,p,w,v,x,b,C,E,A,N,S,I,F,O,L,z=r.constructor,q=r.s==n.s?1:-1,W=r.d,R=n.d;if(!W||!W[0]||!R||!R[0])return new z(!r.s||!n.s||(W?R&&W[0]==R[0]:!R)?NaN:W&&W[0]==0||!R?q*0:q/0);for(c?(g=1,d=r.e-n.e):(c=Hr,g=Et,d=Qe(r.e/g)-Qe(n.e/g)),O=R.length,I=W.length,v=new z(q),x=v.d=[],h=0;R[h]==(W[h]||0);h++);if(R[h]>(W[h]||0)&&d--,s==null?(A=s=z.precision,a=z.rounding):u?A=s+(r.e-n.e)+1:A=s,A<0)x.push(1),y=!0;else{if(A=A/g+2|0,h=0,O==1){for(_=0,R=R[0],A++;(h<I||_)&&A--;h++)N=_*c+(W[h]||0),x[h]=N/R|0,_=N%R|0;y=_||h<I}else{for(_=c/(R[0]+1)|0,_>1&&(R=i(R,_,c),W=i(W,_,c),O=R.length,I=W.length),S=O,b=W.slice(0,O),C=b.length;C<O;)b[C++]=0;L=R.slice(),L.unshift(0),F=R[0],R[1]>=c/2&&++F;do _=0,f=t(R,b,O,C),f<0?(E=b[0],O!=C&&(E=E*c+(b[1]||0)),_=E/F|0,_>1?(_>=c&&(_=c-1),p=i(R,_,c),w=p.length,C=b.length,f=t(p,b,w,C),f==1&&(_--,e(p,O<w?L:R,w,c))):(_==0&&(f=_=1),p=R.slice()),w=p.length,w<C&&p.unshift(0),e(b,p,C,c),f==-1&&(C=b.length,f=t(R,b,O,C),f<1&&(_++,e(b,O<C?L:R,C,c))),C=b.length):f===0&&(_++,b=[0]),x[h++]=_,f&&b[0]?b[C++]=W[S]||0:(b=[W[S]],C=1);while((S++<I||b[0]!==void 0)&&A--);y=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=d,Ic=y;else{for(h=1,_=x[0];_>=10;_/=10)h++;v.e=h+d*g-1,xt(v,u?s+v.e+1:s,a,y)}return v}}();function xt(i,t,e,r){var n,s,a,u,c,f,d,h,_,g=i.constructor;t:if(t!=null){if(h=i.d,!h)return i;for(n=1,u=h[0];u>=10;u/=10)n++;if(s=t-n,s<0)s+=Et,a=t,d=h[_=0],c=d/ke(10,n-a-1)%10|0;else if(_=Math.ceil((s+1)/Et),u=h.length,_>=u)if(r){for(;u++<=_;)h.push(0);d=c=0,n=1,s%=Et,a=s-Et+1}else break t;else{for(d=u=h[_],n=1;u>=10;u/=10)n++;s%=Et,a=s-Et+n,c=a<0?0:d/ke(10,n-a-1)%10|0}if(r=r||t<0||h[_+1]!==void 0||(a<0?d:d%ke(10,n-a-1)),f=e<4?(c||r)&&(e==0||e==(i.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(s>0?a>0?d/ke(10,n-a):0:h[_-1])%10&1||e==(i.s<0?8:7)),t<1||!h[0])return h.length=0,f?(t-=i.e+1,h[0]=ke(10,(Et-t%Et)%Et),i.e=-t||0):h[0]=i.e=0,i;if(s==0?(h.length=_,u=1,_--):(h.length=_+1,u=ke(10,Et-s),h[_]=a>0?(d/ke(10,n-a)%ke(10,a)|0)*u:0),f)for(;;)if(_==0){for(s=1,a=h[0];a>=10;a/=10)s++;for(a=h[0]+=u,u=1;a>=10;a/=10)u++;s!=u&&(i.e++,h[0]==Hr&&(h[0]=1));break}else{if(h[_]+=u,h[_]!=Hr)break;h[_--]=0,u=1}for(s=h.length;h[--s]===0;)h.pop()}return Ot&&(i.e>g.maxE?(i.d=null,i.e=NaN):i.e<g.minE&&(i.e=0,i.d=[0])),i}function rn(i,t,e){if(!i.isFinite())return Wc(i);var r,n=i.e,s=Ke(i.d),a=s.length;return t?(e&&(r=e-a)>0?s=s.charAt(0)+"."+s.slice(1)+Bn(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i.e<0?"e":"e+")+i.e):n<0?(s="0."+Bn(-n-1)+s,e&&(r=e-a)>0&&(s+=Bn(r))):n>=a?(s+=Bn(n+1-a),e&&(r=e-n-1)>0&&(s=s+"."+Bn(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(s+="."),s+=Bn(r))),s}function Ws(i,t){var e=i[0];for(t*=Et;e>=10;e/=10)t++;return t}function js(i,t,e){if(t>Hp)throw Ot=!0,e&&(i.precision=e),Error($c);return xt(new i(ks),t,1,!0)}function Zr(i,t,e){if(t>ka)throw Error($c);return xt(new i(zs),t,e,!0)}function kc(i){var t=i.length-1,e=t*Et+1;if(t=i[t],t){for(;t%10==0;t/=10)e--;for(t=i[0];t>=10;t/=10)e++}return e}function Bn(i){for(var t="";i--;)t+="0";return t}function zc(i,t,e,r){var n,s=new i(1),a=Math.ceil(r/Et+4);for(Ot=!1;;){if(e%2&&(s=s.times(t),Yc(s.d,a)&&(n=!0)),e=Qe(e/2),e===0){e=s.d.length-1,n&&s.d[e]===0&&++s.d[e];break}t=t.times(t),Yc(t.d,a)}return Ot=!0,s}function qc(i){return i.d[i.d.length-1]&1}function Uc(i,t,e){for(var r,n=new i(t[0]),s=0;++s<t.length;)if(r=new i(t[s]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function za(i,t){var e,r,n,s,a,u,c,f=0,d=0,h=0,_=i.constructor,g=_.rounding,y=_.precision;if(!i.d||!i.d[0]||i.e>17)return new _(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(t==null?(Ot=!1,c=y):c=t,u=new _(.03125);i.e>-2;)i=i.times(u),h+=5;for(r=Math.log(ke(2,h))/Math.LN10*2+5|0,c+=r,e=s=a=new _(1),_.precision=c;;){if(s=xt(s.times(i),c,1),e=e.times(++d),u=a.plus(_e(s,e,c,1)),Ke(u.d).slice(0,c)===Ke(a.d).slice(0,c)){for(n=h;n--;)a=xt(a.times(a),c,1);if(t==null)if(f<3&&rs(a.d,c-r,g,f))_.precision=c+=10,e=s=u=new _(1),d=0,f++;else return xt(a,_.precision=y,g,Ot=!0);else return _.precision=y,a}a=u}}function Tn(i,t){var e,r,n,s,a,u,c,f,d,h,_,g=1,y=10,p=i,w=p.d,v=p.constructor,x=v.rounding,b=v.precision;if(p.s<0||!w||!w[0]||!p.e&&w[0]==1&&w.length==1)return new v(w&&!w[0]?-1/0:p.s!=1?NaN:w?0:p);if(t==null?(Ot=!1,d=b):d=t,v.precision=d+=y,e=Ke(w),r=e.charAt(0),Math.abs(s=p.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)p=p.times(i),e=Ke(p.d),r=e.charAt(0),g++;s=p.e,r>1?(p=new v("0."+e),s++):p=new v(r+"."+e.slice(1))}else return f=js(v,d+2,b).times(s+""),p=Tn(new v(r+"."+e.slice(1)),d-y).plus(f),v.precision=b,t==null?xt(p,b,x,Ot=!0):p;for(h=p,c=a=p=_e(p.minus(1),p.plus(1),d,1),_=xt(p.times(p),d,1),n=3;;){if(a=xt(a.times(_),d,1),f=c.plus(_e(a,new v(n),d,1)),Ke(f.d).slice(0,d)===Ke(c.d).slice(0,d))if(c=c.times(2),s!==0&&(c=c.plus(js(v,d+2,b).times(s+""))),c=_e(c,new v(g),d,1),t==null)if(rs(c.d,d-y,x,u))v.precision=d+=y,f=a=p=_e(h.minus(1),h.plus(1),d,1),_=xt(p.times(p),d,1),n=u=1;else return xt(c,v.precision=b,x,Ot=!0);else return v.precision=b,c;c=f,n+=2}}function Wc(i){return String(i.s*i.s/0)}function qa(i,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,i.e=e=e-r-1,i.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&i.d.push(+t.slice(0,r)),n-=Et;r<n;)i.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";i.d.push(+t),Ot&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function Kp(i,t){var e,r,n,s,a,u,c,f,d;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Pc.test(t))return qa(i,t)}else if(t==="Infinity"||t==="NaN")return+t||(i.s=NaN),i.e=NaN,i.d=null,i;if(jp.test(t))e=16,t=t.toLowerCase();else if(Wp.test(t))e=2;else if(Yp.test(t))e=8;else throw Error(On+t);for(s=t.search(/p/i),s>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),a=s>=0,r=i.constructor,a&&(t=t.replace(".",""),u=t.length,s=u-s,n=zc(r,new r(e),s,s*2)),f=Us(t,e,Hr),d=f.length-1,s=d;f[s]===0;--s)f.pop();return s<0?new r(i.s*0):(i.e=Ws(f,d),i.d=f,Ot=!1,a&&(i=_e(i,n,u*4)),c&&(i=i.times(Math.abs(c)<54?ke(2,c):Ei.pow(2,c))),Ot=!0,i)}function Gp(i,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:xi(i,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ys(5,e)),t=xi(i,2,t,t);for(var n,s=new i(5),a=new i(16),u=new i(20);e--;)n=t.times(t),t=t.times(s.plus(n.times(a.times(n).minus(u))));return t}function xi(i,t,e,r,n){var s,a,u,c,f=i.precision,d=Math.ceil(f/Et);for(Ot=!1,c=e.times(e),u=new i(r);;){if(a=_e(u.times(c),new i(t++*t++),f,1),u=n?r.plus(a):r.minus(a),r=_e(a.times(c),new i(t++*t++),f,1),a=u.plus(r),a.d[d]!==void 0){for(s=d;a.d[s]===u.d[s]&&s--;);if(s==-1)break}s=u,u=r,r=a,a=s}return Ot=!0,a.d.length=d+1,a}function Ys(i,t){for(var e=i;--t;)e*=i;return e}function jc(i,t){var e,r=t.s<0,n=Zr(i,i.precision,1),s=n.times(.5);if(t=t.abs(),t.lte(s))return hn=r?4:1,t;if(e=t.divToInt(n),e.isZero())hn=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(s))return hn=qc(e)?r?2:3:r?4:1,t;hn=qc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Ua(i,t,e,r){var n,s,a,u,c,f,d,h,_,g=i.constructor,y=e!==void 0;if(y?(cr(e,1,Sn),r===void 0?r=g.rounding:cr(r,0,8)):(e=g.precision,r=g.rounding),!i.isFinite())d=Wc(i);else{for(d=rn(i),a=d.indexOf("."),y?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(d=d.replace(".",""),_=new g(1),_.e=d.length-a,_.d=Us(rn(_),10,n),_.e=_.d.length),h=Us(d,10,n),s=c=h.length;h[--c]==0;)h.pop();if(!h[0])d=y?"0p+0":"0";else{if(a<0?s--:(i=new g(i),i.d=h,i.e=s,i=_e(i,_,e,r,0,n),h=i.d,s=i.e,f=Ic),a=h[e],u=n/2,f=f||h[e+1]!==void 0,f=r<4?(a!==void 0||f)&&(r===0||r===(i.s<0?3:2)):a>u||a===u&&(r===4||f||r===6&&h[e-1]&1||r===(i.s<0?8:7)),h.length=e,f)for(;++h[--e]>n-1;)h[e]=0,e||(++s,h.unshift(1));for(c=h.length;!h[c-1];--c);for(a=0,d="";a<c;a++)d+=Ra.charAt(h[a]);if(y){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)d+="0";for(h=Us(d,n,t),c=h.length;!h[c-1];--c);for(a=1,d="1.";a<c;a++)d+=Ra.charAt(h[a])}else d=d.charAt(0)+"."+d.slice(1);d=d+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)d="0"+d;d="0."+d}else if(++s>c)for(s-=c;s--;)d+="0";else s<c&&(d=d.slice(0,s)+"."+d.slice(s))}d=(t==16?"0x":t==2?"0b":t==8?"0o":"")+d}return i.s<0?"-"+d:d}function Yc(i,t){if(i.length>t)return i.length=t,!0}function Jp(i){return new this(i).abs()}function Xp(i){return new this(i).acos()}function Qp(i){return new this(i).acosh()}function tm(i,t){return new this(i).plus(t)}function em(i){return new this(i).asin()}function rm(i){return new this(i).asinh()}function nm(i){return new this(i).atan()}function im(i){return new this(i).atanh()}function sm(i,t){i=new this(i),t=new this(t);var e,r=this.precision,n=this.rounding,s=r+4;return!i.s||!t.s?e=new this(NaN):!i.d&&!t.d?(e=Zr(this,s,1).times(t.s>0?.25:.75),e.s=i.s):!t.d||i.isZero()?(e=t.s<0?Zr(this,r,n):new this(0),e.s=i.s):!i.d||t.isZero()?(e=Zr(this,s,1).times(.5),e.s=i.s):t.s<0?(this.precision=s,this.rounding=1,e=this.atan(_e(i,t,s,1)),t=Zr(this,s,1),this.precision=r,this.rounding=n,e=i.s<0?e.minus(t):e.plus(t)):e=this.atan(_e(i,t,s,1)),e}function om(i){return new this(i).cbrt()}function am(i){return xt(i=new this(i),i.e+1,2)}function um(i,t,e){return new this(i).clamp(t,e)}function lm(i){if(!i||typeof i!="object")throw Error(qs+"Object expected");var t,e,r,n=i.defaults===!0,s=["precision",1,Sn,"rounding",0,8,"toExpNeg",-bi,0,"toExpPos",0,bi,"maxE",0,bi,"minE",-bi,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],n&&(this[e]=Pa[e]),(r=i[e])!==void 0)if(Qe(r)===r&&r>=s[t+1]&&r<=s[t+2])this[e]=r;else throw Error(On+e+": "+r);if(e="crypto",n&&(this[e]=Pa[e]),(r=i[e])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(Lc);else this[e]=!1;else throw Error(On+e+": "+r);return this}function cm(i){return new this(i).cos()}function fm(i){return new this(i).cosh()}function Vc(i){var t,e,r;function n(s){var a,u,c,f=this;if(!(f instanceof n))return new n(s);if(f.constructor=n,Hc(s)){f.s=s.s,Ot?!s.d||s.e>n.maxE?(f.e=NaN,f.d=null):s.e<n.minE?(f.e=0,f.d=[0]):(f.e=s.e,f.d=s.d.slice()):(f.e=s.e,f.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){f.s=1/s<0?-1:1,f.e=0,f.d=[0];return}if(s<0?(s=-s,f.s=-1):f.s=1,s===~~s&&s<1e7){for(a=0,u=s;u>=10;u/=10)a++;Ot?a>n.maxE?(f.e=NaN,f.d=null):a<n.minE?(f.e=0,f.d=[0]):(f.e=a,f.d=[s]):(f.e=a,f.d=[s]);return}else if(s*0!==0){s||(f.s=NaN),f.e=NaN,f.d=null;return}return qa(f,s.toString())}else if(c!=="string")throw Error(On+s);return(u=s.charCodeAt(0))===45?(s=s.slice(1),f.s=-1):(u===43&&(s=s.slice(1)),f.s=1),Pc.test(s)?qa(f,s):Kp(f,s)}if(n.prototype=it,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=lm,n.clone=Vc,n.isDecimal=Hc,n.abs=Jp,n.acos=Xp,n.acosh=Qp,n.add=tm,n.asin=em,n.asinh=rm,n.atan=nm,n.atanh=im,n.atan2=sm,n.cbrt=om,n.ceil=am,n.clamp=um,n.cos=cm,n.cosh=fm,n.div=hm,n.exp=dm,n.floor=_m,n.hypot=pm,n.ln=mm,n.log=gm,n.log10=ym,n.log2=vm,n.max=wm,n.min=Dm,n.mod=bm,n.mul=xm,n.pow=Em,n.random=Cm,n.round=Am,n.sign=Mm,n.sin=Fm,n.sinh=Nm,n.sqrt=Sm,n.sub=Om,n.sum=Bm,n.tan=Tm,n.tanh=Im,n.trunc=$m,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)i.hasOwnProperty(e=r[t++])||(i[e]=this[e]);return n.config(i),n}function hm(i,t){return new this(i).div(t)}function dm(i){return new this(i).exp()}function _m(i){return xt(i=new this(i),i.e+1,3)}function pm(){var i,t,e=new this(0);for(Ot=!1,i=0;i<arguments.length;)if(t=new this(arguments[i++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return Ot=!0,new this(1/0);e=t}return Ot=!0,e.sqrt()}function Hc(i){return i instanceof Ei||i&&i.toStringTag===Rc||!1}function mm(i){return new this(i).ln()}function gm(i,t){return new this(i).log(t)}function vm(i){return new this(i).log(2)}function ym(i){return new this(i).log(10)}function wm(){return Uc(this,arguments,"lt")}function Dm(){return Uc(this,arguments,"gt")}function bm(i,t){return new this(i).mod(t)}function xm(i,t){return new this(i).mul(t)}function Em(i,t){return new this(i).pow(t)}function Cm(i){var t,e,r,n,s=0,a=new this(1),u=[];if(i===void 0?i=this.precision:cr(i,1,Sn),r=Math.ceil(i/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)n=t[s],n>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)n=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,s):(u.push(n%1e7),s+=4);s=r/4}else throw Error(Lc);else for(;s<r;)u[s++]=Math.random()*1e7|0;for(r=u[--s],i%=Et,r&&i&&(n=ke(10,Et-i),u[s]=(r/n|0)*n);u[s]===0;s--)u.pop();if(s<0)e=0,u=[0];else{for(e=-1;u[0]===0;e-=Et)u.shift();for(r=1,n=u[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=u,a}function Am(i){return xt(i=new this(i),i.e+1,this.rounding)}function Mm(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Fm(i){return new this(i).sin()}function Nm(i){return new this(i).sinh()}function Sm(i){return new this(i).sqrt()}function Om(i,t){return new this(i).sub(t)}function Bm(){var i=0,t=arguments,e=new this(t[i]);for(Ot=!1;e.s&&++i<t.length;)e=e.plus(t[i]);return Ot=!0,xt(e,this.precision,this.rounding)}function Tm(i){return new this(i).tan()}function Im(i){return new this(i).tanh()}function $m(i){return xt(i=new this(i),i.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var Ei=it.constructor=Vc(Pa);ks=new Ei(ks),zs=new Ei(zs);var Lm="BigNumber",Rm=["?on","config"],Pm=gt(Lm,Rm,i=>{var{on:t,config:e}=i,r=Ei.clone({precision:e.precision,modulo:Ei.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},t&&t("config",function(n,s){n.precision!==s.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),Zc={exports:{}};/**
|
41
41
|
* @license Complex.js v2.1.1 12/05/2020
|
42
42
|
*
|
43
43
|
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
@@ -49,21 +49,21 @@ Example:
|
|
49
49
|
*
|
50
50
|
* Copyright (c) 2023, Robert Eisele (robert@raw.org)
|
51
51
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
52
|
-
**/(function(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(v,x){if(isNaN(v=parseInt(v,10)))throw p();return v*x}function a(v,x){if(x===0)throw y();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var C=_(v,x);return b.n=v/C,b.d=x/C,b}function u(v){for(var x={},b=v,C=2,E=4;E<=b;){for(;b%C===0;)b/=C,x[C]=(x[C]||0)+1;E+=1+2*C++}return b!==v?b>1&&(x[b]=(x[b]||0)+1):x[v]=(x[v]||0)+1,x}var c=function(v,x){var b=0,C=1,E=1,A=0,N=0,S=0,I=1,F=1,O=0,L=1,z=1,q=1,W=1e7,P;if(v!=null)if(x!==void 0){if(b=v,C=x,E=b*C,b%1!==0||C%1!==0)throw w()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,C=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(C=v[1]);else throw p();E=b*C;break}case"number":{if(v<0&&(E=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(F=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=F);L<=W&&q<=W;)if(P=(O+z)/(L+q),v===P){L+q<=W?(b=O+z,C=L+q):q>L?(b=z,C=q):(b=O,C=L);break}else v>P?(O+=z,L+=q):(z+=O,q+=L),L>W?(b=z,C=q):(b=O,C=L);b*=F}else(isNaN(v)||isNaN(x))&&(C=b=NaN);break}case"string":{if(L=v.match(/\d+|./g),L===null)throw p();if(L[O]==="-"?(E=-1,O++):L[O]==="+"&&O++,L.length===O+1?N=s(L[O++],E):L[O+1]==="."||L[O]==="."?(L[O]!=="."&&(A=s(L[O++],E)),O++,(O+1===L.length||L[O+1]==="("&&L[O+3]===")"||L[O+1]==="'"&&L[O+3]==="'")&&(N=s(L[O],E),I=Math.pow(10,L[O].length),O++),(L[O]==="("&&L[O+2]===")"||L[O]==="'"&&L[O+2]==="'")&&(S=s(L[O+1],E),F=Math.pow(10,L[O+1].length)-1,O+=3)):L[O+1]==="/"||L[O+1]===":"?(N=s(L[O],E),I=s(L[O+2],1),O+=3):L[O+3]==="/"&&L[O+1]===" "&&(A=s(L[O],E),N=s(L[O+2],E),I=s(L[O+4],1),O+=5),L.length<=O){C=I*F,E=b=S+C*A+F*N;break}}default:throw p()}if(C===0)throw y();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(C)};function f(v,x,b){for(var C=1;x>0;v=v*v%b,x>>=1)x&1&&(C=C*v%b);return C}function d(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,C=1;b!==1;C++)if(b=b*10%x,C>r)return 0;return C}function h(v,x,b){for(var C=1,E=f(10,b,x),A=0;A<300;A++){if(C===E)return A;C=C*10%x,E=E*10%x}return 0}function _(v,x){if(!v)return x;if(!x)return v;for(;;){if(v%=x,!v)return x;if(x%=v,!x)return v}}function g(v,x){if(c(v,x),this instanceof g)v=_(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var y=function(){return new Error("Division by Zero")},p=function(){return new Error("Invalid argument")},w=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,x){return c(v,x),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,x){return c(v,x),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,x){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,x),n.n===0&&this.d===0)throw y();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,x){return c(v,x),a(_(n.n,this.n)*_(n.d,this.d),n.d*this.d)},lcm:function(v,x){return c(v,x),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,_(n.n,this.n)*_(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,x){if(c(v,x),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=u(this.n),C=u(this.d),E=1,A=1;for(var N in b)if(N!=="1"){if(N==="0"){E=0;break}if(b[N]*=n.n,b[N]%n.d===0)b[N]/=n.d;else return null;E*=Math.pow(N,b[N])}for(var N in C)if(N!=="1"){if(C[N]*=n.n,C[N]%n.d===0)C[N]/=n.d;else return null;A*=Math.pow(N,C[N])}return n.s<0?a(A,E):a(E,A)},equals:function(v,x){return c(v,x),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,x){c(v,x);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var x=this.abs(),b=x.toContinued(),C=1;C<b.length;C++){for(var E=a(b[C-1],1),A=C-2;A>=0;A--)E=E.inverse().add(b[A]);if(Math.abs(E.sub(x).valueOf())<v)return E.mul(this.s)}return this},divisible:function(v,x){return c(v,x),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var x,b="",C=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=C:(v&&(x=Math.floor(C/E))>0&&(b+=x,b+=" ",C%=E),b+=C,b+="/",b+=E),b},toLatex:function(v){var x,b="",C=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=C:(v&&(x=Math.floor(C/E))>0&&(b+=x,C%=E),b+="\\frac{",b+=C,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,C=[];if(isNaN(x)||isNaN(b))return C;do C.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return C},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var C=d(x,b),E=h(x,b,C),A=this.s<0?"-":"";if(A+=x/b|0,x%=b,x*=10,x&&(A+="."),C){for(var N=E;N--;)A+=x/b|0,x%=b,x*=10;A+="(";for(var N=C;N--;)A+=x/b|0,x%=b,x*=10;A+=")"}else for(var N=v;x&&N--;)A+=x/b|0,x%=b,x*=10;return A}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,i.exports=g})()})(Kc);var Wm=Kc.exports,dn=Kt(Wm),jm="Fraction",Ym=[],Vm=gt(jm,Ym,()=>(Object.defineProperty(dn,"name",{value:"Fraction"}),dn.prototype.constructor=dn,dn.prototype.type="Fraction",dn.prototype.isFraction=!0,dn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},dn.fromJSON=function(i){return new dn(i)},dn),{isClass:!0}),Hm="Matrix",Zm=[],Km=gt(Hm,Zm,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function Gc(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Gm="DenseMatrix",Jm=["Matrix"],Xm=gt(Gm,Jm,i=>{var{Matrix:t}=i;function e(d,h){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!en(h))throw new Error("Invalid datatype: "+h);if(we(d))d.type==="DenseMatrix"?(this._data=ue(d._data),this._size=ue(d._size),this._datatype=h||d._datatype):(this._data=d.toArray(),this._size=d.size(),this._datatype=h||d._datatype);else if(d&&Ae(d.data)&&Ae(d.size))this._data=d.data,this._size=d.size,Ec(this._data,this._size),this._datatype=h||d.datatype;else if(Ae(d))this._data=f(d),this._size=Ie(this._data),Ec(this._data,this._size),this._datatype=h;else{if(d)throw new TypeError("Unsupported type of data ("+Fn(d)+")");this._data=[],this._size=[0],this._datatype=h}}e.prototype=new t,e.prototype.createDenseMatrix=function(d,h){return new e(d,h)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Ls(this._data,Fn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(d,h){return new e(d,h)},e.prototype.subset=function(d,h,_){switch(arguments.length){case 1:return r(this,d);case 2:case 3:return s(this,d,h,_);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(d){if(!Ae(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new Jt(d.length,this._size.length);for(var h=0;h<d.length;h++)Me(d[h],this._size[h]);for(var _=this._data,g=0,y=d.length;g<y;g++){var p=d[g];Me(p,_.length),_=_[p]}return _},e.prototype.set=function(d,h,_){if(!Ae(d))throw new TypeError("Array expected");if(d.length<this._size.length)throw new Jt(d.length,this._size.length,"<");var g,y,p,w=d.map(function(x){return x+1});c(this,w,_);var v=this._data;for(g=0,y=d.length-1;g<y;g++)p=d[g],Me(p,v.length),v=v[p];return p=d[d.length-1],Me(p,v.length),v[p]=h,this};function r(d,h){if(!Ca(h))throw new TypeError("Invalid index");var _=h.isScalar();if(_)return d.get(h.min());var g=h.size();if(g.length!==d._size.length)throw new Jt(g.length,d._size.length);for(var y=h.min(),p=h.max(),w=0,v=d._size.length;w<v;w++)Me(y[w],d._size[w]),Me(p[w],d._size[w]);return new e(n(d._data,h,g.length,0),d._datatype)}function n(d,h,_,g){var y=g===_-1,p=h.dimension(g);return y?p.map(function(w){return Me(w,d.length),d[w]}).valueOf():p.map(function(w){Me(w,d.length);var v=d[w];return n(v,h,_,g+1)}).valueOf()}function s(d,h,_,g){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var y=h.size(),p=h.isScalar(),w;if(we(_)?(w=_.size(),_=_.valueOf()):w=Ie(_),p){if(w.length!==0)throw new TypeError("Scalar expected");d.set(h.min(),_,g)}else{if(!yi(w,y))try{w.length===0?_=Sc([_],y):_=Sc(_,y),w=Ie(_)}catch{}if(y.length<d._size.length)throw new Jt(y.length,d._size.length,"<");if(w.length<y.length){for(var v=0,x=0;y[v]===1&&w[v]===1;)v++;for(;y[v]===1;)x++,v++;_=Ac(_,y.length,x,w)}if(!yi(y,w))throw new Jt(y,w,">");var b=h.max().map(function(A){return A+1});c(d,b,g);var C=y.length,E=0;a(d._data,h,_,C,E)}return d}function a(d,h,_,g,y){var p=y===g-1,w=h.dimension(y);p?w.forEach(function(v,x){Me(v),d[v]=_[x[0]]}):w.forEach(function(v,x){Me(v),a(d[v],h,_[x[0]],g,y+1)})}e.prototype.resize=function(d,h,_){if(!ts(d))throw new TypeError("Array or Matrix expected");var g=d.valueOf().map(p=>Array.isArray(p)&&p.length===1?p[0]:p),y=_?this.clone():this;return u(y,g,h)};function u(d,h,_){if(h.length===0){for(var g=d._data;Ae(g);)g=g[0];return g}return d._size=h.slice(0),d._data=Sa(d._data,d._size,_),d}e.prototype.reshape=function(d,h){var _=h?this.clone():this;_._data=Ba(_._data,d);var g=_._size.reduce((y,p)=>y*p);return _._size=Ta(d,g),_};function c(d,h,_){for(var g=d._size.slice(0),y=!1;g.length<h.length;)g.push(0),y=!0;for(var p=0,w=h.length;p<w;p++)h[p]>g[p]&&(g[p]=h[p],y=!0);y&&u(d,g,_)}e.prototype.clone=function(){var d=new e({data:ue(this._data),size:ue(this._size),datatype:this._datatype});return d},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(d){var h=this,_=Gc(d),g=function w(v,x){return Ae(v)?v.map(function(b,C){return w(b,x.concat(C))}):_===1?d(v):_===2?d(v,x):d(v,x,h)},y=g(this._data,[]),p=this._datatype!==void 0?Ls(y,Fn):void 0;return new e(y,p)},e.prototype.forEach=function(d){var h=this,_=function g(y,p){Ae(y)?y.forEach(function(w,v){g(w,p.concat(v))}):d(y,p,h)};_(this._data,[])},e.prototype[Symbol.iterator]=function*(){var d=function*h(_,g){if(Ae(_))for(var y=0;y<_.length;y++)yield*h(_[y],g.concat(y));else yield{value:_,index:g}};yield*d(this._data,[])},e.prototype.rows=function(){var d=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var _=this._data;for(var g of _)d.push(new e([g],this._datatype));return d},e.prototype.columns=function(){var d=this,h=[],_=this.size();if(_.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,y=function(v){var x=g.map(b=>[b[v]]);h.push(new e(x,d._datatype))},p=0;p<_[1];p++)y(p);return h},e.prototype.toArray=function(){return ue(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(d){return de(this._data,d)},e.prototype.toString=function(){return de(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(d){if(d){if(Oe(d)&&(d=d.toNumber()),!me(d)||!xe(d))throw new TypeError("The parameter k must be an integer number")}else d=0;for(var h=d>0?d:0,_=d<0?-d:0,g=this._size[0],y=this._size[1],p=Math.min(g-_,y-h),w=[],v=0;v<p;v++)w[v]=this._data[v+_][v+h];return new e({data:w,size:[p],datatype:this._datatype})},e.diagonal=function(d,h,_,g){if(!Ae(d))throw new TypeError("Array expected, size parameter");if(d.length!==2)throw new Error("Only two dimensions matrix are supported");if(d=d.map(function(N){if(Oe(N)&&(N=N.toNumber()),!me(N)||!xe(N)||N<1)throw new Error("Size values must be positive integers");return N}),_){if(Oe(_)&&(_=_.toNumber()),!me(_)||!xe(_))throw new TypeError("The parameter k must be an integer number")}else _=0;var y=_>0?_:0,p=_<0?-_:0,w=d[0],v=d[1],x=Math.min(w-p,v-y),b;if(Ae(h)){if(h.length!==x)throw new Error("Invalid value array length");b=function(S){return h[S]}}else if(we(h)){var C=h.size();if(C.length!==1||C[0]!==x)throw new Error("Invalid matrix length");b=function(S){return h.get([S])}}else b=function(){return h};g||(g=Oe(b(0))?b(0).mul(0):0);var E=[];if(d.length>0){E=Sa(E,d,g);for(var A=0;A<x;A++)E[A+p][A+y]=b(A)}return new e({data:E,size:[w,v]})},e.fromJSON=function(d){return new e(d)},e.prototype.swapRows=function(d,h){if(!me(d)||!xe(d)||!me(h)||!xe(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Me(d,this._size[0]),Me(h,this._size[0]),e._swapRows(d,h,this._data),this},e._swapRows=function(d,h,_){var g=_[d];_[d]=_[h],_[h]=g};function f(d){return we(d)?f(d.valueOf()):Ae(d)?d.map(f):d}return e},{isClass:!0});function Qm(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(i[r][n]);s.push(a)}return s}function Vs(i){for(var t=0;t<i.length;t++)if(ts(i[t]))return!0;return!1}function ns(i,t){we(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?ns(n,t):t(n)}}function Kr(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Kr(r,t)}):t(i)}function Wa(i,t,e){var r=Array.isArray(i)?Ie(i):i.size();if(t<0||t>=r.length)throw new Nn(t,r.length);return we(i)?i.create(Hs(i.valueOf(),t,e)):Hs(i,t,e)}function Hs(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=Qm(i),n=[],r=0;r<a.length;r++)n[r]=Hs(a[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=Hs(i[r],t-1,e);return n}}var Jc="isInteger",tg=["typed"],eg=gt(Jc,tg,i=>{var{typed:t}=i;return t(Jc,{number:xe,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),Xc="number",Zs="number, number";function Qc(i){return Math.abs(i)}Qc.signature=Xc;function tf(i,t){return i+t}tf.signature=Zs;function ef(i,t){return i-t}ef.signature=Zs;function rf(i,t){return i*t}rf.signature=Zs;function nf(i){return-i}nf.signature=Xc;function sf(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}sf.signature=Zs;var of="number";function af(i){return i===0}af.signature=of;function uf(i){return Number.isNaN(i)}uf.signature=of;var lf="isNumeric",rg=["typed"],ng=gt(lf,rg,i=>{var{typed:t}=i;return t(lf,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),cf="isZero",ig=["typed"],sg=gt(cf,ig,i=>{var{typed:t}=i;return t(cf,{number:af,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),ff="isNaN",og=["typed"],ag=gt(ff,og,i=>{var{typed:t}=i;return t(ff,{number:uf,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 Kr(r,Number.isNaN)}})});function Ks(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function ug(i,t,e){return Qn(i.re,t.re,e)&&Qn(i.im,t.im,e)}var Gs=gt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Js="equalScalar",lg=["typed","config"],cg=gt(Js,lg,i=>{var{typed:t,config:e}=i,r=Gs({typed:t});return t(Js,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return Qn(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||Ks(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return ug(s,a,e.epsilon)}},r)});gt(Js,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Js,{"number, number":function(n,s){return Qn(n,s,e.epsilon)}})});var fg="SparseMatrix",hg=["typed","equalScalar","Matrix"],dg=gt(fg,hg,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(p,w){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(w&&!en(w))throw new Error("Invalid datatype: "+w);if(we(p))s(this,p,w);else if(p&&Ae(p.index)&&Ae(p.ptr)&&Ae(p.size))this._values=p.values,this._index=p.index,this._ptr=p.ptr,this._size=p.size,this._datatype=w||p.datatype;else if(Ae(p))a(this,p,w);else{if(p)throw new TypeError("Unsupported type of data ("+Fn(p)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=w}}function s(p,w,v){w.type==="SparseMatrix"?(p._values=w._values?ue(w._values):void 0,p._index=ue(w._index),p._ptr=ue(w._ptr),p._size=ue(w._size),p._datatype=v||w._datatype):a(p,w.valueOf(),v||w._datatype)}function a(p,w,v){p._values=[],p._index=[],p._ptr=[],p._datatype=v;var x=w.length,b=0,C=e,E=0;if(en(v)&&(C=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var A=0;do{p._ptr.push(p._index.length);for(var N=0;N<x;N++){var S=w[N];if(Ae(S)){if(A===0&&b<S.length&&(b=S.length),A<S.length){var I=S[A];C(I,E)||(p._values.push(I),p._index.push(N))}}else A===0&&b<1&&(b=1),C(S,E)||(p._values.push(S),p._index.push(N))}A++}while(A<b)}p._ptr.push(p._index.length),p._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(p,w){return new n(p,w)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Ls(this._values,Fn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(p,w){return new n(p,w)},n.prototype.density=function(){var p=this._size[0],w=this._size[1];return p!==0&&w!==0?this._index.length/(p*w):0},n.prototype.subset=function(p,w,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return u(this,p);case 2:case 3:return c(this,p,w,v);default:throw new SyntaxError("Wrong number of arguments")}};function u(p,w){if(!Ca(w))throw new TypeError("Invalid index");var v=w.isScalar();if(v)return p.get(w.min());var x=w.size();if(x.length!==p._size.length)throw new Jt(x.length,p._size.length);var b,C,E,A,N=w.min(),S=w.max();for(b=0,C=p._size.length;b<C;b++)Me(N[b],p._size[b]),Me(S[b],p._size[b]);var I=p._values,F=p._index,O=p._ptr,L=w.dimension(0),z=w.dimension(1),q=[],W=[];L.forEach(function(G,X){W[G]=X[0],q[G]=!0});var P=I?[]:void 0,Z=[],Y=[];return z.forEach(function(G){for(Y.push(Z.length),E=O[G],A=O[G+1];E<A;E++)b=F[E],q[b]===!0&&(Z.push(W[b]),P&&P.push(I[E]))}),Y.push(Z.length),new n({values:P,index:Z,ptr:Y,size:x,datatype:p._datatype})}function c(p,w,v,x){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),C=w.isScalar(),E;if(we(v)?(E=v.size(),v=v.toArray()):E=Ie(v),C){if(E.length!==0)throw new TypeError("Scalar expected");p.set(w.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Jt(b.length,p._size.length,"<");if(E.length<b.length){for(var A=0,N=0;b[A]===1&&E[A]===1;)A++;for(;b[A]===1;)N++,A++;v=Ac(v,b.length,N,E)}if(!yi(b,E))throw new Jt(b,E,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(O,L){Me(O),p.set([O,0],v[L[0]],x)})}else{var I=w.dimension(0),F=w.dimension(1);I.forEach(function(O,L){Me(O),F.forEach(function(z,q){Me(z),p.set([O,z],v[L[0]][q[0]],x)})})}}return p}n.prototype.get=function(p){if(!Ae(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Jt(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var w=p[0],v=p[1];Me(w,this._size[0]),Me(v,this._size[1]);var x=f(w,this._ptr[v],this._ptr[v+1],this._index);return x<this._ptr[v+1]&&this._index[x]===w?this._values[x]:0},n.prototype.set=function(p,w,v){if(!Ae(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Jt(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=p[0],b=p[1],C=this._size[0],E=this._size[1],A=e,N=0;en(this._datatype)&&(A=t.find(e,[this._datatype,this._datatype])||e,N=t.convert(0,this._datatype)),(x>C-1||b>E-1)&&(_(this,Math.max(x+1,C),Math.max(b+1,E),v),C=this._size[0],E=this._size[1]),Me(x,C),Me(b,E);var S=f(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?A(w,N)?d(S,b,this._values,this._index,this._ptr):this._values[S]=w:A(w,N)||h(S,x,b,w,this._values,this._index,this._ptr),this};function f(p,w,v,x){if(v-w===0)return v;for(var b=w;b<v;b++)if(x[b]===p)return b;return w}function d(p,w,v,x,b){v.splice(p,1),x.splice(p,1);for(var C=w+1;C<b.length;C++)b[C]--}function h(p,w,v,x,b,C,E){b.splice(p,0,x),C.splice(p,0,w);for(var A=v+1;A<E.length;A++)E[A]++}n.prototype.resize=function(p,w,v){if(!ts(p))throw new TypeError("Array or Matrix expected");var x=p.valueOf().map(C=>Array.isArray(C)&&C.length===1?C[0]:C);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(C){if(!me(C)||!xe(C)||C<0)throw new TypeError("Invalid size, must contain positive integers (size: "+de(x)+")")});var b=v?this.clone():this;return _(b,x[0],x[1],w)};function _(p,w,v,x){var b=x||0,C=e,E=0;en(p._datatype)&&(C=t.find(e,[p._datatype,p._datatype])||e,E=t.convert(0,p._datatype),b=t.convert(b,p._datatype));var A=!C(b,E),N=p._size[0],S=p._size[1],I,F,O;if(v>S){for(F=S;F<v;F++)if(p._ptr[F]=p._values.length,A)for(I=0;I<N;I++)p._values.push(b),p._index.push(I);p._ptr[v]=p._values.length}else v<S&&(p._ptr.splice(v+1,S-v),p._values.splice(p._ptr[v],p._values.length),p._index.splice(p._ptr[v],p._index.length));if(S=v,w>N){if(A){var L=0;for(F=0;F<S;F++){p._ptr[F]=p._ptr[F]+L,O=p._ptr[F+1]+L;var z=0;for(I=N;I<w;I++,z++)p._values.splice(O+z,0,b),p._index.splice(O+z,0,I),L++}p._ptr[S]=p._values.length}}else if(w<N){var q=0;for(F=0;F<S;F++){p._ptr[F]=p._ptr[F]-q;var W=p._ptr[F],P=p._ptr[F+1]-q;for(O=W;O<P;O++)I=p._index[O],I>w-1&&(p._values.splice(O,1),p._index.splice(O,1),q++)}p._ptr[F]=p._values.length}return p._size[0]=w,p._size[1]=v,p}n.prototype.reshape=function(p,w){if(!Ae(p))throw new TypeError("Array expected");if(p.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");p.forEach(function(G){if(!me(G)||!xe(G)||G<=-2||G===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+de(p)+")")});var v=this._size[0]*this._size[1];p=Ta(p,v);var x=p[0]*p[1];if(v!==x)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=w?this.clone():this;if(this._size[0]===p[0]&&this._size[1]===p[1])return b;for(var C=[],E=0;E<b._ptr.length;E++)for(var A=0;A<b._ptr[E+1]-b._ptr[E];A++)C.push(E);for(var N=b._values.slice(),S=b._index.slice(),I=0;I<b._index.length;I++){var F=S[I],O=C[I],L=F*b._size[1]+O;C[I]=L%p[1],S[I]=Math.floor(L/p[1])}b._values.length=0,b._index.length=0,b._ptr.length=p[1]+1,b._size=p.slice();for(var z=0;z<b._ptr.length;z++)b._ptr[z]=0;for(var q=0;q<N.length;q++){var W=S[q],P=C[q],Z=N[q],Y=f(W,b._ptr[P],b._ptr[P+1],b._index);h(Y,W,P,Z,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var p=new n({values:this._values?ue(this._values):void 0,index:ue(this._index),ptr:ue(this._ptr),size:ue(this._size),datatype:this._datatype});return p},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(p,w){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,x=this._size[0],b=this._size[1],C=Gc(p),E=function(N,S,I){return C===1?p(N):C===2?p(N,[S,I]):p(N,[S,I],v)};return g(this,0,x-1,0,b-1,E,w)};function g(p,w,v,x,b,C,E){var A=[],N=[],S=[],I=e,F=0;en(p._datatype)&&(I=t.find(e,[p._datatype,p._datatype])||e,F=t.convert(0,p._datatype));for(var O=function(at,vt,wt){at=C(at,vt,wt),I(at,F)||(A.push(at),N.push(vt))},L=x;L<=b;L++){S.push(A.length);var z=p._ptr[L],q=p._ptr[L+1];if(E)for(var W=z;W<q;W++){var P=p._index[W];P>=w&&P<=v&&O(p._values[W],P-w,L-x)}else{for(var Z={},Y=z;Y<q;Y++){var G=p._index[Y];Z[G]=p._values[Y]}for(var X=w;X<=v;X++){var ut=X in Z?Z[X]:0;O(ut,X-w,L-x)}}}return S.push(A.length),new n({values:A,index:N,ptr:S,size:[v-w+1,b-x+1]})}n.prototype.forEach=function(p,w){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,x=this._size[0],b=this._size[1],C=0;C<b;C++){var E=this._ptr[C],A=this._ptr[C+1];if(w)for(var N=E;N<A;N++){var S=this._index[N];p(this._values[N],[S,C],v)}else{for(var I={},F=E;F<A;F++){var O=this._index[F];I[O]=this._values[F]}for(var L=0;L<x;L++){var z=L in I?I[L]:0;p(z,[L,C],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var p=this._size[1],w=0;w<p;w++)for(var v=this._ptr[w],x=this._ptr[w+1],b=v;b<x;b++){var C=this._index[b];yield{value:this._values[b],index:[C,w]}}},n.prototype.toArray=function(){return y(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return y(this._values,this._index,this._ptr,this._size,!1)};function y(p,w,v,x,b){var C=x[0],E=x[1],A=[],N,S;for(N=0;N<C;N++)for(A[N]=[],S=0;S<E;S++)A[N][S]=0;for(S=0;S<E;S++)for(var I=v[S],F=v[S+1],O=I;O<F;O++)N=w[O],A[N][S]=p?b?ue(p[O]):p[O]:1;return A}return n.prototype.format=function(p){for(var w=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+de(w,p)+" x "+de(v,p)+"] density: "+de(x,p)+`
|
52
|
+
**/(function(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(v,x){if(isNaN(v=parseInt(v,10)))throw p();return v*x}function a(v,x){if(x===0)throw y();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var C=_(v,x);return b.n=v/C,b.d=x/C,b}function u(v){for(var x={},b=v,C=2,E=4;E<=b;){for(;b%C===0;)b/=C,x[C]=(x[C]||0)+1;E+=1+2*C++}return b!==v?b>1&&(x[b]=(x[b]||0)+1):x[v]=(x[v]||0)+1,x}var c=function(v,x){var b=0,C=1,E=1,A=0,N=0,S=0,I=1,F=1,O=0,L=1,z=1,q=1,W=1e7,R;if(v!=null)if(x!==void 0){if(b=v,C=x,E=b*C,b%1!==0||C%1!==0)throw w()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,C=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(C=v[1]);else throw p();E=b*C;break}case"number":{if(v<0&&(E=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(F=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=F);L<=W&&q<=W;)if(R=(O+z)/(L+q),v===R){L+q<=W?(b=O+z,C=L+q):q>L?(b=z,C=q):(b=O,C=L);break}else v>R?(O+=z,L+=q):(z+=O,q+=L),L>W?(b=z,C=q):(b=O,C=L);b*=F}else(isNaN(v)||isNaN(x))&&(C=b=NaN);break}case"string":{if(L=v.match(/\d+|./g),L===null)throw p();if(L[O]==="-"?(E=-1,O++):L[O]==="+"&&O++,L.length===O+1?N=s(L[O++],E):L[O+1]==="."||L[O]==="."?(L[O]!=="."&&(A=s(L[O++],E)),O++,(O+1===L.length||L[O+1]==="("&&L[O+3]===")"||L[O+1]==="'"&&L[O+3]==="'")&&(N=s(L[O],E),I=Math.pow(10,L[O].length),O++),(L[O]==="("&&L[O+2]===")"||L[O]==="'"&&L[O+2]==="'")&&(S=s(L[O+1],E),F=Math.pow(10,L[O+1].length)-1,O+=3)):L[O+1]==="/"||L[O+1]===":"?(N=s(L[O],E),I=s(L[O+2],1),O+=3):L[O+3]==="/"&&L[O+1]===" "&&(A=s(L[O],E),N=s(L[O+2],E),I=s(L[O+4],1),O+=5),L.length<=O){C=I*F,E=b=S+C*A+F*N;break}}default:throw p()}if(C===0)throw y();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(C)};function f(v,x,b){for(var C=1;x>0;v=v*v%b,x>>=1)x&1&&(C=C*v%b);return C}function d(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,C=1;b!==1;C++)if(b=b*10%x,C>r)return 0;return C}function h(v,x,b){for(var C=1,E=f(10,b,x),A=0;A<300;A++){if(C===E)return A;C=C*10%x,E=E*10%x}return 0}function _(v,x){if(!v)return x;if(!x)return v;for(;;){if(v%=x,!v)return x;if(x%=v,!x)return v}}function g(v,x){if(c(v,x),this instanceof g)v=_(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var y=function(){return new Error("Division by Zero")},p=function(){return new Error("Invalid argument")},w=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,x){return c(v,x),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,x){return c(v,x),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,x){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,x),n.n===0&&this.d===0)throw y();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,x){return c(v,x),a(_(n.n,this.n)*_(n.d,this.d),n.d*this.d)},lcm:function(v,x){return c(v,x),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,_(n.n,this.n)*_(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,x){if(c(v,x),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=u(this.n),C=u(this.d),E=1,A=1;for(var N in b)if(N!=="1"){if(N==="0"){E=0;break}if(b[N]*=n.n,b[N]%n.d===0)b[N]/=n.d;else return null;E*=Math.pow(N,b[N])}for(var N in C)if(N!=="1"){if(C[N]*=n.n,C[N]%n.d===0)C[N]/=n.d;else return null;A*=Math.pow(N,C[N])}return n.s<0?a(A,E):a(E,A)},equals:function(v,x){return c(v,x),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,x){c(v,x);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var x=this.abs(),b=x.toContinued(),C=1;C<b.length;C++){for(var E=a(b[C-1],1),A=C-2;A>=0;A--)E=E.inverse().add(b[A]);if(Math.abs(E.sub(x).valueOf())<v)return E.mul(this.s)}return this},divisible:function(v,x){return c(v,x),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var x,b="",C=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=C:(v&&(x=Math.floor(C/E))>0&&(b+=x,b+=" ",C%=E),b+=C,b+="/",b+=E),b},toLatex:function(v){var x,b="",C=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=C:(v&&(x=Math.floor(C/E))>0&&(b+=x,C%=E),b+="\\frac{",b+=C,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,C=[];if(isNaN(x)||isNaN(b))return C;do C.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return C},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var C=d(x,b),E=h(x,b,C),A=this.s<0?"-":"";if(A+=x/b|0,x%=b,x*=10,x&&(A+="."),C){for(var N=E;N--;)A+=x/b|0,x%=b,x*=10;A+="(";for(var N=C;N--;)A+=x/b|0,x%=b,x*=10;A+=")"}else for(var N=v;x&&N--;)A+=x/b|0,x%=b,x*=10;return A}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,i.exports=g})()})(Kc);var Wm=Kc.exports,dn=Kt(Wm),jm="Fraction",Ym=[],Vm=gt(jm,Ym,()=>(Object.defineProperty(dn,"name",{value:"Fraction"}),dn.prototype.constructor=dn,dn.prototype.type="Fraction",dn.prototype.isFraction=!0,dn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},dn.fromJSON=function(i){return new dn(i)},dn),{isClass:!0}),Hm="Matrix",Zm=[],Km=gt(Hm,Zm,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function Gc(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Gm="DenseMatrix",Jm=["Matrix"],Xm=gt(Gm,Jm,i=>{var{Matrix:t}=i;function e(d,h){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!en(h))throw new Error("Invalid datatype: "+h);if(we(d))d.type==="DenseMatrix"?(this._data=ue(d._data),this._size=ue(d._size),this._datatype=h||d._datatype):(this._data=d.toArray(),this._size=d.size(),this._datatype=h||d._datatype);else if(d&&Ae(d.data)&&Ae(d.size))this._data=d.data,this._size=d.size,Ec(this._data,this._size),this._datatype=h||d.datatype;else if(Ae(d))this._data=f(d),this._size=Ie(this._data),Ec(this._data,this._size),this._datatype=h;else{if(d)throw new TypeError("Unsupported type of data ("+Fn(d)+")");this._data=[],this._size=[0],this._datatype=h}}e.prototype=new t,e.prototype.createDenseMatrix=function(d,h){return new e(d,h)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Ls(this._data,Fn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(d,h){return new e(d,h)},e.prototype.subset=function(d,h,_){switch(arguments.length){case 1:return r(this,d);case 2:case 3:return s(this,d,h,_);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(d){if(!Ae(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new Jt(d.length,this._size.length);for(var h=0;h<d.length;h++)Me(d[h],this._size[h]);for(var _=this._data,g=0,y=d.length;g<y;g++){var p=d[g];Me(p,_.length),_=_[p]}return _},e.prototype.set=function(d,h,_){if(!Ae(d))throw new TypeError("Array expected");if(d.length<this._size.length)throw new Jt(d.length,this._size.length,"<");var g,y,p,w=d.map(function(x){return x+1});c(this,w,_);var v=this._data;for(g=0,y=d.length-1;g<y;g++)p=d[g],Me(p,v.length),v=v[p];return p=d[d.length-1],Me(p,v.length),v[p]=h,this};function r(d,h){if(!Ca(h))throw new TypeError("Invalid index");var _=h.isScalar();if(_)return d.get(h.min());var g=h.size();if(g.length!==d._size.length)throw new Jt(g.length,d._size.length);for(var y=h.min(),p=h.max(),w=0,v=d._size.length;w<v;w++)Me(y[w],d._size[w]),Me(p[w],d._size[w]);return new e(n(d._data,h,g.length,0),d._datatype)}function n(d,h,_,g){var y=g===_-1,p=h.dimension(g);return y?p.map(function(w){return Me(w,d.length),d[w]}).valueOf():p.map(function(w){Me(w,d.length);var v=d[w];return n(v,h,_,g+1)}).valueOf()}function s(d,h,_,g){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var y=h.size(),p=h.isScalar(),w;if(we(_)?(w=_.size(),_=_.valueOf()):w=Ie(_),p){if(w.length!==0)throw new TypeError("Scalar expected");d.set(h.min(),_,g)}else{if(!yi(w,y))try{w.length===0?_=Sc([_],y):_=Sc(_,y),w=Ie(_)}catch{}if(y.length<d._size.length)throw new Jt(y.length,d._size.length,"<");if(w.length<y.length){for(var v=0,x=0;y[v]===1&&w[v]===1;)v++;for(;y[v]===1;)x++,v++;_=Ac(_,y.length,x,w)}if(!yi(y,w))throw new Jt(y,w,">");var b=h.max().map(function(A){return A+1});c(d,b,g);var C=y.length,E=0;a(d._data,h,_,C,E)}return d}function a(d,h,_,g,y){var p=y===g-1,w=h.dimension(y);p?w.forEach(function(v,x){Me(v),d[v]=_[x[0]]}):w.forEach(function(v,x){Me(v),a(d[v],h,_[x[0]],g,y+1)})}e.prototype.resize=function(d,h,_){if(!ts(d))throw new TypeError("Array or Matrix expected");var g=d.valueOf().map(p=>Array.isArray(p)&&p.length===1?p[0]:p),y=_?this.clone():this;return u(y,g,h)};function u(d,h,_){if(h.length===0){for(var g=d._data;Ae(g);)g=g[0];return g}return d._size=h.slice(0),d._data=Sa(d._data,d._size,_),d}e.prototype.reshape=function(d,h){var _=h?this.clone():this;_._data=Ba(_._data,d);var g=_._size.reduce((y,p)=>y*p);return _._size=Ta(d,g),_};function c(d,h,_){for(var g=d._size.slice(0),y=!1;g.length<h.length;)g.push(0),y=!0;for(var p=0,w=h.length;p<w;p++)h[p]>g[p]&&(g[p]=h[p],y=!0);y&&u(d,g,_)}e.prototype.clone=function(){var d=new e({data:ue(this._data),size:ue(this._size),datatype:this._datatype});return d},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(d){var h=this,_=Gc(d),g=function w(v,x){return Ae(v)?v.map(function(b,C){return w(b,x.concat(C))}):_===1?d(v):_===2?d(v,x):d(v,x,h)},y=g(this._data,[]),p=this._datatype!==void 0?Ls(y,Fn):void 0;return new e(y,p)},e.prototype.forEach=function(d){var h=this,_=function g(y,p){Ae(y)?y.forEach(function(w,v){g(w,p.concat(v))}):d(y,p,h)};_(this._data,[])},e.prototype[Symbol.iterator]=function*(){var d=function*h(_,g){if(Ae(_))for(var y=0;y<_.length;y++)yield*h(_[y],g.concat(y));else yield{value:_,index:g}};yield*d(this._data,[])},e.prototype.rows=function(){var d=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var _=this._data;for(var g of _)d.push(new e([g],this._datatype));return d},e.prototype.columns=function(){var d=this,h=[],_=this.size();if(_.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,y=function(v){var x=g.map(b=>[b[v]]);h.push(new e(x,d._datatype))},p=0;p<_[1];p++)y(p);return h},e.prototype.toArray=function(){return ue(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(d){return de(this._data,d)},e.prototype.toString=function(){return de(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(d){if(d){if(Oe(d)&&(d=d.toNumber()),!me(d)||!xe(d))throw new TypeError("The parameter k must be an integer number")}else d=0;for(var h=d>0?d:0,_=d<0?-d:0,g=this._size[0],y=this._size[1],p=Math.min(g-_,y-h),w=[],v=0;v<p;v++)w[v]=this._data[v+_][v+h];return new e({data:w,size:[p],datatype:this._datatype})},e.diagonal=function(d,h,_,g){if(!Ae(d))throw new TypeError("Array expected, size parameter");if(d.length!==2)throw new Error("Only two dimensions matrix are supported");if(d=d.map(function(N){if(Oe(N)&&(N=N.toNumber()),!me(N)||!xe(N)||N<1)throw new Error("Size values must be positive integers");return N}),_){if(Oe(_)&&(_=_.toNumber()),!me(_)||!xe(_))throw new TypeError("The parameter k must be an integer number")}else _=0;var y=_>0?_:0,p=_<0?-_:0,w=d[0],v=d[1],x=Math.min(w-p,v-y),b;if(Ae(h)){if(h.length!==x)throw new Error("Invalid value array length");b=function(S){return h[S]}}else if(we(h)){var C=h.size();if(C.length!==1||C[0]!==x)throw new Error("Invalid matrix length");b=function(S){return h.get([S])}}else b=function(){return h};g||(g=Oe(b(0))?b(0).mul(0):0);var E=[];if(d.length>0){E=Sa(E,d,g);for(var A=0;A<x;A++)E[A+p][A+y]=b(A)}return new e({data:E,size:[w,v]})},e.fromJSON=function(d){return new e(d)},e.prototype.swapRows=function(d,h){if(!me(d)||!xe(d)||!me(h)||!xe(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Me(d,this._size[0]),Me(h,this._size[0]),e._swapRows(d,h,this._data),this},e._swapRows=function(d,h,_){var g=_[d];_[d]=_[h],_[h]=g};function f(d){return we(d)?f(d.valueOf()):Ae(d)?d.map(f):d}return e},{isClass:!0});function Qm(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(i[r][n]);s.push(a)}return s}function Vs(i){for(var t=0;t<i.length;t++)if(ts(i[t]))return!0;return!1}function ns(i,t){we(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?ns(n,t):t(n)}}function Kr(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Kr(r,t)}):t(i)}function Wa(i,t,e){var r=Array.isArray(i)?Ie(i):i.size();if(t<0||t>=r.length)throw new Nn(t,r.length);return we(i)?i.create(Hs(i.valueOf(),t,e)):Hs(i,t,e)}function Hs(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=Qm(i),n=[],r=0;r<a.length;r++)n[r]=Hs(a[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=Hs(i[r],t-1,e);return n}}var Jc="isInteger",tg=["typed"],eg=gt(Jc,tg,i=>{var{typed:t}=i;return t(Jc,{number:xe,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),Xc="number",Zs="number, number";function Qc(i){return Math.abs(i)}Qc.signature=Xc;function tf(i,t){return i+t}tf.signature=Zs;function ef(i,t){return i-t}ef.signature=Zs;function rf(i,t){return i*t}rf.signature=Zs;function nf(i){return-i}nf.signature=Xc;function sf(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}sf.signature=Zs;var of="number";function af(i){return i===0}af.signature=of;function uf(i){return Number.isNaN(i)}uf.signature=of;var lf="isNumeric",rg=["typed"],ng=gt(lf,rg,i=>{var{typed:t}=i;return t(lf,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),cf="isZero",ig=["typed"],sg=gt(cf,ig,i=>{var{typed:t}=i;return t(cf,{number:af,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),ff="isNaN",og=["typed"],ag=gt(ff,og,i=>{var{typed:t}=i;return t(ff,{number:uf,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 Kr(r,Number.isNaN)}})});function Ks(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function ug(i,t,e){return Qn(i.re,t.re,e)&&Qn(i.im,t.im,e)}var Gs=gt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Js="equalScalar",lg=["typed","config"],cg=gt(Js,lg,i=>{var{typed:t,config:e}=i,r=Gs({typed:t});return t(Js,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return Qn(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||Ks(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return ug(s,a,e.epsilon)}},r)});gt(Js,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Js,{"number, number":function(n,s){return Qn(n,s,e.epsilon)}})});var fg="SparseMatrix",hg=["typed","equalScalar","Matrix"],dg=gt(fg,hg,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(p,w){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(w&&!en(w))throw new Error("Invalid datatype: "+w);if(we(p))s(this,p,w);else if(p&&Ae(p.index)&&Ae(p.ptr)&&Ae(p.size))this._values=p.values,this._index=p.index,this._ptr=p.ptr,this._size=p.size,this._datatype=w||p.datatype;else if(Ae(p))a(this,p,w);else{if(p)throw new TypeError("Unsupported type of data ("+Fn(p)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=w}}function s(p,w,v){w.type==="SparseMatrix"?(p._values=w._values?ue(w._values):void 0,p._index=ue(w._index),p._ptr=ue(w._ptr),p._size=ue(w._size),p._datatype=v||w._datatype):a(p,w.valueOf(),v||w._datatype)}function a(p,w,v){p._values=[],p._index=[],p._ptr=[],p._datatype=v;var x=w.length,b=0,C=e,E=0;if(en(v)&&(C=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var A=0;do{p._ptr.push(p._index.length);for(var N=0;N<x;N++){var S=w[N];if(Ae(S)){if(A===0&&b<S.length&&(b=S.length),A<S.length){var I=S[A];C(I,E)||(p._values.push(I),p._index.push(N))}}else A===0&&b<1&&(b=1),C(S,E)||(p._values.push(S),p._index.push(N))}A++}while(A<b)}p._ptr.push(p._index.length),p._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(p,w){return new n(p,w)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Ls(this._values,Fn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(p,w){return new n(p,w)},n.prototype.density=function(){var p=this._size[0],w=this._size[1];return p!==0&&w!==0?this._index.length/(p*w):0},n.prototype.subset=function(p,w,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return u(this,p);case 2:case 3:return c(this,p,w,v);default:throw new SyntaxError("Wrong number of arguments")}};function u(p,w){if(!Ca(w))throw new TypeError("Invalid index");var v=w.isScalar();if(v)return p.get(w.min());var x=w.size();if(x.length!==p._size.length)throw new Jt(x.length,p._size.length);var b,C,E,A,N=w.min(),S=w.max();for(b=0,C=p._size.length;b<C;b++)Me(N[b],p._size[b]),Me(S[b],p._size[b]);var I=p._values,F=p._index,O=p._ptr,L=w.dimension(0),z=w.dimension(1),q=[],W=[];L.forEach(function(G,Q){W[G]=Q[0],q[G]=!0});var R=I?[]:void 0,Z=[],Y=[];return z.forEach(function(G){for(Y.push(Z.length),E=O[G],A=O[G+1];E<A;E++)b=F[E],q[b]===!0&&(Z.push(W[b]),R&&R.push(I[E]))}),Y.push(Z.length),new n({values:R,index:Z,ptr:Y,size:x,datatype:p._datatype})}function c(p,w,v,x){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),C=w.isScalar(),E;if(we(v)?(E=v.size(),v=v.toArray()):E=Ie(v),C){if(E.length!==0)throw new TypeError("Scalar expected");p.set(w.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Jt(b.length,p._size.length,"<");if(E.length<b.length){for(var A=0,N=0;b[A]===1&&E[A]===1;)A++;for(;b[A]===1;)N++,A++;v=Ac(v,b.length,N,E)}if(!yi(b,E))throw new Jt(b,E,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(O,L){Me(O),p.set([O,0],v[L[0]],x)})}else{var I=w.dimension(0),F=w.dimension(1);I.forEach(function(O,L){Me(O),F.forEach(function(z,q){Me(z),p.set([O,z],v[L[0]][q[0]],x)})})}}return p}n.prototype.get=function(p){if(!Ae(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Jt(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var w=p[0],v=p[1];Me(w,this._size[0]),Me(v,this._size[1]);var x=f(w,this._ptr[v],this._ptr[v+1],this._index);return x<this._ptr[v+1]&&this._index[x]===w?this._values[x]:0},n.prototype.set=function(p,w,v){if(!Ae(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Jt(p.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=p[0],b=p[1],C=this._size[0],E=this._size[1],A=e,N=0;en(this._datatype)&&(A=t.find(e,[this._datatype,this._datatype])||e,N=t.convert(0,this._datatype)),(x>C-1||b>E-1)&&(_(this,Math.max(x+1,C),Math.max(b+1,E),v),C=this._size[0],E=this._size[1]),Me(x,C),Me(b,E);var S=f(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?A(w,N)?d(S,b,this._values,this._index,this._ptr):this._values[S]=w:A(w,N)||h(S,x,b,w,this._values,this._index,this._ptr),this};function f(p,w,v,x){if(v-w===0)return v;for(var b=w;b<v;b++)if(x[b]===p)return b;return w}function d(p,w,v,x,b){v.splice(p,1),x.splice(p,1);for(var C=w+1;C<b.length;C++)b[C]--}function h(p,w,v,x,b,C,E){b.splice(p,0,x),C.splice(p,0,w);for(var A=v+1;A<E.length;A++)E[A]++}n.prototype.resize=function(p,w,v){if(!ts(p))throw new TypeError("Array or Matrix expected");var x=p.valueOf().map(C=>Array.isArray(C)&&C.length===1?C[0]:C);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(C){if(!me(C)||!xe(C)||C<0)throw new TypeError("Invalid size, must contain positive integers (size: "+de(x)+")")});var b=v?this.clone():this;return _(b,x[0],x[1],w)};function _(p,w,v,x){var b=x||0,C=e,E=0;en(p._datatype)&&(C=t.find(e,[p._datatype,p._datatype])||e,E=t.convert(0,p._datatype),b=t.convert(b,p._datatype));var A=!C(b,E),N=p._size[0],S=p._size[1],I,F,O;if(v>S){for(F=S;F<v;F++)if(p._ptr[F]=p._values.length,A)for(I=0;I<N;I++)p._values.push(b),p._index.push(I);p._ptr[v]=p._values.length}else v<S&&(p._ptr.splice(v+1,S-v),p._values.splice(p._ptr[v],p._values.length),p._index.splice(p._ptr[v],p._index.length));if(S=v,w>N){if(A){var L=0;for(F=0;F<S;F++){p._ptr[F]=p._ptr[F]+L,O=p._ptr[F+1]+L;var z=0;for(I=N;I<w;I++,z++)p._values.splice(O+z,0,b),p._index.splice(O+z,0,I),L++}p._ptr[S]=p._values.length}}else if(w<N){var q=0;for(F=0;F<S;F++){p._ptr[F]=p._ptr[F]-q;var W=p._ptr[F],R=p._ptr[F+1]-q;for(O=W;O<R;O++)I=p._index[O],I>w-1&&(p._values.splice(O,1),p._index.splice(O,1),q++)}p._ptr[F]=p._values.length}return p._size[0]=w,p._size[1]=v,p}n.prototype.reshape=function(p,w){if(!Ae(p))throw new TypeError("Array expected");if(p.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");p.forEach(function(G){if(!me(G)||!xe(G)||G<=-2||G===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+de(p)+")")});var v=this._size[0]*this._size[1];p=Ta(p,v);var x=p[0]*p[1];if(v!==x)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=w?this.clone():this;if(this._size[0]===p[0]&&this._size[1]===p[1])return b;for(var C=[],E=0;E<b._ptr.length;E++)for(var A=0;A<b._ptr[E+1]-b._ptr[E];A++)C.push(E);for(var N=b._values.slice(),S=b._index.slice(),I=0;I<b._index.length;I++){var F=S[I],O=C[I],L=F*b._size[1]+O;C[I]=L%p[1],S[I]=Math.floor(L/p[1])}b._values.length=0,b._index.length=0,b._ptr.length=p[1]+1,b._size=p.slice();for(var z=0;z<b._ptr.length;z++)b._ptr[z]=0;for(var q=0;q<N.length;q++){var W=S[q],R=C[q],Z=N[q],Y=f(W,b._ptr[R],b._ptr[R+1],b._index);h(Y,W,R,Z,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var p=new n({values:this._values?ue(this._values):void 0,index:ue(this._index),ptr:ue(this._ptr),size:ue(this._size),datatype:this._datatype});return p},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(p,w){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,x=this._size[0],b=this._size[1],C=Gc(p),E=function(N,S,I){return C===1?p(N):C===2?p(N,[S,I]):p(N,[S,I],v)};return g(this,0,x-1,0,b-1,E,w)};function g(p,w,v,x,b,C,E){var A=[],N=[],S=[],I=e,F=0;en(p._datatype)&&(I=t.find(e,[p._datatype,p._datatype])||e,F=t.convert(0,p._datatype));for(var O=function(at,vt,wt){at=C(at,vt,wt),I(at,F)||(A.push(at),N.push(vt))},L=x;L<=b;L++){S.push(A.length);var z=p._ptr[L],q=p._ptr[L+1];if(E)for(var W=z;W<q;W++){var R=p._index[W];R>=w&&R<=v&&O(p._values[W],R-w,L-x)}else{for(var Z={},Y=z;Y<q;Y++){var G=p._index[Y];Z[G]=p._values[Y]}for(var Q=w;Q<=v;Q++){var ut=Q in Z?Z[Q]:0;O(ut,Q-w,L-x)}}}return S.push(A.length),new n({values:A,index:N,ptr:S,size:[v-w+1,b-x+1]})}n.prototype.forEach=function(p,w){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,x=this._size[0],b=this._size[1],C=0;C<b;C++){var E=this._ptr[C],A=this._ptr[C+1];if(w)for(var N=E;N<A;N++){var S=this._index[N];p(this._values[N],[S,C],v)}else{for(var I={},F=E;F<A;F++){var O=this._index[F];I[O]=this._values[F]}for(var L=0;L<x;L++){var z=L in I?I[L]:0;p(z,[L,C],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var p=this._size[1],w=0;w<p;w++)for(var v=this._ptr[w],x=this._ptr[w+1],b=v;b<x;b++){var C=this._index[b];yield{value:this._values[b],index:[C,w]}}},n.prototype.toArray=function(){return y(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return y(this._values,this._index,this._ptr,this._size,!1)};function y(p,w,v,x,b){var C=x[0],E=x[1],A=[],N,S;for(N=0;N<C;N++)for(A[N]=[],S=0;S<E;S++)A[N][S]=0;for(S=0;S<E;S++)for(var I=v[S],F=v[S+1],O=I;O<F;O++)N=w[O],A[N][S]=p?b?ue(p[O]):p[O]:1;return A}return n.prototype.format=function(p){for(var w=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+de(w,p)+" x "+de(v,p)+"] density: "+de(x,p)+`
|
53
53
|
`,C=0;C<v;C++)for(var E=this._ptr[C],A=this._ptr[C+1],N=E;N<A;N++){var S=this._index[N];b+=`
|
54
|
-
(`+de(S,p)+", "+de(C,p)+") ==> "+(this._values?de(this._values[N],p):"X")}return b},n.prototype.toString=function(){return de(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(p){if(p){if(Oe(p)&&(p=p.toNumber()),!me(p)||!xe(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var w=p>0?p:0,v=p<0?-p:0,x=this._size[0],b=this._size[1],C=Math.min(x-v,b-w),E=[],A=[],N=[];N[0]=0;for(var S=w;S<b&&E.length<C;S++)for(var I=this._ptr[S],F=this._ptr[S+1],O=I;O<F;O++){var L=this._index[O];if(L===S-w+v){E.push(this._values[O]),A[E.length-1]=L-v;break}}return N.push(E.length),new n({values:E,index:A,ptr:N,size:[C,1]})},n.fromJSON=function(p){return new n(p)},n.diagonal=function(p,w,v,x,b){if(!Ae(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function(G){if(Oe(G)&&(G=G.toNumber()),!me(G)||!xe(G)||G<1)throw new Error("Size values must be positive integers");return G}),v){if(Oe(v)&&(v=v.toNumber()),!me(v)||!xe(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var C=e,E=0;en(b)&&(C=t.find(e,[b,b])||e,E=t.convert(0,b));var A=v>0?v:0,N=v<0?-v:0,S=p[0],I=p[1],F=Math.min(S-N,I-A),O;if(Ae(w)){if(w.length!==F)throw new Error("Invalid value array length");O=function(X){return w[X]}}else if(we(w)){var L=w.size();if(L.length!==1||L[0]!==F)throw new Error("Invalid matrix length");O=function(X){return w.get([X])}}else O=function(){return w};for(var z=[],q=[],W=[],P=0;P<I;P++){W.push(z.length);var Z=P-A;if(Z>=0&&Z<F){var Y=O(Z);C(Y,E)||(q.push(Z+N),z.push(Y))}}return W.push(z.length),new n({values:z,index:q,ptr:W,size:[S,I]})},n.prototype.swapRows=function(p,w){if(!me(p)||!xe(p)||!me(w)||!xe(w))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Me(p,this._size[0]),Me(w,this._size[0]),n._swapRows(p,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(p,w,v,x,b){for(var C=x[p],E=x[p+1],A=C;A<E;A++)b(v[A],w[A])},n._swapRows=function(p,w,v,x,b,C){for(var E=0;E<v;E++){var A=C[E],N=C[E+1],S=f(p,A,N,b),I=f(w,A,N,b);if(S<N&&I<N&&b[S]===p&&b[I]===w){if(x){var F=x[S];x[S]=x[I],x[I]=F}continue}if(S<N&&b[S]===p&&(I>=N||b[I]!==w)){var O=x?x[S]:void 0;b.splice(I,0,w),x&&x.splice(I,0,O),b.splice(I<=S?S+1:S,1),x&&x.splice(I<=S?S+1:S,1);continue}if(I<N&&b[I]===w&&(S>=N||b[S]!==p)){var L=x?x[I]:void 0;b.splice(S,0,p),x&&x.splice(S,0,L),b.splice(S<=I?I+1:I,1),x&&x.splice(S<=I?I+1:I,1)}}},n},{isClass:!0}),_g="number",pg=["typed"];function mg(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function gg(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var vg=gt(_g,pg,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=mg(n);if(s)return gg(s);var a=0,u=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);u&&(a=Number(u[2]),n=u[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(u){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Kr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),yg="bignumber",wg=["typed","BigNumber"],Dg=gt(yg,wg,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],u=e(s[1]),c=new e(2).pow(Number(a));if(u.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var f=new e(2).pow(Number(a)-1);return u.gte(f)?u.sub(c):u}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Kr(n,r))})}),bg="fraction",xg=["typed","Fraction"],Eg=gt(bg,xg,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Kr(n,r))})}),hf="matrix",Cg=["typed","Matrix","DenseMatrix","SparseMatrix"],Ag=gt(hf,Cg,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(hf,{"":function(){return s([])},string:function(u){return s([],u)},"string, string":function(u,c){return s([],u,c)},Array:function(u){return s(u)},Matrix:function(u){return s(u,u.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,u,c){if(u==="dense"||u==="default"||u===void 0)return new r(a,c);if(u==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(u)+".")}}),df="unaryMinus",Mg=["typed"],Fg=gt(df,Mg,i=>{var{typed:t}=i;return t(df,{number:nf,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),_f="abs",Ng=["typed"],Sg=gt(_f,Ng,i=>{var{typed:t}=i;return t(_f,{number:Qc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),pf="addScalar",Og=["typed"],Bg=gt(pf,Og,i=>{var{typed:t}=i;return t(pf,{"number, number":tf,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),mf="subtractScalar",Tg=["typed"],Ig=gt(mf,Tg,i=>{var{typed:t}=i;return t(mf,{"number, number":ef,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),$g="matAlgo11xS0s",Lg=["typed","equalScalar"],ja=gt($g,Lg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,u){var c=n._values,f=n._index,d=n._ptr,h=n._size,_=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],y=h[1],p,w=e,v=0,x=a;typeof _=="string"&&(p=_,w=t.find(e,[p,p]),v=t.convert(0,p),s=t.convert(s,p),x=t.find(a,[p,p]));for(var b=[],C=[],E=[],A=0;A<y;A++){E[A]=C.length;for(var N=d[A],S=d[A+1],I=N;I<S;I++){var F=f[I],O=u?x(s,c[I]):x(c[I],s);w(O,v)||(C.push(F),b.push(O))}}return E[y]=C.length,n.createSparseMatrix({values:b,index:C,ptr:E,size:[g,y],datatype:p})}}),Rg="matAlgo12xSfs",Pg=["typed","DenseMatrix"],Ci=gt(Rg,Pg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,u){var c=n._values,f=n._index,d=n._ptr,h=n._size,_=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],y=h[1],p,w=a;typeof _=="string"&&(p=_,s=t.convert(s,p),w=t.find(a,[p,p]));for(var v=[],x=[],b=[],C=0;C<y;C++){for(var E=C+1,A=d[C],N=d[C+1],S=A;S<N;S++){var I=f[S];x[I]=c[S],b[I]=E}for(var F=0;F<g;F++)C===0&&(v[F]=[]),b[F]===E?v[F][C]=u?w(s,x[F]):w(x[F],s):v[F][C]=u?w(s,0):w(0,s)}return new e({data:v,size:[g,y],datatype:p})}}),kg="matAlgo14xDs",zg=["typed"],Ya=gt(kg,zg,i=>{var{typed:t}=i;return function(n,s,a,u){var c=n._data,f=n._size,d=n._datatype,h,_=a;typeof d=="string"&&(h=d,s=t.convert(s,h),_=t.find(a,[h,h]));var g=f.length>0?e(_,0,f,f[0],c,s,u):[];return n.createDenseMatrix({data:g,size:ue(f),datatype:h})};function e(r,n,s,a,u,c,f){var d=[];if(n===s.length-1)for(var h=0;h<a;h++)d[h]=f?r(c,u[h]):r(u[h],c);else for(var _=0;_<a;_++)d[_]=e(r,n+1,s,s[n+1],u[_],c,f);return d}}),qg="matAlgo02xDS0",Ug=["typed","equalScalar"],Wg=gt(qg,Ug,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,u){var c=n._data,f=n._size,d=n._datatype||n.getDataType(),h=s._values,_=s._index,g=s._ptr,y=s._size,p=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(f.length!==y.length)throw new Jt(f.length,y.length);if(f[0]!==y[0]||f[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+y+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=f[0],v=f[1],x,b=e,C=0,E=a;typeof d=="string"&&d===p&&d!=="mixed"&&(x=d,b=t.find(e,[x,x]),C=t.convert(0,x),E=t.find(a,[x,x]));for(var A=[],N=[],S=[],I=0;I<v;I++){S[I]=N.length;for(var F=g[I],O=g[I+1],L=F;L<O;L++){var z=_[L],q=u?E(h[L],c[z][I]):E(c[z][I],h[L]);b(q,C)||(N.push(z),A.push(q))}}return S[v]=N.length,s.createSparseMatrix({values:A,index:N,ptr:S,size:[w,v],datatype:d===n._datatype&&p===s._datatype?x:void 0})}}),jg="matAlgo03xDSf",Yg=["typed"],Ai=gt(jg,Yg,i=>{var{typed:t}=i;return function(r,n,s,a){var u=r._data,c=r._size,f=r._datatype||r.getDataType(),d=n._values,h=n._index,_=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Jt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=c[0],w=c[1],v,x=0,b=s;typeof f=="string"&&f===y&&f!=="mixed"&&(v=f,x=t.convert(0,v),b=t.find(s,[v,v]));for(var C=[],E=0;E<p;E++)C[E]=[];for(var A=[],N=[],S=0;S<w;S++){for(var I=S+1,F=_[S],O=_[S+1],L=F;L<O;L++){var z=h[L];A[z]=a?b(d[L],u[z][S]):b(u[z][S],d[L]),N[z]=I}for(var q=0;q<p;q++)N[q]===I?C[q][S]=A[q]:C[q][S]=a?b(x,u[q][S]):b(u[q][S],x)}return r.createDenseMatrix({data:C,size:[p,w],datatype:f===r._datatype&&y===n._datatype?v:void 0})}}),Vg="matAlgo05xSfSf",Hg=["typed","equalScalar"],gf=gt(Vg,Hg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var u=n._values,c=n._index,f=n._ptr,d=n._size,h=n._datatype||n._data===void 0?n._datatype:n.getDataType(),_=s._values,g=s._index,y=s._ptr,p=s._size,w=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==p.length)throw new Jt(d.length,p.length);if(d[0]!==p[0]||d[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+p+")");var v=d[0],x=d[1],b,C=e,E=0,A=a;typeof h=="string"&&h===w&&h!=="mixed"&&(b=h,C=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var N=u&&_?[]:void 0,S=[],I=[],F=N?[]:void 0,O=N?[]:void 0,L=[],z=[],q,W,P,Z;for(W=0;W<x;W++){I[W]=S.length;var Y=W+1;for(P=f[W],Z=f[W+1];P<Z;P++)q=c[P],S.push(q),L[q]=Y,F&&(F[q]=u[P]);for(P=y[W],Z=y[W+1];P<Z;P++)q=g[P],L[q]!==Y&&S.push(q),z[q]=Y,O&&(O[q]=_[P]);if(N)for(P=I[W];P<S.length;){q=S[P];var G=L[q],X=z[q];if(G===Y||X===Y){var ut=G===Y?F[q]:E,_t=X===Y?O[q]:E,at=A(ut,_t);C(at,E)?S.splice(P,1):(N.push(at),P++)}}}return I[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:I,size:[v,x],datatype:h===n._datatype&&w===s._datatype?b:void 0})}}),Zg="matAlgo13xDD",Kg=["typed"],Gg=gt(Zg,Kg,i=>{var{typed:t}=i;return function(n,s,a){var u=n._data,c=n._size,f=n._datatype,d=s._data,h=s._size,_=s._datatype,g=[];if(c.length!==h.length)throw new Jt(c.length,h.length);for(var y=0;y<c.length;y++){if(c[y]!==h[y])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");g[y]=c[y]}var p,w=a;typeof f=="string"&&f===_&&(p=f,w=t.find(a,[p,p]));var v=g.length>0?e(w,0,g,g[0],u,d):[];return n.createDenseMatrix({data:v,size:g,datatype:p})};function e(r,n,s,a,u,c){var f=[];if(n===s.length-1)for(var d=0;d<a;d++)f[d]=r(u[d],c[d]);else for(var h=0;h<a;h++)f[h]=e(r,n+1,s,s[n+1],u[h],c[h]);return f}}),Jg="broadcast",Xg=["concat"],Qg=gt(Jg,Xg,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((y,p)=>y===s._size[p]))return[n,s];for(var u=e(n._size,a,0),c=e(s._size,a,0),f=[],d=0;d<a;d++)f[d]=Math.max(u[d],c[d]);Rs(u,f),Rs(c,f);var h=n.clone(),_=s.clone();h._size.length<a?h.reshape(e(h._size,a,1)):_._size.length<a&&_.reshape(e(_._size,a,1));for(var g=0;g<a;g++)h._size[g]<f[g]&&(h=r(h,f[g],g)),_._size[g]<f[g]&&(_=r(_,f[g],g));return[h,_]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),tv="matrixAlgorithmSuite",ev=["typed","matrix","concat"],ti=gt(tv,ev,i=>{var{typed:t,matrix:e,concat:r}=i,n=Gg({typed:t}),s=Ya({typed:t}),a=Qg({concat:r});return function(c){var f=c.elop,d=c.SD||c.DS,h;f?(h={"DenseMatrix, DenseMatrix":(p,w)=>n(...a(p,w),f),"Array, Array":(p,w)=>n(...a(e(p),e(w)),f).valueOf(),"Array, DenseMatrix":(p,w)=>n(...a(e(p),w),f),"DenseMatrix, Array":(p,w)=>n(...a(p,e(w)),f)},c.SS&&(h["SparseMatrix, SparseMatrix"]=(p,w)=>c.SS(...a(p,w),f,!1)),c.DS&&(h["DenseMatrix, SparseMatrix"]=(p,w)=>c.DS(...a(p,w),f,!1),h["Array, SparseMatrix"]=(p,w)=>c.DS(...a(e(p),w),f,!1)),d&&(h["SparseMatrix, DenseMatrix"]=(p,w)=>d(...a(w,p),f,!0),h["SparseMatrix, Array"]=(p,w)=>d(...a(e(w),p),f,!0))):(h={"DenseMatrix, DenseMatrix":t.referToSelf(p=>(w,v)=>n(...a(w,v),p)),"Array, Array":t.referToSelf(p=>(w,v)=>n(...a(e(w),e(v)),p).valueOf()),"Array, DenseMatrix":t.referToSelf(p=>(w,v)=>n(...a(e(w),v),p)),"DenseMatrix, Array":t.referToSelf(p=>(w,v)=>n(...a(w,e(v)),p))},c.SS&&(h["SparseMatrix, SparseMatrix"]=t.referToSelf(p=>(w,v)=>c.SS(...a(w,v),p,!1))),c.DS&&(h["DenseMatrix, SparseMatrix"]=t.referToSelf(p=>(w,v)=>c.DS(...a(w,v),p,!1)),h["Array, SparseMatrix"]=t.referToSelf(p=>(w,v)=>c.DS(...a(e(w),v),p,!1))),d&&(h["SparseMatrix, DenseMatrix"]=t.referToSelf(p=>(w,v)=>d(...a(v,w),p,!0)),h["SparseMatrix, Array"]=t.referToSelf(p=>(w,v)=>d(...a(e(v),w),p,!0))));var _=c.scalar||"any",g=c.Ds||c.Ss;g&&(f?(h["DenseMatrix,"+_]=(p,w)=>s(p,w,f,!1),h[_+", DenseMatrix"]=(p,w)=>s(w,p,f,!0),h["Array,"+_]=(p,w)=>s(e(p),w,f,!1).valueOf(),h[_+", Array"]=(p,w)=>s(e(w),p,f,!0).valueOf()):(h["DenseMatrix,"+_]=t.referToSelf(p=>(w,v)=>s(w,v,p,!1)),h[_+", DenseMatrix"]=t.referToSelf(p=>(w,v)=>s(v,w,p,!0)),h["Array,"+_]=t.referToSelf(p=>(w,v)=>s(e(w),v,p,!1).valueOf()),h[_+", Array"]=t.referToSelf(p=>(w,v)=>s(e(v),w,p,!0).valueOf())));var y=c.sS!==void 0?c.sS:c.Ss;return f?(c.Ss&&(h["SparseMatrix,"+_]=(p,w)=>c.Ss(p,w,f,!1)),y&&(h[_+", SparseMatrix"]=(p,w)=>y(w,p,f,!0))):(c.Ss&&(h["SparseMatrix,"+_]=t.referToSelf(p=>(w,v)=>c.Ss(w,v,p,!1))),y&&(h[_+", SparseMatrix"]=t.referToSelf(p=>(w,v)=>y(v,w,p,!0)))),f&&f.signatures&&lc(h,f.signatures),h}}),rv="matAlgo01xDSid",nv=["typed"],vf=gt(rv,nv,i=>{var{typed:t}=i;return function(r,n,s,a){var u=r._data,c=r._size,f=r._datatype||r.getDataType(),d=n._values,h=n._index,_=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Jt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=c[0],w=c[1],v=typeof f=="string"&&f!=="mixed"&&f===y?f:void 0,x=v?t.find(s,[v,v]):s,b,C,E=[];for(b=0;b<p;b++)E[b]=[];var A=[],N=[];for(C=0;C<w;C++){for(var S=C+1,I=_[C],F=_[C+1],O=I;O<F;O++)b=h[O],A[b]=a?x(d[O],u[b][C]):x(u[b][C],d[O]),N[b]=S;for(b=0;b<p;b++)N[b]===S?E[b][C]=A[b]:E[b][C]=u[b][C]}return r.createDenseMatrix({data:E,size:[p,w],datatype:f===r._datatype&&y===n._datatype?v:void 0})}}),iv="matAlgo04xSidSid",sv=["typed","equalScalar"],ov=gt(iv,sv,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var u=n._values,c=n._index,f=n._ptr,d=n._size,h=n._datatype||n._data===void 0?n._datatype:n.getDataType(),_=s._values,g=s._index,y=s._ptr,p=s._size,w=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==p.length)throw new Jt(d.length,p.length);if(d[0]!==p[0]||d[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+p+")");var v=d[0],x=d[1],b,C=e,E=0,A=a;typeof h=="string"&&h===w&&h!=="mixed"&&(b=h,C=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var N=u&&_?[]:void 0,S=[],I=[],F=u&&_?[]:void 0,O=u&&_?[]:void 0,L=[],z=[],q,W,P,Z,Y;for(W=0;W<x;W++){I[W]=S.length;var G=W+1;for(Z=f[W],Y=f[W+1],P=Z;P<Y;P++)q=c[P],S.push(q),L[q]=G,F&&(F[q]=u[P]);for(Z=y[W],Y=y[W+1],P=Z;P<Y;P++)if(q=g[P],L[q]===G){if(F){var X=A(F[q],_[P]);C(X,E)?L[q]=null:F[q]=X}}else S.push(q),z[q]=G,O&&(O[q]=_[P]);if(F&&O)for(P=I[W];P<S.length;)q=S[P],L[q]===G?(N[P]=F[q],P++):z[q]===G?(N[P]=O[q],P++):S.splice(P,1)}return I[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:I,size:[v,x],datatype:h===n._datatype&&w===s._datatype?b:void 0})}}),av="matAlgo10xSids",uv=["typed","DenseMatrix"],yf=gt(av,uv,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,u){var c=n._values,f=n._index,d=n._ptr,h=n._size,_=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],y=h[1],p,w=a;typeof _=="string"&&(p=_,s=t.convert(s,p),w=t.find(a,[p,p]));for(var v=[],x=[],b=[],C=0;C<y;C++){for(var E=C+1,A=d[C],N=d[C+1],S=A;S<N;S++){var I=f[S];x[I]=c[S],b[I]=E}for(var F=0;F<g;F++)C===0&&(v[F]=[]),b[F]===E?v[F][C]=u?w(s,x[F]):w(x[F],s):v[F][C]=s}return new e({data:v,size:[g,y],datatype:p})}}),lv="multiplyScalar",cv=["typed"],fv=gt(lv,cv,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":rf,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),wf="multiply",hv=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],dv=gt(wf,hv,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,u=ja({typed:t,equalScalar:s}),c=Ya({typed:t});function f(E,A){switch(E.length){case 1:switch(A.length){case 1:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+E[0]+") must match Matrix rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;case 2:switch(A.length){case 1:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+E[1]+") must match Vector length ("+A[0]+")");break;case 2:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+E[1]+") must match Matrix B rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+E.length+" dimensions)")}}function d(E,A,N){if(N===0)throw new Error("Cannot multiply two empty vectors");return a(E,A)}function h(E,A){if(A.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return _(E,A)}function _(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._data,O=A._size,L=A._datatype||A.getDataType(),z=S[0],q=O[1],W,P=r,Z=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&(W=I,P=t.find(r,[W,W]),Z=t.find(n,[W,W]));for(var Y=[],G=0;G<q;G++){for(var X=Z(N[0],F[0][G]),ut=1;ut<z;ut++)X=P(X,Z(N[ut],F[ut][G]));Y[G]=X}return E.createDenseMatrix({data:Y,size:[q],datatype:I===E._datatype&&L===A._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":p,"SparseMatrix, any":x}),y=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":C});function p(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._data,O=A._datatype||A.getDataType(),L=S[0],z=S[1],q,W=r,P=n;I&&O&&I===O&&typeof I=="string"&&I!=="mixed"&&(q=I,W=t.find(r,[q,q]),P=t.find(n,[q,q]));for(var Z=[],Y=0;Y<L;Y++){for(var G=N[Y],X=P(G[0],F[0]),ut=1;ut<z;ut++)X=W(X,P(G[ut],F[ut]));Z[Y]=X}return E.createDenseMatrix({data:Z,size:[L],datatype:I===E._datatype&&O===A._datatype?q:void 0})}function w(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._data,O=A._size,L=A._datatype||A.getDataType(),z=S[0],q=S[1],W=O[1],P,Z=r,Y=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&I!=="mixed"&&(P=I,Z=t.find(r,[P,P]),Y=t.find(n,[P,P]));for(var G=[],X=0;X<z;X++){var ut=N[X];G[X]=[];for(var _t=0;_t<W;_t++){for(var at=Y(ut[0],F[0][_t]),vt=1;vt<q;vt++)at=Z(at,Y(ut[vt],F[vt][_t]));G[X][_t]=at}}return E.createDenseMatrix({data:G,size:[z,W],datatype:I===E._datatype&&L===A._datatype?P:void 0})}function v(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._values,O=A._index,L=A._ptr,z=A._size,q=A._datatype||A._data===void 0?A._datatype:A.getDataType();if(!F)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],P=z[1],Z,Y=r,G=n,X=s,ut=0;I&&q&&I===q&&typeof I=="string"&&I!=="mixed"&&(Z=I,Y=t.find(r,[Z,Z]),G=t.find(n,[Z,Z]),X=t.find(s,[Z,Z]),ut=t.convert(0,Z));for(var _t=[],at=[],vt=[],wt=A.createSparseMatrix({values:_t,index:at,ptr:vt,size:[W,P],datatype:I===E._datatype&&q===A._datatype?Z:void 0}),Ct=0;Ct<P;Ct++){vt[Ct]=at.length;var bt=L[Ct],re=L[Ct+1];if(re>bt)for(var Bt=0,Nt=0;Nt<W;Nt++){for(var he=Nt+1,se=void 0,qt=bt;qt<re;qt++){var Xt=O[qt];Bt!==he?(se=G(N[Nt][Xt],F[qt]),Bt=he):se=Y(se,G(N[Nt][Xt],F[qt]))}Bt===he&&!X(se,ut)&&(at.push(Nt),_t.push(se))}}return vt[P]=at.length,wt}function x(E,A){var N=E._values,S=E._index,I=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,L=A._datatype||A.getDataType(),z=E._size[0],q=A._size[0],W=[],P=[],Z=[],Y,G=r,X=n,ut=s,_t=0;F&&L&&F===L&&typeof F=="string"&&F!=="mixed"&&(Y=F,G=t.find(r,[Y,Y]),X=t.find(n,[Y,Y]),ut=t.find(s,[Y,Y]),_t=t.convert(0,Y));var at=[],vt=[];Z[0]=0;for(var wt=0;wt<q;wt++){var Ct=O[wt];if(!ut(Ct,_t))for(var bt=I[wt],re=I[wt+1],Bt=bt;Bt<re;Bt++){var Nt=S[Bt];vt[Nt]?at[Nt]=G(at[Nt],X(Ct,N[Bt])):(vt[Nt]=!0,P.push(Nt),at[Nt]=X(Ct,N[Bt]))}}for(var he=P.length,se=0;se<he;se++){var qt=P[se];W[se]=at[qt]}return Z[1]=P.length,E.createSparseMatrix({values:W,index:P,ptr:Z,size:[z,1],datatype:F===E._datatype&&L===A._datatype?Y:void 0})}function b(E,A){var N=E._values,S=E._index,I=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,L=A._datatype||A.getDataType(),z=E._size[0],q=A._size[0],W=A._size[1],P,Z=r,Y=n,G=s,X=0;F&&L&&F===L&&typeof F=="string"&&F!=="mixed"&&(P=F,Z=t.find(r,[P,P]),Y=t.find(n,[P,P]),G=t.find(s,[P,P]),X=t.convert(0,P));for(var ut=[],_t=[],at=[],vt=E.createSparseMatrix({values:ut,index:_t,ptr:at,size:[z,W],datatype:F===E._datatype&&L===A._datatype?P:void 0}),wt=[],Ct=[],bt=0;bt<W;bt++){at[bt]=_t.length;for(var re=bt+1,Bt=0;Bt<q;Bt++){var Nt=O[Bt][bt];if(!G(Nt,X))for(var he=I[Bt],se=I[Bt+1],qt=he;qt<se;qt++){var Xt=S[qt];Ct[Xt]!==re?(Ct[Xt]=re,_t.push(Xt),wt[Xt]=Y(Nt,N[qt])):wt[Xt]=Z(wt[Xt],Y(Nt,N[qt]))}}for(var Le=at[bt],Dr=_t.length,ze=Le;ze<Dr;ze++){var mn=_t[ze];ut[ze]=wt[mn]}}return at[W]=_t.length,vt}function C(E,A){var N=E._values,S=E._index,I=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType(),O=A._values,L=A._index,z=A._ptr,q=A._datatype||A._data===void 0?A._datatype:A.getDataType(),W=E._size[0],P=A._size[1],Z=N&&O,Y,G=r,X=n;F&&q&&F===q&&typeof F=="string"&&F!=="mixed"&&(Y=F,G=t.find(r,[Y,Y]),X=t.find(n,[Y,Y]));for(var ut=Z?[]:void 0,_t=[],at=[],vt=E.createSparseMatrix({values:ut,index:_t,ptr:at,size:[W,P],datatype:F===E._datatype&&q===A._datatype?Y:void 0}),wt=Z?[]:void 0,Ct=[],bt,re,Bt,Nt,he,se,qt,Xt,Le=0;Le<P;Le++){at[Le]=_t.length;var Dr=Le+1;for(he=z[Le],se=z[Le+1],Nt=he;Nt<se;Nt++)if(Xt=L[Nt],Z)for(re=I[Xt],Bt=I[Xt+1],bt=re;bt<Bt;bt++)qt=S[bt],Ct[qt]!==Dr?(Ct[qt]=Dr,_t.push(qt),wt[qt]=X(O[Nt],N[bt])):wt[qt]=G(wt[qt],X(O[Nt],N[bt]));else for(re=I[Xt],Bt=I[Xt+1],bt=re;bt<Bt;bt++)qt=S[bt],Ct[qt]!==Dr&&(Ct[qt]=Dr,_t.push(qt));if(Z)for(var ze=at[Le],mn=_t.length,Ln=ze;Ln<mn;Ln++){var gn=_t[Ln];ut[Ln]=wt[gn]}}return at[P]=_t.length,vt}return t(wf,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(A,N)=>{f(Ie(A),Ie(N));var S=E(e(A),e(N));return we(S)?S.valueOf():S}),"Matrix, Matrix":function(A,N){var S=A.size(),I=N.size();return f(S,I),S.length===1?I.length===1?d(A,N,S[0]):h(A,N):I.length===1?g(A,N):y(A,N)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(A,N)=>E(A,e(N))),"Array, Matrix":t.referToSelf(E=>(A,N)=>E(e(A,N.storage()),N)),"SparseMatrix, any":function(A,N){return u(A,N,n,!1)},"DenseMatrix, any":function(A,N){return c(A,N,n,!1)},"any, SparseMatrix":function(A,N){return u(N,A,n,!0)},"any, DenseMatrix":function(A,N){return c(N,A,n,!0)},"Array, any":function(A,N){return c(e(A),N,n,!1).valueOf()},"any, Array":function(A,N){return c(e(N),A,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(A,N,S)=>{for(var I=E(A,N),F=0;F<S.length;F++)I=E(I,S[F]);return I})})}),Df="subtract",_v=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],pv=gt(Df,_v,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:u}=i,c=vf({typed:t}),f=Ai({typed:t}),d=gf({typed:t,equalScalar:r}),h=yf({typed:t,DenseMatrix:a}),_=Ci({typed:t,DenseMatrix:a}),g=ti({typed:t,matrix:e,concat:u});return t(Df,{"any, any":n},g({elop:n,SS:d,DS:c,SD:f,Ss:_,sS:h}))}),mv="matAlgo07xSSf",gv=["typed","DenseMatrix"],Xs=gt(mv,gv,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,u){var c=s._size,f=s._datatype||s._data===void 0?s._datatype:s.getDataType(),d=a._size,h=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==d.length)throw new Jt(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var _=c[0],g=c[1],y,p=0,w=u;typeof f=="string"&&f===h&&f!=="mixed"&&(y=f,p=t.convert(0,y),w=t.find(u,[y,y]));var v,x,b=[];for(v=0;v<_;v++)b[v]=[];var C=[],E=[],A=[],N=[];for(x=0;x<g;x++){var S=x+1;for(r(s,x,A,C,S),r(a,x,N,E,S),v=0;v<_;v++){var I=A[v]===S?C[v]:p,F=N[v]===S?E[v]:p;b[v][x]=w(I,F)}}return new e({data:b,size:[_,g],datatype:f===s._datatype&&h===a._datatype?y:void 0})};function r(n,s,a,u,c){for(var f=n._values,d=n._index,h=n._ptr,_=h[s],g=h[s+1];_<g;_++){var y=d[_];a[y]=c,u[y]=f[_]}}}),bf="conj",vv=["typed"],yv=gt(bf,vv,i=>{var{typed:t}=i;return t(bf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),xf="concat",wv=["typed","matrix","isInteger"],Dv=gt(xf,wv,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(xf,{"...Array | Matrix | number | BigNumber":function(s){var a,u=s.length,c=-1,f,d=!1,h=[];for(a=0;a<u;a++){var _=s[a];if(we(_)&&(d=!0),me(_)||Oe(_)){if(a!==u-1)throw new Error("Dimension must be specified as last argument");if(f=c,c=_.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>f)throw new Nn(c,f+1)}else{var g=ue(_).valueOf(),y=Ie(g);if(h[a]=g,f=c,c=y.length-1,a>0&&c!==f)throw new Jt(f+1,c+1)}}if(h.length===0)throw new SyntaxError("At least one matrix expected");for(var p=h.shift();h.length;)p=Nc(p,h.shift(),c);return d?e(p):p},"...string":function(s){return s.join("")}})}),Ef="count",bv=["typed","size","prod"],xv=gt(Ef,bv,i=>{var{typed:t,size:e,prod:r}=i;return t(Ef,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Cf="identity",Ev=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Cv=gt(Cf,Ev,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(Cf,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(d){return r(d)},"number | BigNumber":function(d){return c(d,d,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(d,h){return c(d,d,h)},"number | BigNumber, number | BigNumber":function(d,h){return c(d,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(d,h,_){return c(d,h,_)},Array:function(d){return u(d)},"Array, string":function(d,h){return u(d,h)},Matrix:function(d){return u(d.valueOf(),d.storage())},"Matrix, string":function(d,h){return u(d.valueOf(),h)}});function u(f,d){switch(f.length){case 0:return d?r(d):[];case 1:return c(f[0],f[0],d);case 2:return c(f[0],f[1],d);default:throw new Error("Vector containing two values expected")}}function c(f,d,h){var _=Oe(f)||Oe(d)?n:null;if(Oe(f)&&(f=f.toNumber()),Oe(d)&&(d=d.toNumber()),!xe(f)||f<1)throw new Error("Parameters in function identity must be positive integers");if(!xe(d)||d<1)throw new Error("Parameters in function identity must be positive integers");var g=_?new n(1):1,y=_?new _(0):0,p=[f,d];if(h){if(h==="sparse")return a.diagonal(p,g,0,y);if(h==="dense")return s.diagonal(p,g,0,y);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}for(var w=Sa([],p,y),v=f<d?f:d,x=0;x<v;x++)w[x][x]=g;return w}}),Af="kron",Av=["typed","matrix","multiplyScalar"],Mv=gt(Af,Av,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Af,{"Matrix, Matrix":function(a,u){return e(n(a.toArray(),u.toArray()))},"Matrix, Array":function(a,u){return e(n(a.toArray(),u))},"Array, Matrix":function(a,u){return e(n(a,u.toArray()))},"Array, Array":n});function n(s,a){if(Ie(s).length===1&&(s=[s]),Ie(a).length===1&&(a=[a]),Ie(s).length>2||Ie(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var u=[],c=[];return s.map(function(f){return a.map(function(d){return c=[],u.push(c),f.map(function(h){return d.map(function(_){return c.push(r(h,_))})})})})&&u}});function Fv(){throw new Error('No "bignumber" implementation available')}function Nv(){throw new Error('No "fraction" implementation available')}function Sv(){throw new Error('No "matrix" implementation available')}var Mf="reshape",Ov=["typed","isInteger","matrix"],Bv=gt(Mf,Ov,i=>{var{typed:t,isInteger:e}=i;return t(Mf,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),Ba(n,s)}})}),Ff="size",Tv=["typed","config","?matrix"],Iv=gt(Ff,Tv,i=>{var{typed:t,config:e,matrix:r}=i;return t(Ff,{Matrix:function(s){return s.create(s.size())},Array:Ie,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):Sv()}})}),Nf="transpose",$v=["typed","matrix"],Lv=gt(Nf,$v,i=>{var{typed:t,matrix:e}=i;return t(Nf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:ue});function r(a){var u=a.size(),c;switch(u.length){case 1:c=a.clone();break;case 2:{var f=u[0],d=u[1];if(d===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+de(u)+")");switch(a.storage()){case"dense":c=n(a,f,d);break;case"sparse":c=s(a,f,d);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+de(u)+")")}return c}function n(a,u,c){for(var f=a._data,d=[],h,_=0;_<c;_++){h=d[_]=[];for(var g=0;g<u;g++)h[g]=ue(f[g][_])}return a.createDenseMatrix({data:d,size:[c,u],datatype:a._datatype})}function s(a,u,c){for(var f=a._values,d=a._index,h=a._ptr,_=f?[]:void 0,g=[],y=[],p=[],w=0;w<u;w++)p[w]=0;var v,x,b;for(v=0,x=d.length;v<x;v++)p[d[v]]++;for(var C=0,E=0;E<u;E++)y.push(C),C+=p[E],p[E]=y[E];for(y.push(C),b=0;b<c;b++)for(var A=h[b],N=h[b+1],S=A;S<N;S++){var I=p[d[S]]++;g[I]=b,f&&(_[I]=ue(f[S]))}return a.createSparseMatrix({values:_,index:g,ptr:y,size:[c,u],datatype:a._datatype})}}),Sf="ctranspose",Rv=["typed","transpose","conj"],Pv=gt(Sf,Rv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(Sf,{any:function(s){return r(e(s))}})}),Of="mode",kv=["typed","isNaN","isNumeric"],zv=gt(Of,kv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(Of,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=Ia(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var u={},c=[],f=0,d=0;d<s.length;d++){var h=s[d];if(r(h)&&e(h))throw new Error("Cannot calculate mode of an array containing NaN values");h in u||(u[h]=0),u[h]++,u[h]===f?c.push(h):u[h]>f&&(f=u[h],c=[h])}return c}});function In(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+Fn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+Fn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var Bf="prod",qv=["typed","config","multiplyScalar","numeric"],Uv=gt(Bf,qv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(Bf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(u,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(u){return s(u)}});function s(a){var u;if(ns(a,function(c){try{u=u===void 0?c:r(u,c)}catch(f){throw In(f,"prod",c)}}),typeof u=="string"&&(u=n(u,e.number)),u===void 0)throw new Error("Cannot calculate prod of an empty array");return u}}),Wv="numeric",jv=["number","?bignumber","?fraction"],Yv=gt(Wv,jv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):Fv,Fraction:r?a=>r(a):Nv};return function(u){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",f=arguments.length>2?arguments[2]:void 0;if(f!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var d=Fn(u);if(!(d in n))throw new TypeError("Cannot convert "+u+' of type "'+d+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in s))throw new TypeError("Cannot convert "+u+' to type "'+c+'"; valid output types are '+Object.keys(s).join(", "));return c===d?u:s[c](u)}}),Tf="divideScalar",Vv=["typed","numeric"],Hv=gt(Tf,Vv,i=>{var{typed:t,numeric:e}=i;return t(Tf,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),If="pow",Zv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Kv=gt(If,Zv,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:u,fraction:c,Complex:f}=i;return t(If,{"number, number":d,"Complex, Complex":function(y,p){return y.pow(p)},"BigNumber, BigNumber":function(y,p){return p.isInteger()||y>=0||e.predictable?y.pow(p):new f(y.toNumber(),0).pow(p.toNumber(),0)},"Fraction, Fraction":function(y,p){var w=y.pow(p);if(w!=null)return w;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return d(y.valueOf(),p.valueOf())},"Array, number":h,"Array, BigNumber":function(y,p){return h(y,p.toNumber())},"Matrix, number":_,"Matrix, BigNumber":function(y,p){return _(y,p.toNumber())},"Unit, number | BigNumber":function(y,p){return y.pow(p)}});function d(g,y){if(e.predictable&&!xe(y)&&g<0)try{var p=c(y),w=u(p);if((y===w||Math.abs((y-w)/y)<1e-14)&&p.d%2===1)return(p.n%2===0?1:-1)*Math.pow(-g,y)}catch{}return e.predictable&&(g<-1&&y===1/0||g>-1&&g<0&&y===-1/0)?NaN:xe(y)||g>=0||e.predictable?sf(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new f(g,0).pow(y,0)}function h(g,y){if(!xe(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var p=Ie(g);if(p.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+p.length+" dimensions)");if(p[0]!==p[1])throw new Error("For A^b, A must be square (size is "+p[0]+"x"+p[1]+")");if(y<0)try{return h(a(g),-y)}catch(x){throw x.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 "+y+")"):x}for(var w=r(p[0]).valueOf(),v=g;y>=1;)(y&1)===1&&(w=n(v,w)),y>>=1,v=n(v,v);return w}function _(g,y){return s(h(g.valueOf(),y))}}),$f="dotDivide",Gv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Jv=gt($f,Gv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,u=Wg({typed:t,equalScalar:r}),c=Ai({typed:t}),f=Xs({typed:t,DenseMatrix:s}),d=ja({typed:t,equalScalar:r}),h=Ci({typed:t,DenseMatrix:s}),_=ti({typed:t,matrix:e,concat:a});return t($f,_({elop:n,SS:f,DS:c,SD:u,Ss:d,sS:h}))}),Qs="compare",Xv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],Qv=gt(Qs,Xv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:u,concat:c}=i,f=Ai({typed:t}),d=gf({typed:t,equalScalar:r}),h=Ci({typed:t,DenseMatrix:u}),_=ti({typed:t,matrix:n,concat:c}),g=Gs({typed:t});return t(Qs,t1({typed:t,config:e}),{"boolean, boolean":function(p,w){return p===w?0:p>w?1:-1},"BigNumber, BigNumber":function(p,w){return Ks(p,w,e.epsilon)?new s(0):new s(p.cmp(w))},"Fraction, Fraction":function(p,w){return new a(p.compare(w))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,_({SS:d,DS:f,Ss:h}))}),t1=gt(Qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Qs,{"number, number":function(n,s){return Qn(n,s,e.epsilon)?0:n>s?1:-1}})}),to="equal",e1=["typed","matrix","equalScalar","DenseMatrix","concat"],r1=gt(to,e1,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),u=Xs({typed:t,DenseMatrix:n}),c=Ci({typed:t,DenseMatrix:n}),f=ti({typed:t,matrix:e,concat:s});return t(to,n1({typed:t,equalScalar:r}),f({elop:r,SS:u,DS:a,Ss:c}))}),n1=gt(to,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(to,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),eo="smaller",i1=["typed","config","matrix","DenseMatrix","concat"],s1=gt(eo,i1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),u=Xs({typed:t,DenseMatrix:n}),c=Ci({typed:t,DenseMatrix:n}),f=ti({typed:t,matrix:r,concat:s}),d=Gs({typed:t});return t(eo,o1({typed:t,config:e}),{"boolean, boolean":(h,_)=>h<_,"BigNumber, BigNumber":function(_,g){return _.lt(g)&&!Ks(_,g,e.epsilon)},"Fraction, Fraction":(h,_)=>h.compare(_)===-1,"Complex, Complex":function(_,g){throw new TypeError("No ordering relation is defined for complex numbers")}},d,f({SS:u,DS:a,Ss:c}))}),o1=gt(eo,["typed","config"],i=>{var{typed:t,config:e}=i;return t(eo,{"number, number":function(n,s){return n<s&&!Qn(n,s,e.epsilon)}})}),ro="larger",a1=["typed","config","matrix","DenseMatrix","concat"],u1=gt(ro,a1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),u=Xs({typed:t,DenseMatrix:n}),c=Ci({typed:t,DenseMatrix:n}),f=ti({typed:t,matrix:r,concat:s}),d=Gs({typed:t});return t(ro,l1({typed:t,config:e}),{"boolean, boolean":(h,_)=>h>_,"BigNumber, BigNumber":function(_,g){return _.gt(g)&&!Ks(_,g,e.epsilon)},"Fraction, Fraction":(h,_)=>h.compare(_)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,f({SS:u,DS:a,Ss:c}))}),l1=gt(ro,["typed","config"],i=>{var{typed:t,config:e}=i;return t(ro,{"number, number":function(n,s){return n>s&&!Qn(n,s,e.epsilon)}})}),Lf="deepEqual",c1=["typed","equal"],f1=gt(Lf,c1,i=>{var{typed:t,equal:e}=i;return t(Lf,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var u=0;u<a;u++)if(!r(n[u],s[u]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),Rf="partitionSelect",h1=["typed","isNumeric","isNaN","compare"],d1=gt(Rf,h1,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(f,d)=>-n(f,d);return t(Rf,{"Array | Matrix, number":function(d,h){return u(d,h,s)},"Array | Matrix, number, string":function(d,h,_){if(_==="asc")return u(d,h,s);if(_==="desc")return u(d,h,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":u});function u(f,d,h){if(!xe(d)||d<0)throw new Error("k must be a non-negative integer");if(we(f)){var _=f.size();if(_.length>1)throw new Error("Only one dimensional matrices supported");return c(f.valueOf(),d,h)}if(Array.isArray(f))return c(f,d,h)}function c(f,d,h){if(d>=f.length)throw new Error("k out of bounds");for(var _=0;_<f.length;_++)if(e(f[_])&&r(f[_]))return f[_];for(var g=0,y=f.length-1;g<y;){for(var p=g,w=y,v=f[Math.floor(Math.random()*(y-g+1))+g];p<w;)if(h(f[p],v)>=0){var x=f[w];f[w]=f[p],f[p]=x,--w}else++p;h(f[p],v)>0&&--p,d<=p?y=p:g=p+1}return f[d]}}),Pf="max",_1=["typed","config","numeric","larger"],p1=gt(Pf,_1,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(Pf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,f){return Wa(c,f.valueOf(),s)},"...":function(c){if(Vs(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function s(u,c){try{return n(u,c)?u:c}catch(f){throw In(f,"max",c)}}function a(u){var c;if(ns(u,function(f){try{isNaN(f)&&typeof f=="number"?c=NaN:(c===void 0||n(f,c))&&(c=f)}catch(d){throw In(d,"max",f)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),kf="min",m1=["typed","config","numeric","smaller"],g1=gt(kf,m1,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(kf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,f){return Wa(c,f.valueOf(),s)},"...":function(c){if(Vs(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function s(u,c){try{return n(u,c)?u:c}catch(f){throw In(f,"min",c)}}function a(u){var c;if(ns(u,function(f){try{isNaN(f)&&typeof f=="number"?c=NaN:(c===void 0||n(f,c))&&(c=f)}catch(d){throw In(d,"min",f)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),zf="add",v1=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],y1=gt(zf,v1,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:u}=i,c=vf({typed:t}),f=ov({typed:t,equalScalar:n}),d=yf({typed:t,DenseMatrix:s}),h=ti({typed:t,matrix:e,concat:u});return t(zf,{"any, any":r,"any, any, ...any":t.referToSelf(_=>(g,y,p)=>{for(var w=_(g,y),v=0;v<p.length;v++)w=_(w,p[v]);return w})},h({elop:r,DS:c,SS:f,Ss:d}))}),qf="dot",w1=["typed","addScalar","multiplyScalar","conj","size"],D1=gt(qf,w1,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(qf,{"Array | DenseMatrix, Array | DenseMatrix":u,"SparseMatrix, SparseMatrix":c});function a(d,h){var _=f(d),g=f(h),y,p;if(_.length===1)y=_[0];else if(_.length===2&&_[1]===1)y=_[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+_.join(", ")+")");if(g.length===1)p=g[0];else if(g.length===2&&g[1]===1)p=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(y!==p)throw new RangeError("Vectors must have equal length ("+y+" != "+p+")");if(y===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return y}function u(d,h){var _=a(d,h),g=we(d)?d._data:d,y=we(d)?d._datatype||d.getDataType():void 0,p=we(h)?h._data:h,w=we(h)?h._datatype||h.getDataType():void 0,v=f(d).length===2,x=f(h).length===2,b=e,C=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var E=y;b=t.find(e,[E,E]),C=t.find(r,[E,E])}if(!v&&!x){for(var A=C(n(g[0]),p[0]),N=1;N<_;N++)A=b(A,C(n(g[N]),p[N]));return A}if(!v&&x){for(var S=C(n(g[0]),p[0][0]),I=1;I<_;I++)S=b(S,C(n(g[I]),p[I][0]));return S}if(v&&!x){for(var F=C(n(g[0][0]),p[0]),O=1;O<_;O++)F=b(F,C(n(g[O][0]),p[O]));return F}if(v&&x){for(var L=C(n(g[0][0]),p[0][0]),z=1;z<_;z++)L=b(L,C(n(g[z][0]),p[z][0]));return L}}function c(d,h){a(d,h);for(var _=d._index,g=d._values,y=h._index,p=h._values,w=0,v=e,x=r,b=0,C=0;b<_.length&&C<y.length;){var E=_[b],A=y[C];if(E<A){b++;continue}if(E>A){C++;continue}E===A&&(w=v(w,x(g[b],p[C])),b++,C++)}return w}function f(d){return we(d)?d.size():s(d)}}),b1="trace",x1=["typed","matrix","add"],E1=gt(b1,x1,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(u){return n(e(u))},SparseMatrix:s,DenseMatrix:n,any:ue});function n(a){var u=a._size,c=a._data;switch(u.length){case 1:if(u[0]===1)return ue(c[0]);throw new RangeError("Matrix must be square (size: "+de(u)+")");case 2:{var f=u[0],d=u[1];if(f===d){for(var h=0,_=0;_<f;_++)h=r(h,c[_][_]);return h}else throw new RangeError("Matrix must be square (size: "+de(u)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+de(u)+")")}}function s(a){var u=a._values,c=a._index,f=a._ptr,d=a._size,h=d[0],_=d[1];if(h===_){var g=0;if(u.length>0)for(var y=0;y<_;y++)for(var p=f[y],w=f[y+1],v=p;v<w;v++){var x=c[v];if(x===y){g=r(g,u[v]);break}if(x>y)break}return g}throw new RangeError("Matrix must be square (size: "+de(d)+")")}}),Uf="det",C1=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],A1=gt(Uf,C1,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:u}=i;return t(Uf,{any:function(d){return ue(d)},"Array | Matrix":function(d){var h;switch(we(d)?h=d.size():Array.isArray(d)?(d=e(d),h=d.size()):h=[],h.length){case 0:return ue(d);case 1:if(h[0]===1)return ue(d.valueOf()[0]);if(h[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+de(h)+")");case 2:{var _=h[0],g=h[1];if(_===g)return c(d.clone().valueOf(),_);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+de(h)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+de(h)+")")}}});function c(f,d,h){if(d===1)return ue(f[0][0]);if(d===2)return r(n(f[0][0],f[1][1]),n(f[1][0],f[0][1]));for(var _=!1,g=new Array(d).fill(0).map((N,S)=>S),y=0;y<d;y++){var p=g[y];if(a(f[p][y])){var w=void 0;for(w=y+1;w<d;w++)if(!a(f[g[w]][y])){p=g[w],g[w]=g[y],g[y]=p,_=!_;break}if(w===d)return f[p][y]}for(var v=f[p][y],x=y===0?1:f[g[y-1]][y-1],b=y+1;b<d;b++)for(var C=g[b],E=y+1;E<d;E++)f[C][E]=s(r(n(f[C][E],v),n(f[C][y],f[p][E])),x)}var A=f[g[d-1]][d-1];return _?u(A):A}}),Wf="inv",M1=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],F1=gt(Wf,M1,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:u,identity:c,abs:f}=i;return t(Wf,{"Array | Matrix":function(_){var g=we(_)?_.size():Ie(_);switch(g.length){case 1:if(g[0]===1)return we(_)?e([r(1,_.valueOf()[0])]):[r(1,_[0])];throw new RangeError("Matrix must be square (size: "+de(g)+")");case 2:{var y=g[0],p=g[1];if(y===p)return we(_)?e(d(_.valueOf(),y,p),_.storage()):d(_,y,p);throw new RangeError("Matrix must be square (size: "+de(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+de(g)+")")}},any:function(_){return r(1,_)}});function d(h,_,g){var y,p,w,v,x;if(_===1){if(v=h[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(_===2){var b=u(h);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(h[1][1],b),r(a(h[0][1]),b)],[r(a(h[1][0]),b),r(h[0][0],b)]]}else{var C=h.concat();for(y=0;y<_;y++)C[y]=C[y].concat();for(var E=c(_).valueOf(),A=0;A<g;A++){var N=f(C[A][A]),S=A;for(y=A+1;y<_;)f(C[y][A])>N&&(N=f(C[y][A]),S=y),y++;if(N===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==A&&(x=C[A],C[A]=C[y],C[y]=x,x=E[A],E[A]=E[y],E[y]=x);var I=C[A],F=E[A];for(y=0;y<_;y++){var O=C[y],L=E[y];if(y!==A){if(O[A]!==0){for(w=r(a(O[A]),I[A]),p=A;p<g;p++)O[p]=n(O[p],s(w,I[p]));for(p=0;p<g;p++)L[p]=n(L[p],s(w,F[p]))}}else{for(w=I[A],p=A;p<g;p++)O[p]=r(O[p],w);for(p=0;p<g;p++)L[p]=r(L[p],w)}}}return E}}}),jf="pinv",N1=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],S1=gt(jf,N1,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:u,ctranspose:c,divideScalar:f,multiply:d,add:h,Complex:_}=i;return t(jf,{"Array | Matrix":function(b){var C=we(b)?b.size():Ie(b);switch(C.length){case 1:return v(b)?c(b):C[0]===1?r(b):a(c(b),u(b,b));case 2:{if(v(b))return c(b);var E=C[0],A=C[1];if(E===A)try{return r(b)}catch(N){if(!(N instanceof Error&&N.message.match(/Cannot calculate inverse, determinant is zero/)))throw N}return we(b)?e(g(b.valueOf(),E,A),b.storage()):g(b,E,A)}default:throw new RangeError("Matrix must be two dimensional (size: "+de(C)+")")}},any:function(b){return s(b,0)?ue(b):f(1,b)}});function g(x,b,C){var{C:E,F:A}=p(x,b,C),N=d(r(d(c(E),E)),c(E)),S=d(c(A),r(d(A,c(A))));return d(S,N)}function y(x,b,C){for(var E=ue(x),A=0,N=0;N<b;N++){if(C<=A)return E;for(var S=N;w(E[S][A]);)if(S++,b===S&&(S=N,A++,C===A))return E;[E[S],E[N]]=[E[N],E[S]];for(var I=E[N][A],F=0;F<C;F++)E[N][F]=a(E[N][F],I);for(var O=0;O<b;O++)if(O!==N){I=E[O][A];for(var L=0;L<C;L++)E[O][L]=h(E[O][L],d(-1,d(I,E[N][L])))}A++}return E}function p(x,b,C){var E=y(x,b,C),A=x.map((S,I)=>S.filter((F,O)=>O<b&&!w(u(E[O],E[O])))),N=E.filter((S,I)=>!w(u(E[I],E[I])));return{C:A,F:N}}function w(x){return s(h(x,_(1,1)),h(0,_(1,1)))}function v(x){return n(h(x,_(1,1)),h(d(x,0),_(1,1)))}}),O1="divide",B1=["typed","matrix","multiply","equalScalar","divideScalar","inv"],T1=gt(O1,B1,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,u=ja({typed:t,equalScalar:n}),c=Ya({typed:t});return t("divide",lc({"Array | Matrix, Array | Matrix":function(d,h){return r(d,a(h))},"DenseMatrix, any":function(d,h){return c(d,h,s,!1)},"SparseMatrix, any":function(d,h){return u(d,h,s,!1)},"Array, any":function(d,h){return c(e(d),h,s,!1).valueOf()},"any, Array | Matrix":function(d,h){return r(d,a(h))}},s.signatures))}),Yf="sum",I1=["typed","config","add","numeric"],$1=gt(Yf,I1,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(Yf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(c){if(Vs(c))throw new TypeError("Scalar values expected in function sum");return s(c)}});function s(u){var c;return ns(u,function(f){try{c=c===void 0?f:r(c,f)}catch(d){throw In(d,"sum",f)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(u,c){try{var f=Wa(u,c,r);return f}catch(d){throw In(d,"sum")}}}),Vf="median",L1=["typed","add","divide","compare","partitionSelect"],R1=gt(Vf,L1,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(f){try{f=Ia(f.valueOf());var d=f.length;if(d===0)throw new Error("Cannot calculate median of an empty array");if(d%2===0){for(var h=d/2-1,_=s(f,h+1),g=f[h],y=0;y<h;++y)n(f[y],g)>0&&(g=f[y]);return c(g,_)}else{var p=s(f,(d-1)/2);return u(p)}}catch(w){throw In(w,"median")}}var u=t({"number | BigNumber | Complex | Unit":function(d){return d}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(d,h){return r(e(d,h),2)}});return t(Vf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(d,h){throw new Error("median(A, dim) is not yet supported")},"...":function(d){if(Vs(d))throw new TypeError("Scalar values expected in function median");return a(d)}})}),no=Pm({config:yr}),Va=Um({}),Ha=Vm({}),Za=Km({}),nn=Xm({Matrix:Za}),St=qp({BigNumber:no,Complex:Va,DenseMatrix:nn,Fraction:Ha}),P1=Sg({typed:St}),io=Bg({typed:St}),k1=Dg({BigNumber:no,typed:St}),Hf=yv({typed:St}),$n=cg({config:yr,typed:St}),so=eg({typed:St}),z1=sg({typed:St}),oo=fv({typed:St}),Zf=vg({typed:St}),Ka=dg({Matrix:Za,equalScalar:$n,typed:St}),Kf=Ig({typed:St}),Gf=ag({typed:St}),Ga=Fg({typed:St}),Jf=Eg({Fraction:Ha,typed:St}),Xf=ng({typed:St}),$e=Ag({DenseMatrix:nn,Matrix:Za,SparseMatrix:Ka,typed:St}),Qf=zv({isNaN:Gf,isNumeric:Xf,typed:St}),is=Yv({bignumber:k1,fraction:Jf,number:Zf}),q1=Uv({config:yr,multiplyScalar:oo,numeric:is,typed:St}),U1=Bv({isInteger:so,matrix:$e,typed:St}),th=Iv({matrix:$e,config:yr,typed:St}),eh=Lv({matrix:$e,typed:St}),ei=Dv({isInteger:so,matrix:$e,typed:St}),W1=xv({prod:q1,size:th,typed:St}),j1=Pv({conj:Hf,transpose:eh,typed:St}),ss=Hv({numeric:is,typed:St}),Y1=Jv({DenseMatrix:nn,concat:ei,divideScalar:ss,equalScalar:$n,matrix:$e,typed:St}),rh=r1({DenseMatrix:nn,concat:ei,equalScalar:$n,matrix:$e,typed:St}),nh=Cv({BigNumber:no,DenseMatrix:nn,SparseMatrix:Ka,config:yr,matrix:$e,typed:St}),V1=Mv({matrix:$e,multiplyScalar:oo,typed:St}),H1=s1({DenseMatrix:nn,concat:ei,config:yr,matrix:$e,typed:St}),Z1=pv({DenseMatrix:nn,concat:ei,equalScalar:$n,matrix:$e,subtractScalar:Kf,typed:St,unaryMinus:Ga}),os=y1({DenseMatrix:nn,SparseMatrix:Ka,addScalar:io,concat:ei,equalScalar:$n,matrix:$e,typed:St}),ih=Qv({BigNumber:no,DenseMatrix:nn,Fraction:Ha,concat:ei,config:yr,equalScalar:$n,matrix:$e,typed:St}),K1=f1({equal:rh,typed:St}),sh=D1({addScalar:io,conj:Hf,multiplyScalar:oo,size:th,typed:St}),G1=u1({DenseMatrix:nn,concat:ei,config:yr,matrix:$e,typed:St}),Ja=g1({config:yr,numeric:is,smaller:H1,typed:St}),Mi=dv({addScalar:io,dot:sh,equalScalar:$n,matrix:$e,multiplyScalar:oo,typed:St}),J1=d1({compare:ih,isNaN:Gf,isNumeric:Xf,typed:St}),X1=$1({add:os,config:yr,numeric:is,typed:St}),Q1=E1({add:os,matrix:$e,typed:St}),oh=A1({divideScalar:ss,isZero:z1,matrix:$e,multiply:Mi,subtractScalar:Kf,typed:St,unaryMinus:Ga}),ty=p1({config:yr,larger:G1,numeric:is,typed:St}),ao=F1({abs:P1,addScalar:io,det:oh,divideScalar:ss,identity:nh,matrix:$e,multiply:Mi,typed:St,unaryMinus:Ga}),ey=S1({Complex:Va,add:os,ctranspose:j1,deepEqual:K1,divideScalar:ss,dot:sh,dotDivide:Y1,equal:rh,inv:ao,matrix:$e,multiply:Mi,typed:St}),ry=Kv({Complex:Va,config:yr,fraction:Jf,identity:nh,inv:ao,matrix:$e,multiply:Mi,number:Zf,typed:St}),ny=T1({divideScalar:ss,equalScalar:$n,inv:ao,matrix:$e,multiply:Mi,typed:St}),ah=R1({add:os,compare:ih,divide:ny,partitionSelect:J1,typed:St});class iy{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_math");$(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(e===void 0||r===void 0||n===void 0)return;const u=this._cacheDataList(t,e,`alma_${a}`);if(u===void 0)return;let c=r*(e-1);s&&(c=Math.floor(c));const f=e/n;let d=0,h=0;for(let _=0;_<=e-1;_++){const g=Math.exp(-1*Math.pow(_-c,2)/(2*Math.pow(f,2)));d+=g,h+=u[u.length-1-(e-_-1)]*g}return h/d}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=X1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._verifyCacheData(`rma_${r}`);if(n)return n==null?void 0:n.sum;const{sum:s}=this._getCacheData(`rma_${r}`),a=1/e,u=this.sma({source:t,length:e},r),c=s===void 0?u:a*t+(1-a)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:c}),c}atr({length:t},e){const r=this._verifyCacheData(`atr_${e}`);if(r)return r==null?void 0:r.value;const{high:n,close:s}=this._getCacheData(`atr_${e}`),{high:a,close:u,low:c}=this._variables,f=n===void 0?a-c:Math.max(Math.max(a-c,Math.abs(a-s)),Math.abs(c-s)),d=this.rma({source:f,length:t},e);return this._cacheDataHandle(`atr_${e}`,{high:a,close:u,value:d}),d}barssince({condition:t},e){const r=this._verifyCacheData(`barssince_${e}`);if(r)return r==null?void 0:r.count;let{count:n}=this._getCacheData(`barssince_${e}`);if(t)n=0;else{if(n===void 0)return;n+=1}return this._cacheDataHandle(`barssince_${e}`,{count:n}),n}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let u=0;for(let c=0;c<e;c++){const f=this._sum(s[s.length-1-c],-(a||0));u+=f*f}return r||e<=1?Math.sqrt(u/e):Math.sqrt(u/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const u=r*a;return[s,s+u,s-u]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const u=r*a;return(s+u-(s-u))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheDataList(t,e,`change_${r}`);if(n===void 0)return;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?typeof t=="number"?0:s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let u=0;u<e;u++){const c=n[n.length-1-u];a+=c*(u+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),u=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||u===void 0||s===void 0)return;let c=0,f=0,d=0;for(let _=0;_<r;_++){const[g,y]=s[s.length-1-_],p=g-a,w=y-u;c+=p*w,f+=p*p,d+=w*w}return isNaN(f)||isNaN(c)||isNaN(d)?void 0:c/Math.sqrt(f*d)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const n=this._verifyCacheData(`cross_${r}`);if(n)return n==null?void 0:n.value;const{source1:s,source2:a}=this._getCacheData(`cross_${r}`);let u=!1;return s===void 0||a===void 0?u=!1:u=s>=a&&t<e||s<=a&&t>e,this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e,value:u}),u}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const n=this._verifyCacheData(`crossover_${r}`);if(n)return n==null?void 0:n.value;const{source1:s,source2:a}=this._getCacheData(`crossover_${r}`);let u=!1;return s===void 0||a===void 0?u=!1:u=s<=a&&t>e,this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e,value:u}),u}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const n=this._verifyCacheData(`crossunder_${r}`);if(n)return n==null?void 0:n.value;const{source1:s,source2:a}=this._getCacheData(`crossunder_${r}`);let u=!1;return s===void 0||a===void 0?u=!1:u=s>=a&&t<e,this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e,value:u}),u}cum({source:t=0},e){const r=this._verifyCacheData(`cum_${e}`);if(r)return r==null?void 0:r.sum;t=isNaN(t)?0:t;let{sum:n}=this._getCacheData(`cum_${e}`);return n=n||0,n+=t,this._cacheDataHandle(`cum_${e}`,{sum:n}),n}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let u=0;u<e;u++){const c=a[a.length-1-u];s+=Math.abs(c-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,s=this._verifyCacheData(n);if(s)return s==null?void 0:s.value;const{low:a,high:u,close:c,PDMS:f,NDMS:d,TRS:h,ADX:_,count:g=0}=this._getCacheData(n),{low:y,high:p,close:w}=this._variables;if(a===void 0||u===void 0||c===void 0)return this._cacheData[n]={low:y,high:p,close:w,PDMS:f,NDMS:d,TRS:p-y,count:1},[void 0,void 0,void 0];let v=p-u,x=a-y;v=v>x&&v>0?v:0,x=x>v&&x>0?x:0,v===x&&(v=x=0);const b=Math.max(p-y,Math.abs(p-c),Math.abs(y-c));let C={};if(g<t)C={low:y,high:p,close:w,PDMS:(f||0)+v,NDMS:(d||0)+x,TRS:(h||0)+b,count:g+1,value:[void 0,void 0,void 0]};else{const E=f-f/t+v,A=d-d/t+x,N=h-h/t+b,S=E/N*100,I=A/N*100,F=Math.abs((S-I)/(S+I))*100;let O=F,L=[S,I,void 0];if(g+1-t<e){const z=g+1-t;O=((_||0)*(z-1)+F)/z}else O=(_*(e-1)+F)/e,L=[S,I,O];C={low:y,high:p,close:w,PDMS:E,NDMS:A,TRS:N,ADX:O,count:g+1,value:L}}return this._cacheDataHandle(n,C),C.value}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._verifyCacheData(`ema_${r}`);if(n)return n==null?void 0:n.sum;let{sum:s,count:a=1}=this._getCacheData(`ema_${r}`);const u=this.sma({source:t,length:e},r);if(a>e){const c=2/(e+1);s=s===void 0?t:c*t+(1-c)*(s||0)}else s=u;return a+=1,this._cacheDataHandle(`ema_${r}`,{sum:s,count:a}),s}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const n=this._verifyCacheData(`falling_${r}`);if(n)return n==null?void 0:n.value;const{source:s,fallings:a=[]}=this._getCacheData(`falling_${r}`);a.push(s>t);const u=a.slice(-e);let c=!1;return u.length<e?c=!1:c=u.every(f=>f),this._cacheDataHandle(`falling_${r}`,{source:t,fallings:u,value:c}),c}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const n=this._verifyCacheData(`rising_${r}`);if(n)return n==null?void 0:n.value;const{source:s,risings:a=[]}=this._getCacheData(`rising_${r}`);a.push(s<t);const u=a.slice(-e);let c=!1;return u.length<e?c=!1:c=u.every(f=>f),this._cacheDataHandle(`rising_${r}`,{source:t,risings:u,value:c}),c}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(s)return Math.max(...s.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return s?s.slice(-e).reduce((u,c,f,d)=>c>=d[u]?f:u,0)-e+1:void 0}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let u=0;u<e;u++){const c=(e-u)*e;s+=c,a+=n[n.length-1-u]*c}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:u,high:c,low:f}=this._variables,d=n?u.tr:c-f,h=this.ema({source:d,length:e},`range_${s}`);return[a,a+h*r,a-h*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:u,high:c,low:f}=this._variables,d=n?u.tr:c-f,h=this.ema({source:d,length:e},`range_${s}`);return(a+h*r-(a-h*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(g=>g!==void 0);let u=0,c=0,f=0,d=0;for(const[g,y]of a.entries())u+=g,c+=y,f+=g*y,d+=g*g;const h=(e*f-u*c)/(e*d-u*u);return(c-h*u)/e+h*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(s)return Math.min(...s.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return s?s.slice(-e).reduce((u,c,f,d)=>c<=d[u]?f:u,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),u=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||u===void 0)return[void 0,void 0,void 0];const c=a-u,f=this.ema({source:c,length:n},`macd_${s}`);if(f===void 0)return[c,f,void 0];const d=c-f;return[c,f,d]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return ah(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),u=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(u===void 0||a===void 0))return 100-100/(1+u/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Ja(Qf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheDataList(t,e,n);if(!s||s.length<=e||t===void 0||isNaN(t))return;let a=s.length-e-1,u;for(;u===void 0&&a>=0;)u=s[a],a--;return u===void 0?u:t-u}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),u=a.length;r/=100;const c=1/(u*2);if(r<=c)return a[0];if(r>=1-1/(u*2))return a[u-1];for(const[f,d]of a.entries()){const h=a[f-1];if(r<(f+.5)/u)return h===void 0||d===void 0?void 0:h+(d-h)*(r-(f-.5)/u)/(1/u)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),u=r/100*a.length,c=Math.ceil(u)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let u=0;for(let c=0;c<s.length;c++)s[c]!==void 0&&(s[c]<a||s[c]===a&&c<e)&&u++;return u/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new ee;let{close:a,open:u,low:c,high:f}=this._variables;const d=`pivot_point_levels_${n}`,h=this._verifyCacheData(d);if(h)return s._value=(h==null?void 0:h.result)||[],s;const{close:_,low:g,high:y,open:p,result:w}=this._getCacheData(d);if(!e&&(y&&g&&(f=Math.max(y,f),c=Math.min(g,c)),this._cacheDataHandle(d,{close:a,open:u,low:c,high:f,result:w}),!r))return s._value=w||[],s;const v={close:a,open:u,low:c,high:f};e===!0&&!r&&(a=_,u=p,c=g,f=y);const x=this._getPivotPointLevels(f,c,a,u,r,t);return this._cacheDataHandle(d,{...v,result:x}),s._value=x,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Xn.traditional:return this._traditional(t,e,r);case Xn.fibonacci:return this._fibonacci(t,e,r);case Xn.woodie:return s?[]:this._woodie(t,e);case Xn.classic:return this._classic(t,e,r);case Xn.dm:return this._DM(t,e,r,n);case Xn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),u=n*2+(t-2*e),c=n*3+(t-3*e),f=n*4+(t-4*e),d=n*2-t,h=n-(t-e),_=n*2-(2*t-e),g=n*3-(3*t-e),y=n*4-(4*t-e);return[n,s,d,a,h,u,_,c,g,f,y]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),u=n+.618*(t-e),c=n-.618*(t-e),f=n+(t-e),d=n-(t-e);return[n,s,a,u,c,f,d]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,u=n+(t-e),c=n-(t-e),f=t+2*(n-e),d=e-2*(t-n),h=f+(t-e),_=d-(t-e);return[n,s,a,u,c,f,d,h,_]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,u=n+(t-e),c=n-(t-e),f=n+2*(t-e),d=n-2*(t-e),h=n+3*(t-e),_=n-3*(t-e);return[n,s,a,u,c,f,d,h,_]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,u=s/2-e,c=s/2-t;return[a,u,c]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,u=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,f=r+1.1*(t-e)/4,d=r-1.1*(t-e)/4,h=r+1.1*(t-e)/2,_=r-1.1*(t-e)/2,g=t/e*r,y=r-(g-r);return[n,s,a,u,c,f,d,h,_,g,y]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),u=a[e];return Math.max(...a)===u?u:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),u=a[e];return Math.min(...a)===u?u:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const s=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...s),u=Math.min(...s);return a-u}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._verifyCacheData(`rsi_${r}`);if(n)return n==null?void 0:n.value;const{source:s}=this._getCacheData(`rsi_${r}`),a=Math.max(t-s,0),u=Math.max(s-t,0),c=this.rma({source:a,length:e},`rma1_${r}`),f=this.rma({source:u,length:e},`rma2_${r}`),d=c===void 0||f===void 0?void 0:100-100/(1+c/f);return this._cacheDataHandle(`rsi_${r}`,{source:t,value:d}),d}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const s=this._verifyCacheData(`sar_${n}`);if(s)return s==null?void 0:s.result;const{close:a,low:u,high:c,preLow:f,preHigh:d,data:h={}}=this._getCacheData(`sar_${n}`);let{result:_,maxMin:g,acceleration:y,isBelow:p}=h,w=!1;const{close:v,low:x,high:b,bar_index:C}=this._variables;return C===1&&(v>a?(p=!0,g=b,_=u):(p=!1,g=x,_=c),w=!0,y=t),_=_+y*(g-_),p?_>x&&(w=!0,p=!1,_=Math.max(b,g||0),g=x,y=t):_<b&&(w=!0,p=!0,_=Math.min(x,g||0),g=b,y=t),w||(p?b>(g||0)&&(g=b,y=Math.min((y||0)+e,r)):x<(g||0)&&(g=x,y=Math.min((y||0)+e,r))),p?(_=Math.min(_,u),C>1&&(_=Math.min(_,f))):(_=Math.max(_,c),C>1&&(_=Math.max(_,d))),this._cacheDataHandle(`sar_${n}`,{high:b,close:v,low:x,preLow:u,preHigh:c,data:Object.assign(h,{result:_,maxMin:g,acceleration:y,isBelow:p})}),_}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},s),u=this.highest({source:e,length:n},s);if(!(a===void 0||u===void 0))return 100*(t-a)/(u-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const n=`supertrend_${r}`,s=this._verifyCacheData(n);if(s)return s==null?void 0:s.value;let a=1;const{hl2:u,close:c}=this._variables,{upperBand:f,lowerBand:d,superTrend:h,atr:_,close:g}=this._getCacheData(n),y=this.atr({length:e},r);if(y===void 0)return this._cacheDataHandle(n,{close:c,value:[void 0,a]}),[void 0,a];let p=u+t*y,w=u-t*y;const v=f||0,x=d||0;w=w>x||g<x?w:x,p=p<v||g>v?p:v,_===void 0?a=1:h===v?a=c>p?-1:1:a=c<w?1:-1;const b=a===-1?w:p;return this._cacheDataHandle(n,{upperBand:p,lowerBand:w,superTrend:b,atr:y,close:c,value:[b,a]}),[b,a]}swma({source:t},e){const r=this._verifyCacheData(`swma_${e}`);if(r)return r==null?void 0:r.value;let{list:n}=this._getCacheData(`swma_${e}`);n||(n=[]),n.push(t),n=n.slice(-4);const s=n.filter(a=>a!==void 0).length<4?void 0:n[3]*1/6+n[2]*2/6+n[1]*2/6+n[0]*1/6;return this._cacheDataHandle(`swma_${e}`,{list:n,value:s}),s}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,a=this._verifyCacheData(`tr_${e}`);if(a)return a==null?void 0:a.value;const{close:u}=this._getCacheData(`tr_${e}`);let c;return u===void 0?c=t?s-n:void 0:c=Math.max(s-n,Math.abs(s-u),Math.abs(n-u)),this._cacheDataHandle(`tr_${e}`,{close:r,value:c}),c}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),u=this.ema({source:s,length:e},`ema1_${n}`);if(u===void 0)return;const c=this.ema({source:u,length:r},`ema2_${n}`),f=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/f}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;const s=this._verifyCacheData(`valuewhen_${n}`);if(s)return s==null?void 0:s.value;let{list:a}=this._getCacheData(`valuewhen_${n}`);a||(a=[]),t&&a.push(e);const u=a[a.length-1-r];return this._cacheDataHandle(`valuewhen_${n}`,{list:a,value:u}),u}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`variance_${n}`,!0);if(!a||s===void 0)return;const u=a.filter(f=>f!==void 0&&!isNaN(f)).slice(-e);if(u.length<e)return;const c=u.reduce((f,d)=>f+Math.pow(d-s,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;const s=`vwap_${n}`,a=this._verifyCacheData(s);if(a)return a==null?void 0:a.value;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:u}=this._variables;let{sum:c=0,sumV:f=0,count:d=0,isReset:h,sumS:_=0}=this._getCacheData(s);if(e&&(c=f=d=_=0,h=!0),!h)return r!==void 0?[]:void 0;const g=t*u+c,y=u+f,p=g/y;if(d++,r!==void 0){_=u*Math.pow(t,2)+_;const w=this._computeBands(_,y,r,p);return this._cacheDataHandle(s,{sum:g,sumV:y,count:d,isReset:h,sumS:_,value:w}),w}return this._cacheDataHandle(s,{sum:g,sumV:y,count:d,isReset:h,value:p}),p}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),u=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,u,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:u}=n,c=t[s];if(c!==void 0){if(a!==void 0&&c<a){t.splice(s,1),t.splice(u,0,c),n={currentIndex:u+1,currentVal:a};continue}n={currentIndex:s,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const s=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(s.barIndex<=a){const u=s.list.length;if(s.barIndex===a)s.list[u-1]=t;else{let c=a-s.barIndex-1;if(s.barIndex!==-1&&c>0){const f=s.list[u-1];for(;c>0;)s.list.push(f),c--}s.list.push(t)}s.barIndex=a,s.list.length>e+5&&!n&&s.list.shift(),this._cacheData[r]=s}if(!(s.list.length<e))return s.list}_getCacheData(t){const{bar_index:e}=this._variables,r=this._cacheData[t]||{};return r.barIndex===e?r.preCacheData||{}:r}_cacheDataHandle(t,e){const{bar_index:r,_isRealTimeBar:n,_isRepeated:s}=this._variables;if(!n&&!s){const a=this._cacheData[t]||{};this._cacheData[t]=Object.assign(e,{barIndex:r,preCacheData:{...a}})}}_verifyCacheData(t){const{bar_index:e,_isRepeated:r}=this._variables,n=this._cacheData[t]||{},{barIndex:s}=n;if(s===e&&r)return n}}class sy{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_errorListener");$(this,"_historyInputs");$(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){if(!(t!=null&&t.length)){self.workerStorage.delete(this._name),this._cacheData={};return}for(const e of t){const r=e.id,n=this._historyInputs[r];(!(e!=null&&e.sourceTypeName)&&(n==null?void 0:n.defval)!==e.defval||n!=null&&n.sourceTypeName&&e.sourceTypeName!==(n==null?void 0:n.sourceTypeName))&&(this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}))}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._verifyMaxOrMin(t,e),this._cacheHandle(t,e,sr.INT)}bool(t,e){return this._cacheHandle(t,e,sr.BOOL)}color(t,e){return this._cacheHandle(t,e,sr.COLOR)}time(t,e){return this._cacheHandle(t,e,sr.TIME)}float(t,e){return this._verifyMaxOrMin(t,e),this._cacheHandle(t,e,sr.FLOAT)}price(t,e){return this._cacheHandle(t,e,sr.PRICE)}source(t,e){return this._cacheHandle(t,e,sr.SOURCE)}string(t,e){return this._cacheHandle(t,e,sr.STRING)}symbol(t,e){return this._cacheHandle(t,e,sr.SYMBOL)}session(t,e){return this._cacheHandle(t,e,sr.SESSION)}text_area(t,e){return this._cacheHandle(t,e,sr.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,sr.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,sr.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(ie.inputDefvalErr,e,Rt.Error),self.workerStorage.setValue(this._name,n,{...t}),s)if(!s.isModify)Object.assign(this._cacheData[n],t);else{const a=this._historyInputs[n];!(t.sourceTypeName||a!=null&&a.sourceTypeName)&&t.defval===(a==null?void 0:a.defval)||t.sourceTypeName&&(a==null?void 0:a.sourceTypeName)===t.sourceTypeName?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:u}=t;this._displayVerify(e,u),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===sr.SOURCE?this._cacheData[n].options=O_:t.options&&!t.options.includes(a)&&this._errorListener.addError(He(ie.inputOptErr,{defval:String(a),args:t.options.toString()}),e,Rt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ze.dataWindow)||e.includes(Ze.statusLine)||this._errorListener.addError(He(ie.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,Rt.Error)}_verifyMaxOrMin(t,e){const{defval:r,maxval:n,minval:s}=t;typeof r=="number"&&(n!==void 0&&r>n||s!==void 0&&r<s)&&this._errorListener.addError(ie.minOrMaxErr,e,Rt.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e.sort((r,n)=>(r.index||0)-(n.index||0))}}class oy{color({x:t}){return t}new({color:t,transp:e=100}){mt(e)&&(e=100);const r=(100-e)/100,{r:n,g:s,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(s)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return mt(n)&&(n=0),mt(t)&&(t=0),mt(e)&&(e=0),mt(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){if(mt(t)||mt(e)||mt(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),u=Math.min(Math.max(a,0),1),{r:c,g:f,b:d,a:h}=this._parseColor(n||"rgba(0,0,0,0)"),{r:_,g,b:y,a:p}=this._parseColor(s||"rgba(0,0,0,0)"),w=c+u*(_-c),v=f+u*(g-f),x=d+u*(y-d),b=h+u*(p-h);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var zt={};const ay=Object.prototype.toString;function as(i){const t=ay.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var uy=Object.freeze({__proto__:null,isAnyArray:as}),ly=Se(uy);function cy(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!as(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],u=r+1;u<s;u++)i[u]>a&&(a=i[u]);return a}function fy(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!as(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],u=r+1;u<s;u++)i[u]<a&&(a=i[u]);return a}function hy(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(as(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!as(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=fy(i),n=cy(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,u=t.max,c=u===void 0?t.autoMinMax?n:1:u;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var f=(c-a)/(n-r),d=0;d<i.length;d++)e[d]=(i[d]-r)*f+a;return e}var dy=Object.freeze({__proto__:null,default:hy}),_y=Se(dy);Object.defineProperty(zt,"__esModule",{value:!0});var fr=ly,uh=_y;const uo=" ".repeat(2),lh=" ".repeat(4);function py(){return ch(this)}function ch(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
|
54
|
+
(`+de(S,p)+", "+de(C,p)+") ==> "+(this._values?de(this._values[N],p):"X")}return b},n.prototype.toString=function(){return de(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(p){if(p){if(Oe(p)&&(p=p.toNumber()),!me(p)||!xe(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var w=p>0?p:0,v=p<0?-p:0,x=this._size[0],b=this._size[1],C=Math.min(x-v,b-w),E=[],A=[],N=[];N[0]=0;for(var S=w;S<b&&E.length<C;S++)for(var I=this._ptr[S],F=this._ptr[S+1],O=I;O<F;O++){var L=this._index[O];if(L===S-w+v){E.push(this._values[O]),A[E.length-1]=L-v;break}}return N.push(E.length),new n({values:E,index:A,ptr:N,size:[C,1]})},n.fromJSON=function(p){return new n(p)},n.diagonal=function(p,w,v,x,b){if(!Ae(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function(G){if(Oe(G)&&(G=G.toNumber()),!me(G)||!xe(G)||G<1)throw new Error("Size values must be positive integers");return G}),v){if(Oe(v)&&(v=v.toNumber()),!me(v)||!xe(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var C=e,E=0;en(b)&&(C=t.find(e,[b,b])||e,E=t.convert(0,b));var A=v>0?v:0,N=v<0?-v:0,S=p[0],I=p[1],F=Math.min(S-N,I-A),O;if(Ae(w)){if(w.length!==F)throw new Error("Invalid value array length");O=function(Q){return w[Q]}}else if(we(w)){var L=w.size();if(L.length!==1||L[0]!==F)throw new Error("Invalid matrix length");O=function(Q){return w.get([Q])}}else O=function(){return w};for(var z=[],q=[],W=[],R=0;R<I;R++){W.push(z.length);var Z=R-A;if(Z>=0&&Z<F){var Y=O(Z);C(Y,E)||(q.push(Z+N),z.push(Y))}}return W.push(z.length),new n({values:z,index:q,ptr:W,size:[S,I]})},n.prototype.swapRows=function(p,w){if(!me(p)||!xe(p)||!me(w)||!xe(w))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Me(p,this._size[0]),Me(w,this._size[0]),n._swapRows(p,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(p,w,v,x,b){for(var C=x[p],E=x[p+1],A=C;A<E;A++)b(v[A],w[A])},n._swapRows=function(p,w,v,x,b,C){for(var E=0;E<v;E++){var A=C[E],N=C[E+1],S=f(p,A,N,b),I=f(w,A,N,b);if(S<N&&I<N&&b[S]===p&&b[I]===w){if(x){var F=x[S];x[S]=x[I],x[I]=F}continue}if(S<N&&b[S]===p&&(I>=N||b[I]!==w)){var O=x?x[S]:void 0;b.splice(I,0,w),x&&x.splice(I,0,O),b.splice(I<=S?S+1:S,1),x&&x.splice(I<=S?S+1:S,1);continue}if(I<N&&b[I]===w&&(S>=N||b[S]!==p)){var L=x?x[I]:void 0;b.splice(S,0,p),x&&x.splice(S,0,L),b.splice(S<=I?I+1:I,1),x&&x.splice(S<=I?I+1:I,1)}}},n},{isClass:!0}),_g="number",pg=["typed"];function mg(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function gg(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var vg=gt(_g,pg,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=mg(n);if(s)return gg(s);var a=0,u=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);u&&(a=Number(u[2]),n=u[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(u){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Kr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),yg="bignumber",wg=["typed","BigNumber"],Dg=gt(yg,wg,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],u=e(s[1]),c=new e(2).pow(Number(a));if(u.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var f=new e(2).pow(Number(a)-1);return u.gte(f)?u.sub(c):u}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Kr(n,r))})}),bg="fraction",xg=["typed","Fraction"],Eg=gt(bg,xg,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Kr(n,r))})}),hf="matrix",Cg=["typed","Matrix","DenseMatrix","SparseMatrix"],Ag=gt(hf,Cg,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(hf,{"":function(){return s([])},string:function(u){return s([],u)},"string, string":function(u,c){return s([],u,c)},Array:function(u){return s(u)},Matrix:function(u){return s(u,u.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,u,c){if(u==="dense"||u==="default"||u===void 0)return new r(a,c);if(u==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(u)+".")}}),df="unaryMinus",Mg=["typed"],Fg=gt(df,Mg,i=>{var{typed:t}=i;return t(df,{number:nf,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),_f="abs",Ng=["typed"],Sg=gt(_f,Ng,i=>{var{typed:t}=i;return t(_f,{number:Qc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),pf="addScalar",Og=["typed"],Bg=gt(pf,Og,i=>{var{typed:t}=i;return t(pf,{"number, number":tf,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),mf="subtractScalar",Tg=["typed"],Ig=gt(mf,Tg,i=>{var{typed:t}=i;return t(mf,{"number, number":ef,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),$g="matAlgo11xS0s",Lg=["typed","equalScalar"],ja=gt($g,Lg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,u){var c=n._values,f=n._index,d=n._ptr,h=n._size,_=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],y=h[1],p,w=e,v=0,x=a;typeof _=="string"&&(p=_,w=t.find(e,[p,p]),v=t.convert(0,p),s=t.convert(s,p),x=t.find(a,[p,p]));for(var b=[],C=[],E=[],A=0;A<y;A++){E[A]=C.length;for(var N=d[A],S=d[A+1],I=N;I<S;I++){var F=f[I],O=u?x(s,c[I]):x(c[I],s);w(O,v)||(C.push(F),b.push(O))}}return E[y]=C.length,n.createSparseMatrix({values:b,index:C,ptr:E,size:[g,y],datatype:p})}}),Rg="matAlgo12xSfs",Pg=["typed","DenseMatrix"],Ci=gt(Rg,Pg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,u){var c=n._values,f=n._index,d=n._ptr,h=n._size,_=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],y=h[1],p,w=a;typeof _=="string"&&(p=_,s=t.convert(s,p),w=t.find(a,[p,p]));for(var v=[],x=[],b=[],C=0;C<y;C++){for(var E=C+1,A=d[C],N=d[C+1],S=A;S<N;S++){var I=f[S];x[I]=c[S],b[I]=E}for(var F=0;F<g;F++)C===0&&(v[F]=[]),b[F]===E?v[F][C]=u?w(s,x[F]):w(x[F],s):v[F][C]=u?w(s,0):w(0,s)}return new e({data:v,size:[g,y],datatype:p})}}),kg="matAlgo14xDs",zg=["typed"],Ya=gt(kg,zg,i=>{var{typed:t}=i;return function(n,s,a,u){var c=n._data,f=n._size,d=n._datatype,h,_=a;typeof d=="string"&&(h=d,s=t.convert(s,h),_=t.find(a,[h,h]));var g=f.length>0?e(_,0,f,f[0],c,s,u):[];return n.createDenseMatrix({data:g,size:ue(f),datatype:h})};function e(r,n,s,a,u,c,f){var d=[];if(n===s.length-1)for(var h=0;h<a;h++)d[h]=f?r(c,u[h]):r(u[h],c);else for(var _=0;_<a;_++)d[_]=e(r,n+1,s,s[n+1],u[_],c,f);return d}}),qg="matAlgo02xDS0",Ug=["typed","equalScalar"],Wg=gt(qg,Ug,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,u){var c=n._data,f=n._size,d=n._datatype||n.getDataType(),h=s._values,_=s._index,g=s._ptr,y=s._size,p=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(f.length!==y.length)throw new Jt(f.length,y.length);if(f[0]!==y[0]||f[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+y+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=f[0],v=f[1],x,b=e,C=0,E=a;typeof d=="string"&&d===p&&d!=="mixed"&&(x=d,b=t.find(e,[x,x]),C=t.convert(0,x),E=t.find(a,[x,x]));for(var A=[],N=[],S=[],I=0;I<v;I++){S[I]=N.length;for(var F=g[I],O=g[I+1],L=F;L<O;L++){var z=_[L],q=u?E(h[L],c[z][I]):E(c[z][I],h[L]);b(q,C)||(N.push(z),A.push(q))}}return S[v]=N.length,s.createSparseMatrix({values:A,index:N,ptr:S,size:[w,v],datatype:d===n._datatype&&p===s._datatype?x:void 0})}}),jg="matAlgo03xDSf",Yg=["typed"],Ai=gt(jg,Yg,i=>{var{typed:t}=i;return function(r,n,s,a){var u=r._data,c=r._size,f=r._datatype||r.getDataType(),d=n._values,h=n._index,_=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Jt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=c[0],w=c[1],v,x=0,b=s;typeof f=="string"&&f===y&&f!=="mixed"&&(v=f,x=t.convert(0,v),b=t.find(s,[v,v]));for(var C=[],E=0;E<p;E++)C[E]=[];for(var A=[],N=[],S=0;S<w;S++){for(var I=S+1,F=_[S],O=_[S+1],L=F;L<O;L++){var z=h[L];A[z]=a?b(d[L],u[z][S]):b(u[z][S],d[L]),N[z]=I}for(var q=0;q<p;q++)N[q]===I?C[q][S]=A[q]:C[q][S]=a?b(x,u[q][S]):b(u[q][S],x)}return r.createDenseMatrix({data:C,size:[p,w],datatype:f===r._datatype&&y===n._datatype?v:void 0})}}),Vg="matAlgo05xSfSf",Hg=["typed","equalScalar"],gf=gt(Vg,Hg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var u=n._values,c=n._index,f=n._ptr,d=n._size,h=n._datatype||n._data===void 0?n._datatype:n.getDataType(),_=s._values,g=s._index,y=s._ptr,p=s._size,w=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==p.length)throw new Jt(d.length,p.length);if(d[0]!==p[0]||d[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+p+")");var v=d[0],x=d[1],b,C=e,E=0,A=a;typeof h=="string"&&h===w&&h!=="mixed"&&(b=h,C=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var N=u&&_?[]:void 0,S=[],I=[],F=N?[]:void 0,O=N?[]:void 0,L=[],z=[],q,W,R,Z;for(W=0;W<x;W++){I[W]=S.length;var Y=W+1;for(R=f[W],Z=f[W+1];R<Z;R++)q=c[R],S.push(q),L[q]=Y,F&&(F[q]=u[R]);for(R=y[W],Z=y[W+1];R<Z;R++)q=g[R],L[q]!==Y&&S.push(q),z[q]=Y,O&&(O[q]=_[R]);if(N)for(R=I[W];R<S.length;){q=S[R];var G=L[q],Q=z[q];if(G===Y||Q===Y){var ut=G===Y?F[q]:E,_t=Q===Y?O[q]:E,at=A(ut,_t);C(at,E)?S.splice(R,1):(N.push(at),R++)}}}return I[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:I,size:[v,x],datatype:h===n._datatype&&w===s._datatype?b:void 0})}}),Zg="matAlgo13xDD",Kg=["typed"],Gg=gt(Zg,Kg,i=>{var{typed:t}=i;return function(n,s,a){var u=n._data,c=n._size,f=n._datatype,d=s._data,h=s._size,_=s._datatype,g=[];if(c.length!==h.length)throw new Jt(c.length,h.length);for(var y=0;y<c.length;y++){if(c[y]!==h[y])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");g[y]=c[y]}var p,w=a;typeof f=="string"&&f===_&&(p=f,w=t.find(a,[p,p]));var v=g.length>0?e(w,0,g,g[0],u,d):[];return n.createDenseMatrix({data:v,size:g,datatype:p})};function e(r,n,s,a,u,c){var f=[];if(n===s.length-1)for(var d=0;d<a;d++)f[d]=r(u[d],c[d]);else for(var h=0;h<a;h++)f[h]=e(r,n+1,s,s[n+1],u[h],c[h]);return f}}),Jg="broadcast",Xg=["concat"],Qg=gt(Jg,Xg,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((y,p)=>y===s._size[p]))return[n,s];for(var u=e(n._size,a,0),c=e(s._size,a,0),f=[],d=0;d<a;d++)f[d]=Math.max(u[d],c[d]);Rs(u,f),Rs(c,f);var h=n.clone(),_=s.clone();h._size.length<a?h.reshape(e(h._size,a,1)):_._size.length<a&&_.reshape(e(_._size,a,1));for(var g=0;g<a;g++)h._size[g]<f[g]&&(h=r(h,f[g],g)),_._size[g]<f[g]&&(_=r(_,f[g],g));return[h,_]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),tv="matrixAlgorithmSuite",ev=["typed","matrix","concat"],ti=gt(tv,ev,i=>{var{typed:t,matrix:e,concat:r}=i,n=Gg({typed:t}),s=Ya({typed:t}),a=Qg({concat:r});return function(c){var f=c.elop,d=c.SD||c.DS,h;f?(h={"DenseMatrix, DenseMatrix":(p,w)=>n(...a(p,w),f),"Array, Array":(p,w)=>n(...a(e(p),e(w)),f).valueOf(),"Array, DenseMatrix":(p,w)=>n(...a(e(p),w),f),"DenseMatrix, Array":(p,w)=>n(...a(p,e(w)),f)},c.SS&&(h["SparseMatrix, SparseMatrix"]=(p,w)=>c.SS(...a(p,w),f,!1)),c.DS&&(h["DenseMatrix, SparseMatrix"]=(p,w)=>c.DS(...a(p,w),f,!1),h["Array, SparseMatrix"]=(p,w)=>c.DS(...a(e(p),w),f,!1)),d&&(h["SparseMatrix, DenseMatrix"]=(p,w)=>d(...a(w,p),f,!0),h["SparseMatrix, Array"]=(p,w)=>d(...a(e(w),p),f,!0))):(h={"DenseMatrix, DenseMatrix":t.referToSelf(p=>(w,v)=>n(...a(w,v),p)),"Array, Array":t.referToSelf(p=>(w,v)=>n(...a(e(w),e(v)),p).valueOf()),"Array, DenseMatrix":t.referToSelf(p=>(w,v)=>n(...a(e(w),v),p)),"DenseMatrix, Array":t.referToSelf(p=>(w,v)=>n(...a(w,e(v)),p))},c.SS&&(h["SparseMatrix, SparseMatrix"]=t.referToSelf(p=>(w,v)=>c.SS(...a(w,v),p,!1))),c.DS&&(h["DenseMatrix, SparseMatrix"]=t.referToSelf(p=>(w,v)=>c.DS(...a(w,v),p,!1)),h["Array, SparseMatrix"]=t.referToSelf(p=>(w,v)=>c.DS(...a(e(w),v),p,!1))),d&&(h["SparseMatrix, DenseMatrix"]=t.referToSelf(p=>(w,v)=>d(...a(v,w),p,!0)),h["SparseMatrix, Array"]=t.referToSelf(p=>(w,v)=>d(...a(e(v),w),p,!0))));var _=c.scalar||"any",g=c.Ds||c.Ss;g&&(f?(h["DenseMatrix,"+_]=(p,w)=>s(p,w,f,!1),h[_+", DenseMatrix"]=(p,w)=>s(w,p,f,!0),h["Array,"+_]=(p,w)=>s(e(p),w,f,!1).valueOf(),h[_+", Array"]=(p,w)=>s(e(w),p,f,!0).valueOf()):(h["DenseMatrix,"+_]=t.referToSelf(p=>(w,v)=>s(w,v,p,!1)),h[_+", DenseMatrix"]=t.referToSelf(p=>(w,v)=>s(v,w,p,!0)),h["Array,"+_]=t.referToSelf(p=>(w,v)=>s(e(w),v,p,!1).valueOf()),h[_+", Array"]=t.referToSelf(p=>(w,v)=>s(e(v),w,p,!0).valueOf())));var y=c.sS!==void 0?c.sS:c.Ss;return f?(c.Ss&&(h["SparseMatrix,"+_]=(p,w)=>c.Ss(p,w,f,!1)),y&&(h[_+", SparseMatrix"]=(p,w)=>y(w,p,f,!0))):(c.Ss&&(h["SparseMatrix,"+_]=t.referToSelf(p=>(w,v)=>c.Ss(w,v,p,!1))),y&&(h[_+", SparseMatrix"]=t.referToSelf(p=>(w,v)=>y(v,w,p,!0)))),f&&f.signatures&&lc(h,f.signatures),h}}),rv="matAlgo01xDSid",nv=["typed"],vf=gt(rv,nv,i=>{var{typed:t}=i;return function(r,n,s,a){var u=r._data,c=r._size,f=r._datatype||r.getDataType(),d=n._values,h=n._index,_=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Jt(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=c[0],w=c[1],v=typeof f=="string"&&f!=="mixed"&&f===y?f:void 0,x=v?t.find(s,[v,v]):s,b,C,E=[];for(b=0;b<p;b++)E[b]=[];var A=[],N=[];for(C=0;C<w;C++){for(var S=C+1,I=_[C],F=_[C+1],O=I;O<F;O++)b=h[O],A[b]=a?x(d[O],u[b][C]):x(u[b][C],d[O]),N[b]=S;for(b=0;b<p;b++)N[b]===S?E[b][C]=A[b]:E[b][C]=u[b][C]}return r.createDenseMatrix({data:E,size:[p,w],datatype:f===r._datatype&&y===n._datatype?v:void 0})}}),iv="matAlgo04xSidSid",sv=["typed","equalScalar"],ov=gt(iv,sv,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var u=n._values,c=n._index,f=n._ptr,d=n._size,h=n._datatype||n._data===void 0?n._datatype:n.getDataType(),_=s._values,g=s._index,y=s._ptr,p=s._size,w=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==p.length)throw new Jt(d.length,p.length);if(d[0]!==p[0]||d[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+p+")");var v=d[0],x=d[1],b,C=e,E=0,A=a;typeof h=="string"&&h===w&&h!=="mixed"&&(b=h,C=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var N=u&&_?[]:void 0,S=[],I=[],F=u&&_?[]:void 0,O=u&&_?[]:void 0,L=[],z=[],q,W,R,Z,Y;for(W=0;W<x;W++){I[W]=S.length;var G=W+1;for(Z=f[W],Y=f[W+1],R=Z;R<Y;R++)q=c[R],S.push(q),L[q]=G,F&&(F[q]=u[R]);for(Z=y[W],Y=y[W+1],R=Z;R<Y;R++)if(q=g[R],L[q]===G){if(F){var Q=A(F[q],_[R]);C(Q,E)?L[q]=null:F[q]=Q}}else S.push(q),z[q]=G,O&&(O[q]=_[R]);if(F&&O)for(R=I[W];R<S.length;)q=S[R],L[q]===G?(N[R]=F[q],R++):z[q]===G?(N[R]=O[q],R++):S.splice(R,1)}return I[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:I,size:[v,x],datatype:h===n._datatype&&w===s._datatype?b:void 0})}}),av="matAlgo10xSids",uv=["typed","DenseMatrix"],yf=gt(av,uv,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,u){var c=n._values,f=n._index,d=n._ptr,h=n._size,_=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],y=h[1],p,w=a;typeof _=="string"&&(p=_,s=t.convert(s,p),w=t.find(a,[p,p]));for(var v=[],x=[],b=[],C=0;C<y;C++){for(var E=C+1,A=d[C],N=d[C+1],S=A;S<N;S++){var I=f[S];x[I]=c[S],b[I]=E}for(var F=0;F<g;F++)C===0&&(v[F]=[]),b[F]===E?v[F][C]=u?w(s,x[F]):w(x[F],s):v[F][C]=s}return new e({data:v,size:[g,y],datatype:p})}}),lv="multiplyScalar",cv=["typed"],fv=gt(lv,cv,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":rf,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),wf="multiply",hv=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],dv=gt(wf,hv,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,u=ja({typed:t,equalScalar:s}),c=Ya({typed:t});function f(E,A){switch(E.length){case 1:switch(A.length){case 1:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+E[0]+") must match Matrix rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;case 2:switch(A.length){case 1:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+E[1]+") must match Vector length ("+A[0]+")");break;case 2:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+E[1]+") must match Matrix B rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+E.length+" dimensions)")}}function d(E,A,N){if(N===0)throw new Error("Cannot multiply two empty vectors");return a(E,A)}function h(E,A){if(A.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return _(E,A)}function _(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._data,O=A._size,L=A._datatype||A.getDataType(),z=S[0],q=O[1],W,R=r,Z=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&(W=I,R=t.find(r,[W,W]),Z=t.find(n,[W,W]));for(var Y=[],G=0;G<q;G++){for(var Q=Z(N[0],F[0][G]),ut=1;ut<z;ut++)Q=R(Q,Z(N[ut],F[ut][G]));Y[G]=Q}return E.createDenseMatrix({data:Y,size:[q],datatype:I===E._datatype&&L===A._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":p,"SparseMatrix, any":x}),y=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":C});function p(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._data,O=A._datatype||A.getDataType(),L=S[0],z=S[1],q,W=r,R=n;I&&O&&I===O&&typeof I=="string"&&I!=="mixed"&&(q=I,W=t.find(r,[q,q]),R=t.find(n,[q,q]));for(var Z=[],Y=0;Y<L;Y++){for(var G=N[Y],Q=R(G[0],F[0]),ut=1;ut<z;ut++)Q=W(Q,R(G[ut],F[ut]));Z[Y]=Q}return E.createDenseMatrix({data:Z,size:[L],datatype:I===E._datatype&&O===A._datatype?q:void 0})}function w(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._data,O=A._size,L=A._datatype||A.getDataType(),z=S[0],q=S[1],W=O[1],R,Z=r,Y=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&I!=="mixed"&&(R=I,Z=t.find(r,[R,R]),Y=t.find(n,[R,R]));for(var G=[],Q=0;Q<z;Q++){var ut=N[Q];G[Q]=[];for(var _t=0;_t<W;_t++){for(var at=Y(ut[0],F[0][_t]),vt=1;vt<q;vt++)at=Z(at,Y(ut[vt],F[vt][_t]));G[Q][_t]=at}}return E.createDenseMatrix({data:G,size:[z,W],datatype:I===E._datatype&&L===A._datatype?R:void 0})}function v(E,A){var N=E._data,S=E._size,I=E._datatype||E.getDataType(),F=A._values,O=A._index,L=A._ptr,z=A._size,q=A._datatype||A._data===void 0?A._datatype:A.getDataType();if(!F)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],R=z[1],Z,Y=r,G=n,Q=s,ut=0;I&&q&&I===q&&typeof I=="string"&&I!=="mixed"&&(Z=I,Y=t.find(r,[Z,Z]),G=t.find(n,[Z,Z]),Q=t.find(s,[Z,Z]),ut=t.convert(0,Z));for(var _t=[],at=[],vt=[],wt=A.createSparseMatrix({values:_t,index:at,ptr:vt,size:[W,R],datatype:I===E._datatype&&q===A._datatype?Z:void 0}),Ct=0;Ct<R;Ct++){vt[Ct]=at.length;var bt=L[Ct],re=L[Ct+1];if(re>bt)for(var Bt=0,Nt=0;Nt<W;Nt++){for(var he=Nt+1,se=void 0,qt=bt;qt<re;qt++){var Xt=O[qt];Bt!==he?(se=G(N[Nt][Xt],F[qt]),Bt=he):se=Y(se,G(N[Nt][Xt],F[qt]))}Bt===he&&!Q(se,ut)&&(at.push(Nt),_t.push(se))}}return vt[R]=at.length,wt}function x(E,A){var N=E._values,S=E._index,I=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,L=A._datatype||A.getDataType(),z=E._size[0],q=A._size[0],W=[],R=[],Z=[],Y,G=r,Q=n,ut=s,_t=0;F&&L&&F===L&&typeof F=="string"&&F!=="mixed"&&(Y=F,G=t.find(r,[Y,Y]),Q=t.find(n,[Y,Y]),ut=t.find(s,[Y,Y]),_t=t.convert(0,Y));var at=[],vt=[];Z[0]=0;for(var wt=0;wt<q;wt++){var Ct=O[wt];if(!ut(Ct,_t))for(var bt=I[wt],re=I[wt+1],Bt=bt;Bt<re;Bt++){var Nt=S[Bt];vt[Nt]?at[Nt]=G(at[Nt],Q(Ct,N[Bt])):(vt[Nt]=!0,R.push(Nt),at[Nt]=Q(Ct,N[Bt]))}}for(var he=R.length,se=0;se<he;se++){var qt=R[se];W[se]=at[qt]}return Z[1]=R.length,E.createSparseMatrix({values:W,index:R,ptr:Z,size:[z,1],datatype:F===E._datatype&&L===A._datatype?Y:void 0})}function b(E,A){var N=E._values,S=E._index,I=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,L=A._datatype||A.getDataType(),z=E._size[0],q=A._size[0],W=A._size[1],R,Z=r,Y=n,G=s,Q=0;F&&L&&F===L&&typeof F=="string"&&F!=="mixed"&&(R=F,Z=t.find(r,[R,R]),Y=t.find(n,[R,R]),G=t.find(s,[R,R]),Q=t.convert(0,R));for(var ut=[],_t=[],at=[],vt=E.createSparseMatrix({values:ut,index:_t,ptr:at,size:[z,W],datatype:F===E._datatype&&L===A._datatype?R:void 0}),wt=[],Ct=[],bt=0;bt<W;bt++){at[bt]=_t.length;for(var re=bt+1,Bt=0;Bt<q;Bt++){var Nt=O[Bt][bt];if(!G(Nt,Q))for(var he=I[Bt],se=I[Bt+1],qt=he;qt<se;qt++){var Xt=S[qt];Ct[Xt]!==re?(Ct[Xt]=re,_t.push(Xt),wt[Xt]=Y(Nt,N[qt])):wt[Xt]=Z(wt[Xt],Y(Nt,N[qt]))}}for(var Le=at[bt],Dr=_t.length,ze=Le;ze<Dr;ze++){var mn=_t[ze];ut[ze]=wt[mn]}}return at[W]=_t.length,vt}function C(E,A){var N=E._values,S=E._index,I=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType(),O=A._values,L=A._index,z=A._ptr,q=A._datatype||A._data===void 0?A._datatype:A.getDataType(),W=E._size[0],R=A._size[1],Z=N&&O,Y,G=r,Q=n;F&&q&&F===q&&typeof F=="string"&&F!=="mixed"&&(Y=F,G=t.find(r,[Y,Y]),Q=t.find(n,[Y,Y]));for(var ut=Z?[]:void 0,_t=[],at=[],vt=E.createSparseMatrix({values:ut,index:_t,ptr:at,size:[W,R],datatype:F===E._datatype&&q===A._datatype?Y:void 0}),wt=Z?[]:void 0,Ct=[],bt,re,Bt,Nt,he,se,qt,Xt,Le=0;Le<R;Le++){at[Le]=_t.length;var Dr=Le+1;for(he=z[Le],se=z[Le+1],Nt=he;Nt<se;Nt++)if(Xt=L[Nt],Z)for(re=I[Xt],Bt=I[Xt+1],bt=re;bt<Bt;bt++)qt=S[bt],Ct[qt]!==Dr?(Ct[qt]=Dr,_t.push(qt),wt[qt]=Q(O[Nt],N[bt])):wt[qt]=G(wt[qt],Q(O[Nt],N[bt]));else for(re=I[Xt],Bt=I[Xt+1],bt=re;bt<Bt;bt++)qt=S[bt],Ct[qt]!==Dr&&(Ct[qt]=Dr,_t.push(qt));if(Z)for(var ze=at[Le],mn=_t.length,Ln=ze;Ln<mn;Ln++){var gn=_t[Ln];ut[Ln]=wt[gn]}}return at[R]=_t.length,vt}return t(wf,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(A,N)=>{f(Ie(A),Ie(N));var S=E(e(A),e(N));return we(S)?S.valueOf():S}),"Matrix, Matrix":function(A,N){var S=A.size(),I=N.size();return f(S,I),S.length===1?I.length===1?d(A,N,S[0]):h(A,N):I.length===1?g(A,N):y(A,N)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(A,N)=>E(A,e(N))),"Array, Matrix":t.referToSelf(E=>(A,N)=>E(e(A,N.storage()),N)),"SparseMatrix, any":function(A,N){return u(A,N,n,!1)},"DenseMatrix, any":function(A,N){return c(A,N,n,!1)},"any, SparseMatrix":function(A,N){return u(N,A,n,!0)},"any, DenseMatrix":function(A,N){return c(N,A,n,!0)},"Array, any":function(A,N){return c(e(A),N,n,!1).valueOf()},"any, Array":function(A,N){return c(e(N),A,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(A,N,S)=>{for(var I=E(A,N),F=0;F<S.length;F++)I=E(I,S[F]);return I})})}),Df="subtract",_v=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],pv=gt(Df,_v,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:u}=i,c=vf({typed:t}),f=Ai({typed:t}),d=gf({typed:t,equalScalar:r}),h=yf({typed:t,DenseMatrix:a}),_=Ci({typed:t,DenseMatrix:a}),g=ti({typed:t,matrix:e,concat:u});return t(Df,{"any, any":n},g({elop:n,SS:d,DS:c,SD:f,Ss:_,sS:h}))}),mv="matAlgo07xSSf",gv=["typed","DenseMatrix"],Xs=gt(mv,gv,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,u){var c=s._size,f=s._datatype||s._data===void 0?s._datatype:s.getDataType(),d=a._size,h=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==d.length)throw new Jt(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var _=c[0],g=c[1],y,p=0,w=u;typeof f=="string"&&f===h&&f!=="mixed"&&(y=f,p=t.convert(0,y),w=t.find(u,[y,y]));var v,x,b=[];for(v=0;v<_;v++)b[v]=[];var C=[],E=[],A=[],N=[];for(x=0;x<g;x++){var S=x+1;for(r(s,x,A,C,S),r(a,x,N,E,S),v=0;v<_;v++){var I=A[v]===S?C[v]:p,F=N[v]===S?E[v]:p;b[v][x]=w(I,F)}}return new e({data:b,size:[_,g],datatype:f===s._datatype&&h===a._datatype?y:void 0})};function r(n,s,a,u,c){for(var f=n._values,d=n._index,h=n._ptr,_=h[s],g=h[s+1];_<g;_++){var y=d[_];a[y]=c,u[y]=f[_]}}}),bf="conj",vv=["typed"],yv=gt(bf,vv,i=>{var{typed:t}=i;return t(bf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Kr(r,e))})}),xf="concat",wv=["typed","matrix","isInteger"],Dv=gt(xf,wv,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(xf,{"...Array | Matrix | number | BigNumber":function(s){var a,u=s.length,c=-1,f,d=!1,h=[];for(a=0;a<u;a++){var _=s[a];if(we(_)&&(d=!0),me(_)||Oe(_)){if(a!==u-1)throw new Error("Dimension must be specified as last argument");if(f=c,c=_.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>f)throw new Nn(c,f+1)}else{var g=ue(_).valueOf(),y=Ie(g);if(h[a]=g,f=c,c=y.length-1,a>0&&c!==f)throw new Jt(f+1,c+1)}}if(h.length===0)throw new SyntaxError("At least one matrix expected");for(var p=h.shift();h.length;)p=Nc(p,h.shift(),c);return d?e(p):p},"...string":function(s){return s.join("")}})}),Ef="count",bv=["typed","size","prod"],xv=gt(Ef,bv,i=>{var{typed:t,size:e,prod:r}=i;return t(Ef,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Cf="identity",Ev=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Cv=gt(Cf,Ev,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(Cf,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(d){return r(d)},"number | BigNumber":function(d){return c(d,d,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(d,h){return c(d,d,h)},"number | BigNumber, number | BigNumber":function(d,h){return c(d,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(d,h,_){return c(d,h,_)},Array:function(d){return u(d)},"Array, string":function(d,h){return u(d,h)},Matrix:function(d){return u(d.valueOf(),d.storage())},"Matrix, string":function(d,h){return u(d.valueOf(),h)}});function u(f,d){switch(f.length){case 0:return d?r(d):[];case 1:return c(f[0],f[0],d);case 2:return c(f[0],f[1],d);default:throw new Error("Vector containing two values expected")}}function c(f,d,h){var _=Oe(f)||Oe(d)?n:null;if(Oe(f)&&(f=f.toNumber()),Oe(d)&&(d=d.toNumber()),!xe(f)||f<1)throw new Error("Parameters in function identity must be positive integers");if(!xe(d)||d<1)throw new Error("Parameters in function identity must be positive integers");var g=_?new n(1):1,y=_?new _(0):0,p=[f,d];if(h){if(h==="sparse")return a.diagonal(p,g,0,y);if(h==="dense")return s.diagonal(p,g,0,y);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}for(var w=Sa([],p,y),v=f<d?f:d,x=0;x<v;x++)w[x][x]=g;return w}}),Af="kron",Av=["typed","matrix","multiplyScalar"],Mv=gt(Af,Av,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Af,{"Matrix, Matrix":function(a,u){return e(n(a.toArray(),u.toArray()))},"Matrix, Array":function(a,u){return e(n(a.toArray(),u))},"Array, Matrix":function(a,u){return e(n(a,u.toArray()))},"Array, Array":n});function n(s,a){if(Ie(s).length===1&&(s=[s]),Ie(a).length===1&&(a=[a]),Ie(s).length>2||Ie(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var u=[],c=[];return s.map(function(f){return a.map(function(d){return c=[],u.push(c),f.map(function(h){return d.map(function(_){return c.push(r(h,_))})})})})&&u}});function Fv(){throw new Error('No "bignumber" implementation available')}function Nv(){throw new Error('No "fraction" implementation available')}function Sv(){throw new Error('No "matrix" implementation available')}var Mf="reshape",Ov=["typed","isInteger","matrix"],Bv=gt(Mf,Ov,i=>{var{typed:t,isInteger:e}=i;return t(Mf,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),Ba(n,s)}})}),Ff="size",Tv=["typed","config","?matrix"],Iv=gt(Ff,Tv,i=>{var{typed:t,config:e,matrix:r}=i;return t(Ff,{Matrix:function(s){return s.create(s.size())},Array:Ie,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):Sv()}})}),Nf="transpose",$v=["typed","matrix"],Lv=gt(Nf,$v,i=>{var{typed:t,matrix:e}=i;return t(Nf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:ue});function r(a){var u=a.size(),c;switch(u.length){case 1:c=a.clone();break;case 2:{var f=u[0],d=u[1];if(d===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+de(u)+")");switch(a.storage()){case"dense":c=n(a,f,d);break;case"sparse":c=s(a,f,d);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+de(u)+")")}return c}function n(a,u,c){for(var f=a._data,d=[],h,_=0;_<c;_++){h=d[_]=[];for(var g=0;g<u;g++)h[g]=ue(f[g][_])}return a.createDenseMatrix({data:d,size:[c,u],datatype:a._datatype})}function s(a,u,c){for(var f=a._values,d=a._index,h=a._ptr,_=f?[]:void 0,g=[],y=[],p=[],w=0;w<u;w++)p[w]=0;var v,x,b;for(v=0,x=d.length;v<x;v++)p[d[v]]++;for(var C=0,E=0;E<u;E++)y.push(C),C+=p[E],p[E]=y[E];for(y.push(C),b=0;b<c;b++)for(var A=h[b],N=h[b+1],S=A;S<N;S++){var I=p[d[S]]++;g[I]=b,f&&(_[I]=ue(f[S]))}return a.createSparseMatrix({values:_,index:g,ptr:y,size:[c,u],datatype:a._datatype})}}),Sf="ctranspose",Rv=["typed","transpose","conj"],Pv=gt(Sf,Rv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(Sf,{any:function(s){return r(e(s))}})}),Of="mode",kv=["typed","isNaN","isNumeric"],zv=gt(Of,kv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(Of,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=Ia(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var u={},c=[],f=0,d=0;d<s.length;d++){var h=s[d];if(r(h)&&e(h))throw new Error("Cannot calculate mode of an array containing NaN values");h in u||(u[h]=0),u[h]++,u[h]===f?c.push(h):u[h]>f&&(f=u[h],c=[h])}return c}});function In(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+Fn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+Fn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var Bf="prod",qv=["typed","config","multiplyScalar","numeric"],Uv=gt(Bf,qv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(Bf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(u,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(u){return s(u)}});function s(a){var u;if(ns(a,function(c){try{u=u===void 0?c:r(u,c)}catch(f){throw In(f,"prod",c)}}),typeof u=="string"&&(u=n(u,e.number)),u===void 0)throw new Error("Cannot calculate prod of an empty array");return u}}),Wv="numeric",jv=["number","?bignumber","?fraction"],Yv=gt(Wv,jv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):Fv,Fraction:r?a=>r(a):Nv};return function(u){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",f=arguments.length>2?arguments[2]:void 0;if(f!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var d=Fn(u);if(!(d in n))throw new TypeError("Cannot convert "+u+' of type "'+d+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in s))throw new TypeError("Cannot convert "+u+' to type "'+c+'"; valid output types are '+Object.keys(s).join(", "));return c===d?u:s[c](u)}}),Tf="divideScalar",Vv=["typed","numeric"],Hv=gt(Tf,Vv,i=>{var{typed:t,numeric:e}=i;return t(Tf,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),If="pow",Zv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Kv=gt(If,Zv,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:u,fraction:c,Complex:f}=i;return t(If,{"number, number":d,"Complex, Complex":function(y,p){return y.pow(p)},"BigNumber, BigNumber":function(y,p){return p.isInteger()||y>=0||e.predictable?y.pow(p):new f(y.toNumber(),0).pow(p.toNumber(),0)},"Fraction, Fraction":function(y,p){var w=y.pow(p);if(w!=null)return w;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return d(y.valueOf(),p.valueOf())},"Array, number":h,"Array, BigNumber":function(y,p){return h(y,p.toNumber())},"Matrix, number":_,"Matrix, BigNumber":function(y,p){return _(y,p.toNumber())},"Unit, number | BigNumber":function(y,p){return y.pow(p)}});function d(g,y){if(e.predictable&&!xe(y)&&g<0)try{var p=c(y),w=u(p);if((y===w||Math.abs((y-w)/y)<1e-14)&&p.d%2===1)return(p.n%2===0?1:-1)*Math.pow(-g,y)}catch{}return e.predictable&&(g<-1&&y===1/0||g>-1&&g<0&&y===-1/0)?NaN:xe(y)||g>=0||e.predictable?sf(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new f(g,0).pow(y,0)}function h(g,y){if(!xe(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var p=Ie(g);if(p.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+p.length+" dimensions)");if(p[0]!==p[1])throw new Error("For A^b, A must be square (size is "+p[0]+"x"+p[1]+")");if(y<0)try{return h(a(g),-y)}catch(x){throw x.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 "+y+")"):x}for(var w=r(p[0]).valueOf(),v=g;y>=1;)(y&1)===1&&(w=n(v,w)),y>>=1,v=n(v,v);return w}function _(g,y){return s(h(g.valueOf(),y))}}),$f="dotDivide",Gv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Jv=gt($f,Gv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,u=Wg({typed:t,equalScalar:r}),c=Ai({typed:t}),f=Xs({typed:t,DenseMatrix:s}),d=ja({typed:t,equalScalar:r}),h=Ci({typed:t,DenseMatrix:s}),_=ti({typed:t,matrix:e,concat:a});return t($f,_({elop:n,SS:f,DS:c,SD:u,Ss:d,sS:h}))}),Qs="compare",Xv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],Qv=gt(Qs,Xv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:u,concat:c}=i,f=Ai({typed:t}),d=gf({typed:t,equalScalar:r}),h=Ci({typed:t,DenseMatrix:u}),_=ti({typed:t,matrix:n,concat:c}),g=Gs({typed:t});return t(Qs,t1({typed:t,config:e}),{"boolean, boolean":function(p,w){return p===w?0:p>w?1:-1},"BigNumber, BigNumber":function(p,w){return Ks(p,w,e.epsilon)?new s(0):new s(p.cmp(w))},"Fraction, Fraction":function(p,w){return new a(p.compare(w))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,_({SS:d,DS:f,Ss:h}))}),t1=gt(Qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Qs,{"number, number":function(n,s){return Qn(n,s,e.epsilon)?0:n>s?1:-1}})}),to="equal",e1=["typed","matrix","equalScalar","DenseMatrix","concat"],r1=gt(to,e1,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),u=Xs({typed:t,DenseMatrix:n}),c=Ci({typed:t,DenseMatrix:n}),f=ti({typed:t,matrix:e,concat:s});return t(to,n1({typed:t,equalScalar:r}),f({elop:r,SS:u,DS:a,Ss:c}))}),n1=gt(to,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(to,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),eo="smaller",i1=["typed","config","matrix","DenseMatrix","concat"],s1=gt(eo,i1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),u=Xs({typed:t,DenseMatrix:n}),c=Ci({typed:t,DenseMatrix:n}),f=ti({typed:t,matrix:r,concat:s}),d=Gs({typed:t});return t(eo,o1({typed:t,config:e}),{"boolean, boolean":(h,_)=>h<_,"BigNumber, BigNumber":function(_,g){return _.lt(g)&&!Ks(_,g,e.epsilon)},"Fraction, Fraction":(h,_)=>h.compare(_)===-1,"Complex, Complex":function(_,g){throw new TypeError("No ordering relation is defined for complex numbers")}},d,f({SS:u,DS:a,Ss:c}))}),o1=gt(eo,["typed","config"],i=>{var{typed:t,config:e}=i;return t(eo,{"number, number":function(n,s){return n<s&&!Qn(n,s,e.epsilon)}})}),ro="larger",a1=["typed","config","matrix","DenseMatrix","concat"],u1=gt(ro,a1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),u=Xs({typed:t,DenseMatrix:n}),c=Ci({typed:t,DenseMatrix:n}),f=ti({typed:t,matrix:r,concat:s}),d=Gs({typed:t});return t(ro,l1({typed:t,config:e}),{"boolean, boolean":(h,_)=>h>_,"BigNumber, BigNumber":function(_,g){return _.gt(g)&&!Ks(_,g,e.epsilon)},"Fraction, Fraction":(h,_)=>h.compare(_)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,f({SS:u,DS:a,Ss:c}))}),l1=gt(ro,["typed","config"],i=>{var{typed:t,config:e}=i;return t(ro,{"number, number":function(n,s){return n>s&&!Qn(n,s,e.epsilon)}})}),Lf="deepEqual",c1=["typed","equal"],f1=gt(Lf,c1,i=>{var{typed:t,equal:e}=i;return t(Lf,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var u=0;u<a;u++)if(!r(n[u],s[u]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),Rf="partitionSelect",h1=["typed","isNumeric","isNaN","compare"],d1=gt(Rf,h1,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(f,d)=>-n(f,d);return t(Rf,{"Array | Matrix, number":function(d,h){return u(d,h,s)},"Array | Matrix, number, string":function(d,h,_){if(_==="asc")return u(d,h,s);if(_==="desc")return u(d,h,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":u});function u(f,d,h){if(!xe(d)||d<0)throw new Error("k must be a non-negative integer");if(we(f)){var _=f.size();if(_.length>1)throw new Error("Only one dimensional matrices supported");return c(f.valueOf(),d,h)}if(Array.isArray(f))return c(f,d,h)}function c(f,d,h){if(d>=f.length)throw new Error("k out of bounds");for(var _=0;_<f.length;_++)if(e(f[_])&&r(f[_]))return f[_];for(var g=0,y=f.length-1;g<y;){for(var p=g,w=y,v=f[Math.floor(Math.random()*(y-g+1))+g];p<w;)if(h(f[p],v)>=0){var x=f[w];f[w]=f[p],f[p]=x,--w}else++p;h(f[p],v)>0&&--p,d<=p?y=p:g=p+1}return f[d]}}),Pf="max",_1=["typed","config","numeric","larger"],p1=gt(Pf,_1,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(Pf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,f){return Wa(c,f.valueOf(),s)},"...":function(c){if(Vs(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function s(u,c){try{return n(u,c)?u:c}catch(f){throw In(f,"max",c)}}function a(u){var c;if(ns(u,function(f){try{isNaN(f)&&typeof f=="number"?c=NaN:(c===void 0||n(f,c))&&(c=f)}catch(d){throw In(d,"max",f)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),kf="min",m1=["typed","config","numeric","smaller"],g1=gt(kf,m1,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(kf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,f){return Wa(c,f.valueOf(),s)},"...":function(c){if(Vs(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function s(u,c){try{return n(u,c)?u:c}catch(f){throw In(f,"min",c)}}function a(u){var c;if(ns(u,function(f){try{isNaN(f)&&typeof f=="number"?c=NaN:(c===void 0||n(f,c))&&(c=f)}catch(d){throw In(d,"min",f)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),zf="add",v1=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],y1=gt(zf,v1,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:u}=i,c=vf({typed:t}),f=ov({typed:t,equalScalar:n}),d=yf({typed:t,DenseMatrix:s}),h=ti({typed:t,matrix:e,concat:u});return t(zf,{"any, any":r,"any, any, ...any":t.referToSelf(_=>(g,y,p)=>{for(var w=_(g,y),v=0;v<p.length;v++)w=_(w,p[v]);return w})},h({elop:r,DS:c,SS:f,Ss:d}))}),qf="dot",w1=["typed","addScalar","multiplyScalar","conj","size"],D1=gt(qf,w1,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(qf,{"Array | DenseMatrix, Array | DenseMatrix":u,"SparseMatrix, SparseMatrix":c});function a(d,h){var _=f(d),g=f(h),y,p;if(_.length===1)y=_[0];else if(_.length===2&&_[1]===1)y=_[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+_.join(", ")+")");if(g.length===1)p=g[0];else if(g.length===2&&g[1]===1)p=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(y!==p)throw new RangeError("Vectors must have equal length ("+y+" != "+p+")");if(y===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return y}function u(d,h){var _=a(d,h),g=we(d)?d._data:d,y=we(d)?d._datatype||d.getDataType():void 0,p=we(h)?h._data:h,w=we(h)?h._datatype||h.getDataType():void 0,v=f(d).length===2,x=f(h).length===2,b=e,C=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var E=y;b=t.find(e,[E,E]),C=t.find(r,[E,E])}if(!v&&!x){for(var A=C(n(g[0]),p[0]),N=1;N<_;N++)A=b(A,C(n(g[N]),p[N]));return A}if(!v&&x){for(var S=C(n(g[0]),p[0][0]),I=1;I<_;I++)S=b(S,C(n(g[I]),p[I][0]));return S}if(v&&!x){for(var F=C(n(g[0][0]),p[0]),O=1;O<_;O++)F=b(F,C(n(g[O][0]),p[O]));return F}if(v&&x){for(var L=C(n(g[0][0]),p[0][0]),z=1;z<_;z++)L=b(L,C(n(g[z][0]),p[z][0]));return L}}function c(d,h){a(d,h);for(var _=d._index,g=d._values,y=h._index,p=h._values,w=0,v=e,x=r,b=0,C=0;b<_.length&&C<y.length;){var E=_[b],A=y[C];if(E<A){b++;continue}if(E>A){C++;continue}E===A&&(w=v(w,x(g[b],p[C])),b++,C++)}return w}function f(d){return we(d)?d.size():s(d)}}),b1="trace",x1=["typed","matrix","add"],E1=gt(b1,x1,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(u){return n(e(u))},SparseMatrix:s,DenseMatrix:n,any:ue});function n(a){var u=a._size,c=a._data;switch(u.length){case 1:if(u[0]===1)return ue(c[0]);throw new RangeError("Matrix must be square (size: "+de(u)+")");case 2:{var f=u[0],d=u[1];if(f===d){for(var h=0,_=0;_<f;_++)h=r(h,c[_][_]);return h}else throw new RangeError("Matrix must be square (size: "+de(u)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+de(u)+")")}}function s(a){var u=a._values,c=a._index,f=a._ptr,d=a._size,h=d[0],_=d[1];if(h===_){var g=0;if(u.length>0)for(var y=0;y<_;y++)for(var p=f[y],w=f[y+1],v=p;v<w;v++){var x=c[v];if(x===y){g=r(g,u[v]);break}if(x>y)break}return g}throw new RangeError("Matrix must be square (size: "+de(d)+")")}}),Uf="det",C1=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],A1=gt(Uf,C1,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:u}=i;return t(Uf,{any:function(d){return ue(d)},"Array | Matrix":function(d){var h;switch(we(d)?h=d.size():Array.isArray(d)?(d=e(d),h=d.size()):h=[],h.length){case 0:return ue(d);case 1:if(h[0]===1)return ue(d.valueOf()[0]);if(h[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+de(h)+")");case 2:{var _=h[0],g=h[1];if(_===g)return c(d.clone().valueOf(),_);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+de(h)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+de(h)+")")}}});function c(f,d,h){if(d===1)return ue(f[0][0]);if(d===2)return r(n(f[0][0],f[1][1]),n(f[1][0],f[0][1]));for(var _=!1,g=new Array(d).fill(0).map((N,S)=>S),y=0;y<d;y++){var p=g[y];if(a(f[p][y])){var w=void 0;for(w=y+1;w<d;w++)if(!a(f[g[w]][y])){p=g[w],g[w]=g[y],g[y]=p,_=!_;break}if(w===d)return f[p][y]}for(var v=f[p][y],x=y===0?1:f[g[y-1]][y-1],b=y+1;b<d;b++)for(var C=g[b],E=y+1;E<d;E++)f[C][E]=s(r(n(f[C][E],v),n(f[C][y],f[p][E])),x)}var A=f[g[d-1]][d-1];return _?u(A):A}}),Wf="inv",M1=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],F1=gt(Wf,M1,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:u,identity:c,abs:f}=i;return t(Wf,{"Array | Matrix":function(_){var g=we(_)?_.size():Ie(_);switch(g.length){case 1:if(g[0]===1)return we(_)?e([r(1,_.valueOf()[0])]):[r(1,_[0])];throw new RangeError("Matrix must be square (size: "+de(g)+")");case 2:{var y=g[0],p=g[1];if(y===p)return we(_)?e(d(_.valueOf(),y,p),_.storage()):d(_,y,p);throw new RangeError("Matrix must be square (size: "+de(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+de(g)+")")}},any:function(_){return r(1,_)}});function d(h,_,g){var y,p,w,v,x;if(_===1){if(v=h[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(_===2){var b=u(h);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(h[1][1],b),r(a(h[0][1]),b)],[r(a(h[1][0]),b),r(h[0][0],b)]]}else{var C=h.concat();for(y=0;y<_;y++)C[y]=C[y].concat();for(var E=c(_).valueOf(),A=0;A<g;A++){var N=f(C[A][A]),S=A;for(y=A+1;y<_;)f(C[y][A])>N&&(N=f(C[y][A]),S=y),y++;if(N===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==A&&(x=C[A],C[A]=C[y],C[y]=x,x=E[A],E[A]=E[y],E[y]=x);var I=C[A],F=E[A];for(y=0;y<_;y++){var O=C[y],L=E[y];if(y!==A){if(O[A]!==0){for(w=r(a(O[A]),I[A]),p=A;p<g;p++)O[p]=n(O[p],s(w,I[p]));for(p=0;p<g;p++)L[p]=n(L[p],s(w,F[p]))}}else{for(w=I[A],p=A;p<g;p++)O[p]=r(O[p],w);for(p=0;p<g;p++)L[p]=r(L[p],w)}}}return E}}}),jf="pinv",N1=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],S1=gt(jf,N1,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:u,ctranspose:c,divideScalar:f,multiply:d,add:h,Complex:_}=i;return t(jf,{"Array | Matrix":function(b){var C=we(b)?b.size():Ie(b);switch(C.length){case 1:return v(b)?c(b):C[0]===1?r(b):a(c(b),u(b,b));case 2:{if(v(b))return c(b);var E=C[0],A=C[1];if(E===A)try{return r(b)}catch(N){if(!(N instanceof Error&&N.message.match(/Cannot calculate inverse, determinant is zero/)))throw N}return we(b)?e(g(b.valueOf(),E,A),b.storage()):g(b,E,A)}default:throw new RangeError("Matrix must be two dimensional (size: "+de(C)+")")}},any:function(b){return s(b,0)?ue(b):f(1,b)}});function g(x,b,C){var{C:E,F:A}=p(x,b,C),N=d(r(d(c(E),E)),c(E)),S=d(c(A),r(d(A,c(A))));return d(S,N)}function y(x,b,C){for(var E=ue(x),A=0,N=0;N<b;N++){if(C<=A)return E;for(var S=N;w(E[S][A]);)if(S++,b===S&&(S=N,A++,C===A))return E;[E[S],E[N]]=[E[N],E[S]];for(var I=E[N][A],F=0;F<C;F++)E[N][F]=a(E[N][F],I);for(var O=0;O<b;O++)if(O!==N){I=E[O][A];for(var L=0;L<C;L++)E[O][L]=h(E[O][L],d(-1,d(I,E[N][L])))}A++}return E}function p(x,b,C){var E=y(x,b,C),A=x.map((S,I)=>S.filter((F,O)=>O<b&&!w(u(E[O],E[O])))),N=E.filter((S,I)=>!w(u(E[I],E[I])));return{C:A,F:N}}function w(x){return s(h(x,_(1,1)),h(0,_(1,1)))}function v(x){return n(h(x,_(1,1)),h(d(x,0),_(1,1)))}}),O1="divide",B1=["typed","matrix","multiply","equalScalar","divideScalar","inv"],T1=gt(O1,B1,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,u=ja({typed:t,equalScalar:n}),c=Ya({typed:t});return t("divide",lc({"Array | Matrix, Array | Matrix":function(d,h){return r(d,a(h))},"DenseMatrix, any":function(d,h){return c(d,h,s,!1)},"SparseMatrix, any":function(d,h){return u(d,h,s,!1)},"Array, any":function(d,h){return c(e(d),h,s,!1).valueOf()},"any, Array | Matrix":function(d,h){return r(d,a(h))}},s.signatures))}),Yf="sum",I1=["typed","config","add","numeric"],$1=gt(Yf,I1,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(Yf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(c){if(Vs(c))throw new TypeError("Scalar values expected in function sum");return s(c)}});function s(u){var c;return ns(u,function(f){try{c=c===void 0?f:r(c,f)}catch(d){throw In(d,"sum",f)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(u,c){try{var f=Wa(u,c,r);return f}catch(d){throw In(d,"sum")}}}),Vf="median",L1=["typed","add","divide","compare","partitionSelect"],R1=gt(Vf,L1,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(f){try{f=Ia(f.valueOf());var d=f.length;if(d===0)throw new Error("Cannot calculate median of an empty array");if(d%2===0){for(var h=d/2-1,_=s(f,h+1),g=f[h],y=0;y<h;++y)n(f[y],g)>0&&(g=f[y]);return c(g,_)}else{var p=s(f,(d-1)/2);return u(p)}}catch(w){throw In(w,"median")}}var u=t({"number | BigNumber | Complex | Unit":function(d){return d}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(d,h){return r(e(d,h),2)}});return t(Vf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(d,h){throw new Error("median(A, dim) is not yet supported")},"...":function(d){if(Vs(d))throw new TypeError("Scalar values expected in function median");return a(d)}})}),no=Pm({config:yr}),Va=Um({}),Ha=Vm({}),Za=Km({}),nn=Xm({Matrix:Za}),St=qp({BigNumber:no,Complex:Va,DenseMatrix:nn,Fraction:Ha}),P1=Sg({typed:St}),io=Bg({typed:St}),k1=Dg({BigNumber:no,typed:St}),Hf=yv({typed:St}),$n=cg({config:yr,typed:St}),so=eg({typed:St}),z1=sg({typed:St}),oo=fv({typed:St}),Zf=vg({typed:St}),Ka=dg({Matrix:Za,equalScalar:$n,typed:St}),Kf=Ig({typed:St}),Gf=ag({typed:St}),Ga=Fg({typed:St}),Jf=Eg({Fraction:Ha,typed:St}),Xf=ng({typed:St}),$e=Ag({DenseMatrix:nn,Matrix:Za,SparseMatrix:Ka,typed:St}),Qf=zv({isNaN:Gf,isNumeric:Xf,typed:St}),is=Yv({bignumber:k1,fraction:Jf,number:Zf}),q1=Uv({config:yr,multiplyScalar:oo,numeric:is,typed:St}),U1=Bv({isInteger:so,matrix:$e,typed:St}),th=Iv({matrix:$e,config:yr,typed:St}),eh=Lv({matrix:$e,typed:St}),ei=Dv({isInteger:so,matrix:$e,typed:St}),W1=xv({prod:q1,size:th,typed:St}),j1=Pv({conj:Hf,transpose:eh,typed:St}),ss=Hv({numeric:is,typed:St}),Y1=Jv({DenseMatrix:nn,concat:ei,divideScalar:ss,equalScalar:$n,matrix:$e,typed:St}),rh=r1({DenseMatrix:nn,concat:ei,equalScalar:$n,matrix:$e,typed:St}),nh=Cv({BigNumber:no,DenseMatrix:nn,SparseMatrix:Ka,config:yr,matrix:$e,typed:St}),V1=Mv({matrix:$e,multiplyScalar:oo,typed:St}),H1=s1({DenseMatrix:nn,concat:ei,config:yr,matrix:$e,typed:St}),Z1=pv({DenseMatrix:nn,concat:ei,equalScalar:$n,matrix:$e,subtractScalar:Kf,typed:St,unaryMinus:Ga}),os=y1({DenseMatrix:nn,SparseMatrix:Ka,addScalar:io,concat:ei,equalScalar:$n,matrix:$e,typed:St}),ih=Qv({BigNumber:no,DenseMatrix:nn,Fraction:Ha,concat:ei,config:yr,equalScalar:$n,matrix:$e,typed:St}),K1=f1({equal:rh,typed:St}),sh=D1({addScalar:io,conj:Hf,multiplyScalar:oo,size:th,typed:St}),G1=u1({DenseMatrix:nn,concat:ei,config:yr,matrix:$e,typed:St}),Ja=g1({config:yr,numeric:is,smaller:H1,typed:St}),Mi=dv({addScalar:io,dot:sh,equalScalar:$n,matrix:$e,multiplyScalar:oo,typed:St}),J1=d1({compare:ih,isNaN:Gf,isNumeric:Xf,typed:St}),X1=$1({add:os,config:yr,numeric:is,typed:St}),Q1=E1({add:os,matrix:$e,typed:St}),oh=A1({divideScalar:ss,isZero:z1,matrix:$e,multiply:Mi,subtractScalar:Kf,typed:St,unaryMinus:Ga}),ty=p1({config:yr,larger:G1,numeric:is,typed:St}),ao=F1({abs:P1,addScalar:io,det:oh,divideScalar:ss,identity:nh,matrix:$e,multiply:Mi,typed:St,unaryMinus:Ga}),ey=S1({Complex:Va,add:os,ctranspose:j1,deepEqual:K1,divideScalar:ss,dot:sh,dotDivide:Y1,equal:rh,inv:ao,matrix:$e,multiply:Mi,typed:St}),ry=Kv({Complex:Va,config:yr,fraction:Jf,identity:nh,inv:ao,matrix:$e,multiply:Mi,number:Zf,typed:St}),ny=T1({divideScalar:ss,equalScalar:$n,inv:ao,matrix:$e,multiply:Mi,typed:St}),ah=R1({add:os,compare:ih,divide:ny,partitionSelect:J1,typed:St});class iy{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_math");$(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(e===void 0||r===void 0||n===void 0)return;const u=this._cacheDataList(t,e,`alma_${a}`);if(u===void 0)return;let c=r*(e-1);s&&(c=Math.floor(c));const f=e/n;let d=0,h=0;for(let _=0;_<=e-1;_++){const g=Math.exp(-1*Math.pow(_-c,2)/(2*Math.pow(f,2)));d+=g,h+=u[u.length-1-(e-_-1)]*g}return h/d}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=X1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._verifyCacheData(`rma_${r}`);if(n)return n==null?void 0:n.sum;const{sum:s}=this._getCacheData(`rma_${r}`),a=1/e,u=this.sma({source:t,length:e},r),c=s===void 0?u:a*t+(1-a)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:c}),c}atr({length:t},e){const r=this._verifyCacheData(`atr_${e}`);if(r)return r==null?void 0:r.value;const{high:n,close:s}=this._getCacheData(`atr_${e}`),{high:a,close:u,low:c}=this._variables,f=n===void 0?a-c:Math.max(Math.max(a-c,Math.abs(a-s)),Math.abs(c-s)),d=this.rma({source:f,length:t},e);return this._cacheDataHandle(`atr_${e}`,{high:a,close:u,value:d}),d}barssince({condition:t},e){const r=this._verifyCacheData(`barssince_${e}`);if(r)return r==null?void 0:r.count;let{count:n}=this._getCacheData(`barssince_${e}`);if(t)n=0;else{if(n===void 0)return;n+=1}return this._cacheDataHandle(`barssince_${e}`,{count:n}),n}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let u=0;for(let c=0;c<e;c++){const f=this._sum(s[s.length-1-c],-(a||0));u+=f*f}return r||e<=1?Math.sqrt(u/e):Math.sqrt(u/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const u=r*a;return[s,s+u,s-u]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const u=r*a;return(s+u-(s-u))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheDataList(t,e,`change_${r}`);if(n===void 0)return;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?typeof t=="number"?0:s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let u=0;u<e;u++){const c=n[n.length-1-u];a+=c*(u+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),u=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||u===void 0||s===void 0)return;let c=0,f=0,d=0;for(let _=0;_<r;_++){const[g,y]=s[s.length-1-_],p=g-a,w=y-u;c+=p*w,f+=p*p,d+=w*w}return isNaN(f)||isNaN(c)||isNaN(d)?void 0:c/Math.sqrt(f*d)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const n=this._verifyCacheData(`cross_${r}`);if(n)return n==null?void 0:n.value;const{source1:s,source2:a}=this._getCacheData(`cross_${r}`);let u=!1;return s===void 0||a===void 0?u=!1:u=s>=a&&t<e||s<=a&&t>e,this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e,value:u}),u}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const n=this._verifyCacheData(`crossover_${r}`);if(n)return n==null?void 0:n.value;const{source1:s,source2:a}=this._getCacheData(`crossover_${r}`);let u=!1;return s===void 0||a===void 0?u=!1:u=s<=a&&t>e,this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e,value:u}),u}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const n=this._verifyCacheData(`crossunder_${r}`);if(n)return n==null?void 0:n.value;const{source1:s,source2:a}=this._getCacheData(`crossunder_${r}`);let u=!1;return s===void 0||a===void 0?u=!1:u=s>=a&&t<e,this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e,value:u}),u}cum({source:t=0},e){const r=this._verifyCacheData(`cum_${e}`);if(r)return r==null?void 0:r.sum;t=isNaN(t)?0:t;let{sum:n}=this._getCacheData(`cum_${e}`);return n=n||0,n+=t,this._cacheDataHandle(`cum_${e}`,{sum:n}),n}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let u=0;u<e;u++){const c=a[a.length-1-u];s+=Math.abs(c-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,s=this._verifyCacheData(n);if(s)return s==null?void 0:s.value;const{low:a,high:u,close:c,PDMS:f,NDMS:d,TRS:h,ADX:_,count:g=0}=this._getCacheData(n),{low:y,high:p,close:w}=this._variables;if(a===void 0||u===void 0||c===void 0)return this._cacheData[n]={low:y,high:p,close:w,PDMS:f,NDMS:d,TRS:p-y,count:1},[void 0,void 0,void 0];let v=p-u,x=a-y;v=v>x&&v>0?v:0,x=x>v&&x>0?x:0,v===x&&(v=x=0);const b=Math.max(p-y,Math.abs(p-c),Math.abs(y-c));let C={};if(g<t)C={low:y,high:p,close:w,PDMS:(f||0)+v,NDMS:(d||0)+x,TRS:(h||0)+b,count:g+1,value:[void 0,void 0,void 0]};else{const E=f-f/t+v,A=d-d/t+x,N=h-h/t+b,S=E/N*100,I=A/N*100,F=Math.abs((S-I)/(S+I))*100;let O=F,L=[S,I,void 0];if(g+1-t<e){const z=g+1-t;O=((_||0)*(z-1)+F)/z}else O=(_*(e-1)+F)/e,L=[S,I,O];C={low:y,high:p,close:w,PDMS:E,NDMS:A,TRS:N,ADX:O,count:g+1,value:L}}return this._cacheDataHandle(n,C),C.value}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._verifyCacheData(`ema_${r}`);if(n)return n==null?void 0:n.sum;let{sum:s,count:a=1}=this._getCacheData(`ema_${r}`);const u=this.sma({source:t,length:e},r);if(a>e){const c=2/(e+1);s=s===void 0?t:c*t+(1-c)*(s||0)}else s=u;return a+=1,this._cacheDataHandle(`ema_${r}`,{sum:s,count:a}),s}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const n=this._verifyCacheData(`falling_${r}`);if(n)return n==null?void 0:n.value;const{source:s,fallings:a=[]}=this._getCacheData(`falling_${r}`);a.push(s>t);const u=a.slice(-e);let c=!1;return u.length<e?c=!1:c=u.every(f=>f),this._cacheDataHandle(`falling_${r}`,{source:t,fallings:u,value:c}),c}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const n=this._verifyCacheData(`rising_${r}`);if(n)return n==null?void 0:n.value;const{source:s,risings:a=[]}=this._getCacheData(`rising_${r}`);a.push(s<t);const u=a.slice(-e);let c=!1;return u.length<e?c=!1:c=u.every(f=>f),this._cacheDataHandle(`rising_${r}`,{source:t,risings:u,value:c}),c}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(s)return Math.max(...s.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return s?s.slice(-e).reduce((u,c,f,d)=>c>=d[u]?f:u,0)-e+1:void 0}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let u=0;u<e;u++){const c=(e-u)*e;s+=c,a+=n[n.length-1-u]*c}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:u,high:c,low:f}=this._variables,d=n?u.tr:c-f,h=this.ema({source:d,length:e},`range_${s}`);return[a,a+h*r,a-h*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:u,high:c,low:f}=this._variables,d=n?u.tr:c-f,h=this.ema({source:d,length:e},`range_${s}`);return(a+h*r-(a-h*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(g=>g!==void 0);let u=0,c=0,f=0,d=0;for(const[g,y]of a.entries())u+=g,c+=y,f+=g*y,d+=g*g;const h=(e*f-u*c)/(e*d-u*u);return(c-h*u)/e+h*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(s)return Math.min(...s.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return s?s.slice(-e).reduce((u,c,f,d)=>c<=d[u]?f:u,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),u=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||u===void 0)return[void 0,void 0,void 0];const c=a-u,f=this.ema({source:c,length:n},`macd_${s}`);if(f===void 0)return[c,f,void 0];const d=c-f;return[c,f,d]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return ah(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),u=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(u===void 0||a===void 0))return 100-100/(1+u/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Ja(Qf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheDataList(t,e,n);if(!s||s.length<=e||t===void 0||isNaN(t))return;let a=s.length-e-1,u;for(;u===void 0&&a>=0;)u=s[a],a--;return u===void 0?u:t-u}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),u=a.length;r/=100;const c=1/(u*2);if(r<=c)return a[0];if(r>=1-1/(u*2))return a[u-1];for(const[f,d]of a.entries()){const h=a[f-1];if(r<(f+.5)/u)return h===void 0||d===void 0?void 0:h+(d-h)*(r-(f-.5)/u)/(1/u)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),u=r/100*a.length,c=Math.ceil(u)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let u=0;for(let c=0;c<s.length;c++)s[c]!==void 0&&(s[c]<a||s[c]===a&&c<e)&&u++;return u/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new ee;let{close:a,open:u,low:c,high:f}=this._variables;const d=`pivot_point_levels_${n}`,h=this._verifyCacheData(d);if(h)return s._value=(h==null?void 0:h.result)||[],s;const{close:_,low:g,high:y,open:p,result:w}=this._getCacheData(d);if(!e&&(y&&g&&(f=Math.max(y,f),c=Math.min(g,c)),this._cacheDataHandle(d,{close:a,open:u,low:c,high:f,result:w}),!r))return s._value=w||[],s;const v={close:a,open:u,low:c,high:f};e===!0&&!r&&(a=_,u=p,c=g,f=y);const x=this._getPivotPointLevels(f,c,a,u,r,t);return this._cacheDataHandle(d,{...v,result:x}),s._value=x,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Xn.traditional:return this._traditional(t,e,r);case Xn.fibonacci:return this._fibonacci(t,e,r);case Xn.woodie:return s?[]:this._woodie(t,e);case Xn.classic:return this._classic(t,e,r);case Xn.dm:return this._DM(t,e,r,n);case Xn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),u=n*2+(t-2*e),c=n*3+(t-3*e),f=n*4+(t-4*e),d=n*2-t,h=n-(t-e),_=n*2-(2*t-e),g=n*3-(3*t-e),y=n*4-(4*t-e);return[n,s,d,a,h,u,_,c,g,f,y]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),u=n+.618*(t-e),c=n-.618*(t-e),f=n+(t-e),d=n-(t-e);return[n,s,a,u,c,f,d]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,u=n+(t-e),c=n-(t-e),f=t+2*(n-e),d=e-2*(t-n),h=f+(t-e),_=d-(t-e);return[n,s,a,u,c,f,d,h,_]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,u=n+(t-e),c=n-(t-e),f=n+2*(t-e),d=n-2*(t-e),h=n+3*(t-e),_=n-3*(t-e);return[n,s,a,u,c,f,d,h,_]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,u=s/2-e,c=s/2-t;return[a,u,c]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,u=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,f=r+1.1*(t-e)/4,d=r-1.1*(t-e)/4,h=r+1.1*(t-e)/2,_=r-1.1*(t-e)/2,g=t/e*r,y=r-(g-r);return[n,s,a,u,c,f,d,h,_,g,y]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),u=a[e];return Math.max(...a)===u?u:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),u=a[e];return Math.min(...a)===u?u:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const s=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...s),u=Math.min(...s);return a-u}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._verifyCacheData(`rsi_${r}`);if(n)return n==null?void 0:n.value;const{source:s}=this._getCacheData(`rsi_${r}`),a=Math.max(t-s,0),u=Math.max(s-t,0),c=this.rma({source:a,length:e},`rma1_${r}`),f=this.rma({source:u,length:e},`rma2_${r}`),d=c===void 0||f===void 0?void 0:100-100/(1+c/f);return this._cacheDataHandle(`rsi_${r}`,{source:t,value:d}),d}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const s=this._verifyCacheData(`sar_${n}`);if(s)return s==null?void 0:s.result;const{close:a,low:u,high:c,preLow:f,preHigh:d,data:h={}}=this._getCacheData(`sar_${n}`);let{result:_,maxMin:g,acceleration:y,isBelow:p}=h,w=!1;const{close:v,low:x,high:b,bar_index:C}=this._variables;return C===1&&(v>a?(p=!0,g=b,_=u):(p=!1,g=x,_=c),w=!0,y=t),_=_+y*(g-_),p?_>x&&(w=!0,p=!1,_=Math.max(b,g||0),g=x,y=t):_<b&&(w=!0,p=!0,_=Math.min(x,g||0),g=b,y=t),w||(p?b>(g||0)&&(g=b,y=Math.min((y||0)+e,r)):x<(g||0)&&(g=x,y=Math.min((y||0)+e,r))),p?(_=Math.min(_,u),C>1&&(_=Math.min(_,f))):(_=Math.max(_,c),C>1&&(_=Math.max(_,d))),this._cacheDataHandle(`sar_${n}`,{high:b,close:v,low:x,preLow:u,preHigh:c,data:Object.assign(h,{result:_,maxMin:g,acceleration:y,isBelow:p})}),_}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},s),u=this.highest({source:e,length:n},s);if(!(a===void 0||u===void 0))return 100*(t-a)/(u-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const n=`supertrend_${r}`,s=this._verifyCacheData(n);if(s)return s==null?void 0:s.value;let a=1;const{hl2:u,close:c}=this._variables,{upperBand:f,lowerBand:d,superTrend:h,atr:_,close:g}=this._getCacheData(n),y=this.atr({length:e},r);if(y===void 0)return this._cacheDataHandle(n,{close:c,value:[void 0,a]}),[void 0,a];let p=u+t*y,w=u-t*y;const v=f||0,x=d||0;w=w>x||g<x?w:x,p=p<v||g>v?p:v,_===void 0?a=1:h===v?a=c>p?-1:1:a=c<w?1:-1;const b=a===-1?w:p;return this._cacheDataHandle(n,{upperBand:p,lowerBand:w,superTrend:b,atr:y,close:c,value:[b,a]}),[b,a]}swma({source:t},e){const r=this._verifyCacheData(`swma_${e}`);if(r)return r==null?void 0:r.value;let{list:n}=this._getCacheData(`swma_${e}`);n||(n=[]),n.push(t),n=n.slice(-4);const s=n.filter(a=>a!==void 0).length<4?void 0:n[3]*1/6+n[2]*2/6+n[1]*2/6+n[0]*1/6;return this._cacheDataHandle(`swma_${e}`,{list:n,value:s}),s}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,a=this._verifyCacheData(`tr_${e}`);if(a)return a==null?void 0:a.value;const{close:u}=this._getCacheData(`tr_${e}`);let c;return u===void 0?c=t?s-n:void 0:c=Math.max(s-n,Math.abs(s-u),Math.abs(n-u)),this._cacheDataHandle(`tr_${e}`,{close:r,value:c}),c}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),u=this.ema({source:s,length:e},`ema1_${n}`);if(u===void 0)return;const c=this.ema({source:u,length:r},`ema2_${n}`),f=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/f}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;const s=this._verifyCacheData(`valuewhen_${n}`);if(s)return s==null?void 0:s.value;let{list:a}=this._getCacheData(`valuewhen_${n}`);a||(a=[]),t&&a.push(e);const u=a[a.length-1-r];return this._cacheDataHandle(`valuewhen_${n}`,{list:a,value:u}),u}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`variance_${n}`,!0);if(!a||s===void 0)return;const u=a.filter(f=>f!==void 0&&!isNaN(f)).slice(-e);if(u.length<e)return;const c=u.reduce((f,d)=>f+Math.pow(d-s,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;const s=`vwap_${n}`,a=this._verifyCacheData(s);if(a)return a==null?void 0:a.value;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:u}=this._variables;let{sum:c=0,sumV:f=0,count:d=0,isReset:h,sumS:_=0}=this._getCacheData(s);if(e&&(c=f=d=_=0,h=!0),!h)return r!==void 0?[]:void 0;const g=t*u+c,y=u+f,p=g/y;if(d++,r!==void 0){_=u*Math.pow(t,2)+_;const w=this._computeBands(_,y,r,p);return this._cacheDataHandle(s,{sum:g,sumV:y,count:d,isReset:h,sumS:_,value:w}),w}return this._cacheDataHandle(s,{sum:g,sumV:y,count:d,isReset:h,value:p}),p}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),u=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,u,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:u}=n,c=t[s];if(c!==void 0){if(a!==void 0&&c<a){t.splice(s,1),t.splice(u,0,c),n={currentIndex:u+1,currentVal:a};continue}n={currentIndex:s,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const s=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(s.barIndex<=a){const u=s.list.length;if(s.barIndex===a)s.list[u-1]=t;else{let c=a-s.barIndex-1;if(s.barIndex!==-1&&c>0){const f=s.list[u-1];for(;c>0;)s.list.push(f),c--}s.list.push(t)}s.barIndex=a,s.list.length>e+5&&!n&&s.list.shift(),this._cacheData[r]=s}if(!(s.list.length<e))return s.list}_getCacheData(t){const{bar_index:e}=this._variables,r=this._cacheData[t]||{};return r.barIndex===e?r.preCacheData||{}:r}_cacheDataHandle(t,e){const{bar_index:r,_isRealTimeBar:n,_isRepeated:s}=this._variables;if(!n&&!s){const a=this._cacheData[t]||{};this._cacheData[t]=Object.assign(e,{barIndex:r,preCacheData:{...a}})}}_verifyCacheData(t){const{bar_index:e,_isRepeated:r}=this._variables,n=this._cacheData[t]||{},{barIndex:s}=n;if(s===e&&r)return n}}class sy{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_errorListener");$(this,"_historyInputs");$(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){if(!(t!=null&&t.length)){self.workerStorage.delete(this._name),this._cacheData={};return}for(const e of t){const r=e.id,n=this._historyInputs[r];(!(e!=null&&e.sourceTypeName)&&(n==null?void 0:n.defval)!==e.defval||n!=null&&n.sourceTypeName&&e.sourceTypeName!==(n==null?void 0:n.sourceTypeName))&&(this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}))}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._verifyMaxOrMin(t,e),this._cacheHandle(t,e,sr.INT)}bool(t,e){return this._cacheHandle(t,e,sr.BOOL)}color(t,e){return this._cacheHandle(t,e,sr.COLOR)}time(t,e){return this._cacheHandle(t,e,sr.TIME)}float(t,e){return this._verifyMaxOrMin(t,e),this._cacheHandle(t,e,sr.FLOAT)}price(t,e){return this._cacheHandle(t,e,sr.PRICE)}source(t,e){return this._cacheHandle(t,e,sr.SOURCE)}string(t,e){return this._cacheHandle(t,e,sr.STRING)}symbol(t,e){return this._cacheHandle(t,e,sr.SYMBOL)}session(t,e){return this._cacheHandle(t,e,sr.SESSION)}text_area(t,e){return this._cacheHandle(t,e,sr.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,sr.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,sr.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(ie.inputDefvalErr,e,Rt.Error),self.workerStorage.setValue(this._name,n,{...t}),s)if(!s.isModify)Object.assign(this._cacheData[n],t);else{const a=this._historyInputs[n];!(t.sourceTypeName||a!=null&&a.sourceTypeName)&&t.defval===(a==null?void 0:a.defval)||t.sourceTypeName&&(a==null?void 0:a.sourceTypeName)===t.sourceTypeName?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:u}=t;this._displayVerify(e,u),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===sr.SOURCE?this._cacheData[n].options=O_:t.options&&!t.options.includes(a)&&this._errorListener.addError(He(ie.inputOptErr,{defval:String(a),args:t.options.toString()}),e,Rt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ze.dataWindow)||e.includes(Ze.statusLine)||this._errorListener.addError(He(ie.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,Rt.Error)}_verifyMaxOrMin(t,e){const{defval:r,maxval:n,minval:s}=t;typeof r=="number"&&(n!==void 0&&r>n||s!==void 0&&r<s)&&this._errorListener.addError(ie.minOrMaxErr,e,Rt.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e.sort((r,n)=>(r.index||0)-(n.index||0))}}class oy{color({x:t}){return t}new({color:t,transp:e=100}){mt(e)&&(e=100);const r=(100-e)/100,{r:n,g:s,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(s)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return mt(n)&&(n=0),mt(t)&&(t=0),mt(e)&&(e=0),mt(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){if(mt(t)||mt(e)||mt(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),u=Math.min(Math.max(a,0),1),{r:c,g:f,b:d,a:h}=this._parseColor(n||"rgba(0,0,0,0)"),{r:_,g,b:y,a:p}=this._parseColor(s||"rgba(0,0,0,0)"),w=c+u*(_-c),v=f+u*(g-f),x=d+u*(y-d),b=h+u*(p-h);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var zt={};const ay=Object.prototype.toString;function as(i){const t=ay.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var uy=Object.freeze({__proto__:null,isAnyArray:as}),ly=Se(uy);function cy(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!as(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],u=r+1;u<s;u++)i[u]>a&&(a=i[u]);return a}function fy(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!as(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],u=r+1;u<s;u++)i[u]<a&&(a=i[u]);return a}function hy(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(as(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!as(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=fy(i),n=cy(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,u=t.max,c=u===void 0?t.autoMinMax?n:1:u;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var f=(c-a)/(n-r),d=0;d<i.length;d++)e[d]=(i[d]-r)*f+a;return e}var dy=Object.freeze({__proto__:null,default:hy}),_y=Se(dy);Object.defineProperty(zt,"__esModule",{value:!0});var fr=ly,uh=_y;const uo=" ".repeat(2),lh=" ".repeat(4);function py(){return ch(this)}function ch(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
|
55
55
|
${uo}[
|
56
56
|
${lh}${my(i,e,r,n,s)}
|
57
57
|
${uo}]
|
58
58
|
${uo}rows: ${i.rows}
|
59
59
|
${uo}columns: ${i.columns}
|
60
60
|
}`}function my(i,t,e,r,n){const{rows:s,columns:a}=i,u=Math.min(s,t),c=Math.min(a,e),f=[];if(n==="auto"){n=!1;t:for(let d=0;d<u;d++)for(let h=0;h<c;h++)if(i.get(d,h)<0){n=!0;break t}}for(let d=0;d<u;d++){let h=[];for(let _=0;_<c;_++)h.push(gy(i.get(d,_),r,n));f.push(`${h.join(" ")}`)}return c!==a&&(f[f.length-1]+=` ... ${a-e} more columns`),u!==s&&f.push(`... ${s-t} more rows`),f.join(`
|
61
|
-
${lh}`)}function gy(i,t,e){return(i>=0&&e?` ${fh(i,t-1)}`:fh(i,t)).padEnd(t)}function fh(i,t){let e=i.toString();if(e.length<=t)return e;let r=i.toFixed(t);if(r.length>t&&(r=i.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=i.toExponential(t);return n.length>t&&(n=i.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function vy(i,t){i.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},i.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r);return this},i.prototype.addM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r.get(n,s));return this},i.add=function(r,n){return new t(r).add(n)},i.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},i.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r);return this},i.prototype.subM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r.get(n,s));return this},i.sub=function(r,n){return new t(r).sub(n)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},i.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r);return this},i.prototype.mulM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r.get(n,s));return this},i.mul=function(r,n){return new t(r).mul(n)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},i.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r);return this},i.prototype.divM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r.get(n,s));return this},i.div=function(r,n){return new t(r).div(n)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},i.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r);return this},i.prototype.modM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r.get(n,s));return this},i.mod=function(r,n){return new t(r).mod(n)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},i.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r);return this},i.prototype.andM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r.get(n,s));return this},i.and=function(r,n){return new t(r).and(n)},i.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},i.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r);return this},i.prototype.orM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r.get(n,s));return this},i.or=function(r,n){return new t(r).or(n)},i.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},i.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r);return this},i.prototype.xorM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r.get(n,s));return this},i.xor=function(r,n){return new t(r).xor(n)},i.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},i.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r);return this},i.prototype.leftShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r.get(n,s));return this},i.leftShift=function(r,n){return new t(r).leftShift(n)},i.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},i.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r);return this},i.prototype.signPropagatingRightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r.get(n,s));return this},i.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},i.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},i.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r);return this},i.prototype.rightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r.get(n,s));return this},i.rightShift=function(r,n){return new t(r).rightShift(n)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},i.not=function(r){return new t(r).not()},i.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},i.abs=function(r){return new t(r).abs()},i.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},i.acos=function(r){return new t(r).acos()},i.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},i.acosh=function(r){return new t(r).acosh()},i.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},i.asin=function(r){return new t(r).asin()},i.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},i.asinh=function(r){return new t(r).asinh()},i.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},i.atan=function(r){return new t(r).atan()},i.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},i.atanh=function(r){return new t(r).atanh()},i.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},i.cbrt=function(r){return new t(r).cbrt()},i.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},i.ceil=function(r){return new t(r).ceil()},i.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},i.clz32=function(r){return new t(r).clz32()},i.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},i.cos=function(r){return new t(r).cos()},i.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},i.cosh=function(r){return new t(r).cosh()},i.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},i.exp=function(r){return new t(r).exp()},i.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},i.expm1=function(r){return new t(r).expm1()},i.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},i.floor=function(r){return new t(r).floor()},i.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},i.fround=function(r){return new t(r).fround()},i.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},i.log=function(r){return new t(r).log()},i.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},i.log1p=function(r){return new t(r).log1p()},i.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},i.log10=function(r){return new t(r).log10()},i.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},i.log2=function(r){return new t(r).log2()},i.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},i.round=function(r){return new t(r).round()},i.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},i.sign=function(r){return new t(r).sign()},i.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},i.sin=function(r){return new t(r).sin()},i.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},i.sinh=function(r){return new t(r).sinh()},i.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},i.sqrt=function(r){return new t(r).sqrt()},i.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},i.tan=function(r){return new t(r).tan()},i.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},i.tanh=function(r){return new t(r).tanh()},i.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},i.trunc=function(r){return new t(r).trunc()},i.pow=function(r,n){return new t(r).pow(n)},i.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},i.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r));return this},i.prototype.powM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r.get(n,s)));return this}}function Tr(i,t,e){let r=e?i.rows:i.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Ir(i,t,e){let r=e?i.columns:i.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Fi(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function Ni(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Xa(i,t){if(!fr.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.rows)throw new RangeError("row indices are out of range")}function Qa(i,t){if(!fr.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.columns)throw new RangeError("column indices are out of range")}function tu(i,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(co("startRow",t),co("endRow",e),co("startColumn",r),co("endColumn",n),t>e||r>n||t<0||t>=i.rows||e<0||e>=i.rows||r<0||r>=i.columns||n<0||n>=i.columns)throw new RangeError("Submatrix indices are out of range")}function lo(i,t=0){let e=[];for(let r=0;r<i;r++)e.push(t);return e}function co(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function Si(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function yy(i){let t=lo(i.rows);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]+=i.get(e,r);return t}function wy(i){let t=lo(i.columns);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]+=i.get(e,r);return t}function Dy(i){let t=0;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t+=i.get(e,r);return t}function by(i){let t=lo(i.rows,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]*=i.get(e,r);return t}function xy(i){let t=lo(i.columns,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]*=i.get(e,r);return t}function Ey(i){let t=1;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t*=i.get(e,r);return t}function Cy(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<r;a++){let u=0,c=0,f=0;for(let d=0;d<n;d++)f=i.get(a,d)-e[a],u+=f,c+=f*f;t?s.push((c-u*u/n)/(n-1)):s.push((c-u*u/n)/n)}return s}function Ay(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<n;a++){let u=0,c=0,f=0;for(let d=0;d<r;d++)f=i.get(d,a)-e[a],u+=f,c+=f*f;t?s.push((c-u*u/r)/(r-1)):s.push((c-u*u/r)/r)}return s}function My(i,t,e){const r=i.rows,n=i.columns,s=r*n;let a=0,u=0,c=0;for(let f=0;f<r;f++)for(let d=0;d<n;d++)c=i.get(f,d)-e,a+=c,u+=c*c;return t?(u-a*a/s)/(s-1):(u-a*a/s)/s}function Fy(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[e])}function Ny(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[r])}function Sy(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t)}function Oy(i){const t=[];for(let e=0;e<i.rows;e++){let r=0;for(let n=0;n<i.columns;n++)r+=Math.pow(i.get(e,n),2)/(i.columns-1);t.push(Math.sqrt(r))}return t}function By(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[e])}function Ty(i){const t=[];for(let e=0;e<i.columns;e++){let r=0;for(let n=0;n<i.rows;n++)r+=Math.pow(i.get(n,e),2)/(i.rows-1);t.push(Math.sqrt(r))}return t}function Iy(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[r])}function $y(i){const t=i.size-1;let e=0;for(let r=0;r<i.columns;r++)for(let n=0;n<i.rows;n++)e+=Math.pow(i.get(n,r),2)/t;return Math.sqrt(e)}function Ly(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t)}class $t{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let s=new dt(t,e);for(let a=0;a<t;a++)for(let u=0;u<e;u++)s.set(a,u,r[a*e+u]);return s}static rowVector(t){let e=new dt(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new dt(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new dt(t,e)}static ones(t,e){return new dt(t,e).fill(1)}static rand(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let s=new dt(t,e);for(let a=0;a<t;a++)for(let u=0;u<e;u++)s.set(a,u,n());return s}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:s=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(n>=s)throw new RangeError("min must be smaller than max");let u=s-n,c=new dt(t,e);for(let f=0;f<t;f++)for(let d=0;d<e;d++){let h=n+Math.round(a()*u);c.set(f,d,h)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),s=this.zeros(t,e);for(let a=0;a<n;a++)s.set(a,a,r);return s}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let s=Math.min(n,e,r),a=this.zeros(e,r);for(let u=0;u<s;u++)a.set(u,u,t[u]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new dt(r,n);for(let a=0;a<r;a++)for(let u=0;u<n;u++)s.set(a,u,Math.min(t.get(a,u),e.get(a,u)));return s}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new this(r,n);for(let a=0;a<r;a++)for(let u=0;u<n;u++)s.set(a,u,Math.max(t.get(a,u),e.get(a,u)));return s}static checkMatrix(t){return $t.isMatrix(t)?t:new dt(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(this.get(t,t)!==0)return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);for(let a=e+1;a<this.rows;a++)this.get(t,a)!==0&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let s=e;s<t.rows;s++)t.get(s,r)>t.get(n,r)&&(n=s);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let s=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/s);for(let a=e+1;a<t.rows;a++){let u=t.get(a,r)/t.get(e,r);t.set(a,r,0);for(let c=r+1;c<t.columns;c++)t.set(a,c,t.get(a,c)-t.get(e,c)*u)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(t.maxRow(n)===0)n--;else{let s=0,a=!1;for(;s<r&&a===!1;)t.get(n,s)===1?a=!0:s++;for(let u=0;u<n;u++){let c=t.get(u,s);for(let f=s;f<e;f++){let d=t.get(u,f)-c*t.get(n,f);t.set(u,f,d)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new dt(this.rows*e,this.columns*r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*s,this.columns*a);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Tr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return dt.rowVector(this.getRow(t))}setRow(t,e){Tr(this,t),e=Fi(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Tr(this,t),Tr(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Ir(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return dt.columnVector(this.getColumn(t))}setColumn(t,e){Ir(this,t),e=Ni(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Ir(this,t),Ir(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Tr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Ir(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Si(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Si(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Tr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Tr(this,t),Si(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Tr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Tr(this,t),Si(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Ir(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Ir(this,t),Si(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Ir(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Ir(this,t),Si(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){$t.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,s=new dt(e,n),a=new Float64Array(r);for(let u=0;u<n;u++){for(let c=0;c<r;c++)a[c]=t.get(c,u);for(let c=0;c<e;c++){let f=0;for(let d=0;d<r;d++)f+=this.get(c,d)*a[d];s.set(c,u,f)}}return s}strassen2x2(t){t=dt.checkMatrix(t);let e=new dt(2,2);const r=this.get(0,0),n=t.get(0,0),s=this.get(0,1),a=t.get(0,1),u=this.get(1,0),c=t.get(1,0),f=this.get(1,1),d=t.get(1,1),h=(r+f)*(n+d),_=(u+f)*n,g=r*(a-d),y=f*(c-n),p=(r+s)*d,w=(u-r)*(n+a),v=(s-f)*(c+d),x=h+y-p+v,b=g+p,C=_+y,E=h-_+g+w;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,C),e.set(1,1,E),e}strassen3x3(t){t=dt.checkMatrix(t);let e=new dt(3,3);const r=this.get(0,0),n=this.get(0,1),s=this.get(0,2),a=this.get(1,0),u=this.get(1,1),c=this.get(1,2),f=this.get(2,0),d=this.get(2,1),h=this.get(2,2),_=t.get(0,0),g=t.get(0,1),y=t.get(0,2),p=t.get(1,0),w=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),C=t.get(2,2),E=(r+n+s-a-u-d-h)*w,A=(r-a)*(-g+w),N=u*(-_+g+p-w-v-x+C),S=(-r+a+u)*(_-g+w),I=(a+u)*(-_+g),F=r*_,O=(-r+f+d)*(_-y+v),L=(-r+f)*(y-v),z=(f+d)*(-_+y),q=(r+n+s-u-c-f-d)*v,W=d*(-_+y+p-w-v-x+b),P=(-s+d+h)*(w+x-b),Z=(s-h)*(w-b),Y=s*x,G=(d+h)*(-x+b),X=(-s+u+c)*(v+x-C),ut=(s-c)*(v-C),_t=(u+c)*(-x+C),at=n*p,vt=c*b,wt=a*y,Ct=f*g,bt=h*C,re=F+Y+at,Bt=E+S+I+F+P+Y+G,Nt=F+O+z+q+Y+X+_t,he=A+N+S+F+Y+X+ut,se=A+S+I+F+vt,qt=Y+X+ut+_t+wt,Xt=F+O+L+W+P+Z+Y,Le=P+Z+Y+G+Ct,Dr=F+O+L+z+bt;return e.set(0,0,re),e.set(0,1,Bt),e.set(0,2,Nt),e.set(1,0,he),e.set(1,1,se),e.set(1,2,qt),e.set(2,0,Xt),e.set(2,1,Le),e.set(2,2,Dr),e}mmulStrassen(t){t=dt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,s=t.rows,a=t.columns;n!==s&&console.warn(`Multiplying ${r} x ${n} and ${s} x ${a} matrix: dimensions do not match.`);function u(h,_,g){let y=h.rows,p=h.columns;if(y===_&&p===g)return h;{let w=$t.zeros(_,g);return w=w.setSubMatrix(h,0,0),w}}let c=Math.max(r,s),f=Math.max(n,a);e=u(e,c,f),t=u(t,c,f);function d(h,_,g,y){if(g<=512||y<=512)return h.mmul(_);g%2===1&&y%2===1?(h=u(h,g+1,y+1),_=u(_,g+1,y+1)):g%2===1?(h=u(h,g+1,y),_=u(_,g+1,y)):y%2===1&&(h=u(h,g,y+1),_=u(_,g,y+1));let p=parseInt(h.rows/2,10),w=parseInt(h.columns/2,10),v=h.subMatrix(0,p-1,0,w-1),x=_.subMatrix(0,p-1,0,w-1),b=h.subMatrix(0,p-1,w,h.columns-1),C=_.subMatrix(0,p-1,w,_.columns-1),E=h.subMatrix(p,h.rows-1,0,w-1),A=_.subMatrix(p,_.rows-1,0,w-1),N=h.subMatrix(p,h.rows-1,w,h.columns-1),S=_.subMatrix(p,_.rows-1,w,_.columns-1),I=d($t.add(v,N),$t.add(x,S),p,w),F=d($t.add(E,N),x,p,w),O=d(v,$t.sub(C,S),p,w),L=d(N,$t.sub(A,x),p,w),z=d($t.add(v,b),S,p,w),q=d($t.sub(E,v),$t.add(x,C),p,w),W=d($t.sub(b,N),$t.add(A,S),p,w),P=$t.add(I,L);P.sub(z),P.add(W);let Z=$t.add(O,z),Y=$t.add(F,L),G=$t.sub(I,F);G.add(O),G.add(q);let X=$t.zeros(2*P.rows,2*P.columns);return X=X.setSubMatrix(P,0,0),X=X.setSubMatrix(Z,P.rows,0),X=X.setSubMatrix(Y,0,P.columns),X=X.setSubMatrix(G,P.rows,P.columns),X.subMatrix(0,g-1,0,y-1)}return d(e,t,c,f)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.rows;s++){const a=this.getRow(s);a.length>0&&uh(a,{min:e,max:r,output:a}),n.setRow(s,a)}return n}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.columns;s++){const a=this.getColumn(s);a.length&&uh(a,{min:e,max:r,output:a}),n.setColumn(s,a)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let n=this.get(e,r),s=this.get(e,this.columns-1-r);this.set(e,r,s),this.set(e,this.columns-1-r,n)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let n=this.get(r,e),s=this.get(this.rows-1-r,e);this.set(r,e,s),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,s=t.columns,a=new dt(e*n,r*s);for(let u=0;u<e;u++)for(let c=0;c<r;c++)for(let f=0;f<n;f++)for(let d=0;d<s;d++)a.set(n*u+f,s*c+d,this.get(u,c)*t.get(f,d));return a}kroneckerSum(t){if(t=dt.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(dt.eye(r,r)),s=dt.eye(e,e).kroneckerProduct(t);return n.add(s)}transpose(){let t=new dt(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=hh){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=hh){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){tu(this,t,e,r,n);let s=new dt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let u=r;u<=n;u++)s.set(a-t,u-r,this.get(a,u));return s}subMatrixRow(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new dt(t.length,r-e+1);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);n.set(s,a-e,this.get(t[s],a))}return n}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new dt(r-e+1,t.length);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);n.set(a-e,s,this.get(a,t[s]))}return n}setSubMatrix(t,e,r){if(t=dt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,s=r+t.columns-1;tu(this,e,n,r,s);for(let a=0;a<t.rows;a++)for(let u=0;u<t.columns;u++)this.set(e+a,r+u,t.get(a,u));return this}selection(t,e){Xa(this,t),Qa(this,e);let r=new dt(t.length,e.length);for(let n=0;n<t.length;n++){let s=t[n];for(let a=0;a<e.length;a++){let u=e[a];r.set(n,a,this.get(s,u))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new dt(this.rows,this.columns))}static copy(t,e){for(const[r,n,s]of t.entries())e.set(r,n,s);return e}sum(t){switch(t){case"row":return yy(this);case"column":return wy(this);case void 0:return Dy(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return by(this);case"column":return xy(this);case void 0:return Ey(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":{for(let r=0;r<this.rows;r++)e[r]/=this.columns;return e}case"column":{for(let r=0;r<this.columns;r++)e[r]/=this.rows;return e}case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return Cy(this,r,n)}case"column":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return Ay(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return My(this,r,n)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){typeof t=="object"&&(e=t,t=void 0);const r=this.variance(t,e);if(t===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return Fy(this,r),this}case"column":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return Ny(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return Sy(this,r),this}default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":{if(r===void 0)r=Oy(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return By(this,r),this}case"column":{if(r===void 0)r=Ty(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return Iy(this,r),this}case void 0:{if(r===void 0)r=$y(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return Ly(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return ch(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}$t.prototype.klass="Matrix",typeof Symbol<"u"&&($t.prototype[Symbol.for("nodejs.util.inspect.custom")]=py);function hh(i,t){return i-t}function Ry(i){return i.every(t=>typeof t=="number")}$t.random=$t.rand,$t.randomInt=$t.randInt,$t.diagonal=$t.diag,$t.prototype.diagonal=$t.prototype.diag,$t.identity=$t.eye,$t.prototype.negate=$t.prototype.neg,$t.prototype.tensorProduct=$t.prototype.kroneckerProduct;let dt=(Ri=class extends $t{constructor(e,r){super();Yl(this,cs);$(this,"data");if(Ri.isMatrix(e))Vl(this,cs,Hl).call(this,e.rows,e.columns),Ri.copy(e,this);else if(Number.isInteger(e)&&e>=0)Vl(this,cs,Hl).call(this,e,r);else if(fr.isAnyArray(e)){const n=e;if(e=n.length,r=e?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s<e;s++){if(n[s].length!==r)throw new RangeError("Inconsistent array dimensions");if(!Ry(n[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[s]))}this.rows=e,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(e,r,n){return this.data[e][r]=n,this}get(e,r){return this.data[e][r]}removeRow(e){return Tr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Tr(this,e,!0),r=Float64Array.from(Fi(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Ir(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let s=0;s<e;s++)n[s]=this.data[r][s];for(let s=e+1;s<this.columns;s++)n[s-1]=this.data[r][s];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Ir(this,e,!0),r=Ni(this,r);for(let n=0;n<this.rows;n++){const s=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)s[a]=this.data[n][a];for(s[a++]=r[n];a<this.columns+1;a++)s[a]=this.data[n][a-1];this.data[n]=s}return this.columns+=1,this}},cs=new WeakSet,Hl=function(e,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=e,this.columns=r},Ri);vy($t,dt);const Oo=class Oo extends $t{constructor(e){super();Yl(this,tr,void 0);if(dt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ba(this,tr,dt.copy(e,new dt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ba(this,tr,new dt(e,e));else if(ba(this,tr,new dt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return tn(this,tr).size}get rows(){return tn(this,tr).rows}get columns(){return tn(this,tr).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return dt.isMatrix(e)&&e.klassType==="SymmetricMatrix"}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){const e=new Oo(this.diagonalSize);for(const[r,n,s]of this.upperRightEntries())e.set(r,n,s);return e}toMatrix(){return new dt(this)}get(e,r){return tn(this,tr).get(e,r)}set(e,r,n){return tn(this,tr).set(e,r,n),tn(this,tr).set(r,e,n),this}removeCross(e){return tn(this,tr).removeRow(e),tn(this,tr).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),tn(this,tr).addRow(e,n),tn(this,tr).addColumn(e,r),this}applyMask(e){if(e.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,s]of e.entries())s||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let n=0,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=e&&(n=++s);return r}static fromCompact(e){const r=e.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(e)}`);const s=new Oo(n);for(let a=0,u=0,c=0;c<r;c++)s.set(a,u,e[c]),++a>=n&&(a=++u);return s}*upperRightEntries(){for(let e=0,r=0;e<this.diagonalSize;void 0){const n=this.get(e,r);yield[e,r,n],++r>=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e<this.diagonalSize;void 0)yield this.get(e,r),++r>=this.diagonalSize&&(r=++e)}};tr=new WeakMap;let ri=Oo;ri.prototype.klassType="SymmetricMatrix";class fo extends ri{static isDistanceMatrix(t){return ri.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new ri(this)}clone(){const t=new fo(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let n=1,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=t&&(n=++s+1);return r}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let s=1,a=0,u=0;u<e;u++)n.set(s,a,t[u]),++s>=r&&(s=++a+1);return n}}fo.prototype.klassSubType="DistanceMatrix";class _n extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class Py extends _n{constructor(t,e){Ir(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}class ky extends _n{constructor(t,e){Qa(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class zy extends _n{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class qy extends _n{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class Uy extends _n{constructor(t,e){Tr(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class Wy extends _n{constructor(t,e){Xa(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class ho extends _n{constructor(t,e,r){Xa(t,e),Qa(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class jy extends _n{constructor(t,e,r,n,s){tu(t,e,r,n,s),super(t,r-e+1,s-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class Yy extends _n{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class dh extends $t{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class wr extends $t{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function Vy(i,t){if(fr.isAnyArray(i))return i[0]&&fr.isAnyArray(i[0])?new wr(i):new dh(i,t);throw new Error("the argument is not an array")}class _o{constructor(t){t=wr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,s=new Float64Array(r),a=1,u,c,f,d,h,_,g,y,p;for(u=0;u<r;u++)s[u]=u;for(y=new Float64Array(r),c=0;c<n;c++){for(u=0;u<r;u++)y[u]=e.get(u,c);for(u=0;u<r;u++){for(p=Math.min(u,c),h=0,f=0;f<p;f++)h+=e.get(u,f)*y[f];y[u]-=h,e.set(u,c,y[u])}for(d=c,u=c+1;u<r;u++)Math.abs(y[u])>Math.abs(y[d])&&(d=u);if(d!==c){for(f=0;f<n;f++)_=e.get(d,f),e.set(d,f,e.get(c,f)),e.set(c,f,_);g=s[d],s[d]=s[c],s[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(u=c+1;u<r;u++)e.set(u,c,e.get(u,c)/e.get(c,c))}this.LU=e,this.pivotVector=s,this.pivotSign=a}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(t.get(r,r)===0)return!0;return!1}solve(t){t=dt.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=t.columns,s=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,u,c,f;for(f=0;f<a;f++)for(u=f+1;u<a;u++)for(c=0;c<n;c++)s.set(u,c,s.get(u,c)-s.get(f,c)*e.get(u,f));for(f=a-1;f>=0;f--){for(c=0;c<n;c++)s.set(f,c,s.get(f,c)/e.get(f,f));for(u=0;u<f;u++)for(c=0;c<n;c++)s.set(u,c,s.get(u,c)-s.get(f,c)*e.get(u,f))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s>a?n.set(s,a,t.get(s,a)):s===a?n.set(s,a,1):n.set(s,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s<=a?n.set(s,a,t.get(s,a)):n.set(s,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function pn(i,t){let e=0;return Math.abs(i)>Math.abs(t)?(e=t/i,Math.abs(i)*Math.sqrt(1+e*e)):t!==0?(e=i/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class eu{constructor(t){t=wr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,s=new Float64Array(n),a,u,c,f;for(c=0;c<n;c++){let d=0;for(a=c;a<r;a++)d=pn(d,e.get(a,c));if(d!==0){for(e.get(c,c)<0&&(d=-d),a=c;a<r;a++)e.set(a,c,e.get(a,c)/d);for(e.set(c,c,e.get(c,c)+1),u=c+1;u<n;u++){for(f=0,a=c;a<r;a++)f+=e.get(a,c)*e.get(a,u);for(f=-f/e.get(c,c),a=c;a<r;a++)e.set(a,u,e.get(a,u)+f*e.get(a,c))}}s[c]=-d}this.QR=e,this.Rdiag=s}solve(t){t=dt.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=t.columns,s=t.clone(),a=e.columns,u,c,f,d;for(f=0;f<a;f++)for(c=0;c<n;c++){for(d=0,u=f;u<r;u++)d+=e.get(u,f)*s.get(u,c);for(d=-d/e.get(f,f),u=f;u<r;u++)s.set(u,c,s.get(u,c)+d*e.get(u,f))}for(f=a-1;f>=0;f--){for(c=0;c<n;c++)s.set(f,c,s.get(f,c)/this.Rdiag[f]);for(u=0;u<f;u++)for(c=0;c<n;c++)s.set(u,c,s.get(u,c)-s.get(f,c)*e.get(u,f))}return s.subMatrix(0,a-1,0,n-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,r=new dt(e,e),n,s;for(n=0;n<e;n++)for(s=0;s<e;s++)n<s?r.set(n,s,t.get(n,s)):n===s?r.set(n,s,this.Rdiag[n]):r.set(n,s,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new dt(e,r),s,a,u,c;for(u=r-1;u>=0;u--){for(s=0;s<e;s++)n.set(s,u,0);for(n.set(u,u,1),a=u;a<r;a++)if(t.get(u,u)!==0){for(c=0,s=u;s<e;s++)c+=t.get(s,u)*n.get(s,a);for(c=-c/t.get(u,u),s=u;s<e;s++)n.set(s,a,n.get(s,a)+c*t.get(s,u))}}return n}}class Oi{constructor(t,e={}){if(t=wr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:a=!0,autoTranspose:u=!1}=e;let c=!!s,f=!!a,d=!1,h;if(r<n)if(!u)h=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{h=t.transpose(),r=h.rows,n=h.columns,d=!0;let F=c;c=f,f=F}else h=t.clone();let _=Math.min(r,n),g=Math.min(r+1,n),y=new Float64Array(g),p=new dt(r,_),w=new dt(n,n),v=new Float64Array(n),x=new Float64Array(r),b=new Float64Array(g);for(let F=0;F<g;F++)b[F]=F;let C=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),A=Math.max(C,E);for(let F=0;F<A;F++){if(F<C){y[F]=0;for(let O=F;O<r;O++)y[F]=pn(y[F],h.get(O,F));if(y[F]!==0){h.get(F,F)<0&&(y[F]=-y[F]);for(let O=F;O<r;O++)h.set(O,F,h.get(O,F)/y[F]);h.set(F,F,h.get(F,F)+1)}y[F]=-y[F]}for(let O=F+1;O<n;O++){if(F<C&&y[F]!==0){let L=0;for(let z=F;z<r;z++)L+=h.get(z,F)*h.get(z,O);L=-L/h.get(F,F);for(let z=F;z<r;z++)h.set(z,O,h.get(z,O)+L*h.get(z,F))}v[O]=h.get(F,O)}if(c&&F<C)for(let O=F;O<r;O++)p.set(O,F,h.get(O,F));if(F<E){v[F]=0;for(let O=F+1;O<n;O++)v[F]=pn(v[F],v[O]);if(v[F]!==0){v[F+1]<0&&(v[F]=0-v[F]);for(let O=F+1;O<n;O++)v[O]/=v[F];v[F+1]+=1}if(v[F]=-v[F],F+1<r&&v[F]!==0){for(let O=F+1;O<r;O++)x[O]=0;for(let O=F+1;O<r;O++)for(let L=F+1;L<n;L++)x[O]+=v[L]*h.get(O,L);for(let O=F+1;O<n;O++){let L=-v[O]/v[F+1];for(let z=F+1;z<r;z++)h.set(z,O,h.get(z,O)+L*x[z])}}if(f)for(let O=F+1;O<n;O++)w.set(O,F,v[O])}}let N=Math.min(n,r+1);if(C<n&&(y[C]=h.get(C,C)),r<N&&(y[N-1]=0),E+1<N&&(v[E]=h.get(E,N-1)),v[N-1]=0,c){for(let F=C;F<_;F++){for(let O=0;O<r;O++)p.set(O,F,0);p.set(F,F,1)}for(let F=C-1;F>=0;F--)if(y[F]!==0){for(let O=F+1;O<_;O++){let L=0;for(let z=F;z<r;z++)L+=p.get(z,F)*p.get(z,O);L=-L/p.get(F,F);for(let z=F;z<r;z++)p.set(z,O,p.get(z,O)+L*p.get(z,F))}for(let O=F;O<r;O++)p.set(O,F,-p.get(O,F));p.set(F,F,1+p.get(F,F));for(let O=0;O<F-1;O++)p.set(O,F,0)}else{for(let O=0;O<r;O++)p.set(O,F,0);p.set(F,F,1)}}if(f)for(let F=n-1;F>=0;F--){if(F<E&&v[F]!==0)for(let O=F+1;O<n;O++){let L=0;for(let z=F+1;z<n;z++)L+=w.get(z,F)*w.get(z,O);L=-L/w.get(F+1,F);for(let z=F+1;z<n;z++)w.set(z,O,w.get(z,O)+L*w.get(z,F))}for(let O=0;O<n;O++)w.set(O,F,0);w.set(F,F,1)}let S=N-1,I=Number.EPSILON;for(;N>0;){let F,O;for(F=N-2;F>=-1&&F!==-1;F--){const L=Number.MIN_VALUE+I*Math.abs(y[F]+Math.abs(y[F+1]));if(Math.abs(v[F])<=L||Number.isNaN(v[F])){v[F]=0;break}}if(F===N-2)O=4;else{let L;for(L=N-1;L>=F&&L!==F;L--){let z=(L!==N?Math.abs(v[L]):0)+(L!==F+1?Math.abs(v[L-1]):0);if(Math.abs(y[L])<=I*z){y[L]=0;break}}L===F?O=3:L===N-1?O=1:(O=2,F=L)}switch(F++,O){case 1:{let L=v[N-2];v[N-2]=0;for(let z=N-2;z>=F;z--){let q=pn(y[z],L),W=y[z]/q,P=L/q;if(y[z]=q,z!==F&&(L=-P*v[z-1],v[z-1]=W*v[z-1]),f)for(let Z=0;Z<n;Z++)q=W*w.get(Z,z)+P*w.get(Z,N-1),w.set(Z,N-1,-P*w.get(Z,z)+W*w.get(Z,N-1)),w.set(Z,z,q)}break}case 2:{let L=v[F-1];v[F-1]=0;for(let z=F;z<N;z++){let q=pn(y[z],L),W=y[z]/q,P=L/q;if(y[z]=q,L=-P*v[z],v[z]=W*v[z],c)for(let Z=0;Z<r;Z++)q=W*p.get(Z,z)+P*p.get(Z,F-1),p.set(Z,F-1,-P*p.get(Z,z)+W*p.get(Z,F-1)),p.set(Z,z,q)}break}case 3:{const L=Math.max(Math.abs(y[N-1]),Math.abs(y[N-2]),Math.abs(v[N-2]),Math.abs(y[F]),Math.abs(v[F])),z=y[N-1]/L,q=y[N-2]/L,W=v[N-2]/L,P=y[F]/L,Z=v[F]/L,Y=((q+z)*(q-z)+W*W)/2,G=z*W*(z*W);let X=0;(Y!==0||G!==0)&&(Y<0?X=0-Math.sqrt(Y*Y+G):X=Math.sqrt(Y*Y+G),X=G/(Y+X));let ut=(P+z)*(P-z)+X,_t=P*Z;for(let at=F;at<N-1;at++){let vt=pn(ut,_t);vt===0&&(vt=Number.MIN_VALUE);let wt=ut/vt,Ct=_t/vt;if(at!==F&&(v[at-1]=vt),ut=wt*y[at]+Ct*v[at],v[at]=wt*v[at]-Ct*y[at],_t=Ct*y[at+1],y[at+1]=wt*y[at+1],f)for(let bt=0;bt<n;bt++)vt=wt*w.get(bt,at)+Ct*w.get(bt,at+1),w.set(bt,at+1,-Ct*w.get(bt,at)+wt*w.get(bt,at+1)),w.set(bt,at,vt);if(vt=pn(ut,_t),vt===0&&(vt=Number.MIN_VALUE),wt=ut/vt,Ct=_t/vt,y[at]=vt,ut=wt*v[at]+Ct*y[at+1],y[at+1]=-Ct*v[at]+wt*y[at+1],_t=Ct*v[at+1],v[at+1]=wt*v[at+1],c&&at<r-1)for(let bt=0;bt<r;bt++)vt=wt*p.get(bt,at)+Ct*p.get(bt,at+1),p.set(bt,at+1,-Ct*p.get(bt,at)+wt*p.get(bt,at+1)),p.set(bt,at,vt)}v[N-2]=ut;break}case 4:{if(y[F]<=0&&(y[F]=y[F]<0?-y[F]:0,f))for(let L=0;L<=S;L++)w.set(L,F,-w.get(L,F));for(;F<S&&!(y[F]>=y[F+1]);){let L=y[F];if(y[F]=y[F+1],y[F+1]=L,f&&F<n-1)for(let z=0;z<n;z++)L=w.get(z,F+1),w.set(z,F+1,w.get(z,F)),w.set(z,F,L);if(c&&F<r-1)for(let z=0;z<r;z++)L=p.get(z,F+1),p.set(z,F+1,p.get(z,F)),p.set(z,F,L);F++}N--;break}}}if(d){let F=w;w=p,p=F}this.m=r,this.n=n,this.s=y,this.U=p,this.V=w}solve(t){let e=t,r=this.threshold,n=this.s.length,s=dt.zeros(n,n);for(let _=0;_<n;_++)Math.abs(this.s[_])<=r?s.set(_,_,0):s.set(_,_,1/this.s[_]);let a=this.U,u=this.rightSingularVectors,c=u.mmul(s),f=u.rows,d=a.rows,h=dt.zeros(f,d);for(let _=0;_<f;_++)for(let g=0;g<d;g++){let y=0;for(let p=0;p<n;p++)y+=c.get(_,p)*a.get(g,p);h.set(_,g,y)}return h.mmul(e)}solveForDiagonal(t){return this.solve(dt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,s=new dt(r,this.s.length);for(let d=0;d<r;d++)for(let h=0;h<n;h++)Math.abs(this.s[h])>e&&s.set(d,h,t.get(d,h)/this.s[h]);let a=this.U,u=a.rows,c=a.columns,f=new dt(r,u);for(let d=0;d<r;d++)for(let h=0;h<u;h++){let _=0;for(let g=0;g<c;g++)_+=s.get(d,g)*a.get(h,g);f.set(d,h,_)}return f}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,s=r.length;n<s;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return dt.diag(this.s)}}function Hy(i,t=!1){return i=wr.checkMatrix(i),t?new Oi(i).inverse():_h(i,dt.eye(i.rows))}function _h(i,t,e=!1){return i=wr.checkMatrix(i),t=wr.checkMatrix(t),e?new Oi(i).solve(t):i.isSquare()?new _o(i).solve(t):new eu(i).solve(t)}function po(i){if(i=dt.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let t,e,r,n;if(i.columns===2)return t=i.get(0,0),e=i.get(0,1),r=i.get(1,0),n=i.get(1,1),t*n-e*r;if(i.columns===3){let s,a,u;return s=new ho(i,[1,2],[1,2]),a=new ho(i,[1,2],[0,2]),u=new ho(i,[1,2],[0,1]),t=i.get(0,0),e=i.get(0,1),r=i.get(0,2),t*po(s)-e*po(a)+r*po(u)}else return new _o(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Zy(i,t){let e=[];for(let r=0;r<i;r++)r!==t&&e.push(r);return e}function Ky(i,t,e,r=1e-9,n=1e-9){if(i>n)return new Array(t.rows+1).fill(0);{let s=t.addRow(e,[0]);for(let a=0;a<s.rows;a++)Math.abs(s.get(a,0))<r&&s.set(a,0,0);return s.to1DArray()}}function Gy(i,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;i=dt.checkMatrix(i);let n=i.rows,s=new dt(n,n);for(let a=0;a<n;a++){let u=dt.columnVector(i.getRow(a)),c=i.subMatrixRow(Zy(n,a)).transpose(),d=new Oi(c).solve(u),h=dt.sub(u,c.mmul(d)).abs().max();s.setRow(a,Ky(h,d,a,e,r))}return s}function Jy(i,t=Number.EPSILON){if(i=dt.checkMatrix(i),i.isEmpty())return i.transpose();let e=new Oi(i,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,s=e.diagonal;for(let a=0;a<s.length;a++)Math.abs(s[a])>t?s[a]=1/s[a]:s[a]=0;return n.mmul(dt.diag(s).mmul(r.transpose()))}function Xy(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(i=i.center("column"),r||(t=t.center("column")));const s=i.transpose().mmul(t);for(let a=0;a<s.rows;a++)for(let u=0;u<s.columns;u++)s.set(a,u,s.get(a,u)*(1/(i.rows-1)));return s}function Qy(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=e;n&&(i.center("column"),r||t.center("column")),s&&(i.scale("column"),r||t.scale("column"));const a=i.standardDeviation("column",{unbiased:!0}),u=r?a:t.standardDeviation("column",{unbiased:!0}),c=i.transpose().mmul(t);for(let f=0;f<c.rows;f++)for(let d=0;d<c.columns;d++)c.set(f,d,c.get(f,d)*(1/(a[f]*u[d]))*(1/(i.rows-1)));return c}let ph=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=wr.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n=t.columns,s=new dt(n,n),a=new Float64Array(n),u=new Float64Array(n),c=t,f,d,h=!1;if(r?h=!0:h=t.isSymmetric(),h){for(f=0;f<n;f++)for(d=0;d<n;d++)s.set(f,d,c.get(f,d));tw(n,u,a,s),ew(n,u,a,s)}else{let _=new dt(n,n),g=new Float64Array(n);for(d=0;d<n;d++)for(f=0;f<n;f++)_.set(f,d,c.get(f,d));rw(n,_,g,s),nw(n,u,a,s,_)}this.n=n,this.e=u,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,r=this.d,n=new dt(t,t),s,a;for(s=0;s<t;s++){for(a=0;a<t;a++)n.set(s,a,0);n.set(s,s,r[s]),e[s]>0?n.set(s,s+1,e[s]):e[s]<0&&n.set(s,s-1,e[s])}return n}};function tw(i,t,e,r){let n,s,a,u,c,f,d,h;for(c=0;c<i;c++)e[c]=r.get(i-1,c);for(u=i-1;u>0;u--){for(h=0,a=0,f=0;f<u;f++)h=h+Math.abs(e[f]);if(h===0)for(t[u]=e[u-1],c=0;c<u;c++)e[c]=r.get(u-1,c),r.set(u,c,0),r.set(c,u,0);else{for(f=0;f<u;f++)e[f]/=h,a+=e[f]*e[f];for(n=e[u-1],s=Math.sqrt(a),n>0&&(s=-s),t[u]=h*s,a=a-n*s,e[u-1]=n-s,c=0;c<u;c++)t[c]=0;for(c=0;c<u;c++){for(n=e[c],r.set(c,u,n),s=t[c]+r.get(c,c)*n,f=c+1;f<=u-1;f++)s+=r.get(f,c)*e[f],t[f]+=r.get(f,c)*n;t[c]=s}for(n=0,c=0;c<u;c++)t[c]/=a,n+=t[c]*e[c];for(d=n/(a+a),c=0;c<u;c++)t[c]-=d*e[c];for(c=0;c<u;c++){for(n=e[c],s=t[c],f=c;f<=u-1;f++)r.set(f,c,r.get(f,c)-(n*t[f]+s*e[f]));e[c]=r.get(u-1,c),r.set(u,c,0)}}e[u]=a}for(u=0;u<i-1;u++){if(r.set(i-1,u,r.get(u,u)),r.set(u,u,1),a=e[u+1],a!==0){for(f=0;f<=u;f++)e[f]=r.get(f,u+1)/a;for(c=0;c<=u;c++){for(s=0,f=0;f<=u;f++)s+=r.get(f,u+1)*r.get(f,c);for(f=0;f<=u;f++)r.set(f,c,r.get(f,c)-s*e[f])}}for(f=0;f<=u;f++)r.set(f,u+1,0)}for(c=0;c<i;c++)e[c]=r.get(i-1,c),r.set(i-1,c,0);r.set(i-1,i-1,1),t[0]=0}function ew(i,t,e,r){let n,s,a,u,c,f,d,h,_,g,y,p,w,v,x,b;for(a=1;a<i;a++)t[a-1]=t[a];t[i-1]=0;let C=0,E=0,A=Number.EPSILON;for(f=0;f<i;f++){for(E=Math.max(E,Math.abs(e[f])+Math.abs(t[f])),d=f;d<i&&!(Math.abs(t[d])<=A*E);)d++;if(d>f)do{for(n=e[f],h=(e[f+1]-n)/(2*t[f]),_=pn(h,1),h<0&&(_=-_),e[f]=t[f]/(h+_),e[f+1]=t[f]*(h+_),g=e[f+1],s=n-e[f],a=f+2;a<i;a++)e[a]-=s;for(C=C+s,h=e[d],y=1,p=y,w=y,v=t[f+1],x=0,b=0,a=d-1;a>=f;a--)for(w=p,p=y,b=x,n=y*t[a],s=y*h,_=pn(h,t[a]),t[a+1]=x*_,x=t[a]/_,y=h/_,h=y*e[a]-x*n,e[a+1]=s+x*(y*n+x*e[a]),c=0;c<i;c++)s=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+y*s),r.set(c,a,y*r.get(c,a)-x*s);h=-x*b*w*v*t[f]/g,t[f]=x*h,e[f]=y*h}while(Math.abs(t[f])>A*E);e[f]=e[f]+C,t[f]=0}for(a=0;a<i-1;a++){for(c=a,h=e[a],u=a+1;u<i;u++)e[u]<h&&(c=u,h=e[u]);if(c!==a)for(e[c]=e[a],e[a]=h,u=0;u<i;u++)h=r.get(u,a),r.set(u,a,r.get(u,c)),r.set(u,c,h)}}function rw(i,t,e,r){let n=0,s=i-1,a,u,c,f,d,h,_;for(h=n+1;h<=s-1;h++){for(_=0,f=h;f<=s;f++)_=_+Math.abs(t.get(f,h-1));if(_!==0){for(c=0,f=s;f>=h;f--)e[f]=t.get(f,h-1)/_,c+=e[f]*e[f];for(u=Math.sqrt(c),e[h]>0&&(u=-u),c=c-e[h]*u,e[h]=e[h]-u,d=h;d<i;d++){for(a=0,f=s;f>=h;f--)a+=e[f]*t.get(f,d);for(a=a/c,f=h;f<=s;f++)t.set(f,d,t.get(f,d)-a*e[f])}for(f=0;f<=s;f++){for(a=0,d=s;d>=h;d--)a+=e[d]*t.get(f,d);for(a=a/c,d=h;d<=s;d++)t.set(f,d,t.get(f,d)-a*e[d])}e[h]=_*e[h],t.set(h,h-1,_*u)}}for(f=0;f<i;f++)for(d=0;d<i;d++)r.set(f,d,f===d?1:0);for(h=s-1;h>=n+1;h--)if(t.get(h,h-1)!==0){for(f=h+1;f<=s;f++)e[f]=t.get(f,h-1);for(d=h;d<=s;d++){for(u=0,f=h;f<=s;f++)u+=e[f]*r.get(f,d);for(u=u/e[h]/t.get(h,h-1),f=h;f<=s;f++)r.set(f,d,r.get(f,d)+u*e[f])}}}function nw(i,t,e,r,n){let s=i-1,a=0,u=i-1,c=Number.EPSILON,f=0,d=0,h=0,_=0,g=0,y=0,p=0,w=0,v,x,b,C,E,A,N,S,I,F,O,L,z,q,W;for(v=0;v<i;v++)for((v<a||v>u)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<i;x++)d=d+Math.abs(n.get(v,x));for(;s>=a;){for(C=s;C>a&&(y=Math.abs(n.get(C-1,C-1))+Math.abs(n.get(C,C)),y===0&&(y=d),!(Math.abs(n.get(C,C-1))<c*y));)C--;if(C===s)n.set(s,s,n.get(s,s)+f),e[s]=n.get(s,s),t[s]=0,s--,w=0;else if(C===s-1){if(N=n.get(s,s-1)*n.get(s-1,s),h=(n.get(s-1,s-1)-n.get(s,s))/2,_=h*h+N,p=Math.sqrt(Math.abs(_)),n.set(s,s,n.get(s,s)+f),n.set(s-1,s-1,n.get(s-1,s-1)+f),S=n.get(s,s),_>=0){for(p=h>=0?h+p:h-p,e[s-1]=S+p,e[s]=e[s-1],p!==0&&(e[s]=S-N/p),t[s-1]=0,t[s]=0,S=n.get(s,s-1),y=Math.abs(S)+Math.abs(p),h=S/y,_=p/y,g=Math.sqrt(h*h+_*_),h=h/g,_=_/g,x=s-1;x<i;x++)p=n.get(s-1,x),n.set(s-1,x,_*p+h*n.get(s,x)),n.set(s,x,_*n.get(s,x)-h*p);for(v=0;v<=s;v++)p=n.get(v,s-1),n.set(v,s-1,_*p+h*n.get(v,s)),n.set(v,s,_*n.get(v,s)-h*p);for(v=a;v<=u;v++)p=r.get(v,s-1),r.set(v,s-1,_*p+h*r.get(v,s)),r.set(v,s,_*r.get(v,s)-h*p)}else e[s-1]=S+h,e[s]=S+h,t[s-1]=p,t[s]=-p;s=s-2,w=0}else{if(S=n.get(s,s),I=0,N=0,C<s&&(I=n.get(s-1,s-1),N=n.get(s,s-1)*n.get(s-1,s)),w===10){for(f+=S,v=a;v<=s;v++)n.set(v,v,n.get(v,v)-S);y=Math.abs(n.get(s,s-1))+Math.abs(n.get(s-1,s-2)),S=I=.75*y,N=-.4375*y*y}if(w===30&&(y=(I-S)/2,y=y*y+N,y>0)){for(y=Math.sqrt(y),I<S&&(y=-y),y=S-N/((I-S)/2+y),v=a;v<=s;v++)n.set(v,v,n.get(v,v)-y);f+=y,S=I=N=.964}for(w=w+1,E=s-2;E>=C&&(p=n.get(E,E),g=S-p,y=I-p,h=(g*y-N)/n.get(E+1,E)+n.get(E,E+1),_=n.get(E+1,E+1)-p-g-y,g=n.get(E+2,E+1),y=Math.abs(h)+Math.abs(_)+Math.abs(g),h=h/y,_=_/y,g=g/y,!(E===C||Math.abs(n.get(E,E-1))*(Math.abs(_)+Math.abs(g))<c*(Math.abs(h)*(Math.abs(n.get(E-1,E-1))+Math.abs(p)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=s;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=s-1&&(q=b!==s-1,b!==E&&(h=n.get(b,b-1),_=n.get(b+1,b-1),g=q?n.get(b+2,b-1):0,S=Math.abs(h)+Math.abs(_)+Math.abs(g),S!==0&&(h=h/S,_=_/S,g=g/S)),S!==0);b++)if(y=Math.sqrt(h*h+_*_+g*g),h<0&&(y=-y),y!==0){for(b!==E?n.set(b,b-1,-y*S):C!==E&&n.set(b,b-1,-n.get(b,b-1)),h=h+y,S=h/y,I=_/y,p=g/y,_=_/h,g=g/h,x=b;x<i;x++)h=n.get(b,x)+_*n.get(b+1,x),q&&(h=h+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-h*p)),n.set(b,x,n.get(b,x)-h*S),n.set(b+1,x,n.get(b+1,x)-h*I);for(v=0;v<=Math.min(s,b+3);v++)h=S*n.get(v,b)+I*n.get(v,b+1),q&&(h=h+p*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-h*g)),n.set(v,b,n.get(v,b)-h),n.set(v,b+1,n.get(v,b+1)-h*_);for(v=a;v<=u;v++)h=S*r.get(v,b)+I*r.get(v,b+1),q&&(h=h+p*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-h*g)),r.set(v,b,r.get(v,b)-h),r.set(v,b+1,r.get(v,b+1)-h*_)}}}if(d!==0){for(s=i-1;s>=0;s--)if(h=e[s],_=t[s],_===0)for(C=s,n.set(s,s,1),v=s-1;v>=0;v--){for(N=n.get(v,v)-h,g=0,x=C;x<=s;x++)g=g+n.get(v,x)*n.get(x,s);if(t[v]<0)p=N,y=g;else if(C=v,t[v]===0?n.set(v,s,N!==0?-g/N:-g/(c*d)):(S=n.get(v,v+1),I=n.get(v+1,v),_=(e[v]-h)*(e[v]-h)+t[v]*t[v],A=(S*y-p*g)/_,n.set(v,s,A),n.set(v+1,s,Math.abs(S)>Math.abs(p)?(-g-N*A)/S:(-y-I*A)/p)),A=Math.abs(n.get(v,s)),c*A*A>1)for(x=v;x<=s;x++)n.set(x,s,n.get(x,s)/A)}else if(_<0)for(C=s-1,Math.abs(n.get(s,s-1))>Math.abs(n.get(s-1,s))?(n.set(s-1,s-1,_/n.get(s,s-1)),n.set(s-1,s,-(n.get(s,s)-h)/n.get(s,s-1))):(W=mo(0,-n.get(s-1,s),n.get(s-1,s-1)-h,_),n.set(s-1,s-1,W[0]),n.set(s-1,s,W[1])),n.set(s,s-1,0),n.set(s,s,1),v=s-2;v>=0;v--){for(F=0,O=0,x=C;x<=s;x++)F=F+n.get(v,x)*n.get(x,s-1),O=O+n.get(v,x)*n.get(x,s);if(N=n.get(v,v)-h,t[v]<0)p=N,g=F,y=O;else if(C=v,t[v]===0?(W=mo(-F,-O,N,_),n.set(v,s-1,W[0]),n.set(v,s,W[1])):(S=n.get(v,v+1),I=n.get(v+1,v),L=(e[v]-h)*(e[v]-h)+t[v]*t[v]-_*_,z=(e[v]-h)*2*_,L===0&&z===0&&(L=c*d*(Math.abs(N)+Math.abs(_)+Math.abs(S)+Math.abs(I)+Math.abs(p))),W=mo(S*g-p*F+_*O,S*y-p*O-_*F,L,z),n.set(v,s-1,W[0]),n.set(v,s,W[1]),Math.abs(S)>Math.abs(p)+Math.abs(_)?(n.set(v+1,s-1,(-F-N*n.get(v,s-1)+_*n.get(v,s))/S),n.set(v+1,s,(-O-N*n.get(v,s)-_*n.get(v,s-1))/S)):(W=mo(-g-I*n.get(v,s-1),-y-I*n.get(v,s),p,_),n.set(v+1,s-1,W[0]),n.set(v+1,s,W[1]))),A=Math.max(Math.abs(n.get(v,s-1)),Math.abs(n.get(v,s))),c*A*A>1)for(x=v;x<=s;x++)n.set(x,s-1,n.get(x,s-1)/A),n.set(x,s,n.get(x,s)/A)}for(v=0;v<i;v++)if(v<a||v>u)for(x=v;x<i;x++)r.set(v,x,n.get(v,x));for(x=i-1;x>=a;x--)for(v=a;v<=u;v++){for(p=0,b=a;b<=Math.min(x,u);b++)p=p+r.get(v,b)*n.get(b,x);r.set(v,x,p)}}}function mo(i,t,e,r){let n,s;return Math.abs(e)>Math.abs(r)?(n=r/e,s=e+n*r,[(i+n*t)/s,(t-n*i)/s]):(n=e/r,s=r+n*e,[(n*i+t)/s,(n*t-i)/s])}class mh{constructor(t){if(t=wr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new dt(r,r),s=!0,a,u,c;for(u=0;u<r;u++){let f=0;for(c=0;c<u;c++){let d=0;for(a=0;a<c;a++)d+=n.get(c,a)*n.get(u,a);d=(e.get(u,c)-d)/n.get(c,c),n.set(u,c,d),f=f+d*d}for(f=e.get(u,u)-f,s&=f>0,n.set(u,u,Math.sqrt(Math.max(f,0))),c=u+1;c<r;c++)n.set(u,c,0)}this.L=n,this.positiveDefinite=!!s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=wr.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=t.columns,s=t.clone(),a,u,c;for(c=0;c<r;c++)for(u=0;u<n;u++){for(a=0;a<c;a++)s.set(c,u,s.get(c,u)-s.get(a,u)*e.get(c,a));s.set(c,u,s.get(c,u)/e.get(c,c))}for(c=r-1;c>=0;c--)for(u=0;u<n;u++){for(a=c+1;a<r;a++)s.set(c,u,s.get(c,u)-s.get(a,u)*e.get(a,c));s.set(c,u,s.get(c,u)/e.get(c,c))}return s}get lowerTriangularMatrix(){return this.L}}class gh{constructor(t,e={}){t=wr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:s=1e3,terminationCriteria:a=1e-10}=e;let u;if(r){if(fr.isAnyArray(r)&&typeof r[0]=="number"?r=dt.columnVector(r):r=wr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");u=r.getColumnVector(0)}else u=t.getColumnVector(0);let c=1,f,d,h,_;for(let g=0;g<s&&c>a;g++)h=t.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),h=h.div(h.norm()),f=t.mmul(h).div(h.transpose().mmul(h).get(0,0)),g>0&&(c=f.clone().sub(_).pow(2).sum()),_=f.clone(),r?(d=r.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0)),d=d.div(d.norm()),u=r.mmul(d).div(d.transpose().mmul(d).get(0,0))):u=f;if(r){let g=t.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0));g=g.div(g.norm());let y=t.clone().sub(f.clone().mmul(g.transpose())),p=u.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0)),w=r.clone().sub(f.clone().mulS(p.get(0,0)).mmul(d.transpose()));this.t=f,this.p=g.transpose(),this.w=h.transpose(),this.q=d,this.u=u,this.s=f.transpose().mmul(f),this.xResidual=y,this.yResidual=w,this.betas=p}else this.w=h.transpose(),this.s=f.transpose().mmul(f).sqrt(),n?this.t=f.clone().div(this.s.get(0,0)):this.t=f,this.xResidual=t.sub(f.mmul(h.transpose()))}}zt.AbstractMatrix=$t,zt.CHO=mh,zt.CholeskyDecomposition=mh,zt.DistanceMatrix=fo,zt.EVD=ph;var iw=zt.EigenvalueDecomposition=ph;zt.LU=_o,zt.LuDecomposition=_o;var vh=zt.Matrix=dt;zt.MatrixColumnSelectionView=ky,zt.MatrixColumnView=Py,zt.MatrixFlipColumnView=zy,zt.MatrixFlipRowView=qy,zt.MatrixRowSelectionView=Wy,zt.MatrixRowView=Uy,zt.MatrixSelectionView=ho,zt.MatrixSubView=jy,zt.MatrixTransposeView=Yy,zt.NIPALS=gh,zt.Nipals=gh,zt.QR=eu,zt.QrDecomposition=eu,zt.SVD=Oi,zt.SingularValueDecomposition=Oi,zt.SymmetricMatrix=ri,zt.WrapperMatrix1D=dh,zt.WrapperMatrix2D=wr,zt.correlation=Qy,zt.covariance=Xy;var yh=zt.default=dt;zt.determinant=po,zt.inverse=Hy,zt.linearDependencies=Gy,zt.pseudoInverse=Jy,zt.solve=_h,zt.wrap=Vy;const wh=iw,Dh=vh;yh.Matrix&&yh.Matrix;class sw{constructor(t){$(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new ru(t,e,r,this._errorListener)}avg({id:t}){return t==null?void 0:t.avg()}col({id:t,column:e}){return t==null?void 0:t.col({column:e})}det({id:t}){return t==null?void 0:t.det()}get({id:t,row:e,column:r}){return t==null?void 0:t.get({row:e,column:r})}inv({id:t}){return t==null?void 0:t.inv()}max({id:t}){return t==null?void 0:t.max()}min({id:t}){return t==null?void 0:t.min()}pow({id:t,power:e}){return t==null?void 0:t.pow({power:e})}row({id:t,row:e}){return t==null?void 0:t.row({row:e})}set({id:t,row:e,column:r,value:n}){t==null||t.set({row:e,column:r,value:n})}sum({id1:t,id2:e}){return t==null?void 0:t.sum({id2:e})}copy({id:t}){return t==null?void 0:t.copy()}diff({id1:t,id2:e}){return t==null?void 0:t.diff({id2:e})}rows({id:t}){return t==null?void 0:t.rows()}columns({id:t}){return t==null?void 0:t.columns()}fill({id:t,value:e,from_row:r,to_row:n,from_column:s,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:s,to_column:a})}kron({id1:t,id2:e}){return t==null?void 0:t.kron({id2:e})}mode({id:t}){return t==null?void 0:t.mode()}mult({id1:t,id2:e}){return t==null?void 0:t.mult({id2:e})}pinv({id:t}){return t==null?void 0:t.pinv()}rank({id:t}){return t==null?void 0:t.rank()}sort({id:t,column:e,order:r}){t==null||t.sort({column:e,order:r})}trace({id:t}){return t==null?void 0:t.trace()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}median({id:t}){return t==null?void 0:t.median()}add_col({id:t,column:e,array_id:r}){t==null||t.add_col({column:e,array_id:r})}add_row({id:t,row:e,array_id:r}){t==null||t.add_row({row:e,array_id:r})}is_zero({id:t}){return t==null?void 0:t.is_zero()}reshape({id:t,rows:e,columns:r},n){return t==null?void 0:t.reshape({rows:e,columns:r},n)}reverse({id:t}){t==null||t.reverse()}is_binary({id:t}){return t==null?void 0:t.is_binary()}is_square({id:t}){return t==null?void 0:t.is_square()}submatrix({id:t,from_row:e,to_row:r,from_column:n,to_column:s}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:s})}swap_rows({id:t,row1:e,row2:r}){t==null||t.swap_rows({row1:e,row2:r})}transpose({id:t}){return t==null?void 0:t.transpose()}remove_col({id:t,column:e}){return t==null?void 0:t.remove_col({column:e})}remove_row({id:t,row:e}){return t==null?void 0:t.remove_row({row:e})}eigenvalues({id:t}){return t==null?void 0:t.eigenvalues()}is_diagonal({id:t}){return t==null?void 0:t.is_diagonal()}is_identity({id:t}){return t==null?void 0:t.is_identity()}eigenvectors({id:t}){return t==null?void 0:t.eigenvectors()}is_symmetric({id:t}){return t==null?void 0:t.is_symmetric()}swap_columns({id:t,column1:e,column2:r}){t==null||t.swap_columns({column1:e,column2:r})}is_stochastic({id:t}){return t==null?void 0:t.is_stochastic()}is_triangular({id:t}){return t==null?void 0:t.is_triangular()}elements_count({id:t}){return t==null?void 0:t.elements_count()}is_antidiagonal({id:t}){return t==null?void 0:t.is_antidiagonal()}is_antisymmetric({id:t}){return t==null?void 0:t.is_antisymmetric()}}class ru{constructor(t=0,e=0,r=void 0,n){$(this,"_matrixInstance");$(this,"_errorListener");this._matrixInstance=this._createMatrix(t,e,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(t=>[...t._value])}get _value(){return this._matrixInstance}set _value(t){this._matrixInstance=t}get isMatrix(){return!0}_createMatrix(t,e,r){return Array.from(new Array(t),()=>new ee(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const s of n._value)t+=mt(s)?0:s,e+=1;return t/e}col({column:t}){const e=[],r=new ee(0,void 0,this._errorListener);if(mt(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return oh(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(mt(t)||mt(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=ao(this._matrixArray);return this._newMatrix(t)}max(){return ty(this._matrixArray)}min(){return Ja(this._matrixArray)}pow({power:t}){const e=mt(t)?this._matrixArray:ry(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return mt(t)?new ee(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){mt(t)||mt(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=os(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=Z1(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:t,from_row:e,to_row:r,from_column:n,to_column:s}={}){mt(e)&&(e=0),mt(r)&&(r=this.rows()),mt(n)&&(n=0),mt(s)&&(s=this.columns());for(const[a,u]of this._matrixInstance.entries())for(const[c]of u._value.entries())a<r&&a>=e&&c>=n&&c<s&&u.set({index:c,value:t})}kron({id2:t}){const e=V1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return Ja(Qf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=Mi(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=ey(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Gn.ascending}={}){mt(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const s=r._value[t],a=n._value[t];return e!==Gn.descending?s-a:a-s})}trace(){return Q1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return ah(this._matrixArray)}add_col({column:t,array_id:e}={}){mt(t)&&(t=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:t,value:e?e._value[r]:void 0})}add_row({row:t,array_id:e}){mt(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new ee(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t=0,columns:e=0},r){if(t*e!==this.columns()*this.rows()){this._errorListener.addError(ie.matrixRehapeErr,r,Rt.Error);return}const n=U1(this._matrixArray,[t,e]);this._matrixInstance=n.map(s=>{const a=new ee(0,void 0,this._errorListener);return a._value=[...s],a})}reverse(){this._matrixInstance.reverse();for(const t of this._matrixInstance)t.reverse()}is_binary(){return this._matrixArray.every(t=>t.every(e=>e===0||e===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:t,to_row:e,from_column:r,to_column:n}={}){mt(t)&&(t=0),mt(e)&&(e=this.rows()),mt(r)&&(r=0),mt(n)&&(n=this.columns());const s=this._matrixArray.splice(t,e),a=[];for(const u of s)a.push(u.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(mt(t)||mt(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=eh(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){mt(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const s=n._value.splice(t,1);e.push(s[0])}const r=new ee(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return mt(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new wh(new Dh(this._matrixArray)),e=new ee(0,void 0,this._errorListener);return e._value=t.realEigenvalues,e}is_diagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0)return!1;return!0}is_identity(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0||n===s&&r[n][s]!==1)return!1;return!0}eigenvectors(){const t=new wh(new Dh(this._matrixArray));return this._newMatrix(t.eigenvectorMatrix.to2DArray())}is_symmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=n+1;s<e;s++)if(r[n][s]!==r[s][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(mt(t)||mt(e)))for(const r of this._matrixInstance){const n=r._value[t],s=r._value[e];r.set({index:t,value:s}),r.set({index:e,value:n})}}is_stochastic(){const t=this._matrixArray;for(let e=0;e<t.length;e++){let r=0;for(let n=0;n<t[e].length;n++){if(t[e][n]<0)return!1;r+=t[e][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const t=this.rows(),e=this.columns();return t!==e?!1:this._isUpperTriangular(t)||this._isLowerTriangular(t)}elements_count(){return W1(this._matrixArray)}is_antidiagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n+s!==t-1&&r[n][s]!==0)return!1;return!0}is_antisymmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n!==s&&r[n][s]!==-r[s][n])return!1;return!0}_isUpperTriangular(t){const e=this._matrixArray;for(let r=1;r<t;r++)for(let n=0;n<r;n++)if(e[r][n]!==0)return!1;return!0}_isLowerTriangular(t){const e=this._matrixArray;for(let r=0;r<t-1;r++)for(let n=r+1;n<t;n++)if(e[r][n]!==0)return!1;return!0}_newMatrix(t){const e=new ru(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new ee(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,s=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let u=a;for(;u<r&&s[u][a]===0;)u++;if(u===r)continue;if(u!==a){const f=s[u];s[u]=s[a],s[a]=f}const c=s[a][a];for(let f=0;f<n;f++)s[a][f]/=c;for(let f=a+1;f<r;f++){const d=s[f][a];s[f]=s[f].map((h,_)=>h-d*s[a][_]),s[f][a]=0}}for(let a=0;a<r;a++)s[a].some(u=>Number(u.toFixed(8))!==0)&&e++;return e}}class ow{constructor(t){$(this,"_variables");$(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const{time:r,__period:n}=this._variables,s=gr(t,r),a=gr(n,r);if(s<a)return!0;const u=`change_${e}`,c=this._cacheData[u],f=this._variables.time;if(c){if(c.offset){if(c.currentTime+c.offset<=f)return this._cacheData[u]={currentTime:f,offset:0},!0}else if(c.currentTime+s*1e3<=f)return this._cacheData[u]={currentTime:f,offset:0},!0}else{const d=this._calcTimeOffset(f,t);return this._cacheData[u]={currentTime:f,offset:d},!1}return!1}in_seconds({timeframe:t}={}){const{time:e,__period:r}=this._variables;return gr(t||r,e)}from_seconds({seconds:t=0}){const e=t*1e3,r=Wt.duration(e);if(r.years())return"12M";const s=r.asMonths();if(so(s))return`${s}M`;const a=r.asWeeks();if(so(a))return`${a}M`;const u=r.asDays();if(u>=1)return`${Math.ceil(u)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const f=r.asSeconds();return f<=1?"1S":f<=5?"5S":f<=10?"10S":f<=15?"15S":f<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const u=Wt(t).day();e="1D",u!==1&&(r=(8-u)*60*60*24*1e3)}else if(e.includes("M")){const u=Wt(t).date();e="1D";const c=Wt(t).daysInMonth();u!==1&&(r=(c-u+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),s=gr(e,t)*1e3,a=t-n-Math.floor((t-n)/s)*s;return r?r-a:a}}var bh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(r,n,s){var a=n.prototype,u=a.format;s.en.formats=e,a.format=function(c){c===void 0&&(c="YYYY-MM-DDTHH:mm:ssZ");var f=this.$locale().formats,d=function(h,_){return h.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(g,y,p){var w=p&&p.toUpperCase();return y||_[p]||e[p]||_[w].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(v,x,b){return x||b.slice(1)})})}(c,f===void 0?{}:f);return u.call(this,d)}}})})(bh);var aw=bh.exports,uw=Kt(aw);Wt.extend(uw);class lw{constructor(t,e){$(this,"_errorListener");$(this,"_intlNumberFormatter");$(this,"_precision");$(this,"_intlFormat");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"}),this._intlFormat=new Intl.NumberFormat("en-US")}pos({source:t="",str:e=""}){return t==null?void 0:t.indexOf(e)}trim({source:t=""}){return t==null?void 0:t.trim()}lower({source:t=""}){return t==null?void 0:t.toLocaleLowerCase()}match({source:t="",regex:e=""}){const r=t==null?void 0:t.match(new RegExp(e));return r?r[0]:""}split({string:t="",separator:e=""}){const r=t==null?void 0:t.split(e),n=new ee;return n._value=r||[],n}upper({source:t=""}){return t==null?void 0:t.toLocaleUpperCase()}format({formatString:t=""},e){return this._strFormat(t,e)}length({string:t=""}){return t==null?void 0:t.length}repeat({source:t="",repeat:e,separator:r=""},n){if(mt(e)){this._errorListener.addError(ie.arrLenErr,n,Rt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){mt(n)&&(n=0);let s=-1;for(let a=0;a<n+1&&(s=t.indexOf(e,s+1),s!==-1);a++);return s!==-1?t.substring(0,s)+r+t.substring(s+e.length):t}contains({source:t="",str:e=""}){return t==null?void 0:t.includes(e)}endswith({source:t="",str:e=""}){return t==null?void 0:t.endsWith(e)}tonumber({string:t=""}){if(/[^\d.]/.test(t))return;const e=parseFloat(t);return isNaN(e)?void 0:e}tostring({value:t,format:e}){if(t===void 0)return"NaN";if(typeof t=="object"){if(t.isArray)return this._arrToStr(t._value,e);if(t.isMatrix){const r=[];for(const n of t._matrixArray)r.push(this._arrToStr(n,e));return r.join(`
|
62
|
-
`)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return String(this._toStringFormat(t,e==null?void 0:e.replace(/0/g,"#")))}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._toStringFormat(n,e):n).toString()}]`}substring({source:t="",begin_pos:e=0,end_pos:r}){return mt(e)&&(e=0),mt(r)&&(r=void 0),t==null?void 0:t.substring(e,r)}startswith({source:t="",str:e=""}){return t==null?void 0:t.startsWith(e)}format_time({time:t,format:e="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return mt(t)&&(t=0),mr(t,r).format(e)}replace_all({source:t="",target:e="",replacement:r=""}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_toStringFormat(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case Gt.mintick:return t.toFixed(this._precision);case Gt.percent:return`${t}%`;case Gt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var u;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[s,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),f=((u=c[c.length-1])==null?void 0:u.replace(/[^#]/g,"").length)||0;f&&(s=s.replace(new RegExp(`\\B(?=(\\d{${f}})+(?!\\d))`,"g"),",")),r=c.join("")}s=r.replace(/#/,s).replace(/#/g,"")}else s=`${r}${s}`;if(n&&n.includes("#")){const c=n.split("#").length-1,f=+`${s}.${a}`;if(!isNaN(f))return`${f.toFixed(c)}${n.replace(/#/g,"")}`;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${s}.${a}`:s}_formatNumber(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:return this._formatOthers(t,e)}}strformat({formatString:t=""},e,r){return this._strFormat(t,e,r)}_strFormat(t,e,r){return t.replace(/{[^{}]+}/g,n=>{if(!n)return n;const s=n.replace(/[{}]/g,"").split(","),a=Number(s[0]);if(isNaN(a)||e.length<=a)return n;const u=e[a];if(s.length===1)return typeof u=="number"&&r?this._intlFormat.format(u):u;if(s.length===2){const c=s[1].trim();return c==="number"?r?this._intlFormat.format(u):u:c==="date"?Wt(u).format("LL"):n}else{const c=s[1].trim(),f=s[2].trim();if(c==="number")return this._formatNumber(u,f);if(c==="date"){let d="YYYY-MM-DD";switch(f){case"long":d="LL";break;case"short":d="L";break;default:f&&(d=f)}return Wt(u).format(d)}return n}})}}class cw{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new nu(this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}get({id:t,key:e}){return t==null?void 0:t.get({key:e})}put({id:t,key:e,value:r}){return t==null?void 0:t.put({key:e,value:r})}keys({id:t}){return t==null?void 0:t.keys()}size({id:t}){return t==null?void 0:t.size()}clear({id:t}){t==null||t.clear()}remove({id:t,key:e}){return t==null?void 0:t.remove({key:e})}values({id:t}){return t==null?void 0:t.values()}put_all({id:t,id2:e}){t==null||t.put_all({id2:e})}contains({id:t,key:e}){return t==null?void 0:t.contains({key:e})}}class nu{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new nu(this._errorListener);return e._mapInstance=new Map(t.entries()),e}copy(){return this._copyMap(this._mapInstance)}get({key:t}){return this._mapInstance.get(t)}put({key:t,value:e}){return this._mapInstance.set(t,e)}keys(){const t=new ee(0,void 0,this._errorListener);return t._value=[...this._mapInstance.keys()],t}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:t}){const e=this._mapInstance.get(t);return this._mapInstance.delete(t),e||void 0}values(){const t=new ee(0,void 0,this._errorListener);return t._value=[...this._mapInstance.values()],t}put_all({id2:t}){this._mapInstance=new Map([...this._mapInstance,...t._mapInstance])}contains({key:t}){return this._mapInstance.has(t)}}class fw{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Bi(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Bi(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Bi(t,e)}from_time({price:t,time:e}){return new Bi(t,void 0,e)}}class Bi{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}set index(t){this._index=t}get price(){return this._price}set price(t){this._price=t}get time(){return this._time}set time(t){this._time=t}copy(){return new Bi(this._price,this._index,this._time)}}class hw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:be.bar_index,yloc:Vr.price,size:ir.normal,style:ye.styleLabelDown,textalign:jt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:s,bar_index:a}=this._variables,u=`label_${e}_${a}`;ve(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:u,time:r,high:n,low:s,bar_index:a};t.point&&(c.x=c.xloc===be.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Vr.abovebar?c.y=n:c.yloc===Vr.belowbar&&(c.y=s),this._verfiyArgs(t,e);const f=new go(u,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(u,c,f),f}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:s,size:a,textalign:u,text_font_family:c}=t,f="label.new";this._paramVerfiy(s,e,f,Object.values(ye),"style"),this._paramVerfiy(r,e,f,Object.values(be),"xloc"),this._paramVerfiy(n,e,f,Object.values(Vr),"yloc"),this._paramVerfiy(a,e,f,Object.values(ir),"size"),this._paramVerfiy(u,e,f,[jt.alignLeft,jt.alignCenter,jt.alignRight],"textalign"),this._paramVerfiy(c,e,f,Object.values(Jn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}label(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class go{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");this._id=t,this._variables=e,this._errorListener=r}get type(){return te.LABEL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.label.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`label_${t}_${e}`,n=this._getLabel(t),s=new go(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,s)}return s}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t),this._paramVerfiy(t,e,"label.set_size",Object.values(ir),"size")}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e,this._paramVerfiy(e,r,"label.set_xloc",Object.values(be),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:s}=this._variables;r&&(r.yloc=t,t===Vr.abovebar?r.y=n:t===Vr.belowbar&&(r.y=s),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Vr),"yloc"))}set_color(t,e){const r=this._getLabel(e);ve(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===be.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t),this._paramVerfiy(t,e,"label.set_style",Object.values(ye),"style")}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t),this._paramVerfiy(t,e,"label.set_textalign",[jt.alignLeft,jt.alignCenter,jt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);ve(t,["textcolor"]),r&&(r.textcolor=t.textcolor)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t),this._paramVerfiy(t,e,"label.set_text_font_family",Object.values(Jn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const dw={freq_all:jr.freqAll,freq_once_per_bar:jr.freqOncePerBar,freq_once_per_bar_close:jr.freqOncePerBarClose},_w={gaps_off:ln.gapsOff,gaps_on:ln.gapsOn,lookahead_off:ln.lookaheadOff,lookahead_on:ln.lookaheadOn},Ti={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#FF5252",silver:"#B2B5BE",teal:"#00897B",white:"#FFFFFF",yellow:"#FFEB3B"},xh={AUD:"AUD",BTC:"BTC",CAD:"CAD",CHF:"CHF",ETH:"ETH",EUR:"EUR",GBP:"GBP",HKD:"HKD",INR:"INR",JPY:"JPY",KRW:"KRW",MYR:"MYR",NOK:"NOK",NONE:"NONE",NZD:"NZD",RUB:"RUB",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",USDT:"USDT",ZAR:"ZAR"},pw={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Eh={all:[Ze.dataWindow,Ze.pane,Ze.priceScale,Ze.statusLine],data_window:[Ze.dataWindow],none:[],pane:[Ze.pane],price_scale:[Ze.priceScale],status_line:[Ze.statusLine]},mw={both:Yr.both,left:Yr.left,none:Yr.none,right:Yr.right},gw={inherit:Gt.inherit,mintick:Gt.mintick,percent:Gt.percent,price:Gt.price,volume:Gt.volume},vw={style_solid:Ss.styleSolid,style_dashed:Ss.styleDashed,style_dotted:Ss.styleDotted},yw={style_arrowdown:ye.styleArrowdown,style_arrowup:ye.styleArrowup,style_circle:ye.styleCircle,style_cross:ye.styleCross,style_diamond:ye.styleDiamond,style_flag:ye.styleFlag,style_label_center:ye.styleLabelCenter,style_label_down:ye.styleLabelDown,style_label_left:ye.styleLabelLeft,style_label_lower_left:ye.styleLabelLowerLeft,style_label_lower_right:ye.styleLabelLowerRight,style_label_right:ye.styleLabelRight,style_label_up:ye.styleLabelUp,style_label_upper_left:ye.styleLabelUpperLeft,style_label_upper_right:ye.styleLabelUpperRight,style_none:ye.styleNone,style_square:ye.styleSquare,style_text_outline:ye.styleTextOutline,style_triangledown:ye.styleTriangledown,style_triangleup:ye.styleTriangleup,style_xcross:ye.styleXcross},ww={style_arrow_both:Re.styleArrowBoth,style_arrow_left:Re.styleArrowLeft,style_arrow_right:Re.styleArrowRight,style_dashed:Re.styleDashed,style_dotted:Re.styleDotted,style_solid:Re.styleSolid},Dw={abovebar:cn.abovebar,absolute:cn.absolute,belowbar:cn.belowbar,bottom:cn.bottom,top:cn.top},bw={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},xw={style_area:Or.styleArea,style_areabr:Or.styleAreabr,style_circles:Or.styleCircles,style_columns:Or.styleColumns,style_cross:Or.styleCross,style_histogram:Or.styleHistogram,style_line:Or.styleLine,style_linebr:Or.styleLinebr,style_stepline:Or.styleStepline,style_stepline_diamond:Or.styleSteplineDiamond,style_steplinebr:Or.styleSteplinebr},Ew={bottom_center:vr.bottomCenter,bottom_left:vr.bottomLeft,bottom_right:vr.bottomRight,middle_center:vr.middleCenter,middle_left:vr.middleLeft,middle_right:vr.middleRight,top_center:vr.topCenter,top_left:vr.topLeft,top_right:vr.topRight},Cw={left:Os.left,none:Os.none,right:Os.right},Aw={arrowdown:lr.arrowdown,arrowup:lr.arrowup,circle:lr.circle,cross:lr.cross,diamond:lr.diamond,flag:lr.flag,labeldown:lr.labeldown,labelup:lr.labelup,square:lr.square,triangledown:lr.triangledown,triangleup:lr.triangleup,xcross:lr.xcross},Mw={auto:ir.auto,huge:ir.huge,large:ir.large,normal:ir.normal,small:ir.small,tiny:ir.tiny},Fw={cash:Pe.cash,fixed:Pe.fixed,percent_of_equity:Pe.percentOfEquity,commission:{cash_per_contract:je.cashPerContract,cash_per_order:je.cashPerOrder,percent:je.percent},direction:{all:fe.all,long:fe.long,short:fe.short},oca:{cancel:fn.cancel,none:fn.none,reduce:fn.reduce}},Nw={align_bottom:jt.alignBottom,align_center:jt.alignCenter,align_left:jt.alignLeft,align_right:jt.alignRight,align_top:jt.alignTop,wrap_auto:jt.wrapAuto,wrap_none:jt.wrapNone},Sw={bar_index:be.bar_index,bar_time:be.bar_time},Ow={abovebar:Vr.abovebar,belowbar:Vr.belowbar,price:Vr.price},Bw={actual:Bs.actual,estimate:Bs.estimate,standardized:Bs.standardized};class Ch{constructor(){$(this,"adjustment",{dividends:Ns.dividends,none:Ns.none,splits:Ns.splits});$(this,"alert",dw);$(this,"barmerge",_w);$(this,"color",Ti);$(this,"currency",xh);$(this,"dayofweek",pw);$(this,"earnings",Bw);$(this,"display",Eh);$(this,"extend",mw);$(this,"font",{family_default:Jn.familyDefault,family_monospace:Jn.familyMonospace});$(this,"format",gw);$(this,"hline",vw);$(this,"label",yw);$(this,"line",ww);$(this,"location",Dw);$(this,"math",bw);$(this,"order",{ascending:Gn.ascending,descending:Gn.descending});$(this,"plot",xw);$(this,"position",Ew);$(this,"scale",Cw);$(this,"session",{extended:Mn.extended,regular:Mn.regular});$(this,"shape",Aw);$(this,"size",Mw);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",Fw);$(this,"text",Nw);$(this,"xloc",Sw);$(this,"yloc",Ow)}updateData(){}}class Tw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:be.bar_index,line_color:Ti.blue,line_style:Re.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var u;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,s=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(u=t.points)==null?void 0:u._value.map(c=>({time:c.time,index:c.index,price:c.price}))});ve(s,["line_color","fill_color"]);const a=new Ah(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,s,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,s="polyline.new";this._paramVerfiy(r,e,s,Object.values(Re),"line_style"),this._paramVerfiy(n,e,s,Object.values(be),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}delete({id:t}){t&&t.delete()}}class Ah{constructor(t,e){$(this,"_id");$(this,"_variables");$(this,"_suffix");this._variables=e,this._id=t}get type(){return te.POLYLINE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}}class Iw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:be.bar_index,extend:Yr.none,style:Re.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:s}=this._variables,a=`line_${n}_${s}`;ve(r,["color"]);const u={...this._defaultLine,...r,id:a,bar_index:s};if(t&&e){const f=u.xloc===be.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,d=u.xloc===be.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(u,{x1:f,y1:t==null?void 0:t.price,x2:d,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new vo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,u,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:s}=t,a="line.new";this._paramVerfiy(s,e,a,Object.values(Re),"style"),this._paramVerfiy(r,e,a,Object.values(Yr),"extend"),this._paramVerfiy(n,e,a,Object.values(be),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}line(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class vo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_suffix","");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get type(){return te.LINE}get data(){return this._variables.line.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`line_${t}_${e}`,n=this._getLine(t),s=new vo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e,isVar:void 0},s),s}delete(){this._variables.line.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===be.bar_index){const{x1:n,y1:s,x2:a,y2:u}=r;return n===void 0||a===void 0||s===void 0||u===void 0?void 0:(u-s)/(a-n)*(t-n)+s}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const s=this._getLine(n);s&&(s.xloc=t,s.x1=e,s.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(be),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(ve(t,["color"]),r.color=t.color)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values(Re),"style"))}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t,this._paramVerfiy(t,e,"line.set_extend",Object.values(Yr),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},u=r.xloc===be.bar_index?n:s,c=a;u&&(r.x1=u),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},u=r.xloc===be.bar_index?n:s,c=a;u&&(r.x2=u),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class $w{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:s}=this._variables,a=`linefill_${e}_${s}`,u=r==null?void 0:r.data,c=n==null?void 0:n.data;u&&(u.linefills=u.linefills||[],u.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),ve(t,["color"]);const f=new yo(this._variables,a,r,n);return e.startsWith("export")||(u||c)&&this._variables.linefill.add(a,{line1:u,line2:c,color:t.color,id:a,bar_index:s},f),f}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class yo{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");$(this,"_suffix");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return te.LINEFILL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new yo(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:s}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),s&&(s.linefills=(r=s.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(ve(t,["color"]),e.color=t.color)}}class Lw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Ti.blue,border_width:1,bgcolor:Ti.blue,xloc:be.bar_index,extend:Yr.none,style:Re.styleSolid,text:"",text_size:ir.auto,text_color:Ti.black,text_halign:jt.alignCenter,text_valign:jt.alignCenter,text_wrap:jt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:s}=this._variables,a=`box_${n}_${s}`,u={...this._defaultBox,...r,id:a,bar_index:s};if(ve(u,["border_color","bgcolor","text_color"]),t){const{price:f,time:d,index:h}=t;u.top=f,u.left=u.xloc===be.bar_index?h:d}if(e){const{price:f,time:d,index:h}=e;u.bottom=f,u.right=u.xloc===be.bar_index?h:d}this._verfiyArgs(r,n);const c=new wo(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,u,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:s,text_size:a,text_halign:u,text_valign:c,text_wrap:f,text_font_family:d}=t,h="box.new";this._paramVerfiy(r,e,h,[Re.styleDashed,Re.styleDotted,Re.styleSolid],"border_style"),this._paramVerfiy(n,e,h,Object.values(Yr),"extend"),this._paramVerfiy(s,e,h,Object.values(be),"xloc"),this._paramVerfiy(a,e,h,Object.values(ir),"text_size"),this._paramVerfiy(u,e,h,[jt.alignLeft,jt.alignCenter,jt.alignRight],"text_halign"),this._paramVerfiy(c,e,h,[jt.alignBottom,jt.alignCenter,jt.alignTop],"text_valign"),this._paramVerfiy(f,e,h,[jt.wrapAuto,jt.wrapNone],"text_wrap"),this._paramVerfiy(d,e,h,Object.values(Jn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_text({id:t,...e}){t==null||t.set_text(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e},r){t==null||t.set_border_style(e,r)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e},r){t==null||t.set_text_size(e,r)}set_text_wrap({id:t,...e},r){t==null||t.set_text_wrap(e,r)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e},r){t==null||t.set_text_halign(e,r)}set_text_valign({id:t,...e},r){t==null||t.set_text_valign(e,r)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class wo{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");this._variables=t,this._id=e,this._errorListener=r}get type(){return te.BOX}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.box.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`box_${t}_${e}`,n=this._getBox(),s=new wo(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},s),s}delete(){this._variables.box.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t},e){const r=this._getBox();r&&(r.extend=t,this._paramVerfiy(t,e,"box.set_extend",Object.values(Yr),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,ve(e,["bgcolor"]))}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t},e){const r=this._getBox();r&&(r.text_size=t,this._paramVerfiy(t,e,"box.set_text_size",Object.values(ir),"text_size"))}set_text_wrap({text_wrap:t},e){const r=this._getBox();r&&(r.text_wrap=t,this._paramVerfiy(t,e,"box.set_text_wrap",[jt.wrapAuto,jt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,ve(e,["text_color"]))}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t},e){const r=this._getBox();r&&(r.text_halign=t,this._paramVerfiy(t,e,"box.set_text_halign",[jt.alignLeft,jt.alignCenter,jt.alignRight],"text_halign"))}set_text_valign({text_valign:t},e){const r=this._getBox();r&&(r.text_valign=t,this._paramVerfiy(t,e,"box.set_text_valign",[jt.alignBottom,jt.alignCenter,jt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.top=n,e.left=e.xloc===be.bar_index?r:s}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,ve(e,["border_color"]))}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[Re.styleDashed,Re.styleDotted,Re.styleSolid],"style"))}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.bottom=n,e.right=e.xloc===be.bar_index?r:s}}set_text_font_family({text_font_family:t},e){const r=this._getBox();r&&(r.text_font_family=t,this._paramVerfiy(t,e,"box.set_text_font_family",Object.values(Jn),"text_font_family"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Rw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:vr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t}){return t}new(t,e){const{bar_index:r}=this._variables,n=`table_${e}_${r}`,{rows:s}=t;ve(t,["text_color","bgcolor","border_color"]);const a=Array.from(Array(s),()=>[]),u=e.split("_"),c=u.pop(),f=u.pop(),d={...this._defaultTable,...t,cell:a,id:n,bar_index:r,line:f,col:c},h=new Mh(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(vr),"position"),e.startsWith("export")||this._variables.table.add(n,d,h),h}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e},r){t==null||t.set_position(e,r)}}class Mh{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ti.black,text_halign:jt.alignCenter,text_valign:jt.alignCenter,text_size:ir.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return te.TABLE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.table.get(this._id)}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,s=this._variables.table.get(this._id);if(s){const a=s.cell||[],u=a[n]||[];u[r]=e,a[n]=u,s.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r,ve(n,["text_color"]))}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0}){const s=this._variables.table.get(this._id);if(s){const a=s.cell;if(a)for(let u=e;u<=n;u++)for(let c=t;c<=r;c++){const f=a[u];f&&(f[c]=void 0)}}}delete(){this._variables.table.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},s){if(t>r||e>n){this._errorListener.addError(ie.mergeCellErr,s,Rt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const u=a.merge_cells||[];u.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=u}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,ve(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,ve(e,["border_color"]))}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t},e){const r=this._variables.table.get(this._id);r&&(r.position=t,this._paramVerfiy(t,e,"table.set_position",Object.values(vr),"position"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class Pw{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){return this._verifyTradeNum(t)&&this._strategy.historyOrders[t].commission||0}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.historyOrders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_price}entry_time({trade_num:t}){if(!this._verifyTradeNum(t))return;const{in_time:e,entry_time:r}=this._strategy.historyOrders[t];return r||e}exit_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_index}exit_comment({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_comment:""}exit_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_id:""}exit_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_price}exit_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{out_qty:e=0,direction:r}=this._strategy.historyOrders[t];return r===fe.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class kw{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,original_qty:r=0,commission:n=0}=this._strategy.orders[t];return n*e/r}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.orders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_price}entry_time({trade_num:t}){if(!this._verifyTradeNum(t))return;const{in_time:e,entry_time:r}=this._strategy.orders[t];return r||e}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,direction:r}=this._strategy.orders[t];return r===fe.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class zw{constructor(t,e){$(this,"_strategy");$(this,"_errorListener");this._strategy=t,this._errorListener=e}allow_entry_in({value:t},e){this._paramVerfiy(t,e,"strategy.risk.allow_entry_in",Object.values(fe),"value"),this._strategy.updateRisk({allow_entry_in:t})}max_cons_loss_days({count:t}){this._strategy.updateRisk({max_cons_loss_days:t})}max_drawdown({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_drawdown",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_drawdown:t,max_drawdown_type:e})}max_intraday_filled_orders({count:t}){this._strategy.updateRisk({max_intraday_filled_orders:t})}max_intraday_loss({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_intraday_loss",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_intraday_loss:t,max_intraday_loss_type:e})}max_position_size({contracts:t}){this._strategy.updateRisk({max_position_size:t})}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}}var qw=20,Uw=1,ni=1e6,Fh=1e6,Ww=-7,jw=21,Yw=!1,us="[big.js] ",ii=us+"Invalid ",Do=ii+"decimal places",Vw=ii+"rounding mode",Nh=us+"Division by zero",le={},sn=void 0,Hw=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Sh(){function i(t){var e=this;if(!(e instanceof i))return t===sn?Sh():new i(t);if(t instanceof i)e.s=t.s,e.e=t.e,e.c=t.c.slice();else{if(typeof t!="string"){if(i.strict===!0&&typeof t!="bigint")throw TypeError(ii+"value");t=t===0&&1/t<0?"-0":String(t)}Zw(e,t)}e.constructor=i}return i.prototype=le,i.DP=qw,i.RM=Uw,i.NE=Ww,i.PE=jw,i.strict=Yw,i.roundDown=0,i.roundHalfUp=1,i.roundHalfEven=2,i.roundUp=3,i}function Zw(i,t){var e,r,n;if(!Hw.test(t))throw Error(ii+"number");for(i.s=t.charAt(0)=="-"?(t=t.slice(1),-1):1,(e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),n=t.length,r=0;r<n&&t.charAt(r)=="0";)++r;if(r==n)i.c=[i.e=0];else{for(;n>0&&t.charAt(--n)=="0";);for(i.e=e-r-1,i.c=[],e=0;r<=n;)i.c[e++]=+t.charAt(r++)}return i}function si(i,t,e,r){var n=i.c;if(e===sn&&(e=i.constructor.RM),e!==0&&e!==1&&e!==2&&e!==3)throw Error(Vw);if(t<1)r=e===3&&(r||!!n[0])||t===0&&(e===1&&n[0]>=5||e===2&&(n[0]>5||n[0]===5&&(r||n[1]!==sn))),n.length=1,r?(i.e=i.e-t+1,n[0]=1):n[0]=i.e=0;else if(t<n.length){if(r=e===1&&n[t]>=5||e===2&&(n[t]>5||n[t]===5&&(r||n[t+1]!==sn||n[t-1]&1))||e===3&&(r||!!n[0]),n.length=t,r){for(;++n[--t]>9;)if(n[t]=0,t===0){++i.e,n.unshift(1);break}}for(t=n.length;!n[--t];)n.pop()}return i}function oi(i,t,e){var r=i.e,n=i.c.join(""),s=n.length;if(t)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r<s&&(n=n.slice(0,r)+"."+n.slice(r));else s>1&&(n=n.charAt(0)+"."+n.slice(1));return i.s<0&&e?"-"+n:n}le.abs=function(){var i=new this.constructor(this);return i.s=1,i},le.cmp=function(i){var t,e=this,r=e.c,n=(i=new e.constructor(i)).c,s=e.s,a=i.s,u=e.e,c=i.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-a:0;if(s!=a)return s;if(t=s<0,u!=c)return u>c^t?1:-1;for(a=(u=r.length)<(c=n.length)?u:c,s=-1;++s<a;)if(r[s]!=n[s])return r[s]>n[s]^t?1:-1;return u==c?0:u>c^t?1:-1},le.div=function(i){var t=this,e=t.constructor,r=t.c,n=(i=new e(i)).c,s=t.s==i.s?1:-1,a=e.DP;if(a!==~~a||a<0||a>ni)throw Error(Do);if(!n[0])throw Error(Nh);if(!r[0])return i.s=s,i.c=[i.e=0],i;var u,c,f,d,h,_=n.slice(),g=u=n.length,y=r.length,p=r.slice(0,u),w=p.length,v=i,x=v.c=[],b=0,C=a+(v.e=t.e-i.e)+1;for(v.s=s,s=C<0?0:C,_.unshift(0);w++<u;)p.push(0);do{for(f=0;f<10;f++){if(u!=(w=p.length))d=u>w?1:-1;else for(h=-1,d=0;++h<u;)if(n[h]!=p[h]){d=n[h]>p[h]?1:-1;break}if(d<0){for(c=w==u?n:_;w;){if(p[--w]<c[w]){for(h=w;h&&!p[--h];)p[h]=9;--p[h],p[w]+=10}p[w]-=c[w]}for(;!p[0];)p.shift()}else break}x[b++]=d?f:++f,p[0]&&d?p[w]=r[g]||0:p=[r[g]]}while((g++<y||p[0]!==sn)&&s--);return!x[0]&&b!=1&&(x.shift(),v.e--,C--),b>C&&si(v,C,e.RM,p[0]!==sn),v},le.eq=function(i){return this.cmp(i)===0},le.gt=function(i){return this.cmp(i)>0},le.gte=function(i){return this.cmp(i)>-1},le.lt=function(i){return this.cmp(i)<0},le.lte=function(i){return this.cmp(i)<1},le.minus=le.sub=function(i){var t,e,r,n,s=this,a=s.constructor,u=s.s,c=(i=new a(i)).s;if(u!=c)return i.s=-c,s.plus(i);var f=s.c.slice(),d=s.e,h=i.c,_=i.e;if(!f[0]||!h[0])return h[0]?i.s=-c:f[0]?i=new a(s):i.s=1,i;if(u=d-_){for((n=u<0)?(u=-u,r=f):(_=d,r=h),r.reverse(),c=u;c--;)r.push(0);r.reverse()}else for(e=((n=f.length<h.length)?f:h).length,u=c=0;c<e;c++)if(f[c]!=h[c]){n=f[c]<h[c];break}if(n&&(r=f,f=h,h=r,i.s=-i.s),(c=(e=h.length)-(t=f.length))>0)for(;c--;)f[t++]=0;for(c=t;e>u;){if(f[--e]<h[e]){for(t=e;t&&!f[--t];)f[t]=9;--f[t],f[e]+=10}f[e]-=h[e]}for(;f[--c]===0;)f.pop();for(;f[0]===0;)f.shift(),--_;return f[0]||(i.s=1,f=[_=0]),i.c=f,i.e=_,i},le.mod=function(i){var t,e=this,r=e.constructor,n=e.s,s=(i=new r(i)).s;if(!i.c[0])throw Error(Nh);return e.s=i.s=1,t=i.cmp(e)==1,e.s=n,i.s=s,t?new r(e):(n=r.DP,s=r.RM,r.DP=r.RM=0,e=e.div(i),r.DP=n,r.RM=s,this.minus(e.times(i)))},le.neg=function(){var i=new this.constructor(this);return i.s=-i.s,i},le.plus=le.add=function(i){var t,e,r,n=this,s=n.constructor;if(i=new s(i),n.s!=i.s)return i.s=-i.s,n.minus(i);var a=n.e,u=n.c,c=i.e,f=i.c;if(!u[0]||!f[0])return f[0]||(u[0]?i=new s(n):i.s=n.s),i;if(u=u.slice(),t=a-c){for(t>0?(c=a,r=f):(t=-t,r=u),r.reverse();t--;)r.push(0);r.reverse()}for(u.length-f.length<0&&(r=f,f=u,u=r),t=f.length,e=0;t;u[t]%=10)e=(u[--t]=u[t]+f[t]+e)/10|0;for(e&&(u.unshift(e),++c),t=u.length;u[--t]===0;)u.pop();return i.c=u,i.e=c,i},le.pow=function(i){var t=this,e=new t.constructor("1"),r=e,n=i<0;if(i!==~~i||i<-Fh||i>Fh)throw Error(ii+"exponent");for(n&&(i=-i);i&1&&(r=r.times(t)),i>>=1,!!i;)t=t.times(t);return n?e.div(r):r},le.prec=function(i,t){if(i!==~~i||i<1||i>ni)throw Error(ii+"precision");return si(new this.constructor(this),i,t)},le.round=function(i,t){if(i===sn)i=0;else if(i!==~~i||i<-ni||i>ni)throw Error(Do);return si(new this.constructor(this),i+this.e+1,t)},le.sqrt=function(){var i,t,e,r=this,n=r.constructor,s=r.s,a=r.e,u=new n("0.5");if(!r.c[0])return new n(r);if(s<0)throw Error(us+"No square root");s=Math.sqrt(+oi(r,!0,!0)),s===0||s===1/0?(t=r.c.join(""),t.length+a&1||(t+="0"),s=Math.sqrt(t),a=((a+1)/2|0)-(a<0||a&1),i=new n((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+a)):i=new n(s+""),a=i.e+(n.DP+=4);do e=i,i=u.times(e.plus(r.div(e)));while(e.c.slice(0,a).join("")!==i.c.slice(0,a).join(""));return si(i,(n.DP-=4)+i.e+1,n.RM)},le.times=le.mul=function(i){var t,e=this,r=e.constructor,n=e.c,s=(i=new r(i)).c,a=n.length,u=s.length,c=e.e,f=i.e;if(i.s=e.s==i.s?1:-1,!n[0]||!s[0])return i.c=[i.e=0],i;for(i.e=c+f,a<u&&(t=n,n=s,s=t,f=a,a=u,u=f),t=new Array(f=a+u);f--;)t[f]=0;for(c=u;c--;){for(u=0,f=a+c;f>c;)u=t[f]+s[c]*n[f-c-1]+u,t[f--]=u%10,u=u/10|0;t[f]=u}for(u?++i.e:t.shift(),c=t.length;!t[--c];)t.pop();return i.c=t,i},le.toExponential=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ni)throw Error(Do);for(e=si(new e.constructor(e),++i,t);e.c.length<i;)e.c.push(0)}return oi(e,!0,!!r)},le.toFixed=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ni)throw Error(Do);for(e=si(new e.constructor(e),i+e.e+1,t),i=i+e.e+1;e.c.length<i;)e.c.push(0)}return oi(e,!1,!!r)},le[Symbol.for("nodejs.util.inspect.custom")]=le.toJSON=le.toString=function(){var i=this,t=i.constructor;return oi(i,i.e<=t.NE||i.e>=t.PE,!!i.c[0])},le.toNumber=function(){var i=+oi(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(i.toString()))throw Error(us+"Imprecise conversion");return i},le.toPrecision=function(i,t){var e=this,r=e.constructor,n=e.c[0];if(i!==sn){if(i!==~~i||i<1||i>ni)throw Error(ii+"precision");for(e=si(new r(e),i,t);e.c.length<i;)e.c.push(0)}return oi(e,i<=e.e||e.e<=r.NE||e.e>=r.PE,!!n)},le.valueOf=function(){var i=this,t=i.constructor;if(t.strict===!0)throw Error(us+"valueOf disallowed");return oi(i,i.e<=t.NE||i.e>=t.PE,!0)};var iu=Sh();function Oh(i,t){return iu(i).plus(t).toNumber()}function bo(i,t){return iu(i).minus(t).toNumber()}function Ii(i,t){return iu(i).mul(t).toNumber()}let Kw=class{constructor(t,e,r,n,s){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_exitOrders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");$(this,"_maxDrawdownVerifyIndex",0);$(this,"calcOnOrderFillsData",{index:-1});this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Gt.inherit,pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Pe.fixed,default_qty_value:1,initial_capital:1e6,currency:xh.NONE,slippage:0,commission_type:je.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=e,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._exitOrders=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new kw(this),this._closedtrades=new Pw(this),this._riskNamespace=new zw(this,n),this._id=`strategy_${s}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;return this._orders.reduce((e,r)=>e+t*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}get isCalcOnEveryTick(){return this._options.calc_on_every_tick}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._ordersHandle(),this._pendingOrderHandle(),this._exitOrdersHandle(),this._maxIntradayFilledOrdersVerify(),this._maxDrawdownVerify();const{open:t,high:e,low:r}=this.calcOnOrderFillsData.data||this._variables;let n=this._variables.close;this.calcOnOrderFillsData.tradeData&&(n=this.calcOnOrderFillsData.tradeData.open),this._variables.strategy.update({open:t,close:n,high:e,low:r}),!this._options.process_orders_on_close&&this._calcLiquidate(),this._calcProfitAndLoss()}calcCurrentOrder(){this._ordersHandle(),this._pendingOrderHandle(),this._calcProfitAndLoss()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:t,max_intraday_loss_type:e,isDisabledOpen:r}=this._risk;if(t===void 0||!e||r)return;const{time_tradingday:n,time:s,strategy:{netprofit:a,initial_capital:u}}=this._variables,{high:c,low:f}=this.calcOnOrderFillsData.data||this._variables;let{preNetprofit:d=0}=this._risk;s===n&&(d=a,this._risk.preNetprofit=a,this._risk.isTemporaryBan=!1);let h=d-a;h+=this._orders.reduce((y,p)=>{const{in_price:w,direction:v,qty:x=0,commission:b=0,original_qty:C=0}=p,E=v===fe.long?1:-1,A=(c-w)*x,N=(f-w)*x,S=E===1?N:-A;return y+S+x/C*b},0);let _=!1;switch(e){case Pe.cash:_=t<h;break;case Pe.percentOfEquity:const y=h/(u+a)*100;_=t<y;break}if(_){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===fe.long?f:c,"Close Position (Max intraday Loss)",void 0,"close"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:t,intradayOrders:e=0,isDisabledOpen:r}=this._risk;if(t===void 0||r)return;const{time:n,time_tradingday:s}=this._variables,{open:a}=this.calcOnOrderFillsData.data||this._variables;n===s&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),t<=e&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)",void 0,"close"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:t,lossDays:e=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(t===void 0||r)return;const{time:s,time_tradingday:a,strategy:u}=this._variables,{open:c}=this.calcOnOrderFillsData.data||this._variables;let f=e;if(s===a){const d=u.netprofit+u.openprofit;d<n?f=0:f++,Object.assign(this._risk,{lossDays:f,totalProfit:d})}t<=f&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(r)return;const{bar_index:n}=this._variables,{open:s}=this.calcOnOrderFillsData.data||this._variables;if(t!==void 0&&e&&this._maxDrawdownVerifyIndex===n){const{initial_capital:a}=this._options,c=this._orders.reduce((d,h)=>{const{in_price:_,commission:g=0,qty:y=0,original_qty:p=0,direction:w}=h,v=w===fe.long?1:-1,x=(s-_)*v*y;return d+x+g*y/p},0)+this._totalChangeCapital;let f=!1;switch(e){case Pe.percentOfEquity:f=c/a*100<=-t;break;case Pe.cash:f=c<=-t;break}f&&this._riskTouchOff(s,"Close Position (Max Drawdown)")}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._orders.length&&this._closeOrders(this._orders,t,e,"close"),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Gt.inherit,Gt.price,Gt.percent,Gt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Pe),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(je),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={...this._updateOptions};if(r)for(const s of Object.keys({...r,...t}))t[s]!==r[s]&&delete n[s];self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,userSetStrategyConfig:n,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(fn),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(fn),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.filter(r=>!this._options.process_orders_on_close||r.in_index!==this._variables.bar_index).length)return;const{immediately:e}=t;if(e||this._options.process_orders_on_close){const r=this._pendingCloseOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingCloseOrders.push({...t,place_order_type:"close"})}else{const r=this._pendingOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingOrders.push({...t,place_order_type:"close"})}}close_all(t){if(typeof t=="string"&&(t={}),!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close_all"}):this._pendingOrders.push({...t,place_order_type:"close_all"})}cancel({id:t}){this._pendingOrders=this._pendingOrders.filter(e=>!(e.id===t&&e.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(t=>t.place_order_type==="close_all")}exit(t,e){this._exit(t,e)}convert_to_account({value:t}){return t}convert_to_symbol({value:t}){return t}default_entry_qty({fill_price:t}){return t?this._calcDefaultQty(t):0}_calcDefaultQty(t){const{default_qty_type:e=Pe.fixed,default_qty_value:r=1,initial_capital:n,commission_value:s}=this._options;let a=r;switch(e){case Pe.cash:a=r/t;break;case Pe.percentOfEquity:const u=this._getOrderProfit(t),c=n+u+this._totalChangeCapital;s?a=this._getCommQty(c,t):a=c*r/100/t;break}return Ql(a,this._getLen(t))}_getCommQty(t,e){const{commission_type:r,commission_value:n=0,default_qty_value:s=0}=this._options;let a=0;switch(r){case je.percent:a=t*s/(100*e+n*e);break;case je.cashPerContract:a=t*s/(100*e+n);break;case je.cashPerOrder:a=(t-n)*s/100/e}return a}_getLen(t){const e=String(Math.floor(t)).length-3;return e<0?0:e}_getCapital(t,e){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&t===1?e=e*100/r:n<=100&&n>0&&t===-1&&(e=e*100/n),e}_calcProfitAndLoss(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:s}=e,a=s===fe.long?1:-1,u=(t-r)*a*n,[c,f]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,u,c,f)}}_calcProfitAndLossHandle(t,e,r,n){const{high:s,low:a}=this.calcOnOrderFillsData.data||this._variables,u=((n||s)-t)*e,c=((n||a)-t)*e;let f=r===1?u:-c,d=r===1?c:-u;return[f,d]}_calcOrderPercent(t,e,r,n){const{commission_value:s}=this._options,{close:a}=this.calcOnOrderFillsData.data||this._variables,{original_qty:u=0,qty:c=0,in_price:f,max_profit:d=0,trading_loss:h=0}=t;let{commission:_=0}=t,g=f*c;if(s){const y=this._getCommission(a,c);_=_*c/u,r-=_,n-=_,g+=_,e=e-y-_}r=Math.max(r,d,0),n=Math.min(n,h,0),Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/(this._options.initial_capital+this._totalChangeCapital)*100,max_profit:r,trading_loss:n,profit_percent:e/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{time:t}=this._variables,{high:e,low:r}=this.calcOnOrderFillsData.data||this._variables,{initial_capital:n,margin_long:s=0,margin_short:a=0}=this._options,u=this._orders[0].direction===fe.long?1:-1;let c=u===1?r:e;if(u===1&&s===100)return;const f=(u===1?s:a)/100;if(f<=0)return;let d=!1;const[h,_]=this._orders.reduce((w,v)=>{let[x,b]=w;const{in_price:C,qty:E=0,in_time:A}=v;A===t&&(d=!0);const N=C*E,S=c*E;return x+=N,b+=S,[x,b]},[0,0]);let g=0,y=0;const p=n+this._totalChangeCapital;if(d&&(g=p-h*f,g<0&&(c=this._orders[0].in_price,y=Math.abs(Math.trunc(g/f/c)*4),y=Math.max(y,1))),g>=0){const w=u*(_-h);if(g=p+w-_*f,g>=0)return;y=Math.abs(Math.trunc(g/f/c)*4)}y<=0||this._marginCallOrders(c,y,"Margin Call")}_marginCallOrders(t,e,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,t,e*this._orders.length,r,r,!0);return}for(const s of this.orders)s.position_close_type=s.place_order_type,s.isTiggerClose=!0,this._processOrder(s,t,e,r,r,!0);this._orders=this._orders.filter(s=>!s.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:s,quantities:a,close:u,price:c,activePrice:f,isTouch:d}=this._orderArgsParse(t),h=t.direction===fe.long?1:-1;if(a<=0)return;let _=a;if((s||d)&&e){const y=d?c:u;if(n.length){const E=this._processOrders(n,y,_,t.id,t.comment,!1,"order");if(E<=0)return;_=E}const p=y-h*r*this._mintick;if(!this._judgeCapitalEnough(_,p,h))return;this._ocaGroupVerify(_,t.oca_name,t.oca_type);const{bar_index:v,time:x}=this._variables,{high:b,low:C}=this.calcOnOrderFillsData.data||this._variables;this._calcCurrentOrder({...t,in_price:p,in_high:b,in_low:C,in_index:v,in_time:x,qty:_,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,h)&&this._addPendingOrders(t,c,_,s,f)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(d=>(d.direction===fe.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:s=0,margin_short:a=0}=this._options;if(s===0&&r===1||a===0&&r===-1)return!0;const u=this._getOrderProfit(e),f=this._getCapital(r,this._options.initial_capital+u+this._totalChangeCapital)-n;return t*e<=f}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:s=0,direction:a}=r,u=a===fe.long?1:-1;return e+(t-n)*s*u},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===fn.none)return!1;let n=!1;switch(r){case fn.cancel:this._pendingOrders=this._pendingOrders.filter(s=>{if(s.oca_name===e)s.isCancel=!0,n=!0;else return!0});break;case fn.reduce:this._pendingOrders=this._pendingOrders.filter(s=>{const{qty:a=0,oca_name:u}=s;if(e===u){const c=a-t;return n=!0,c<=0?(s.isCancel=!0,!1):(s.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,s,a=!1,u,c){let f=r;for(const d of t)if(d.position_close_type=u||d.place_order_type,d.immediately=c,d.isTiggerClose=a||d.position_close_type==="close",f=this._processOrder(d,e,f,n,s,a),f<=0)break;return this._orders=this._orders.filter(d=>!d.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),f}_addPendingOrders(t,e,r,n,s){const a=this._pendingOrders.find(u=>u.id===t.id&&!u.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else{const u={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,entry_time:this._variables.time,place_order_type:"order"};this._pendingOrders.push(u)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let s=t.limit||0;const{close:a}=this.calcOnOrderFillsData.data||this._variables;let u=a,c=!1,f;const d=e===fe.long?1:-1,h=n&&(n-a)*d>=0,{backtest_fill_limits_assumption:_=0}=this._options;_>0&&s&&(s-=_*this._mintick*d);const g=s&&(s-a)*d<=0;let y=!1;h&&g?(n!==a&&(f=n),u=s):h?(u=n,y=n===a):g?(u=s,y=s===a):c=!0;const p=r!==void 0?Ql(r,this._getLen(u)):this._calcDefaultQty(u);return{orders:this._orders.filter(v=>v.direction!==e),isMarketPrice:c,activePrice:f,quantities:p,close:a,price:u,isTouch:y}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:s,close:a,price:u,activePrice:c,isTouch:f}=this._orderArgsParse(t);if(s<=0)return;if((n||f)&&e){this._entryOrder(r,f?u:a,s,t);return}this._judgeCapitalEnough(s,a,t.direction===fe.long?1:-1)&&this._addPendingEntry(t,u,s,n,c)}_entryOrder(t,e,r,n){const{time:s,bar_index:a}=this._variables,{high:u,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:f=0}=this._options,{oca_name:d,oca_type:h,direction:_,comment:g,id:y}=n,p=_===fe.long?1:-1;if(r=this._getAvailablePositionSize(r,_),r<=0)return;const w=e;if(e=e+f*this._mintick*p,!this._judgeCapitalEnough(r,e,p))return;this._closeOrders(t,w,y,g,"entry",void 0,!0);const x={...n,in_price:e,qty:r,in_index:a,in_high:u,in_low:c,in_time:s,place_order_type:"entry"},{orders:b}=this._getEntryOrders(_),C=b.length;C&&C>=(this._options.pyramiding||1)||(this._ocaGroupVerify(r,d,h),this._calcCurrentOrder(x))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==fe.all&&n!==e)return 0;if(r===void 0)return t;const s=this._orders.reduce((a,u)=>a+(u.qty||0),0);return s?s+t>r?0:t:t>r?t-r:0}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===t),r=this._orders.filter(n=>n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,s){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:u}=this._getEntryOrders(t.direction),c=a.find(f=>f.id===t.id&&f.place_order_type==="entry");if(c)Object.assign(c,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else{const f={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,entry_time:this._variables.time,place_order_type:"entry"};this._pendingOrders.push(f)}}_closeAllOrders(t,e){const{comment:r,immediately:n}=t,{bar_index:s}=this._variables,a=this._orders.filter(u=>u.in_index!==s);a.length&&(this._closeOrders(a,e,"Close position order",r,"close",n),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n,s,a,u){for(const c of t)c.position_close_type=s,c.immediately=a,c.isTiggerClose=!0,this._closeOrder(c,e,r,n,u);this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n,s){const{time:a,bar_index:u}=this._variables,{high:c,low:f}=this.calcOnOrderFillsData.data||this._variables,{slippage:d=0}=this._options,{in_price:h,qty:_=0,direction:g}=t,y=g===fe.long?1:-1;e=e-y*d*this._mintick,t.isDeal=!0;const p=(e-h)*y*_,w={...t,out_price:e,out_id:r,out_index:u,out_high:c,out_low:f,out_time:a,out_comment:n,out_qty:_,profit:p};this._calcPercent(w,s)}_exitOrdersHandle(){if(!this._exitOrders.length)return;let{open:t,low:e,high:r,close:n}=this.calcOnOrderFillsData.data||this._variables;const s=[],a=Math.abs(r-t),u=Math.abs(e-t),c=[],f=this._variables.precision;t=Number(t.toFixed(f)),e=Number(e.toFixed(f)),r=Number(r.toFixed(f)),n=Number(n.toFixed(f));for(const d of this._exitOrders){const{directionNum:h,id:_,comment:g,qty:y,comment_loss:p,comment_profit:w,comment_trailing:v,order:x}=d;if(x.isTiggerClose)continue;let b=a<u||a===u&&h===1;const C=[],[E,A]=this._getLimitPrice(d,t,e,r,b);E&&C.push({order:x,price:E,index:A,isHighFront:b,exitInfo:{id:_,comment:w||g,qty:y}});const[N,S]=this._getStopPrice(d,t,e,r,b);N&&C.push({order:x,price:N,index:S,isHighFront:b,exitInfo:{id:_,comment:p||g,qty:y}});const[I,F]=this._getTrailStopPrice(d,t,e,r,n,b);if(I&&C.push({order:x,price:I,index:F,isHighFront:b,exitInfo:{id:_,comment:v||g,qty:y}}),C.length){this._executesSort(C),s.push(C[0]);continue}c.push(d)}this._exitOrders=c,this._executesSort(s);for(const d of s){const{order:h,price:_,exitInfo:g,isHighFront:y,index:p}=d;y?(r=p===1?_:r,e=p===1?t:_):(r=p===1?t:_,e=p===1?_:e),this._variables.strategy.update({open:_,high:r,low:e,close:n}),this._processExitOnClose(h,_,g)}}_executesSort(t){return t.sort(({price:e,index:r,isHighFront:n},{price:s,index:a})=>r!==a?r-a:n?r===1?e-s:s-e:r===1?s-e:e-s),t}_getLimitPrice(t,e,r,n,s){const{limit:a,directionNum:u}=t;let c,f=1;return a&&((e-a)*u>=0?(c=e,f=1):r<=a&&n>=a&&(c=a,s&&a>e||!s&&a<e?f=1:f=2)),[c,f]}_getStopPrice(t,e,r,n,s){const{stop:a,directionNum:u}=t;let c,f=1;return a&&((e-a)*u<=0?(c=e,f=1):r<=a&&n>=a&&(c=a,s&&a>e||!s&&a<e?f=1:f=2)),[c,f]}_getTrailStopPrice(t,e,r,n,s,a){const{trail_stop_price:u,directionNum:c,active_price:f,trail_offset:d=0}=t;let h=u,_,g=1;if(h)if((h-e)*c>=0)_=e,g=1;else{const[y,p,w]=this._calcTrailStopPrice(h,n,r,s,d,c,a);_=p,g=w||1,t.trail_stop_price=y}if(f&&!_&&f<=n&&f>=r)if(d===0)_=f,a&&f>e||!a&&f<e?g=1:g=2;else{h=bo(f,Ii(d*c,this._mintick));let y=n,p=r;a?f>=e&&f<=n?(y=n,g=1):(a=!1,y=s,g=2):f<e&&f>=r?(p=r,g=1):(a=!0,p=s,g=2);const[w,v,x=1]=this._calcTrailStopPrice(h,y,p,s,d,c,a);delete t.active_price,g<x&&(g=x),t.trail_stop_price=w,_=v}return[_,g]}_ordersHandle(t){const e=this._orders.filter(a=>a.isMarketPriceLimit||a.isMarketPriceStop);if(!e.length)return;const{open:r,close:n}=this.calcOnOrderFillsData.data||this._variables,s=t?n:r;for(const a of e){const{out_comment:u,out_qty:c,out_id:f}=a;this._processExitOnClose(a,s,{id:f,comment:u,qty:c})}}_calcTrailStopPrice(t,e,r,n,s,a,u){let c=t,f;const d=bo(a===1?e:r,Ii(s*a,this._mintick));let h=1;return a===1?u?(c<d&&(c=d),c>=r&&(h=2,f=c)):c>=r?(h=1,f=c):d>c&&(c=d,d>=n&&(h=3,f=d)):u?c<=e?(h=1,f=c):d<c&&(c=d,d<=n&&(h=3,f=d)):(d<c&&(c=d),c<=e&&(h=2,f=c)),[c,f,h]}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(r=>r.place_order_type==="exit");for(const r of this._pendingOrders){const{isCancel:n,place_order_type:s}=r;if(n)continue;let a;switch(s){case"entry":a=this._entryOrderHandle(r);break;case"order":a=this._orderOrderHandle(r);break;case"close":a=this._closeOrderHandle(r);break;case"close_all":const{open:u}=this.calcOnOrderFillsData.data||this._variables;this._closeAllOrders(r,u);break}a&&t.push(a)}for(const r of e){const n=this._exitOrderHandle(r);n&&t.push(n)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(r=>["close","close_all"].includes(r.place_order_type||"")),{close:e}=this.calcOnOrderFillsData.data||this._variables;this._pendingCloseOrders=[];for(const r of t)switch(r.place_order_type){case"close":const n=this._closeOrderHandle(r,!0);n&&this._pendingCloseOrders.push(n);break;case"close_all":this._closeAllOrders(r,e);break}this._ordersHandle(!0)}_entryOrderHandle(t){const{open:e,low:r,high:n}=this.calcOnOrderFillsData.data||this._variables,{isMarketPrice:s,qty:a=0,in_price:u,direction:c,active_price:f}=t;if(f&&n>=f&&r<=f)return delete t.active_price,t;let d=u;if(s&&(d=e),d<=n&&d>=r){const h=this._orders.filter(_=>_.direction!==c);this._entryOrder(h,d,a,t)}else return t}_orderOrderHandle(t){const{time:e,bar_index:r}=this._variables,{open:n,low:s,high:a}=this.calcOnOrderFillsData.data||this._variables,{slippage:u=0}=this._options,{isMarketPrice:c,qty:f=0,in_price:d,direction:h,comment:_,oca_name:g,oca_type:y,active_price:p,id:w}=t;if(p&&a>=p&&s<=p)return delete t.active_price,t;let v=d,x=f;if(c&&(v=n),v<=a&&v>=s){const b=this._orders.filter(E=>E.direction!==h);if(b.length&&(x=this._processOrders(b,v,f,w,_,!1,"order"),x<=0))return;const C=h===fe.long?1:-1;this._ocaGroupVerify(x,g,y),this._calcCurrentOrder({...t,in_price:v-C*u*this._mintick,in_index:r,in_time:e,in_high:a,in_low:s,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:s=100,comment:a,immediately:u}=t,{close_entries_rule:c="FIFO"}=this._options;let f=[];if(c==="FIFO"?f=this._orders.filter(g=>g.id===r):f=this._orders.filter(g=>g.id===r&&!g.close_qty),!f.length)return;let d=0;if(n?d=n:(d=f.reduce((g,y)=>g+(y.qty||0),d),d=s/100*d),d<=0)return;const{open:h,close:_}=this.calcOnOrderFillsData.data||this._variables;if(c==="FIFO")this._processOrders(f,e?_:h,d,`Close entry(s) order ${r}`,a,!1,"close",u);else if(this._processCloseOrders(f,e?_:h,d,`Close entry(s) order ${r}`,a,u))return t}_processCloseOrders(t,e,r,n,s,a){let u=!1;for(const c of t)c.close_qty=r,(c.qty||0)>r&&(u=!0),c.immediately=a,c.position_close_type="close",c.isTiggerClose=!0,this._processOrder(c,e,r,n,s);return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),u}_exitOrderHandle(t){const{from_entry:e}=t,r=this._orders.filter(n=>(!e||e===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,t,!0)))return t}_exit(t,e){if(!t.hasOwnProperty("profit")&&!t.hasOwnProperty("loss")&&!t.hasOwnProperty("stop")&&!t.hasOwnProperty("limit")&&(!t.hasOwnProperty("trail_offset")||!t.hasOwnProperty("trail_price")&&!t.hasOwnProperty("trail_points"))){this._errorListener.addError(ie.strategyExitErr,e,Rt.Error);return}const{profit:r,loss:n,stop:s,limit:a,trail_offset:u,trail_price:c,trail_points:f,from_entry:d="",id:h}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(s)&&this._isNaN(a)&&(this._isNaN(u)||this._isNaN(f)&&this._isNaN(c)))return;const _={...t,place_order_type:"exit"},g=this._orders.filter(v=>(!d||d===v.id)&&!v.hasExit),y=this._updateExitOrders(_),p=this._pendingOrders.filter(v=>(!d||d===v.id)&&["order","entry"].includes(v.place_order_type||""));if(g.length){if(!this._ordersToExit(g,_,!1))return}else if(!p.length||y)return;const w=this._pendingOrders.find(v=>v.id===h&&v.place_order_type==="exit");w?Object.assign(w,{...t}):this._pendingOrders.push(_)}_updateExitOrders(t){let e=!1;const r=this._exitOrders.filter(n=>n.id===t.id&&(n.from_entry===t.from_entry||!t.from_entry));for(const n of r){const{directionNum:s,order:a}=n;if(a.isTiggerClose){n.isClose=!0;continue}e=!0;const u={...t};if(this._stopProfit(a,s,u)){n.isClose=!0;continue}if(this._stopLoss(a,s,u)){n.isClose=!0;continue}if(this._trailStopLoss(a,s,u)){n.isClose=!0;continue}Object.assign(n,u)}return this._exitOrders=this._exitOrders.filter(n=>!n.isClose),e}_ordersToExit(t,e,r){const{qty:n,qty_percent:s=100,id:a,comment:u}=e;let c=n,f=!1;e.comment=u||a;const d=t[0],h={...e},{qty:_=0}=d,g=d.direction===fe.long?1:-1;return c=n?n>=_?_:n:s/100*_,h.qty=c,c<_&&(f=!0),this._stopProfit(d,g,h,r)||this._stopLoss(d,g,h,r)||this._trailStopLoss(d,g,h,r)||(this._exitOrders.push({...h,directionNum:g,order:d}),d.hasExit=!0),f}_addExitPendingCloseOrders(t){const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r,n){const{limit:s,profit:a,comment_profit:u,comment:c,id:f,qty:d}=r;let h=s;const{close:_}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:y}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(h=Oh(g,Ii(a*e,this._mintick))),r.limit=e===1?ec(h,this._variables.precision):rc(h,this._variables.precision),!n&&h!==void 0&&(h-_)*e<=0)return t.isMarketPriceLimit=!0,r.comment=u||c,Object.assign(t,{out_comment:r.comment,out_id:f,out_qty:d}),y&&this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r,n){const{stop:s,loss:a,comment_loss:u,comment:c,id:f,qty:d}=r;let h=s;const{close:_}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:y}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(h=bo(g,Ii(a*e,this._mintick))),r.stop=e===1?rc(h,this._variables.precision):ec(h,this._variables.precision),!n&&h!==void 0&&(h-_)*e>=0)return t.isMarketPriceStop=!0,r.comment=u||c,Object.assign(t,{out_comment:r.comment,out_id:f,out_qty:d}),y&&this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r,n){const{trail_offset:s,trail_price:a,trail_points:u,comment_trailing:c,comment:f,id:d,qty:h}=r;if(!this._isNaN(s)){const{close:_}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:y}=this._options;let p;if(this._isNaN(a)?this._isNaN(u)||(p=Oh(g,Ii(u*e,this._mintick))):p=a,r.active_price=p,n)return;if(p!==void 0&&(p-_)*e<=0){const w=bo(_,Ii(s*e,this._mintick));if((w-_)*e>=0)return t.isMarketPriceStop=!0,r.comment=c||f,Object.assign(t,{out_comment:r.comment,out_id:d,out_qty:h}),y&&this._addExitPendingCloseOrders(r),!0;r.trail_stop_price=w}}}_processExitOnClose(t,e,r){const{qty:n=0,comment:s,id:a}=r,{close_entries_rule:u="FIFO"}=this._options;if(n)if(t.isTiggerClose=!0,u==="FIFO")this._processExitOrders(this._orders,e,n,a,s);else{if(t.isDeal)return;this._processOrders([t],e,n,a,s,!1,"exit")}}_processExitOrders(t,e,r,n,s){let a=r,u;for(const c of t)if(u=c,c.position_close_type="exit",a=this._processOrder(c,e,a,n,s),a<=0)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),u}_processOrder(t,e,r,n,s,a=!1){const{time:u,bar_index:c}=this._variables,{low:f,high:d}=this.calcOnOrderFillsData.data||this._variables,{slippage:h=0}=this._options,{in_price:_,qty:g=0,max_profit:y,trading_loss:p,direction:w,commission:v=0,original_qty:x=0}=t,b=w===fe.long?1:-1;if(e=e-b*h*this._mintick,r<g){const C=g-r,E=(e-_)*b*r,A=y!==void 0?y/g*r:void 0,N=p!==void 0?p/g*r:void 0,S=v*C/x;this._calcPercent({...t,out_price:e,last_commission:S,out_id:n,out_index:c,out_high:d,out_low:f,out_time:u,out_comment:s,profit:E,out_qty:r,max_profit:A,trading_loss:N});const I=(e-_)*b*C-S;Object.assign(t,{qty:C,profit:I,max_profit:y!==void 0?y-(A||0):void 0,trading_loss:p!==void 0?p-(N||0):void 0,total_profit:this._totalChangeCapital+I}),r=0}else{t.isDeal=!0;const C=(e-_)*b*g;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_high:d,out_low:f,out_time:u,out_comment:s,out_qty:g,profit:C}),r-=g}return a&&(b===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t,e){const{commission_value:r,process_orders_on_close:n}=this._options,{in_price:s,out_qty:a=0,out_price:u=0,original_qty:c=0,direction:f,last_commission:d=0,immediately:h}=t;let{profit:_=0,max_profit:g,trading_loss:y,commission:p=0}=t,w=s*a,v=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=_,r){const E=this._getCommission(u,a);this._totalChangeCapital-=E;let A=p*a/c;w+=A,A+=E,_=_-A,Object.assign(t,{commission:A});const N=this._orders.reduce((S,I)=>{const{qty:F=0,original_qty:O=0,commission:L=0}=I;return S+L*F/O},0);v+=N-d}const x=f===fe.long?1:-1;let[b,C]=this._calcProfitAndLossHandle(s,a,x,u);if(r){const E=p*a/c;b-=E,C-=E}g=Math.max(b,g||0),y=Math.min(C,y||0),_=parseFloat(String(_)),Object.assign(t,{max_profit:g,profit:_,trading_loss:y,total_profit:this._totalChangeCapital,total_profit_percent:_/v*100,profit_percent:_/w*100,max_profit_percent:g/w*100,trading_loss_percent:y/w*100}),this._maxDrawdownVerifyIndex=this._variables.bar_index+(n?1:0),this._risk.intradayOrders+=1,this._historyOrder.push(t),!e&&this._calcOrderFillsHandle(u,f,h)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:s=0,trading_loss:a=0,direction:u,immediately:c}=t;let{profit:f=0}=t,d=r*n;const h=this._totalChangeCapital+this._options.initial_capital;if(e){const _=this._getCommission(r,n);this._totalChangeCapital-=_,f=f-_,d+=_,Object.assign(t,{commission:_,total_profit:this._totalChangeCapital})}f=parseFloat(String(f)),Object.assign(t,{original_qty:n,profit:f,total_profit_percent:f/h*100,profit_percent:f/d*100,max_profit_percent:s/d*100,trading_loss_percent:a/d*100,stop:void 0,limit:void 0}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder),this._calcOrderFillsHandle(r,u,c)}_calcOrderFillsHandle(t,e,r=!1){const{calc_on_order_fills:n,process_orders_on_close:s,slippage:a=0}=this._options;if(n){const{open:u,high:c,low:f,close:d}=this._variables,h=e===fe.long?1:-1,_=d-h*a*this._mintick;if((r||s)&&t===_)return;const g=u-h*a*this._mintick;let y={open:u,high:c,low:f,close:d},p=this.calcOnOrderFillsData.index;const w=Math.abs(c-u)<=Math.abs(f-u);switch(p){case-1:t===g?p=0:t>g?w?(p=1,y={open:c,high:c,low:f,close:d}):(p=2,y={open:c,high:c,low:d,close:d}):w?(p=2,y={open:f,high:d,low:f,close:d}):(p=1,y={open:f,high:c,low:f,close:d});break;case 0:t===g?(p=1,w?y={open:c,high:c,low:f,close:d}:y={open:f,high:c,low:f,close:d}):t>g?w?(p=1,y={open:c,high:c,low:f,close:d}):(p=2,y={open:c,high:c,low:d,close:d}):w?(p=2,y={open:f,high:d,low:f,close:d}):(p=1,y={open:f,high:c,low:f,close:d});break;case 1:p=2,w?y={open:f,high:d,low:f,close:d}:y={open:c,high:c,low:d,close:d};break;case 2:p=-1,y=void 0;break}this.calcOnOrderFillsData={tradeData:y,index:p}}}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}};var Bh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){return function(e,r,n){r.prototype.isBetween=function(s,a,u,c){var f=n(s),d=n(a),h=(c=c||"()")[0]==="(",_=c[1]===")";return(h?this.isAfter(f,u):!this.isBefore(f,u))&&(_?this.isBefore(d,u):!this.isAfter(d,u))||(h?this.isBefore(f,u):!this.isAfter(f,u))&&(_?this.isAfter(d,u):!this.isBefore(d,u))}}})})(Bh);var Gw=Bh.exports,Jw=Kt(Gw),Th={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){return function(e,r,n){var s=r.prototype,a=function(_){var g,y=_.date,p=_.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||s.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=p?n.utc():n();Object.keys(y).forEach(function(I){var F,O;w[F=I,O=s.$utils().p(F),O==="date"?"day":O]=y[I]});var x=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),C=w.month>=0?w.month:w.year||w.day?0:v.month(),E=w.hour||0,A=w.minute||0,N=w.second||0,S=w.millisecond||0;return p?new Date(Date.UTC(b,C,x,E,A,N,S)):new Date(b,C,x,E,A,N,S)}return y},u=s.parse;s.parse=function(_){_.date=a.bind(this)(_),u.bind(this)(_)};var c=s.set,f=s.add,d=s.subtract,h=function(_,g,y,p){p===void 0&&(p=1);var w=Object.keys(g),v=this;return w.forEach(function(x){v=_.bind(v)(g[x]*p,x)}),v};s.set=function(_,g){return g=g===void 0?_:g,_.constructor.name==="Object"?h.bind(this)(function(y,p){return c.bind(this)(p,y)},g,_):c.bind(this)(_,g)},s.add=function(_,g){return _.constructor.name==="Object"?h.bind(this)(f,_,g):f.bind(this)(_,g)},s.subtract=function(_,g){return _.constructor.name==="Object"?h.bind(this)(f,_,g,-1):d.bind(this)(_,g)}}})})(Th);var Xw=Th.exports,Qw=Kt(Xw),Ih={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e,r,n=1e3,s=6e4,a=36e5,u=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=31536e6,d=2628e6,h=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,_={years:f,months:d,days:u,hours:a,minutes:s,seconds:n,milliseconds:1,weeks:6048e5},g=function(A){return A instanceof C},y=function(A,N,S){return new C(A,S,N.$l)},p=function(A){return r.p(A)+"s"},w=function(A){return A<0},v=function(A){return w(A)?Math.ceil(A):Math.floor(A)},x=function(A){return Math.abs(A)},b=function(A,N){return A?w(A)?{negative:!0,format:""+x(A)+N}:{negative:!1,format:""+A+N}:{negative:!1,format:""}},C=function(){function A(S,I,F){var O=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),I)return y(S*_[p(I)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(q){O.$d[p(q)]=S[q]}),this.calMilliseconds(),this;if(typeof S=="string"){var L=S.match(h);if(L){var z=L.slice(2).map(function(q){return q!=null?Number(q):0});return this.$d.years=z[0],this.$d.months=z[1],this.$d.weeks=z[2],this.$d.days=z[3],this.$d.hours=z[4],this.$d.minutes=z[5],this.$d.seconds=z[6],this.calMilliseconds(),this}}return this}var N=A.prototype;return N.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(I,F){return I+(S.$d[F]||0)*_[F]},0)},N.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/f),S%=f,this.$d.months=v(S/d),S%=d,this.$d.days=v(S/u),S%=u,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/s),S%=s,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},N.toISOString=function(){var S=b(this.$d.years,"Y"),I=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var O=b(F,"D"),L=b(this.$d.hours,"H"),z=b(this.$d.minutes,"M"),q=this.$d.seconds||0;this.$d.milliseconds&&(q+=this.$d.milliseconds/1e3,q=Math.round(1e3*q)/1e3);var W=b(q,"S"),P=S.negative||I.negative||O.negative||L.negative||z.negative||W.negative,Z=L.format||z.format||W.format?"T":"",Y=(P?"-":"")+"P"+S.format+I.format+O.format+Z+L.format+z.format+W.format;return Y==="P"||Y==="-P"?"P0D":Y},N.toJSON=function(){return this.toISOString()},N.format=function(S){var I=S||"YYYY-MM-DDTHH:mm:ss",F={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return I.replace(c,function(O,L){return L||String(F[O])})},N.as=function(S){return this.$ms/_[p(S)]},N.get=function(S){var I=this.$ms,F=p(S);return F==="milliseconds"?I%=1e3:I=F==="weeks"?v(I/_[F]):this.$d[F],I||0},N.add=function(S,I,F){var O;return O=I?S*_[p(I)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+O*(F?-1:1),this)},N.subtract=function(S,I){return this.add(S,I,!0)},N.locale=function(S){var I=this.clone();return I.$l=S,I},N.clone=function(){return y(this.$ms,this)},N.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},N.valueOf=function(){return this.asMilliseconds()},N.milliseconds=function(){return this.get("milliseconds")},N.asMilliseconds=function(){return this.as("milliseconds")},N.seconds=function(){return this.get("seconds")},N.asSeconds=function(){return this.as("seconds")},N.minutes=function(){return this.get("minutes")},N.asMinutes=function(){return this.as("minutes")},N.hours=function(){return this.get("hours")},N.asHours=function(){return this.as("hours")},N.days=function(){return this.get("days")},N.asDays=function(){return this.as("days")},N.weeks=function(){return this.get("weeks")},N.asWeeks=function(){return this.as("weeks")},N.months=function(){return this.get("months")},N.asMonths=function(){return this.as("months")},N.years=function(){return this.get("years")},N.asYears=function(){return this.as("years")},A}(),E=function(A,N,S){return A.add(N.years()*S,"y").add(N.months()*S,"M").add(N.days()*S,"d").add(N.hours()*S,"h").add(N.minutes()*S,"m").add(N.seconds()*S,"s").add(N.milliseconds()*S,"ms")};return function(A,N,S){e=S,r=S().$utils(),S.duration=function(O,L){var z=S.locale();return y(O,{$l:z},L)},S.isDuration=g;var I=N.prototype.add,F=N.prototype.subtract;N.prototype.add=function(O,L){return g(O)?E(this,O,1):I.bind(this)(O,L)},N.prototype.subtract=function(O,L){return g(O)?E(this,O,-1):F.bind(this)(O,L)}}})})(Ih);var tD=Ih.exports,eD=Kt(tD);Wt.extend(xa),Wt.extend(Ea),Wt.extend(Jw),Wt.extend(Qw),Wt.extend(eD);class $h{constructor(t,e,r){$(this,"array");$(this,"color");$(this,"math");$(this,"str");$(this,"map");$(this,"matrix");$(this,"timeframe");$(this,"ta");$(this,"input");$(this,"_variables");$(this,"_cacheData");$(this,"_options");$(this,"_errorListener");$(this,"_plots");$(this,"_plotshapes");$(this,"_plotbars");$(this,"_plotchars");$(this,"_plotarrows");$(this,"_plotcandles");$(this,"_alerts");$(this,"_bgColors");$(this,"_hlines");$(this,"_fills");$(this,"chart");$(this,"line");$(this,"label");$(this,"polyline");$(this,"box");$(this,"table");$(this,"linefill");$(this,"log");$(this,"runtime");$(this,"strategy");$(this,"request");$(this,"syminfo");$(this,"_count",0);var s;const n=((s=t.toString().split(".")[1])==null?void 0:s.length)||5;this._variables=e,this._errorListener=new aD,this.array=new I_(this._errorListener),this.math=new $_(n,this._errorListener),this.color=new oy,this.str=new lw(this._errorListener,n),this.map=new cw(this._errorListener),this.timeframe=new ow(e),this.matrix=new sw(this._errorListener),this.ta=new iy(e,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new sy(e,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new fw(e)},this.line=new Iw(e,this._errorListener),this.label=new hw(e,this._errorListener),this.polyline=new Tw(e,this._errorListener),this.box=new Lw(e,this._errorListener),this.table=new Rw(e,this._errorListener),this.linefill=new $w(e),this.log=new sD(e,this.str),this.runtime=new oD(this._errorListener),this.strategy=new Kw(this._variables,this._options,t,this._errorListener,r),this.request=new nD(this._variables,r),this.syminfo=new iD}get errors(){return this._errorListener.errors}get scriptType(){return this._options.scriptType}options(t){if(t.length)return this._getDataOfBarindex(t);const e=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let s;if(n.length){s={};for(const v of n)s[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,u=this._fills.size?[...this._fills.values()]:void 0,c=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders,strategySummary:this._variables.strategy.summaryData});const f=this._plots.size>0?[...this._plots.values()]:void 0,d=this._plotbars.size>0?[...this._plotbars.values()]:void 0,h=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,_=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,y=this._plotchars.size>0?[...this._plotchars.values()]:void 0,p=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:f,draws:p,alerts:r,colors:s,hlines:a,fills:u,logs:c,plotshapes:h,plotarrows:_,plotcandles:g,plotchars:y,plotbars:d,isUseBgColor:w})}_getDataOfBarindex(t){const e=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const v of r)n[v]=[...this._bgColors[v].values()].map(x=>{const b=[];for(const C of t){const E=x.data[C];E&&b.push(E)}return x.data=b,x})}const s=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,u=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._getDataFromBarindex(t,[...this._plots.values()]),f=this._plotbars.size>0?this._getDataFromBarindex(t,[...this._plotbars.values()]):void 0,d=this._plotarrows.size>0?this._getDataFromBarindex(t,[...this._plotarrows.values()]):void 0,h=this._plotcandles.size>0?this._getDataFromBarindex(t,[...this._plotcandles.values()]):void 0,_=this._plotchars.size>0?this._getDataFromBarindex(t,[...this._plotchars.values()]):void 0,g=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,y=this._getDrawsFromBarindex(t),p=this._getDrawDeletes(t),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,plotarrows:d,plotcandles:h,plotchars:_,plotbars:f,draws:y,drawDeletes:p,alerts:e,colors:n,hlines:s,fills:a,logs:u,plotshapes:g,isUseBgColor:w})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const s of t){const a=r.data[s];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:s,label:a}=this._variables,u={};return t.data.length&&(u.lines=t.data),e.data.length&&(u.linefills=e.data),r.data.length&&(u.tables=r.data),n.data.length&&(u.boxes=n.data),s.data.length&&(u.polylines=s.data),a.data.length&&(u.labels=a.data),Object.keys(u).length?u:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:s,polyline:a,label:u}=this._variables,c={};return e.data.length&&(c.lines=e.getValOfBarIndex(t)),r.data.length&&(c.linefills=r.getValOfBarIndex(t)),n.data.length&&(c.tables=n.getValOfBarIndex(t)),s.data.length&&(c.boxes=s.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),u.data.length&&(c.labels=u.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}_getDrawDeletes(t){const{line:e,linefill:r,table:n,box:s,polyline:a,label:u}=this._variables,c={},f=e.getDeleteIds(t),d=r.getDeleteIds(t),h=n.getDeleteIds(t),_=s.getDeleteIds(t),g=a.getDeleteIds(t),y=u.getDeleteIds(t);return f.length&&(c.lines=f),d.length&&(c.linefills=d),h.length&&(c.tables=h),_.length&&(c.boxes=_),g.length&&(c.polylines=g),y.length&&(c.labels=y),c}updateOptions(t){var n;const{inputs:e,strategy:r}=t;this.input.update(e),r&&((n=this.strategy)==null||n.updateOptions(r))}update(t){const{barIndex:e}=t;this.strategy.update(),this.math.update(e)}endExecution(){this.strategy.endExecution()}library(t,e){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=t;r.test(n)?(T_.includes(n)||B_.includes(n))&&this._errorListener.addError(He(ie.libraryTitleIsKeywordErr,{name:n}),e,Rt.Error):this._errorListener.addError(ie.libraryTitleErr,e,Rt.Error),this._options.scriptType="library",this._options.library=t}}indicator(t,e){if(!this._variables.bar_index){const{format:r}=t;this._paramVerfiy(r,e,"indicator",[Gt.inherit,Gt.percent,Gt.price,Gt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,s="format"){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(S_.lineWidthWarning,e,Rt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];ve(t,r);const{series:n,color:s,...a}=t,{bar_index:u,time:c}=this._variables,f=`plot_${e}`,d=this._plots.get(f),h=(d==null?void 0:d.data)||[],_=n!==void 0&&isNaN(n)?void 0:n;if(h[u]={value:[c,_],barIndex:u,itemStyle:{color:s}},this._seriesColorHandle(t,r,d),!d){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Gt.percent,Gt.price,Gt.volume]);const g=s?[s]:void 0;this._plots.set(f,{editable:!0,...a,colors:g,data:h,id:f,zIndex:this._count})}return{type:"plot",key:f}}plotbar(t,e){const r=["color"];ve(t,r);const{open:n,close:s,low:a,high:u,color:c,...f}=t,{bar_index:d,time:h}=this._variables,_=`plotbar_${e}`,g=this._plotbars.get(_),y=(g==null?void 0:g.data)||[],p=s!==void 0&&isNaN(s)?void 0:s,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=u!==void 0&&isNaN(u)?void 0:u,b=[h,w,p,v,x];if(y[d]={value:b,barIndex:d,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Gt.percent,Gt.price,Gt.volume]);const C=c?[c]:void 0;this._plotbars.set(_,{editable:!0,...f,colors:C,data:y,id:_,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:s,location:a,style:u}=t;this._paramVerfiy(u,r,e,Object.values(lr),"style"),this._paramVerfiy(a,r,e,Object.values(cn),"location"),this._paramVerfiy(n,r,e,Object.values(ir),"size"),this._paramVerfiy(s,r,e,[Gt.percent,Gt.price,Gt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];ve(t,r);const{series:n,color:s,textcolor:a,location:u=cn.abovebar,...c}=t,{bar_index:f,time:d,high:h,low:_}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),p=(y==null?void 0:y.data)||[],w={value:[d,n],barIndex:f,itemStyle:{color:s,textcolor:a},low:_,high:h};p[f]=w,this._seriesColorHandle(t,r,y),y||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:u,data:p,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];ve(t,r);const{series:n,colorup:s,colordown:a,...u}=t,{bar_index:c,time:f,low:d,high:h}=this._variables,_=`plotarrow_${e}`,g=this._plotarrows.get(_),y=(g==null?void 0:g.data)||[];y[c]={value:[f,n!==void 0&&isNaN(n)?void 0:n],barIndex:c,itemStyle:{colorup:s,colordown:a},low:d,high:h},this._seriesColorHandle(t,r,g),g||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Gt.percent,Gt.price,Gt.volume]),this._plotarrows.set(_,{editable:!0,...u,data:y,id:_,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];ve(t,r);const{series:n,color:s,textcolor:a,location:u=cn.abovebar,...c}=t,{bar_index:f,time:d,low:h,high:_}=this._variables,g=`plotshape_${e}`,y=this._plotshapes.get(g),p=(y==null?void 0:y.data)||[],w={value:n,barIndex:f,color:s,textcolor:a,time:d,low:h,high:_};if(p[f]=w,this._seriesColorHandle(t,r,y),!y){this._count++;const v=s?[s]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:p,location:u,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];ve(t,r);const{wickcolor:n,bordercolor:s,color:a,close:u,open:c,low:f,high:d,...h}=t,{bar_index:_,time:g}=this._variables,y=`plotcandle_${e}`,p=this._plotcandles.get(y),w=(p==null?void 0:p.data)||[],v=u!==void 0&&isNaN(u)?void 0:u,x=c!==void 0&&isNaN(c)?void 0:c,b=f!==void 0&&isNaN(f)?void 0:f,C=d!==void 0&&isNaN(d)?void 0:d,E=[g,x,v,b,C];w[_]={value:E,barIndex:_,wickcolor:n,bordercolor:s,color:a},this._seriesColorHandle(t,r,p),p||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Gt.percent,Gt.price,Gt.volume]),this._plotcandles.set(y,{editable:!0,...h,data:w,id:y,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;ve(t,["color"]),this._verifyDisplay(t.display,"hline",e);const s=t.display&&!t.display.length?Ze.none:Ze.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:s,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,I,F,O,L,z,q,W,P,Z;const r=["color","top_color","bottom_color"];ve(t,r);const{color:n,top_color:s,bottom_color:a,seriesColors:u,hline1:c,hline2:f,plot1:d,plot2:h,top_value:_,bottom_value:g,...y}=t,{bar_index:p,time:w}=this._variables,v=`fill_${e}`,x=this._fills.get(v),b=(x==null?void 0:x.data)||[];this._verifyDisplay(t.display,"fill",e);const C=t.display&&!t.display.length?Ze.none:Ze.all;let E,A,N="plot";if(c&&f)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,A=(I=this._hlines.get(f==null?void 0:f.key))==null?void 0:I.price,N="hline";else{const Y=((F=this._plots.get(d==null?void 0:d.key))==null?void 0:F.data)||[],G=((O=this._plots.get(h==null?void 0:h.key))==null?void 0:O.data)||[];E=(z=(L=Y[p])==null?void 0:L.value)==null?void 0:z[1],A=(W=(q=G[p])==null?void 0:q.value)==null?void 0:W[1]}if(b[p]={time:w,color:n,top_color:s,bottom_color:a,plot1:E,plot2:A,top_value:_,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Y=((P=this._options.indicator)==null?void 0:P.explicit_plot_zorder)||((Z=this._options.strategy)==null?void 0:Z.explicit_plot_zorder),G=n?[n]:void 0,X=s?[s]:void 0,ut=a?[a]:void 0;this._fills.set(v,{id:v,colors:G,top_colors:X,bottom_colors:ut,display:C,data:b,type:N,editable:!0,fillgaps:!1,hline1:c,hline2:f,plot1:d,plot2:h,...y,zIndex:Y?this._count:void 0})}}alert({message:t,freq:e=jr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:s,last_bar_index:a}=this._variables,u=`alert_${r}`,c=this._cacheData[u]||{},f=c.barIndex;if(this._paramVerfiy(e,r,"alert",[jr.freqAll,jr.freqOncePerBar,jr.freqOncePerBarClose]),e===jr.freqOncePerBar&&n===f){this._alerts.delete(u);return}this._cacheData[u]=c;const d={message:t,freq:e,id:u,type:"alert"};if(s){e!==jr.freqOncePerBarClose&&this._alerts.set(u,d),c.barIndex=n;return}if(!s&&e===jr.freqOncePerBarClose&&n===f&&a===n-1){this._alerts.set(u,d),c.barIndex=n;return}this._alerts.delete(u)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:s}=this._variables,a=`alertcondition_${n}`;s&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t,e){this._setColors(t,"barcolor",e)}bgcolor(t,e){this._setColors(t,"bgcolor",e)}_verifyDisplay(t=Eh.all,e,r){t.length&&t.length<4&&this._errorListener.addError(He(ie.displayErr,{func:e,values:"[display.none, display.all]"}),r,Rt.Error)}_setColors(t,e,r){ve(t,["color"]);const{color:s,...a}=t;this._verifyDisplay(a.display,e,r);const u=t.display&&!t.display.length?Ze.none:Ze.all,{bar_index:c,time:f}=this._variables,d=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const h=this._bgColors[e].get(d),_=(h==null?void 0:h.data)||[],g=(h==null?void 0:h.setColors)||[];s&&!g.includes(s)&&g.push(s),_[c]={color:s,time:f,barIndex:c},h||this._bgColors[e].set(d,{...a,display:u,data:_,setColors:g,id:d})}max_bars_back({var:t,num:e,var_name:r}){console.log(t,e,r)}float({x:t}){return t}bool({x:t}){return t||!1}string({x:t}){return t}int({x:t}){return t&&Math.trunc(t)}na({x:t}){return!!(t===void 0||typeof t=="number"&&isNaN(t))}fixnan({source:t},e){return t===void 0||typeof t=="number"&&isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!(typeof t=="number"&&isNaN(t))?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n,!0)}timestamp(t){const{dateString:e,timezone:r,year:n,month:s,day:a,hour:u=0,minute:c=0,second:f=0}=t;if(e)return Wt(e).utc(!/GMT|UTC/.test(e)).valueOf();let d=s-1,h=n;if(d<0){const _=Math.ceil(Math.abs(d/12));d=12*_+d,h=n-_}return mr({year:h,month:d,day:a,hour:u,minute:c,second:f},r).valueOf()}weekofyear({time:t,timezone:e}){return mr(t,e).week()}year({time:t,timezone:e}){return mr(t,e).year()}second({time:t,timezone:e}){return mr(t,e).second()}month({time:t,timezone:e}){return mr(t,e).month()+1}minute({time:t,timezone:e}){return mr(t,e).minute()}hour({time:t,timezone:e}){return mr(t,e).hour()}dayofweek({time:t,timezone:e}){return mr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return mr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,this._variables.timeframe.period),n=gr(e,t)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,s,a=0,u=!1){const c=r||this._variables.__period,f=gr(c,t),d=gr(this._variables.__period,t);let h;if(f<=d)h=t,u&&(h+=d*1e3);else{const _=`time_${e}`,g=this._cacheData[_];if(g)g.currentTime+f*1e3-g.offset<=t?(h=t,this._cacheData[_]={currentTime:t,offset:0}):h=g.currentTime;else{const y=this._calcTimeOffset(t,c);this._cacheData[_]={currentTime:t,offset:y},h=t}u&&(h+=f*1e3)}if(n&&n!==Mn.regular&&n!==Mn.extended){const{timePeriods:_,weeks:g}=this._parserSession(n,e),y=mr(t,s),p=y.format("YYYY-MM-DD HH:mm"),w=y.format("YYYY-MM-DD"),v=h,x=mr(h,s).format("YYYY-MM-DD HH:mm");h=void 0;for(const C of _){const[E,A]=C;let N;if(E===A&&(N=y.add(1,"day").format("YYYY-MM-DD")),Wt(p).isBetween(`${w} ${E}`,`${N||w} ${A}`,"hour","[)")){Wt(x).isBetween(`${w} ${E}`,`${N||w} ${A}`,"hour","[)")?h=v:h=mr(`${w} ${E}`,s).valueOf();break}}const b=this._variables.dayofweek;h&&!g.includes(b)&&(h=void 0)}return h&&h-a*d*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const s of e){if((n=r.gradientColorKeys)!=null&&n.includes(s))continue;const a=t[s];if(!a)continue;const u=r[`${s}s`]||[];u.includes(a)||(u.push(a),r[`${s}s`]=u,u.length>5&&(r[`${s}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(s)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const f=parseInt(c,10);if(f<1||f>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,Rt.Error);return}return f});return{timePeriods:n.split(",").map(c=>{c===""||c===Mn.regular?c="0930-1500":c===Mn.extended&&(c="1500-1830");const f=c.split("-");return f.length!==2?[]:[this._processTime(f[0],e),this._processTime(f[1],e)]}),weeks:a}}_processTime(t,e){const r=parseInt(t.slice(0,2),10),n=parseInt(t.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",e,Rt.Error);return}return`${r}:${n}`}}const rD={1:"1M",3:"3M",5:"5M",15:"15M",30:"30M",45:"45M",60:"1H",120:"2H",180:"3H",240:"4H",D:"1D",W:"1W",M:"1MTH","3M":"3MTH","6M":"6MTH","12M":"12MTH"};let nD=class{constructor(t,e){$(this,"_variables");$(this,"_scriptId");$(this,"_cacheData");this._variables=t,this._scriptId=e,this._cacheData=new Map}security(t,e){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=t,s=this._getRequestData(t,e);if(r!=null&&r.has(e)){if(!s)return;const c=r.get(e);return this._runScripts(c,e,!1,n,s)}const a=this._parseExprCode(t),u=this._runScripts(a,e,!0,n,s);return r==null||r.set(e,a),u}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],s=1;e=Xl(e);const a=JSON.parse(e),u=a.pop();let c=(u==null?void 0:u.memberCodes)||{},f=(u==null?void 0:u.depends)||[];if(!f.length)return`return ${u==null?void 0:u.code}`;let d=[],h=[];const _=[];if(this._getDependCodes(f,a,n,d,h,_),n.push(..._),h.length){const p=r.length;let w=[];for(let v=p-1;v>=0;v--){const x=r[v];let b=JSON.parse(Xl(x));const C=[];s!==0&&h.length&&(w.unshift("{"),s++),b=b.map(S=>{const{scope:I,code:F,varNames:O,dependSelf:L}=S;return I===2&&!C.includes(O)&&!L&&(S.code=`let ${F}`),O&&C.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],A=[];let N=h.map(S=>({...S,isArg:!1,isPreArg:!0}));h=[],this._getDependCodes(N,b,A,d,h,E),w.unshift(...A,...E),n=w.concat(n),w=[]}}for(n.push(`return ${u==null?void 0:u.code}`);s>1;)n.push("}"),s--;n=d.concat(n);let g=n.join(`
|
61
|
+
${lh}`)}function gy(i,t,e){return(i>=0&&e?` ${fh(i,t-1)}`:fh(i,t)).padEnd(t)}function fh(i,t){let e=i.toString();if(e.length<=t)return e;let r=i.toFixed(t);if(r.length>t&&(r=i.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=i.toExponential(t);return n.length>t&&(n=i.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function vy(i,t){i.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},i.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r);return this},i.prototype.addM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r.get(n,s));return this},i.add=function(r,n){return new t(r).add(n)},i.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},i.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r);return this},i.prototype.subM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r.get(n,s));return this},i.sub=function(r,n){return new t(r).sub(n)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},i.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r);return this},i.prototype.mulM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r.get(n,s));return this},i.mul=function(r,n){return new t(r).mul(n)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},i.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r);return this},i.prototype.divM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r.get(n,s));return this},i.div=function(r,n){return new t(r).div(n)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},i.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r);return this},i.prototype.modM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r.get(n,s));return this},i.mod=function(r,n){return new t(r).mod(n)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},i.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r);return this},i.prototype.andM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r.get(n,s));return this},i.and=function(r,n){return new t(r).and(n)},i.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},i.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r);return this},i.prototype.orM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r.get(n,s));return this},i.or=function(r,n){return new t(r).or(n)},i.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},i.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r);return this},i.prototype.xorM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r.get(n,s));return this},i.xor=function(r,n){return new t(r).xor(n)},i.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},i.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r);return this},i.prototype.leftShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r.get(n,s));return this},i.leftShift=function(r,n){return new t(r).leftShift(n)},i.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},i.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r);return this},i.prototype.signPropagatingRightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r.get(n,s));return this},i.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},i.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},i.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r);return this},i.prototype.rightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r.get(n,s));return this},i.rightShift=function(r,n){return new t(r).rightShift(n)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},i.not=function(r){return new t(r).not()},i.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},i.abs=function(r){return new t(r).abs()},i.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},i.acos=function(r){return new t(r).acos()},i.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},i.acosh=function(r){return new t(r).acosh()},i.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},i.asin=function(r){return new t(r).asin()},i.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},i.asinh=function(r){return new t(r).asinh()},i.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},i.atan=function(r){return new t(r).atan()},i.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},i.atanh=function(r){return new t(r).atanh()},i.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},i.cbrt=function(r){return new t(r).cbrt()},i.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},i.ceil=function(r){return new t(r).ceil()},i.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},i.clz32=function(r){return new t(r).clz32()},i.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},i.cos=function(r){return new t(r).cos()},i.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},i.cosh=function(r){return new t(r).cosh()},i.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},i.exp=function(r){return new t(r).exp()},i.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},i.expm1=function(r){return new t(r).expm1()},i.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},i.floor=function(r){return new t(r).floor()},i.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},i.fround=function(r){return new t(r).fround()},i.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},i.log=function(r){return new t(r).log()},i.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},i.log1p=function(r){return new t(r).log1p()},i.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},i.log10=function(r){return new t(r).log10()},i.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},i.log2=function(r){return new t(r).log2()},i.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},i.round=function(r){return new t(r).round()},i.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},i.sign=function(r){return new t(r).sign()},i.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},i.sin=function(r){return new t(r).sin()},i.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},i.sinh=function(r){return new t(r).sinh()},i.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},i.sqrt=function(r){return new t(r).sqrt()},i.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},i.tan=function(r){return new t(r).tan()},i.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},i.tanh=function(r){return new t(r).tanh()},i.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},i.trunc=function(r){return new t(r).trunc()},i.pow=function(r,n){return new t(r).pow(n)},i.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},i.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r));return this},i.prototype.powM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r.get(n,s)));return this}}function Tr(i,t,e){let r=e?i.rows:i.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Ir(i,t,e){let r=e?i.columns:i.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Fi(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function Ni(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Xa(i,t){if(!fr.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.rows)throw new RangeError("row indices are out of range")}function Qa(i,t){if(!fr.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.columns)throw new RangeError("column indices are out of range")}function tu(i,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(co("startRow",t),co("endRow",e),co("startColumn",r),co("endColumn",n),t>e||r>n||t<0||t>=i.rows||e<0||e>=i.rows||r<0||r>=i.columns||n<0||n>=i.columns)throw new RangeError("Submatrix indices are out of range")}function lo(i,t=0){let e=[];for(let r=0;r<i;r++)e.push(t);return e}function co(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function Si(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function yy(i){let t=lo(i.rows);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]+=i.get(e,r);return t}function wy(i){let t=lo(i.columns);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]+=i.get(e,r);return t}function Dy(i){let t=0;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t+=i.get(e,r);return t}function by(i){let t=lo(i.rows,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]*=i.get(e,r);return t}function xy(i){let t=lo(i.columns,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]*=i.get(e,r);return t}function Ey(i){let t=1;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t*=i.get(e,r);return t}function Cy(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<r;a++){let u=0,c=0,f=0;for(let d=0;d<n;d++)f=i.get(a,d)-e[a],u+=f,c+=f*f;t?s.push((c-u*u/n)/(n-1)):s.push((c-u*u/n)/n)}return s}function Ay(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<n;a++){let u=0,c=0,f=0;for(let d=0;d<r;d++)f=i.get(d,a)-e[a],u+=f,c+=f*f;t?s.push((c-u*u/r)/(r-1)):s.push((c-u*u/r)/r)}return s}function My(i,t,e){const r=i.rows,n=i.columns,s=r*n;let a=0,u=0,c=0;for(let f=0;f<r;f++)for(let d=0;d<n;d++)c=i.get(f,d)-e,a+=c,u+=c*c;return t?(u-a*a/s)/(s-1):(u-a*a/s)/s}function Fy(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[e])}function Ny(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[r])}function Sy(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t)}function Oy(i){const t=[];for(let e=0;e<i.rows;e++){let r=0;for(let n=0;n<i.columns;n++)r+=Math.pow(i.get(e,n),2)/(i.columns-1);t.push(Math.sqrt(r))}return t}function By(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[e])}function Ty(i){const t=[];for(let e=0;e<i.columns;e++){let r=0;for(let n=0;n<i.rows;n++)r+=Math.pow(i.get(n,e),2)/(i.rows-1);t.push(Math.sqrt(r))}return t}function Iy(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[r])}function $y(i){const t=i.size-1;let e=0;for(let r=0;r<i.columns;r++)for(let n=0;n<i.rows;n++)e+=Math.pow(i.get(n,r),2)/t;return Math.sqrt(e)}function Ly(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t)}class $t{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let s=new dt(t,e);for(let a=0;a<t;a++)for(let u=0;u<e;u++)s.set(a,u,r[a*e+u]);return s}static rowVector(t){let e=new dt(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new dt(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new dt(t,e)}static ones(t,e){return new dt(t,e).fill(1)}static rand(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let s=new dt(t,e);for(let a=0;a<t;a++)for(let u=0;u<e;u++)s.set(a,u,n());return s}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:s=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(n>=s)throw new RangeError("min must be smaller than max");let u=s-n,c=new dt(t,e);for(let f=0;f<t;f++)for(let d=0;d<e;d++){let h=n+Math.round(a()*u);c.set(f,d,h)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),s=this.zeros(t,e);for(let a=0;a<n;a++)s.set(a,a,r);return s}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let s=Math.min(n,e,r),a=this.zeros(e,r);for(let u=0;u<s;u++)a.set(u,u,t[u]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new dt(r,n);for(let a=0;a<r;a++)for(let u=0;u<n;u++)s.set(a,u,Math.min(t.get(a,u),e.get(a,u)));return s}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new this(r,n);for(let a=0;a<r;a++)for(let u=0;u<n;u++)s.set(a,u,Math.max(t.get(a,u),e.get(a,u)));return s}static checkMatrix(t){return $t.isMatrix(t)?t:new dt(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(this.get(t,t)!==0)return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);for(let a=e+1;a<this.rows;a++)this.get(t,a)!==0&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let s=e;s<t.rows;s++)t.get(s,r)>t.get(n,r)&&(n=s);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let s=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/s);for(let a=e+1;a<t.rows;a++){let u=t.get(a,r)/t.get(e,r);t.set(a,r,0);for(let c=r+1;c<t.columns;c++)t.set(a,c,t.get(a,c)-t.get(e,c)*u)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(t.maxRow(n)===0)n--;else{let s=0,a=!1;for(;s<r&&a===!1;)t.get(n,s)===1?a=!0:s++;for(let u=0;u<n;u++){let c=t.get(u,s);for(let f=s;f<e;f++){let d=t.get(u,f)-c*t.get(n,f);t.set(u,f,d)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new dt(this.rows*e,this.columns*r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*s,this.columns*a);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Tr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return dt.rowVector(this.getRow(t))}setRow(t,e){Tr(this,t),e=Fi(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Tr(this,t),Tr(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Ir(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return dt.columnVector(this.getColumn(t))}setColumn(t,e){Ir(this,t),e=Ni(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Ir(this,t),Ir(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=Ni(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Tr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Ir(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Si(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Si(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Tr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Tr(this,t),Si(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Tr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Tr(this,t),Si(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Ir(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Ir(this,t),Si(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Ir(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Ir(this,t),Si(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){$t.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,s=new dt(e,n),a=new Float64Array(r);for(let u=0;u<n;u++){for(let c=0;c<r;c++)a[c]=t.get(c,u);for(let c=0;c<e;c++){let f=0;for(let d=0;d<r;d++)f+=this.get(c,d)*a[d];s.set(c,u,f)}}return s}strassen2x2(t){t=dt.checkMatrix(t);let e=new dt(2,2);const r=this.get(0,0),n=t.get(0,0),s=this.get(0,1),a=t.get(0,1),u=this.get(1,0),c=t.get(1,0),f=this.get(1,1),d=t.get(1,1),h=(r+f)*(n+d),_=(u+f)*n,g=r*(a-d),y=f*(c-n),p=(r+s)*d,w=(u-r)*(n+a),v=(s-f)*(c+d),x=h+y-p+v,b=g+p,C=_+y,E=h-_+g+w;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,C),e.set(1,1,E),e}strassen3x3(t){t=dt.checkMatrix(t);let e=new dt(3,3);const r=this.get(0,0),n=this.get(0,1),s=this.get(0,2),a=this.get(1,0),u=this.get(1,1),c=this.get(1,2),f=this.get(2,0),d=this.get(2,1),h=this.get(2,2),_=t.get(0,0),g=t.get(0,1),y=t.get(0,2),p=t.get(1,0),w=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),C=t.get(2,2),E=(r+n+s-a-u-d-h)*w,A=(r-a)*(-g+w),N=u*(-_+g+p-w-v-x+C),S=(-r+a+u)*(_-g+w),I=(a+u)*(-_+g),F=r*_,O=(-r+f+d)*(_-y+v),L=(-r+f)*(y-v),z=(f+d)*(-_+y),q=(r+n+s-u-c-f-d)*v,W=d*(-_+y+p-w-v-x+b),R=(-s+d+h)*(w+x-b),Z=(s-h)*(w-b),Y=s*x,G=(d+h)*(-x+b),Q=(-s+u+c)*(v+x-C),ut=(s-c)*(v-C),_t=(u+c)*(-x+C),at=n*p,vt=c*b,wt=a*y,Ct=f*g,bt=h*C,re=F+Y+at,Bt=E+S+I+F+R+Y+G,Nt=F+O+z+q+Y+Q+_t,he=A+N+S+F+Y+Q+ut,se=A+S+I+F+vt,qt=Y+Q+ut+_t+wt,Xt=F+O+L+W+R+Z+Y,Le=R+Z+Y+G+Ct,Dr=F+O+L+z+bt;return e.set(0,0,re),e.set(0,1,Bt),e.set(0,2,Nt),e.set(1,0,he),e.set(1,1,se),e.set(1,2,qt),e.set(2,0,Xt),e.set(2,1,Le),e.set(2,2,Dr),e}mmulStrassen(t){t=dt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,s=t.rows,a=t.columns;n!==s&&console.warn(`Multiplying ${r} x ${n} and ${s} x ${a} matrix: dimensions do not match.`);function u(h,_,g){let y=h.rows,p=h.columns;if(y===_&&p===g)return h;{let w=$t.zeros(_,g);return w=w.setSubMatrix(h,0,0),w}}let c=Math.max(r,s),f=Math.max(n,a);e=u(e,c,f),t=u(t,c,f);function d(h,_,g,y){if(g<=512||y<=512)return h.mmul(_);g%2===1&&y%2===1?(h=u(h,g+1,y+1),_=u(_,g+1,y+1)):g%2===1?(h=u(h,g+1,y),_=u(_,g+1,y)):y%2===1&&(h=u(h,g,y+1),_=u(_,g,y+1));let p=parseInt(h.rows/2,10),w=parseInt(h.columns/2,10),v=h.subMatrix(0,p-1,0,w-1),x=_.subMatrix(0,p-1,0,w-1),b=h.subMatrix(0,p-1,w,h.columns-1),C=_.subMatrix(0,p-1,w,_.columns-1),E=h.subMatrix(p,h.rows-1,0,w-1),A=_.subMatrix(p,_.rows-1,0,w-1),N=h.subMatrix(p,h.rows-1,w,h.columns-1),S=_.subMatrix(p,_.rows-1,w,_.columns-1),I=d($t.add(v,N),$t.add(x,S),p,w),F=d($t.add(E,N),x,p,w),O=d(v,$t.sub(C,S),p,w),L=d(N,$t.sub(A,x),p,w),z=d($t.add(v,b),S,p,w),q=d($t.sub(E,v),$t.add(x,C),p,w),W=d($t.sub(b,N),$t.add(A,S),p,w),R=$t.add(I,L);R.sub(z),R.add(W);let Z=$t.add(O,z),Y=$t.add(F,L),G=$t.sub(I,F);G.add(O),G.add(q);let Q=$t.zeros(2*R.rows,2*R.columns);return Q=Q.setSubMatrix(R,0,0),Q=Q.setSubMatrix(Z,R.rows,0),Q=Q.setSubMatrix(Y,0,R.columns),Q=Q.setSubMatrix(G,R.rows,R.columns),Q.subMatrix(0,g-1,0,y-1)}return d(e,t,c,f)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.rows;s++){const a=this.getRow(s);a.length>0&&uh(a,{min:e,max:r,output:a}),n.setRow(s,a)}return n}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.columns;s++){const a=this.getColumn(s);a.length&&uh(a,{min:e,max:r,output:a}),n.setColumn(s,a)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let n=this.get(e,r),s=this.get(e,this.columns-1-r);this.set(e,r,s),this.set(e,this.columns-1-r,n)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let n=this.get(r,e),s=this.get(this.rows-1-r,e);this.set(r,e,s),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,s=t.columns,a=new dt(e*n,r*s);for(let u=0;u<e;u++)for(let c=0;c<r;c++)for(let f=0;f<n;f++)for(let d=0;d<s;d++)a.set(n*u+f,s*c+d,this.get(u,c)*t.get(f,d));return a}kroneckerSum(t){if(t=dt.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(dt.eye(r,r)),s=dt.eye(e,e).kroneckerProduct(t);return n.add(s)}transpose(){let t=new dt(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=hh){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=hh){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){tu(this,t,e,r,n);let s=new dt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let u=r;u<=n;u++)s.set(a-t,u-r,this.get(a,u));return s}subMatrixRow(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new dt(t.length,r-e+1);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);n.set(s,a-e,this.get(t[s],a))}return n}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new dt(r-e+1,t.length);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);n.set(a-e,s,this.get(a,t[s]))}return n}setSubMatrix(t,e,r){if(t=dt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,s=r+t.columns-1;tu(this,e,n,r,s);for(let a=0;a<t.rows;a++)for(let u=0;u<t.columns;u++)this.set(e+a,r+u,t.get(a,u));return this}selection(t,e){Xa(this,t),Qa(this,e);let r=new dt(t.length,e.length);for(let n=0;n<t.length;n++){let s=t[n];for(let a=0;a<e.length;a++){let u=e[a];r.set(n,a,this.get(s,u))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new dt(this.rows,this.columns))}static copy(t,e){for(const[r,n,s]of t.entries())e.set(r,n,s);return e}sum(t){switch(t){case"row":return yy(this);case"column":return wy(this);case void 0:return Dy(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return by(this);case"column":return xy(this);case void 0:return Ey(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":{for(let r=0;r<this.rows;r++)e[r]/=this.columns;return e}case"column":{for(let r=0;r<this.columns;r++)e[r]/=this.rows;return e}case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return Cy(this,r,n)}case"column":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return Ay(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return My(this,r,n)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){typeof t=="object"&&(e=t,t=void 0);const r=this.variance(t,e);if(t===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return Fy(this,r),this}case"column":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return Ny(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return Sy(this,r),this}default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":{if(r===void 0)r=Oy(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return By(this,r),this}case"column":{if(r===void 0)r=Ty(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return Iy(this,r),this}case void 0:{if(r===void 0)r=$y(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return Ly(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return ch(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}$t.prototype.klass="Matrix",typeof Symbol<"u"&&($t.prototype[Symbol.for("nodejs.util.inspect.custom")]=py);function hh(i,t){return i-t}function Ry(i){return i.every(t=>typeof t=="number")}$t.random=$t.rand,$t.randomInt=$t.randInt,$t.diagonal=$t.diag,$t.prototype.diagonal=$t.prototype.diag,$t.identity=$t.eye,$t.prototype.negate=$t.prototype.neg,$t.prototype.tensorProduct=$t.prototype.kroneckerProduct;let dt=(Ri=class extends $t{constructor(e,r){super();Yl(this,cs);$(this,"data");if(Ri.isMatrix(e))Vl(this,cs,Hl).call(this,e.rows,e.columns),Ri.copy(e,this);else if(Number.isInteger(e)&&e>=0)Vl(this,cs,Hl).call(this,e,r);else if(fr.isAnyArray(e)){const n=e;if(e=n.length,r=e?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s<e;s++){if(n[s].length!==r)throw new RangeError("Inconsistent array dimensions");if(!Ry(n[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[s]))}this.rows=e,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(e,r,n){return this.data[e][r]=n,this}get(e,r){return this.data[e][r]}removeRow(e){return Tr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Tr(this,e,!0),r=Float64Array.from(Fi(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Ir(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let s=0;s<e;s++)n[s]=this.data[r][s];for(let s=e+1;s<this.columns;s++)n[s-1]=this.data[r][s];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Ir(this,e,!0),r=Ni(this,r);for(let n=0;n<this.rows;n++){const s=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)s[a]=this.data[n][a];for(s[a++]=r[n];a<this.columns+1;a++)s[a]=this.data[n][a-1];this.data[n]=s}return this.columns+=1,this}},cs=new WeakSet,Hl=function(e,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=e,this.columns=r},Ri);vy($t,dt);const Oo=class Oo extends $t{constructor(e){super();Yl(this,tr,void 0);if(dt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ba(this,tr,dt.copy(e,new dt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ba(this,tr,new dt(e,e));else if(ba(this,tr,new dt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return tn(this,tr).size}get rows(){return tn(this,tr).rows}get columns(){return tn(this,tr).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return dt.isMatrix(e)&&e.klassType==="SymmetricMatrix"}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){const e=new Oo(this.diagonalSize);for(const[r,n,s]of this.upperRightEntries())e.set(r,n,s);return e}toMatrix(){return new dt(this)}get(e,r){return tn(this,tr).get(e,r)}set(e,r,n){return tn(this,tr).set(e,r,n),tn(this,tr).set(r,e,n),this}removeCross(e){return tn(this,tr).removeRow(e),tn(this,tr).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),tn(this,tr).addRow(e,n),tn(this,tr).addColumn(e,r),this}applyMask(e){if(e.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,s]of e.entries())s||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let n=0,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=e&&(n=++s);return r}static fromCompact(e){const r=e.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(e)}`);const s=new Oo(n);for(let a=0,u=0,c=0;c<r;c++)s.set(a,u,e[c]),++a>=n&&(a=++u);return s}*upperRightEntries(){for(let e=0,r=0;e<this.diagonalSize;void 0){const n=this.get(e,r);yield[e,r,n],++r>=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e<this.diagonalSize;void 0)yield this.get(e,r),++r>=this.diagonalSize&&(r=++e)}};tr=new WeakMap;let ri=Oo;ri.prototype.klassType="SymmetricMatrix";class fo extends ri{static isDistanceMatrix(t){return ri.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new ri(this)}clone(){const t=new fo(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let n=1,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=t&&(n=++s+1);return r}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let s=1,a=0,u=0;u<e;u++)n.set(s,a,t[u]),++s>=r&&(s=++a+1);return n}}fo.prototype.klassSubType="DistanceMatrix";class _n extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class Py extends _n{constructor(t,e){Ir(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}class ky extends _n{constructor(t,e){Qa(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class zy extends _n{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class qy extends _n{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class Uy extends _n{constructor(t,e){Tr(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class Wy extends _n{constructor(t,e){Xa(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class ho extends _n{constructor(t,e,r){Xa(t,e),Qa(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class jy extends _n{constructor(t,e,r,n,s){tu(t,e,r,n,s),super(t,r-e+1,s-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class Yy extends _n{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class dh extends $t{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class wr extends $t{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function Vy(i,t){if(fr.isAnyArray(i))return i[0]&&fr.isAnyArray(i[0])?new wr(i):new dh(i,t);throw new Error("the argument is not an array")}class _o{constructor(t){t=wr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,s=new Float64Array(r),a=1,u,c,f,d,h,_,g,y,p;for(u=0;u<r;u++)s[u]=u;for(y=new Float64Array(r),c=0;c<n;c++){for(u=0;u<r;u++)y[u]=e.get(u,c);for(u=0;u<r;u++){for(p=Math.min(u,c),h=0,f=0;f<p;f++)h+=e.get(u,f)*y[f];y[u]-=h,e.set(u,c,y[u])}for(d=c,u=c+1;u<r;u++)Math.abs(y[u])>Math.abs(y[d])&&(d=u);if(d!==c){for(f=0;f<n;f++)_=e.get(d,f),e.set(d,f,e.get(c,f)),e.set(c,f,_);g=s[d],s[d]=s[c],s[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(u=c+1;u<r;u++)e.set(u,c,e.get(u,c)/e.get(c,c))}this.LU=e,this.pivotVector=s,this.pivotSign=a}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(t.get(r,r)===0)return!0;return!1}solve(t){t=dt.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=t.columns,s=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,u,c,f;for(f=0;f<a;f++)for(u=f+1;u<a;u++)for(c=0;c<n;c++)s.set(u,c,s.get(u,c)-s.get(f,c)*e.get(u,f));for(f=a-1;f>=0;f--){for(c=0;c<n;c++)s.set(f,c,s.get(f,c)/e.get(f,f));for(u=0;u<f;u++)for(c=0;c<n;c++)s.set(u,c,s.get(u,c)-s.get(f,c)*e.get(u,f))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s>a?n.set(s,a,t.get(s,a)):s===a?n.set(s,a,1):n.set(s,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s<=a?n.set(s,a,t.get(s,a)):n.set(s,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function pn(i,t){let e=0;return Math.abs(i)>Math.abs(t)?(e=t/i,Math.abs(i)*Math.sqrt(1+e*e)):t!==0?(e=i/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class eu{constructor(t){t=wr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,s=new Float64Array(n),a,u,c,f;for(c=0;c<n;c++){let d=0;for(a=c;a<r;a++)d=pn(d,e.get(a,c));if(d!==0){for(e.get(c,c)<0&&(d=-d),a=c;a<r;a++)e.set(a,c,e.get(a,c)/d);for(e.set(c,c,e.get(c,c)+1),u=c+1;u<n;u++){for(f=0,a=c;a<r;a++)f+=e.get(a,c)*e.get(a,u);for(f=-f/e.get(c,c),a=c;a<r;a++)e.set(a,u,e.get(a,u)+f*e.get(a,c))}}s[c]=-d}this.QR=e,this.Rdiag=s}solve(t){t=dt.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=t.columns,s=t.clone(),a=e.columns,u,c,f,d;for(f=0;f<a;f++)for(c=0;c<n;c++){for(d=0,u=f;u<r;u++)d+=e.get(u,f)*s.get(u,c);for(d=-d/e.get(f,f),u=f;u<r;u++)s.set(u,c,s.get(u,c)+d*e.get(u,f))}for(f=a-1;f>=0;f--){for(c=0;c<n;c++)s.set(f,c,s.get(f,c)/this.Rdiag[f]);for(u=0;u<f;u++)for(c=0;c<n;c++)s.set(u,c,s.get(u,c)-s.get(f,c)*e.get(u,f))}return s.subMatrix(0,a-1,0,n-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,r=new dt(e,e),n,s;for(n=0;n<e;n++)for(s=0;s<e;s++)n<s?r.set(n,s,t.get(n,s)):n===s?r.set(n,s,this.Rdiag[n]):r.set(n,s,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new dt(e,r),s,a,u,c;for(u=r-1;u>=0;u--){for(s=0;s<e;s++)n.set(s,u,0);for(n.set(u,u,1),a=u;a<r;a++)if(t.get(u,u)!==0){for(c=0,s=u;s<e;s++)c+=t.get(s,u)*n.get(s,a);for(c=-c/t.get(u,u),s=u;s<e;s++)n.set(s,a,n.get(s,a)+c*t.get(s,u))}}return n}}class Oi{constructor(t,e={}){if(t=wr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:a=!0,autoTranspose:u=!1}=e;let c=!!s,f=!!a,d=!1,h;if(r<n)if(!u)h=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{h=t.transpose(),r=h.rows,n=h.columns,d=!0;let F=c;c=f,f=F}else h=t.clone();let _=Math.min(r,n),g=Math.min(r+1,n),y=new Float64Array(g),p=new dt(r,_),w=new dt(n,n),v=new Float64Array(n),x=new Float64Array(r),b=new Float64Array(g);for(let F=0;F<g;F++)b[F]=F;let C=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),A=Math.max(C,E);for(let F=0;F<A;F++){if(F<C){y[F]=0;for(let O=F;O<r;O++)y[F]=pn(y[F],h.get(O,F));if(y[F]!==0){h.get(F,F)<0&&(y[F]=-y[F]);for(let O=F;O<r;O++)h.set(O,F,h.get(O,F)/y[F]);h.set(F,F,h.get(F,F)+1)}y[F]=-y[F]}for(let O=F+1;O<n;O++){if(F<C&&y[F]!==0){let L=0;for(let z=F;z<r;z++)L+=h.get(z,F)*h.get(z,O);L=-L/h.get(F,F);for(let z=F;z<r;z++)h.set(z,O,h.get(z,O)+L*h.get(z,F))}v[O]=h.get(F,O)}if(c&&F<C)for(let O=F;O<r;O++)p.set(O,F,h.get(O,F));if(F<E){v[F]=0;for(let O=F+1;O<n;O++)v[F]=pn(v[F],v[O]);if(v[F]!==0){v[F+1]<0&&(v[F]=0-v[F]);for(let O=F+1;O<n;O++)v[O]/=v[F];v[F+1]+=1}if(v[F]=-v[F],F+1<r&&v[F]!==0){for(let O=F+1;O<r;O++)x[O]=0;for(let O=F+1;O<r;O++)for(let L=F+1;L<n;L++)x[O]+=v[L]*h.get(O,L);for(let O=F+1;O<n;O++){let L=-v[O]/v[F+1];for(let z=F+1;z<r;z++)h.set(z,O,h.get(z,O)+L*x[z])}}if(f)for(let O=F+1;O<n;O++)w.set(O,F,v[O])}}let N=Math.min(n,r+1);if(C<n&&(y[C]=h.get(C,C)),r<N&&(y[N-1]=0),E+1<N&&(v[E]=h.get(E,N-1)),v[N-1]=0,c){for(let F=C;F<_;F++){for(let O=0;O<r;O++)p.set(O,F,0);p.set(F,F,1)}for(let F=C-1;F>=0;F--)if(y[F]!==0){for(let O=F+1;O<_;O++){let L=0;for(let z=F;z<r;z++)L+=p.get(z,F)*p.get(z,O);L=-L/p.get(F,F);for(let z=F;z<r;z++)p.set(z,O,p.get(z,O)+L*p.get(z,F))}for(let O=F;O<r;O++)p.set(O,F,-p.get(O,F));p.set(F,F,1+p.get(F,F));for(let O=0;O<F-1;O++)p.set(O,F,0)}else{for(let O=0;O<r;O++)p.set(O,F,0);p.set(F,F,1)}}if(f)for(let F=n-1;F>=0;F--){if(F<E&&v[F]!==0)for(let O=F+1;O<n;O++){let L=0;for(let z=F+1;z<n;z++)L+=w.get(z,F)*w.get(z,O);L=-L/w.get(F+1,F);for(let z=F+1;z<n;z++)w.set(z,O,w.get(z,O)+L*w.get(z,F))}for(let O=0;O<n;O++)w.set(O,F,0);w.set(F,F,1)}let S=N-1,I=Number.EPSILON;for(;N>0;){let F,O;for(F=N-2;F>=-1&&F!==-1;F--){const L=Number.MIN_VALUE+I*Math.abs(y[F]+Math.abs(y[F+1]));if(Math.abs(v[F])<=L||Number.isNaN(v[F])){v[F]=0;break}}if(F===N-2)O=4;else{let L;for(L=N-1;L>=F&&L!==F;L--){let z=(L!==N?Math.abs(v[L]):0)+(L!==F+1?Math.abs(v[L-1]):0);if(Math.abs(y[L])<=I*z){y[L]=0;break}}L===F?O=3:L===N-1?O=1:(O=2,F=L)}switch(F++,O){case 1:{let L=v[N-2];v[N-2]=0;for(let z=N-2;z>=F;z--){let q=pn(y[z],L),W=y[z]/q,R=L/q;if(y[z]=q,z!==F&&(L=-R*v[z-1],v[z-1]=W*v[z-1]),f)for(let Z=0;Z<n;Z++)q=W*w.get(Z,z)+R*w.get(Z,N-1),w.set(Z,N-1,-R*w.get(Z,z)+W*w.get(Z,N-1)),w.set(Z,z,q)}break}case 2:{let L=v[F-1];v[F-1]=0;for(let z=F;z<N;z++){let q=pn(y[z],L),W=y[z]/q,R=L/q;if(y[z]=q,L=-R*v[z],v[z]=W*v[z],c)for(let Z=0;Z<r;Z++)q=W*p.get(Z,z)+R*p.get(Z,F-1),p.set(Z,F-1,-R*p.get(Z,z)+W*p.get(Z,F-1)),p.set(Z,z,q)}break}case 3:{const L=Math.max(Math.abs(y[N-1]),Math.abs(y[N-2]),Math.abs(v[N-2]),Math.abs(y[F]),Math.abs(v[F])),z=y[N-1]/L,q=y[N-2]/L,W=v[N-2]/L,R=y[F]/L,Z=v[F]/L,Y=((q+z)*(q-z)+W*W)/2,G=z*W*(z*W);let Q=0;(Y!==0||G!==0)&&(Y<0?Q=0-Math.sqrt(Y*Y+G):Q=Math.sqrt(Y*Y+G),Q=G/(Y+Q));let ut=(R+z)*(R-z)+Q,_t=R*Z;for(let at=F;at<N-1;at++){let vt=pn(ut,_t);vt===0&&(vt=Number.MIN_VALUE);let wt=ut/vt,Ct=_t/vt;if(at!==F&&(v[at-1]=vt),ut=wt*y[at]+Ct*v[at],v[at]=wt*v[at]-Ct*y[at],_t=Ct*y[at+1],y[at+1]=wt*y[at+1],f)for(let bt=0;bt<n;bt++)vt=wt*w.get(bt,at)+Ct*w.get(bt,at+1),w.set(bt,at+1,-Ct*w.get(bt,at)+wt*w.get(bt,at+1)),w.set(bt,at,vt);if(vt=pn(ut,_t),vt===0&&(vt=Number.MIN_VALUE),wt=ut/vt,Ct=_t/vt,y[at]=vt,ut=wt*v[at]+Ct*y[at+1],y[at+1]=-Ct*v[at]+wt*y[at+1],_t=Ct*v[at+1],v[at+1]=wt*v[at+1],c&&at<r-1)for(let bt=0;bt<r;bt++)vt=wt*p.get(bt,at)+Ct*p.get(bt,at+1),p.set(bt,at+1,-Ct*p.get(bt,at)+wt*p.get(bt,at+1)),p.set(bt,at,vt)}v[N-2]=ut;break}case 4:{if(y[F]<=0&&(y[F]=y[F]<0?-y[F]:0,f))for(let L=0;L<=S;L++)w.set(L,F,-w.get(L,F));for(;F<S&&!(y[F]>=y[F+1]);){let L=y[F];if(y[F]=y[F+1],y[F+1]=L,f&&F<n-1)for(let z=0;z<n;z++)L=w.get(z,F+1),w.set(z,F+1,w.get(z,F)),w.set(z,F,L);if(c&&F<r-1)for(let z=0;z<r;z++)L=p.get(z,F+1),p.set(z,F+1,p.get(z,F)),p.set(z,F,L);F++}N--;break}}}if(d){let F=w;w=p,p=F}this.m=r,this.n=n,this.s=y,this.U=p,this.V=w}solve(t){let e=t,r=this.threshold,n=this.s.length,s=dt.zeros(n,n);for(let _=0;_<n;_++)Math.abs(this.s[_])<=r?s.set(_,_,0):s.set(_,_,1/this.s[_]);let a=this.U,u=this.rightSingularVectors,c=u.mmul(s),f=u.rows,d=a.rows,h=dt.zeros(f,d);for(let _=0;_<f;_++)for(let g=0;g<d;g++){let y=0;for(let p=0;p<n;p++)y+=c.get(_,p)*a.get(g,p);h.set(_,g,y)}return h.mmul(e)}solveForDiagonal(t){return this.solve(dt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,s=new dt(r,this.s.length);for(let d=0;d<r;d++)for(let h=0;h<n;h++)Math.abs(this.s[h])>e&&s.set(d,h,t.get(d,h)/this.s[h]);let a=this.U,u=a.rows,c=a.columns,f=new dt(r,u);for(let d=0;d<r;d++)for(let h=0;h<u;h++){let _=0;for(let g=0;g<c;g++)_+=s.get(d,g)*a.get(h,g);f.set(d,h,_)}return f}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,s=r.length;n<s;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return dt.diag(this.s)}}function Hy(i,t=!1){return i=wr.checkMatrix(i),t?new Oi(i).inverse():_h(i,dt.eye(i.rows))}function _h(i,t,e=!1){return i=wr.checkMatrix(i),t=wr.checkMatrix(t),e?new Oi(i).solve(t):i.isSquare()?new _o(i).solve(t):new eu(i).solve(t)}function po(i){if(i=dt.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let t,e,r,n;if(i.columns===2)return t=i.get(0,0),e=i.get(0,1),r=i.get(1,0),n=i.get(1,1),t*n-e*r;if(i.columns===3){let s,a,u;return s=new ho(i,[1,2],[1,2]),a=new ho(i,[1,2],[0,2]),u=new ho(i,[1,2],[0,1]),t=i.get(0,0),e=i.get(0,1),r=i.get(0,2),t*po(s)-e*po(a)+r*po(u)}else return new _o(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Zy(i,t){let e=[];for(let r=0;r<i;r++)r!==t&&e.push(r);return e}function Ky(i,t,e,r=1e-9,n=1e-9){if(i>n)return new Array(t.rows+1).fill(0);{let s=t.addRow(e,[0]);for(let a=0;a<s.rows;a++)Math.abs(s.get(a,0))<r&&s.set(a,0,0);return s.to1DArray()}}function Gy(i,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;i=dt.checkMatrix(i);let n=i.rows,s=new dt(n,n);for(let a=0;a<n;a++){let u=dt.columnVector(i.getRow(a)),c=i.subMatrixRow(Zy(n,a)).transpose(),d=new Oi(c).solve(u),h=dt.sub(u,c.mmul(d)).abs().max();s.setRow(a,Ky(h,d,a,e,r))}return s}function Jy(i,t=Number.EPSILON){if(i=dt.checkMatrix(i),i.isEmpty())return i.transpose();let e=new Oi(i,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,s=e.diagonal;for(let a=0;a<s.length;a++)Math.abs(s[a])>t?s[a]=1/s[a]:s[a]=0;return n.mmul(dt.diag(s).mmul(r.transpose()))}function Xy(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(i=i.center("column"),r||(t=t.center("column")));const s=i.transpose().mmul(t);for(let a=0;a<s.rows;a++)for(let u=0;u<s.columns;u++)s.set(a,u,s.get(a,u)*(1/(i.rows-1)));return s}function Qy(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=e;n&&(i.center("column"),r||t.center("column")),s&&(i.scale("column"),r||t.scale("column"));const a=i.standardDeviation("column",{unbiased:!0}),u=r?a:t.standardDeviation("column",{unbiased:!0}),c=i.transpose().mmul(t);for(let f=0;f<c.rows;f++)for(let d=0;d<c.columns;d++)c.set(f,d,c.get(f,d)*(1/(a[f]*u[d]))*(1/(i.rows-1)));return c}let ph=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=wr.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n=t.columns,s=new dt(n,n),a=new Float64Array(n),u=new Float64Array(n),c=t,f,d,h=!1;if(r?h=!0:h=t.isSymmetric(),h){for(f=0;f<n;f++)for(d=0;d<n;d++)s.set(f,d,c.get(f,d));tw(n,u,a,s),ew(n,u,a,s)}else{let _=new dt(n,n),g=new Float64Array(n);for(d=0;d<n;d++)for(f=0;f<n;f++)_.set(f,d,c.get(f,d));rw(n,_,g,s),nw(n,u,a,s,_)}this.n=n,this.e=u,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,r=this.d,n=new dt(t,t),s,a;for(s=0;s<t;s++){for(a=0;a<t;a++)n.set(s,a,0);n.set(s,s,r[s]),e[s]>0?n.set(s,s+1,e[s]):e[s]<0&&n.set(s,s-1,e[s])}return n}};function tw(i,t,e,r){let n,s,a,u,c,f,d,h;for(c=0;c<i;c++)e[c]=r.get(i-1,c);for(u=i-1;u>0;u--){for(h=0,a=0,f=0;f<u;f++)h=h+Math.abs(e[f]);if(h===0)for(t[u]=e[u-1],c=0;c<u;c++)e[c]=r.get(u-1,c),r.set(u,c,0),r.set(c,u,0);else{for(f=0;f<u;f++)e[f]/=h,a+=e[f]*e[f];for(n=e[u-1],s=Math.sqrt(a),n>0&&(s=-s),t[u]=h*s,a=a-n*s,e[u-1]=n-s,c=0;c<u;c++)t[c]=0;for(c=0;c<u;c++){for(n=e[c],r.set(c,u,n),s=t[c]+r.get(c,c)*n,f=c+1;f<=u-1;f++)s+=r.get(f,c)*e[f],t[f]+=r.get(f,c)*n;t[c]=s}for(n=0,c=0;c<u;c++)t[c]/=a,n+=t[c]*e[c];for(d=n/(a+a),c=0;c<u;c++)t[c]-=d*e[c];for(c=0;c<u;c++){for(n=e[c],s=t[c],f=c;f<=u-1;f++)r.set(f,c,r.get(f,c)-(n*t[f]+s*e[f]));e[c]=r.get(u-1,c),r.set(u,c,0)}}e[u]=a}for(u=0;u<i-1;u++){if(r.set(i-1,u,r.get(u,u)),r.set(u,u,1),a=e[u+1],a!==0){for(f=0;f<=u;f++)e[f]=r.get(f,u+1)/a;for(c=0;c<=u;c++){for(s=0,f=0;f<=u;f++)s+=r.get(f,u+1)*r.get(f,c);for(f=0;f<=u;f++)r.set(f,c,r.get(f,c)-s*e[f])}}for(f=0;f<=u;f++)r.set(f,u+1,0)}for(c=0;c<i;c++)e[c]=r.get(i-1,c),r.set(i-1,c,0);r.set(i-1,i-1,1),t[0]=0}function ew(i,t,e,r){let n,s,a,u,c,f,d,h,_,g,y,p,w,v,x,b;for(a=1;a<i;a++)t[a-1]=t[a];t[i-1]=0;let C=0,E=0,A=Number.EPSILON;for(f=0;f<i;f++){for(E=Math.max(E,Math.abs(e[f])+Math.abs(t[f])),d=f;d<i&&!(Math.abs(t[d])<=A*E);)d++;if(d>f)do{for(n=e[f],h=(e[f+1]-n)/(2*t[f]),_=pn(h,1),h<0&&(_=-_),e[f]=t[f]/(h+_),e[f+1]=t[f]*(h+_),g=e[f+1],s=n-e[f],a=f+2;a<i;a++)e[a]-=s;for(C=C+s,h=e[d],y=1,p=y,w=y,v=t[f+1],x=0,b=0,a=d-1;a>=f;a--)for(w=p,p=y,b=x,n=y*t[a],s=y*h,_=pn(h,t[a]),t[a+1]=x*_,x=t[a]/_,y=h/_,h=y*e[a]-x*n,e[a+1]=s+x*(y*n+x*e[a]),c=0;c<i;c++)s=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+y*s),r.set(c,a,y*r.get(c,a)-x*s);h=-x*b*w*v*t[f]/g,t[f]=x*h,e[f]=y*h}while(Math.abs(t[f])>A*E);e[f]=e[f]+C,t[f]=0}for(a=0;a<i-1;a++){for(c=a,h=e[a],u=a+1;u<i;u++)e[u]<h&&(c=u,h=e[u]);if(c!==a)for(e[c]=e[a],e[a]=h,u=0;u<i;u++)h=r.get(u,a),r.set(u,a,r.get(u,c)),r.set(u,c,h)}}function rw(i,t,e,r){let n=0,s=i-1,a,u,c,f,d,h,_;for(h=n+1;h<=s-1;h++){for(_=0,f=h;f<=s;f++)_=_+Math.abs(t.get(f,h-1));if(_!==0){for(c=0,f=s;f>=h;f--)e[f]=t.get(f,h-1)/_,c+=e[f]*e[f];for(u=Math.sqrt(c),e[h]>0&&(u=-u),c=c-e[h]*u,e[h]=e[h]-u,d=h;d<i;d++){for(a=0,f=s;f>=h;f--)a+=e[f]*t.get(f,d);for(a=a/c,f=h;f<=s;f++)t.set(f,d,t.get(f,d)-a*e[f])}for(f=0;f<=s;f++){for(a=0,d=s;d>=h;d--)a+=e[d]*t.get(f,d);for(a=a/c,d=h;d<=s;d++)t.set(f,d,t.get(f,d)-a*e[d])}e[h]=_*e[h],t.set(h,h-1,_*u)}}for(f=0;f<i;f++)for(d=0;d<i;d++)r.set(f,d,f===d?1:0);for(h=s-1;h>=n+1;h--)if(t.get(h,h-1)!==0){for(f=h+1;f<=s;f++)e[f]=t.get(f,h-1);for(d=h;d<=s;d++){for(u=0,f=h;f<=s;f++)u+=e[f]*r.get(f,d);for(u=u/e[h]/t.get(h,h-1),f=h;f<=s;f++)r.set(f,d,r.get(f,d)+u*e[f])}}}function nw(i,t,e,r,n){let s=i-1,a=0,u=i-1,c=Number.EPSILON,f=0,d=0,h=0,_=0,g=0,y=0,p=0,w=0,v,x,b,C,E,A,N,S,I,F,O,L,z,q,W;for(v=0;v<i;v++)for((v<a||v>u)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<i;x++)d=d+Math.abs(n.get(v,x));for(;s>=a;){for(C=s;C>a&&(y=Math.abs(n.get(C-1,C-1))+Math.abs(n.get(C,C)),y===0&&(y=d),!(Math.abs(n.get(C,C-1))<c*y));)C--;if(C===s)n.set(s,s,n.get(s,s)+f),e[s]=n.get(s,s),t[s]=0,s--,w=0;else if(C===s-1){if(N=n.get(s,s-1)*n.get(s-1,s),h=(n.get(s-1,s-1)-n.get(s,s))/2,_=h*h+N,p=Math.sqrt(Math.abs(_)),n.set(s,s,n.get(s,s)+f),n.set(s-1,s-1,n.get(s-1,s-1)+f),S=n.get(s,s),_>=0){for(p=h>=0?h+p:h-p,e[s-1]=S+p,e[s]=e[s-1],p!==0&&(e[s]=S-N/p),t[s-1]=0,t[s]=0,S=n.get(s,s-1),y=Math.abs(S)+Math.abs(p),h=S/y,_=p/y,g=Math.sqrt(h*h+_*_),h=h/g,_=_/g,x=s-1;x<i;x++)p=n.get(s-1,x),n.set(s-1,x,_*p+h*n.get(s,x)),n.set(s,x,_*n.get(s,x)-h*p);for(v=0;v<=s;v++)p=n.get(v,s-1),n.set(v,s-1,_*p+h*n.get(v,s)),n.set(v,s,_*n.get(v,s)-h*p);for(v=a;v<=u;v++)p=r.get(v,s-1),r.set(v,s-1,_*p+h*r.get(v,s)),r.set(v,s,_*r.get(v,s)-h*p)}else e[s-1]=S+h,e[s]=S+h,t[s-1]=p,t[s]=-p;s=s-2,w=0}else{if(S=n.get(s,s),I=0,N=0,C<s&&(I=n.get(s-1,s-1),N=n.get(s,s-1)*n.get(s-1,s)),w===10){for(f+=S,v=a;v<=s;v++)n.set(v,v,n.get(v,v)-S);y=Math.abs(n.get(s,s-1))+Math.abs(n.get(s-1,s-2)),S=I=.75*y,N=-.4375*y*y}if(w===30&&(y=(I-S)/2,y=y*y+N,y>0)){for(y=Math.sqrt(y),I<S&&(y=-y),y=S-N/((I-S)/2+y),v=a;v<=s;v++)n.set(v,v,n.get(v,v)-y);f+=y,S=I=N=.964}for(w=w+1,E=s-2;E>=C&&(p=n.get(E,E),g=S-p,y=I-p,h=(g*y-N)/n.get(E+1,E)+n.get(E,E+1),_=n.get(E+1,E+1)-p-g-y,g=n.get(E+2,E+1),y=Math.abs(h)+Math.abs(_)+Math.abs(g),h=h/y,_=_/y,g=g/y,!(E===C||Math.abs(n.get(E,E-1))*(Math.abs(_)+Math.abs(g))<c*(Math.abs(h)*(Math.abs(n.get(E-1,E-1))+Math.abs(p)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=s;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=s-1&&(q=b!==s-1,b!==E&&(h=n.get(b,b-1),_=n.get(b+1,b-1),g=q?n.get(b+2,b-1):0,S=Math.abs(h)+Math.abs(_)+Math.abs(g),S!==0&&(h=h/S,_=_/S,g=g/S)),S!==0);b++)if(y=Math.sqrt(h*h+_*_+g*g),h<0&&(y=-y),y!==0){for(b!==E?n.set(b,b-1,-y*S):C!==E&&n.set(b,b-1,-n.get(b,b-1)),h=h+y,S=h/y,I=_/y,p=g/y,_=_/h,g=g/h,x=b;x<i;x++)h=n.get(b,x)+_*n.get(b+1,x),q&&(h=h+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-h*p)),n.set(b,x,n.get(b,x)-h*S),n.set(b+1,x,n.get(b+1,x)-h*I);for(v=0;v<=Math.min(s,b+3);v++)h=S*n.get(v,b)+I*n.get(v,b+1),q&&(h=h+p*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-h*g)),n.set(v,b,n.get(v,b)-h),n.set(v,b+1,n.get(v,b+1)-h*_);for(v=a;v<=u;v++)h=S*r.get(v,b)+I*r.get(v,b+1),q&&(h=h+p*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-h*g)),r.set(v,b,r.get(v,b)-h),r.set(v,b+1,r.get(v,b+1)-h*_)}}}if(d!==0){for(s=i-1;s>=0;s--)if(h=e[s],_=t[s],_===0)for(C=s,n.set(s,s,1),v=s-1;v>=0;v--){for(N=n.get(v,v)-h,g=0,x=C;x<=s;x++)g=g+n.get(v,x)*n.get(x,s);if(t[v]<0)p=N,y=g;else if(C=v,t[v]===0?n.set(v,s,N!==0?-g/N:-g/(c*d)):(S=n.get(v,v+1),I=n.get(v+1,v),_=(e[v]-h)*(e[v]-h)+t[v]*t[v],A=(S*y-p*g)/_,n.set(v,s,A),n.set(v+1,s,Math.abs(S)>Math.abs(p)?(-g-N*A)/S:(-y-I*A)/p)),A=Math.abs(n.get(v,s)),c*A*A>1)for(x=v;x<=s;x++)n.set(x,s,n.get(x,s)/A)}else if(_<0)for(C=s-1,Math.abs(n.get(s,s-1))>Math.abs(n.get(s-1,s))?(n.set(s-1,s-1,_/n.get(s,s-1)),n.set(s-1,s,-(n.get(s,s)-h)/n.get(s,s-1))):(W=mo(0,-n.get(s-1,s),n.get(s-1,s-1)-h,_),n.set(s-1,s-1,W[0]),n.set(s-1,s,W[1])),n.set(s,s-1,0),n.set(s,s,1),v=s-2;v>=0;v--){for(F=0,O=0,x=C;x<=s;x++)F=F+n.get(v,x)*n.get(x,s-1),O=O+n.get(v,x)*n.get(x,s);if(N=n.get(v,v)-h,t[v]<0)p=N,g=F,y=O;else if(C=v,t[v]===0?(W=mo(-F,-O,N,_),n.set(v,s-1,W[0]),n.set(v,s,W[1])):(S=n.get(v,v+1),I=n.get(v+1,v),L=(e[v]-h)*(e[v]-h)+t[v]*t[v]-_*_,z=(e[v]-h)*2*_,L===0&&z===0&&(L=c*d*(Math.abs(N)+Math.abs(_)+Math.abs(S)+Math.abs(I)+Math.abs(p))),W=mo(S*g-p*F+_*O,S*y-p*O-_*F,L,z),n.set(v,s-1,W[0]),n.set(v,s,W[1]),Math.abs(S)>Math.abs(p)+Math.abs(_)?(n.set(v+1,s-1,(-F-N*n.get(v,s-1)+_*n.get(v,s))/S),n.set(v+1,s,(-O-N*n.get(v,s)-_*n.get(v,s-1))/S)):(W=mo(-g-I*n.get(v,s-1),-y-I*n.get(v,s),p,_),n.set(v+1,s-1,W[0]),n.set(v+1,s,W[1]))),A=Math.max(Math.abs(n.get(v,s-1)),Math.abs(n.get(v,s))),c*A*A>1)for(x=v;x<=s;x++)n.set(x,s-1,n.get(x,s-1)/A),n.set(x,s,n.get(x,s)/A)}for(v=0;v<i;v++)if(v<a||v>u)for(x=v;x<i;x++)r.set(v,x,n.get(v,x));for(x=i-1;x>=a;x--)for(v=a;v<=u;v++){for(p=0,b=a;b<=Math.min(x,u);b++)p=p+r.get(v,b)*n.get(b,x);r.set(v,x,p)}}}function mo(i,t,e,r){let n,s;return Math.abs(e)>Math.abs(r)?(n=r/e,s=e+n*r,[(i+n*t)/s,(t-n*i)/s]):(n=e/r,s=r+n*e,[(n*i+t)/s,(n*t-i)/s])}class mh{constructor(t){if(t=wr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new dt(r,r),s=!0,a,u,c;for(u=0;u<r;u++){let f=0;for(c=0;c<u;c++){let d=0;for(a=0;a<c;a++)d+=n.get(c,a)*n.get(u,a);d=(e.get(u,c)-d)/n.get(c,c),n.set(u,c,d),f=f+d*d}for(f=e.get(u,u)-f,s&=f>0,n.set(u,u,Math.sqrt(Math.max(f,0))),c=u+1;c<r;c++)n.set(u,c,0)}this.L=n,this.positiveDefinite=!!s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=wr.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=t.columns,s=t.clone(),a,u,c;for(c=0;c<r;c++)for(u=0;u<n;u++){for(a=0;a<c;a++)s.set(c,u,s.get(c,u)-s.get(a,u)*e.get(c,a));s.set(c,u,s.get(c,u)/e.get(c,c))}for(c=r-1;c>=0;c--)for(u=0;u<n;u++){for(a=c+1;a<r;a++)s.set(c,u,s.get(c,u)-s.get(a,u)*e.get(a,c));s.set(c,u,s.get(c,u)/e.get(c,c))}return s}get lowerTriangularMatrix(){return this.L}}class gh{constructor(t,e={}){t=wr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:s=1e3,terminationCriteria:a=1e-10}=e;let u;if(r){if(fr.isAnyArray(r)&&typeof r[0]=="number"?r=dt.columnVector(r):r=wr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");u=r.getColumnVector(0)}else u=t.getColumnVector(0);let c=1,f,d,h,_;for(let g=0;g<s&&c>a;g++)h=t.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),h=h.div(h.norm()),f=t.mmul(h).div(h.transpose().mmul(h).get(0,0)),g>0&&(c=f.clone().sub(_).pow(2).sum()),_=f.clone(),r?(d=r.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0)),d=d.div(d.norm()),u=r.mmul(d).div(d.transpose().mmul(d).get(0,0))):u=f;if(r){let g=t.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0));g=g.div(g.norm());let y=t.clone().sub(f.clone().mmul(g.transpose())),p=u.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0)),w=r.clone().sub(f.clone().mulS(p.get(0,0)).mmul(d.transpose()));this.t=f,this.p=g.transpose(),this.w=h.transpose(),this.q=d,this.u=u,this.s=f.transpose().mmul(f),this.xResidual=y,this.yResidual=w,this.betas=p}else this.w=h.transpose(),this.s=f.transpose().mmul(f).sqrt(),n?this.t=f.clone().div(this.s.get(0,0)):this.t=f,this.xResidual=t.sub(f.mmul(h.transpose()))}}zt.AbstractMatrix=$t,zt.CHO=mh,zt.CholeskyDecomposition=mh,zt.DistanceMatrix=fo,zt.EVD=ph;var iw=zt.EigenvalueDecomposition=ph;zt.LU=_o,zt.LuDecomposition=_o;var vh=zt.Matrix=dt;zt.MatrixColumnSelectionView=ky,zt.MatrixColumnView=Py,zt.MatrixFlipColumnView=zy,zt.MatrixFlipRowView=qy,zt.MatrixRowSelectionView=Wy,zt.MatrixRowView=Uy,zt.MatrixSelectionView=ho,zt.MatrixSubView=jy,zt.MatrixTransposeView=Yy,zt.NIPALS=gh,zt.Nipals=gh,zt.QR=eu,zt.QrDecomposition=eu,zt.SVD=Oi,zt.SingularValueDecomposition=Oi,zt.SymmetricMatrix=ri,zt.WrapperMatrix1D=dh,zt.WrapperMatrix2D=wr,zt.correlation=Qy,zt.covariance=Xy;var yh=zt.default=dt;zt.determinant=po,zt.inverse=Hy,zt.linearDependencies=Gy,zt.pseudoInverse=Jy,zt.solve=_h,zt.wrap=Vy;const wh=iw,Dh=vh;yh.Matrix&&yh.Matrix;class sw{constructor(t){$(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new ru(t,e,r,this._errorListener)}avg({id:t}){return t==null?void 0:t.avg()}col({id:t,column:e}){return t==null?void 0:t.col({column:e})}det({id:t}){return t==null?void 0:t.det()}get({id:t,row:e,column:r}){return t==null?void 0:t.get({row:e,column:r})}inv({id:t}){return t==null?void 0:t.inv()}max({id:t}){return t==null?void 0:t.max()}min({id:t}){return t==null?void 0:t.min()}pow({id:t,power:e}){return t==null?void 0:t.pow({power:e})}row({id:t,row:e}){return t==null?void 0:t.row({row:e})}set({id:t,row:e,column:r,value:n}){t==null||t.set({row:e,column:r,value:n})}sum({id1:t,id2:e}){return t==null?void 0:t.sum({id2:e})}copy({id:t}){return t==null?void 0:t.copy()}diff({id1:t,id2:e}){return t==null?void 0:t.diff({id2:e})}rows({id:t}){return t==null?void 0:t.rows()}columns({id:t}){return t==null?void 0:t.columns()}fill({id:t,value:e,from_row:r,to_row:n,from_column:s,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:s,to_column:a})}kron({id1:t,id2:e}){return t==null?void 0:t.kron({id2:e})}mode({id:t}){return t==null?void 0:t.mode()}mult({id1:t,id2:e}){return t==null?void 0:t.mult({id2:e})}pinv({id:t}){return t==null?void 0:t.pinv()}rank({id:t}){return t==null?void 0:t.rank()}sort({id:t,column:e,order:r}){t==null||t.sort({column:e,order:r})}trace({id:t}){return t==null?void 0:t.trace()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}median({id:t}){return t==null?void 0:t.median()}add_col({id:t,column:e,array_id:r}){t==null||t.add_col({column:e,array_id:r})}add_row({id:t,row:e,array_id:r}){t==null||t.add_row({row:e,array_id:r})}is_zero({id:t}){return t==null?void 0:t.is_zero()}reshape({id:t,rows:e,columns:r},n){return t==null?void 0:t.reshape({rows:e,columns:r},n)}reverse({id:t}){t==null||t.reverse()}is_binary({id:t}){return t==null?void 0:t.is_binary()}is_square({id:t}){return t==null?void 0:t.is_square()}submatrix({id:t,from_row:e,to_row:r,from_column:n,to_column:s}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:s})}swap_rows({id:t,row1:e,row2:r}){t==null||t.swap_rows({row1:e,row2:r})}transpose({id:t}){return t==null?void 0:t.transpose()}remove_col({id:t,column:e}){return t==null?void 0:t.remove_col({column:e})}remove_row({id:t,row:e}){return t==null?void 0:t.remove_row({row:e})}eigenvalues({id:t}){return t==null?void 0:t.eigenvalues()}is_diagonal({id:t}){return t==null?void 0:t.is_diagonal()}is_identity({id:t}){return t==null?void 0:t.is_identity()}eigenvectors({id:t}){return t==null?void 0:t.eigenvectors()}is_symmetric({id:t}){return t==null?void 0:t.is_symmetric()}swap_columns({id:t,column1:e,column2:r}){t==null||t.swap_columns({column1:e,column2:r})}is_stochastic({id:t}){return t==null?void 0:t.is_stochastic()}is_triangular({id:t}){return t==null?void 0:t.is_triangular()}elements_count({id:t}){return t==null?void 0:t.elements_count()}is_antidiagonal({id:t}){return t==null?void 0:t.is_antidiagonal()}is_antisymmetric({id:t}){return t==null?void 0:t.is_antisymmetric()}}class ru{constructor(t=0,e=0,r=void 0,n){$(this,"_matrixInstance");$(this,"_errorListener");this._matrixInstance=this._createMatrix(t,e,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(t=>[...t._value])}get _value(){return this._matrixInstance}set _value(t){this._matrixInstance=t}get isMatrix(){return!0}_createMatrix(t,e,r){return Array.from(new Array(t),()=>new ee(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const s of n._value)t+=mt(s)?0:s,e+=1;return t/e}col({column:t}){const e=[],r=new ee(0,void 0,this._errorListener);if(mt(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return oh(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(mt(t)||mt(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=ao(this._matrixArray);return this._newMatrix(t)}max(){return ty(this._matrixArray)}min(){return Ja(this._matrixArray)}pow({power:t}){const e=mt(t)?this._matrixArray:ry(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return mt(t)?new ee(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){mt(t)||mt(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=os(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=Z1(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:t,from_row:e,to_row:r,from_column:n,to_column:s}={}){mt(e)&&(e=0),mt(r)&&(r=this.rows()),mt(n)&&(n=0),mt(s)&&(s=this.columns());for(const[a,u]of this._matrixInstance.entries())for(const[c]of u._value.entries())a<r&&a>=e&&c>=n&&c<s&&u.set({index:c,value:t})}kron({id2:t}){const e=V1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return Ja(Qf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=Mi(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=ey(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Gn.ascending}={}){mt(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const s=r._value[t],a=n._value[t];return e!==Gn.descending?s-a:a-s})}trace(){return Q1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return ah(this._matrixArray)}add_col({column:t,array_id:e}={}){mt(t)&&(t=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:t,value:e?e._value[r]:void 0})}add_row({row:t,array_id:e}){mt(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new ee(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t=0,columns:e=0},r){if(t*e!==this.columns()*this.rows()){this._errorListener.addError(ie.matrixRehapeErr,r,Rt.Error);return}const n=U1(this._matrixArray,[t,e]);this._matrixInstance=n.map(s=>{const a=new ee(0,void 0,this._errorListener);return a._value=[...s],a})}reverse(){this._matrixInstance.reverse();for(const t of this._matrixInstance)t.reverse()}is_binary(){return this._matrixArray.every(t=>t.every(e=>e===0||e===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:t,to_row:e,from_column:r,to_column:n}={}){mt(t)&&(t=0),mt(e)&&(e=this.rows()),mt(r)&&(r=0),mt(n)&&(n=this.columns());const s=this._matrixArray.splice(t,e),a=[];for(const u of s)a.push(u.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(mt(t)||mt(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=eh(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){mt(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const s=n._value.splice(t,1);e.push(s[0])}const r=new ee(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return mt(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new wh(new Dh(this._matrixArray)),e=new ee(0,void 0,this._errorListener);return e._value=t.realEigenvalues,e}is_diagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0)return!1;return!0}is_identity(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0||n===s&&r[n][s]!==1)return!1;return!0}eigenvectors(){const t=new wh(new Dh(this._matrixArray));return this._newMatrix(t.eigenvectorMatrix.to2DArray())}is_symmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=n+1;s<e;s++)if(r[n][s]!==r[s][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(mt(t)||mt(e)))for(const r of this._matrixInstance){const n=r._value[t],s=r._value[e];r.set({index:t,value:s}),r.set({index:e,value:n})}}is_stochastic(){const t=this._matrixArray;for(let e=0;e<t.length;e++){let r=0;for(let n=0;n<t[e].length;n++){if(t[e][n]<0)return!1;r+=t[e][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const t=this.rows(),e=this.columns();return t!==e?!1:this._isUpperTriangular(t)||this._isLowerTriangular(t)}elements_count(){return W1(this._matrixArray)}is_antidiagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n+s!==t-1&&r[n][s]!==0)return!1;return!0}is_antisymmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n!==s&&r[n][s]!==-r[s][n])return!1;return!0}_isUpperTriangular(t){const e=this._matrixArray;for(let r=1;r<t;r++)for(let n=0;n<r;n++)if(e[r][n]!==0)return!1;return!0}_isLowerTriangular(t){const e=this._matrixArray;for(let r=0;r<t-1;r++)for(let n=r+1;n<t;n++)if(e[r][n]!==0)return!1;return!0}_newMatrix(t){const e=new ru(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new ee(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,s=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let u=a;for(;u<r&&s[u][a]===0;)u++;if(u===r)continue;if(u!==a){const f=s[u];s[u]=s[a],s[a]=f}const c=s[a][a];for(let f=0;f<n;f++)s[a][f]/=c;for(let f=a+1;f<r;f++){const d=s[f][a];s[f]=s[f].map((h,_)=>h-d*s[a][_]),s[f][a]=0}}for(let a=0;a<r;a++)s[a].some(u=>Number(u.toFixed(8))!==0)&&e++;return e}}class ow{constructor(t){$(this,"_variables");$(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const{time:r,__period:n}=this._variables,s=gr(t,r),a=gr(n,r);if(s<a)return!0;const u=`change_${e}`,c=this._cacheData[u],f=this._variables.time;if(c){if(c.offset){if(c.currentTime+c.offset<=f)return this._cacheData[u]={currentTime:f,offset:0},!0}else if(c.currentTime+s*1e3<=f)return this._cacheData[u]={currentTime:f,offset:0},!0}else{const d=this._calcTimeOffset(f,t);return this._cacheData[u]={currentTime:f,offset:d},!1}return!1}in_seconds({timeframe:t}={}){const{time:e,__period:r}=this._variables;return gr(t||r,e)}from_seconds({seconds:t=0}){const e=t*1e3,r=Wt.duration(e);if(r.years())return"12M";const s=r.asMonths();if(so(s))return`${s}M`;const a=r.asWeeks();if(so(a))return`${a}M`;const u=r.asDays();if(u>=1)return`${Math.ceil(u)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const f=r.asSeconds();return f<=1?"1S":f<=5?"5S":f<=10?"10S":f<=15?"15S":f<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const u=Wt(t).day();e="1D",u!==1&&(r=(8-u)*60*60*24*1e3)}else if(e.includes("M")){const u=Wt(t).date();e="1D";const c=Wt(t).daysInMonth();u!==1&&(r=(c-u+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),s=gr(e,t)*1e3,a=t-n-Math.floor((t-n)/s)*s;return r?r-a:a}}var bh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(r,n,s){var a=n.prototype,u=a.format;s.en.formats=e,a.format=function(c){c===void 0&&(c="YYYY-MM-DDTHH:mm:ssZ");var f=this.$locale().formats,d=function(h,_){return h.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(g,y,p){var w=p&&p.toUpperCase();return y||_[p]||e[p]||_[w].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(v,x,b){return x||b.slice(1)})})}(c,f===void 0?{}:f);return u.call(this,d)}}})})(bh);var aw=bh.exports,uw=Kt(aw);Wt.extend(uw);class lw{constructor(t,e){$(this,"_errorListener");$(this,"_intlNumberFormatter");$(this,"_precision");$(this,"_intlFormat");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"}),this._intlFormat=new Intl.NumberFormat("en-US")}pos({source:t="",str:e=""}){return t==null?void 0:t.indexOf(e)}trim({source:t=""}){return t==null?void 0:t.trim()}lower({source:t=""}){return t==null?void 0:t.toLocaleLowerCase()}match({source:t="",regex:e=""}){const r=t==null?void 0:t.match(new RegExp(e));return r?r[0]:""}split({string:t="",separator:e=""}){const r=t==null?void 0:t.split(e),n=new ee;return n._value=r||[],n}upper({source:t=""}){return t==null?void 0:t.toLocaleUpperCase()}format({formatString:t=""},e){return this._strFormat(t,e)}length({string:t=""}){return t==null?void 0:t.length}repeat({source:t="",repeat:e,separator:r=""},n){if(mt(e)){this._errorListener.addError(ie.arrLenErr,n,Rt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){mt(n)&&(n=0);let s=-1;for(let a=0;a<n+1&&(s=t.indexOf(e,s+1),s!==-1);a++);return s!==-1?t.substring(0,s)+r+t.substring(s+e.length):t}contains({source:t="",str:e=""}){return t==null?void 0:t.includes(e)}endswith({source:t="",str:e=""}){return t==null?void 0:t.endsWith(e)}tonumber({string:t=""}){if(/[^\d.]/.test(t))return;const e=parseFloat(t);return isNaN(e)?void 0:e}tostring({value:t,format:e}){if(t===void 0)return"NaN";if(typeof t=="object"){if(t.isArray)return this._arrToStr(t._value,e);if(t.isMatrix){const r=[];for(const n of t._matrixArray)r.push(this._arrToStr(n,e));return r.join(`
|
62
|
+
`)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return String(this._toStringFormat(t,e==null?void 0:e.replace(/0/g,"#")))}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._toStringFormat(n,e):n).toString()}]`}substring({source:t="",begin_pos:e=0,end_pos:r}){return mt(e)&&(e=0),mt(r)&&(r=void 0),t==null?void 0:t.substring(e,r)}startswith({source:t="",str:e=""}){return t==null?void 0:t.startsWith(e)}format_time({time:t,format:e="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return mt(t)&&(t=0),mr(t,r).format(e)}replace_all({source:t="",target:e="",replacement:r=""}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_toStringFormat(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case Gt.mintick:return t.toFixed(this._precision);case Gt.percent:return`${t}%`;case Gt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var u;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[s,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),f=((u=c[c.length-1])==null?void 0:u.replace(/[^#]/g,"").length)||0;f&&(s=s.replace(new RegExp(`\\B(?=(\\d{${f}})+(?!\\d))`,"g"),",")),r=c.join("")}s=r.replace(/#/,s).replace(/#/g,"")}else s=`${r}${s}`;if(n&&n.includes("#")){const c=n.split("#").length-1,f=+`${s}.${a}`;if(!isNaN(f))return`${f.toFixed(c)}${n.replace(/#/g,"")}`;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${s}.${a}`:s}_formatNumber(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:return this._formatOthers(t,e)}}strformat({formatString:t=""},e,r){return this._strFormat(t,e,r)}_strFormat(t,e,r){return t.replace(/{[^{}]+}/g,n=>{if(!n)return n;const s=n.replace(/[{}]/g,"").split(","),a=Number(s[0]);if(isNaN(a)||e.length<=a)return n;const u=e[a];if(s.length===1)return typeof u=="number"&&r?this._intlFormat.format(u):u;if(s.length===2){const c=s[1].trim();return c==="number"?r?this._intlFormat.format(u):u:c==="date"?Wt(u).format("LL"):n}else{const c=s[1].trim(),f=s[2].trim();if(c==="number")return this._formatNumber(u,f);if(c==="date"){let d="YYYY-MM-DD";switch(f){case"long":d="LL";break;case"short":d="L";break;default:f&&(d=f)}return Wt(u).format(d)}return n}})}}class cw{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new nu(this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}get({id:t,key:e}){return t==null?void 0:t.get({key:e})}put({id:t,key:e,value:r}){return t==null?void 0:t.put({key:e,value:r})}keys({id:t}){return t==null?void 0:t.keys()}size({id:t}){return t==null?void 0:t.size()}clear({id:t}){t==null||t.clear()}remove({id:t,key:e}){return t==null?void 0:t.remove({key:e})}values({id:t}){return t==null?void 0:t.values()}put_all({id:t,id2:e}){t==null||t.put_all({id2:e})}contains({id:t,key:e}){return t==null?void 0:t.contains({key:e})}}class nu{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new nu(this._errorListener);return e._mapInstance=new Map(t.entries()),e}copy(){return this._copyMap(this._mapInstance)}get({key:t}){return this._mapInstance.get(t)}put({key:t,value:e}){return this._mapInstance.set(t,e)}keys(){const t=new ee(0,void 0,this._errorListener);return t._value=[...this._mapInstance.keys()],t}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:t}){const e=this._mapInstance.get(t);return this._mapInstance.delete(t),e||void 0}values(){const t=new ee(0,void 0,this._errorListener);return t._value=[...this._mapInstance.values()],t}put_all({id2:t}){this._mapInstance=new Map([...this._mapInstance,...t._mapInstance])}contains({key:t}){return this._mapInstance.has(t)}}class fw{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Bi(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Bi(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Bi(t,e)}from_time({price:t,time:e}){return new Bi(t,void 0,e)}}class Bi{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}set index(t){this._index=t}get price(){return this._price}set price(t){this._price=t}get time(){return this._time}set time(t){this._time=t}copy(){return new Bi(this._price,this._index,this._time)}}class hw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:be.bar_index,yloc:Vr.price,size:ir.normal,style:ye.styleLabelDown,textalign:jt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:s,bar_index:a}=this._variables,u=`label_${e}_${a}`;ve(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:u,time:r,high:n,low:s,bar_index:a};t.point&&(c.x=c.xloc===be.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Vr.abovebar?c.y=n:c.yloc===Vr.belowbar&&(c.y=s),this._verfiyArgs(t,e);const f=new go(u,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(u,c,f),f}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:s,size:a,textalign:u,text_font_family:c}=t,f="label.new";this._paramVerfiy(s,e,f,Object.values(ye),"style"),this._paramVerfiy(r,e,f,Object.values(be),"xloc"),this._paramVerfiy(n,e,f,Object.values(Vr),"yloc"),this._paramVerfiy(a,e,f,Object.values(ir),"size"),this._paramVerfiy(u,e,f,[jt.alignLeft,jt.alignCenter,jt.alignRight],"textalign"),this._paramVerfiy(c,e,f,Object.values(Jn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}label(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class go{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");this._id=t,this._variables=e,this._errorListener=r}get type(){return te.LABEL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.label.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`label_${t}_${e}`,n=this._getLabel(t),s=new go(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,s)}return s}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t),this._paramVerfiy(t,e,"label.set_size",Object.values(ir),"size")}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e,this._paramVerfiy(e,r,"label.set_xloc",Object.values(be),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:s}=this._variables;r&&(r.yloc=t,t===Vr.abovebar?r.y=n:t===Vr.belowbar&&(r.y=s),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Vr),"yloc"))}set_color(t,e){const r=this._getLabel(e);ve(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===be.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t),this._paramVerfiy(t,e,"label.set_style",Object.values(ye),"style")}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t),this._paramVerfiy(t,e,"label.set_textalign",[jt.alignLeft,jt.alignCenter,jt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);ve(t,["textcolor"]),r&&(r.textcolor=t.textcolor)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t),this._paramVerfiy(t,e,"label.set_text_font_family",Object.values(Jn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const dw={freq_all:jr.freqAll,freq_once_per_bar:jr.freqOncePerBar,freq_once_per_bar_close:jr.freqOncePerBarClose},_w={gaps_off:ln.gapsOff,gaps_on:ln.gapsOn,lookahead_off:ln.lookaheadOff,lookahead_on:ln.lookaheadOn},Ti={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#FF5252",silver:"#B2B5BE",teal:"#00897B",white:"#FFFFFF",yellow:"#FFEB3B"},xh={AUD:"AUD",BTC:"BTC",CAD:"CAD",CHF:"CHF",ETH:"ETH",EUR:"EUR",GBP:"GBP",HKD:"HKD",INR:"INR",JPY:"JPY",KRW:"KRW",MYR:"MYR",NOK:"NOK",NONE:"NONE",NZD:"NZD",RUB:"RUB",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",USDT:"USDT",ZAR:"ZAR"},pw={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Eh={all:[Ze.dataWindow,Ze.pane,Ze.priceScale,Ze.statusLine],data_window:[Ze.dataWindow],none:[],pane:[Ze.pane],price_scale:[Ze.priceScale],status_line:[Ze.statusLine]},mw={both:Yr.both,left:Yr.left,none:Yr.none,right:Yr.right},gw={inherit:Gt.inherit,mintick:Gt.mintick,percent:Gt.percent,price:Gt.price,volume:Gt.volume},vw={style_solid:Ss.styleSolid,style_dashed:Ss.styleDashed,style_dotted:Ss.styleDotted},yw={style_arrowdown:ye.styleArrowdown,style_arrowup:ye.styleArrowup,style_circle:ye.styleCircle,style_cross:ye.styleCross,style_diamond:ye.styleDiamond,style_flag:ye.styleFlag,style_label_center:ye.styleLabelCenter,style_label_down:ye.styleLabelDown,style_label_left:ye.styleLabelLeft,style_label_lower_left:ye.styleLabelLowerLeft,style_label_lower_right:ye.styleLabelLowerRight,style_label_right:ye.styleLabelRight,style_label_up:ye.styleLabelUp,style_label_upper_left:ye.styleLabelUpperLeft,style_label_upper_right:ye.styleLabelUpperRight,style_none:ye.styleNone,style_square:ye.styleSquare,style_text_outline:ye.styleTextOutline,style_triangledown:ye.styleTriangledown,style_triangleup:ye.styleTriangleup,style_xcross:ye.styleXcross},ww={style_arrow_both:Re.styleArrowBoth,style_arrow_left:Re.styleArrowLeft,style_arrow_right:Re.styleArrowRight,style_dashed:Re.styleDashed,style_dotted:Re.styleDotted,style_solid:Re.styleSolid},Dw={abovebar:cn.abovebar,absolute:cn.absolute,belowbar:cn.belowbar,bottom:cn.bottom,top:cn.top},bw={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},xw={style_area:Or.styleArea,style_areabr:Or.styleAreabr,style_circles:Or.styleCircles,style_columns:Or.styleColumns,style_cross:Or.styleCross,style_histogram:Or.styleHistogram,style_line:Or.styleLine,style_linebr:Or.styleLinebr,style_stepline:Or.styleStepline,style_stepline_diamond:Or.styleSteplineDiamond,style_steplinebr:Or.styleSteplinebr},Ew={bottom_center:vr.bottomCenter,bottom_left:vr.bottomLeft,bottom_right:vr.bottomRight,middle_center:vr.middleCenter,middle_left:vr.middleLeft,middle_right:vr.middleRight,top_center:vr.topCenter,top_left:vr.topLeft,top_right:vr.topRight},Cw={left:Os.left,none:Os.none,right:Os.right},Aw={arrowdown:lr.arrowdown,arrowup:lr.arrowup,circle:lr.circle,cross:lr.cross,diamond:lr.diamond,flag:lr.flag,labeldown:lr.labeldown,labelup:lr.labelup,square:lr.square,triangledown:lr.triangledown,triangleup:lr.triangleup,xcross:lr.xcross},Mw={auto:ir.auto,huge:ir.huge,large:ir.large,normal:ir.normal,small:ir.small,tiny:ir.tiny},Fw={cash:Pe.cash,fixed:Pe.fixed,percent_of_equity:Pe.percentOfEquity,commission:{cash_per_contract:je.cashPerContract,cash_per_order:je.cashPerOrder,percent:je.percent},direction:{all:fe.all,long:fe.long,short:fe.short},oca:{cancel:fn.cancel,none:fn.none,reduce:fn.reduce}},Nw={align_bottom:jt.alignBottom,align_center:jt.alignCenter,align_left:jt.alignLeft,align_right:jt.alignRight,align_top:jt.alignTop,wrap_auto:jt.wrapAuto,wrap_none:jt.wrapNone},Sw={bar_index:be.bar_index,bar_time:be.bar_time},Ow={abovebar:Vr.abovebar,belowbar:Vr.belowbar,price:Vr.price},Bw={actual:Bs.actual,estimate:Bs.estimate,standardized:Bs.standardized};class Ch{constructor(){$(this,"adjustment",{dividends:Ns.dividends,none:Ns.none,splits:Ns.splits});$(this,"alert",dw);$(this,"barmerge",_w);$(this,"color",Ti);$(this,"currency",xh);$(this,"dayofweek",pw);$(this,"earnings",Bw);$(this,"display",Eh);$(this,"extend",mw);$(this,"font",{family_default:Jn.familyDefault,family_monospace:Jn.familyMonospace});$(this,"format",gw);$(this,"hline",vw);$(this,"label",yw);$(this,"line",ww);$(this,"location",Dw);$(this,"math",bw);$(this,"order",{ascending:Gn.ascending,descending:Gn.descending});$(this,"plot",xw);$(this,"position",Ew);$(this,"scale",Cw);$(this,"session",{extended:Mn.extended,regular:Mn.regular});$(this,"shape",Aw);$(this,"size",Mw);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",Fw);$(this,"text",Nw);$(this,"xloc",Sw);$(this,"yloc",Ow)}updateData(){}}class Tw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:be.bar_index,line_color:Ti.blue,line_style:Re.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var u;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,s=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(u=t.points)==null?void 0:u._value.map(c=>({time:c.time,index:c.index,price:c.price}))});ve(s,["line_color","fill_color"]);const a=new Ah(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,s,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,s="polyline.new";this._paramVerfiy(r,e,s,Object.values(Re),"line_style"),this._paramVerfiy(n,e,s,Object.values(be),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}delete({id:t}){t&&t.delete()}}class Ah{constructor(t,e){$(this,"_id");$(this,"_variables");$(this,"_suffix");this._variables=e,this._id=t}get type(){return te.POLYLINE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}}class Iw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:be.bar_index,extend:Yr.none,style:Re.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:s}=this._variables,a=`line_${n}_${s}`;ve(r,["color"]);const u={...this._defaultLine,...r,id:a,bar_index:s};if(t&&e){const f=u.xloc===be.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,d=u.xloc===be.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(u,{x1:f,y1:t==null?void 0:t.price,x2:d,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new vo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,u,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:s}=t,a="line.new";this._paramVerfiy(s,e,a,Object.values(Re),"style"),this._paramVerfiy(r,e,a,Object.values(Yr),"extend"),this._paramVerfiy(n,e,a,Object.values(be),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}line(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class vo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_suffix","");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get type(){return te.LINE}get data(){return this._variables.line.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`line_${t}_${e}`,n=this._getLine(t),s=new vo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e,isVar:void 0},s),s}delete(){this._variables.line.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===be.bar_index){const{x1:n,y1:s,x2:a,y2:u}=r;return n===void 0||a===void 0||s===void 0||u===void 0?void 0:(u-s)/(a-n)*(t-n)+s}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const s=this._getLine(n);s&&(s.xloc=t,s.x1=e,s.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(be),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(ve(t,["color"]),r.color=t.color)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values(Re),"style"))}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t,this._paramVerfiy(t,e,"line.set_extend",Object.values(Yr),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},u=r.xloc===be.bar_index?n:s,c=a;u&&(r.x1=u),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},u=r.xloc===be.bar_index?n:s,c=a;u&&(r.x2=u),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class $w{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:s}=this._variables,a=`linefill_${e}_${s}`,u=r==null?void 0:r.data,c=n==null?void 0:n.data;u&&(u.linefills=u.linefills||[],u.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),ve(t,["color"]);const f=new yo(this._variables,a,r,n);return e.startsWith("export")||(u||c)&&this._variables.linefill.add(a,{line1:u,line2:c,color:t.color,id:a,bar_index:s},f),f}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class yo{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");$(this,"_suffix");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return te.LINEFILL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new yo(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:s}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),s&&(s.linefills=(r=s.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(ve(t,["color"]),e.color=t.color)}}class Lw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Ti.blue,border_width:1,bgcolor:Ti.blue,xloc:be.bar_index,extend:Yr.none,style:Re.styleSolid,text:"",text_size:ir.auto,text_color:Ti.black,text_halign:jt.alignCenter,text_valign:jt.alignCenter,text_wrap:jt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:s}=this._variables,a=`box_${n}_${s}`,u={...this._defaultBox,...r,id:a,bar_index:s};if(ve(u,["border_color","bgcolor","text_color"]),t){const{price:f,time:d,index:h}=t;u.top=f,u.left=u.xloc===be.bar_index?h:d}if(e){const{price:f,time:d,index:h}=e;u.bottom=f,u.right=u.xloc===be.bar_index?h:d}this._verfiyArgs(r,n);const c=new wo(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,u,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:s,text_size:a,text_halign:u,text_valign:c,text_wrap:f,text_font_family:d}=t,h="box.new";this._paramVerfiy(r,e,h,[Re.styleDashed,Re.styleDotted,Re.styleSolid],"border_style"),this._paramVerfiy(n,e,h,Object.values(Yr),"extend"),this._paramVerfiy(s,e,h,Object.values(be),"xloc"),this._paramVerfiy(a,e,h,Object.values(ir),"text_size"),this._paramVerfiy(u,e,h,[jt.alignLeft,jt.alignCenter,jt.alignRight],"text_halign"),this._paramVerfiy(c,e,h,[jt.alignBottom,jt.alignCenter,jt.alignTop],"text_valign"),this._paramVerfiy(f,e,h,[jt.wrapAuto,jt.wrapNone],"text_wrap"),this._paramVerfiy(d,e,h,Object.values(Jn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_text({id:t,...e}){t==null||t.set_text(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e},r){t==null||t.set_border_style(e,r)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e},r){t==null||t.set_text_size(e,r)}set_text_wrap({id:t,...e},r){t==null||t.set_text_wrap(e,r)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e},r){t==null||t.set_text_halign(e,r)}set_text_valign({id:t,...e},r){t==null||t.set_text_valign(e,r)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class wo{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");this._variables=t,this._id=e,this._errorListener=r}get type(){return te.BOX}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.box.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`box_${t}_${e}`,n=this._getBox(),s=new wo(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},s),s}delete(){this._variables.box.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t},e){const r=this._getBox();r&&(r.extend=t,this._paramVerfiy(t,e,"box.set_extend",Object.values(Yr),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,ve(e,["bgcolor"]))}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t},e){const r=this._getBox();r&&(r.text_size=t,this._paramVerfiy(t,e,"box.set_text_size",Object.values(ir),"text_size"))}set_text_wrap({text_wrap:t},e){const r=this._getBox();r&&(r.text_wrap=t,this._paramVerfiy(t,e,"box.set_text_wrap",[jt.wrapAuto,jt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,ve(e,["text_color"]))}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t},e){const r=this._getBox();r&&(r.text_halign=t,this._paramVerfiy(t,e,"box.set_text_halign",[jt.alignLeft,jt.alignCenter,jt.alignRight],"text_halign"))}set_text_valign({text_valign:t},e){const r=this._getBox();r&&(r.text_valign=t,this._paramVerfiy(t,e,"box.set_text_valign",[jt.alignBottom,jt.alignCenter,jt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.top=n,e.left=e.xloc===be.bar_index?r:s}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,ve(e,["border_color"]))}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[Re.styleDashed,Re.styleDotted,Re.styleSolid],"style"))}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.bottom=n,e.right=e.xloc===be.bar_index?r:s}}set_text_font_family({text_font_family:t},e){const r=this._getBox();r&&(r.text_font_family=t,this._paramVerfiy(t,e,"box.set_text_font_family",Object.values(Jn),"text_font_family"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Rw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:vr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t}){return t}new(t,e){const{bar_index:r}=this._variables,n=`table_${e}_${r}`,{rows:s}=t;ve(t,["text_color","bgcolor","border_color"]);const a=Array.from(Array(s),()=>[]),u=e.split("_"),c=u.pop(),f=u.pop(),d={...this._defaultTable,...t,cell:a,id:n,bar_index:r,line:f,col:c},h=new Mh(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(vr),"position"),e.startsWith("export")||this._variables.table.add(n,d,h),h}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e},r){t==null||t.set_position(e,r)}}class Mh{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ti.black,text_halign:jt.alignCenter,text_valign:jt.alignCenter,text_size:ir.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return te.TABLE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.table.get(this._id)}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,s=this._variables.table.get(this._id);if(s){const a=s.cell||[],u=a[n]||[];u[r]=e,a[n]=u,s.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r,ve(n,["text_color"]))}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0}){const s=this._variables.table.get(this._id);if(s){const a=s.cell;if(a)for(let u=e;u<=n;u++)for(let c=t;c<=r;c++){const f=a[u];f&&(f[c]=void 0)}}}delete(){this._variables.table.delete(this._id,this._variables._isRealTimeBar?void 0:this._variables.bar_index)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},s){if(t>r||e>n){this._errorListener.addError(ie.mergeCellErr,s,Rt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const u=a.merge_cells||[];u.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=u}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,ve(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,ve(e,["border_color"]))}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t},e){const r=this._variables.table.get(this._id);r&&(r.position=t,this._paramVerfiy(t,e,"table.set_position",Object.values(vr),"position"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class Pw{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){return this._verifyTradeNum(t)&&this._strategy.historyOrders[t].commission||0}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.historyOrders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_price}entry_time({trade_num:t}){if(!this._verifyTradeNum(t))return;const{in_time:e,entry_time:r}=this._strategy.historyOrders[t];return r||e}exit_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_index}exit_comment({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_comment:""}exit_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_id:""}exit_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_price}exit_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{out_qty:e=0,direction:r}=this._strategy.historyOrders[t];return r===fe.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class kw{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,original_qty:r=0,commission:n=0}=this._strategy.orders[t];return n*e/r}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.orders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_price}entry_time({trade_num:t}){if(!this._verifyTradeNum(t))return;const{in_time:e,entry_time:r}=this._strategy.orders[t];return r||e}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,direction:r}=this._strategy.orders[t];return r===fe.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class zw{constructor(t,e){$(this,"_strategy");$(this,"_errorListener");this._strategy=t,this._errorListener=e}allow_entry_in({value:t},e){this._paramVerfiy(t,e,"strategy.risk.allow_entry_in",Object.values(fe),"value"),this._strategy.updateRisk({allow_entry_in:t})}max_cons_loss_days({count:t}){this._strategy.updateRisk({max_cons_loss_days:t})}max_drawdown({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_drawdown",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_drawdown:t,max_drawdown_type:e})}max_intraday_filled_orders({count:t}){this._strategy.updateRisk({max_intraday_filled_orders:t})}max_intraday_loss({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_intraday_loss",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_intraday_loss:t,max_intraday_loss_type:e})}max_position_size({contracts:t}){this._strategy.updateRisk({max_position_size:t})}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}}var qw=20,Uw=1,ni=1e6,Fh=1e6,Ww=-7,jw=21,Yw=!1,us="[big.js] ",ii=us+"Invalid ",Do=ii+"decimal places",Vw=ii+"rounding mode",Nh=us+"Division by zero",le={},sn=void 0,Hw=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Sh(){function i(t){var e=this;if(!(e instanceof i))return t===sn?Sh():new i(t);if(t instanceof i)e.s=t.s,e.e=t.e,e.c=t.c.slice();else{if(typeof t!="string"){if(i.strict===!0&&typeof t!="bigint")throw TypeError(ii+"value");t=t===0&&1/t<0?"-0":String(t)}Zw(e,t)}e.constructor=i}return i.prototype=le,i.DP=qw,i.RM=Uw,i.NE=Ww,i.PE=jw,i.strict=Yw,i.roundDown=0,i.roundHalfUp=1,i.roundHalfEven=2,i.roundUp=3,i}function Zw(i,t){var e,r,n;if(!Hw.test(t))throw Error(ii+"number");for(i.s=t.charAt(0)=="-"?(t=t.slice(1),-1):1,(e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),n=t.length,r=0;r<n&&t.charAt(r)=="0";)++r;if(r==n)i.c=[i.e=0];else{for(;n>0&&t.charAt(--n)=="0";);for(i.e=e-r-1,i.c=[],e=0;r<=n;)i.c[e++]=+t.charAt(r++)}return i}function si(i,t,e,r){var n=i.c;if(e===sn&&(e=i.constructor.RM),e!==0&&e!==1&&e!==2&&e!==3)throw Error(Vw);if(t<1)r=e===3&&(r||!!n[0])||t===0&&(e===1&&n[0]>=5||e===2&&(n[0]>5||n[0]===5&&(r||n[1]!==sn))),n.length=1,r?(i.e=i.e-t+1,n[0]=1):n[0]=i.e=0;else if(t<n.length){if(r=e===1&&n[t]>=5||e===2&&(n[t]>5||n[t]===5&&(r||n[t+1]!==sn||n[t-1]&1))||e===3&&(r||!!n[0]),n.length=t,r){for(;++n[--t]>9;)if(n[t]=0,t===0){++i.e,n.unshift(1);break}}for(t=n.length;!n[--t];)n.pop()}return i}function oi(i,t,e){var r=i.e,n=i.c.join(""),s=n.length;if(t)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r<s&&(n=n.slice(0,r)+"."+n.slice(r));else s>1&&(n=n.charAt(0)+"."+n.slice(1));return i.s<0&&e?"-"+n:n}le.abs=function(){var i=new this.constructor(this);return i.s=1,i},le.cmp=function(i){var t,e=this,r=e.c,n=(i=new e.constructor(i)).c,s=e.s,a=i.s,u=e.e,c=i.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-a:0;if(s!=a)return s;if(t=s<0,u!=c)return u>c^t?1:-1;for(a=(u=r.length)<(c=n.length)?u:c,s=-1;++s<a;)if(r[s]!=n[s])return r[s]>n[s]^t?1:-1;return u==c?0:u>c^t?1:-1},le.div=function(i){var t=this,e=t.constructor,r=t.c,n=(i=new e(i)).c,s=t.s==i.s?1:-1,a=e.DP;if(a!==~~a||a<0||a>ni)throw Error(Do);if(!n[0])throw Error(Nh);if(!r[0])return i.s=s,i.c=[i.e=0],i;var u,c,f,d,h,_=n.slice(),g=u=n.length,y=r.length,p=r.slice(0,u),w=p.length,v=i,x=v.c=[],b=0,C=a+(v.e=t.e-i.e)+1;for(v.s=s,s=C<0?0:C,_.unshift(0);w++<u;)p.push(0);do{for(f=0;f<10;f++){if(u!=(w=p.length))d=u>w?1:-1;else for(h=-1,d=0;++h<u;)if(n[h]!=p[h]){d=n[h]>p[h]?1:-1;break}if(d<0){for(c=w==u?n:_;w;){if(p[--w]<c[w]){for(h=w;h&&!p[--h];)p[h]=9;--p[h],p[w]+=10}p[w]-=c[w]}for(;!p[0];)p.shift()}else break}x[b++]=d?f:++f,p[0]&&d?p[w]=r[g]||0:p=[r[g]]}while((g++<y||p[0]!==sn)&&s--);return!x[0]&&b!=1&&(x.shift(),v.e--,C--),b>C&&si(v,C,e.RM,p[0]!==sn),v},le.eq=function(i){return this.cmp(i)===0},le.gt=function(i){return this.cmp(i)>0},le.gte=function(i){return this.cmp(i)>-1},le.lt=function(i){return this.cmp(i)<0},le.lte=function(i){return this.cmp(i)<1},le.minus=le.sub=function(i){var t,e,r,n,s=this,a=s.constructor,u=s.s,c=(i=new a(i)).s;if(u!=c)return i.s=-c,s.plus(i);var f=s.c.slice(),d=s.e,h=i.c,_=i.e;if(!f[0]||!h[0])return h[0]?i.s=-c:f[0]?i=new a(s):i.s=1,i;if(u=d-_){for((n=u<0)?(u=-u,r=f):(_=d,r=h),r.reverse(),c=u;c--;)r.push(0);r.reverse()}else for(e=((n=f.length<h.length)?f:h).length,u=c=0;c<e;c++)if(f[c]!=h[c]){n=f[c]<h[c];break}if(n&&(r=f,f=h,h=r,i.s=-i.s),(c=(e=h.length)-(t=f.length))>0)for(;c--;)f[t++]=0;for(c=t;e>u;){if(f[--e]<h[e]){for(t=e;t&&!f[--t];)f[t]=9;--f[t],f[e]+=10}f[e]-=h[e]}for(;f[--c]===0;)f.pop();for(;f[0]===0;)f.shift(),--_;return f[0]||(i.s=1,f=[_=0]),i.c=f,i.e=_,i},le.mod=function(i){var t,e=this,r=e.constructor,n=e.s,s=(i=new r(i)).s;if(!i.c[0])throw Error(Nh);return e.s=i.s=1,t=i.cmp(e)==1,e.s=n,i.s=s,t?new r(e):(n=r.DP,s=r.RM,r.DP=r.RM=0,e=e.div(i),r.DP=n,r.RM=s,this.minus(e.times(i)))},le.neg=function(){var i=new this.constructor(this);return i.s=-i.s,i},le.plus=le.add=function(i){var t,e,r,n=this,s=n.constructor;if(i=new s(i),n.s!=i.s)return i.s=-i.s,n.minus(i);var a=n.e,u=n.c,c=i.e,f=i.c;if(!u[0]||!f[0])return f[0]||(u[0]?i=new s(n):i.s=n.s),i;if(u=u.slice(),t=a-c){for(t>0?(c=a,r=f):(t=-t,r=u),r.reverse();t--;)r.push(0);r.reverse()}for(u.length-f.length<0&&(r=f,f=u,u=r),t=f.length,e=0;t;u[t]%=10)e=(u[--t]=u[t]+f[t]+e)/10|0;for(e&&(u.unshift(e),++c),t=u.length;u[--t]===0;)u.pop();return i.c=u,i.e=c,i},le.pow=function(i){var t=this,e=new t.constructor("1"),r=e,n=i<0;if(i!==~~i||i<-Fh||i>Fh)throw Error(ii+"exponent");for(n&&(i=-i);i&1&&(r=r.times(t)),i>>=1,!!i;)t=t.times(t);return n?e.div(r):r},le.prec=function(i,t){if(i!==~~i||i<1||i>ni)throw Error(ii+"precision");return si(new this.constructor(this),i,t)},le.round=function(i,t){if(i===sn)i=0;else if(i!==~~i||i<-ni||i>ni)throw Error(Do);return si(new this.constructor(this),i+this.e+1,t)},le.sqrt=function(){var i,t,e,r=this,n=r.constructor,s=r.s,a=r.e,u=new n("0.5");if(!r.c[0])return new n(r);if(s<0)throw Error(us+"No square root");s=Math.sqrt(+oi(r,!0,!0)),s===0||s===1/0?(t=r.c.join(""),t.length+a&1||(t+="0"),s=Math.sqrt(t),a=((a+1)/2|0)-(a<0||a&1),i=new n((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+a)):i=new n(s+""),a=i.e+(n.DP+=4);do e=i,i=u.times(e.plus(r.div(e)));while(e.c.slice(0,a).join("")!==i.c.slice(0,a).join(""));return si(i,(n.DP-=4)+i.e+1,n.RM)},le.times=le.mul=function(i){var t,e=this,r=e.constructor,n=e.c,s=(i=new r(i)).c,a=n.length,u=s.length,c=e.e,f=i.e;if(i.s=e.s==i.s?1:-1,!n[0]||!s[0])return i.c=[i.e=0],i;for(i.e=c+f,a<u&&(t=n,n=s,s=t,f=a,a=u,u=f),t=new Array(f=a+u);f--;)t[f]=0;for(c=u;c--;){for(u=0,f=a+c;f>c;)u=t[f]+s[c]*n[f-c-1]+u,t[f--]=u%10,u=u/10|0;t[f]=u}for(u?++i.e:t.shift(),c=t.length;!t[--c];)t.pop();return i.c=t,i},le.toExponential=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ni)throw Error(Do);for(e=si(new e.constructor(e),++i,t);e.c.length<i;)e.c.push(0)}return oi(e,!0,!!r)},le.toFixed=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ni)throw Error(Do);for(e=si(new e.constructor(e),i+e.e+1,t),i=i+e.e+1;e.c.length<i;)e.c.push(0)}return oi(e,!1,!!r)},le[Symbol.for("nodejs.util.inspect.custom")]=le.toJSON=le.toString=function(){var i=this,t=i.constructor;return oi(i,i.e<=t.NE||i.e>=t.PE,!!i.c[0])},le.toNumber=function(){var i=+oi(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(i.toString()))throw Error(us+"Imprecise conversion");return i},le.toPrecision=function(i,t){var e=this,r=e.constructor,n=e.c[0];if(i!==sn){if(i!==~~i||i<1||i>ni)throw Error(ii+"precision");for(e=si(new r(e),i,t);e.c.length<i;)e.c.push(0)}return oi(e,i<=e.e||e.e<=r.NE||e.e>=r.PE,!!n)},le.valueOf=function(){var i=this,t=i.constructor;if(t.strict===!0)throw Error(us+"valueOf disallowed");return oi(i,i.e<=t.NE||i.e>=t.PE,!0)};var iu=Sh();function Oh(i,t){return iu(i).plus(t).toNumber()}function bo(i,t){return iu(i).minus(t).toNumber()}function Ii(i,t){return iu(i).mul(t).toNumber()}let Kw=class{constructor(t,e,r,n,s){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_exitOrders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");$(this,"_maxDrawdownVerifyIndex",0);$(this,"calcOnOrderFillsData",{index:-1});this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Gt.inherit,pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Pe.fixed,default_qty_value:1,initial_capital:1e6,currency:xh.NONE,slippage:0,commission_type:je.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=e,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._exitOrders=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new kw(this),this._closedtrades=new Pw(this),this._riskNamespace=new zw(this,n),this._id=`strategy_${s}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;return this._orders.reduce((e,r)=>e+t*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}get isCalcOnEveryTick(){return this._options.calc_on_every_tick}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._ordersHandle(),this._pendingOrderHandle(),this._exitOrdersHandle(),this._maxIntradayFilledOrdersVerify(),this._maxDrawdownVerify();const{open:t,high:e,low:r}=this.calcOnOrderFillsData.data||this._variables;let n=this._variables.close;this.calcOnOrderFillsData.tradeData&&(n=this.calcOnOrderFillsData.tradeData.open),this._variables.strategy.update({open:t,close:n,high:e,low:r}),!this._options.process_orders_on_close&&this._calcLiquidate(),this._calcProfitAndLoss()}calcCurrentOrder(){this._ordersHandle(),this._pendingOrderHandle(),this._calcProfitAndLoss()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:t,max_intraday_loss_type:e,isDisabledOpen:r}=this._risk;if(t===void 0||!e||r)return;const{time_tradingday:n,time:s,strategy:{netprofit:a,initial_capital:u}}=this._variables,{high:c,low:f}=this.calcOnOrderFillsData.data||this._variables;let{preNetprofit:d=0}=this._risk;s===n&&(d=a,this._risk.preNetprofit=a,this._risk.isTemporaryBan=!1);let h=d-a;h+=this._orders.reduce((y,p)=>{const{in_price:w,direction:v,qty:x=0,commission:b=0,original_qty:C=0}=p,E=v===fe.long?1:-1,A=(c-w)*x,N=(f-w)*x,S=E===1?N:-A;return y+S+x/C*b},0);let _=!1;switch(e){case Pe.cash:_=t<h;break;case Pe.percentOfEquity:const y=h/(u+a)*100;_=t<y;break}if(_){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===fe.long?f:c,"Close Position (Max intraday Loss)",void 0,"close"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:t,intradayOrders:e=0,isDisabledOpen:r}=this._risk;if(t===void 0||r)return;const{time:n,time_tradingday:s}=this._variables,{open:a}=this.calcOnOrderFillsData.data||this._variables;n===s&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),t<=e&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)",void 0,"close"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:t,lossDays:e=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(t===void 0||r)return;const{time:s,time_tradingday:a,strategy:u}=this._variables,{open:c}=this.calcOnOrderFillsData.data||this._variables;let f=e;if(s===a){const d=u.netprofit+u.openprofit;d<n?f=0:f++,Object.assign(this._risk,{lossDays:f,totalProfit:d})}t<=f&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(r)return;const{bar_index:n}=this._variables,{open:s}=this.calcOnOrderFillsData.data||this._variables;if(t!==void 0&&e&&this._maxDrawdownVerifyIndex===n){const{initial_capital:a}=this._options,c=this._orders.reduce((d,h)=>{const{in_price:_,commission:g=0,qty:y=0,original_qty:p=0,direction:w}=h,v=w===fe.long?1:-1,x=(s-_)*v*y;return d+x+g*y/p},0)+this._totalChangeCapital;let f=!1;switch(e){case Pe.percentOfEquity:f=c/a*100<=-t;break;case Pe.cash:f=c<=-t;break}f&&this._riskTouchOff(s,"Close Position (Max Drawdown)")}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._orders.length&&this._closeOrders(this._orders,t,e,"close"),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Gt.inherit,Gt.price,Gt.percent,Gt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Pe),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(je),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={...this._updateOptions};if(r)for(const s of Object.keys({...r,...t}))t[s]!==r[s]&&delete n[s];self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,userSetStrategyConfig:n,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(fn),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(fn),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.filter(r=>!this._options.process_orders_on_close||r.in_index!==this._variables.bar_index).length)return;const{immediately:e}=t;if(e||this._options.process_orders_on_close){const r=this._pendingCloseOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingCloseOrders.push({...t,place_order_type:"close"})}else{const r=this._pendingOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingOrders.push({...t,place_order_type:"close"})}}close_all(t){if(typeof t=="string"&&(t={}),!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close_all"}):this._pendingOrders.push({...t,place_order_type:"close_all"})}cancel({id:t}){this._pendingOrders=this._pendingOrders.filter(e=>!(e.id===t&&e.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(t=>t.place_order_type==="close_all")}exit(t,e){this._exit(t,e)}convert_to_account({value:t}){return t}convert_to_symbol({value:t}){return t}default_entry_qty({fill_price:t}){return t?this._calcDefaultQty(t):0}_calcDefaultQty(t){const{default_qty_type:e=Pe.fixed,default_qty_value:r=1,initial_capital:n,commission_value:s}=this._options;let a=r;switch(e){case Pe.cash:a=r/t;break;case Pe.percentOfEquity:const u=this._getOrderProfit(t),c=n+u+this._totalChangeCapital;s?a=this._getCommQty(c,t):a=c*r/100/t;break}return Ql(a,this._getLen(t))}_getCommQty(t,e){const{commission_type:r,commission_value:n=0,default_qty_value:s=0}=this._options;let a=0;switch(r){case je.percent:a=t*s/(100*e+n*e);break;case je.cashPerContract:a=t*s/(100*e+n);break;case je.cashPerOrder:a=(t-n)*s/100/e}return a}_getLen(t){const e=String(Math.floor(t)).length-3;return e<0?0:e}_getCapital(t,e){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&t===1?e=e*100/r:n<=100&&n>0&&t===-1&&(e=e*100/n),e}_calcProfitAndLoss(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:s}=e,a=s===fe.long?1:-1,u=(t-r)*a*n,[c,f]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,u,c,f)}}_calcProfitAndLossHandle(t,e,r,n){const{high:s,low:a}=this.calcOnOrderFillsData.data||this._variables,u=((n||s)-t)*e,c=((n||a)-t)*e;let f=r===1?u:-c,d=r===1?c:-u;return[f,d]}_calcOrderPercent(t,e,r,n){const{commission_value:s}=this._options,{close:a}=this.calcOnOrderFillsData.data||this._variables,{original_qty:u=0,qty:c=0,in_price:f,max_profit:d=0,trading_loss:h=0}=t;let{commission:_=0}=t,g=f*c;if(s){const y=this._getCommission(a,c);_=_*c/u,r-=_,n-=_,g+=_,e=e-y-_}r=Math.max(r,d,0),n=Math.min(n,h,0),Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/(this._options.initial_capital+this._totalChangeCapital)*100,max_profit:r,trading_loss:n,profit_percent:e/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{time:t}=this._variables,{high:e,low:r}=this.calcOnOrderFillsData.data||this._variables,{initial_capital:n,margin_long:s=0,margin_short:a=0}=this._options,u=this._orders[0].direction===fe.long?1:-1;let c=u===1?r:e;if(u===1&&s===100)return;const f=(u===1?s:a)/100;if(f<=0)return;let d=!1;const[h,_]=this._orders.reduce((w,v)=>{let[x,b]=w;const{in_price:C,qty:E=0,in_time:A}=v;A===t&&(d=!0);const N=C*E,S=c*E;return x+=N,b+=S,[x,b]},[0,0]);let g=0,y=0;const p=n+this._totalChangeCapital;if(d&&(g=p-h*f,g<0&&(c=this._orders[0].in_price,y=Math.abs(Math.trunc(g/f/c)*4),y=Math.max(y,1))),g>=0){const w=u*(_-h);if(g=p+w-_*f,g>=0)return;y=Math.abs(Math.trunc(g/f/c)*4)}y<=0||this._marginCallOrders(c,y,"Margin Call")}_marginCallOrders(t,e,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,t,e*this._orders.length,r,r,!0);return}for(const s of this.orders)s.position_close_type=s.place_order_type,s.isTiggerClose=!0,this._processOrder(s,t,e,r,r,!0);this._orders=this._orders.filter(s=>!s.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:s,quantities:a,close:u,price:c,activePrice:f,isTouch:d}=this._orderArgsParse(t),h=t.direction===fe.long?1:-1;if(a<=0)return;let _=a;if((s||d)&&e){const y=d?c:u;if(n.length){const E=this._processOrders(n,y,_,t.id,t.comment,!1,"order");if(E<=0)return;_=E}const p=y-h*r*this._mintick;if(!this._judgeCapitalEnough(_,p,h))return;this._ocaGroupVerify(_,t.oca_name,t.oca_type);const{bar_index:v,time:x}=this._variables,{high:b,low:C}=this.calcOnOrderFillsData.data||this._variables;this._calcCurrentOrder({...t,in_price:p,in_high:b,in_low:C,in_index:v,in_time:x,qty:_,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,h)&&this._addPendingOrders(t,c,_,s,f)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(d=>(d.direction===fe.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:s=0,margin_short:a=0}=this._options;if(s===0&&r===1||a===0&&r===-1)return!0;const u=this._getOrderProfit(e),f=this._getCapital(r,this._options.initial_capital+u+this._totalChangeCapital)-n;return t*e<=f}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:s=0,direction:a}=r,u=a===fe.long?1:-1;return e+(t-n)*s*u},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===fn.none)return!1;let n=!1;switch(r){case fn.cancel:this._pendingOrders=this._pendingOrders.filter(s=>{if(s.oca_name===e)s.isCancel=!0,n=!0;else return!0});break;case fn.reduce:this._pendingOrders=this._pendingOrders.filter(s=>{const{qty:a=0,oca_name:u}=s;if(e===u){const c=a-t;return n=!0,c<=0?(s.isCancel=!0,!1):(s.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,s,a=!1,u,c){let f=r;for(const d of t)if(d.position_close_type=u||d.place_order_type,d.immediately=c,d.isTiggerClose=a||d.position_close_type==="close",f=this._processOrder(d,e,f,n,s,a),f<=0)break;return this._orders=this._orders.filter(d=>!d.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),f}_addPendingOrders(t,e,r,n,s){const a=this._pendingOrders.find(u=>u.id===t.id&&!u.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else{const u={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,entry_time:this._variables.time,place_order_type:"order"};this._pendingOrders.push(u)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let s=t.limit||0;const{close:a}=this.calcOnOrderFillsData.data||this._variables;let u=a,c=!1,f;const d=e===fe.long?1:-1,h=n&&(n-a)*d>=0,{backtest_fill_limits_assumption:_=0}=this._options;_>0&&s&&(s-=_*this._mintick*d);const g=s&&(s-a)*d<=0;let y=!1;h&&g?(n!==a&&(f=n),u=s):h?(u=n,y=n===a):g?(u=s,y=s===a):c=!0;const p=r!==void 0?Ql(r,this._getLen(u)):this._calcDefaultQty(u);return{orders:this._orders.filter(v=>v.direction!==e),isMarketPrice:c,activePrice:f,quantities:p,close:a,price:u,isTouch:y}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:s,close:a,price:u,activePrice:c,isTouch:f}=this._orderArgsParse(t);if(s<=0)return;if((n||f)&&e){this._entryOrder(r,f?u:a,s,t);return}this._judgeCapitalEnough(s,a,t.direction===fe.long?1:-1)&&this._addPendingEntry(t,u,s,n,c)}_entryOrder(t,e,r,n){const{time:s,bar_index:a}=this._variables,{high:u,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:f=0}=this._options,{oca_name:d,oca_type:h,direction:_,comment:g,id:y}=n,p=_===fe.long?1:-1;if(r=this._getAvailablePositionSize(r,_),r<=0)return;const w=e;if(e=e+f*this._mintick*p,!this._judgeCapitalEnough(r,e,p))return;this._closeOrders(t,w,y,g,"entry",void 0,!0);const x={...n,in_price:e,qty:r,in_index:a,in_high:u,in_low:c,in_time:s,place_order_type:"entry"},{orders:b}=this._getEntryOrders(_),C=b.length;C&&C>=(this._options.pyramiding||1)||(this._ocaGroupVerify(r,d,h),this._calcCurrentOrder(x))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==fe.all&&n!==e)return 0;if(r===void 0)return t;const s=this._orders.reduce((a,u)=>a+(u.qty||0),0);return s?s+t>r?0:t:t>r?t-r:0}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===t),r=this._orders.filter(n=>n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,s){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:u}=this._getEntryOrders(t.direction),c=a.find(f=>f.id===t.id&&f.place_order_type==="entry");if(c)Object.assign(c,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else{const f={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,entry_time:this._variables.time,place_order_type:"entry"};this._pendingOrders.push(f)}}_closeAllOrders(t,e){const{comment:r,immediately:n}=t,{bar_index:s}=this._variables,a=this._orders.filter(u=>u.in_index!==s);a.length&&(this._closeOrders(a,e,"Close position order",r,"close",n),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n,s,a,u){for(const c of t)c.position_close_type=s,c.immediately=a,c.isTiggerClose=!0,this._closeOrder(c,e,r,n,u);this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n,s){const{time:a,bar_index:u}=this._variables,{high:c,low:f}=this.calcOnOrderFillsData.data||this._variables,{slippage:d=0}=this._options,{in_price:h,qty:_=0,direction:g}=t,y=g===fe.long?1:-1;e=e-y*d*this._mintick,t.isDeal=!0;const p=(e-h)*y*_,w={...t,out_price:e,out_id:r,out_index:u,out_high:c,out_low:f,out_time:a,out_comment:n,out_qty:_,profit:p};this._calcPercent(w,s)}_exitOrdersHandle(){if(!this._exitOrders.length)return;let{open:t,low:e,high:r,close:n}=this.calcOnOrderFillsData.data||this._variables;const s=[],a=Math.abs(r-t),u=Math.abs(e-t),c=[],f=this._variables.precision;t=Number(t.toFixed(f)),e=Number(e.toFixed(f)),r=Number(r.toFixed(f)),n=Number(n.toFixed(f));for(const d of this._exitOrders){const{directionNum:h,id:_,comment:g,qty:y,comment_loss:p,comment_profit:w,comment_trailing:v,order:x}=d;if(x.isTiggerClose)continue;let b=a<u||a===u&&h===1;const C=[],[E,A]=this._getLimitPrice(d,t,e,r,b);E&&C.push({order:x,price:E,index:A,isHighFront:b,exitInfo:{id:_,comment:w||g,qty:y}});const[N,S]=this._getStopPrice(d,t,e,r,b);N&&C.push({order:x,price:N,index:S,isHighFront:b,exitInfo:{id:_,comment:p||g,qty:y}});const[I,F]=this._getTrailStopPrice(d,t,e,r,n,b);if(I&&C.push({order:x,price:I,index:F,isHighFront:b,exitInfo:{id:_,comment:v||g,qty:y}}),C.length){this._executesSort(C),s.push(C[0]);continue}c.push(d)}this._exitOrders=c,this._executesSort(s);for(const d of s){const{order:h,price:_,exitInfo:g,isHighFront:y,index:p}=d;y?(r=p===1?_:r,e=p===1?t:_):(r=p===1?t:_,e=p===1?_:e),this._variables.strategy.update({open:_,high:r,low:e,close:n}),this._processExitOnClose(h,_,g)}}_executesSort(t){return t.sort(({price:e,index:r,isHighFront:n},{price:s,index:a})=>r!==a?r-a:n?r===1?e-s:s-e:r===1?s-e:e-s),t}_getLimitPrice(t,e,r,n,s){const{limit:a,directionNum:u}=t;let c,f=1;return a&&((e-a)*u>=0?(c=e,f=1):r<=a&&n>=a&&(c=a,s&&a>e||!s&&a<e?f=1:f=2)),[c,f]}_getStopPrice(t,e,r,n,s){const{stop:a,directionNum:u}=t;let c,f=1;return a&&((e-a)*u<=0?(c=e,f=1):r<=a&&n>=a&&(c=a,s&&a>e||!s&&a<e?f=1:f=2)),[c,f]}_getTrailStopPrice(t,e,r,n,s,a){const{trail_stop_price:u,directionNum:c,active_price:f,trail_offset:d=0}=t;let h=u,_,g=1;if(h)if((h-e)*c>=0)_=e,g=1;else{const[y,p,w]=this._calcTrailStopPrice(h,n,r,s,d,c,a);_=p,g=w||1,t.trail_stop_price=y}if(f&&!_&&f<=n&&f>=r)if(d===0)_=f,a&&f>e||!a&&f<e?g=1:g=2;else{h=bo(f,Ii(d*c,this._mintick));let y=n,p=r;a?f>=e&&f<=n?(y=n,g=1):(a=!1,y=s,g=2):f<e&&f>=r?(p=r,g=1):(a=!0,p=s,g=2);const[w,v,x=1]=this._calcTrailStopPrice(h,y,p,s,d,c,a);delete t.active_price,g<x&&(g=x),t.trail_stop_price=w,_=v}return[_,g]}_ordersHandle(t){const e=this._orders.filter(a=>a.isMarketPriceLimit||a.isMarketPriceStop);if(!e.length)return;const{open:r,close:n}=this.calcOnOrderFillsData.data||this._variables,s=t?n:r;for(const a of e){const{out_comment:u,out_qty:c,out_id:f}=a;this._processExitOnClose(a,s,{id:f,comment:u,qty:c})}}_calcTrailStopPrice(t,e,r,n,s,a,u){let c=t,f;const d=bo(a===1?e:r,Ii(s*a,this._mintick));let h=1;return a===1?u?(c<d&&(c=d),c>=r&&(h=2,f=c)):c>=r?(h=1,f=c):d>c&&(c=d,d>=n&&(h=3,f=d)):u?c<=e?(h=1,f=c):d<c&&(c=d,d<=n&&(h=3,f=d)):(d<c&&(c=d),c<=e&&(h=2,f=c)),[c,f,h]}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(r=>r.place_order_type==="exit");for(const r of this._pendingOrders){const{isCancel:n,place_order_type:s}=r;if(n)continue;let a;switch(s){case"entry":a=this._entryOrderHandle(r);break;case"order":a=this._orderOrderHandle(r);break;case"close":a=this._closeOrderHandle(r);break;case"close_all":const{open:u}=this.calcOnOrderFillsData.data||this._variables;this._closeAllOrders(r,u);break}a&&t.push(a)}for(const r of e){const n=this._exitOrderHandle(r);n&&t.push(n)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(r=>["close","close_all"].includes(r.place_order_type||"")),{close:e}=this.calcOnOrderFillsData.data||this._variables;this._pendingCloseOrders=[];for(const r of t)switch(r.place_order_type){case"close":const n=this._closeOrderHandle(r,!0);n&&this._pendingCloseOrders.push(n);break;case"close_all":this._closeAllOrders(r,e);break}this._ordersHandle(!0)}_entryOrderHandle(t){const{open:e,low:r,high:n}=this.calcOnOrderFillsData.data||this._variables,{isMarketPrice:s,qty:a=0,in_price:u,direction:c,active_price:f}=t;if(f&&n>=f&&r<=f)return delete t.active_price,t;let d=u;if(s&&(d=e),d<=n&&d>=r){const h=this._orders.filter(_=>_.direction!==c);this._entryOrder(h,d,a,t)}else return t}_orderOrderHandle(t){const{time:e,bar_index:r}=this._variables,{open:n,low:s,high:a}=this.calcOnOrderFillsData.data||this._variables,{slippage:u=0}=this._options,{isMarketPrice:c,qty:f=0,in_price:d,direction:h,comment:_,oca_name:g,oca_type:y,active_price:p,id:w}=t;if(p&&a>=p&&s<=p)return delete t.active_price,t;let v=d,x=f;if(c&&(v=n),v<=a&&v>=s){const b=this._orders.filter(E=>E.direction!==h);if(b.length&&(x=this._processOrders(b,v,f,w,_,!1,"order"),x<=0))return;const C=h===fe.long?1:-1;this._ocaGroupVerify(x,g,y),this._calcCurrentOrder({...t,in_price:v-C*u*this._mintick,in_index:r,in_time:e,in_high:a,in_low:s,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:s=100,comment:a,immediately:u}=t,{close_entries_rule:c="FIFO"}=this._options;let f=[];if(c==="FIFO"?f=this._orders.filter(g=>g.id===r):f=this._orders.filter(g=>g.id===r&&!g.close_qty),!f.length)return;let d=0;if(n?d=n:(d=f.reduce((g,y)=>g+(y.qty||0),d),d=s/100*d),d<=0)return;const{open:h,close:_}=this.calcOnOrderFillsData.data||this._variables;if(c==="FIFO")this._processOrders(f,e?_:h,d,`Close entry(s) order ${r}`,a,!1,"close",u);else if(this._processCloseOrders(f,e?_:h,d,`Close entry(s) order ${r}`,a,u))return t}_processCloseOrders(t,e,r,n,s,a){let u=!1;for(const c of t)c.close_qty=r,(c.qty||0)>r&&(u=!0),c.immediately=a,c.position_close_type="close",c.isTiggerClose=!0,this._processOrder(c,e,r,n,s);return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),u}_exitOrderHandle(t){const{from_entry:e}=t,r=this._orders.filter(n=>(!e||e===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,t,!0)))return t}_exit(t,e){if(!t.hasOwnProperty("profit")&&!t.hasOwnProperty("loss")&&!t.hasOwnProperty("stop")&&!t.hasOwnProperty("limit")&&(!t.hasOwnProperty("trail_offset")||!t.hasOwnProperty("trail_price")&&!t.hasOwnProperty("trail_points"))){this._errorListener.addError(ie.strategyExitErr,e,Rt.Error);return}const{profit:r,loss:n,stop:s,limit:a,trail_offset:u,trail_price:c,trail_points:f,from_entry:d="",id:h}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(s)&&this._isNaN(a)&&(this._isNaN(u)||this._isNaN(f)&&this._isNaN(c)))return;const _={...t,place_order_type:"exit"},g=this._orders.filter(v=>(!d||d===v.id)&&!v.hasExit),y=this._updateExitOrders(_),p=this._pendingOrders.filter(v=>(!d||d===v.id)&&["order","entry"].includes(v.place_order_type||""));if(g.length){if(!this._ordersToExit(g,_,!1))return}else if(!p.length||y)return;const w=this._pendingOrders.find(v=>v.id===h&&v.place_order_type==="exit");w?Object.assign(w,{...t}):this._pendingOrders.push(_)}_updateExitOrders(t){let e=!1;const r=this._exitOrders.filter(n=>n.id===t.id&&(n.from_entry===t.from_entry||!t.from_entry));for(const n of r){const{directionNum:s,order:a}=n;if(a.isTiggerClose){n.isClose=!0;continue}e=!0;const u={...t};if(this._stopProfit(a,s,u)){n.isClose=!0;continue}if(this._stopLoss(a,s,u)){n.isClose=!0;continue}if(this._trailStopLoss(a,s,u)){n.isClose=!0;continue}Object.assign(n,u)}return this._exitOrders=this._exitOrders.filter(n=>!n.isClose),e}_ordersToExit(t,e,r){const{qty:n,qty_percent:s=100,id:a,comment:u}=e;let c=n,f=!1;e.comment=u||a;const d=t[0],h={...e},{qty:_=0}=d,g=d.direction===fe.long?1:-1;return c=n?n>=_?_:n:s/100*_,h.qty=c,c<_&&(f=!0),this._stopProfit(d,g,h,r)||this._stopLoss(d,g,h,r)||this._trailStopLoss(d,g,h,r)||(this._exitOrders.push({...h,directionNum:g,order:d}),d.hasExit=!0),f}_addExitPendingCloseOrders(t){const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r,n){const{limit:s,profit:a,comment_profit:u,comment:c,id:f,qty:d}=r;let h=s;const{close:_}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:y}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(h=Oh(g,Ii(a*e,this._mintick))),r.limit=e===1?ec(h,this._variables.precision):rc(h,this._variables.precision),!n&&h!==void 0&&(h-_)*e<=0)return t.isMarketPriceLimit=!0,r.comment=u||c,Object.assign(t,{out_comment:r.comment,out_id:f,out_qty:d}),y&&this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r,n){const{stop:s,loss:a,comment_loss:u,comment:c,id:f,qty:d}=r;let h=s;const{close:_}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:y}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(h=bo(g,Ii(a*e,this._mintick))),r.stop=e===1?rc(h,this._variables.precision):ec(h,this._variables.precision),!n&&h!==void 0&&(h-_)*e>=0)return t.isMarketPriceStop=!0,r.comment=u||c,Object.assign(t,{out_comment:r.comment,out_id:f,out_qty:d}),y&&this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r,n){const{trail_offset:s,trail_price:a,trail_points:u,comment_trailing:c,comment:f,id:d,qty:h}=r;if(!this._isNaN(s)){const{close:_}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:y}=this._options;let p;if(this._isNaN(a)?this._isNaN(u)||(p=Oh(g,Ii(u*e,this._mintick))):p=a,r.active_price=p,n)return;if(p!==void 0&&(p-_)*e<=0){const w=bo(_,Ii(s*e,this._mintick));if((w-_)*e>=0)return t.isMarketPriceStop=!0,r.comment=c||f,Object.assign(t,{out_comment:r.comment,out_id:d,out_qty:h}),y&&this._addExitPendingCloseOrders(r),!0;r.trail_stop_price=w}}}_processExitOnClose(t,e,r){const{qty:n=0,comment:s,id:a}=r,{close_entries_rule:u="FIFO"}=this._options;if(n)if(t.isTiggerClose=!0,u==="FIFO")this._processExitOrders(this._orders,e,n,a,s);else{if(t.isDeal)return;this._processOrders([t],e,n,a,s,!1,"exit")}}_processExitOrders(t,e,r,n,s){let a=r,u;for(const c of t)if(u=c,c.position_close_type="exit",a=this._processOrder(c,e,a,n,s),a<=0)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),u}_processOrder(t,e,r,n,s,a=!1){const{time:u,bar_index:c}=this._variables,{low:f,high:d}=this.calcOnOrderFillsData.data||this._variables,{slippage:h=0}=this._options,{in_price:_,qty:g=0,max_profit:y,trading_loss:p,direction:w,commission:v=0,original_qty:x=0}=t,b=w===fe.long?1:-1;if(e=e-b*h*this._mintick,r<g){const C=g-r,E=(e-_)*b*r,A=y!==void 0?y/g*r:void 0,N=p!==void 0?p/g*r:void 0,S=v*C/x;this._calcPercent({...t,out_price:e,last_commission:S,out_id:n,out_index:c,out_high:d,out_low:f,out_time:u,out_comment:s,profit:E,out_qty:r,max_profit:A,trading_loss:N});const I=(e-_)*b*C-S;Object.assign(t,{qty:C,profit:I,max_profit:y!==void 0?y-(A||0):void 0,trading_loss:p!==void 0?p-(N||0):void 0,total_profit:this._totalChangeCapital+I}),r=0}else{t.isDeal=!0;const C=(e-_)*b*g;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_high:d,out_low:f,out_time:u,out_comment:s,out_qty:g,profit:C}),r-=g}return a&&(b===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t,e){const{commission_value:r,process_orders_on_close:n}=this._options,{in_price:s,out_qty:a=0,out_price:u=0,original_qty:c=0,direction:f,last_commission:d=0,immediately:h}=t;let{profit:_=0,max_profit:g,trading_loss:y,commission:p=0}=t,w=s*a,v=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=_,r){const E=this._getCommission(u,a);this._totalChangeCapital-=E;let A=p*a/c;w+=A,A+=E,_=_-A,Object.assign(t,{commission:A});const N=this._orders.reduce((S,I)=>{const{qty:F=0,original_qty:O=0,commission:L=0}=I;return S+L*F/O},0);v+=N-d}const x=f===fe.long?1:-1;let[b,C]=this._calcProfitAndLossHandle(s,a,x,u);if(r){const E=p*a/c;b-=E,C-=E}g=Math.max(b,g||0),y=Math.min(C,y||0),_=parseFloat(String(_)),Object.assign(t,{max_profit:g,profit:_,trading_loss:y,total_profit:this._totalChangeCapital,total_profit_percent:_/v*100,profit_percent:_/w*100,max_profit_percent:g/w*100,trading_loss_percent:y/w*100}),this._maxDrawdownVerifyIndex=this._variables.bar_index+(n?1:0),this._risk.intradayOrders+=1,this._historyOrder.push(t),!e&&this._calcOrderFillsHandle(u,f,h)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:s=0,trading_loss:a=0,direction:u,immediately:c}=t;let{profit:f=0}=t,d=r*n;const h=this._totalChangeCapital+this._options.initial_capital;if(e){const _=this._getCommission(r,n);this._totalChangeCapital-=_,f=f-_,d+=_,Object.assign(t,{commission:_,total_profit:this._totalChangeCapital})}f=parseFloat(String(f)),Object.assign(t,{original_qty:n,profit:f,total_profit_percent:f/h*100,profit_percent:f/d*100,max_profit_percent:s/d*100,trading_loss_percent:a/d*100,stop:void 0,limit:void 0}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder),this._calcOrderFillsHandle(r,u,c)}_calcOrderFillsHandle(t,e,r=!1){const{calc_on_order_fills:n,process_orders_on_close:s,slippage:a=0}=this._options;if(n){const{open:u,high:c,low:f,close:d}=this._variables,h=e===fe.long?1:-1,_=d-h*a*this._mintick;if((r||s)&&t===_)return;const g=u-h*a*this._mintick;let y={open:u,high:c,low:f,close:d},p=this.calcOnOrderFillsData.index;const w=Math.abs(c-u)<=Math.abs(f-u);switch(p){case-1:t===g?p=0:t>g?w?(p=1,y={open:c,high:c,low:f,close:d}):(p=2,y={open:c,high:c,low:d,close:d}):w?(p=2,y={open:f,high:d,low:f,close:d}):(p=1,y={open:f,high:c,low:f,close:d});break;case 0:t===g?(p=1,w?y={open:c,high:c,low:f,close:d}:y={open:f,high:c,low:f,close:d}):t>g?w?(p=1,y={open:c,high:c,low:f,close:d}):(p=2,y={open:c,high:c,low:d,close:d}):w?(p=2,y={open:f,high:d,low:f,close:d}):(p=1,y={open:f,high:c,low:f,close:d});break;case 1:p=2,w?y={open:f,high:d,low:f,close:d}:y={open:c,high:c,low:d,close:d};break;case 2:p=-1,y=void 0;break}this.calcOnOrderFillsData={tradeData:y,index:p}}}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}};var Bh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){return function(e,r,n){r.prototype.isBetween=function(s,a,u,c){var f=n(s),d=n(a),h=(c=c||"()")[0]==="(",_=c[1]===")";return(h?this.isAfter(f,u):!this.isBefore(f,u))&&(_?this.isBefore(d,u):!this.isAfter(d,u))||(h?this.isBefore(f,u):!this.isAfter(f,u))&&(_?this.isAfter(d,u):!this.isBefore(d,u))}}})})(Bh);var Gw=Bh.exports,Jw=Kt(Gw),Th={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){return function(e,r,n){var s=r.prototype,a=function(_){var g,y=_.date,p=_.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||s.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=p?n.utc():n();Object.keys(y).forEach(function(I){var F,O;w[F=I,O=s.$utils().p(F),O==="date"?"day":O]=y[I]});var x=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),C=w.month>=0?w.month:w.year||w.day?0:v.month(),E=w.hour||0,A=w.minute||0,N=w.second||0,S=w.millisecond||0;return p?new Date(Date.UTC(b,C,x,E,A,N,S)):new Date(b,C,x,E,A,N,S)}return y},u=s.parse;s.parse=function(_){_.date=a.bind(this)(_),u.bind(this)(_)};var c=s.set,f=s.add,d=s.subtract,h=function(_,g,y,p){p===void 0&&(p=1);var w=Object.keys(g),v=this;return w.forEach(function(x){v=_.bind(v)(g[x]*p,x)}),v};s.set=function(_,g){return g=g===void 0?_:g,_.constructor.name==="Object"?h.bind(this)(function(y,p){return c.bind(this)(p,y)},g,_):c.bind(this)(_,g)},s.add=function(_,g){return _.constructor.name==="Object"?h.bind(this)(f,_,g):f.bind(this)(_,g)},s.subtract=function(_,g){return _.constructor.name==="Object"?h.bind(this)(f,_,g,-1):d.bind(this)(_,g)}}})})(Th);var Xw=Th.exports,Qw=Kt(Xw),Ih={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Vt,function(){var e,r,n=1e3,s=6e4,a=36e5,u=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=31536e6,d=2628e6,h=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,_={years:f,months:d,days:u,hours:a,minutes:s,seconds:n,milliseconds:1,weeks:6048e5},g=function(A){return A instanceof C},y=function(A,N,S){return new C(A,S,N.$l)},p=function(A){return r.p(A)+"s"},w=function(A){return A<0},v=function(A){return w(A)?Math.ceil(A):Math.floor(A)},x=function(A){return Math.abs(A)},b=function(A,N){return A?w(A)?{negative:!0,format:""+x(A)+N}:{negative:!1,format:""+A+N}:{negative:!1,format:""}},C=function(){function A(S,I,F){var O=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),I)return y(S*_[p(I)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(q){O.$d[p(q)]=S[q]}),this.calMilliseconds(),this;if(typeof S=="string"){var L=S.match(h);if(L){var z=L.slice(2).map(function(q){return q!=null?Number(q):0});return this.$d.years=z[0],this.$d.months=z[1],this.$d.weeks=z[2],this.$d.days=z[3],this.$d.hours=z[4],this.$d.minutes=z[5],this.$d.seconds=z[6],this.calMilliseconds(),this}}return this}var N=A.prototype;return N.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(I,F){return I+(S.$d[F]||0)*_[F]},0)},N.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/f),S%=f,this.$d.months=v(S/d),S%=d,this.$d.days=v(S/u),S%=u,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/s),S%=s,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},N.toISOString=function(){var S=b(this.$d.years,"Y"),I=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var O=b(F,"D"),L=b(this.$d.hours,"H"),z=b(this.$d.minutes,"M"),q=this.$d.seconds||0;this.$d.milliseconds&&(q+=this.$d.milliseconds/1e3,q=Math.round(1e3*q)/1e3);var W=b(q,"S"),R=S.negative||I.negative||O.negative||L.negative||z.negative||W.negative,Z=L.format||z.format||W.format?"T":"",Y=(R?"-":"")+"P"+S.format+I.format+O.format+Z+L.format+z.format+W.format;return Y==="P"||Y==="-P"?"P0D":Y},N.toJSON=function(){return this.toISOString()},N.format=function(S){var I=S||"YYYY-MM-DDTHH:mm:ss",F={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return I.replace(c,function(O,L){return L||String(F[O])})},N.as=function(S){return this.$ms/_[p(S)]},N.get=function(S){var I=this.$ms,F=p(S);return F==="milliseconds"?I%=1e3:I=F==="weeks"?v(I/_[F]):this.$d[F],I||0},N.add=function(S,I,F){var O;return O=I?S*_[p(I)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+O*(F?-1:1),this)},N.subtract=function(S,I){return this.add(S,I,!0)},N.locale=function(S){var I=this.clone();return I.$l=S,I},N.clone=function(){return y(this.$ms,this)},N.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},N.valueOf=function(){return this.asMilliseconds()},N.milliseconds=function(){return this.get("milliseconds")},N.asMilliseconds=function(){return this.as("milliseconds")},N.seconds=function(){return this.get("seconds")},N.asSeconds=function(){return this.as("seconds")},N.minutes=function(){return this.get("minutes")},N.asMinutes=function(){return this.as("minutes")},N.hours=function(){return this.get("hours")},N.asHours=function(){return this.as("hours")},N.days=function(){return this.get("days")},N.asDays=function(){return this.as("days")},N.weeks=function(){return this.get("weeks")},N.asWeeks=function(){return this.as("weeks")},N.months=function(){return this.get("months")},N.asMonths=function(){return this.as("months")},N.years=function(){return this.get("years")},N.asYears=function(){return this.as("years")},A}(),E=function(A,N,S){return A.add(N.years()*S,"y").add(N.months()*S,"M").add(N.days()*S,"d").add(N.hours()*S,"h").add(N.minutes()*S,"m").add(N.seconds()*S,"s").add(N.milliseconds()*S,"ms")};return function(A,N,S){e=S,r=S().$utils(),S.duration=function(O,L){var z=S.locale();return y(O,{$l:z},L)},S.isDuration=g;var I=N.prototype.add,F=N.prototype.subtract;N.prototype.add=function(O,L){return g(O)?E(this,O,1):I.bind(this)(O,L)},N.prototype.subtract=function(O,L){return g(O)?E(this,O,-1):F.bind(this)(O,L)}}})})(Ih);var tD=Ih.exports,eD=Kt(tD);Wt.extend(xa),Wt.extend(Ea),Wt.extend(Jw),Wt.extend(Qw),Wt.extend(eD);class $h{constructor(t,e,r){$(this,"array");$(this,"color");$(this,"math");$(this,"str");$(this,"map");$(this,"matrix");$(this,"timeframe");$(this,"ta");$(this,"input");$(this,"_variables");$(this,"_cacheData");$(this,"_options");$(this,"_errorListener");$(this,"_plots");$(this,"_plotshapes");$(this,"_plotbars");$(this,"_plotchars");$(this,"_plotarrows");$(this,"_plotcandles");$(this,"_alerts");$(this,"_bgColors");$(this,"_hlines");$(this,"_fills");$(this,"chart");$(this,"line");$(this,"label");$(this,"polyline");$(this,"box");$(this,"table");$(this,"linefill");$(this,"log");$(this,"runtime");$(this,"strategy");$(this,"request");$(this,"syminfo");$(this,"_count",0);var s;const n=((s=t.toString().split(".")[1])==null?void 0:s.length)||5;this._variables=e,this._errorListener=new aD,this.array=new I_(this._errorListener),this.math=new $_(n,this._errorListener),this.color=new oy,this.str=new lw(this._errorListener,n),this.map=new cw(this._errorListener),this.timeframe=new ow(e),this.matrix=new sw(this._errorListener),this.ta=new iy(e,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new sy(e,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new fw(e)},this.line=new Iw(e,this._errorListener),this.label=new hw(e,this._errorListener),this.polyline=new Tw(e,this._errorListener),this.box=new Lw(e,this._errorListener),this.table=new Rw(e,this._errorListener),this.linefill=new $w(e),this.log=new sD(e,this.str),this.runtime=new oD(this._errorListener),this.strategy=new Kw(this._variables,this._options,t,this._errorListener,r),this.request=new nD(this._variables,r),this.syminfo=new iD}get errors(){return this._errorListener.errors}get scriptType(){return this._options.scriptType}options(t){if(t.length)return this._getDataOfBarindex(t);const e=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let s;if(n.length){s={};for(const v of n)s[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,u=this._fills.size?[...this._fills.values()]:void 0,c=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders,strategySummary:this._variables.strategy.summaryData});const f=this._plots.size>0?[...this._plots.values()]:void 0,d=this._plotbars.size>0?[...this._plotbars.values()]:void 0,h=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,_=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,y=this._plotchars.size>0?[...this._plotchars.values()]:void 0,p=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:f,draws:p,alerts:r,colors:s,hlines:a,fills:u,logs:c,plotshapes:h,plotarrows:_,plotcandles:g,plotchars:y,plotbars:d,isUseBgColor:w})}_getDataOfBarindex(t){const e=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const v of r)n[v]=[...this._bgColors[v].values()].map(x=>{const b=[];for(const C of t){const E=x.data[C];E&&b.push(E)}return x.data=b,x})}const s=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,u=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._getDataFromBarindex(t,[...this._plots.values()]),f=this._plotbars.size>0?this._getDataFromBarindex(t,[...this._plotbars.values()]):void 0,d=this._plotarrows.size>0?this._getDataFromBarindex(t,[...this._plotarrows.values()]):void 0,h=this._plotcandles.size>0?this._getDataFromBarindex(t,[...this._plotcandles.values()]):void 0,_=this._plotchars.size>0?this._getDataFromBarindex(t,[...this._plotchars.values()]):void 0,g=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,y=this._getDrawsFromBarindex(t),p=this._getDrawDeletes(t),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,plotarrows:d,plotcandles:h,plotchars:_,plotbars:f,draws:y,drawDeletes:p,alerts:e,colors:n,hlines:s,fills:a,logs:u,plotshapes:g,isUseBgColor:w})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const s of t){const a=r.data[s];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:s,label:a}=this._variables,u={};return t.data.length&&(u.lines=t.data),e.data.length&&(u.linefills=e.data),r.data.length&&(u.tables=r.data),n.data.length&&(u.boxes=n.data),s.data.length&&(u.polylines=s.data),a.data.length&&(u.labels=a.data),Object.keys(u).length?u:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:s,polyline:a,label:u}=this._variables,c={};return e.data.length&&(c.lines=e.getValOfBarIndex(t)),r.data.length&&(c.linefills=r.getValOfBarIndex(t)),n.data.length&&(c.tables=n.getValOfBarIndex(t)),s.data.length&&(c.boxes=s.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),u.data.length&&(c.labels=u.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}_getDrawDeletes(t){const{line:e,linefill:r,table:n,box:s,polyline:a,label:u}=this._variables,c={},f=e.getDeleteIds(t),d=r.getDeleteIds(t),h=n.getDeleteIds(t),_=s.getDeleteIds(t),g=a.getDeleteIds(t),y=u.getDeleteIds(t);return f.length&&(c.lines=f),d.length&&(c.linefills=d),h.length&&(c.tables=h),_.length&&(c.boxes=_),g.length&&(c.polylines=g),y.length&&(c.labels=y),c}updateOptions(t){var n;const{inputs:e,strategy:r}=t;this.input.update(e),r&&((n=this.strategy)==null||n.updateOptions(r))}update(t){const{barIndex:e}=t;this.strategy.update(),this.math.update(e)}endExecution(){this.strategy.endExecution()}library(t,e){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=t;r.test(n)?(T_.includes(n)||B_.includes(n))&&this._errorListener.addError(He(ie.libraryTitleIsKeywordErr,{name:n}),e,Rt.Error):this._errorListener.addError(ie.libraryTitleErr,e,Rt.Error),this._options.scriptType="library",this._options.library=t}}indicator(t,e){if(!this._variables.bar_index){const{format:r}=t;this._paramVerfiy(r,e,"indicator",[Gt.inherit,Gt.percent,Gt.price,Gt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,s="format"){t&&!n.includes(t)&&this._errorListener.addError(He(ie.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Rt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(S_.lineWidthWarning,e,Rt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];ve(t,r);const{series:n,color:s,...a}=t,{bar_index:u,time:c}=this._variables,f=`plot_${e}`,d=this._plots.get(f),h=(d==null?void 0:d.data)||[],_=n!==void 0&&isNaN(n)?void 0:n;if(h[u]={value:[c,_],barIndex:u,itemStyle:{color:s}},this._seriesColorHandle(t,r,d),!d){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Gt.percent,Gt.price,Gt.volume]);const g=s?[s]:void 0;this._plots.set(f,{editable:!0,...a,colors:g,data:h,id:f,zIndex:this._count})}return{type:"plot",offset:t.offset||0,key:f}}plotbar(t,e){const r=["color"];ve(t,r);const{open:n,close:s,low:a,high:u,color:c,...f}=t,{bar_index:d,time:h}=this._variables,_=`plotbar_${e}`,g=this._plotbars.get(_),y=(g==null?void 0:g.data)||[],p=s!==void 0&&isNaN(s)?void 0:s,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=u!==void 0&&isNaN(u)?void 0:u,b=[h,w,p,v,x];if(y[d]={value:b,barIndex:d,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Gt.percent,Gt.price,Gt.volume]);const C=c?[c]:void 0;this._plotbars.set(_,{editable:!0,...f,colors:C,data:y,id:_,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:s,location:a,style:u}=t;this._paramVerfiy(u,r,e,Object.values(lr),"style"),this._paramVerfiy(a,r,e,Object.values(cn),"location"),this._paramVerfiy(n,r,e,Object.values(ir),"size"),this._paramVerfiy(s,r,e,[Gt.percent,Gt.price,Gt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];ve(t,r);const{series:n,color:s,textcolor:a,location:u=cn.abovebar,...c}=t,{bar_index:f,time:d,high:h,low:_}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),p=(y==null?void 0:y.data)||[],w={value:[d,n],barIndex:f,itemStyle:{color:s,textcolor:a},low:_,high:h};p[f]=w,this._seriesColorHandle(t,r,y),y||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:u,data:p,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];ve(t,r);const{series:n,colorup:s,colordown:a,...u}=t,{bar_index:c,time:f,low:d,high:h}=this._variables,_=`plotarrow_${e}`,g=this._plotarrows.get(_),y=(g==null?void 0:g.data)||[];y[c]={value:[f,n!==void 0&&isNaN(n)?void 0:n],barIndex:c,itemStyle:{colorup:s,colordown:a},low:d,high:h},this._seriesColorHandle(t,r,g),g||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Gt.percent,Gt.price,Gt.volume]),this._plotarrows.set(_,{editable:!0,...u,data:y,id:_,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];ve(t,r);const{series:n,color:s,textcolor:a,location:u=cn.abovebar,...c}=t,{bar_index:f,time:d,low:h,high:_}=this._variables,g=`plotshape_${e}`,y=this._plotshapes.get(g),p=(y==null?void 0:y.data)||[],w={value:n,barIndex:f,color:s,textcolor:a,time:d,low:h,high:_};if(p[f]=w,this._seriesColorHandle(t,r,y),!y){this._count++;const v=s?[s]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:p,location:u,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];ve(t,r);const{wickcolor:n,bordercolor:s,color:a,close:u,open:c,low:f,high:d,...h}=t,{bar_index:_,time:g}=this._variables,y=`plotcandle_${e}`,p=this._plotcandles.get(y),w=(p==null?void 0:p.data)||[],v=u!==void 0&&isNaN(u)?void 0:u,x=c!==void 0&&isNaN(c)?void 0:c,b=f!==void 0&&isNaN(f)?void 0:f,C=d!==void 0&&isNaN(d)?void 0:d,E=[g,x,v,b,C];w[_]={value:E,barIndex:_,wickcolor:n,bordercolor:s,color:a},this._seriesColorHandle(t,r,p),p||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Gt.percent,Gt.price,Gt.volume]),this._plotcandles.set(y,{editable:!0,...h,data:w,id:y,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;ve(t,["color"]),this._verifyDisplay(t.display,"hline",e);const s=t.display&&!t.display.length?Ze.none:Ze.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:s,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,I,F,O,L,z,q,W;const r=["color","top_color","bottom_color"];ve(t,r);const{color:n,top_color:s,bottom_color:a,seriesColors:u,hline1:c,hline2:f,plot1:d,plot2:h,top_value:_,bottom_value:g,...y}=t,{bar_index:p,time:w}=this._variables,v=`fill_${e}`,x=this._fills.get(v),b=(x==null?void 0:x.data)||[];this._verifyDisplay(t.display,"fill",e);const C=t.display&&!t.display.length?Ze.none:Ze.all;let E,A,N="plot";if(c&&f)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,A=(I=this._hlines.get(f==null?void 0:f.key))==null?void 0:I.price,N="hline";else{const R=this._plots.get(d==null?void 0:d.key),Z=this._plots.get(h==null?void 0:h.key),Y=(R==null?void 0:R.data)||[],G=(Z==null?void 0:Z.data)||[];E=(O=(F=Y[p])==null?void 0:F.value)==null?void 0:O[1],A=(z=(L=G[p])==null?void 0:L.value)==null?void 0:z[1]}if(b[p]={time:w,color:n,top_color:s,bottom_color:a,plot1:E,plot2:A,top_value:_,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const R=((q=this._options.indicator)==null?void 0:q.explicit_plot_zorder)||((W=this._options.strategy)==null?void 0:W.explicit_plot_zorder),Z=n?[n]:void 0,Y=s?[s]:void 0,G=a?[a]:void 0;this._fills.set(v,{id:v,colors:Z,top_colors:Y,bottom_colors:G,display:C,data:b,type:N,editable:!0,fillgaps:!1,hline1:c,hline2:f,plot1:d,plot2:h,...y,zIndex:R?this._count:void 0})}}alert({message:t,freq:e=jr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:s,last_bar_index:a}=this._variables,u=`alert_${r}`,c=this._cacheData[u]||{},f=c.barIndex;if(this._paramVerfiy(e,r,"alert",[jr.freqAll,jr.freqOncePerBar,jr.freqOncePerBarClose]),e===jr.freqOncePerBar&&n===f){this._alerts.delete(u);return}this._cacheData[u]=c;const d={message:t,freq:e,id:u,type:"alert"};if(s){e!==jr.freqOncePerBarClose&&this._alerts.set(u,d),c.barIndex=n;return}if(!s&&e===jr.freqOncePerBarClose&&n===f&&a===n-1){this._alerts.set(u,d),c.barIndex=n;return}this._alerts.delete(u)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:s}=this._variables,a=`alertcondition_${n}`;s&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t,e){this._setColors(t,"barcolor",e)}bgcolor(t,e){this._setColors(t,"bgcolor",e)}_verifyDisplay(t=Eh.all,e,r){t.length&&t.length<4&&this._errorListener.addError(He(ie.displayErr,{func:e,values:"[display.none, display.all]"}),r,Rt.Error)}_setColors(t,e,r){ve(t,["color"]);const{color:s,...a}=t;this._verifyDisplay(a.display,e,r);const u=t.display&&!t.display.length?Ze.none:Ze.all,{bar_index:c,time:f}=this._variables,d=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const h=this._bgColors[e].get(d),_=(h==null?void 0:h.data)||[],g=(h==null?void 0:h.setColors)||[];s&&!g.includes(s)&&g.push(s),_[c]={color:s,time:f,barIndex:c},h||this._bgColors[e].set(d,{...a,display:u,data:_,setColors:g,id:d})}max_bars_back({var:t,num:e,var_name:r}){console.log(t,e,r)}float({x:t}){return t}bool({x:t}){return t||!1}string({x:t}){return t}int({x:t}){return t&&Math.trunc(t)}na({x:t}){return!!(t===void 0||typeof t=="number"&&isNaN(t))}fixnan({source:t},e){return t===void 0||typeof t=="number"&&isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!(typeof t=="number"&&isNaN(t))?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n,!0)}timestamp(t){const{dateString:e,timezone:r,year:n,month:s,day:a,hour:u=0,minute:c=0,second:f=0}=t;if(e)return Wt(e).utc(!/GMT|UTC/.test(e)).valueOf();let d=s-1,h=n;if(d<0){const _=Math.ceil(Math.abs(d/12));d=12*_+d,h=n-_}return mr({year:h,month:d,day:a,hour:u,minute:c,second:f},r).valueOf()}weekofyear({time:t,timezone:e}){return mr(t,e).week()}year({time:t,timezone:e}){return mr(t,e).year()}second({time:t,timezone:e}){return mr(t,e).second()}month({time:t,timezone:e}){return mr(t,e).month()+1}minute({time:t,timezone:e}){return mr(t,e).minute()}hour({time:t,timezone:e}){return mr(t,e).hour()}dayofweek({time:t,timezone:e}){return mr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return mr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,this._variables.timeframe.period),n=gr(e,t)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,s,a=0,u=!1){const c=r||this._variables.__period,f=gr(c,t),d=gr(this._variables.__period,t);let h;if(f<=d)h=t,u&&(h+=d*1e3);else{const _=`time_${e}`,g=this._cacheData[_];if(g)g.currentTime+f*1e3-g.offset<=t?(h=t,this._cacheData[_]={currentTime:t,offset:0}):h=g.currentTime;else{const y=this._calcTimeOffset(t,c);this._cacheData[_]={currentTime:t,offset:y},h=t}u&&(h+=f*1e3)}if(n&&n!==Mn.regular&&n!==Mn.extended){const{timePeriods:_,weeks:g}=this._parserSession(n,e),y=mr(t,s),p=y.format("YYYY-MM-DD HH:mm"),w=y.format("YYYY-MM-DD"),v=h,x=mr(h,s).format("YYYY-MM-DD HH:mm");h=void 0;for(const C of _){const[E,A]=C;let N;if(E===A&&(N=y.add(1,"day").format("YYYY-MM-DD")),Wt(p).isBetween(`${w} ${E}`,`${N||w} ${A}`,"hour","[)")){Wt(x).isBetween(`${w} ${E}`,`${N||w} ${A}`,"hour","[)")?h=v:h=mr(`${w} ${E}`,s).valueOf();break}}const b=this._variables.dayofweek;h&&!g.includes(b)&&(h=void 0)}return h&&h-a*d*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const s of e){if((n=r.gradientColorKeys)!=null&&n.includes(s))continue;const a=t[s];if(!a)continue;const u=r[`${s}s`]||[];u.includes(a)||(u.push(a),r[`${s}s`]=u,u.length>5&&(r[`${s}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(s)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const f=parseInt(c,10);if(f<1||f>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,Rt.Error);return}return f});return{timePeriods:n.split(",").map(c=>{c===""||c===Mn.regular?c="0930-1500":c===Mn.extended&&(c="1500-1830");const f=c.split("-");return f.length!==2?[]:[this._processTime(f[0],e),this._processTime(f[1],e)]}),weeks:a}}_processTime(t,e){const r=parseInt(t.slice(0,2),10),n=parseInt(t.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",e,Rt.Error);return}return`${r}:${n}`}}const rD={1:"1M",3:"3M",5:"5M",15:"15M",30:"30M",45:"45M",60:"1H",120:"2H",180:"3H",240:"4H",D:"1D",W:"1W",M:"1MTH","3M":"3MTH","6M":"6MTH","12M":"12MTH"};let nD=class{constructor(t,e){$(this,"_variables");$(this,"_scriptId");$(this,"_cacheData");this._variables=t,this._scriptId=e,this._cacheData=new Map}security(t,e){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=t,s=this._getRequestData(t,e);if(r!=null&&r.has(e)){if(!s)return;const c=r.get(e);return this._runScripts(c,e,!1,n,s)}const a=this._parseExprCode(t),u=this._runScripts(a,e,!0,n,s);return r==null||r.set(e,a),u}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],s=1;e=Xl(e);const a=JSON.parse(e),u=a.pop();let c=(u==null?void 0:u.memberCodes)||{},f=(u==null?void 0:u.depends)||[];if(!f.length)return`return ${u==null?void 0:u.code}`;let d=[],h=[];const _=[];if(this._getDependCodes(f,a,n,d,h,_),n.push(..._),h.length){const p=r.length;let w=[];for(let v=p-1;v>=0;v--){const x=r[v];let b=JSON.parse(Xl(x));const C=[];s!==0&&h.length&&(w.unshift("{"),s++),b=b.map(S=>{const{scope:I,code:F,varNames:O,dependSelf:L}=S;return I===2&&!C.includes(O)&&!L&&(S.code=`let ${F}`),O&&C.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],A=[];let N=h.map(S=>({...S,isArg:!1,isPreArg:!0}));h=[],this._getDependCodes(N,b,A,d,h,E),w.unshift(...A,...E),n=w.concat(n),w=[]}}for(n.push(`return ${u==null?void 0:u.code}`);s>1;)n.push("}"),s--;n=d.concat(n);let g=n.join(`
|
63
63
|
`);const y=[];for(const p of Object.keys(c))g.includes(`$_var.getCacheData("${p}"`)&&y.push(c[p]);return y.length&&(g=`${y.join(`
|
64
64
|
`)}
|
65
|
-
${g}`),g}_getRequestData(t,e){var C,E,A,N,S;let{symbol:r,timeframe:n,calc_bars_count:s,gaps:a,lookahead:u,ignore_invalid_symbol:c}=t;const{__period:f,syminfo:{ticker:d,tickerid:h},mintick:_,time:g,nextBarTime:y}=this._variables;if(n=nc(n),(f===n||n==="")&&(r===d||r===h)){const{close:I,open:F,high:O,low:L,bar_index:z,last_bar_index:q,last_bar_time:W,_isRealTimeBar:P,volume:Z,time:Y,time_tradingday:G}=this._variables;return{barIndex:z,c:I,o:F,h:O,l:L,volume:Z,lastBarIndex:q,lastBarTime:W/1e3,nextBarTime:y,isrealtime:P,time_tradingday:G,time:Y/1e3,interval:f,mintick:_}}const p=`${r}--${n||f}`,w=self.workerStorage.get(`request_${this._scriptId}_data`),v=self.workerStorage.get(`request_${this._scriptId}_list`),x=self.workerStorage.get(`request_${this._scriptId}_tmp`),b={id:p,calc_bars_count:s,ignore_invalid_symbol:c,symbol:r,timeframe:rD[n||f]||n};if(w!=null&&w.has(p)){let I=gr(n,g)*1e3;const F=gr(f,g)*1e3;x==null||x.delete(p),e=`${e}_${p}`;const{index:O=0,periodStamp:L=F}=this._cacheData.get(e)||{},z=w==null?void 0:w.get(p);if(!z.length)return;const q=z.slice(O);let W=g,P=L+W;const Z=z.length-1;if(Z<0)return;const Y={lastBarIndex:z[Z].barindex||Z,lastBarTime:z[Z].time,interval:n,mintick:_};if(I>L){let G;if(u===ln.lookaheadOn?G=this._lookaheadOnHandle(q,n,P,I,Y,O,L,e,W,a):G=this._lookaheadOffHandle(q,n,P,I,Y,O,L,e,W,y||P,a),G)return G;if(G===null)return}else if(u===ln.lookaheadOn)for(const[G,X]of q.entries()){let{time:ut,barindex:_t}=X;ut=ut*1e3;const at=((C=q[G+1])==null?void 0:C.time)*1e3||ut+I;let vt=O+G;if(ut>=P){this._cacheData.set(e,{index:vt,periodStamp:L});return}if(ut<=W&&at>W){const wt=O+G;return this._cacheData.set(e,{index:wt,periodStamp:L}),{...X,barIndex:_t||wt,nextBarTime:(E=q[G+1])==null?void 0:E.time,...Y}}}else for(const[G,X]of q.entries()){let{time:ut,barindex:_t}=X;ut=ut*1e3;const at=((A=q[G+1])==null?void 0:A.time)*1e3||ut+I;let vt=O+G;if(ut>P){this._cacheData.set(e,{index:vt,periodStamp:L});return}if(ut<=P&&P<at)return this._cacheData.set(e,{index:vt,periodStamp:L}),{...X,barIndex:_t||vt,nextBarTime:(N=q[G+1])==null?void 0:N.time,...Y};if(ut>=W&&ut<=P&&(_t||vt)===Y.lastBarIndex)return this._cacheData.set(e,{index:vt,periodStamp:L}),{...X,barIndex:_t||vt,nextBarTime:(S=q[G+1])==null?void 0:S.time,...Y}}this._cacheData.set(e,{index:z.length,periodStamp:L})}else(v==null?void 0:v.get(p))||x==null||x.set(p,b);v==null||v.set(p,b)}_lookaheadOnHandle(t,e,r,n,s,a,u,c,f,d){var h;for(const[_,g]of t.entries()){let{time:y,barindex:p}=g;y=y*1e3,e.includes("M")&&(n=gr(e,y)*1e3-(Wt(y).date()-1)*864e5);const w=y,v=n+w;let x=a+_;if(r<=w)return this._cacheData.set(c,{index:x,periodStamp:u}),null;let b={...g,barIndex:p||x,nextBarTime:(h=t[_+1])==null?void 0:h.time,...s};if(d===ln.gapsOn){if(r>w&&f<=w)return this._cacheData.set(c,{index:x,periodStamp:u}),b}else{if(r>v)continue;if(r>w)return this._cacheData.set(c,{index:x,periodStamp:u}),b}}}_lookaheadOffHandle(t,e,r,n,s,a,u,c,f,d,h){var _,g;for(const[y,p]of t.entries()){let{time:w,barindex:v}=p;w=w*1e3,e.includes("M")&&(n=gr(e,w)*1e3-(Wt(w).date()-1)*864e5);const x=w,b=n+x,C=a+y;if(r<x)return this._cacheData.set(c,{index:C,periodStamp:u}),null;const E={...p,barIndex:v||C,nextBarTime:(_=t[y+1])==null?void 0:_.time,...s};if(r>=b&&f<b||r<b&&d>=b)return h===ln.gapsOn?(this._cacheData.set(c,{index:C,periodStamp:u}),E):(this._cacheData.set(c,{index:C,data:E,periodStamp:u}),E);if(!(f>b)&&f>=x){let A=(g=this._cacheData.get(c))==null?void 0:g.data;if(!A){const N=t[C-1];if(!N)return null;A={...N,barIndex:N.barindex||C-1,nextBarTime:E.time,...s},this._cacheData.set(c,{index:C,data:A,periodStamp:u})}return A}}}_getDependCodes(t,e,r,n,s,a){for(const u of t){if(!u.isArg){const c=e.filter(d=>{var h;return(h=d==null?void 0:d.depends)==null?void 0:h.some(_=>_.name===u.name&&_.scope===u.scope&&_.isAgainAssign)});for(const d of c){const{code:h,depends:_}=d;if(!r.includes(h)&&(r.unshift(h),_!=null&&_.length)){for(const g of _)g.memberCode&&a.push(g.memberCode);this._getDependCodes(_,e,r,n,s,a)}}const f=e.find(d=>{var h;return((h=d.varNames)==null?void 0:h.split(", ").includes(u.name))&&(!u.isPreArg||u.isPreArg&&d.methodName===u.functionName)||d.funcName===u.name});if(f){const{code:d,depends:h}=f,_=r.findIndex(g=>g===d);if(_!==-1&&r.splice(_,1),r.unshift(d),h!=null&&h.length){for(const g of h)g.memberCode&&a.push(g.memberCode);this._getDependCodes(h,e,r,n,s,a)}continue}}s.some(c=>c.name===u.name)||s.push(u)}}_runScripts(t,e,r,n,s){const a=`${this._scriptId}_${e}`;let{builtInGather:u,buildinConstants:c,buildInFunctions:f,tradingvueFunc:d}=self.workerStorage.get(a)||{};const{interval:h,mintick:_,...g}=s||{};r&&(u=new Lh(a),c=new Ch,f=new $h(this._variables.mintick||1e-5,u,this._scriptId),d=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),u.updateOptions({interval:h,mintick:_||1e-5}),self.workerStorage.set(a,{builtInGather:u,buildinConstants:c,buildInFunctions:f,tradingvueFunc:d})),u.updateData(g),f.update({barIndex:(g==null?void 0:g.barindex)||0});const y=d(u,c,f,n||[],e);return f.endExecution(),y}},iD=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class sD{constructor(t,e){$(this,"_logs");$(this,"_variables");$(this,"_str");$(this,"_preBar",{barIndex:-1,isrealtime:!1});this._variables=t,this._logs=[],this._str=e}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:s,formatString:a}=t,{time:u,bar_index:c,_isRealTimeBar:f,_isRepeated:d}=this._variables;let h=s;a&&Array.isArray(e)&&e.length&&(e=e.map(p=>(typeof p=="object"&&(p.isArray?p=JSON.stringify(p._value):p=p.toString()),p!==void 0?p:"na")),h=this._str.strformat({formatString:a},e,!0));const{barIndex:_,isrealtime:g}=this._preBar;this._preBar={barIndex:c,isrealtime:f};const y=Date.now();h&&this._logs.push({message:`[${Wt(g||f?y:u).format("YYYY-MM-DDTHH:mm:ss.SSSZ")}]: ${h}`,time:u,id:M_(6),barIndex:c,type:r})}}class oD{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,Rt.Error)}}class aD{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Wr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[s,a]=e.split("_").slice(-2),u=this._errors.get(e),c={message:t,endLineNumber:Number(s),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(s),type:r};u?u.push(c):this._errors.set(e,[c])}}class uD{constructor(){$(this,"_isMarketOpen");$(this,"_currentBarIndex");$(this,"_totalBarIndex");$(this,"_isRealTimeBar");$(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class lD{constructor(t){$(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const{time:t,__period:e}=this._variables,r=gr(e,t);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const{time:t,__period:e}=this._variables,r=gr(e,t);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class cD{constructor(t){$(this,"_orders");$(this,"_historyOrders");$(this,"_options");$(this,"_max_contracts_held_all",0);$(this,"_max_contracts_held_long",0);$(this,"_max_contracts_held_short",0);$(this,"_max_drawdown",0);$(this,"_max_runup",0);$(this,"_max_runup_percent",0);$(this,"_max_drawdown_percent",0);$(this,"_variables");$(this,"_netprofit",0);$(this,"_eventrades",0);$(this,"_avg_trade_percent");$(this,"_avg_losing_trade_percent");$(this,"_avg_winning_trade_percent");$(this,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossprofit",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"_preMaxNetValue",0);$(this,"_preMinNetValue",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(t){this._calcMaxDrawdownAndMaxRunup(t)}_calcMaxDrawdownAndMaxRunup(t){if(!this._orders.length&&!this._historyOrders.length)return;let e=0,r=0;const{high:n,low:s,close:a}=t;let u=0;for(const[d,h]of this._orders.entries()){const{in_price:_,qty:g=0,direction:y,commission:p,original_qty:w=1}=h,v=y===fe.long?1:-1,x=(n-_)*g,b=(s-_)*g,C=v===1?x:-b,E=v===1?-b:x;u+=(a-_)*v*g,e+=E,d>0&&p&&(r-=p*g/w),r+=C}this._openprofit=u;const c=this.initial_capital,f=c+this._netprofit;this._preMinNetValue=this._preMinNetValue||c,this._preMaxNetValue=this._preMaxNetValue||c,e=this._preMaxNetValue-f+Math.max(e,0),r=f-this._preMinNetValue+r,this._max_drawdown<e&&(this._max_drawdown=e,this._max_drawdown_percent=e/this._preMaxNetValue*100),r>this._max_runup&&(this._max_runup=r,this._max_runup_percent=r/(this._preMinNetValue+r)*100)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,s,a,u,c]=this._orders.reduce(([f,d,h,_,g,y,p],w)=>{const{direction:v,qty:x=0,in_price:b,commission:C=0}=w;return v===fe.long?(f+=x,d+=x,y+=x):(f+=x,h+=x,y-=x),_+=x*b,g+=b,p+=C,[f,d,h,_,g,y,p]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=c),this._position_size=u,this._position_avg_price=a/t,this._opentrades_capital_held=s,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,s,a,u,c,f,d]=this._historyOrders.reduce((g,y)=>{let[p,w,v,x,b,C,E,A]=g;const{profit:N=0,profit_percent:S=0}=y;return p+=N,w+=S,N<0?(v+=N,x+=S,E+=1):N>0&&(b+=N,C+=S,A+=1),[p,w,v,x,b,C,E,A]},[0,0,0,0,0,0,0,0]),h=this._orders.reduce((g,y)=>{const{commission:p=0,qty:w=0,original_qty:v=0}=y,x=p*w/v;return g+x},0);this._avg_trade_percent=e?n/e:void 0,this._avg_losing_trade_percent=e?Math.abs(a)/f:void 0,this._avg_winning_trade_percent=e?c/d:void 0,this._netprofit=r-h;const _=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,_),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,_),this._grossloss=Math.abs(s-h),this._grossprofit=u,this._eventrades=e-f-d,this._losstrades=f,this._wintrades=d}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){return this._avg_losing_trade_percent}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){return this._avg_winning_trade_percent}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:s=0}=this._options,a=this._orders[0].direction===fe.long?1:-1,u=(a===1?e:r)/100;if(u<=0)return;const{close:c}=this._variables,[f,d]=this._orders.reduce((h,_)=>{let[g,y]=h;const{in_price:p,qty:w=0,original_qty:v=0}=_,x=p*w;if(g+=x,s){let b=0;switch(n){case je.percent:b=(x+w*c)*s/100;break;case je.cashPerContract:b=w*s*2;break;case je.cashPerOrder:b=w/v*s+s;break}y+=b}return[g,y]},[0,0]);return(f-(t+this._netprofit-d))*a/this._position_size/(1-a*u)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}}class fD{constructor(t){$(this,"_preAccdist");$(this,"_preNvi");$(this,"_prePvi");$(this,"_preObv");$(this,"_prePvt");$(this,"_preWad");$(this,"_preVwap");$(this,"_preValue");$(this,"_currentData");$(this,"_preData");$(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const s=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=s),this._preValue.accdist=s,s}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,s=(2*t-r-e)/((r-e)*n);return this._preValue.iii=s,s}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:s}=this._currentData,a=(t-s)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const s=Math.max(e,n),a=Math.min(r,n),u=t-n,f=(u>0?t-a:u<0?t-s:0)+this._preWad;return!this.isRealTime&&(this._preWad=f),this._preValue.wad=f,f}get vwap(){var d,h;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:s}=this._preVwap;if(((h=(d=self.workerStorage)==null?void 0:d.get(this._id))==null?void 0:h.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(s=!0,r=n=0),!s)return;const u=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:u,sumV:c,isReset:s});const f=u/c;return this._preValue.vwap=f,f}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const u=t||1;return n&&e?a=s<r?u+(n-e)/e*u:u:a=u,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const u=t||1;return n&&e?a=s>r?u+(n-e)/e*u:u:a=u,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class hD{constructor(){$(this,"_period");$(this,"_multiplier");$(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=Fs(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class dD{constructor(t){$(this,"_variables");$(this,"_bgColor");$(this,"_fgColor");$(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class _D{constructor(){$(this,"_syminfo",{})}update(t){this._syminfo=t}get basecurrency(){return this._syminfo.basecurrency||""}get country(){return this._syminfo.country}get currency(){return this._syminfo.currency||"USD"}get description(){return this._syminfo.description||""}get employees(){return this._syminfo.employees||100}get expiration_date(){return this._syminfo.expiration_date}get industry(){return this._syminfo.industry}get minmove(){return this._syminfo.minmove&&Number(this._syminfo.minmove)}get mintick(){return this._syminfo.mintick}get pointvalue(){return this._syminfo.pointvalue&&Number(this._syminfo.pointvalue)}get prefix(){return this.tickerid.replace(`:${this.ticker}`,"")}get pricescale(){return this._syminfo.pricescale&&Number(this._syminfo.pricescale)}get recommendations_buy(){return this._syminfo.recommendations_buy}get recommendations_buy_strong(){return this._syminfo.recommendations_buy_strong}get recommendations_date(){return this._syminfo.recommendations_date}get recommendations_hold(){return this._syminfo.recommendations_hold}get recommendations_sell(){return this._syminfo.recommendations_sell}get recommendations_sell_strong(){return this._syminfo.recommendations_sell_strong}get recommendations_total(){return this._syminfo.recommendations_total}get root(){return this._syminfo.root||""}get sector(){return this._syminfo.sector}get session(){return this._syminfo.session||Mn.regular}get shareholders(){return this._syminfo.shareholders}get shares_outstanding_float(){return this._syminfo.shares_outstanding_float}get shares_outstanding_total(){return this._syminfo.shares_outstanding_total}get target_price_average(){return this._syminfo.target_price_average}get target_price_date(){return this._syminfo.target_price_date}get target_price_estimates(){return this._syminfo.pricescale}get target_price_high(){return this._syminfo.target_price_high}get target_price_low(){return this._syminfo.target_price_low}get target_price_median(){return this._syminfo.target_price_median}get ticker(){return this._syminfo.ticker||""}get tickerid(){return this._syminfo.tickerid||""}get timezone(){return this._syminfo.timezone||"UTC+8"}get type(){return this._syminfo.type}get volumetype(){return this._syminfo.volumetype||"n/a"}}class pD{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class mD{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}Wt.extend(A_),Wt.extend(xa),Wt.extend(Ea);class Lh{constructor(t){$(this,"_cacheData");$(this,"_barIndex");$(this,"_isRealTimeBar");$(this,"_barstate");$(this,"_priceVariables");$(this,"_lastBarIndex");$(this,"_currentBarTime");$(this,"_lastBarTime");$(this,"_period");$(this,"_offsetTime");$(this,"_timeframe");$(this,"_ta");$(this,"_polyline");$(this,"_label");$(this,"_line");$(this,"_linefill");$(this,"_box");$(this,"_table");$(this,"_strategy");$(this,"_session");$(this,"syminfo");$(this,"chart");$(this,"earnings");$(this,"dividends");$(this,"_timeTradingday");$(this,"_mintick");$(this,"_cacheSpace");$(this,"_precision");$(this,"_nextBarTime");$(this,"_isRepeated");$(this,"_preCacheData");this._cacheData={varData:{},varNewData:{},varipData:{}},this._preCacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new uD,this._timeframe=new hD,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new fD(t),this._polyline=new $i,this._label=new $i,this._line=new $i,this._linefill=new $i,this._box=new $i,this._table=new $i,this._strategy=new cD(this),this._session=new lD(this),this.syminfo=new _D,this.chart=new dD(this),this.earnings=new mD(this),this.dividends=new pD(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return Wt(this._currentBarTime).hour()}get minute(){return Wt(this._currentBarTime).minute()}get second(){return Wt(this._currentBarTime).second()}get month(){return Wt(this._currentBarTime).month()+1}get year(){return Wt(this._currentBarTime).year()}get dayofweek(){return Wt(this._currentBarTime).day()}get dayofmonth(){return Wt(this._currentBarTime).date()}get weekofyear(){return Wt(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=Fs(this._period);return this._isRealTimeBar?void 0:Wt(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}get precision(){return this._precision}get nextBarTime(){return this._nextBarTime}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:s}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),s&&this._polyline.setMaxLen(s)}getTimeTradingday(t,e){const[r,n]=Fs(e),s=Wt(t);return["M","w","y","d"].includes(n)?s.valueOf():(s.subtract(this._offsetTime,"h"),s.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){var f;const{interval:e="1D",offsetTime:r=5,mintick:n,chart:s,syminfo:a}=t,u=((f=n.toString().split(".")[1])==null?void 0:f.length)||5;this._precision=u;const c=this._transformPeriod(e);this._period=c,this._mintick=n,this._offsetTime=r,this._timeframe.update(c),this.chart.updateOptions(s),this.syminfo.update(a)}updateData(t,e){const{barIndex:r,c:n,o:s,h:a,l:u,volume:c,time:f,lastBarIndex:d,lastBarTime:h,isrealtime:_,time_tradingday:g,nextBarTime:y}=t;if(this._priceVariables={close:Number(n),open:Number(s),high:Number(a),low:Number(u),volume:Number(c)},this._isRealTimeBar=_,r>this._barIndex){const{varData:p,varNewData:w,varipData:v}=this._cacheData;this._preCacheData={varData:{...p},varNewData:{...w},varipData:{...v}},this._isRealTimeBar&&(this._cacheData.varNewData={})}this._isRepeated=e,this._timeTradingday=g,this._currentBarTime=f*1e3,this._lastBarIndex=d,this._barIndex=r,this._lastBarTime=h*1e3,this._nextBarTime=y*1e3,this._barstate.update(r,d,_,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:r})}getCacheData(t,e,r){const n=this.setCacheData(t,r),s=this._cacheSpace.get(t)||0;return e=Math.floor(e),s<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new D_(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`,s=this._isRepeated?this._preCacheData:this._cacheData;return r==="var"?this._isRealTimeBar&&s.varNewData.hasOwnProperty(n)?s.varNewData[n]:s.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var u;if(this._isRepeated&&n==="var")return this.getVarValue(t,e,n);const s=`${t}_${e}`;let a;switch(typeof r=="object"&&((u=r==null?void 0:r.varipKeys)!=null&&u.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[s]||this._cacheData.varipData[s]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[s]=r,a&&a.length)for(const c of a)this._cacheData.varData[s][c]=r[c]}else this._cacheData.varData[s]=r;break;case"varip":this._cacheData.varipData[s]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case te.BOX:this._setChartDraw(e,this._box);break;case te.LINE:this._setChartDraw(e,this._line);break;case te.POLYLINE:this._setChartDraw(e,this._polyline);break;case te.LABEL:this._setChartDraw(e,this._label);break;case te.LINEFILL:this._setChartDraw(e,this._linefill);break;case te.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t);if(!n||!r)return;const s=(r==null?void 0:r.updateId())||t;e.delete(t),e.set(s,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Wr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}equal(t,e,r,n){if(t!==void 0&&e!==void 0)return t==e;if(!(r.endsWith(te.BOOL)&&t===void 0))return(r.endsWith(te.FLOAT)||r.endsWith(te.INT)||n.endsWith(te.FLOAT)||n.endsWith(te.INT))&&t===void 0&&e===void 0?!1:r.endsWith(te.STRING)&&t===""&&e===void 0||n.endsWith(te.STRING)&&e===""&&t===void 0?!0:r.endsWith(te.NA)&&n.endsWith(te.NA)?!1:t==e}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case go.name:case Ah.name:case wo.name:case Mh.name:case vo.name:case yo.name:t==null||t.delete();break}}_transformPeriod(t){return t.includes("MTH")?t=t.replace("MTH","M"):t.includes("M")&&(t=t.replace("M","")),nc(t)}}class $i{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");$(this,"_deleteIds");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new ee,this._maxLength=t,this._deleteIds=new Map}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[s,a]of this._all){const{isVar:u,id:c,bar_index:f}=a;if(f===n)break;if(u)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const s=r.filter(a=>a.endsWith(`_${n}`));for(const a of s){const u=this._all.get(a);u&&e.push(u)}}return e.length?e:void 0}getDeleteIds(t){let e=[];for(const r of t)e=e.concat(this._deleteIds.get(r)||[]);return this._deleteIds.clear(),Wr.uniq(e)}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t,e){if(this._all.delete(t),this._allInstance.delete(t),typeof e=="number"){const r=this._deleteIds.get(e)||[];r.push(t),this._deleteIds.set(e,r)}}}/**
|
65
|
+
${g}`),g}_getRequestData(t,e){var C,E,A,N,S;let{symbol:r,timeframe:n,calc_bars_count:s,gaps:a,lookahead:u,ignore_invalid_symbol:c}=t;const{__period:f,syminfo:{ticker:d,tickerid:h},mintick:_,time:g,nextBarTime:y}=this._variables;if(n=nc(n),(f===n||n==="")&&(r===d||r===h)){const{close:I,open:F,high:O,low:L,bar_index:z,last_bar_index:q,last_bar_time:W,_isRealTimeBar:R,volume:Z,time:Y,time_tradingday:G}=this._variables;return{barIndex:z,c:I,o:F,h:O,l:L,volume:Z,lastBarIndex:q,lastBarTime:W/1e3,nextBarTime:y,isrealtime:R,time_tradingday:G,time:Y/1e3,interval:f,mintick:_}}const p=`${r}--${n||f}`,w=self.workerStorage.get(`request_${this._scriptId}_data`),v=self.workerStorage.get(`request_${this._scriptId}_list`),x=self.workerStorage.get(`request_${this._scriptId}_tmp`),b={id:p,calc_bars_count:s,ignore_invalid_symbol:c,symbol:r,timeframe:rD[n||f]||n};if(w!=null&&w.has(p)){let I=gr(n,g)*1e3;const F=gr(f,g)*1e3;x==null||x.delete(p),e=`${e}_${p}`;const{index:O=0,periodStamp:L=F}=this._cacheData.get(e)||{},z=w==null?void 0:w.get(p);if(!z.length)return;const q=z.slice(O);let W=g,R=L+W;const Z=z.length-1;if(Z<0)return;const Y={lastBarIndex:z[Z].barindex||Z,lastBarTime:z[Z].time,interval:n,mintick:_};if(I>L){let G;if(u===ln.lookaheadOn?G=this._lookaheadOnHandle(q,n,R,I,Y,O,L,e,W,a):G=this._lookaheadOffHandle(q,n,R,I,Y,O,L,e,W,y||R,a),G)return G;if(G===null)return}else if(u===ln.lookaheadOn)for(const[G,Q]of q.entries()){let{time:ut,barindex:_t}=Q;ut=ut*1e3;const at=((C=q[G+1])==null?void 0:C.time)*1e3||ut+I;let vt=O+G;if(ut>=R){this._cacheData.set(e,{index:vt,periodStamp:L});return}if(ut<=W&&at>W){const wt=O+G;return this._cacheData.set(e,{index:wt,periodStamp:L}),{...Q,barIndex:_t||wt,nextBarTime:(E=q[G+1])==null?void 0:E.time,...Y}}}else for(const[G,Q]of q.entries()){let{time:ut,barindex:_t}=Q;ut=ut*1e3;const at=((A=q[G+1])==null?void 0:A.time)*1e3||ut+I;let vt=O+G;if(ut>R){this._cacheData.set(e,{index:vt,periodStamp:L});return}if(ut<=R&&R<at)return this._cacheData.set(e,{index:vt,periodStamp:L}),{...Q,barIndex:_t||vt,nextBarTime:(N=q[G+1])==null?void 0:N.time,...Y};if(ut>=W&&ut<=R&&(_t||vt)===Y.lastBarIndex)return this._cacheData.set(e,{index:vt,periodStamp:L}),{...Q,barIndex:_t||vt,nextBarTime:(S=q[G+1])==null?void 0:S.time,...Y}}this._cacheData.set(e,{index:z.length,periodStamp:L})}else(v==null?void 0:v.get(p))||x==null||x.set(p,b);v==null||v.set(p,b)}_lookaheadOnHandle(t,e,r,n,s,a,u,c,f,d){var h;for(const[_,g]of t.entries()){let{time:y,barindex:p}=g;y=y*1e3,e.includes("M")&&(n=gr(e,y)*1e3-(Wt(y).date()-1)*864e5);const w=y,v=n+w;let x=a+_;if(r<=w)return this._cacheData.set(c,{index:x,periodStamp:u}),null;let b={...g,barIndex:p||x,nextBarTime:(h=t[_+1])==null?void 0:h.time,...s};if(d===ln.gapsOn){if(r>w&&f<=w)return this._cacheData.set(c,{index:x,periodStamp:u}),b}else{if(r>v)continue;if(r>w)return this._cacheData.set(c,{index:x,periodStamp:u}),b}}}_lookaheadOffHandle(t,e,r,n,s,a,u,c,f,d,h){var _,g;for(const[y,p]of t.entries()){let{time:w,barindex:v}=p;w=w*1e3,e.includes("M")&&(n=gr(e,w)*1e3-(Wt(w).date()-1)*864e5);const x=w,b=n+x,C=a+y;if(r<x)return this._cacheData.set(c,{index:C,periodStamp:u}),null;const E={...p,barIndex:v||C,nextBarTime:(_=t[y+1])==null?void 0:_.time,...s};if(r>=b&&f<b||r<b&&d>=b)return h===ln.gapsOn?(this._cacheData.set(c,{index:C,periodStamp:u}),E):(this._cacheData.set(c,{index:C,data:E,periodStamp:u}),E);if(!(f>b)&&f>=x){let A=(g=this._cacheData.get(c))==null?void 0:g.data;if(!A){const N=t[C-1];if(!N)return null;A={...N,barIndex:N.barindex||C-1,nextBarTime:E.time,...s},this._cacheData.set(c,{index:C,data:A,periodStamp:u})}return A}}}_getDependCodes(t,e,r,n,s,a){for(const u of t){if(!u.isArg){const c=e.filter(d=>{var h;return(h=d==null?void 0:d.depends)==null?void 0:h.some(_=>_.name===u.name&&_.scope===u.scope&&_.isAgainAssign)});for(const d of c){const{code:h,depends:_}=d;if(!r.includes(h)&&(r.unshift(h),_!=null&&_.length)){for(const g of _)g.memberCode&&a.push(g.memberCode);this._getDependCodes(_,e,r,n,s,a)}}const f=e.find(d=>{var h;return((h=d.varNames)==null?void 0:h.split(", ").includes(u.name))&&(!u.isPreArg||u.isPreArg&&d.methodName===u.functionName)||d.funcName===u.name});if(f){const{code:d,depends:h}=f,_=r.findIndex(g=>g===d);if(_!==-1&&r.splice(_,1),r.unshift(d),h!=null&&h.length){for(const g of h)g.memberCode&&a.push(g.memberCode);this._getDependCodes(h,e,r,n,s,a)}continue}}s.some(c=>c.name===u.name)||s.push(u)}}_runScripts(t,e,r,n,s){const a=`${this._scriptId}_${e}`;let{builtInGather:u,buildinConstants:c,buildInFunctions:f,tradingvueFunc:d}=self.workerStorage.get(a)||{};const{interval:h,mintick:_,...g}=s||{};r&&(u=new Lh(a),c=new Ch,f=new $h(this._variables.mintick||1e-5,u,this._scriptId),d=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),u.updateOptions({interval:h,mintick:_||1e-5}),self.workerStorage.set(a,{builtInGather:u,buildinConstants:c,buildInFunctions:f,tradingvueFunc:d})),u.updateData(g),f.update({barIndex:(g==null?void 0:g.barindex)||0});const y=d(u,c,f,n||[],e);return f.endExecution(),y}},iD=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class sD{constructor(t,e){$(this,"_logs");$(this,"_variables");$(this,"_str");$(this,"_preBar",{barIndex:-1,isrealtime:!1});this._variables=t,this._logs=[],this._str=e}get logs(){return this._logs}clearLogForIndex(t){this._logs=this._logs.filter(e=>e.barIndex!==t)}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:s,formatString:a}=t,{time:u,bar_index:c,_isRealTimeBar:f}=this._variables;let d=s;a&&Array.isArray(e)&&e.length&&(e=e.map(g=>(typeof g=="object"&&(g.isArray?g=JSON.stringify(g._value):g=g.toString()),g!==void 0?g:"na")),d=this._str.strformat({formatString:a},e,!0));const{isrealtime:h}=this._preBar;this._preBar={barIndex:c,isrealtime:f};const _=Date.now();d&&this._logs.push({message:`[${Wt(h||f?_:u).format("YYYY-MM-DDTHH:mm:ss.SSSZ")}]: ${d}`,time:u,id:M_(6),barIndex:c,type:r})}}class oD{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,Rt.Error)}}class aD{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Wr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[s,a]=e.split("_").slice(-2),u=this._errors.get(e),c={message:t,endLineNumber:Number(s),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(s),type:r};u?u.push(c):this._errors.set(e,[c])}}class uD{constructor(){$(this,"_isMarketOpen");$(this,"_currentBarIndex");$(this,"_totalBarIndex");$(this,"_isRealTimeBar");$(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class lD{constructor(t){$(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const{time:t,__period:e}=this._variables,r=gr(e,t);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const{time:t,__period:e}=this._variables,r=gr(e,t);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class cD{constructor(t){$(this,"_orders");$(this,"_historyOrders");$(this,"_options");$(this,"_max_contracts_held_all",0);$(this,"_max_contracts_held_long",0);$(this,"_max_contracts_held_short",0);$(this,"_max_drawdown",0);$(this,"_max_runup",0);$(this,"_max_runup_percent",0);$(this,"_max_drawdown_percent",0);$(this,"_variables");$(this,"_netprofit",0);$(this,"_eventrades",0);$(this,"_avg_trade_percent");$(this,"_avg_losing_trade_percent");$(this,"_avg_winning_trade_percent");$(this,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossprofit",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"_preMaxNetValue",0);$(this,"_preMinNetValue",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(t){this._calcMaxDrawdownAndMaxRunup(t)}_calcMaxDrawdownAndMaxRunup(t){if(!this._orders.length&&!this._historyOrders.length)return;let e=0,r=0;const{high:n,low:s,close:a}=t;let u=0;for(const[d,h]of this._orders.entries()){const{in_price:_,qty:g=0,direction:y,commission:p,original_qty:w=1}=h,v=y===fe.long?1:-1,x=(n-_)*g,b=(s-_)*g,C=v===1?x:-b,E=v===1?-b:x;u+=(a-_)*v*g,e+=E,d>0&&p&&(r-=p*g/w),r+=C}this._openprofit=u;const c=this.initial_capital,f=c+this._netprofit;this._preMinNetValue=this._preMinNetValue||c,this._preMaxNetValue=this._preMaxNetValue||c,e=this._preMaxNetValue-f+Math.max(e,0),r=f-this._preMinNetValue+r,this._max_drawdown<e&&(this._max_drawdown=e,this._max_drawdown_percent=e/this._preMaxNetValue*100),r>this._max_runup&&(this._max_runup=r,this._max_runup_percent=r/(this._preMinNetValue+r)*100)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,s,a,u,c]=this._orders.reduce(([f,d,h,_,g,y,p],w)=>{const{direction:v,qty:x=0,in_price:b,commission:C=0}=w;return v===fe.long?(f+=x,d+=x,y+=x):(f+=x,h+=x,y-=x),_+=x*b,g+=b,p+=C,[f,d,h,_,g,y,p]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=c),this._position_size=u,this._position_avg_price=a/t,this._opentrades_capital_held=s,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,s,a,u,c,f,d]=this._historyOrders.reduce((g,y)=>{let[p,w,v,x,b,C,E,A]=g;const{profit:N=0,profit_percent:S=0}=y;return p+=N,w+=S,N<0?(v+=N,x+=S,E+=1):N>0&&(b+=N,C+=S,A+=1),[p,w,v,x,b,C,E,A]},[0,0,0,0,0,0,0,0]),h=this._orders.reduce((g,y)=>{const{commission:p=0,qty:w=0,original_qty:v=0}=y,x=p*w/v;return g+x},0);this._avg_trade_percent=e?n/e:void 0,this._avg_losing_trade_percent=e?Math.abs(a)/f:void 0,this._avg_winning_trade_percent=e?c/d:void 0,this._netprofit=r-h;const _=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,_),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,_),this._grossloss=Math.abs(s-h),this._grossprofit=u,this._eventrades=e-f-d,this._losstrades=f,this._wintrades=d}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){return this._avg_losing_trade_percent}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){return this._avg_winning_trade_percent}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:s=0}=this._options,a=this._orders[0].direction===fe.long?1:-1,u=(a===1?e:r)/100;if(u<=0)return;const{close:c}=this._variables,[f,d]=this._orders.reduce((h,_)=>{let[g,y]=h;const{in_price:p,qty:w=0,original_qty:v=0}=_,x=p*w;if(g+=x,s){let b=0;switch(n){case je.percent:b=(x+w*c)*s/100;break;case je.cashPerContract:b=w*s*2;break;case je.cashPerOrder:b=w/v*s+s;break}y+=b}return[g,y]},[0,0]);return(f-(t+this._netprofit-d))*a/this._position_size/(1-a*u)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}}class fD{constructor(t){$(this,"_preAccdist");$(this,"_preNvi");$(this,"_prePvi");$(this,"_preObv");$(this,"_prePvt");$(this,"_preWad");$(this,"_preVwap");$(this,"_preValue");$(this,"_currentData");$(this,"_preData");$(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const s=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=s),this._preValue.accdist=s,s}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,s=(2*t-r-e)/((r-e)*n);return this._preValue.iii=s,s}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:s}=this._currentData,a=(t-s)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const s=Math.max(e,n),a=Math.min(r,n),u=t-n,f=(u>0?t-a:u<0?t-s:0)+this._preWad;return!this.isRealTime&&(this._preWad=f),this._preValue.wad=f,f}get vwap(){var d,h;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:s}=this._preVwap;if(((h=(d=self.workerStorage)==null?void 0:d.get(this._id))==null?void 0:h.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(s=!0,r=n=0),!s)return;const u=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:u,sumV:c,isReset:s});const f=u/c;return this._preValue.vwap=f,f}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const u=t||1;return n&&e?a=s<r?u+(n-e)/e*u:u:a=u,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const u=t||1;return n&&e?a=s>r?u+(n-e)/e*u:u:a=u,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class hD{constructor(){$(this,"_period");$(this,"_multiplier");$(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=Fs(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class dD{constructor(t){$(this,"_variables");$(this,"_bgColor");$(this,"_fgColor");$(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class _D{constructor(){$(this,"_syminfo",{})}update(t){this._syminfo=t}get basecurrency(){return this._syminfo.basecurrency||""}get country(){return this._syminfo.country}get currency(){return this._syminfo.currency||"USD"}get description(){return this._syminfo.description||""}get employees(){return this._syminfo.employees||100}get expiration_date(){return this._syminfo.expiration_date}get industry(){return this._syminfo.industry}get minmove(){return this._syminfo.minmove&&Number(this._syminfo.minmove)}get mintick(){return this._syminfo.mintick}get pointvalue(){return this._syminfo.pointvalue&&Number(this._syminfo.pointvalue)}get prefix(){return this.tickerid.replace(`:${this.ticker}`,"")}get pricescale(){return this._syminfo.pricescale&&Number(this._syminfo.pricescale)}get recommendations_buy(){return this._syminfo.recommendations_buy}get recommendations_buy_strong(){return this._syminfo.recommendations_buy_strong}get recommendations_date(){return this._syminfo.recommendations_date}get recommendations_hold(){return this._syminfo.recommendations_hold}get recommendations_sell(){return this._syminfo.recommendations_sell}get recommendations_sell_strong(){return this._syminfo.recommendations_sell_strong}get recommendations_total(){return this._syminfo.recommendations_total}get root(){return this._syminfo.root||""}get sector(){return this._syminfo.sector}get session(){return this._syminfo.session||Mn.regular}get shareholders(){return this._syminfo.shareholders}get shares_outstanding_float(){return this._syminfo.shares_outstanding_float}get shares_outstanding_total(){return this._syminfo.shares_outstanding_total}get target_price_average(){return this._syminfo.target_price_average}get target_price_date(){return this._syminfo.target_price_date}get target_price_estimates(){return this._syminfo.pricescale}get target_price_high(){return this._syminfo.target_price_high}get target_price_low(){return this._syminfo.target_price_low}get target_price_median(){return this._syminfo.target_price_median}get ticker(){return this._syminfo.ticker||""}get tickerid(){return this._syminfo.tickerid||""}get timezone(){return this._syminfo.timezone||"UTC+8"}get type(){return this._syminfo.type}get volumetype(){return this._syminfo.volumetype||"n/a"}}class pD{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class mD{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}Wt.extend(A_),Wt.extend(xa),Wt.extend(Ea);class Lh{constructor(t){$(this,"_cacheData");$(this,"_barIndex");$(this,"_isRealTimeBar");$(this,"_barstate");$(this,"_priceVariables");$(this,"_lastBarIndex");$(this,"_currentBarTime");$(this,"_lastBarTime");$(this,"_period");$(this,"_offsetTime");$(this,"_timeframe");$(this,"_ta");$(this,"_polyline");$(this,"_label");$(this,"_line");$(this,"_linefill");$(this,"_box");$(this,"_table");$(this,"_strategy");$(this,"_session");$(this,"syminfo");$(this,"chart");$(this,"earnings");$(this,"dividends");$(this,"_timeTradingday");$(this,"_mintick");$(this,"_cacheSpace");$(this,"_precision");$(this,"_nextBarTime");$(this,"_isRepeated");$(this,"_preCacheData");this._cacheData={varData:{},varNewData:{},varipData:{}},this._preCacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new uD,this._timeframe=new hD,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new fD(t),this._polyline=new $i,this._label=new $i,this._line=new $i,this._linefill=new $i,this._box=new $i,this._table=new $i,this._strategy=new cD(this),this._session=new lD(this),this.syminfo=new _D,this.chart=new dD(this),this.earnings=new mD(this),this.dividends=new pD(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return Wt(this._currentBarTime).hour()}get minute(){return Wt(this._currentBarTime).minute()}get second(){return Wt(this._currentBarTime).second()}get month(){return Wt(this._currentBarTime).month()+1}get year(){return Wt(this._currentBarTime).year()}get dayofweek(){return Wt(this._currentBarTime).day()}get dayofmonth(){return Wt(this._currentBarTime).date()}get weekofyear(){return Wt(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=Fs(this._period);return this._isRealTimeBar?void 0:Wt(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}get precision(){return this._precision}get nextBarTime(){return this._nextBarTime}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:s}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),s&&this._polyline.setMaxLen(s)}getTimeTradingday(t,e){const[r,n]=Fs(e),s=Wt(t);return["M","w","y","d"].includes(n)?s.valueOf():(s.subtract(this._offsetTime,"h"),s.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){var f;const{interval:e="1D",offsetTime:r=5,mintick:n,chart:s,syminfo:a}=t,u=((f=n.toString().split(".")[1])==null?void 0:f.length)||5;this._precision=u;const c=this._transformPeriod(e);this._period=c,this._mintick=n,this._offsetTime=r,this._timeframe.update(c),this.chart.updateOptions(s),this.syminfo.update(a)}updateData(t,e){const{barIndex:r,c:n,o:s,h:a,l:u,volume:c,time:f,lastBarIndex:d,lastBarTime:h,isrealtime:_,time_tradingday:g,nextBarTime:y}=t;if(this._priceVariables={close:Number(n),open:Number(s),high:Number(a),low:Number(u),volume:Number(c)},this._isRealTimeBar=_,r>this._barIndex){const{varData:p,varNewData:w,varipData:v}=this._cacheData;this._preCacheData={varData:{...p},varNewData:{...w},varipData:{...v}},this._isRealTimeBar&&(this._cacheData.varNewData={})}this._isRepeated=e,this._timeTradingday=g,this._currentBarTime=f*1e3,this._lastBarIndex=d,this._barIndex=r,this._lastBarTime=h*1e3,this._nextBarTime=y*1e3,this._barstate.update(r,d,_,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:r})}getCacheData(t,e,r){const n=this.setCacheData(t,r),s=this._cacheSpace.get(t)||0;return e=Math.floor(e),s<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new D_(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`,s=this._isRepeated?this._preCacheData:this._cacheData;return r==="var"?this._isRealTimeBar&&s.varNewData.hasOwnProperty(n)?s.varNewData[n]:s.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var u;if(this._isRepeated&&n==="var")return this.getVarValue(t,e,n);const s=`${t}_${e}`;let a;switch(typeof r=="object"&&((u=r==null?void 0:r.varipKeys)!=null&&u.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[s]||this._cacheData.varipData[s]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[s]=r,a&&a.length)for(const c of a)this._cacheData.varData[s][c]=r[c]}else this._cacheData.varData[s]=r;break;case"varip":this._cacheData.varipData[s]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case te.BOX:this._setChartDraw(e,this._box);break;case te.LINE:this._setChartDraw(e,this._line);break;case te.POLYLINE:this._setChartDraw(e,this._polyline);break;case te.LABEL:this._setChartDraw(e,this._label);break;case te.LINEFILL:this._setChartDraw(e,this._linefill);break;case te.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t);if(!n||!r)return;const s=(r==null?void 0:r.updateId())||t;e.delete(t),e.set(s,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Wr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}equal(t,e,r,n){if(t!==void 0&&e!==void 0)return t==e;if(!(r.endsWith(te.BOOL)&&t===void 0))return(r.endsWith(te.FLOAT)||r.endsWith(te.INT)||n.endsWith(te.FLOAT)||n.endsWith(te.INT))&&t===void 0&&e===void 0?!1:r.endsWith(te.STRING)&&t===""&&e===void 0||n.endsWith(te.STRING)&&e===""&&t===void 0?!0:r.endsWith(te.NA)&&n.endsWith(te.NA)?!1:t==e}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case go.name:case Ah.name:case wo.name:case Mh.name:case vo.name:case yo.name:t==null||t.delete();break}}_transformPeriod(t){return t.includes("MTH")?t=t.replace("MTH","M"):t.includes("M")&&(t=t.replace("M","")),nc(t)}}class $i{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");$(this,"_deleteIds");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new ee,this._maxLength=t,this._deleteIds=new Map}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[s,a]of this._all){const{isVar:u,id:c,bar_index:f}=a;if(f===n)break;if(u)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const s=r.filter(a=>a.endsWith(`_${n}`));for(const a of s){const u=this._all.get(a);u&&e.push(u)}}return e.length?e:void 0}getDeleteIds(t){let e=[];for(const r of t)e=e.concat(this._deleteIds.get(r)||[]);return this._deleteIds.clear(),Wr.uniq(e)}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t,e){if(this._all.delete(t),this._allInstance.delete(t),typeof e=="number"){const r=this._deleteIds.get(e)||[];r.push(t),this._deleteIds.set(e,r)}}}/**
|
66
66
|
* @license
|
67
67
|
* Copyright 2019 Google LLC
|
68
68
|
* SPDX-License-Identifier: Apache-2.0
|
69
|
-
*/const Rh=Symbol("Comlink.proxy"),gD=Symbol("Comlink.endpoint"),vD=Symbol("Comlink.releaseProxy"),su=Symbol("Comlink.finalizer"),xo=Symbol("Comlink.thrown"),Ph=i=>typeof i=="object"&&i!==null||typeof i=="function",yD={canHandle:i=>Ph(i)&&i[Rh],serialize(i){const{port1:t,port2:e}=new MessageChannel;return ou(i,t),[e,[e]]},deserialize(i){return i.start(),xD(i)}},wD={canHandle:i=>Ph(i)&&xo in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},kh=new Map([["proxy",yD],["throw",wD]]);function DD(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function ou(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!DD(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:u}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(ai);let f;try{const d=u.slice(0,-1).reduce((_,g)=>_[g],i),h=u.reduce((_,g)=>_[g],i);switch(a){case"GET":f=h;break;case"SET":d[u.slice(-1)[0]]=ai(n.data.value),f=!0;break;case"APPLY":f=h.apply(d,c);break;case"CONSTRUCT":{const _=new h(...c);f=FD(_)}break;case"ENDPOINT":{const{port1:_,port2:g}=new MessageChannel;ou(i,g),f=MD(_,[_])}break;case"RELEASE":f=void 0;break;default:return}}catch(d){f={value:d,[xo]:0}}Promise.resolve(f).catch(d=>({value:d,[xo]:0})).then(d=>{const[h,_]=Mo(d);t.postMessage(Object.assign(Object.assign({},h),{id:s}),_),a==="RELEASE"&&(t.removeEventListener("message",r),zh(t),su in i&&typeof i[su]=="function"&&i[su]())}).catch(d=>{const[h,_]=Mo({value:new TypeError("Unserializable return value"),[xo]:0});t.postMessage(Object.assign(Object.assign({},h),{id:s}),_)})}),t.start&&t.start()}function bD(i){return i.constructor.name==="MessagePort"}function zh(i){bD(i)&&i.close()}function xD(i,t){return au(i,[],t)}function Eo(i){if(i)throw new Error("Proxy has been released and is not useable")}function qh(i){return Li(i,{type:"RELEASE"}).then(()=>{zh(i)})}const Co=new WeakMap,Ao="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(Co.get(i)||0)-1;Co.set(i,t),t===0&&qh(i)});function ED(i,t){const e=(Co.get(t)||0)+1;Co.set(t,e),Ao&&Ao.register(i,t,i)}function CD(i){Ao&&Ao.unregister(i)}function au(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(Eo(r),a===vD)return()=>{CD(n),qh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const u=Li(i,{type:"GET",path:t.map(c=>c.toString())}).then(ai);return u.then.bind(u)}return au(i,[...t,a])},set(s,a,u){Eo(r);const[c,f]=Mo(u);return Li(i,{type:"SET",path:[...t,a].map(d=>d.toString()),value:c},f).then(ai)},apply(s,a,u){Eo(r);const c=t[t.length-1];if(c===gD)return Li(i,{type:"ENDPOINT"}).then(ai);if(c==="bind")return au(i,t.slice(0,-1));const[f,d]=Uh(u);return Li(i,{type:"APPLY",path:t.map(h=>h.toString()),argumentList:f},d).then(ai)},construct(s,a){Eo(r);const[u,c]=Uh(a);return Li(i,{type:"CONSTRUCT",path:t.map(f=>f.toString()),argumentList:u},c).then(ai)}});return ED(n,i),n}function AD(i){return Array.prototype.concat.apply([],i)}function Uh(i){const t=i.map(Mo);return[t.map(e=>e[0]),AD(t.map(e=>e[1]))]}const Wh=new WeakMap;function MD(i,t){return Wh.set(i,t),i}function FD(i){return Object.assign(i,{[Rh]:!0})}function Mo(i){for(const[t,e]of kh)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},Wh.get(i)||[]]}function ai(i){switch(i.type){case"HANDLER":return kh.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Li(i,t,e){return new Promise(r=>{const n=ND();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function ND(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class SD{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}class jh extends Error{constructor(e,r,n){const s=e.status||e.status===0?e.status:"",a=e.statusText||"",u=`${s} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`);$(this,"response");$(this,"request");$(this,"options");this.name="HTTPError",this.response=e,this.request=r,this.options=n}}class Yh extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`);$(this,"request");this.name="TimeoutError",this.request=e}}const ls=i=>i!==null&&typeof i=="object",Fo=(...i)=>{for(const t of i)if((!ls(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return uu({},...i)},Vh=(i={},t={})=>{const e=new globalThis.Headers(i),r=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[s,a]of n.entries())r&&a==="undefined"||a===void 0?e.delete(s):e.set(s,a);return e};function No(i,t,e){return Object.hasOwn(t,e)&&t[e]===void 0?[]:uu(i[e]??[],t[e]??[])}const Hh=(i={},t={})=>({beforeRequest:No(i,t,"beforeRequest"),beforeRetry:No(i,t,"beforeRetry"),afterResponse:No(i,t,"afterResponse"),beforeError:No(i,t,"beforeError")}),uu=(...i)=>{let t={},e={},r={};for(const n of i)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(ls(n)){for(let[s,a]of Object.entries(n))ls(a)&&s in t&&(a=uu(t[s],a)),t={...t,[s]:a};ls(n.hooks)&&(r=Hh(r,n.hooks),t.hooks=r),ls(n.headers)&&(e=Vh(e,n.headers),t.headers=e)}return t},OD=(()=>{let i=!1,t=!1;const e=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(e&&r)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return i=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return i&&!t})(),BD=typeof globalThis.AbortController=="function",TD=typeof globalThis.ReadableStream=="function",ID=typeof globalThis.FormData=="function",Zh=["get","post","put","patch","head","delete"],$D={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},lu=2147483647,Kh=Symbol("stop"),LD={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},RD={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},PD=i=>Zh.includes(i)?i.toUpperCase():i,Gh={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:i=>.3*2**(i-1)*1e3},kD=(i={})=>{if(typeof i=="number")return{...Gh,limit:i};if(i.methods&&!Array.isArray(i.methods))throw new Error("retry.methods must be an array");if(i.statusCodes&&!Array.isArray(i.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Gh,...i}};async function zD(i,t,e,r){return new Promise((n,s)=>{const a=setTimeout(()=>{e&&e.abort(),s(new Yh(i))},r.timeout);r.fetch(i,t).then(n).catch(s).then(()=>{clearTimeout(a)})})}async function qD(i,{signal:t}){return new Promise((e,r)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(s),r(t.reason)}const s=setTimeout(()=>{t==null||t.removeEventListener("abort",n),e()},i)})}const UD=(i,t)=>{const e={};for(const r in t)!(r in RD)&&!(r in LD)&&!(r in i)&&(e[r]=t[r]);return e};class So{constructor(t,e={}){$(this,"request");$(this,"abortController");$(this,"_retryCount",0);$(this,"_input");$(this,"_options");var r,n;if(this._input=t,this._options={...e,headers:Vh(this._input.headers,e.headers),hooks:Hh({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:PD(e.method??this._input.method),prefixUrl:String(e.prefixUrl||""),retry:kD(e.retry),throwHttpErrors:e.throwHttpErrors!==!1,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(BD){this.abortController=new globalThis.AbortController;const s=this._options.signal??this._input.signal;s==null||s.addEventListener("abort",()=>{this.abortController.abort(s.reason)}),this._options.signal=this.abortController.signal}if(OD&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((n=(r=this._options).stringifyJson)==null?void 0:n.call(r,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const a="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(ID&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(u,{...this.request}),this._options)}}static create(t,e){const r=new So(t,e),n=async()=>{if(typeof r._options.timeout=="number"&&r._options.timeout>lu)throw new RangeError(`The \`timeout\` option cannot be greater than ${lu}`);await Promise.resolve();let u=await r._fetch();for(const c of r._options.hooks.afterResponse){const f=await c(r.request,r._options,r._decorateResponse(u.clone()));f instanceof globalThis.Response&&(u=f)}if(r._decorateResponse(u),!u.ok&&r._options.throwHttpErrors){let c=new jh(u,r.request,r._options);for(const f of r._options.hooks.beforeError)c=await f(c);throw c}if(r._options.onDownloadProgress){if(typeof r._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!TD)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return r._stream(u.clone(),r._options.onDownloadProgress)}return u},a=r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(n):n();for(const[u,c]of Object.entries($D))a[u]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||c);const d=(await a).clone();if(u==="json"){if(d.status===204||(await d.clone().arrayBuffer()).byteLength===0)return"";if(e.parseJson)return e.parseJson(await d.text())}return d[u]()};return a}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Yh)throw t;if(t instanceof jh){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const r=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(r&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(r)*1e3;Number.isNaN(n)?n=Date.parse(r)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const s=this._options.retry.maxRetryAfter??n;return n<s?n:s}if(t.response.status===413)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const r=Math.min(this._calculateRetryDelay(e),lu);if(this._retryCount<1)throw e;await qD(r,{signal:this._options.signal});for(const n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Kh)return;return this._retry(t)}}async _fetch(){for(const r of this._options.hooks.beforeRequest){const n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}const t=UD(this.request,this._options),e=this.request;return this.request=e.clone(),this._options.timeout===!1?this._options.fetch(e,t):zD(e,t,this.abortController,this._options)}_stream(t,e){const r=Number(t.headers.get("content-length"))||0;let n=0;return t.status===204?(e&&e({percent:1,totalBytes:r,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(s){const a=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){const{done:c,value:f}=await a.read();if(c){s.close();return}if(e){n+=f.byteLength;const d=r===0?0:n/r;e({percent:d,transferredBytes:n,totalBytes:r},f)}s.enqueue(f),await u()}await u()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}/*! MIT License © Sindre Sorhus */const cu=i=>{const t=(e,r)=>So.create(e,Fo(i,r));for(const e of Zh)t[e]=(r,n)=>So.create(r,Fo(i,n,{method:e}));return t.create=e=>cu(Fo(e)),t.extend=e=>(typeof e=="function"&&(e=e(i??{})),cu(Fo(i,e))),t.stop=Kh,t},WD=cu().create({prefixUrl:"https://data.tradingvue.com/",retry:0});function jD(i){return WD.post("symbol/data/v1/",{json:i})}async function YD(i,t,e){var A,N,S;const{data:r,isPreParser:n,id:s="default",syminfo:a={},interval:u,inputs:c,chart:f,strategy:d,scriptType:h,isManuallyAdd:_,subscribeData:g}=t;self.workerStorage||(self.workerStorage=new SD);let{builtInGather:y,buildinConstants:p,buildInFunctions:w,tradingvueFunc:v}=self.workerStorage.get(s)||{},x=[];const b=a.mintick?Number(a.mintick):1e-5;a.mintick=b,e&&(y=new Lh(s),p=new Ch,w=new $h(b,y,s),v=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:y,buildinConstants:p,buildInFunctions:w,tradingvueFunc:v}),self.workerStorage.set(`request_${s}`,new Map),(_||!self.workerStorage.has(`request_${s}_data`))&&self.workerStorage.set(`request_${s}_data`,new Map),self.workerStorage.set(`request_${s}_list`,new Map),self.workerStorage.set(`request_${s}_tmp`,new Map));let C=[];if(VD(g,s),n)v(y,p,w);else if(r&&r.length){const I=r.length-1;y.updateOptions({interval:u,mintick:b,chart:f,syminfo:a}),w.updateOptions({inputs:c,strategy:d});const F=self.workerStorage.get(`request_${s}_tmp`),O=self.workerStorage.get(`request_${s}_data`);try{let L;for(const[q,W]of r.entries()){const{barindex:P}=W;if(!e&&(P||P===0)&&x.push(P),F!=null&&F.size){const Y=[],G=[];for(const[ut,_t]of F){const{symbol:at,timeframe:vt,id:wt,calc_bars_count:Ct,ignore_invalid_symbol:bt}=_t,re=`${at}:${vt}`;G.push({id:wt,key:re,ignore_invalid_symbol:bt});const[Bt,Nt]=at.split(":");Y.push(jD({params:[{exchange:Bt,symbol:Nt,limit:Ct||5e3,start:0,end:0,period:vt}]}).json())}const X=await Promise.all(Y);for(const[ut,_t]of X.entries()){const{code:at,data:vt,msg:wt}=_t,Ct=G[ut];if(at!==200&&!Ct.ignore_invalid_symbol)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:wt,type:Rt.Error}]};O==null||O.set(Ct.id,((N=(A=vt[Ct.key])==null?void 0:A.list)==null?void 0:N.reverse())||[])}F==null||F.clear(),L&&Jh(y,w,p,v,h,L)}L=Object.assign(W,{barIndex:P||q,lastBarIndex:r[I].barindex||I,lastBarTime:r[I].time,nextBarTime:(S=r[q+1])==null?void 0:S.time}),Jh(y,w,p,v,h,L);const Z=w.errors;if(Z.length&&Z.some(Y=>Y.type===Rt.Error))return{status:1,errors:Z}}const z=self.workerStorage.get(`request_${s}_list`);if((z==null?void 0:z.size)>40)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:ie.requestsNumErr,type:Rt.Error}]};if(z!=null&&z.size){const q=new Map;for(const[W,P]of z)C.push(P),e&&(O!=null&&O.has(W))&&q.set(W,O.get(W));e&&self.workerStorage.set(`request_${s}_data`,q)}C.length&&(z==null||z.clear()),e&&self.workerStorage.delete(`request_${s}_tmp`)}catch(L){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:L==null?void 0:L.message,type:Rt.Error}]}}}const E=w.errors;return E.length&&E.some(I=>I.type===Rt.Error)?{status:1,errors:E}:{status:0,requestList:C,errors:E,options:{...w.options(x),id:s}}}function VD(i,t){if(!i)return;const e=self.workerStorage.get(`request_${t}_data`),r=Object.keys(i);if(r.length)for(const n of r){let s=i[n]||[];if(e!=null&&e.has(n)){const a=(e==null?void 0:e.get(n))||[];if(a.length){const u=a[a.length-1].time;s=s.filter(c=>c.time>=u),s[0].time===u&&a.pop()}e==null||e.set(n,a.concat(s))}}}function Jh(i,t,e,r,n,s){if(i.updateData(s),t.update({barIndex:s.barIndex}),n=n||t.scriptType,s.isrealtime&&n===ic.strategy&&!t.strategy.isCalcOnEveryTick){t.strategy.calcCurrentOrder();return}if(r(i,e,t),t.endExecution(),t.strategy.calcOnOrderFillsData.tradeData){for(;t.strategy.calcOnOrderFillsData.tradeData;)t.strategy.calcOnOrderFillsData.data=t.strategy.calcOnOrderFillsData.tradeData,t.strategy.calcOnOrderFillsData.tradeData=void 0,i.updateData(s,!0),t.update({barIndex:s==null?void 0:s.barIndex}),r(i,e,t),t.endExecution();t.strategy.calcOnOrderFillsData={index:-1}}}function HD(i){var t,e,r,n,s,a;(t=self==null?void 0:self.workerStorage)==null||t.deleteStartwidthKey(i),(e=self==null?void 0:self.workerStorage)==null||e.delete(`inputs_${i}`),(r=self==null?void 0:self.workerStorage)==null||r.delete(`strategy_${i}`),(n=self==null?void 0:self.workerStorage)==null||n.delete(`request_${i}`),(s=self==null?void 0:self.workerStorage)==null||s.delete(`request_${i}_data`),(a=self==null?void 0:self.workerStorage)==null||a.delete(`request_${i}_list`)}ou({runScript:YD,removeScript:HD})})();
|
69
|
+
*/const Rh=Symbol("Comlink.proxy"),gD=Symbol("Comlink.endpoint"),vD=Symbol("Comlink.releaseProxy"),su=Symbol("Comlink.finalizer"),xo=Symbol("Comlink.thrown"),Ph=i=>typeof i=="object"&&i!==null||typeof i=="function",yD={canHandle:i=>Ph(i)&&i[Rh],serialize(i){const{port1:t,port2:e}=new MessageChannel;return ou(i,t),[e,[e]]},deserialize(i){return i.start(),xD(i)}},wD={canHandle:i=>Ph(i)&&xo in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},kh=new Map([["proxy",yD],["throw",wD]]);function DD(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function ou(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!DD(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:u}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(ai);let f;try{const d=u.slice(0,-1).reduce((_,g)=>_[g],i),h=u.reduce((_,g)=>_[g],i);switch(a){case"GET":f=h;break;case"SET":d[u.slice(-1)[0]]=ai(n.data.value),f=!0;break;case"APPLY":f=h.apply(d,c);break;case"CONSTRUCT":{const _=new h(...c);f=FD(_)}break;case"ENDPOINT":{const{port1:_,port2:g}=new MessageChannel;ou(i,g),f=MD(_,[_])}break;case"RELEASE":f=void 0;break;default:return}}catch(d){f={value:d,[xo]:0}}Promise.resolve(f).catch(d=>({value:d,[xo]:0})).then(d=>{const[h,_]=Mo(d);t.postMessage(Object.assign(Object.assign({},h),{id:s}),_),a==="RELEASE"&&(t.removeEventListener("message",r),zh(t),su in i&&typeof i[su]=="function"&&i[su]())}).catch(d=>{const[h,_]=Mo({value:new TypeError("Unserializable return value"),[xo]:0});t.postMessage(Object.assign(Object.assign({},h),{id:s}),_)})}),t.start&&t.start()}function bD(i){return i.constructor.name==="MessagePort"}function zh(i){bD(i)&&i.close()}function xD(i,t){return au(i,[],t)}function Eo(i){if(i)throw new Error("Proxy has been released and is not useable")}function qh(i){return Li(i,{type:"RELEASE"}).then(()=>{zh(i)})}const Co=new WeakMap,Ao="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(Co.get(i)||0)-1;Co.set(i,t),t===0&&qh(i)});function ED(i,t){const e=(Co.get(t)||0)+1;Co.set(t,e),Ao&&Ao.register(i,t,i)}function CD(i){Ao&&Ao.unregister(i)}function au(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(Eo(r),a===vD)return()=>{CD(n),qh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const u=Li(i,{type:"GET",path:t.map(c=>c.toString())}).then(ai);return u.then.bind(u)}return au(i,[...t,a])},set(s,a,u){Eo(r);const[c,f]=Mo(u);return Li(i,{type:"SET",path:[...t,a].map(d=>d.toString()),value:c},f).then(ai)},apply(s,a,u){Eo(r);const c=t[t.length-1];if(c===gD)return Li(i,{type:"ENDPOINT"}).then(ai);if(c==="bind")return au(i,t.slice(0,-1));const[f,d]=Uh(u);return Li(i,{type:"APPLY",path:t.map(h=>h.toString()),argumentList:f},d).then(ai)},construct(s,a){Eo(r);const[u,c]=Uh(a);return Li(i,{type:"CONSTRUCT",path:t.map(f=>f.toString()),argumentList:u},c).then(ai)}});return ED(n,i),n}function AD(i){return Array.prototype.concat.apply([],i)}function Uh(i){const t=i.map(Mo);return[t.map(e=>e[0]),AD(t.map(e=>e[1]))]}const Wh=new WeakMap;function MD(i,t){return Wh.set(i,t),i}function FD(i){return Object.assign(i,{[Rh]:!0})}function Mo(i){for(const[t,e]of kh)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},Wh.get(i)||[]]}function ai(i){switch(i.type){case"HANDLER":return kh.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Li(i,t,e){return new Promise(r=>{const n=ND();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function ND(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class SD{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}class jh extends Error{constructor(e,r,n){const s=e.status||e.status===0?e.status:"",a=e.statusText||"",u=`${s} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`);$(this,"response");$(this,"request");$(this,"options");this.name="HTTPError",this.response=e,this.request=r,this.options=n}}class Yh extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`);$(this,"request");this.name="TimeoutError",this.request=e}}const ls=i=>i!==null&&typeof i=="object",Fo=(...i)=>{for(const t of i)if((!ls(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return uu({},...i)},Vh=(i={},t={})=>{const e=new globalThis.Headers(i),r=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[s,a]of n.entries())r&&a==="undefined"||a===void 0?e.delete(s):e.set(s,a);return e};function No(i,t,e){return Object.hasOwn(t,e)&&t[e]===void 0?[]:uu(i[e]??[],t[e]??[])}const Hh=(i={},t={})=>({beforeRequest:No(i,t,"beforeRequest"),beforeRetry:No(i,t,"beforeRetry"),afterResponse:No(i,t,"afterResponse"),beforeError:No(i,t,"beforeError")}),uu=(...i)=>{let t={},e={},r={};for(const n of i)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(ls(n)){for(let[s,a]of Object.entries(n))ls(a)&&s in t&&(a=uu(t[s],a)),t={...t,[s]:a};ls(n.hooks)&&(r=Hh(r,n.hooks),t.hooks=r),ls(n.headers)&&(e=Vh(e,n.headers),t.headers=e)}return t},OD=(()=>{let i=!1,t=!1;const e=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(e&&r)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return i=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return i&&!t})(),BD=typeof globalThis.AbortController=="function",TD=typeof globalThis.ReadableStream=="function",ID=typeof globalThis.FormData=="function",Zh=["get","post","put","patch","head","delete"],$D={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},lu=2147483647,Kh=Symbol("stop"),LD={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},RD={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},PD=i=>Zh.includes(i)?i.toUpperCase():i,Gh={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:i=>.3*2**(i-1)*1e3},kD=(i={})=>{if(typeof i=="number")return{...Gh,limit:i};if(i.methods&&!Array.isArray(i.methods))throw new Error("retry.methods must be an array");if(i.statusCodes&&!Array.isArray(i.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Gh,...i}};async function zD(i,t,e,r){return new Promise((n,s)=>{const a=setTimeout(()=>{e&&e.abort(),s(new Yh(i))},r.timeout);r.fetch(i,t).then(n).catch(s).then(()=>{clearTimeout(a)})})}async function qD(i,{signal:t}){return new Promise((e,r)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(s),r(t.reason)}const s=setTimeout(()=>{t==null||t.removeEventListener("abort",n),e()},i)})}const UD=(i,t)=>{const e={};for(const r in t)!(r in RD)&&!(r in LD)&&!(r in i)&&(e[r]=t[r]);return e};class So{constructor(t,e={}){$(this,"request");$(this,"abortController");$(this,"_retryCount",0);$(this,"_input");$(this,"_options");var r,n;if(this._input=t,this._options={...e,headers:Vh(this._input.headers,e.headers),hooks:Hh({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:PD(e.method??this._input.method),prefixUrl:String(e.prefixUrl||""),retry:kD(e.retry),throwHttpErrors:e.throwHttpErrors!==!1,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(BD){this.abortController=new globalThis.AbortController;const s=this._options.signal??this._input.signal;s==null||s.addEventListener("abort",()=>{this.abortController.abort(s.reason)}),this._options.signal=this.abortController.signal}if(OD&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((n=(r=this._options).stringifyJson)==null?void 0:n.call(r,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const a="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(ID&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(u,{...this.request}),this._options)}}static create(t,e){const r=new So(t,e),n=async()=>{if(typeof r._options.timeout=="number"&&r._options.timeout>lu)throw new RangeError(`The \`timeout\` option cannot be greater than ${lu}`);await Promise.resolve();let u=await r._fetch();for(const c of r._options.hooks.afterResponse){const f=await c(r.request,r._options,r._decorateResponse(u.clone()));f instanceof globalThis.Response&&(u=f)}if(r._decorateResponse(u),!u.ok&&r._options.throwHttpErrors){let c=new jh(u,r.request,r._options);for(const f of r._options.hooks.beforeError)c=await f(c);throw c}if(r._options.onDownloadProgress){if(typeof r._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!TD)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return r._stream(u.clone(),r._options.onDownloadProgress)}return u},a=r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(n):n();for(const[u,c]of Object.entries($D))a[u]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||c);const d=(await a).clone();if(u==="json"){if(d.status===204||(await d.clone().arrayBuffer()).byteLength===0)return"";if(e.parseJson)return e.parseJson(await d.text())}return d[u]()};return a}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Yh)throw t;if(t instanceof jh){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const r=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(r&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(r)*1e3;Number.isNaN(n)?n=Date.parse(r)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const s=this._options.retry.maxRetryAfter??n;return n<s?n:s}if(t.response.status===413)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const r=Math.min(this._calculateRetryDelay(e),lu);if(this._retryCount<1)throw e;await qD(r,{signal:this._options.signal});for(const n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Kh)return;return this._retry(t)}}async _fetch(){for(const r of this._options.hooks.beforeRequest){const n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}const t=UD(this.request,this._options),e=this.request;return this.request=e.clone(),this._options.timeout===!1?this._options.fetch(e,t):zD(e,t,this.abortController,this._options)}_stream(t,e){const r=Number(t.headers.get("content-length"))||0;let n=0;return t.status===204?(e&&e({percent:1,totalBytes:r,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(s){const a=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){const{done:c,value:f}=await a.read();if(c){s.close();return}if(e){n+=f.byteLength;const d=r===0?0:n/r;e({percent:d,transferredBytes:n,totalBytes:r},f)}s.enqueue(f),await u()}await u()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}/*! MIT License © Sindre Sorhus */const cu=i=>{const t=(e,r)=>So.create(e,Fo(i,r));for(const e of Zh)t[e]=(r,n)=>So.create(r,Fo(i,n,{method:e}));return t.create=e=>cu(Fo(e)),t.extend=e=>(typeof e=="function"&&(e=e(i??{})),cu(Fo(i,e))),t.stop=Kh,t},WD=cu().create({prefixUrl:"https://data.tradingvue.com/",retry:0});function jD(i){return WD.post("symbol/data/v1/",{json:i})}async function YD(i,t,e){var A,N,S;const{data:r,isPreParser:n,id:s="default",syminfo:a={},interval:u,inputs:c,chart:f,strategy:d,scriptType:h,isManuallyAdd:_,subscribeData:g}=t;self.workerStorage||(self.workerStorage=new SD);let{builtInGather:y,buildinConstants:p,buildInFunctions:w,tradingvueFunc:v}=self.workerStorage.get(s)||{},x=[];const b=a.mintick?Number(a.mintick):1e-5;a.mintick=b,e&&(y=new Lh(s),p=new Ch,w=new $h(b,y,s),v=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:y,buildinConstants:p,buildInFunctions:w,tradingvueFunc:v}),self.workerStorage.set(`request_${s}`,new Map),(_||!self.workerStorage.has(`request_${s}_data`))&&self.workerStorage.set(`request_${s}_data`,new Map),self.workerStorage.set(`request_${s}_list`,new Map),self.workerStorage.set(`request_${s}_tmp`,new Map));let C=[];if(VD(g,s),n)v(y,p,w);else if(r&&r.length){const I=r.length-1;y.updateOptions({interval:u,mintick:b,chart:f,syminfo:a}),w.updateOptions({inputs:c,strategy:d});const F=self.workerStorage.get(`request_${s}_tmp`),O=self.workerStorage.get(`request_${s}_data`);try{let L;for(const[q,W]of r.entries()){const{barindex:R}=W;if(!e&&(R||R===0)&&x.push(R),F!=null&&F.size){const Y=[],G=[];for(const[ut,_t]of F){const{symbol:at,timeframe:vt,id:wt,calc_bars_count:Ct,ignore_invalid_symbol:bt}=_t,re=`${at}:${vt}`;G.push({id:wt,key:re,ignore_invalid_symbol:bt});const[Bt,Nt]=at.split(":");Y.push(jD({params:[{exchange:Bt,symbol:Nt,limit:Ct||5e3,start:0,end:0,period:vt}]}).json())}const Q=await Promise.all(Y);for(const[ut,_t]of Q.entries()){const{code:at,data:vt,msg:wt}=_t,Ct=G[ut];if(at!==200&&!Ct.ignore_invalid_symbol)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:wt,type:Rt.Error}]};O==null||O.set(Ct.id,((N=(A=vt[Ct.key])==null?void 0:A.list)==null?void 0:N.reverse())||[])}F==null||F.clear(),L&&(w.log.clearLogForIndex(L.barIndex),Jh(y,w,p,v,h,L))}L=Object.assign(W,{barIndex:R||q,lastBarIndex:r[I].barindex||I,lastBarTime:r[I].time,nextBarTime:(S=r[q+1])==null?void 0:S.time}),Jh(y,w,p,v,h,L);const Z=w.errors;if(Z.length&&Z.some(Y=>Y.type===Rt.Error))return{status:1,errors:Z}}const z=self.workerStorage.get(`request_${s}_list`);if((z==null?void 0:z.size)>40)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:ie.requestsNumErr,type:Rt.Error}]};if(z!=null&&z.size){const q=new Map;for(const[W,R]of z)C.push(R),e&&(O!=null&&O.has(W))&&q.set(W,O.get(W));e&&self.workerStorage.set(`request_${s}_data`,q)}C.length&&(z==null||z.clear()),e&&self.workerStorage.delete(`request_${s}_tmp`)}catch(L){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:L==null?void 0:L.message,type:Rt.Error}]}}}const E=w.errors;return E.length&&E.some(I=>I.type===Rt.Error)?{status:1,errors:E}:{status:0,requestList:C,errors:E,options:{...w.options(x),id:s}}}function VD(i,t){var n;if(!i)return;const e=self.workerStorage.get(`request_${t}_data`),r=Object.keys(i);if(r.length)for(const s of r){let a=i[s]||[];if(e!=null&&e.has(s)){const u=(e==null?void 0:e.get(s))||[];if(u.length){const c=u[u.length-1].time;a=a.filter(f=>f.time>=c),((n=a[0])==null?void 0:n.time)===c&&u.pop()}e==null||e.set(s,u.concat(a))}}}function Jh(i,t,e,r,n,s){if(i.updateData(s),t.update({barIndex:s.barIndex}),n=n||t.scriptType,s.isrealtime&&n===ic.strategy&&!t.strategy.isCalcOnEveryTick){t.strategy.calcCurrentOrder();return}if(r(i,e,t),t.endExecution(),t.strategy.calcOnOrderFillsData.tradeData){for(;t.strategy.calcOnOrderFillsData.tradeData;)t.strategy.calcOnOrderFillsData.data=t.strategy.calcOnOrderFillsData.tradeData,t.strategy.calcOnOrderFillsData.tradeData=void 0,i.updateData(s,!0),t.update({barIndex:s==null?void 0:s.barIndex}),r(i,e,t),t.endExecution();t.strategy.calcOnOrderFillsData={index:-1}}}function HD(i){var t,e,r,n,s,a;(t=self==null?void 0:self.workerStorage)==null||t.deleteStartwidthKey(i),(e=self==null?void 0:self.workerStorage)==null||e.delete(`inputs_${i}`),(r=self==null?void 0:self.workerStorage)==null||r.delete(`strategy_${i}`),(n=self==null?void 0:self.workerStorage)==null||n.delete(`request_${i}`),(s=self==null?void 0:self.workerStorage)==null||s.delete(`request_${i}_data`),(a=self==null?void 0:self.workerStorage)==null||a.delete(`request_${i}_list`)}ou({runScript:YD,removeScript:HD})})();
|