@guihz/trading-vue-editor-tes 0.0.193 → 0.0.195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/{parserTccWorker-BmFWyyKc.js → parserTccWorker-BRdbggcL.js} +1 -1
- package/lib/assets/{scriptsRunWorker-D4hM4juw.js → scriptsRunWorker-BD3Df3Mn.js} +15 -15
- package/lib/components/editor/parseScript/buildInFuncNamespace/strategy.d.ts +1 -0
- package/lib/components/editor/parseScript/buildInVarNamespace/syminfo.d.ts +2 -2
- package/lib/components/editor/utils/calc.d.ts +53 -0
- package/lib/trading-vue-editor.js +2 -2
- package/lib/trading-vue-editor.umd.cjs +1 -1
- package/package.json +1 -1
@@ -5,9 +5,9 @@ var k2=Object.defineProperty;var U2=(Vt,Gt,Ne)=>Gt in Vt?k2(Vt,Gt,{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
|
-
*/Yn.exports,function(s,t){(function(){var e,r="4.17.21",n=200,i="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,p="__lodash_placeholder__",f=1,d=2,g=4,y=1,m=2,w=1,v=2,x=4,b=8,N=16,E=32,C=64,M=128,S=256,T=512,F=30,O="...",R=800,U=16,k=1,W=2,z=3,K=1/0,Z=9007199254740991,X=17976931348623157e292,Q=NaN,ct=4294967295,vt=ct-1,lt=ct>>>1,wt=[["ary",M],["bind",w],["bindKey",v],["curry",b],["curryRight",N],["flip",T],["partial",E],["partialRight",C],["rearg",S]],bt="[object Arguments]",Bt="[object Array]",xt="[object AsyncFunction]",oe="[object Boolean]",It="[object Date]",Nt="[object DOMException]",ce="[object Error]",re="[object Function]",kt="[object GeneratorFunction]",Jt="[object Map]",Le="[object Number]",vr="[object Null]",ze="[object Object]",pn="[object Promise]",On="[object Proxy]",dn="[object RegExp]",yr="[object Set]",In="[object String]",L="[object Symbol]",V="[object Undefined]",G="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",at="[object Int16Array]",Xt="[object Int32Array]",ne="[object Uint8Array]",be="[object Uint8ClampedArray]",We="[object Uint16Array]",qe="[object Uint32Array]",wr=/\b__p \+= '';/g,Dr=/\b(__p \+=) '' \+/g,Tn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ti=/&(?:amp|lt|gt|quot|#39);/g,vo=/[&<>"']/g,Ya=RegExp(ti.source),Va=RegExp(vo.source),Za=/<%-([\s\S]+?)%>/g,Ka=/<%([\s\S]+?)%>/g,yo=/<%=([\s\S]+?)%>/g,Ga=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ha=/^\w*$/,Ja=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rs=/[\\^$.*+?()[\]{}|]/g,Xa=RegExp(rs.source),ns=/^\s+/,Qa=/\s/,tu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,eu=/\{\n\/\* \[wrapped with (.+)\] \*/,ru=/,? & /,nu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,iu=/[()=,{}\[\]\/\s]/,su=/\\(\\)?/g,ou=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,wo=/\w*$/,au=/^[-+]0x[0-9a-f]+$/i,uu=/^0b[01]+$/i,lu=/^\[object .+?Constructor\]$/,cu=/^0o[0-7]+$/i,fu=/^(?:0|[1-9]\d*)$/,hu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Si=/($^)/,ei=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",Qe="\\u0300-\\u036f",pu="\\ufe20-\\ufe2f",Bi="\\u20d0-\\u20ff",$n=Qe+pu+Bi,Do="\\u2700-\\u27bf",dh="a-z\\xdf-\\xf6\\xf8-\\xff",Rw="\\xac\\xb1\\xd7\\xf7",Pw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",zw="\\u2000-\\u206f",qw=" \\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",_h="A-Z\\xc0-\\xd6\\xd8-\\xde",mh="\\ufe0e\\ufe0f",gh=Rw+Pw+zw+qw,du="['’]",kw="["+Zt+"]",vh="["+gh+"]",bo="["+$n+"]",yh="\\d+",Uw="["+Do+"]",wh="["+dh+"]",Dh="[^"+Zt+gh+yh+Do+dh+_h+"]",_u="\\ud83c[\\udffb-\\udfff]",Ww="(?:"+bo+"|"+_u+")",bh="[^"+Zt+"]",mu="(?:\\ud83c[\\udde6-\\uddff]){2}",gu="[\\ud800-\\udbff][\\udc00-\\udfff]",Oi="["+_h+"]",xh="\\u200d",Eh="(?:"+wh+"|"+Dh+")",jw="(?:"+Oi+"|"+Dh+")",Ah="(?:"+du+"(?:d|ll|m|re|s|t|ve))?",Ch="(?:"+du+"(?:D|LL|M|RE|S|T|VE))?",Fh=Ww+"?",Mh="["+mh+"]?",Yw="(?:"+xh+"(?:"+[bh,mu,gu].join("|")+")"+Mh+Fh+")*",Vw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Zw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Nh=Mh+Fh+Yw,Kw="(?:"+[Uw,mu,gu].join("|")+")"+Nh,Gw="(?:"+[bh+bo+"?",bo,mu,gu,kw].join("|")+")",Hw=RegExp(du,"g"),Jw=RegExp(bo,"g"),vu=RegExp(_u+"(?="+_u+")|"+Gw+Nh,"g"),Xw=RegExp([Oi+"?"+wh+"+"+Ah+"(?="+[vh,Oi,"$"].join("|")+")",jw+"+"+Ch+"(?="+[vh,Oi+Eh,"$"].join("|")+")",Oi+"?"+Eh+"+"+Ah,Oi+"+"+Ch,Zw,Vw,yh,Kw].join("|"),"g"),Qw=RegExp("["+xh+Zt+$n+mh+"]"),tD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,eD=["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"],rD=-1,ye={};ye[ft]=ye[ut]=ye[ht]=ye[at]=ye[Xt]=ye[ne]=ye[be]=ye[We]=ye[qe]=!0,ye[bt]=ye[Bt]=ye[st]=ye[oe]=ye[rt]=ye[It]=ye[ce]=ye[re]=ye[Jt]=ye[Le]=ye[ze]=ye[dn]=ye[yr]=ye[In]=ye[G]=!1;var _e={};_e[bt]=_e[Bt]=_e[st]=_e[rt]=_e[oe]=_e[It]=_e[ft]=_e[ut]=_e[ht]=_e[at]=_e[Xt]=_e[Jt]=_e[Le]=_e[ze]=_e[dn]=_e[yr]=_e[In]=_e[L]=_e[ne]=_e[be]=_e[We]=_e[qe]=!0,_e[ce]=_e[re]=_e[G]=!1;var nD={À:"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"},iD={"&":"&","<":"<",">":">",'"':""","'":"'"},sD={"&":"&","<":"<",">":">",""":'"',"'":"'"},oD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},aD=parseFloat,uD=parseInt,Sh=typeof Vt=="object"&&Vt&&Vt.Object===Object&&Vt,lD=typeof self=="object"&&self&&self.Object===Object&&self,Ge=Sh||lD||Function("return this")(),yu=t&&!t.nodeType&&t,ri=yu&&!0&&s&&!s.nodeType&&s,Bh=ri&&ri.exports===yu,wu=Bh&&Sh.process,Or=function(){try{var j=ri&&ri.require&&ri.require("util").types;return j||wu&&wu.binding&&wu.binding("util")}catch{}}(),Oh=Or&&Or.isArrayBuffer,Ih=Or&&Or.isDate,Th=Or&&Or.isMap,$h=Or&&Or.isRegExp,Lh=Or&&Or.isSet,Rh=Or&&Or.isTypedArray;function br(j,J,H){switch(H.length){case 0:return j.call(J);case 1:return j.call(J,H[0]);case 2:return j.call(J,H[0],H[1]);case 3:return j.call(J,H[0],H[1],H[2])}return j.apply(J,H)}function cD(j,J,H,gt){for(var Ot=-1,te=j==null?0:j.length;++Ot<te;){var ke=j[Ot];J(gt,ke,H(ke),j)}return gt}function Ir(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt&&J(j[H],H,j)!==!1;);return j}function fD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function Ph(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(!J(j[H],H,j))return!1;return!0}function Ln(j,J){for(var H=-1,gt=j==null?0:j.length,Ot=0,te=[];++H<gt;){var ke=j[H];J(ke,H,j)&&(te[Ot++]=ke)}return te}function xo(j,J){var H=j==null?0:j.length;return!!H&&Ii(j,J,0)>-1}function Du(j,J,H){for(var gt=-1,Ot=j==null?0:j.length;++gt<Ot;)if(H(J,j[gt]))return!0;return!1}function xe(j,J){for(var H=-1,gt=j==null?0:j.length,Ot=Array(gt);++H<gt;)Ot[H]=J(j[H],H,j);return Ot}function Rn(j,J){for(var H=-1,gt=J.length,Ot=j.length;++H<gt;)j[Ot+H]=J[H];return j}function bu(j,J,H,gt){var Ot=-1,te=j==null?0:j.length;for(gt&&te&&(H=j[++Ot]);++Ot<te;)H=J(H,j[Ot],Ot,j);return H}function hD(j,J,H,gt){var Ot=j==null?0:j.length;for(gt&&Ot&&(H=j[--Ot]);Ot--;)H=J(H,j[Ot],Ot,j);return H}function xu(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(J(j[H],H,j))return!0;return!1}var pD=Eu("length");function dD(j){return j.split("")}function _D(j){return j.match(nu)||[]}function zh(j,J,H){var gt;return H(j,function(Ot,te,ke){if(J(Ot,te,ke))return gt=te,!1}),gt}function Eo(j,J,H,gt){for(var Ot=j.length,te=H+(gt?1:-1);gt?te--:++te<Ot;)if(J(j[te],te,j))return te;return-1}function Ii(j,J,H){return J===J?FD(j,J,H):Eo(j,qh,H)}function mD(j,J,H,gt){for(var Ot=H-1,te=j.length;++Ot<te;)if(gt(j[Ot],J))return Ot;return-1}function qh(j){return j!==j}function kh(j,J){var H=j==null?0:j.length;return H?Cu(j,J)/H:Q}function Eu(j){return function(J){return J==null?e:J[j]}}function Au(j){return function(J){return j==null?e:j[J]}}function Uh(j,J,H,gt,Ot){return Ot(j,function(te,ke,pe){H=gt?(gt=!1,te):J(H,te,ke,pe)}),H}function gD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Cu(j,J){for(var H,gt=-1,Ot=j.length;++gt<Ot;){var te=J(j[gt]);te!==e&&(H=H===e?te:H+te)}return H}function Fu(j,J){for(var H=-1,gt=Array(j);++H<j;)gt[H]=J(H);return gt}function vD(j,J){return xe(J,function(H){return[H,j[H]]})}function Wh(j){return j&&j.slice(0,Zh(j)+1).replace(ns,"")}function xr(j){return function(J){return j(J)}}function Mu(j,J){return xe(J,function(H){return j[H]})}function is(j,J){return j.has(J)}function jh(j,J){for(var H=-1,gt=j.length;++H<gt&&Ii(J,j[H],0)>-1;);return H}function Yh(j,J){for(var H=j.length;H--&&Ii(J,j[H],0)>-1;);return H}function yD(j,J){for(var H=j.length,gt=0;H--;)j[H]===J&&++gt;return gt}var wD=Au(nD),DD=Au(iD);function bD(j){return"\\"+oD[j]}function xD(j,J){return j==null?e:j[J]}function Ti(j){return Qw.test(j)}function ED(j){return tD.test(j)}function AD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function Nu(j){var J=-1,H=Array(j.size);return j.forEach(function(gt,Ot){H[++J]=[Ot,gt]}),H}function Vh(j,J){return function(H){return j(J(H))}}function Pn(j,J){for(var H=-1,gt=j.length,Ot=0,te=[];++H<gt;){var ke=j[H];(ke===J||ke===p)&&(j[H]=p,te[Ot++]=H)}return te}function Ao(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=gt}),H}function CD(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=[gt,gt]}),H}function FD(j,J,H){for(var gt=H-1,Ot=j.length;++gt<Ot;)if(j[gt]===J)return gt;return-1}function MD(j,J,H){for(var gt=H+1;gt--;)if(j[gt]===J)return gt;return gt}function $i(j){return Ti(j)?SD(j):pD(j)}function Zr(j){return Ti(j)?BD(j):dD(j)}function Zh(j){for(var J=j.length;J--&&Qa.test(j.charAt(J)););return J}var ND=Au(sD);function SD(j){for(var J=vu.lastIndex=0;vu.test(j);)++J;return J}function BD(j){return j.match(vu)||[]}function OD(j){return j.match(Xw)||[]}var ID=function j(J){J=J==null?Ge:Li.defaults(Ge.Object(),J,Li.pick(Ge,eD));var H=J.Array,gt=J.Date,Ot=J.Error,te=J.Function,ke=J.Math,pe=J.Object,Su=J.RegExp,TD=J.String,Tr=J.TypeError,Co=H.prototype,$D=te.prototype,Ri=pe.prototype,Fo=J["__core-js_shared__"],Mo=$D.toString,ae=Ri.hasOwnProperty,LD=0,Kh=function(){var o=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),No=Ri.toString,RD=Mo.call(pe),PD=Ge._,zD=Su("^"+Mo.call(ae).replace(rs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),So=Bh?J.Buffer:e,zn=J.Symbol,Bo=J.Uint8Array,Gh=So?So.allocUnsafe:e,Oo=Vh(pe.getPrototypeOf,pe),Hh=pe.create,Jh=Ri.propertyIsEnumerable,Io=Co.splice,Xh=zn?zn.isConcatSpreadable:e,ss=zn?zn.iterator:e,ni=zn?zn.toStringTag:e,To=function(){try{var o=ui(pe,"defineProperty");return o({},"",{}),o}catch{}}(),qD=J.clearTimeout!==Ge.clearTimeout&&J.clearTimeout,kD=gt&>.now!==Ge.Date.now&>.now,UD=J.setTimeout!==Ge.setTimeout&&J.setTimeout,$o=ke.ceil,Lo=ke.floor,Bu=pe.getOwnPropertySymbols,WD=So?So.isBuffer:e,Qh=J.isFinite,jD=Co.join,YD=Vh(pe.keys,pe),Ue=ke.max,tr=ke.min,VD=gt.now,ZD=J.parseInt,t0=ke.random,KD=Co.reverse,Ou=ui(J,"DataView"),os=ui(J,"Map"),Iu=ui(J,"Promise"),Pi=ui(J,"Set"),as=ui(J,"WeakMap"),us=ui(pe,"create"),Ro=as&&new as,zi={},GD=li(Ou),HD=li(os),JD=li(Iu),XD=li(Pi),QD=li(as),Po=zn?zn.prototype:e,ls=Po?Po.valueOf:e,e0=Po?Po.toString:e;function B(o){if(Me(o)&&!Tt(o)&&!(o instanceof jt)){if(o instanceof $r)return o;if(ae.call(o,"__wrapped__"))return rp(o)}return new $r(o)}var qi=function(){function o(){}return function(u){if(!Ce(u))return{};if(Hh)return Hh(u);o.prototype=u;var _=new o;return o.prototype=e,_}}();function zo(){}function $r(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}B.templateSettings={escape:Za,evaluate:Ka,interpolate:yo,variable:"",imports:{_:B}},B.prototype=zo.prototype,B.prototype.constructor=B,$r.prototype=qi(zo.prototype),$r.prototype.constructor=$r;function jt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function tb(){var o=new jt(this.__wrapped__);return o.__actions__=fr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=fr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=fr(this.__views__),o}function eb(){if(this.__filtered__){var o=new jt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function rb(){var o=this.__wrapped__.value(),u=this.__dir__,_=Tt(o),D=u<0,A=_?o.length:0,I=dx(0,A,this.__views__),P=I.start,q=I.end,Y=q-P,tt=D?q:P-1,et=this.__iteratees__,ot=et.length,dt=0,yt=tr(Y,this.__takeCount__);if(!_||!D&&A==Y&&yt==Y)return A0(o,this.__actions__);var Ct=[];t:for(;Y--&&dt<yt;){tt+=u;for(var Rt=-1,Ft=o[tt];++Rt<ot;){var Ut=et[Rt],Yt=Ut.iteratee,Cr=Ut.type,ar=Yt(Ft);if(Cr==W)Ft=ar;else if(!ar){if(Cr==k)continue t;break t}}Ct[dt++]=Ft}return Ct}jt.prototype=qi(zo.prototype),jt.prototype.constructor=jt;function ii(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function nb(){this.__data__=us?us(null):{},this.size=0}function ib(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function sb(o){var u=this.__data__;if(us){var _=u[o];return _===c?e:_}return ae.call(u,o)?u[o]:e}function ob(o){var u=this.__data__;return us?u[o]!==e:ae.call(u,o)}function ab(o,u){var _=this.__data__;return this.size+=this.has(o)?0:1,_[o]=us&&u===e?c:u,this}ii.prototype.clear=nb,ii.prototype.delete=ib,ii.prototype.get=sb,ii.prototype.has=ob,ii.prototype.set=ab;function _n(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function ub(){this.__data__=[],this.size=0}function lb(o){var u=this.__data__,_=qo(u,o);if(_<0)return!1;var D=u.length-1;return _==D?u.pop():Io.call(u,_,1),--this.size,!0}function cb(o){var u=this.__data__,_=qo(u,o);return _<0?e:u[_][1]}function fb(o){return qo(this.__data__,o)>-1}function hb(o,u){var _=this.__data__,D=qo(_,o);return D<0?(++this.size,_.push([o,u])):_[D][1]=u,this}_n.prototype.clear=ub,_n.prototype.delete=lb,_n.prototype.get=cb,_n.prototype.has=fb,_n.prototype.set=hb;function mn(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function pb(){this.size=0,this.__data__={hash:new ii,map:new(os||_n),string:new ii}}function db(o){var u=Xo(this,o).delete(o);return this.size-=u?1:0,u}function _b(o){return Xo(this,o).get(o)}function mb(o){return Xo(this,o).has(o)}function gb(o,u){var _=Xo(this,o),D=_.size;return _.set(o,u),this.size+=_.size==D?0:1,this}mn.prototype.clear=pb,mn.prototype.delete=db,mn.prototype.get=_b,mn.prototype.has=mb,mn.prototype.set=gb;function si(o){var u=-1,_=o==null?0:o.length;for(this.__data__=new mn;++u<_;)this.add(o[u])}function vb(o){return this.__data__.set(o,c),this}function yb(o){return this.__data__.has(o)}si.prototype.add=si.prototype.push=vb,si.prototype.has=yb;function Kr(o){var u=this.__data__=new _n(o);this.size=u.size}function wb(){this.__data__=new _n,this.size=0}function Db(o){var u=this.__data__,_=u.delete(o);return this.size=u.size,_}function bb(o){return this.__data__.get(o)}function xb(o){return this.__data__.has(o)}function Eb(o,u){var _=this.__data__;if(_ instanceof _n){var D=_.__data__;if(!os||D.length<n-1)return D.push([o,u]),this.size=++_.size,this;_=this.__data__=new mn(D)}return _.set(o,u),this.size=_.size,this}Kr.prototype.clear=wb,Kr.prototype.delete=Db,Kr.prototype.get=bb,Kr.prototype.has=xb,Kr.prototype.set=Eb;function r0(o,u){var _=Tt(o),D=!_&&ci(o),A=!_&&!D&&jn(o),I=!_&&!D&&!A&&ji(o),P=_||D||A||I,q=P?Fu(o.length,TD):[],Y=q.length;for(var tt in o)(u||ae.call(o,tt))&&!(P&&(tt=="length"||A&&(tt=="offset"||tt=="parent")||I&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||wn(tt,Y)))&&q.push(tt);return q}function n0(o){var u=o.length;return u?o[ju(0,u-1)]:e}function Ab(o,u){return Qo(fr(o),oi(u,0,o.length))}function Cb(o){return Qo(fr(o))}function Tu(o,u,_){(_!==e&&!Gr(o[u],_)||_===e&&!(u in o))&&gn(o,u,_)}function cs(o,u,_){var D=o[u];(!(ae.call(o,u)&&Gr(D,_))||_===e&&!(u in o))&&gn(o,u,_)}function qo(o,u){for(var _=o.length;_--;)if(Gr(o[_][0],u))return _;return-1}function Fb(o,u,_,D){return qn(o,function(A,I,P){u(D,A,_(A),P)}),D}function i0(o,u){return o&&sn(u,je(u),o)}function Mb(o,u){return o&&sn(u,pr(u),o)}function gn(o,u,_){u=="__proto__"&&To?To(o,u,{configurable:!0,enumerable:!0,value:_,writable:!0}):o[u]=_}function $u(o,u){for(var _=-1,D=u.length,A=H(D),I=o==null;++_<D;)A[_]=I?e:_l(o,u[_]);return A}function oi(o,u,_){return o===o&&(_!==e&&(o=o<=_?o:_),u!==e&&(o=o>=u?o:u)),o}function Lr(o,u,_,D,A,I){var P,q=u&f,Y=u&d,tt=u&g;if(_&&(P=A?_(o,D,A,I):_(o)),P!==e)return P;if(!Ce(o))return o;var et=Tt(o);if(et){if(P=mx(o),!q)return fr(o,P)}else{var ot=er(o),dt=ot==re||ot==kt;if(jn(o))return M0(o,q);if(ot==ze||ot==bt||dt&&!A){if(P=Y||dt?{}:Z0(o),!q)return Y?sx(o,Mb(P,o)):ix(o,i0(P,o))}else{if(!_e[ot])return A?o:{};P=gx(o,ot,q)}}I||(I=new Kr);var yt=I.get(o);if(yt)return yt;I.set(o,P),bp(o)?o.forEach(function(Ft){P.add(Lr(Ft,u,_,Ft,o,I))}):wp(o)&&o.forEach(function(Ft,Ut){P.set(Ut,Lr(Ft,u,_,Ut,o,I))});var Ct=tt?Y?el:tl:Y?pr:je,Rt=et?e:Ct(o);return Ir(Rt||o,function(Ft,Ut){Rt&&(Ut=Ft,Ft=o[Ut]),cs(P,Ut,Lr(Ft,u,_,Ut,o,I))}),P}function Nb(o){var u=je(o);return function(_){return s0(_,o,u)}}function s0(o,u,_){var D=_.length;if(o==null)return!D;for(o=pe(o);D--;){var A=_[D],I=u[A],P=o[A];if(P===e&&!(A in o)||!I(P))return!1}return!0}function o0(o,u,_){if(typeof o!="function")throw new Tr(a);return gs(function(){o.apply(e,_)},u)}function fs(o,u,_,D){var A=-1,I=xo,P=!0,q=o.length,Y=[],tt=u.length;if(!q)return Y;_&&(u=xe(u,xr(_))),D?(I=Du,P=!1):u.length>=n&&(I=is,P=!1,u=new si(u));t:for(;++A<q;){var et=o[A],ot=_==null?et:_(et);if(et=D||et!==0?et:0,P&&ot===ot){for(var dt=tt;dt--;)if(u[dt]===ot)continue t;Y.push(et)}else I(u,ot,D)||Y.push(et)}return Y}var qn=I0(nn),a0=I0(Ru,!0);function Sb(o,u){var _=!0;return qn(o,function(D,A,I){return _=!!u(D,A,I),_}),_}function ko(o,u,_){for(var D=-1,A=o.length;++D<A;){var I=o[D],P=u(I);if(P!=null&&(q===e?P===P&&!Ar(P):_(P,q)))var q=P,Y=I}return Y}function Bb(o,u,_,D){var A=o.length;for(_=Lt(_),_<0&&(_=-_>A?0:A+_),D=D===e||D>A?A:Lt(D),D<0&&(D+=A),D=_>D?0:Ep(D);_<D;)o[_++]=u;return o}function u0(o,u){var _=[];return qn(o,function(D,A,I){u(D,A,I)&&_.push(D)}),_}function He(o,u,_,D,A){var I=-1,P=o.length;for(_||(_=yx),A||(A=[]);++I<P;){var q=o[I];u>0&&_(q)?u>1?He(q,u-1,_,D,A):Rn(A,q):D||(A[A.length]=q)}return A}var Lu=T0(),l0=T0(!0);function nn(o,u){return o&&Lu(o,u,je)}function Ru(o,u){return o&&l0(o,u,je)}function Uo(o,u){return Ln(u,function(_){return Dn(o[_])})}function ai(o,u){u=Un(u,o);for(var _=0,D=u.length;o!=null&&_<D;)o=o[on(u[_++])];return _&&_==D?o:e}function c0(o,u,_){var D=u(o);return Tt(o)?D:Rn(D,_(o))}function sr(o){return o==null?o===e?V:vr:ni&&ni in pe(o)?px(o):Cx(o)}function Pu(o,u){return o>u}function Ob(o,u){return o!=null&&ae.call(o,u)}function Ib(o,u){return o!=null&&u in pe(o)}function Tb(o,u,_){return o>=tr(u,_)&&o<Ue(u,_)}function zu(o,u,_){for(var D=_?Du:xo,A=o[0].length,I=o.length,P=I,q=H(I),Y=1/0,tt=[];P--;){var et=o[P];P&&u&&(et=xe(et,xr(u))),Y=tr(et.length,Y),q[P]=!_&&(u||A>=120&&et.length>=120)?new si(P&&et):e}et=o[0];var ot=-1,dt=q[0];t:for(;++ot<A&&tt.length<Y;){var yt=et[ot],Ct=u?u(yt):yt;if(yt=_||yt!==0?yt:0,!(dt?is(dt,Ct):D(tt,Ct,_))){for(P=I;--P;){var Rt=q[P];if(!(Rt?is(Rt,Ct):D(o[P],Ct,_)))continue t}dt&&dt.push(Ct),tt.push(yt)}}return tt}function $b(o,u,_,D){return nn(o,function(A,I,P){u(D,_(A),I,P)}),D}function hs(o,u,_){u=Un(u,o),o=J0(o,u);var D=o==null?o:o[on(Pr(u))];return D==null?e:br(D,o,_)}function f0(o){return Me(o)&&sr(o)==bt}function Lb(o){return Me(o)&&sr(o)==st}function Rb(o){return Me(o)&&sr(o)==It}function ps(o,u,_,D,A){return o===u?!0:o==null||u==null||!Me(o)&&!Me(u)?o!==o&&u!==u:Pb(o,u,_,D,ps,A)}function Pb(o,u,_,D,A,I){var P=Tt(o),q=Tt(u),Y=P?Bt:er(o),tt=q?Bt:er(u);Y=Y==bt?ze:Y,tt=tt==bt?ze:tt;var et=Y==ze,ot=tt==ze,dt=Y==tt;if(dt&&jn(o)){if(!jn(u))return!1;P=!0,et=!1}if(dt&&!et)return I||(I=new Kr),P||ji(o)?j0(o,u,_,D,A,I):fx(o,u,Y,_,D,A,I);if(!(_&y)){var yt=et&&ae.call(o,"__wrapped__"),Ct=ot&&ae.call(u,"__wrapped__");if(yt||Ct){var Rt=yt?o.value():o,Ft=Ct?u.value():u;return I||(I=new Kr),A(Rt,Ft,_,D,I)}}return dt?(I||(I=new Kr),hx(o,u,_,D,A,I)):!1}function zb(o){return Me(o)&&er(o)==Jt}function qu(o,u,_,D){var A=_.length,I=A,P=!D;if(o==null)return!I;for(o=pe(o);A--;){var q=_[A];if(P&&q[2]?q[1]!==o[q[0]]:!(q[0]in o))return!1}for(;++A<I;){q=_[A];var Y=q[0],tt=o[Y],et=q[1];if(P&&q[2]){if(tt===e&&!(Y in o))return!1}else{var ot=new Kr;if(D)var dt=D(tt,et,Y,o,u,ot);if(!(dt===e?ps(et,tt,y|m,D,ot):dt))return!1}}return!0}function h0(o){if(!Ce(o)||Dx(o))return!1;var u=Dn(o)?zD:lu;return u.test(li(o))}function qb(o){return Me(o)&&sr(o)==dn}function kb(o){return Me(o)&&er(o)==yr}function Ub(o){return Me(o)&&sa(o.length)&&!!ye[sr(o)]}function p0(o){return typeof o=="function"?o:o==null?dr:typeof o=="object"?Tt(o)?m0(o[0],o[1]):_0(o):$p(o)}function ku(o){if(!ms(o))return YD(o);var u=[];for(var _ in pe(o))ae.call(o,_)&&_!="constructor"&&u.push(_);return u}function Wb(o){if(!Ce(o))return Ax(o);var u=ms(o),_=[];for(var D in o)D=="constructor"&&(u||!ae.call(o,D))||_.push(D);return _}function Uu(o,u){return o<u}function d0(o,u){var _=-1,D=hr(o)?H(o.length):[];return qn(o,function(A,I,P){D[++_]=u(A,I,P)}),D}function _0(o){var u=nl(o);return u.length==1&&u[0][2]?G0(u[0][0],u[0][1]):function(_){return _===o||qu(_,o,u)}}function m0(o,u){return sl(o)&&K0(u)?G0(on(o),u):function(_){var D=_l(_,o);return D===e&&D===u?ml(_,o):ps(u,D,y|m)}}function Wo(o,u,_,D,A){o!==u&&Lu(u,function(I,P){if(A||(A=new Kr),Ce(I))jb(o,u,P,_,Wo,D,A);else{var q=D?D(al(o,P),I,P+"",o,u,A):e;q===e&&(q=I),Tu(o,P,q)}},pr)}function jb(o,u,_,D,A,I,P){var q=al(o,_),Y=al(u,_),tt=P.get(Y);if(tt){Tu(o,_,tt);return}var et=I?I(q,Y,_+"",o,u,P):e,ot=et===e;if(ot){var dt=Tt(Y),yt=!dt&&jn(Y),Ct=!dt&&!yt&&ji(Y);et=Y,dt||yt||Ct?Tt(q)?et=q:Be(q)?et=fr(q):yt?(ot=!1,et=M0(Y,!0)):Ct?(ot=!1,et=N0(Y,!0)):et=[]:vs(Y)||ci(Y)?(et=q,ci(q)?et=Ap(q):(!Ce(q)||Dn(q))&&(et=Z0(Y))):ot=!1}ot&&(P.set(Y,et),A(et,Y,D,I,P),P.delete(Y)),Tu(o,_,et)}function g0(o,u){var _=o.length;if(_)return u+=u<0?_:0,wn(u,_)?o[u]:e}function v0(o,u,_){u.length?u=xe(u,function(I){return Tt(I)?function(P){return ai(P,I.length===1?I[0]:I)}:I}):u=[dr];var D=-1;u=xe(u,xr(At()));var A=d0(o,function(I,P,q){var Y=xe(u,function(tt){return tt(I)});return{criteria:Y,index:++D,value:I}});return gD(A,function(I,P){return nx(I,P,_)})}function Yb(o,u){return y0(o,u,function(_,D){return ml(o,D)})}function y0(o,u,_){for(var D=-1,A=u.length,I={};++D<A;){var P=u[D],q=ai(o,P);_(q,P)&&ds(I,Un(P,o),q)}return I}function Vb(o){return function(u){return ai(u,o)}}function Wu(o,u,_,D){var A=D?mD:Ii,I=-1,P=u.length,q=o;for(o===u&&(u=fr(u)),_&&(q=xe(o,xr(_)));++I<P;)for(var Y=0,tt=u[I],et=_?_(tt):tt;(Y=A(q,et,Y,D))>-1;)q!==o&&Io.call(q,Y,1),Io.call(o,Y,1);return o}function w0(o,u){for(var _=o?u.length:0,D=_-1;_--;){var A=u[_];if(_==D||A!==I){var I=A;wn(A)?Io.call(o,A,1):Zu(o,A)}}return o}function ju(o,u){return o+Lo(t0()*(u-o+1))}function Zb(o,u,_,D){for(var A=-1,I=Ue($o((u-o)/(_||1)),0),P=H(I);I--;)P[D?I:++A]=o,o+=_;return P}function Yu(o,u){var _="";if(!o||u<1||u>Z)return _;do u%2&&(_+=o),u=Lo(u/2),u&&(o+=o);while(u);return _}function Pt(o,u){return ul(H0(o,u,dr),o+"")}function Kb(o){return n0(Yi(o))}function Gb(o,u){var _=Yi(o);return Qo(_,oi(u,0,_.length))}function ds(o,u,_,D){if(!Ce(o))return o;u=Un(u,o);for(var A=-1,I=u.length,P=I-1,q=o;q!=null&&++A<I;){var Y=on(u[A]),tt=_;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return o;if(A!=P){var et=q[Y];tt=D?D(et,Y,q):e,tt===e&&(tt=Ce(et)?et:wn(u[A+1])?[]:{})}cs(q,Y,tt),q=q[Y]}return o}var D0=Ro?function(o,u){return Ro.set(o,u),o}:dr,Hb=To?function(o,u){return To(o,"toString",{configurable:!0,enumerable:!1,value:vl(u),writable:!0})}:dr;function Jb(o){return Qo(Yi(o))}function Rr(o,u,_){var D=-1,A=o.length;u<0&&(u=-u>A?0:A+u),_=_>A?A:_,_<0&&(_+=A),A=u>_?0:_-u>>>0,u>>>=0;for(var I=H(A);++D<A;)I[D]=o[D+u];return I}function Xb(o,u){var _;return qn(o,function(D,A,I){return _=u(D,A,I),!_}),!!_}function jo(o,u,_){var D=0,A=o==null?D:o.length;if(typeof u=="number"&&u===u&&A<=lt){for(;D<A;){var I=D+A>>>1,P=o[I];P!==null&&!Ar(P)&&(_?P<=u:P<u)?D=I+1:A=I}return A}return Vu(o,u,dr,_)}function Vu(o,u,_,D){var A=0,I=o==null?0:o.length;if(I===0)return 0;u=_(u);for(var P=u!==u,q=u===null,Y=Ar(u),tt=u===e;A<I;){var et=Lo((A+I)/2),ot=_(o[et]),dt=ot!==e,yt=ot===null,Ct=ot===ot,Rt=Ar(ot);if(P)var Ft=D||Ct;else tt?Ft=Ct&&(D||dt):q?Ft=Ct&&dt&&(D||!yt):Y?Ft=Ct&&dt&&!yt&&(D||!Rt):yt||Rt?Ft=!1:Ft=D?ot<=u:ot<u;Ft?A=et+1:I=et}return tr(I,vt)}function b0(o,u){for(var _=-1,D=o.length,A=0,I=[];++_<D;){var P=o[_],q=u?u(P):P;if(!_||!Gr(q,Y)){var Y=q;I[A++]=P===0?0:P}}return I}function x0(o){return typeof o=="number"?o:Ar(o)?Q:+o}function Er(o){if(typeof o=="string")return o;if(Tt(o))return xe(o,Er)+"";if(Ar(o))return e0?e0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function kn(o,u,_){var D=-1,A=xo,I=o.length,P=!0,q=[],Y=q;if(_)P=!1,A=Du;else if(I>=n){var tt=u?null:lx(o);if(tt)return Ao(tt);P=!1,A=is,Y=new si}else Y=u?[]:q;t:for(;++D<I;){var et=o[D],ot=u?u(et):et;if(et=_||et!==0?et:0,P&&ot===ot){for(var dt=Y.length;dt--;)if(Y[dt]===ot)continue t;u&&Y.push(ot),q.push(et)}else A(Y,ot,_)||(Y!==q&&Y.push(ot),q.push(et))}return q}function Zu(o,u){return u=Un(u,o),o=J0(o,u),o==null||delete o[on(Pr(u))]}function E0(o,u,_,D){return ds(o,u,_(ai(o,u)),D)}function Yo(o,u,_,D){for(var A=o.length,I=D?A:-1;(D?I--:++I<A)&&u(o[I],I,o););return _?Rr(o,D?0:I,D?I+1:A):Rr(o,D?I+1:0,D?A:I)}function A0(o,u){var _=o;return _ instanceof jt&&(_=_.value()),bu(u,function(D,A){return A.func.apply(A.thisArg,Rn([D],A.args))},_)}function Ku(o,u,_){var D=o.length;if(D<2)return D?kn(o[0]):[];for(var A=-1,I=H(D);++A<D;)for(var P=o[A],q=-1;++q<D;)q!=A&&(I[A]=fs(I[A]||P,o[q],u,_));return kn(He(I,1),u,_)}function C0(o,u,_){for(var D=-1,A=o.length,I=u.length,P={};++D<A;){var q=D<I?u[D]:e;_(P,o[D],q)}return P}function Gu(o){return Be(o)?o:[]}function Hu(o){return typeof o=="function"?o:dr}function Un(o,u){return Tt(o)?o:sl(o,u)?[o]:ep(ie(o))}var Qb=Pt;function Wn(o,u,_){var D=o.length;return _=_===e?D:_,!u&&_>=D?o:Rr(o,u,_)}var F0=qD||function(o){return Ge.clearTimeout(o)};function M0(o,u){if(u)return o.slice();var _=o.length,D=Gh?Gh(_):new o.constructor(_);return o.copy(D),D}function Ju(o){var u=new o.constructor(o.byteLength);return new Bo(u).set(new Bo(o)),u}function tx(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.byteLength)}function ex(o){var u=new o.constructor(o.source,wo.exec(o));return u.lastIndex=o.lastIndex,u}function rx(o){return ls?pe(ls.call(o)):{}}function N0(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.length)}function S0(o,u){if(o!==u){var _=o!==e,D=o===null,A=o===o,I=Ar(o),P=u!==e,q=u===null,Y=u===u,tt=Ar(u);if(!q&&!tt&&!I&&o>u||I&&P&&Y&&!q&&!tt||D&&P&&Y||!_&&Y||!A)return 1;if(!D&&!I&&!tt&&o<u||tt&&_&&A&&!D&&!I||q&&_&&A||!P&&A||!Y)return-1}return 0}function nx(o,u,_){for(var D=-1,A=o.criteria,I=u.criteria,P=A.length,q=_.length;++D<P;){var Y=S0(A[D],I[D]);if(Y){if(D>=q)return Y;var tt=_[D];return Y*(tt=="desc"?-1:1)}}return o.index-u.index}function B0(o,u,_,D){for(var A=-1,I=o.length,P=_.length,q=-1,Y=u.length,tt=Ue(I-P,0),et=H(Y+tt),ot=!D;++q<Y;)et[q]=u[q];for(;++A<P;)(ot||A<I)&&(et[_[A]]=o[A]);for(;tt--;)et[q++]=o[A++];return et}function O0(o,u,_,D){for(var A=-1,I=o.length,P=-1,q=_.length,Y=-1,tt=u.length,et=Ue(I-q,0),ot=H(et+tt),dt=!D;++A<et;)ot[A]=o[A];for(var yt=A;++Y<tt;)ot[yt+Y]=u[Y];for(;++P<q;)(dt||A<I)&&(ot[yt+_[P]]=o[A++]);return ot}function fr(o,u){var _=-1,D=o.length;for(u||(u=H(D));++_<D;)u[_]=o[_];return u}function sn(o,u,_,D){var A=!_;_||(_={});for(var I=-1,P=u.length;++I<P;){var q=u[I],Y=D?D(_[q],o[q],q,_,o):e;Y===e&&(Y=o[q]),A?gn(_,q,Y):cs(_,q,Y)}return _}function ix(o,u){return sn(o,il(o),u)}function sx(o,u){return sn(o,Y0(o),u)}function Vo(o,u){return function(_,D){var A=Tt(_)?cD:Fb,I=u?u():{};return A(_,o,At(D,2),I)}}function ki(o){return Pt(function(u,_){var D=-1,A=_.length,I=A>1?_[A-1]:e,P=A>2?_[2]:e;for(I=o.length>3&&typeof I=="function"?(A--,I):e,P&&or(_[0],_[1],P)&&(I=A<3?e:I,A=1),u=pe(u);++D<A;){var q=_[D];q&&o(u,q,D,I)}return u})}function I0(o,u){return function(_,D){if(_==null)return _;if(!hr(_))return o(_,D);for(var A=_.length,I=u?A:-1,P=pe(_);(u?I--:++I<A)&&D(P[I],I,P)!==!1;);return _}}function T0(o){return function(u,_,D){for(var A=-1,I=pe(u),P=D(u),q=P.length;q--;){var Y=P[o?q:++A];if(_(I[Y],Y,I)===!1)break}return u}}function ox(o,u,_){var D=u&w,A=_s(o);function I(){var P=this&&this!==Ge&&this instanceof I?A:o;return P.apply(D?_:this,arguments)}return I}function $0(o){return function(u){u=ie(u);var _=Ti(u)?Zr(u):e,D=_?_[0]:u.charAt(0),A=_?Wn(_,1).join(""):u.slice(1);return D[o]()+A}}function Ui(o){return function(u){return bu(Ip(Op(u).replace(Hw,"")),o,"")}}function _s(o){return function(){var u=arguments;switch(u.length){case 0:return new o;case 1:return new o(u[0]);case 2:return new o(u[0],u[1]);case 3:return new o(u[0],u[1],u[2]);case 4:return new o(u[0],u[1],u[2],u[3]);case 5:return new o(u[0],u[1],u[2],u[3],u[4]);case 6:return new o(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new o(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var _=qi(o.prototype),D=o.apply(_,u);return Ce(D)?D:_}}function ax(o,u,_){var D=_s(o);function A(){for(var I=arguments.length,P=H(I),q=I,Y=Wi(A);q--;)P[q]=arguments[q];var tt=I<3&&P[0]!==Y&&P[I-1]!==Y?[]:Pn(P,Y);if(I-=tt.length,I<_)return q0(o,u,Zo,A.placeholder,e,P,tt,e,e,_-I);var et=this&&this!==Ge&&this instanceof A?D:o;return br(et,this,P)}return A}function L0(o){return function(u,_,D){var A=pe(u);if(!hr(u)){var I=At(_,3);u=je(u),_=function(q){return I(A[q],q,A)}}var P=o(u,_,D);return P>-1?A[I?u[P]:P]:e}}function R0(o){return yn(function(u){var _=u.length,D=_,A=$r.prototype.thru;for(o&&u.reverse();D--;){var I=u[D];if(typeof I!="function")throw new Tr(a);if(A&&!P&&Jo(I)=="wrapper")var P=new $r([],!0)}for(D=P?D:_;++D<_;){I=u[D];var q=Jo(I),Y=q=="wrapper"?rl(I):e;Y&&ol(Y[0])&&Y[1]==(M|b|E|S)&&!Y[4].length&&Y[9]==1?P=P[Jo(Y[0])].apply(P,Y[3]):P=I.length==1&&ol(I)?P[q]():P.thru(I)}return function(){var tt=arguments,et=tt[0];if(P&&tt.length==1&&Tt(et))return P.plant(et).value();for(var ot=0,dt=_?u[ot].apply(this,tt):et;++ot<_;)dt=u[ot].call(this,dt);return dt}})}function Zo(o,u,_,D,A,I,P,q,Y,tt){var et=u&M,ot=u&w,dt=u&v,yt=u&(b|N),Ct=u&T,Rt=dt?e:_s(o);function Ft(){for(var Ut=arguments.length,Yt=H(Ut),Cr=Ut;Cr--;)Yt[Cr]=arguments[Cr];if(yt)var ar=Wi(Ft),Fr=yD(Yt,ar);if(D&&(Yt=B0(Yt,D,A,yt)),I&&(Yt=O0(Yt,I,P,yt)),Ut-=Fr,yt&&Ut<tt){var Oe=Pn(Yt,ar);return q0(o,u,Zo,Ft.placeholder,_,Yt,Oe,q,Y,tt-Ut)}var Hr=ot?_:this,xn=dt?Hr[o]:o;return Ut=Yt.length,q?Yt=Fx(Yt,q):Ct&&Ut>1&&Yt.reverse(),et&&Y<Ut&&(Yt.length=Y),this&&this!==Ge&&this instanceof Ft&&(xn=Rt||_s(xn)),xn.apply(Hr,Yt)}return Ft}function P0(o,u){return function(_,D){return $b(_,o,u(D),{})}}function Ko(o,u){return function(_,D){var A;if(_===e&&D===e)return u;if(_!==e&&(A=_),D!==e){if(A===e)return D;typeof _=="string"||typeof D=="string"?(_=Er(_),D=Er(D)):(_=x0(_),D=x0(D)),A=o(_,D)}return A}}function Xu(o){return yn(function(u){return u=xe(u,xr(At())),Pt(function(_){var D=this;return o(u,function(A){return br(A,D,_)})})})}function Go(o,u){u=u===e?" ":Er(u);var _=u.length;if(_<2)return _?Yu(u,o):u;var D=Yu(u,$o(o/$i(u)));return Ti(u)?Wn(Zr(D),0,o).join(""):D.slice(0,o)}function ux(o,u,_,D){var A=u&w,I=_s(o);function P(){for(var q=-1,Y=arguments.length,tt=-1,et=D.length,ot=H(et+Y),dt=this&&this!==Ge&&this instanceof P?I:o;++tt<et;)ot[tt]=D[tt];for(;Y--;)ot[tt++]=arguments[++q];return br(dt,A?_:this,ot)}return P}function z0(o){return function(u,_,D){return D&&typeof D!="number"&&or(u,_,D)&&(_=D=e),u=bn(u),_===e?(_=u,u=0):_=bn(_),D=D===e?u<_?1:-1:bn(D),Zb(u,_,D,o)}}function Ho(o){return function(u,_){return typeof u=="string"&&typeof _=="string"||(u=zr(u),_=zr(_)),o(u,_)}}function q0(o,u,_,D,A,I,P,q,Y,tt){var et=u&b,ot=et?P:e,dt=et?e:P,yt=et?I:e,Ct=et?e:I;u|=et?E:C,u&=~(et?C:E),u&x||(u&=~(w|v));var Rt=[o,u,A,yt,ot,Ct,dt,q,Y,tt],Ft=_.apply(e,Rt);return ol(o)&&X0(Ft,Rt),Ft.placeholder=D,Q0(Ft,o,u)}function Qu(o){var u=ke[o];return function(_,D){if(_=zr(_),D=D==null?0:tr(Lt(D),292),D&&Qh(_)){var A=(ie(_)+"e").split("e"),I=u(A[0]+"e"+(+A[1]+D));return A=(ie(I)+"e").split("e"),+(A[0]+"e"+(+A[1]-D))}return u(_)}}var lx=Pi&&1/Ao(new Pi([,-0]))[1]==K?function(o){return new Pi(o)}:Dl;function k0(o){return function(u){var _=er(u);return _==Jt?Nu(u):_==yr?CD(u):vD(u,o(u))}}function vn(o,u,_,D,A,I,P,q){var Y=u&v;if(!Y&&typeof o!="function")throw new Tr(a);var tt=D?D.length:0;if(tt||(u&=~(E|C),D=A=e),P=P===e?P:Ue(Lt(P),0),q=q===e?q:Lt(q),tt-=A?A.length:0,u&C){var et=D,ot=A;D=A=e}var dt=Y?e:rl(o),yt=[o,u,_,D,A,et,ot,I,P,q];if(dt&&Ex(yt,dt),o=yt[0],u=yt[1],_=yt[2],D=yt[3],A=yt[4],q=yt[9]=yt[9]===e?Y?0:o.length:Ue(yt[9]-tt,0),!q&&u&(b|N)&&(u&=~(b|N)),!u||u==w)var Ct=ox(o,u,_);else u==b||u==N?Ct=ax(o,u,q):(u==E||u==(w|E))&&!A.length?Ct=ux(o,u,_,D):Ct=Zo.apply(e,yt);var Rt=dt?D0:X0;return Q0(Rt(Ct,yt),o,u)}function U0(o,u,_,D){return o===e||Gr(o,Ri[_])&&!ae.call(D,_)?u:o}function W0(o,u,_,D,A,I){return Ce(o)&&Ce(u)&&(I.set(u,o),Wo(o,u,e,W0,I),I.delete(u)),o}function cx(o){return vs(o)?e:o}function j0(o,u,_,D,A,I){var P=_&y,q=o.length,Y=u.length;if(q!=Y&&!(P&&Y>q))return!1;var tt=I.get(o),et=I.get(u);if(tt&&et)return tt==u&&et==o;var ot=-1,dt=!0,yt=_&m?new si:e;for(I.set(o,u),I.set(u,o);++ot<q;){var Ct=o[ot],Rt=u[ot];if(D)var Ft=P?D(Rt,Ct,ot,u,o,I):D(Ct,Rt,ot,o,u,I);if(Ft!==e){if(Ft)continue;dt=!1;break}if(yt){if(!xu(u,function(Ut,Yt){if(!is(yt,Yt)&&(Ct===Ut||A(Ct,Ut,_,D,I)))return yt.push(Yt)})){dt=!1;break}}else if(!(Ct===Rt||A(Ct,Rt,_,D,I))){dt=!1;break}}return I.delete(o),I.delete(u),dt}function fx(o,u,_,D,A,I,P){switch(_){case rt:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case st:return!(o.byteLength!=u.byteLength||!I(new Bo(o),new Bo(u)));case oe:case It:case Le:return Gr(+o,+u);case ce:return o.name==u.name&&o.message==u.message;case dn:case In:return o==u+"";case Jt:var q=Nu;case yr:var Y=D&y;if(q||(q=Ao),o.size!=u.size&&!Y)return!1;var tt=P.get(o);if(tt)return tt==u;D|=m,P.set(o,u);var et=j0(q(o),q(u),D,A,I,P);return P.delete(o),et;case L:if(ls)return ls.call(o)==ls.call(u)}return!1}function hx(o,u,_,D,A,I){var P=_&y,q=tl(o),Y=q.length,tt=tl(u),et=tt.length;if(Y!=et&&!P)return!1;for(var ot=Y;ot--;){var dt=q[ot];if(!(P?dt in u:ae.call(u,dt)))return!1}var yt=I.get(o),Ct=I.get(u);if(yt&&Ct)return yt==u&&Ct==o;var Rt=!0;I.set(o,u),I.set(u,o);for(var Ft=P;++ot<Y;){dt=q[ot];var Ut=o[dt],Yt=u[dt];if(D)var Cr=P?D(Yt,Ut,dt,u,o,I):D(Ut,Yt,dt,o,u,I);if(!(Cr===e?Ut===Yt||A(Ut,Yt,_,D,I):Cr)){Rt=!1;break}Ft||(Ft=dt=="constructor")}if(Rt&&!Ft){var ar=o.constructor,Fr=u.constructor;ar!=Fr&&"constructor"in o&&"constructor"in u&&!(typeof ar=="function"&&ar instanceof ar&&typeof Fr=="function"&&Fr instanceof Fr)&&(Rt=!1)}return I.delete(o),I.delete(u),Rt}function yn(o){return ul(H0(o,e,sp),o+"")}function tl(o){return c0(o,je,il)}function el(o){return c0(o,pr,Y0)}var rl=Ro?function(o){return Ro.get(o)}:Dl;function Jo(o){for(var u=o.name+"",_=zi[u],D=ae.call(zi,u)?_.length:0;D--;){var A=_[D],I=A.func;if(I==null||I==o)return A.name}return u}function Wi(o){var u=ae.call(B,"placeholder")?B:o;return u.placeholder}function At(){var o=B.iteratee||yl;return o=o===yl?p0:o,arguments.length?o(arguments[0],arguments[1]):o}function Xo(o,u){var _=o.__data__;return wx(u)?_[typeof u=="string"?"string":"hash"]:_.map}function nl(o){for(var u=je(o),_=u.length;_--;){var D=u[_],A=o[D];u[_]=[D,A,K0(A)]}return u}function ui(o,u){var _=xD(o,u);return h0(_)?_:e}function px(o){var u=ae.call(o,ni),_=o[ni];try{o[ni]=e;var D=!0}catch{}var A=No.call(o);return D&&(u?o[ni]=_:delete o[ni]),A}var il=Bu?function(o){return o==null?[]:(o=pe(o),Ln(Bu(o),function(u){return Jh.call(o,u)}))}:bl,Y0=Bu?function(o){for(var u=[];o;)Rn(u,il(o)),o=Oo(o);return u}:bl,er=sr;(Ou&&er(new Ou(new ArrayBuffer(1)))!=rt||os&&er(new os)!=Jt||Iu&&er(Iu.resolve())!=pn||Pi&&er(new Pi)!=yr||as&&er(new as)!=G)&&(er=function(o){var u=sr(o),_=u==ze?o.constructor:e,D=_?li(_):"";if(D)switch(D){case GD:return rt;case HD:return Jt;case JD:return pn;case XD:return yr;case QD:return G}return u});function dx(o,u,_){for(var D=-1,A=_.length;++D<A;){var I=_[D],P=I.size;switch(I.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=tr(u,o+P);break;case"takeRight":o=Ue(o,u-P);break}}return{start:o,end:u}}function _x(o){var u=o.match(eu);return u?u[1].split(ru):[]}function V0(o,u,_){u=Un(u,o);for(var D=-1,A=u.length,I=!1;++D<A;){var P=on(u[D]);if(!(I=o!=null&&_(o,P)))break;o=o[P]}return I||++D!=A?I:(A=o==null?0:o.length,!!A&&sa(A)&&wn(P,A)&&(Tt(o)||ci(o)))}function mx(o){var u=o.length,_=new o.constructor(u);return u&&typeof o[0]=="string"&&ae.call(o,"index")&&(_.index=o.index,_.input=o.input),_}function Z0(o){return typeof o.constructor=="function"&&!ms(o)?qi(Oo(o)):{}}function gx(o,u,_){var D=o.constructor;switch(u){case st:return Ju(o);case oe:case It:return new D(+o);case rt:return tx(o,_);case ft:case ut:case ht:case at:case Xt:case ne:case be:case We:case qe:return N0(o,_);case Jt:return new D;case Le:case In:return new D(o);case dn:return ex(o);case yr:return new D;case L:return rx(o)}}function vx(o,u){var _=u.length;if(!_)return o;var D=_-1;return u[D]=(_>1?"& ":"")+u[D],u=u.join(_>2?", ":" "),o.replace(tu,`{
|
8
|
+
*/Yn.exports,function(s,t){(function(){var e,r="4.17.21",n=200,i="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",p=500,h="__lodash_placeholder__",f=1,d=2,g=4,y=1,m=2,w=1,v=2,x=4,b=8,N=16,E=32,A=64,M=128,S=256,T=512,F=30,O="...",R=800,U=16,k=1,W=2,z=3,K=1/0,Z=9007199254740991,X=17976931348623157e292,Q=NaN,ct=4294967295,vt=ct-1,lt=ct>>>1,wt=[["ary",M],["bind",w],["bindKey",v],["curry",b],["curryRight",N],["flip",T],["partial",E],["partialRight",A],["rearg",S]],bt="[object Arguments]",Bt="[object Array]",xt="[object AsyncFunction]",oe="[object Boolean]",It="[object Date]",Nt="[object DOMException]",ce="[object Error]",re="[object Function]",kt="[object GeneratorFunction]",Jt="[object Map]",Le="[object Number]",vr="[object Null]",ze="[object Object]",pn="[object Promise]",On="[object Proxy]",dn="[object RegExp]",yr="[object Set]",In="[object String]",L="[object Symbol]",V="[object Undefined]",G="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",at="[object Int16Array]",Xt="[object Int32Array]",ne="[object Uint8Array]",be="[object Uint8ClampedArray]",We="[object Uint16Array]",qe="[object Uint32Array]",wr=/\b__p \+= '';/g,Dr=/\b(__p \+=) '' \+/g,Tn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ti=/&(?:amp|lt|gt|quot|#39);/g,vo=/[&<>"']/g,Ya=RegExp(ti.source),Va=RegExp(vo.source),Za=/<%-([\s\S]+?)%>/g,Ka=/<%([\s\S]+?)%>/g,yo=/<%=([\s\S]+?)%>/g,Ga=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ha=/^\w*$/,Ja=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rs=/[\\^$.*+?()[\]{}|]/g,Xa=RegExp(rs.source),ns=/^\s+/,Qa=/\s/,tu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,eu=/\{\n\/\* \[wrapped with (.+)\] \*/,ru=/,? & /,nu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,iu=/[()=,{}\[\]\/\s]/,su=/\\(\\)?/g,ou=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,wo=/\w*$/,au=/^[-+]0x[0-9a-f]+$/i,uu=/^0b[01]+$/i,lu=/^\[object .+?Constructor\]$/,cu=/^0o[0-7]+$/i,fu=/^(?:0|[1-9]\d*)$/,hu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Si=/($^)/,ei=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",Qe="\\u0300-\\u036f",pu="\\ufe20-\\ufe2f",Bi="\\u20d0-\\u20ff",$n=Qe+pu+Bi,Do="\\u2700-\\u27bf",dh="a-z\\xdf-\\xf6\\xf8-\\xff",Rw="\\xac\\xb1\\xd7\\xf7",Pw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",zw="\\u2000-\\u206f",qw=" \\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",_h="A-Z\\xc0-\\xd6\\xd8-\\xde",mh="\\ufe0e\\ufe0f",gh=Rw+Pw+zw+qw,du="['’]",kw="["+Zt+"]",vh="["+gh+"]",bo="["+$n+"]",yh="\\d+",Uw="["+Do+"]",wh="["+dh+"]",Dh="[^"+Zt+gh+yh+Do+dh+_h+"]",_u="\\ud83c[\\udffb-\\udfff]",Ww="(?:"+bo+"|"+_u+")",bh="[^"+Zt+"]",mu="(?:\\ud83c[\\udde6-\\uddff]){2}",gu="[\\ud800-\\udbff][\\udc00-\\udfff]",Oi="["+_h+"]",xh="\\u200d",Eh="(?:"+wh+"|"+Dh+")",jw="(?:"+Oi+"|"+Dh+")",Ah="(?:"+du+"(?:d|ll|m|re|s|t|ve))?",Ch="(?:"+du+"(?:D|LL|M|RE|S|T|VE))?",Fh=Ww+"?",Mh="["+mh+"]?",Yw="(?:"+xh+"(?:"+[bh,mu,gu].join("|")+")"+Mh+Fh+")*",Vw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Zw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Nh=Mh+Fh+Yw,Kw="(?:"+[Uw,mu,gu].join("|")+")"+Nh,Gw="(?:"+[bh+bo+"?",bo,mu,gu,kw].join("|")+")",Hw=RegExp(du,"g"),Jw=RegExp(bo,"g"),vu=RegExp(_u+"(?="+_u+")|"+Gw+Nh,"g"),Xw=RegExp([Oi+"?"+wh+"+"+Ah+"(?="+[vh,Oi,"$"].join("|")+")",jw+"+"+Ch+"(?="+[vh,Oi+Eh,"$"].join("|")+")",Oi+"?"+Eh+"+"+Ah,Oi+"+"+Ch,Zw,Vw,yh,Kw].join("|"),"g"),Qw=RegExp("["+xh+Zt+$n+mh+"]"),tD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,eD=["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"],rD=-1,ye={};ye[ft]=ye[ut]=ye[ht]=ye[at]=ye[Xt]=ye[ne]=ye[be]=ye[We]=ye[qe]=!0,ye[bt]=ye[Bt]=ye[st]=ye[oe]=ye[rt]=ye[It]=ye[ce]=ye[re]=ye[Jt]=ye[Le]=ye[ze]=ye[dn]=ye[yr]=ye[In]=ye[G]=!1;var _e={};_e[bt]=_e[Bt]=_e[st]=_e[rt]=_e[oe]=_e[It]=_e[ft]=_e[ut]=_e[ht]=_e[at]=_e[Xt]=_e[Jt]=_e[Le]=_e[ze]=_e[dn]=_e[yr]=_e[In]=_e[L]=_e[ne]=_e[be]=_e[We]=_e[qe]=!0,_e[ce]=_e[re]=_e[G]=!1;var nD={À:"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"},iD={"&":"&","<":"<",">":">",'"':""","'":"'"},sD={"&":"&","<":"<",">":">",""":'"',"'":"'"},oD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},aD=parseFloat,uD=parseInt,Sh=typeof Vt=="object"&&Vt&&Vt.Object===Object&&Vt,lD=typeof self=="object"&&self&&self.Object===Object&&self,Ge=Sh||lD||Function("return this")(),yu=t&&!t.nodeType&&t,ri=yu&&!0&&s&&!s.nodeType&&s,Bh=ri&&ri.exports===yu,wu=Bh&&Sh.process,Or=function(){try{var j=ri&&ri.require&&ri.require("util").types;return j||wu&&wu.binding&&wu.binding("util")}catch{}}(),Oh=Or&&Or.isArrayBuffer,Ih=Or&&Or.isDate,Th=Or&&Or.isMap,$h=Or&&Or.isRegExp,Lh=Or&&Or.isSet,Rh=Or&&Or.isTypedArray;function br(j,J,H){switch(H.length){case 0:return j.call(J);case 1:return j.call(J,H[0]);case 2:return j.call(J,H[0],H[1]);case 3:return j.call(J,H[0],H[1],H[2])}return j.apply(J,H)}function cD(j,J,H,gt){for(var Ot=-1,te=j==null?0:j.length;++Ot<te;){var ke=j[Ot];J(gt,ke,H(ke),j)}return gt}function Ir(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt&&J(j[H],H,j)!==!1;);return j}function fD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function Ph(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(!J(j[H],H,j))return!1;return!0}function Ln(j,J){for(var H=-1,gt=j==null?0:j.length,Ot=0,te=[];++H<gt;){var ke=j[H];J(ke,H,j)&&(te[Ot++]=ke)}return te}function xo(j,J){var H=j==null?0:j.length;return!!H&&Ii(j,J,0)>-1}function Du(j,J,H){for(var gt=-1,Ot=j==null?0:j.length;++gt<Ot;)if(H(J,j[gt]))return!0;return!1}function xe(j,J){for(var H=-1,gt=j==null?0:j.length,Ot=Array(gt);++H<gt;)Ot[H]=J(j[H],H,j);return Ot}function Rn(j,J){for(var H=-1,gt=J.length,Ot=j.length;++H<gt;)j[Ot+H]=J[H];return j}function bu(j,J,H,gt){var Ot=-1,te=j==null?0:j.length;for(gt&&te&&(H=j[++Ot]);++Ot<te;)H=J(H,j[Ot],Ot,j);return H}function hD(j,J,H,gt){var Ot=j==null?0:j.length;for(gt&&Ot&&(H=j[--Ot]);Ot--;)H=J(H,j[Ot],Ot,j);return H}function xu(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(J(j[H],H,j))return!0;return!1}var pD=Eu("length");function dD(j){return j.split("")}function _D(j){return j.match(nu)||[]}function zh(j,J,H){var gt;return H(j,function(Ot,te,ke){if(J(Ot,te,ke))return gt=te,!1}),gt}function Eo(j,J,H,gt){for(var Ot=j.length,te=H+(gt?1:-1);gt?te--:++te<Ot;)if(J(j[te],te,j))return te;return-1}function Ii(j,J,H){return J===J?FD(j,J,H):Eo(j,qh,H)}function mD(j,J,H,gt){for(var Ot=H-1,te=j.length;++Ot<te;)if(gt(j[Ot],J))return Ot;return-1}function qh(j){return j!==j}function kh(j,J){var H=j==null?0:j.length;return H?Cu(j,J)/H:Q}function Eu(j){return function(J){return J==null?e:J[j]}}function Au(j){return function(J){return j==null?e:j[J]}}function Uh(j,J,H,gt,Ot){return Ot(j,function(te,ke,pe){H=gt?(gt=!1,te):J(H,te,ke,pe)}),H}function gD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Cu(j,J){for(var H,gt=-1,Ot=j.length;++gt<Ot;){var te=J(j[gt]);te!==e&&(H=H===e?te:H+te)}return H}function Fu(j,J){for(var H=-1,gt=Array(j);++H<j;)gt[H]=J(H);return gt}function vD(j,J){return xe(J,function(H){return[H,j[H]]})}function Wh(j){return j&&j.slice(0,Zh(j)+1).replace(ns,"")}function xr(j){return function(J){return j(J)}}function Mu(j,J){return xe(J,function(H){return j[H]})}function is(j,J){return j.has(J)}function jh(j,J){for(var H=-1,gt=j.length;++H<gt&&Ii(J,j[H],0)>-1;);return H}function Yh(j,J){for(var H=j.length;H--&&Ii(J,j[H],0)>-1;);return H}function yD(j,J){for(var H=j.length,gt=0;H--;)j[H]===J&&++gt;return gt}var wD=Au(nD),DD=Au(iD);function bD(j){return"\\"+oD[j]}function xD(j,J){return j==null?e:j[J]}function Ti(j){return Qw.test(j)}function ED(j){return tD.test(j)}function AD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function Nu(j){var J=-1,H=Array(j.size);return j.forEach(function(gt,Ot){H[++J]=[Ot,gt]}),H}function Vh(j,J){return function(H){return j(J(H))}}function Pn(j,J){for(var H=-1,gt=j.length,Ot=0,te=[];++H<gt;){var ke=j[H];(ke===J||ke===h)&&(j[H]=h,te[Ot++]=H)}return te}function Ao(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=gt}),H}function CD(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=[gt,gt]}),H}function FD(j,J,H){for(var gt=H-1,Ot=j.length;++gt<Ot;)if(j[gt]===J)return gt;return-1}function MD(j,J,H){for(var gt=H+1;gt--;)if(j[gt]===J)return gt;return gt}function $i(j){return Ti(j)?SD(j):pD(j)}function Zr(j){return Ti(j)?BD(j):dD(j)}function Zh(j){for(var J=j.length;J--&&Qa.test(j.charAt(J)););return J}var ND=Au(sD);function SD(j){for(var J=vu.lastIndex=0;vu.test(j);)++J;return J}function BD(j){return j.match(vu)||[]}function OD(j){return j.match(Xw)||[]}var ID=function j(J){J=J==null?Ge:Li.defaults(Ge.Object(),J,Li.pick(Ge,eD));var H=J.Array,gt=J.Date,Ot=J.Error,te=J.Function,ke=J.Math,pe=J.Object,Su=J.RegExp,TD=J.String,Tr=J.TypeError,Co=H.prototype,$D=te.prototype,Ri=pe.prototype,Fo=J["__core-js_shared__"],Mo=$D.toString,ae=Ri.hasOwnProperty,LD=0,Kh=function(){var o=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),No=Ri.toString,RD=Mo.call(pe),PD=Ge._,zD=Su("^"+Mo.call(ae).replace(rs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),So=Bh?J.Buffer:e,zn=J.Symbol,Bo=J.Uint8Array,Gh=So?So.allocUnsafe:e,Oo=Vh(pe.getPrototypeOf,pe),Hh=pe.create,Jh=Ri.propertyIsEnumerable,Io=Co.splice,Xh=zn?zn.isConcatSpreadable:e,ss=zn?zn.iterator:e,ni=zn?zn.toStringTag:e,To=function(){try{var o=ui(pe,"defineProperty");return o({},"",{}),o}catch{}}(),qD=J.clearTimeout!==Ge.clearTimeout&&J.clearTimeout,kD=gt&>.now!==Ge.Date.now&>.now,UD=J.setTimeout!==Ge.setTimeout&&J.setTimeout,$o=ke.ceil,Lo=ke.floor,Bu=pe.getOwnPropertySymbols,WD=So?So.isBuffer:e,Qh=J.isFinite,jD=Co.join,YD=Vh(pe.keys,pe),Ue=ke.max,tr=ke.min,VD=gt.now,ZD=J.parseInt,t0=ke.random,KD=Co.reverse,Ou=ui(J,"DataView"),os=ui(J,"Map"),Iu=ui(J,"Promise"),Pi=ui(J,"Set"),as=ui(J,"WeakMap"),us=ui(pe,"create"),Ro=as&&new as,zi={},GD=li(Ou),HD=li(os),JD=li(Iu),XD=li(Pi),QD=li(as),Po=zn?zn.prototype:e,ls=Po?Po.valueOf:e,e0=Po?Po.toString:e;function B(o){if(Me(o)&&!Tt(o)&&!(o instanceof jt)){if(o instanceof $r)return o;if(ae.call(o,"__wrapped__"))return rp(o)}return new $r(o)}var qi=function(){function o(){}return function(u){if(!Ce(u))return{};if(Hh)return Hh(u);o.prototype=u;var _=new o;return o.prototype=e,_}}();function zo(){}function $r(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}B.templateSettings={escape:Za,evaluate:Ka,interpolate:yo,variable:"",imports:{_:B}},B.prototype=zo.prototype,B.prototype.constructor=B,$r.prototype=qi(zo.prototype),$r.prototype.constructor=$r;function jt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function tb(){var o=new jt(this.__wrapped__);return o.__actions__=fr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=fr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=fr(this.__views__),o}function eb(){if(this.__filtered__){var o=new jt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function rb(){var o=this.__wrapped__.value(),u=this.__dir__,_=Tt(o),D=u<0,C=_?o.length:0,I=dx(0,C,this.__views__),P=I.start,q=I.end,Y=q-P,tt=D?q:P-1,et=this.__iteratees__,ot=et.length,dt=0,yt=tr(Y,this.__takeCount__);if(!_||!D&&C==Y&&yt==Y)return A0(o,this.__actions__);var Ct=[];t:for(;Y--&&dt<yt;){tt+=u;for(var Rt=-1,Ft=o[tt];++Rt<ot;){var Ut=et[Rt],Yt=Ut.iteratee,Cr=Ut.type,ar=Yt(Ft);if(Cr==W)Ft=ar;else if(!ar){if(Cr==k)continue t;break t}}Ct[dt++]=Ft}return Ct}jt.prototype=qi(zo.prototype),jt.prototype.constructor=jt;function ii(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function nb(){this.__data__=us?us(null):{},this.size=0}function ib(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function sb(o){var u=this.__data__;if(us){var _=u[o];return _===c?e:_}return ae.call(u,o)?u[o]:e}function ob(o){var u=this.__data__;return us?u[o]!==e:ae.call(u,o)}function ab(o,u){var _=this.__data__;return this.size+=this.has(o)?0:1,_[o]=us&&u===e?c:u,this}ii.prototype.clear=nb,ii.prototype.delete=ib,ii.prototype.get=sb,ii.prototype.has=ob,ii.prototype.set=ab;function _n(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function ub(){this.__data__=[],this.size=0}function lb(o){var u=this.__data__,_=qo(u,o);if(_<0)return!1;var D=u.length-1;return _==D?u.pop():Io.call(u,_,1),--this.size,!0}function cb(o){var u=this.__data__,_=qo(u,o);return _<0?e:u[_][1]}function fb(o){return qo(this.__data__,o)>-1}function hb(o,u){var _=this.__data__,D=qo(_,o);return D<0?(++this.size,_.push([o,u])):_[D][1]=u,this}_n.prototype.clear=ub,_n.prototype.delete=lb,_n.prototype.get=cb,_n.prototype.has=fb,_n.prototype.set=hb;function mn(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function pb(){this.size=0,this.__data__={hash:new ii,map:new(os||_n),string:new ii}}function db(o){var u=Xo(this,o).delete(o);return this.size-=u?1:0,u}function _b(o){return Xo(this,o).get(o)}function mb(o){return Xo(this,o).has(o)}function gb(o,u){var _=Xo(this,o),D=_.size;return _.set(o,u),this.size+=_.size==D?0:1,this}mn.prototype.clear=pb,mn.prototype.delete=db,mn.prototype.get=_b,mn.prototype.has=mb,mn.prototype.set=gb;function si(o){var u=-1,_=o==null?0:o.length;for(this.__data__=new mn;++u<_;)this.add(o[u])}function vb(o){return this.__data__.set(o,c),this}function yb(o){return this.__data__.has(o)}si.prototype.add=si.prototype.push=vb,si.prototype.has=yb;function Kr(o){var u=this.__data__=new _n(o);this.size=u.size}function wb(){this.__data__=new _n,this.size=0}function Db(o){var u=this.__data__,_=u.delete(o);return this.size=u.size,_}function bb(o){return this.__data__.get(o)}function xb(o){return this.__data__.has(o)}function Eb(o,u){var _=this.__data__;if(_ instanceof _n){var D=_.__data__;if(!os||D.length<n-1)return D.push([o,u]),this.size=++_.size,this;_=this.__data__=new mn(D)}return _.set(o,u),this.size=_.size,this}Kr.prototype.clear=wb,Kr.prototype.delete=Db,Kr.prototype.get=bb,Kr.prototype.has=xb,Kr.prototype.set=Eb;function r0(o,u){var _=Tt(o),D=!_&&ci(o),C=!_&&!D&&jn(o),I=!_&&!D&&!C&&ji(o),P=_||D||C||I,q=P?Fu(o.length,TD):[],Y=q.length;for(var tt in o)(u||ae.call(o,tt))&&!(P&&(tt=="length"||C&&(tt=="offset"||tt=="parent")||I&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||wn(tt,Y)))&&q.push(tt);return q}function n0(o){var u=o.length;return u?o[ju(0,u-1)]:e}function Ab(o,u){return Qo(fr(o),oi(u,0,o.length))}function Cb(o){return Qo(fr(o))}function Tu(o,u,_){(_!==e&&!Gr(o[u],_)||_===e&&!(u in o))&&gn(o,u,_)}function cs(o,u,_){var D=o[u];(!(ae.call(o,u)&&Gr(D,_))||_===e&&!(u in o))&&gn(o,u,_)}function qo(o,u){for(var _=o.length;_--;)if(Gr(o[_][0],u))return _;return-1}function Fb(o,u,_,D){return qn(o,function(C,I,P){u(D,C,_(C),P)}),D}function i0(o,u){return o&&sn(u,je(u),o)}function Mb(o,u){return o&&sn(u,pr(u),o)}function gn(o,u,_){u=="__proto__"&&To?To(o,u,{configurable:!0,enumerable:!0,value:_,writable:!0}):o[u]=_}function $u(o,u){for(var _=-1,D=u.length,C=H(D),I=o==null;++_<D;)C[_]=I?e:_l(o,u[_]);return C}function oi(o,u,_){return o===o&&(_!==e&&(o=o<=_?o:_),u!==e&&(o=o>=u?o:u)),o}function Lr(o,u,_,D,C,I){var P,q=u&f,Y=u&d,tt=u&g;if(_&&(P=C?_(o,D,C,I):_(o)),P!==e)return P;if(!Ce(o))return o;var et=Tt(o);if(et){if(P=mx(o),!q)return fr(o,P)}else{var ot=er(o),dt=ot==re||ot==kt;if(jn(o))return M0(o,q);if(ot==ze||ot==bt||dt&&!C){if(P=Y||dt?{}:Z0(o),!q)return Y?sx(o,Mb(P,o)):ix(o,i0(P,o))}else{if(!_e[ot])return C?o:{};P=gx(o,ot,q)}}I||(I=new Kr);var yt=I.get(o);if(yt)return yt;I.set(o,P),bp(o)?o.forEach(function(Ft){P.add(Lr(Ft,u,_,Ft,o,I))}):wp(o)&&o.forEach(function(Ft,Ut){P.set(Ut,Lr(Ft,u,_,Ut,o,I))});var Ct=tt?Y?el:tl:Y?pr:je,Rt=et?e:Ct(o);return Ir(Rt||o,function(Ft,Ut){Rt&&(Ut=Ft,Ft=o[Ut]),cs(P,Ut,Lr(Ft,u,_,Ut,o,I))}),P}function Nb(o){var u=je(o);return function(_){return s0(_,o,u)}}function s0(o,u,_){var D=_.length;if(o==null)return!D;for(o=pe(o);D--;){var C=_[D],I=u[C],P=o[C];if(P===e&&!(C in o)||!I(P))return!1}return!0}function o0(o,u,_){if(typeof o!="function")throw new Tr(a);return gs(function(){o.apply(e,_)},u)}function fs(o,u,_,D){var C=-1,I=xo,P=!0,q=o.length,Y=[],tt=u.length;if(!q)return Y;_&&(u=xe(u,xr(_))),D?(I=Du,P=!1):u.length>=n&&(I=is,P=!1,u=new si(u));t:for(;++C<q;){var et=o[C],ot=_==null?et:_(et);if(et=D||et!==0?et:0,P&&ot===ot){for(var dt=tt;dt--;)if(u[dt]===ot)continue t;Y.push(et)}else I(u,ot,D)||Y.push(et)}return Y}var qn=I0(nn),a0=I0(Ru,!0);function Sb(o,u){var _=!0;return qn(o,function(D,C,I){return _=!!u(D,C,I),_}),_}function ko(o,u,_){for(var D=-1,C=o.length;++D<C;){var I=o[D],P=u(I);if(P!=null&&(q===e?P===P&&!Ar(P):_(P,q)))var q=P,Y=I}return Y}function Bb(o,u,_,D){var C=o.length;for(_=Lt(_),_<0&&(_=-_>C?0:C+_),D=D===e||D>C?C:Lt(D),D<0&&(D+=C),D=_>D?0:Ep(D);_<D;)o[_++]=u;return o}function u0(o,u){var _=[];return qn(o,function(D,C,I){u(D,C,I)&&_.push(D)}),_}function He(o,u,_,D,C){var I=-1,P=o.length;for(_||(_=yx),C||(C=[]);++I<P;){var q=o[I];u>0&&_(q)?u>1?He(q,u-1,_,D,C):Rn(C,q):D||(C[C.length]=q)}return C}var Lu=T0(),l0=T0(!0);function nn(o,u){return o&&Lu(o,u,je)}function Ru(o,u){return o&&l0(o,u,je)}function Uo(o,u){return Ln(u,function(_){return Dn(o[_])})}function ai(o,u){u=Un(u,o);for(var _=0,D=u.length;o!=null&&_<D;)o=o[on(u[_++])];return _&&_==D?o:e}function c0(o,u,_){var D=u(o);return Tt(o)?D:Rn(D,_(o))}function sr(o){return o==null?o===e?V:vr:ni&&ni in pe(o)?px(o):Cx(o)}function Pu(o,u){return o>u}function Ob(o,u){return o!=null&&ae.call(o,u)}function Ib(o,u){return o!=null&&u in pe(o)}function Tb(o,u,_){return o>=tr(u,_)&&o<Ue(u,_)}function zu(o,u,_){for(var D=_?Du:xo,C=o[0].length,I=o.length,P=I,q=H(I),Y=1/0,tt=[];P--;){var et=o[P];P&&u&&(et=xe(et,xr(u))),Y=tr(et.length,Y),q[P]=!_&&(u||C>=120&&et.length>=120)?new si(P&&et):e}et=o[0];var ot=-1,dt=q[0];t:for(;++ot<C&&tt.length<Y;){var yt=et[ot],Ct=u?u(yt):yt;if(yt=_||yt!==0?yt:0,!(dt?is(dt,Ct):D(tt,Ct,_))){for(P=I;--P;){var Rt=q[P];if(!(Rt?is(Rt,Ct):D(o[P],Ct,_)))continue t}dt&&dt.push(Ct),tt.push(yt)}}return tt}function $b(o,u,_,D){return nn(o,function(C,I,P){u(D,_(C),I,P)}),D}function hs(o,u,_){u=Un(u,o),o=J0(o,u);var D=o==null?o:o[on(Pr(u))];return D==null?e:br(D,o,_)}function f0(o){return Me(o)&&sr(o)==bt}function Lb(o){return Me(o)&&sr(o)==st}function Rb(o){return Me(o)&&sr(o)==It}function ps(o,u,_,D,C){return o===u?!0:o==null||u==null||!Me(o)&&!Me(u)?o!==o&&u!==u:Pb(o,u,_,D,ps,C)}function Pb(o,u,_,D,C,I){var P=Tt(o),q=Tt(u),Y=P?Bt:er(o),tt=q?Bt:er(u);Y=Y==bt?ze:Y,tt=tt==bt?ze:tt;var et=Y==ze,ot=tt==ze,dt=Y==tt;if(dt&&jn(o)){if(!jn(u))return!1;P=!0,et=!1}if(dt&&!et)return I||(I=new Kr),P||ji(o)?j0(o,u,_,D,C,I):fx(o,u,Y,_,D,C,I);if(!(_&y)){var yt=et&&ae.call(o,"__wrapped__"),Ct=ot&&ae.call(u,"__wrapped__");if(yt||Ct){var Rt=yt?o.value():o,Ft=Ct?u.value():u;return I||(I=new Kr),C(Rt,Ft,_,D,I)}}return dt?(I||(I=new Kr),hx(o,u,_,D,C,I)):!1}function zb(o){return Me(o)&&er(o)==Jt}function qu(o,u,_,D){var C=_.length,I=C,P=!D;if(o==null)return!I;for(o=pe(o);C--;){var q=_[C];if(P&&q[2]?q[1]!==o[q[0]]:!(q[0]in o))return!1}for(;++C<I;){q=_[C];var Y=q[0],tt=o[Y],et=q[1];if(P&&q[2]){if(tt===e&&!(Y in o))return!1}else{var ot=new Kr;if(D)var dt=D(tt,et,Y,o,u,ot);if(!(dt===e?ps(et,tt,y|m,D,ot):dt))return!1}}return!0}function h0(o){if(!Ce(o)||Dx(o))return!1;var u=Dn(o)?zD:lu;return u.test(li(o))}function qb(o){return Me(o)&&sr(o)==dn}function kb(o){return Me(o)&&er(o)==yr}function Ub(o){return Me(o)&&sa(o.length)&&!!ye[sr(o)]}function p0(o){return typeof o=="function"?o:o==null?dr:typeof o=="object"?Tt(o)?m0(o[0],o[1]):_0(o):$p(o)}function ku(o){if(!ms(o))return YD(o);var u=[];for(var _ in pe(o))ae.call(o,_)&&_!="constructor"&&u.push(_);return u}function Wb(o){if(!Ce(o))return Ax(o);var u=ms(o),_=[];for(var D in o)D=="constructor"&&(u||!ae.call(o,D))||_.push(D);return _}function Uu(o,u){return o<u}function d0(o,u){var _=-1,D=hr(o)?H(o.length):[];return qn(o,function(C,I,P){D[++_]=u(C,I,P)}),D}function _0(o){var u=nl(o);return u.length==1&&u[0][2]?G0(u[0][0],u[0][1]):function(_){return _===o||qu(_,o,u)}}function m0(o,u){return sl(o)&&K0(u)?G0(on(o),u):function(_){var D=_l(_,o);return D===e&&D===u?ml(_,o):ps(u,D,y|m)}}function Wo(o,u,_,D,C){o!==u&&Lu(u,function(I,P){if(C||(C=new Kr),Ce(I))jb(o,u,P,_,Wo,D,C);else{var q=D?D(al(o,P),I,P+"",o,u,C):e;q===e&&(q=I),Tu(o,P,q)}},pr)}function jb(o,u,_,D,C,I,P){var q=al(o,_),Y=al(u,_),tt=P.get(Y);if(tt){Tu(o,_,tt);return}var et=I?I(q,Y,_+"",o,u,P):e,ot=et===e;if(ot){var dt=Tt(Y),yt=!dt&&jn(Y),Ct=!dt&&!yt&&ji(Y);et=Y,dt||yt||Ct?Tt(q)?et=q:Be(q)?et=fr(q):yt?(ot=!1,et=M0(Y,!0)):Ct?(ot=!1,et=N0(Y,!0)):et=[]:vs(Y)||ci(Y)?(et=q,ci(q)?et=Ap(q):(!Ce(q)||Dn(q))&&(et=Z0(Y))):ot=!1}ot&&(P.set(Y,et),C(et,Y,D,I,P),P.delete(Y)),Tu(o,_,et)}function g0(o,u){var _=o.length;if(_)return u+=u<0?_:0,wn(u,_)?o[u]:e}function v0(o,u,_){u.length?u=xe(u,function(I){return Tt(I)?function(P){return ai(P,I.length===1?I[0]:I)}:I}):u=[dr];var D=-1;u=xe(u,xr(At()));var C=d0(o,function(I,P,q){var Y=xe(u,function(tt){return tt(I)});return{criteria:Y,index:++D,value:I}});return gD(C,function(I,P){return nx(I,P,_)})}function Yb(o,u){return y0(o,u,function(_,D){return ml(o,D)})}function y0(o,u,_){for(var D=-1,C=u.length,I={};++D<C;){var P=u[D],q=ai(o,P);_(q,P)&&ds(I,Un(P,o),q)}return I}function Vb(o){return function(u){return ai(u,o)}}function Wu(o,u,_,D){var C=D?mD:Ii,I=-1,P=u.length,q=o;for(o===u&&(u=fr(u)),_&&(q=xe(o,xr(_)));++I<P;)for(var Y=0,tt=u[I],et=_?_(tt):tt;(Y=C(q,et,Y,D))>-1;)q!==o&&Io.call(q,Y,1),Io.call(o,Y,1);return o}function w0(o,u){for(var _=o?u.length:0,D=_-1;_--;){var C=u[_];if(_==D||C!==I){var I=C;wn(C)?Io.call(o,C,1):Zu(o,C)}}return o}function ju(o,u){return o+Lo(t0()*(u-o+1))}function Zb(o,u,_,D){for(var C=-1,I=Ue($o((u-o)/(_||1)),0),P=H(I);I--;)P[D?I:++C]=o,o+=_;return P}function Yu(o,u){var _="";if(!o||u<1||u>Z)return _;do u%2&&(_+=o),u=Lo(u/2),u&&(o+=o);while(u);return _}function Pt(o,u){return ul(H0(o,u,dr),o+"")}function Kb(o){return n0(Yi(o))}function Gb(o,u){var _=Yi(o);return Qo(_,oi(u,0,_.length))}function ds(o,u,_,D){if(!Ce(o))return o;u=Un(u,o);for(var C=-1,I=u.length,P=I-1,q=o;q!=null&&++C<I;){var Y=on(u[C]),tt=_;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return o;if(C!=P){var et=q[Y];tt=D?D(et,Y,q):e,tt===e&&(tt=Ce(et)?et:wn(u[C+1])?[]:{})}cs(q,Y,tt),q=q[Y]}return o}var D0=Ro?function(o,u){return Ro.set(o,u),o}:dr,Hb=To?function(o,u){return To(o,"toString",{configurable:!0,enumerable:!1,value:vl(u),writable:!0})}:dr;function Jb(o){return Qo(Yi(o))}function Rr(o,u,_){var D=-1,C=o.length;u<0&&(u=-u>C?0:C+u),_=_>C?C:_,_<0&&(_+=C),C=u>_?0:_-u>>>0,u>>>=0;for(var I=H(C);++D<C;)I[D]=o[D+u];return I}function Xb(o,u){var _;return qn(o,function(D,C,I){return _=u(D,C,I),!_}),!!_}function jo(o,u,_){var D=0,C=o==null?D:o.length;if(typeof u=="number"&&u===u&&C<=lt){for(;D<C;){var I=D+C>>>1,P=o[I];P!==null&&!Ar(P)&&(_?P<=u:P<u)?D=I+1:C=I}return C}return Vu(o,u,dr,_)}function Vu(o,u,_,D){var C=0,I=o==null?0:o.length;if(I===0)return 0;u=_(u);for(var P=u!==u,q=u===null,Y=Ar(u),tt=u===e;C<I;){var et=Lo((C+I)/2),ot=_(o[et]),dt=ot!==e,yt=ot===null,Ct=ot===ot,Rt=Ar(ot);if(P)var Ft=D||Ct;else tt?Ft=Ct&&(D||dt):q?Ft=Ct&&dt&&(D||!yt):Y?Ft=Ct&&dt&&!yt&&(D||!Rt):yt||Rt?Ft=!1:Ft=D?ot<=u:ot<u;Ft?C=et+1:I=et}return tr(I,vt)}function b0(o,u){for(var _=-1,D=o.length,C=0,I=[];++_<D;){var P=o[_],q=u?u(P):P;if(!_||!Gr(q,Y)){var Y=q;I[C++]=P===0?0:P}}return I}function x0(o){return typeof o=="number"?o:Ar(o)?Q:+o}function Er(o){if(typeof o=="string")return o;if(Tt(o))return xe(o,Er)+"";if(Ar(o))return e0?e0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function kn(o,u,_){var D=-1,C=xo,I=o.length,P=!0,q=[],Y=q;if(_)P=!1,C=Du;else if(I>=n){var tt=u?null:lx(o);if(tt)return Ao(tt);P=!1,C=is,Y=new si}else Y=u?[]:q;t:for(;++D<I;){var et=o[D],ot=u?u(et):et;if(et=_||et!==0?et:0,P&&ot===ot){for(var dt=Y.length;dt--;)if(Y[dt]===ot)continue t;u&&Y.push(ot),q.push(et)}else C(Y,ot,_)||(Y!==q&&Y.push(ot),q.push(et))}return q}function Zu(o,u){return u=Un(u,o),o=J0(o,u),o==null||delete o[on(Pr(u))]}function E0(o,u,_,D){return ds(o,u,_(ai(o,u)),D)}function Yo(o,u,_,D){for(var C=o.length,I=D?C:-1;(D?I--:++I<C)&&u(o[I],I,o););return _?Rr(o,D?0:I,D?I+1:C):Rr(o,D?I+1:0,D?C:I)}function A0(o,u){var _=o;return _ instanceof jt&&(_=_.value()),bu(u,function(D,C){return C.func.apply(C.thisArg,Rn([D],C.args))},_)}function Ku(o,u,_){var D=o.length;if(D<2)return D?kn(o[0]):[];for(var C=-1,I=H(D);++C<D;)for(var P=o[C],q=-1;++q<D;)q!=C&&(I[C]=fs(I[C]||P,o[q],u,_));return kn(He(I,1),u,_)}function C0(o,u,_){for(var D=-1,C=o.length,I=u.length,P={};++D<C;){var q=D<I?u[D]:e;_(P,o[D],q)}return P}function Gu(o){return Be(o)?o:[]}function Hu(o){return typeof o=="function"?o:dr}function Un(o,u){return Tt(o)?o:sl(o,u)?[o]:ep(ie(o))}var Qb=Pt;function Wn(o,u,_){var D=o.length;return _=_===e?D:_,!u&&_>=D?o:Rr(o,u,_)}var F0=qD||function(o){return Ge.clearTimeout(o)};function M0(o,u){if(u)return o.slice();var _=o.length,D=Gh?Gh(_):new o.constructor(_);return o.copy(D),D}function Ju(o){var u=new o.constructor(o.byteLength);return new Bo(u).set(new Bo(o)),u}function tx(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.byteLength)}function ex(o){var u=new o.constructor(o.source,wo.exec(o));return u.lastIndex=o.lastIndex,u}function rx(o){return ls?pe(ls.call(o)):{}}function N0(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.length)}function S0(o,u){if(o!==u){var _=o!==e,D=o===null,C=o===o,I=Ar(o),P=u!==e,q=u===null,Y=u===u,tt=Ar(u);if(!q&&!tt&&!I&&o>u||I&&P&&Y&&!q&&!tt||D&&P&&Y||!_&&Y||!C)return 1;if(!D&&!I&&!tt&&o<u||tt&&_&&C&&!D&&!I||q&&_&&C||!P&&C||!Y)return-1}return 0}function nx(o,u,_){for(var D=-1,C=o.criteria,I=u.criteria,P=C.length,q=_.length;++D<P;){var Y=S0(C[D],I[D]);if(Y){if(D>=q)return Y;var tt=_[D];return Y*(tt=="desc"?-1:1)}}return o.index-u.index}function B0(o,u,_,D){for(var C=-1,I=o.length,P=_.length,q=-1,Y=u.length,tt=Ue(I-P,0),et=H(Y+tt),ot=!D;++q<Y;)et[q]=u[q];for(;++C<P;)(ot||C<I)&&(et[_[C]]=o[C]);for(;tt--;)et[q++]=o[C++];return et}function O0(o,u,_,D){for(var C=-1,I=o.length,P=-1,q=_.length,Y=-1,tt=u.length,et=Ue(I-q,0),ot=H(et+tt),dt=!D;++C<et;)ot[C]=o[C];for(var yt=C;++Y<tt;)ot[yt+Y]=u[Y];for(;++P<q;)(dt||C<I)&&(ot[yt+_[P]]=o[C++]);return ot}function fr(o,u){var _=-1,D=o.length;for(u||(u=H(D));++_<D;)u[_]=o[_];return u}function sn(o,u,_,D){var C=!_;_||(_={});for(var I=-1,P=u.length;++I<P;){var q=u[I],Y=D?D(_[q],o[q],q,_,o):e;Y===e&&(Y=o[q]),C?gn(_,q,Y):cs(_,q,Y)}return _}function ix(o,u){return sn(o,il(o),u)}function sx(o,u){return sn(o,Y0(o),u)}function Vo(o,u){return function(_,D){var C=Tt(_)?cD:Fb,I=u?u():{};return C(_,o,At(D,2),I)}}function ki(o){return Pt(function(u,_){var D=-1,C=_.length,I=C>1?_[C-1]:e,P=C>2?_[2]:e;for(I=o.length>3&&typeof I=="function"?(C--,I):e,P&&or(_[0],_[1],P)&&(I=C<3?e:I,C=1),u=pe(u);++D<C;){var q=_[D];q&&o(u,q,D,I)}return u})}function I0(o,u){return function(_,D){if(_==null)return _;if(!hr(_))return o(_,D);for(var C=_.length,I=u?C:-1,P=pe(_);(u?I--:++I<C)&&D(P[I],I,P)!==!1;);return _}}function T0(o){return function(u,_,D){for(var C=-1,I=pe(u),P=D(u),q=P.length;q--;){var Y=P[o?q:++C];if(_(I[Y],Y,I)===!1)break}return u}}function ox(o,u,_){var D=u&w,C=_s(o);function I(){var P=this&&this!==Ge&&this instanceof I?C:o;return P.apply(D?_:this,arguments)}return I}function $0(o){return function(u){u=ie(u);var _=Ti(u)?Zr(u):e,D=_?_[0]:u.charAt(0),C=_?Wn(_,1).join(""):u.slice(1);return D[o]()+C}}function Ui(o){return function(u){return bu(Ip(Op(u).replace(Hw,"")),o,"")}}function _s(o){return function(){var u=arguments;switch(u.length){case 0:return new o;case 1:return new o(u[0]);case 2:return new o(u[0],u[1]);case 3:return new o(u[0],u[1],u[2]);case 4:return new o(u[0],u[1],u[2],u[3]);case 5:return new o(u[0],u[1],u[2],u[3],u[4]);case 6:return new o(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new o(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var _=qi(o.prototype),D=o.apply(_,u);return Ce(D)?D:_}}function ax(o,u,_){var D=_s(o);function C(){for(var I=arguments.length,P=H(I),q=I,Y=Wi(C);q--;)P[q]=arguments[q];var tt=I<3&&P[0]!==Y&&P[I-1]!==Y?[]:Pn(P,Y);if(I-=tt.length,I<_)return q0(o,u,Zo,C.placeholder,e,P,tt,e,e,_-I);var et=this&&this!==Ge&&this instanceof C?D:o;return br(et,this,P)}return C}function L0(o){return function(u,_,D){var C=pe(u);if(!hr(u)){var I=At(_,3);u=je(u),_=function(q){return I(C[q],q,C)}}var P=o(u,_,D);return P>-1?C[I?u[P]:P]:e}}function R0(o){return yn(function(u){var _=u.length,D=_,C=$r.prototype.thru;for(o&&u.reverse();D--;){var I=u[D];if(typeof I!="function")throw new Tr(a);if(C&&!P&&Jo(I)=="wrapper")var P=new $r([],!0)}for(D=P?D:_;++D<_;){I=u[D];var q=Jo(I),Y=q=="wrapper"?rl(I):e;Y&&ol(Y[0])&&Y[1]==(M|b|E|S)&&!Y[4].length&&Y[9]==1?P=P[Jo(Y[0])].apply(P,Y[3]):P=I.length==1&&ol(I)?P[q]():P.thru(I)}return function(){var tt=arguments,et=tt[0];if(P&&tt.length==1&&Tt(et))return P.plant(et).value();for(var ot=0,dt=_?u[ot].apply(this,tt):et;++ot<_;)dt=u[ot].call(this,dt);return dt}})}function Zo(o,u,_,D,C,I,P,q,Y,tt){var et=u&M,ot=u&w,dt=u&v,yt=u&(b|N),Ct=u&T,Rt=dt?e:_s(o);function Ft(){for(var Ut=arguments.length,Yt=H(Ut),Cr=Ut;Cr--;)Yt[Cr]=arguments[Cr];if(yt)var ar=Wi(Ft),Fr=yD(Yt,ar);if(D&&(Yt=B0(Yt,D,C,yt)),I&&(Yt=O0(Yt,I,P,yt)),Ut-=Fr,yt&&Ut<tt){var Oe=Pn(Yt,ar);return q0(o,u,Zo,Ft.placeholder,_,Yt,Oe,q,Y,tt-Ut)}var Hr=ot?_:this,xn=dt?Hr[o]:o;return Ut=Yt.length,q?Yt=Fx(Yt,q):Ct&&Ut>1&&Yt.reverse(),et&&Y<Ut&&(Yt.length=Y),this&&this!==Ge&&this instanceof Ft&&(xn=Rt||_s(xn)),xn.apply(Hr,Yt)}return Ft}function P0(o,u){return function(_,D){return $b(_,o,u(D),{})}}function Ko(o,u){return function(_,D){var C;if(_===e&&D===e)return u;if(_!==e&&(C=_),D!==e){if(C===e)return D;typeof _=="string"||typeof D=="string"?(_=Er(_),D=Er(D)):(_=x0(_),D=x0(D)),C=o(_,D)}return C}}function Xu(o){return yn(function(u){return u=xe(u,xr(At())),Pt(function(_){var D=this;return o(u,function(C){return br(C,D,_)})})})}function Go(o,u){u=u===e?" ":Er(u);var _=u.length;if(_<2)return _?Yu(u,o):u;var D=Yu(u,$o(o/$i(u)));return Ti(u)?Wn(Zr(D),0,o).join(""):D.slice(0,o)}function ux(o,u,_,D){var C=u&w,I=_s(o);function P(){for(var q=-1,Y=arguments.length,tt=-1,et=D.length,ot=H(et+Y),dt=this&&this!==Ge&&this instanceof P?I:o;++tt<et;)ot[tt]=D[tt];for(;Y--;)ot[tt++]=arguments[++q];return br(dt,C?_:this,ot)}return P}function z0(o){return function(u,_,D){return D&&typeof D!="number"&&or(u,_,D)&&(_=D=e),u=bn(u),_===e?(_=u,u=0):_=bn(_),D=D===e?u<_?1:-1:bn(D),Zb(u,_,D,o)}}function Ho(o){return function(u,_){return typeof u=="string"&&typeof _=="string"||(u=zr(u),_=zr(_)),o(u,_)}}function q0(o,u,_,D,C,I,P,q,Y,tt){var et=u&b,ot=et?P:e,dt=et?e:P,yt=et?I:e,Ct=et?e:I;u|=et?E:A,u&=~(et?A:E),u&x||(u&=~(w|v));var Rt=[o,u,C,yt,ot,Ct,dt,q,Y,tt],Ft=_.apply(e,Rt);return ol(o)&&X0(Ft,Rt),Ft.placeholder=D,Q0(Ft,o,u)}function Qu(o){var u=ke[o];return function(_,D){if(_=zr(_),D=D==null?0:tr(Lt(D),292),D&&Qh(_)){var C=(ie(_)+"e").split("e"),I=u(C[0]+"e"+(+C[1]+D));return C=(ie(I)+"e").split("e"),+(C[0]+"e"+(+C[1]-D))}return u(_)}}var lx=Pi&&1/Ao(new Pi([,-0]))[1]==K?function(o){return new Pi(o)}:Dl;function k0(o){return function(u){var _=er(u);return _==Jt?Nu(u):_==yr?CD(u):vD(u,o(u))}}function vn(o,u,_,D,C,I,P,q){var Y=u&v;if(!Y&&typeof o!="function")throw new Tr(a);var tt=D?D.length:0;if(tt||(u&=~(E|A),D=C=e),P=P===e?P:Ue(Lt(P),0),q=q===e?q:Lt(q),tt-=C?C.length:0,u&A){var et=D,ot=C;D=C=e}var dt=Y?e:rl(o),yt=[o,u,_,D,C,et,ot,I,P,q];if(dt&&Ex(yt,dt),o=yt[0],u=yt[1],_=yt[2],D=yt[3],C=yt[4],q=yt[9]=yt[9]===e?Y?0:o.length:Ue(yt[9]-tt,0),!q&&u&(b|N)&&(u&=~(b|N)),!u||u==w)var Ct=ox(o,u,_);else u==b||u==N?Ct=ax(o,u,q):(u==E||u==(w|E))&&!C.length?Ct=ux(o,u,_,D):Ct=Zo.apply(e,yt);var Rt=dt?D0:X0;return Q0(Rt(Ct,yt),o,u)}function U0(o,u,_,D){return o===e||Gr(o,Ri[_])&&!ae.call(D,_)?u:o}function W0(o,u,_,D,C,I){return Ce(o)&&Ce(u)&&(I.set(u,o),Wo(o,u,e,W0,I),I.delete(u)),o}function cx(o){return vs(o)?e:o}function j0(o,u,_,D,C,I){var P=_&y,q=o.length,Y=u.length;if(q!=Y&&!(P&&Y>q))return!1;var tt=I.get(o),et=I.get(u);if(tt&&et)return tt==u&&et==o;var ot=-1,dt=!0,yt=_&m?new si:e;for(I.set(o,u),I.set(u,o);++ot<q;){var Ct=o[ot],Rt=u[ot];if(D)var Ft=P?D(Rt,Ct,ot,u,o,I):D(Ct,Rt,ot,o,u,I);if(Ft!==e){if(Ft)continue;dt=!1;break}if(yt){if(!xu(u,function(Ut,Yt){if(!is(yt,Yt)&&(Ct===Ut||C(Ct,Ut,_,D,I)))return yt.push(Yt)})){dt=!1;break}}else if(!(Ct===Rt||C(Ct,Rt,_,D,I))){dt=!1;break}}return I.delete(o),I.delete(u),dt}function fx(o,u,_,D,C,I,P){switch(_){case rt:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case st:return!(o.byteLength!=u.byteLength||!I(new Bo(o),new Bo(u)));case oe:case It:case Le:return Gr(+o,+u);case ce:return o.name==u.name&&o.message==u.message;case dn:case In:return o==u+"";case Jt:var q=Nu;case yr:var Y=D&y;if(q||(q=Ao),o.size!=u.size&&!Y)return!1;var tt=P.get(o);if(tt)return tt==u;D|=m,P.set(o,u);var et=j0(q(o),q(u),D,C,I,P);return P.delete(o),et;case L:if(ls)return ls.call(o)==ls.call(u)}return!1}function hx(o,u,_,D,C,I){var P=_&y,q=tl(o),Y=q.length,tt=tl(u),et=tt.length;if(Y!=et&&!P)return!1;for(var ot=Y;ot--;){var dt=q[ot];if(!(P?dt in u:ae.call(u,dt)))return!1}var yt=I.get(o),Ct=I.get(u);if(yt&&Ct)return yt==u&&Ct==o;var Rt=!0;I.set(o,u),I.set(u,o);for(var Ft=P;++ot<Y;){dt=q[ot];var Ut=o[dt],Yt=u[dt];if(D)var Cr=P?D(Yt,Ut,dt,u,o,I):D(Ut,Yt,dt,o,u,I);if(!(Cr===e?Ut===Yt||C(Ut,Yt,_,D,I):Cr)){Rt=!1;break}Ft||(Ft=dt=="constructor")}if(Rt&&!Ft){var ar=o.constructor,Fr=u.constructor;ar!=Fr&&"constructor"in o&&"constructor"in u&&!(typeof ar=="function"&&ar instanceof ar&&typeof Fr=="function"&&Fr instanceof Fr)&&(Rt=!1)}return I.delete(o),I.delete(u),Rt}function yn(o){return ul(H0(o,e,sp),o+"")}function tl(o){return c0(o,je,il)}function el(o){return c0(o,pr,Y0)}var rl=Ro?function(o){return Ro.get(o)}:Dl;function Jo(o){for(var u=o.name+"",_=zi[u],D=ae.call(zi,u)?_.length:0;D--;){var C=_[D],I=C.func;if(I==null||I==o)return C.name}return u}function Wi(o){var u=ae.call(B,"placeholder")?B:o;return u.placeholder}function At(){var o=B.iteratee||yl;return o=o===yl?p0:o,arguments.length?o(arguments[0],arguments[1]):o}function Xo(o,u){var _=o.__data__;return wx(u)?_[typeof u=="string"?"string":"hash"]:_.map}function nl(o){for(var u=je(o),_=u.length;_--;){var D=u[_],C=o[D];u[_]=[D,C,K0(C)]}return u}function ui(o,u){var _=xD(o,u);return h0(_)?_:e}function px(o){var u=ae.call(o,ni),_=o[ni];try{o[ni]=e;var D=!0}catch{}var C=No.call(o);return D&&(u?o[ni]=_:delete o[ni]),C}var il=Bu?function(o){return o==null?[]:(o=pe(o),Ln(Bu(o),function(u){return Jh.call(o,u)}))}:bl,Y0=Bu?function(o){for(var u=[];o;)Rn(u,il(o)),o=Oo(o);return u}:bl,er=sr;(Ou&&er(new Ou(new ArrayBuffer(1)))!=rt||os&&er(new os)!=Jt||Iu&&er(Iu.resolve())!=pn||Pi&&er(new Pi)!=yr||as&&er(new as)!=G)&&(er=function(o){var u=sr(o),_=u==ze?o.constructor:e,D=_?li(_):"";if(D)switch(D){case GD:return rt;case HD:return Jt;case JD:return pn;case XD:return yr;case QD:return G}return u});function dx(o,u,_){for(var D=-1,C=_.length;++D<C;){var I=_[D],P=I.size;switch(I.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=tr(u,o+P);break;case"takeRight":o=Ue(o,u-P);break}}return{start:o,end:u}}function _x(o){var u=o.match(eu);return u?u[1].split(ru):[]}function V0(o,u,_){u=Un(u,o);for(var D=-1,C=u.length,I=!1;++D<C;){var P=on(u[D]);if(!(I=o!=null&&_(o,P)))break;o=o[P]}return I||++D!=C?I:(C=o==null?0:o.length,!!C&&sa(C)&&wn(P,C)&&(Tt(o)||ci(o)))}function mx(o){var u=o.length,_=new o.constructor(u);return u&&typeof o[0]=="string"&&ae.call(o,"index")&&(_.index=o.index,_.input=o.input),_}function Z0(o){return typeof o.constructor=="function"&&!ms(o)?qi(Oo(o)):{}}function gx(o,u,_){var D=o.constructor;switch(u){case st:return Ju(o);case oe:case It:return new D(+o);case rt:return tx(o,_);case ft:case ut:case ht:case at:case Xt:case ne:case be:case We:case qe:return N0(o,_);case Jt:return new D;case Le:case In:return new D(o);case dn:return ex(o);case yr:return new D;case L:return rx(o)}}function vx(o,u){var _=u.length;if(!_)return o;var D=_-1;return u[D]=(_>1?"& ":"")+u[D],u=u.join(_>2?", ":" "),o.replace(tu,`{
|
9
9
|
/* [wrapped with `+u+`] */
|
10
|
-
`)}function yx(o){return Tt(o)||ci(o)||!!(Xh&&o&&o[Xh])}function wn(o,u){var _=typeof o;return u=u??Z,!!u&&(_=="number"||_!="symbol"&&fu.test(o))&&o>-1&&o%1==0&&o<u}function or(o,u,_){if(!Ce(_))return!1;var D=typeof u;return(D=="number"?hr(_)&&wn(u,_.length):D=="string"&&u in _)?Gr(_[u],o):!1}function sl(o,u){if(Tt(o))return!1;var _=typeof o;return _=="number"||_=="symbol"||_=="boolean"||o==null||Ar(o)?!0:Ha.test(o)||!Ga.test(o)||u!=null&&o in pe(u)}function wx(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function ol(o){var u=Jo(o),_=B[u];if(typeof _!="function"||!(u in jt.prototype))return!1;if(o===_)return!0;var D=rl(_);return!!D&&o===D[0]}function Dx(o){return!!Kh&&Kh in o}var bx=Fo?Dn:xl;function ms(o){var u=o&&o.constructor,_=typeof u=="function"&&u.prototype||Ri;return o===_}function K0(o){return o===o&&!Ce(o)}function G0(o,u){return function(_){return _==null?!1:_[o]===u&&(u!==e||o in pe(_))}}function xx(o){var u=na(o,function(D){return _.size===h&&_.clear(),D}),_=u.cache;return u}function Ex(o,u){var _=o[1],D=u[1],A=_|D,I=A<(w|v|M),P=D==M&&_==b||D==M&&_==S&&o[7].length<=u[8]||D==(M|S)&&u[7].length<=u[8]&&_==b;if(!(I||P))return o;D&w&&(o[2]=u[2],A|=_&w?0:x);var q=u[3];if(q){var Y=o[3];o[3]=Y?B0(Y,q,u[4]):q,o[4]=Y?Pn(o[3],p):u[4]}return q=u[5],q&&(Y=o[5],o[5]=Y?O0(Y,q,u[6]):q,o[6]=Y?Pn(o[5],p):u[6]),q=u[7],q&&(o[7]=q),D&M&&(o[8]=o[8]==null?u[8]:tr(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=A,o}function Ax(o){var u=[];if(o!=null)for(var _ in pe(o))u.push(_);return u}function Cx(o){return No.call(o)}function H0(o,u,_){return u=Ue(u===e?o.length-1:u,0),function(){for(var D=arguments,A=-1,I=Ue(D.length-u,0),P=H(I);++A<I;)P[A]=D[u+A];A=-1;for(var q=H(u+1);++A<u;)q[A]=D[A];return q[u]=_(P),br(o,this,q)}}function J0(o,u){return u.length<2?o:ai(o,Rr(u,0,-1))}function Fx(o,u){for(var _=o.length,D=tr(u.length,_),A=fr(o);D--;){var I=u[D];o[D]=wn(I,_)?A[I]:e}return o}function al(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var X0=tp(D0),gs=UD||function(o,u){return Ge.setTimeout(o,u)},ul=tp(Hb);function Q0(o,u,_){var D=u+"";return ul(o,vx(D,Mx(_x(D),_)))}function tp(o){var u=0,_=0;return function(){var D=VD(),A=U-(D-_);if(_=D,A>0){if(++u>=R)return arguments[0]}else u=0;return o.apply(e,arguments)}}function Qo(o,u){var _=-1,D=o.length,A=D-1;for(u=u===e?D:u;++_<u;){var I=ju(_,A),P=o[I];o[I]=o[_],o[_]=P}return o.length=u,o}var ep=xx(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(Ja,function(_,D,A,I){u.push(A?I.replace(su,"$1"):D||_)}),u});function on(o){if(typeof o=="string"||Ar(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function li(o){if(o!=null){try{return Mo.call(o)}catch{}try{return o+""}catch{}}return""}function Mx(o,u){return Ir(wt,function(_){var D="_."+_[0];u&_[1]&&!xo(o,D)&&o.push(D)}),o.sort()}function rp(o){if(o instanceof jt)return o.clone();var u=new $r(o.__wrapped__,o.__chain__);return u.__actions__=fr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function Nx(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Ue(Lt(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var A=0,I=0,P=H($o(D/u));A<D;)P[I++]=Rr(o,A,A+=u);return P}function Sx(o){for(var u=-1,_=o==null?0:o.length,D=0,A=[];++u<_;){var I=o[u];I&&(A[D++]=I)}return A}function Bx(){var o=arguments.length;if(!o)return[];for(var u=H(o-1),_=arguments[0],D=o;D--;)u[D-1]=arguments[D];return Rn(Tt(_)?fr(_):[_],He(u,1))}var Ox=Pt(function(o,u){return Be(o)?fs(o,He(u,1,Be,!0)):[]}),Ix=Pt(function(o,u){var _=Pr(u);return Be(_)&&(_=e),Be(o)?fs(o,He(u,1,Be,!0),At(_,2)):[]}),Tx=Pt(function(o,u){var _=Pr(u);return Be(_)&&(_=e),Be(o)?fs(o,He(u,1,Be,!0),e,_):[]});function $x(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),Rr(o,u<0?0:u,D)):[]}function Lx(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,0,u<0?0:u)):[]}function Rx(o,u){return o&&o.length?Yo(o,At(u,3),!0,!0):[]}function Px(o,u){return o&&o.length?Yo(o,At(u,3),!0):[]}function zx(o,u,_,D){var A=o==null?0:o.length;return A?(_&&typeof _!="number"&&or(o,u,_)&&(_=0,D=A),Bb(o,u,_,D)):[]}function np(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=_==null?0:Lt(_);return A<0&&(A=Ue(D+A,0)),Eo(o,At(u,3),A)}function ip(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=D-1;return _!==e&&(A=Lt(_),A=_<0?Ue(D+A,0):tr(A,D-1)),Eo(o,At(u,3),A,!0)}function sp(o){var u=o==null?0:o.length;return u?He(o,1):[]}function qx(o){var u=o==null?0:o.length;return u?He(o,K):[]}function kx(o,u){var _=o==null?0:o.length;return _?(u=u===e?1:Lt(u),He(o,u)):[]}function Ux(o){for(var u=-1,_=o==null?0:o.length,D={};++u<_;){var A=o[u];D[A[0]]=A[1]}return D}function op(o){return o&&o.length?o[0]:e}function Wx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=_==null?0:Lt(_);return A<0&&(A=Ue(D+A,0)),Ii(o,u,A)}function jx(o){var u=o==null?0:o.length;return u?Rr(o,0,-1):[]}var Yx=Pt(function(o){var u=xe(o,Gu);return u.length&&u[0]===o[0]?zu(u):[]}),Vx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u===Pr(_)?u=e:_.pop(),_.length&&_[0]===o[0]?zu(_,At(u,2)):[]}),Zx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u=typeof u=="function"?u:e,u&&_.pop(),_.length&&_[0]===o[0]?zu(_,e,u):[]});function Kx(o,u){return o==null?"":jD.call(o,u)}function Pr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function Gx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=D;return _!==e&&(A=Lt(_),A=A<0?Ue(D+A,0):tr(A,D-1)),u===u?MD(o,u,A):Eo(o,qh,A,!0)}function Hx(o,u){return o&&o.length?g0(o,Lt(u)):e}var Jx=Pt(ap);function ap(o,u){return o&&o.length&&u&&u.length?Wu(o,u):o}function Xx(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,At(_,2)):o}function Qx(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,e,_):o}var tE=yn(function(o,u){var _=o==null?0:o.length,D=$u(o,u);return w0(o,xe(u,function(A){return wn(A,_)?+A:A}).sort(S0)),D});function eE(o,u){var _=[];if(!(o&&o.length))return _;var D=-1,A=[],I=o.length;for(u=At(u,3);++D<I;){var P=o[D];u(P,D,o)&&(_.push(P),A.push(D))}return w0(o,A),_}function ll(o){return o==null?o:KD.call(o)}function rE(o,u,_){var D=o==null?0:o.length;return D?(_&&typeof _!="number"&&or(o,u,_)?(u=0,_=D):(u=u==null?0:Lt(u),_=_===e?D:Lt(_)),Rr(o,u,_)):[]}function nE(o,u){return jo(o,u)}function iE(o,u,_){return Vu(o,u,At(_,2))}function sE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u);if(D<_&&Gr(o[D],u))return D}return-1}function oE(o,u){return jo(o,u,!0)}function aE(o,u,_){return Vu(o,u,At(_,2),!0)}function uE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u,!0)-1;if(Gr(o[D],u))return D}return-1}function lE(o){return o&&o.length?b0(o):[]}function cE(o,u){return o&&o.length?b0(o,At(u,2)):[]}function fE(o){var u=o==null?0:o.length;return u?Rr(o,1,u):[]}function hE(o,u,_){return o&&o.length?(u=_||u===e?1:Lt(u),Rr(o,0,u<0?0:u)):[]}function pE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,u<0?0:u,D)):[]}function dE(o,u){return o&&o.length?Yo(o,At(u,3),!1,!0):[]}function _E(o,u){return o&&o.length?Yo(o,At(u,3)):[]}var mE=Pt(function(o){return kn(He(o,1,Be,!0))}),gE=Pt(function(o){var u=Pr(o);return Be(u)&&(u=e),kn(He(o,1,Be,!0),At(u,2))}),vE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,kn(He(o,1,Be,!0),e,u)});function yE(o){return o&&o.length?kn(o):[]}function wE(o,u){return o&&o.length?kn(o,At(u,2)):[]}function DE(o,u){return u=typeof u=="function"?u:e,o&&o.length?kn(o,e,u):[]}function cl(o){if(!(o&&o.length))return[];var u=0;return o=Ln(o,function(_){if(Be(_))return u=Ue(_.length,u),!0}),Fu(u,function(_){return xe(o,Eu(_))})}function up(o,u){if(!(o&&o.length))return[];var _=cl(o);return u==null?_:xe(_,function(D){return br(u,e,D)})}var bE=Pt(function(o,u){return Be(o)?fs(o,u):[]}),xE=Pt(function(o){return Ku(Ln(o,Be))}),EE=Pt(function(o){var u=Pr(o);return Be(u)&&(u=e),Ku(Ln(o,Be),At(u,2))}),AE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,Ku(Ln(o,Be),e,u)}),CE=Pt(cl);function FE(o,u){return C0(o||[],u||[],cs)}function ME(o,u){return C0(o||[],u||[],ds)}var NE=Pt(function(o){var u=o.length,_=u>1?o[u-1]:e;return _=typeof _=="function"?(o.pop(),_):e,up(o,_)});function lp(o){var u=B(o);return u.__chain__=!0,u}function SE(o,u){return u(o),o}function ta(o,u){return u(o)}var BE=yn(function(o){var u=o.length,_=u?o[0]:0,D=this.__wrapped__,A=function(I){return $u(I,o)};return u>1||this.__actions__.length||!(D instanceof jt)||!wn(_)?this.thru(A):(D=D.slice(_,+_+(u?1:0)),D.__actions__.push({func:ta,args:[A],thisArg:e}),new $r(D,this.__chain__).thru(function(I){return u&&!I.length&&I.push(e),I}))});function OE(){return lp(this)}function IE(){return new $r(this.value(),this.__chain__)}function TE(){this.__values__===e&&(this.__values__=xp(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function $E(){return this}function LE(o){for(var u,_=this;_ instanceof zo;){var D=rp(_);D.__index__=0,D.__values__=e,u?A.__wrapped__=D:u=D;var A=D;_=_.__wrapped__}return A.__wrapped__=o,u}function RE(){var o=this.__wrapped__;if(o instanceof jt){var u=o;return this.__actions__.length&&(u=new jt(this)),u=u.reverse(),u.__actions__.push({func:ta,args:[ll],thisArg:e}),new $r(u,this.__chain__)}return this.thru(ll)}function PE(){return A0(this.__wrapped__,this.__actions__)}var zE=Vo(function(o,u,_){ae.call(o,_)?++o[_]:gn(o,_,1)});function qE(o,u,_){var D=Tt(o)?Ph:Sb;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}function kE(o,u){var _=Tt(o)?Ln:u0;return _(o,At(u,3))}var UE=L0(np),WE=L0(ip);function jE(o,u){return He(ea(o,u),1)}function YE(o,u){return He(ea(o,u),K)}function VE(o,u,_){return _=_===e?1:Lt(_),He(ea(o,u),_)}function cp(o,u){var _=Tt(o)?Ir:qn;return _(o,At(u,3))}function fp(o,u){var _=Tt(o)?fD:a0;return _(o,At(u,3))}var ZE=Vo(function(o,u,_){ae.call(o,_)?o[_].push(u):gn(o,_,[u])});function KE(o,u,_,D){o=hr(o)?o:Yi(o),_=_&&!D?Lt(_):0;var A=o.length;return _<0&&(_=Ue(A+_,0)),oa(o)?_<=A&&o.indexOf(u,_)>-1:!!A&&Ii(o,u,_)>-1}var GE=Pt(function(o,u,_){var D=-1,A=typeof u=="function",I=hr(o)?H(o.length):[];return qn(o,function(P){I[++D]=A?br(u,P,_):hs(P,u,_)}),I}),HE=Vo(function(o,u,_){gn(o,_,u)});function ea(o,u){var _=Tt(o)?xe:d0;return _(o,At(u,3))}function JE(o,u,_,D){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),_=D?e:_,Tt(_)||(_=_==null?[]:[_]),v0(o,u,_))}var XE=Vo(function(o,u,_){o[_?0:1].push(u)},function(){return[[],[]]});function QE(o,u,_){var D=Tt(o)?bu:Uh,A=arguments.length<3;return D(o,At(u,4),_,A,qn)}function tA(o,u,_){var D=Tt(o)?hD:Uh,A=arguments.length<3;return D(o,At(u,4),_,A,a0)}function eA(o,u){var _=Tt(o)?Ln:u0;return _(o,ia(At(u,3)))}function rA(o){var u=Tt(o)?n0:Kb;return u(o)}function nA(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Lt(u);var D=Tt(o)?Ab:Gb;return D(o,u)}function iA(o){var u=Tt(o)?Cb:Jb;return u(o)}function sA(o){if(o==null)return 0;if(hr(o))return oa(o)?$i(o):o.length;var u=er(o);return u==Jt||u==yr?o.size:ku(o).length}function oA(o,u,_){var D=Tt(o)?xu:Xb;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}var aA=Pt(function(o,u){if(o==null)return[];var _=u.length;return _>1&&or(o,u[0],u[1])?u=[]:_>2&&or(u[0],u[1],u[2])&&(u=[u[0]]),v0(o,He(u,1),[])}),ra=kD||function(){return Ge.Date.now()};function uA(o,u){if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){if(--o<1)return u.apply(this,arguments)}}function hp(o,u,_){return u=_?e:u,u=o&&u==null?o.length:u,vn(o,M,e,e,e,e,u)}function pp(o,u){var _;if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){return--o>0&&(_=u.apply(this,arguments)),o<=1&&(u=e),_}}var fl=Pt(function(o,u,_){var D=w;if(_.length){var A=Pn(_,Wi(fl));D|=E}return vn(o,D,u,_,A)}),dp=Pt(function(o,u,_){var D=w|v;if(_.length){var A=Pn(_,Wi(dp));D|=E}return vn(u,D,o,_,A)});function _p(o,u,_){u=_?e:u;var D=vn(o,b,e,e,e,e,e,u);return D.placeholder=_p.placeholder,D}function mp(o,u,_){u=_?e:u;var D=vn(o,N,e,e,e,e,e,u);return D.placeholder=mp.placeholder,D}function gp(o,u,_){var D,A,I,P,q,Y,tt=0,et=!1,ot=!1,dt=!0;if(typeof o!="function")throw new Tr(a);u=zr(u)||0,Ce(_)&&(et=!!_.leading,ot="maxWait"in _,I=ot?Ue(zr(_.maxWait)||0,u):I,dt="trailing"in _?!!_.trailing:dt);function yt(Oe){var Hr=D,xn=A;return D=A=e,tt=Oe,P=o.apply(xn,Hr),P}function Ct(Oe){return tt=Oe,q=gs(Ut,u),et?yt(Oe):P}function Rt(Oe){var Hr=Oe-Y,xn=Oe-tt,Lp=u-Hr;return ot?tr(Lp,I-xn):Lp}function Ft(Oe){var Hr=Oe-Y,xn=Oe-tt;return Y===e||Hr>=u||Hr<0||ot&&xn>=I}function Ut(){var Oe=ra();if(Ft(Oe))return Yt(Oe);q=gs(Ut,Rt(Oe))}function Yt(Oe){return q=e,dt&&D?yt(Oe):(D=A=e,P)}function Cr(){q!==e&&F0(q),tt=0,D=Y=A=q=e}function ar(){return q===e?P:Yt(ra())}function Fr(){var Oe=ra(),Hr=Ft(Oe);if(D=arguments,A=this,Y=Oe,Hr){if(q===e)return Ct(Y);if(ot)return F0(q),q=gs(Ut,u),yt(Y)}return q===e&&(q=gs(Ut,u)),P}return Fr.cancel=Cr,Fr.flush=ar,Fr}var lA=Pt(function(o,u){return o0(o,1,u)}),cA=Pt(function(o,u,_){return o0(o,zr(u)||0,_)});function fA(o){return vn(o,T)}function na(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new Tr(a);var _=function(){var D=arguments,A=u?u.apply(this,D):D[0],I=_.cache;if(I.has(A))return I.get(A);var P=o.apply(this,D);return _.cache=I.set(A,P)||I,P};return _.cache=new(na.Cache||mn),_}na.Cache=mn;function ia(o){if(typeof o!="function")throw new Tr(a);return function(){var u=arguments;switch(u.length){case 0:return!o.call(this);case 1:return!o.call(this,u[0]);case 2:return!o.call(this,u[0],u[1]);case 3:return!o.call(this,u[0],u[1],u[2])}return!o.apply(this,u)}}function hA(o){return pp(2,o)}var pA=Qb(function(o,u){u=u.length==1&&Tt(u[0])?xe(u[0],xr(At())):xe(He(u,1),xr(At()));var _=u.length;return Pt(function(D){for(var A=-1,I=tr(D.length,_);++A<I;)D[A]=u[A].call(this,D[A]);return br(o,this,D)})}),hl=Pt(function(o,u){var _=Pn(u,Wi(hl));return vn(o,E,e,u,_)}),vp=Pt(function(o,u){var _=Pn(u,Wi(vp));return vn(o,C,e,u,_)}),dA=yn(function(o,u){return vn(o,S,e,e,e,u)});function _A(o,u){if(typeof o!="function")throw new Tr(a);return u=u===e?u:Lt(u),Pt(o,u)}function mA(o,u){if(typeof o!="function")throw new Tr(a);return u=u==null?0:Ue(Lt(u),0),Pt(function(_){var D=_[u],A=Wn(_,0,u);return D&&Rn(A,D),br(o,this,A)})}function gA(o,u,_){var D=!0,A=!0;if(typeof o!="function")throw new Tr(a);return Ce(_)&&(D="leading"in _?!!_.leading:D,A="trailing"in _?!!_.trailing:A),gp(o,u,{leading:D,maxWait:u,trailing:A})}function vA(o){return hp(o,1)}function yA(o,u){return hl(Hu(u),o)}function wA(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function DA(o){return Lr(o,g)}function bA(o,u){return u=typeof u=="function"?u:e,Lr(o,g,u)}function xA(o){return Lr(o,f|g)}function EA(o,u){return u=typeof u=="function"?u:e,Lr(o,f|g,u)}function AA(o,u){return u==null||s0(o,u,je(u))}function Gr(o,u){return o===u||o!==o&&u!==u}var CA=Ho(Pu),FA=Ho(function(o,u){return o>=u}),ci=f0(function(){return arguments}())?f0:function(o){return Me(o)&&ae.call(o,"callee")&&!Jh.call(o,"callee")},Tt=H.isArray,MA=Oh?xr(Oh):Lb;function hr(o){return o!=null&&sa(o.length)&&!Dn(o)}function Be(o){return Me(o)&&hr(o)}function NA(o){return o===!0||o===!1||Me(o)&&sr(o)==oe}var jn=WD||xl,SA=Ih?xr(Ih):Rb;function BA(o){return Me(o)&&o.nodeType===1&&!vs(o)}function OA(o){if(o==null)return!0;if(hr(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||jn(o)||ji(o)||ci(o)))return!o.length;var u=er(o);if(u==Jt||u==yr)return!o.size;if(ms(o))return!ku(o).length;for(var _ in o)if(ae.call(o,_))return!1;return!0}function IA(o,u){return ps(o,u)}function TA(o,u,_){_=typeof _=="function"?_:e;var D=_?_(o,u):e;return D===e?ps(o,u,e,_):!!D}function pl(o){if(!Me(o))return!1;var u=sr(o);return u==ce||u==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!vs(o)}function $A(o){return typeof o=="number"&&Qh(o)}function Dn(o){if(!Ce(o))return!1;var u=sr(o);return u==re||u==kt||u==xt||u==On}function yp(o){return typeof o=="number"&&o==Lt(o)}function sa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Ce(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Me(o){return o!=null&&typeof o=="object"}var wp=Th?xr(Th):zb;function LA(o,u){return o===u||qu(o,u,nl(u))}function RA(o,u,_){return _=typeof _=="function"?_:e,qu(o,u,nl(u),_)}function PA(o){return Dp(o)&&o!=+o}function zA(o){if(bx(o))throw new Ot(i);return h0(o)}function qA(o){return o===null}function kA(o){return o==null}function Dp(o){return typeof o=="number"||Me(o)&&sr(o)==Le}function vs(o){if(!Me(o)||sr(o)!=ze)return!1;var u=Oo(o);if(u===null)return!0;var _=ae.call(u,"constructor")&&u.constructor;return typeof _=="function"&&_ instanceof _&&Mo.call(_)==RD}var dl=$h?xr($h):qb;function UA(o){return yp(o)&&o>=-Z&&o<=Z}var bp=Lh?xr(Lh):kb;function oa(o){return typeof o=="string"||!Tt(o)&&Me(o)&&sr(o)==In}function Ar(o){return typeof o=="symbol"||Me(o)&&sr(o)==L}var ji=Rh?xr(Rh):Ub;function WA(o){return o===e}function jA(o){return Me(o)&&er(o)==G}function YA(o){return Me(o)&&sr(o)==nt}var VA=Ho(Uu),ZA=Ho(function(o,u){return o<=u});function xp(o){if(!o)return[];if(hr(o))return oa(o)?Zr(o):fr(o);if(ss&&o[ss])return AD(o[ss]());var u=er(o),_=u==Jt?Nu:u==yr?Ao:Yi;return _(o)}function bn(o){if(!o)return o===0?o:0;if(o=zr(o),o===K||o===-K){var u=o<0?-1:1;return u*X}return o===o?o:0}function Lt(o){var u=bn(o),_=u%1;return u===u?_?u-_:u:0}function Ep(o){return o?oi(Lt(o),0,ct):0}function zr(o){if(typeof o=="number")return o;if(Ar(o))return Q;if(Ce(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Ce(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=Wh(o);var _=uu.test(o);return _||cu.test(o)?uD(o.slice(2),_?2:8):au.test(o)?Q:+o}function Ap(o){return sn(o,pr(o))}function KA(o){return o?oi(Lt(o),-Z,Z):o===0?o:0}function ie(o){return o==null?"":Er(o)}var GA=ki(function(o,u){if(ms(u)||hr(u)){sn(u,je(u),o);return}for(var _ in u)ae.call(u,_)&&cs(o,_,u[_])}),Cp=ki(function(o,u){sn(u,pr(u),o)}),aa=ki(function(o,u,_,D){sn(u,pr(u),o,D)}),HA=ki(function(o,u,_,D){sn(u,je(u),o,D)}),JA=yn($u);function XA(o,u){var _=qi(o);return u==null?_:i0(_,u)}var QA=Pt(function(o,u){o=pe(o);var _=-1,D=u.length,A=D>2?u[2]:e;for(A&&or(u[0],u[1],A)&&(D=1);++_<D;)for(var I=u[_],P=pr(I),q=-1,Y=P.length;++q<Y;){var tt=P[q],et=o[tt];(et===e||Gr(et,Ri[tt])&&!ae.call(o,tt))&&(o[tt]=I[tt])}return o}),tC=Pt(function(o){return o.push(e,W0),br(Fp,e,o)});function eC(o,u){return zh(o,At(u,3),nn)}function rC(o,u){return zh(o,At(u,3),Ru)}function nC(o,u){return o==null?o:Lu(o,At(u,3),pr)}function iC(o,u){return o==null?o:l0(o,At(u,3),pr)}function sC(o,u){return o&&nn(o,At(u,3))}function oC(o,u){return o&&Ru(o,At(u,3))}function aC(o){return o==null?[]:Uo(o,je(o))}function uC(o){return o==null?[]:Uo(o,pr(o))}function _l(o,u,_){var D=o==null?e:ai(o,u);return D===e?_:D}function lC(o,u){return o!=null&&V0(o,u,Ob)}function ml(o,u){return o!=null&&V0(o,u,Ib)}var cC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),o[u]=_},vl(dr)),fC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),ae.call(o,u)?o[u].push(_):o[u]=[_]},At),hC=Pt(hs);function je(o){return hr(o)?r0(o):ku(o)}function pr(o){return hr(o)?r0(o,!0):Wb(o)}function pC(o,u){var _={};return u=At(u,3),nn(o,function(D,A,I){gn(_,u(D,A,I),D)}),_}function dC(o,u){var _={};return u=At(u,3),nn(o,function(D,A,I){gn(_,A,u(D,A,I))}),_}var _C=ki(function(o,u,_){Wo(o,u,_)}),Fp=ki(function(o,u,_,D){Wo(o,u,_,D)}),mC=yn(function(o,u){var _={};if(o==null)return _;var D=!1;u=xe(u,function(I){return I=Un(I,o),D||(D=I.length>1),I}),sn(o,el(o),_),D&&(_=Lr(_,f|d|g,cx));for(var A=u.length;A--;)Zu(_,u[A]);return _});function gC(o,u){return Mp(o,ia(At(u)))}var vC=yn(function(o,u){return o==null?{}:Yb(o,u)});function Mp(o,u){if(o==null)return{};var _=xe(el(o),function(D){return[D]});return u=At(u),y0(o,_,function(D,A){return u(D,A[0])})}function yC(o,u,_){u=Un(u,o);var D=-1,A=u.length;for(A||(A=1,o=e);++D<A;){var I=o==null?e:o[on(u[D])];I===e&&(D=A,I=_),o=Dn(I)?I.call(o):I}return o}function wC(o,u,_){return o==null?o:ds(o,u,_)}function DC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:ds(o,u,_,D)}var Np=k0(je),Sp=k0(pr);function bC(o,u,_){var D=Tt(o),A=D||jn(o)||ji(o);if(u=At(u,4),_==null){var I=o&&o.constructor;A?_=D?new I:[]:Ce(o)?_=Dn(I)?qi(Oo(o)):{}:_={}}return(A?Ir:nn)(o,function(P,q,Y){return u(_,P,q,Y)}),_}function xC(o,u){return o==null?!0:Zu(o,u)}function EC(o,u,_){return o==null?o:E0(o,u,Hu(_))}function AC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:E0(o,u,Hu(_),D)}function Yi(o){return o==null?[]:Mu(o,je(o))}function CC(o){return o==null?[]:Mu(o,pr(o))}function FC(o,u,_){return _===e&&(_=u,u=e),_!==e&&(_=zr(_),_=_===_?_:0),u!==e&&(u=zr(u),u=u===u?u:0),oi(zr(o),u,_)}function MC(o,u,_){return u=bn(u),_===e?(_=u,u=0):_=bn(_),o=zr(o),Tb(o,u,_)}function NC(o,u,_){if(_&&typeof _!="boolean"&&or(o,u,_)&&(u=_=e),_===e&&(typeof u=="boolean"?(_=u,u=e):typeof o=="boolean"&&(_=o,o=e)),o===e&&u===e?(o=0,u=1):(o=bn(o),u===e?(u=o,o=0):u=bn(u)),o>u){var D=o;o=u,u=D}if(_||o%1||u%1){var A=t0();return tr(o+A*(u-o+aD("1e-"+((A+"").length-1))),u)}return ju(o,u)}var SC=Ui(function(o,u,_){return u=u.toLowerCase(),o+(_?Bp(u):u)});function Bp(o){return gl(ie(o).toLowerCase())}function Op(o){return o=ie(o),o&&o.replace(hu,wD).replace(Jw,"")}function BC(o,u,_){o=ie(o),u=Er(u);var D=o.length;_=_===e?D:oi(Lt(_),0,D);var A=_;return _-=u.length,_>=0&&o.slice(_,A)==u}function OC(o){return o=ie(o),o&&Va.test(o)?o.replace(vo,DD):o}function IC(o){return o=ie(o),o&&Xa.test(o)?o.replace(rs,"\\$&"):o}var TC=Ui(function(o,u,_){return o+(_?"-":"")+u.toLowerCase()}),$C=Ui(function(o,u,_){return o+(_?" ":"")+u.toLowerCase()}),LC=$0("toLowerCase");function RC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;if(!u||D>=u)return o;var A=(u-D)/2;return Go(Lo(A),_)+o+Go($o(A),_)}function PC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?o+Go(u-D,_):o}function zC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?Go(u-D,_)+o:o}function qC(o,u,_){return _||u==null?u=0:u&&(u=+u),ZD(ie(o).replace(ns,""),u||0)}function kC(o,u,_){return(_?or(o,u,_):u===e)?u=1:u=Lt(u),Yu(ie(o),u)}function UC(){var o=arguments,u=ie(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var WC=Ui(function(o,u,_){return o+(_?"_":"")+u.toLowerCase()});function jC(o,u,_){return _&&typeof _!="number"&&or(o,u,_)&&(u=_=e),_=_===e?ct:_>>>0,_?(o=ie(o),o&&(typeof u=="string"||u!=null&&!dl(u))&&(u=Er(u),!u&&Ti(o))?Wn(Zr(o),0,_):o.split(u,_)):[]}var YC=Ui(function(o,u,_){return o+(_?" ":"")+gl(u)});function VC(o,u,_){return o=ie(o),_=_==null?0:oi(Lt(_),0,o.length),u=Er(u),o.slice(_,_+u.length)==u}function ZC(o,u,_){var D=B.templateSettings;_&&or(o,u,_)&&(u=e),o=ie(o),u=aa({},u,D,U0);var A=aa({},u.imports,D.imports,U0),I=je(A),P=Mu(A,I),q,Y,tt=0,et=u.interpolate||Si,ot="__p += '",dt=Su((u.escape||Si).source+"|"+et.source+"|"+(et===yo?ou:Si).source+"|"+(u.evaluate||Si).source+"|$","g"),yt="//# sourceURL="+(ae.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rD+"]")+`
|
10
|
+
`)}function yx(o){return Tt(o)||ci(o)||!!(Xh&&o&&o[Xh])}function wn(o,u){var _=typeof o;return u=u??Z,!!u&&(_=="number"||_!="symbol"&&fu.test(o))&&o>-1&&o%1==0&&o<u}function or(o,u,_){if(!Ce(_))return!1;var D=typeof u;return(D=="number"?hr(_)&&wn(u,_.length):D=="string"&&u in _)?Gr(_[u],o):!1}function sl(o,u){if(Tt(o))return!1;var _=typeof o;return _=="number"||_=="symbol"||_=="boolean"||o==null||Ar(o)?!0:Ha.test(o)||!Ga.test(o)||u!=null&&o in pe(u)}function wx(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function ol(o){var u=Jo(o),_=B[u];if(typeof _!="function"||!(u in jt.prototype))return!1;if(o===_)return!0;var D=rl(_);return!!D&&o===D[0]}function Dx(o){return!!Kh&&Kh in o}var bx=Fo?Dn:xl;function ms(o){var u=o&&o.constructor,_=typeof u=="function"&&u.prototype||Ri;return o===_}function K0(o){return o===o&&!Ce(o)}function G0(o,u){return function(_){return _==null?!1:_[o]===u&&(u!==e||o in pe(_))}}function xx(o){var u=na(o,function(D){return _.size===p&&_.clear(),D}),_=u.cache;return u}function Ex(o,u){var _=o[1],D=u[1],C=_|D,I=C<(w|v|M),P=D==M&&_==b||D==M&&_==S&&o[7].length<=u[8]||D==(M|S)&&u[7].length<=u[8]&&_==b;if(!(I||P))return o;D&w&&(o[2]=u[2],C|=_&w?0:x);var q=u[3];if(q){var Y=o[3];o[3]=Y?B0(Y,q,u[4]):q,o[4]=Y?Pn(o[3],h):u[4]}return q=u[5],q&&(Y=o[5],o[5]=Y?O0(Y,q,u[6]):q,o[6]=Y?Pn(o[5],h):u[6]),q=u[7],q&&(o[7]=q),D&M&&(o[8]=o[8]==null?u[8]:tr(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=C,o}function Ax(o){var u=[];if(o!=null)for(var _ in pe(o))u.push(_);return u}function Cx(o){return No.call(o)}function H0(o,u,_){return u=Ue(u===e?o.length-1:u,0),function(){for(var D=arguments,C=-1,I=Ue(D.length-u,0),P=H(I);++C<I;)P[C]=D[u+C];C=-1;for(var q=H(u+1);++C<u;)q[C]=D[C];return q[u]=_(P),br(o,this,q)}}function J0(o,u){return u.length<2?o:ai(o,Rr(u,0,-1))}function Fx(o,u){for(var _=o.length,D=tr(u.length,_),C=fr(o);D--;){var I=u[D];o[D]=wn(I,_)?C[I]:e}return o}function al(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var X0=tp(D0),gs=UD||function(o,u){return Ge.setTimeout(o,u)},ul=tp(Hb);function Q0(o,u,_){var D=u+"";return ul(o,vx(D,Mx(_x(D),_)))}function tp(o){var u=0,_=0;return function(){var D=VD(),C=U-(D-_);if(_=D,C>0){if(++u>=R)return arguments[0]}else u=0;return o.apply(e,arguments)}}function Qo(o,u){var _=-1,D=o.length,C=D-1;for(u=u===e?D:u;++_<u;){var I=ju(_,C),P=o[I];o[I]=o[_],o[_]=P}return o.length=u,o}var ep=xx(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(Ja,function(_,D,C,I){u.push(C?I.replace(su,"$1"):D||_)}),u});function on(o){if(typeof o=="string"||Ar(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function li(o){if(o!=null){try{return Mo.call(o)}catch{}try{return o+""}catch{}}return""}function Mx(o,u){return Ir(wt,function(_){var D="_."+_[0];u&_[1]&&!xo(o,D)&&o.push(D)}),o.sort()}function rp(o){if(o instanceof jt)return o.clone();var u=new $r(o.__wrapped__,o.__chain__);return u.__actions__=fr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function Nx(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Ue(Lt(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var C=0,I=0,P=H($o(D/u));C<D;)P[I++]=Rr(o,C,C+=u);return P}function Sx(o){for(var u=-1,_=o==null?0:o.length,D=0,C=[];++u<_;){var I=o[u];I&&(C[D++]=I)}return C}function Bx(){var o=arguments.length;if(!o)return[];for(var u=H(o-1),_=arguments[0],D=o;D--;)u[D-1]=arguments[D];return Rn(Tt(_)?fr(_):[_],He(u,1))}var Ox=Pt(function(o,u){return Be(o)?fs(o,He(u,1,Be,!0)):[]}),Ix=Pt(function(o,u){var _=Pr(u);return Be(_)&&(_=e),Be(o)?fs(o,He(u,1,Be,!0),At(_,2)):[]}),Tx=Pt(function(o,u){var _=Pr(u);return Be(_)&&(_=e),Be(o)?fs(o,He(u,1,Be,!0),e,_):[]});function $x(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),Rr(o,u<0?0:u,D)):[]}function Lx(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,0,u<0?0:u)):[]}function Rx(o,u){return o&&o.length?Yo(o,At(u,3),!0,!0):[]}function Px(o,u){return o&&o.length?Yo(o,At(u,3),!0):[]}function zx(o,u,_,D){var C=o==null?0:o.length;return C?(_&&typeof _!="number"&&or(o,u,_)&&(_=0,D=C),Bb(o,u,_,D)):[]}function np(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=Ue(D+C,0)),Eo(o,At(u,3),C)}function ip(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D-1;return _!==e&&(C=Lt(_),C=_<0?Ue(D+C,0):tr(C,D-1)),Eo(o,At(u,3),C,!0)}function sp(o){var u=o==null?0:o.length;return u?He(o,1):[]}function qx(o){var u=o==null?0:o.length;return u?He(o,K):[]}function kx(o,u){var _=o==null?0:o.length;return _?(u=u===e?1:Lt(u),He(o,u)):[]}function Ux(o){for(var u=-1,_=o==null?0:o.length,D={};++u<_;){var C=o[u];D[C[0]]=C[1]}return D}function op(o){return o&&o.length?o[0]:e}function Wx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=Ue(D+C,0)),Ii(o,u,C)}function jx(o){var u=o==null?0:o.length;return u?Rr(o,0,-1):[]}var Yx=Pt(function(o){var u=xe(o,Gu);return u.length&&u[0]===o[0]?zu(u):[]}),Vx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u===Pr(_)?u=e:_.pop(),_.length&&_[0]===o[0]?zu(_,At(u,2)):[]}),Zx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u=typeof u=="function"?u:e,u&&_.pop(),_.length&&_[0]===o[0]?zu(_,e,u):[]});function Kx(o,u){return o==null?"":jD.call(o,u)}function Pr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function Gx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D;return _!==e&&(C=Lt(_),C=C<0?Ue(D+C,0):tr(C,D-1)),u===u?MD(o,u,C):Eo(o,qh,C,!0)}function Hx(o,u){return o&&o.length?g0(o,Lt(u)):e}var Jx=Pt(ap);function ap(o,u){return o&&o.length&&u&&u.length?Wu(o,u):o}function Xx(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,At(_,2)):o}function Qx(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,e,_):o}var tE=yn(function(o,u){var _=o==null?0:o.length,D=$u(o,u);return w0(o,xe(u,function(C){return wn(C,_)?+C:C}).sort(S0)),D});function eE(o,u){var _=[];if(!(o&&o.length))return _;var D=-1,C=[],I=o.length;for(u=At(u,3);++D<I;){var P=o[D];u(P,D,o)&&(_.push(P),C.push(D))}return w0(o,C),_}function ll(o){return o==null?o:KD.call(o)}function rE(o,u,_){var D=o==null?0:o.length;return D?(_&&typeof _!="number"&&or(o,u,_)?(u=0,_=D):(u=u==null?0:Lt(u),_=_===e?D:Lt(_)),Rr(o,u,_)):[]}function nE(o,u){return jo(o,u)}function iE(o,u,_){return Vu(o,u,At(_,2))}function sE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u);if(D<_&&Gr(o[D],u))return D}return-1}function oE(o,u){return jo(o,u,!0)}function aE(o,u,_){return Vu(o,u,At(_,2),!0)}function uE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u,!0)-1;if(Gr(o[D],u))return D}return-1}function lE(o){return o&&o.length?b0(o):[]}function cE(o,u){return o&&o.length?b0(o,At(u,2)):[]}function fE(o){var u=o==null?0:o.length;return u?Rr(o,1,u):[]}function hE(o,u,_){return o&&o.length?(u=_||u===e?1:Lt(u),Rr(o,0,u<0?0:u)):[]}function pE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,u<0?0:u,D)):[]}function dE(o,u){return o&&o.length?Yo(o,At(u,3),!1,!0):[]}function _E(o,u){return o&&o.length?Yo(o,At(u,3)):[]}var mE=Pt(function(o){return kn(He(o,1,Be,!0))}),gE=Pt(function(o){var u=Pr(o);return Be(u)&&(u=e),kn(He(o,1,Be,!0),At(u,2))}),vE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,kn(He(o,1,Be,!0),e,u)});function yE(o){return o&&o.length?kn(o):[]}function wE(o,u){return o&&o.length?kn(o,At(u,2)):[]}function DE(o,u){return u=typeof u=="function"?u:e,o&&o.length?kn(o,e,u):[]}function cl(o){if(!(o&&o.length))return[];var u=0;return o=Ln(o,function(_){if(Be(_))return u=Ue(_.length,u),!0}),Fu(u,function(_){return xe(o,Eu(_))})}function up(o,u){if(!(o&&o.length))return[];var _=cl(o);return u==null?_:xe(_,function(D){return br(u,e,D)})}var bE=Pt(function(o,u){return Be(o)?fs(o,u):[]}),xE=Pt(function(o){return Ku(Ln(o,Be))}),EE=Pt(function(o){var u=Pr(o);return Be(u)&&(u=e),Ku(Ln(o,Be),At(u,2))}),AE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,Ku(Ln(o,Be),e,u)}),CE=Pt(cl);function FE(o,u){return C0(o||[],u||[],cs)}function ME(o,u){return C0(o||[],u||[],ds)}var NE=Pt(function(o){var u=o.length,_=u>1?o[u-1]:e;return _=typeof _=="function"?(o.pop(),_):e,up(o,_)});function lp(o){var u=B(o);return u.__chain__=!0,u}function SE(o,u){return u(o),o}function ta(o,u){return u(o)}var BE=yn(function(o){var u=o.length,_=u?o[0]:0,D=this.__wrapped__,C=function(I){return $u(I,o)};return u>1||this.__actions__.length||!(D instanceof jt)||!wn(_)?this.thru(C):(D=D.slice(_,+_+(u?1:0)),D.__actions__.push({func:ta,args:[C],thisArg:e}),new $r(D,this.__chain__).thru(function(I){return u&&!I.length&&I.push(e),I}))});function OE(){return lp(this)}function IE(){return new $r(this.value(),this.__chain__)}function TE(){this.__values__===e&&(this.__values__=xp(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function $E(){return this}function LE(o){for(var u,_=this;_ instanceof zo;){var D=rp(_);D.__index__=0,D.__values__=e,u?C.__wrapped__=D:u=D;var C=D;_=_.__wrapped__}return C.__wrapped__=o,u}function RE(){var o=this.__wrapped__;if(o instanceof jt){var u=o;return this.__actions__.length&&(u=new jt(this)),u=u.reverse(),u.__actions__.push({func:ta,args:[ll],thisArg:e}),new $r(u,this.__chain__)}return this.thru(ll)}function PE(){return A0(this.__wrapped__,this.__actions__)}var zE=Vo(function(o,u,_){ae.call(o,_)?++o[_]:gn(o,_,1)});function qE(o,u,_){var D=Tt(o)?Ph:Sb;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}function kE(o,u){var _=Tt(o)?Ln:u0;return _(o,At(u,3))}var UE=L0(np),WE=L0(ip);function jE(o,u){return He(ea(o,u),1)}function YE(o,u){return He(ea(o,u),K)}function VE(o,u,_){return _=_===e?1:Lt(_),He(ea(o,u),_)}function cp(o,u){var _=Tt(o)?Ir:qn;return _(o,At(u,3))}function fp(o,u){var _=Tt(o)?fD:a0;return _(o,At(u,3))}var ZE=Vo(function(o,u,_){ae.call(o,_)?o[_].push(u):gn(o,_,[u])});function KE(o,u,_,D){o=hr(o)?o:Yi(o),_=_&&!D?Lt(_):0;var C=o.length;return _<0&&(_=Ue(C+_,0)),oa(o)?_<=C&&o.indexOf(u,_)>-1:!!C&&Ii(o,u,_)>-1}var GE=Pt(function(o,u,_){var D=-1,C=typeof u=="function",I=hr(o)?H(o.length):[];return qn(o,function(P){I[++D]=C?br(u,P,_):hs(P,u,_)}),I}),HE=Vo(function(o,u,_){gn(o,_,u)});function ea(o,u){var _=Tt(o)?xe:d0;return _(o,At(u,3))}function JE(o,u,_,D){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),_=D?e:_,Tt(_)||(_=_==null?[]:[_]),v0(o,u,_))}var XE=Vo(function(o,u,_){o[_?0:1].push(u)},function(){return[[],[]]});function QE(o,u,_){var D=Tt(o)?bu:Uh,C=arguments.length<3;return D(o,At(u,4),_,C,qn)}function tA(o,u,_){var D=Tt(o)?hD:Uh,C=arguments.length<3;return D(o,At(u,4),_,C,a0)}function eA(o,u){var _=Tt(o)?Ln:u0;return _(o,ia(At(u,3)))}function rA(o){var u=Tt(o)?n0:Kb;return u(o)}function nA(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Lt(u);var D=Tt(o)?Ab:Gb;return D(o,u)}function iA(o){var u=Tt(o)?Cb:Jb;return u(o)}function sA(o){if(o==null)return 0;if(hr(o))return oa(o)?$i(o):o.length;var u=er(o);return u==Jt||u==yr?o.size:ku(o).length}function oA(o,u,_){var D=Tt(o)?xu:Xb;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}var aA=Pt(function(o,u){if(o==null)return[];var _=u.length;return _>1&&or(o,u[0],u[1])?u=[]:_>2&&or(u[0],u[1],u[2])&&(u=[u[0]]),v0(o,He(u,1),[])}),ra=kD||function(){return Ge.Date.now()};function uA(o,u){if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){if(--o<1)return u.apply(this,arguments)}}function hp(o,u,_){return u=_?e:u,u=o&&u==null?o.length:u,vn(o,M,e,e,e,e,u)}function pp(o,u){var _;if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){return--o>0&&(_=u.apply(this,arguments)),o<=1&&(u=e),_}}var fl=Pt(function(o,u,_){var D=w;if(_.length){var C=Pn(_,Wi(fl));D|=E}return vn(o,D,u,_,C)}),dp=Pt(function(o,u,_){var D=w|v;if(_.length){var C=Pn(_,Wi(dp));D|=E}return vn(u,D,o,_,C)});function _p(o,u,_){u=_?e:u;var D=vn(o,b,e,e,e,e,e,u);return D.placeholder=_p.placeholder,D}function mp(o,u,_){u=_?e:u;var D=vn(o,N,e,e,e,e,e,u);return D.placeholder=mp.placeholder,D}function gp(o,u,_){var D,C,I,P,q,Y,tt=0,et=!1,ot=!1,dt=!0;if(typeof o!="function")throw new Tr(a);u=zr(u)||0,Ce(_)&&(et=!!_.leading,ot="maxWait"in _,I=ot?Ue(zr(_.maxWait)||0,u):I,dt="trailing"in _?!!_.trailing:dt);function yt(Oe){var Hr=D,xn=C;return D=C=e,tt=Oe,P=o.apply(xn,Hr),P}function Ct(Oe){return tt=Oe,q=gs(Ut,u),et?yt(Oe):P}function Rt(Oe){var Hr=Oe-Y,xn=Oe-tt,Lp=u-Hr;return ot?tr(Lp,I-xn):Lp}function Ft(Oe){var Hr=Oe-Y,xn=Oe-tt;return Y===e||Hr>=u||Hr<0||ot&&xn>=I}function Ut(){var Oe=ra();if(Ft(Oe))return Yt(Oe);q=gs(Ut,Rt(Oe))}function Yt(Oe){return q=e,dt&&D?yt(Oe):(D=C=e,P)}function Cr(){q!==e&&F0(q),tt=0,D=Y=C=q=e}function ar(){return q===e?P:Yt(ra())}function Fr(){var Oe=ra(),Hr=Ft(Oe);if(D=arguments,C=this,Y=Oe,Hr){if(q===e)return Ct(Y);if(ot)return F0(q),q=gs(Ut,u),yt(Y)}return q===e&&(q=gs(Ut,u)),P}return Fr.cancel=Cr,Fr.flush=ar,Fr}var lA=Pt(function(o,u){return o0(o,1,u)}),cA=Pt(function(o,u,_){return o0(o,zr(u)||0,_)});function fA(o){return vn(o,T)}function na(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new Tr(a);var _=function(){var D=arguments,C=u?u.apply(this,D):D[0],I=_.cache;if(I.has(C))return I.get(C);var P=o.apply(this,D);return _.cache=I.set(C,P)||I,P};return _.cache=new(na.Cache||mn),_}na.Cache=mn;function ia(o){if(typeof o!="function")throw new Tr(a);return function(){var u=arguments;switch(u.length){case 0:return!o.call(this);case 1:return!o.call(this,u[0]);case 2:return!o.call(this,u[0],u[1]);case 3:return!o.call(this,u[0],u[1],u[2])}return!o.apply(this,u)}}function hA(o){return pp(2,o)}var pA=Qb(function(o,u){u=u.length==1&&Tt(u[0])?xe(u[0],xr(At())):xe(He(u,1),xr(At()));var _=u.length;return Pt(function(D){for(var C=-1,I=tr(D.length,_);++C<I;)D[C]=u[C].call(this,D[C]);return br(o,this,D)})}),hl=Pt(function(o,u){var _=Pn(u,Wi(hl));return vn(o,E,e,u,_)}),vp=Pt(function(o,u){var _=Pn(u,Wi(vp));return vn(o,A,e,u,_)}),dA=yn(function(o,u){return vn(o,S,e,e,e,u)});function _A(o,u){if(typeof o!="function")throw new Tr(a);return u=u===e?u:Lt(u),Pt(o,u)}function mA(o,u){if(typeof o!="function")throw new Tr(a);return u=u==null?0:Ue(Lt(u),0),Pt(function(_){var D=_[u],C=Wn(_,0,u);return D&&Rn(C,D),br(o,this,C)})}function gA(o,u,_){var D=!0,C=!0;if(typeof o!="function")throw new Tr(a);return Ce(_)&&(D="leading"in _?!!_.leading:D,C="trailing"in _?!!_.trailing:C),gp(o,u,{leading:D,maxWait:u,trailing:C})}function vA(o){return hp(o,1)}function yA(o,u){return hl(Hu(u),o)}function wA(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function DA(o){return Lr(o,g)}function bA(o,u){return u=typeof u=="function"?u:e,Lr(o,g,u)}function xA(o){return Lr(o,f|g)}function EA(o,u){return u=typeof u=="function"?u:e,Lr(o,f|g,u)}function AA(o,u){return u==null||s0(o,u,je(u))}function Gr(o,u){return o===u||o!==o&&u!==u}var CA=Ho(Pu),FA=Ho(function(o,u){return o>=u}),ci=f0(function(){return arguments}())?f0:function(o){return Me(o)&&ae.call(o,"callee")&&!Jh.call(o,"callee")},Tt=H.isArray,MA=Oh?xr(Oh):Lb;function hr(o){return o!=null&&sa(o.length)&&!Dn(o)}function Be(o){return Me(o)&&hr(o)}function NA(o){return o===!0||o===!1||Me(o)&&sr(o)==oe}var jn=WD||xl,SA=Ih?xr(Ih):Rb;function BA(o){return Me(o)&&o.nodeType===1&&!vs(o)}function OA(o){if(o==null)return!0;if(hr(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||jn(o)||ji(o)||ci(o)))return!o.length;var u=er(o);if(u==Jt||u==yr)return!o.size;if(ms(o))return!ku(o).length;for(var _ in o)if(ae.call(o,_))return!1;return!0}function IA(o,u){return ps(o,u)}function TA(o,u,_){_=typeof _=="function"?_:e;var D=_?_(o,u):e;return D===e?ps(o,u,e,_):!!D}function pl(o){if(!Me(o))return!1;var u=sr(o);return u==ce||u==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!vs(o)}function $A(o){return typeof o=="number"&&Qh(o)}function Dn(o){if(!Ce(o))return!1;var u=sr(o);return u==re||u==kt||u==xt||u==On}function yp(o){return typeof o=="number"&&o==Lt(o)}function sa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Ce(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Me(o){return o!=null&&typeof o=="object"}var wp=Th?xr(Th):zb;function LA(o,u){return o===u||qu(o,u,nl(u))}function RA(o,u,_){return _=typeof _=="function"?_:e,qu(o,u,nl(u),_)}function PA(o){return Dp(o)&&o!=+o}function zA(o){if(bx(o))throw new Ot(i);return h0(o)}function qA(o){return o===null}function kA(o){return o==null}function Dp(o){return typeof o=="number"||Me(o)&&sr(o)==Le}function vs(o){if(!Me(o)||sr(o)!=ze)return!1;var u=Oo(o);if(u===null)return!0;var _=ae.call(u,"constructor")&&u.constructor;return typeof _=="function"&&_ instanceof _&&Mo.call(_)==RD}var dl=$h?xr($h):qb;function UA(o){return yp(o)&&o>=-Z&&o<=Z}var bp=Lh?xr(Lh):kb;function oa(o){return typeof o=="string"||!Tt(o)&&Me(o)&&sr(o)==In}function Ar(o){return typeof o=="symbol"||Me(o)&&sr(o)==L}var ji=Rh?xr(Rh):Ub;function WA(o){return o===e}function jA(o){return Me(o)&&er(o)==G}function YA(o){return Me(o)&&sr(o)==nt}var VA=Ho(Uu),ZA=Ho(function(o,u){return o<=u});function xp(o){if(!o)return[];if(hr(o))return oa(o)?Zr(o):fr(o);if(ss&&o[ss])return AD(o[ss]());var u=er(o),_=u==Jt?Nu:u==yr?Ao:Yi;return _(o)}function bn(o){if(!o)return o===0?o:0;if(o=zr(o),o===K||o===-K){var u=o<0?-1:1;return u*X}return o===o?o:0}function Lt(o){var u=bn(o),_=u%1;return u===u?_?u-_:u:0}function Ep(o){return o?oi(Lt(o),0,ct):0}function zr(o){if(typeof o=="number")return o;if(Ar(o))return Q;if(Ce(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Ce(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=Wh(o);var _=uu.test(o);return _||cu.test(o)?uD(o.slice(2),_?2:8):au.test(o)?Q:+o}function Ap(o){return sn(o,pr(o))}function KA(o){return o?oi(Lt(o),-Z,Z):o===0?o:0}function ie(o){return o==null?"":Er(o)}var GA=ki(function(o,u){if(ms(u)||hr(u)){sn(u,je(u),o);return}for(var _ in u)ae.call(u,_)&&cs(o,_,u[_])}),Cp=ki(function(o,u){sn(u,pr(u),o)}),aa=ki(function(o,u,_,D){sn(u,pr(u),o,D)}),HA=ki(function(o,u,_,D){sn(u,je(u),o,D)}),JA=yn($u);function XA(o,u){var _=qi(o);return u==null?_:i0(_,u)}var QA=Pt(function(o,u){o=pe(o);var _=-1,D=u.length,C=D>2?u[2]:e;for(C&&or(u[0],u[1],C)&&(D=1);++_<D;)for(var I=u[_],P=pr(I),q=-1,Y=P.length;++q<Y;){var tt=P[q],et=o[tt];(et===e||Gr(et,Ri[tt])&&!ae.call(o,tt))&&(o[tt]=I[tt])}return o}),tC=Pt(function(o){return o.push(e,W0),br(Fp,e,o)});function eC(o,u){return zh(o,At(u,3),nn)}function rC(o,u){return zh(o,At(u,3),Ru)}function nC(o,u){return o==null?o:Lu(o,At(u,3),pr)}function iC(o,u){return o==null?o:l0(o,At(u,3),pr)}function sC(o,u){return o&&nn(o,At(u,3))}function oC(o,u){return o&&Ru(o,At(u,3))}function aC(o){return o==null?[]:Uo(o,je(o))}function uC(o){return o==null?[]:Uo(o,pr(o))}function _l(o,u,_){var D=o==null?e:ai(o,u);return D===e?_:D}function lC(o,u){return o!=null&&V0(o,u,Ob)}function ml(o,u){return o!=null&&V0(o,u,Ib)}var cC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),o[u]=_},vl(dr)),fC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),ae.call(o,u)?o[u].push(_):o[u]=[_]},At),hC=Pt(hs);function je(o){return hr(o)?r0(o):ku(o)}function pr(o){return hr(o)?r0(o,!0):Wb(o)}function pC(o,u){var _={};return u=At(u,3),nn(o,function(D,C,I){gn(_,u(D,C,I),D)}),_}function dC(o,u){var _={};return u=At(u,3),nn(o,function(D,C,I){gn(_,C,u(D,C,I))}),_}var _C=ki(function(o,u,_){Wo(o,u,_)}),Fp=ki(function(o,u,_,D){Wo(o,u,_,D)}),mC=yn(function(o,u){var _={};if(o==null)return _;var D=!1;u=xe(u,function(I){return I=Un(I,o),D||(D=I.length>1),I}),sn(o,el(o),_),D&&(_=Lr(_,f|d|g,cx));for(var C=u.length;C--;)Zu(_,u[C]);return _});function gC(o,u){return Mp(o,ia(At(u)))}var vC=yn(function(o,u){return o==null?{}:Yb(o,u)});function Mp(o,u){if(o==null)return{};var _=xe(el(o),function(D){return[D]});return u=At(u),y0(o,_,function(D,C){return u(D,C[0])})}function yC(o,u,_){u=Un(u,o);var D=-1,C=u.length;for(C||(C=1,o=e);++D<C;){var I=o==null?e:o[on(u[D])];I===e&&(D=C,I=_),o=Dn(I)?I.call(o):I}return o}function wC(o,u,_){return o==null?o:ds(o,u,_)}function DC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:ds(o,u,_,D)}var Np=k0(je),Sp=k0(pr);function bC(o,u,_){var D=Tt(o),C=D||jn(o)||ji(o);if(u=At(u,4),_==null){var I=o&&o.constructor;C?_=D?new I:[]:Ce(o)?_=Dn(I)?qi(Oo(o)):{}:_={}}return(C?Ir:nn)(o,function(P,q,Y){return u(_,P,q,Y)}),_}function xC(o,u){return o==null?!0:Zu(o,u)}function EC(o,u,_){return o==null?o:E0(o,u,Hu(_))}function AC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:E0(o,u,Hu(_),D)}function Yi(o){return o==null?[]:Mu(o,je(o))}function CC(o){return o==null?[]:Mu(o,pr(o))}function FC(o,u,_){return _===e&&(_=u,u=e),_!==e&&(_=zr(_),_=_===_?_:0),u!==e&&(u=zr(u),u=u===u?u:0),oi(zr(o),u,_)}function MC(o,u,_){return u=bn(u),_===e?(_=u,u=0):_=bn(_),o=zr(o),Tb(o,u,_)}function NC(o,u,_){if(_&&typeof _!="boolean"&&or(o,u,_)&&(u=_=e),_===e&&(typeof u=="boolean"?(_=u,u=e):typeof o=="boolean"&&(_=o,o=e)),o===e&&u===e?(o=0,u=1):(o=bn(o),u===e?(u=o,o=0):u=bn(u)),o>u){var D=o;o=u,u=D}if(_||o%1||u%1){var C=t0();return tr(o+C*(u-o+aD("1e-"+((C+"").length-1))),u)}return ju(o,u)}var SC=Ui(function(o,u,_){return u=u.toLowerCase(),o+(_?Bp(u):u)});function Bp(o){return gl(ie(o).toLowerCase())}function Op(o){return o=ie(o),o&&o.replace(hu,wD).replace(Jw,"")}function BC(o,u,_){o=ie(o),u=Er(u);var D=o.length;_=_===e?D:oi(Lt(_),0,D);var C=_;return _-=u.length,_>=0&&o.slice(_,C)==u}function OC(o){return o=ie(o),o&&Va.test(o)?o.replace(vo,DD):o}function IC(o){return o=ie(o),o&&Xa.test(o)?o.replace(rs,"\\$&"):o}var TC=Ui(function(o,u,_){return o+(_?"-":"")+u.toLowerCase()}),$C=Ui(function(o,u,_){return o+(_?" ":"")+u.toLowerCase()}),LC=$0("toLowerCase");function RC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;if(!u||D>=u)return o;var C=(u-D)/2;return Go(Lo(C),_)+o+Go($o(C),_)}function PC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?o+Go(u-D,_):o}function zC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?Go(u-D,_)+o:o}function qC(o,u,_){return _||u==null?u=0:u&&(u=+u),ZD(ie(o).replace(ns,""),u||0)}function kC(o,u,_){return(_?or(o,u,_):u===e)?u=1:u=Lt(u),Yu(ie(o),u)}function UC(){var o=arguments,u=ie(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var WC=Ui(function(o,u,_){return o+(_?"_":"")+u.toLowerCase()});function jC(o,u,_){return _&&typeof _!="number"&&or(o,u,_)&&(u=_=e),_=_===e?ct:_>>>0,_?(o=ie(o),o&&(typeof u=="string"||u!=null&&!dl(u))&&(u=Er(u),!u&&Ti(o))?Wn(Zr(o),0,_):o.split(u,_)):[]}var YC=Ui(function(o,u,_){return o+(_?" ":"")+gl(u)});function VC(o,u,_){return o=ie(o),_=_==null?0:oi(Lt(_),0,o.length),u=Er(u),o.slice(_,_+u.length)==u}function ZC(o,u,_){var D=B.templateSettings;_&&or(o,u,_)&&(u=e),o=ie(o),u=aa({},u,D,U0);var C=aa({},u.imports,D.imports,U0),I=je(C),P=Mu(C,I),q,Y,tt=0,et=u.interpolate||Si,ot="__p += '",dt=Su((u.escape||Si).source+"|"+et.source+"|"+(et===yo?ou:Si).source+"|"+(u.evaluate||Si).source+"|$","g"),yt="//# sourceURL="+(ae.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rD+"]")+`
|
11
11
|
`;o.replace(dt,function(Ft,Ut,Yt,Cr,ar,Fr){return Yt||(Yt=Cr),ot+=o.slice(tt,Fr).replace(ei,bD),Ut&&(q=!0,ot+=`' +
|
12
12
|
__e(`+Ut+`) +
|
13
13
|
'`),ar&&(Y=!0,ot+=`';
|
@@ -24,46 +24,46 @@ __p += '`),Yt&&(ot+=`' +
|
|
24
24
|
function print() { __p += __j.call(arguments, '') }
|
25
25
|
`:`;
|
26
26
|
`)+ot+`return __p
|
27
|
-
}`;var Rt=Tp(function(){return te(I,yt+"return "+ot).apply(e,P)});if(Rt.source=ot,pl(Rt))throw Rt;return Rt}function KC(o){return ie(o).toLowerCase()}function GC(o){return ie(o).toUpperCase()}function HC(o,u,_){if(o=ie(o),o&&(_||u===e))return Wh(o);if(!o||!(u=Er(u)))return o;var D=Zr(o),A=Zr(u),I=jh(D,A),P=Yh(D,A)+1;return Wn(D,I,P).join("")}function JC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.slice(0,Zh(o)+1);if(!o||!(u=Er(u)))return o;var D=Zr(o),A=Yh(D,Zr(u))+1;return Wn(D,0,A).join("")}function XC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.replace(ns,"");if(!o||!(u=Er(u)))return o;var D=Zr(o),A=jh(D,Zr(u));return Wn(D,A).join("")}function QC(o,u){var _=F,D=O;if(Ce(u)){var A="separator"in u?u.separator:A;_="length"in u?Lt(u.length):_,D="omission"in u?Er(u.omission):D}o=ie(o);var I=o.length;if(Ti(o)){var P=Zr(o);I=P.length}if(_>=I)return o;var q=_-$i(D);if(q<1)return D;var Y=P?Wn(P,0,q).join(""):o.slice(0,q);if(A===e)return Y+D;if(P&&(q+=Y.length-q),dl(A)){if(o.slice(q).search(A)){var tt,et=Y;for(A.global||(A=Su(A.source,ie(wo.exec(A))+"g")),A.lastIndex=0;tt=A.exec(et);)var ot=tt.index;Y=Y.slice(0,ot===e?q:ot)}}else if(o.indexOf(Er(A),q)!=q){var dt=Y.lastIndexOf(A);dt>-1&&(Y=Y.slice(0,dt))}return Y+D}function t2(o){return o=ie(o),o&&Ya.test(o)?o.replace(ti,ND):o}var e2=Ui(function(o,u,_){return o+(_?" ":"")+u.toUpperCase()}),gl=$0("toUpperCase");function Ip(o,u,_){return o=ie(o),u=_?e:u,u===e?ED(o)?OD(o):_D(o):o.match(u)||[]}var Tp=Pt(function(o,u){try{return br(o,e,u)}catch(_){return pl(_)?_:new Ot(_)}}),r2=yn(function(o,u){return Ir(u,function(_){_=on(_),gn(o,_,fl(o[_],o))}),o});function n2(o){var u=o==null?0:o.length,_=At();return o=u?xe(o,function(D){if(typeof D[1]!="function")throw new Tr(a);return[_(D[0]),D[1]]}):[],Pt(function(D){for(var A=-1;++A<u;){var I=o[A];if(br(I[0],this,D))return br(I[1],this,D)}})}function i2(o){return Nb(Lr(o,f))}function vl(o){return function(){return o}}function s2(o,u){return o==null||o!==o?u:o}var o2=R0(),a2=R0(!0);function dr(o){return o}function yl(o){return p0(typeof o=="function"?o:Lr(o,f))}function u2(o){return _0(Lr(o,f))}function l2(o,u){return m0(o,Lr(u,f))}var c2=Pt(function(o,u){return function(_){return hs(_,o,u)}}),f2=Pt(function(o,u){return function(_){return hs(o,_,u)}});function wl(o,u,_){var D=je(u),A=Uo(u,D);_==null&&!(Ce(u)&&(A.length||!D.length))&&(_=u,u=o,o=this,A=Uo(u,je(u)));var I=!(Ce(_)&&"chain"in _)||!!_.chain,P=Dn(o);return Ir(A,function(q){var Y=u[q];o[q]=Y,P&&(o.prototype[q]=function(){var tt=this.__chain__;if(I||tt){var et=o(this.__wrapped__),ot=et.__actions__=fr(this.__actions__);return ot.push({func:Y,args:arguments,thisArg:o}),et.__chain__=tt,et}return Y.apply(o,Rn([this.value()],arguments))})}),o}function h2(){return Ge._===this&&(Ge._=PD),this}function Dl(){}function p2(o){return o=Lt(o),Pt(function(u){return g0(u,o)})}var d2=Xu(xe),_2=Xu(Ph),m2=Xu(xu);function $p(o){return sl(o)?Eu(on(o)):Vb(o)}function g2(o){return function(u){return o==null?e:ai(o,u)}}var v2=z0(),y2=z0(!0);function bl(){return[]}function xl(){return!1}function w2(){return{}}function D2(){return""}function b2(){return!0}function x2(o,u){if(o=Lt(o),o<1||o>Z)return[];var _=ct,D=tr(o,ct);u=At(u),o-=ct;for(var A=Fu(D,u);++_<o;)u(_);return A}function E2(o){return Tt(o)?xe(o,on):Ar(o)?[o]:fr(ep(ie(o)))}function A2(o){var u=++LD;return ie(o)+u}var C2=Ko(function(o,u){return o+u},0),F2=Qu("ceil"),M2=Ko(function(o,u){return o/u},1),N2=Qu("floor");function S2(o){return o&&o.length?ko(o,dr,Pu):e}function B2(o,u){return o&&o.length?ko(o,At(u,2),Pu):e}function O2(o){return kh(o,dr)}function I2(o,u){return kh(o,At(u,2))}function T2(o){return o&&o.length?ko(o,dr,Uu):e}function $2(o,u){return o&&o.length?ko(o,At(u,2),Uu):e}var L2=Ko(function(o,u){return o*u},1),R2=Qu("round"),P2=Ko(function(o,u){return o-u},0);function z2(o){return o&&o.length?Cu(o,dr):0}function q2(o,u){return o&&o.length?Cu(o,At(u,2)):0}return B.after=uA,B.ary=hp,B.assign=GA,B.assignIn=Cp,B.assignInWith=aa,B.assignWith=HA,B.at=JA,B.before=pp,B.bind=fl,B.bindAll=r2,B.bindKey=dp,B.castArray=wA,B.chain=lp,B.chunk=Nx,B.compact=Sx,B.concat=Bx,B.cond=n2,B.conforms=i2,B.constant=vl,B.countBy=zE,B.create=XA,B.curry=_p,B.curryRight=mp,B.debounce=gp,B.defaults=QA,B.defaultsDeep=tC,B.defer=lA,B.delay=cA,B.difference=Ox,B.differenceBy=Ix,B.differenceWith=Tx,B.drop=$x,B.dropRight=Lx,B.dropRightWhile=Rx,B.dropWhile=Px,B.fill=zx,B.filter=kE,B.flatMap=jE,B.flatMapDeep=YE,B.flatMapDepth=VE,B.flatten=sp,B.flattenDeep=qx,B.flattenDepth=kx,B.flip=fA,B.flow=o2,B.flowRight=a2,B.fromPairs=Ux,B.functions=aC,B.functionsIn=uC,B.groupBy=ZE,B.initial=jx,B.intersection=Yx,B.intersectionBy=Vx,B.intersectionWith=Zx,B.invert=cC,B.invertBy=fC,B.invokeMap=GE,B.iteratee=yl,B.keyBy=HE,B.keys=je,B.keysIn=pr,B.map=ea,B.mapKeys=pC,B.mapValues=dC,B.matches=u2,B.matchesProperty=l2,B.memoize=na,B.merge=_C,B.mergeWith=Fp,B.method=c2,B.methodOf=f2,B.mixin=wl,B.negate=ia,B.nthArg=p2,B.omit=mC,B.omitBy=gC,B.once=hA,B.orderBy=JE,B.over=d2,B.overArgs=pA,B.overEvery=_2,B.overSome=m2,B.partial=hl,B.partialRight=vp,B.partition=XE,B.pick=vC,B.pickBy=Mp,B.property=$p,B.propertyOf=g2,B.pull=Jx,B.pullAll=ap,B.pullAllBy=Xx,B.pullAllWith=Qx,B.pullAt=tE,B.range=v2,B.rangeRight=y2,B.rearg=dA,B.reject=eA,B.remove=eE,B.rest=_A,B.reverse=ll,B.sampleSize=nA,B.set=wC,B.setWith=DC,B.shuffle=iA,B.slice=rE,B.sortBy=aA,B.sortedUniq=lE,B.sortedUniqBy=cE,B.split=jC,B.spread=mA,B.tail=fE,B.take=hE,B.takeRight=pE,B.takeRightWhile=dE,B.takeWhile=_E,B.tap=SE,B.throttle=gA,B.thru=ta,B.toArray=xp,B.toPairs=Np,B.toPairsIn=Sp,B.toPath=E2,B.toPlainObject=Ap,B.transform=bC,B.unary=vA,B.union=mE,B.unionBy=gE,B.unionWith=vE,B.uniq=yE,B.uniqBy=wE,B.uniqWith=DE,B.unset=xC,B.unzip=cl,B.unzipWith=up,B.update=EC,B.updateWith=AC,B.values=Yi,B.valuesIn=CC,B.without=bE,B.words=Ip,B.wrap=yA,B.xor=xE,B.xorBy=EE,B.xorWith=AE,B.zip=CE,B.zipObject=FE,B.zipObjectDeep=ME,B.zipWith=NE,B.entries=Np,B.entriesIn=Sp,B.extend=Cp,B.extendWith=aa,wl(B,B),B.add=C2,B.attempt=Tp,B.camelCase=SC,B.capitalize=Bp,B.ceil=F2,B.clamp=FC,B.clone=DA,B.cloneDeep=xA,B.cloneDeepWith=EA,B.cloneWith=bA,B.conformsTo=AA,B.deburr=Op,B.defaultTo=s2,B.divide=M2,B.endsWith=BC,B.eq=Gr,B.escape=OC,B.escapeRegExp=IC,B.every=qE,B.find=UE,B.findIndex=np,B.findKey=eC,B.findLast=WE,B.findLastIndex=ip,B.findLastKey=rC,B.floor=N2,B.forEach=cp,B.forEachRight=fp,B.forIn=nC,B.forInRight=iC,B.forOwn=sC,B.forOwnRight=oC,B.get=_l,B.gt=CA,B.gte=FA,B.has=lC,B.hasIn=ml,B.head=op,B.identity=dr,B.includes=KE,B.indexOf=Wx,B.inRange=MC,B.invoke=hC,B.isArguments=ci,B.isArray=Tt,B.isArrayBuffer=MA,B.isArrayLike=hr,B.isArrayLikeObject=Be,B.isBoolean=NA,B.isBuffer=jn,B.isDate=SA,B.isElement=BA,B.isEmpty=OA,B.isEqual=IA,B.isEqualWith=TA,B.isError=pl,B.isFinite=$A,B.isFunction=Dn,B.isInteger=yp,B.isLength=sa,B.isMap=wp,B.isMatch=LA,B.isMatchWith=RA,B.isNaN=PA,B.isNative=zA,B.isNil=kA,B.isNull=qA,B.isNumber=Dp,B.isObject=Ce,B.isObjectLike=Me,B.isPlainObject=vs,B.isRegExp=dl,B.isSafeInteger=UA,B.isSet=bp,B.isString=oa,B.isSymbol=Ar,B.isTypedArray=ji,B.isUndefined=WA,B.isWeakMap=jA,B.isWeakSet=YA,B.join=Kx,B.kebabCase=TC,B.last=Pr,B.lastIndexOf=Gx,B.lowerCase=$C,B.lowerFirst=LC,B.lt=VA,B.lte=ZA,B.max=S2,B.maxBy=B2,B.mean=O2,B.meanBy=I2,B.min=T2,B.minBy=$2,B.stubArray=bl,B.stubFalse=xl,B.stubObject=w2,B.stubString=D2,B.stubTrue=b2,B.multiply=L2,B.nth=Hx,B.noConflict=h2,B.noop=Dl,B.now=ra,B.pad=RC,B.padEnd=PC,B.padStart=zC,B.parseInt=qC,B.random=NC,B.reduce=QE,B.reduceRight=tA,B.repeat=kC,B.replace=UC,B.result=yC,B.round=R2,B.runInContext=j,B.sample=rA,B.size=sA,B.snakeCase=WC,B.some=oA,B.sortedIndex=nE,B.sortedIndexBy=iE,B.sortedIndexOf=sE,B.sortedLastIndex=oE,B.sortedLastIndexBy=aE,B.sortedLastIndexOf=uE,B.startCase=YC,B.startsWith=VC,B.subtract=P2,B.sum=z2,B.sumBy=q2,B.template=ZC,B.times=x2,B.toFinite=bn,B.toInteger=Lt,B.toLength=Ep,B.toLower=KC,B.toNumber=zr,B.toSafeInteger=KA,B.toString=ie,B.toUpper=GC,B.trim=HC,B.trimEnd=JC,B.trimStart=XC,B.truncate=QC,B.unescape=t2,B.uniqueId=A2,B.upperCase=e2,B.upperFirst=gl,B.each=cp,B.eachRight=fp,B.first=op,wl(B,function(){var o={};return nn(B,function(u,_){ae.call(B.prototype,_)||(o[_]=u)}),o}(),{chain:!1}),B.VERSION=r,Ir(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Ir(["drop","take"],function(o,u){jt.prototype[o]=function(_){_=_===e?1:Ue(Lt(_),0);var D=this.__filtered__&&!u?new jt(this):this.clone();return D.__filtered__?D.__takeCount__=tr(_,D.__takeCount__):D.__views__.push({size:tr(_,ct),type:o+(D.__dir__<0?"Right":"")}),D},jt.prototype[o+"Right"]=function(_){return this.reverse()[o](_).reverse()}}),Ir(["filter","map","takeWhile"],function(o,u){var _=u+1,D=_==k||_==z;jt.prototype[o]=function(A){var I=this.clone();return I.__iteratees__.push({iteratee:At(A,3),type:_}),I.__filtered__=I.__filtered__||D,I}}),Ir(["head","last"],function(o,u){var _="take"+(u?"Right":"");jt.prototype[o]=function(){return this[_](1).value()[0]}}),Ir(["initial","tail"],function(o,u){var _="drop"+(u?"":"Right");jt.prototype[o]=function(){return this.__filtered__?new jt(this):this[_](1)}}),jt.prototype.compact=function(){return this.filter(dr)},jt.prototype.find=function(o){return this.filter(o).head()},jt.prototype.findLast=function(o){return this.reverse().find(o)},jt.prototype.invokeMap=Pt(function(o,u){return typeof o=="function"?new jt(this):this.map(function(_){return hs(_,o,u)})}),jt.prototype.reject=function(o){return this.filter(ia(At(o)))},jt.prototype.slice=function(o,u){o=Lt(o);var _=this;return _.__filtered__&&(o>0||u<0)?new jt(_):(o<0?_=_.takeRight(-o):o&&(_=_.drop(o)),u!==e&&(u=Lt(u),_=u<0?_.dropRight(-u):_.take(u-o)),_)},jt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},jt.prototype.toArray=function(){return this.take(ct)},nn(jt.prototype,function(o,u){var _=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),A=B[D?"take"+(u=="last"?"Right":""):u],I=D||/^find/.test(u);A&&(B.prototype[u]=function(){var P=this.__wrapped__,q=D?[1]:arguments,Y=P instanceof jt,tt=q[0],et=Y||Tt(P),ot=function(Ut){var Yt=A.apply(B,Rn([Ut],q));return D&&dt?Yt[0]:Yt};et&&_&&typeof tt=="function"&&tt.length!=1&&(Y=et=!1);var dt=this.__chain__,yt=!!this.__actions__.length,Ct=I&&!dt,Rt=Y&&!yt;if(!I&&et){P=Rt?P:new jt(this);var Ft=o.apply(P,q);return Ft.__actions__.push({func:ta,args:[ot],thisArg:e}),new $r(Ft,dt)}return Ct&&Rt?o.apply(this,q):(Ft=this.thru(ot),Ct?D?Ft.value()[0]:Ft.value():Ft)})}),Ir(["pop","push","shift","sort","splice","unshift"],function(o){var u=Co[o],_=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var A=arguments;if(D&&!this.__chain__){var I=this.value();return u.apply(Tt(I)?I:[],A)}return this[_](function(P){return u.apply(Tt(P)?P:[],A)})}}),nn(jt.prototype,function(o,u){var _=B[u];if(_){var D=_.name+"";ae.call(zi,D)||(zi[D]=[]),zi[D].push({name:u,func:_})}}),zi[Zo(e,v).name]=[{name:"wrapper",func:e}],jt.prototype.clone=tb,jt.prototype.reverse=eb,jt.prototype.value=rb,B.prototype.at=BE,B.prototype.chain=OE,B.prototype.commit=IE,B.prototype.next=TE,B.prototype.plant=LE,B.prototype.reverse=RE,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=PE,B.prototype.first=B.prototype.head,ss&&(B.prototype[ss]=$E),B},Li=ID();ri?((ri.exports=Li)._=Li,yu._=Li):Ge._=Li}).call(Vt)}(Yn,Yn.exports);var Xr=Yn.exports;class Rp{constructor(t,e){$(this,"_defaultParams");$(this,"_UserTypeFileds");$(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Xr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Xr.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 Xr.cloneDeep(this)}}}}var Ml={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e=1e3,r=6e4,n=36e5,i="millisecond",a="second",l="minute",c="hour",h="day",p="week",f="month",d="quarter",g="year",y="date",m="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(k){var W=["th","st","nd","rd"],z=k%100;return"["+k+(W[(z-20)%10]||W[z]||W[0])+"]"}},b=function(k,W,z){var K=String(k);return!K||K.length>=W?k:""+Array(W+1-K.length).join(z)+k},N={s:b,z:function(k){var W=-k.utcOffset(),z=Math.abs(W),K=Math.floor(z/60),Z=z%60;return(W<=0?"+":"-")+b(K,2,"0")+":"+b(Z,2,"0")},m:function k(W,z){if(W.date()<z.date())return-k(z,W);var K=12*(z.year()-W.year())+(z.month()-W.month()),Z=W.clone().add(K,f),X=z-Z<0,Q=W.clone().add(K+(X?-1:1),f);return+(-(K+(z-Z)/(X?Z-Q:Q-Z))||0)},a:function(k){return k<0?Math.ceil(k)||0:Math.floor(k)},p:function(k){return{M:f,y:g,w:p,d:h,D:y,h:c,m:l,s:a,ms:i,Q:d}[k]||String(k||"").toLowerCase().replace(/s$/,"")},u:function(k){return k===void 0}},E="en",C={};C[E]=x;var M="$isDayjsObject",S=function(k){return k instanceof R||!(!k||!k[M])},T=function k(W,z,K){var Z;if(!W)return E;if(typeof W=="string"){var X=W.toLowerCase();C[X]&&(Z=X),z&&(C[X]=z,Z=X);var Q=W.split("-");if(!Z&&Q.length>1)return k(Q[0])}else{var ct=W.name;C[ct]=W,Z=ct}return!K&&Z&&(E=Z),Z||!K&&E},F=function(k,W){if(S(k))return k.clone();var z=typeof W=="object"?W:{};return z.date=k,z.args=arguments,new R(z)},O=N;O.l=T,O.i=S,O.w=function(k,W){return F(k,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var R=function(){function k(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[M]=!0}var W=k.prototype;return W.parse=function(z){this.$d=function(K){var Z=K.date,X=K.utc;if(Z===null)return new Date(NaN);if(O.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var Q=Z.match(w);if(Q){var ct=Q[2]-1||0,vt=(Q[7]||"0").substring(0,3);return X?new Date(Date.UTC(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)):new Date(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)}}return new Date(Z)}(z),this.init()},W.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},W.$utils=function(){return O},W.isValid=function(){return this.$d.toString()!==m},W.isSame=function(z,K){var Z=F(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},W.isAfter=function(z,K){return F(z)<this.startOf(K)},W.isBefore=function(z,K){return this.endOf(K)<F(z)},W.$g=function(z,K,Z){return O.u(z)?this[K]:this.set(Z,z)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(z,K){var Z=this,X=!!O.u(K)||K,Q=O.p(z),ct=function(It,Nt){var ce=O.w(Z.$u?Date.UTC(Z.$y,Nt,It):new Date(Z.$y,Nt,It),Z);return X?ce:ce.endOf(h)},vt=function(It,Nt){return O.w(Z.toDate()[It].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Z)},lt=this.$W,wt=this.$M,bt=this.$D,Bt="set"+(this.$u?"UTC":"");switch(Q){case g:return X?ct(1,0):ct(31,11);case f:return X?ct(1,wt):ct(0,wt+1);case p:var xt=this.$locale().weekStart||0,oe=(lt<xt?lt+7:lt)-xt;return ct(X?bt-oe:bt+(6-oe),wt);case h:case y:return vt(Bt+"Hours",0);case c:return vt(Bt+"Minutes",1);case l:return vt(Bt+"Seconds",2);case a:return vt(Bt+"Milliseconds",3);default:return this.clone()}},W.endOf=function(z){return this.startOf(z,!1)},W.$set=function(z,K){var Z,X=O.p(z),Q="set"+(this.$u?"UTC":""),ct=(Z={},Z[h]=Q+"Date",Z[y]=Q+"Date",Z[f]=Q+"Month",Z[g]=Q+"FullYear",Z[c]=Q+"Hours",Z[l]=Q+"Minutes",Z[a]=Q+"Seconds",Z[i]=Q+"Milliseconds",Z)[X],vt=X===h?this.$D+(K-this.$W):K;if(X===f||X===g){var lt=this.clone().set(y,1);lt.$d[ct](vt),lt.init(),this.$d=lt.set(y,Math.min(this.$D,lt.daysInMonth())).$d}else ct&&this.$d[ct](vt);return this.init(),this},W.set=function(z,K){return this.clone().$set(z,K)},W.get=function(z){return this[O.p(z)]()},W.add=function(z,K){var Z,X=this;z=Number(z);var Q=O.p(K),ct=function(wt){var bt=F(X);return O.w(bt.date(bt.date()+Math.round(wt*z)),X)};if(Q===f)return this.set(f,this.$M+z);if(Q===g)return this.set(g,this.$y+z);if(Q===h)return ct(1);if(Q===p)return ct(7);var vt=(Z={},Z[l]=r,Z[c]=n,Z[a]=e,Z)[Q]||1,lt=this.$d.getTime()+z*vt;return O.w(lt,this)},W.subtract=function(z,K){return this.add(-1*z,K)},W.format=function(z){var K=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||m;var X=z||"YYYY-MM-DDTHH:mm:ssZ",Q=O.z(this),ct=this.$H,vt=this.$m,lt=this.$M,wt=Z.weekdays,bt=Z.months,Bt=Z.meridiem,xt=function(Nt,ce,re,kt){return Nt&&(Nt[ce]||Nt(K,X))||re[ce].slice(0,kt)},oe=function(Nt){return O.s(ct%12||12,Nt,"0")},It=Bt||function(Nt,ce,re){var kt=Nt<12?"AM":"PM";return re?kt.toLowerCase():kt};return X.replace(v,function(Nt,ce){return ce||function(re){switch(re){case"YY":return String(K.$y).slice(-2);case"YYYY":return O.s(K.$y,4,"0");case"M":return lt+1;case"MM":return O.s(lt+1,2,"0");case"MMM":return xt(Z.monthsShort,lt,bt,3);case"MMMM":return xt(bt,lt);case"D":return K.$D;case"DD":return O.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return xt(Z.weekdaysMin,K.$W,wt,2);case"ddd":return xt(Z.weekdaysShort,K.$W,wt,3);case"dddd":return wt[K.$W];case"H":return String(ct);case"HH":return O.s(ct,2,"0");case"h":return oe(1);case"hh":return oe(2);case"a":return It(ct,vt,!0);case"A":return It(ct,vt,!1);case"m":return String(vt);case"mm":return O.s(vt,2,"0");case"s":return String(K.$s);case"ss":return O.s(K.$s,2,"0");case"SSS":return O.s(K.$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(z,K,Z){var X,Q=this,ct=O.p(K),vt=F(z),lt=(vt.utcOffset()-this.utcOffset())*r,wt=this-vt,bt=function(){return O.m(Q,vt)};switch(ct){case g:X=bt()/12;break;case f:X=bt();break;case d:X=bt()/3;break;case p:X=(wt-lt)/6048e5;break;case h:X=(wt-lt)/864e5;break;case c:X=wt/n;break;case l:X=wt/r;break;case a:X=wt/e;break;default:X=wt}return Z?X:O.a(X)},W.daysInMonth=function(){return this.endOf(f).$D},W.$locale=function(){return C[this.$L]},W.locale=function(z,K){if(!z)return this.$L;var Z=this.clone(),X=T(z,K,!0);return X&&(Z.$L=X),Z},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()},k}(),U=R.prototype;return F.prototype=U,[["$ms",i],["$s",a],["$m",l],["$H",c],["$W",h],["$M",f],["$y",g],["$D",y]].forEach(function(k){U[k[1]]=function(W){return this.$g(W,k[0],k[1])}}),F.extend=function(k,W){return k.$i||(k(W,R,F),k.$i=!0),F},F.locale=T,F.isDayjs=S,F.unix=function(k){return F(1e3*k)},F.en=C[E],F.Ls=C,F.p={},F})})(Ml);var Pp=Ml.exports,ee=Gt(Pp),Nl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,a,l){var c=a.prototype;l.utc=function(m){var w={date:m,utc:!0,args:arguments};return new a(w)},c.utc=function(m){var w=l(this.toDate(),{locale:this.$L,utc:!0});return m?w.add(this.utcOffset(),e):w},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var h=c.parse;c.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),h.call(this,m)};var p=c.init;c.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else p.call(this)};var f=c.utcOffset;c.utcOffset=function(m,w){var v=this.$utils().u;if(v(m))return this.$u?0:v(this.$offset)?f.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var C=E.match(r);if(!C)return null;var M=(""+C[0]).match(n)||["-",0,0],S=M[0],T=60*+M[1]+ +M[2];return T===0?0:S==="+"?T:-T}(m),m===null))return this;var x=Math.abs(m)<=16?60*m:m,b=this;if(w)return b.$offset=x,b.$u=m===0,b;if(m!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+N,e)).$offset=x,b.$x.$localOffset=N}else b=this.utc();return b};var d=c.format;c.format=function(m){var w=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,w)},c.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},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(m){return m==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var y=c.diff;c.diff=function(m,w,v){if(m&&this.$u===m.$u)return y.call(this,m,w,v);var x=this.local(),b=l(m).local();return y.call(x,b,w,v)}}})})(Nl);var zp=Nl.exports,Sl=Gt(zp),Bl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,i,a){var l,c=function(d,g,y){y===void 0&&(y={});var m=new Date(d),w=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",N=v+"|"+b,E=r[N];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[N]=E),E}(g,y);return w.formatToParts(m)},h=function(d,g){for(var y=c(d,g),m=[],w=0;w<y.length;w+=1){var v=y[w],x=v.type,b=v.value,N=e[x];N>=0&&(m[N]=parseInt(b,10))}var E=m[3],C=E===24?0:E,M=m[0]+"-"+m[1]+"-"+m[2]+" "+C+":"+m[4]+":"+m[5]+":000",S=+d;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},p=i.prototype;p.tz=function(d,g){d===void 0&&(d=l);var y=this.utcOffset(),m=this.toDate(),w=m.toLocaleString("en-US",{timeZone:d}),v=Math.round((m-new Date(w))/1e3/60),x=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(y-b,"minute")}return x.$x.$timezone=d,x},p.offsetName=function(d){var g=this.$x.$timezone||a.tz.guess(),y=c(this.valueOf(),g,{timeZoneName:d}).find(function(m){return m.type.toLowerCase()==="timezonename"});return y&&y.value};var f=p.startOf;p.startOf=function(d,g){if(!this.$x||!this.$x.$timezone)return f.call(this,d,g);var y=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return f.call(y,d,g).tz(this.$x.$timezone,!0)},a.tz=function(d,g,y){var m=y&&g,w=y||g||l,v=h(+a(),w);if(typeof d!="string")return a(d).tz(w);var x=function(C,M,S){var T=C-60*M*1e3,F=h(T,S);if(M===F)return[T,M];var O=h(T-=60*(F-M)*1e3,S);return F===O?[T,F]:[C-60*Math.min(F,O)*1e3,Math.max(F,O)]}(a.utc(d,m).valueOf(),v,w),b=x[0],N=x[1],E=a(b).utcOffset(N);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(d){l=d}}})})(Bl);var qp=Bl.exports,kp=Gt(qp),Ol={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e="week",r="year";return function(n,i,a){var l=i.prototype;l.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var h=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var p=a(this).startOf(r).add(1,r).date(h),f=a(this).endOf(e);if(p.isBefore(f))return 1}var d=a(this).startOf(r).date(h).startOf(e).subtract(1,"millisecond"),g=this.diff(d,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},l.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Ol);var Up=Ol.exports,Wp=Gt(Up);function Ye(s,t){return s.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function ys(s){const t=parseInt(s)||1;let e=s.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function jp(s){const t=/([+-])(\d{1,2})(\d{0,2})/,e=s.replace(/GMT|UTC/,"").match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,i]=e,a=parseInt(n,10)*60||0,l=parseInt(i,10)||0;return(r==="+"?-1:1)*(a+l)}function qr(s,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ee(s).utcOffset(jp(t)):ee(s).tz(t)}function Qr(s){const[t,e]=ys(s);let r=0;switch(e){case"m":r=60;break;case"s":r=1;break;case"M":r=31*24*60*60;break;case"d":r=24*60*60;break;case"w":r=7*24*60*60;break;default:r=60*60;break}return Math.round(Number(t)*r)}function _t(s){return typeof s!="number"||isNaN(s)}function me(s,t){for(const e of t)s!=null&&s.hasOwnProperty(e)&&s[e]===void 0&&(s[e]=null)}function Il(s){var t=atob(s),e=decodeURI(t);return e}var Fe=(s=>(s.BOOL="bool",s.INT="int",s.FLOAT="float",s.ARRAY="array",s.BOX="box",s.CHART_POINT="chart.point",s.COLOR="color",s.CONST="const",s.LABEL="label",s.LINE="line",s.LINEFILL="linefill",s.MAP="map",s.MATRIX="matrix",s.POLYLINE="polyline",s.SERIES="series",s.SIMPLE="simple",s.STRING="string",s.TABLE="table",s.UNDETERMINED="undetermined type",s.INPUT="input",s.NA="na",s.VOID="void",s.ENUM="enum",s))(Fe||{}),ws=(s=>(s.dividends="dividends",s.none="none",s.splits="splits",s))(ws||{}),kr=(s=>(s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close",s))(kr||{}),Vi=(s=>(s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on",s))(Vi||{}),Ve=(s=>(s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line",s))(Ve||{}),Ur=(s=>(s.both="both",s.left="left",s.none="none",s.right="right",s))(Ur||{}),Kt=(s=>(s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume",s))(Kt||{}),Ds=(s=>(s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Ds||{}),ge=(s=>(s.styleArrowdown="style_arrowdown",s.styleArrowup="style_arrowup",s.styleCircle="style_circle",s.styleCross="style_cross",s.styleDiamond="style_diamond",s.styleFlag="style_flag",s.styleLabelCenter="style_label_center",s.styleLabelDown="style_label_down",s.styleLabelLeft="style_label_left",s.styleLabelLowerLeft="style_label_lower_left",s.styleLabelLowerRight="style_label_lower_right",s.styleLabelRight="style_label_right",s.styleLabelUp="style_label_up",s.styleLabelUpperLeft="style_label_upper_left",s.styleLabelUpperRight="style_label_upper_right",s.styleNone="style_none",s.styleSquare="style_square",s.styleTextOutline="style_text_outline",s.styleTriangledown="style_triangledown",s.styleTriangleup="style_triangleup",s.styleXcross="style_xcross",s))(ge||{}),Re=(s=>(s.styleArrowBoth="style_arrow_both",s.styleArrowLeft="style_arrow_left",s.styleArrowRight="style_arrow_right",s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Re||{}),an=(s=>(s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top",s))(an||{}),Vn=(s=>(s.ascending="ascending",s.descending="descending",s))(Vn||{}),Mr=(s=>(s.styleArea="Area",s.styleAreabr="Area With Breaks",s.styleCircles="Circles",s.styleColumns="Columns",s.styleCross="Cross",s.styleHistogram="Histogram",s.styleLine="Line",s.styleLinebr="Line With Breaks",s.styleStepline="Step Line",s.styleSteplineDiamond="Step Line With Diamonds",s.styleSteplinebr="Step line with Breaks",s))(Mr||{}),_r=(s=>(s.bottomCenter="bottom_center",s.bottomLeft="bottom_left",s.bottomRight="bottom_right",s.middleCenter="middle_center",s.middleLeft="middle_left",s.middleRight="middle_right",s.topCenter="top_center",s.topLeft="top_left",s.topRight="top_right",s))(_r||{}),bs=(s=>(s.left="left",s.none="none",s.right="right",s))(bs||{}),fi=(s=>(s.extended="extended",s.regular="regular",s))(fi||{}),ur=(s=>(s.arrowdown="arrowdown",s.arrowup="arrowup",s.circle="circle",s.cross="cross",s.diamond="diamond",s.flag="flag",s.labeldown="labeldown",s.labelup="labelup",s.square="square",s.triangledown="triangledown",s.triangleup="triangleup",s.xcross="xcross",s))(ur||{}),rr=(s=>(s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny",s))(rr||{}),Zn=(s=>(s.familyDefault="default",s.familyMonospace="monospace",s))(Zn||{}),Ie=(s=>(s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity",s))(Ie||{}),nr=(s=>(s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent",s))(nr||{}),ue=(s=>(s.all="all",s.long="long",s.short="short",s))(ue||{}),un=(s=>(s.cancel="cancel",s.none="none",s.reduce="reduce",s))(un||{}),Wt=(s=>(s.alignBottom="align_bottom",s.alignCenter="align_center",s.alignLeft="align_left",s.alignRight="align_right",s.alignTop="align_top",s.wrapAuto="wrap_auto",s.wrapNone="wrap_none",s))(Wt||{}),we=(s=>(s.bar_index="bar_index",s.bar_time="bar_time",s))(we||{}),Wr=(s=>(s.abovebar="abovebar",s.belowbar="belowbar",s.price="price",s))(Wr||{}),xs=(s=>(s.actual="actual",s.estimate="estimate",s.standardized="standardized",s))(xs||{}),Kn=(s=>(s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla",s))(Kn||{}),ir=(s=>(s.INT="int",s.BOOL="bool",s.TIME="time",s.COLOR="color",s.FLOAT="float",s.PRICE="price",s.SOURCE="source",s.STRING="string",s.SYMBOL="symbol",s.SESSION="session",s.TEXT_AREA="text_area",s.TIMEFRAME="timeframe",s.ENUM="enum",s))(ir||{}),zt=(s=>(s[s.Hint=1]="Hint",s[s.Info=2]="Info",s[s.Warning=4]="Warning",s[s.Error=8]="Error",s))(zt||{});const le={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.$name方法只能使用$type类型数组!",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"},Yp={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."};Fe.SERIES,Fe.SIMPLE,Fe.INPUT,Fe.CONST,Fe.INT,Fe.FLOAT,Fe.BOOL,Fe.COLOR,Fe.STRING;const Vp=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Zp=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Kp=["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 Gp{constructor(t){$(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new Qt(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 Qt(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 Qt{constructor(t=0,e,r){$(this,"_arrInstance");$(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Xr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Xr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Qt(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Qt(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 Qt(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),Xr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),_t(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),_t(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),_t(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(!_t(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}){_t(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||_t(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,zt.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 i;if(this._arrInstance.length===0){(i=this._errorListener)==null||i.addError(le.arrEmptyErr,t,zt.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(!_t(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){_t(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!==Vn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((i,a)=>a);r.sort((i,a)=>t!==Vn.descending?this._arrInstance[i]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[i]);const n=new Qt(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new Qt(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(le.arrEmptyErr,e,zt.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(le.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>a+((l||0)-r)**2,0),i=n/t.length;return e?i:t.length>1?n/(t.length-1):i}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>{const c=(l||0)-r;return a+c*c},0),i=Math.sqrt(n/t.length);return e?i:t.length>1?Math.sqrt(n/(t.length-1)):i}_standardizeArray(t){const e=t.reduce((i,a)=>i+(a||0),0)/t.length,r=Math.sqrt(t.reduce((i,a)=>i+Math.pow((a||0)-e,2),0)/t.length);return t.map(i=>((i||0)-e)/r)}_getPercentileRank(t,e=0){if(_t(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,l)=>a-l),n=e/100*r.length,i=Math.ceil(n)-1;return r[i>=r.length?r.length-1:i]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||_t(e))return;t.sort(function(i,a){return i-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[i,a]of t.entries()){const l=t[i-1];if(e<(i+.5)/r)return l+(a-l)*(e-(i-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const i of t)e[i]=(e[i]||0)+1,r=Math.max(r,e[i]);for(const i in e)e[i]===r&&n.push(Number(i));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 i=r;i<n;i++)t[i]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(le.arrLengthDiffErr,n,zt.Error);return}t=t.filter(h=>h!==void 0),e=e.filter(h=>h!==void 0);const i=t.reduce((h,p)=>h+p,0)/t.length,a=e.reduce((h,p)=>h+p,0)/e.length;let l=0;for(let h=0;h<t.length;h++)l+=(t[h]-i)*(e[h]-a);return r?l/t.length:l/(t.length-1)}_verifySimpleType(t,e,r,n,i=this._arrInstance){var l;i.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((l=this._errorListener)==null||l.addError(Ye(le.arrTypeErr,{name:e,type:r}),n,zt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const i=Math.floor((r+n)/2);if(t[i]===e)return i;t[i]<e?r=i+1:n=i-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<e?r=a+1:n=a-1}return i.length?Math.min(...i):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<=e?r=a+1:n=a-1}return i.length?Math.max(...i):r}}class Hp{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(!_t(t))return Math.abs(t)}acos({angle:t}){if(_t(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(_t(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(_t(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Xr.mean(e)}ceil({number:t}){if(!_t(t))return Math.ceil(t)}floor({number:t}){if(!_t(t))return Math.floor(t)}cos({angle:t}){if(_t(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(_t(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(_t(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!_t(t))return Math.exp(t)}log({number:t}){if(!_t(t))return Math.log(t)}log10({number:t}){if(!_t(t))return Math.log10(t)}max(t,e){return e=e.filter(r=>!_t(r)),Math.max(...e)}min(t,e){return e=e.filter(r=>!_t(r)),Math.min(...e)}pow({base:t,exponent:e}){if(!(_t(t)||_t(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(_t(t)&&(t=0),_t(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(le.mathRandomErr,n,zt.Error);return}let i;do i=Math.random()*(e-t)+t;while(i===t||i===e);return r&&(this._randomNums[r]=i),i}round({number:t,precision:e}){if(!_t(t))return _t(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!_t(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!_t(t))return t&&Math.sign(t)}sqrt({number:t}){if(!_t(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 i=n.filter(a=>!_t(a));if(!(i.length<e))return Xr.sum(i.slice(-e))}todegrees({radians:t}){if(!_t(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!_t(t))return t*(Math.PI/180)}}function Es(){return Es=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=e[r])}return s},Es.apply(this,arguments)}var Tl={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function de(s){return typeof s=="number"}function Se(s){return!s||typeof s!="object"||typeof s.constructor!="function"?!1:s.isBigNumber===!0&&typeof s.constructor.prototype=="object"&&s.constructor.prototype.isBigNumber===!0||typeof s.constructor.isDecimal=="function"&&s.constructor.isDecimal(s)===!0}function $l(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isComplex===!0||!1}function Ll(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isFraction===!0||!1}function Rl(s){return s&&s.constructor.prototype.isUnit===!0||!1}function tn(s){return typeof s=="string"}var Ee=Array.isArray;function ve(s){return s&&s.constructor.prototype.isMatrix===!0||!1}function Zi(s){return Array.isArray(s)||ve(s)}function Jp(s){return s&&s.isDenseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Xp(s){return s&&s.isSparseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Qp(s){return s&&s.constructor.prototype.isRange===!0||!1}function la(s){return s&&s.constructor.prototype.isIndex===!0||!1}function td(s){return typeof s=="boolean"}function ed(s){return s&&s.constructor.prototype.isResultSet===!0||!1}function rd(s){return s&&s.constructor.prototype.isHelp===!0||!1}function nd(s){return typeof s=="function"}function id(s){return s instanceof Date}function sd(s){return s instanceof RegExp}function ca(s){return!!(s&&typeof s=="object"&&s.constructor===Object&&!$l(s)&&!Ll(s))}function od(s){return s===null}function ad(s){return s===void 0}function ud(s){return s&&s.isAccessorNode===!0&&s.constructor.prototype.isNode===!0||!1}function ld(s){return s&&s.isArrayNode===!0&&s.constructor.prototype.isNode===!0||!1}function cd(s){return s&&s.isAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function fd(s){return s&&s.isBlockNode===!0&&s.constructor.prototype.isNode===!0||!1}function hd(s){return s&&s.isConditionalNode===!0&&s.constructor.prototype.isNode===!0||!1}function pd(s){return s&&s.isConstantNode===!0&&s.constructor.prototype.isNode===!0||!1}function dd(s){return s&&s.isFunctionAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function _d(s){return s&&s.isFunctionNode===!0&&s.constructor.prototype.isNode===!0||!1}function md(s){return s&&s.isIndexNode===!0&&s.constructor.prototype.isNode===!0||!1}function gd(s){return s&&s.isNode===!0&&s.constructor.prototype.isNode===!0||!1}function vd(s){return s&&s.isObjectNode===!0&&s.constructor.prototype.isNode===!0||!1}function yd(s){return s&&s.isOperatorNode===!0&&s.constructor.prototype.isNode===!0||!1}function wd(s){return s&&s.isParenthesisNode===!0&&s.constructor.prototype.isNode===!0||!1}function Dd(s){return s&&s.isRangeNode===!0&&s.constructor.prototype.isNode===!0||!1}function bd(s){return s&&s.isRelationalNode===!0&&s.constructor.prototype.isNode===!0||!1}function xd(s){return s&&s.isSymbolNode===!0&&s.constructor.prototype.isNode===!0||!1}function Ed(s){return s&&s.constructor.prototype.isChain===!0||!1}function En(s){var t=typeof s;return t==="object"?s===null?"null":Se(s)?"BigNumber":s.constructor&&s.constructor.name?s.constructor.name:"Object":t}function se(s){var t=typeof s;if(t==="number"||t==="string"||t==="boolean"||s===null||s===void 0)return s;if(typeof s.clone=="function")return s.clone();if(Array.isArray(s))return s.map(function(e){return se(e)});if(s instanceof Date)return new Date(s.valueOf());if(Se(s))return s;if(ca(s))return Ad(s,se);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(s,")"))}function Ad(s,t){var e={};for(var r in s)Ki(s,r)&&(e[r]=t(s[r]));return e}function Pl(s,t){for(var e in t)Ki(t,e)&&(s[e]=t[e]);return s}function hi(s,t){var e,r,n;if(Array.isArray(s)){if(!Array.isArray(t)||s.length!==t.length)return!1;for(r=0,n=s.length;r<n;r++)if(!hi(s[r],t[r]))return!1;return!0}else{if(typeof s=="function")return s===t;if(s instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in s)if(!(e in t)||!hi(s[e],t[e]))return!1;for(e in t)if(!(e in s))return!1;return!0}else return s===t}}function Ki(s,t){return s&&Object.hasOwnProperty.call(s,t)}function Cd(s,t){for(var e={},r=0;r<t.length;r++){var n=t[r],i=s[n];i!==void 0&&(e[n]=i)}return e}var Fd=["Matrix","Array"],Md=["number","BigNumber","Fraction"],mr=function(t){if(t)throw new Error(`The global config is readonly.
|
27
|
+
}`;var Rt=Tp(function(){return te(I,yt+"return "+ot).apply(e,P)});if(Rt.source=ot,pl(Rt))throw Rt;return Rt}function KC(o){return ie(o).toLowerCase()}function GC(o){return ie(o).toUpperCase()}function HC(o,u,_){if(o=ie(o),o&&(_||u===e))return Wh(o);if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Zr(u),I=jh(D,C),P=Yh(D,C)+1;return Wn(D,I,P).join("")}function JC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.slice(0,Zh(o)+1);if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Yh(D,Zr(u))+1;return Wn(D,0,C).join("")}function XC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.replace(ns,"");if(!o||!(u=Er(u)))return o;var D=Zr(o),C=jh(D,Zr(u));return Wn(D,C).join("")}function QC(o,u){var _=F,D=O;if(Ce(u)){var C="separator"in u?u.separator:C;_="length"in u?Lt(u.length):_,D="omission"in u?Er(u.omission):D}o=ie(o);var I=o.length;if(Ti(o)){var P=Zr(o);I=P.length}if(_>=I)return o;var q=_-$i(D);if(q<1)return D;var Y=P?Wn(P,0,q).join(""):o.slice(0,q);if(C===e)return Y+D;if(P&&(q+=Y.length-q),dl(C)){if(o.slice(q).search(C)){var tt,et=Y;for(C.global||(C=Su(C.source,ie(wo.exec(C))+"g")),C.lastIndex=0;tt=C.exec(et);)var ot=tt.index;Y=Y.slice(0,ot===e?q:ot)}}else if(o.indexOf(Er(C),q)!=q){var dt=Y.lastIndexOf(C);dt>-1&&(Y=Y.slice(0,dt))}return Y+D}function t2(o){return o=ie(o),o&&Ya.test(o)?o.replace(ti,ND):o}var e2=Ui(function(o,u,_){return o+(_?" ":"")+u.toUpperCase()}),gl=$0("toUpperCase");function Ip(o,u,_){return o=ie(o),u=_?e:u,u===e?ED(o)?OD(o):_D(o):o.match(u)||[]}var Tp=Pt(function(o,u){try{return br(o,e,u)}catch(_){return pl(_)?_:new Ot(_)}}),r2=yn(function(o,u){return Ir(u,function(_){_=on(_),gn(o,_,fl(o[_],o))}),o});function n2(o){var u=o==null?0:o.length,_=At();return o=u?xe(o,function(D){if(typeof D[1]!="function")throw new Tr(a);return[_(D[0]),D[1]]}):[],Pt(function(D){for(var C=-1;++C<u;){var I=o[C];if(br(I[0],this,D))return br(I[1],this,D)}})}function i2(o){return Nb(Lr(o,f))}function vl(o){return function(){return o}}function s2(o,u){return o==null||o!==o?u:o}var o2=R0(),a2=R0(!0);function dr(o){return o}function yl(o){return p0(typeof o=="function"?o:Lr(o,f))}function u2(o){return _0(Lr(o,f))}function l2(o,u){return m0(o,Lr(u,f))}var c2=Pt(function(o,u){return function(_){return hs(_,o,u)}}),f2=Pt(function(o,u){return function(_){return hs(o,_,u)}});function wl(o,u,_){var D=je(u),C=Uo(u,D);_==null&&!(Ce(u)&&(C.length||!D.length))&&(_=u,u=o,o=this,C=Uo(u,je(u)));var I=!(Ce(_)&&"chain"in _)||!!_.chain,P=Dn(o);return Ir(C,function(q){var Y=u[q];o[q]=Y,P&&(o.prototype[q]=function(){var tt=this.__chain__;if(I||tt){var et=o(this.__wrapped__),ot=et.__actions__=fr(this.__actions__);return ot.push({func:Y,args:arguments,thisArg:o}),et.__chain__=tt,et}return Y.apply(o,Rn([this.value()],arguments))})}),o}function h2(){return Ge._===this&&(Ge._=PD),this}function Dl(){}function p2(o){return o=Lt(o),Pt(function(u){return g0(u,o)})}var d2=Xu(xe),_2=Xu(Ph),m2=Xu(xu);function $p(o){return sl(o)?Eu(on(o)):Vb(o)}function g2(o){return function(u){return o==null?e:ai(o,u)}}var v2=z0(),y2=z0(!0);function bl(){return[]}function xl(){return!1}function w2(){return{}}function D2(){return""}function b2(){return!0}function x2(o,u){if(o=Lt(o),o<1||o>Z)return[];var _=ct,D=tr(o,ct);u=At(u),o-=ct;for(var C=Fu(D,u);++_<o;)u(_);return C}function E2(o){return Tt(o)?xe(o,on):Ar(o)?[o]:fr(ep(ie(o)))}function A2(o){var u=++LD;return ie(o)+u}var C2=Ko(function(o,u){return o+u},0),F2=Qu("ceil"),M2=Ko(function(o,u){return o/u},1),N2=Qu("floor");function S2(o){return o&&o.length?ko(o,dr,Pu):e}function B2(o,u){return o&&o.length?ko(o,At(u,2),Pu):e}function O2(o){return kh(o,dr)}function I2(o,u){return kh(o,At(u,2))}function T2(o){return o&&o.length?ko(o,dr,Uu):e}function $2(o,u){return o&&o.length?ko(o,At(u,2),Uu):e}var L2=Ko(function(o,u){return o*u},1),R2=Qu("round"),P2=Ko(function(o,u){return o-u},0);function z2(o){return o&&o.length?Cu(o,dr):0}function q2(o,u){return o&&o.length?Cu(o,At(u,2)):0}return B.after=uA,B.ary=hp,B.assign=GA,B.assignIn=Cp,B.assignInWith=aa,B.assignWith=HA,B.at=JA,B.before=pp,B.bind=fl,B.bindAll=r2,B.bindKey=dp,B.castArray=wA,B.chain=lp,B.chunk=Nx,B.compact=Sx,B.concat=Bx,B.cond=n2,B.conforms=i2,B.constant=vl,B.countBy=zE,B.create=XA,B.curry=_p,B.curryRight=mp,B.debounce=gp,B.defaults=QA,B.defaultsDeep=tC,B.defer=lA,B.delay=cA,B.difference=Ox,B.differenceBy=Ix,B.differenceWith=Tx,B.drop=$x,B.dropRight=Lx,B.dropRightWhile=Rx,B.dropWhile=Px,B.fill=zx,B.filter=kE,B.flatMap=jE,B.flatMapDeep=YE,B.flatMapDepth=VE,B.flatten=sp,B.flattenDeep=qx,B.flattenDepth=kx,B.flip=fA,B.flow=o2,B.flowRight=a2,B.fromPairs=Ux,B.functions=aC,B.functionsIn=uC,B.groupBy=ZE,B.initial=jx,B.intersection=Yx,B.intersectionBy=Vx,B.intersectionWith=Zx,B.invert=cC,B.invertBy=fC,B.invokeMap=GE,B.iteratee=yl,B.keyBy=HE,B.keys=je,B.keysIn=pr,B.map=ea,B.mapKeys=pC,B.mapValues=dC,B.matches=u2,B.matchesProperty=l2,B.memoize=na,B.merge=_C,B.mergeWith=Fp,B.method=c2,B.methodOf=f2,B.mixin=wl,B.negate=ia,B.nthArg=p2,B.omit=mC,B.omitBy=gC,B.once=hA,B.orderBy=JE,B.over=d2,B.overArgs=pA,B.overEvery=_2,B.overSome=m2,B.partial=hl,B.partialRight=vp,B.partition=XE,B.pick=vC,B.pickBy=Mp,B.property=$p,B.propertyOf=g2,B.pull=Jx,B.pullAll=ap,B.pullAllBy=Xx,B.pullAllWith=Qx,B.pullAt=tE,B.range=v2,B.rangeRight=y2,B.rearg=dA,B.reject=eA,B.remove=eE,B.rest=_A,B.reverse=ll,B.sampleSize=nA,B.set=wC,B.setWith=DC,B.shuffle=iA,B.slice=rE,B.sortBy=aA,B.sortedUniq=lE,B.sortedUniqBy=cE,B.split=jC,B.spread=mA,B.tail=fE,B.take=hE,B.takeRight=pE,B.takeRightWhile=dE,B.takeWhile=_E,B.tap=SE,B.throttle=gA,B.thru=ta,B.toArray=xp,B.toPairs=Np,B.toPairsIn=Sp,B.toPath=E2,B.toPlainObject=Ap,B.transform=bC,B.unary=vA,B.union=mE,B.unionBy=gE,B.unionWith=vE,B.uniq=yE,B.uniqBy=wE,B.uniqWith=DE,B.unset=xC,B.unzip=cl,B.unzipWith=up,B.update=EC,B.updateWith=AC,B.values=Yi,B.valuesIn=CC,B.without=bE,B.words=Ip,B.wrap=yA,B.xor=xE,B.xorBy=EE,B.xorWith=AE,B.zip=CE,B.zipObject=FE,B.zipObjectDeep=ME,B.zipWith=NE,B.entries=Np,B.entriesIn=Sp,B.extend=Cp,B.extendWith=aa,wl(B,B),B.add=C2,B.attempt=Tp,B.camelCase=SC,B.capitalize=Bp,B.ceil=F2,B.clamp=FC,B.clone=DA,B.cloneDeep=xA,B.cloneDeepWith=EA,B.cloneWith=bA,B.conformsTo=AA,B.deburr=Op,B.defaultTo=s2,B.divide=M2,B.endsWith=BC,B.eq=Gr,B.escape=OC,B.escapeRegExp=IC,B.every=qE,B.find=UE,B.findIndex=np,B.findKey=eC,B.findLast=WE,B.findLastIndex=ip,B.findLastKey=rC,B.floor=N2,B.forEach=cp,B.forEachRight=fp,B.forIn=nC,B.forInRight=iC,B.forOwn=sC,B.forOwnRight=oC,B.get=_l,B.gt=CA,B.gte=FA,B.has=lC,B.hasIn=ml,B.head=op,B.identity=dr,B.includes=KE,B.indexOf=Wx,B.inRange=MC,B.invoke=hC,B.isArguments=ci,B.isArray=Tt,B.isArrayBuffer=MA,B.isArrayLike=hr,B.isArrayLikeObject=Be,B.isBoolean=NA,B.isBuffer=jn,B.isDate=SA,B.isElement=BA,B.isEmpty=OA,B.isEqual=IA,B.isEqualWith=TA,B.isError=pl,B.isFinite=$A,B.isFunction=Dn,B.isInteger=yp,B.isLength=sa,B.isMap=wp,B.isMatch=LA,B.isMatchWith=RA,B.isNaN=PA,B.isNative=zA,B.isNil=kA,B.isNull=qA,B.isNumber=Dp,B.isObject=Ce,B.isObjectLike=Me,B.isPlainObject=vs,B.isRegExp=dl,B.isSafeInteger=UA,B.isSet=bp,B.isString=oa,B.isSymbol=Ar,B.isTypedArray=ji,B.isUndefined=WA,B.isWeakMap=jA,B.isWeakSet=YA,B.join=Kx,B.kebabCase=TC,B.last=Pr,B.lastIndexOf=Gx,B.lowerCase=$C,B.lowerFirst=LC,B.lt=VA,B.lte=ZA,B.max=S2,B.maxBy=B2,B.mean=O2,B.meanBy=I2,B.min=T2,B.minBy=$2,B.stubArray=bl,B.stubFalse=xl,B.stubObject=w2,B.stubString=D2,B.stubTrue=b2,B.multiply=L2,B.nth=Hx,B.noConflict=h2,B.noop=Dl,B.now=ra,B.pad=RC,B.padEnd=PC,B.padStart=zC,B.parseInt=qC,B.random=NC,B.reduce=QE,B.reduceRight=tA,B.repeat=kC,B.replace=UC,B.result=yC,B.round=R2,B.runInContext=j,B.sample=rA,B.size=sA,B.snakeCase=WC,B.some=oA,B.sortedIndex=nE,B.sortedIndexBy=iE,B.sortedIndexOf=sE,B.sortedLastIndex=oE,B.sortedLastIndexBy=aE,B.sortedLastIndexOf=uE,B.startCase=YC,B.startsWith=VC,B.subtract=P2,B.sum=z2,B.sumBy=q2,B.template=ZC,B.times=x2,B.toFinite=bn,B.toInteger=Lt,B.toLength=Ep,B.toLower=KC,B.toNumber=zr,B.toSafeInteger=KA,B.toString=ie,B.toUpper=GC,B.trim=HC,B.trimEnd=JC,B.trimStart=XC,B.truncate=QC,B.unescape=t2,B.uniqueId=A2,B.upperCase=e2,B.upperFirst=gl,B.each=cp,B.eachRight=fp,B.first=op,wl(B,function(){var o={};return nn(B,function(u,_){ae.call(B.prototype,_)||(o[_]=u)}),o}(),{chain:!1}),B.VERSION=r,Ir(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Ir(["drop","take"],function(o,u){jt.prototype[o]=function(_){_=_===e?1:Ue(Lt(_),0);var D=this.__filtered__&&!u?new jt(this):this.clone();return D.__filtered__?D.__takeCount__=tr(_,D.__takeCount__):D.__views__.push({size:tr(_,ct),type:o+(D.__dir__<0?"Right":"")}),D},jt.prototype[o+"Right"]=function(_){return this.reverse()[o](_).reverse()}}),Ir(["filter","map","takeWhile"],function(o,u){var _=u+1,D=_==k||_==z;jt.prototype[o]=function(C){var I=this.clone();return I.__iteratees__.push({iteratee:At(C,3),type:_}),I.__filtered__=I.__filtered__||D,I}}),Ir(["head","last"],function(o,u){var _="take"+(u?"Right":"");jt.prototype[o]=function(){return this[_](1).value()[0]}}),Ir(["initial","tail"],function(o,u){var _="drop"+(u?"":"Right");jt.prototype[o]=function(){return this.__filtered__?new jt(this):this[_](1)}}),jt.prototype.compact=function(){return this.filter(dr)},jt.prototype.find=function(o){return this.filter(o).head()},jt.prototype.findLast=function(o){return this.reverse().find(o)},jt.prototype.invokeMap=Pt(function(o,u){return typeof o=="function"?new jt(this):this.map(function(_){return hs(_,o,u)})}),jt.prototype.reject=function(o){return this.filter(ia(At(o)))},jt.prototype.slice=function(o,u){o=Lt(o);var _=this;return _.__filtered__&&(o>0||u<0)?new jt(_):(o<0?_=_.takeRight(-o):o&&(_=_.drop(o)),u!==e&&(u=Lt(u),_=u<0?_.dropRight(-u):_.take(u-o)),_)},jt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},jt.prototype.toArray=function(){return this.take(ct)},nn(jt.prototype,function(o,u){var _=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),C=B[D?"take"+(u=="last"?"Right":""):u],I=D||/^find/.test(u);C&&(B.prototype[u]=function(){var P=this.__wrapped__,q=D?[1]:arguments,Y=P instanceof jt,tt=q[0],et=Y||Tt(P),ot=function(Ut){var Yt=C.apply(B,Rn([Ut],q));return D&&dt?Yt[0]:Yt};et&&_&&typeof tt=="function"&&tt.length!=1&&(Y=et=!1);var dt=this.__chain__,yt=!!this.__actions__.length,Ct=I&&!dt,Rt=Y&&!yt;if(!I&&et){P=Rt?P:new jt(this);var Ft=o.apply(P,q);return Ft.__actions__.push({func:ta,args:[ot],thisArg:e}),new $r(Ft,dt)}return Ct&&Rt?o.apply(this,q):(Ft=this.thru(ot),Ct?D?Ft.value()[0]:Ft.value():Ft)})}),Ir(["pop","push","shift","sort","splice","unshift"],function(o){var u=Co[o],_=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var C=arguments;if(D&&!this.__chain__){var I=this.value();return u.apply(Tt(I)?I:[],C)}return this[_](function(P){return u.apply(Tt(P)?P:[],C)})}}),nn(jt.prototype,function(o,u){var _=B[u];if(_){var D=_.name+"";ae.call(zi,D)||(zi[D]=[]),zi[D].push({name:u,func:_})}}),zi[Zo(e,v).name]=[{name:"wrapper",func:e}],jt.prototype.clone=tb,jt.prototype.reverse=eb,jt.prototype.value=rb,B.prototype.at=BE,B.prototype.chain=OE,B.prototype.commit=IE,B.prototype.next=TE,B.prototype.plant=LE,B.prototype.reverse=RE,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=PE,B.prototype.first=B.prototype.head,ss&&(B.prototype[ss]=$E),B},Li=ID();ri?((ri.exports=Li)._=Li,yu._=Li):Ge._=Li}).call(Vt)}(Yn,Yn.exports);var Xr=Yn.exports;class Rp{constructor(t,e){$(this,"_defaultParams");$(this,"_UserTypeFileds");$(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Xr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Xr.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 Xr.cloneDeep(this)}}}}var Ml={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e=1e3,r=6e4,n=36e5,i="millisecond",a="second",l="minute",c="hour",p="day",h="week",f="month",d="quarter",g="year",y="date",m="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(k){var W=["th","st","nd","rd"],z=k%100;return"["+k+(W[(z-20)%10]||W[z]||W[0])+"]"}},b=function(k,W,z){var K=String(k);return!K||K.length>=W?k:""+Array(W+1-K.length).join(z)+k},N={s:b,z:function(k){var W=-k.utcOffset(),z=Math.abs(W),K=Math.floor(z/60),Z=z%60;return(W<=0?"+":"-")+b(K,2,"0")+":"+b(Z,2,"0")},m:function k(W,z){if(W.date()<z.date())return-k(z,W);var K=12*(z.year()-W.year())+(z.month()-W.month()),Z=W.clone().add(K,f),X=z-Z<0,Q=W.clone().add(K+(X?-1:1),f);return+(-(K+(z-Z)/(X?Z-Q:Q-Z))||0)},a:function(k){return k<0?Math.ceil(k)||0:Math.floor(k)},p:function(k){return{M:f,y:g,w:h,d:p,D:y,h:c,m:l,s:a,ms:i,Q:d}[k]||String(k||"").toLowerCase().replace(/s$/,"")},u:function(k){return k===void 0}},E="en",A={};A[E]=x;var M="$isDayjsObject",S=function(k){return k instanceof R||!(!k||!k[M])},T=function k(W,z,K){var Z;if(!W)return E;if(typeof W=="string"){var X=W.toLowerCase();A[X]&&(Z=X),z&&(A[X]=z,Z=X);var Q=W.split("-");if(!Z&&Q.length>1)return k(Q[0])}else{var ct=W.name;A[ct]=W,Z=ct}return!K&&Z&&(E=Z),Z||!K&&E},F=function(k,W){if(S(k))return k.clone();var z=typeof W=="object"?W:{};return z.date=k,z.args=arguments,new R(z)},O=N;O.l=T,O.i=S,O.w=function(k,W){return F(k,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var R=function(){function k(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[M]=!0}var W=k.prototype;return W.parse=function(z){this.$d=function(K){var Z=K.date,X=K.utc;if(Z===null)return new Date(NaN);if(O.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var Q=Z.match(w);if(Q){var ct=Q[2]-1||0,vt=(Q[7]||"0").substring(0,3);return X?new Date(Date.UTC(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)):new Date(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)}}return new Date(Z)}(z),this.init()},W.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},W.$utils=function(){return O},W.isValid=function(){return this.$d.toString()!==m},W.isSame=function(z,K){var Z=F(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},W.isAfter=function(z,K){return F(z)<this.startOf(K)},W.isBefore=function(z,K){return this.endOf(K)<F(z)},W.$g=function(z,K,Z){return O.u(z)?this[K]:this.set(Z,z)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(z,K){var Z=this,X=!!O.u(K)||K,Q=O.p(z),ct=function(It,Nt){var ce=O.w(Z.$u?Date.UTC(Z.$y,Nt,It):new Date(Z.$y,Nt,It),Z);return X?ce:ce.endOf(p)},vt=function(It,Nt){return O.w(Z.toDate()[It].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Z)},lt=this.$W,wt=this.$M,bt=this.$D,Bt="set"+(this.$u?"UTC":"");switch(Q){case g:return X?ct(1,0):ct(31,11);case f:return X?ct(1,wt):ct(0,wt+1);case h:var xt=this.$locale().weekStart||0,oe=(lt<xt?lt+7:lt)-xt;return ct(X?bt-oe:bt+(6-oe),wt);case p:case y:return vt(Bt+"Hours",0);case c:return vt(Bt+"Minutes",1);case l:return vt(Bt+"Seconds",2);case a:return vt(Bt+"Milliseconds",3);default:return this.clone()}},W.endOf=function(z){return this.startOf(z,!1)},W.$set=function(z,K){var Z,X=O.p(z),Q="set"+(this.$u?"UTC":""),ct=(Z={},Z[p]=Q+"Date",Z[y]=Q+"Date",Z[f]=Q+"Month",Z[g]=Q+"FullYear",Z[c]=Q+"Hours",Z[l]=Q+"Minutes",Z[a]=Q+"Seconds",Z[i]=Q+"Milliseconds",Z)[X],vt=X===p?this.$D+(K-this.$W):K;if(X===f||X===g){var lt=this.clone().set(y,1);lt.$d[ct](vt),lt.init(),this.$d=lt.set(y,Math.min(this.$D,lt.daysInMonth())).$d}else ct&&this.$d[ct](vt);return this.init(),this},W.set=function(z,K){return this.clone().$set(z,K)},W.get=function(z){return this[O.p(z)]()},W.add=function(z,K){var Z,X=this;z=Number(z);var Q=O.p(K),ct=function(wt){var bt=F(X);return O.w(bt.date(bt.date()+Math.round(wt*z)),X)};if(Q===f)return this.set(f,this.$M+z);if(Q===g)return this.set(g,this.$y+z);if(Q===p)return ct(1);if(Q===h)return ct(7);var vt=(Z={},Z[l]=r,Z[c]=n,Z[a]=e,Z)[Q]||1,lt=this.$d.getTime()+z*vt;return O.w(lt,this)},W.subtract=function(z,K){return this.add(-1*z,K)},W.format=function(z){var K=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||m;var X=z||"YYYY-MM-DDTHH:mm:ssZ",Q=O.z(this),ct=this.$H,vt=this.$m,lt=this.$M,wt=Z.weekdays,bt=Z.months,Bt=Z.meridiem,xt=function(Nt,ce,re,kt){return Nt&&(Nt[ce]||Nt(K,X))||re[ce].slice(0,kt)},oe=function(Nt){return O.s(ct%12||12,Nt,"0")},It=Bt||function(Nt,ce,re){var kt=Nt<12?"AM":"PM";return re?kt.toLowerCase():kt};return X.replace(v,function(Nt,ce){return ce||function(re){switch(re){case"YY":return String(K.$y).slice(-2);case"YYYY":return O.s(K.$y,4,"0");case"M":return lt+1;case"MM":return O.s(lt+1,2,"0");case"MMM":return xt(Z.monthsShort,lt,bt,3);case"MMMM":return xt(bt,lt);case"D":return K.$D;case"DD":return O.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return xt(Z.weekdaysMin,K.$W,wt,2);case"ddd":return xt(Z.weekdaysShort,K.$W,wt,3);case"dddd":return wt[K.$W];case"H":return String(ct);case"HH":return O.s(ct,2,"0");case"h":return oe(1);case"hh":return oe(2);case"a":return It(ct,vt,!0);case"A":return It(ct,vt,!1);case"m":return String(vt);case"mm":return O.s(vt,2,"0");case"s":return String(K.$s);case"ss":return O.s(K.$s,2,"0");case"SSS":return O.s(K.$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(z,K,Z){var X,Q=this,ct=O.p(K),vt=F(z),lt=(vt.utcOffset()-this.utcOffset())*r,wt=this-vt,bt=function(){return O.m(Q,vt)};switch(ct){case g:X=bt()/12;break;case f:X=bt();break;case d:X=bt()/3;break;case h:X=(wt-lt)/6048e5;break;case p:X=(wt-lt)/864e5;break;case c:X=wt/n;break;case l:X=wt/r;break;case a:X=wt/e;break;default:X=wt}return Z?X:O.a(X)},W.daysInMonth=function(){return this.endOf(f).$D},W.$locale=function(){return A[this.$L]},W.locale=function(z,K){if(!z)return this.$L;var Z=this.clone(),X=T(z,K,!0);return X&&(Z.$L=X),Z},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()},k}(),U=R.prototype;return F.prototype=U,[["$ms",i],["$s",a],["$m",l],["$H",c],["$W",p],["$M",f],["$y",g],["$D",y]].forEach(function(k){U[k[1]]=function(W){return this.$g(W,k[0],k[1])}}),F.extend=function(k,W){return k.$i||(k(W,R,F),k.$i=!0),F},F.locale=T,F.isDayjs=S,F.unix=function(k){return F(1e3*k)},F.en=A[E],F.Ls=A,F.p={},F})})(Ml);var Pp=Ml.exports,ee=Gt(Pp),Nl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,a,l){var c=a.prototype;l.utc=function(m){var w={date:m,utc:!0,args:arguments};return new a(w)},c.utc=function(m){var w=l(this.toDate(),{locale:this.$L,utc:!0});return m?w.add(this.utcOffset(),e):w},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var p=c.parse;c.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),p.call(this,m)};var h=c.init;c.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else h.call(this)};var f=c.utcOffset;c.utcOffset=function(m,w){var v=this.$utils().u;if(v(m))return this.$u?0:v(this.$offset)?f.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var A=E.match(r);if(!A)return null;var M=(""+A[0]).match(n)||["-",0,0],S=M[0],T=60*+M[1]+ +M[2];return T===0?0:S==="+"?T:-T}(m),m===null))return this;var x=Math.abs(m)<=16?60*m:m,b=this;if(w)return b.$offset=x,b.$u=m===0,b;if(m!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+N,e)).$offset=x,b.$x.$localOffset=N}else b=this.utc();return b};var d=c.format;c.format=function(m){var w=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,w)},c.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},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(m){return m==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var y=c.diff;c.diff=function(m,w,v){if(m&&this.$u===m.$u)return y.call(this,m,w,v);var x=this.local(),b=l(m).local();return y.call(x,b,w,v)}}})})(Nl);var zp=Nl.exports,Sl=Gt(zp),Bl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,i,a){var l,c=function(d,g,y){y===void 0&&(y={});var m=new Date(d),w=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",N=v+"|"+b,E=r[N];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[N]=E),E}(g,y);return w.formatToParts(m)},p=function(d,g){for(var y=c(d,g),m=[],w=0;w<y.length;w+=1){var v=y[w],x=v.type,b=v.value,N=e[x];N>=0&&(m[N]=parseInt(b,10))}var E=m[3],A=E===24?0:E,M=m[0]+"-"+m[1]+"-"+m[2]+" "+A+":"+m[4]+":"+m[5]+":000",S=+d;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},h=i.prototype;h.tz=function(d,g){d===void 0&&(d=l);var y=this.utcOffset(),m=this.toDate(),w=m.toLocaleString("en-US",{timeZone:d}),v=Math.round((m-new Date(w))/1e3/60),x=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(y-b,"minute")}return x.$x.$timezone=d,x},h.offsetName=function(d){var g=this.$x.$timezone||a.tz.guess(),y=c(this.valueOf(),g,{timeZoneName:d}).find(function(m){return m.type.toLowerCase()==="timezonename"});return y&&y.value};var f=h.startOf;h.startOf=function(d,g){if(!this.$x||!this.$x.$timezone)return f.call(this,d,g);var y=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return f.call(y,d,g).tz(this.$x.$timezone,!0)},a.tz=function(d,g,y){var m=y&&g,w=y||g||l,v=p(+a(),w);if(typeof d!="string")return a(d).tz(w);var x=function(A,M,S){var T=A-60*M*1e3,F=p(T,S);if(M===F)return[T,M];var O=p(T-=60*(F-M)*1e3,S);return F===O?[T,F]:[A-60*Math.min(F,O)*1e3,Math.max(F,O)]}(a.utc(d,m).valueOf(),v,w),b=x[0],N=x[1],E=a(b).utcOffset(N);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(d){l=d}}})})(Bl);var qp=Bl.exports,kp=Gt(qp),Ol={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e="week",r="year";return function(n,i,a){var l=i.prototype;l.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var p=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var h=a(this).startOf(r).add(1,r).date(p),f=a(this).endOf(e);if(h.isBefore(f))return 1}var d=a(this).startOf(r).date(p).startOf(e).subtract(1,"millisecond"),g=this.diff(d,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},l.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Ol);var Up=Ol.exports,Wp=Gt(Up);function Ye(s,t){return s.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function ys(s){const t=parseInt(s)||1;let e=s.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function jp(s){const t=/([+-])(\d{1,2})(\d{0,2})/,e=s.replace(/GMT|UTC/,"").match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,i]=e,a=parseInt(n,10)*60||0,l=parseInt(i,10)||0;return(r==="+"?-1:1)*(a+l)}function qr(s,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ee(s).utcOffset(jp(t)):ee(s).tz(t)}function Qr(s){const[t,e]=ys(s);let r=0;switch(e){case"m":r=60;break;case"s":r=1;break;case"M":r=31*24*60*60;break;case"d":r=24*60*60;break;case"w":r=7*24*60*60;break;default:r=60*60;break}return Math.round(Number(t)*r)}function _t(s){return typeof s!="number"||isNaN(s)}function me(s,t){for(const e of t)s!=null&&s.hasOwnProperty(e)&&s[e]===void 0&&(s[e]=null)}function Il(s){var t=atob(s),e=decodeURI(t);return e}var Fe=(s=>(s.BOOL="bool",s.INT="int",s.FLOAT="float",s.ARRAY="array",s.BOX="box",s.CHART_POINT="chart.point",s.COLOR="color",s.CONST="const",s.LABEL="label",s.LINE="line",s.LINEFILL="linefill",s.MAP="map",s.MATRIX="matrix",s.POLYLINE="polyline",s.SERIES="series",s.SIMPLE="simple",s.STRING="string",s.TABLE="table",s.UNDETERMINED="undetermined type",s.INPUT="input",s.NA="na",s.VOID="void",s.ENUM="enum",s))(Fe||{}),ws=(s=>(s.dividends="dividends",s.none="none",s.splits="splits",s))(ws||{}),kr=(s=>(s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close",s))(kr||{}),Vi=(s=>(s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on",s))(Vi||{}),Ve=(s=>(s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line",s))(Ve||{}),Ur=(s=>(s.both="both",s.left="left",s.none="none",s.right="right",s))(Ur||{}),Kt=(s=>(s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume",s))(Kt||{}),Ds=(s=>(s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Ds||{}),ge=(s=>(s.styleArrowdown="style_arrowdown",s.styleArrowup="style_arrowup",s.styleCircle="style_circle",s.styleCross="style_cross",s.styleDiamond="style_diamond",s.styleFlag="style_flag",s.styleLabelCenter="style_label_center",s.styleLabelDown="style_label_down",s.styleLabelLeft="style_label_left",s.styleLabelLowerLeft="style_label_lower_left",s.styleLabelLowerRight="style_label_lower_right",s.styleLabelRight="style_label_right",s.styleLabelUp="style_label_up",s.styleLabelUpperLeft="style_label_upper_left",s.styleLabelUpperRight="style_label_upper_right",s.styleNone="style_none",s.styleSquare="style_square",s.styleTextOutline="style_text_outline",s.styleTriangledown="style_triangledown",s.styleTriangleup="style_triangleup",s.styleXcross="style_xcross",s))(ge||{}),Re=(s=>(s.styleArrowBoth="style_arrow_both",s.styleArrowLeft="style_arrow_left",s.styleArrowRight="style_arrow_right",s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Re||{}),an=(s=>(s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top",s))(an||{}),Vn=(s=>(s.ascending="ascending",s.descending="descending",s))(Vn||{}),Mr=(s=>(s.styleArea="Area",s.styleAreabr="Area With Breaks",s.styleCircles="Circles",s.styleColumns="Columns",s.styleCross="Cross",s.styleHistogram="Histogram",s.styleLine="Line",s.styleLinebr="Line With Breaks",s.styleStepline="Step Line",s.styleSteplineDiamond="Step Line With Diamonds",s.styleSteplinebr="Step line with Breaks",s))(Mr||{}),_r=(s=>(s.bottomCenter="bottom_center",s.bottomLeft="bottom_left",s.bottomRight="bottom_right",s.middleCenter="middle_center",s.middleLeft="middle_left",s.middleRight="middle_right",s.topCenter="top_center",s.topLeft="top_left",s.topRight="top_right",s))(_r||{}),bs=(s=>(s.left="left",s.none="none",s.right="right",s))(bs||{}),fi=(s=>(s.extended="extended",s.regular="regular",s))(fi||{}),ur=(s=>(s.arrowdown="arrowdown",s.arrowup="arrowup",s.circle="circle",s.cross="cross",s.diamond="diamond",s.flag="flag",s.labeldown="labeldown",s.labelup="labelup",s.square="square",s.triangledown="triangledown",s.triangleup="triangleup",s.xcross="xcross",s))(ur||{}),rr=(s=>(s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny",s))(rr||{}),Zn=(s=>(s.familyDefault="default",s.familyMonospace="monospace",s))(Zn||{}),Ie=(s=>(s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity",s))(Ie||{}),nr=(s=>(s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent",s))(nr||{}),ue=(s=>(s.all="all",s.long="long",s.short="short",s))(ue||{}),un=(s=>(s.cancel="cancel",s.none="none",s.reduce="reduce",s))(un||{}),Wt=(s=>(s.alignBottom="align_bottom",s.alignCenter="align_center",s.alignLeft="align_left",s.alignRight="align_right",s.alignTop="align_top",s.wrapAuto="wrap_auto",s.wrapNone="wrap_none",s))(Wt||{}),we=(s=>(s.bar_index="bar_index",s.bar_time="bar_time",s))(we||{}),Wr=(s=>(s.abovebar="abovebar",s.belowbar="belowbar",s.price="price",s))(Wr||{}),xs=(s=>(s.actual="actual",s.estimate="estimate",s.standardized="standardized",s))(xs||{}),Kn=(s=>(s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla",s))(Kn||{}),ir=(s=>(s.INT="int",s.BOOL="bool",s.TIME="time",s.COLOR="color",s.FLOAT="float",s.PRICE="price",s.SOURCE="source",s.STRING="string",s.SYMBOL="symbol",s.SESSION="session",s.TEXT_AREA="text_area",s.TIMEFRAME="timeframe",s.ENUM="enum",s))(ir||{}),zt=(s=>(s[s.Hint=1]="Hint",s[s.Info=2]="Info",s[s.Warning=4]="Warning",s[s.Error=8]="Error",s))(zt||{});const le={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.$name方法只能使用$type类型数组!",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"},Yp={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."};Fe.SERIES,Fe.SIMPLE,Fe.INPUT,Fe.CONST,Fe.INT,Fe.FLOAT,Fe.BOOL,Fe.COLOR,Fe.STRING;const Vp=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Zp=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Kp=["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 Gp{constructor(t){$(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new Qt(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 Qt(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 Qt{constructor(t=0,e,r){$(this,"_arrInstance");$(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Xr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Xr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Qt(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Qt(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 Qt(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),Xr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),_t(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),_t(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),_t(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(!_t(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}){_t(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||_t(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,zt.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 i;if(this._arrInstance.length===0){(i=this._errorListener)==null||i.addError(le.arrEmptyErr,t,zt.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(!_t(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){_t(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!==Vn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((i,a)=>a);r.sort((i,a)=>t!==Vn.descending?this._arrInstance[i]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[i]);const n=new Qt(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new Qt(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(le.arrEmptyErr,e,zt.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(le.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>a+((l||0)-r)**2,0),i=n/t.length;return e?i:t.length>1?n/(t.length-1):i}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>{const c=(l||0)-r;return a+c*c},0),i=Math.sqrt(n/t.length);return e?i:t.length>1?Math.sqrt(n/(t.length-1)):i}_standardizeArray(t){const e=t.reduce((i,a)=>i+(a||0),0)/t.length,r=Math.sqrt(t.reduce((i,a)=>i+Math.pow((a||0)-e,2),0)/t.length);return t.map(i=>((i||0)-e)/r)}_getPercentileRank(t,e=0){if(_t(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,l)=>a-l),n=e/100*r.length,i=Math.ceil(n)-1;return r[i>=r.length?r.length-1:i]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||_t(e))return;t.sort(function(i,a){return i-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[i,a]of t.entries()){const l=t[i-1];if(e<(i+.5)/r)return l+(a-l)*(e-(i-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const i of t)e[i]=(e[i]||0)+1,r=Math.max(r,e[i]);for(const i in e)e[i]===r&&n.push(Number(i));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 i=r;i<n;i++)t[i]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(le.arrLengthDiffErr,n,zt.Error);return}t=t.filter(p=>p!==void 0),e=e.filter(p=>p!==void 0);const i=t.reduce((p,h)=>p+h,0)/t.length,a=e.reduce((p,h)=>p+h,0)/e.length;let l=0;for(let p=0;p<t.length;p++)l+=(t[p]-i)*(e[p]-a);return r?l/t.length:l/(t.length-1)}_verifySimpleType(t,e,r,n,i=this._arrInstance){var l;i.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((l=this._errorListener)==null||l.addError(Ye(le.arrTypeErr,{name:e,type:r}),n,zt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const i=Math.floor((r+n)/2);if(t[i]===e)return i;t[i]<e?r=i+1:n=i-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<e?r=a+1:n=a-1}return i.length?Math.min(...i):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<=e?r=a+1:n=a-1}return i.length?Math.max(...i):r}}class Hp{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(!_t(t))return Math.abs(t)}acos({angle:t}){if(_t(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(_t(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(_t(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Xr.mean(e)}ceil({number:t}){if(!_t(t))return Math.ceil(t)}floor({number:t}){if(!_t(t))return Math.floor(t)}cos({angle:t}){if(_t(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(_t(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(_t(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!_t(t))return Math.exp(t)}log({number:t}){if(!_t(t))return Math.log(t)}log10({number:t}){if(!_t(t))return Math.log10(t)}max(t,e){return e=e.filter(r=>!_t(r)),Math.max(...e)}min(t,e){return e=e.filter(r=>!_t(r)),Math.min(...e)}pow({base:t,exponent:e}){if(!(_t(t)||_t(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(_t(t)&&(t=0),_t(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(le.mathRandomErr,n,zt.Error);return}let i;do i=Math.random()*(e-t)+t;while(i===t||i===e);return r&&(this._randomNums[r]=i),i}round({number:t,precision:e}){if(!_t(t))return _t(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!_t(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!_t(t))return t&&Math.sign(t)}sqrt({number:t}){if(!_t(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 i=n.filter(a=>!_t(a));if(!(i.length<e))return Xr.sum(i.slice(-e))}todegrees({radians:t}){if(!_t(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!_t(t))return t*(Math.PI/180)}}function Es(){return Es=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=e[r])}return s},Es.apply(this,arguments)}var Tl={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function de(s){return typeof s=="number"}function Se(s){return!s||typeof s!="object"||typeof s.constructor!="function"?!1:s.isBigNumber===!0&&typeof s.constructor.prototype=="object"&&s.constructor.prototype.isBigNumber===!0||typeof s.constructor.isDecimal=="function"&&s.constructor.isDecimal(s)===!0}function $l(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isComplex===!0||!1}function Ll(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isFraction===!0||!1}function Rl(s){return s&&s.constructor.prototype.isUnit===!0||!1}function tn(s){return typeof s=="string"}var Ee=Array.isArray;function ve(s){return s&&s.constructor.prototype.isMatrix===!0||!1}function Zi(s){return Array.isArray(s)||ve(s)}function Jp(s){return s&&s.isDenseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Xp(s){return s&&s.isSparseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Qp(s){return s&&s.constructor.prototype.isRange===!0||!1}function la(s){return s&&s.constructor.prototype.isIndex===!0||!1}function td(s){return typeof s=="boolean"}function ed(s){return s&&s.constructor.prototype.isResultSet===!0||!1}function rd(s){return s&&s.constructor.prototype.isHelp===!0||!1}function nd(s){return typeof s=="function"}function id(s){return s instanceof Date}function sd(s){return s instanceof RegExp}function ca(s){return!!(s&&typeof s=="object"&&s.constructor===Object&&!$l(s)&&!Ll(s))}function od(s){return s===null}function ad(s){return s===void 0}function ud(s){return s&&s.isAccessorNode===!0&&s.constructor.prototype.isNode===!0||!1}function ld(s){return s&&s.isArrayNode===!0&&s.constructor.prototype.isNode===!0||!1}function cd(s){return s&&s.isAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function fd(s){return s&&s.isBlockNode===!0&&s.constructor.prototype.isNode===!0||!1}function hd(s){return s&&s.isConditionalNode===!0&&s.constructor.prototype.isNode===!0||!1}function pd(s){return s&&s.isConstantNode===!0&&s.constructor.prototype.isNode===!0||!1}function dd(s){return s&&s.isFunctionAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function _d(s){return s&&s.isFunctionNode===!0&&s.constructor.prototype.isNode===!0||!1}function md(s){return s&&s.isIndexNode===!0&&s.constructor.prototype.isNode===!0||!1}function gd(s){return s&&s.isNode===!0&&s.constructor.prototype.isNode===!0||!1}function vd(s){return s&&s.isObjectNode===!0&&s.constructor.prototype.isNode===!0||!1}function yd(s){return s&&s.isOperatorNode===!0&&s.constructor.prototype.isNode===!0||!1}function wd(s){return s&&s.isParenthesisNode===!0&&s.constructor.prototype.isNode===!0||!1}function Dd(s){return s&&s.isRangeNode===!0&&s.constructor.prototype.isNode===!0||!1}function bd(s){return s&&s.isRelationalNode===!0&&s.constructor.prototype.isNode===!0||!1}function xd(s){return s&&s.isSymbolNode===!0&&s.constructor.prototype.isNode===!0||!1}function Ed(s){return s&&s.constructor.prototype.isChain===!0||!1}function En(s){var t=typeof s;return t==="object"?s===null?"null":Se(s)?"BigNumber":s.constructor&&s.constructor.name?s.constructor.name:"Object":t}function se(s){var t=typeof s;if(t==="number"||t==="string"||t==="boolean"||s===null||s===void 0)return s;if(typeof s.clone=="function")return s.clone();if(Array.isArray(s))return s.map(function(e){return se(e)});if(s instanceof Date)return new Date(s.valueOf());if(Se(s))return s;if(ca(s))return Ad(s,se);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(s,")"))}function Ad(s,t){var e={};for(var r in s)Ki(s,r)&&(e[r]=t(s[r]));return e}function Pl(s,t){for(var e in t)Ki(t,e)&&(s[e]=t[e]);return s}function hi(s,t){var e,r,n;if(Array.isArray(s)){if(!Array.isArray(t)||s.length!==t.length)return!1;for(r=0,n=s.length;r<n;r++)if(!hi(s[r],t[r]))return!1;return!0}else{if(typeof s=="function")return s===t;if(s instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in s)if(!(e in t)||!hi(s[e],t[e]))return!1;for(e in t)if(!(e in s))return!1;return!0}else return s===t}}function Ki(s,t){return s&&Object.hasOwnProperty.call(s,t)}function Cd(s,t){for(var e={},r=0;r<t.length;r++){var n=t[r],i=s[n];i!==void 0&&(e[n]=i)}return e}var Fd=["Matrix","Array"],Md=["number","BigNumber","Fraction"],mr=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(Tl)};Es(mr,Tl,{MATRIX_OPTIONS:Fd,NUMBER_OPTIONS:Md});function zl(){return!0}function Nr(){return!1}function pi(){}const ql="Argument is not a typed-function.";function kl(){function s(L){return typeof L=="object"&&L!==null&&L.constructor===Object}const t=[{name:"number",test:function(L){return typeof L=="number"}},{name:"string",test:function(L){return typeof L=="string"}},{name:"boolean",test:function(L){return typeof L=="boolean"}},{name:"Function",test:function(L){return typeof L=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(L){return L instanceof Date}},{name:"RegExp",test:function(L){return L instanceof RegExp}},{name:"Object",test:s},{name:"null",test:function(L){return L===null}},{name:"undefined",test:function(L){return L===void 0}}],e={name:"any",test:zl,isAny:!0};let r,n,i=0,a={createCount:0};function l(L){const V=r.get(L);if(V)return V;let G='Unknown type "'+L+'"';const nt=L.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){G+='. Did you mean "'+st+'" ?';break}throw new TypeError(G)}function c(L){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=V?l(V).index:n.length,nt=[];for(let rt=0;rt<L.length;++rt){if(!L[rt]||typeof L[rt].name!="string"||typeof L[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=L[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:L[rt].test,isAny:L[rt].isAny,index:G+rt,conversionsTo:[]})}const st=n.slice(G);n=n.slice(0,G).concat(nt).concat(st);for(let rt=G+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function h(){r=new Map,n=[],i=0,c([e],!1)}h(),c(t);function p(){let L;for(L of n)r.get(L).conversionsTo=[];i=0}function f(L){const V=n.filter(G=>{const nt=r.get(G);return!nt.isAny&&nt.test(L)});return V.length?V:["any"]}function d(L){return L&&typeof L=="function"&&"_typedFunctionData"in L}function g(L,V,G){if(!d(L))throw new TypeError(ql);const nt=G&&G.exact,st=Array.isArray(V)?V.join(","):V,rt=N(st),ft=w(rt);if(!nt||ft in L.signatures){const Xt=L._typedFunctionData.signatureMap.get(ft);if(Xt)return Xt}const ut=rt.length;let ht;if(nt){ht=[];let Xt;for(Xt in L.signatures)ht.push(L._typedFunctionData.signatureMap.get(Xt))}else ht=L._typedFunctionData.signatures;for(let Xt=0;Xt<ut;++Xt){const ne=rt[Xt],be=[];let We;for(We of ht){const qe=S(We.params,Xt);if(!(!qe||ne.restParam&&!qe.restParam)){if(!qe.hasAny){const wr=b(qe);if(ne.types.some(Dr=>!wr.has(Dr.name)))continue}be.push(We)}}if(ht=be,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+(L.name||"unnamed")+"("+w(rt,", ")+"))")}function y(L,V,G){return g(L,V,G).implementation}function m(L,V){const G=l(V);if(G.test(L))return L;const nt=G.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+V+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test(L))return nt[st].convert(L);throw new Error("Cannot convert "+L+" to "+V)}function w(L){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return L.map(G=>G.name).join(V)}function v(L){const V=L.indexOf("...")===0,nt=(V?L.length>3?L.slice(3):"any":L).split("|").map(ut=>l(ut.trim()));let st=!1,rt=V?"...":"";return{types:nt.map(function(ut){return st=ut.isAny||st,rt+=ut.name+"|",{name:ut.name,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:V}}function x(L){const V=L.types.map(ft=>ft.name),G=K(V);let nt=L.hasAny,st=L.name;const rt=G.map(function(ft){const ut=l(ft.from);return nt=ut.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:ft,conversionIndex:ft.index}});return{types:L.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:L.restParam}}function b(L){return L.typeSet||(L.typeSet=new Set,L.types.forEach(V=>L.typeSet.add(V.name))),L.typeSet}function N(L){const V=[];if(typeof L!="string")throw new TypeError("Signatures must be strings");const G=L.trim();if(G==="")return V;const nt=G.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;V.push(rt)}return V}function E(L){const V=It(L);return V?V.restParam:!1}function C(L){if(!L||L.types.length===0)return zl;if(L.types.length===1)return l(L.types[0].name).test;if(L.types.length===2){const V=l(L.types[0].name).test,G=l(L.types[1].name).test;return function(st){return V(st)||G(st)}}else{const V=L.types.map(function(G){return l(G.name).test});return function(nt){for(let st=0;st<V.length;st++)if(V[st](nt))return!0;return!1}}}function M(L){let V,G,nt;if(E(L)){V=oe(L).map(C);const st=V.length,rt=C(It(L)),ft=function(ut){for(let ht=st;ht<ut.length;ht++)if(!rt(ut[ht]))return!1;return!0};return function(ht){for(let at=0;at<V.length;at++)if(!V[at](ht[at]))return!1;return ft(ht)&&ht.length>=st+1}}else return L.length===0?function(rt){return rt.length===0}:L.length===1?(G=C(L[0]),function(rt){return G(rt[0])&&rt.length===1}):L.length===2?(G=C(L[0]),nt=C(L[1]),function(rt){return G(rt[0])&&nt(rt[1])&&rt.length===2}):(V=L.map(C),function(rt){for(let ft=0;ft<V.length;ft++)if(!V[ft](rt[ft]))return!1;return rt.length===V.length})}function S(L,V){return V<L.length?L[V]:E(L)?It(L):null}function T(L,V){const G=S(L,V);return G?b(G):new Set}function F(L){return L.conversion===null||L.conversion===void 0}function O(L,V){const G=new Set;return L.forEach(nt=>{const st=T(nt.params,V);let rt;for(rt of st)G.add(rt)}),G.has("any")?["any"]:Array.from(G)}function R(L,V,G){let nt,st;const rt=L||"unnamed";let ft=G,ut;for(ut=0;ut<V.length;ut++){const ne=[];if(ft.forEach(be=>{const We=S(be.params,ut),qe=C(We);(ut<be.params.length||E(be.params))&&qe(V[ut])&&ne.push(be)}),ne.length===0){if(st=O(ft,ut),st.length>0){const be=f(V[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+be.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:be,expected:st},nt}}else ft=ne}const ht=ft.map(function(ne){return E(ne.params)?1/0:ne.params.length});if(V.length<Math.min.apply(null,ht))return st=O(ft,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+V.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:V.length,expected:st},nt;const at=Math.max.apply(null,ht);if(V.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+V.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:V.length,expectedLength:at},nt;const Xt=[];for(let ne=0;ne<V.length;++ne)Xt.push(f(V[ne]).join("|"));return nt=new TypeError('Arguments of type "'+Xt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Xt},nt}function U(L){let V=n.length+1;for(let G=0;G<L.types.length;G++)F(L.types[G])&&(V=Math.min(V,L.types[G].typeIndex));return V}function k(L){let V=i+1;for(let G=0;G<L.types.length;G++)F(L.types[G])||(V=Math.min(V,L.types[G].conversionIndex));return V}function W(L,V){if(L.hasAny){if(!V.hasAny)return 1}else if(V.hasAny)return-1;if(L.restParam){if(!V.restParam)return 1}else if(V.restParam)return-1;if(L.hasConversion){if(!V.hasConversion)return 1}else if(V.hasConversion)return-1;const G=U(L)-U(V);if(G<0)return-1;if(G>0)return 1;const nt=k(L)-k(V);return nt<0?-1:nt>0?1:0}function z(L,V){const G=L.params,nt=V.params,st=It(G),rt=It(nt),ft=E(G),ut=E(nt);if(ft&&st.hasAny){if(!ut||!rt.hasAny)return 1}else if(ut&&rt.hasAny)return-1;let ht=0,at=0,Xt;for(Xt of G)Xt.hasAny&&++ht,Xt.hasConversion&&++at;let ne=0,be=0;for(Xt of nt)Xt.hasAny&&++ne,Xt.hasConversion&&++be;if(ht!==ne)return ht-ne;if(ft&&st.hasConversion){if(!ut||!rt.hasConversion)return 1}else if(ut&&rt.hasConversion)return-1;if(at!==be)return at-be;if(ft){if(!ut)return 1}else if(ut)return-1;const We=(G.length-nt.length)*(ft?-1:1);if(We!==0)return We;const qe=[];let wr=0;for(let Tn=0;Tn<G.length;++Tn){const ti=W(G[Tn],nt[Tn]);qe.push(ti),wr+=ti}if(wr!==0)return wr;let Dr;for(Dr of qe)if(Dr!==0)return Dr;return 0}function K(L){if(L.length===0)return[];const V=L.map(l);L.length>1&&V.sort((st,rt)=>st.index-rt.index);let G=V[0].conversionsTo;if(L.length===1)return G;G=G.concat([]);const nt=new Set(L);for(let st=1;st<V.length;++st){let rt;for(rt of V[st].conversionsTo)nt.has(rt.from)||(G.push(rt),nt.add(rt.from))}return G}function Z(L,V){let G=V;if(L.some(st=>st.hasConversion)){const st=E(L),rt=L.map(X);G=function(){const ut=[],ht=st?arguments.length-1:arguments.length;for(let at=0;at<ht;at++)ut[at]=rt[at](arguments[at]);return st&&(ut[ht]=arguments[ht].map(rt[ht])),V.apply(this,ut)}}let nt=G;if(E(L)){const st=L.length-1;nt=function(){return G.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function X(L){let V,G,nt,st;const rt=[],ft=[];switch(L.types.forEach(function(ut){ut.conversion&&(rt.push(l(ut.conversion.from).test),ft.push(ut.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return V=rt[0],nt=ft[0],function(ht){return V(ht)?nt(ht):ht};case 2:return V=rt[0],G=rt[1],nt=ft[0],st=ft[1],function(ht){return V(ht)?nt(ht):G(ht)?st(ht):ht};default:return function(ht){for(let at=0;at<ft.length;at++)if(rt[at](ht))return ft[at](ht);return ht}}}function Q(L){function V(G,nt,st){if(nt<G.length){const rt=G[nt];let ft=[];if(rt.restParam){const ut=rt.types.filter(F);ut.length<rt.types.length&&ft.push({types:ut,name:"..."+ut.map(ht=>ht.name).join("|"),hasAny:ut.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ut){return{types:[ut],name:ut.name,hasAny:ut.isAny,hasConversion:ut.conversion,restParam:!1}});return re(ft,function(ut){return V(G,nt+1,st.concat([ut]))})}else return[st]}return V(L,0,[])}function ct(L,V){const G=Math.max(L.length,V.length);for(let ut=0;ut<G;ut++){const ht=T(L,ut),at=T(V,ut);let Xt=!1,ne;for(ne of at)if(ht.has(ne)){Xt=!0;break}if(!Xt)return!1}const nt=L.length,st=V.length,rt=E(L),ft=E(V);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function vt(L){return L.map(V=>ze(V)?Le(V.referToSelf.callback):vr(V)?Jt(V.referTo.references,V.referTo.callback):V)}function lt(L,V,G){const nt=[];let st;for(st of L){let rt=G[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=V[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function wt(L,V,G){const nt=vt(L),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ut=0;ut<nt.length;++ut){if(st[ut])continue;const ht=nt[ut];if(ze(ht))nt[ut]=ht.referToSelf.callback(G),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ft=!1;else if(vr(ht)){const at=lt(ht.referTo.references,nt,V);at?(nt[ut]=ht.referTo.callback.apply(this,at),nt[ut].referTo=ht.referTo,st[ut]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function bt(L){const V=/\bthis(\(|\.signatures\b)/;Object.keys(L).forEach(G=>{const nt=L[G];if(V.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 Bt(L,V){if(a.createCount++,Object.keys(V).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&bt(V);const G=[],nt=[],st={},rt=[];let ft;for(ft in V){if(!Object.prototype.hasOwnProperty.call(V,ft))continue;const Zt=N(ft);if(!Zt)continue;G.forEach(function($n){if(ct($n,Zt))throw new TypeError('Conflicting signatures "'+w($n)+'" and "'+w(Zt)+'".')}),G.push(Zt);const Qe=nt.length;nt.push(V[ft]);const pu=Zt.map(x);let Bi;for(Bi of Q(pu)){const $n=w(Bi);rt.push({params:Bi,name:$n,fn:Qe}),Bi.every(Do=>!Do.hasConversion)&&(st[$n]=Qe)}}rt.sort(z);const ut=wt(nt,st,ei);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ut[st[ht]]);const at=[],Xt=new Map;for(ht of rt)Xt.has(ht.name)||(ht.fn=ut[ht.fn],at.push(ht),Xt.set(ht.name,ht));const ne=at[0]&&at[0].params.length<=2&&!E(at[0].params),be=at[1]&&at[1].params.length<=2&&!E(at[1].params),We=at[2]&&at[2].params.length<=2&&!E(at[2].params),qe=at[3]&&at[3].params.length<=2&&!E(at[3].params),wr=at[4]&&at[4].params.length<=2&&!E(at[4].params),Dr=at[5]&&at[5].params.length<=2&&!E(at[5].params),Tn=ne&&be&&We&&qe&&wr&&Dr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].test=M(at[Zt].params);const ti=ne?C(at[0].params[0]):Nr,vo=be?C(at[1].params[0]):Nr,Ya=We?C(at[2].params[0]):Nr,Va=qe?C(at[3].params[0]):Nr,Za=wr?C(at[4].params[0]):Nr,Ka=Dr?C(at[5].params[0]):Nr,yo=ne?C(at[0].params[1]):Nr,Ga=be?C(at[1].params[1]):Nr,Ha=We?C(at[2].params[1]):Nr,Ja=qe?C(at[3].params[1]):Nr,rs=wr?C(at[4].params[1]):Nr,Xa=Dr?C(at[5].params[1]):Nr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].implementation=Z(at[Zt].params,at[Zt].fn);const ns=ne?at[0].implementation:pi,Qa=be?at[1].implementation:pi,tu=We?at[2].implementation:pi,eu=qe?at[3].implementation:pi,ru=wr?at[4].implementation:pi,nu=Dr?at[5].implementation:pi,iu=ne?at[0].params.length:-1,su=be?at[1].params.length:-1,ou=We?at[2].params.length:-1,wo=qe?at[3].params.length:-1,au=wr?at[4].params.length:-1,uu=Dr?at[5].params.length:-1,lu=Tn?6:0,cu=at.length,fu=at.map(Zt=>Zt.test),hu=at.map(Zt=>Zt.implementation),Si=function(){for(let Qe=lu;Qe<cu;Qe++)if(fu[Qe](arguments))return hu[Qe].apply(this,arguments);return a.onMismatch(L,arguments,at)};function ei(Zt,Qe){return arguments.length===iu&&ti(Zt)&&yo(Qe)?ns.apply(this,arguments):arguments.length===su&&vo(Zt)&&Ga(Qe)?Qa.apply(this,arguments):arguments.length===ou&&Ya(Zt)&&Ha(Qe)?tu.apply(this,arguments):arguments.length===wo&&Va(Zt)&&Ja(Qe)?eu.apply(this,arguments):arguments.length===au&&Za(Zt)&&rs(Qe)?ru.apply(this,arguments):arguments.length===uu&&Ka(Zt)&&Xa(Qe)?nu.apply(this,arguments):Si.apply(this,arguments)}try{Object.defineProperty(ei,"name",{value:L})}catch{}return ei.signatures=st,ei._typedFunctionData={signatures:at,signatureMap:Xt},ei}function xt(L,V,G){throw R(L,V,G)}function oe(L){return Nt(L,0,L.length-1)}function It(L){return L[L.length-1]}function Nt(L,V,G){return Array.prototype.slice.call(L,V,G)}function ce(L,V){for(let G=0;G<L.length;G++)if(V(L[G]))return L[G]}function re(L,V){return Array.prototype.concat.apply([],L.map(V))}function kt(){const L=oe(arguments).map(G=>w(N(G))),V=It(arguments);if(typeof V!="function")throw new TypeError("Callback function expected as last argument");return Jt(L,V)}function Jt(L,V){return{referTo:{references:L,callback:V}}}function Le(L){if(typeof L!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:L}}}function vr(L){return L&&typeof L.referTo=="object"&&Array.isArray(L.referTo.references)&&typeof L.referTo.callback=="function"}function ze(L){return L&&typeof L.referToSelf=="object"&&typeof L.referToSelf.callback=="function"}function pn(L,V){if(!L)return V;if(V&&V!==L){const G=new Error("Function names do not match (expected: "+L+", actual: "+V+")");throw G.data={actual:V,expected:L},G}return L}function On(L){let V;for(const G in L)Object.prototype.hasOwnProperty.call(L,G)&&(d(L[G])||typeof L[G].signature=="string")&&(V=pn(V,L[G].name));return V}function dn(L,V){let G;for(G in V)if(Object.prototype.hasOwnProperty.call(V,G)){if(G in L&&V[G]!==L[G]){const nt=new Error('Signature "'+G+'" is defined twice');throw nt.data={signature:G,sourceFunction:V[G],destFunction:L[G]},nt}L[G]=V[G]}}const yr=a;a=function(L){const V=typeof L=="string",G=V?1:0;let nt=V?L:"";const st={};for(let rt=G;rt<arguments.length;++rt){const ft=arguments[rt];let ut={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ut[ft.signature]=ft:d(ft)&&(ut=ft.signatures)):s(ft)&&(ut=ft,V||(ht=On(ft))),Object.keys(ut).length===0){const at=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 at.data={index:rt,argument:ft},at}V||(nt=pn(nt,ht)),dn(st,ut)}return Bt(nt||"",st)},a.create=kl,a.createCount=yr.createCount,a.onMismatch=xt,a.throwMismatchError=xt,a.createError=R,a.clear=h,a.clearConversions=p,a.addTypes=c,a._findType=l,a.referTo=kt,a.referToSelf=Le,a.convert=m,a.findSignature=g,a.find=y,a.isTypedFunction=d,a.warnAgainstDeprecatedThis=!0,a.addType=function(L,V){let G="any";V!==!1&&r.has("Object")&&(G="Object"),a.addTypes([L],G)};function In(L){if(!L||typeof L.from!="string"||typeof L.to!="string"||typeof L.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(L.to===L.from)throw new SyntaxError('Illegal to define conversion from "'+L.from+'" to itself.')}return a.addConversion=function(L){In(L);const V=l(L.to);if(V.conversionsTo.every(function(G){return G.from!==L.from}))V.conversionsTo.push({from:L.from,convert:L.convert,index:i++});else throw new Error('There is already a conversion from "'+L.from+'" to "'+V.name+'"')},a.addConversions=function(L){L.forEach(a.addConversion)},a.removeConversion=function(L){In(L);const V=l(L.to),G=ce(V.conversionsTo,st=>st.from===L.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+L.from+" to "+L.to);if(G.convert!==L.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=V.conversionsTo.indexOf(G);V.conversionsTo.splice(nt,1)},a.resolve=function(L,V){if(!d(L))throw new TypeError(ql);const G=L._typedFunctionData.signatures;for(let nt=0;nt<G.length;++nt)if(G[nt].test(V))return G[nt];return null},a}var Ul=kl();function De(s){return typeof s=="boolean"?!0:isFinite(s)?s===Math.round(s):!1}function fa(s,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s>2**(e-1)-1||s<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!De(s))throw new Error("Value must be an integer");s<0&&(s=s+2**e),i="i".concat(e)}var a="";return s<0&&(s=-s,a="-"),"".concat(a).concat(n).concat(s.toString(t)).concat(i)}function ha(s,t){if(typeof t=="function")return t(s);if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if(isNaN(s))return"NaN";var{notation:e,precision:r,wordSize:n}=Wl(t);switch(e){case"fixed":return Sd(s,r);case"exponential":return jl(s,r);case"engineering":return Nd(s,r);case"bin":return fa(s,2,n);case"oct":return fa(s,8,n);case"hex":return fa(s,16,n);case"auto":return Bd(s,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],a=arguments[4];return i!=="."?i+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Wl(s){var t="auto",e,r;if(s!==void 0)if(de(s))e=s;else if(Se(s))e=s.toNumber();else if(ca(s))s.precision!==void 0&&(e=Yl(s.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),s.wordSize!==void 0&&(r=Yl(s.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),s.notation&&(t=s.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function As(s){var t=String(s).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+s);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),i=r.indexOf(".");n+=i!==-1?i-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(l){return n-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function Nd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=Cs(e,t),n=r.exponent,i=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(de(t))for(;t>i.length||n-a+1>i.length;)i.push(0);else for(var l=Math.abs(n-a)-(i.length-1),c=0;c<l;c++)i.push(0);for(var h=Math.abs(n-a),p=1;h>0;)p++,h--;var f=i.slice(p).join(""),d=de(t)&&f.length||f.match(/[1-9]/)?"."+f:"",g=i.slice(0,p).join("")+d+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Sd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=typeof t=="number"?Cs(e,e.exponent+1+t):e,n=r.coefficients,i=r.exponent+1,a=i+(t||0);return n.length<a&&(n=n.concat(di(a-n.length))),i<0&&(n=di(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),r.sign+n.join("")}function jl(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=t?Cs(e,t):e,n=r.coefficients,i=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"+(i>=0?"+":"")+i}function Bd(s,t,e){if(isNaN(s)||!isFinite(s))return String(s);var r=Vl(e==null?void 0:e.lowerExp,-3),n=Vl(e==null?void 0:e.upperExp,5),i=As(s),a=t?Cs(i,t):i;if(a.exponent<r||a.exponent>=n)return jl(s,t);var l=a.coefficients,c=a.exponent;l.length<t&&(l=l.concat(di(t-l.length))),l=l.concat(di(c-l.length+1+(l.length<t?t-l.length:0))),l=di(-c).concat(l);var h=c>0?c:0;return h<l.length-1&&l.splice(h+1,0,"."),a.sign+l.join("")}function Cs(s,t){for(var e={sign:s.sign,coefficients:s.coefficients,exponent:s.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 i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),e.exponent++,i++),i--,r[i]++}}return e}function di(s){for(var t=[],e=0;e<s;e++)t.push(0);return t}function Od(s){return s.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Id=Number.EPSILON||2220446049250313e-31;function Gn(s,t,e){if(e==null)return s===t;if(s===t)return!0;if(isNaN(s)||isNaN(t))return!1;if(isFinite(s)&&isFinite(t)){var r=Math.abs(s-t);return r<=Id?!0:r<=Math.max(Math.abs(s),Math.abs(t))*e}return!1}function Yl(s,t){if(de(s))return s;if(Se(s))return s.toNumber();t()}function Vl(s,t){return de(s)?s:Se(s)?s.toNumber():t}function pa(s,t,e){var r=s.constructor,n=new r(2),i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s.greaterThan(n.pow(e-1).sub(1))||s.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(!s.isInteger())throw new Error("Value must be an integer");s.lessThan(0)&&(s=s.add(n.pow(e))),i="i".concat(e)}switch(t){case 2:return"".concat(s.toBinary()).concat(i);case 8:return"".concat(s.toOctal()).concat(i);case 16:return"".concat(s.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(t," not supported "))}}function Td(s,t){if(typeof t=="function")return t(s);if(!s.isFinite())return s.isNaN()?"NaN":s.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=Wl(t);switch(e){case"fixed":return Ld(s,r);case"exponential":return Zl(s,r);case"engineering":return $d(s,r);case"bin":return pa(s,2,n);case"oct":return pa(s,8,n);case"hex":return pa(s,16,n);case"auto":{var i=Kl(t==null?void 0:t.lowerExp,-3),a=Kl(t==null?void 0:t.upperExp,5);if(s.isZero())return"0";var l,c=s.toSignificantDigits(r),h=c.e;return h>=i&&h<a?l=c.toFixed():l=Zl(s,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var p=arguments[2],f=arguments[4];return p!=="."?p+f:f})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function $d(s,t){var e=s.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=s.mul(Math.pow(10,-r)),i=n.toPrecision(t);if(i.indexOf("e")!==-1){var a=s.constructor;i=new a(i).toFixed()}return i+"e"+(e>=0?"+":"")+r.toString()}function Zl(s,t){return t!==void 0?s.toExponential(t-1):s.toExponential()}function Ld(s,t){return s.toFixed(t)}function Kl(s,t){return de(s)?s:Se(s)?s.toNumber():t}function fe(s,t){var e=Rd(s,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function Rd(s,t){if(typeof s=="number")return ha(s,t);if(Se(s))return Td(s,t);if(Pd(s))return!t||t.fraction!=="decimal"?s.s*s.n+"/"+s.d:s.toString();if(Array.isArray(s))return Jl(s,t);if(tn(s))return Gl(s);if(typeof s=="function")return s.syntax?String(s.syntax):"function";if(s&&typeof s=="object"){if(typeof s.format=="function")return s.format(t);if(s&&s.toString(t)!=={}.toString())return s.toString(t);var e=Object.keys(s).map(r=>Gl(r)+": "+fe(s[r],t));return"{"+e.join(", ")+"}"}return String(s)}function Gl(s){for(var t=String(s),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Hl?Hl[n]:n,r++}return'"'+e+'"'}var Hl={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Jl(s,t){if(Array.isArray(s)){for(var e="[",r=s.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=Jl(s[n],t);return e+="]",e}else return fe(s,t)}function Pd(s){return s&&typeof s=="object"&&typeof s.s=="number"&&typeof s.n=="number"&&typeof s.d=="number"||!1}function Ht(s,t,e){if(!(this instanceof Ht))throw new SyntaxError("Constructor must be called with the new operator");this.actual=s,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(s)?"["+s.join(", ")+"]":s)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Ht.prototype=new RangeError,Ht.prototype.constructor=RangeError,Ht.prototype.name="DimensionError",Ht.prototype.isDimensionError=!0;function An(s,t,e){if(!(this instanceof An))throw new SyntaxError("Constructor must be called with the new operator");this.index=s,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}An.prototype=new RangeError,An.prototype.constructor=RangeError,An.prototype.name="IndexError",An.prototype.isIndexError=!0;function Te(s){for(var t=[];Array.isArray(s);)t.push(s.length),s=s[0];return t}function Xl(s,t,e){var r,n=s.length;if(n!==t[e])throw new Ht(n,t[e]);if(e<t.length-1){var i=e+1;for(r=0;r<n;r++){var a=s[r];if(!Array.isArray(a))throw new Ht(t.length-1,t.length,"<");Xl(s[r],t,i)}}else for(r=0;r<n;r++)if(Array.isArray(s[r]))throw new Ht(t.length+1,t.length,">")}function Ql(s,t){var e=t.length===0;if(e){if(Array.isArray(s))throw new Ht(s.length,0)}else Xl(s,t,0)}function Ae(s,t){if(s!==void 0){if(!de(s)||!De(s))throw new TypeError("Index must be an integer (value: "+s+")");if(s<0||typeof t=="number"&&s>=t)throw new An(s,t)}}function da(s,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(!de(n)||!De(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(t)+")")}),(de(s)||Se(s))&&(s=[s]);var r=e!==void 0?e:0;return _a(s,t,0,r),s}function _a(s,t,e,r){var n,i,a=s.length,l=t[e],c=Math.min(a,l);if(s.length=l,e<t.length-1){var h=e+1;for(n=0;n<c;n++)i=s[n],Array.isArray(i)||(i=[i],s[n]=i),_a(i,t,h,r);for(n=c;n<l;n++)i=[],s[n]=i,_a(i,t,h,r)}else{for(n=0;n<c;n++)for(;Array.isArray(s[n]);)s[n]=s[n][0];for(n=c;n<l;n++)s[n]=r}}function ma(s,t){var e=va(s),r=e.length;if(!Array.isArray(s)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Ht(0,r,"!=");t=ga(t,r);var n=tc(t);if(r!==n)throw new Ht(n,r,"!=");try{return zd(e,t)}catch(i){throw i instanceof Ht?new Ht(n,r,"!="):i}}function ga(s,t){var e=tc(s),r=s.slice(),n=-1,i=s.indexOf(n),a=s.indexOf(n,i+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=i>=0,c=t%e===0;if(l)if(c)r[i]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function tc(s){return s.reduce((t,e)=>t*e,1)}function zd(s,t){for(var e=s,r,n=t.length-1;n>0;n--){var i=t[n];r=[];for(var a=e.length/i,l=0;l<a;l++)r.push(e.slice(l*i,(l+1)*i));e=r}return e}function ec(s,t,e,r){var n=r||Te(s);if(e)for(var i=0;i<e;i++)s=[s],n.unshift(1);for(s=rc(s,t,0);n.length<t;)n.push(1);return s}function rc(s,t,e){var r,n;if(Array.isArray(s)){var i=e+1;for(r=0,n=s.length;r<n;r++)s[r]=rc(s[r],t,i)}else for(var a=e;a<t;a++)s=[s];return s}function va(s){if(!Array.isArray(s))return s;var t=[];return s.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Fs(s,t){for(var e,r=0,n=0;n<s.length;n++){var i=s[n],a=Array.isArray(i);if(n===0&&a&&(r=i.length),a&&i.length!==r)return;var l=a?Fs(i,t):t(i);if(e===void 0)e=l;else if(e!==l)return"mixed"}return e}function nc(s,t,e,r){if(r<e){if(s.length!==t.length)throw new Ht(s.length,t.length);for(var n=[],i=0;i<s.length;i++)n[i]=nc(s[i],t[i],e,r+1);return n}else return s.concat(t)}function ic(){var s=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(s.length===1)return s[0];if(s.length>1)return s.slice(1).reduce(function(e,r){return nc(e,r,t,0)},s[0]);throw new Error("Wrong number of arguments in function concat")}function qd(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];for(var r=t.map(d=>d.length),n=Math.max(...r),i=new Array(n).fill(null),a=0;a<t.length;a++)for(var l=t[a],c=r[a],h=0;h<c;h++){var p=n-c+h;l[h]>i[p]&&(i[p]=l[h])}for(var f=0;f<t.length;f++)Ms(t[f],i);return i}function Ms(s,t){for(var e=t.length,r=s.length,n=0;n<r;n++){var i=e-r+n;if(s[n]<t[i]&&s[n]>1||s[n]>t[i])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(s,") not possible to broadcast dimension ").concat(r," with size ").concat(s[n]," to size ").concat(t[i]))}}function sc(s,t){var e=Te(s);if(hi(e,t))return s;Ms(e,t);var r=qd(e,t),n=r.length,i=[...Array(n-e.length).fill(1),...e],a=Ud(s);e.length<n&&(a=ma(a,i),e=Te(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=kd(a,r[l],l),e=Te(a));return a}function kd(s,t,e){return ic(...Array(t).fill(s),e)}function Ud(s){return Es([],s)}function mt(s,t,e,r){function n(i){var a=Cd(i,t.map(Yd));return Wd(s,t,i),e(a)}return n.isFactory=!0,n.fn=s,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Wd(s,t,e){var r=t.filter(i=>!jd(i)).every(i=>e[i]!==void 0);if(!r){var n=t.filter(i=>e[i]===void 0);throw new Error('Cannot create function "'.concat(s,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function jd(s){return s&&s[0]==="?"}function Yd(s){return s&&s[0]==="?"?s.slice(1):s}function Vd(s,t){if(ac(s)&&oc(s,t))return s[t];throw typeof s[t]=="function"&&Gd(s,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Zd(s,t,e){if(ac(s)&&oc(s,t))return s[t]=e,e;throw new Error('No access to property "'+t+'"')}function Kd(s,t){return t in s}function oc(s,t){return!s||typeof s!="object"?!1:Ki(Hd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Gd(s,t){return s==null||typeof s[t]!="function"||Ki(s,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(s)?!1:Ki(Jd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function ac(s){return typeof s=="object"&&s&&s.constructor===Object}var Hd={length:!0,name:!0},Jd={toString:!0,valueOf:!0,toLocaleString:!0};class Xd{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Vd(this.wrappedObject,t)}set(t,e){return Zd(this.wrappedObject,t,e),this}has(t){return Kd(this.wrappedObject,t)}entries(){return Qd(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 Qd(s,t){return{next:()=>{var e=s.next();return e.done?e:{value:t(e.value),done:!1}}}}function t_(s){return s?s instanceof Map||s instanceof Xd||typeof s.set=="function"&&typeof s.get=="function"&&typeof s.keys=="function"&&typeof s.has=="function":!1}var uc=function(){return uc=Ul.create,Ul},e_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],r_=mt("typed",e_,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:i}=t,a=uc();return a.clear(),a.addTypes([{name:"number",test:de},{name:"Complex",test:$l},{name:"BigNumber",test:Se},{name:"Fraction",test:Ll},{name:"Unit",test:Rl},{name:"identifier",test:l=>tn&&/^(?:[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(l)},{name:"string",test:tn},{name:"Chain",test:Ed},{name:"Array",test:Ee},{name:"Matrix",test:ve},{name:"DenseMatrix",test:Jp},{name:"SparseMatrix",test:Xp},{name:"Range",test:Qp},{name:"Index",test:la},{name:"boolean",test:td},{name:"ResultSet",test:ed},{name:"Help",test:rd},{name:"function",test:nd},{name:"Date",test:id},{name:"RegExp",test:sd},{name:"null",test:od},{name:"undefined",test:ad},{name:"AccessorNode",test:ud},{name:"ArrayNode",test:ld},{name:"AssignmentNode",test:cd},{name:"BlockNode",test:fd},{name:"ConditionalNode",test:hd},{name:"ConstantNode",test:pd},{name:"FunctionNode",test:_d},{name:"FunctionAssignmentNode",test:dd},{name:"IndexNode",test:md},{name:"Node",test:gd},{name:"ObjectNode",test:vd},{name:"OperatorNode",test:yd},{name:"ParenthesisNode",test:wd},{name:"RangeNode",test:Dd},{name:"RelationalNode",test:bd},{name:"SymbolNode",test:xd},{name:"Map",test:t_},{name:"Object",test:ca}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||ya(c),Od(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||Ns(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ns(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||Ns(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){i||wa(c);var h=new i(c);if(h.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 h}},{from:"string",to:"number",convert:function(c){var h=Number(c);if(isNaN(h))throw new Error('Cannot convert "'+c+'" to a number');return h}},{from:"string",to:"BigNumber",convert:function(c){e||ya(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){i||wa(c);try{return new i(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ns(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||ya(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return i||wa(c),new i(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||n_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,h)=>{var p=a.createError(l,c,h);if(["wrongType","mismatch"].includes(p.data.category)&&c.length===1&&Zi(c[0])&&h.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=p.data,f}throw p},a.onMismatch=(l,c,h)=>{var p=a.createError(l,c,h);if(["wrongType","mismatch"].includes(p.data.category)&&c.length===1&&Zi(c[0])&&h.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=p.data,f}throw p},a});function ya(s){throw new Error("Cannot convert value ".concat(s," into a BigNumber: no class 'BigNumber' provided"))}function Ns(s){throw new Error("Cannot convert value ".concat(s," into a Complex number: no class 'Complex' provided"))}function n_(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function wa(s){throw new Error("Cannot convert value ".concat(s," into a Fraction, no class 'Fraction' provided."))}/*!
|
34
|
+
`);return Object.freeze(Tl)};Es(mr,Tl,{MATRIX_OPTIONS:Fd,NUMBER_OPTIONS:Md});function zl(){return!0}function Nr(){return!1}function pi(){}const ql="Argument is not a typed-function.";function kl(){function s(L){return typeof L=="object"&&L!==null&&L.constructor===Object}const t=[{name:"number",test:function(L){return typeof L=="number"}},{name:"string",test:function(L){return typeof L=="string"}},{name:"boolean",test:function(L){return typeof L=="boolean"}},{name:"Function",test:function(L){return typeof L=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(L){return L instanceof Date}},{name:"RegExp",test:function(L){return L instanceof RegExp}},{name:"Object",test:s},{name:"null",test:function(L){return L===null}},{name:"undefined",test:function(L){return L===void 0}}],e={name:"any",test:zl,isAny:!0};let r,n,i=0,a={createCount:0};function l(L){const V=r.get(L);if(V)return V;let G='Unknown type "'+L+'"';const nt=L.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){G+='. Did you mean "'+st+'" ?';break}throw new TypeError(G)}function c(L){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=V?l(V).index:n.length,nt=[];for(let rt=0;rt<L.length;++rt){if(!L[rt]||typeof L[rt].name!="string"||typeof L[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=L[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:L[rt].test,isAny:L[rt].isAny,index:G+rt,conversionsTo:[]})}const st=n.slice(G);n=n.slice(0,G).concat(nt).concat(st);for(let rt=G+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function p(){r=new Map,n=[],i=0,c([e],!1)}p(),c(t);function h(){let L;for(L of n)r.get(L).conversionsTo=[];i=0}function f(L){const V=n.filter(G=>{const nt=r.get(G);return!nt.isAny&&nt.test(L)});return V.length?V:["any"]}function d(L){return L&&typeof L=="function"&&"_typedFunctionData"in L}function g(L,V,G){if(!d(L))throw new TypeError(ql);const nt=G&&G.exact,st=Array.isArray(V)?V.join(","):V,rt=N(st),ft=w(rt);if(!nt||ft in L.signatures){const Xt=L._typedFunctionData.signatureMap.get(ft);if(Xt)return Xt}const ut=rt.length;let ht;if(nt){ht=[];let Xt;for(Xt in L.signatures)ht.push(L._typedFunctionData.signatureMap.get(Xt))}else ht=L._typedFunctionData.signatures;for(let Xt=0;Xt<ut;++Xt){const ne=rt[Xt],be=[];let We;for(We of ht){const qe=S(We.params,Xt);if(!(!qe||ne.restParam&&!qe.restParam)){if(!qe.hasAny){const wr=b(qe);if(ne.types.some(Dr=>!wr.has(Dr.name)))continue}be.push(We)}}if(ht=be,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+(L.name||"unnamed")+"("+w(rt,", ")+"))")}function y(L,V,G){return g(L,V,G).implementation}function m(L,V){const G=l(V);if(G.test(L))return L;const nt=G.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+V+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test(L))return nt[st].convert(L);throw new Error("Cannot convert "+L+" to "+V)}function w(L){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return L.map(G=>G.name).join(V)}function v(L){const V=L.indexOf("...")===0,nt=(V?L.length>3?L.slice(3):"any":L).split("|").map(ut=>l(ut.trim()));let st=!1,rt=V?"...":"";return{types:nt.map(function(ut){return st=ut.isAny||st,rt+=ut.name+"|",{name:ut.name,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:V}}function x(L){const V=L.types.map(ft=>ft.name),G=K(V);let nt=L.hasAny,st=L.name;const rt=G.map(function(ft){const ut=l(ft.from);return nt=ut.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:ft,conversionIndex:ft.index}});return{types:L.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:L.restParam}}function b(L){return L.typeSet||(L.typeSet=new Set,L.types.forEach(V=>L.typeSet.add(V.name))),L.typeSet}function N(L){const V=[];if(typeof L!="string")throw new TypeError("Signatures must be strings");const G=L.trim();if(G==="")return V;const nt=G.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;V.push(rt)}return V}function E(L){const V=It(L);return V?V.restParam:!1}function A(L){if(!L||L.types.length===0)return zl;if(L.types.length===1)return l(L.types[0].name).test;if(L.types.length===2){const V=l(L.types[0].name).test,G=l(L.types[1].name).test;return function(st){return V(st)||G(st)}}else{const V=L.types.map(function(G){return l(G.name).test});return function(nt){for(let st=0;st<V.length;st++)if(V[st](nt))return!0;return!1}}}function M(L){let V,G,nt;if(E(L)){V=oe(L).map(A);const st=V.length,rt=A(It(L)),ft=function(ut){for(let ht=st;ht<ut.length;ht++)if(!rt(ut[ht]))return!1;return!0};return function(ht){for(let at=0;at<V.length;at++)if(!V[at](ht[at]))return!1;return ft(ht)&&ht.length>=st+1}}else return L.length===0?function(rt){return rt.length===0}:L.length===1?(G=A(L[0]),function(rt){return G(rt[0])&&rt.length===1}):L.length===2?(G=A(L[0]),nt=A(L[1]),function(rt){return G(rt[0])&&nt(rt[1])&&rt.length===2}):(V=L.map(A),function(rt){for(let ft=0;ft<V.length;ft++)if(!V[ft](rt[ft]))return!1;return rt.length===V.length})}function S(L,V){return V<L.length?L[V]:E(L)?It(L):null}function T(L,V){const G=S(L,V);return G?b(G):new Set}function F(L){return L.conversion===null||L.conversion===void 0}function O(L,V){const G=new Set;return L.forEach(nt=>{const st=T(nt.params,V);let rt;for(rt of st)G.add(rt)}),G.has("any")?["any"]:Array.from(G)}function R(L,V,G){let nt,st;const rt=L||"unnamed";let ft=G,ut;for(ut=0;ut<V.length;ut++){const ne=[];if(ft.forEach(be=>{const We=S(be.params,ut),qe=A(We);(ut<be.params.length||E(be.params))&&qe(V[ut])&&ne.push(be)}),ne.length===0){if(st=O(ft,ut),st.length>0){const be=f(V[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+be.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:be,expected:st},nt}}else ft=ne}const ht=ft.map(function(ne){return E(ne.params)?1/0:ne.params.length});if(V.length<Math.min.apply(null,ht))return st=O(ft,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+V.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:V.length,expected:st},nt;const at=Math.max.apply(null,ht);if(V.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+V.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:V.length,expectedLength:at},nt;const Xt=[];for(let ne=0;ne<V.length;++ne)Xt.push(f(V[ne]).join("|"));return nt=new TypeError('Arguments of type "'+Xt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Xt},nt}function U(L){let V=n.length+1;for(let G=0;G<L.types.length;G++)F(L.types[G])&&(V=Math.min(V,L.types[G].typeIndex));return V}function k(L){let V=i+1;for(let G=0;G<L.types.length;G++)F(L.types[G])||(V=Math.min(V,L.types[G].conversionIndex));return V}function W(L,V){if(L.hasAny){if(!V.hasAny)return 1}else if(V.hasAny)return-1;if(L.restParam){if(!V.restParam)return 1}else if(V.restParam)return-1;if(L.hasConversion){if(!V.hasConversion)return 1}else if(V.hasConversion)return-1;const G=U(L)-U(V);if(G<0)return-1;if(G>0)return 1;const nt=k(L)-k(V);return nt<0?-1:nt>0?1:0}function z(L,V){const G=L.params,nt=V.params,st=It(G),rt=It(nt),ft=E(G),ut=E(nt);if(ft&&st.hasAny){if(!ut||!rt.hasAny)return 1}else if(ut&&rt.hasAny)return-1;let ht=0,at=0,Xt;for(Xt of G)Xt.hasAny&&++ht,Xt.hasConversion&&++at;let ne=0,be=0;for(Xt of nt)Xt.hasAny&&++ne,Xt.hasConversion&&++be;if(ht!==ne)return ht-ne;if(ft&&st.hasConversion){if(!ut||!rt.hasConversion)return 1}else if(ut&&rt.hasConversion)return-1;if(at!==be)return at-be;if(ft){if(!ut)return 1}else if(ut)return-1;const We=(G.length-nt.length)*(ft?-1:1);if(We!==0)return We;const qe=[];let wr=0;for(let Tn=0;Tn<G.length;++Tn){const ti=W(G[Tn],nt[Tn]);qe.push(ti),wr+=ti}if(wr!==0)return wr;let Dr;for(Dr of qe)if(Dr!==0)return Dr;return 0}function K(L){if(L.length===0)return[];const V=L.map(l);L.length>1&&V.sort((st,rt)=>st.index-rt.index);let G=V[0].conversionsTo;if(L.length===1)return G;G=G.concat([]);const nt=new Set(L);for(let st=1;st<V.length;++st){let rt;for(rt of V[st].conversionsTo)nt.has(rt.from)||(G.push(rt),nt.add(rt.from))}return G}function Z(L,V){let G=V;if(L.some(st=>st.hasConversion)){const st=E(L),rt=L.map(X);G=function(){const ut=[],ht=st?arguments.length-1:arguments.length;for(let at=0;at<ht;at++)ut[at]=rt[at](arguments[at]);return st&&(ut[ht]=arguments[ht].map(rt[ht])),V.apply(this,ut)}}let nt=G;if(E(L)){const st=L.length-1;nt=function(){return G.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function X(L){let V,G,nt,st;const rt=[],ft=[];switch(L.types.forEach(function(ut){ut.conversion&&(rt.push(l(ut.conversion.from).test),ft.push(ut.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return V=rt[0],nt=ft[0],function(ht){return V(ht)?nt(ht):ht};case 2:return V=rt[0],G=rt[1],nt=ft[0],st=ft[1],function(ht){return V(ht)?nt(ht):G(ht)?st(ht):ht};default:return function(ht){for(let at=0;at<ft.length;at++)if(rt[at](ht))return ft[at](ht);return ht}}}function Q(L){function V(G,nt,st){if(nt<G.length){const rt=G[nt];let ft=[];if(rt.restParam){const ut=rt.types.filter(F);ut.length<rt.types.length&&ft.push({types:ut,name:"..."+ut.map(ht=>ht.name).join("|"),hasAny:ut.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ut){return{types:[ut],name:ut.name,hasAny:ut.isAny,hasConversion:ut.conversion,restParam:!1}});return re(ft,function(ut){return V(G,nt+1,st.concat([ut]))})}else return[st]}return V(L,0,[])}function ct(L,V){const G=Math.max(L.length,V.length);for(let ut=0;ut<G;ut++){const ht=T(L,ut),at=T(V,ut);let Xt=!1,ne;for(ne of at)if(ht.has(ne)){Xt=!0;break}if(!Xt)return!1}const nt=L.length,st=V.length,rt=E(L),ft=E(V);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function vt(L){return L.map(V=>ze(V)?Le(V.referToSelf.callback):vr(V)?Jt(V.referTo.references,V.referTo.callback):V)}function lt(L,V,G){const nt=[];let st;for(st of L){let rt=G[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=V[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function wt(L,V,G){const nt=vt(L),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ut=0;ut<nt.length;++ut){if(st[ut])continue;const ht=nt[ut];if(ze(ht))nt[ut]=ht.referToSelf.callback(G),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ft=!1;else if(vr(ht)){const at=lt(ht.referTo.references,nt,V);at?(nt[ut]=ht.referTo.callback.apply(this,at),nt[ut].referTo=ht.referTo,st[ut]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function bt(L){const V=/\bthis(\(|\.signatures\b)/;Object.keys(L).forEach(G=>{const nt=L[G];if(V.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 Bt(L,V){if(a.createCount++,Object.keys(V).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&bt(V);const G=[],nt=[],st={},rt=[];let ft;for(ft in V){if(!Object.prototype.hasOwnProperty.call(V,ft))continue;const Zt=N(ft);if(!Zt)continue;G.forEach(function($n){if(ct($n,Zt))throw new TypeError('Conflicting signatures "'+w($n)+'" and "'+w(Zt)+'".')}),G.push(Zt);const Qe=nt.length;nt.push(V[ft]);const pu=Zt.map(x);let Bi;for(Bi of Q(pu)){const $n=w(Bi);rt.push({params:Bi,name:$n,fn:Qe}),Bi.every(Do=>!Do.hasConversion)&&(st[$n]=Qe)}}rt.sort(z);const ut=wt(nt,st,ei);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ut[st[ht]]);const at=[],Xt=new Map;for(ht of rt)Xt.has(ht.name)||(ht.fn=ut[ht.fn],at.push(ht),Xt.set(ht.name,ht));const ne=at[0]&&at[0].params.length<=2&&!E(at[0].params),be=at[1]&&at[1].params.length<=2&&!E(at[1].params),We=at[2]&&at[2].params.length<=2&&!E(at[2].params),qe=at[3]&&at[3].params.length<=2&&!E(at[3].params),wr=at[4]&&at[4].params.length<=2&&!E(at[4].params),Dr=at[5]&&at[5].params.length<=2&&!E(at[5].params),Tn=ne&&be&&We&&qe&&wr&&Dr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].test=M(at[Zt].params);const ti=ne?A(at[0].params[0]):Nr,vo=be?A(at[1].params[0]):Nr,Ya=We?A(at[2].params[0]):Nr,Va=qe?A(at[3].params[0]):Nr,Za=wr?A(at[4].params[0]):Nr,Ka=Dr?A(at[5].params[0]):Nr,yo=ne?A(at[0].params[1]):Nr,Ga=be?A(at[1].params[1]):Nr,Ha=We?A(at[2].params[1]):Nr,Ja=qe?A(at[3].params[1]):Nr,rs=wr?A(at[4].params[1]):Nr,Xa=Dr?A(at[5].params[1]):Nr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].implementation=Z(at[Zt].params,at[Zt].fn);const ns=ne?at[0].implementation:pi,Qa=be?at[1].implementation:pi,tu=We?at[2].implementation:pi,eu=qe?at[3].implementation:pi,ru=wr?at[4].implementation:pi,nu=Dr?at[5].implementation:pi,iu=ne?at[0].params.length:-1,su=be?at[1].params.length:-1,ou=We?at[2].params.length:-1,wo=qe?at[3].params.length:-1,au=wr?at[4].params.length:-1,uu=Dr?at[5].params.length:-1,lu=Tn?6:0,cu=at.length,fu=at.map(Zt=>Zt.test),hu=at.map(Zt=>Zt.implementation),Si=function(){for(let Qe=lu;Qe<cu;Qe++)if(fu[Qe](arguments))return hu[Qe].apply(this,arguments);return a.onMismatch(L,arguments,at)};function ei(Zt,Qe){return arguments.length===iu&&ti(Zt)&&yo(Qe)?ns.apply(this,arguments):arguments.length===su&&vo(Zt)&&Ga(Qe)?Qa.apply(this,arguments):arguments.length===ou&&Ya(Zt)&&Ha(Qe)?tu.apply(this,arguments):arguments.length===wo&&Va(Zt)&&Ja(Qe)?eu.apply(this,arguments):arguments.length===au&&Za(Zt)&&rs(Qe)?ru.apply(this,arguments):arguments.length===uu&&Ka(Zt)&&Xa(Qe)?nu.apply(this,arguments):Si.apply(this,arguments)}try{Object.defineProperty(ei,"name",{value:L})}catch{}return ei.signatures=st,ei._typedFunctionData={signatures:at,signatureMap:Xt},ei}function xt(L,V,G){throw R(L,V,G)}function oe(L){return Nt(L,0,L.length-1)}function It(L){return L[L.length-1]}function Nt(L,V,G){return Array.prototype.slice.call(L,V,G)}function ce(L,V){for(let G=0;G<L.length;G++)if(V(L[G]))return L[G]}function re(L,V){return Array.prototype.concat.apply([],L.map(V))}function kt(){const L=oe(arguments).map(G=>w(N(G))),V=It(arguments);if(typeof V!="function")throw new TypeError("Callback function expected as last argument");return Jt(L,V)}function Jt(L,V){return{referTo:{references:L,callback:V}}}function Le(L){if(typeof L!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:L}}}function vr(L){return L&&typeof L.referTo=="object"&&Array.isArray(L.referTo.references)&&typeof L.referTo.callback=="function"}function ze(L){return L&&typeof L.referToSelf=="object"&&typeof L.referToSelf.callback=="function"}function pn(L,V){if(!L)return V;if(V&&V!==L){const G=new Error("Function names do not match (expected: "+L+", actual: "+V+")");throw G.data={actual:V,expected:L},G}return L}function On(L){let V;for(const G in L)Object.prototype.hasOwnProperty.call(L,G)&&(d(L[G])||typeof L[G].signature=="string")&&(V=pn(V,L[G].name));return V}function dn(L,V){let G;for(G in V)if(Object.prototype.hasOwnProperty.call(V,G)){if(G in L&&V[G]!==L[G]){const nt=new Error('Signature "'+G+'" is defined twice');throw nt.data={signature:G,sourceFunction:V[G],destFunction:L[G]},nt}L[G]=V[G]}}const yr=a;a=function(L){const V=typeof L=="string",G=V?1:0;let nt=V?L:"";const st={};for(let rt=G;rt<arguments.length;++rt){const ft=arguments[rt];let ut={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ut[ft.signature]=ft:d(ft)&&(ut=ft.signatures)):s(ft)&&(ut=ft,V||(ht=On(ft))),Object.keys(ut).length===0){const at=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 at.data={index:rt,argument:ft},at}V||(nt=pn(nt,ht)),dn(st,ut)}return Bt(nt||"",st)},a.create=kl,a.createCount=yr.createCount,a.onMismatch=xt,a.throwMismatchError=xt,a.createError=R,a.clear=p,a.clearConversions=h,a.addTypes=c,a._findType=l,a.referTo=kt,a.referToSelf=Le,a.convert=m,a.findSignature=g,a.find=y,a.isTypedFunction=d,a.warnAgainstDeprecatedThis=!0,a.addType=function(L,V){let G="any";V!==!1&&r.has("Object")&&(G="Object"),a.addTypes([L],G)};function In(L){if(!L||typeof L.from!="string"||typeof L.to!="string"||typeof L.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(L.to===L.from)throw new SyntaxError('Illegal to define conversion from "'+L.from+'" to itself.')}return a.addConversion=function(L){In(L);const V=l(L.to);if(V.conversionsTo.every(function(G){return G.from!==L.from}))V.conversionsTo.push({from:L.from,convert:L.convert,index:i++});else throw new Error('There is already a conversion from "'+L.from+'" to "'+V.name+'"')},a.addConversions=function(L){L.forEach(a.addConversion)},a.removeConversion=function(L){In(L);const V=l(L.to),G=ce(V.conversionsTo,st=>st.from===L.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+L.from+" to "+L.to);if(G.convert!==L.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=V.conversionsTo.indexOf(G);V.conversionsTo.splice(nt,1)},a.resolve=function(L,V){if(!d(L))throw new TypeError(ql);const G=L._typedFunctionData.signatures;for(let nt=0;nt<G.length;++nt)if(G[nt].test(V))return G[nt];return null},a}var Ul=kl();function De(s){return typeof s=="boolean"?!0:isFinite(s)?s===Math.round(s):!1}function fa(s,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s>2**(e-1)-1||s<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!De(s))throw new Error("Value must be an integer");s<0&&(s=s+2**e),i="i".concat(e)}var a="";return s<0&&(s=-s,a="-"),"".concat(a).concat(n).concat(s.toString(t)).concat(i)}function ha(s,t){if(typeof t=="function")return t(s);if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if(isNaN(s))return"NaN";var{notation:e,precision:r,wordSize:n}=Wl(t);switch(e){case"fixed":return Sd(s,r);case"exponential":return jl(s,r);case"engineering":return Nd(s,r);case"bin":return fa(s,2,n);case"oct":return fa(s,8,n);case"hex":return fa(s,16,n);case"auto":return Bd(s,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],a=arguments[4];return i!=="."?i+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Wl(s){var t="auto",e,r;if(s!==void 0)if(de(s))e=s;else if(Se(s))e=s.toNumber();else if(ca(s))s.precision!==void 0&&(e=Yl(s.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),s.wordSize!==void 0&&(r=Yl(s.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),s.notation&&(t=s.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function As(s){var t=String(s).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+s);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),i=r.indexOf(".");n+=i!==-1?i-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(l){return n-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function Nd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=Cs(e,t),n=r.exponent,i=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(de(t))for(;t>i.length||n-a+1>i.length;)i.push(0);else for(var l=Math.abs(n-a)-(i.length-1),c=0;c<l;c++)i.push(0);for(var p=Math.abs(n-a),h=1;p>0;)h++,p--;var f=i.slice(h).join(""),d=de(t)&&f.length||f.match(/[1-9]/)?"."+f:"",g=i.slice(0,h).join("")+d+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Sd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=typeof t=="number"?Cs(e,e.exponent+1+t):e,n=r.coefficients,i=r.exponent+1,a=i+(t||0);return n.length<a&&(n=n.concat(di(a-n.length))),i<0&&(n=di(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),r.sign+n.join("")}function jl(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=t?Cs(e,t):e,n=r.coefficients,i=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"+(i>=0?"+":"")+i}function Bd(s,t,e){if(isNaN(s)||!isFinite(s))return String(s);var r=Vl(e==null?void 0:e.lowerExp,-3),n=Vl(e==null?void 0:e.upperExp,5),i=As(s),a=t?Cs(i,t):i;if(a.exponent<r||a.exponent>=n)return jl(s,t);var l=a.coefficients,c=a.exponent;l.length<t&&(l=l.concat(di(t-l.length))),l=l.concat(di(c-l.length+1+(l.length<t?t-l.length:0))),l=di(-c).concat(l);var p=c>0?c:0;return p<l.length-1&&l.splice(p+1,0,"."),a.sign+l.join("")}function Cs(s,t){for(var e={sign:s.sign,coefficients:s.coefficients,exponent:s.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 i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),e.exponent++,i++),i--,r[i]++}}return e}function di(s){for(var t=[],e=0;e<s;e++)t.push(0);return t}function Od(s){return s.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Id=Number.EPSILON||2220446049250313e-31;function Gn(s,t,e){if(e==null)return s===t;if(s===t)return!0;if(isNaN(s)||isNaN(t))return!1;if(isFinite(s)&&isFinite(t)){var r=Math.abs(s-t);return r<=Id?!0:r<=Math.max(Math.abs(s),Math.abs(t))*e}return!1}function Yl(s,t){if(de(s))return s;if(Se(s))return s.toNumber();t()}function Vl(s,t){return de(s)?s:Se(s)?s.toNumber():t}function pa(s,t,e){var r=s.constructor,n=new r(2),i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s.greaterThan(n.pow(e-1).sub(1))||s.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(!s.isInteger())throw new Error("Value must be an integer");s.lessThan(0)&&(s=s.add(n.pow(e))),i="i".concat(e)}switch(t){case 2:return"".concat(s.toBinary()).concat(i);case 8:return"".concat(s.toOctal()).concat(i);case 16:return"".concat(s.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(t," not supported "))}}function Td(s,t){if(typeof t=="function")return t(s);if(!s.isFinite())return s.isNaN()?"NaN":s.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=Wl(t);switch(e){case"fixed":return Ld(s,r);case"exponential":return Zl(s,r);case"engineering":return $d(s,r);case"bin":return pa(s,2,n);case"oct":return pa(s,8,n);case"hex":return pa(s,16,n);case"auto":{var i=Kl(t==null?void 0:t.lowerExp,-3),a=Kl(t==null?void 0:t.upperExp,5);if(s.isZero())return"0";var l,c=s.toSignificantDigits(r),p=c.e;return p>=i&&p<a?l=c.toFixed():l=Zl(s,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var h=arguments[2],f=arguments[4];return h!=="."?h+f:f})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function $d(s,t){var e=s.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=s.mul(Math.pow(10,-r)),i=n.toPrecision(t);if(i.indexOf("e")!==-1){var a=s.constructor;i=new a(i).toFixed()}return i+"e"+(e>=0?"+":"")+r.toString()}function Zl(s,t){return t!==void 0?s.toExponential(t-1):s.toExponential()}function Ld(s,t){return s.toFixed(t)}function Kl(s,t){return de(s)?s:Se(s)?s.toNumber():t}function fe(s,t){var e=Rd(s,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function Rd(s,t){if(typeof s=="number")return ha(s,t);if(Se(s))return Td(s,t);if(Pd(s))return!t||t.fraction!=="decimal"?s.s*s.n+"/"+s.d:s.toString();if(Array.isArray(s))return Jl(s,t);if(tn(s))return Gl(s);if(typeof s=="function")return s.syntax?String(s.syntax):"function";if(s&&typeof s=="object"){if(typeof s.format=="function")return s.format(t);if(s&&s.toString(t)!=={}.toString())return s.toString(t);var e=Object.keys(s).map(r=>Gl(r)+": "+fe(s[r],t));return"{"+e.join(", ")+"}"}return String(s)}function Gl(s){for(var t=String(s),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Hl?Hl[n]:n,r++}return'"'+e+'"'}var Hl={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Jl(s,t){if(Array.isArray(s)){for(var e="[",r=s.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=Jl(s[n],t);return e+="]",e}else return fe(s,t)}function Pd(s){return s&&typeof s=="object"&&typeof s.s=="number"&&typeof s.n=="number"&&typeof s.d=="number"||!1}function Ht(s,t,e){if(!(this instanceof Ht))throw new SyntaxError("Constructor must be called with the new operator");this.actual=s,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(s)?"["+s.join(", ")+"]":s)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Ht.prototype=new RangeError,Ht.prototype.constructor=RangeError,Ht.prototype.name="DimensionError",Ht.prototype.isDimensionError=!0;function An(s,t,e){if(!(this instanceof An))throw new SyntaxError("Constructor must be called with the new operator");this.index=s,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}An.prototype=new RangeError,An.prototype.constructor=RangeError,An.prototype.name="IndexError",An.prototype.isIndexError=!0;function Te(s){for(var t=[];Array.isArray(s);)t.push(s.length),s=s[0];return t}function Xl(s,t,e){var r,n=s.length;if(n!==t[e])throw new Ht(n,t[e]);if(e<t.length-1){var i=e+1;for(r=0;r<n;r++){var a=s[r];if(!Array.isArray(a))throw new Ht(t.length-1,t.length,"<");Xl(s[r],t,i)}}else for(r=0;r<n;r++)if(Array.isArray(s[r]))throw new Ht(t.length+1,t.length,">")}function Ql(s,t){var e=t.length===0;if(e){if(Array.isArray(s))throw new Ht(s.length,0)}else Xl(s,t,0)}function Ae(s,t){if(s!==void 0){if(!de(s)||!De(s))throw new TypeError("Index must be an integer (value: "+s+")");if(s<0||typeof t=="number"&&s>=t)throw new An(s,t)}}function da(s,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(!de(n)||!De(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(t)+")")}),(de(s)||Se(s))&&(s=[s]);var r=e!==void 0?e:0;return _a(s,t,0,r),s}function _a(s,t,e,r){var n,i,a=s.length,l=t[e],c=Math.min(a,l);if(s.length=l,e<t.length-1){var p=e+1;for(n=0;n<c;n++)i=s[n],Array.isArray(i)||(i=[i],s[n]=i),_a(i,t,p,r);for(n=c;n<l;n++)i=[],s[n]=i,_a(i,t,p,r)}else{for(n=0;n<c;n++)for(;Array.isArray(s[n]);)s[n]=s[n][0];for(n=c;n<l;n++)s[n]=r}}function ma(s,t){var e=va(s),r=e.length;if(!Array.isArray(s)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Ht(0,r,"!=");t=ga(t,r);var n=tc(t);if(r!==n)throw new Ht(n,r,"!=");try{return zd(e,t)}catch(i){throw i instanceof Ht?new Ht(n,r,"!="):i}}function ga(s,t){var e=tc(s),r=s.slice(),n=-1,i=s.indexOf(n),a=s.indexOf(n,i+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=i>=0,c=t%e===0;if(l)if(c)r[i]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function tc(s){return s.reduce((t,e)=>t*e,1)}function zd(s,t){for(var e=s,r,n=t.length-1;n>0;n--){var i=t[n];r=[];for(var a=e.length/i,l=0;l<a;l++)r.push(e.slice(l*i,(l+1)*i));e=r}return e}function ec(s,t,e,r){var n=r||Te(s);if(e)for(var i=0;i<e;i++)s=[s],n.unshift(1);for(s=rc(s,t,0);n.length<t;)n.push(1);return s}function rc(s,t,e){var r,n;if(Array.isArray(s)){var i=e+1;for(r=0,n=s.length;r<n;r++)s[r]=rc(s[r],t,i)}else for(var a=e;a<t;a++)s=[s];return s}function va(s){if(!Array.isArray(s))return s;var t=[];return s.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Fs(s,t){for(var e,r=0,n=0;n<s.length;n++){var i=s[n],a=Array.isArray(i);if(n===0&&a&&(r=i.length),a&&i.length!==r)return;var l=a?Fs(i,t):t(i);if(e===void 0)e=l;else if(e!==l)return"mixed"}return e}function nc(s,t,e,r){if(r<e){if(s.length!==t.length)throw new Ht(s.length,t.length);for(var n=[],i=0;i<s.length;i++)n[i]=nc(s[i],t[i],e,r+1);return n}else return s.concat(t)}function ic(){var s=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(s.length===1)return s[0];if(s.length>1)return s.slice(1).reduce(function(e,r){return nc(e,r,t,0)},s[0]);throw new Error("Wrong number of arguments in function concat")}function qd(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];for(var r=t.map(d=>d.length),n=Math.max(...r),i=new Array(n).fill(null),a=0;a<t.length;a++)for(var l=t[a],c=r[a],p=0;p<c;p++){var h=n-c+p;l[p]>i[h]&&(i[h]=l[p])}for(var f=0;f<t.length;f++)Ms(t[f],i);return i}function Ms(s,t){for(var e=t.length,r=s.length,n=0;n<r;n++){var i=e-r+n;if(s[n]<t[i]&&s[n]>1||s[n]>t[i])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(s,") not possible to broadcast dimension ").concat(r," with size ").concat(s[n]," to size ").concat(t[i]))}}function sc(s,t){var e=Te(s);if(hi(e,t))return s;Ms(e,t);var r=qd(e,t),n=r.length,i=[...Array(n-e.length).fill(1),...e],a=Ud(s);e.length<n&&(a=ma(a,i),e=Te(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=kd(a,r[l],l),e=Te(a));return a}function kd(s,t,e){return ic(...Array(t).fill(s),e)}function Ud(s){return Es([],s)}function mt(s,t,e,r){function n(i){var a=Cd(i,t.map(Yd));return Wd(s,t,i),e(a)}return n.isFactory=!0,n.fn=s,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Wd(s,t,e){var r=t.filter(i=>!jd(i)).every(i=>e[i]!==void 0);if(!r){var n=t.filter(i=>e[i]===void 0);throw new Error('Cannot create function "'.concat(s,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function jd(s){return s&&s[0]==="?"}function Yd(s){return s&&s[0]==="?"?s.slice(1):s}function Vd(s,t){if(ac(s)&&oc(s,t))return s[t];throw typeof s[t]=="function"&&Gd(s,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Zd(s,t,e){if(ac(s)&&oc(s,t))return s[t]=e,e;throw new Error('No access to property "'+t+'"')}function Kd(s,t){return t in s}function oc(s,t){return!s||typeof s!="object"?!1:Ki(Hd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Gd(s,t){return s==null||typeof s[t]!="function"||Ki(s,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(s)?!1:Ki(Jd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function ac(s){return typeof s=="object"&&s&&s.constructor===Object}var Hd={length:!0,name:!0},Jd={toString:!0,valueOf:!0,toLocaleString:!0};class Xd{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Vd(this.wrappedObject,t)}set(t,e){return Zd(this.wrappedObject,t,e),this}has(t){return Kd(this.wrappedObject,t)}entries(){return Qd(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 Qd(s,t){return{next:()=>{var e=s.next();return e.done?e:{value:t(e.value),done:!1}}}}function t_(s){return s?s instanceof Map||s instanceof Xd||typeof s.set=="function"&&typeof s.get=="function"&&typeof s.keys=="function"&&typeof s.has=="function":!1}var uc=function(){return uc=Ul.create,Ul},e_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],r_=mt("typed",e_,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:i}=t,a=uc();return a.clear(),a.addTypes([{name:"number",test:de},{name:"Complex",test:$l},{name:"BigNumber",test:Se},{name:"Fraction",test:Ll},{name:"Unit",test:Rl},{name:"identifier",test:l=>tn&&/^(?:[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(l)},{name:"string",test:tn},{name:"Chain",test:Ed},{name:"Array",test:Ee},{name:"Matrix",test:ve},{name:"DenseMatrix",test:Jp},{name:"SparseMatrix",test:Xp},{name:"Range",test:Qp},{name:"Index",test:la},{name:"boolean",test:td},{name:"ResultSet",test:ed},{name:"Help",test:rd},{name:"function",test:nd},{name:"Date",test:id},{name:"RegExp",test:sd},{name:"null",test:od},{name:"undefined",test:ad},{name:"AccessorNode",test:ud},{name:"ArrayNode",test:ld},{name:"AssignmentNode",test:cd},{name:"BlockNode",test:fd},{name:"ConditionalNode",test:hd},{name:"ConstantNode",test:pd},{name:"FunctionNode",test:_d},{name:"FunctionAssignmentNode",test:dd},{name:"IndexNode",test:md},{name:"Node",test:gd},{name:"ObjectNode",test:vd},{name:"OperatorNode",test:yd},{name:"ParenthesisNode",test:wd},{name:"RangeNode",test:Dd},{name:"RelationalNode",test:bd},{name:"SymbolNode",test:xd},{name:"Map",test:t_},{name:"Object",test:ca}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||ya(c),Od(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||Ns(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ns(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||Ns(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){i||wa(c);var p=new i(c);if(p.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 p}},{from:"string",to:"number",convert:function(c){var p=Number(c);if(isNaN(p))throw new Error('Cannot convert "'+c+'" to a number');return p}},{from:"string",to:"BigNumber",convert:function(c){e||ya(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){i||wa(c);try{return new i(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ns(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||ya(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return i||wa(c),new i(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||n_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,p)=>{var h=a.createError(l,c,p);if(["wrongType","mismatch"].includes(h.data.category)&&c.length===1&&Zi(c[0])&&p.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=h.data,f}throw h},a.onMismatch=(l,c,p)=>{var h=a.createError(l,c,p);if(["wrongType","mismatch"].includes(h.data.category)&&c.length===1&&Zi(c[0])&&p.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=h.data,f}throw h},a});function ya(s){throw new Error("Cannot convert value ".concat(s," into a BigNumber: no class 'BigNumber' provided"))}function Ns(s){throw new Error("Cannot convert value ".concat(s," into a Complex number: no class 'Complex' provided"))}function n_(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function wa(s){throw new Error("Cannot convert value ".concat(s," 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 _i=9e15,Cn=1e9,Da="0123456789abcdef",Ss="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Bs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ba={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-_i,maxE:_i,crypto:!1},lc,ln,St=!0,Os="[DecimalError] ",Fn=Os+"Invalid argument: ",cc=Os+"Precision limit exceeded",fc=Os+"crypto unavailable",hc="[object Decimal]",Je=Math.floor,Pe=Math.pow,i_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,s_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,o_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,pc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,Et=7,a_=9007199254740991,u_=Ss.length-1,xa=Bs.length-1,it={toStringTag:hc};it.absoluteValue=it.abs=function(){var s=new this.constructor(this);return s.s<0&&(s.s=1),Dt(s)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(s,t){var e,r=this,n=r.constructor;if(s=new n(s),t=new n(t),!s.s||!t.s)return new n(NaN);if(s.gt(t))throw Error(Fn+t);return e=r.cmp(s),e<0?s:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(s){var t,e,r,n,i=this,a=i.d,l=(s=new i.constructor(s)).d,c=i.s,h=s.s;if(!a||!l)return!c||!h?NaN:c!==h?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-h:0;if(c!==h)return c;if(i.e!==s.e)return i.e>s.e^c<0?1:-1;for(r=a.length,n=l.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==l[t])return a[t]>l[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var s,t,e=this,r=e.constructor;return e.d?e.d[0]?(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=l_(r,yc(r,e)),r.precision=s,r.rounding=t,Dt(ln==2||ln==3?e.neg():e,s,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var s,t,e,r,n,i,a,l,c,h,p=this,f=p.constructor;if(!p.isFinite()||p.isZero())return new f(p);for(St=!1,i=p.s*Pe(p.s*p,1/3),!i||Math.abs(i)==1/0?(e=Ze(p.d),s=p.e,(i=(s-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=Pe(e,1/3),s=Je((s+1)/3)-(s%3==(s<0?-1:2)),i==1/0?e="5e"+s:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+s),r=new f(e),r.s=p.s):r=new f(i.toString()),a=(s=f.precision)+3;;)if(l=r,c=l.times(l).times(l),h=c.plus(p),r=he(h.plus(p).times(l),h.plus(c),a+2,1),Ze(l.d).slice(0,a)===(e=Ze(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(l,s+1,0),l.times(l).times(l).eq(p))){r=l;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,s+1,1),t=!r.times(r).times(r).eq(p));break}return St=!0,Dt(r,s,f.rounding,t)},it.decimalPlaces=it.dp=function(){var s,t=this.d,e=NaN;if(t){if(s=t.length-1,e=(s-Je(this.e/Et))*Et,s=t[s],s)for(;s%10==0;s/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(s){return he(this,new this.constructor(s))},it.dividedToIntegerBy=it.divToInt=function(s){var t=this,e=t.constructor;return Dt(he(t,new e(s),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(s){return this.cmp(s)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(s){return this.cmp(s)>0},it.greaterThanOrEqualTo=it.gte=function(s){var t=this.cmp(s);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var s,t,e,r,n,i=this,a=i.constructor,l=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return l;e=a.precision,r=a.rounding,a.precision=e+Math.max(i.e,i.sd())+4,a.rounding=1,n=i.d.length,n<32?(s=Math.ceil(n/3),t=(1/Ls(4,s)).toString()):(s=16,t="2.3283064365386962890625e-10"),i=mi(a,1,i.times(t),new a(1),!0);for(var c,h=s,p=new a(8);h--;)c=i.times(i),i=l.minus(c.times(p.minus(c.times(p))));return Dt(i,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var s,t,e,r,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+4,i.rounding=1,r=n.d.length,r<3)n=mi(i,2,n,n,!0);else{s=1.4*Math.sqrt(r),s=s>16?16:s|0,n=n.times(1/Ls(5,s)),n=mi(i,2,n,n,!0);for(var a,l=new i(5),c=new i(16),h=new i(20);s--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(h))))}return i.precision=t,i.rounding=e,Dt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+7,r.rounding=1,he(e.sinh(),e.cosh(),r.precision=s,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var s,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return r!==-1?r===0?t.isNeg()?Yr(e,n,i):new e(0):new e(NaN):t.isZero()?Yr(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),s=Yr(e,n+4,i).times(.5),e.precision=n,e.rounding=i,s.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var s,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(s=r.precision,t=r.rounding,r.precision=s+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,St=!1,e=e.times(e).minus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var s,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,St=!1,e=e.times(e).plus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var s,t,e,r,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(s=i.precision,t=i.rounding,r=n.sd(),Math.max(r,s)<2*-n.e-1?Dt(new i(n),s,t,!0):(i.precision=e=r-n.e,n=he(n.plus(1),new i(1).minus(n),e+s,1),i.precision=s+4,i.rounding=1,n=n.ln(),i.precision=s,i.rounding=t,n.times(.5))):new i(NaN)},it.inverseSine=it.asin=function(){var s,t,e,r,n=this,i=n.constructor;return n.isZero()?new i(n):(t=n.abs().cmp(1),e=i.precision,r=i.rounding,t!==-1?t===0?(s=Yr(i,e+4,r).times(.5),s.s=n.s,s):new i(NaN):(i.precision=e+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var s,t,e,r,n,i,a,l,c,h=this,p=h.constructor,f=p.precision,d=p.rounding;if(h.isFinite()){if(h.isZero())return new p(h);if(h.abs().eq(1)&&f+4<=xa)return a=Yr(p,f+4,d).times(.25),a.s=h.s,a}else{if(!h.s)return new p(NaN);if(f+4<=xa)return a=Yr(p,f+4,d).times(.5),a.s=h.s,a}for(p.precision=l=f+10,p.rounding=1,e=Math.min(28,l/Et+2|0),s=e;s;--s)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(l/Et),r=1,c=h.times(h),a=new p(h),n=h;s!==-1;)if(n=n.times(c),i=a.minus(n.div(r+=2)),n=n.times(c),a=i.plus(n.div(r+=2)),a.d[t]!==void 0)for(s=t;a.d[s]===i.d[s]&&s--;);return e&&(a=a.times(2<<e-1)),St=!0,Dt(a,p.precision=f,p.rounding=d,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Je(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(s){return this.cmp(s)<0},it.lessThanOrEqualTo=it.lte=function(s){return this.cmp(s)<1},it.logarithm=it.log=function(s){var t,e,r,n,i,a,l,c,h=this,p=h.constructor,f=p.precision,d=p.rounding,g=5;if(s==null)s=new p(10),t=!0;else{if(s=new p(s),e=s.d,s.s<0||!e||!e[0]||s.eq(1))return new p(NaN);t=s.eq(10)}if(e=h.d,h.s<0||!e||!e[0]||h.eq(1))return new p(e&&!e[0]?-1/0:h.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)i=!0;else{for(n=e[0];n%10===0;)n/=10;i=n!==1}if(St=!1,l=f+g,a=Nn(h,l),r=t?$s(p,l+10):Nn(s,l),c=he(a,r,l,1),Gi(c.d,n=f,d))do if(l+=10,a=Nn(h,l),r=t?$s(p,l+10):Nn(s,l),c=he(a,r,l,1),!i){+Ze(c.d).slice(n+1,n+15)+1==1e14&&(c=Dt(c,f+1,0));break}while(Gi(c.d,n+=10,d));return St=!0,Dt(c,f,d)},it.minus=it.sub=function(s){var t,e,r,n,i,a,l,c,h,p,f,d,g=this,y=g.constructor;if(s=new y(s),!g.d||!s.d)return!g.s||!s.s?s=new y(NaN):g.d?s.s=-s.s:s=new y(s.d||g.s!==s.s?g:NaN),s;if(g.s!=s.s)return s.s=-s.s,g.plus(s);if(h=g.d,d=s.d,l=y.precision,c=y.rounding,!h[0]||!d[0]){if(d[0])s.s=-s.s;else if(h[0])s=new y(g);else return new y(c===3?-0:0);return St?Dt(s,l,c):s}if(e=Je(s.e/Et),p=Je(g.e/Et),h=h.slice(),i=p-e,i){for(f=i<0,f?(t=h,i=-i,a=d.length):(t=d,e=p,a=h.length),r=Math.max(Math.ceil(l/Et),a)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=h.length,a=d.length,f=r<a,f&&(a=r),r=0;r<a;r++)if(h[r]!=d[r]){f=h[r]<d[r];break}i=0}for(f&&(t=h,h=d,d=t,s.s=-s.s),a=h.length,r=d.length-a;r>0;--r)h[a++]=0;for(r=d.length;r>i;){if(h[--r]<d[r]){for(n=r;n&&h[--n]===0;)h[n]=jr-1;--h[n],h[r]+=jr}h[r]-=d[r]}for(;h[--a]===0;)h.pop();for(;h[0]===0;h.shift())--e;return h[0]?(s.d=h,s.e=Ts(h,e),St?Dt(s,l,c):s):new y(c===3?-0:0)},it.modulo=it.mod=function(s){var t,e=this,r=e.constructor;return s=new r(s),!e.d||!s.s||s.d&&!s.d[0]?new r(NaN):!s.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(St=!1,r.modulo==9?(t=he(e,s.abs(),0,3,1),t.s*=s.s):t=he(e,s,0,r.modulo,1),t=t.times(s),St=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return Ea(this)},it.naturalLogarithm=it.ln=function(){return Nn(this)},it.negated=it.neg=function(){var s=new this.constructor(this);return s.s=-s.s,Dt(s)},it.plus=it.add=function(s){var t,e,r,n,i,a,l,c,h,p,f=this,d=f.constructor;if(s=new d(s),!f.d||!s.d)return!f.s||!s.s?s=new d(NaN):f.d||(s=new d(s.d||f.s===s.s?f:NaN)),s;if(f.s!=s.s)return s.s=-s.s,f.minus(s);if(h=f.d,p=s.d,l=d.precision,c=d.rounding,!h[0]||!p[0])return p[0]||(s=new d(f)),St?Dt(s,l,c):s;if(i=Je(f.e/Et),r=Je(s.e/Et),h=h.slice(),n=i-r,n){for(n<0?(e=h,n=-n,a=p.length):(e=p,r=i,a=h.length),i=Math.ceil(l/Et),a=i>a?i+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=h.length,n=p.length,a-n<0&&(n=a,e=p,p=h,h=e),t=0;n;)t=(h[--n]=h[n]+p[n]+t)/jr|0,h[n]%=jr;for(t&&(h.unshift(t),++r),a=h.length;h[--a]==0;)h.pop();return s.d=h,s.e=Ts(h,r),St?Dt(s,l,c):s},it.precision=it.sd=function(s){var t,e=this;if(s!==void 0&&s!==!!s&&s!==1&&s!==0)throw Error(Fn+s);return e.d?(t=dc(e.d),s&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var s=this,t=s.constructor;return Dt(new t(s),s.e+1,t.rounding)},it.sine=it.sin=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=f_(r,yc(r,e)),r.precision=s,r.rounding=t,Dt(ln>2?e.neg():e,s,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var s,t,e,r,n,i,a=this,l=a.d,c=a.e,h=a.s,p=a.constructor;if(h!==1||!l||!l[0])return new p(!h||h<0&&(!l||l[0])?NaN:l?a:1/0);for(St=!1,h=Math.sqrt(+a),h==0||h==1/0?(t=Ze(l),(t.length+c)%2==0&&(t+="0"),h=Math.sqrt(t),c=Je((c+1)/2)-(c<0||c%2),h==1/0?t="5e"+c:(t=h.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new p(t)):r=new p(h.toString()),e=(c=p.precision)+3;;)if(i=r,r=i.plus(he(a,i,e+2,1)).times(.5),Ze(i.d).slice(0,e)===(t=Ze(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(i,c+1,0),i.times(i).eq(a))){r=i;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,c+1,1),s=!r.times(r).eq(a));break}return St=!0,Dt(r,c,p.rounding,s)},it.tangent=it.tan=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+10,r.rounding=1,e=e.sin(),e.s=1,e=he(e,new r(1).minus(e.times(e)).sqrt(),s+10,0),r.precision=s,r.rounding=t,Dt(ln==2||ln==4?e.neg():e,s,t,!0)):new r(NaN)},it.times=it.mul=function(s){var t,e,r,n,i,a,l,c,h,p=this,f=p.constructor,d=p.d,g=(s=new f(s)).d;if(s.s*=p.s,!d||!d[0]||!g||!g[0])return new f(!s.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:!d||!g?s.s/0:s.s*0);for(e=Je(p.e/Et)+Je(s.e/Et),c=d.length,h=g.length,c<h&&(i=d,d=g,g=i,a=c,c=h,h=a),i=[],a=c+h,r=a;r--;)i.push(0);for(r=h;--r>=0;){for(t=0,n=c+r;n>r;)l=i[n]+g[r]*d[n-r-1]+t,i[n--]=l%jr|0,t=l/jr|0;i[n]=(i[n]+t)%jr|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),s.d=i,s.e=Ts(i,e),St?Dt(s,f.precision,f.rounding):s},it.toBinary=function(s,t){return Ca(this,2,s,t)},it.toDecimalPlaces=it.toDP=function(s,t){var e=this,r=e.constructor;return e=new r(e),s===void 0?e:(lr(s,0,Cn),t===void 0?t=r.rounding:lr(t,0,8),Dt(e,s+e.e+1,t))},it.toExponential=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,!0):(lr(s,0,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s+1,t),e=en(r,!0,s+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(s,t){var e,r,n=this,i=n.constructor;return s===void 0?e=en(n):(lr(s,0,Cn),t===void 0?t=i.rounding:lr(t,0,8),r=Dt(new i(n),s+n.e+1,t),e=en(r,!1,s+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(s){var t,e,r,n,i,a,l,c,h,p,f,d,g=this,y=g.d,m=g.constructor;if(!y)return new m(g);if(h=e=new m(1),r=c=new m(0),t=new m(r),i=t.e=dc(y)-g.e-1,a=i%Et,t.d[0]=Pe(10,a<0?Et+a:a),s==null)s=i>0?t:h;else{if(l=new m(s),!l.isInt()||l.lt(h))throw Error(Fn+l);s=l.gt(t)?i>0?t:h:l}for(St=!1,l=new m(Ze(y)),p=m.precision,m.precision=i=y.length*Et*2;f=he(l,t,0,1,1),n=e.plus(f.times(r)),n.cmp(s)!=1;)e=r,r=n,n=h,h=c.plus(f.times(n)),c=n,n=t,t=l.minus(f.times(n)),l=n;return n=he(s.minus(e),r,0,1,1),c=c.plus(n.times(h)),e=e.plus(n.times(r)),c.s=h.s=g.s,d=he(h,r,i,1).minus(g).abs().cmp(he(c,e,i,1).minus(g).abs())<1?[h,r]:[c,e],m.precision=p,St=!0,d},it.toHexadecimal=it.toHex=function(s,t){return Ca(this,16,s,t)},it.toNearest=function(s,t){var e=this,r=e.constructor;if(e=new r(e),s==null){if(!e.d)return e;s=new r(1),t=r.rounding}else{if(s=new r(s),t===void 0?t=r.rounding:lr(t,0,8),!e.d)return s.s?e:s;if(!s.d)return s.s&&(s.s=e.s),s}return s.d[0]?(St=!1,e=he(e,s,0,t,1).times(s),St=!0,Dt(e)):(s.s=e.s,e=s),e},it.toNumber=function(){return+this},it.toOctal=function(s,t){return Ca(this,8,s,t)},it.toPower=it.pow=function(s){var t,e,r,n,i,a,l=this,c=l.constructor,h=+(s=new c(s));if(!l.d||!s.d||!l.d[0]||!s.d[0])return new c(Pe(+l,h));if(l=new c(l),l.eq(1))return l;if(r=c.precision,i=c.rounding,s.eq(1))return Dt(l,r,i);if(t=Je(s.e/Et),t>=s.d.length-1&&(e=h<0?-h:h)<=a_)return n=_c(c,l,e,r),s.s<0?new c(1).div(n):Dt(n,r,i);if(a=l.s,a<0){if(t<s.d.length-1)return new c(NaN);if(s.d[t]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return e=Pe(+l,h),t=e==0||!isFinite(e)?Je(h*(Math.log("0."+Ze(l.d))/Math.LN10+l.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(St=!1,c.rounding=l.s=1,e=Math.min(12,(t+"").length),n=Ea(s.times(Nn(l,r+e)),r),n.d&&(n=Dt(n,r+5,1),Gi(n.d,r,i)&&(t=r+10,n=Dt(Ea(s.times(Nn(l,t+e)),t),t+5,1),+Ze(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,St=!0,c.rounding=i,Dt(n,r,i))},it.toPrecision=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(lr(s,1,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s,t),e=en(r,s<=r.e||r.e<=n.toExpNeg,s)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(s,t){var e=this,r=e.constructor;return s===void 0?(s=r.precision,t=r.rounding):(lr(s,1,Cn),t===void 0?t=r.rounding:lr(t,0,8)),Dt(new r(e),s,t)},it.toString=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()&&!s.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()?"-"+e:e};function Ze(s){var t,e,r,n=s.length-1,i="",a=s[0];if(n>0){for(i+=a,t=1;t<n;t++)r=s[t]+"",e=Et-r.length,e&&(i+=Mn(e)),i+=r;a=s[t],r=a+"",e=Et-r.length,e&&(i+=Mn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function lr(s,t,e){if(s!==~~s||s<t||s>e)throw Error(Fn+s)}function Gi(s,t,e,r){var n,i,a,l;for(i=s[0];i>=10;i/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),i=Pe(10,Et-t),l=s[n]%i|0,r==null?t<3?(t==0?l=l/100|0:t==1&&(l=l/10|0),a=e<4&&l==99999||e>3&&l==49999||l==5e4||l==0):a=(e<4&&l+1==i||e>3&&l+1==i/2)&&(s[n+1]/i/100|0)==Pe(10,t-2)-1||(l==i/2||l==0)&&(s[n+1]/i/100|0)==0:t<4?(t==0?l=l/1e3|0:t==1?l=l/100|0:t==2&&(l=l/10|0),a=(r||e<4)&&l==9999||!r&&e>3&&l==4999):a=((r||e<4)&&l+1==i||!r&&e>3&&l+1==i/2)&&(s[n+1]/i/1e3|0)==Pe(10,t-3)-1,a}function Is(s,t,e){for(var r,n=[0],i,a=0,l=s.length;a<l;){for(i=n.length;i--;)n[i]*=t;for(n[0]+=Da.indexOf(s.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 l_(s,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ls(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),s.precision+=e,t=mi(s,1,t.times(n),new s(1));for(var i=e;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return s.precision-=e,t}var he=function(){function s(r,n,i){var a,l=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+l,r[c]=a%i|0,l=a/i|0;return l&&r.unshift(l),r}function t(r,n,i,a){var l,c;if(i!=a)c=i>a?1:-1;else for(l=c=0;l<i;l++)if(r[l]!=n[l]){c=r[l]>n[l]?1:-1;break}return c}function e(r,n,i,a){for(var l=0;i--;)r[i]-=l,l=r[i]<n[i]?1:0,r[i]=l*a+r[i]-n[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,i,a,l,c){var h,p,f,d,g,y,m,w,v,x,b,N,E,C,M,S,T,F,O,R,U=r.constructor,k=r.s==n.s?1:-1,W=r.d,z=n.d;if(!W||!W[0]||!z||!z[0])return new U(!r.s||!n.s||(W?z&&W[0]==z[0]:!z)?NaN:W&&W[0]==0||!z?k*0:k/0);for(c?(g=1,p=r.e-n.e):(c=jr,g=Et,p=Je(r.e/g)-Je(n.e/g)),O=z.length,T=W.length,v=new U(k),x=v.d=[],f=0;z[f]==(W[f]||0);f++);if(z[f]>(W[f]||0)&&p--,i==null?(C=i=U.precision,a=U.rounding):l?C=i+(r.e-n.e)+1:C=i,C<0)x.push(1),y=!0;else{if(C=C/g+2|0,f=0,O==1){for(d=0,z=z[0],C++;(f<T||d)&&C--;f++)M=d*c+(W[f]||0),x[f]=M/z|0,d=M%z|0;y=d||f<T}else{for(d=c/(z[0]+1)|0,d>1&&(z=s(z,d,c),W=s(W,d,c),O=z.length,T=W.length),S=O,b=W.slice(0,O),N=b.length;N<O;)b[N++]=0;R=z.slice(),R.unshift(0),F=z[0],z[1]>=c/2&&++F;do d=0,h=t(z,b,O,N),h<0?(E=b[0],O!=N&&(E=E*c+(b[1]||0)),d=E/F|0,d>1?(d>=c&&(d=c-1),m=s(z,d,c),w=m.length,N=b.length,h=t(m,b,w,N),h==1&&(d--,e(m,O<w?R:z,w,c))):(d==0&&(h=d=1),m=z.slice()),w=m.length,w<N&&m.unshift(0),e(b,m,N,c),h==-1&&(N=b.length,h=t(z,b,O,N),h<1&&(d++,e(b,O<N?R:z,N,c))),N=b.length):h===0&&(d++,b=[0]),x[f++]=d,h&&b[0]?b[N++]=W[S]||0:(b=[W[S]],N=1);while((S++<T||b[0]!==void 0)&&C--);y=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=p,lc=y;else{for(f=1,d=x[0];d>=10;d/=10)f++;v.e=f+p*g-1,Dt(v,l?i+v.e+1:i,a,y)}return v}}();function Dt(s,t,e,r){var n,i,a,l,c,h,p,f,d,g=s.constructor;t:if(t!=null){if(f=s.d,!f)return s;for(n=1,l=f[0];l>=10;l/=10)n++;if(i=t-n,i<0)i+=Et,a=t,p=f[d=0],c=p/Pe(10,n-a-1)%10|0;else if(d=Math.ceil((i+1)/Et),l=f.length,d>=l)if(r){for(;l++<=d;)f.push(0);p=c=0,n=1,i%=Et,a=i-Et+1}else break t;else{for(p=l=f[d],n=1;l>=10;l/=10)n++;i%=Et,a=i-Et+n,c=a<0?0:p/Pe(10,n-a-1)%10|0}if(r=r||t<0||f[d+1]!==void 0||(a<0?p:p%Pe(10,n-a-1)),h=e<4?(c||r)&&(e==0||e==(s.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(i>0?a>0?p/Pe(10,n-a):0:f[d-1])%10&1||e==(s.s<0?8:7)),t<1||!f[0])return f.length=0,h?(t-=s.e+1,f[0]=Pe(10,(Et-t%Et)%Et),s.e=-t||0):f[0]=s.e=0,s;if(i==0?(f.length=d,l=1,d--):(f.length=d+1,l=Pe(10,Et-i),f[d]=a>0?(p/Pe(10,n-a)%Pe(10,a)|0)*l:0),h)for(;;)if(d==0){for(i=1,a=f[0];a>=10;a/=10)i++;for(a=f[0]+=l,l=1;a>=10;a/=10)l++;i!=l&&(s.e++,f[0]==jr&&(f[0]=1));break}else{if(f[d]+=l,f[d]!=jr)break;f[d--]=0,l=1}for(i=f.length;f[--i]===0;)f.pop()}return St&&(s.e>g.maxE?(s.d=null,s.e=NaN):s.e<g.minE&&(s.e=0,s.d=[0])),s}function en(s,t,e){if(!s.isFinite())return vc(s);var r,n=s.e,i=Ze(s.d),a=i.length;return t?(e&&(r=e-a)>0?i=i.charAt(0)+"."+i.slice(1)+Mn(r):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s.e<0?"e":"e+")+s.e):n<0?(i="0."+Mn(-n-1)+i,e&&(r=e-a)>0&&(i+=Mn(r))):n>=a?(i+=Mn(n+1-a),e&&(r=e-n-1)>0&&(i=i+"."+Mn(r))):((r=n+1)<a&&(i=i.slice(0,r)+"."+i.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(i+="."),i+=Mn(r))),i}function Ts(s,t){var e=s[0];for(t*=Et;e>=10;e/=10)t++;return t}function $s(s,t,e){if(t>u_)throw St=!0,e&&(s.precision=e),Error(cc);return Dt(new s(Ss),t,1,!0)}function Yr(s,t,e){if(t>xa)throw Error(cc);return Dt(new s(Bs),t,e,!0)}function dc(s){var t=s.length-1,e=t*Et+1;if(t=s[t],t){for(;t%10==0;t/=10)e--;for(t=s[0];t>=10;t/=10)e++}return e}function Mn(s){for(var t="";s--;)t+="0";return t}function _c(s,t,e,r){var n,i=new s(1),a=Math.ceil(r/Et+4);for(St=!1;;){if(e%2&&(i=i.times(t),wc(i.d,a)&&(n=!0)),e=Je(e/2),e===0){e=i.d.length-1,n&&i.d[e]===0&&++i.d[e];break}t=t.times(t),wc(t.d,a)}return St=!0,i}function mc(s){return s.d[s.d.length-1]&1}function gc(s,t,e){for(var r,n=new s(t[0]),i=0;++i<t.length;)if(r=new s(t[i]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function Ea(s,t){var e,r,n,i,a,l,c,h=0,p=0,f=0,d=s.constructor,g=d.rounding,y=d.precision;if(!s.d||!s.d[0]||s.e>17)return new d(s.d?s.d[0]?s.s<0?0:1/0:1:s.s?s.s<0?0:s:NaN);for(t==null?(St=!1,c=y):c=t,l=new d(.03125);s.e>-2;)s=s.times(l),f+=5;for(r=Math.log(Pe(2,f))/Math.LN10*2+5|0,c+=r,e=i=a=new d(1),d.precision=c;;){if(i=Dt(i.times(s),c,1),e=e.times(++p),l=a.plus(he(i,e,c,1)),Ze(l.d).slice(0,c)===Ze(a.d).slice(0,c)){for(n=f;n--;)a=Dt(a.times(a),c,1);if(t==null)if(h<3&&Gi(a.d,c-r,g,h))d.precision=c+=10,e=i=l=new d(1),p=0,h++;else return Dt(a,d.precision=y,g,St=!0);else return d.precision=y,a}a=l}}function Nn(s,t){var e,r,n,i,a,l,c,h,p,f,d,g=1,y=10,m=s,w=m.d,v=m.constructor,x=v.rounding,b=v.precision;if(m.s<0||!w||!w[0]||!m.e&&w[0]==1&&w.length==1)return new v(w&&!w[0]?-1/0:m.s!=1?NaN:w?0:m);if(t==null?(St=!1,p=b):p=t,v.precision=p+=y,e=Ze(w),r=e.charAt(0),Math.abs(i=m.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)m=m.times(s),e=Ze(m.d),r=e.charAt(0),g++;i=m.e,r>1?(m=new v("0."+e),i++):m=new v(r+"."+e.slice(1))}else return h=$s(v,p+2,b).times(i+""),m=Nn(new v(r+"."+e.slice(1)),p-y).plus(h),v.precision=b,t==null?Dt(m,b,x,St=!0):m;for(f=m,c=a=m=he(m.minus(1),m.plus(1),p,1),d=Dt(m.times(m),p,1),n=3;;){if(a=Dt(a.times(d),p,1),h=c.plus(he(a,new v(n),p,1)),Ze(h.d).slice(0,p)===Ze(c.d).slice(0,p))if(c=c.times(2),i!==0&&(c=c.plus($s(v,p+2,b).times(i+""))),c=he(c,new v(g),p,1),t==null)if(Gi(c.d,p-y,x,l))v.precision=p+=y,h=a=m=he(f.minus(1),f.plus(1),p,1),d=Dt(m.times(m),p,1),n=l=1;else return Dt(c,v.precision=b,x,St=!0);else return v.precision=b,c;c=h,n+=2}}function vc(s){return String(s.s*s.s/0)}function Aa(s,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,s.e=e=e-r-1,s.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&s.d.push(+t.slice(0,r)),n-=Et;r<n;)s.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";s.d.push(+t),St&&(s.e>s.constructor.maxE?(s.d=null,s.e=NaN):s.e<s.constructor.minE&&(s.e=0,s.d=[0]))}else s.e=0,s.d=[0];return s}function c_(s,t){var e,r,n,i,a,l,c,h,p;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),pc.test(t))return Aa(s,t)}else if(t==="Infinity"||t==="NaN")return+t||(s.s=NaN),s.e=NaN,s.d=null,s;if(s_.test(t))e=16,t=t.toLowerCase();else if(i_.test(t))e=2;else if(o_.test(t))e=8;else throw Error(Fn+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),a=i>=0,r=s.constructor,a&&(t=t.replace(".",""),l=t.length,i=l-i,n=_c(r,new r(e),i,i*2)),h=Is(t,e,jr),p=h.length-1,i=p;h[i]===0;--i)h.pop();return i<0?new r(s.s*0):(s.e=Ts(h,p),s.d=h,St=!1,a&&(s=he(s,n,l*4)),c&&(s=s.times(Math.abs(c)<54?Pe(2,c):gi.pow(2,c))),St=!0,s)}function f_(s,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:mi(s,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ls(5,e)),t=mi(s,2,t,t);for(var n,i=new s(5),a=new s(16),l=new s(20);e--;)n=t.times(t),t=t.times(i.plus(n.times(a.times(n).minus(l))));return t}function mi(s,t,e,r,n){var i,a,l,c,h=s.precision,p=Math.ceil(h/Et);for(St=!1,c=e.times(e),l=new s(r);;){if(a=he(l.times(c),new s(t++*t++),h,1),l=n?r.plus(a):r.minus(a),r=he(a.times(c),new s(t++*t++),h,1),a=l.plus(r),a.d[p]!==void 0){for(i=p;a.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=r,r=a,a=i}return St=!0,a.d.length=p+1,a}function Ls(s,t){for(var e=s;--t;)e*=s;return e}function yc(s,t){var e,r=t.s<0,n=Yr(s,s.precision,1),i=n.times(.5);if(t=t.abs(),t.lte(i))return ln=r?4:1,t;if(e=t.divToInt(n),e.isZero())ln=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(i))return ln=mc(e)?r?2:3:r?4:1,t;ln=mc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Ca(s,t,e,r){var n,i,a,l,c,h,p,f,d,g=s.constructor,y=e!==void 0;if(y?(lr(e,1,Cn),r===void 0?r=g.rounding:lr(r,0,8)):(e=g.precision,r=g.rounding),!s.isFinite())p=vc(s);else{for(p=en(s),a=p.indexOf("."),y?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(p=p.replace(".",""),d=new g(1),d.e=p.length-a,d.d=Is(en(d),10,n),d.e=d.d.length),f=Is(p,10,n),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])p=y?"0p+0":"0";else{if(a<0?i--:(s=new g(s),s.d=f,s.e=i,s=he(s,d,e,r,0,n),f=s.d,i=s.e,h=lc),a=f[e],l=n/2,h=h||f[e+1]!==void 0,h=r<4?(a!==void 0||h)&&(r===0||r===(s.s<0?3:2)):a>l||a===l&&(r===4||h||r===6&&f[e-1]&1||r===(s.s<0?8:7)),f.length=e,h)for(;++f[--e]>n-1;)f[e]=0,e||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(a=0,p="";a<c;a++)p+=Da.charAt(f[a]);if(y){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)p+="0";for(f=Is(p,n,t),c=f.length;!f[c-1];--c);for(a=1,p="1.";a<c;a++)p+=Da.charAt(f[a])}else p=p.charAt(0)+"."+p.slice(1);p=p+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)p="0"+p;p="0."+p}else if(++i>c)for(i-=c;i--;)p+="0";else i<c&&(p=p.slice(0,i)+"."+p.slice(i))}p=(t==16?"0x":t==2?"0b":t==8?"0o":"")+p}return s.s<0?"-"+p:p}function wc(s,t){if(s.length>t)return s.length=t,!0}function h_(s){return new this(s).abs()}function p_(s){return new this(s).acos()}function d_(s){return new this(s).acosh()}function __(s,t){return new this(s).plus(t)}function m_(s){return new this(s).asin()}function g_(s){return new this(s).asinh()}function v_(s){return new this(s).atan()}function y_(s){return new this(s).atanh()}function w_(s,t){s=new this(s),t=new this(t);var e,r=this.precision,n=this.rounding,i=r+4;return!s.s||!t.s?e=new this(NaN):!s.d&&!t.d?(e=Yr(this,i,1).times(t.s>0?.25:.75),e.s=s.s):!t.d||s.isZero()?(e=t.s<0?Yr(this,r,n):new this(0),e.s=s.s):!s.d||t.isZero()?(e=Yr(this,i,1).times(.5),e.s=s.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(he(s,t,i,1)),t=Yr(this,i,1),this.precision=r,this.rounding=n,e=s.s<0?e.minus(t):e.plus(t)):e=this.atan(he(s,t,i,1)),e}function D_(s){return new this(s).cbrt()}function b_(s){return Dt(s=new this(s),s.e+1,2)}function x_(s,t,e){return new this(s).clamp(t,e)}function E_(s){if(!s||typeof s!="object")throw Error(Os+"Object expected");var t,e,r,n=s.defaults===!0,i=["precision",1,Cn,"rounding",0,8,"toExpNeg",-_i,0,"toExpPos",0,_i,"maxE",0,_i,"minE",-_i,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(e=i[t],n&&(this[e]=ba[e]),(r=s[e])!==void 0)if(Je(r)===r&&r>=i[t+1]&&r<=i[t+2])this[e]=r;else throw Error(Fn+e+": "+r);if(e="crypto",n&&(this[e]=ba[e]),(r=s[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(fc);else this[e]=!1;else throw Error(Fn+e+": "+r);return this}function A_(s){return new this(s).cos()}function C_(s){return new this(s).cosh()}function Dc(s){var t,e,r;function n(i){var a,l,c,h=this;if(!(h instanceof n))return new n(i);if(h.constructor=n,bc(i)){h.s=i.s,St?!i.d||i.e>n.maxE?(h.e=NaN,h.d=null):i.e<n.minE?(h.e=0,h.d=[0]):(h.e=i.e,h.d=i.d.slice()):(h.e=i.e,h.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){h.s=1/i<0?-1:1,h.e=0,h.d=[0];return}if(i<0?(i=-i,h.s=-1):h.s=1,i===~~i&&i<1e7){for(a=0,l=i;l>=10;l/=10)a++;St?a>n.maxE?(h.e=NaN,h.d=null):a<n.minE?(h.e=0,h.d=[0]):(h.e=a,h.d=[i]):(h.e=a,h.d=[i]);return}else if(i*0!==0){i||(h.s=NaN),h.e=NaN,h.d=null;return}return Aa(h,i.toString())}else if(c!=="string")throw Error(Fn+i);return(l=i.charCodeAt(0))===45?(i=i.slice(1),h.s=-1):(l===43&&(i=i.slice(1)),h.s=1),pc.test(i)?Aa(h,i):c_(h,i)}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=E_,n.clone=Dc,n.isDecimal=bc,n.abs=h_,n.acos=p_,n.acosh=d_,n.add=__,n.asin=m_,n.asinh=g_,n.atan=v_,n.atanh=y_,n.atan2=w_,n.cbrt=D_,n.ceil=b_,n.clamp=x_,n.cos=A_,n.cosh=C_,n.div=F_,n.exp=M_,n.floor=N_,n.hypot=S_,n.ln=B_,n.log=O_,n.log10=T_,n.log2=I_,n.max=$_,n.min=L_,n.mod=R_,n.mul=P_,n.pow=z_,n.random=q_,n.round=k_,n.sign=U_,n.sin=W_,n.sinh=j_,n.sqrt=Y_,n.sub=V_,n.sum=Z_,n.tan=K_,n.tanh=G_,n.trunc=H_,s===void 0&&(s={}),s&&s.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)s.hasOwnProperty(e=r[t++])||(s[e]=this[e]);return n.config(s),n}function F_(s,t){return new this(s).div(t)}function M_(s){return new this(s).exp()}function N_(s){return Dt(s=new this(s),s.e+1,3)}function S_(){var s,t,e=new this(0);for(St=!1,s=0;s<arguments.length;)if(t=new this(arguments[s++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return St=!0,new this(1/0);e=t}return St=!0,e.sqrt()}function bc(s){return s instanceof gi||s&&s.toStringTag===hc||!1}function B_(s){return new this(s).ln()}function O_(s,t){return new this(s).log(t)}function I_(s){return new this(s).log(2)}function T_(s){return new this(s).log(10)}function $_(){return gc(this,arguments,"lt")}function L_(){return gc(this,arguments,"gt")}function R_(s,t){return new this(s).mod(t)}function P_(s,t){return new this(s).mul(t)}function z_(s,t){return new this(s).pow(t)}function q_(s){var t,e,r,n,i=0,a=new this(1),l=[];if(s===void 0?s=this.precision:lr(s,1,Cn),r=Math.ceil(s/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)n=t[i],n>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)n=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,i):(l.push(n%1e7),i+=4);i=r/4}else throw Error(fc);else for(;i<r;)l[i++]=Math.random()*1e7|0;for(r=l[--i],s%=Et,r&&s&&(n=Pe(10,Et-s),l[i]=(r/n|0)*n);l[i]===0;i--)l.pop();if(i<0)e=0,l=[0];else{for(e=-1;l[0]===0;e-=Et)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=l,a}function k_(s){return Dt(s=new this(s),s.e+1,this.rounding)}function U_(s){return s=new this(s),s.d?s.d[0]?s.s:0*s.s:s.s||NaN}function W_(s){return new this(s).sin()}function j_(s){return new this(s).sinh()}function Y_(s){return new this(s).sqrt()}function V_(s,t){return new this(s).sub(t)}function Z_(){var s=0,t=arguments,e=new this(t[s]);for(St=!1;e.s&&++s<t.length;)e=e.plus(t[s]);return St=!0,Dt(e,this.precision,this.rounding)}function K_(s){return new this(s).tan()}function G_(s){return new this(s).tanh()}function H_(s){return Dt(s=new this(s),s.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var gi=it.constructor=Dc(ba);Ss=new gi(Ss),Bs=new gi(Bs);var J_="BigNumber",X_=["?on","config"],Q_=mt(J_,X_,s=>{var{on:t,config:e}=s,r=gi.clone({precision:e.precision,modulo:gi.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,i){n.precision!==i.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),xc={exports:{}};/**
|
40
|
+
*/var _i=9e15,Cn=1e9,Da="0123456789abcdef",Ss="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Bs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ba={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-_i,maxE:_i,crypto:!1},lc,ln,St=!0,Os="[DecimalError] ",Fn=Os+"Invalid argument: ",cc=Os+"Precision limit exceeded",fc=Os+"crypto unavailable",hc="[object Decimal]",Je=Math.floor,Pe=Math.pow,i_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,s_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,o_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,pc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,Et=7,a_=9007199254740991,u_=Ss.length-1,xa=Bs.length-1,it={toStringTag:hc};it.absoluteValue=it.abs=function(){var s=new this.constructor(this);return s.s<0&&(s.s=1),Dt(s)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(s,t){var e,r=this,n=r.constructor;if(s=new n(s),t=new n(t),!s.s||!t.s)return new n(NaN);if(s.gt(t))throw Error(Fn+t);return e=r.cmp(s),e<0?s:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(s){var t,e,r,n,i=this,a=i.d,l=(s=new i.constructor(s)).d,c=i.s,p=s.s;if(!a||!l)return!c||!p?NaN:c!==p?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-p:0;if(c!==p)return c;if(i.e!==s.e)return i.e>s.e^c<0?1:-1;for(r=a.length,n=l.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==l[t])return a[t]>l[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var s,t,e=this,r=e.constructor;return e.d?e.d[0]?(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=l_(r,yc(r,e)),r.precision=s,r.rounding=t,Dt(ln==2||ln==3?e.neg():e,s,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var s,t,e,r,n,i,a,l,c,p,h=this,f=h.constructor;if(!h.isFinite()||h.isZero())return new f(h);for(St=!1,i=h.s*Pe(h.s*h,1/3),!i||Math.abs(i)==1/0?(e=Ze(h.d),s=h.e,(i=(s-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=Pe(e,1/3),s=Je((s+1)/3)-(s%3==(s<0?-1:2)),i==1/0?e="5e"+s:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+s),r=new f(e),r.s=h.s):r=new f(i.toString()),a=(s=f.precision)+3;;)if(l=r,c=l.times(l).times(l),p=c.plus(h),r=he(p.plus(h).times(l),p.plus(c),a+2,1),Ze(l.d).slice(0,a)===(e=Ze(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(l,s+1,0),l.times(l).times(l).eq(h))){r=l;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,s+1,1),t=!r.times(r).times(r).eq(h));break}return St=!0,Dt(r,s,f.rounding,t)},it.decimalPlaces=it.dp=function(){var s,t=this.d,e=NaN;if(t){if(s=t.length-1,e=(s-Je(this.e/Et))*Et,s=t[s],s)for(;s%10==0;s/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(s){return he(this,new this.constructor(s))},it.dividedToIntegerBy=it.divToInt=function(s){var t=this,e=t.constructor;return Dt(he(t,new e(s),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(s){return this.cmp(s)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(s){return this.cmp(s)>0},it.greaterThanOrEqualTo=it.gte=function(s){var t=this.cmp(s);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var s,t,e,r,n,i=this,a=i.constructor,l=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return l;e=a.precision,r=a.rounding,a.precision=e+Math.max(i.e,i.sd())+4,a.rounding=1,n=i.d.length,n<32?(s=Math.ceil(n/3),t=(1/Ls(4,s)).toString()):(s=16,t="2.3283064365386962890625e-10"),i=mi(a,1,i.times(t),new a(1),!0);for(var c,p=s,h=new a(8);p--;)c=i.times(i),i=l.minus(c.times(h.minus(c.times(h))));return Dt(i,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var s,t,e,r,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+4,i.rounding=1,r=n.d.length,r<3)n=mi(i,2,n,n,!0);else{s=1.4*Math.sqrt(r),s=s>16?16:s|0,n=n.times(1/Ls(5,s)),n=mi(i,2,n,n,!0);for(var a,l=new i(5),c=new i(16),p=new i(20);s--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(p))))}return i.precision=t,i.rounding=e,Dt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+7,r.rounding=1,he(e.sinh(),e.cosh(),r.precision=s,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var s,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return r!==-1?r===0?t.isNeg()?Yr(e,n,i):new e(0):new e(NaN):t.isZero()?Yr(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),s=Yr(e,n+4,i).times(.5),e.precision=n,e.rounding=i,s.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var s,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(s=r.precision,t=r.rounding,r.precision=s+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,St=!1,e=e.times(e).minus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var s,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,St=!1,e=e.times(e).plus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var s,t,e,r,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(s=i.precision,t=i.rounding,r=n.sd(),Math.max(r,s)<2*-n.e-1?Dt(new i(n),s,t,!0):(i.precision=e=r-n.e,n=he(n.plus(1),new i(1).minus(n),e+s,1),i.precision=s+4,i.rounding=1,n=n.ln(),i.precision=s,i.rounding=t,n.times(.5))):new i(NaN)},it.inverseSine=it.asin=function(){var s,t,e,r,n=this,i=n.constructor;return n.isZero()?new i(n):(t=n.abs().cmp(1),e=i.precision,r=i.rounding,t!==-1?t===0?(s=Yr(i,e+4,r).times(.5),s.s=n.s,s):new i(NaN):(i.precision=e+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var s,t,e,r,n,i,a,l,c,p=this,h=p.constructor,f=h.precision,d=h.rounding;if(p.isFinite()){if(p.isZero())return new h(p);if(p.abs().eq(1)&&f+4<=xa)return a=Yr(h,f+4,d).times(.25),a.s=p.s,a}else{if(!p.s)return new h(NaN);if(f+4<=xa)return a=Yr(h,f+4,d).times(.5),a.s=p.s,a}for(h.precision=l=f+10,h.rounding=1,e=Math.min(28,l/Et+2|0),s=e;s;--s)p=p.div(p.times(p).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(l/Et),r=1,c=p.times(p),a=new h(p),n=p;s!==-1;)if(n=n.times(c),i=a.minus(n.div(r+=2)),n=n.times(c),a=i.plus(n.div(r+=2)),a.d[t]!==void 0)for(s=t;a.d[s]===i.d[s]&&s--;);return e&&(a=a.times(2<<e-1)),St=!0,Dt(a,h.precision=f,h.rounding=d,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Je(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(s){return this.cmp(s)<0},it.lessThanOrEqualTo=it.lte=function(s){return this.cmp(s)<1},it.logarithm=it.log=function(s){var t,e,r,n,i,a,l,c,p=this,h=p.constructor,f=h.precision,d=h.rounding,g=5;if(s==null)s=new h(10),t=!0;else{if(s=new h(s),e=s.d,s.s<0||!e||!e[0]||s.eq(1))return new h(NaN);t=s.eq(10)}if(e=p.d,p.s<0||!e||!e[0]||p.eq(1))return new h(e&&!e[0]?-1/0:p.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)i=!0;else{for(n=e[0];n%10===0;)n/=10;i=n!==1}if(St=!1,l=f+g,a=Nn(p,l),r=t?$s(h,l+10):Nn(s,l),c=he(a,r,l,1),Gi(c.d,n=f,d))do if(l+=10,a=Nn(p,l),r=t?$s(h,l+10):Nn(s,l),c=he(a,r,l,1),!i){+Ze(c.d).slice(n+1,n+15)+1==1e14&&(c=Dt(c,f+1,0));break}while(Gi(c.d,n+=10,d));return St=!0,Dt(c,f,d)},it.minus=it.sub=function(s){var t,e,r,n,i,a,l,c,p,h,f,d,g=this,y=g.constructor;if(s=new y(s),!g.d||!s.d)return!g.s||!s.s?s=new y(NaN):g.d?s.s=-s.s:s=new y(s.d||g.s!==s.s?g:NaN),s;if(g.s!=s.s)return s.s=-s.s,g.plus(s);if(p=g.d,d=s.d,l=y.precision,c=y.rounding,!p[0]||!d[0]){if(d[0])s.s=-s.s;else if(p[0])s=new y(g);else return new y(c===3?-0:0);return St?Dt(s,l,c):s}if(e=Je(s.e/Et),h=Je(g.e/Et),p=p.slice(),i=h-e,i){for(f=i<0,f?(t=p,i=-i,a=d.length):(t=d,e=h,a=p.length),r=Math.max(Math.ceil(l/Et),a)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=p.length,a=d.length,f=r<a,f&&(a=r),r=0;r<a;r++)if(p[r]!=d[r]){f=p[r]<d[r];break}i=0}for(f&&(t=p,p=d,d=t,s.s=-s.s),a=p.length,r=d.length-a;r>0;--r)p[a++]=0;for(r=d.length;r>i;){if(p[--r]<d[r]){for(n=r;n&&p[--n]===0;)p[n]=jr-1;--p[n],p[r]+=jr}p[r]-=d[r]}for(;p[--a]===0;)p.pop();for(;p[0]===0;p.shift())--e;return p[0]?(s.d=p,s.e=Ts(p,e),St?Dt(s,l,c):s):new y(c===3?-0:0)},it.modulo=it.mod=function(s){var t,e=this,r=e.constructor;return s=new r(s),!e.d||!s.s||s.d&&!s.d[0]?new r(NaN):!s.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(St=!1,r.modulo==9?(t=he(e,s.abs(),0,3,1),t.s*=s.s):t=he(e,s,0,r.modulo,1),t=t.times(s),St=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return Ea(this)},it.naturalLogarithm=it.ln=function(){return Nn(this)},it.negated=it.neg=function(){var s=new this.constructor(this);return s.s=-s.s,Dt(s)},it.plus=it.add=function(s){var t,e,r,n,i,a,l,c,p,h,f=this,d=f.constructor;if(s=new d(s),!f.d||!s.d)return!f.s||!s.s?s=new d(NaN):f.d||(s=new d(s.d||f.s===s.s?f:NaN)),s;if(f.s!=s.s)return s.s=-s.s,f.minus(s);if(p=f.d,h=s.d,l=d.precision,c=d.rounding,!p[0]||!h[0])return h[0]||(s=new d(f)),St?Dt(s,l,c):s;if(i=Je(f.e/Et),r=Je(s.e/Et),p=p.slice(),n=i-r,n){for(n<0?(e=p,n=-n,a=h.length):(e=h,r=i,a=p.length),i=Math.ceil(l/Et),a=i>a?i+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=p.length,n=h.length,a-n<0&&(n=a,e=h,h=p,p=e),t=0;n;)t=(p[--n]=p[n]+h[n]+t)/jr|0,p[n]%=jr;for(t&&(p.unshift(t),++r),a=p.length;p[--a]==0;)p.pop();return s.d=p,s.e=Ts(p,r),St?Dt(s,l,c):s},it.precision=it.sd=function(s){var t,e=this;if(s!==void 0&&s!==!!s&&s!==1&&s!==0)throw Error(Fn+s);return e.d?(t=dc(e.d),s&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var s=this,t=s.constructor;return Dt(new t(s),s.e+1,t.rounding)},it.sine=it.sin=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=f_(r,yc(r,e)),r.precision=s,r.rounding=t,Dt(ln>2?e.neg():e,s,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var s,t,e,r,n,i,a=this,l=a.d,c=a.e,p=a.s,h=a.constructor;if(p!==1||!l||!l[0])return new h(!p||p<0&&(!l||l[0])?NaN:l?a:1/0);for(St=!1,p=Math.sqrt(+a),p==0||p==1/0?(t=Ze(l),(t.length+c)%2==0&&(t+="0"),p=Math.sqrt(t),c=Je((c+1)/2)-(c<0||c%2),p==1/0?t="5e"+c:(t=p.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new h(t)):r=new h(p.toString()),e=(c=h.precision)+3;;)if(i=r,r=i.plus(he(a,i,e+2,1)).times(.5),Ze(i.d).slice(0,e)===(t=Ze(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(i,c+1,0),i.times(i).eq(a))){r=i;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,c+1,1),s=!r.times(r).eq(a));break}return St=!0,Dt(r,c,h.rounding,s)},it.tangent=it.tan=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+10,r.rounding=1,e=e.sin(),e.s=1,e=he(e,new r(1).minus(e.times(e)).sqrt(),s+10,0),r.precision=s,r.rounding=t,Dt(ln==2||ln==4?e.neg():e,s,t,!0)):new r(NaN)},it.times=it.mul=function(s){var t,e,r,n,i,a,l,c,p,h=this,f=h.constructor,d=h.d,g=(s=new f(s)).d;if(s.s*=h.s,!d||!d[0]||!g||!g[0])return new f(!s.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:!d||!g?s.s/0:s.s*0);for(e=Je(h.e/Et)+Je(s.e/Et),c=d.length,p=g.length,c<p&&(i=d,d=g,g=i,a=c,c=p,p=a),i=[],a=c+p,r=a;r--;)i.push(0);for(r=p;--r>=0;){for(t=0,n=c+r;n>r;)l=i[n]+g[r]*d[n-r-1]+t,i[n--]=l%jr|0,t=l/jr|0;i[n]=(i[n]+t)%jr|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),s.d=i,s.e=Ts(i,e),St?Dt(s,f.precision,f.rounding):s},it.toBinary=function(s,t){return Ca(this,2,s,t)},it.toDecimalPlaces=it.toDP=function(s,t){var e=this,r=e.constructor;return e=new r(e),s===void 0?e:(lr(s,0,Cn),t===void 0?t=r.rounding:lr(t,0,8),Dt(e,s+e.e+1,t))},it.toExponential=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,!0):(lr(s,0,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s+1,t),e=en(r,!0,s+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(s,t){var e,r,n=this,i=n.constructor;return s===void 0?e=en(n):(lr(s,0,Cn),t===void 0?t=i.rounding:lr(t,0,8),r=Dt(new i(n),s+n.e+1,t),e=en(r,!1,s+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(s){var t,e,r,n,i,a,l,c,p,h,f,d,g=this,y=g.d,m=g.constructor;if(!y)return new m(g);if(p=e=new m(1),r=c=new m(0),t=new m(r),i=t.e=dc(y)-g.e-1,a=i%Et,t.d[0]=Pe(10,a<0?Et+a:a),s==null)s=i>0?t:p;else{if(l=new m(s),!l.isInt()||l.lt(p))throw Error(Fn+l);s=l.gt(t)?i>0?t:p:l}for(St=!1,l=new m(Ze(y)),h=m.precision,m.precision=i=y.length*Et*2;f=he(l,t,0,1,1),n=e.plus(f.times(r)),n.cmp(s)!=1;)e=r,r=n,n=p,p=c.plus(f.times(n)),c=n,n=t,t=l.minus(f.times(n)),l=n;return n=he(s.minus(e),r,0,1,1),c=c.plus(n.times(p)),e=e.plus(n.times(r)),c.s=p.s=g.s,d=he(p,r,i,1).minus(g).abs().cmp(he(c,e,i,1).minus(g).abs())<1?[p,r]:[c,e],m.precision=h,St=!0,d},it.toHexadecimal=it.toHex=function(s,t){return Ca(this,16,s,t)},it.toNearest=function(s,t){var e=this,r=e.constructor;if(e=new r(e),s==null){if(!e.d)return e;s=new r(1),t=r.rounding}else{if(s=new r(s),t===void 0?t=r.rounding:lr(t,0,8),!e.d)return s.s?e:s;if(!s.d)return s.s&&(s.s=e.s),s}return s.d[0]?(St=!1,e=he(e,s,0,t,1).times(s),St=!0,Dt(e)):(s.s=e.s,e=s),e},it.toNumber=function(){return+this},it.toOctal=function(s,t){return Ca(this,8,s,t)},it.toPower=it.pow=function(s){var t,e,r,n,i,a,l=this,c=l.constructor,p=+(s=new c(s));if(!l.d||!s.d||!l.d[0]||!s.d[0])return new c(Pe(+l,p));if(l=new c(l),l.eq(1))return l;if(r=c.precision,i=c.rounding,s.eq(1))return Dt(l,r,i);if(t=Je(s.e/Et),t>=s.d.length-1&&(e=p<0?-p:p)<=a_)return n=_c(c,l,e,r),s.s<0?new c(1).div(n):Dt(n,r,i);if(a=l.s,a<0){if(t<s.d.length-1)return new c(NaN);if(s.d[t]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return e=Pe(+l,p),t=e==0||!isFinite(e)?Je(p*(Math.log("0."+Ze(l.d))/Math.LN10+l.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(St=!1,c.rounding=l.s=1,e=Math.min(12,(t+"").length),n=Ea(s.times(Nn(l,r+e)),r),n.d&&(n=Dt(n,r+5,1),Gi(n.d,r,i)&&(t=r+10,n=Dt(Ea(s.times(Nn(l,t+e)),t),t+5,1),+Ze(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,St=!0,c.rounding=i,Dt(n,r,i))},it.toPrecision=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(lr(s,1,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s,t),e=en(r,s<=r.e||r.e<=n.toExpNeg,s)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(s,t){var e=this,r=e.constructor;return s===void 0?(s=r.precision,t=r.rounding):(lr(s,1,Cn),t===void 0?t=r.rounding:lr(t,0,8)),Dt(new r(e),s,t)},it.toString=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()&&!s.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()?"-"+e:e};function Ze(s){var t,e,r,n=s.length-1,i="",a=s[0];if(n>0){for(i+=a,t=1;t<n;t++)r=s[t]+"",e=Et-r.length,e&&(i+=Mn(e)),i+=r;a=s[t],r=a+"",e=Et-r.length,e&&(i+=Mn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function lr(s,t,e){if(s!==~~s||s<t||s>e)throw Error(Fn+s)}function Gi(s,t,e,r){var n,i,a,l;for(i=s[0];i>=10;i/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),i=Pe(10,Et-t),l=s[n]%i|0,r==null?t<3?(t==0?l=l/100|0:t==1&&(l=l/10|0),a=e<4&&l==99999||e>3&&l==49999||l==5e4||l==0):a=(e<4&&l+1==i||e>3&&l+1==i/2)&&(s[n+1]/i/100|0)==Pe(10,t-2)-1||(l==i/2||l==0)&&(s[n+1]/i/100|0)==0:t<4?(t==0?l=l/1e3|0:t==1?l=l/100|0:t==2&&(l=l/10|0),a=(r||e<4)&&l==9999||!r&&e>3&&l==4999):a=((r||e<4)&&l+1==i||!r&&e>3&&l+1==i/2)&&(s[n+1]/i/1e3|0)==Pe(10,t-3)-1,a}function Is(s,t,e){for(var r,n=[0],i,a=0,l=s.length;a<l;){for(i=n.length;i--;)n[i]*=t;for(n[0]+=Da.indexOf(s.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 l_(s,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ls(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),s.precision+=e,t=mi(s,1,t.times(n),new s(1));for(var i=e;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return s.precision-=e,t}var he=function(){function s(r,n,i){var a,l=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+l,r[c]=a%i|0,l=a/i|0;return l&&r.unshift(l),r}function t(r,n,i,a){var l,c;if(i!=a)c=i>a?1:-1;else for(l=c=0;l<i;l++)if(r[l]!=n[l]){c=r[l]>n[l]?1:-1;break}return c}function e(r,n,i,a){for(var l=0;i--;)r[i]-=l,l=r[i]<n[i]?1:0,r[i]=l*a+r[i]-n[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,i,a,l,c){var p,h,f,d,g,y,m,w,v,x,b,N,E,A,M,S,T,F,O,R,U=r.constructor,k=r.s==n.s?1:-1,W=r.d,z=n.d;if(!W||!W[0]||!z||!z[0])return new U(!r.s||!n.s||(W?z&&W[0]==z[0]:!z)?NaN:W&&W[0]==0||!z?k*0:k/0);for(c?(g=1,h=r.e-n.e):(c=jr,g=Et,h=Je(r.e/g)-Je(n.e/g)),O=z.length,T=W.length,v=new U(k),x=v.d=[],f=0;z[f]==(W[f]||0);f++);if(z[f]>(W[f]||0)&&h--,i==null?(A=i=U.precision,a=U.rounding):l?A=i+(r.e-n.e)+1:A=i,A<0)x.push(1),y=!0;else{if(A=A/g+2|0,f=0,O==1){for(d=0,z=z[0],A++;(f<T||d)&&A--;f++)M=d*c+(W[f]||0),x[f]=M/z|0,d=M%z|0;y=d||f<T}else{for(d=c/(z[0]+1)|0,d>1&&(z=s(z,d,c),W=s(W,d,c),O=z.length,T=W.length),S=O,b=W.slice(0,O),N=b.length;N<O;)b[N++]=0;R=z.slice(),R.unshift(0),F=z[0],z[1]>=c/2&&++F;do d=0,p=t(z,b,O,N),p<0?(E=b[0],O!=N&&(E=E*c+(b[1]||0)),d=E/F|0,d>1?(d>=c&&(d=c-1),m=s(z,d,c),w=m.length,N=b.length,p=t(m,b,w,N),p==1&&(d--,e(m,O<w?R:z,w,c))):(d==0&&(p=d=1),m=z.slice()),w=m.length,w<N&&m.unshift(0),e(b,m,N,c),p==-1&&(N=b.length,p=t(z,b,O,N),p<1&&(d++,e(b,O<N?R:z,N,c))),N=b.length):p===0&&(d++,b=[0]),x[f++]=d,p&&b[0]?b[N++]=W[S]||0:(b=[W[S]],N=1);while((S++<T||b[0]!==void 0)&&A--);y=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=h,lc=y;else{for(f=1,d=x[0];d>=10;d/=10)f++;v.e=f+h*g-1,Dt(v,l?i+v.e+1:i,a,y)}return v}}();function Dt(s,t,e,r){var n,i,a,l,c,p,h,f,d,g=s.constructor;t:if(t!=null){if(f=s.d,!f)return s;for(n=1,l=f[0];l>=10;l/=10)n++;if(i=t-n,i<0)i+=Et,a=t,h=f[d=0],c=h/Pe(10,n-a-1)%10|0;else if(d=Math.ceil((i+1)/Et),l=f.length,d>=l)if(r){for(;l++<=d;)f.push(0);h=c=0,n=1,i%=Et,a=i-Et+1}else break t;else{for(h=l=f[d],n=1;l>=10;l/=10)n++;i%=Et,a=i-Et+n,c=a<0?0:h/Pe(10,n-a-1)%10|0}if(r=r||t<0||f[d+1]!==void 0||(a<0?h:h%Pe(10,n-a-1)),p=e<4?(c||r)&&(e==0||e==(s.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(i>0?a>0?h/Pe(10,n-a):0:f[d-1])%10&1||e==(s.s<0?8:7)),t<1||!f[0])return f.length=0,p?(t-=s.e+1,f[0]=Pe(10,(Et-t%Et)%Et),s.e=-t||0):f[0]=s.e=0,s;if(i==0?(f.length=d,l=1,d--):(f.length=d+1,l=Pe(10,Et-i),f[d]=a>0?(h/Pe(10,n-a)%Pe(10,a)|0)*l:0),p)for(;;)if(d==0){for(i=1,a=f[0];a>=10;a/=10)i++;for(a=f[0]+=l,l=1;a>=10;a/=10)l++;i!=l&&(s.e++,f[0]==jr&&(f[0]=1));break}else{if(f[d]+=l,f[d]!=jr)break;f[d--]=0,l=1}for(i=f.length;f[--i]===0;)f.pop()}return St&&(s.e>g.maxE?(s.d=null,s.e=NaN):s.e<g.minE&&(s.e=0,s.d=[0])),s}function en(s,t,e){if(!s.isFinite())return vc(s);var r,n=s.e,i=Ze(s.d),a=i.length;return t?(e&&(r=e-a)>0?i=i.charAt(0)+"."+i.slice(1)+Mn(r):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s.e<0?"e":"e+")+s.e):n<0?(i="0."+Mn(-n-1)+i,e&&(r=e-a)>0&&(i+=Mn(r))):n>=a?(i+=Mn(n+1-a),e&&(r=e-n-1)>0&&(i=i+"."+Mn(r))):((r=n+1)<a&&(i=i.slice(0,r)+"."+i.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(i+="."),i+=Mn(r))),i}function Ts(s,t){var e=s[0];for(t*=Et;e>=10;e/=10)t++;return t}function $s(s,t,e){if(t>u_)throw St=!0,e&&(s.precision=e),Error(cc);return Dt(new s(Ss),t,1,!0)}function Yr(s,t,e){if(t>xa)throw Error(cc);return Dt(new s(Bs),t,e,!0)}function dc(s){var t=s.length-1,e=t*Et+1;if(t=s[t],t){for(;t%10==0;t/=10)e--;for(t=s[0];t>=10;t/=10)e++}return e}function Mn(s){for(var t="";s--;)t+="0";return t}function _c(s,t,e,r){var n,i=new s(1),a=Math.ceil(r/Et+4);for(St=!1;;){if(e%2&&(i=i.times(t),wc(i.d,a)&&(n=!0)),e=Je(e/2),e===0){e=i.d.length-1,n&&i.d[e]===0&&++i.d[e];break}t=t.times(t),wc(t.d,a)}return St=!0,i}function mc(s){return s.d[s.d.length-1]&1}function gc(s,t,e){for(var r,n=new s(t[0]),i=0;++i<t.length;)if(r=new s(t[i]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function Ea(s,t){var e,r,n,i,a,l,c,p=0,h=0,f=0,d=s.constructor,g=d.rounding,y=d.precision;if(!s.d||!s.d[0]||s.e>17)return new d(s.d?s.d[0]?s.s<0?0:1/0:1:s.s?s.s<0?0:s:NaN);for(t==null?(St=!1,c=y):c=t,l=new d(.03125);s.e>-2;)s=s.times(l),f+=5;for(r=Math.log(Pe(2,f))/Math.LN10*2+5|0,c+=r,e=i=a=new d(1),d.precision=c;;){if(i=Dt(i.times(s),c,1),e=e.times(++h),l=a.plus(he(i,e,c,1)),Ze(l.d).slice(0,c)===Ze(a.d).slice(0,c)){for(n=f;n--;)a=Dt(a.times(a),c,1);if(t==null)if(p<3&&Gi(a.d,c-r,g,p))d.precision=c+=10,e=i=l=new d(1),h=0,p++;else return Dt(a,d.precision=y,g,St=!0);else return d.precision=y,a}a=l}}function Nn(s,t){var e,r,n,i,a,l,c,p,h,f,d,g=1,y=10,m=s,w=m.d,v=m.constructor,x=v.rounding,b=v.precision;if(m.s<0||!w||!w[0]||!m.e&&w[0]==1&&w.length==1)return new v(w&&!w[0]?-1/0:m.s!=1?NaN:w?0:m);if(t==null?(St=!1,h=b):h=t,v.precision=h+=y,e=Ze(w),r=e.charAt(0),Math.abs(i=m.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)m=m.times(s),e=Ze(m.d),r=e.charAt(0),g++;i=m.e,r>1?(m=new v("0."+e),i++):m=new v(r+"."+e.slice(1))}else return p=$s(v,h+2,b).times(i+""),m=Nn(new v(r+"."+e.slice(1)),h-y).plus(p),v.precision=b,t==null?Dt(m,b,x,St=!0):m;for(f=m,c=a=m=he(m.minus(1),m.plus(1),h,1),d=Dt(m.times(m),h,1),n=3;;){if(a=Dt(a.times(d),h,1),p=c.plus(he(a,new v(n),h,1)),Ze(p.d).slice(0,h)===Ze(c.d).slice(0,h))if(c=c.times(2),i!==0&&(c=c.plus($s(v,h+2,b).times(i+""))),c=he(c,new v(g),h,1),t==null)if(Gi(c.d,h-y,x,l))v.precision=h+=y,p=a=m=he(f.minus(1),f.plus(1),h,1),d=Dt(m.times(m),h,1),n=l=1;else return Dt(c,v.precision=b,x,St=!0);else return v.precision=b,c;c=p,n+=2}}function vc(s){return String(s.s*s.s/0)}function Aa(s,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,s.e=e=e-r-1,s.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&s.d.push(+t.slice(0,r)),n-=Et;r<n;)s.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";s.d.push(+t),St&&(s.e>s.constructor.maxE?(s.d=null,s.e=NaN):s.e<s.constructor.minE&&(s.e=0,s.d=[0]))}else s.e=0,s.d=[0];return s}function c_(s,t){var e,r,n,i,a,l,c,p,h;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),pc.test(t))return Aa(s,t)}else if(t==="Infinity"||t==="NaN")return+t||(s.s=NaN),s.e=NaN,s.d=null,s;if(s_.test(t))e=16,t=t.toLowerCase();else if(i_.test(t))e=2;else if(o_.test(t))e=8;else throw Error(Fn+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),a=i>=0,r=s.constructor,a&&(t=t.replace(".",""),l=t.length,i=l-i,n=_c(r,new r(e),i,i*2)),p=Is(t,e,jr),h=p.length-1,i=h;p[i]===0;--i)p.pop();return i<0?new r(s.s*0):(s.e=Ts(p,h),s.d=p,St=!1,a&&(s=he(s,n,l*4)),c&&(s=s.times(Math.abs(c)<54?Pe(2,c):gi.pow(2,c))),St=!0,s)}function f_(s,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:mi(s,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ls(5,e)),t=mi(s,2,t,t);for(var n,i=new s(5),a=new s(16),l=new s(20);e--;)n=t.times(t),t=t.times(i.plus(n.times(a.times(n).minus(l))));return t}function mi(s,t,e,r,n){var i,a,l,c,p=s.precision,h=Math.ceil(p/Et);for(St=!1,c=e.times(e),l=new s(r);;){if(a=he(l.times(c),new s(t++*t++),p,1),l=n?r.plus(a):r.minus(a),r=he(a.times(c),new s(t++*t++),p,1),a=l.plus(r),a.d[h]!==void 0){for(i=h;a.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=r,r=a,a=i}return St=!0,a.d.length=h+1,a}function Ls(s,t){for(var e=s;--t;)e*=s;return e}function yc(s,t){var e,r=t.s<0,n=Yr(s,s.precision,1),i=n.times(.5);if(t=t.abs(),t.lte(i))return ln=r?4:1,t;if(e=t.divToInt(n),e.isZero())ln=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(i))return ln=mc(e)?r?2:3:r?4:1,t;ln=mc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Ca(s,t,e,r){var n,i,a,l,c,p,h,f,d,g=s.constructor,y=e!==void 0;if(y?(lr(e,1,Cn),r===void 0?r=g.rounding:lr(r,0,8)):(e=g.precision,r=g.rounding),!s.isFinite())h=vc(s);else{for(h=en(s),a=h.indexOf("."),y?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(h=h.replace(".",""),d=new g(1),d.e=h.length-a,d.d=Is(en(d),10,n),d.e=d.d.length),f=Is(h,10,n),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])h=y?"0p+0":"0";else{if(a<0?i--:(s=new g(s),s.d=f,s.e=i,s=he(s,d,e,r,0,n),f=s.d,i=s.e,p=lc),a=f[e],l=n/2,p=p||f[e+1]!==void 0,p=r<4?(a!==void 0||p)&&(r===0||r===(s.s<0?3:2)):a>l||a===l&&(r===4||p||r===6&&f[e-1]&1||r===(s.s<0?8:7)),f.length=e,p)for(;++f[--e]>n-1;)f[e]=0,e||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(a=0,h="";a<c;a++)h+=Da.charAt(f[a]);if(y){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)h+="0";for(f=Is(h,n,t),c=f.length;!f[c-1];--c);for(a=1,h="1.";a<c;a++)h+=Da.charAt(f[a])}else h=h.charAt(0)+"."+h.slice(1);h=h+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)h="0"+h;h="0."+h}else if(++i>c)for(i-=c;i--;)h+="0";else i<c&&(h=h.slice(0,i)+"."+h.slice(i))}h=(t==16?"0x":t==2?"0b":t==8?"0o":"")+h}return s.s<0?"-"+h:h}function wc(s,t){if(s.length>t)return s.length=t,!0}function h_(s){return new this(s).abs()}function p_(s){return new this(s).acos()}function d_(s){return new this(s).acosh()}function __(s,t){return new this(s).plus(t)}function m_(s){return new this(s).asin()}function g_(s){return new this(s).asinh()}function v_(s){return new this(s).atan()}function y_(s){return new this(s).atanh()}function w_(s,t){s=new this(s),t=new this(t);var e,r=this.precision,n=this.rounding,i=r+4;return!s.s||!t.s?e=new this(NaN):!s.d&&!t.d?(e=Yr(this,i,1).times(t.s>0?.25:.75),e.s=s.s):!t.d||s.isZero()?(e=t.s<0?Yr(this,r,n):new this(0),e.s=s.s):!s.d||t.isZero()?(e=Yr(this,i,1).times(.5),e.s=s.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(he(s,t,i,1)),t=Yr(this,i,1),this.precision=r,this.rounding=n,e=s.s<0?e.minus(t):e.plus(t)):e=this.atan(he(s,t,i,1)),e}function D_(s){return new this(s).cbrt()}function b_(s){return Dt(s=new this(s),s.e+1,2)}function x_(s,t,e){return new this(s).clamp(t,e)}function E_(s){if(!s||typeof s!="object")throw Error(Os+"Object expected");var t,e,r,n=s.defaults===!0,i=["precision",1,Cn,"rounding",0,8,"toExpNeg",-_i,0,"toExpPos",0,_i,"maxE",0,_i,"minE",-_i,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(e=i[t],n&&(this[e]=ba[e]),(r=s[e])!==void 0)if(Je(r)===r&&r>=i[t+1]&&r<=i[t+2])this[e]=r;else throw Error(Fn+e+": "+r);if(e="crypto",n&&(this[e]=ba[e]),(r=s[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(fc);else this[e]=!1;else throw Error(Fn+e+": "+r);return this}function A_(s){return new this(s).cos()}function C_(s){return new this(s).cosh()}function Dc(s){var t,e,r;function n(i){var a,l,c,p=this;if(!(p instanceof n))return new n(i);if(p.constructor=n,bc(i)){p.s=i.s,St?!i.d||i.e>n.maxE?(p.e=NaN,p.d=null):i.e<n.minE?(p.e=0,p.d=[0]):(p.e=i.e,p.d=i.d.slice()):(p.e=i.e,p.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){p.s=1/i<0?-1:1,p.e=0,p.d=[0];return}if(i<0?(i=-i,p.s=-1):p.s=1,i===~~i&&i<1e7){for(a=0,l=i;l>=10;l/=10)a++;St?a>n.maxE?(p.e=NaN,p.d=null):a<n.minE?(p.e=0,p.d=[0]):(p.e=a,p.d=[i]):(p.e=a,p.d=[i]);return}else if(i*0!==0){i||(p.s=NaN),p.e=NaN,p.d=null;return}return Aa(p,i.toString())}else if(c!=="string")throw Error(Fn+i);return(l=i.charCodeAt(0))===45?(i=i.slice(1),p.s=-1):(l===43&&(i=i.slice(1)),p.s=1),pc.test(i)?Aa(p,i):c_(p,i)}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=E_,n.clone=Dc,n.isDecimal=bc,n.abs=h_,n.acos=p_,n.acosh=d_,n.add=__,n.asin=m_,n.asinh=g_,n.atan=v_,n.atanh=y_,n.atan2=w_,n.cbrt=D_,n.ceil=b_,n.clamp=x_,n.cos=A_,n.cosh=C_,n.div=F_,n.exp=M_,n.floor=N_,n.hypot=S_,n.ln=B_,n.log=O_,n.log10=T_,n.log2=I_,n.max=$_,n.min=L_,n.mod=R_,n.mul=P_,n.pow=z_,n.random=q_,n.round=k_,n.sign=U_,n.sin=W_,n.sinh=j_,n.sqrt=Y_,n.sub=V_,n.sum=Z_,n.tan=K_,n.tanh=G_,n.trunc=H_,s===void 0&&(s={}),s&&s.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)s.hasOwnProperty(e=r[t++])||(s[e]=this[e]);return n.config(s),n}function F_(s,t){return new this(s).div(t)}function M_(s){return new this(s).exp()}function N_(s){return Dt(s=new this(s),s.e+1,3)}function S_(){var s,t,e=new this(0);for(St=!1,s=0;s<arguments.length;)if(t=new this(arguments[s++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return St=!0,new this(1/0);e=t}return St=!0,e.sqrt()}function bc(s){return s instanceof gi||s&&s.toStringTag===hc||!1}function B_(s){return new this(s).ln()}function O_(s,t){return new this(s).log(t)}function I_(s){return new this(s).log(2)}function T_(s){return new this(s).log(10)}function $_(){return gc(this,arguments,"lt")}function L_(){return gc(this,arguments,"gt")}function R_(s,t){return new this(s).mod(t)}function P_(s,t){return new this(s).mul(t)}function z_(s,t){return new this(s).pow(t)}function q_(s){var t,e,r,n,i=0,a=new this(1),l=[];if(s===void 0?s=this.precision:lr(s,1,Cn),r=Math.ceil(s/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)n=t[i],n>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)n=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,i):(l.push(n%1e7),i+=4);i=r/4}else throw Error(fc);else for(;i<r;)l[i++]=Math.random()*1e7|0;for(r=l[--i],s%=Et,r&&s&&(n=Pe(10,Et-s),l[i]=(r/n|0)*n);l[i]===0;i--)l.pop();if(i<0)e=0,l=[0];else{for(e=-1;l[0]===0;e-=Et)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=l,a}function k_(s){return Dt(s=new this(s),s.e+1,this.rounding)}function U_(s){return s=new this(s),s.d?s.d[0]?s.s:0*s.s:s.s||NaN}function W_(s){return new this(s).sin()}function j_(s){return new this(s).sinh()}function Y_(s){return new this(s).sqrt()}function V_(s,t){return new this(s).sub(t)}function Z_(){var s=0,t=arguments,e=new this(t[s]);for(St=!1;e.s&&++s<t.length;)e=e.plus(t[s]);return St=!0,Dt(e,this.precision,this.rounding)}function K_(s){return new this(s).tan()}function G_(s){return new this(s).tanh()}function H_(s){return Dt(s=new this(s),s.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var gi=it.constructor=Dc(ba);Ss=new gi(Ss),Bs=new gi(Bs);var J_="BigNumber",X_=["?on","config"],Q_=mt(J_,X_,s=>{var{on:t,config:e}=s,r=gi.clone({precision:e.precision,modulo:gi.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,i){n.precision!==i.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),xc={exports:{}};/**
|
41
41
|
* @license Complex.js v2.1.1 12/05/2020
|
42
42
|
*
|
43
43
|
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
44
44
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
45
|
-
**/(function(s,t){(function(e){var r=Math.cosh||function(f){return Math.abs(f)<1e-9?1-f:(Math.exp(f)+Math.exp(-f))*.5},n=Math.sinh||function(f){return Math.abs(f)<1e-9?f:(Math.exp(f)-Math.exp(-f))*.5},i=function(f){var d=Math.PI/4;if(-d>f||f>d)return Math.cos(f)-1;var g=f*f;return g*(g*(g*(g*(g*(g*(g*(g/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(f,d){var g=Math.abs(f),y=Math.abs(d);return g<3e3&&y<3e3?Math.sqrt(g*g+y*y):(g<y?(g=y,y=f/d):y=d/f,g*Math.sqrt(1+y*y))},l=function(){throw SyntaxError("Invalid Param")};function c(f,d){var g=Math.abs(f),y=Math.abs(d);return f===0?Math.log(y):d===0?Math.log(g):g<3e3&&y<3e3?Math.log(f*f+d*d)*.5:(f=f/2,d=d/2,.5*Math.log(f*f+d*d)+Math.LN2)}var
|
46
|
-
`||(x==="+"?m++:x==="-"?w++:x==="i"||x==="I"?(m+w===0&&l(),y[v+1]!==" "&&!isNaN(y[v+1])?(g.im+=parseFloat((w%2?"-":"")+y[v+1]),v++):g.im+=parseFloat((w%2?"-":"")+"1"),m=w=0):((m+w===0||isNaN(x))&&l(),y[v+1]==="i"||y[v+1]==="I"?(g.im+=parseFloat((w%2?"-":"")+x),v++):g.re+=parseFloat((w%2?"-":"")+x),m=w=0))}m+w>0&&l();break;case"number":g.im=0,g.re=f;break;default:l()}return isNaN(g.re)||isNaN(g.im),g};function
|
45
|
+
**/(function(s,t){(function(e){var r=Math.cosh||function(f){return Math.abs(f)<1e-9?1-f:(Math.exp(f)+Math.exp(-f))*.5},n=Math.sinh||function(f){return Math.abs(f)<1e-9?f:(Math.exp(f)-Math.exp(-f))*.5},i=function(f){var d=Math.PI/4;if(-d>f||f>d)return Math.cos(f)-1;var g=f*f;return g*(g*(g*(g*(g*(g*(g*(g/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(f,d){var g=Math.abs(f),y=Math.abs(d);return g<3e3&&y<3e3?Math.sqrt(g*g+y*y):(g<y?(g=y,y=f/d):y=d/f,g*Math.sqrt(1+y*y))},l=function(){throw SyntaxError("Invalid Param")};function c(f,d){var g=Math.abs(f),y=Math.abs(d);return f===0?Math.log(y):d===0?Math.log(g):g<3e3&&y<3e3?Math.log(f*f+d*d)*.5:(f=f/2,d=d/2,.5*Math.log(f*f+d*d)+Math.LN2)}var p=function(f,d){var g={re:0,im:0};if(f==null)g.re=g.im=0;else if(d!==void 0)g.re=f,g.im=d;else switch(typeof f){case"object":if("im"in f&&"re"in f)g.re=f.re,g.im=f.im;else if("abs"in f&&"arg"in f){if(!Number.isFinite(f.abs)&&Number.isFinite(f.arg))return h.INFINITY;g.re=f.abs*Math.cos(f.arg),g.im=f.abs*Math.sin(f.arg)}else if("r"in f&&"phi"in f){if(!Number.isFinite(f.r)&&Number.isFinite(f.phi))return h.INFINITY;g.re=f.r*Math.cos(f.phi),g.im=f.r*Math.sin(f.phi)}else f.length===2?(g.re=f[0],g.im=f[1]):l();break;case"string":g.im=g.re=0;var y=f.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),m=1,w=0;y===null&&l();for(var v=0;v<y.length;v++){var x=y[v];x===" "||x===" "||x===`
|
46
|
+
`||(x==="+"?m++:x==="-"?w++:x==="i"||x==="I"?(m+w===0&&l(),y[v+1]!==" "&&!isNaN(y[v+1])?(g.im+=parseFloat((w%2?"-":"")+y[v+1]),v++):g.im+=parseFloat((w%2?"-":"")+"1"),m=w=0):((m+w===0||isNaN(x))&&l(),y[v+1]==="i"||y[v+1]==="I"?(g.im+=parseFloat((w%2?"-":"")+x),v++):g.re+=parseFloat((w%2?"-":"")+x),m=w=0))}m+w>0&&l();break;case"number":g.im=0,g.re=f;break;default:l()}return isNaN(g.re)||isNaN(g.im),g};function h(f,d){if(!(this instanceof h))return new h(f,d);var g=p(f,d);this.re=g.re,this.im=g.im}h.prototype={re:0,im:0,sign:function(){var f=this.abs();return new h(this.re/f,this.im/f)},add:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:new h(this.re+g.re,this.im+g.im)},sub:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:new h(this.re-g.re,this.im-g.im)},mul:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isZero()||this.isZero()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:g.im===0&&this.im===0?new h(this.re*g.re,0):new h(this.re*g.re-this.im*g.im,this.re*g.im+this.im*g.re)},div:function(f,d){var g=new h(f,d);if(this.isZero()&&g.isZero()||this.isInfinite()&&g.isInfinite())return h.NAN;if(this.isInfinite()||g.isZero())return h.INFINITY;if(this.isZero()||g.isInfinite())return h.ZERO;f=this.re,d=this.im;var y=g.re,m=g.im,w,v;return m===0?new h(f/y,d/y):Math.abs(y)<Math.abs(m)?(v=y/m,w=y*v+m,new h((f*v+d)/w,(d*v-f)/w)):(v=m/y,w=m*v+y,new h((f+d*v)/w,(d-f*v)/w))},pow:function(f,d){var g=new h(f,d);if(f=this.re,d=this.im,g.isZero())return h.ONE;if(g.im===0){if(d===0&&f>0)return new h(Math.pow(f,g.re),0);if(f===0)switch((g.re%4+4)%4){case 0:return new h(Math.pow(d,g.re),0);case 1:return new h(0,Math.pow(d,g.re));case 2:return new h(-Math.pow(d,g.re),0);case 3:return new h(0,-Math.pow(d,g.re))}}if(f===0&&d===0&&g.re>0&&g.im>=0)return h.ZERO;var y=Math.atan2(d,f),m=c(f,d);return f=Math.exp(g.re*m-g.im*y),d=g.im*m+g.re*y,new h(f*Math.cos(d),f*Math.sin(d))},sqrt:function(){var f=this.re,d=this.im,g=this.abs(),y,m;if(f>=0){if(d===0)return new h(Math.sqrt(f),0);y=.5*Math.sqrt(2*(g+f))}else y=Math.abs(d)/Math.sqrt(2*(g-f));return f<=0?m=.5*Math.sqrt(2*(g-f)):m=Math.abs(d)/Math.sqrt(2*(g+f)),new h(y,d<0?-m:m)},exp:function(){var f=Math.exp(this.re);return this.im,new h(f*Math.cos(this.im),f*Math.sin(this.im))},expm1:function(){var f=this.re,d=this.im;return new h(Math.expm1(f)*Math.cos(d)+i(d),Math.exp(f)*Math.sin(d))},log:function(){var f=this.re,d=this.im;return new h(c(f,d),Math.atan2(d,f))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var f=this.re,d=this.im;return new h(Math.sin(f)*r(d),Math.cos(f)*n(d))},cos:function(){var f=this.re,d=this.im;return new h(Math.cos(f)*r(d),-Math.sin(f)*n(d))},tan:function(){var f=2*this.re,d=2*this.im,g=Math.cos(f)+r(d);return new h(Math.sin(f)/g,n(d)/g)},cot:function(){var f=2*this.re,d=2*this.im,g=Math.cos(f)-r(d);return new h(-Math.sin(f)/g,n(d)/g)},sec:function(){var f=this.re,d=this.im,g=.5*r(2*d)+.5*Math.cos(2*f);return new h(Math.cos(f)*r(d)/g,Math.sin(f)*n(d)/g)},csc:function(){var f=this.re,d=this.im,g=.5*r(2*d)-.5*Math.cos(2*f);return new h(Math.sin(f)*r(d)/g,-Math.cos(f)*n(d)/g)},asin:function(){var f=this.re,d=this.im,g=new h(d*d-f*f+1,-2*f*d).sqrt(),y=new h(g.re-d,g.im+f).log();return new h(y.im,-y.re)},acos:function(){var f=this.re,d=this.im,g=new h(d*d-f*f+1,-2*f*d).sqrt(),y=new h(g.re-d,g.im+f).log();return new h(Math.PI/2-y.im,y.re)},atan:function(){var f=this.re,d=this.im;if(f===0){if(d===1)return new h(0,1/0);if(d===-1)return new h(0,-1/0)}var g=f*f+(1-d)*(1-d),y=new h((1-d*d-f*f)/g,-2*f/g).log();return new h(-.5*y.im,.5*y.re)},acot:function(){var f=this.re,d=this.im;if(d===0)return new h(Math.atan2(1,f),0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).atan():new h(f!==0?f/0:0,d!==0?-d/0:0).atan()},asec:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new h(0,1/0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).acos():new h(f!==0?f/0:0,d!==0?-d/0:0).acos()},acsc:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new h(Math.PI/2,1/0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).asin():new h(f!==0?f/0:0,d!==0?-d/0:0).asin()},sinh:function(){var f=this.re,d=this.im;return new h(n(f)*Math.cos(d),r(f)*Math.sin(d))},cosh:function(){var f=this.re,d=this.im;return new h(r(f)*Math.cos(d),n(f)*Math.sin(d))},tanh:function(){var f=2*this.re,d=2*this.im,g=r(f)+Math.cos(d);return new h(n(f)/g,Math.sin(d)/g)},coth:function(){var f=2*this.re,d=2*this.im,g=r(f)-Math.cos(d);return new h(n(f)/g,-Math.sin(d)/g)},csch:function(){var f=this.re,d=this.im,g=Math.cos(2*d)-r(2*f);return new h(-2*n(f)*Math.cos(d)/g,2*r(f)*Math.sin(d)/g)},sech:function(){var f=this.re,d=this.im,g=Math.cos(2*d)+r(2*f);return new h(2*r(f)*Math.cos(d)/g,-2*n(f)*Math.sin(d)/g)},asinh:function(){var f=this.im;this.im=-this.re,this.re=f;var d=this.asin();return this.re=-this.im,this.im=f,f=d.re,d.re=-d.im,d.im=f,d},acosh:function(){var f=this.acos();if(f.im<=0){var d=f.re;f.re=-f.im,f.im=d}else{var d=f.im;f.im=-f.re,f.re=d}return f},atanh:function(){var f=this.re,d=this.im,g=f>1&&d===0,y=1-f,m=1+f,w=y*y+d*d,v=w!==0?new h((m*y-d*d)/w,(d*y+m*d)/w):new h(f!==-1?f/0:0,d!==0?d/0:0),x=v.re;return v.re=c(v.re,v.im)/2,v.im=Math.atan2(v.im,x)/2,g&&(v.im=-v.im),v},acoth:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new h(0,Math.PI/2);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).atanh():new h(f!==0?f/0:0,d!==0?-d/0:0).atanh()},acsch:function(){var f=this.re,d=this.im;if(d===0)return new h(f!==0?Math.log(f+Math.sqrt(f*f+1)):1/0,0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).asinh():new h(f!==0?f/0:0,d!==0?-d/0:0).asinh()},asech:function(){var f=this.re,d=this.im;if(this.isZero())return h.INFINITY;var g=f*f+d*d;return g!==0?new h(f/g,-d/g).acosh():new h(f!==0?f/0:0,d!==0?-d/0:0).acosh()},inverse:function(){if(this.isZero())return h.INFINITY;if(this.isInfinite())return h.ZERO;var f=this.re,d=this.im,g=f*f+d*d;return new h(f/g,-d/g)},conjugate:function(){return new h(this.re,-this.im)},neg:function(){return new h(-this.re,-this.im)},ceil:function(f){return f=Math.pow(10,f||0),new h(Math.ceil(this.re*f)/f,Math.ceil(this.im*f)/f)},floor:function(f){return f=Math.pow(10,f||0),new h(Math.floor(this.re*f)/f,Math.floor(this.im*f)/f)},round:function(f){return f=Math.pow(10,f||0),new h(Math.round(this.re*f)/f,Math.round(this.im*f)/f)},equals:function(f,d){var g=new h(f,d);return Math.abs(g.re-this.re)<=h.EPSILON&&Math.abs(g.im-this.im)<=h.EPSILON},clone:function(){return new h(this.re,this.im)},toString:function(){var f=this.re,d=this.im,g="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(f)<h.EPSILON&&(f=0),Math.abs(d)<h.EPSILON&&(d=0),d===0?g+f:(f!==0?(g+=f,g+=" ",d<0?(d=-d,g+="-"):g+="+",g+=" "):d<0&&(d=-d,g+="-"),d!==1&&(g+=d),g+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},h.ZERO=new h(0,0),h.ONE=new h(1,0),h.I=new h(0,1),h.PI=new h(Math.PI,0),h.E=new h(Math.E,0),h.INFINITY=new h(1/0,1/0),h.NAN=new h(NaN,NaN),h.EPSILON=1e-15,Object.defineProperty(h,"__esModule",{value:!0}),h.default=h,h.Complex=h,s.exports=h})()})(xc);var tm=xc.exports,Ke=Gt(tm),em="Complex",rm=[],nm=mt(em,rm,()=>(Object.defineProperty(Ke,"name",{value:"Complex"}),Ke.prototype.constructor=Ke,Ke.prototype.type="Complex",Ke.prototype.isComplex=!0,Ke.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Ke.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Ke.prototype.format=function(s){var t="",e=this.im,r=this.re,n=ha(this.re,s),i=ha(this.im,s),a=de(s)?s:s?s.precision:null;if(a!==null){var l=Math.pow(10,-a);Math.abs(r/e)<l&&(r=0),Math.abs(e/r)<l&&(e=0)}return e===0?t=n:r===0?e===1?t="i":e===-1?t="-i":t=i+"i":e<0?e===-1?t=n+" - i":t=n+" - "+i.substring(1)+"i":e===1?t=n+" + i":t=n+" + "+i+"i",t},Ke.fromPolar=function(s){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return Ke(t);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var e=arguments[0],r=arguments[1];if(de(e)){if(Rl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),de(r))return new Ke({r:e,phi:r});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},Ke.prototype.valueOf=Ke.prototype.toString,Ke.fromJSON=function(s){return new Ke(s)},Ke.compare=function(s,t){return s.re>t.re?1:s.re<t.re?-1:s.im>t.im?1:s.im<t.im?-1:0},Ke),{isClass:!0}),Ec={exports:{}};/**
|
47
47
|
* @license Fraction.js v4.3.0 20/08/2023
|
48
48
|
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
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(s,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function i(v,x){if(isNaN(v=parseInt(v,10)))throw m();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 N=d(v,x);return b.n=v/N,b.d=x/N,b}function l(v){for(var x={},b=v,N=2,E=4;E<=b;){for(;b%N===0;)b/=N,x[N]=(x[N]||0)+1;E+=1+2*N++}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,N=1,E=1,C=0,M=0,S=0,T=1,F=1,O=0,R=1,U=1,k=1,W=1e7,z;if(v!=null)if(x!==void 0){if(b=v,N=x,E=b*N,b%1!==0||N%1!==0)throw w()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw m();E=b*N;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);R<=W&&k<=W;)if(z=(O+U)/(R+k),v===z){R+k<=W?(b=O+U,N=R+k):k>R?(b=U,N=k):(b=O,N=R);break}else v>z?(O+=U,R+=k):(U+=O,k+=R),R>W?(b=U,N=k):(b=O,N=R);b*=F}else(isNaN(v)||isNaN(x))&&(N=b=NaN);break}case"string":{if(R=v.match(/\d+|./g),R===null)throw m();if(R[O]==="-"?(E=-1,O++):R[O]==="+"&&O++,R.length===O+1?M=i(R[O++],E):R[O+1]==="."||R[O]==="."?(R[O]!=="."&&(C=i(R[O++],E)),O++,(O+1===R.length||R[O+1]==="("&&R[O+3]===")"||R[O+1]==="'"&&R[O+3]==="'")&&(M=i(R[O],E),T=Math.pow(10,R[O].length),O++),(R[O]==="("&&R[O+2]===")"||R[O]==="'"&&R[O+2]==="'")&&(S=i(R[O+1],E),F=Math.pow(10,R[O+1].length)-1,O+=3)):R[O+1]==="/"||R[O+1]===":"?(M=i(R[O],E),T=i(R[O+2],1),O+=3):R[O+3]==="/"&&R[O+1]===" "&&(C=i(R[O],E),M=i(R[O+2],E),T=i(R[O+4],1),O+=5),R.length<=O){N=T*F,E=b=S+N*C+F*M;break}}default:throw m()}if(N===0)throw y();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function h(v,x,b){for(var N=1;x>0;v=v*v%b,x>>=1)x&1&&(N=N*v%b);return N}function p(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,N=1;b!==1;N++)if(b=b*10%x,N>r)return 0;return N}function f(v,x,b){for(var N=1,E=h(10,b,x),C=0;C<300;C++){if(N===E)return C;N=N*10%x,E=E*10%x}return 0}function d(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=d(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var y=function(){return new Error("Division by Zero")},m=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(d(n.n,this.n)*d(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,d(n.n,this.n)*d(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,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=l(this.n),N=l(this.d),E=1,C=1;for(var M in b)if(M!=="1"){if(M==="0"){E=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;E*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;C*=Math.pow(M,N[M])}return n.s<0?a(C,E):a(E,C)},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(),N=1;N<b.length;N++){for(var E=a(b[N-1],1),C=N-2;C>=0;C--)E=E.inverse().add(b[C]);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="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,b+=" ",N%=E),b+=N,b+="/",b+=E),b},toLatex:function(v){var x,b="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,N%=E),b+="\\frac{",b+=N,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,N=[];if(isNaN(x)||isNaN(b))return N;do N.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return N},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var N=p(x,b),E=f(x,b,N),C=this.s<0?"-":"";if(C+=x/b|0,x%=b,x*=10,x&&(C+="."),N){for(var M=E;M--;)C+=x/b|0,x%=b,x*=10;C+="(";for(var M=N;M--;)C+=x/b|0,x%=b,x*=10;C+=")"}else for(var M=v;x&&M--;)C+=x/b|0,x%=b,x*=10;return C}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,s.exports=g})()})(Ec);var im=Ec.exports,cn=Gt(im),sm="Fraction",om=[],am=mt(sm,om,()=>(Object.defineProperty(cn,"name",{value:"Fraction"}),cn.prototype.constructor=cn,cn.prototype.type="Fraction",cn.prototype.isFraction=!0,cn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},cn.fromJSON=function(s){return new cn(s)},cn),{isClass:!0}),um="Matrix",lm=[],cm=mt(um,lm,()=>{function s(){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator")}return s.prototype.type="Matrix",s.prototype.isMatrix=!0,s.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},s.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},s.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},s.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},s.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},s.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},s.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},s.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},s.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},s.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},s.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},s.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},s.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},s.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},s.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},s.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},s.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},s},{isClass:!0});function Ac(s){return Object.keys(s.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var fm="DenseMatrix",hm=["Matrix"],pm=mt(fm,hm,s=>{var{Matrix:t}=s;function e(p,f){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!tn(f))throw new Error("Invalid datatype: "+f);if(ve(p))p.type==="DenseMatrix"?(this._data=se(p._data),this._size=se(p._size),this._datatype=f||p._datatype):(this._data=p.toArray(),this._size=p.size(),this._datatype=f||p._datatype);else if(p&&Ee(p.data)&&Ee(p.size))this._data=p.data,this._size=p.size,Ql(this._data,this._size),this._datatype=f||p.datatype;else if(Ee(p))this._data=h(p),this._size=Te(this._data),Ql(this._data,this._size),this._datatype=f;else{if(p)throw new TypeError("Unsupported type of data ("+En(p)+")");this._data=[],this._size=[0],this._datatype=f}}e.prototype=new t,e.prototype.createDenseMatrix=function(p,f){return new e(p,f)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Fs(this._data,En)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(p,f){return new e(p,f)},e.prototype.subset=function(p,f,d){switch(arguments.length){case 1:return r(this,p);case 2:case 3:return i(this,p,f,d);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(p){if(!Ee(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ht(p.length,this._size.length);for(var f=0;f<p.length;f++)Ae(p[f],this._size[f]);for(var d=this._data,g=0,y=p.length;g<y;g++){var m=p[g];Ae(m,d.length),d=d[m]}return d},e.prototype.set=function(p,f,d){if(!Ee(p))throw new TypeError("Array expected");if(p.length<this._size.length)throw new Ht(p.length,this._size.length,"<");var g,y,m,w=p.map(function(x){return x+1});c(this,w,d);var v=this._data;for(g=0,y=p.length-1;g<y;g++)m=p[g],Ae(m,v.length),v=v[m];return m=p[p.length-1],Ae(m,v.length),v[m]=f,this};function r(p,f){if(!la(f))throw new TypeError("Invalid index");var d=f.isScalar();if(d)return p.get(f.min());var g=f.size();if(g.length!==p._size.length)throw new Ht(g.length,p._size.length);for(var y=f.min(),m=f.max(),w=0,v=p._size.length;w<v;w++)Ae(y[w],p._size[w]),Ae(m[w],p._size[w]);return new e(n(p._data,f,g.length,0),p._datatype)}function n(p,f,d,g){var y=g===d-1,m=f.dimension(g);return y?m.map(function(w){return Ae(w,p.length),p[w]}).valueOf():m.map(function(w){Ae(w,p.length);var v=p[w];return n(v,f,d,g+1)}).valueOf()}function i(p,f,d,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var y=f.size(),m=f.isScalar(),w;if(ve(d)?(w=d.size(),d=d.valueOf()):w=Te(d),m){if(w.length!==0)throw new TypeError("Scalar expected");p.set(f.min(),d,g)}else{if(!hi(w,y))try{w.length===0?d=sc([d],y):d=sc(d,y),w=Te(d)}catch{}if(y.length<p._size.length)throw new Ht(y.length,p._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++;d=ec(d,y.length,x,w)}if(!hi(y,w))throw new Ht(y,w,">");var b=f.max().map(function(C){return C+1});c(p,b,g);var N=y.length,E=0;a(p._data,f,d,N,E)}return p}function a(p,f,d,g,y){var m=y===g-1,w=f.dimension(y);m?w.forEach(function(v,x){Ae(v),p[v]=d[x[0]]}):w.forEach(function(v,x){Ae(v),a(p[v],f,d[x[0]],g,y+1)})}e.prototype.resize=function(p,f,d){if(!Zi(p))throw new TypeError("Array or Matrix expected");var g=p.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),y=d?this.clone():this;return l(y,g,f)};function l(p,f,d){if(f.length===0){for(var g=p._data;Ee(g);)g=g[0];return g}return p._size=f.slice(0),p._data=da(p._data,p._size,d),p}e.prototype.reshape=function(p,f){var d=f?this.clone():this;d._data=ma(d._data,p);var g=d._size.reduce((y,m)=>y*m);return d._size=ga(p,g),d};function c(p,f,d){for(var g=p._size.slice(0),y=!1;g.length<f.length;)g.push(0),y=!0;for(var m=0,w=f.length;m<w;m++)f[m]>g[m]&&(g[m]=f[m],y=!0);y&&l(p,g,d)}e.prototype.clone=function(){var p=new e({data:se(this._data),size:se(this._size),datatype:this._datatype});return p},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(p){var f=this,d=Ac(p),g=function w(v,x){return Ee(v)?v.map(function(b,N){return w(b,x.concat(N))}):d===1?p(v):d===2?p(v,x):p(v,x,f)},y=g(this._data,[]),m=this._datatype!==void 0?Fs(y,En):void 0;return new e(y,m)},e.prototype.forEach=function(p){var f=this,d=function g(y,m){Ee(y)?y.forEach(function(w,v){g(w,m.concat(v))}):p(y,m,f)};d(this._data,[])},e.prototype[Symbol.iterator]=function*(){var p=function*f(d,g){if(Ee(d))for(var y=0;y<d.length;y++)yield*f(d[y],g.concat(y));else yield{value:d,index:g}};yield*p(this._data,[])},e.prototype.rows=function(){var p=[],f=this.size();if(f.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var d=this._data;for(var g of d)p.push(new e([g],this._datatype));return p},e.prototype.columns=function(){var p=this,f=[],d=this.size();if(d.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,y=function(v){var x=g.map(b=>[b[v]]);f.push(new e(x,p._datatype))},m=0;m<d[1];m++)y(m);return f},e.prototype.toArray=function(){return se(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(p){return fe(this._data,p)},e.prototype.toString=function(){return fe(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(p){if(p){if(Se(p)&&(p=p.toNumber()),!de(p)||!De(p))throw new TypeError("The parameter k must be an integer number")}else p=0;for(var f=p>0?p:0,d=p<0?-p:0,g=this._size[0],y=this._size[1],m=Math.min(g-d,y-f),w=[],v=0;v<m;v++)w[v]=this._data[v+d][v+f];return new e({data:w,size:[m],datatype:this._datatype})},e.diagonal=function(p,f,d,g){if(!Ee(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function(M){if(Se(M)&&(M=M.toNumber()),!de(M)||!De(M)||M<1)throw new Error("Size values must be positive integers");return M}),d){if(Se(d)&&(d=d.toNumber()),!de(d)||!De(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var y=d>0?d:0,m=d<0?-d:0,w=p[0],v=p[1],x=Math.min(w-m,v-y),b;if(Ee(f)){if(f.length!==x)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(ve(f)){var N=f.size();if(N.length!==1||N[0]!==x)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=Se(b(0))?b(0).mul(0):0);var E=[];if(p.length>0){E=da(E,p,g);for(var C=0;C<x;C++)E[C+m][C+y]=b(C)}return new e({data:E,size:[w,v]})},e.fromJSON=function(p){return new e(p)},e.prototype.swapRows=function(p,f){if(!de(p)||!De(p)||!de(f)||!De(f))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ae(p,this._size[0]),Ae(f,this._size[0]),e._swapRows(p,f,this._data),this},e._swapRows=function(p,f,d){var g=d[p];d[p]=d[f],d[f]=g};function h(p){return ve(p)?h(p.valueOf()):Ee(p)?p.map(h):p}return e},{isClass:!0});function dm(s){var t=s.length,e=s[0].length,r,n,i=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(s[r][n]);i.push(a)}return i}function Rs(s){for(var t=0;t<s.length;t++)if(Zi(s[t]))return!0;return!1}function Hi(s,t){ve(s)&&(s=s.valueOf());for(var e=0,r=s.length;e<r;e++){var n=s[e];Array.isArray(n)?Hi(n,t):t(n)}}function Vr(s,t,e){return s&&typeof s.map=="function"?s.map(function(r){return Vr(r,t)}):t(s)}function Fa(s,t,e){var r=Array.isArray(s)?Te(s):s.size();if(t<0||t>=r.length)throw new An(t,r.length);return ve(s)?s.create(Ps(s.valueOf(),t,e)):Ps(s,t,e)}function Ps(s,t,e){var r,n,i,a;if(t<=0)if(Array.isArray(s[0])){for(a=dm(s),n=[],r=0;r<a.length;r++)n[r]=Ps(a[r],t-1,e);return n}else{for(i=s[0],r=1;r<s.length;r++)i=e(i,s[r]);return i}else{for(n=[],r=0;r<s.length;r++)n[r]=Ps(s[r],t-1,e);return n}}var Cc="isInteger",_m=["typed"],mm=mt(Cc,_m,s=>{var{typed:t}=s;return t(Cc,{number:De,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Fc="number",zs="number, number";function Mc(s){return Math.abs(s)}Mc.signature=Fc;function Nc(s,t){return s+t}Nc.signature=zs;function Sc(s,t){return s-t}Sc.signature=zs;function Bc(s,t){return s*t}Bc.signature=zs;function Oc(s){return-s}Oc.signature=Fc;function Ic(s,t){return s*s<1&&t===1/0||s*s>1&&t===-1/0?0:Math.pow(s,t)}Ic.signature=zs;var Tc="number";function $c(s){return s===0}$c.signature=Tc;function Lc(s){return Number.isNaN(s)}Lc.signature=Tc;var Rc="isNumeric",gm=["typed"],vm=mt(Rc,gm,s=>{var{typed:t}=s;return t(Rc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Pc="isZero",ym=["typed"],wm=mt(Pc,ym,s=>{var{typed:t}=s;return t(Pc,{number:$c,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=>Vr(r,e))})}),zc="isNaN",Dm=["typed"],bm=mt(zc,Dm,s=>{var{typed:t}=s;return t(zc,{number:Lc,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 Vr(r,Number.isNaN)}})});function qs(s,t,e){if(e==null)return s.eq(t);if(s.eq(t))return!0;if(s.isNaN()||t.isNaN())return!1;if(s.isFinite()&&t.isFinite()){var r=s.minus(t).abs();if(r.isZero())return!0;var n=s.constructor.max(s.abs(),t.abs());return r.lte(n.times(e))}return!1}function xm(s,t,e){return Gn(s.re,t.re,e)&&Gn(s.im,t.im,e)}var ks=mt("compareUnits",["typed"],s=>{var{typed:t}=s;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)})}}),Us="equalScalar",Em=["typed","config"],Am=mt(Us,Em,s=>{var{typed:t,config:e}=s,r=ks({typed:t});return t(Us,{"boolean, boolean":function(i,a){return i===a},"number, number":function(i,a){return Gn(i,a,e.epsilon)},"BigNumber, BigNumber":function(i,a){return i.eq(a)||qs(i,a,e.epsilon)},"Fraction, Fraction":function(i,a){return i.equals(a)},"Complex, Complex":function(i,a){return xm(i,a,e.epsilon)}},r)});mt(Us,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Us,{"number, number":function(n,i){return Gn(n,i,e.epsilon)}})});var Cm="SparseMatrix",Fm=["typed","equalScalar","Matrix"],Mm=mt(Cm,Fm,s=>{var{typed:t,equalScalar:e,Matrix:r}=s;function n(m,w){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(w&&!tn(w))throw new Error("Invalid datatype: "+w);if(ve(m))i(this,m,w);else if(m&&Ee(m.index)&&Ee(m.ptr)&&Ee(m.size))this._values=m.values,this._index=m.index,this._ptr=m.ptr,this._size=m.size,this._datatype=w||m.datatype;else if(Ee(m))a(this,m,w);else{if(m)throw new TypeError("Unsupported type of data ("+En(m)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=w}}function i(m,w,v){w.type==="SparseMatrix"?(m._values=w._values?se(w._values):void 0,m._index=se(w._index),m._ptr=se(w._ptr),m._size=se(w._size),m._datatype=v||w._datatype):a(m,w.valueOf(),v||w._datatype)}function a(m,w,v){m._values=[],m._index=[],m._ptr=[],m._datatype=v;var x=w.length,b=0,N=e,E=0;if(tn(v)&&(N=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var C=0;do{m._ptr.push(m._index.length);for(var M=0;M<x;M++){var S=w[M];if(Ee(S)){if(C===0&&b<S.length&&(b=S.length),C<S.length){var T=S[C];N(T,E)||(m._values.push(T),m._index.push(M))}}else C===0&&b<1&&(b=1),N(S,E)||(m._values.push(S),m._index.push(M))}C++}while(C<b)}m._ptr.push(m._index.length),m._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(m,w){return new n(m,w)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Fs(this._values,En)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(m,w){return new n(m,w)},n.prototype.density=function(){var m=this._size[0],w=this._size[1];return m!==0&&w!==0?this._index.length/(m*w):0},n.prototype.subset=function(m,w,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,m);case 2:case 3:return c(this,m,w,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(m,w){if(!la(w))throw new TypeError("Invalid index");var v=w.isScalar();if(v)return m.get(w.min());var x=w.size();if(x.length!==m._size.length)throw new Ht(x.length,m._size.length);var b,N,E,C,M=w.min(),S=w.max();for(b=0,N=m._size.length;b<N;b++)Ae(M[b],m._size[b]),Ae(S[b],m._size[b]);var T=m._values,F=m._index,O=m._ptr,R=w.dimension(0),U=w.dimension(1),k=[],W=[];R.forEach(function(X,Q){W[X]=Q[0],k[X]=!0});var z=T?[]:void 0,K=[],Z=[];return U.forEach(function(X){for(Z.push(K.length),E=O[X],C=O[X+1];E<C;E++)b=F[E],k[b]===!0&&(K.push(W[b]),z&&z.push(T[E]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:x,datatype:m._datatype})}function c(m,w,v,x){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),N=w.isScalar(),E;if(ve(v)?(E=v.size(),v=v.toArray()):E=Te(v),N){if(E.length!==0)throw new TypeError("Scalar expected");m.set(w.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Ht(b.length,m._size.length,"<");if(E.length<b.length){for(var C=0,M=0;b[C]===1&&E[C]===1;)C++;for(;b[C]===1;)M++,C++;v=ec(v,b.length,M,E)}if(!hi(b,E))throw new Ht(b,E,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(O,R){Ae(O),m.set([O,0],v[R[0]],x)})}else{var T=w.dimension(0),F=w.dimension(1);T.forEach(function(O,R){Ae(O),F.forEach(function(U,k){Ae(U),m.set([O,U],v[R[0]][k[0]],x)})})}}return m}n.prototype.get=function(m){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var w=m[0],v=m[1];Ae(w,this._size[0]),Ae(v,this._size[1]);var x=h(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(m,w,v){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=m[0],b=m[1],N=this._size[0],E=this._size[1],C=e,M=0;tn(this._datatype)&&(C=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(x>N-1||b>E-1)&&(d(this,Math.max(x+1,N),Math.max(b+1,E),v),N=this._size[0],E=this._size[1]),Ae(x,N),Ae(b,E);var S=h(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?C(w,M)?p(S,b,this._values,this._index,this._ptr):this._values[S]=w:C(w,M)||f(S,x,b,w,this._values,this._index,this._ptr),this};function h(m,w,v,x){if(v-w===0)return v;for(var b=w;b<v;b++)if(x[b]===m)return b;return w}function p(m,w,v,x,b){v.splice(m,1),x.splice(m,1);for(var N=w+1;N<b.length;N++)b[N]--}function f(m,w,v,x,b,N,E){b.splice(m,0,x),N.splice(m,0,w);for(var C=v+1;C<E.length;C++)E[C]++}n.prototype.resize=function(m,w,v){if(!Zi(m))throw new TypeError("Array or Matrix expected");var x=m.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(N){if(!de(N)||!De(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(x)+")")});var b=v?this.clone():this;return d(b,x[0],x[1],w)};function d(m,w,v,x){var b=x||0,N=e,E=0;tn(m._datatype)&&(N=t.find(e,[m._datatype,m._datatype])||e,E=t.convert(0,m._datatype),b=t.convert(b,m._datatype));var C=!N(b,E),M=m._size[0],S=m._size[1],T,F,O;if(v>S){for(F=S;F<v;F++)if(m._ptr[F]=m._values.length,C)for(T=0;T<M;T++)m._values.push(b),m._index.push(T);m._ptr[v]=m._values.length}else v<S&&(m._ptr.splice(v+1,S-v),m._values.splice(m._ptr[v],m._values.length),m._index.splice(m._ptr[v],m._index.length));if(S=v,w>M){if(C){var R=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]+R,O=m._ptr[F+1]+R;var U=0;for(T=M;T<w;T++,U++)m._values.splice(O+U,0,b),m._index.splice(O+U,0,T),R++}m._ptr[S]=m._values.length}}else if(w<M){var k=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]-k;var W=m._ptr[F],z=m._ptr[F+1]-k;for(O=W;O<z;O++)T=m._index[O],T>w-1&&(m._values.splice(O,1),m._index.splice(O,1),k++)}m._ptr[F]=m._values.length}return m._size[0]=w,m._size[1]=v,m}n.prototype.reshape=function(m,w){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");m.forEach(function(X){if(!de(X)||!De(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+fe(m)+")")});var v=this._size[0]*this._size[1];m=ga(m,v);var x=m[0]*m[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]===m[0]&&this._size[1]===m[1])return b;for(var N=[],E=0;E<b._ptr.length;E++)for(var C=0;C<b._ptr[E+1]-b._ptr[E];C++)N.push(E);for(var M=b._values.slice(),S=b._index.slice(),T=0;T<b._index.length;T++){var F=S[T],O=N[T],R=F*b._size[1]+O;N[T]=R%m[1],S[T]=Math.floor(R/m[1])}b._values.length=0,b._index.length=0,b._ptr.length=m[1]+1,b._size=m.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var k=0;k<M.length;k++){var W=S[k],z=N[k],K=M[k],Z=h(W,b._ptr[z],b._ptr[z+1],b._index);f(Z,W,z,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var m=new n({values:this._values?se(this._values):void 0,index:se(this._index),ptr:se(this._ptr),size:se(this._size),datatype:this._datatype});return m},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(m,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],N=Ac(m),E=function(M,S,T){return N===1?m(M):N===2?m(M,[S,T]):m(M,[S,T],v)};return g(this,0,x-1,0,b-1,E,w)};function g(m,w,v,x,b,N,E){var C=[],M=[],S=[],T=e,F=0;tn(m._datatype)&&(T=t.find(e,[m._datatype,m._datatype])||e,F=t.convert(0,m._datatype));for(var O=function(lt,wt,bt){lt=N(lt,wt,bt),T(lt,F)||(C.push(lt),M.push(wt))},R=x;R<=b;R++){S.push(C.length);var U=m._ptr[R],k=m._ptr[R+1];if(E)for(var W=U;W<k;W++){var z=m._index[W];z>=w&&z<=v&&O(m._values[W],z-w,R-x)}else{for(var K={},Z=U;Z<k;Z++){var X=m._index[Z];K[X]=m._values[Z]}for(var Q=w;Q<=v;Q++){var ct=Q in K?K[Q]:0;O(ct,Q-w,R-x)}}}return S.push(C.length),new n({values:C,index:M,ptr:S,size:[v-w+1,b-x+1]})}n.prototype.forEach=function(m,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],N=0;N<b;N++){var E=this._ptr[N],C=this._ptr[N+1];if(w)for(var M=E;M<C;M++){var S=this._index[M];m(this._values[M],[S,N],v)}else{for(var T={},F=E;F<C;F++){var O=this._index[F];T[O]=this._values[F]}for(var R=0;R<x;R++){var U=R in T?T[R]:0;m(U,[R,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var m=this._size[1],w=0;w<m;w++)for(var v=this._ptr[w],x=this._ptr[w+1],b=v;b<x;b++){var N=this._index[b];yield{value:this._values[b],index:[N,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(m,w,v,x,b){var N=x[0],E=x[1],C=[],M,S;for(M=0;M<N;M++)for(C[M]=[],S=0;S<E;S++)C[M][S]=0;for(S=0;S<E;S++)for(var T=v[S],F=v[S+1],O=T;O<F;O++)M=w[O],C[M][S]=m?b?se(m[O]):m[O]:1;return C}return n.prototype.format=function(m){for(var w=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+fe(w,m)+" x "+fe(v,m)+"] density: "+fe(x,m)+`
|
53
|
-
`,N=0;N<v;N++)for(var E=this._ptr[N],
|
54
|
-
(`+fe(S,m)+", "+fe(N,m)+") ==> "+(this._values?fe(this._values[M],m):"X")}return b},n.prototype.toString=function(){return fe(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(m){if(m){if(Se(m)&&(m=m.toNumber()),!de(m)||!De(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var w=m>0?m:0,v=m<0?-m:0,x=this._size[0],b=this._size[1],N=Math.min(x-v,b-w),E=[],C=[],M=[];M[0]=0;for(var S=w;S<b&&E.length<N;S++)for(var T=this._ptr[S],F=this._ptr[S+1],O=T;O<F;O++){var R=this._index[O];if(R===S-w+v){E.push(this._values[O]),C[E.length-1]=R-v;break}}return M.push(E.length),new n({values:E,index:C,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,w,v,x,b){if(!Ee(m))throw new TypeError("Array expected, size parameter");if(m.length!==2)throw new Error("Only two dimensions matrix are supported");if(m=m.map(function(X){if(Se(X)&&(X=X.toNumber()),!de(X)||!De(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Se(v)&&(v=v.toNumber()),!de(v)||!De(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,E=0;tn(b)&&(N=t.find(e,[b,b])||e,E=t.convert(0,b));var C=v>0?v:0,M=v<0?-v:0,S=m[0],T=m[1],F=Math.min(S-M,T-C),O;if(Ee(w)){if(w.length!==F)throw new Error("Invalid value array length");O=function(Q){return w[Q]}}else if(ve(w)){var R=w.size();if(R.length!==1||R[0]!==F)throw new Error("Invalid matrix length");O=function(Q){return w.get([Q])}}else O=function(){return w};for(var U=[],k=[],W=[],z=0;z<T;z++){W.push(U.length);var K=z-C;if(K>=0&&K<F){var Z=O(K);N(Z,E)||(k.push(K+M),U.push(Z))}}return W.push(U.length),new n({values:U,index:k,ptr:W,size:[S,T]})},n.prototype.swapRows=function(m,w){if(!de(m)||!De(m)||!de(w)||!De(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 Ae(m,this._size[0]),Ae(w,this._size[0]),n._swapRows(m,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,w,v,x,b){for(var N=x[m],E=x[m+1],C=N;C<E;C++)b(v[C],w[C])},n._swapRows=function(m,w,v,x,b,N){for(var E=0;E<v;E++){var C=N[E],M=N[E+1],S=h(m,C,M,b),T=h(w,C,M,b);if(S<M&&T<M&&b[S]===m&&b[T]===w){if(x){var F=x[S];x[S]=x[T],x[T]=F}continue}if(S<M&&b[S]===m&&(T>=M||b[T]!==w)){var O=x?x[S]:void 0;b.splice(T,0,w),x&&x.splice(T,0,O),b.splice(T<=S?S+1:S,1),x&&x.splice(T<=S?S+1:S,1);continue}if(T<M&&b[T]===w&&(S>=M||b[S]!==m)){var R=x?x[T]:void 0;b.splice(S,0,m),x&&x.splice(S,0,R),b.splice(S<=T?T+1:T,1),x&&x.splice(S<=T?T+1:T,1)}}},n},{isClass:!0}),Nm="number",Sm=["typed"];function Bm(s){var t=s.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:s,radix:e,integerPart:r,fractionalPart:n}}else return null}function Om(s){for(var t=parseInt(s.integerPart,s.radix),e=0,r=0;r<s.fractionalPart.length;r++){var n=parseInt(s.fractionalPart[r],s.radix);e+=n/Math.pow(s.radix,r+1)}var i=t+e;if(isNaN(i))throw new SyntaxError('String "'+s.input+'" is not a valid number');return i}var Im=mt(Nm,Sm,s=>{var{typed:t}=s,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Bm(n);if(i)return Om(i);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":t.referToSelf(r=>n=>Vr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Tm="bignumber",$m=["typed","BigNumber"],Lm=mt(Tm,$m,s=>{var{typed:t,BigNumber:e}=s;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var a=i[2],l=e(i[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var h=new e(2).pow(Number(a)-1);return l.gte(h)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),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=>Vr(n,r))})}),Rm="fraction",Pm=["typed","Fraction"],zm=mt(Rm,Pm,s=>{var{typed:t,Fraction:e}=s;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,i){return new e(n,i)},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 i=n.clone();return i.value=r(n.value),i}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Vr(n,r))})}),qc="matrix",qm=["typed","Matrix","DenseMatrix","SparseMatrix"],km=mt(qc,qm,s=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=s;return t(qc,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,c){return i([],l,c)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(a,l,c){if(l==="dense"||l==="default"||l===void 0)return new r(a,c);if(l==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),kc="unaryMinus",Um=["typed"],Wm=mt(kc,Um,s=>{var{typed:t}=s;return t(kc,{number:Oc,"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=>Vr(r,e))})}),Uc="abs",jm=["typed"],Ym=mt(Uc,jm,s=>{var{typed:t}=s;return t(Uc,{number:Mc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Wc="addScalar",Vm=["typed"],Zm=mt(Wc,Vm,s=>{var{typed:t}=s;return t(Wc,{"number, number":Nc,"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 i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),jc="subtractScalar",Km=["typed"],Gm=mt(jc,Km,s=>{var{typed:t}=s;return t(jc,{"number, number":Sc,"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 i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Hm="matAlgo11xS0s",Jm=["typed","equalScalar"],Ma=mt(Hm,Jm,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=e,v=0,x=a;typeof d=="string"&&(m=d,w=t.find(e,[m,m]),v=t.convert(0,m),i=t.convert(i,m),x=t.find(a,[m,m]));for(var b=[],N=[],E=[],C=0;C<y;C++){E[C]=N.length;for(var M=p[C],S=p[C+1],T=M;T<S;T++){var F=h[T],O=l?x(i,c[T]):x(c[T],i);w(O,v)||(N.push(F),b.push(O))}}return E[y]=N.length,n.createSparseMatrix({values:b,index:N,ptr:E,size:[g,y],datatype:m})}}),Xm="matAlgo12xSfs",Qm=["typed","DenseMatrix"],vi=mt(Xm,Qm,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,C=p[N],M=p[N+1],S=C;S<M;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=l?w(i,0):w(0,i)}return new e({data:v,size:[g,y],datatype:m})}}),tg="matAlgo14xDs",eg=["typed"],Na=mt(tg,eg,s=>{var{typed:t}=s;return function(n,i,a,l){var c=n._data,h=n._size,p=n._datatype,f,d=a;typeof p=="string"&&(f=p,i=t.convert(i,f),d=t.find(a,[f,f]));var g=h.length>0?e(d,0,h,h[0],c,i,l):[];return n.createDenseMatrix({data:g,size:se(h),datatype:f})};function e(r,n,i,a,l,c,h){var p=[];if(n===i.length-1)for(var f=0;f<a;f++)p[f]=h?r(c,l[f]):r(l[f],c);else for(var d=0;d<a;d++)p[d]=e(r,n+1,i,i[n+1],l[d],c,h);return p}}),rg="matAlgo02xDS0",ng=["typed","equalScalar"],ig=mt(rg,ng,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._data,h=n._size,p=n._datatype||n.getDataType(),f=i._values,d=i._index,g=i._ptr,y=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==y.length)throw new Ht(h.length,y.length);if(h[0]!==y[0]||h[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+y+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=h[0],v=h[1],x,b=e,N=0,E=a;typeof p=="string"&&p===m&&p!=="mixed"&&(x=p,b=t.find(e,[x,x]),N=t.convert(0,x),E=t.find(a,[x,x]));for(var C=[],M=[],S=[],T=0;T<v;T++){S[T]=M.length;for(var F=g[T],O=g[T+1],R=F;R<O;R++){var U=d[R],k=l?E(f[R],c[U][T]):E(c[U][T],f[R]);b(k,N)||(M.push(U),C.push(k))}}return S[v]=M.length,i.createSparseMatrix({values:C,index:M,ptr:S,size:[w,v],datatype:p===n._datatype&&m===i._datatype?x:void 0})}}),sg="matAlgo03xDSf",og=["typed"],yi=mt(sg,og,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v,x=0,b=i;typeof h=="string"&&h===y&&h!=="mixed"&&(v=h,x=t.convert(0,v),b=t.find(i,[v,v]));for(var N=[],E=0;E<m;E++)N[E]=[];for(var C=[],M=[],S=0;S<w;S++){for(var T=S+1,F=d[S],O=d[S+1],R=F;R<O;R++){var U=f[R];C[U]=a?b(p[R],l[U][S]):b(l[U][S],p[R]),M[U]=T}for(var k=0;k<m;k++)M[k]===T?N[k][S]=C[k]:N[k][S]=a?b(x,l[k][S]):b(l[k][S],x)}return r.createDenseMatrix({data:N,size:[m,w],datatype:h===r._datatype&&y===n._datatype?v:void 0})}}),ag="matAlgo05xSfSf",ug=["typed","equalScalar"],Yc=mt(ag,ug,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(p.length!==m.length)throw new Ht(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],x=p[1],b,N=e,E=0,C=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),C=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],T=[],F=M?[]:void 0,O=M?[]:void 0,R=[],U=[],k,W,z,K;for(W=0;W<x;W++){T[W]=S.length;var Z=W+1;for(z=h[W],K=h[W+1];z<K;z++)k=c[z],S.push(k),R[k]=Z,F&&(F[k]=l[z]);for(z=y[W],K=y[W+1];z<K;z++)k=g[z],R[k]!==Z&&S.push(k),U[k]=Z,O&&(O[k]=d[z]);if(M)for(z=T[W];z<S.length;){k=S[z];var X=R[k],Q=U[k];if(X===Z||Q===Z){var ct=X===Z?F[k]:E,vt=Q===Z?O[k]:E,lt=C(ct,vt);N(lt,E)?S.splice(z,1):(M.push(lt),z++)}}}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),lg="matAlgo13xDD",cg=["typed"],fg=mt(lg,cg,s=>{var{typed:t}=s;return function(n,i,a){var l=n._data,c=n._size,h=n._datatype,p=i._data,f=i._size,d=i._datatype,g=[];if(c.length!==f.length)throw new Ht(c.length,f.length);for(var y=0;y<c.length;y++){if(c[y]!==f[y])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[y]=c[y]}var m,w=a;typeof h=="string"&&h===d&&(m=h,w=t.find(a,[m,m]));var v=g.length>0?e(w,0,g,g[0],l,p):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,i,a,l,c){var h=[];if(n===i.length-1)for(var p=0;p<a;p++)h[p]=r(l[p],c[p]);else for(var f=0;f<a;f++)h[f]=e(r,n+1,i,i[n+1],l[f],c[f]);return h}}),hg="broadcast",pg=["concat"],dg=mt(hg,pg,s=>{var{concat:t}=s;return function(n,i){var a=Math.max(n._size.length,i._size.length);if(n._size.length===i._size.length&&n._size.every((y,m)=>y===i._size[m]))return[n,i];for(var l=e(n._size,a,0),c=e(i._size,a,0),h=[],p=0;p<a;p++)h[p]=Math.max(l[p],c[p]);Ms(l,h),Ms(c,h);var f=n.clone(),d=i.clone();f._size.length<a?f.reshape(e(f._size,a,1)):d._size.length<a&&d.reshape(e(d._size,a,1));for(var g=0;g<a;g++)f._size[g]<h[g]&&(f=r(f,h[g],g)),d._size[g]<h[g]&&(d=r(d,h[g],g));return[f,d]};function e(n,i,a){return[...Array(i-n.length).fill(a),...n]}function r(n,i,a){return t(...Array(i).fill(n),a)}}),_g="matrixAlgorithmSuite",mg=["typed","matrix","concat"],Hn=mt(_g,mg,s=>{var{typed:t,matrix:e,concat:r}=s,n=fg({typed:t}),i=Na({typed:t}),a=dg({concat:r});return function(c){var h=c.elop,p=c.SD||c.DS,f;h?(f={"DenseMatrix, DenseMatrix":(m,w)=>n(...a(m,w),h),"Array, Array":(m,w)=>n(...a(e(m),e(w)),h).valueOf(),"Array, DenseMatrix":(m,w)=>n(...a(e(m),w),h),"DenseMatrix, Array":(m,w)=>n(...a(m,e(w)),h)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,w)=>c.SS(...a(m,w),h,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,w)=>c.DS(...a(m,w),h,!1),f["Array, SparseMatrix"]=(m,w)=>c.DS(...a(e(m),w),h,!1)),p&&(f["SparseMatrix, DenseMatrix"]=(m,w)=>p(...a(w,m),h,!0),f["SparseMatrix, Array"]=(m,w)=>p(...a(e(w),m),h,!0))):(f={"DenseMatrix, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(w,v),m)),"Array, Array":t.referToSelf(m=>(w,v)=>n(...a(e(w),e(v)),m).valueOf()),"Array, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(e(w),v),m)),"DenseMatrix, Array":t.referToSelf(m=>(w,v)=>n(...a(w,e(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.SS(...a(w,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(w,v),m,!1)),f["Array, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(e(w),v),m,!1))),p&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(w,v)=>p(...a(v,w),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(w,v)=>p(...a(e(v),w),m,!0))));var d=c.scalar||"any",g=c.Ds||c.Ss;g&&(h?(f["DenseMatrix,"+d]=(m,w)=>i(m,w,h,!1),f[d+", DenseMatrix"]=(m,w)=>i(w,m,h,!0),f["Array,"+d]=(m,w)=>i(e(m),w,h,!1).valueOf(),f[d+", Array"]=(m,w)=>i(e(w),m,h,!0).valueOf()):(f["DenseMatrix,"+d]=t.referToSelf(m=>(w,v)=>i(w,v,m,!1)),f[d+", DenseMatrix"]=t.referToSelf(m=>(w,v)=>i(v,w,m,!0)),f["Array,"+d]=t.referToSelf(m=>(w,v)=>i(e(w),v,m,!1).valueOf()),f[d+", Array"]=t.referToSelf(m=>(w,v)=>i(e(v),w,m,!0).valueOf())));var y=c.sS!==void 0?c.sS:c.Ss;return h?(c.Ss&&(f["SparseMatrix,"+d]=(m,w)=>c.Ss(m,w,h,!1)),y&&(f[d+", SparseMatrix"]=(m,w)=>y(w,m,h,!0))):(c.Ss&&(f["SparseMatrix,"+d]=t.referToSelf(m=>(w,v)=>c.Ss(w,v,m,!1))),y&&(f[d+", SparseMatrix"]=t.referToSelf(m=>(w,v)=>y(v,w,m,!0)))),h&&h.signatures&&Pl(f,h.signatures),f}}),gg="matAlgo01xDSid",vg=["typed"],Vc=mt(gg,vg,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v=typeof h=="string"&&h!=="mixed"&&h===y?h:void 0,x=v?t.find(i,[v,v]):i,b,N,E=[];for(b=0;b<m;b++)E[b]=[];var C=[],M=[];for(N=0;N<w;N++){for(var S=N+1,T=d[N],F=d[N+1],O=T;O<F;O++)b=f[O],C[b]=a?x(p[O],l[b][N]):x(l[b][N],p[O]),M[b]=S;for(b=0;b<m;b++)M[b]===S?E[b][N]=C[b]:E[b][N]=l[b][N]}return r.createDenseMatrix({data:E,size:[m,w],datatype:h===r._datatype&&y===n._datatype?v:void 0})}}),yg="matAlgo04xSidSid",wg=["typed","equalScalar"],Dg=mt(yg,wg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(p.length!==m.length)throw new Ht(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],x=p[1],b,N=e,E=0,C=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),C=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],T=[],F=l&&d?[]:void 0,O=l&&d?[]:void 0,R=[],U=[],k,W,z,K,Z;for(W=0;W<x;W++){T[W]=S.length;var X=W+1;for(K=h[W],Z=h[W+1],z=K;z<Z;z++)k=c[z],S.push(k),R[k]=X,F&&(F[k]=l[z]);for(K=y[W],Z=y[W+1],z=K;z<Z;z++)if(k=g[z],R[k]===X){if(F){var Q=C(F[k],d[z]);N(Q,E)?R[k]=null:F[k]=Q}}else S.push(k),U[k]=X,O&&(O[k]=d[z]);if(F&&O)for(z=T[W];z<S.length;)k=S[z],R[k]===X?(M[z]=F[k],z++):U[k]===X?(M[z]=O[k],z++):S.splice(z,1)}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),bg="matAlgo10xSids",xg=["typed","DenseMatrix"],Zc=mt(bg,xg,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,C=p[N],M=p[N+1],S=C;S<M;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=i}return new e({data:v,size:[g,y],datatype:m})}}),Eg="multiplyScalar",Ag=["typed"],Cg=mt(Eg,Ag,s=>{var{typed:t}=s;return t("multiplyScalar",{"number, number":Bc,"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)})}),Kc="multiply",Fg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Mg=mt(Kc,Fg,s=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:i,dot:a}=s,l=Ma({typed:t,equalScalar:i}),c=Na({typed:t});function h(E,C){switch(E.length){case 1:switch(C.length){case 1:if(E[0]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(E[0]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+E[0]+") must match Matrix rows ("+C[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+C.length+" dimensions)")}break;case 2:switch(C.length){case 1:if(E[1]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+E[1]+") must match Vector length ("+C[0]+")");break;case 2:if(E[1]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+E[1]+") must match Matrix B rows ("+C[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+C.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+E.length+" dimensions)")}}function p(E,C,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(E,C)}function f(E,C){if(C.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(E,C)}function d(E,C){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=C._data,O=C._size,R=C._datatype||C.getDataType(),U=S[0],k=O[1],W,z=r,K=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&(W=T,z=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var Z=[],X=0;X<k;X++){for(var Q=K(M[0],F[0][X]),ct=1;ct<U;ct++)Q=z(Q,K(M[ct],F[ct][X]));Z[X]=Q}return E.createDenseMatrix({data:Z,size:[k],datatype:T===E._datatype&&R===C._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":x}),y=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(E,C){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=C._data,O=C._datatype||C.getDataType(),R=S[0],U=S[1],k,W=r,z=n;T&&O&&T===O&&typeof T=="string"&&T!=="mixed"&&(k=T,W=t.find(r,[k,k]),z=t.find(n,[k,k]));for(var K=[],Z=0;Z<R;Z++){for(var X=M[Z],Q=z(X[0],F[0]),ct=1;ct<U;ct++)Q=W(Q,z(X[ct],F[ct]));K[Z]=Q}return E.createDenseMatrix({data:K,size:[R],datatype:T===E._datatype&&O===C._datatype?k:void 0})}function w(E,C){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=C._data,O=C._size,R=C._datatype||C.getDataType(),U=S[0],k=S[1],W=O[1],z,K=r,Z=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&T!=="mixed"&&(z=T,K=t.find(r,[z,z]),Z=t.find(n,[z,z]));for(var X=[],Q=0;Q<U;Q++){var ct=M[Q];X[Q]=[];for(var vt=0;vt<W;vt++){for(var lt=Z(ct[0],F[0][vt]),wt=1;wt<k;wt++)lt=K(lt,Z(ct[wt],F[wt][vt]));X[Q][vt]=lt}}return E.createDenseMatrix({data:X,size:[U,W],datatype:T===E._datatype&&R===C._datatype?z:void 0})}function v(E,C){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=C._values,O=C._index,R=C._ptr,U=C._size,k=C._datatype||C._data===void 0?C._datatype:C.getDataType();if(!F)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],z=U[1],K,Z=r,X=n,Q=i,ct=0;T&&k&&T===k&&typeof T=="string"&&T!=="mixed"&&(K=T,Z=t.find(r,[K,K]),X=t.find(n,[K,K]),Q=t.find(i,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],wt=[],bt=C.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[W,z],datatype:T===E._datatype&&k===C._datatype?K:void 0}),Bt=0;Bt<z;Bt++){wt[Bt]=lt.length;var xt=R[Bt],oe=R[Bt+1];if(oe>xt)for(var It=0,Nt=0;Nt<W;Nt++){for(var ce=Nt+1,re=void 0,kt=xt;kt<oe;kt++){var Jt=O[kt];It!==ce?(re=X(M[Nt][Jt],F[kt]),It=ce):re=Z(re,X(M[Nt][Jt],F[kt]))}It===ce&&!Q(re,ct)&&(lt.push(Nt),vt.push(re))}}return wt[z]=lt.length,bt}function x(E,C){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=C._data,R=C._datatype||C.getDataType(),U=E._size[0],k=C._size[0],W=[],z=[],K=[],Z,X=r,Q=n,ct=i,vt=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]),ct=t.find(i,[Z,Z]),vt=t.convert(0,Z));var lt=[],wt=[];K[0]=0;for(var bt=0;bt<k;bt++){var Bt=O[bt];if(!ct(Bt,vt))for(var xt=T[bt],oe=T[bt+1],It=xt;It<oe;It++){var Nt=S[It];wt[Nt]?lt[Nt]=X(lt[Nt],Q(Bt,M[It])):(wt[Nt]=!0,z.push(Nt),lt[Nt]=Q(Bt,M[It]))}}for(var ce=z.length,re=0;re<ce;re++){var kt=z[re];W[re]=lt[kt]}return K[1]=z.length,E.createSparseMatrix({values:W,index:z,ptr:K,size:[U,1],datatype:F===E._datatype&&R===C._datatype?Z:void 0})}function b(E,C){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=C._data,R=C._datatype||C.getDataType(),U=E._size[0],k=C._size[0],W=C._size[1],z,K=r,Z=n,X=i,Q=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(z=F,K=t.find(r,[z,z]),Z=t.find(n,[z,z]),X=t.find(i,[z,z]),Q=t.convert(0,z));for(var ct=[],vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,W],datatype:F===E._datatype&&R===C._datatype?z:void 0}),bt=[],Bt=[],xt=0;xt<W;xt++){lt[xt]=vt.length;for(var oe=xt+1,It=0;It<k;It++){var Nt=O[It][xt];if(!X(Nt,Q))for(var ce=T[It],re=T[It+1],kt=ce;kt<re;kt++){var Jt=S[kt];Bt[Jt]!==oe?(Bt[Jt]=oe,vt.push(Jt),bt[Jt]=Z(Nt,M[kt])):bt[Jt]=K(bt[Jt],Z(Nt,M[kt]))}}for(var Le=lt[xt],vr=vt.length,ze=Le;ze<vr;ze++){var pn=vt[ze];ct[ze]=bt[pn]}}return lt[W]=vt.length,wt}function N(E,C){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType(),O=C._values,R=C._index,U=C._ptr,k=C._datatype||C._data===void 0?C._datatype:C.getDataType(),W=E._size[0],z=C._size[1],K=M&&O,Z,X=r,Q=n;F&&k&&F===k&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]));for(var ct=K?[]:void 0,vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,z],datatype:F===E._datatype&&k===C._datatype?Z:void 0}),bt=K?[]:void 0,Bt=[],xt,oe,It,Nt,ce,re,kt,Jt,Le=0;Le<z;Le++){lt[Le]=vt.length;var vr=Le+1;for(ce=U[Le],re=U[Le+1],Nt=ce;Nt<re;Nt++)if(Jt=R[Nt],K)for(oe=T[Jt],It=T[Jt+1],xt=oe;xt<It;xt++)kt=S[xt],Bt[kt]!==vr?(Bt[kt]=vr,vt.push(kt),bt[kt]=Q(O[Nt],M[xt])):bt[kt]=X(bt[kt],Q(O[Nt],M[xt]));else for(oe=T[Jt],It=T[Jt+1],xt=oe;xt<It;xt++)kt=S[xt],Bt[kt]!==vr&&(Bt[kt]=vr,vt.push(kt));if(K)for(var ze=lt[Le],pn=vt.length,On=ze;On<pn;On++){var dn=vt[On];ct[On]=bt[dn]}}return lt[z]=vt.length,wt}return t(Kc,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(C,M)=>{h(Te(C),Te(M));var S=E(e(C),e(M));return ve(S)?S.valueOf():S}),"Matrix, Matrix":function(C,M){var S=C.size(),T=M.size();return h(S,T),S.length===1?T.length===1?p(C,M,S[0]):f(C,M):T.length===1?g(C,M):y(C,M)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(C,M)=>E(C,e(M))),"Array, Matrix":t.referToSelf(E=>(C,M)=>E(e(C,M.storage()),M)),"SparseMatrix, any":function(C,M){return l(C,M,n,!1)},"DenseMatrix, any":function(C,M){return c(C,M,n,!1)},"any, SparseMatrix":function(C,M){return l(M,C,n,!0)},"any, DenseMatrix":function(C,M){return c(M,C,n,!0)},"Array, any":function(C,M){return c(e(C),M,n,!1).valueOf()},"any, Array":function(C,M){return c(e(M),C,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(C,M,S)=>{for(var T=E(C,M),F=0;F<S.length;F++)T=E(T,S[F]);return T})})}),Gc="subtract",Ng=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Sg=mt(Gc,Ng,s=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:l}=s,c=Vc({typed:t}),h=yi({typed:t}),p=Yc({typed:t,equalScalar:r}),f=Zc({typed:t,DenseMatrix:a}),d=vi({typed:t,DenseMatrix:a}),g=Hn({typed:t,matrix:e,concat:l});return t(Gc,{"any, any":n},g({elop:n,SS:p,DS:c,SD:h,Ss:d,sS:f}))}),Bg="matAlgo07xSSf",Og=["typed","DenseMatrix"],Ws=mt(Bg,Og,s=>{var{typed:t,DenseMatrix:e}=s;return function(i,a,l){var c=i._size,h=i._datatype||i._data===void 0?i._datatype:i.getDataType(),p=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==p.length)throw new Ht(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");var d=c[0],g=c[1],y,m=0,w=l;typeof h=="string"&&h===f&&h!=="mixed"&&(y=h,m=t.convert(0,y),w=t.find(l,[y,y]));var v,x,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],E=[],C=[],M=[];for(x=0;x<g;x++){var S=x+1;for(r(i,x,C,N,S),r(a,x,M,E,S),v=0;v<d;v++){var T=C[v]===S?N[v]:m,F=M[v]===S?E[v]:m;b[v][x]=w(T,F)}}return new e({data:b,size:[d,g],datatype:h===i._datatype&&f===a._datatype?y:void 0})};function r(n,i,a,l,c){for(var h=n._values,p=n._index,f=n._ptr,d=f[i],g=f[i+1];d<g;d++){var y=p[d];a[y]=c,l[y]=h[d]}}}),Hc="conj",Ig=["typed"],Tg=mt(Hc,Ig,s=>{var{typed:t}=s;return t(Hc,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Jc="concat",$g=["typed","matrix","isInteger"],Lg=mt(Jc,$g,s=>{var{typed:t,matrix:e,isInteger:r}=s;return t(Jc,{"...Array | Matrix | number | BigNumber":function(i){var a,l=i.length,c=-1,h,p=!1,f=[];for(a=0;a<l;a++){var d=i[a];if(ve(d)&&(p=!0),de(d)||Se(d)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(h=c,c=d.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>h)throw new An(c,h+1)}else{var g=se(d).valueOf(),y=Te(g);if(f[a]=g,h=c,c=y.length-1,a>0&&c!==h)throw new Ht(h+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=ic(m,f.shift(),c);return p?e(m):m},"...string":function(i){return i.join("")}})}),Xc="count",Rg=["typed","size","prod"],Pg=mt(Xc,Rg,s=>{var{typed:t,size:e,prod:r}=s;return t(Xc,{string:function(i){return i.length},"Matrix | Array":function(i){return r(e(i))}})}),Qc="identity",zg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],qg=mt(Qc,zg,s=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:i,SparseMatrix:a}=s;return t(Qc,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(p){return r(p)},"number | BigNumber":function(p){return c(p,p,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(p,f){return c(p,p,f)},"number | BigNumber, number | BigNumber":function(p,f){return c(p,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(p,f,d){return c(p,f,d)},Array:function(p){return l(p)},"Array, string":function(p,f){return l(p,f)},Matrix:function(p){return l(p.valueOf(),p.storage())},"Matrix, string":function(p,f){return l(p.valueOf(),f)}});function l(h,p){switch(h.length){case 0:return p?r(p):[];case 1:return c(h[0],h[0],p);case 2:return c(h[0],h[1],p);default:throw new Error("Vector containing two values expected")}}function c(h,p,f){var d=Se(h)||Se(p)?n:null;if(Se(h)&&(h=h.toNumber()),Se(p)&&(p=p.toNumber()),!De(h)||h<1)throw new Error("Parameters in function identity must be positive integers");if(!De(p)||p<1)throw new Error("Parameters in function identity must be positive integers");var g=d?new n(1):1,y=d?new d(0):0,m=[h,p];if(f){if(f==="sparse")return a.diagonal(m,g,0,y);if(f==="dense")return i.diagonal(m,g,0,y);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var w=da([],m,y),v=h<p?h:p,x=0;x<v;x++)w[x][x]=g;return w}}),tf="kron",kg=["typed","matrix","multiplyScalar"],Ug=mt(tf,kg,s=>{var{typed:t,matrix:e,multiplyScalar:r}=s;return t(tf,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(i,a){if(Te(i).length===1&&(i=[i]),Te(a).length===1&&(a=[a]),Te(i).length>2||Te(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return i.map(function(h){return a.map(function(p){return c=[],l.push(c),h.map(function(f){return p.map(function(d){return c.push(r(f,d))})})})})&&l}});function Wg(){throw new Error('No "bignumber" implementation available')}function jg(){throw new Error('No "fraction" implementation available')}function Yg(){throw new Error('No "matrix" implementation available')}var ef="reshape",Vg=["typed","isInteger","matrix"],Zg=mt(ef,Vg,s=>{var{typed:t,isInteger:e}=s;return t(ef,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),ma(n,i)}})}),rf="size",Kg=["typed","config","?matrix"],Gg=mt(rf,Kg,s=>{var{typed:t,config:e,matrix:r}=s;return t(rf,{Matrix:function(i){return i.create(i.size())},Array:Te,string:function(i){return e.matrix==="Array"?[i.length]:r([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return e.matrix==="Array"?[]:r?r([]):Yg()}})}),nf="transpose",Hg=["typed","matrix"],Jg=mt(nf,Hg,s=>{var{typed:t,matrix:e}=s;return t(nf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:se});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var h=l[0],p=l[1];if(p===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+fe(l)+")");switch(a.storage()){case"dense":c=n(a,h,p);break;case"sparse":c=i(a,h,p);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+fe(l)+")")}return c}function n(a,l,c){for(var h=a._data,p=[],f,d=0;d<c;d++){f=p[d]=[];for(var g=0;g<l;g++)f[g]=se(h[g][d])}return a.createDenseMatrix({data:p,size:[c,l],datatype:a._datatype})}function i(a,l,c){for(var h=a._values,p=a._index,f=a._ptr,d=h?[]:void 0,g=[],y=[],m=[],w=0;w<l;w++)m[w]=0;var v,x,b;for(v=0,x=p.length;v<x;v++)m[p[v]]++;for(var N=0,E=0;E<l;E++)y.push(N),N+=m[E],m[E]=y[E];for(y.push(N),b=0;b<c;b++)for(var C=f[b],M=f[b+1],S=C;S<M;S++){var T=m[p[S]]++;g[T]=b,h&&(d[T]=se(h[S]))}return a.createSparseMatrix({values:d,index:g,ptr:y,size:[c,l],datatype:a._datatype})}}),sf="ctranspose",Xg=["typed","transpose","conj"],Qg=mt(sf,Xg,s=>{var{typed:t,transpose:e,conj:r}=s;return t(sf,{any:function(i){return r(e(i))}})}),of="mode",tv=["typed","isNaN","isNumeric"],ev=mt(of,tv,s=>{var{typed:t,isNaN:e,isNumeric:r}=s;return t(of,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(i){i=va(i.valueOf());var a=i.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],h=0,p=0;p<i.length;p++){var f=i[p];if(r(f)&&e(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===h?c.push(f):l[f]>h&&(h=l[f],c=[f])}return c}});function Sn(s,t,e){var r;return String(s).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":" (type: "+s.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(s).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):s}var af="prod",rv=["typed","config","multiplyScalar","numeric"],nv=mt(af,rv,s=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=s;return t(af,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(a){var l;if(Hi(a,function(c){try{l=l===void 0?c:r(l,c)}catch(h){throw Sn(h,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),iv="numeric",sv=["number","?bignumber","?fraction"],ov=mt(iv,sv,s=>{var{number:t,bignumber:e,fraction:r}=s,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:a=>t(a),BigNumber:e?a=>e(a):Wg,Fraction:r?a=>r(a):jg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",h=arguments.length>2?arguments[2]:void 0;if(h!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var p=En(l);if(!(p in n))throw new TypeError("Cannot convert "+l+' of type "'+p+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in i))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(i).join(", "));return c===p?l:i[c](l)}}),uf="divideScalar",av=["typed","numeric"],uv=mt(uf,av,s=>{var{typed:t,numeric:e}=s;return t(uf,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),lf="pow",lv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],cv=mt(lf,lv,s=>{var{typed:t,config:e,identity:r,multiply:n,matrix:i,inv:a,number:l,fraction:c,Complex:h}=s;return t(lf,{"number, number":p,"Complex, Complex":function(y,m){return y.pow(m)},"BigNumber, BigNumber":function(y,m){return m.isInteger()||y>=0||e.predictable?y.pow(m):new h(y.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(y,m){var w=y.pow(m);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 p(y.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(y,m){return f(y,m.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(y,m){return d(y,m.toNumber())},"Unit, number | BigNumber":function(y,m){return y.pow(m)}});function p(g,y){if(e.predictable&&!De(y)&&g<0)try{var m=c(y),w=l(m);if((y===w||Math.abs((y-w)/y)<1e-14)&&m.d%2===1)return(m.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:De(y)||g>=0||e.predictable?Ic(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new h(g,0).pow(y,0)}function f(g,y){if(!De(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var m=Te(g);if(m.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+m.length+" dimensions)");if(m[0]!==m[1])throw new Error("For A^b, A must be square (size is "+m[0]+"x"+m[1]+")");if(y<0)try{return f(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(m[0]).valueOf(),v=g;y>=1;)(y&1)===1&&(w=n(v,w)),y>>=1,v=n(v,v);return w}function d(g,y){return i(f(g.valueOf(),y))}}),cf="dotDivide",fv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],hv=mt(cf,fv,s=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,l=ig({typed:t,equalScalar:r}),c=yi({typed:t}),h=Ws({typed:t,DenseMatrix:i}),p=Ma({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:i}),d=Hn({typed:t,matrix:e,concat:a});return t(cf,d({elop:n,SS:h,DS:c,SD:l,Ss:p,sS:f}))}),js="compare",pv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],dv=mt(js,pv,s=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:l,concat:c}=s,h=yi({typed:t}),p=Yc({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:l}),d=Hn({typed:t,matrix:n,concat:c}),g=ks({typed:t});return t(js,_v({typed:t,config:e}),{"boolean, boolean":function(m,w){return m===w?0:m>w?1:-1},"BigNumber, BigNumber":function(m,w){return qs(m,w,e.epsilon)?new i(0):new i(m.cmp(w))},"Fraction, Fraction":function(m,w){return new a(m.compare(w))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,d({SS:p,DS:h,Ss:f}))}),_v=mt(js,["typed","config"],s=>{var{typed:t,config:e}=s;return t(js,{"number, number":function(n,i){return Gn(n,i,e.epsilon)?0:n>i?1:-1}})}),Ys="equal",mv=["typed","matrix","equalScalar","DenseMatrix","concat"],gv=mt(Ys,mv,s=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:e,concat:i});return t(Ys,vv({typed:t,equalScalar:r}),h({elop:r,SS:l,DS:a,Ss:c}))}),vv=mt(Ys,["typed","equalScalar"],s=>{var{typed:t,equalScalar:e}=s;return t(Ys,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:e(n,i)}})}),Vs="smaller",yv=["typed","config","matrix","DenseMatrix","concat"],wv=mt(Vs,yv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:r,concat:i}),p=ks({typed:t});return t(Vs,Dv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f<d,"BigNumber, BigNumber":function(d,g){return d.lt(g)&&!qs(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===-1,"Complex, Complex":function(d,g){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),Dv=mt(Vs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Vs,{"number, number":function(n,i){return n<i&&!Gn(n,i,e.epsilon)}})}),Zs="larger",bv=["typed","config","matrix","DenseMatrix","concat"],xv=mt(Zs,bv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:r,concat:i}),p=ks({typed:t});return t(Zs,Ev({typed:t,config:e}),{"boolean, boolean":(f,d)=>f>d,"BigNumber, BigNumber":function(d,g){return d.gt(g)&&!qs(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),Ev=mt(Zs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Zs,{"number, number":function(n,i){return n>i&&!Gn(n,i,e.epsilon)}})}),ff="deepEqual",Av=["typed","equal"],Cv=mt(ff,Av,s=>{var{typed:t,equal:e}=s;return t(ff,{"any, any":function(i,a){return r(i.valueOf(),a.valueOf())}});function r(n,i){if(Array.isArray(n))if(Array.isArray(i)){var a=n.length;if(a!==i.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:e(n,i)}}),hf="partitionSelect",Fv=["typed","isNumeric","isNaN","compare"],Mv=mt(hf,Fv,s=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=s,i=n,a=(h,p)=>-n(h,p);return t(hf,{"Array | Matrix, number":function(p,f){return l(p,f,i)},"Array | Matrix, number, string":function(p,f,d){if(d==="asc")return l(p,f,i);if(d==="desc")return l(p,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(h,p,f){if(!De(p)||p<0)throw new Error("k must be a non-negative integer");if(ve(h)){var d=h.size();if(d.length>1)throw new Error("Only one dimensional matrices supported");return c(h.valueOf(),p,f)}if(Array.isArray(h))return c(h,p,f)}function c(h,p,f){if(p>=h.length)throw new Error("k out of bounds");for(var d=0;d<h.length;d++)if(e(h[d])&&r(h[d]))return h[d];for(var g=0,y=h.length-1;g<y;){for(var m=g,w=y,v=h[Math.floor(Math.random()*(y-g+1))+g];m<w;)if(f(h[m],v)>=0){var x=h[w];h[w]=h[m],h[m]=x,--w}else++m;f(h[m],v)>0&&--m,p<=m?y=m:g=m+1}return h[p]}}),pf="max",Nv=["typed","config","numeric","larger"],Sv=mt(pf,Nv,s=>{var{typed:t,config:e,numeric:r,larger:n}=s;return t(pf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Fa(c,h.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(h){throw Sn(h,"max",c)}}function a(l){var c;if(Hi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw Sn(p,"max",h)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),df="min",Bv=["typed","config","numeric","smaller"],Ov=mt(df,Bv,s=>{var{typed:t,config:e,numeric:r,smaller:n}=s;return t(df,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Fa(c,h.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(h){throw Sn(h,"min",c)}}function a(l){var c;if(Hi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw Sn(p,"min",h)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),_f="add",Iv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Tv=mt(_f,Iv,s=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:l}=s,c=Vc({typed:t}),h=Dg({typed:t,equalScalar:n}),p=Zc({typed:t,DenseMatrix:i}),f=Hn({typed:t,matrix:e,concat:l});return t(_f,{"any, any":r,"any, any, ...any":t.referToSelf(d=>(g,y,m)=>{for(var w=d(g,y),v=0;v<m.length;v++)w=d(w,m[v]);return w})},f({elop:r,DS:c,SS:h,Ss:p}))}),mf="dot",$v=["typed","addScalar","multiplyScalar","conj","size"],Lv=mt(mf,$v,s=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:i}=s;return t(mf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(p,f){var d=h(p),g=h(f),y,m;if(d.length===1)y=d[0];else if(d.length===2&&d[1]===1)y=d[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+d.join(", ")+")");if(g.length===1)m=g[0];else if(g.length===2&&g[1]===1)m=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(y!==m)throw new RangeError("Vectors must have equal length ("+y+" != "+m+")");if(y===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return y}function l(p,f){var d=a(p,f),g=ve(p)?p._data:p,y=ve(p)?p._datatype||p.getDataType():void 0,m=ve(f)?f._data:f,w=ve(f)?f._datatype||f.getDataType():void 0,v=h(p).length===2,x=h(f).length===2,b=e,N=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var E=y;b=t.find(e,[E,E]),N=t.find(r,[E,E])}if(!v&&!x){for(var C=N(n(g[0]),m[0]),M=1;M<d;M++)C=b(C,N(n(g[M]),m[M]));return C}if(!v&&x){for(var S=N(n(g[0]),m[0][0]),T=1;T<d;T++)S=b(S,N(n(g[T]),m[T][0]));return S}if(v&&!x){for(var F=N(n(g[0][0]),m[0]),O=1;O<d;O++)F=b(F,N(n(g[O][0]),m[O]));return F}if(v&&x){for(var R=N(n(g[0][0]),m[0][0]),U=1;U<d;U++)R=b(R,N(n(g[U][0]),m[U][0]));return R}}function c(p,f){a(p,f);for(var d=p._index,g=p._values,y=f._index,m=f._values,w=0,v=e,x=r,b=0,N=0;b<d.length&&N<y.length;){var E=d[b],C=y[N];if(E<C){b++;continue}if(E>C){N++;continue}E===C&&(w=v(w,x(g[b],m[N])),b++,N++)}return w}function h(p){return ve(p)?p.size():i(p)}}),Rv="trace",Pv=["typed","matrix","add"],zv=mt(Rv,Pv,s=>{var{typed:t,matrix:e,add:r}=s;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:i,DenseMatrix:n,any:se});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return se(c[0]);throw new RangeError("Matrix must be square (size: "+fe(l)+")");case 2:{var h=l[0],p=l[1];if(h===p){for(var f=0,d=0;d<h;d++)f=r(f,c[d][d]);return f}else throw new RangeError("Matrix must be square (size: "+fe(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(l)+")")}}function i(a){var l=a._values,c=a._index,h=a._ptr,p=a._size,f=p[0],d=p[1];if(f===d){var g=0;if(l.length>0)for(var y=0;y<d;y++)for(var m=h[y],w=h[y+1],v=m;v<w;v++){var x=c[v];if(x===y){g=r(g,l[v]);break}if(x>y)break}return g}throw new RangeError("Matrix must be square (size: "+fe(p)+")")}}),gf="det",qv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],kv=mt(gf,qv,s=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:i,isZero:a,unaryMinus:l}=s;return t(gf,{any:function(p){return se(p)},"Array | Matrix":function(p){var f;switch(ve(p)?f=p.size():Array.isArray(p)?(p=e(p),f=p.size()):f=[],f.length){case 0:return se(p);case 1:if(f[0]===1)return se(p.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")");case 2:{var d=f[0],g=f[1];if(d===g)return c(p.clone().valueOf(),d);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(f)+")")}}});function c(h,p,f){if(p===1)return se(h[0][0]);if(p===2)return r(n(h[0][0],h[1][1]),n(h[1][0],h[0][1]));for(var d=!1,g=new Array(p).fill(0).map((M,S)=>S),y=0;y<p;y++){var m=g[y];if(a(h[m][y])){var w=void 0;for(w=y+1;w<p;w++)if(!a(h[g[w]][y])){m=g[w],g[w]=g[y],g[y]=m,d=!d;break}if(w===p)return h[m][y]}for(var v=h[m][y],x=y===0?1:h[g[y-1]][y-1],b=y+1;b<p;b++)for(var N=g[b],E=y+1;E<p;E++)h[N][E]=i(r(n(h[N][E],v),n(h[N][y],h[m][E])),x)}var C=h[g[p-1]][p-1];return d?l(C):C}}),vf="inv",Uv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Wv=mt(vf,Uv,s=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:l,identity:c,abs:h}=s;return t(vf,{"Array | Matrix":function(d){var g=ve(d)?d.size():Te(d);switch(g.length){case 1:if(g[0]===1)return ve(d)?e([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+fe(g)+")");case 2:{var y=g[0],m=g[1];if(y===m)return ve(d)?e(p(d.valueOf(),y,m),d.storage()):p(d,y,m);throw new RangeError("Matrix must be square (size: "+fe(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(g)+")")}},any:function(d){return r(1,d)}});function p(f,d,g){var y,m,w,v,x;if(d===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(d===2){var b=l(f);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(f[1][1],b),r(a(f[0][1]),b)],[r(a(f[1][0]),b),r(f[0][0],b)]]}else{var N=f.concat();for(y=0;y<d;y++)N[y]=N[y].concat();for(var E=c(d).valueOf(),C=0;C<g;C++){var M=h(N[C][C]),S=C;for(y=C+1;y<d;)h(N[y][C])>M&&(M=h(N[y][C]),S=y),y++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==C&&(x=N[C],N[C]=N[y],N[y]=x,x=E[C],E[C]=E[y],E[y]=x);var T=N[C],F=E[C];for(y=0;y<d;y++){var O=N[y],R=E[y];if(y!==C){if(O[C]!==0){for(w=r(a(O[C]),T[C]),m=C;m<g;m++)O[m]=n(O[m],i(w,T[m]));for(m=0;m<g;m++)R[m]=n(R[m],i(w,F[m]))}}else{for(w=T[C],m=C;m<g;m++)O[m]=r(O[m],w);for(m=0;m<g;m++)R[m]=r(R[m],w)}}}return E}}}),yf="pinv",jv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Yv=mt(yf,jv,s=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:l,ctranspose:c,divideScalar:h,multiply:p,add:f,Complex:d}=s;return t(yf,{"Array | Matrix":function(b){var N=ve(b)?b.size():Te(b);switch(N.length){case 1:return v(b)?c(b):N[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var E=N[0],C=N[1];if(E===C)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return ve(b)?e(g(b.valueOf(),E,C),b.storage()):g(b,E,C)}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(N)+")")}},any:function(b){return i(b,0)?se(b):h(1,b)}});function g(x,b,N){var{C:E,F:C}=m(x,b,N),M=p(r(p(c(E),E)),c(E)),S=p(c(C),r(p(C,c(C))));return p(S,M)}function y(x,b,N){for(var E=se(x),C=0,M=0;M<b;M++){if(N<=C)return E;for(var S=M;w(E[S][C]);)if(S++,b===S&&(S=M,C++,N===C))return E;[E[S],E[M]]=[E[M],E[S]];for(var T=E[M][C],F=0;F<N;F++)E[M][F]=a(E[M][F],T);for(var O=0;O<b;O++)if(O!==M){T=E[O][C];for(var R=0;R<N;R++)E[O][R]=f(E[O][R],p(-1,p(T,E[M][R])))}C++}return E}function m(x,b,N){var E=y(x,b,N),C=x.map((S,T)=>S.filter((F,O)=>O<b&&!w(l(E[O],E[O])))),M=E.filter((S,T)=>!w(l(E[T],E[T])));return{C,F:M}}function w(x){return i(f(x,d(1,1)),f(0,d(1,1)))}function v(x){return n(f(x,d(1,1)),f(p(x,0),d(1,1)))}}),Vv="divide",Zv=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Kv=mt(Vv,Zv,s=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:i,inv:a}=s,l=Ma({typed:t,equalScalar:n}),c=Na({typed:t});return t("divide",Pl({"Array | Matrix, Array | Matrix":function(p,f){return r(p,a(f))},"DenseMatrix, any":function(p,f){return c(p,f,i,!1)},"SparseMatrix, any":function(p,f){return l(p,f,i,!1)},"Array, any":function(p,f){return c(e(p),f,i,!1).valueOf()},"any, Array | Matrix":function(p,f){return r(p,a(f))}},i.signatures))}),wf="sum",Gv=["typed","config","add","numeric"],Hv=mt(wf,Gv,s=>{var{typed:t,config:e,add:r,numeric:n}=s;return t(wf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function sum");return i(c)}});function i(l){var c;return Hi(l,function(h){try{c=c===void 0?h:r(c,h)}catch(p){throw Sn(p,"sum",h)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var h=Fa(l,c,r);return h}catch(p){throw Sn(p,"sum")}}}),Df="median",Jv=["typed","add","divide","compare","partitionSelect"],Xv=mt(Df,Jv,s=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:i}=s;function a(h){try{h=va(h.valueOf());var p=h.length;if(p===0)throw new Error("Cannot calculate median of an empty array");if(p%2===0){for(var f=p/2-1,d=i(h,f+1),g=h[f],y=0;y<f;++y)n(h[y],g)>0&&(g=h[y]);return c(g,d)}else{var m=i(h,(p-1)/2);return l(m)}}catch(w){throw Sn(w,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(p){return p}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(p,f){return r(e(p,f),2)}});return t(Df,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(p,f){throw new Error("median(A, dim) is not yet supported")},"...":function(p){if(Rs(p))throw new TypeError("Scalar values expected in function median");return a(p)}})}),Ks=Q_({config:mr}),Sa=nm({}),Ba=am({}),Oa=cm({}),rn=pm({Matrix:Oa}),Mt=r_({BigNumber:Ks,Complex:Sa,DenseMatrix:rn,Fraction:Ba}),Qv=Ym({typed:Mt}),Gs=Zm({typed:Mt}),t1=Lm({BigNumber:Ks,typed:Mt}),bf=Tg({typed:Mt}),Bn=Am({config:mr,typed:Mt}),Hs=mm({typed:Mt}),e1=wm({typed:Mt}),Js=Cg({typed:Mt}),xf=Im({typed:Mt}),Ia=Mm({Matrix:Oa,equalScalar:Bn,typed:Mt}),Ef=Gm({typed:Mt}),Af=bm({typed:Mt}),Ta=Wm({typed:Mt}),Cf=zm({Fraction:Ba,typed:Mt}),Ff=vm({typed:Mt}),$e=km({DenseMatrix:rn,Matrix:Oa,SparseMatrix:Ia,typed:Mt}),Mf=ev({isNaN:Af,isNumeric:Ff,typed:Mt}),Ji=ov({bignumber:t1,fraction:Cf,number:xf}),r1=nv({config:mr,multiplyScalar:Js,numeric:Ji,typed:Mt}),n1=Zg({isInteger:Hs,matrix:$e,typed:Mt}),Nf=Gg({matrix:$e,config:mr,typed:Mt}),Sf=Jg({matrix:$e,typed:Mt}),Jn=Lg({isInteger:Hs,matrix:$e,typed:Mt}),i1=Pg({prod:r1,size:Nf,typed:Mt}),s1=Qg({conj:bf,transpose:Sf,typed:Mt}),Xi=uv({numeric:Ji,typed:Mt}),o1=hv({DenseMatrix:rn,concat:Jn,divideScalar:Xi,equalScalar:Bn,matrix:$e,typed:Mt}),Bf=gv({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:$e,typed:Mt}),Of=qg({BigNumber:Ks,DenseMatrix:rn,SparseMatrix:Ia,config:mr,matrix:$e,typed:Mt}),a1=Ug({matrix:$e,multiplyScalar:Js,typed:Mt}),u1=wv({DenseMatrix:rn,concat:Jn,config:mr,matrix:$e,typed:Mt}),l1=Sg({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:$e,subtractScalar:Ef,typed:Mt,unaryMinus:Ta}),Qi=Tv({DenseMatrix:rn,SparseMatrix:Ia,addScalar:Gs,concat:Jn,equalScalar:Bn,matrix:$e,typed:Mt}),If=dv({BigNumber:Ks,DenseMatrix:rn,Fraction:Ba,concat:Jn,config:mr,equalScalar:Bn,matrix:$e,typed:Mt}),c1=Cv({equal:Bf,typed:Mt}),Tf=Lv({addScalar:Gs,conj:bf,multiplyScalar:Js,size:Nf,typed:Mt}),f1=xv({DenseMatrix:rn,concat:Jn,config:mr,matrix:$e,typed:Mt}),$a=Ov({config:mr,numeric:Ji,smaller:u1,typed:Mt}),wi=Mg({addScalar:Gs,dot:Tf,equalScalar:Bn,matrix:$e,multiplyScalar:Js,typed:Mt}),h1=Mv({compare:If,isNaN:Af,isNumeric:Ff,typed:Mt}),p1=Hv({add:Qi,config:mr,numeric:Ji,typed:Mt}),d1=zv({add:Qi,matrix:$e,typed:Mt}),$f=kv({divideScalar:Xi,isZero:e1,matrix:$e,multiply:wi,subtractScalar:Ef,typed:Mt,unaryMinus:Ta}),_1=Sv({config:mr,larger:f1,numeric:Ji,typed:Mt}),Xs=Wv({abs:Qv,addScalar:Gs,det:$f,divideScalar:Xi,identity:Of,matrix:$e,multiply:wi,typed:Mt,unaryMinus:Ta}),m1=Yv({Complex:Sa,add:Qi,ctranspose:s1,deepEqual:c1,divideScalar:Xi,dot:Tf,dotDivide:o1,equal:Bf,inv:Xs,matrix:$e,multiply:wi,typed:Mt}),g1=cv({Complex:Sa,config:mr,fraction:Cf,identity:Of,inv:Xs,matrix:$e,multiply:wi,number:xf,typed:Mt}),v1=Kv({divideScalar:Xi,equalScalar:Bn,inv:Xs,matrix:$e,multiply:wi,typed:Mt}),Lf=Xv({add:Qi,compare:If,divide:v1,partitionSelect:h1,typed:Mt});class y1{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:i},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);i&&(c=Math.floor(c));const h=e/n;let p=0,f=0;for(let d=0;d<=e-1;d++){const g=Math.exp(-1*Math.pow(d-c,2)/(2*Math.pow(h,2)));p+=g,f+=l[l.length-1-(e-d-1)]*g}return f/p}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const i=this._cacheDataList(t,e,`sma_${r}`);if(i===void 0)return;const a=i.slice(-e);return n=p1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;this._cacheDataList(t,e,`sma_${r}`);const{sum:n}=this._cacheData[`rma_${r}`]||{},i=1/e,a=n===void 0?this.sma({source:t,length:e},r):i*t+(1-i)*(n||0);return this._cacheDataHandle(`rma_${r}`,{sum:a}),a}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:i,close:a,low:l}=this._variables,c=r===void 0?i-l:Math.max(Math.max(i-l,Math.abs(i-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:i,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const i=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(i===void 0)return;let l=0;for(let c=0;c<e;c++){const h=this._sum(i[i.length-1-c],-(a||0));l+=h*h}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return[];const l=r*a;return[i,i+l,i-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return;const l=r*a;return(i+l-(i-l))/i}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),i=this.dev({source:t,length:e},r);if(!(n===void 0||i===void 0))return(t-n)/(.015*i)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const i=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return i===void 0?i:typeof t=="boolean"?i!==t:t-i}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 i=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(!(i===void 0||a===void 0))return 100*(i-a)/(i+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}`),i=this._math.sum({source:t,length:e},r);if(i===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/i}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const i=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||i===void 0)return;let c=0,h=0,p=0;for(let d=0;d<r;d++){const[g,y]=i[i.length-1-d],m=g-a,w=y-l;c+=m*w,h+=m*m,p+=w*w}return isNaN(h)||isNaN(c)||isNaN(p)?void 0:c/Math.sqrt(h*p)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e||n<=i&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n<=i&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let i=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];i+=Math.abs(c-n)}return i/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:i,high:a,close:l,PDMS:c,NDMS:h,TRS:p,ADX:f,count:d=0}=this._cacheData[n]||{},{low:g,high:y,close:m}=this._variables;if(i===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:y,close:m,PDMS:c,NDMS:h,TRS:y-g,count:1},[void 0,void 0,void 0];let w=y-a,v=i-g;w=w>v&&w>0?w:0,v=v>w&&v>0?v:0,w===v&&(w=v=0);const x=Math.max(y-g,Math.abs(y-l),Math.abs(g-l));if(d<t)return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:(c||0)+w,NDMS:(h||0)+v,TRS:(p||0)+x,count:d+1}),[void 0,void 0,void 0];{const b=c-c/t+w,N=h-h/t+v,E=p-p/t+x,C=b/E*100,M=N/E*100,S=Math.abs((C-M)/(C+M))*100;let T=S,F=[C,M,void 0];if(d+1-t<e){const O=d+1-t;T=((f||0)*(O-1)+S)/O}else T=(f*(e-1)+S)/e,F=[C,M,T];return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:b,NDMS:N,TRS:E,ADX:T,count:d+1}),F}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:i=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(i>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return i+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:i}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:i=[]}=this._cacheData[`falling_${r}`]||{};i.push(n>t);const a=i.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:i=[]}=this._cacheData[`rising_${r}`]||{};i.push(n<t);const a=i.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(i)return Math.max(...i.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return i?i.slice(-e).reduce((l,c,h,p)=>c>=p[l]?h:l,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 i=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;i+=c,a+=n[n.length-1-l]*c}return a/i}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),i=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||i===void 0?void 0:this.wma({source:2*i-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},i){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},i),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${i}`);return[a,a+f*r,a-f*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},i),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${i}`);return(a+f*r-(a-f*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const i=this._cacheDataList(t,e,`dev_${n}`);if(!i)return;const a=i.slice(-e).filter(g=>g!==void 0);let l=0,c=0,h=0,p=0;for(const[g,y]of a.entries())l+=g,c+=y,h+=g*y,p+=g*g;const f=(e*h-l*c)/(e*p-l*l);return(c-f*l)/e+f*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(i)return Math.min(...i.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return i?i.slice(-e).reduce((l,c,h,p)=>c<=p[l]?h:l,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},i){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_${i}`),l=this.ema({source:t,length:r},`ema2_${i}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,h=this.ema({source:c,length:n},`macd_${i}`);if(h===void 0)return[c,h,void 0];const p=c-h;return[c,h,p]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Lf(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,i=this.change({source:t},r),a=this._math.sum({source:n*(i>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(i<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return $a(Mf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,i=this._cacheData[n]||[];if(i[this._variables.bar_index]=t,this._cacheData[n]=i,i.length<=e||t===void 0||isNaN(t))return;let a=i.length-e-1,l;for(;l===void 0&&a>=0;)l=i[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!i)return;const a=this._sort(i.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[h,p]of a.entries()){const f=a[h-1];if(r<(h+.5)/l)return f===void 0||p===void 0?void 0:f+(p-f)*(r-(h-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!i)return;const a=this._sort(i.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const i=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<i.length;c++)i[c]!==void 0&&(i[c]<a||i[c]===a&&c<e)&&l++;return l/(i.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const i=new Qt;let{close:a,open:l,low:c,high:h}=this._variables;const p=`pivot_point_levels_${n}`,{close:f,low:d,high:g,open:y,result:m}=this._cacheData[p]||{};if(!e&&(g&&d&&(h=Math.max(g,h),c=Math.min(d,c)),this._cacheDataHandle(p,{close:a,open:l,low:c,high:h,result:m}),!r))return i._value=m||[],i;const w={close:a,open:l,low:c,high:h};e===!0&&!r&&(a=f,l=y,c=d,h=g);const v=this._getPivotPointLevels(h,c,a,l,r,t);return this._cacheDataHandle(p,{...w,result:v}),i._value=v,i}_getPivotPointLevels(t,e,r,n,i,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Kn.traditional:return this._traditional(t,e,r);case Kn.fibonacci:return this._fibonacci(t,e,r);case Kn.woodie:return i?[]:this._woodie(t,e);case Kn.classic:return this._classic(t,e,r);case Kn.dm:return this._DM(t,e,r,n);case Kn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,i=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),h=n*4+(t-4*e),p=n*2-t,f=n-(t-e),d=n*2-(2*t-e),g=n*3-(3*t-e),y=n*4-(4*t-e);return[n,i,p,a,f,l,d,c,g,h,y]}_fibonacci(t,e,r){const n=(t+e+r)/3,i=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),h=n+(t-e),p=n-(t-e);return[n,i,a,l,c,h,p]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=t+2*(n-e),p=e-2*(t-n),f=h+(t-e),d=p-(t-e);return[n,i,a,l,c,h,p,f,d]}_classic(t,e,r){const n=(t+e+r)/3,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=n+2*(t-e),p=n-2*(t-e),f=n+3*(t-e),d=n-3*(t-e);return[n,i,a,l,c,h,p,f,d]}_DM(t,e,r,n){let i;n===r?i=t+e+2*r:r>n?i=2*t+e+r:i=2*e+t+r;const a=i/4,l=i/2-e,c=i/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,i=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,h=r+1.1*(t-e)/4,p=r-1.1*(t-e)/4,f=r+1.1*(t-e)/2,d=r-1.1*(t-e)/2,g=t/e*r,y=r-(g-r);return[n,i,a,l,c,h,p,f,d,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 i=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const i=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const i=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...i),l=Math.min(...i);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),i=this.change({source:t,length:e},r);if(n)return 100*i/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},i=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:i,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:i,low:a,high:l,preLow:c,preHigh:h,data:p={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:d,acceleration:g,isBelow:y}=p,m=!1;const{close:w,low:v,high:x,bar_index:b}=this._variables;return b===1&&(w>i?(y=!0,d=x,f=a):(y=!1,d=v,f=l),m=!0,g=t),f=f+g*(d-f),y?f>v&&(m=!0,y=!1,f=Math.max(x,d||0),d=v,g=t):f<x&&(m=!0,y=!0,f=Math.min(v,d||0),d=x,g=t),m||(y?x>(d||0)&&(d=x,g=Math.min((g||0)+e,r)):v<(d||0)&&(d=v,g=Math.min((g||0)+e,r))),y?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,h))),this._cacheDataHandle(`sar_${n}`,{high:x,close:w,low:v,preLow:a,preHigh:l,data:Object.assign(p,{result:f,maxMin:d,acceleration:g,isBelow:y})}),f}stoch({source:t,high:e,low:r,length:n},i){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},i),l=this.highest({source:e,length:n},i);if(!(a===void 0||l===void 0))return 100*(this._variables.close-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:i}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:h,atr:p,close:f}=this._cacheData[a]||{},d=this.atr({length:e},r);if(d===void 0)return this._cacheDataHandle(a,{close:i}),[void 0,void 0];let g=n+t*d,y=n-t*d;const m=l||0,w=c||0;y=y>w||f<w?y:w,g=g<m||f>m?g:m;let v;p===void 0?v=1:h===m?v=i>g?-1:1:v=i<y?1:-1;const x=v===-1?y:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:y,superTrend:x,atr:d,close:i}),[x,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:i}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?i-n:void 0:Math.max(i-n,Math.abs(i-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.change({source:t},n);if(i===void 0)return;const a=this.ema({source:Math.abs(i),length:e},`absema1_${n}`),l=this.ema({source:i,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),h=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/h}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:i}=this._cacheData[`valuewhen_${n}`]||{};return i||(i=[]),t&&i.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:i}),i[i.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const i=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`mode_${n}`,!0);if(!a||i===void 0)return;const l=a.filter(h=>h!==void 0&&!isNaN(h)).slice(-e);if(l.length<e)return;const c=l.reduce((h,p)=>h+Math.pow(p-i,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:i}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:h,sumS:p=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=p=0,h=!0),!h)return r!==void 0?[]:void 0;const f=t*i+a,d=i+l,g=f/d;return c++,r!==void 0?(p=i*Math.pow(t,2)+p,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h,sumS:p}),this._computeBands(p,d,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h}),g)}_computeBands(t,e,r,n){let i=t/e-Math.pow(n,2);i=i<0?0:i;const a=Math.sqrt(i),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,i=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(i===void 0||a===void 0))return i/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:i}=this._variables;if(!(r===void 0||n===void 0))return(r-i)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let i=0;i<e-r;i++){const{currentVal:a,currentIndex:l}=n,c=t[i];if(c!==void 0){if(a!==void 0&&c<a){t.splice(i,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:i,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const i=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(i.barIndex<=a&&(i.barIndex===a?i.list[i.list.length-1]=t:i.list.push(t),i.barIndex=a,i.list.length>e+5&&!n&&i.list.shift(),this._cacheData[r]=i),!(i.list.length<e))return i.list}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&!this._variables._isRealTimeBar&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}class w1{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._cacheHandle(t,e,ir.INT)}bool(t,e){return this._cacheHandle(t,e,ir.BOOL)}color(t,e){return this._cacheHandle(t,e,ir.COLOR)}time(t,e){return this._cacheHandle(t,e,ir.TIME)}float(t,e){return this._cacheHandle(t,e,ir.FLOAT)}price(t,e){return this._cacheHandle(t,e,ir.PRICE)}source(t,e){return this._cacheHandle(t,e,ir.SOURCE)}string(t,e){return this._cacheHandle(t,e,ir.STRING)}symbol(t,e){return this._cacheHandle(t,e,ir.SYMBOL)}session(t,e){return this._cacheHandle(t,e,ir.SESSION)}text_area(t,e){return this._cacheHandle(t,e,ir.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,ir.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,ir.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,i=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(le.inputDefvalErr,e,zt.Error),self.workerStorage.setValue(this._name,n,{...t}),i)if(!i.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?i.sourceTypeName&&(this._cacheData[n].defval=this._variables[i.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:l}=t;this._displayVerify(e,l),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===ir.SOURCE?this._cacheData[n].options=Vp:t.options&&!t.options.includes(a)&&this._errorListener.addError(Ye(le.inputOptErr,{defval:String(a),args:t.options.toString()}),e,zt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ve.dataWindow)||e.includes(Ve.statusLine)||this._errorListener.addError(Ye(le.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,zt.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 D1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const r=(100-e)/100,{r:n,g:i,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(i)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:i}){if(_t(t)||_t(e)||_t(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:h,b:p,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:d,g,b:y,a:m}=this._parseColor(i||"rgba(0,0,0,0)"),w=c+l*(d-c),v=h+l*(g-h),x=p+l*(y-p),b=f+l*(m-f);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,i;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?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var qt={};const b1=Object.prototype.toString;function ts(s){const t=b1.call(s);return t.endsWith("Array]")&&!t.includes("Big")}var x1=Object.freeze({__proto__:null,isAnyArray:ts}),E1=Ne(x1);function A1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]>a&&(a=s[l]);return a}function C1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]<a&&(a=s[l]);return a}function F1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ts(s)){if(s.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(!ts(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(s.length);var r=C1(s),n=A1(s);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=t.min,a=i===void 0?t.autoMinMax?r:0:i,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var h=(c-a)/(n-r),p=0;p<s.length;p++)e[p]=(s[p]-r)*h+a;return e}var M1=Object.freeze({__proto__:null,default:F1}),N1=Ne(M1);Object.defineProperty(qt,"__esModule",{value:!0});var cr=E1,Rf=N1;const Qs=" ".repeat(2),Pf=" ".repeat(4);function S1(){return zf(this)}function zf(s,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=t;return`${s.constructor.name} {
|
52
|
+
**/(function(s,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function i(v,x){if(isNaN(v=parseInt(v,10)))throw m();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 N=d(v,x);return b.n=v/N,b.d=x/N,b}function l(v){for(var x={},b=v,N=2,E=4;E<=b;){for(;b%N===0;)b/=N,x[N]=(x[N]||0)+1;E+=1+2*N++}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,N=1,E=1,A=0,M=0,S=0,T=1,F=1,O=0,R=1,U=1,k=1,W=1e7,z;if(v!=null)if(x!==void 0){if(b=v,N=x,E=b*N,b%1!==0||N%1!==0)throw w()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw m();E=b*N;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);R<=W&&k<=W;)if(z=(O+U)/(R+k),v===z){R+k<=W?(b=O+U,N=R+k):k>R?(b=U,N=k):(b=O,N=R);break}else v>z?(O+=U,R+=k):(U+=O,k+=R),R>W?(b=U,N=k):(b=O,N=R);b*=F}else(isNaN(v)||isNaN(x))&&(N=b=NaN);break}case"string":{if(R=v.match(/\d+|./g),R===null)throw m();if(R[O]==="-"?(E=-1,O++):R[O]==="+"&&O++,R.length===O+1?M=i(R[O++],E):R[O+1]==="."||R[O]==="."?(R[O]!=="."&&(A=i(R[O++],E)),O++,(O+1===R.length||R[O+1]==="("&&R[O+3]===")"||R[O+1]==="'"&&R[O+3]==="'")&&(M=i(R[O],E),T=Math.pow(10,R[O].length),O++),(R[O]==="("&&R[O+2]===")"||R[O]==="'"&&R[O+2]==="'")&&(S=i(R[O+1],E),F=Math.pow(10,R[O+1].length)-1,O+=3)):R[O+1]==="/"||R[O+1]===":"?(M=i(R[O],E),T=i(R[O+2],1),O+=3):R[O+3]==="/"&&R[O+1]===" "&&(A=i(R[O],E),M=i(R[O+2],E),T=i(R[O+4],1),O+=5),R.length<=O){N=T*F,E=b=S+N*A+F*M;break}}default:throw m()}if(N===0)throw y();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function p(v,x,b){for(var N=1;x>0;v=v*v%b,x>>=1)x&1&&(N=N*v%b);return N}function h(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,N=1;b!==1;N++)if(b=b*10%x,N>r)return 0;return N}function f(v,x,b){for(var N=1,E=p(10,b,x),A=0;A<300;A++){if(N===E)return A;N=N*10%x,E=E*10%x}return 0}function d(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=d(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var y=function(){return new Error("Division by Zero")},m=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(d(n.n,this.n)*d(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,d(n.n,this.n)*d(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,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=l(this.n),N=l(this.d),E=1,A=1;for(var M in b)if(M!=="1"){if(M==="0"){E=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;E*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;A*=Math.pow(M,N[M])}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(),N=1;N<b.length;N++){for(var E=a(b[N-1],1),A=N-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="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,b+=" ",N%=E),b+=N,b+="/",b+=E),b},toLatex:function(v){var x,b="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,N%=E),b+="\\frac{",b+=N,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,N=[];if(isNaN(x)||isNaN(b))return N;do N.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return N},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var N=h(x,b),E=f(x,b,N),A=this.s<0?"-":"";if(A+=x/b|0,x%=b,x*=10,x&&(A+="."),N){for(var M=E;M--;)A+=x/b|0,x%=b,x*=10;A+="(";for(var M=N;M--;)A+=x/b|0,x%=b,x*=10;A+=")"}else for(var M=v;x&&M--;)A+=x/b|0,x%=b,x*=10;return A}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,s.exports=g})()})(Ec);var im=Ec.exports,cn=Gt(im),sm="Fraction",om=[],am=mt(sm,om,()=>(Object.defineProperty(cn,"name",{value:"Fraction"}),cn.prototype.constructor=cn,cn.prototype.type="Fraction",cn.prototype.isFraction=!0,cn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},cn.fromJSON=function(s){return new cn(s)},cn),{isClass:!0}),um="Matrix",lm=[],cm=mt(um,lm,()=>{function s(){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator")}return s.prototype.type="Matrix",s.prototype.isMatrix=!0,s.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},s.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},s.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},s.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},s.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},s.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},s.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},s.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},s.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},s.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},s.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},s.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},s.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},s.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},s.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},s.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},s.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},s},{isClass:!0});function Ac(s){return Object.keys(s.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var fm="DenseMatrix",hm=["Matrix"],pm=mt(fm,hm,s=>{var{Matrix:t}=s;function e(h,f){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!tn(f))throw new Error("Invalid datatype: "+f);if(ve(h))h.type==="DenseMatrix"?(this._data=se(h._data),this._size=se(h._size),this._datatype=f||h._datatype):(this._data=h.toArray(),this._size=h.size(),this._datatype=f||h._datatype);else if(h&&Ee(h.data)&&Ee(h.size))this._data=h.data,this._size=h.size,Ql(this._data,this._size),this._datatype=f||h.datatype;else if(Ee(h))this._data=p(h),this._size=Te(this._data),Ql(this._data,this._size),this._datatype=f;else{if(h)throw new TypeError("Unsupported type of data ("+En(h)+")");this._data=[],this._size=[0],this._datatype=f}}e.prototype=new t,e.prototype.createDenseMatrix=function(h,f){return new e(h,f)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Fs(this._data,En)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(h,f){return new e(h,f)},e.prototype.subset=function(h,f,d){switch(arguments.length){case 1:return r(this,h);case 2:case 3:return i(this,h,f,d);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(h){if(!Ee(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Ht(h.length,this._size.length);for(var f=0;f<h.length;f++)Ae(h[f],this._size[f]);for(var d=this._data,g=0,y=h.length;g<y;g++){var m=h[g];Ae(m,d.length),d=d[m]}return d},e.prototype.set=function(h,f,d){if(!Ee(h))throw new TypeError("Array expected");if(h.length<this._size.length)throw new Ht(h.length,this._size.length,"<");var g,y,m,w=h.map(function(x){return x+1});c(this,w,d);var v=this._data;for(g=0,y=h.length-1;g<y;g++)m=h[g],Ae(m,v.length),v=v[m];return m=h[h.length-1],Ae(m,v.length),v[m]=f,this};function r(h,f){if(!la(f))throw new TypeError("Invalid index");var d=f.isScalar();if(d)return h.get(f.min());var g=f.size();if(g.length!==h._size.length)throw new Ht(g.length,h._size.length);for(var y=f.min(),m=f.max(),w=0,v=h._size.length;w<v;w++)Ae(y[w],h._size[w]),Ae(m[w],h._size[w]);return new e(n(h._data,f,g.length,0),h._datatype)}function n(h,f,d,g){var y=g===d-1,m=f.dimension(g);return y?m.map(function(w){return Ae(w,h.length),h[w]}).valueOf():m.map(function(w){Ae(w,h.length);var v=h[w];return n(v,f,d,g+1)}).valueOf()}function i(h,f,d,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var y=f.size(),m=f.isScalar(),w;if(ve(d)?(w=d.size(),d=d.valueOf()):w=Te(d),m){if(w.length!==0)throw new TypeError("Scalar expected");h.set(f.min(),d,g)}else{if(!hi(w,y))try{w.length===0?d=sc([d],y):d=sc(d,y),w=Te(d)}catch{}if(y.length<h._size.length)throw new Ht(y.length,h._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++;d=ec(d,y.length,x,w)}if(!hi(y,w))throw new Ht(y,w,">");var b=f.max().map(function(A){return A+1});c(h,b,g);var N=y.length,E=0;a(h._data,f,d,N,E)}return h}function a(h,f,d,g,y){var m=y===g-1,w=f.dimension(y);m?w.forEach(function(v,x){Ae(v),h[v]=d[x[0]]}):w.forEach(function(v,x){Ae(v),a(h[v],f,d[x[0]],g,y+1)})}e.prototype.resize=function(h,f,d){if(!Zi(h))throw new TypeError("Array or Matrix expected");var g=h.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),y=d?this.clone():this;return l(y,g,f)};function l(h,f,d){if(f.length===0){for(var g=h._data;Ee(g);)g=g[0];return g}return h._size=f.slice(0),h._data=da(h._data,h._size,d),h}e.prototype.reshape=function(h,f){var d=f?this.clone():this;d._data=ma(d._data,h);var g=d._size.reduce((y,m)=>y*m);return d._size=ga(h,g),d};function c(h,f,d){for(var g=h._size.slice(0),y=!1;g.length<f.length;)g.push(0),y=!0;for(var m=0,w=f.length;m<w;m++)f[m]>g[m]&&(g[m]=f[m],y=!0);y&&l(h,g,d)}e.prototype.clone=function(){var h=new e({data:se(this._data),size:se(this._size),datatype:this._datatype});return h},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(h){var f=this,d=Ac(h),g=function w(v,x){return Ee(v)?v.map(function(b,N){return w(b,x.concat(N))}):d===1?h(v):d===2?h(v,x):h(v,x,f)},y=g(this._data,[]),m=this._datatype!==void 0?Fs(y,En):void 0;return new e(y,m)},e.prototype.forEach=function(h){var f=this,d=function g(y,m){Ee(y)?y.forEach(function(w,v){g(w,m.concat(v))}):h(y,m,f)};d(this._data,[])},e.prototype[Symbol.iterator]=function*(){var h=function*f(d,g){if(Ee(d))for(var y=0;y<d.length;y++)yield*f(d[y],g.concat(y));else yield{value:d,index:g}};yield*h(this._data,[])},e.prototype.rows=function(){var h=[],f=this.size();if(f.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var d=this._data;for(var g of d)h.push(new e([g],this._datatype));return h},e.prototype.columns=function(){var h=this,f=[],d=this.size();if(d.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,y=function(v){var x=g.map(b=>[b[v]]);f.push(new e(x,h._datatype))},m=0;m<d[1];m++)y(m);return f},e.prototype.toArray=function(){return se(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(h){return fe(this._data,h)},e.prototype.toString=function(){return fe(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(h){if(h){if(Se(h)&&(h=h.toNumber()),!de(h)||!De(h))throw new TypeError("The parameter k must be an integer number")}else h=0;for(var f=h>0?h:0,d=h<0?-h:0,g=this._size[0],y=this._size[1],m=Math.min(g-d,y-f),w=[],v=0;v<m;v++)w[v]=this._data[v+d][v+f];return new e({data:w,size:[m],datatype:this._datatype})},e.diagonal=function(h,f,d,g){if(!Ee(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(M){if(Se(M)&&(M=M.toNumber()),!de(M)||!De(M)||M<1)throw new Error("Size values must be positive integers");return M}),d){if(Se(d)&&(d=d.toNumber()),!de(d)||!De(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var y=d>0?d:0,m=d<0?-d:0,w=h[0],v=h[1],x=Math.min(w-m,v-y),b;if(Ee(f)){if(f.length!==x)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(ve(f)){var N=f.size();if(N.length!==1||N[0]!==x)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=Se(b(0))?b(0).mul(0):0);var E=[];if(h.length>0){E=da(E,h,g);for(var A=0;A<x;A++)E[A+m][A+y]=b(A)}return new e({data:E,size:[w,v]})},e.fromJSON=function(h){return new e(h)},e.prototype.swapRows=function(h,f){if(!de(h)||!De(h)||!de(f)||!De(f))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ae(h,this._size[0]),Ae(f,this._size[0]),e._swapRows(h,f,this._data),this},e._swapRows=function(h,f,d){var g=d[h];d[h]=d[f],d[f]=g};function p(h){return ve(h)?p(h.valueOf()):Ee(h)?h.map(p):h}return e},{isClass:!0});function dm(s){var t=s.length,e=s[0].length,r,n,i=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(s[r][n]);i.push(a)}return i}function Rs(s){for(var t=0;t<s.length;t++)if(Zi(s[t]))return!0;return!1}function Hi(s,t){ve(s)&&(s=s.valueOf());for(var e=0,r=s.length;e<r;e++){var n=s[e];Array.isArray(n)?Hi(n,t):t(n)}}function Vr(s,t,e){return s&&typeof s.map=="function"?s.map(function(r){return Vr(r,t)}):t(s)}function Fa(s,t,e){var r=Array.isArray(s)?Te(s):s.size();if(t<0||t>=r.length)throw new An(t,r.length);return ve(s)?s.create(Ps(s.valueOf(),t,e)):Ps(s,t,e)}function Ps(s,t,e){var r,n,i,a;if(t<=0)if(Array.isArray(s[0])){for(a=dm(s),n=[],r=0;r<a.length;r++)n[r]=Ps(a[r],t-1,e);return n}else{for(i=s[0],r=1;r<s.length;r++)i=e(i,s[r]);return i}else{for(n=[],r=0;r<s.length;r++)n[r]=Ps(s[r],t-1,e);return n}}var Cc="isInteger",_m=["typed"],mm=mt(Cc,_m,s=>{var{typed:t}=s;return t(Cc,{number:De,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Fc="number",zs="number, number";function Mc(s){return Math.abs(s)}Mc.signature=Fc;function Nc(s,t){return s+t}Nc.signature=zs;function Sc(s,t){return s-t}Sc.signature=zs;function Bc(s,t){return s*t}Bc.signature=zs;function Oc(s){return-s}Oc.signature=Fc;function Ic(s,t){return s*s<1&&t===1/0||s*s>1&&t===-1/0?0:Math.pow(s,t)}Ic.signature=zs;var Tc="number";function $c(s){return s===0}$c.signature=Tc;function Lc(s){return Number.isNaN(s)}Lc.signature=Tc;var Rc="isNumeric",gm=["typed"],vm=mt(Rc,gm,s=>{var{typed:t}=s;return t(Rc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Pc="isZero",ym=["typed"],wm=mt(Pc,ym,s=>{var{typed:t}=s;return t(Pc,{number:$c,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=>Vr(r,e))})}),zc="isNaN",Dm=["typed"],bm=mt(zc,Dm,s=>{var{typed:t}=s;return t(zc,{number:Lc,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 Vr(r,Number.isNaN)}})});function qs(s,t,e){if(e==null)return s.eq(t);if(s.eq(t))return!0;if(s.isNaN()||t.isNaN())return!1;if(s.isFinite()&&t.isFinite()){var r=s.minus(t).abs();if(r.isZero())return!0;var n=s.constructor.max(s.abs(),t.abs());return r.lte(n.times(e))}return!1}function xm(s,t,e){return Gn(s.re,t.re,e)&&Gn(s.im,t.im,e)}var ks=mt("compareUnits",["typed"],s=>{var{typed:t}=s;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)})}}),Us="equalScalar",Em=["typed","config"],Am=mt(Us,Em,s=>{var{typed:t,config:e}=s,r=ks({typed:t});return t(Us,{"boolean, boolean":function(i,a){return i===a},"number, number":function(i,a){return Gn(i,a,e.epsilon)},"BigNumber, BigNumber":function(i,a){return i.eq(a)||qs(i,a,e.epsilon)},"Fraction, Fraction":function(i,a){return i.equals(a)},"Complex, Complex":function(i,a){return xm(i,a,e.epsilon)}},r)});mt(Us,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Us,{"number, number":function(n,i){return Gn(n,i,e.epsilon)}})});var Cm="SparseMatrix",Fm=["typed","equalScalar","Matrix"],Mm=mt(Cm,Fm,s=>{var{typed:t,equalScalar:e,Matrix:r}=s;function n(m,w){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(w&&!tn(w))throw new Error("Invalid datatype: "+w);if(ve(m))i(this,m,w);else if(m&&Ee(m.index)&&Ee(m.ptr)&&Ee(m.size))this._values=m.values,this._index=m.index,this._ptr=m.ptr,this._size=m.size,this._datatype=w||m.datatype;else if(Ee(m))a(this,m,w);else{if(m)throw new TypeError("Unsupported type of data ("+En(m)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=w}}function i(m,w,v){w.type==="SparseMatrix"?(m._values=w._values?se(w._values):void 0,m._index=se(w._index),m._ptr=se(w._ptr),m._size=se(w._size),m._datatype=v||w._datatype):a(m,w.valueOf(),v||w._datatype)}function a(m,w,v){m._values=[],m._index=[],m._ptr=[],m._datatype=v;var x=w.length,b=0,N=e,E=0;if(tn(v)&&(N=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var A=0;do{m._ptr.push(m._index.length);for(var M=0;M<x;M++){var S=w[M];if(Ee(S)){if(A===0&&b<S.length&&(b=S.length),A<S.length){var T=S[A];N(T,E)||(m._values.push(T),m._index.push(M))}}else A===0&&b<1&&(b=1),N(S,E)||(m._values.push(S),m._index.push(M))}A++}while(A<b)}m._ptr.push(m._index.length),m._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(m,w){return new n(m,w)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Fs(this._values,En)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(m,w){return new n(m,w)},n.prototype.density=function(){var m=this._size[0],w=this._size[1];return m!==0&&w!==0?this._index.length/(m*w):0},n.prototype.subset=function(m,w,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,m);case 2:case 3:return c(this,m,w,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(m,w){if(!la(w))throw new TypeError("Invalid index");var v=w.isScalar();if(v)return m.get(w.min());var x=w.size();if(x.length!==m._size.length)throw new Ht(x.length,m._size.length);var b,N,E,A,M=w.min(),S=w.max();for(b=0,N=m._size.length;b<N;b++)Ae(M[b],m._size[b]),Ae(S[b],m._size[b]);var T=m._values,F=m._index,O=m._ptr,R=w.dimension(0),U=w.dimension(1),k=[],W=[];R.forEach(function(X,Q){W[X]=Q[0],k[X]=!0});var z=T?[]:void 0,K=[],Z=[];return U.forEach(function(X){for(Z.push(K.length),E=O[X],A=O[X+1];E<A;E++)b=F[E],k[b]===!0&&(K.push(W[b]),z&&z.push(T[E]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:x,datatype:m._datatype})}function c(m,w,v,x){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),N=w.isScalar(),E;if(ve(v)?(E=v.size(),v=v.toArray()):E=Te(v),N){if(E.length!==0)throw new TypeError("Scalar expected");m.set(w.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Ht(b.length,m._size.length,"<");if(E.length<b.length){for(var A=0,M=0;b[A]===1&&E[A]===1;)A++;for(;b[A]===1;)M++,A++;v=ec(v,b.length,M,E)}if(!hi(b,E))throw new Ht(b,E,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(O,R){Ae(O),m.set([O,0],v[R[0]],x)})}else{var T=w.dimension(0),F=w.dimension(1);T.forEach(function(O,R){Ae(O),F.forEach(function(U,k){Ae(U),m.set([O,U],v[R[0]][k[0]],x)})})}}return m}n.prototype.get=function(m){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var w=m[0],v=m[1];Ae(w,this._size[0]),Ae(v,this._size[1]);var x=p(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(m,w,v){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=m[0],b=m[1],N=this._size[0],E=this._size[1],A=e,M=0;tn(this._datatype)&&(A=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(x>N-1||b>E-1)&&(d(this,Math.max(x+1,N),Math.max(b+1,E),v),N=this._size[0],E=this._size[1]),Ae(x,N),Ae(b,E);var S=p(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?A(w,M)?h(S,b,this._values,this._index,this._ptr):this._values[S]=w:A(w,M)||f(S,x,b,w,this._values,this._index,this._ptr),this};function p(m,w,v,x){if(v-w===0)return v;for(var b=w;b<v;b++)if(x[b]===m)return b;return w}function h(m,w,v,x,b){v.splice(m,1),x.splice(m,1);for(var N=w+1;N<b.length;N++)b[N]--}function f(m,w,v,x,b,N,E){b.splice(m,0,x),N.splice(m,0,w);for(var A=v+1;A<E.length;A++)E[A]++}n.prototype.resize=function(m,w,v){if(!Zi(m))throw new TypeError("Array or Matrix expected");var x=m.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(N){if(!de(N)||!De(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(x)+")")});var b=v?this.clone():this;return d(b,x[0],x[1],w)};function d(m,w,v,x){var b=x||0,N=e,E=0;tn(m._datatype)&&(N=t.find(e,[m._datatype,m._datatype])||e,E=t.convert(0,m._datatype),b=t.convert(b,m._datatype));var A=!N(b,E),M=m._size[0],S=m._size[1],T,F,O;if(v>S){for(F=S;F<v;F++)if(m._ptr[F]=m._values.length,A)for(T=0;T<M;T++)m._values.push(b),m._index.push(T);m._ptr[v]=m._values.length}else v<S&&(m._ptr.splice(v+1,S-v),m._values.splice(m._ptr[v],m._values.length),m._index.splice(m._ptr[v],m._index.length));if(S=v,w>M){if(A){var R=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]+R,O=m._ptr[F+1]+R;var U=0;for(T=M;T<w;T++,U++)m._values.splice(O+U,0,b),m._index.splice(O+U,0,T),R++}m._ptr[S]=m._values.length}}else if(w<M){var k=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]-k;var W=m._ptr[F],z=m._ptr[F+1]-k;for(O=W;O<z;O++)T=m._index[O],T>w-1&&(m._values.splice(O,1),m._index.splice(O,1),k++)}m._ptr[F]=m._values.length}return m._size[0]=w,m._size[1]=v,m}n.prototype.reshape=function(m,w){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");m.forEach(function(X){if(!de(X)||!De(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+fe(m)+")")});var v=this._size[0]*this._size[1];m=ga(m,v);var x=m[0]*m[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]===m[0]&&this._size[1]===m[1])return b;for(var N=[],E=0;E<b._ptr.length;E++)for(var A=0;A<b._ptr[E+1]-b._ptr[E];A++)N.push(E);for(var M=b._values.slice(),S=b._index.slice(),T=0;T<b._index.length;T++){var F=S[T],O=N[T],R=F*b._size[1]+O;N[T]=R%m[1],S[T]=Math.floor(R/m[1])}b._values.length=0,b._index.length=0,b._ptr.length=m[1]+1,b._size=m.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var k=0;k<M.length;k++){var W=S[k],z=N[k],K=M[k],Z=p(W,b._ptr[z],b._ptr[z+1],b._index);f(Z,W,z,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var m=new n({values:this._values?se(this._values):void 0,index:se(this._index),ptr:se(this._ptr),size:se(this._size),datatype:this._datatype});return m},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(m,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],N=Ac(m),E=function(M,S,T){return N===1?m(M):N===2?m(M,[S,T]):m(M,[S,T],v)};return g(this,0,x-1,0,b-1,E,w)};function g(m,w,v,x,b,N,E){var A=[],M=[],S=[],T=e,F=0;tn(m._datatype)&&(T=t.find(e,[m._datatype,m._datatype])||e,F=t.convert(0,m._datatype));for(var O=function(lt,wt,bt){lt=N(lt,wt,bt),T(lt,F)||(A.push(lt),M.push(wt))},R=x;R<=b;R++){S.push(A.length);var U=m._ptr[R],k=m._ptr[R+1];if(E)for(var W=U;W<k;W++){var z=m._index[W];z>=w&&z<=v&&O(m._values[W],z-w,R-x)}else{for(var K={},Z=U;Z<k;Z++){var X=m._index[Z];K[X]=m._values[Z]}for(var Q=w;Q<=v;Q++){var ct=Q in K?K[Q]:0;O(ct,Q-w,R-x)}}}return S.push(A.length),new n({values:A,index:M,ptr:S,size:[v-w+1,b-x+1]})}n.prototype.forEach=function(m,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],N=0;N<b;N++){var E=this._ptr[N],A=this._ptr[N+1];if(w)for(var M=E;M<A;M++){var S=this._index[M];m(this._values[M],[S,N],v)}else{for(var T={},F=E;F<A;F++){var O=this._index[F];T[O]=this._values[F]}for(var R=0;R<x;R++){var U=R in T?T[R]:0;m(U,[R,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var m=this._size[1],w=0;w<m;w++)for(var v=this._ptr[w],x=this._ptr[w+1],b=v;b<x;b++){var N=this._index[b];yield{value:this._values[b],index:[N,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(m,w,v,x,b){var N=x[0],E=x[1],A=[],M,S;for(M=0;M<N;M++)for(A[M]=[],S=0;S<E;S++)A[M][S]=0;for(S=0;S<E;S++)for(var T=v[S],F=v[S+1],O=T;O<F;O++)M=w[O],A[M][S]=m?b?se(m[O]):m[O]:1;return A}return n.prototype.format=function(m){for(var w=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+fe(w,m)+" x "+fe(v,m)+"] density: "+fe(x,m)+`
|
53
|
+
`,N=0;N<v;N++)for(var E=this._ptr[N],A=this._ptr[N+1],M=E;M<A;M++){var S=this._index[M];b+=`
|
54
|
+
(`+fe(S,m)+", "+fe(N,m)+") ==> "+(this._values?fe(this._values[M],m):"X")}return b},n.prototype.toString=function(){return fe(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(m){if(m){if(Se(m)&&(m=m.toNumber()),!de(m)||!De(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var w=m>0?m:0,v=m<0?-m:0,x=this._size[0],b=this._size[1],N=Math.min(x-v,b-w),E=[],A=[],M=[];M[0]=0;for(var S=w;S<b&&E.length<N;S++)for(var T=this._ptr[S],F=this._ptr[S+1],O=T;O<F;O++){var R=this._index[O];if(R===S-w+v){E.push(this._values[O]),A[E.length-1]=R-v;break}}return M.push(E.length),new n({values:E,index:A,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,w,v,x,b){if(!Ee(m))throw new TypeError("Array expected, size parameter");if(m.length!==2)throw new Error("Only two dimensions matrix are supported");if(m=m.map(function(X){if(Se(X)&&(X=X.toNumber()),!de(X)||!De(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Se(v)&&(v=v.toNumber()),!de(v)||!De(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,E=0;tn(b)&&(N=t.find(e,[b,b])||e,E=t.convert(0,b));var A=v>0?v:0,M=v<0?-v:0,S=m[0],T=m[1],F=Math.min(S-M,T-A),O;if(Ee(w)){if(w.length!==F)throw new Error("Invalid value array length");O=function(Q){return w[Q]}}else if(ve(w)){var R=w.size();if(R.length!==1||R[0]!==F)throw new Error("Invalid matrix length");O=function(Q){return w.get([Q])}}else O=function(){return w};for(var U=[],k=[],W=[],z=0;z<T;z++){W.push(U.length);var K=z-A;if(K>=0&&K<F){var Z=O(K);N(Z,E)||(k.push(K+M),U.push(Z))}}return W.push(U.length),new n({values:U,index:k,ptr:W,size:[S,T]})},n.prototype.swapRows=function(m,w){if(!de(m)||!De(m)||!de(w)||!De(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 Ae(m,this._size[0]),Ae(w,this._size[0]),n._swapRows(m,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,w,v,x,b){for(var N=x[m],E=x[m+1],A=N;A<E;A++)b(v[A],w[A])},n._swapRows=function(m,w,v,x,b,N){for(var E=0;E<v;E++){var A=N[E],M=N[E+1],S=p(m,A,M,b),T=p(w,A,M,b);if(S<M&&T<M&&b[S]===m&&b[T]===w){if(x){var F=x[S];x[S]=x[T],x[T]=F}continue}if(S<M&&b[S]===m&&(T>=M||b[T]!==w)){var O=x?x[S]:void 0;b.splice(T,0,w),x&&x.splice(T,0,O),b.splice(T<=S?S+1:S,1),x&&x.splice(T<=S?S+1:S,1);continue}if(T<M&&b[T]===w&&(S>=M||b[S]!==m)){var R=x?x[T]:void 0;b.splice(S,0,m),x&&x.splice(S,0,R),b.splice(S<=T?T+1:T,1),x&&x.splice(S<=T?T+1:T,1)}}},n},{isClass:!0}),Nm="number",Sm=["typed"];function Bm(s){var t=s.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:s,radix:e,integerPart:r,fractionalPart:n}}else return null}function Om(s){for(var t=parseInt(s.integerPart,s.radix),e=0,r=0;r<s.fractionalPart.length;r++){var n=parseInt(s.fractionalPart[r],s.radix);e+=n/Math.pow(s.radix,r+1)}var i=t+e;if(isNaN(i))throw new SyntaxError('String "'+s.input+'" is not a valid number');return i}var Im=mt(Nm,Sm,s=>{var{typed:t}=s,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Bm(n);if(i)return Om(i);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":t.referToSelf(r=>n=>Vr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Tm="bignumber",$m=["typed","BigNumber"],Lm=mt(Tm,$m,s=>{var{typed:t,BigNumber:e}=s;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var a=i[2],l=e(i[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var p=new e(2).pow(Number(a)-1);return l.gte(p)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),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=>Vr(n,r))})}),Rm="fraction",Pm=["typed","Fraction"],zm=mt(Rm,Pm,s=>{var{typed:t,Fraction:e}=s;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,i){return new e(n,i)},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 i=n.clone();return i.value=r(n.value),i}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Vr(n,r))})}),qc="matrix",qm=["typed","Matrix","DenseMatrix","SparseMatrix"],km=mt(qc,qm,s=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=s;return t(qc,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,c){return i([],l,c)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(a,l,c){if(l==="dense"||l==="default"||l===void 0)return new r(a,c);if(l==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),kc="unaryMinus",Um=["typed"],Wm=mt(kc,Um,s=>{var{typed:t}=s;return t(kc,{number:Oc,"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=>Vr(r,e))})}),Uc="abs",jm=["typed"],Ym=mt(Uc,jm,s=>{var{typed:t}=s;return t(Uc,{number:Mc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Wc="addScalar",Vm=["typed"],Zm=mt(Wc,Vm,s=>{var{typed:t}=s;return t(Wc,{"number, number":Nc,"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 i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),jc="subtractScalar",Km=["typed"],Gm=mt(jc,Km,s=>{var{typed:t}=s;return t(jc,{"number, number":Sc,"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 i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Hm="matAlgo11xS0s",Jm=["typed","equalScalar"],Ma=mt(Hm,Jm,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=e,v=0,x=a;typeof d=="string"&&(m=d,w=t.find(e,[m,m]),v=t.convert(0,m),i=t.convert(i,m),x=t.find(a,[m,m]));for(var b=[],N=[],E=[],A=0;A<y;A++){E[A]=N.length;for(var M=h[A],S=h[A+1],T=M;T<S;T++){var F=p[T],O=l?x(i,c[T]):x(c[T],i);w(O,v)||(N.push(F),b.push(O))}}return E[y]=N.length,n.createSparseMatrix({values:b,index:N,ptr:E,size:[g,y],datatype:m})}}),Xm="matAlgo12xSfs",Qm=["typed","DenseMatrix"],vi=mt(Xm,Qm,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,A=h[N],M=h[N+1],S=A;S<M;S++){var T=p[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=l?w(i,0):w(0,i)}return new e({data:v,size:[g,y],datatype:m})}}),tg="matAlgo14xDs",eg=["typed"],Na=mt(tg,eg,s=>{var{typed:t}=s;return function(n,i,a,l){var c=n._data,p=n._size,h=n._datatype,f,d=a;typeof h=="string"&&(f=h,i=t.convert(i,f),d=t.find(a,[f,f]));var g=p.length>0?e(d,0,p,p[0],c,i,l):[];return n.createDenseMatrix({data:g,size:se(p),datatype:f})};function e(r,n,i,a,l,c,p){var h=[];if(n===i.length-1)for(var f=0;f<a;f++)h[f]=p?r(c,l[f]):r(l[f],c);else for(var d=0;d<a;d++)h[d]=e(r,n+1,i,i[n+1],l[d],c,p);return h}}),rg="matAlgo02xDS0",ng=["typed","equalScalar"],ig=mt(rg,ng,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._data,p=n._size,h=n._datatype||n.getDataType(),f=i._values,d=i._index,g=i._ptr,y=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(p.length!==y.length)throw new Ht(p.length,y.length);if(p[0]!==y[0]||p[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+y+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=p[0],v=p[1],x,b=e,N=0,E=a;typeof h=="string"&&h===m&&h!=="mixed"&&(x=h,b=t.find(e,[x,x]),N=t.convert(0,x),E=t.find(a,[x,x]));for(var A=[],M=[],S=[],T=0;T<v;T++){S[T]=M.length;for(var F=g[T],O=g[T+1],R=F;R<O;R++){var U=d[R],k=l?E(f[R],c[U][T]):E(c[U][T],f[R]);b(k,N)||(M.push(U),A.push(k))}}return S[v]=M.length,i.createSparseMatrix({values:A,index:M,ptr:S,size:[w,v],datatype:h===n._datatype&&m===i._datatype?x:void 0})}}),sg="matAlgo03xDSf",og=["typed"],yi=mt(sg,og,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,p=r._datatype||r.getDataType(),h=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(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(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v,x=0,b=i;typeof p=="string"&&p===y&&p!=="mixed"&&(v=p,x=t.convert(0,v),b=t.find(i,[v,v]));for(var N=[],E=0;E<m;E++)N[E]=[];for(var A=[],M=[],S=0;S<w;S++){for(var T=S+1,F=d[S],O=d[S+1],R=F;R<O;R++){var U=f[R];A[U]=a?b(h[R],l[U][S]):b(l[U][S],h[R]),M[U]=T}for(var k=0;k<m;k++)M[k]===T?N[k][S]=A[k]:N[k][S]=a?b(x,l[k][S]):b(l[k][S],x)}return r.createDenseMatrix({data:N,size:[m,w],datatype:p===r._datatype&&y===n._datatype?v:void 0})}}),ag="matAlgo05xSfSf",ug=["typed","equalScalar"],Yc=mt(ag,ug,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,p=n._ptr,h=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==m.length)throw new Ht(h.length,m.length);if(h[0]!==m[0]||h[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+m+")");var v=h[0],x=h[1],b,N=e,E=0,A=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],T=[],F=M?[]:void 0,O=M?[]:void 0,R=[],U=[],k,W,z,K;for(W=0;W<x;W++){T[W]=S.length;var Z=W+1;for(z=p[W],K=p[W+1];z<K;z++)k=c[z],S.push(k),R[k]=Z,F&&(F[k]=l[z]);for(z=y[W],K=y[W+1];z<K;z++)k=g[z],R[k]!==Z&&S.push(k),U[k]=Z,O&&(O[k]=d[z]);if(M)for(z=T[W];z<S.length;){k=S[z];var X=R[k],Q=U[k];if(X===Z||Q===Z){var ct=X===Z?F[k]:E,vt=Q===Z?O[k]:E,lt=A(ct,vt);N(lt,E)?S.splice(z,1):(M.push(lt),z++)}}}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),lg="matAlgo13xDD",cg=["typed"],fg=mt(lg,cg,s=>{var{typed:t}=s;return function(n,i,a){var l=n._data,c=n._size,p=n._datatype,h=i._data,f=i._size,d=i._datatype,g=[];if(c.length!==f.length)throw new Ht(c.length,f.length);for(var y=0;y<c.length;y++){if(c[y]!==f[y])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[y]=c[y]}var m,w=a;typeof p=="string"&&p===d&&(m=p,w=t.find(a,[m,m]));var v=g.length>0?e(w,0,g,g[0],l,h):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,i,a,l,c){var p=[];if(n===i.length-1)for(var h=0;h<a;h++)p[h]=r(l[h],c[h]);else for(var f=0;f<a;f++)p[f]=e(r,n+1,i,i[n+1],l[f],c[f]);return p}}),hg="broadcast",pg=["concat"],dg=mt(hg,pg,s=>{var{concat:t}=s;return function(n,i){var a=Math.max(n._size.length,i._size.length);if(n._size.length===i._size.length&&n._size.every((y,m)=>y===i._size[m]))return[n,i];for(var l=e(n._size,a,0),c=e(i._size,a,0),p=[],h=0;h<a;h++)p[h]=Math.max(l[h],c[h]);Ms(l,p),Ms(c,p);var f=n.clone(),d=i.clone();f._size.length<a?f.reshape(e(f._size,a,1)):d._size.length<a&&d.reshape(e(d._size,a,1));for(var g=0;g<a;g++)f._size[g]<p[g]&&(f=r(f,p[g],g)),d._size[g]<p[g]&&(d=r(d,p[g],g));return[f,d]};function e(n,i,a){return[...Array(i-n.length).fill(a),...n]}function r(n,i,a){return t(...Array(i).fill(n),a)}}),_g="matrixAlgorithmSuite",mg=["typed","matrix","concat"],Hn=mt(_g,mg,s=>{var{typed:t,matrix:e,concat:r}=s,n=fg({typed:t}),i=Na({typed:t}),a=dg({concat:r});return function(c){var p=c.elop,h=c.SD||c.DS,f;p?(f={"DenseMatrix, DenseMatrix":(m,w)=>n(...a(m,w),p),"Array, Array":(m,w)=>n(...a(e(m),e(w)),p).valueOf(),"Array, DenseMatrix":(m,w)=>n(...a(e(m),w),p),"DenseMatrix, Array":(m,w)=>n(...a(m,e(w)),p)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,w)=>c.SS(...a(m,w),p,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,w)=>c.DS(...a(m,w),p,!1),f["Array, SparseMatrix"]=(m,w)=>c.DS(...a(e(m),w),p,!1)),h&&(f["SparseMatrix, DenseMatrix"]=(m,w)=>h(...a(w,m),p,!0),f["SparseMatrix, Array"]=(m,w)=>h(...a(e(w),m),p,!0))):(f={"DenseMatrix, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(w,v),m)),"Array, Array":t.referToSelf(m=>(w,v)=>n(...a(e(w),e(v)),m).valueOf()),"Array, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(e(w),v),m)),"DenseMatrix, Array":t.referToSelf(m=>(w,v)=>n(...a(w,e(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.SS(...a(w,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(w,v),m,!1)),f["Array, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(e(w),v),m,!1))),h&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(w,v)=>h(...a(v,w),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(w,v)=>h(...a(e(v),w),m,!0))));var d=c.scalar||"any",g=c.Ds||c.Ss;g&&(p?(f["DenseMatrix,"+d]=(m,w)=>i(m,w,p,!1),f[d+", DenseMatrix"]=(m,w)=>i(w,m,p,!0),f["Array,"+d]=(m,w)=>i(e(m),w,p,!1).valueOf(),f[d+", Array"]=(m,w)=>i(e(w),m,p,!0).valueOf()):(f["DenseMatrix,"+d]=t.referToSelf(m=>(w,v)=>i(w,v,m,!1)),f[d+", DenseMatrix"]=t.referToSelf(m=>(w,v)=>i(v,w,m,!0)),f["Array,"+d]=t.referToSelf(m=>(w,v)=>i(e(w),v,m,!1).valueOf()),f[d+", Array"]=t.referToSelf(m=>(w,v)=>i(e(v),w,m,!0).valueOf())));var y=c.sS!==void 0?c.sS:c.Ss;return p?(c.Ss&&(f["SparseMatrix,"+d]=(m,w)=>c.Ss(m,w,p,!1)),y&&(f[d+", SparseMatrix"]=(m,w)=>y(w,m,p,!0))):(c.Ss&&(f["SparseMatrix,"+d]=t.referToSelf(m=>(w,v)=>c.Ss(w,v,m,!1))),y&&(f[d+", SparseMatrix"]=t.referToSelf(m=>(w,v)=>y(v,w,m,!0)))),p&&p.signatures&&Pl(f,p.signatures),f}}),gg="matAlgo01xDSid",vg=["typed"],Vc=mt(gg,vg,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,p=r._datatype||r.getDataType(),h=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(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(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v=typeof p=="string"&&p!=="mixed"&&p===y?p:void 0,x=v?t.find(i,[v,v]):i,b,N,E=[];for(b=0;b<m;b++)E[b]=[];var A=[],M=[];for(N=0;N<w;N++){for(var S=N+1,T=d[N],F=d[N+1],O=T;O<F;O++)b=f[O],A[b]=a?x(h[O],l[b][N]):x(l[b][N],h[O]),M[b]=S;for(b=0;b<m;b++)M[b]===S?E[b][N]=A[b]:E[b][N]=l[b][N]}return r.createDenseMatrix({data:E,size:[m,w],datatype:p===r._datatype&&y===n._datatype?v:void 0})}}),yg="matAlgo04xSidSid",wg=["typed","equalScalar"],Dg=mt(yg,wg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,p=n._ptr,h=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==m.length)throw new Ht(h.length,m.length);if(h[0]!==m[0]||h[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+m+")");var v=h[0],x=h[1],b,N=e,E=0,A=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],T=[],F=l&&d?[]:void 0,O=l&&d?[]:void 0,R=[],U=[],k,W,z,K,Z;for(W=0;W<x;W++){T[W]=S.length;var X=W+1;for(K=p[W],Z=p[W+1],z=K;z<Z;z++)k=c[z],S.push(k),R[k]=X,F&&(F[k]=l[z]);for(K=y[W],Z=y[W+1],z=K;z<Z;z++)if(k=g[z],R[k]===X){if(F){var Q=A(F[k],d[z]);N(Q,E)?R[k]=null:F[k]=Q}}else S.push(k),U[k]=X,O&&(O[k]=d[z]);if(F&&O)for(z=T[W];z<S.length;)k=S[z],R[k]===X?(M[z]=F[k],z++):U[k]===X?(M[z]=O[k],z++):S.splice(z,1)}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),bg="matAlgo10xSids",xg=["typed","DenseMatrix"],Zc=mt(bg,xg,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,A=h[N],M=h[N+1],S=A;S<M;S++){var T=p[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=i}return new e({data:v,size:[g,y],datatype:m})}}),Eg="multiplyScalar",Ag=["typed"],Cg=mt(Eg,Ag,s=>{var{typed:t}=s;return t("multiplyScalar",{"number, number":Bc,"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)})}),Kc="multiply",Fg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Mg=mt(Kc,Fg,s=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:i,dot:a}=s,l=Ma({typed:t,equalScalar:i}),c=Na({typed:t});function p(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 h(E,A,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(E,A)}function f(E,A){if(A.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(E,A)}function d(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,O=A._size,R=A._datatype||A.getDataType(),U=S[0],k=O[1],W,z=r,K=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&(W=T,z=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var Z=[],X=0;X<k;X++){for(var Q=K(M[0],F[0][X]),ct=1;ct<U;ct++)Q=z(Q,K(M[ct],F[ct][X]));Z[X]=Q}return E.createDenseMatrix({data:Z,size:[k],datatype:T===E._datatype&&R===A._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":x}),y=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,O=A._datatype||A.getDataType(),R=S[0],U=S[1],k,W=r,z=n;T&&O&&T===O&&typeof T=="string"&&T!=="mixed"&&(k=T,W=t.find(r,[k,k]),z=t.find(n,[k,k]));for(var K=[],Z=0;Z<R;Z++){for(var X=M[Z],Q=z(X[0],F[0]),ct=1;ct<U;ct++)Q=W(Q,z(X[ct],F[ct]));K[Z]=Q}return E.createDenseMatrix({data:K,size:[R],datatype:T===E._datatype&&O===A._datatype?k:void 0})}function w(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,O=A._size,R=A._datatype||A.getDataType(),U=S[0],k=S[1],W=O[1],z,K=r,Z=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&T!=="mixed"&&(z=T,K=t.find(r,[z,z]),Z=t.find(n,[z,z]));for(var X=[],Q=0;Q<U;Q++){var ct=M[Q];X[Q]=[];for(var vt=0;vt<W;vt++){for(var lt=Z(ct[0],F[0][vt]),wt=1;wt<k;wt++)lt=K(lt,Z(ct[wt],F[wt][vt]));X[Q][vt]=lt}}return E.createDenseMatrix({data:X,size:[U,W],datatype:T===E._datatype&&R===A._datatype?z:void 0})}function v(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._values,O=A._index,R=A._ptr,U=A._size,k=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],z=U[1],K,Z=r,X=n,Q=i,ct=0;T&&k&&T===k&&typeof T=="string"&&T!=="mixed"&&(K=T,Z=t.find(r,[K,K]),X=t.find(n,[K,K]),Q=t.find(i,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],wt=[],bt=A.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[W,z],datatype:T===E._datatype&&k===A._datatype?K:void 0}),Bt=0;Bt<z;Bt++){wt[Bt]=lt.length;var xt=R[Bt],oe=R[Bt+1];if(oe>xt)for(var It=0,Nt=0;Nt<W;Nt++){for(var ce=Nt+1,re=void 0,kt=xt;kt<oe;kt++){var Jt=O[kt];It!==ce?(re=X(M[Nt][Jt],F[kt]),It=ce):re=Z(re,X(M[Nt][Jt],F[kt]))}It===ce&&!Q(re,ct)&&(lt.push(Nt),vt.push(re))}}return wt[z]=lt.length,bt}function x(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,R=A._datatype||A.getDataType(),U=E._size[0],k=A._size[0],W=[],z=[],K=[],Z,X=r,Q=n,ct=i,vt=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]),ct=t.find(i,[Z,Z]),vt=t.convert(0,Z));var lt=[],wt=[];K[0]=0;for(var bt=0;bt<k;bt++){var Bt=O[bt];if(!ct(Bt,vt))for(var xt=T[bt],oe=T[bt+1],It=xt;It<oe;It++){var Nt=S[It];wt[Nt]?lt[Nt]=X(lt[Nt],Q(Bt,M[It])):(wt[Nt]=!0,z.push(Nt),lt[Nt]=Q(Bt,M[It]))}}for(var ce=z.length,re=0;re<ce;re++){var kt=z[re];W[re]=lt[kt]}return K[1]=z.length,E.createSparseMatrix({values:W,index:z,ptr:K,size:[U,1],datatype:F===E._datatype&&R===A._datatype?Z:void 0})}function b(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,R=A._datatype||A.getDataType(),U=E._size[0],k=A._size[0],W=A._size[1],z,K=r,Z=n,X=i,Q=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(z=F,K=t.find(r,[z,z]),Z=t.find(n,[z,z]),X=t.find(i,[z,z]),Q=t.convert(0,z));for(var ct=[],vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,W],datatype:F===E._datatype&&R===A._datatype?z:void 0}),bt=[],Bt=[],xt=0;xt<W;xt++){lt[xt]=vt.length;for(var oe=xt+1,It=0;It<k;It++){var Nt=O[It][xt];if(!X(Nt,Q))for(var ce=T[It],re=T[It+1],kt=ce;kt<re;kt++){var Jt=S[kt];Bt[Jt]!==oe?(Bt[Jt]=oe,vt.push(Jt),bt[Jt]=Z(Nt,M[kt])):bt[Jt]=K(bt[Jt],Z(Nt,M[kt]))}}for(var Le=lt[xt],vr=vt.length,ze=Le;ze<vr;ze++){var pn=vt[ze];ct[ze]=bt[pn]}}return lt[W]=vt.length,wt}function N(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType(),O=A._values,R=A._index,U=A._ptr,k=A._datatype||A._data===void 0?A._datatype:A.getDataType(),W=E._size[0],z=A._size[1],K=M&&O,Z,X=r,Q=n;F&&k&&F===k&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]));for(var ct=K?[]:void 0,vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,z],datatype:F===E._datatype&&k===A._datatype?Z:void 0}),bt=K?[]:void 0,Bt=[],xt,oe,It,Nt,ce,re,kt,Jt,Le=0;Le<z;Le++){lt[Le]=vt.length;var vr=Le+1;for(ce=U[Le],re=U[Le+1],Nt=ce;Nt<re;Nt++)if(Jt=R[Nt],K)for(oe=T[Jt],It=T[Jt+1],xt=oe;xt<It;xt++)kt=S[xt],Bt[kt]!==vr?(Bt[kt]=vr,vt.push(kt),bt[kt]=Q(O[Nt],M[xt])):bt[kt]=X(bt[kt],Q(O[Nt],M[xt]));else for(oe=T[Jt],It=T[Jt+1],xt=oe;xt<It;xt++)kt=S[xt],Bt[kt]!==vr&&(Bt[kt]=vr,vt.push(kt));if(K)for(var ze=lt[Le],pn=vt.length,On=ze;On<pn;On++){var dn=vt[On];ct[On]=bt[dn]}}return lt[z]=vt.length,wt}return t(Kc,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(A,M)=>{p(Te(A),Te(M));var S=E(e(A),e(M));return ve(S)?S.valueOf():S}),"Matrix, Matrix":function(A,M){var S=A.size(),T=M.size();return p(S,T),S.length===1?T.length===1?h(A,M,S[0]):f(A,M):T.length===1?g(A,M):y(A,M)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(A,M)=>E(A,e(M))),"Array, Matrix":t.referToSelf(E=>(A,M)=>E(e(A,M.storage()),M)),"SparseMatrix, any":function(A,M){return l(A,M,n,!1)},"DenseMatrix, any":function(A,M){return c(A,M,n,!1)},"any, SparseMatrix":function(A,M){return l(M,A,n,!0)},"any, DenseMatrix":function(A,M){return c(M,A,n,!0)},"Array, any":function(A,M){return c(e(A),M,n,!1).valueOf()},"any, Array":function(A,M){return c(e(M),A,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(A,M,S)=>{for(var T=E(A,M),F=0;F<S.length;F++)T=E(T,S[F]);return T})})}),Gc="subtract",Ng=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Sg=mt(Gc,Ng,s=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:l}=s,c=Vc({typed:t}),p=yi({typed:t}),h=Yc({typed:t,equalScalar:r}),f=Zc({typed:t,DenseMatrix:a}),d=vi({typed:t,DenseMatrix:a}),g=Hn({typed:t,matrix:e,concat:l});return t(Gc,{"any, any":n},g({elop:n,SS:h,DS:c,SD:p,Ss:d,sS:f}))}),Bg="matAlgo07xSSf",Og=["typed","DenseMatrix"],Ws=mt(Bg,Og,s=>{var{typed:t,DenseMatrix:e}=s;return function(i,a,l){var c=i._size,p=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==h.length)throw new Ht(c.length,h.length);if(c[0]!==h[0]||c[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");var d=c[0],g=c[1],y,m=0,w=l;typeof p=="string"&&p===f&&p!=="mixed"&&(y=p,m=t.convert(0,y),w=t.find(l,[y,y]));var v,x,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],E=[],A=[],M=[];for(x=0;x<g;x++){var S=x+1;for(r(i,x,A,N,S),r(a,x,M,E,S),v=0;v<d;v++){var T=A[v]===S?N[v]:m,F=M[v]===S?E[v]:m;b[v][x]=w(T,F)}}return new e({data:b,size:[d,g],datatype:p===i._datatype&&f===a._datatype?y:void 0})};function r(n,i,a,l,c){for(var p=n._values,h=n._index,f=n._ptr,d=f[i],g=f[i+1];d<g;d++){var y=h[d];a[y]=c,l[y]=p[d]}}}),Hc="conj",Ig=["typed"],Tg=mt(Hc,Ig,s=>{var{typed:t}=s;return t(Hc,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Vr(r,e))})}),Jc="concat",$g=["typed","matrix","isInteger"],Lg=mt(Jc,$g,s=>{var{typed:t,matrix:e,isInteger:r}=s;return t(Jc,{"...Array | Matrix | number | BigNumber":function(i){var a,l=i.length,c=-1,p,h=!1,f=[];for(a=0;a<l;a++){var d=i[a];if(ve(d)&&(h=!0),de(d)||Se(d)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(p=c,c=d.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>p)throw new An(c,p+1)}else{var g=se(d).valueOf(),y=Te(g);if(f[a]=g,p=c,c=y.length-1,a>0&&c!==p)throw new Ht(p+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=ic(m,f.shift(),c);return h?e(m):m},"...string":function(i){return i.join("")}})}),Xc="count",Rg=["typed","size","prod"],Pg=mt(Xc,Rg,s=>{var{typed:t,size:e,prod:r}=s;return t(Xc,{string:function(i){return i.length},"Matrix | Array":function(i){return r(e(i))}})}),Qc="identity",zg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],qg=mt(Qc,zg,s=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:i,SparseMatrix:a}=s;return t(Qc,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(h){return r(h)},"number | BigNumber":function(h){return c(h,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,f){return c(h,h,f)},"number | BigNumber, number | BigNumber":function(h,f){return c(h,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,f,d){return c(h,f,d)},Array:function(h){return l(h)},"Array, string":function(h,f){return l(h,f)},Matrix:function(h){return l(h.valueOf(),h.storage())},"Matrix, string":function(h,f){return l(h.valueOf(),f)}});function l(p,h){switch(p.length){case 0:return h?r(h):[];case 1:return c(p[0],p[0],h);case 2:return c(p[0],p[1],h);default:throw new Error("Vector containing two values expected")}}function c(p,h,f){var d=Se(p)||Se(h)?n:null;if(Se(p)&&(p=p.toNumber()),Se(h)&&(h=h.toNumber()),!De(p)||p<1)throw new Error("Parameters in function identity must be positive integers");if(!De(h)||h<1)throw new Error("Parameters in function identity must be positive integers");var g=d?new n(1):1,y=d?new d(0):0,m=[p,h];if(f){if(f==="sparse")return a.diagonal(m,g,0,y);if(f==="dense")return i.diagonal(m,g,0,y);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var w=da([],m,y),v=p<h?p:h,x=0;x<v;x++)w[x][x]=g;return w}}),tf="kron",kg=["typed","matrix","multiplyScalar"],Ug=mt(tf,kg,s=>{var{typed:t,matrix:e,multiplyScalar:r}=s;return t(tf,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(i,a){if(Te(i).length===1&&(i=[i]),Te(a).length===1&&(a=[a]),Te(i).length>2||Te(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return i.map(function(p){return a.map(function(h){return c=[],l.push(c),p.map(function(f){return h.map(function(d){return c.push(r(f,d))})})})})&&l}});function Wg(){throw new Error('No "bignumber" implementation available')}function jg(){throw new Error('No "fraction" implementation available')}function Yg(){throw new Error('No "matrix" implementation available')}var ef="reshape",Vg=["typed","isInteger","matrix"],Zg=mt(ef,Vg,s=>{var{typed:t,isInteger:e}=s;return t(ef,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),ma(n,i)}})}),rf="size",Kg=["typed","config","?matrix"],Gg=mt(rf,Kg,s=>{var{typed:t,config:e,matrix:r}=s;return t(rf,{Matrix:function(i){return i.create(i.size())},Array:Te,string:function(i){return e.matrix==="Array"?[i.length]:r([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return e.matrix==="Array"?[]:r?r([]):Yg()}})}),nf="transpose",Hg=["typed","matrix"],Jg=mt(nf,Hg,s=>{var{typed:t,matrix:e}=s;return t(nf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:se});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var p=l[0],h=l[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+fe(l)+")");switch(a.storage()){case"dense":c=n(a,p,h);break;case"sparse":c=i(a,p,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+fe(l)+")")}return c}function n(a,l,c){for(var p=a._data,h=[],f,d=0;d<c;d++){f=h[d]=[];for(var g=0;g<l;g++)f[g]=se(p[g][d])}return a.createDenseMatrix({data:h,size:[c,l],datatype:a._datatype})}function i(a,l,c){for(var p=a._values,h=a._index,f=a._ptr,d=p?[]:void 0,g=[],y=[],m=[],w=0;w<l;w++)m[w]=0;var v,x,b;for(v=0,x=h.length;v<x;v++)m[h[v]]++;for(var N=0,E=0;E<l;E++)y.push(N),N+=m[E],m[E]=y[E];for(y.push(N),b=0;b<c;b++)for(var A=f[b],M=f[b+1],S=A;S<M;S++){var T=m[h[S]]++;g[T]=b,p&&(d[T]=se(p[S]))}return a.createSparseMatrix({values:d,index:g,ptr:y,size:[c,l],datatype:a._datatype})}}),sf="ctranspose",Xg=["typed","transpose","conj"],Qg=mt(sf,Xg,s=>{var{typed:t,transpose:e,conj:r}=s;return t(sf,{any:function(i){return r(e(i))}})}),of="mode",tv=["typed","isNaN","isNumeric"],ev=mt(of,tv,s=>{var{typed:t,isNaN:e,isNumeric:r}=s;return t(of,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(i){i=va(i.valueOf());var a=i.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],p=0,h=0;h<i.length;h++){var f=i[h];if(r(f)&&e(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===p?c.push(f):l[f]>p&&(p=l[f],c=[f])}return c}});function Sn(s,t,e){var r;return String(s).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":" (type: "+s.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(s).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):s}var af="prod",rv=["typed","config","multiplyScalar","numeric"],nv=mt(af,rv,s=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=s;return t(af,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(a){var l;if(Hi(a,function(c){try{l=l===void 0?c:r(l,c)}catch(p){throw Sn(p,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),iv="numeric",sv=["number","?bignumber","?fraction"],ov=mt(iv,sv,s=>{var{number:t,bignumber:e,fraction:r}=s,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:a=>t(a),BigNumber:e?a=>e(a):Wg,Fraction:r?a=>r(a):jg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",p=arguments.length>2?arguments[2]:void 0;if(p!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var h=En(l);if(!(h in n))throw new TypeError("Cannot convert "+l+' of type "'+h+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in i))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(i).join(", "));return c===h?l:i[c](l)}}),uf="divideScalar",av=["typed","numeric"],uv=mt(uf,av,s=>{var{typed:t,numeric:e}=s;return t(uf,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),lf="pow",lv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],cv=mt(lf,lv,s=>{var{typed:t,config:e,identity:r,multiply:n,matrix:i,inv:a,number:l,fraction:c,Complex:p}=s;return t(lf,{"number, number":h,"Complex, Complex":function(y,m){return y.pow(m)},"BigNumber, BigNumber":function(y,m){return m.isInteger()||y>=0||e.predictable?y.pow(m):new p(y.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(y,m){var w=y.pow(m);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 h(y.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(y,m){return f(y,m.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(y,m){return d(y,m.toNumber())},"Unit, number | BigNumber":function(y,m){return y.pow(m)}});function h(g,y){if(e.predictable&&!De(y)&&g<0)try{var m=c(y),w=l(m);if((y===w||Math.abs((y-w)/y)<1e-14)&&m.d%2===1)return(m.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:De(y)||g>=0||e.predictable?Ic(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new p(g,0).pow(y,0)}function f(g,y){if(!De(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var m=Te(g);if(m.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+m.length+" dimensions)");if(m[0]!==m[1])throw new Error("For A^b, A must be square (size is "+m[0]+"x"+m[1]+")");if(y<0)try{return f(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(m[0]).valueOf(),v=g;y>=1;)(y&1)===1&&(w=n(v,w)),y>>=1,v=n(v,v);return w}function d(g,y){return i(f(g.valueOf(),y))}}),cf="dotDivide",fv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],hv=mt(cf,fv,s=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,l=ig({typed:t,equalScalar:r}),c=yi({typed:t}),p=Ws({typed:t,DenseMatrix:i}),h=Ma({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:i}),d=Hn({typed:t,matrix:e,concat:a});return t(cf,d({elop:n,SS:p,DS:c,SD:l,Ss:h,sS:f}))}),js="compare",pv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],dv=mt(js,pv,s=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:l,concat:c}=s,p=yi({typed:t}),h=Yc({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:l}),d=Hn({typed:t,matrix:n,concat:c}),g=ks({typed:t});return t(js,_v({typed:t,config:e}),{"boolean, boolean":function(m,w){return m===w?0:m>w?1:-1},"BigNumber, BigNumber":function(m,w){return qs(m,w,e.epsilon)?new i(0):new i(m.cmp(w))},"Fraction, Fraction":function(m,w){return new a(m.compare(w))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,d({SS:h,DS:p,Ss:f}))}),_v=mt(js,["typed","config"],s=>{var{typed:t,config:e}=s;return t(js,{"number, number":function(n,i){return Gn(n,i,e.epsilon)?0:n>i?1:-1}})}),Ys="equal",mv=["typed","matrix","equalScalar","DenseMatrix","concat"],gv=mt(Ys,mv,s=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),p=Hn({typed:t,matrix:e,concat:i});return t(Ys,vv({typed:t,equalScalar:r}),p({elop:r,SS:l,DS:a,Ss:c}))}),vv=mt(Ys,["typed","equalScalar"],s=>{var{typed:t,equalScalar:e}=s;return t(Ys,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:e(n,i)}})}),Vs="smaller",yv=["typed","config","matrix","DenseMatrix","concat"],wv=mt(Vs,yv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),p=Hn({typed:t,matrix:r,concat:i}),h=ks({typed:t});return t(Vs,Dv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f<d,"BigNumber, BigNumber":function(d,g){return d.lt(g)&&!qs(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===-1,"Complex, Complex":function(d,g){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:a,Ss:c}))}),Dv=mt(Vs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Vs,{"number, number":function(n,i){return n<i&&!Gn(n,i,e.epsilon)}})}),Zs="larger",bv=["typed","config","matrix","DenseMatrix","concat"],xv=mt(Zs,bv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),p=Hn({typed:t,matrix:r,concat:i}),h=ks({typed:t});return t(Zs,Ev({typed:t,config:e}),{"boolean, boolean":(f,d)=>f>d,"BigNumber, BigNumber":function(d,g){return d.gt(g)&&!qs(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:a,Ss:c}))}),Ev=mt(Zs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Zs,{"number, number":function(n,i){return n>i&&!Gn(n,i,e.epsilon)}})}),ff="deepEqual",Av=["typed","equal"],Cv=mt(ff,Av,s=>{var{typed:t,equal:e}=s;return t(ff,{"any, any":function(i,a){return r(i.valueOf(),a.valueOf())}});function r(n,i){if(Array.isArray(n))if(Array.isArray(i)){var a=n.length;if(a!==i.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:e(n,i)}}),hf="partitionSelect",Fv=["typed","isNumeric","isNaN","compare"],Mv=mt(hf,Fv,s=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=s,i=n,a=(p,h)=>-n(p,h);return t(hf,{"Array | Matrix, number":function(h,f){return l(h,f,i)},"Array | Matrix, number, string":function(h,f,d){if(d==="asc")return l(h,f,i);if(d==="desc")return l(h,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(p,h,f){if(!De(h)||h<0)throw new Error("k must be a non-negative integer");if(ve(p)){var d=p.size();if(d.length>1)throw new Error("Only one dimensional matrices supported");return c(p.valueOf(),h,f)}if(Array.isArray(p))return c(p,h,f)}function c(p,h,f){if(h>=p.length)throw new Error("k out of bounds");for(var d=0;d<p.length;d++)if(e(p[d])&&r(p[d]))return p[d];for(var g=0,y=p.length-1;g<y;){for(var m=g,w=y,v=p[Math.floor(Math.random()*(y-g+1))+g];m<w;)if(f(p[m],v)>=0){var x=p[w];p[w]=p[m],p[m]=x,--w}else++m;f(p[m],v)>0&&--m,h<=m?y=m:g=m+1}return p[h]}}),pf="max",Nv=["typed","config","numeric","larger"],Sv=mt(pf,Nv,s=>{var{typed:t,config:e,numeric:r,larger:n}=s;return t(pf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,p){return Fa(c,p.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(p){throw Sn(p,"max",c)}}function a(l){var c;if(Hi(l,function(p){try{isNaN(p)&&typeof p=="number"?c=NaN:(c===void 0||n(p,c))&&(c=p)}catch(h){throw Sn(h,"max",p)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),df="min",Bv=["typed","config","numeric","smaller"],Ov=mt(df,Bv,s=>{var{typed:t,config:e,numeric:r,smaller:n}=s;return t(df,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,p){return Fa(c,p.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(p){throw Sn(p,"min",c)}}function a(l){var c;if(Hi(l,function(p){try{isNaN(p)&&typeof p=="number"?c=NaN:(c===void 0||n(p,c))&&(c=p)}catch(h){throw Sn(h,"min",p)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),_f="add",Iv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Tv=mt(_f,Iv,s=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:l}=s,c=Vc({typed:t}),p=Dg({typed:t,equalScalar:n}),h=Zc({typed:t,DenseMatrix:i}),f=Hn({typed:t,matrix:e,concat:l});return t(_f,{"any, any":r,"any, any, ...any":t.referToSelf(d=>(g,y,m)=>{for(var w=d(g,y),v=0;v<m.length;v++)w=d(w,m[v]);return w})},f({elop:r,DS:c,SS:p,Ss:h}))}),mf="dot",$v=["typed","addScalar","multiplyScalar","conj","size"],Lv=mt(mf,$v,s=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:i}=s;return t(mf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(h,f){var d=p(h),g=p(f),y,m;if(d.length===1)y=d[0];else if(d.length===2&&d[1]===1)y=d[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+d.join(", ")+")");if(g.length===1)m=g[0];else if(g.length===2&&g[1]===1)m=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(y!==m)throw new RangeError("Vectors must have equal length ("+y+" != "+m+")");if(y===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return y}function l(h,f){var d=a(h,f),g=ve(h)?h._data:h,y=ve(h)?h._datatype||h.getDataType():void 0,m=ve(f)?f._data:f,w=ve(f)?f._datatype||f.getDataType():void 0,v=p(h).length===2,x=p(f).length===2,b=e,N=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var E=y;b=t.find(e,[E,E]),N=t.find(r,[E,E])}if(!v&&!x){for(var A=N(n(g[0]),m[0]),M=1;M<d;M++)A=b(A,N(n(g[M]),m[M]));return A}if(!v&&x){for(var S=N(n(g[0]),m[0][0]),T=1;T<d;T++)S=b(S,N(n(g[T]),m[T][0]));return S}if(v&&!x){for(var F=N(n(g[0][0]),m[0]),O=1;O<d;O++)F=b(F,N(n(g[O][0]),m[O]));return F}if(v&&x){for(var R=N(n(g[0][0]),m[0][0]),U=1;U<d;U++)R=b(R,N(n(g[U][0]),m[U][0]));return R}}function c(h,f){a(h,f);for(var d=h._index,g=h._values,y=f._index,m=f._values,w=0,v=e,x=r,b=0,N=0;b<d.length&&N<y.length;){var E=d[b],A=y[N];if(E<A){b++;continue}if(E>A){N++;continue}E===A&&(w=v(w,x(g[b],m[N])),b++,N++)}return w}function p(h){return ve(h)?h.size():i(h)}}),Rv="trace",Pv=["typed","matrix","add"],zv=mt(Rv,Pv,s=>{var{typed:t,matrix:e,add:r}=s;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:i,DenseMatrix:n,any:se});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return se(c[0]);throw new RangeError("Matrix must be square (size: "+fe(l)+")");case 2:{var p=l[0],h=l[1];if(p===h){for(var f=0,d=0;d<p;d++)f=r(f,c[d][d]);return f}else throw new RangeError("Matrix must be square (size: "+fe(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(l)+")")}}function i(a){var l=a._values,c=a._index,p=a._ptr,h=a._size,f=h[0],d=h[1];if(f===d){var g=0;if(l.length>0)for(var y=0;y<d;y++)for(var m=p[y],w=p[y+1],v=m;v<w;v++){var x=c[v];if(x===y){g=r(g,l[v]);break}if(x>y)break}return g}throw new RangeError("Matrix must be square (size: "+fe(h)+")")}}),gf="det",qv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],kv=mt(gf,qv,s=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:i,isZero:a,unaryMinus:l}=s;return t(gf,{any:function(h){return se(h)},"Array | Matrix":function(h){var f;switch(ve(h)?f=h.size():Array.isArray(h)?(h=e(h),f=h.size()):f=[],f.length){case 0:return se(h);case 1:if(f[0]===1)return se(h.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")");case 2:{var d=f[0],g=f[1];if(d===g)return c(h.clone().valueOf(),d);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(f)+")")}}});function c(p,h,f){if(h===1)return se(p[0][0]);if(h===2)return r(n(p[0][0],p[1][1]),n(p[1][0],p[0][1]));for(var d=!1,g=new Array(h).fill(0).map((M,S)=>S),y=0;y<h;y++){var m=g[y];if(a(p[m][y])){var w=void 0;for(w=y+1;w<h;w++)if(!a(p[g[w]][y])){m=g[w],g[w]=g[y],g[y]=m,d=!d;break}if(w===h)return p[m][y]}for(var v=p[m][y],x=y===0?1:p[g[y-1]][y-1],b=y+1;b<h;b++)for(var N=g[b],E=y+1;E<h;E++)p[N][E]=i(r(n(p[N][E],v),n(p[N][y],p[m][E])),x)}var A=p[g[h-1]][h-1];return d?l(A):A}}),vf="inv",Uv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Wv=mt(vf,Uv,s=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:l,identity:c,abs:p}=s;return t(vf,{"Array | Matrix":function(d){var g=ve(d)?d.size():Te(d);switch(g.length){case 1:if(g[0]===1)return ve(d)?e([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+fe(g)+")");case 2:{var y=g[0],m=g[1];if(y===m)return ve(d)?e(h(d.valueOf(),y,m),d.storage()):h(d,y,m);throw new RangeError("Matrix must be square (size: "+fe(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(g)+")")}},any:function(d){return r(1,d)}});function h(f,d,g){var y,m,w,v,x;if(d===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(d===2){var b=l(f);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(f[1][1],b),r(a(f[0][1]),b)],[r(a(f[1][0]),b),r(f[0][0],b)]]}else{var N=f.concat();for(y=0;y<d;y++)N[y]=N[y].concat();for(var E=c(d).valueOf(),A=0;A<g;A++){var M=p(N[A][A]),S=A;for(y=A+1;y<d;)p(N[y][A])>M&&(M=p(N[y][A]),S=y),y++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==A&&(x=N[A],N[A]=N[y],N[y]=x,x=E[A],E[A]=E[y],E[y]=x);var T=N[A],F=E[A];for(y=0;y<d;y++){var O=N[y],R=E[y];if(y!==A){if(O[A]!==0){for(w=r(a(O[A]),T[A]),m=A;m<g;m++)O[m]=n(O[m],i(w,T[m]));for(m=0;m<g;m++)R[m]=n(R[m],i(w,F[m]))}}else{for(w=T[A],m=A;m<g;m++)O[m]=r(O[m],w);for(m=0;m<g;m++)R[m]=r(R[m],w)}}}return E}}}),yf="pinv",jv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Yv=mt(yf,jv,s=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:l,ctranspose:c,divideScalar:p,multiply:h,add:f,Complex:d}=s;return t(yf,{"Array | Matrix":function(b){var N=ve(b)?b.size():Te(b);switch(N.length){case 1:return v(b)?c(b):N[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var E=N[0],A=N[1];if(E===A)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return ve(b)?e(g(b.valueOf(),E,A),b.storage()):g(b,E,A)}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(N)+")")}},any:function(b){return i(b,0)?se(b):p(1,b)}});function g(x,b,N){var{C:E,F:A}=m(x,b,N),M=h(r(h(c(E),E)),c(E)),S=h(c(A),r(h(A,c(A))));return h(S,M)}function y(x,b,N){for(var E=se(x),A=0,M=0;M<b;M++){if(N<=A)return E;for(var S=M;w(E[S][A]);)if(S++,b===S&&(S=M,A++,N===A))return E;[E[S],E[M]]=[E[M],E[S]];for(var T=E[M][A],F=0;F<N;F++)E[M][F]=a(E[M][F],T);for(var O=0;O<b;O++)if(O!==M){T=E[O][A];for(var R=0;R<N;R++)E[O][R]=f(E[O][R],h(-1,h(T,E[M][R])))}A++}return E}function m(x,b,N){var E=y(x,b,N),A=x.map((S,T)=>S.filter((F,O)=>O<b&&!w(l(E[O],E[O])))),M=E.filter((S,T)=>!w(l(E[T],E[T])));return{C:A,F:M}}function w(x){return i(f(x,d(1,1)),f(0,d(1,1)))}function v(x){return n(f(x,d(1,1)),f(h(x,0),d(1,1)))}}),Vv="divide",Zv=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Kv=mt(Vv,Zv,s=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:i,inv:a}=s,l=Ma({typed:t,equalScalar:n}),c=Na({typed:t});return t("divide",Pl({"Array | Matrix, Array | Matrix":function(h,f){return r(h,a(f))},"DenseMatrix, any":function(h,f){return c(h,f,i,!1)},"SparseMatrix, any":function(h,f){return l(h,f,i,!1)},"Array, any":function(h,f){return c(e(h),f,i,!1).valueOf()},"any, Array | Matrix":function(h,f){return r(h,a(f))}},i.signatures))}),wf="sum",Gv=["typed","config","add","numeric"],Hv=mt(wf,Gv,s=>{var{typed:t,config:e,add:r,numeric:n}=s;return t(wf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function sum");return i(c)}});function i(l){var c;return Hi(l,function(p){try{c=c===void 0?p:r(c,p)}catch(h){throw Sn(h,"sum",p)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var p=Fa(l,c,r);return p}catch(h){throw Sn(h,"sum")}}}),Df="median",Jv=["typed","add","divide","compare","partitionSelect"],Xv=mt(Df,Jv,s=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:i}=s;function a(p){try{p=va(p.valueOf());var h=p.length;if(h===0)throw new Error("Cannot calculate median of an empty array");if(h%2===0){for(var f=h/2-1,d=i(p,f+1),g=p[f],y=0;y<f;++y)n(p[y],g)>0&&(g=p[y]);return c(g,d)}else{var m=i(p,(h-1)/2);return l(m)}}catch(w){throw Sn(w,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(h){return h}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,f){return r(e(h,f),2)}});return t(Df,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,f){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(Rs(h))throw new TypeError("Scalar values expected in function median");return a(h)}})}),Ks=Q_({config:mr}),Sa=nm({}),Ba=am({}),Oa=cm({}),rn=pm({Matrix:Oa}),Mt=r_({BigNumber:Ks,Complex:Sa,DenseMatrix:rn,Fraction:Ba}),Qv=Ym({typed:Mt}),Gs=Zm({typed:Mt}),t1=Lm({BigNumber:Ks,typed:Mt}),bf=Tg({typed:Mt}),Bn=Am({config:mr,typed:Mt}),Hs=mm({typed:Mt}),e1=wm({typed:Mt}),Js=Cg({typed:Mt}),xf=Im({typed:Mt}),Ia=Mm({Matrix:Oa,equalScalar:Bn,typed:Mt}),Ef=Gm({typed:Mt}),Af=bm({typed:Mt}),Ta=Wm({typed:Mt}),Cf=zm({Fraction:Ba,typed:Mt}),Ff=vm({typed:Mt}),$e=km({DenseMatrix:rn,Matrix:Oa,SparseMatrix:Ia,typed:Mt}),Mf=ev({isNaN:Af,isNumeric:Ff,typed:Mt}),Ji=ov({bignumber:t1,fraction:Cf,number:xf}),r1=nv({config:mr,multiplyScalar:Js,numeric:Ji,typed:Mt}),n1=Zg({isInteger:Hs,matrix:$e,typed:Mt}),Nf=Gg({matrix:$e,config:mr,typed:Mt}),Sf=Jg({matrix:$e,typed:Mt}),Jn=Lg({isInteger:Hs,matrix:$e,typed:Mt}),i1=Pg({prod:r1,size:Nf,typed:Mt}),s1=Qg({conj:bf,transpose:Sf,typed:Mt}),Xi=uv({numeric:Ji,typed:Mt}),o1=hv({DenseMatrix:rn,concat:Jn,divideScalar:Xi,equalScalar:Bn,matrix:$e,typed:Mt}),Bf=gv({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:$e,typed:Mt}),Of=qg({BigNumber:Ks,DenseMatrix:rn,SparseMatrix:Ia,config:mr,matrix:$e,typed:Mt}),a1=Ug({matrix:$e,multiplyScalar:Js,typed:Mt}),u1=wv({DenseMatrix:rn,concat:Jn,config:mr,matrix:$e,typed:Mt}),l1=Sg({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:$e,subtractScalar:Ef,typed:Mt,unaryMinus:Ta}),Qi=Tv({DenseMatrix:rn,SparseMatrix:Ia,addScalar:Gs,concat:Jn,equalScalar:Bn,matrix:$e,typed:Mt}),If=dv({BigNumber:Ks,DenseMatrix:rn,Fraction:Ba,concat:Jn,config:mr,equalScalar:Bn,matrix:$e,typed:Mt}),c1=Cv({equal:Bf,typed:Mt}),Tf=Lv({addScalar:Gs,conj:bf,multiplyScalar:Js,size:Nf,typed:Mt}),f1=xv({DenseMatrix:rn,concat:Jn,config:mr,matrix:$e,typed:Mt}),$a=Ov({config:mr,numeric:Ji,smaller:u1,typed:Mt}),wi=Mg({addScalar:Gs,dot:Tf,equalScalar:Bn,matrix:$e,multiplyScalar:Js,typed:Mt}),h1=Mv({compare:If,isNaN:Af,isNumeric:Ff,typed:Mt}),p1=Hv({add:Qi,config:mr,numeric:Ji,typed:Mt}),d1=zv({add:Qi,matrix:$e,typed:Mt}),$f=kv({divideScalar:Xi,isZero:e1,matrix:$e,multiply:wi,subtractScalar:Ef,typed:Mt,unaryMinus:Ta}),_1=Sv({config:mr,larger:f1,numeric:Ji,typed:Mt}),Xs=Wv({abs:Qv,addScalar:Gs,det:$f,divideScalar:Xi,identity:Of,matrix:$e,multiply:wi,typed:Mt,unaryMinus:Ta}),m1=Yv({Complex:Sa,add:Qi,ctranspose:s1,deepEqual:c1,divideScalar:Xi,dot:Tf,dotDivide:o1,equal:Bf,inv:Xs,matrix:$e,multiply:wi,typed:Mt}),g1=cv({Complex:Sa,config:mr,fraction:Cf,identity:Of,inv:Xs,matrix:$e,multiply:wi,number:xf,typed:Mt}),v1=Kv({divideScalar:Xi,equalScalar:Bn,inv:Xs,matrix:$e,multiply:wi,typed:Mt}),Lf=Xv({add:Qi,compare:If,divide:v1,partitionSelect:h1,typed:Mt});class y1{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:i},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);i&&(c=Math.floor(c));const p=e/n;let h=0,f=0;for(let d=0;d<=e-1;d++){const g=Math.exp(-1*Math.pow(d-c,2)/(2*Math.pow(p,2)));h+=g,f+=l[l.length-1-(e-d-1)]*g}return f/h}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const i=this._cacheDataList(t,e,`sma_${r}`);if(i===void 0)return;const a=i.slice(-e);return n=p1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;this._cacheDataList(t,e,`sma_${r}`);const{sum:n}=this._cacheData[`rma_${r}`]||{},i=1/e,a=n===void 0?this.sma({source:t,length:e},r):i*t+(1-i)*(n||0);return this._cacheDataHandle(`rma_${r}`,{sum:a}),a}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:i,close:a,low:l}=this._variables,c=r===void 0?i-l:Math.max(Math.max(i-l,Math.abs(i-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:i,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const i=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(i===void 0)return;let l=0;for(let c=0;c<e;c++){const p=this._sum(i[i.length-1-c],-(a||0));l+=p*p}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return[];const l=r*a;return[i,i+l,i-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return;const l=r*a;return(i+l-(i-l))/i}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),i=this.dev({source:t,length:e},r);if(!(n===void 0||i===void 0))return(t-n)/(.015*i)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const i=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return i===void 0?i:typeof t=="boolean"?i!==t:t-i}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 i=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(!(i===void 0||a===void 0))return 100*(i-a)/(i+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}`),i=this._math.sum({source:t,length:e},r);if(i===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/i}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const i=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||i===void 0)return;let c=0,p=0,h=0;for(let d=0;d<r;d++){const[g,y]=i[i.length-1-d],m=g-a,w=y-l;c+=m*w,p+=m*m,h+=w*w}return isNaN(p)||isNaN(c)||isNaN(h)?void 0:c/Math.sqrt(p*h)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e||n<=i&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n<=i&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let i=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];i+=Math.abs(c-n)}return i/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:i,high:a,close:l,PDMS:c,NDMS:p,TRS:h,ADX:f,count:d=0}=this._cacheData[n]||{},{low:g,high:y,close:m}=this._variables;if(i===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:y,close:m,PDMS:c,NDMS:p,TRS:y-g,count:1},[void 0,void 0,void 0];let w=y-a,v=i-g;w=w>v&&w>0?w:0,v=v>w&&v>0?v:0,w===v&&(w=v=0);const x=Math.max(y-g,Math.abs(y-l),Math.abs(g-l));if(d<t)return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:(c||0)+w,NDMS:(p||0)+v,TRS:(h||0)+x,count:d+1}),[void 0,void 0,void 0];{const b=c-c/t+w,N=p-p/t+v,E=h-h/t+x,A=b/E*100,M=N/E*100,S=Math.abs((A-M)/(A+M))*100;let T=S,F=[A,M,void 0];if(d+1-t<e){const O=d+1-t;T=((f||0)*(O-1)+S)/O}else T=(f*(e-1)+S)/e,F=[A,M,T];return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:b,NDMS:N,TRS:E,ADX:T,count:d+1}),F}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:i=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(i>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return i+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:i}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:i=[]}=this._cacheData[`falling_${r}`]||{};i.push(n>t);const a=i.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:i=[]}=this._cacheData[`rising_${r}`]||{};i.push(n<t);const a=i.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(i)return Math.max(...i.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return i?i.slice(-e).reduce((l,c,p,h)=>c>=h[l]?p:l,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 i=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;i+=c,a+=n[n.length-1-l]*c}return a/i}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),i=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||i===void 0?void 0:this.wma({source:2*i-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},i){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},i),{ta:l,high:c,low:p}=this._variables,h=n?l.tr:c-p,f=this.ema({source:h,length:e},`range_${i}`);return[a,a+f*r,a-f*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},i),{ta:l,high:c,low:p}=this._variables,h=n?l.tr:c-p,f=this.ema({source:h,length:e},`range_${i}`);return(a+f*r-(a-f*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const i=this._cacheDataList(t,e,`dev_${n}`);if(!i)return;const a=i.slice(-e).filter(g=>g!==void 0);let l=0,c=0,p=0,h=0;for(const[g,y]of a.entries())l+=g,c+=y,p+=g*y,h+=g*g;const f=(e*p-l*c)/(e*h-l*l);return(c-f*l)/e+f*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(i)return Math.min(...i.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return i?i.slice(-e).reduce((l,c,p,h)=>c<=h[l]?p:l,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},i){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_${i}`),l=this.ema({source:t,length:r},`ema2_${i}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,p=this.ema({source:c,length:n},`macd_${i}`);if(p===void 0)return[c,p,void 0];const h=c-p;return[c,p,h]}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 Lf(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,i=this.change({source:t},r),a=this._math.sum({source:n*(i>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(i<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return $a(Mf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,i=this._cacheData[n]||[];if(i[this._variables.bar_index]=t,this._cacheData[n]=i,i.length<=e||t===void 0||isNaN(t))return;let a=i.length-e-1,l;for(;l===void 0&&a>=0;)l=i[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!i)return;const a=this._sort(i.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[p,h]of a.entries()){const f=a[p-1];if(r<(p+.5)/l)return f===void 0||h===void 0?void 0:f+(h-f)*(r-(p-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!i)return;const a=this._sort(i.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const i=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<i.length;c++)i[c]!==void 0&&(i[c]<a||i[c]===a&&c<e)&&l++;return l/(i.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const i=new Qt;let{close:a,open:l,low:c,high:p}=this._variables;const h=`pivot_point_levels_${n}`,{close:f,low:d,high:g,open:y,result:m}=this._cacheData[h]||{};if(!e&&(g&&d&&(p=Math.max(g,p),c=Math.min(d,c)),this._cacheDataHandle(h,{close:a,open:l,low:c,high:p,result:m}),!r))return i._value=m||[],i;const w={close:a,open:l,low:c,high:p};e===!0&&!r&&(a=f,l=y,c=d,p=g);const v=this._getPivotPointLevels(p,c,a,l,r,t);return this._cacheDataHandle(h,{...w,result:v}),i._value=v,i}_getPivotPointLevels(t,e,r,n,i,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Kn.traditional:return this._traditional(t,e,r);case Kn.fibonacci:return this._fibonacci(t,e,r);case Kn.woodie:return i?[]:this._woodie(t,e);case Kn.classic:return this._classic(t,e,r);case Kn.dm:return this._DM(t,e,r,n);case Kn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,i=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),p=n*4+(t-4*e),h=n*2-t,f=n-(t-e),d=n*2-(2*t-e),g=n*3-(3*t-e),y=n*4-(4*t-e);return[n,i,h,a,f,l,d,c,g,p,y]}_fibonacci(t,e,r){const n=(t+e+r)/3,i=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),p=n+(t-e),h=n-(t-e);return[n,i,a,l,c,p,h]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),p=t+2*(n-e),h=e-2*(t-n),f=p+(t-e),d=h-(t-e);return[n,i,a,l,c,p,h,f,d]}_classic(t,e,r){const n=(t+e+r)/3,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),p=n+2*(t-e),h=n-2*(t-e),f=n+3*(t-e),d=n-3*(t-e);return[n,i,a,l,c,p,h,f,d]}_DM(t,e,r,n){let i;n===r?i=t+e+2*r:r>n?i=2*t+e+r:i=2*e+t+r;const a=i/4,l=i/2-e,c=i/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,i=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,p=r+1.1*(t-e)/4,h=r-1.1*(t-e)/4,f=r+1.1*(t-e)/2,d=r-1.1*(t-e)/2,g=t/e*r,y=r-(g-r);return[n,i,a,l,c,p,h,f,d,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 i=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const i=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const i=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...i),l=Math.min(...i);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),i=this.change({source:t,length:e},r);if(n)return 100*i/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},i=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:i,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:i,low:a,high:l,preLow:c,preHigh:p,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:d,acceleration:g,isBelow:y}=h,m=!1;const{close:w,low:v,high:x,bar_index:b}=this._variables;return b===1&&(w>i?(y=!0,d=x,f=a):(y=!1,d=v,f=l),m=!0,g=t),f=f+g*(d-f),y?f>v&&(m=!0,y=!1,f=Math.max(x,d||0),d=v,g=t):f<x&&(m=!0,y=!0,f=Math.min(v,d||0),d=x,g=t),m||(y?x>(d||0)&&(d=x,g=Math.min((g||0)+e,r)):v<(d||0)&&(d=v,g=Math.min((g||0)+e,r))),y?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,p))),this._cacheDataHandle(`sar_${n}`,{high:x,close:w,low:v,preLow:a,preHigh:l,data:Object.assign(h,{result:f,maxMin:d,acceleration:g,isBelow:y})}),f}stoch({source:t,high:e,low:r,length:n},i){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},i),l=this.highest({source:e,length:n},i);if(!(a===void 0||l===void 0))return 100*(this._variables.close-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:i}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:p,atr:h,close:f}=this._cacheData[a]||{},d=this.atr({length:e},r);if(d===void 0)return this._cacheDataHandle(a,{close:i}),[void 0,void 0];let g=n+t*d,y=n-t*d;const m=l||0,w=c||0;y=y>w||f<w?y:w,g=g<m||f>m?g:m;let v;h===void 0?v=1:p===m?v=i>g?-1:1:v=i<y?1:-1;const x=v===-1?y:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:y,superTrend:x,atr:d,close:i}),[x,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:i}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?i-n:void 0:Math.max(i-n,Math.abs(i-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.change({source:t},n);if(i===void 0)return;const a=this.ema({source:Math.abs(i),length:e},`absema1_${n}`),l=this.ema({source:i,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),p=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/p}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:i}=this._cacheData[`valuewhen_${n}`]||{};return i||(i=[]),t&&i.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:i}),i[i.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const i=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`mode_${n}`,!0);if(!a||i===void 0)return;const l=a.filter(p=>p!==void 0&&!isNaN(p)).slice(-e);if(l.length<e)return;const c=l.reduce((p,h)=>p+Math.pow(h-i,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:i}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:p,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=h=0,p=!0),!p)return r!==void 0?[]:void 0;const f=t*i+a,d=i+l,g=f/d;return c++,r!==void 0?(h=i*Math.pow(t,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:p,sumS:h}),this._computeBands(h,d,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:p}),g)}_computeBands(t,e,r,n){let i=t/e-Math.pow(n,2);i=i<0?0:i;const a=Math.sqrt(i),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,i=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(i===void 0||a===void 0))return i/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:i}=this._variables;if(!(r===void 0||n===void 0))return(r-i)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let i=0;i<e-r;i++){const{currentVal:a,currentIndex:l}=n,c=t[i];if(c!==void 0){if(a!==void 0&&c<a){t.splice(i,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:i,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const i=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(i.barIndex<=a&&(i.barIndex===a?i.list[i.list.length-1]=t:i.list.push(t),i.barIndex=a,i.list.length>e+5&&!n&&i.list.shift(),this._cacheData[r]=i),!(i.list.length<e))return i.list}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&!this._variables._isRealTimeBar&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}class w1{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._cacheHandle(t,e,ir.INT)}bool(t,e){return this._cacheHandle(t,e,ir.BOOL)}color(t,e){return this._cacheHandle(t,e,ir.COLOR)}time(t,e){return this._cacheHandle(t,e,ir.TIME)}float(t,e){return this._cacheHandle(t,e,ir.FLOAT)}price(t,e){return this._cacheHandle(t,e,ir.PRICE)}source(t,e){return this._cacheHandle(t,e,ir.SOURCE)}string(t,e){return this._cacheHandle(t,e,ir.STRING)}symbol(t,e){return this._cacheHandle(t,e,ir.SYMBOL)}session(t,e){return this._cacheHandle(t,e,ir.SESSION)}text_area(t,e){return this._cacheHandle(t,e,ir.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,ir.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,ir.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,i=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(le.inputDefvalErr,e,zt.Error),self.workerStorage.setValue(this._name,n,{...t}),i)if(!i.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?i.sourceTypeName&&(this._cacheData[n].defval=this._variables[i.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:l}=t;this._displayVerify(e,l),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===ir.SOURCE?this._cacheData[n].options=Vp:t.options&&!t.options.includes(a)&&this._errorListener.addError(Ye(le.inputOptErr,{defval:String(a),args:t.options.toString()}),e,zt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ve.dataWindow)||e.includes(Ve.statusLine)||this._errorListener.addError(Ye(le.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,zt.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 D1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const r=(100-e)/100,{r:n,g:i,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(i)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:i}){if(_t(t)||_t(e)||_t(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:p,b:h,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:d,g,b:y,a:m}=this._parseColor(i||"rgba(0,0,0,0)"),w=c+l*(d-c),v=p+l*(g-p),x=h+l*(y-h),b=f+l*(m-f);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,i;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?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var qt={};const b1=Object.prototype.toString;function ts(s){const t=b1.call(s);return t.endsWith("Array]")&&!t.includes("Big")}var x1=Object.freeze({__proto__:null,isAnyArray:ts}),E1=Ne(x1);function A1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]>a&&(a=s[l]);return a}function C1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]<a&&(a=s[l]);return a}function F1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ts(s)){if(s.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(!ts(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(s.length);var r=C1(s),n=A1(s);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=t.min,a=i===void 0?t.autoMinMax?r:0:i,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var p=(c-a)/(n-r),h=0;h<s.length;h++)e[h]=(s[h]-r)*p+a;return e}var M1=Object.freeze({__proto__:null,default:F1}),N1=Ne(M1);Object.defineProperty(qt,"__esModule",{value:!0});var cr=E1,Rf=N1;const Qs=" ".repeat(2),Pf=" ".repeat(4);function S1(){return zf(this)}function zf(s,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=t;return`${s.constructor.name} {
|
55
55
|
${Qs}[
|
56
56
|
${Pf}${B1(s,e,r,n,i)}
|
57
57
|
${Qs}]
|
58
58
|
${Qs}rows: ${s.rows}
|
59
59
|
${Qs}columns: ${s.columns}
|
60
|
-
}`}function B1(s,t,e,r,n){const{rows:i,columns:a}=s,l=Math.min(i,t),c=Math.min(a,e),
|
61
|
-
${Pf}`)}function O1(s,t,e){return(s>=0&&e?` ${qf(s,t-1)}`:qf(s,t)).padEnd(t)}function qf(s,t){let e=s.toString();if(e.length<=t)return e;let r=s.toFixed(t);if(r.length>t&&(r=s.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=s.toExponential(t);return n.length>t&&(n=s.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function I1(s,t){s.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},s.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r.get(n,i));return this},s.add=function(r,n){return new t(r).add(n)},s.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},s.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r.get(n,i));return this},s.sub=function(r,n){return new t(r).sub(n)},s.prototype.subtract=s.prototype.sub,s.prototype.subtractS=s.prototype.subS,s.prototype.subtractM=s.prototype.subM,s.subtract=s.sub,s.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},s.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r.get(n,i));return this},s.mul=function(r,n){return new t(r).mul(n)},s.prototype.multiply=s.prototype.mul,s.prototype.multiplyS=s.prototype.mulS,s.prototype.multiplyM=s.prototype.mulM,s.multiply=s.mul,s.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},s.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r.get(n,i));return this},s.div=function(r,n){return new t(r).div(n)},s.prototype.divide=s.prototype.div,s.prototype.divideS=s.prototype.divS,s.prototype.divideM=s.prototype.divM,s.divide=s.div,s.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},s.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r.get(n,i));return this},s.mod=function(r,n){return new t(r).mod(n)},s.prototype.modulus=s.prototype.mod,s.prototype.modulusS=s.prototype.modS,s.prototype.modulusM=s.prototype.modM,s.modulus=s.mod,s.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},s.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r.get(n,i));return this},s.and=function(r,n){return new t(r).and(n)},s.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},s.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r.get(n,i));return this},s.or=function(r,n){return new t(r).or(n)},s.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},s.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r.get(n,i));return this},s.xor=function(r,n){return new t(r).xor(n)},s.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},s.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r.get(n,i));return this},s.leftShift=function(r,n){return new t(r).leftShift(n)},s.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},s.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r.get(n,i));return this},s.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},s.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},s.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r.get(n,i));return this},s.rightShift=function(r,n){return new t(r).rightShift(n)},s.prototype.zeroFillRightShift=s.prototype.rightShift,s.prototype.zeroFillRightShiftS=s.prototype.rightShiftS,s.prototype.zeroFillRightShiftM=s.prototype.rightShiftM,s.zeroFillRightShift=s.rightShift,s.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},s.not=function(r){return new t(r).not()},s.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},s.abs=function(r){return new t(r).abs()},s.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},s.acos=function(r){return new t(r).acos()},s.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},s.acosh=function(r){return new t(r).acosh()},s.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},s.asin=function(r){return new t(r).asin()},s.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},s.asinh=function(r){return new t(r).asinh()},s.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},s.atan=function(r){return new t(r).atan()},s.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},s.atanh=function(r){return new t(r).atanh()},s.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},s.cbrt=function(r){return new t(r).cbrt()},s.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},s.ceil=function(r){return new t(r).ceil()},s.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},s.clz32=function(r){return new t(r).clz32()},s.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},s.cos=function(r){return new t(r).cos()},s.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},s.cosh=function(r){return new t(r).cosh()},s.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},s.exp=function(r){return new t(r).exp()},s.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},s.expm1=function(r){return new t(r).expm1()},s.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},s.floor=function(r){return new t(r).floor()},s.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},s.fround=function(r){return new t(r).fround()},s.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},s.log=function(r){return new t(r).log()},s.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},s.log1p=function(r){return new t(r).log1p()},s.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},s.log10=function(r){return new t(r).log10()},s.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},s.log2=function(r){return new t(r).log2()},s.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},s.round=function(r){return new t(r).round()},s.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},s.sign=function(r){return new t(r).sign()},s.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},s.sin=function(r){return new t(r).sin()},s.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},s.sinh=function(r){return new t(r).sinh()},s.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},s.sqrt=function(r){return new t(r).sqrt()},s.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},s.tan=function(r){return new t(r).tan()},s.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},s.tanh=function(r){return new t(r).tanh()},s.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},s.trunc=function(r){return new t(r).trunc()},s.pow=function(r,n){return new t(r).pow(n)},s.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},s.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r));return this},s.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 i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r.get(n,i)));return this}}function Sr(s,t,e){let r=e?s.rows:s.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Br(s,t,e){let r=e?s.columns:s.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Di(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function bi(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function La(s,t){if(!cr.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]>=s.rows)throw new RangeError("row indices are out of range")}function Ra(s,t){if(!cr.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]>=s.columns)throw new RangeError("column indices are out of range")}function Pa(s,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(eo("startRow",t),eo("endRow",e),eo("startColumn",r),eo("endColumn",n),t>e||r>n||t<0||t>=s.rows||e<0||e>=s.rows||r<0||r>=s.columns||n<0||n>=s.columns)throw new RangeError("Submatrix indices are out of range")}function to(s,t=0){let e=[];for(let r=0;r<s;r++)e.push(t);return e}function eo(s,t){if(typeof t!="number")throw new TypeError(`${s} must be a number`)}function xi(s){if(s.isEmpty())throw new Error("Empty matrix has no elements to index")}function T1(s){let t=to(s.rows);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]+=s.get(e,r);return t}function $1(s){let t=to(s.columns);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]+=s.get(e,r);return t}function L1(s){let t=0;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t+=s.get(e,r);return t}function R1(s){let t=to(s.rows,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]*=s.get(e,r);return t}function P1(s){let t=to(s.columns,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]*=s.get(e,r);return t}function z1(s){let t=1;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t*=s.get(e,r);return t}function q1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<r;a++){let l=0,c=0,h=0;for(let p=0;p<n;p++)h=s.get(a,p)-e[a],l+=h,c+=h*h;t?i.push((c-l*l/n)/(n-1)):i.push((c-l*l/n)/n)}return i}function k1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<n;a++){let l=0,c=0,h=0;for(let p=0;p<r;p++)h=s.get(p,a)-e[a],l+=h,c+=h*h;t?i.push((c-l*l/r)/(r-1)):i.push((c-l*l/r)/r)}return i}function U1(s,t,e){const r=s.rows,n=s.columns,i=r*n;let a=0,l=0,c=0;for(let h=0;h<r;h++)for(let p=0;p<n;p++)c=s.get(h,p)-e,a+=c,l+=c*c;return t?(l-a*a/i)/(i-1):(l-a*a/i)/i}function W1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[e])}function j1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[r])}function Y1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t)}function V1(s){const t=[];for(let e=0;e<s.rows;e++){let r=0;for(let n=0;n<s.columns;n++)r+=Math.pow(s.get(e,n),2)/(s.columns-1);t.push(Math.sqrt(r))}return t}function Z1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[e])}function K1(s){const t=[];for(let e=0;e<s.columns;e++){let r=0;for(let n=0;n<s.rows;n++)r+=Math.pow(s.get(n,e),2)/(s.rows-1);t.push(Math.sqrt(r))}return t}function G1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[r])}function H1(s){const t=s.size-1;let e=0;for(let r=0;r<s.columns;r++)for(let n=0;n<s.rows;n++)e+=Math.pow(s.get(n,r),2)/t;return Math.sqrt(e)}function J1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.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 i=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,r[a*e+l]);return i}static rowVector(t){let e=new pt(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 pt(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 pt(t,e)}static ones(t,e){return new pt(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 i=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,n());return i}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let l=i-n,c=new pt(t,e);for(let h=0;h<t;h++)for(let p=0;p<e;p++){let f=n+Math.round(a()*l);c.set(h,p,f)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),i=this.zeros(t,e);for(let a=0;a<n;a++)i.set(a,a,r);return i}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let i=Math.min(n,e,r),a=this.zeros(e,r);for(let l=0;l<i;l++)a.set(l,l,t[l]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new pt(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.min(t.get(a,l),e.get(a,l)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.max(t.get(a,l),e.get(a,l)));return i}static checkMatrix(t){return $t.isMatrix(t)?t:new pt(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,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!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 i=e;i<t.rows;i++)t.get(i,r)>t.get(n,r)&&(n=i);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let i=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/i);for(let a=e+1;a<t.rows;a++){let l=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)*l)}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 i=0,a=!1;for(;i<r&&a===!1;)t.get(n,i)===1?a=!0:i++;for(let l=0;l<n;l++){let c=t.get(l,i);for(let h=i;h<e;h++){let p=t.get(l,h)-c*t.get(n,h);t.set(l,h,p)}}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 pt(this.rows*e,this.columns*r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*i,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){Sr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return pt.rowVector(this.getRow(t))}setRow(t,e){Sr(this,t),e=Di(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Sr(this,t),Sr(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){Br(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return pt.columnVector(this.getColumn(t))}setColumn(t,e){Br(this,t),e=bi(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Br(this,t),Br(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=Di(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=Di(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=Di(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=Di(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=bi(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=bi(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=bi(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=bi(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){Sr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Br(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(){xi(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(){xi(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(Sr(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){Sr(this,t),xi(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(Sr(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){Sr(this,t),xi(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(Br(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){Br(this,t),xi(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(Br(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){Br(this,t),xi(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=pt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,i=new pt(e,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let c=0;c<r;c++)a[c]=t.get(c,l);for(let c=0;c<e;c++){let h=0;for(let p=0;p<r;p++)h+=this.get(c,p)*a[p];i.set(c,l,h)}}return i}strassen2x2(t){t=pt.checkMatrix(t);let e=new pt(2,2);const r=this.get(0,0),n=t.get(0,0),i=this.get(0,1),a=t.get(0,1),l=this.get(1,0),c=t.get(1,0),h=this.get(1,1),p=t.get(1,1),f=(r+h)*(n+p),d=(l+h)*n,g=r*(a-p),y=h*(c-n),m=(r+i)*p,w=(l-r)*(n+a),v=(i-h)*(c+p),x=f+y-m+v,b=g+m,N=d+y,E=f-d+g+w;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,N),e.set(1,1,E),e}strassen3x3(t){t=pt.checkMatrix(t);let e=new pt(3,3);const r=this.get(0,0),n=this.get(0,1),i=this.get(0,2),a=this.get(1,0),l=this.get(1,1),c=this.get(1,2),h=this.get(2,0),p=this.get(2,1),f=this.get(2,2),d=t.get(0,0),g=t.get(0,1),y=t.get(0,2),m=t.get(1,0),w=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),N=t.get(2,2),E=(r+n+i-a-l-p-f)*w,C=(r-a)*(-g+w),M=l*(-d+g+m-w-v-x+N),S=(-r+a+l)*(d-g+w),T=(a+l)*(-d+g),F=r*d,O=(-r+h+p)*(d-y+v),R=(-r+h)*(y-v),U=(h+p)*(-d+y),k=(r+n+i-l-c-h-p)*v,W=p*(-d+y+m-w-v-x+b),z=(-i+p+f)*(w+x-b),K=(i-f)*(w-b),Z=i*x,X=(p+f)*(-x+b),Q=(-i+l+c)*(v+x-N),ct=(i-c)*(v-N),vt=(l+c)*(-x+N),lt=n*m,wt=c*b,bt=a*y,Bt=h*g,xt=f*N,oe=F+Z+lt,It=E+S+T+F+z+Z+X,Nt=F+O+U+k+Z+Q+vt,ce=C+M+S+F+Z+Q+ct,re=C+S+T+F+wt,kt=Z+Q+ct+vt+bt,Jt=F+O+R+W+z+K+Z,Le=z+K+Z+X+Bt,vr=F+O+R+U+xt;return e.set(0,0,oe),e.set(0,1,It),e.set(0,2,Nt),e.set(1,0,ce),e.set(1,1,re),e.set(1,2,kt),e.set(2,0,Jt),e.set(2,1,Le),e.set(2,2,vr),e}mmulStrassen(t){t=pt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,i=t.rows,a=t.columns;n!==i&&console.warn(`Multiplying ${r} x ${n} and ${i} x ${a} matrix: dimensions do not match.`);function l(f,d,g){let y=f.rows,m=f.columns;if(y===d&&m===g)return f;{let w=$t.zeros(d,g);return w=w.setSubMatrix(f,0,0),w}}let c=Math.max(r,i),h=Math.max(n,a);e=l(e,c,h),t=l(t,c,h);function p(f,d,g,y){if(g<=512||y<=512)return f.mmul(d);g%2===1&&y%2===1?(f=l(f,g+1,y+1),d=l(d,g+1,y+1)):g%2===1?(f=l(f,g+1,y),d=l(d,g+1,y)):y%2===1&&(f=l(f,g,y+1),d=l(d,g,y+1));let m=parseInt(f.rows/2,10),w=parseInt(f.columns/2,10),v=f.subMatrix(0,m-1,0,w-1),x=d.subMatrix(0,m-1,0,w-1),b=f.subMatrix(0,m-1,w,f.columns-1),N=d.subMatrix(0,m-1,w,d.columns-1),E=f.subMatrix(m,f.rows-1,0,w-1),C=d.subMatrix(m,d.rows-1,0,w-1),M=f.subMatrix(m,f.rows-1,w,f.columns-1),S=d.subMatrix(m,d.rows-1,w,d.columns-1),T=p($t.add(v,M),$t.add(x,S),m,w),F=p($t.add(E,M),x,m,w),O=p(v,$t.sub(N,S),m,w),R=p(M,$t.sub(C,x),m,w),U=p($t.add(v,b),S,m,w),k=p($t.sub(E,v),$t.add(x,N),m,w),W=p($t.sub(b,M),$t.add(C,S),m,w),z=$t.add(T,R);z.sub(U),z.add(W);let K=$t.add(O,U),Z=$t.add(F,R),X=$t.sub(T,F);X.add(O),X.add(k);let Q=$t.zeros(2*z.rows,2*z.columns);return Q=Q.setSubMatrix(z,0,0),Q=Q.setSubMatrix(K,z.rows,0),Q=Q.setSubMatrix(Z,0,z.columns),Q=Q.setSubMatrix(X,z.rows,z.columns),Q.subMatrix(0,g-1,0,y-1)}return p(e,t,c,h)}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 pt(this.rows,this.columns);for(let i=0;i<this.rows;i++){const a=this.getRow(i);a.length>0&&Rf(a,{min:e,max:r,output:a}),n.setRow(i,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 pt(this.rows,this.columns);for(let i=0;i<this.columns;i++){const a=this.getColumn(i);a.length&&Rf(a,{min:e,max:r,output:a}),n.setColumn(i,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),i=this.get(e,this.columns-1-r);this.set(e,r,i),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),i=this.get(this.rows-1-r,e);this.set(r,e,i),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=pt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,i=t.columns,a=new pt(e*n,r*i);for(let l=0;l<e;l++)for(let c=0;c<r;c++)for(let h=0;h<n;h++)for(let p=0;p<i;p++)a.set(n*l+h,i*c+p,this.get(l,c)*t.get(h,p));return a}kroneckerSum(t){if(t=pt.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(pt.eye(r,r)),i=pt.eye(e,e).kroneckerProduct(t);return n.add(i)}transpose(){let t=new pt(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=kf){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=kf){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Pa(this,t,e,r,n);let i=new pt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let l=r;l<=n;l++)i.set(a-t,l-r,this.get(a,l));return i}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 pt(t.length,r-e+1);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,a-e,this.get(t[i],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 pt(r-e+1,t.length);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(a-e,i,this.get(a,t[i]))}return n}setSubMatrix(t,e,r){if(t=pt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,i=r+t.columns-1;Pa(this,e,n,r,i);for(let a=0;a<t.rows;a++)for(let l=0;l<t.columns;l++)this.set(e+a,r+l,t.get(a,l));return this}selection(t,e){La(this,t),Ra(this,e);let r=new pt(t.length,e.length);for(let n=0;n<t.length;n++){let i=t[n];for(let a=0;a<e.length;a++){let l=e[a];r.set(n,a,this.get(i,l))}}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 pt(this.rows,this.columns))}static copy(t,e){for(const[r,n,i]of t.entries())e.set(r,n,i);return e}sum(t){switch(t){case"row":return T1(this);case"column":return $1(this);case void 0:return L1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return R1(this);case"column":return P1(this);case void 0:return z1(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(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return q1(this,r,n)}case"column":{if(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return k1(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return U1(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(!cr.isAnyArray(r))throw new TypeError("center must be an array");return W1(this,r),this}case"column":{if(!cr.isAnyArray(r))throw new TypeError("center must be an array");return j1(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return Y1(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=V1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return Z1(this,r),this}case"column":{if(r===void 0)r=K1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return G1(this,r),this}case void 0:{if(r===void 0)r=H1(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return J1(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return zf(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")]=S1);function kf(s,t){return s-t}function X1(s){return s.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 pt=(Ni=class extends $t{constructor(e,r){super();Al(this,es);$(this,"data");if(Ni.isMatrix(e))Cl(this,es,Fl).call(this,e.rows,e.columns),Ni.copy(e,this);else if(Number.isInteger(e)&&e>=0)Cl(this,es,Fl).call(this,e,r);else if(cr.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 i=0;i<e;i++){if(n[i].length!==r)throw new RangeError("Inconsistent array dimensions");if(!X1(n[i]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}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 Sr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Sr(this,e,!0),r=Float64Array.from(Di(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Br(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let i=0;i<e;i++)n[i]=this.data[r][i];for(let i=e+1;i<this.columns;i++)n[i-1]=this.data[r][i];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Br(this,e,!0),r=bi(this,r);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)i[a]=this.data[n][a];for(i[a++]=r[n];a<this.columns+1;a++)i[a]=this.data[n][a-1];this.data[n]=i}return this.columns+=1,this}},es=new WeakSet,Fl=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},Ni);I1($t,pt);const go=class go extends $t{constructor(e){super();Al(this,Xe,void 0);if(pt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ua(this,Xe,pt.copy(e,new pt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ua(this,Xe,new pt(e,e));else if(ua(this,Xe,new pt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Jr(this,Xe).size}get rows(){return Jr(this,Xe).rows}get columns(){return Jr(this,Xe).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return pt.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 go(this.diagonalSize);for(const[r,n,i]of this.upperRightEntries())e.set(r,n,i);return e}toMatrix(){return new pt(this)}get(e,r){return Jr(this,Xe).get(e,r)}set(e,r,n){return Jr(this,Xe).set(e,r,n),Jr(this,Xe).set(r,e,n),this}removeCross(e){return Jr(this,Xe).removeRow(e),Jr(this,Xe).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Jr(this,Xe).addRow(e,n),Jr(this,Xe).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,i]of e.entries())i||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,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=e&&(n=++i);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 i=new go(n);for(let a=0,l=0,c=0;c<r;c++)i.set(a,l,e[c]),++a>=n&&(a=++l);return i}*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)}};Xe=new WeakMap;let Xn=go;Xn.prototype.klassType="SymmetricMatrix";class ro extends Xn{static isDistanceMatrix(t){return Xn.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 Xn(this)}clone(){const t=new ro(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,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=t&&(n=++i+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 i=1,a=0,l=0;l<e;l++)n.set(i,a,t[l]),++i>=r&&(i=++a+1);return n}}ro.prototype.klassSubType="DistanceMatrix";class fn extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class Q1 extends fn{constructor(t,e){Br(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 ty extends fn{constructor(t,e){Ra(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 ey extends fn{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 ry extends fn{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 ny extends fn{constructor(t,e){Sr(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 iy extends fn{constructor(t,e){La(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 no extends fn{constructor(t,e,r){La(t,e),Ra(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 sy extends fn{constructor(t,e,r,n,i){Pa(t,e,r,n,i),super(t,r-e+1,i-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 oy extends fn{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 Uf 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 gr 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 ay(s,t){if(cr.isAnyArray(s))return s[0]&&cr.isAnyArray(s[0])?new gr(s):new Uf(s,t);throw new Error("the argument is not an array")}class io{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,i=new Float64Array(r),a=1,l,c,h,p,f,d,g,y,m;for(l=0;l<r;l++)i[l]=l;for(y=new Float64Array(r),c=0;c<n;c++){for(l=0;l<r;l++)y[l]=e.get(l,c);for(l=0;l<r;l++){for(m=Math.min(l,c),f=0,h=0;h<m;h++)f+=e.get(l,h)*y[h];y[l]-=f,e.set(l,c,y[l])}for(p=c,l=c+1;l<r;l++)Math.abs(y[l])>Math.abs(y[p])&&(p=l);if(p!==c){for(h=0;h<n;h++)d=e.get(p,h),e.set(p,h,e.get(c,h)),e.set(c,h,d);g=i[p],i[p]=i[c],i[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(l=c+1;l<r;l++)e.set(l,c,e.get(l,c)/e.get(c,c))}this.LU=e,this.pivotVector=i,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=pt.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,i=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,l,c,h;for(h=0;h<a;h++)for(l=h+1;l<a;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h));for(h=a-1;h>=0;h--){for(c=0;c<n;c++)i.set(h,c,i.get(h,c)/e.get(h,h));for(l=0;l<h;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h))}return i}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 pt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i>a?n.set(i,a,t.get(i,a)):i===a?n.set(i,a,1):n.set(i,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i<=a?n.set(i,a,t.get(i,a)):n.set(i,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hn(s,t){let e=0;return Math.abs(s)>Math.abs(t)?(e=t/s,Math.abs(s)*Math.sqrt(1+e*e)):t!==0?(e=s/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class za{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,i=new Float64Array(n),a,l,c,h;for(c=0;c<n;c++){let p=0;for(a=c;a<r;a++)p=hn(p,e.get(a,c));if(p!==0){for(e.get(c,c)<0&&(p=-p),a=c;a<r;a++)e.set(a,c,e.get(a,c)/p);for(e.set(c,c,e.get(c,c)+1),l=c+1;l<n;l++){for(h=0,a=c;a<r;a++)h+=e.get(a,c)*e.get(a,l);for(h=-h/e.get(c,c),a=c;a<r;a++)e.set(a,l,e.get(a,l)+h*e.get(a,c))}}i[c]=-p}this.QR=e,this.Rdiag=i}solve(t){t=pt.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,i=t.clone(),a=e.columns,l,c,h,p;for(h=0;h<a;h++)for(c=0;c<n;c++){for(p=0,l=h;l<r;l++)p+=e.get(l,h)*i.get(l,c);for(p=-p/e.get(h,h),l=h;l<r;l++)i.set(l,c,i.get(l,c)+p*e.get(l,h))}for(h=a-1;h>=0;h--){for(c=0;c<n;c++)i.set(h,c,i.get(h,c)/this.Rdiag[h]);for(l=0;l<h;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h))}return i.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 pt(e,e),n,i;for(n=0;n<e;n++)for(i=0;i<e;i++)n<i?r.set(n,i,t.get(n,i)):n===i?r.set(n,i,this.Rdiag[n]):r.set(n,i,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new pt(e,r),i,a,l,c;for(l=r-1;l>=0;l--){for(i=0;i<e;i++)n.set(i,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(t.get(l,l)!==0){for(c=0,i=l;i<e;i++)c+=t.get(i,l)*n.get(i,a);for(c=-c/t.get(l,l),i=l;i<e;i++)n.set(i,a,n.get(i,a)+c*t.get(i,l))}}return n}}class Ei{constructor(t,e={}){if(t=gr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=e;let c=!!i,h=!!a,p=!1,f;if(r<n)if(!l)f=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{f=t.transpose(),r=f.rows,n=f.columns,p=!0;let F=c;c=h,h=F}else f=t.clone();let d=Math.min(r,n),g=Math.min(r+1,n),y=new Float64Array(g),m=new pt(r,d),w=new pt(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 N=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),C=Math.max(N,E);for(let F=0;F<C;F++){if(F<N){y[F]=0;for(let O=F;O<r;O++)y[F]=hn(y[F],f.get(O,F));if(y[F]!==0){f.get(F,F)<0&&(y[F]=-y[F]);for(let O=F;O<r;O++)f.set(O,F,f.get(O,F)/y[F]);f.set(F,F,f.get(F,F)+1)}y[F]=-y[F]}for(let O=F+1;O<n;O++){if(F<N&&y[F]!==0){let R=0;for(let U=F;U<r;U++)R+=f.get(U,F)*f.get(U,O);R=-R/f.get(F,F);for(let U=F;U<r;U++)f.set(U,O,f.get(U,O)+R*f.get(U,F))}v[O]=f.get(F,O)}if(c&&F<N)for(let O=F;O<r;O++)m.set(O,F,f.get(O,F));if(F<E){v[F]=0;for(let O=F+1;O<n;O++)v[F]=hn(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 R=F+1;R<n;R++)x[O]+=v[R]*f.get(O,R);for(let O=F+1;O<n;O++){let R=-v[O]/v[F+1];for(let U=F+1;U<r;U++)f.set(U,O,f.get(U,O)+R*x[U])}}if(h)for(let O=F+1;O<n;O++)w.set(O,F,v[O])}}let M=Math.min(n,r+1);if(N<n&&(y[N]=f.get(N,N)),r<M&&(y[M-1]=0),E+1<M&&(v[E]=f.get(E,M-1)),v[M-1]=0,c){for(let F=N;F<d;F++){for(let O=0;O<r;O++)m.set(O,F,0);m.set(F,F,1)}for(let F=N-1;F>=0;F--)if(y[F]!==0){for(let O=F+1;O<d;O++){let R=0;for(let U=F;U<r;U++)R+=m.get(U,F)*m.get(U,O);R=-R/m.get(F,F);for(let U=F;U<r;U++)m.set(U,O,m.get(U,O)+R*m.get(U,F))}for(let O=F;O<r;O++)m.set(O,F,-m.get(O,F));m.set(F,F,1+m.get(F,F));for(let O=0;O<F-1;O++)m.set(O,F,0)}else{for(let O=0;O<r;O++)m.set(O,F,0);m.set(F,F,1)}}if(h)for(let F=n-1;F>=0;F--){if(F<E&&v[F]!==0)for(let O=F+1;O<n;O++){let R=0;for(let U=F+1;U<n;U++)R+=w.get(U,F)*w.get(U,O);R=-R/w.get(F+1,F);for(let U=F+1;U<n;U++)w.set(U,O,w.get(U,O)+R*w.get(U,F))}for(let O=0;O<n;O++)w.set(O,F,0);w.set(F,F,1)}let S=M-1,T=Number.EPSILON;for(;M>0;){let F,O;for(F=M-2;F>=-1&&F!==-1;F--){const R=Number.MIN_VALUE+T*Math.abs(y[F]+Math.abs(y[F+1]));if(Math.abs(v[F])<=R||Number.isNaN(v[F])){v[F]=0;break}}if(F===M-2)O=4;else{let R;for(R=M-1;R>=F&&R!==F;R--){let U=(R!==M?Math.abs(v[R]):0)+(R!==F+1?Math.abs(v[R-1]):0);if(Math.abs(y[R])<=T*U){y[R]=0;break}}R===F?O=3:R===M-1?O=1:(O=2,F=R)}switch(F++,O){case 1:{let R=v[M-2];v[M-2]=0;for(let U=M-2;U>=F;U--){let k=hn(y[U],R),W=y[U]/k,z=R/k;if(y[U]=k,U!==F&&(R=-z*v[U-1],v[U-1]=W*v[U-1]),h)for(let K=0;K<n;K++)k=W*w.get(K,U)+z*w.get(K,M-1),w.set(K,M-1,-z*w.get(K,U)+W*w.get(K,M-1)),w.set(K,U,k)}break}case 2:{let R=v[F-1];v[F-1]=0;for(let U=F;U<M;U++){let k=hn(y[U],R),W=y[U]/k,z=R/k;if(y[U]=k,R=-z*v[U],v[U]=W*v[U],c)for(let K=0;K<r;K++)k=W*m.get(K,U)+z*m.get(K,F-1),m.set(K,F-1,-z*m.get(K,U)+W*m.get(K,F-1)),m.set(K,U,k)}break}case 3:{const R=Math.max(Math.abs(y[M-1]),Math.abs(y[M-2]),Math.abs(v[M-2]),Math.abs(y[F]),Math.abs(v[F])),U=y[M-1]/R,k=y[M-2]/R,W=v[M-2]/R,z=y[F]/R,K=v[F]/R,Z=((k+U)*(k-U)+W*W)/2,X=U*W*(U*W);let Q=0;(Z!==0||X!==0)&&(Z<0?Q=0-Math.sqrt(Z*Z+X):Q=Math.sqrt(Z*Z+X),Q=X/(Z+Q));let ct=(z+U)*(z-U)+Q,vt=z*K;for(let lt=F;lt<M-1;lt++){let wt=hn(ct,vt);wt===0&&(wt=Number.MIN_VALUE);let bt=ct/wt,Bt=vt/wt;if(lt!==F&&(v[lt-1]=wt),ct=bt*y[lt]+Bt*v[lt],v[lt]=bt*v[lt]-Bt*y[lt],vt=Bt*y[lt+1],y[lt+1]=bt*y[lt+1],h)for(let xt=0;xt<n;xt++)wt=bt*w.get(xt,lt)+Bt*w.get(xt,lt+1),w.set(xt,lt+1,-Bt*w.get(xt,lt)+bt*w.get(xt,lt+1)),w.set(xt,lt,wt);if(wt=hn(ct,vt),wt===0&&(wt=Number.MIN_VALUE),bt=ct/wt,Bt=vt/wt,y[lt]=wt,ct=bt*v[lt]+Bt*y[lt+1],y[lt+1]=-Bt*v[lt]+bt*y[lt+1],vt=Bt*v[lt+1],v[lt+1]=bt*v[lt+1],c&<<r-1)for(let xt=0;xt<r;xt++)wt=bt*m.get(xt,lt)+Bt*m.get(xt,lt+1),m.set(xt,lt+1,-Bt*m.get(xt,lt)+bt*m.get(xt,lt+1)),m.set(xt,lt,wt)}v[M-2]=ct;break}case 4:{if(y[F]<=0&&(y[F]=y[F]<0?-y[F]:0,h))for(let R=0;R<=S;R++)w.set(R,F,-w.get(R,F));for(;F<S&&!(y[F]>=y[F+1]);){let R=y[F];if(y[F]=y[F+1],y[F+1]=R,h&&F<n-1)for(let U=0;U<n;U++)R=w.get(U,F+1),w.set(U,F+1,w.get(U,F)),w.set(U,F,R);if(c&&F<r-1)for(let U=0;U<r;U++)R=m.get(U,F+1),m.set(U,F+1,m.get(U,F)),m.set(U,F,R);F++}M--;break}}}if(p){let F=w;w=m,m=F}this.m=r,this.n=n,this.s=y,this.U=m,this.V=w}solve(t){let e=t,r=this.threshold,n=this.s.length,i=pt.zeros(n,n);for(let d=0;d<n;d++)Math.abs(this.s[d])<=r?i.set(d,d,0):i.set(d,d,1/this.s[d]);let a=this.U,l=this.rightSingularVectors,c=l.mmul(i),h=l.rows,p=a.rows,f=pt.zeros(h,p);for(let d=0;d<h;d++)for(let g=0;g<p;g++){let y=0;for(let m=0;m<n;m++)y+=c.get(d,m)*a.get(g,m);f.set(d,g,y)}return f.mmul(e)}solveForDiagonal(t){return this.solve(pt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,i=new pt(r,this.s.length);for(let p=0;p<r;p++)for(let f=0;f<n;f++)Math.abs(this.s[f])>e&&i.set(p,f,t.get(p,f)/this.s[f]);let a=this.U,l=a.rows,c=a.columns,h=new pt(r,l);for(let p=0;p<r;p++)for(let f=0;f<l;f++){let d=0;for(let g=0;g<c;g++)d+=i.get(p,g)*a.get(f,g);h.set(p,f,d)}return h}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,i=r.length;n<i;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 pt.diag(this.s)}}function uy(s,t=!1){return s=gr.checkMatrix(s),t?new Ei(s).inverse():Wf(s,pt.eye(s.rows))}function Wf(s,t,e=!1){return s=gr.checkMatrix(s),t=gr.checkMatrix(t),e?new Ei(s).solve(t):s.isSquare()?new io(s).solve(t):new za(s).solve(t)}function so(s){if(s=pt.checkMatrix(s),s.isSquare()){if(s.columns===0)return 1;let t,e,r,n;if(s.columns===2)return t=s.get(0,0),e=s.get(0,1),r=s.get(1,0),n=s.get(1,1),t*n-e*r;if(s.columns===3){let i,a,l;return i=new no(s,[1,2],[1,2]),a=new no(s,[1,2],[0,2]),l=new no(s,[1,2],[0,1]),t=s.get(0,0),e=s.get(0,1),r=s.get(0,2),t*so(i)-e*so(a)+r*so(l)}else return new io(s).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ly(s,t){let e=[];for(let r=0;r<s;r++)r!==t&&e.push(r);return e}function cy(s,t,e,r=1e-9,n=1e-9){if(s>n)return new Array(t.rows+1).fill(0);{let i=t.addRow(e,[0]);for(let a=0;a<i.rows;a++)Math.abs(i.get(a,0))<r&&i.set(a,0,0);return i.to1DArray()}}function fy(s,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;s=pt.checkMatrix(s);let n=s.rows,i=new pt(n,n);for(let a=0;a<n;a++){let l=pt.columnVector(s.getRow(a)),c=s.subMatrixRow(ly(n,a)).transpose(),p=new Ei(c).solve(l),f=pt.sub(l,c.mmul(p)).abs().max();i.setRow(a,cy(f,p,a,e,r))}return i}function hy(s,t=Number.EPSILON){if(s=pt.checkMatrix(s),s.isEmpty())return s.transpose();let e=new Ei(s,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,i=e.diagonal;for(let a=0;a<i.length;a++)Math.abs(i[a])>t?i[a]=1/i[a]:i[a]=0;return n.mmul(pt.diag(i).mmul(r.transpose()))}function py(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new pt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(s=s.center("column"),r||(t=t.center("column")));const i=s.transpose().mmul(t);for(let a=0;a<i.rows;a++)for(let l=0;l<i.columns;l++)i.set(a,l,i.get(a,l)*(1/(s.rows-1)));return i}function dy(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new pt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:i=!0}=e;n&&(s.center("column"),r||t.center("column")),i&&(s.scale("column"),r||t.scale("column"));const a=s.standardDeviation("column",{unbiased:!0}),l=r?a:t.standardDeviation("column",{unbiased:!0}),c=s.transpose().mmul(t);for(let h=0;h<c.rows;h++)for(let p=0;p<c.columns;p++)c.set(h,p,c.get(h,p)*(1/(a[h]*l[p]))*(1/(s.rows-1)));return c}let jf=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=gr.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,i=new pt(n,n),a=new Float64Array(n),l=new Float64Array(n),c=t,h,p,f=!1;if(r?f=!0:f=t.isSymmetric(),f){for(h=0;h<n;h++)for(p=0;p<n;p++)i.set(h,p,c.get(h,p));_y(n,l,a,i),my(n,l,a,i)}else{let d=new pt(n,n),g=new Float64Array(n);for(p=0;p<n;p++)for(h=0;h<n;h++)d.set(h,p,c.get(h,p));gy(n,d,g,i),vy(n,l,a,i,d)}this.n=n,this.e=l,this.d=a,this.V=i}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 pt(t,t),i,a;for(i=0;i<t;i++){for(a=0;a<t;a++)n.set(i,a,0);n.set(i,i,r[i]),e[i]>0?n.set(i,i+1,e[i]):e[i]<0&&n.set(i,i-1,e[i])}return n}};function _y(s,t,e,r){let n,i,a,l,c,h,p,f;for(c=0;c<s;c++)e[c]=r.get(s-1,c);for(l=s-1;l>0;l--){for(f=0,a=0,h=0;h<l;h++)f=f+Math.abs(e[h]);if(f===0)for(t[l]=e[l-1],c=0;c<l;c++)e[c]=r.get(l-1,c),r.set(l,c,0),r.set(c,l,0);else{for(h=0;h<l;h++)e[h]/=f,a+=e[h]*e[h];for(n=e[l-1],i=Math.sqrt(a),n>0&&(i=-i),t[l]=f*i,a=a-n*i,e[l-1]=n-i,c=0;c<l;c++)t[c]=0;for(c=0;c<l;c++){for(n=e[c],r.set(c,l,n),i=t[c]+r.get(c,c)*n,h=c+1;h<=l-1;h++)i+=r.get(h,c)*e[h],t[h]+=r.get(h,c)*n;t[c]=i}for(n=0,c=0;c<l;c++)t[c]/=a,n+=t[c]*e[c];for(p=n/(a+a),c=0;c<l;c++)t[c]-=p*e[c];for(c=0;c<l;c++){for(n=e[c],i=t[c],h=c;h<=l-1;h++)r.set(h,c,r.get(h,c)-(n*t[h]+i*e[h]));e[c]=r.get(l-1,c),r.set(l,c,0)}}e[l]=a}for(l=0;l<s-1;l++){if(r.set(s-1,l,r.get(l,l)),r.set(l,l,1),a=e[l+1],a!==0){for(h=0;h<=l;h++)e[h]=r.get(h,l+1)/a;for(c=0;c<=l;c++){for(i=0,h=0;h<=l;h++)i+=r.get(h,l+1)*r.get(h,c);for(h=0;h<=l;h++)r.set(h,c,r.get(h,c)-i*e[h])}}for(h=0;h<=l;h++)r.set(h,l+1,0)}for(c=0;c<s;c++)e[c]=r.get(s-1,c),r.set(s-1,c,0);r.set(s-1,s-1,1),t[0]=0}function my(s,t,e,r){let n,i,a,l,c,h,p,f,d,g,y,m,w,v,x,b;for(a=1;a<s;a++)t[a-1]=t[a];t[s-1]=0;let N=0,E=0,C=Number.EPSILON;for(h=0;h<s;h++){for(E=Math.max(E,Math.abs(e[h])+Math.abs(t[h])),p=h;p<s&&!(Math.abs(t[p])<=C*E);)p++;if(p>h)do{for(n=e[h],f=(e[h+1]-n)/(2*t[h]),d=hn(f,1),f<0&&(d=-d),e[h]=t[h]/(f+d),e[h+1]=t[h]*(f+d),g=e[h+1],i=n-e[h],a=h+2;a<s;a++)e[a]-=i;for(N=N+i,f=e[p],y=1,m=y,w=y,v=t[h+1],x=0,b=0,a=p-1;a>=h;a--)for(w=m,m=y,b=x,n=y*t[a],i=y*f,d=hn(f,t[a]),t[a+1]=x*d,x=t[a]/d,y=f/d,f=y*e[a]-x*n,e[a+1]=i+x*(y*n+x*e[a]),c=0;c<s;c++)i=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+y*i),r.set(c,a,y*r.get(c,a)-x*i);f=-x*b*w*v*t[h]/g,t[h]=x*f,e[h]=y*f}while(Math.abs(t[h])>C*E);e[h]=e[h]+N,t[h]=0}for(a=0;a<s-1;a++){for(c=a,f=e[a],l=a+1;l<s;l++)e[l]<f&&(c=l,f=e[l]);if(c!==a)for(e[c]=e[a],e[a]=f,l=0;l<s;l++)f=r.get(l,a),r.set(l,a,r.get(l,c)),r.set(l,c,f)}}function gy(s,t,e,r){let n=0,i=s-1,a,l,c,h,p,f,d;for(f=n+1;f<=i-1;f++){for(d=0,h=f;h<=i;h++)d=d+Math.abs(t.get(h,f-1));if(d!==0){for(c=0,h=i;h>=f;h--)e[h]=t.get(h,f-1)/d,c+=e[h]*e[h];for(l=Math.sqrt(c),e[f]>0&&(l=-l),c=c-e[f]*l,e[f]=e[f]-l,p=f;p<s;p++){for(a=0,h=i;h>=f;h--)a+=e[h]*t.get(h,p);for(a=a/c,h=f;h<=i;h++)t.set(h,p,t.get(h,p)-a*e[h])}for(h=0;h<=i;h++){for(a=0,p=i;p>=f;p--)a+=e[p]*t.get(h,p);for(a=a/c,p=f;p<=i;p++)t.set(h,p,t.get(h,p)-a*e[p])}e[f]=d*e[f],t.set(f,f-1,d*l)}}for(h=0;h<s;h++)for(p=0;p<s;p++)r.set(h,p,h===p?1:0);for(f=i-1;f>=n+1;f--)if(t.get(f,f-1)!==0){for(h=f+1;h<=i;h++)e[h]=t.get(h,f-1);for(p=f;p<=i;p++){for(l=0,h=f;h<=i;h++)l+=e[h]*r.get(h,p);for(l=l/e[f]/t.get(f,f-1),h=f;h<=i;h++)r.set(h,p,r.get(h,p)+l*e[h])}}}function vy(s,t,e,r,n){let i=s-1,a=0,l=s-1,c=Number.EPSILON,h=0,p=0,f=0,d=0,g=0,y=0,m=0,w=0,v,x,b,N,E,C,M,S,T,F,O,R,U,k,W;for(v=0;v<s;v++)for((v<a||v>l)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<s;x++)p=p+Math.abs(n.get(v,x));for(;i>=a;){for(N=i;N>a&&(y=Math.abs(n.get(N-1,N-1))+Math.abs(n.get(N,N)),y===0&&(y=p),!(Math.abs(n.get(N,N-1))<c*y));)N--;if(N===i)n.set(i,i,n.get(i,i)+h),e[i]=n.get(i,i),t[i]=0,i--,w=0;else if(N===i-1){if(M=n.get(i,i-1)*n.get(i-1,i),f=(n.get(i-1,i-1)-n.get(i,i))/2,d=f*f+M,m=Math.sqrt(Math.abs(d)),n.set(i,i,n.get(i,i)+h),n.set(i-1,i-1,n.get(i-1,i-1)+h),S=n.get(i,i),d>=0){for(m=f>=0?f+m:f-m,e[i-1]=S+m,e[i]=e[i-1],m!==0&&(e[i]=S-M/m),t[i-1]=0,t[i]=0,S=n.get(i,i-1),y=Math.abs(S)+Math.abs(m),f=S/y,d=m/y,g=Math.sqrt(f*f+d*d),f=f/g,d=d/g,x=i-1;x<s;x++)m=n.get(i-1,x),n.set(i-1,x,d*m+f*n.get(i,x)),n.set(i,x,d*n.get(i,x)-f*m);for(v=0;v<=i;v++)m=n.get(v,i-1),n.set(v,i-1,d*m+f*n.get(v,i)),n.set(v,i,d*n.get(v,i)-f*m);for(v=a;v<=l;v++)m=r.get(v,i-1),r.set(v,i-1,d*m+f*r.get(v,i)),r.set(v,i,d*r.get(v,i)-f*m)}else e[i-1]=S+f,e[i]=S+f,t[i-1]=m,t[i]=-m;i=i-2,w=0}else{if(S=n.get(i,i),T=0,M=0,N<i&&(T=n.get(i-1,i-1),M=n.get(i,i-1)*n.get(i-1,i)),w===10){for(h+=S,v=a;v<=i;v++)n.set(v,v,n.get(v,v)-S);y=Math.abs(n.get(i,i-1))+Math.abs(n.get(i-1,i-2)),S=T=.75*y,M=-.4375*y*y}if(w===30&&(y=(T-S)/2,y=y*y+M,y>0)){for(y=Math.sqrt(y),T<S&&(y=-y),y=S-M/((T-S)/2+y),v=a;v<=i;v++)n.set(v,v,n.get(v,v)-y);h+=y,S=T=M=.964}for(w=w+1,E=i-2;E>=N&&(m=n.get(E,E),g=S-m,y=T-m,f=(g*y-M)/n.get(E+1,E)+n.get(E,E+1),d=n.get(E+1,E+1)-m-g-y,g=n.get(E+2,E+1),y=Math.abs(f)+Math.abs(d)+Math.abs(g),f=f/y,d=d/y,g=g/y,!(E===N||Math.abs(n.get(E,E-1))*(Math.abs(d)+Math.abs(g))<c*(Math.abs(f)*(Math.abs(n.get(E-1,E-1))+Math.abs(m)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=i;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=i-1&&(k=b!==i-1,b!==E&&(f=n.get(b,b-1),d=n.get(b+1,b-1),g=k?n.get(b+2,b-1):0,S=Math.abs(f)+Math.abs(d)+Math.abs(g),S!==0&&(f=f/S,d=d/S,g=g/S)),S!==0);b++)if(y=Math.sqrt(f*f+d*d+g*g),f<0&&(y=-y),y!==0){for(b!==E?n.set(b,b-1,-y*S):N!==E&&n.set(b,b-1,-n.get(b,b-1)),f=f+y,S=f/y,T=d/y,m=g/y,d=d/f,g=g/f,x=b;x<s;x++)f=n.get(b,x)+d*n.get(b+1,x),k&&(f=f+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-f*m)),n.set(b,x,n.get(b,x)-f*S),n.set(b+1,x,n.get(b+1,x)-f*T);for(v=0;v<=Math.min(i,b+3);v++)f=S*n.get(v,b)+T*n.get(v,b+1),k&&(f=f+m*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-f*g)),n.set(v,b,n.get(v,b)-f),n.set(v,b+1,n.get(v,b+1)-f*d);for(v=a;v<=l;v++)f=S*r.get(v,b)+T*r.get(v,b+1),k&&(f=f+m*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-f*g)),r.set(v,b,r.get(v,b)-f),r.set(v,b+1,r.get(v,b+1)-f*d)}}}if(p!==0){for(i=s-1;i>=0;i--)if(f=e[i],d=t[i],d===0)for(N=i,n.set(i,i,1),v=i-1;v>=0;v--){for(M=n.get(v,v)-f,g=0,x=N;x<=i;x++)g=g+n.get(v,x)*n.get(x,i);if(t[v]<0)m=M,y=g;else if(N=v,t[v]===0?n.set(v,i,M!==0?-g/M:-g/(c*p)):(S=n.get(v,v+1),T=n.get(v+1,v),d=(e[v]-f)*(e[v]-f)+t[v]*t[v],C=(S*y-m*g)/d,n.set(v,i,C),n.set(v+1,i,Math.abs(S)>Math.abs(m)?(-g-M*C)/S:(-y-T*C)/m)),C=Math.abs(n.get(v,i)),c*C*C>1)for(x=v;x<=i;x++)n.set(x,i,n.get(x,i)/C)}else if(d<0)for(N=i-1,Math.abs(n.get(i,i-1))>Math.abs(n.get(i-1,i))?(n.set(i-1,i-1,d/n.get(i,i-1)),n.set(i-1,i,-(n.get(i,i)-f)/n.get(i,i-1))):(W=oo(0,-n.get(i-1,i),n.get(i-1,i-1)-f,d),n.set(i-1,i-1,W[0]),n.set(i-1,i,W[1])),n.set(i,i-1,0),n.set(i,i,1),v=i-2;v>=0;v--){for(F=0,O=0,x=N;x<=i;x++)F=F+n.get(v,x)*n.get(x,i-1),O=O+n.get(v,x)*n.get(x,i);if(M=n.get(v,v)-f,t[v]<0)m=M,g=F,y=O;else if(N=v,t[v]===0?(W=oo(-F,-O,M,d),n.set(v,i-1,W[0]),n.set(v,i,W[1])):(S=n.get(v,v+1),T=n.get(v+1,v),R=(e[v]-f)*(e[v]-f)+t[v]*t[v]-d*d,U=(e[v]-f)*2*d,R===0&&U===0&&(R=c*p*(Math.abs(M)+Math.abs(d)+Math.abs(S)+Math.abs(T)+Math.abs(m))),W=oo(S*g-m*F+d*O,S*y-m*O-d*F,R,U),n.set(v,i-1,W[0]),n.set(v,i,W[1]),Math.abs(S)>Math.abs(m)+Math.abs(d)?(n.set(v+1,i-1,(-F-M*n.get(v,i-1)+d*n.get(v,i))/S),n.set(v+1,i,(-O-M*n.get(v,i)-d*n.get(v,i-1))/S)):(W=oo(-g-T*n.get(v,i-1),-y-T*n.get(v,i),m,d),n.set(v+1,i-1,W[0]),n.set(v+1,i,W[1]))),C=Math.max(Math.abs(n.get(v,i-1)),Math.abs(n.get(v,i))),c*C*C>1)for(x=v;x<=i;x++)n.set(x,i-1,n.get(x,i-1)/C),n.set(x,i,n.get(x,i)/C)}for(v=0;v<s;v++)if(v<a||v>l)for(x=v;x<s;x++)r.set(v,x,n.get(v,x));for(x=s-1;x>=a;x--)for(v=a;v<=l;v++){for(m=0,b=a;b<=Math.min(x,l);b++)m=m+r.get(v,b)*n.get(b,x);r.set(v,x,m)}}}function oo(s,t,e,r){let n,i;return Math.abs(e)>Math.abs(r)?(n=r/e,i=e+n*r,[(s+n*t)/i,(t-n*s)/i]):(n=e/r,i=r+n*e,[(n*s+t)/i,(n*t-s)/i])}class Yf{constructor(t){if(t=gr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new pt(r,r),i=!0,a,l,c;for(l=0;l<r;l++){let h=0;for(c=0;c<l;c++){let p=0;for(a=0;a<c;a++)p+=n.get(c,a)*n.get(l,a);p=(e.get(l,c)-p)/n.get(c,c),n.set(l,c,p),h=h+p*p}for(h=e.get(l,l)-h,i&=h>0,n.set(l,l,Math.sqrt(Math.max(h,0))),c=l+1;c<r;c++)n.set(l,c,0)}this.L=n,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=gr.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,i=t.clone(),a,l,c;for(c=0;c<r;c++)for(l=0;l<n;l++){for(a=0;a<c;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(c,a));i.set(c,l,i.get(c,l)/e.get(c,c))}for(c=r-1;c>=0;c--)for(l=0;l<n;l++){for(a=c+1;a<r;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(a,c));i.set(c,l,i.get(c,l)/e.get(c,c))}return i}get lowerTriangularMatrix(){return this.L}}class Vf{constructor(t,e={}){t=gr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:i=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(cr.isAnyArray(r)&&typeof r[0]=="number"?r=pt.columnVector(r):r=gr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");l=r.getColumnVector(0)}else l=t.getColumnVector(0);let c=1,h,p,f,d;for(let g=0;g<i&&c>a;g++)f=t.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),f=f.div(f.norm()),h=t.mmul(f).div(f.transpose().mmul(f).get(0,0)),g>0&&(c=h.clone().sub(d).pow(2).sum()),d=h.clone(),r?(p=r.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),p=p.div(p.norm()),l=r.mmul(p).div(p.transpose().mmul(p).get(0,0))):l=h;if(r){let g=t.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0));g=g.div(g.norm());let y=t.clone().sub(h.clone().mmul(g.transpose())),m=l.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),w=r.clone().sub(h.clone().mulS(m.get(0,0)).mmul(p.transpose()));this.t=h,this.p=g.transpose(),this.w=f.transpose(),this.q=p,this.u=l,this.s=h.transpose().mmul(h),this.xResidual=y,this.yResidual=w,this.betas=m}else this.w=f.transpose(),this.s=h.transpose().mmul(h).sqrt(),n?this.t=h.clone().div(this.s.get(0,0)):this.t=h,this.xResidual=t.sub(h.mmul(f.transpose()))}}qt.AbstractMatrix=$t,qt.CHO=Yf,qt.CholeskyDecomposition=Yf,qt.DistanceMatrix=ro,qt.EVD=jf;var yy=qt.EigenvalueDecomposition=jf;qt.LU=io,qt.LuDecomposition=io;var Zf=qt.Matrix=pt;qt.MatrixColumnSelectionView=ty,qt.MatrixColumnView=Q1,qt.MatrixFlipColumnView=ey,qt.MatrixFlipRowView=ry,qt.MatrixRowSelectionView=iy,qt.MatrixRowView=ny,qt.MatrixSelectionView=no,qt.MatrixSubView=sy,qt.MatrixTransposeView=oy,qt.NIPALS=Vf,qt.Nipals=Vf,qt.QR=za,qt.QrDecomposition=za,qt.SVD=Ei,qt.SingularValueDecomposition=Ei,qt.SymmetricMatrix=Xn,qt.WrapperMatrix1D=Uf,qt.WrapperMatrix2D=gr,qt.correlation=dy,qt.covariance=py;var Kf=qt.default=pt;qt.determinant=so,qt.inverse=uy,qt.linearDependencies=fy,qt.pseudoInverse=hy,qt.solve=Wf,qt.wrap=ay;const Gf=yy,Hf=Zf;Kf.Matrix&&Kf.Matrix;class wy{constructor(t){$(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new qa(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:i,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:i,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:i}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:i})}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 qa{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 Qt(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const i of n._value)t+=_t(i)?0:i,e+=1;return t/e}col({column:t}){const e=[],r=new Qt(0,void 0,this._errorListener);if(_t(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return $f(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(_t(t)||_t(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=Xs(this._matrixArray);return this._newMatrix(t)}max(){return _1(this._matrixArray)}min(){return $a(this._matrixArray)}pow({power:t}){const e=_t(t)?this._matrixArray:g1(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return _t(t)?new Qt(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){_t(t)||_t(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=Qi(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=l1(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:i}={}){_t(e)&&(e=0),_t(r)&&(r=this.rows()),_t(n)&&(n=0),_t(i)&&(i=this.columns());for(const[a,l]of this._matrixInstance.entries())for(const[c]of l._value.entries())a<r&&a>=e&&c>=n&&c<i&&l.set({index:c,value:t})}kron({id2:t}){const e=a1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return $a(Mf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=wi(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=m1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Vn.ascending}={}){_t(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const i=r._value[t],a=n._value[t];return e!==Vn.descending?i-a:a-i})}trace(){return d1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Lf(this._matrixArray)}add_col({column:t,array_id:e}={}){_t(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}){_t(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new Qt(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(le.matrixRehapeErr,r,zt.Error);return}const n=n1(this._matrixArray,[t,e]);this._matrixInstance=n.map(i=>{const a=new Qt(0,void 0,this._errorListener);return a._value=[...i],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}={}){_t(t)&&(t=0),_t(e)&&(e=this.rows()),_t(r)&&(r=0),_t(n)&&(n=this.columns());const i=this._matrixArray.splice(t,e),a=[];for(const l of i)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(_t(t)||_t(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=Sf(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){_t(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const i=n._value.splice(t,1);e.push(i[0])}const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return _t(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new Gf(new Hf(this._matrixArray)),e=new Qt(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 i=0;i<e;i++)if(n!==i&&r[n][i]!==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 i=0;i<e;i++)if(n!==i&&r[n][i]!==0||n===i&&r[n][i]!==1)return!1;return!0}eigenvectors(){const t=new Gf(new Hf(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 i=n+1;i<e;i++)if(r[n][i]!==r[i][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(_t(t)||_t(e)))for(const r of this._matrixInstance){const n=r._value[t],i=r._value[e];r.set({index:t,value:i}),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 i1(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 i=0;i<t;i++)if(n+i!==t-1&&r[n][i]!==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 i=0;i<t;i++)if(n!==i&&r[n][i]!==-r[i][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 qa(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new Qt(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,i=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&i[l][a]===0;)l++;if(l===r)continue;if(l!==a){const h=i[l];i[l]=i[a],i[a]=h}const c=i[a][a];for(let h=0;h<n;h++)i[a][h]/=c;for(let h=a+1;h<r;h++){const p=i[h][a];i[h]=i[h].map((f,d)=>f-p*i[a][d]),i[h][a]=0}}for(let a=0;a<r;a++)i[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class Dy{constructor(t){$(this,"_variables");$(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const r=Qr(t),n=Qr(this._variables.timeframe.period);if(r<n)return!0;const i=`change_${e}`,a=this._cacheData[i],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else{const c=this._calcTimeOffset(l,t);return this._cacheData[i]={currentTime:l,offset:c},!1}return!1}in_seconds({timeframe:t}={}){return Qr(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=ee.duration(e);if(r.years())return"12M";const i=r.asMonths();if(Hs(i))return`${i}M`;const a=r.asWeeks();if(Hs(a))return`${a}M`;const l=r.asDays();if(l>=1)return`${Math.ceil(l)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const h=r.asSeconds();return h<=1?"1S":h<=5?"5S":h<=10?"10S":h<=15?"15S":h<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const l=ee(t).day();e="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(e.includes("M")){const l=ee(t).date();e="1D";const c=ee(t).daysInMonth();l!==1&&(r=(c-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),i=Qr(e)*1e3,a=t-n-Math.floor((t-n)/i)*i;return r?r-a:a}}class by{constructor(t,e){$(this,"_errorListener");$(this,"_intlNumberFormatter");$(this,"_precision");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}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 Qt;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(_t(e)){this._errorListener.addError(le.arrLenErr,n,zt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){_t(n)&&(n=0);let i=-1;for(let a=0;a<n+1&&(i=t.indexOf(e,i+1),i!==-1);a++);return i!==-1?t.substring(0,i)+r+t.substring(i+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))}_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 _t(e)&&(e=0),_t(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 _t(t)&&(t=0),qr(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 Kt.mintick:return t.toFixed(this._precision);case Kt.percent:return`${t}%`;case Kt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var l;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[i,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),h=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;h&&(i=i.replace(new RegExp(`\\B(?=(\\d{${h}})+(?!\\d))`,"g"),",")),r=c.join("")}i=r.replace(/#/,i).replace(/#/g,"")}else i=`${r}${i}`;if(n&&n.includes("#")){const c=n.split("#").length-1;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}_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(t,e){let r=t;for(const[n,i]of e.entries()){if(i===void 0||typeof i=="number"&&isNaN(i)){r="NaN";continue}if(typeof i=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(i,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(i))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),i)}return r}}class xy{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new ka(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 ka{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new ka(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 Qt(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 Qt(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 Ey{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Ai(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Ai(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Ai(t,e)}from_time({price:t,time:e}){return new Ai(t,void 0,e)}}class Ai{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ai(this._price,this._index,this._time)}}class Ay{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:we.bar_index,yloc:Wr.price,size:rr.normal,style:ge.styleLabelDown,textalign:Wt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:i,bar_index:a}=this._variables,l=`label_${e}_${a}`;me(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:l,time:r,high:n,low:i,bar_index:a};t.point&&(c.x=c.xloc===we.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Wr.abovebar?c.y=n:c.yloc===Wr.belowbar&&(c.y=i),this._verfiyArgs(t,e);const h=new ao(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,h),h}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:i,size:a,textalign:l,text_font_family:c}=t,h="label.new";this._paramVerfiy(i,e,h,Object.values(ge),"style"),this._paramVerfiy(r,e,h,Object.values(we),"xloc"),this._paramVerfiy(n,e,h,Object.values(Wr),"yloc"),this._paramVerfiy(a,e,h,Object.values(rr),"size"),this._paramVerfiy(l,e,h,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,h,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 ao{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get type(){return Fe.LABEL}get id(){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),i=new ao(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,i)}return i}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)}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(rr),"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(we),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:i}=this._variables;r&&(r.yloc=t,t===Wr.abovebar?r.y=n:t===Wr.belowbar&&(r.y=i),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Wr),"yloc"))}set_color(t,e){const r=this._getLabel(e);me(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===we.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(ge),"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",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);me(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(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const Cy={freq_all:kr.freqAll,freq_once_per_bar:kr.freqOncePerBar,freq_once_per_bar_close:kr.freqOncePerBarClose},Fy={gaps_off:Vi.gapsOff,gaps_on:Vi.gapsOn,lookahead_off:Vi.lookaheadOff,lookahead_on:Vi.lookaheadOn},Ci={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"},Jf={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"},My={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Xf={all:[Ve.dataWindow,Ve.pane,Ve.priceScale,Ve.statusLine],data_window:[Ve.dataWindow],none:[],pane:[Ve.pane],price_scale:[Ve.priceScale],status_line:[Ve.statusLine]},Ny={both:Ur.both,left:Ur.left,none:Ur.none,right:Ur.right},Sy={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},By={style_solid:Ds.styleSolid,style_dashed:Ds.styleDashed,style_dotted:Ds.styleDotted},Oy={style_arrowdown:ge.styleArrowdown,style_arrowup:ge.styleArrowup,style_circle:ge.styleCircle,style_cross:ge.styleCross,style_diamond:ge.styleDiamond,style_flag:ge.styleFlag,style_label_center:ge.styleLabelCenter,style_label_down:ge.styleLabelDown,style_label_left:ge.styleLabelLeft,style_label_lower_left:ge.styleLabelLowerLeft,style_label_lower_right:ge.styleLabelLowerRight,style_label_right:ge.styleLabelRight,style_label_up:ge.styleLabelUp,style_label_upper_left:ge.styleLabelUpperLeft,style_label_upper_right:ge.styleLabelUpperRight,style_none:ge.styleNone,style_square:ge.styleSquare,style_text_outline:ge.styleTextOutline,style_triangledown:ge.styleTriangledown,style_triangleup:ge.styleTriangleup,style_xcross:ge.styleXcross},Iy={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},Ty={abovebar:an.abovebar,absolute:an.absolute,belowbar:an.belowbar,bottom:an.bottom,top:an.top},$y={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Ly={style_area:Mr.styleArea,style_areabr:Mr.styleAreabr,style_circles:Mr.styleCircles,style_columns:Mr.styleColumns,style_cross:Mr.styleCross,style_histogram:Mr.styleHistogram,style_line:Mr.styleLine,style_linebr:Mr.styleLinebr,style_stepline:Mr.styleStepline,style_stepline_diamond:Mr.styleSteplineDiamond,style_steplinebr:Mr.styleSteplinebr},Ry={bottom_center:_r.bottomCenter,bottom_left:_r.bottomLeft,bottom_right:_r.bottomRight,middle_center:_r.middleCenter,middle_left:_r.middleLeft,middle_right:_r.middleRight,top_center:_r.topCenter,top_left:_r.topLeft,top_right:_r.topRight},Py={left:bs.left,none:bs.none,right:bs.right},zy={arrowdown:ur.arrowdown,arrowup:ur.arrowup,circle:ur.circle,cross:ur.cross,diamond:ur.diamond,flag:ur.flag,labeldown:ur.labeldown,labelup:ur.labelup,square:ur.square,triangledown:ur.triangledown,triangleup:ur.triangleup,xcross:ur.xcross},qy={auto:rr.auto,huge:rr.huge,large:rr.large,normal:rr.normal,small:rr.small,tiny:rr.tiny},ky={cash:Ie.cash,fixed:Ie.fixed,percent_of_equity:Ie.percentOfEquity,commission:{cash_per_contract:nr.cashPerContract,cash_per_order:nr.cashPerOrder,percent:nr.percent},direction:{all:ue.all,long:ue.long,short:ue.short},oca:{cancel:un.cancel,none:un.none,reduce:un.reduce}},Uy={align_bottom:Wt.alignBottom,align_center:Wt.alignCenter,align_left:Wt.alignLeft,align_right:Wt.alignRight,align_top:Wt.alignTop,wrap_auto:Wt.wrapAuto,wrap_none:Wt.wrapNone},Wy={bar_index:we.bar_index,bar_time:we.bar_time},jy={abovebar:Wr.abovebar,belowbar:Wr.belowbar,price:Wr.price},Yy={actual:xs.actual,estimate:xs.estimate,standardized:xs.standardized};class Qf{constructor(){$(this,"adjustment",{dividends:ws.dividends,none:ws.none,splits:ws.splits});$(this,"alert",Cy);$(this,"barmerge",Fy);$(this,"color",Ci);$(this,"currency",Jf);$(this,"dayofweek",My);$(this,"earnings",Yy);$(this,"display",Xf);$(this,"extend",Ny);$(this,"font",{family_default:Zn.familyDefault,family_monospace:Zn.familyMonospace});$(this,"format",Sy);$(this,"hline",By);$(this,"label",Oy);$(this,"line",Iy);$(this,"location",Ty);$(this,"math",$y);$(this,"order",{ascending:Vn.ascending,descending:Vn.descending});$(this,"plot",Ly);$(this,"position",Ry);$(this,"scale",Py);$(this,"session",{extended:fi.extended,regular:fi.regular});$(this,"shape",zy);$(this,"size",qy);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",ky);$(this,"text",Uy);$(this,"xloc",Wy);$(this,"yloc",jy)}updateData(){}}class Vy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:we.bar_index,line_color:Ci.blue,line_style:Re.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var l;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,i=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(l=t.points)==null?void 0:l._value.map(c=>({time:c.time,index:c.index,price:c.price}))});me(i,["line_color","fill_color"]);const a=new th(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,i,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,i="polyline.new";this._paramVerfiy(r,e,i,Object.values(Re),"line_style"),this._paramVerfiy(n,e,i,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}delete({id:t}){t&&t.delete()}}class th{constructor(t,e){$(this,"_id");$(this,"_variables");this._variables=e,this._id=t}get type(){return Fe.POLYLINE}get id(){return this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id)}}class Zy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:we.bar_index,extend:Ur.none,style:Re.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:i}=this._variables,a=`line_${n}_${i}`;me(r,["color"]);const l={...this._defaultLine,...r,id:a,bar_index:i};if(t&&e){const h=l.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,p=l.xloc===we.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(l,{x1:h,y1:t==null?void 0:t.price,x2:p,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new uo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,l,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:i}=t,a="line.new";this._paramVerfiy(i,e,a,Object.values(Re),"style"),this._paramVerfiy(r,e,a,Object.values(Ur),"extend"),this._paramVerfiy(n,e,a,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 uo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}get type(){return Fe.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),i=new uo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===we.bar_index){const{x1:n,y1:i,x2:a,y2:l}=r;return n===void 0||a===void 0||i===void 0||l===void 0?void 0:(l-i)/(a-n)*(t-n)+i}}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 i=this._getLine(n);i&&(i.xloc=t,i.x1=e,i.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(we),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(me(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(Ur),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class Ky{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:i}=this._variables,a=`linefill_${e}_${i}`,l=r==null?void 0:r.data,c=n==null?void 0:n.data;l&&(l.linefills=l.linefills||[],l.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),me(t,["color"]);const h=new lo(this._variables,a,r,n);return e.startsWith("export")||(l||c)&&this._variables.linefill.add(a,{line1:l,line2:c,color:t.color,id:a,bar_index:i},h),h}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 lo{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return Fe.LINEFILL}get id(){return this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new lo(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:i}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),i&&(i.linefills=(r=i.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(me(t,["color"]),e.color=t.color)}}class Gy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Ci.blue,border_width:1,bgcolor:Ci.blue,xloc:we.bar_index,extend:Ur.none,style:Re.styleSolid,text:"",text_size:rr.auto,text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_wrap:Wt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:i}=this._variables,a=`box_${n}_${i}`,l={...this._defaultBox,...r,id:a,bar_index:i};if(me(l,["border_color","bgcolor","text_color"]),t){const{price:h,time:p,index:f}=t;l.top=h,l.left=l.xloc===we.bar_index?f:p}if(e){const{price:h,time:p,index:f}=e;l.bottom=h,l.right=l.xloc===we.bar_index?f:p}this._verfiyArgs(r,n);const c=new co(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,l,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:l,text_valign:c,text_wrap:h,text_font_family:p}=t,f="box.new";this._paramVerfiy(r,e,f,[Re.styleDashed,Re.styleDotted,Re.styleSolid],"border_style"),this._paramVerfiy(n,e,f,Object.values(Ur),"extend"),this._paramVerfiy(i,e,f,Object.values(we),"xloc"),this._paramVerfiy(a,e,f,Object.values(rr),"text_size"),this._paramVerfiy(l,e,f,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"),this._paramVerfiy(c,e,f,[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"),this._paramVerfiy(h,e,f,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(p,e,f,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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_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 co{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.BOX}get id(){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(),i=new co(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.box.delete(this._id)}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(Ur),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,me(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(rr),"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",[Wt.wrapAuto,Wt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,me(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",[Wt.alignLeft,Wt.alignCenter,Wt.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",[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.top=n,e.left=e.xloc===we.bar_index?r:i}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,me(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:i}=t||{};e.bottom=n,e.right=e.xloc===we.bar_index?r:i}}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(Zn),"text_font_family"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Hy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:_r.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}`,{columns:i,rows:a}=t;me(t,["text_color","bgcolor","border_color"]);const l=Array.from(Array(a),()=>Array.from(Array(i),()=>{})),c={...this._defaultTable,...t,cell:l,id:n,bar_index:r},h=new eh(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(_r),"position"),e.startsWith("export")||this._variables.table.add(n,c,h),h}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 eh{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:rr.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.TABLE}get id(){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,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],l=a[n]||[];l[r]=e,a[n]=l,i.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,me(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 i=this._variables.table.get(this._id);if(i){const a=i.cell;if(a)for(let l=e;l<=n;l++)for(let c=t;c<=r;c++){const h=a[l];h&&(h[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},i){if(t>r||e>n){this._errorListener.addError(le.mergeCellErr,i,zt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,me(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(_r),"position"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 Jy{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 this._strategy.historyOrders[t].in_time}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===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class Xy{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 this._strategy.orders[t].in_time}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===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class Qy{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(ue),"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",[Ie.percentOfEquity,Ie.cash],"type"),e===Ie.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",[Ie.percentOfEquity,Ie.cash],"type"),e===Ie.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,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}}let tw=class{constructor(t,e,r,n,i){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:0,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Ie.fixed,default_qty_value:1,initial_capital:1e6,currency:Jf.NONE,slippage:0,commission_type:nr.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._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 Xy(this),this._closedtrades=new Jy(this),this._riskNamespace=new Qy(this,n),this._id=`strategy_${i}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=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}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),!this._options.process_orders_on_close&&this._calcLiquidate()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._calcProfitAndLoss(),this._variables.strategy.update(),this._maxDrawdownVerify(),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{high:n,low:i,time_tradingday:a,time:l,strategy:{netprofit:c,initial_capital:h}}=this._variables;let{preNetprofit:p=0}=this._risk;l===a&&(p=c,this._risk.preNetprofit=c,this._risk.isTemporaryBan=!1);let f=p-c;f+=this._orders.reduce((y,m)=>{const{in_price:w,direction:v,qty:x=0,commission:b=0,original_qty:N=0}=m,E=v===ue.long?1:-1,C=(n-w)*x,M=(i-w)*x,S=E===1?M:-C;return y+S+x/N*b},0);let d=!1;switch(e){case Ie.cash:d=t<f;break;case Ie.percentOfEquity:const y=f/(h+c)*100;d=t<y;break}if(d){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===ue.long?i:n,"Close Position (Max intraday Loss)"),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:i,open:a}=this._variables;n===i&&(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)"),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:i,time_tradingday:a,strategy:l,open:c}=this._variables;let h=e;if(i===a){const p=l.netprofit+l.openprofit;p<n?h=0:h++,Object.assign(this._risk,{lossDays:h,totalProfit:p})}t<=h&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){var n;const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(!r&&t!==void 0&&e){const{max_drawdown:i,max_drawdown_percent:a}=this._variables.strategy;let l=!1;switch(e){case Ie.percentOfEquity:l=a<i;break;case Ie.cash:l=t<i;break}if(l){const{high:c,low:h}=this._variables,p=(n=this._orders[0])==null?void 0:n.direction;this._riskTouchOff(p===ue.long?c:h,"Close Position (Max Drawdown)")}}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._closeOrders(this._orders,t,e),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Kt.inherit,Kt.price,Kt.percent,Kt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Ie),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(nr),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={};if(r)for(const i of Object.keys(r)){const a=r[i];a!==t[i]&&(n[i]=a)}self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,this._updateOptions,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(un),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(un),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close"}):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=Ie.fixed,default_qty_value:r=1,initial_capital:n}=this._options;switch(e){case Ie.fixed:return r;case Ie.cash:return r/t;case Ie.percentOfEquity:const i=this._getOrderProfit(t);return(n+i+this._totalChangeCapital)*r/100/t}}_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._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:i}=e,a=i===ue.long?1:-1,l=(t-r)*a*n,[c,h]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,l,c,h)}}_calcProfitAndLossHandle(t,e,r){const{high:n,low:i}=this._variables,a=(n-t)*e,l=(i-t)*e;let c=r===1?a:-l,h=r===1?l:-a;return[c,h]}_calcOrderPercent(t,e,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:l=0,qty:c=0,in_price:h,max_profit:p=0,trading_loss:f=0}=t;let{commission:d=0}=t,g=h*c;if(i){const y=this._getCommission(a,c);d=d*c/l,r-=d,n-=d,g+=d,e=e-y-d}r=Math.max(r,p,0),n=Math.min(n,f,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{high:t,low:e,time:r}=this._variables,{initial_capital:n,margin_long:i=0,margin_short:a=0}=this._options,l=this._orders[0].direction===ue.long?1:-1;let c=l===1?e:t;if(l===1&&i===100)return;const h=(l===1?i:a)/100;if(h<=0)return;let p=!1;const[f,d]=this._orders.reduce((w,v)=>{let[x,b]=w;const{in_price:N,qty:E=0,in_time:C}=v;C===r&&(p=!0);const M=N*E,S=c*E;return x+=M,b+=S,[x,b]},[0,0]);let g=0,y=0;const m=n+this._totalChangeCapital;if(p&&(g=m-f*h,g<0&&(c=this._orders[0].in_price,y=Math.abs(Math.trunc(g/h/c)*4),y=Math.max(y,1))),g>=0){const w=l*(d-f);if(g=m+w-d*h,g>=0)return;y=Math.abs(Math.trunc(g/h/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 i of this.orders)this._processOrder(i,t,e,r,r,!0);this._orders=this._orders.filter(i=>!i.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:i,quantities:a,close:l,price:c,activePrice:h}=this._orderArgsParse(t),p=t.direction===ue.long?1:-1;if(a<=0)return;let f=a;if(i&&e){if(n.length){const m=this._processOrders(n,l,f,t.id,t.comment);if(m<=0)return;f=m}const g=l+p*r*this._mintick;if(!this._judgeCapitalEnough(f,g,p))return;this._ocaGroupVerify(f,t.oca_name,t.oca_type),this._calcCurrentOrder({...t,in_price:g,in_index:this._variables.bar_index,in_time:this._variables.time,qty:f,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,p)&&this._addPendingOrders(t,c,f,i,h)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(p=>(p.direction===ue.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:i=0,margin_short:a=0}=this._options;if(i===0&&r===1||a===0&&r===-1)return!0;const l=this._getOrderProfit(e),h=this._getCapital(r,this._options.initial_capital+l+this._totalChangeCapital)-n;return t*e<=h}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:i=0,direction:a}=r,l=a===ue.long?1:-1;return e+(t-n)*i*l},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===un.none)return!1;let n=!1;switch(r){case un.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===e)i.isCancel=!0,n=!0;else return!0});break;case un.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:l}=i;if(e===l){const c=a-t;return n=!0,c<=0?(i.isCancel=!0,!1):(i.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,i,a=!1){let l=r;for(const c of t)if(l=this._processOrder(c,e,l,n,i,a),l<=0)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_addPendingOrders(t,e,r,n,i){const a=this._pendingOrders.find(l=>l.id===t.id&&!l.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let i=t.limit||0;const{close:a}=this._variables;let l=a,c=!1,h;const p=e===ue.long?1:-1,f=n&&(n-a)*p>0,{backtest_fill_limits_assumption:d=0}=this._options;d>0&&i&&(i-=d*this._mintick*p);const g=i&&(i-a)*p<0;f&&g?(h=n,l=i):f?l=n:g?l=i:c=!0;const y=r||this._calcDefaultQty(l)||1;return{orders:this._orders.filter(w=>w.direction!==e),isMarketPrice:c,activePrice:h,quantities:y,close:a,price:l}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:l,activePrice:c}=this._orderArgsParse(t);if(i<=0)return;if(r.length&&n&&e){this._entryOrder(r,a,i,t);return}this._judgeCapitalEnough(i,a,t.direction===ue.long?1:-1)&&this._addPendingEntry(t,l,i,n,c)}_entryOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{oca_name:c,oca_type:h,direction:p,comment:f,isMarketPrice:d,id:g}=n,y=p===ue.long?1:-1;if(r=this._getAvailablePositionSize(r,p),r<=0||(e=e+l*this._mintick*y,!this._judgeCapitalEnough(r,e,y)))return;this._closeOrders(t,e,g,f);const w={...n,in_price:e,qty:r,in_index:a,in_time:i,place_order_type:"entry"};if(d){this._calcCurrentOrder(w);return}const{pendingOrders:v,orders:x}=this._getEntryOrders(p),b=v.length+x.length;b&&b>=(this._options.pyramiding||0)||(this._ocaGroupVerify(r,c,h),this._calcCurrentOrder(w))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==ue.all&&n!==e)return 0;if(r===void 0)return t;const i=this._orders.reduce((a,l)=>a+(l.qty||0),0);return i?i+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,i){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),c=a.length+l.length,h=a.find(p=>p.id===t.id&&p.place_order_type==="entry");if(h)Object.assign(h,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else if(!c||c<(this._options.pyramiding||1)){const p={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(p)}}_closeAllOrders(t,e){const{comment:r}=t,{bar_index:n}=this._variables,i=this._orders.filter(a=>a.in_index!==n);i.length&&(this._closeOrders(i,e,"Close position order",r),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n){for(const i of t)this._closeOrder(i,e,r,n);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{in_price:c,qty:h=0,direction:p}=t,f=p===ue.long?1:-1;e=e-f*l*this._mintick,t.isDeal=!0;const d=(e-c)*f*h,g={...t,out_price:e,out_id:r,out_index:a,out_time:i,out_comment:n,out_qty:h,profit:d};this._calcPercent(g)}_ordersHandle(){const t=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!t.length)return;const{open:e,low:r,high:n,close:i}=this._variables;for(const a of t){const{stop:l,limit:c,trail_stop_price:h,isMarketPriceLimit:p,isMarketPriceStop:f,direction:d,id:g,out_comment:y,active_price:m,trail_offset:w=0,out_qty:v,comment_loss:x,comment_profit:b,comment_trailing:N}=a;let E=h;const C=d===ue.long?1:-1;let M,S=y;if(p||f?M=e:(c&&r<=c&&n>=c&&(S=b||y,M=c),l&&r<=l&&n>=l&&(M=E?(l-E)*C>0?l:E:l,S=(E===M?N:x)||y)),M)this._processExitOnClose(a,M,{from_entry:g,comment:S,qty:v});else{let T=!1;if(m&&m<=n&&m>=r&&(E=m-w*C*this._mintick,(E-i)*C>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(M=E)),T=!0,a.trail_stop_price=E),E)if((E-e)*C>=0&&!T)M=E;else{const F=(C===1?n:r)-w*C*this._mintick;C===1?E<e&&E>=r&&F>E&&F<i?M=E:F>E?(E=F,F>=i&&(M=F)):E<=n&&r<=E&&(M=E):E>e&&E<=n&&F<E&&F>i?M=E:F<E?(E=F,F<=i&&(M=F)):E<=n&&r<=E&&(M=E),a.trail_stop_price=E}M&&this._processExitOnClose(a,M,{from_entry:g,comment:N||y,qty:v})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of r)switch(n.place_order_type){case"close":this._closeOrderHandle(n);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&t.push(l)}for(const n of e){const i=this._exitOrderHandle(n);i&&t.push(i)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),e=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this._variables;for(const n of e)switch(n.place_order_type){case"close":this._closeOrderHandle(n,!0);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of t){const{from_entry:i}=n,a=this._orders.filter(l=>!i||l.id===i&&(l.isMarketPriceLimit||l.isMarketPriceStop));for(const l of a)this._processExitOnClose(l,l.limit||l.stop||l.trail_stop_price||r,n)}this._pendingCloseOrders=[]}_entryOrderHandle(t){const{open:e,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:l,direction:c,active_price:h}=t;if(h&&n>=h&&r<=h)return delete t.active_price,t;let p=l;if(i&&(p=e),p<=n&&p>=r){const f=this._orders.filter(d=>d.direction!==c);this._entryOrder(f,p,a,t)}else return t}_orderOrderHandle(t){const{open:e,low:r,high:n,time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:h=0,in_price:p,direction:f,comment:d,oca_name:g,oca_type:y,active_price:m,id:w}=t;if(m&&n>=m&&r<=m)return delete t.active_price,t;let v=p,x=h;if(c&&(v=e),v<=n&&v>=r){const b=this._orders.filter(E=>E.direction!==f);if(b.length&&(x=this._processOrders(b,v,h,w,d),x<=0))return;const N=f===ue.long?1:-1;this._ocaGroupVerify(x,g,y),this._calcCurrentOrder({...t,in_price:v+N*l*this._mintick,in_index:a,in_time:i,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:i=100,comment:a}=t,{bar_index:l}=this._variables,c=this._orders.filter(g=>g.id===r&&g.in_index!==l&&(!g.close_qty||g.close_qty<(g.qty||0)));if(!c.length)return;let h=0;if(n?h=n:(h=c.reduce((g,y)=>g+(y.qty||0),h),h=i/100*h),h<=0)return;const{open:p,close:f}=this._variables;let d=h;for(const g of c){const{qty:y=0}=g;d<y?g.close_qty=d:(g.close_qty=y,d-=y)}this._processOrders(this._options.close_entries_rule==="ANY"?c:this._orders,e?f:p,h,`Close entry(s) order ${r}`,a)}_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)))return t}_exit(t,e){const{profit:r,loss:n,stop:i,limit:a,trail_offset:l,trail_price:c,trail_points:h,from_entry:p="",id:f}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(h)&&this._isNaN(c))){this._errorListener.addError(le.strategyExitErr,e,zt.Error);return}const d={...t,place_order_type:"exit"},g=this._orders.filter(w=>(!p||p===w.id)&&!w.hasExit),y=this._pendingOrders.filter(w=>!p||p===w.id);if(g.length){if(!this._ordersToExit(g,d))return}else if(!y.length)return;const m=this._pendingOrders.find(w=>w.id===f);m?Object.assign(m,{...t}):this._pendingOrders.push(d)}_ordersToExit(t,e){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:l,comment_profit:c,comment_trailing:h}=e;let p=r,f=!1;e.comment=a||i;for(const d of t){const{qty:g=0}=d,y=d.direction===ue.long?1:-1;p=r?r>=g?g:r:n/100*g,d.out_qty=p,p<g&&(f=!0),Object.assign(d,{out_comment:a||i,comment_loss:l,comment_profit:c,comment_trailing:h}),!(this._stopProfit(d,y,{...e,qty:p})||this._stopLoss(d,y,{...e,qty:p})||this._trailStopLoss(d,y,{...e,qty:p}))&&(d.place_order_type="exit")}return f}_addExitPendingCloseOrders(t){t.place_order_type="exit";const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r){const{limit:n,profit:i,comment_profit:a,comment:l}=r;let c=n;const{close:h}=this._variables,{in_price:p}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=p+e*i*this._mintick),t.limit=c,c&&(c-h)*e<=0&&(t.isMarketPriceLimit=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=h,f))return this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r){const{stop:n,loss:i,comment_loss:a,comment:l}=r;let c=n;const{close:h}=this._variables,{in_price:p}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=p-e*i*this._mintick),t.stop=c,c&&(c-h)*e>=0&&(t.isMarketPriceStop=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=h,f))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:l,comment:c}=r;if(!this._isNaN(n)){const{close:h}=this._variables,{in_price:p}=t,{process_orders_on_close:f}=this._options;let d;if(this._isNaN(i)?this._isNaN(a)||(d=p+a*e*this._mintick):d=i,t.trail_offset=n,d&&(d-h)*e<=0){const g=h-n*e*this._mintick;if((g-h)*e>=0&&(t.trail_stop_price=h,t.isMarketPriceStop=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment}),f))return this._addExitPendingCloseOrders(r),!0;t.trail_stop_price=g}t.active_price=d}}_processExitOnClose(t,e,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const c=this._processExitOrders(this._orders,e,n,a,i);c&&!c.hasExit?(c.hasExit=!0,Object.assign(t,{trail_stop_price:c.trail_stop_price,stop:c.stop,limit:c.limit,trail_offset:c.trail_offset,active_price:c.active_price})):c&&(t.hasExit=!0)}else t.hasExit=!0,this._processOrders([t],e,n,a,i)}_processExitOrders(t,e,r,n,i){let a=r,l;for(const c of t)if(l=c,a=this._processOrder(c,e,a,n,i),a<=0||!c.hasExit)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_processOrder(t,e,r,n,i,a=!1){const{time:l,bar_index:c}=this._variables,{slippage:h=0}=this._options,{in_price:p,qty:f=0,max_profit:d,trading_loss:g,direction:y,commission:m=0,original_qty:w=0}=t,v=y===ue.long?1:-1;if(e=e-v*h*this._mintick,r<f){const x=f-r,b=(e-p)*v*r,N=d!==void 0?d/f*r:void 0,E=g!==void 0?g/f*r:void 0;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_time:l,out_comment:i,profit:b,out_qty:r,max_profit:N,trading_loss:E});const C=(e-p)*v*x-m*x/w;Object.assign(t,{qty:x,profit:C,max_profit:d!==void 0?d-(N||0):void 0,trading_loss:g!==void 0?g-(E||0):void 0,total_profit:this._totalChangeCapital+C}),r=0}else{t.isDeal=!0;const x=(e-p)*v*f;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_time:l,out_comment:i,out_qty:f,profit:x}),r-=f}return a&&(v===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t){const{commission_value:e}=this._options,{in_price:r,out_qty:n=0,out_price:i=0,original_qty:a=0,direction:l}=t;let{profit:c=0,max_profit:h,trading_loss:p,commission:f=0}=t,d=r*n;if(this._totalChangeCapital+=c,e){const g=this._getCommission(i,n);this._totalChangeCapital-=g;let y=f*n/a;d+=y,y+=g,c=c-y,Object.assign(t,{commission:y,profit:c})}if(h===void 0||p===void 0){const g=l===ue.long?1:-1,y=this._calcProfitAndLossHandle(r,n,g);if(h=y[0],p=y[1],e){const m=f*n/a;h-=m,p-=m}h=Math.max(0,h),p=Math.min(0,p)}Object.assign(t,{max_profit:h,trading_loss:p,total_profit:this._totalChangeCapital,total_profit_percent:c/this._options.initial_capital*100,profit_percent:c/d*100,max_profit_percent:h/d*100,trading_loss_percent:p/d*100}),this._risk.intradayOrders+=1,this._historyOrder.push(t)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0}=t;let{profit:l=0}=t,c=r*n;if(e){const h=this._getCommission(r,n);this._totalChangeCapital-=h,l=l-h,c+=h,Object.assign(t,{commission:h,profit:l,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:l/this._options.initial_capital*100,profit_percent:l/c*100,max_profit_percent:i/c*100,trading_loss_percent:a/c*100}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder)}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}};var rh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){return function(e,r,n){r.prototype.isBetween=function(i,a,l,c){var h=n(i),p=n(a),f=(c=c||"()")[0]==="(",d=c[1]===")";return(f?this.isAfter(h,l):!this.isBefore(h,l))&&(d?this.isBefore(p,l):!this.isAfter(p,l))||(f?this.isBefore(h,l):!this.isAfter(h,l))&&(d?this.isAfter(p,l):!this.isBefore(p,l))}}})})(rh);var ew=rh.exports,rw=Gt(ew),nh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){return function(e,r,n){var i=r.prototype,a=function(d){var g,y=d.date,m=d.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||i.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=m?n.utc():n();Object.keys(y).forEach(function(T){var F,O;w[F=T,O=i.$utils().p(F),O==="date"?"day":O]=y[T]});var x=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),N=w.month>=0?w.month:w.year||w.day?0:v.month(),E=w.hour||0,C=w.minute||0,M=w.second||0,S=w.millisecond||0;return m?new Date(Date.UTC(b,N,x,E,C,M,S)):new Date(b,N,x,E,C,M,S)}return y},l=i.parse;i.parse=function(d){d.date=a.bind(this)(d),l.bind(this)(d)};var c=i.set,h=i.add,p=i.subtract,f=function(d,g,y,m){m===void 0&&(m=1);var w=Object.keys(g),v=this;return w.forEach(function(x){v=d.bind(v)(g[x]*m,x)}),v};i.set=function(d,g){return g=g===void 0?d:g,d.constructor.name==="Object"?f.bind(this)(function(y,m){return c.bind(this)(m,y)},g,d):c.bind(this)(d,g)},i.add=function(d,g){return d.constructor.name==="Object"?f.bind(this)(h,d,g):h.bind(this)(d,g)},i.subtract=function(d,g){return d.constructor.name==="Object"?f.bind(this)(h,d,g,-1):p.bind(this)(d,g)}}})})(nh);var nw=nh.exports,iw=Gt(nw),ih={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e,r,n=1e3,i=6e4,a=36e5,l=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,h=31536e6,p=2628e6,f=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,d={years:h,months:p,days:l,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},g=function(C){return C instanceof N},y=function(C,M,S){return new N(C,S,M.$l)},m=function(C){return r.p(C)+"s"},w=function(C){return C<0},v=function(C){return w(C)?Math.ceil(C):Math.floor(C)},x=function(C){return Math.abs(C)},b=function(C,M){return C?w(C)?{negative:!0,format:""+x(C)+M}:{negative:!1,format:""+C+M}:{negative:!1,format:""}},N=function(){function C(S,T,F){var O=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),T)return y(S*d[m(T)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(k){O.$d[m(k)]=S[k]}),this.calMilliseconds(),this;if(typeof S=="string"){var R=S.match(f);if(R){var U=R.slice(2).map(function(k){return k!=null?Number(k):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var M=C.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(T,F){return T+(S.$d[F]||0)*d[F]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/h),S%=h,this.$d.months=v(S/p),S%=p,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/i),S%=i,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),T=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var O=b(F,"D"),R=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),k=this.$d.seconds||0;this.$d.milliseconds&&(k+=this.$d.milliseconds/1e3,k=Math.round(1e3*k)/1e3);var W=b(k,"S"),z=S.negative||T.negative||O.negative||R.negative||U.negative||W.negative,K=R.format||U.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+T.format+O.format+K+R.format+U.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},M.toJSON=function(){return this.toISOString()},M.format=function(S){var T=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 T.replace(c,function(O,R){return R||String(F[O])})},M.as=function(S){return this.$ms/d[m(S)]},M.get=function(S){var T=this.$ms,F=m(S);return F==="milliseconds"?T%=1e3:T=F==="weeks"?v(T/d[F]):this.$d[F],T||0},M.add=function(S,T,F){var O;return O=T?S*d[m(T)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+O*(F?-1:1),this)},M.subtract=function(S,T){return this.add(S,T,!0)},M.locale=function(S){var T=this.clone();return T.$l=S,T},M.clone=function(){return y(this.$ms,this)},M.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},M.valueOf=function(){return this.asMilliseconds()},M.milliseconds=function(){return this.get("milliseconds")},M.asMilliseconds=function(){return this.as("milliseconds")},M.seconds=function(){return this.get("seconds")},M.asSeconds=function(){return this.as("seconds")},M.minutes=function(){return this.get("minutes")},M.asMinutes=function(){return this.as("minutes")},M.hours=function(){return this.get("hours")},M.asHours=function(){return this.as("hours")},M.days=function(){return this.get("days")},M.asDays=function(){return this.as("days")},M.weeks=function(){return this.get("weeks")},M.asWeeks=function(){return this.as("weeks")},M.months=function(){return this.get("months")},M.asMonths=function(){return this.as("months")},M.years=function(){return this.get("years")},M.asYears=function(){return this.as("years")},C}(),E=function(C,M,S){return C.add(M.years()*S,"y").add(M.months()*S,"M").add(M.days()*S,"d").add(M.hours()*S,"h").add(M.minutes()*S,"m").add(M.seconds()*S,"s").add(M.milliseconds()*S,"ms")};return function(C,M,S){e=S,r=S().$utils(),S.duration=function(O,R){var U=S.locale();return y(O,{$l:U},R)},S.isDuration=g;var T=M.prototype.add,F=M.prototype.subtract;M.prototype.add=function(O,R){return g(O)?E(this,O,1):T.bind(this)(O,R)},M.prototype.subtract=function(O,R){return g(O)?E(this,O,-1):F.bind(this)(O,R)}}})})(ih);var sw=ih.exports,ow=Gt(sw);ee.extend(Sl),ee.extend(rw),ee.extend(iw),ee.extend(ow);class sh{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 i;const n=((i=t.toString().split(".")[1])==null?void 0:i.length)||5;this._variables=e,this._errorListener=new fw,this.array=new Gp(this._errorListener),this.math=new Hp(n,this._errorListener),this.color=new D1,this.str=new by(this._errorListener,n),this.map=new xy(this._errorListener),this.timeframe=new Dy(e),this.matrix=new wy(this._errorListener),this.ta=new y1(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 w1(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 Ey(e)},this.line=new Zy(e,this._errorListener),this.label=new Ay(e,this._errorListener),this.polyline=new Vy(e,this._errorListener),this.box=new Gy(e,this._errorListener),this.table=new Hy(e,this._errorListener),this.linefill=new Ky(e),this.log=new lw(e),this.runtime=new cw(this._errorListener),this.strategy=new tw(this._variables,this._options,t,this._errorListener,r),this.request=new aw(this._variables,r),this.syminfo=new uw}get errors(){return this._errorListener.errors}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 i;if(n.length){i={};for(const v of n)i[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=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 h=this._plots.size>0?[...this._plots.values()]:void 0,p=this._plotbars.size>0?[...this._plotbars.values()]:void 0,f=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,d=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,m=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:h,draws:m,alerts:r,colors:i,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:d,plotcandles:g,plotchars:y,plotbars:p,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 d of r)n[d]=[...this._bgColors[d].values()].map(g=>{const y=[];for(const m of t){const w=g.colors[m];w&&y.push(w)}return g.colors=y,g})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,l=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()]),h=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,p=this._getDrawsFromBarindex(t),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:p,alerts:e,colors:n,hlines:i,fills:a,logs:l,plotshapes:h,isUseBgColor:f})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const i of t){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:i,label:a}=this._variables,l={};return t.data.length&&(l.lines=t.data),e.data.length&&(l.linefills=e.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),i.data.length&&(l.polylines=i.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:i,polyline:a,label:l}=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)),i.data.length&&(c.boxes=i.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),l.data.length&&(c.labels=l.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}updateOptions(t){const{inputs:e,strategy:r}=t;this.input.update(e),this.strategy.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)?(Kp.includes(n)||Zp.includes(n))&&this._errorListener.addError(Ye(le.libraryTitleIsKeywordErr,{name:n}),e,zt.Error):this._errorListener.addError(le.libraryTitleErr,e,zt.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",[Kt.inherit,Kt.percent,Kt.price,Kt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,i="format"){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(Yp.lineWidthWarning,e,zt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];me(t,r);const{series:n,color:i,...a}=t,{bar_index:l,time:c}=this._variables,h=`plot_${e}`,p=this._plots.get(h),f=(p==null?void 0:p.data)||[],d=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,d],itemStyle:{color:i}},this._seriesColorHandle(t,r,p),!p){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Kt.percent,Kt.price,Kt.volume]);const g=i?[i]:void 0;this._plots.set(h,{editable:!0,...a,colors:g,data:f,id:h,zIndex:this._count})}return{type:"plot",key:h}}plotbar(t,e){const r=["color"];me(t,r);const{open:n,close:i,low:a,high:l,color:c,...h}=t,{bar_index:p,time:f}=this._variables,d=`plotbar_${e}`,g=this._plotbars.get(d),y=(g==null?void 0:g.data)||[],m=i!==void 0&&isNaN(i)?void 0:i,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=l!==void 0&&isNaN(l)?void 0:l,b=[f,w,m,v,x];if(y[p]={value:b,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Kt.percent,Kt.price,Kt.volume]);const N=c?[c]:void 0;this._plotbars.set(d,{editable:!0,...h,colors:N,data:y,id:d,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:i,location:a,style:l}=t;this._paramVerfiy(l,r,e,Object.values(ur),"style"),this._paramVerfiy(a,r,e,Object.values(an),"location"),this._paramVerfiy(n,r,e,Object.values(rr),"size"),this._paramVerfiy(i,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:h,time:p,high:f,low:d}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),m=(y==null?void 0:y.data)||[],w={value:[p,n],itemStyle:{color:i,textcolor:a},low:d,high:f};m[h]=w,this._seriesColorHandle(t,r,y),y||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:l,data:m,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];me(t,r);const{series:n,colorup:i,colordown:a,...l}=t,{bar_index:c,time:h}=this._variables,p=`plotarrow_${e}`,f=this._plotarrows.get(p),d=(f==null?void 0:f.data)||[];d[c]={value:[h,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(t,r,f),f||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Kt.percent,Kt.price,Kt.volume]),this._plotarrows.set(p,{editable:!0,...l,data:d,id:p,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:h,time:p,low:f,high:d}=this._variables,g=`plotshape_${e}`,y=this._plotshapes.get(g),m=(y==null?void 0:y.data)||[],w={value:n,color:i,textcolor:a,time:p,low:f,high:d};if(m[h]=w,this._seriesColorHandle(t,r,y),!y){this._count++;const v=i?[i]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:m,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];me(t,r);const{wickcolor:n,bordercolor:i,color:a,close:l,open:c,low:h,high:p,...f}=t,{bar_index:d,time:g}=this._variables,y=`plotcandle_${e}`,m=this._plotcandles.get(y),w=(m==null?void 0:m.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,x=c!==void 0&&isNaN(c)?void 0:c,b=h!==void 0&&isNaN(h)?void 0:h,N=p!==void 0&&isNaN(p)?void 0:p,E=[g,x,v,b,N];w[d]={value:E,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(t,r,m),m||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Kt.percent,Kt.price,Kt.volume]),this._plotcandles.set(y,{editable:!0,...f,data:w,id:y,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;me(t,["color"]),this._verifyDisplay(t.display,"hline",e);const i=t.display&&!t.display.length?Ve.none:Ve.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,T,F,O,R,U,k,W,z,K;const r=["color","top_color","bottom_color"];me(t,r);const{color:n,top_color:i,bottom_color:a,seriesColors:l,hline1:c,hline2:h,plot1:p,plot2:f,top_value:d,bottom_value:g,...y}=t,{bar_index:m,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 N=t.display&&!t.display.length?Ve.none:Ve.all;let E,C,M="plot";if(c&&h)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,C=(T=this._hlines.get(h==null?void 0:h.key))==null?void 0:T.price,M="hline";else{const Z=((F=this._plots.get(p==null?void 0:p.key))==null?void 0:F.data)||[],X=((O=this._plots.get(f==null?void 0:f.key))==null?void 0:O.data)||[];E=(U=(R=Z[m])==null?void 0:R.value)==null?void 0:U[1],C=(W=(k=X[m])==null?void 0:k.value)==null?void 0:W[1]}if(b[m]={time:w,color:n,top_color:i,bottom_color:a,plot1:E,plot2:C,top_value:d,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=i?[i]:void 0,ct=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ct,display:N,data:b,type:M,editable:!0,fillgaps:!1,hline1:c,hline2:h,plot1:p,plot2:f,...y,zIndex:Z?this._count:void 0})}}alert({message:t,freq:e=kr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},h=c.barIndex;if(this._paramVerfiy(e,r,"alert",[kr.freqAll,kr.freqOncePerBar,kr.freqOncePerBarClose]),e===kr.freqOncePerBar&&n===h){this._alerts.delete(l);return}this._cacheData[l]=c;const p={message:t,freq:e,id:l,type:"alert"};if(i){e!==kr.freqOncePerBarClose&&this._alerts.set(l,p),c.barIndex=n;return}if(!i&&e===kr.freqOncePerBarClose&&n===h&&a===n-1){this._alerts.set(l,p),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&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=Xf.all,e,r){t.length&&t.length<4&&this._errorListener.addError(Ye(le.displayErr,{func:e,values:"[display.none, display.all]"}),r,zt.Error)}_setColors(t,e,r){me(t,["color"]);const{color:i,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?Ve.none:Ve.all,{bar_index:c,time:h}=this._variables,p=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const f=this._bgColors[e].get(p),d=(f==null?void 0:f.colors)||[],g=(f==null?void 0:f.setColors)||[];i&&!g.includes(i)&&g.push(i),d[c]={color:i,time:h},f||this._bgColors[e].set(p,{...a,display:l,colors:d,setColors:g,id:p})}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},i){return this._timeHandle(this._variables.time,i,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,t,e,r,n)}timestamp(t){const{dateString:e,timezone:r,year:n,month:i,day:a,hour:l=0,minute:c=0,second:h=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let p=i-1,f=n;if(p<0){const g=Math.ceil(Math.abs(p/12));p=12*g+p,f=n-g}let d=ee({year:f,month:p,day:a,hour:l,minute:c,second:h});return r&&(d=qr(d.utc(!0).valueOf(),r)),d.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return qr(t,e).week()}year({time:t,timezone:e}){return qr(t,e).year()}second({time:t,timezone:e}){return qr(t,e).second()}month({time:t,timezone:e}){return qr(t,e).month()+1}minute({time:t,timezone:e}){return qr(t,e).minute()}hour({time:t,timezone:e}){return qr(t,e).hour()}dayofweek({time:t,timezone:e}){return qr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return qr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Qr(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,i,a=0){const l=r||this._variables.timeframe.period,c=Qr(l),h=Qr(this._variables.timeframe.period);let p;if(c<=h)p=t;else{const f=`time_${e}`,d=this._cacheData[f];if(d)d.currentTime+c*1e3-d.offset<=t?(p=t,this._cacheData[f]={currentTime:t,offset:0}):p=d;else{const g=this._calcTimeOffset(t,l);this._cacheData[f]={currentTime:t,offset:g},p=t}}if(n){const{timePeriods:f,weeks:d}=this._parserSession(n,e),g=ee(t).format("YYYY-MM-DD"),y=p;p=void 0;for(const w of f){const[v,x]=w;if(ee(t).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")){ee(y).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")?p=y:p=ee(`${g} ${v}`).valueOf();break}}const m=this._variables.dayofweek;p&&!d.includes(m)&&(p=void 0)}return i&&(p=p&&qr(p,i).valueOf()),p&&p-a*h*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const i of e){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=t[i];if(!a)continue;const l=r[`${i}s`]||[];l.includes(a)||(l.push(a),r[`${i}s`]=l,l.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const h=parseInt(c,10);if(h<1||h>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,zt.Error);return}return h});return{timePeriods:n.split(",").map(c=>{c===""||c===fi.regular?c="0930-1500":c===fi.extended&&(c="1500-1830");const h=c.split("-");return h.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,zt.Error),[]):[this._processTime(h[0],e),this._processTime(h[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,zt.Error);return}return`${r}:${n}`}}class aw{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,i=this._getRequestData(t,e);if(r!=null&&r.has(e)){const c=r.get(e);return this._runScripts(c,e,!1,n,i)}const a=this._parseExprCode(t),l=this._runScripts(a,e,!0,n,i);return r==null||r.set(e,a),l}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],i=1;e=Il(e);const a=JSON.parse(e),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},h=(l==null?void 0:l.depends)||[];if(!h.length)return`return ${l==null?void 0:l.code}`;let p=[],f=[];const d=[];if(this._getDependCodes(h,a,n,p,f,d),f.length){const m=r.length;let w=[];for(let v=m-1;v>=0;v--){const x=r[v];let b=JSON.parse(Il(x));const N=[];i!==0&&f.length&&(w.unshift("{"),i++),b=b.map(S=>{const{scope:T,code:F,varNames:O,dependSelf:R}=S;return T===2&&!N.includes(O)&&!R&&(S.code=`let ${F}`),O&&N.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],C=[];let M=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(M,b,C,p,f,E),w.unshift(...C,...E),n=w.concat(n),w=[]}}for(n.push(`return ${l==null?void 0:l.code}`);i>1;)n.push("}"),i--;n=p.concat(n),n.push(...d);let g=n.join(`
|
60
|
+
}`}function B1(s,t,e,r,n){const{rows:i,columns:a}=s,l=Math.min(i,t),c=Math.min(a,e),p=[];if(n==="auto"){n=!1;t:for(let h=0;h<l;h++)for(let f=0;f<c;f++)if(s.get(h,f)<0){n=!0;break t}}for(let h=0;h<l;h++){let f=[];for(let d=0;d<c;d++)f.push(O1(s.get(h,d),r,n));p.push(`${f.join(" ")}`)}return c!==a&&(p[p.length-1]+=` ... ${a-e} more columns`),l!==i&&p.push(`... ${i-t} more rows`),p.join(`
|
61
|
+
${Pf}`)}function O1(s,t,e){return(s>=0&&e?` ${qf(s,t-1)}`:qf(s,t)).padEnd(t)}function qf(s,t){let e=s.toString();if(e.length<=t)return e;let r=s.toFixed(t);if(r.length>t&&(r=s.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=s.toExponential(t);return n.length>t&&(n=s.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function I1(s,t){s.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},s.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r.get(n,i));return this},s.add=function(r,n){return new t(r).add(n)},s.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},s.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r.get(n,i));return this},s.sub=function(r,n){return new t(r).sub(n)},s.prototype.subtract=s.prototype.sub,s.prototype.subtractS=s.prototype.subS,s.prototype.subtractM=s.prototype.subM,s.subtract=s.sub,s.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},s.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r.get(n,i));return this},s.mul=function(r,n){return new t(r).mul(n)},s.prototype.multiply=s.prototype.mul,s.prototype.multiplyS=s.prototype.mulS,s.prototype.multiplyM=s.prototype.mulM,s.multiply=s.mul,s.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},s.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r.get(n,i));return this},s.div=function(r,n){return new t(r).div(n)},s.prototype.divide=s.prototype.div,s.prototype.divideS=s.prototype.divS,s.prototype.divideM=s.prototype.divM,s.divide=s.div,s.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},s.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r.get(n,i));return this},s.mod=function(r,n){return new t(r).mod(n)},s.prototype.modulus=s.prototype.mod,s.prototype.modulusS=s.prototype.modS,s.prototype.modulusM=s.prototype.modM,s.modulus=s.mod,s.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},s.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r.get(n,i));return this},s.and=function(r,n){return new t(r).and(n)},s.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},s.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r.get(n,i));return this},s.or=function(r,n){return new t(r).or(n)},s.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},s.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r.get(n,i));return this},s.xor=function(r,n){return new t(r).xor(n)},s.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},s.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r.get(n,i));return this},s.leftShift=function(r,n){return new t(r).leftShift(n)},s.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},s.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r.get(n,i));return this},s.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},s.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},s.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r);return this},s.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 i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r.get(n,i));return this},s.rightShift=function(r,n){return new t(r).rightShift(n)},s.prototype.zeroFillRightShift=s.prototype.rightShift,s.prototype.zeroFillRightShiftS=s.prototype.rightShiftS,s.prototype.zeroFillRightShiftM=s.prototype.rightShiftM,s.zeroFillRightShift=s.rightShift,s.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},s.not=function(r){return new t(r).not()},s.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},s.abs=function(r){return new t(r).abs()},s.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},s.acos=function(r){return new t(r).acos()},s.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},s.acosh=function(r){return new t(r).acosh()},s.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},s.asin=function(r){return new t(r).asin()},s.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},s.asinh=function(r){return new t(r).asinh()},s.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},s.atan=function(r){return new t(r).atan()},s.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},s.atanh=function(r){return new t(r).atanh()},s.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},s.cbrt=function(r){return new t(r).cbrt()},s.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},s.ceil=function(r){return new t(r).ceil()},s.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},s.clz32=function(r){return new t(r).clz32()},s.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},s.cos=function(r){return new t(r).cos()},s.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},s.cosh=function(r){return new t(r).cosh()},s.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},s.exp=function(r){return new t(r).exp()},s.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},s.expm1=function(r){return new t(r).expm1()},s.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},s.floor=function(r){return new t(r).floor()},s.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},s.fround=function(r){return new t(r).fround()},s.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},s.log=function(r){return new t(r).log()},s.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},s.log1p=function(r){return new t(r).log1p()},s.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},s.log10=function(r){return new t(r).log10()},s.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},s.log2=function(r){return new t(r).log2()},s.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},s.round=function(r){return new t(r).round()},s.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},s.sign=function(r){return new t(r).sign()},s.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},s.sin=function(r){return new t(r).sin()},s.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},s.sinh=function(r){return new t(r).sinh()},s.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},s.sqrt=function(r){return new t(r).sqrt()},s.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},s.tan=function(r){return new t(r).tan()},s.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},s.tanh=function(r){return new t(r).tanh()},s.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},s.trunc=function(r){return new t(r).trunc()},s.pow=function(r,n){return new t(r).pow(n)},s.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},s.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r));return this},s.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 i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r.get(n,i)));return this}}function Sr(s,t,e){let r=e?s.rows:s.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Br(s,t,e){let r=e?s.columns:s.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Di(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function bi(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function La(s,t){if(!cr.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]>=s.rows)throw new RangeError("row indices are out of range")}function Ra(s,t){if(!cr.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]>=s.columns)throw new RangeError("column indices are out of range")}function Pa(s,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(eo("startRow",t),eo("endRow",e),eo("startColumn",r),eo("endColumn",n),t>e||r>n||t<0||t>=s.rows||e<0||e>=s.rows||r<0||r>=s.columns||n<0||n>=s.columns)throw new RangeError("Submatrix indices are out of range")}function to(s,t=0){let e=[];for(let r=0;r<s;r++)e.push(t);return e}function eo(s,t){if(typeof t!="number")throw new TypeError(`${s} must be a number`)}function xi(s){if(s.isEmpty())throw new Error("Empty matrix has no elements to index")}function T1(s){let t=to(s.rows);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]+=s.get(e,r);return t}function $1(s){let t=to(s.columns);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]+=s.get(e,r);return t}function L1(s){let t=0;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t+=s.get(e,r);return t}function R1(s){let t=to(s.rows,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]*=s.get(e,r);return t}function P1(s){let t=to(s.columns,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]*=s.get(e,r);return t}function z1(s){let t=1;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t*=s.get(e,r);return t}function q1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<r;a++){let l=0,c=0,p=0;for(let h=0;h<n;h++)p=s.get(a,h)-e[a],l+=p,c+=p*p;t?i.push((c-l*l/n)/(n-1)):i.push((c-l*l/n)/n)}return i}function k1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<n;a++){let l=0,c=0,p=0;for(let h=0;h<r;h++)p=s.get(h,a)-e[a],l+=p,c+=p*p;t?i.push((c-l*l/r)/(r-1)):i.push((c-l*l/r)/r)}return i}function U1(s,t,e){const r=s.rows,n=s.columns,i=r*n;let a=0,l=0,c=0;for(let p=0;p<r;p++)for(let h=0;h<n;h++)c=s.get(p,h)-e,a+=c,l+=c*c;return t?(l-a*a/i)/(i-1):(l-a*a/i)/i}function W1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[e])}function j1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[r])}function Y1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t)}function V1(s){const t=[];for(let e=0;e<s.rows;e++){let r=0;for(let n=0;n<s.columns;n++)r+=Math.pow(s.get(e,n),2)/(s.columns-1);t.push(Math.sqrt(r))}return t}function Z1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[e])}function K1(s){const t=[];for(let e=0;e<s.columns;e++){let r=0;for(let n=0;n<s.rows;n++)r+=Math.pow(s.get(n,e),2)/(s.rows-1);t.push(Math.sqrt(r))}return t}function G1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[r])}function H1(s){const t=s.size-1;let e=0;for(let r=0;r<s.columns;r++)for(let n=0;n<s.rows;n++)e+=Math.pow(s.get(n,r),2)/t;return Math.sqrt(e)}function J1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.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 i=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,r[a*e+l]);return i}static rowVector(t){let e=new pt(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 pt(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 pt(t,e)}static ones(t,e){return new pt(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 i=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,n());return i}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let l=i-n,c=new pt(t,e);for(let p=0;p<t;p++)for(let h=0;h<e;h++){let f=n+Math.round(a()*l);c.set(p,h,f)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),i=this.zeros(t,e);for(let a=0;a<n;a++)i.set(a,a,r);return i}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let i=Math.min(n,e,r),a=this.zeros(e,r);for(let l=0;l<i;l++)a.set(l,l,t[l]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new pt(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.min(t.get(a,l),e.get(a,l)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.max(t.get(a,l),e.get(a,l)));return i}static checkMatrix(t){return $t.isMatrix(t)?t:new pt(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,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!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 i=e;i<t.rows;i++)t.get(i,r)>t.get(n,r)&&(n=i);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let i=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/i);for(let a=e+1;a<t.rows;a++){let l=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)*l)}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 i=0,a=!1;for(;i<r&&a===!1;)t.get(n,i)===1?a=!0:i++;for(let l=0;l<n;l++){let c=t.get(l,i);for(let p=i;p<e;p++){let h=t.get(l,p)-c*t.get(n,p);t.set(l,p,h)}}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 pt(this.rows*e,this.columns*r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*i,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){Sr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return pt.rowVector(this.getRow(t))}setRow(t,e){Sr(this,t),e=Di(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Sr(this,t),Sr(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){Br(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return pt.columnVector(this.getColumn(t))}setColumn(t,e){Br(this,t),e=bi(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Br(this,t),Br(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=Di(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=Di(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=Di(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=Di(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=bi(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=bi(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=bi(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=bi(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){Sr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Br(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(){xi(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(){xi(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(Sr(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){Sr(this,t),xi(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(Sr(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){Sr(this,t),xi(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(Br(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){Br(this,t),xi(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(Br(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){Br(this,t),xi(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=pt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,i=new pt(e,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let c=0;c<r;c++)a[c]=t.get(c,l);for(let c=0;c<e;c++){let p=0;for(let h=0;h<r;h++)p+=this.get(c,h)*a[h];i.set(c,l,p)}}return i}strassen2x2(t){t=pt.checkMatrix(t);let e=new pt(2,2);const r=this.get(0,0),n=t.get(0,0),i=this.get(0,1),a=t.get(0,1),l=this.get(1,0),c=t.get(1,0),p=this.get(1,1),h=t.get(1,1),f=(r+p)*(n+h),d=(l+p)*n,g=r*(a-h),y=p*(c-n),m=(r+i)*h,w=(l-r)*(n+a),v=(i-p)*(c+h),x=f+y-m+v,b=g+m,N=d+y,E=f-d+g+w;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,N),e.set(1,1,E),e}strassen3x3(t){t=pt.checkMatrix(t);let e=new pt(3,3);const r=this.get(0,0),n=this.get(0,1),i=this.get(0,2),a=this.get(1,0),l=this.get(1,1),c=this.get(1,2),p=this.get(2,0),h=this.get(2,1),f=this.get(2,2),d=t.get(0,0),g=t.get(0,1),y=t.get(0,2),m=t.get(1,0),w=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),N=t.get(2,2),E=(r+n+i-a-l-h-f)*w,A=(r-a)*(-g+w),M=l*(-d+g+m-w-v-x+N),S=(-r+a+l)*(d-g+w),T=(a+l)*(-d+g),F=r*d,O=(-r+p+h)*(d-y+v),R=(-r+p)*(y-v),U=(p+h)*(-d+y),k=(r+n+i-l-c-p-h)*v,W=h*(-d+y+m-w-v-x+b),z=(-i+h+f)*(w+x-b),K=(i-f)*(w-b),Z=i*x,X=(h+f)*(-x+b),Q=(-i+l+c)*(v+x-N),ct=(i-c)*(v-N),vt=(l+c)*(-x+N),lt=n*m,wt=c*b,bt=a*y,Bt=p*g,xt=f*N,oe=F+Z+lt,It=E+S+T+F+z+Z+X,Nt=F+O+U+k+Z+Q+vt,ce=A+M+S+F+Z+Q+ct,re=A+S+T+F+wt,kt=Z+Q+ct+vt+bt,Jt=F+O+R+W+z+K+Z,Le=z+K+Z+X+Bt,vr=F+O+R+U+xt;return e.set(0,0,oe),e.set(0,1,It),e.set(0,2,Nt),e.set(1,0,ce),e.set(1,1,re),e.set(1,2,kt),e.set(2,0,Jt),e.set(2,1,Le),e.set(2,2,vr),e}mmulStrassen(t){t=pt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,i=t.rows,a=t.columns;n!==i&&console.warn(`Multiplying ${r} x ${n} and ${i} x ${a} matrix: dimensions do not match.`);function l(f,d,g){let y=f.rows,m=f.columns;if(y===d&&m===g)return f;{let w=$t.zeros(d,g);return w=w.setSubMatrix(f,0,0),w}}let c=Math.max(r,i),p=Math.max(n,a);e=l(e,c,p),t=l(t,c,p);function h(f,d,g,y){if(g<=512||y<=512)return f.mmul(d);g%2===1&&y%2===1?(f=l(f,g+1,y+1),d=l(d,g+1,y+1)):g%2===1?(f=l(f,g+1,y),d=l(d,g+1,y)):y%2===1&&(f=l(f,g,y+1),d=l(d,g,y+1));let m=parseInt(f.rows/2,10),w=parseInt(f.columns/2,10),v=f.subMatrix(0,m-1,0,w-1),x=d.subMatrix(0,m-1,0,w-1),b=f.subMatrix(0,m-1,w,f.columns-1),N=d.subMatrix(0,m-1,w,d.columns-1),E=f.subMatrix(m,f.rows-1,0,w-1),A=d.subMatrix(m,d.rows-1,0,w-1),M=f.subMatrix(m,f.rows-1,w,f.columns-1),S=d.subMatrix(m,d.rows-1,w,d.columns-1),T=h($t.add(v,M),$t.add(x,S),m,w),F=h($t.add(E,M),x,m,w),O=h(v,$t.sub(N,S),m,w),R=h(M,$t.sub(A,x),m,w),U=h($t.add(v,b),S,m,w),k=h($t.sub(E,v),$t.add(x,N),m,w),W=h($t.sub(b,M),$t.add(A,S),m,w),z=$t.add(T,R);z.sub(U),z.add(W);let K=$t.add(O,U),Z=$t.add(F,R),X=$t.sub(T,F);X.add(O),X.add(k);let Q=$t.zeros(2*z.rows,2*z.columns);return Q=Q.setSubMatrix(z,0,0),Q=Q.setSubMatrix(K,z.rows,0),Q=Q.setSubMatrix(Z,0,z.columns),Q=Q.setSubMatrix(X,z.rows,z.columns),Q.subMatrix(0,g-1,0,y-1)}return h(e,t,c,p)}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 pt(this.rows,this.columns);for(let i=0;i<this.rows;i++){const a=this.getRow(i);a.length>0&&Rf(a,{min:e,max:r,output:a}),n.setRow(i,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 pt(this.rows,this.columns);for(let i=0;i<this.columns;i++){const a=this.getColumn(i);a.length&&Rf(a,{min:e,max:r,output:a}),n.setColumn(i,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),i=this.get(e,this.columns-1-r);this.set(e,r,i),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),i=this.get(this.rows-1-r,e);this.set(r,e,i),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=pt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,i=t.columns,a=new pt(e*n,r*i);for(let l=0;l<e;l++)for(let c=0;c<r;c++)for(let p=0;p<n;p++)for(let h=0;h<i;h++)a.set(n*l+p,i*c+h,this.get(l,c)*t.get(p,h));return a}kroneckerSum(t){if(t=pt.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(pt.eye(r,r)),i=pt.eye(e,e).kroneckerProduct(t);return n.add(i)}transpose(){let t=new pt(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=kf){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=kf){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Pa(this,t,e,r,n);let i=new pt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let l=r;l<=n;l++)i.set(a-t,l-r,this.get(a,l));return i}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 pt(t.length,r-e+1);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,a-e,this.get(t[i],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 pt(r-e+1,t.length);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(a-e,i,this.get(a,t[i]))}return n}setSubMatrix(t,e,r){if(t=pt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,i=r+t.columns-1;Pa(this,e,n,r,i);for(let a=0;a<t.rows;a++)for(let l=0;l<t.columns;l++)this.set(e+a,r+l,t.get(a,l));return this}selection(t,e){La(this,t),Ra(this,e);let r=new pt(t.length,e.length);for(let n=0;n<t.length;n++){let i=t[n];for(let a=0;a<e.length;a++){let l=e[a];r.set(n,a,this.get(i,l))}}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 pt(this.rows,this.columns))}static copy(t,e){for(const[r,n,i]of t.entries())e.set(r,n,i);return e}sum(t){switch(t){case"row":return T1(this);case"column":return $1(this);case void 0:return L1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return R1(this);case"column":return P1(this);case void 0:return z1(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(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return q1(this,r,n)}case"column":{if(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return k1(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return U1(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(!cr.isAnyArray(r))throw new TypeError("center must be an array");return W1(this,r),this}case"column":{if(!cr.isAnyArray(r))throw new TypeError("center must be an array");return j1(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return Y1(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=V1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return Z1(this,r),this}case"column":{if(r===void 0)r=K1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return G1(this,r),this}case void 0:{if(r===void 0)r=H1(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return J1(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return zf(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")]=S1);function kf(s,t){return s-t}function X1(s){return s.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 pt=(Ni=class extends $t{constructor(e,r){super();Al(this,es);$(this,"data");if(Ni.isMatrix(e))Cl(this,es,Fl).call(this,e.rows,e.columns),Ni.copy(e,this);else if(Number.isInteger(e)&&e>=0)Cl(this,es,Fl).call(this,e,r);else if(cr.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 i=0;i<e;i++){if(n[i].length!==r)throw new RangeError("Inconsistent array dimensions");if(!X1(n[i]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}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 Sr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Sr(this,e,!0),r=Float64Array.from(Di(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Br(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let i=0;i<e;i++)n[i]=this.data[r][i];for(let i=e+1;i<this.columns;i++)n[i-1]=this.data[r][i];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Br(this,e,!0),r=bi(this,r);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)i[a]=this.data[n][a];for(i[a++]=r[n];a<this.columns+1;a++)i[a]=this.data[n][a-1];this.data[n]=i}return this.columns+=1,this}},es=new WeakSet,Fl=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},Ni);I1($t,pt);const go=class go extends $t{constructor(e){super();Al(this,Xe,void 0);if(pt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ua(this,Xe,pt.copy(e,new pt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ua(this,Xe,new pt(e,e));else if(ua(this,Xe,new pt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Jr(this,Xe).size}get rows(){return Jr(this,Xe).rows}get columns(){return Jr(this,Xe).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return pt.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 go(this.diagonalSize);for(const[r,n,i]of this.upperRightEntries())e.set(r,n,i);return e}toMatrix(){return new pt(this)}get(e,r){return Jr(this,Xe).get(e,r)}set(e,r,n){return Jr(this,Xe).set(e,r,n),Jr(this,Xe).set(r,e,n),this}removeCross(e){return Jr(this,Xe).removeRow(e),Jr(this,Xe).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Jr(this,Xe).addRow(e,n),Jr(this,Xe).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,i]of e.entries())i||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,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=e&&(n=++i);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 i=new go(n);for(let a=0,l=0,c=0;c<r;c++)i.set(a,l,e[c]),++a>=n&&(a=++l);return i}*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)}};Xe=new WeakMap;let Xn=go;Xn.prototype.klassType="SymmetricMatrix";class ro extends Xn{static isDistanceMatrix(t){return Xn.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 Xn(this)}clone(){const t=new ro(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,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=t&&(n=++i+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 i=1,a=0,l=0;l<e;l++)n.set(i,a,t[l]),++i>=r&&(i=++a+1);return n}}ro.prototype.klassSubType="DistanceMatrix";class fn extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class Q1 extends fn{constructor(t,e){Br(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 ty extends fn{constructor(t,e){Ra(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 ey extends fn{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 ry extends fn{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 ny extends fn{constructor(t,e){Sr(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 iy extends fn{constructor(t,e){La(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 no extends fn{constructor(t,e,r){La(t,e),Ra(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 sy extends fn{constructor(t,e,r,n,i){Pa(t,e,r,n,i),super(t,r-e+1,i-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 oy extends fn{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 Uf 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 gr 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 ay(s,t){if(cr.isAnyArray(s))return s[0]&&cr.isAnyArray(s[0])?new gr(s):new Uf(s,t);throw new Error("the argument is not an array")}class io{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,i=new Float64Array(r),a=1,l,c,p,h,f,d,g,y,m;for(l=0;l<r;l++)i[l]=l;for(y=new Float64Array(r),c=0;c<n;c++){for(l=0;l<r;l++)y[l]=e.get(l,c);for(l=0;l<r;l++){for(m=Math.min(l,c),f=0,p=0;p<m;p++)f+=e.get(l,p)*y[p];y[l]-=f,e.set(l,c,y[l])}for(h=c,l=c+1;l<r;l++)Math.abs(y[l])>Math.abs(y[h])&&(h=l);if(h!==c){for(p=0;p<n;p++)d=e.get(h,p),e.set(h,p,e.get(c,p)),e.set(c,p,d);g=i[h],i[h]=i[c],i[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(l=c+1;l<r;l++)e.set(l,c,e.get(l,c)/e.get(c,c))}this.LU=e,this.pivotVector=i,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=pt.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,i=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,l,c,p;for(p=0;p<a;p++)for(l=p+1;l<a;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*e.get(l,p));for(p=a-1;p>=0;p--){for(c=0;c<n;c++)i.set(p,c,i.get(p,c)/e.get(p,p));for(l=0;l<p;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*e.get(l,p))}return i}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 pt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i>a?n.set(i,a,t.get(i,a)):i===a?n.set(i,a,1):n.set(i,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i<=a?n.set(i,a,t.get(i,a)):n.set(i,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hn(s,t){let e=0;return Math.abs(s)>Math.abs(t)?(e=t/s,Math.abs(s)*Math.sqrt(1+e*e)):t!==0?(e=s/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class za{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,i=new Float64Array(n),a,l,c,p;for(c=0;c<n;c++){let h=0;for(a=c;a<r;a++)h=hn(h,e.get(a,c));if(h!==0){for(e.get(c,c)<0&&(h=-h),a=c;a<r;a++)e.set(a,c,e.get(a,c)/h);for(e.set(c,c,e.get(c,c)+1),l=c+1;l<n;l++){for(p=0,a=c;a<r;a++)p+=e.get(a,c)*e.get(a,l);for(p=-p/e.get(c,c),a=c;a<r;a++)e.set(a,l,e.get(a,l)+p*e.get(a,c))}}i[c]=-h}this.QR=e,this.Rdiag=i}solve(t){t=pt.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,i=t.clone(),a=e.columns,l,c,p,h;for(p=0;p<a;p++)for(c=0;c<n;c++){for(h=0,l=p;l<r;l++)h+=e.get(l,p)*i.get(l,c);for(h=-h/e.get(p,p),l=p;l<r;l++)i.set(l,c,i.get(l,c)+h*e.get(l,p))}for(p=a-1;p>=0;p--){for(c=0;c<n;c++)i.set(p,c,i.get(p,c)/this.Rdiag[p]);for(l=0;l<p;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*e.get(l,p))}return i.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 pt(e,e),n,i;for(n=0;n<e;n++)for(i=0;i<e;i++)n<i?r.set(n,i,t.get(n,i)):n===i?r.set(n,i,this.Rdiag[n]):r.set(n,i,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new pt(e,r),i,a,l,c;for(l=r-1;l>=0;l--){for(i=0;i<e;i++)n.set(i,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(t.get(l,l)!==0){for(c=0,i=l;i<e;i++)c+=t.get(i,l)*n.get(i,a);for(c=-c/t.get(l,l),i=l;i<e;i++)n.set(i,a,n.get(i,a)+c*t.get(i,l))}}return n}}class Ei{constructor(t,e={}){if(t=gr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=e;let c=!!i,p=!!a,h=!1,f;if(r<n)if(!l)f=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{f=t.transpose(),r=f.rows,n=f.columns,h=!0;let F=c;c=p,p=F}else f=t.clone();let d=Math.min(r,n),g=Math.min(r+1,n),y=new Float64Array(g),m=new pt(r,d),w=new pt(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 N=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),A=Math.max(N,E);for(let F=0;F<A;F++){if(F<N){y[F]=0;for(let O=F;O<r;O++)y[F]=hn(y[F],f.get(O,F));if(y[F]!==0){f.get(F,F)<0&&(y[F]=-y[F]);for(let O=F;O<r;O++)f.set(O,F,f.get(O,F)/y[F]);f.set(F,F,f.get(F,F)+1)}y[F]=-y[F]}for(let O=F+1;O<n;O++){if(F<N&&y[F]!==0){let R=0;for(let U=F;U<r;U++)R+=f.get(U,F)*f.get(U,O);R=-R/f.get(F,F);for(let U=F;U<r;U++)f.set(U,O,f.get(U,O)+R*f.get(U,F))}v[O]=f.get(F,O)}if(c&&F<N)for(let O=F;O<r;O++)m.set(O,F,f.get(O,F));if(F<E){v[F]=0;for(let O=F+1;O<n;O++)v[F]=hn(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 R=F+1;R<n;R++)x[O]+=v[R]*f.get(O,R);for(let O=F+1;O<n;O++){let R=-v[O]/v[F+1];for(let U=F+1;U<r;U++)f.set(U,O,f.get(U,O)+R*x[U])}}if(p)for(let O=F+1;O<n;O++)w.set(O,F,v[O])}}let M=Math.min(n,r+1);if(N<n&&(y[N]=f.get(N,N)),r<M&&(y[M-1]=0),E+1<M&&(v[E]=f.get(E,M-1)),v[M-1]=0,c){for(let F=N;F<d;F++){for(let O=0;O<r;O++)m.set(O,F,0);m.set(F,F,1)}for(let F=N-1;F>=0;F--)if(y[F]!==0){for(let O=F+1;O<d;O++){let R=0;for(let U=F;U<r;U++)R+=m.get(U,F)*m.get(U,O);R=-R/m.get(F,F);for(let U=F;U<r;U++)m.set(U,O,m.get(U,O)+R*m.get(U,F))}for(let O=F;O<r;O++)m.set(O,F,-m.get(O,F));m.set(F,F,1+m.get(F,F));for(let O=0;O<F-1;O++)m.set(O,F,0)}else{for(let O=0;O<r;O++)m.set(O,F,0);m.set(F,F,1)}}if(p)for(let F=n-1;F>=0;F--){if(F<E&&v[F]!==0)for(let O=F+1;O<n;O++){let R=0;for(let U=F+1;U<n;U++)R+=w.get(U,F)*w.get(U,O);R=-R/w.get(F+1,F);for(let U=F+1;U<n;U++)w.set(U,O,w.get(U,O)+R*w.get(U,F))}for(let O=0;O<n;O++)w.set(O,F,0);w.set(F,F,1)}let S=M-1,T=Number.EPSILON;for(;M>0;){let F,O;for(F=M-2;F>=-1&&F!==-1;F--){const R=Number.MIN_VALUE+T*Math.abs(y[F]+Math.abs(y[F+1]));if(Math.abs(v[F])<=R||Number.isNaN(v[F])){v[F]=0;break}}if(F===M-2)O=4;else{let R;for(R=M-1;R>=F&&R!==F;R--){let U=(R!==M?Math.abs(v[R]):0)+(R!==F+1?Math.abs(v[R-1]):0);if(Math.abs(y[R])<=T*U){y[R]=0;break}}R===F?O=3:R===M-1?O=1:(O=2,F=R)}switch(F++,O){case 1:{let R=v[M-2];v[M-2]=0;for(let U=M-2;U>=F;U--){let k=hn(y[U],R),W=y[U]/k,z=R/k;if(y[U]=k,U!==F&&(R=-z*v[U-1],v[U-1]=W*v[U-1]),p)for(let K=0;K<n;K++)k=W*w.get(K,U)+z*w.get(K,M-1),w.set(K,M-1,-z*w.get(K,U)+W*w.get(K,M-1)),w.set(K,U,k)}break}case 2:{let R=v[F-1];v[F-1]=0;for(let U=F;U<M;U++){let k=hn(y[U],R),W=y[U]/k,z=R/k;if(y[U]=k,R=-z*v[U],v[U]=W*v[U],c)for(let K=0;K<r;K++)k=W*m.get(K,U)+z*m.get(K,F-1),m.set(K,F-1,-z*m.get(K,U)+W*m.get(K,F-1)),m.set(K,U,k)}break}case 3:{const R=Math.max(Math.abs(y[M-1]),Math.abs(y[M-2]),Math.abs(v[M-2]),Math.abs(y[F]),Math.abs(v[F])),U=y[M-1]/R,k=y[M-2]/R,W=v[M-2]/R,z=y[F]/R,K=v[F]/R,Z=((k+U)*(k-U)+W*W)/2,X=U*W*(U*W);let Q=0;(Z!==0||X!==0)&&(Z<0?Q=0-Math.sqrt(Z*Z+X):Q=Math.sqrt(Z*Z+X),Q=X/(Z+Q));let ct=(z+U)*(z-U)+Q,vt=z*K;for(let lt=F;lt<M-1;lt++){let wt=hn(ct,vt);wt===0&&(wt=Number.MIN_VALUE);let bt=ct/wt,Bt=vt/wt;if(lt!==F&&(v[lt-1]=wt),ct=bt*y[lt]+Bt*v[lt],v[lt]=bt*v[lt]-Bt*y[lt],vt=Bt*y[lt+1],y[lt+1]=bt*y[lt+1],p)for(let xt=0;xt<n;xt++)wt=bt*w.get(xt,lt)+Bt*w.get(xt,lt+1),w.set(xt,lt+1,-Bt*w.get(xt,lt)+bt*w.get(xt,lt+1)),w.set(xt,lt,wt);if(wt=hn(ct,vt),wt===0&&(wt=Number.MIN_VALUE),bt=ct/wt,Bt=vt/wt,y[lt]=wt,ct=bt*v[lt]+Bt*y[lt+1],y[lt+1]=-Bt*v[lt]+bt*y[lt+1],vt=Bt*v[lt+1],v[lt+1]=bt*v[lt+1],c&<<r-1)for(let xt=0;xt<r;xt++)wt=bt*m.get(xt,lt)+Bt*m.get(xt,lt+1),m.set(xt,lt+1,-Bt*m.get(xt,lt)+bt*m.get(xt,lt+1)),m.set(xt,lt,wt)}v[M-2]=ct;break}case 4:{if(y[F]<=0&&(y[F]=y[F]<0?-y[F]:0,p))for(let R=0;R<=S;R++)w.set(R,F,-w.get(R,F));for(;F<S&&!(y[F]>=y[F+1]);){let R=y[F];if(y[F]=y[F+1],y[F+1]=R,p&&F<n-1)for(let U=0;U<n;U++)R=w.get(U,F+1),w.set(U,F+1,w.get(U,F)),w.set(U,F,R);if(c&&F<r-1)for(let U=0;U<r;U++)R=m.get(U,F+1),m.set(U,F+1,m.get(U,F)),m.set(U,F,R);F++}M--;break}}}if(h){let F=w;w=m,m=F}this.m=r,this.n=n,this.s=y,this.U=m,this.V=w}solve(t){let e=t,r=this.threshold,n=this.s.length,i=pt.zeros(n,n);for(let d=0;d<n;d++)Math.abs(this.s[d])<=r?i.set(d,d,0):i.set(d,d,1/this.s[d]);let a=this.U,l=this.rightSingularVectors,c=l.mmul(i),p=l.rows,h=a.rows,f=pt.zeros(p,h);for(let d=0;d<p;d++)for(let g=0;g<h;g++){let y=0;for(let m=0;m<n;m++)y+=c.get(d,m)*a.get(g,m);f.set(d,g,y)}return f.mmul(e)}solveForDiagonal(t){return this.solve(pt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,i=new pt(r,this.s.length);for(let h=0;h<r;h++)for(let f=0;f<n;f++)Math.abs(this.s[f])>e&&i.set(h,f,t.get(h,f)/this.s[f]);let a=this.U,l=a.rows,c=a.columns,p=new pt(r,l);for(let h=0;h<r;h++)for(let f=0;f<l;f++){let d=0;for(let g=0;g<c;g++)d+=i.get(h,g)*a.get(f,g);p.set(h,f,d)}return p}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,i=r.length;n<i;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 pt.diag(this.s)}}function uy(s,t=!1){return s=gr.checkMatrix(s),t?new Ei(s).inverse():Wf(s,pt.eye(s.rows))}function Wf(s,t,e=!1){return s=gr.checkMatrix(s),t=gr.checkMatrix(t),e?new Ei(s).solve(t):s.isSquare()?new io(s).solve(t):new za(s).solve(t)}function so(s){if(s=pt.checkMatrix(s),s.isSquare()){if(s.columns===0)return 1;let t,e,r,n;if(s.columns===2)return t=s.get(0,0),e=s.get(0,1),r=s.get(1,0),n=s.get(1,1),t*n-e*r;if(s.columns===3){let i,a,l;return i=new no(s,[1,2],[1,2]),a=new no(s,[1,2],[0,2]),l=new no(s,[1,2],[0,1]),t=s.get(0,0),e=s.get(0,1),r=s.get(0,2),t*so(i)-e*so(a)+r*so(l)}else return new io(s).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ly(s,t){let e=[];for(let r=0;r<s;r++)r!==t&&e.push(r);return e}function cy(s,t,e,r=1e-9,n=1e-9){if(s>n)return new Array(t.rows+1).fill(0);{let i=t.addRow(e,[0]);for(let a=0;a<i.rows;a++)Math.abs(i.get(a,0))<r&&i.set(a,0,0);return i.to1DArray()}}function fy(s,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;s=pt.checkMatrix(s);let n=s.rows,i=new pt(n,n);for(let a=0;a<n;a++){let l=pt.columnVector(s.getRow(a)),c=s.subMatrixRow(ly(n,a)).transpose(),h=new Ei(c).solve(l),f=pt.sub(l,c.mmul(h)).abs().max();i.setRow(a,cy(f,h,a,e,r))}return i}function hy(s,t=Number.EPSILON){if(s=pt.checkMatrix(s),s.isEmpty())return s.transpose();let e=new Ei(s,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,i=e.diagonal;for(let a=0;a<i.length;a++)Math.abs(i[a])>t?i[a]=1/i[a]:i[a]=0;return n.mmul(pt.diag(i).mmul(r.transpose()))}function py(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new pt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(s=s.center("column"),r||(t=t.center("column")));const i=s.transpose().mmul(t);for(let a=0;a<i.rows;a++)for(let l=0;l<i.columns;l++)i.set(a,l,i.get(a,l)*(1/(s.rows-1)));return i}function dy(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new pt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:i=!0}=e;n&&(s.center("column"),r||t.center("column")),i&&(s.scale("column"),r||t.scale("column"));const a=s.standardDeviation("column",{unbiased:!0}),l=r?a:t.standardDeviation("column",{unbiased:!0}),c=s.transpose().mmul(t);for(let p=0;p<c.rows;p++)for(let h=0;h<c.columns;h++)c.set(p,h,c.get(p,h)*(1/(a[p]*l[h]))*(1/(s.rows-1)));return c}let jf=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=gr.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,i=new pt(n,n),a=new Float64Array(n),l=new Float64Array(n),c=t,p,h,f=!1;if(r?f=!0:f=t.isSymmetric(),f){for(p=0;p<n;p++)for(h=0;h<n;h++)i.set(p,h,c.get(p,h));_y(n,l,a,i),my(n,l,a,i)}else{let d=new pt(n,n),g=new Float64Array(n);for(h=0;h<n;h++)for(p=0;p<n;p++)d.set(p,h,c.get(p,h));gy(n,d,g,i),vy(n,l,a,i,d)}this.n=n,this.e=l,this.d=a,this.V=i}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 pt(t,t),i,a;for(i=0;i<t;i++){for(a=0;a<t;a++)n.set(i,a,0);n.set(i,i,r[i]),e[i]>0?n.set(i,i+1,e[i]):e[i]<0&&n.set(i,i-1,e[i])}return n}};function _y(s,t,e,r){let n,i,a,l,c,p,h,f;for(c=0;c<s;c++)e[c]=r.get(s-1,c);for(l=s-1;l>0;l--){for(f=0,a=0,p=0;p<l;p++)f=f+Math.abs(e[p]);if(f===0)for(t[l]=e[l-1],c=0;c<l;c++)e[c]=r.get(l-1,c),r.set(l,c,0),r.set(c,l,0);else{for(p=0;p<l;p++)e[p]/=f,a+=e[p]*e[p];for(n=e[l-1],i=Math.sqrt(a),n>0&&(i=-i),t[l]=f*i,a=a-n*i,e[l-1]=n-i,c=0;c<l;c++)t[c]=0;for(c=0;c<l;c++){for(n=e[c],r.set(c,l,n),i=t[c]+r.get(c,c)*n,p=c+1;p<=l-1;p++)i+=r.get(p,c)*e[p],t[p]+=r.get(p,c)*n;t[c]=i}for(n=0,c=0;c<l;c++)t[c]/=a,n+=t[c]*e[c];for(h=n/(a+a),c=0;c<l;c++)t[c]-=h*e[c];for(c=0;c<l;c++){for(n=e[c],i=t[c],p=c;p<=l-1;p++)r.set(p,c,r.get(p,c)-(n*t[p]+i*e[p]));e[c]=r.get(l-1,c),r.set(l,c,0)}}e[l]=a}for(l=0;l<s-1;l++){if(r.set(s-1,l,r.get(l,l)),r.set(l,l,1),a=e[l+1],a!==0){for(p=0;p<=l;p++)e[p]=r.get(p,l+1)/a;for(c=0;c<=l;c++){for(i=0,p=0;p<=l;p++)i+=r.get(p,l+1)*r.get(p,c);for(p=0;p<=l;p++)r.set(p,c,r.get(p,c)-i*e[p])}}for(p=0;p<=l;p++)r.set(p,l+1,0)}for(c=0;c<s;c++)e[c]=r.get(s-1,c),r.set(s-1,c,0);r.set(s-1,s-1,1),t[0]=0}function my(s,t,e,r){let n,i,a,l,c,p,h,f,d,g,y,m,w,v,x,b;for(a=1;a<s;a++)t[a-1]=t[a];t[s-1]=0;let N=0,E=0,A=Number.EPSILON;for(p=0;p<s;p++){for(E=Math.max(E,Math.abs(e[p])+Math.abs(t[p])),h=p;h<s&&!(Math.abs(t[h])<=A*E);)h++;if(h>p)do{for(n=e[p],f=(e[p+1]-n)/(2*t[p]),d=hn(f,1),f<0&&(d=-d),e[p]=t[p]/(f+d),e[p+1]=t[p]*(f+d),g=e[p+1],i=n-e[p],a=p+2;a<s;a++)e[a]-=i;for(N=N+i,f=e[h],y=1,m=y,w=y,v=t[p+1],x=0,b=0,a=h-1;a>=p;a--)for(w=m,m=y,b=x,n=y*t[a],i=y*f,d=hn(f,t[a]),t[a+1]=x*d,x=t[a]/d,y=f/d,f=y*e[a]-x*n,e[a+1]=i+x*(y*n+x*e[a]),c=0;c<s;c++)i=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+y*i),r.set(c,a,y*r.get(c,a)-x*i);f=-x*b*w*v*t[p]/g,t[p]=x*f,e[p]=y*f}while(Math.abs(t[p])>A*E);e[p]=e[p]+N,t[p]=0}for(a=0;a<s-1;a++){for(c=a,f=e[a],l=a+1;l<s;l++)e[l]<f&&(c=l,f=e[l]);if(c!==a)for(e[c]=e[a],e[a]=f,l=0;l<s;l++)f=r.get(l,a),r.set(l,a,r.get(l,c)),r.set(l,c,f)}}function gy(s,t,e,r){let n=0,i=s-1,a,l,c,p,h,f,d;for(f=n+1;f<=i-1;f++){for(d=0,p=f;p<=i;p++)d=d+Math.abs(t.get(p,f-1));if(d!==0){for(c=0,p=i;p>=f;p--)e[p]=t.get(p,f-1)/d,c+=e[p]*e[p];for(l=Math.sqrt(c),e[f]>0&&(l=-l),c=c-e[f]*l,e[f]=e[f]-l,h=f;h<s;h++){for(a=0,p=i;p>=f;p--)a+=e[p]*t.get(p,h);for(a=a/c,p=f;p<=i;p++)t.set(p,h,t.get(p,h)-a*e[p])}for(p=0;p<=i;p++){for(a=0,h=i;h>=f;h--)a+=e[h]*t.get(p,h);for(a=a/c,h=f;h<=i;h++)t.set(p,h,t.get(p,h)-a*e[h])}e[f]=d*e[f],t.set(f,f-1,d*l)}}for(p=0;p<s;p++)for(h=0;h<s;h++)r.set(p,h,p===h?1:0);for(f=i-1;f>=n+1;f--)if(t.get(f,f-1)!==0){for(p=f+1;p<=i;p++)e[p]=t.get(p,f-1);for(h=f;h<=i;h++){for(l=0,p=f;p<=i;p++)l+=e[p]*r.get(p,h);for(l=l/e[f]/t.get(f,f-1),p=f;p<=i;p++)r.set(p,h,r.get(p,h)+l*e[p])}}}function vy(s,t,e,r,n){let i=s-1,a=0,l=s-1,c=Number.EPSILON,p=0,h=0,f=0,d=0,g=0,y=0,m=0,w=0,v,x,b,N,E,A,M,S,T,F,O,R,U,k,W;for(v=0;v<s;v++)for((v<a||v>l)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<s;x++)h=h+Math.abs(n.get(v,x));for(;i>=a;){for(N=i;N>a&&(y=Math.abs(n.get(N-1,N-1))+Math.abs(n.get(N,N)),y===0&&(y=h),!(Math.abs(n.get(N,N-1))<c*y));)N--;if(N===i)n.set(i,i,n.get(i,i)+p),e[i]=n.get(i,i),t[i]=0,i--,w=0;else if(N===i-1){if(M=n.get(i,i-1)*n.get(i-1,i),f=(n.get(i-1,i-1)-n.get(i,i))/2,d=f*f+M,m=Math.sqrt(Math.abs(d)),n.set(i,i,n.get(i,i)+p),n.set(i-1,i-1,n.get(i-1,i-1)+p),S=n.get(i,i),d>=0){for(m=f>=0?f+m:f-m,e[i-1]=S+m,e[i]=e[i-1],m!==0&&(e[i]=S-M/m),t[i-1]=0,t[i]=0,S=n.get(i,i-1),y=Math.abs(S)+Math.abs(m),f=S/y,d=m/y,g=Math.sqrt(f*f+d*d),f=f/g,d=d/g,x=i-1;x<s;x++)m=n.get(i-1,x),n.set(i-1,x,d*m+f*n.get(i,x)),n.set(i,x,d*n.get(i,x)-f*m);for(v=0;v<=i;v++)m=n.get(v,i-1),n.set(v,i-1,d*m+f*n.get(v,i)),n.set(v,i,d*n.get(v,i)-f*m);for(v=a;v<=l;v++)m=r.get(v,i-1),r.set(v,i-1,d*m+f*r.get(v,i)),r.set(v,i,d*r.get(v,i)-f*m)}else e[i-1]=S+f,e[i]=S+f,t[i-1]=m,t[i]=-m;i=i-2,w=0}else{if(S=n.get(i,i),T=0,M=0,N<i&&(T=n.get(i-1,i-1),M=n.get(i,i-1)*n.get(i-1,i)),w===10){for(p+=S,v=a;v<=i;v++)n.set(v,v,n.get(v,v)-S);y=Math.abs(n.get(i,i-1))+Math.abs(n.get(i-1,i-2)),S=T=.75*y,M=-.4375*y*y}if(w===30&&(y=(T-S)/2,y=y*y+M,y>0)){for(y=Math.sqrt(y),T<S&&(y=-y),y=S-M/((T-S)/2+y),v=a;v<=i;v++)n.set(v,v,n.get(v,v)-y);p+=y,S=T=M=.964}for(w=w+1,E=i-2;E>=N&&(m=n.get(E,E),g=S-m,y=T-m,f=(g*y-M)/n.get(E+1,E)+n.get(E,E+1),d=n.get(E+1,E+1)-m-g-y,g=n.get(E+2,E+1),y=Math.abs(f)+Math.abs(d)+Math.abs(g),f=f/y,d=d/y,g=g/y,!(E===N||Math.abs(n.get(E,E-1))*(Math.abs(d)+Math.abs(g))<c*(Math.abs(f)*(Math.abs(n.get(E-1,E-1))+Math.abs(m)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=i;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=i-1&&(k=b!==i-1,b!==E&&(f=n.get(b,b-1),d=n.get(b+1,b-1),g=k?n.get(b+2,b-1):0,S=Math.abs(f)+Math.abs(d)+Math.abs(g),S!==0&&(f=f/S,d=d/S,g=g/S)),S!==0);b++)if(y=Math.sqrt(f*f+d*d+g*g),f<0&&(y=-y),y!==0){for(b!==E?n.set(b,b-1,-y*S):N!==E&&n.set(b,b-1,-n.get(b,b-1)),f=f+y,S=f/y,T=d/y,m=g/y,d=d/f,g=g/f,x=b;x<s;x++)f=n.get(b,x)+d*n.get(b+1,x),k&&(f=f+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-f*m)),n.set(b,x,n.get(b,x)-f*S),n.set(b+1,x,n.get(b+1,x)-f*T);for(v=0;v<=Math.min(i,b+3);v++)f=S*n.get(v,b)+T*n.get(v,b+1),k&&(f=f+m*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-f*g)),n.set(v,b,n.get(v,b)-f),n.set(v,b+1,n.get(v,b+1)-f*d);for(v=a;v<=l;v++)f=S*r.get(v,b)+T*r.get(v,b+1),k&&(f=f+m*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-f*g)),r.set(v,b,r.get(v,b)-f),r.set(v,b+1,r.get(v,b+1)-f*d)}}}if(h!==0){for(i=s-1;i>=0;i--)if(f=e[i],d=t[i],d===0)for(N=i,n.set(i,i,1),v=i-1;v>=0;v--){for(M=n.get(v,v)-f,g=0,x=N;x<=i;x++)g=g+n.get(v,x)*n.get(x,i);if(t[v]<0)m=M,y=g;else if(N=v,t[v]===0?n.set(v,i,M!==0?-g/M:-g/(c*h)):(S=n.get(v,v+1),T=n.get(v+1,v),d=(e[v]-f)*(e[v]-f)+t[v]*t[v],A=(S*y-m*g)/d,n.set(v,i,A),n.set(v+1,i,Math.abs(S)>Math.abs(m)?(-g-M*A)/S:(-y-T*A)/m)),A=Math.abs(n.get(v,i)),c*A*A>1)for(x=v;x<=i;x++)n.set(x,i,n.get(x,i)/A)}else if(d<0)for(N=i-1,Math.abs(n.get(i,i-1))>Math.abs(n.get(i-1,i))?(n.set(i-1,i-1,d/n.get(i,i-1)),n.set(i-1,i,-(n.get(i,i)-f)/n.get(i,i-1))):(W=oo(0,-n.get(i-1,i),n.get(i-1,i-1)-f,d),n.set(i-1,i-1,W[0]),n.set(i-1,i,W[1])),n.set(i,i-1,0),n.set(i,i,1),v=i-2;v>=0;v--){for(F=0,O=0,x=N;x<=i;x++)F=F+n.get(v,x)*n.get(x,i-1),O=O+n.get(v,x)*n.get(x,i);if(M=n.get(v,v)-f,t[v]<0)m=M,g=F,y=O;else if(N=v,t[v]===0?(W=oo(-F,-O,M,d),n.set(v,i-1,W[0]),n.set(v,i,W[1])):(S=n.get(v,v+1),T=n.get(v+1,v),R=(e[v]-f)*(e[v]-f)+t[v]*t[v]-d*d,U=(e[v]-f)*2*d,R===0&&U===0&&(R=c*h*(Math.abs(M)+Math.abs(d)+Math.abs(S)+Math.abs(T)+Math.abs(m))),W=oo(S*g-m*F+d*O,S*y-m*O-d*F,R,U),n.set(v,i-1,W[0]),n.set(v,i,W[1]),Math.abs(S)>Math.abs(m)+Math.abs(d)?(n.set(v+1,i-1,(-F-M*n.get(v,i-1)+d*n.get(v,i))/S),n.set(v+1,i,(-O-M*n.get(v,i)-d*n.get(v,i-1))/S)):(W=oo(-g-T*n.get(v,i-1),-y-T*n.get(v,i),m,d),n.set(v+1,i-1,W[0]),n.set(v+1,i,W[1]))),A=Math.max(Math.abs(n.get(v,i-1)),Math.abs(n.get(v,i))),c*A*A>1)for(x=v;x<=i;x++)n.set(x,i-1,n.get(x,i-1)/A),n.set(x,i,n.get(x,i)/A)}for(v=0;v<s;v++)if(v<a||v>l)for(x=v;x<s;x++)r.set(v,x,n.get(v,x));for(x=s-1;x>=a;x--)for(v=a;v<=l;v++){for(m=0,b=a;b<=Math.min(x,l);b++)m=m+r.get(v,b)*n.get(b,x);r.set(v,x,m)}}}function oo(s,t,e,r){let n,i;return Math.abs(e)>Math.abs(r)?(n=r/e,i=e+n*r,[(s+n*t)/i,(t-n*s)/i]):(n=e/r,i=r+n*e,[(n*s+t)/i,(n*t-s)/i])}class Yf{constructor(t){if(t=gr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new pt(r,r),i=!0,a,l,c;for(l=0;l<r;l++){let p=0;for(c=0;c<l;c++){let h=0;for(a=0;a<c;a++)h+=n.get(c,a)*n.get(l,a);h=(e.get(l,c)-h)/n.get(c,c),n.set(l,c,h),p=p+h*h}for(p=e.get(l,l)-p,i&=p>0,n.set(l,l,Math.sqrt(Math.max(p,0))),c=l+1;c<r;c++)n.set(l,c,0)}this.L=n,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=gr.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,i=t.clone(),a,l,c;for(c=0;c<r;c++)for(l=0;l<n;l++){for(a=0;a<c;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(c,a));i.set(c,l,i.get(c,l)/e.get(c,c))}for(c=r-1;c>=0;c--)for(l=0;l<n;l++){for(a=c+1;a<r;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(a,c));i.set(c,l,i.get(c,l)/e.get(c,c))}return i}get lowerTriangularMatrix(){return this.L}}class Vf{constructor(t,e={}){t=gr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:i=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(cr.isAnyArray(r)&&typeof r[0]=="number"?r=pt.columnVector(r):r=gr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");l=r.getColumnVector(0)}else l=t.getColumnVector(0);let c=1,p,h,f,d;for(let g=0;g<i&&c>a;g++)f=t.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),f=f.div(f.norm()),p=t.mmul(f).div(f.transpose().mmul(f).get(0,0)),g>0&&(c=p.clone().sub(d).pow(2).sum()),d=p.clone(),r?(h=r.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),h=h.div(h.norm()),l=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):l=p;if(r){let g=t.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0));g=g.div(g.norm());let y=t.clone().sub(p.clone().mmul(g.transpose())),m=l.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),w=r.clone().sub(p.clone().mulS(m.get(0,0)).mmul(h.transpose()));this.t=p,this.p=g.transpose(),this.w=f.transpose(),this.q=h,this.u=l,this.s=p.transpose().mmul(p),this.xResidual=y,this.yResidual=w,this.betas=m}else this.w=f.transpose(),this.s=p.transpose().mmul(p).sqrt(),n?this.t=p.clone().div(this.s.get(0,0)):this.t=p,this.xResidual=t.sub(p.mmul(f.transpose()))}}qt.AbstractMatrix=$t,qt.CHO=Yf,qt.CholeskyDecomposition=Yf,qt.DistanceMatrix=ro,qt.EVD=jf;var yy=qt.EigenvalueDecomposition=jf;qt.LU=io,qt.LuDecomposition=io;var Zf=qt.Matrix=pt;qt.MatrixColumnSelectionView=ty,qt.MatrixColumnView=Q1,qt.MatrixFlipColumnView=ey,qt.MatrixFlipRowView=ry,qt.MatrixRowSelectionView=iy,qt.MatrixRowView=ny,qt.MatrixSelectionView=no,qt.MatrixSubView=sy,qt.MatrixTransposeView=oy,qt.NIPALS=Vf,qt.Nipals=Vf,qt.QR=za,qt.QrDecomposition=za,qt.SVD=Ei,qt.SingularValueDecomposition=Ei,qt.SymmetricMatrix=Xn,qt.WrapperMatrix1D=Uf,qt.WrapperMatrix2D=gr,qt.correlation=dy,qt.covariance=py;var Kf=qt.default=pt;qt.determinant=so,qt.inverse=uy,qt.linearDependencies=fy,qt.pseudoInverse=hy,qt.solve=Wf,qt.wrap=ay;const Gf=yy,Hf=Zf;Kf.Matrix&&Kf.Matrix;class wy{constructor(t){$(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new qa(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:i,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:i,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:i}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:i})}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 qa{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 Qt(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const i of n._value)t+=_t(i)?0:i,e+=1;return t/e}col({column:t}){const e=[],r=new Qt(0,void 0,this._errorListener);if(_t(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return $f(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(_t(t)||_t(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=Xs(this._matrixArray);return this._newMatrix(t)}max(){return _1(this._matrixArray)}min(){return $a(this._matrixArray)}pow({power:t}){const e=_t(t)?this._matrixArray:g1(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return _t(t)?new Qt(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){_t(t)||_t(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=Qi(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=l1(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:i}={}){_t(e)&&(e=0),_t(r)&&(r=this.rows()),_t(n)&&(n=0),_t(i)&&(i=this.columns());for(const[a,l]of this._matrixInstance.entries())for(const[c]of l._value.entries())a<r&&a>=e&&c>=n&&c<i&&l.set({index:c,value:t})}kron({id2:t}){const e=a1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return $a(Mf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=wi(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=m1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Vn.ascending}={}){_t(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const i=r._value[t],a=n._value[t];return e!==Vn.descending?i-a:a-i})}trace(){return d1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Lf(this._matrixArray)}add_col({column:t,array_id:e}={}){_t(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}){_t(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new Qt(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(le.matrixRehapeErr,r,zt.Error);return}const n=n1(this._matrixArray,[t,e]);this._matrixInstance=n.map(i=>{const a=new Qt(0,void 0,this._errorListener);return a._value=[...i],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}={}){_t(t)&&(t=0),_t(e)&&(e=this.rows()),_t(r)&&(r=0),_t(n)&&(n=this.columns());const i=this._matrixArray.splice(t,e),a=[];for(const l of i)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(_t(t)||_t(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=Sf(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){_t(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const i=n._value.splice(t,1);e.push(i[0])}const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return _t(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new Gf(new Hf(this._matrixArray)),e=new Qt(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 i=0;i<e;i++)if(n!==i&&r[n][i]!==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 i=0;i<e;i++)if(n!==i&&r[n][i]!==0||n===i&&r[n][i]!==1)return!1;return!0}eigenvectors(){const t=new Gf(new Hf(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 i=n+1;i<e;i++)if(r[n][i]!==r[i][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(_t(t)||_t(e)))for(const r of this._matrixInstance){const n=r._value[t],i=r._value[e];r.set({index:t,value:i}),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 i1(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 i=0;i<t;i++)if(n+i!==t-1&&r[n][i]!==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 i=0;i<t;i++)if(n!==i&&r[n][i]!==-r[i][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 qa(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new Qt(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,i=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&i[l][a]===0;)l++;if(l===r)continue;if(l!==a){const p=i[l];i[l]=i[a],i[a]=p}const c=i[a][a];for(let p=0;p<n;p++)i[a][p]/=c;for(let p=a+1;p<r;p++){const h=i[p][a];i[p]=i[p].map((f,d)=>f-h*i[a][d]),i[p][a]=0}}for(let a=0;a<r;a++)i[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class Dy{constructor(t){$(this,"_variables");$(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const r=Qr(t),n=Qr(this._variables.timeframe.period);if(r<n)return!0;const i=`change_${e}`,a=this._cacheData[i],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else{const c=this._calcTimeOffset(l,t);return this._cacheData[i]={currentTime:l,offset:c},!1}return!1}in_seconds({timeframe:t}={}){return Qr(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=ee.duration(e);if(r.years())return"12M";const i=r.asMonths();if(Hs(i))return`${i}M`;const a=r.asWeeks();if(Hs(a))return`${a}M`;const l=r.asDays();if(l>=1)return`${Math.ceil(l)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const p=r.asSeconds();return p<=1?"1S":p<=5?"5S":p<=10?"10S":p<=15?"15S":p<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const l=ee(t).day();e="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(e.includes("M")){const l=ee(t).date();e="1D";const c=ee(t).daysInMonth();l!==1&&(r=(c-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),i=Qr(e)*1e3,a=t-n-Math.floor((t-n)/i)*i;return r?r-a:a}}class by{constructor(t,e){$(this,"_errorListener");$(this,"_intlNumberFormatter");$(this,"_precision");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}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 Qt;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(_t(e)){this._errorListener.addError(le.arrLenErr,n,zt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){_t(n)&&(n=0);let i=-1;for(let a=0;a<n+1&&(i=t.indexOf(e,i+1),i!==-1);a++);return i!==-1?t.substring(0,i)+r+t.substring(i+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))}_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 _t(e)&&(e=0),_t(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 _t(t)&&(t=0),qr(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 Kt.mintick:return t.toFixed(this._precision);case Kt.percent:return`${t}%`;case Kt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var l;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[i,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),p=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;p&&(i=i.replace(new RegExp(`\\B(?=(\\d{${p}})+(?!\\d))`,"g"),",")),r=c.join("")}i=r.replace(/#/,i).replace(/#/g,"")}else i=`${r}${i}`;if(n&&n.includes("#")){const c=n.split("#").length-1;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}_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(t,e){let r=t;for(const[n,i]of e.entries()){if(i===void 0||typeof i=="number"&&isNaN(i)){r="NaN";continue}if(typeof i=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(i,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(i))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),i)}return r}}class xy{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new ka(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 ka{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new ka(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 Qt(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 Qt(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 Ey{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Ai(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Ai(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Ai(t,e)}from_time({price:t,time:e}){return new Ai(t,void 0,e)}}class Ai{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ai(this._price,this._index,this._time)}}class Ay{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:we.bar_index,yloc:Wr.price,size:rr.normal,style:ge.styleLabelDown,textalign:Wt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:i,bar_index:a}=this._variables,l=`label_${e}_${a}`;me(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:l,time:r,high:n,low:i,bar_index:a};t.point&&(c.x=c.xloc===we.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Wr.abovebar?c.y=n:c.yloc===Wr.belowbar&&(c.y=i),this._verfiyArgs(t,e);const p=new ao(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,p),p}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:i,size:a,textalign:l,text_font_family:c}=t,p="label.new";this._paramVerfiy(i,e,p,Object.values(ge),"style"),this._paramVerfiy(r,e,p,Object.values(we),"xloc"),this._paramVerfiy(n,e,p,Object.values(Wr),"yloc"),this._paramVerfiy(a,e,p,Object.values(rr),"size"),this._paramVerfiy(l,e,p,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,p,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 ao{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get type(){return Fe.LABEL}get id(){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),i=new ao(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,i)}return i}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)}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(rr),"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(we),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:i}=this._variables;r&&(r.yloc=t,t===Wr.abovebar?r.y=n:t===Wr.belowbar&&(r.y=i),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Wr),"yloc"))}set_color(t,e){const r=this._getLabel(e);me(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===we.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(ge),"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",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);me(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(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const Cy={freq_all:kr.freqAll,freq_once_per_bar:kr.freqOncePerBar,freq_once_per_bar_close:kr.freqOncePerBarClose},Fy={gaps_off:Vi.gapsOff,gaps_on:Vi.gapsOn,lookahead_off:Vi.lookaheadOff,lookahead_on:Vi.lookaheadOn},Ci={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"},Jf={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"},My={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Xf={all:[Ve.dataWindow,Ve.pane,Ve.priceScale,Ve.statusLine],data_window:[Ve.dataWindow],none:[],pane:[Ve.pane],price_scale:[Ve.priceScale],status_line:[Ve.statusLine]},Ny={both:Ur.both,left:Ur.left,none:Ur.none,right:Ur.right},Sy={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},By={style_solid:Ds.styleSolid,style_dashed:Ds.styleDashed,style_dotted:Ds.styleDotted},Oy={style_arrowdown:ge.styleArrowdown,style_arrowup:ge.styleArrowup,style_circle:ge.styleCircle,style_cross:ge.styleCross,style_diamond:ge.styleDiamond,style_flag:ge.styleFlag,style_label_center:ge.styleLabelCenter,style_label_down:ge.styleLabelDown,style_label_left:ge.styleLabelLeft,style_label_lower_left:ge.styleLabelLowerLeft,style_label_lower_right:ge.styleLabelLowerRight,style_label_right:ge.styleLabelRight,style_label_up:ge.styleLabelUp,style_label_upper_left:ge.styleLabelUpperLeft,style_label_upper_right:ge.styleLabelUpperRight,style_none:ge.styleNone,style_square:ge.styleSquare,style_text_outline:ge.styleTextOutline,style_triangledown:ge.styleTriangledown,style_triangleup:ge.styleTriangleup,style_xcross:ge.styleXcross},Iy={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},Ty={abovebar:an.abovebar,absolute:an.absolute,belowbar:an.belowbar,bottom:an.bottom,top:an.top},$y={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Ly={style_area:Mr.styleArea,style_areabr:Mr.styleAreabr,style_circles:Mr.styleCircles,style_columns:Mr.styleColumns,style_cross:Mr.styleCross,style_histogram:Mr.styleHistogram,style_line:Mr.styleLine,style_linebr:Mr.styleLinebr,style_stepline:Mr.styleStepline,style_stepline_diamond:Mr.styleSteplineDiamond,style_steplinebr:Mr.styleSteplinebr},Ry={bottom_center:_r.bottomCenter,bottom_left:_r.bottomLeft,bottom_right:_r.bottomRight,middle_center:_r.middleCenter,middle_left:_r.middleLeft,middle_right:_r.middleRight,top_center:_r.topCenter,top_left:_r.topLeft,top_right:_r.topRight},Py={left:bs.left,none:bs.none,right:bs.right},zy={arrowdown:ur.arrowdown,arrowup:ur.arrowup,circle:ur.circle,cross:ur.cross,diamond:ur.diamond,flag:ur.flag,labeldown:ur.labeldown,labelup:ur.labelup,square:ur.square,triangledown:ur.triangledown,triangleup:ur.triangleup,xcross:ur.xcross},qy={auto:rr.auto,huge:rr.huge,large:rr.large,normal:rr.normal,small:rr.small,tiny:rr.tiny},ky={cash:Ie.cash,fixed:Ie.fixed,percent_of_equity:Ie.percentOfEquity,commission:{cash_per_contract:nr.cashPerContract,cash_per_order:nr.cashPerOrder,percent:nr.percent},direction:{all:ue.all,long:ue.long,short:ue.short},oca:{cancel:un.cancel,none:un.none,reduce:un.reduce}},Uy={align_bottom:Wt.alignBottom,align_center:Wt.alignCenter,align_left:Wt.alignLeft,align_right:Wt.alignRight,align_top:Wt.alignTop,wrap_auto:Wt.wrapAuto,wrap_none:Wt.wrapNone},Wy={bar_index:we.bar_index,bar_time:we.bar_time},jy={abovebar:Wr.abovebar,belowbar:Wr.belowbar,price:Wr.price},Yy={actual:xs.actual,estimate:xs.estimate,standardized:xs.standardized};class Qf{constructor(){$(this,"adjustment",{dividends:ws.dividends,none:ws.none,splits:ws.splits});$(this,"alert",Cy);$(this,"barmerge",Fy);$(this,"color",Ci);$(this,"currency",Jf);$(this,"dayofweek",My);$(this,"earnings",Yy);$(this,"display",Xf);$(this,"extend",Ny);$(this,"font",{family_default:Zn.familyDefault,family_monospace:Zn.familyMonospace});$(this,"format",Sy);$(this,"hline",By);$(this,"label",Oy);$(this,"line",Iy);$(this,"location",Ty);$(this,"math",$y);$(this,"order",{ascending:Vn.ascending,descending:Vn.descending});$(this,"plot",Ly);$(this,"position",Ry);$(this,"scale",Py);$(this,"session",{extended:fi.extended,regular:fi.regular});$(this,"shape",zy);$(this,"size",qy);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",ky);$(this,"text",Uy);$(this,"xloc",Wy);$(this,"yloc",jy)}updateData(){}}class Vy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:we.bar_index,line_color:Ci.blue,line_style:Re.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var l;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,i=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(l=t.points)==null?void 0:l._value.map(c=>({time:c.time,index:c.index,price:c.price}))});me(i,["line_color","fill_color"]);const a=new th(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,i,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,i="polyline.new";this._paramVerfiy(r,e,i,Object.values(Re),"line_style"),this._paramVerfiy(n,e,i,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}delete({id:t}){t&&t.delete()}}class th{constructor(t,e){$(this,"_id");$(this,"_variables");this._variables=e,this._id=t}get type(){return Fe.POLYLINE}get id(){return this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id)}}class Zy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:we.bar_index,extend:Ur.none,style:Re.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:i}=this._variables,a=`line_${n}_${i}`;me(r,["color"]);const l={...this._defaultLine,...r,id:a,bar_index:i};if(t&&e){const p=l.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,h=l.xloc===we.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(l,{x1:p,y1:t==null?void 0:t.price,x2:h,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new uo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,l,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:i}=t,a="line.new";this._paramVerfiy(i,e,a,Object.values(Re),"style"),this._paramVerfiy(r,e,a,Object.values(Ur),"extend"),this._paramVerfiy(n,e,a,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 uo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}get type(){return Fe.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),i=new uo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===we.bar_index){const{x1:n,y1:i,x2:a,y2:l}=r;return n===void 0||a===void 0||i===void 0||l===void 0?void 0:(l-i)/(a-n)*(t-n)+i}}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 i=this._getLine(n);i&&(i.xloc=t,i.x1=e,i.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(we),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(me(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(Ur),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class Ky{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:i}=this._variables,a=`linefill_${e}_${i}`,l=r==null?void 0:r.data,c=n==null?void 0:n.data;l&&(l.linefills=l.linefills||[],l.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),me(t,["color"]);const p=new lo(this._variables,a,r,n);return e.startsWith("export")||(l||c)&&this._variables.linefill.add(a,{line1:l,line2:c,color:t.color,id:a,bar_index:i},p),p}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 lo{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return Fe.LINEFILL}get id(){return this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new lo(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:i}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),i&&(i.linefills=(r=i.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(me(t,["color"]),e.color=t.color)}}class Gy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Ci.blue,border_width:1,bgcolor:Ci.blue,xloc:we.bar_index,extend:Ur.none,style:Re.styleSolid,text:"",text_size:rr.auto,text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_wrap:Wt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:i}=this._variables,a=`box_${n}_${i}`,l={...this._defaultBox,...r,id:a,bar_index:i};if(me(l,["border_color","bgcolor","text_color"]),t){const{price:p,time:h,index:f}=t;l.top=p,l.left=l.xloc===we.bar_index?f:h}if(e){const{price:p,time:h,index:f}=e;l.bottom=p,l.right=l.xloc===we.bar_index?f:h}this._verfiyArgs(r,n);const c=new co(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,l,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:l,text_valign:c,text_wrap:p,text_font_family:h}=t,f="box.new";this._paramVerfiy(r,e,f,[Re.styleDashed,Re.styleDotted,Re.styleSolid],"border_style"),this._paramVerfiy(n,e,f,Object.values(Ur),"extend"),this._paramVerfiy(i,e,f,Object.values(we),"xloc"),this._paramVerfiy(a,e,f,Object.values(rr),"text_size"),this._paramVerfiy(l,e,f,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"),this._paramVerfiy(c,e,f,[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"),this._paramVerfiy(p,e,f,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(h,e,f,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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_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 co{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.BOX}get id(){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(),i=new co(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.box.delete(this._id)}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(Ur),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,me(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(rr),"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",[Wt.wrapAuto,Wt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,me(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",[Wt.alignLeft,Wt.alignCenter,Wt.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",[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.top=n,e.left=e.xloc===we.bar_index?r:i}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,me(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:i}=t||{};e.bottom=n,e.right=e.xloc===we.bar_index?r:i}}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(Zn),"text_font_family"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Hy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:_r.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}`,{columns:i,rows:a}=t;me(t,["text_color","bgcolor","border_color"]);const l=Array.from(Array(a),()=>Array.from(Array(i),()=>{})),c={...this._defaultTable,...t,cell:l,id:n,bar_index:r},p=new eh(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(_r),"position"),e.startsWith("export")||this._variables.table.add(n,c,p),p}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 eh{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:rr.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.TABLE}get id(){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,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],l=a[n]||[];l[r]=e,a[n]=l,i.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,me(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 i=this._variables.table.get(this._id);if(i){const a=i.cell;if(a)for(let l=e;l<=n;l++)for(let c=t;c<=r;c++){const p=a[l];p&&(p[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},i){if(t>r||e>n){this._errorListener.addError(le.mergeCellErr,i,zt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,me(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(_r),"position"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.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 Jy{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 this._strategy.historyOrders[t].in_time}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===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class Xy{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 this._strategy.orders[t].in_time}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===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class Qy{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(ue),"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",[Ie.percentOfEquity,Ie.cash],"type"),e===Ie.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",[Ie.percentOfEquity,Ie.cash],"type"),e===Ie.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,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}}let tw=class{constructor(t,e,r,n,i){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:0,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Ie.fixed,default_qty_value:1,initial_capital:1e6,currency:Jf.NONE,slippage:0,commission_type:nr.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._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 Xy(this),this._closedtrades=new Jy(this),this._riskNamespace=new Qy(this,n),this._id=`strategy_${i}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=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}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),!this._options.process_orders_on_close&&this._calcLiquidate()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._calcProfitAndLoss(),this._variables.strategy.update(),this._maxDrawdownVerify(),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{high:n,low:i,time_tradingday:a,time:l,strategy:{netprofit:c,initial_capital:p}}=this._variables;let{preNetprofit:h=0}=this._risk;l===a&&(h=c,this._risk.preNetprofit=c,this._risk.isTemporaryBan=!1);let f=h-c;f+=this._orders.reduce((y,m)=>{const{in_price:w,direction:v,qty:x=0,commission:b=0,original_qty:N=0}=m,E=v===ue.long?1:-1,A=(n-w)*x,M=(i-w)*x,S=E===1?M:-A;return y+S+x/N*b},0);let d=!1;switch(e){case Ie.cash:d=t<f;break;case Ie.percentOfEquity:const y=f/(p+c)*100;d=t<y;break}if(d){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===ue.long?i:n,"Close Position (Max intraday Loss)"),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:i,open:a}=this._variables;n===i&&(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)"),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:i,time_tradingday:a,strategy:l,open:c}=this._variables;let p=e;if(i===a){const h=l.netprofit+l.openprofit;h<n?p=0:p++,Object.assign(this._risk,{lossDays:p,totalProfit:h})}t<=p&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){var n;const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(!r&&t!==void 0&&e){const{max_drawdown:i,max_drawdown_percent:a}=this._variables.strategy;let l=!1;switch(e){case Ie.percentOfEquity:l=a<i;break;case Ie.cash:l=t<i;break}if(l){const{high:c,low:p}=this._variables,h=(n=this._orders[0])==null?void 0:n.direction;this._riskTouchOff(h===ue.long?c:p,"Close Position (Max Drawdown)")}}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._closeOrders(this._orders,t,e),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Kt.inherit,Kt.price,Kt.percent,Kt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Ie),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(nr),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={};if(r)for(const i of Object.keys(r)){const a=t[i];a!==r[i]&&(n[i]=a)}self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,this._updateOptions,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(un),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(un),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close"}):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=Ie.fixed,default_qty_value:r=1,initial_capital:n}=this._options;switch(e){case Ie.fixed:return r;case Ie.cash:return r/t;case Ie.percentOfEquity:const i=this._getOrderProfit(t);return(n+i+this._totalChangeCapital)*r/100/t}}_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._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:i}=e,a=i===ue.long?1:-1,l=(t-r)*a*n,[c,p]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,l,c,p)}}_calcProfitAndLossHandle(t,e,r){const{high:n,low:i}=this._variables,a=(n-t)*e,l=(i-t)*e;let c=r===1?a:-l,p=r===1?l:-a;return[c,p]}_calcOrderPercent(t,e,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:l=0,qty:c=0,in_price:p,max_profit:h=0,trading_loss:f=0}=t;let{commission:d=0}=t,g=p*c;if(i){const y=this._getCommission(a,c);d=d*c/l,r-=d,n-=d,g+=d,e=e-y-d}r=Math.max(r,h,0),n=Math.min(n,f,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{high:t,low:e,time:r}=this._variables,{initial_capital:n,margin_long:i=0,margin_short:a=0}=this._options,l=this._orders[0].direction===ue.long?1:-1;let c=l===1?e:t;if(l===1&&i===100)return;const p=(l===1?i:a)/100;if(p<=0)return;let h=!1;const[f,d]=this._orders.reduce((w,v)=>{let[x,b]=w;const{in_price:N,qty:E=0,in_time:A}=v;A===r&&(h=!0);const M=N*E,S=c*E;return x+=M,b+=S,[x,b]},[0,0]);let g=0,y=0;const m=n+this._totalChangeCapital;if(h&&(g=m-f*p,g<0&&(c=this._orders[0].in_price,y=Math.abs(Math.trunc(g/p/c)*4),y=Math.max(y,1))),g>=0){const w=l*(d-f);if(g=m+w-d*p,g>=0)return;y=Math.abs(Math.trunc(g/p/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 i of this.orders)this._processOrder(i,t,e,r,r,!0);this._orders=this._orders.filter(i=>!i.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:i,quantities:a,close:l,price:c,activePrice:p}=this._orderArgsParse(t),h=t.direction===ue.long?1:-1;if(a<=0)return;let f=a;if(i&&e){if(n.length){const m=this._processOrders(n,l,f,t.id,t.comment);if(m<=0)return;f=m}const g=l+h*r*this._mintick;if(!this._judgeCapitalEnough(f,g,h))return;this._ocaGroupVerify(f,t.oca_name,t.oca_type),this._calcCurrentOrder({...t,in_price:g,in_index:this._variables.bar_index,in_time:this._variables.time,qty:f,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,h)&&this._addPendingOrders(t,c,f,i,p)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(h=>(h.direction===ue.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:i=0,margin_short:a=0}=this._options;if(i===0&&r===1||a===0&&r===-1)return!0;const l=this._getOrderProfit(e),p=this._getCapital(r,this._options.initial_capital+l+this._totalChangeCapital)-n;return t*e<=p}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:i=0,direction:a}=r,l=a===ue.long?1:-1;return e+(t-n)*i*l},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===un.none)return!1;let n=!1;switch(r){case un.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===e)i.isCancel=!0,n=!0;else return!0});break;case un.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:l}=i;if(e===l){const c=a-t;return n=!0,c<=0?(i.isCancel=!0,!1):(i.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,i,a=!1){let l=r;for(const c of t)if(l=this._processOrder(c,e,l,n,i,a),l<=0)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_addPendingOrders(t,e,r,n,i){const a=this._pendingOrders.find(l=>l.id===t.id&&!l.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let i=t.limit||0;const{close:a}=this._variables;let l=a,c=!1,p;const h=e===ue.long?1:-1,f=n&&(n-a)*h>0,{backtest_fill_limits_assumption:d=0}=this._options;d>0&&i&&(i-=d*this._mintick*h);const g=i&&(i-a)*h<0;f&&g?(p=n,l=i):f?l=n:g?l=i:c=!0;const y=r||this._calcDefaultQty(l)||1;return{orders:this._orders.filter(w=>w.direction!==e),isMarketPrice:c,activePrice:p,quantities:y,close:a,price:l}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:l,activePrice:c}=this._orderArgsParse(t);if(i<=0)return;if(r.length&&n&&e){this._entryOrder(r,a,i,t);return}this._judgeCapitalEnough(i,a,t.direction===ue.long?1:-1)&&this._addPendingEntry(t,l,i,n,c)}_entryOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{oca_name:c,oca_type:p,direction:h,comment:f,isMarketPrice:d,id:g}=n,y=h===ue.long?1:-1;if(r=this._getAvailablePositionSize(r,h),r<=0||(e=e+l*this._mintick*y,!this._judgeCapitalEnough(r,e,y)))return;this._closeOrders(t,e,g,f);const w={...n,in_price:e,qty:r,in_index:a,in_time:i,place_order_type:"entry"};if(d){this._calcCurrentOrder(w);return}const{pendingOrders:v,orders:x}=this._getEntryOrders(h),b=v.length+x.length;b&&b>=(this._options.pyramiding||0)||(this._ocaGroupVerify(r,c,p),this._calcCurrentOrder(w))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==ue.all&&n!==e)return 0;if(r===void 0)return t;const i=this._orders.reduce((a,l)=>a+(l.qty||0),0);return i?i+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,i){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),c=a.length+l.length,p=a.find(h=>h.id===t.id&&h.place_order_type==="entry");if(p)Object.assign(p,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else if(!c||c<(this._options.pyramiding||1)){const h={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(h)}}_closeAllOrders(t,e){const{comment:r}=t,{bar_index:n}=this._variables,i=this._orders.filter(a=>a.in_index!==n);i.length&&(this._closeOrders(i,e,"Close position order",r),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n){for(const i of t)this._closeOrder(i,e,r,n);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{in_price:c,qty:p=0,direction:h}=t,f=h===ue.long?1:-1;e=e-f*l*this._mintick,t.isDeal=!0;const d=(e-c)*f*p,g={...t,out_price:e,out_id:r,out_index:a,out_time:i,out_comment:n,out_qty:p,profit:d};this._calcPercent(g)}_ordersHandle(){const t=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!t.length)return;const{open:e,low:r,high:n,close:i}=this._variables;for(const a of t){const{stop:l,limit:c,trail_stop_price:p,isMarketPriceLimit:h,isMarketPriceStop:f,direction:d,id:g,out_comment:y,active_price:m,trail_offset:w=0,out_qty:v,comment_loss:x,comment_profit:b,comment_trailing:N}=a;let E=p;const A=d===ue.long?1:-1;let M,S=y;if(h||f?M=e:(c&&r<=c&&n>=c&&(S=b||y,M=c),l&&r<=l&&n>=l&&(M=E?(l-E)*A>0?l:E:l,S=(E===M?N:x)||y)),M)this._processExitOnClose(a,M,{from_entry:g,comment:S,qty:v});else{let T=!1;if(m&&m<=n&&m>=r&&(E=m-w*A*this._mintick,(E-i)*A>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(M=E)),T=!0,a.trail_stop_price=E),E)if((E-e)*A>=0&&!T)M=E;else{const F=(A===1?n:r)-w*A*this._mintick;A===1?E<e&&E>=r&&F>E&&F<i?M=E:F>E?(E=F,F>=i&&(M=F)):E<=n&&r<=E&&(M=E):E>e&&E<=n&&F<E&&F>i?M=E:F<E?(E=F,F<=i&&(M=F)):E<=n&&r<=E&&(M=E),a.trail_stop_price=E}M&&this._processExitOnClose(a,M,{from_entry:g,comment:N||y,qty:v})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of r)switch(n.place_order_type){case"close":this._closeOrderHandle(n);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&t.push(l)}for(const n of e){const i=this._exitOrderHandle(n);i&&t.push(i)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),e=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this._variables;for(const n of e)switch(n.place_order_type){case"close":this._closeOrderHandle(n,!0);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of t){const{from_entry:i}=n,a=this._orders.filter(l=>!i||l.id===i&&(l.isMarketPriceLimit||l.isMarketPriceStop));for(const l of a)this._processExitOnClose(l,l.limit||l.stop||l.trail_stop_price||r,n)}this._pendingCloseOrders=[]}_entryOrderHandle(t){const{open:e,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:l,direction:c,active_price:p}=t;if(p&&n>=p&&r<=p)return delete t.active_price,t;let h=l;if(i&&(h=e),h<=n&&h>=r){const f=this._orders.filter(d=>d.direction!==c);this._entryOrder(f,h,a,t)}else return t}_orderOrderHandle(t){const{open:e,low:r,high:n,time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:p=0,in_price:h,direction:f,comment:d,oca_name:g,oca_type:y,active_price:m,id:w}=t;if(m&&n>=m&&r<=m)return delete t.active_price,t;let v=h,x=p;if(c&&(v=e),v<=n&&v>=r){const b=this._orders.filter(E=>E.direction!==f);if(b.length&&(x=this._processOrders(b,v,p,w,d),x<=0))return;const N=f===ue.long?1:-1;this._ocaGroupVerify(x,g,y),this._calcCurrentOrder({...t,in_price:v+N*l*this._mintick,in_index:a,in_time:i,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:i=100,comment:a}=t,{bar_index:l}=this._variables,c=this._orders.filter(g=>g.id===r&&g.in_index!==l&&(!g.close_qty||g.close_qty<(g.qty||0)));if(!c.length)return;let p=0;if(n?p=n:(p=c.reduce((g,y)=>g+(y.qty||0),p),p=i/100*p),p<=0)return;const{open:h,close:f}=this._variables;let d=p;for(const g of c){const{qty:y=0}=g;d<y?g.close_qty=d:(g.close_qty=y,d-=y)}this._processOrders(this._options.close_entries_rule==="ANY"?c:this._orders,e?f:h,p,`Close entry(s) order ${r}`,a)}_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)))return t}_exit(t,e){const{profit:r,loss:n,stop:i,limit:a,trail_offset:l,trail_price:c,trail_points:p,from_entry:h="",id:f}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(p)&&this._isNaN(c))){this._errorListener.addError(le.strategyExitErr,e,zt.Error);return}const d={...t,place_order_type:"exit"},g=this._orders.filter(w=>(!h||h===w.id)&&!w.hasExit),y=this._pendingOrders.filter(w=>!h||h===w.id);if(g.length){if(!this._ordersToExit(g,d))return}else if(!y.length)return;const m=this._pendingOrders.find(w=>w.id===f);m?Object.assign(m,{...t}):this._pendingOrders.push(d)}_ordersToExit(t,e){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:l,comment_profit:c,comment_trailing:p}=e;let h=r,f=!1;e.comment=a||i;for(const d of t){const{qty:g=0}=d,y=d.direction===ue.long?1:-1;h=r?r>=g?g:r:n/100*g,d.out_qty=h,h<g&&(f=!0),Object.assign(d,{out_comment:a||i,comment_loss:l,comment_profit:c,comment_trailing:p}),!(this._stopProfit(d,y,{...e,qty:h})||this._stopLoss(d,y,{...e,qty:h})||this._trailStopLoss(d,y,{...e,qty:h}))&&(d.place_order_type="exit")}return f}_addExitPendingCloseOrders(t){t.place_order_type="exit";const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r){const{limit:n,profit:i,comment_profit:a,comment:l}=r;let c=n;const{close:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h+e*i*this._mintick),t.limit=c,c&&(c-p)*e<=0&&(t.isMarketPriceLimit=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=p,f))return this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r){const{stop:n,loss:i,comment_loss:a,comment:l}=r;let c=n;const{close:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h-e*i*this._mintick),t.stop=c,c&&(c-p)*e>=0&&(t.isMarketPriceStop=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=p,f))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:l,comment:c}=r;if(!this._isNaN(n)){const{close:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;let d;if(this._isNaN(i)?this._isNaN(a)||(d=h+a*e*this._mintick):d=i,t.trail_offset=n,d&&(d-p)*e<=0){const g=p-n*e*this._mintick;if((g-p)*e>=0&&(t.trail_stop_price=p,t.isMarketPriceStop=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment}),f))return this._addExitPendingCloseOrders(r),!0;t.trail_stop_price=g}t.active_price=d}}_processExitOnClose(t,e,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const c=this._processExitOrders(this._orders,e,n,a,i);c&&!c.hasExit?(c.hasExit=!0,Object.assign(t,{trail_stop_price:c.trail_stop_price,stop:c.stop,limit:c.limit,trail_offset:c.trail_offset,active_price:c.active_price})):c&&(t.hasExit=!0)}else t.hasExit=!0,this._processOrders([t],e,n,a,i)}_processExitOrders(t,e,r,n,i){let a=r,l;for(const c of t)if(l=c,a=this._processOrder(c,e,a,n,i),a<=0||!c.hasExit)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_processOrder(t,e,r,n,i,a=!1){const{time:l,bar_index:c}=this._variables,{slippage:p=0}=this._options,{in_price:h,qty:f=0,max_profit:d,trading_loss:g,direction:y,commission:m=0,original_qty:w=0}=t,v=y===ue.long?1:-1;if(e=e-v*p*this._mintick,r<f){const x=f-r,b=(e-h)*v*r,N=d!==void 0?d/f*r:void 0,E=g!==void 0?g/f*r:void 0,A=m*x/w;this._calcPercent({...t,out_price:e,last_commission:A,out_id:n,out_index:c,out_time:l,out_comment:i,profit:b,out_qty:r,max_profit:N,trading_loss:E});const M=(e-h)*v*x-A;Object.assign(t,{qty:x,profit:M,max_profit:d!==void 0?d-(N||0):void 0,trading_loss:g!==void 0?g-(E||0):void 0,total_profit:this._totalChangeCapital+M}),r=0}else{t.isDeal=!0;const x=(e-h)*v*f;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_time:l,out_comment:i,out_qty:f,profit:x}),r-=f}return a&&(v===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t){const{commission_value:e}=this._options,{in_price:r,out_qty:n=0,out_price:i=0,original_qty:a=0,direction:l,last_commission:c=0}=t;let{profit:p=0,max_profit:h,trading_loss:f,commission:d=0}=t,g=r*n,y=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=p,e){const m=this._getCommission(i,n);this._totalChangeCapital-=m;let w=d*n/a;g+=w,w+=m,p=p-w,Object.assign(t,{commission:w,profit:p});const v=this._orders.reduce((x,b)=>{const{qty:N=0,original_qty:E=0,commission:A=0}=b;return x+A*N/E},0);y+=v-c}if(h===void 0||f===void 0){const m=l===ue.long?1:-1,w=this._calcProfitAndLossHandle(r,n,m);if(h=w[0],f=w[1],e){const v=d*n/a;h-=v,f-=v}h=Math.max(0,h),f=Math.min(0,f)}Object.assign(t,{max_profit:h,trading_loss:f,total_profit:this._totalChangeCapital,total_profit_percent:p/y*100,profit_percent:p/g*100,max_profit_percent:h/g*100,trading_loss_percent:f/g*100}),this._risk.intradayOrders+=1,this._historyOrder.push(t)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0}=t;let{profit:l=0}=t,c=r*n;const p=this._totalChangeCapital+this._options.initial_capital;if(e){const h=this._getCommission(r,n);this._totalChangeCapital-=h,l=l-h,c+=h,Object.assign(t,{commission:h,profit:l,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:l/p*100,profit_percent:l/c*100,max_profit_percent:i/c*100,trading_loss_percent:a/c*100}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder)}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}};var rh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){return function(e,r,n){r.prototype.isBetween=function(i,a,l,c){var p=n(i),h=n(a),f=(c=c||"()")[0]==="(",d=c[1]===")";return(f?this.isAfter(p,l):!this.isBefore(p,l))&&(d?this.isBefore(h,l):!this.isAfter(h,l))||(f?this.isBefore(p,l):!this.isAfter(p,l))&&(d?this.isAfter(h,l):!this.isBefore(h,l))}}})})(rh);var ew=rh.exports,rw=Gt(ew),nh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){return function(e,r,n){var i=r.prototype,a=function(d){var g,y=d.date,m=d.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||i.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=m?n.utc():n();Object.keys(y).forEach(function(T){var F,O;w[F=T,O=i.$utils().p(F),O==="date"?"day":O]=y[T]});var x=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),N=w.month>=0?w.month:w.year||w.day?0:v.month(),E=w.hour||0,A=w.minute||0,M=w.second||0,S=w.millisecond||0;return m?new Date(Date.UTC(b,N,x,E,A,M,S)):new Date(b,N,x,E,A,M,S)}return y},l=i.parse;i.parse=function(d){d.date=a.bind(this)(d),l.bind(this)(d)};var c=i.set,p=i.add,h=i.subtract,f=function(d,g,y,m){m===void 0&&(m=1);var w=Object.keys(g),v=this;return w.forEach(function(x){v=d.bind(v)(g[x]*m,x)}),v};i.set=function(d,g){return g=g===void 0?d:g,d.constructor.name==="Object"?f.bind(this)(function(y,m){return c.bind(this)(m,y)},g,d):c.bind(this)(d,g)},i.add=function(d,g){return d.constructor.name==="Object"?f.bind(this)(p,d,g):p.bind(this)(d,g)},i.subtract=function(d,g){return d.constructor.name==="Object"?f.bind(this)(p,d,g,-1):h.bind(this)(d,g)}}})})(nh);var nw=nh.exports,iw=Gt(nw),ih={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e,r,n=1e3,i=6e4,a=36e5,l=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,p=31536e6,h=2628e6,f=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,d={years:p,months:h,days:l,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},g=function(A){return A instanceof N},y=function(A,M,S){return new N(A,S,M.$l)},m=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,M){return A?w(A)?{negative:!0,format:""+x(A)+M}:{negative:!1,format:""+A+M}:{negative:!1,format:""}},N=function(){function A(S,T,F){var O=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),T)return y(S*d[m(T)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(k){O.$d[m(k)]=S[k]}),this.calMilliseconds(),this;if(typeof S=="string"){var R=S.match(f);if(R){var U=R.slice(2).map(function(k){return k!=null?Number(k):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var M=A.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(T,F){return T+(S.$d[F]||0)*d[F]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/p),S%=p,this.$d.months=v(S/h),S%=h,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/i),S%=i,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),T=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var O=b(F,"D"),R=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),k=this.$d.seconds||0;this.$d.milliseconds&&(k+=this.$d.milliseconds/1e3,k=Math.round(1e3*k)/1e3);var W=b(k,"S"),z=S.negative||T.negative||O.negative||R.negative||U.negative||W.negative,K=R.format||U.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+T.format+O.format+K+R.format+U.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},M.toJSON=function(){return this.toISOString()},M.format=function(S){var T=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 T.replace(c,function(O,R){return R||String(F[O])})},M.as=function(S){return this.$ms/d[m(S)]},M.get=function(S){var T=this.$ms,F=m(S);return F==="milliseconds"?T%=1e3:T=F==="weeks"?v(T/d[F]):this.$d[F],T||0},M.add=function(S,T,F){var O;return O=T?S*d[m(T)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+O*(F?-1:1),this)},M.subtract=function(S,T){return this.add(S,T,!0)},M.locale=function(S){var T=this.clone();return T.$l=S,T},M.clone=function(){return y(this.$ms,this)},M.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},M.valueOf=function(){return this.asMilliseconds()},M.milliseconds=function(){return this.get("milliseconds")},M.asMilliseconds=function(){return this.as("milliseconds")},M.seconds=function(){return this.get("seconds")},M.asSeconds=function(){return this.as("seconds")},M.minutes=function(){return this.get("minutes")},M.asMinutes=function(){return this.as("minutes")},M.hours=function(){return this.get("hours")},M.asHours=function(){return this.as("hours")},M.days=function(){return this.get("days")},M.asDays=function(){return this.as("days")},M.weeks=function(){return this.get("weeks")},M.asWeeks=function(){return this.as("weeks")},M.months=function(){return this.get("months")},M.asMonths=function(){return this.as("months")},M.years=function(){return this.get("years")},M.asYears=function(){return this.as("years")},A}(),E=function(A,M,S){return A.add(M.years()*S,"y").add(M.months()*S,"M").add(M.days()*S,"d").add(M.hours()*S,"h").add(M.minutes()*S,"m").add(M.seconds()*S,"s").add(M.milliseconds()*S,"ms")};return function(A,M,S){e=S,r=S().$utils(),S.duration=function(O,R){var U=S.locale();return y(O,{$l:U},R)},S.isDuration=g;var T=M.prototype.add,F=M.prototype.subtract;M.prototype.add=function(O,R){return g(O)?E(this,O,1):T.bind(this)(O,R)},M.prototype.subtract=function(O,R){return g(O)?E(this,O,-1):F.bind(this)(O,R)}}})})(ih);var sw=ih.exports,ow=Gt(sw);ee.extend(Sl),ee.extend(rw),ee.extend(iw),ee.extend(ow);class sh{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 i;const n=((i=t.toString().split(".")[1])==null?void 0:i.length)||5;this._variables=e,this._errorListener=new fw,this.array=new Gp(this._errorListener),this.math=new Hp(n,this._errorListener),this.color=new D1,this.str=new by(this._errorListener,n),this.map=new xy(this._errorListener),this.timeframe=new Dy(e),this.matrix=new wy(this._errorListener),this.ta=new y1(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 w1(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 Ey(e)},this.line=new Zy(e,this._errorListener),this.label=new Ay(e,this._errorListener),this.polyline=new Vy(e,this._errorListener),this.box=new Gy(e,this._errorListener),this.table=new Hy(e,this._errorListener),this.linefill=new Ky(e),this.log=new lw(e),this.runtime=new cw(this._errorListener),this.strategy=new tw(this._variables,this._options,t,this._errorListener,r),this.request=new aw(this._variables,r),this.syminfo=new uw}get errors(){return this._errorListener.errors}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 i;if(n.length){i={};for(const v of n)i[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=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 p=this._plots.size>0?[...this._plots.values()]:void 0,h=this._plotbars.size>0?[...this._plotbars.values()]:void 0,f=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,d=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,m=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:p,draws:m,alerts:r,colors:i,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:d,plotcandles:g,plotchars:y,plotbars:h,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 d of r)n[d]=[...this._bgColors[d].values()].map(g=>{const y=[];for(const m of t){const w=g.colors[m];w&&y.push(w)}return g.colors=y,g})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,l=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()]),p=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,h=this._getDrawsFromBarindex(t),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:h,alerts:e,colors:n,hlines:i,fills:a,logs:l,plotshapes:p,isUseBgColor:f})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const i of t){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:i,label:a}=this._variables,l={};return t.data.length&&(l.lines=t.data),e.data.length&&(l.linefills=e.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),i.data.length&&(l.polylines=i.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:i,polyline:a,label:l}=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)),i.data.length&&(c.boxes=i.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),l.data.length&&(c.labels=l.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}updateOptions(t){const{inputs:e,strategy:r}=t;this.input.update(e),this.strategy.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)?(Kp.includes(n)||Zp.includes(n))&&this._errorListener.addError(Ye(le.libraryTitleIsKeywordErr,{name:n}),e,zt.Error):this._errorListener.addError(le.libraryTitleErr,e,zt.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",[Kt.inherit,Kt.percent,Kt.price,Kt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,i="format"){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(Yp.lineWidthWarning,e,zt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];me(t,r);const{series:n,color:i,...a}=t,{bar_index:l,time:c}=this._variables,p=`plot_${e}`,h=this._plots.get(p),f=(h==null?void 0:h.data)||[],d=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,d],itemStyle:{color:i}},this._seriesColorHandle(t,r,h),!h){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Kt.percent,Kt.price,Kt.volume]);const g=i?[i]:void 0;this._plots.set(p,{editable:!0,...a,colors:g,data:f,id:p,zIndex:this._count})}return{type:"plot",key:p}}plotbar(t,e){const r=["color"];me(t,r);const{open:n,close:i,low:a,high:l,color:c,...p}=t,{bar_index:h,time:f}=this._variables,d=`plotbar_${e}`,g=this._plotbars.get(d),y=(g==null?void 0:g.data)||[],m=i!==void 0&&isNaN(i)?void 0:i,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=l!==void 0&&isNaN(l)?void 0:l,b=[f,w,m,v,x];if(y[h]={value:b,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Kt.percent,Kt.price,Kt.volume]);const N=c?[c]:void 0;this._plotbars.set(d,{editable:!0,...p,colors:N,data:y,id:d,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:i,location:a,style:l}=t;this._paramVerfiy(l,r,e,Object.values(ur),"style"),this._paramVerfiy(a,r,e,Object.values(an),"location"),this._paramVerfiy(n,r,e,Object.values(rr),"size"),this._paramVerfiy(i,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:p,time:h,high:f,low:d}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),m=(y==null?void 0:y.data)||[],w={value:[h,n],itemStyle:{color:i,textcolor:a},low:d,high:f};m[p]=w,this._seriesColorHandle(t,r,y),y||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:l,data:m,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];me(t,r);const{series:n,colorup:i,colordown:a,...l}=t,{bar_index:c,time:p}=this._variables,h=`plotarrow_${e}`,f=this._plotarrows.get(h),d=(f==null?void 0:f.data)||[];d[c]={value:[p,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(t,r,f),f||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Kt.percent,Kt.price,Kt.volume]),this._plotarrows.set(h,{editable:!0,...l,data:d,id:h,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:p,time:h,low:f,high:d}=this._variables,g=`plotshape_${e}`,y=this._plotshapes.get(g),m=(y==null?void 0:y.data)||[],w={value:n,color:i,textcolor:a,time:h,low:f,high:d};if(m[p]=w,this._seriesColorHandle(t,r,y),!y){this._count++;const v=i?[i]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:m,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];me(t,r);const{wickcolor:n,bordercolor:i,color:a,close:l,open:c,low:p,high:h,...f}=t,{bar_index:d,time:g}=this._variables,y=`plotcandle_${e}`,m=this._plotcandles.get(y),w=(m==null?void 0:m.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,x=c!==void 0&&isNaN(c)?void 0:c,b=p!==void 0&&isNaN(p)?void 0:p,N=h!==void 0&&isNaN(h)?void 0:h,E=[g,x,v,b,N];w[d]={value:E,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(t,r,m),m||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Kt.percent,Kt.price,Kt.volume]),this._plotcandles.set(y,{editable:!0,...f,data:w,id:y,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;me(t,["color"]),this._verifyDisplay(t.display,"hline",e);const i=t.display&&!t.display.length?Ve.none:Ve.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,T,F,O,R,U,k,W,z,K;const r=["color","top_color","bottom_color"];me(t,r);const{color:n,top_color:i,bottom_color:a,seriesColors:l,hline1:c,hline2:p,plot1:h,plot2:f,top_value:d,bottom_value:g,...y}=t,{bar_index:m,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 N=t.display&&!t.display.length?Ve.none:Ve.all;let E,A,M="plot";if(c&&p)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,A=(T=this._hlines.get(p==null?void 0:p.key))==null?void 0:T.price,M="hline";else{const Z=((F=this._plots.get(h==null?void 0:h.key))==null?void 0:F.data)||[],X=((O=this._plots.get(f==null?void 0:f.key))==null?void 0:O.data)||[];E=(U=(R=Z[m])==null?void 0:R.value)==null?void 0:U[1],A=(W=(k=X[m])==null?void 0:k.value)==null?void 0:W[1]}if(b[m]={time:w,color:n,top_color:i,bottom_color:a,plot1:E,plot2:A,top_value:d,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=i?[i]:void 0,ct=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ct,display:N,data:b,type:M,editable:!0,fillgaps:!1,hline1:c,hline2:p,plot1:h,plot2:f,...y,zIndex:Z?this._count:void 0})}}alert({message:t,freq:e=kr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},p=c.barIndex;if(this._paramVerfiy(e,r,"alert",[kr.freqAll,kr.freqOncePerBar,kr.freqOncePerBarClose]),e===kr.freqOncePerBar&&n===p){this._alerts.delete(l);return}this._cacheData[l]=c;const h={message:t,freq:e,id:l,type:"alert"};if(i){e!==kr.freqOncePerBarClose&&this._alerts.set(l,h),c.barIndex=n;return}if(!i&&e===kr.freqOncePerBarClose&&n===p&&a===n-1){this._alerts.set(l,h),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&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=Xf.all,e,r){t.length&&t.length<4&&this._errorListener.addError(Ye(le.displayErr,{func:e,values:"[display.none, display.all]"}),r,zt.Error)}_setColors(t,e,r){me(t,["color"]);const{color:i,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?Ve.none:Ve.all,{bar_index:c,time:p}=this._variables,h=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const f=this._bgColors[e].get(h),d=(f==null?void 0:f.colors)||[],g=(f==null?void 0:f.setColors)||[];i&&!g.includes(i)&&g.push(i),d[c]={color:i,time:p},f||this._bgColors[e].set(h,{...a,display:l,colors:d,setColors:g,id:h})}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},i){return this._timeHandle(this._variables.time,i,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,t,e,r,n)}timestamp(t){const{dateString:e,timezone:r,year:n,month:i,day:a,hour:l=0,minute:c=0,second:p=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let h=i-1,f=n;if(h<0){const g=Math.ceil(Math.abs(h/12));h=12*g+h,f=n-g}let d=ee({year:f,month:h,day:a,hour:l,minute:c,second:p});return r&&(d=qr(d.utc(!0).valueOf(),r)),d.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return qr(t,e).week()}year({time:t,timezone:e}){return qr(t,e).year()}second({time:t,timezone:e}){return qr(t,e).second()}month({time:t,timezone:e}){return qr(t,e).month()+1}minute({time:t,timezone:e}){return qr(t,e).minute()}hour({time:t,timezone:e}){return qr(t,e).hour()}dayofweek({time:t,timezone:e}){return qr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return qr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Qr(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,i,a=0){const l=r||this._variables.timeframe.period,c=Qr(l),p=Qr(this._variables.timeframe.period);let h;if(c<=p)h=t;else{const f=`time_${e}`,d=this._cacheData[f];if(d)d.currentTime+c*1e3-d.offset<=t?(h=t,this._cacheData[f]={currentTime:t,offset:0}):h=d;else{const g=this._calcTimeOffset(t,l);this._cacheData[f]={currentTime:t,offset:g},h=t}}if(n){const{timePeriods:f,weeks:d}=this._parserSession(n,e),g=ee(t).format("YYYY-MM-DD"),y=h;h=void 0;for(const w of f){const[v,x]=w;if(ee(t).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")){ee(y).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")?h=y:h=ee(`${g} ${v}`).valueOf();break}}const m=this._variables.dayofweek;h&&!d.includes(m)&&(h=void 0)}return i&&(h=h&&qr(h,i).valueOf()),h&&h-a*p*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const i of e){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=t[i];if(!a)continue;const l=r[`${i}s`]||[];l.includes(a)||(l.push(a),r[`${i}s`]=l,l.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const p=parseInt(c,10);if(p<1||p>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,zt.Error);return}return p});return{timePeriods:n.split(",").map(c=>{c===""||c===fi.regular?c="0930-1500":c===fi.extended&&(c="1500-1830");const p=c.split("-");return p.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,zt.Error),[]):[this._processTime(p[0],e),this._processTime(p[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,zt.Error);return}return`${r}:${n}`}}class aw{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,i=this._getRequestData(t,e);if(r!=null&&r.has(e)){const c=r.get(e);return this._runScripts(c,e,!1,n,i)}const a=this._parseExprCode(t),l=this._runScripts(a,e,!0,n,i);return r==null||r.set(e,a),l}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],i=1;e=Il(e);const a=JSON.parse(e),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},p=(l==null?void 0:l.depends)||[];if(!p.length)return`return ${l==null?void 0:l.code}`;let h=[],f=[];const d=[];if(this._getDependCodes(p,a,n,h,f,d),f.length){const m=r.length;let w=[];for(let v=m-1;v>=0;v--){const x=r[v];let b=JSON.parse(Il(x));const N=[];i!==0&&f.length&&(w.unshift("{"),i++),b=b.map(S=>{const{scope:T,code:F,varNames:O,dependSelf:R}=S;return T===2&&!N.includes(O)&&!R&&(S.code=`let ${F}`),O&&N.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],A=[];let M=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(M,b,A,h,f,E),w.unshift(...A,...E),n=w.concat(n),w=[]}}for(n.push(`return ${l==null?void 0:l.code}`);i>1;)n.push("}"),i--;n=h.concat(n),n.push(...d);let g=n.join(`
|
63
63
|
`);const y=[];for(const m of Object.keys(c))g.includes(`$_var.getCacheData("${m}"`)&&y.push(c[m]);return y.length&&(g=`${y.join(`
|
64
64
|
`)}
|
65
|
-
${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:i}=t;const a=self.workerStorage.get(`request_${this._scriptId}_data`),l=`${r}--${n}`;if(a!=null&&a.has(l)){const{index:c=0,periodStamp:h=Qr(this._variables.__period)*1e3}=this._cacheData.get(e)||{},p=(a.get(l)||[]).slice(c),f=this._variables.time,d=h+f;for(const[g,y]of p.entries()){const{timestamp:m,close:w,open:v,high:x,low:b,volume:N}=y;let E=m*1e3;if(E>=d){this._cacheData.set(e,{index:g,periodStamp:h});return}if(E>=f)return this._cacheData.set(e,{index:g+1,periodStamp:h}),{close:Number(w),open:Number(v),high:Number(x),low:Number(b),timestamp:m,volume:N}}this._cacheData.set(e,{index:p.length,periodStamp:h})}else{const c=self.workerStorage.get(`request_${this._scriptId}_list`);(c==null?void 0:c.get(l))||c==null||c.set(l,{id:l,calc_bars_count:i,symbol:r,timeframe:n})}}_getDependCodes(t,e,r,n,i,a){for(const l of t){if(!l.isArg){const c=e.filter(p=>{var f;return(f=p==null?void 0:p.depends)==null?void 0:f.some(d=>d.name===l.name&&d.scope===l.scope&&d.isAgainAssign)});for(const p of c){const{code:f,depends:d}=p;if(!r.includes(f)&&(r.unshift(f),d!=null&&d.length)){for(const g of d)g.memberCode&&a.push(g.memberCode);this._getDependCodes(d,e,r,n,i,a)}}const h=e.find(p=>{var f;return((f=p.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&p.methodName===l.functionName)||p.funcName===l.name});if(h){const{code:p,depends:f}=h,d=r.findIndex(g=>g===p);if(d!==-1&&r.splice(d,1),r.unshift(p),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,e,r,n,i,a)}continue}}i.some(c=>c.name===l.name)||i.push(l)}}_runScripts(t,e,r,n,i){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:p}=self.workerStorage.get(a)||{};return r&&(l=new oh(a),c=new Qf,h=new sh(this._variables.mintick||1e-5,l,this._scriptId),p=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:p})),p(l,c,h,n||[],e)}}let uw=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 lw{constructor(t){$(this,"_logs");$(this,"_variables");$(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}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:i,formatString:a}=t,{time:l,bar_index:c}=this._variables;let h=i;a&&Array.isArray(e)&&e.length&&(h=a.replace(/{(\d+)}/g,(p,f)=>{let d=e[f];return typeof d=="number"&&(d=this._intlFormat.format(parseFloat(d.toFixed(3)))),typeof d=="object"&&(d.isArray?d=JSON.stringify(d._value):d=d.toString()),d!==void 0?d:p})),h&&this._logs.push({message:`[${ee(l).format()}]: ${h}`,time:l,barIndex:c,type:r})}}class cw{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class fw{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Xr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[i,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(i),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(i),type:r};l?l.push(c):this._errors.set(e,[c])}}class hw{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}}class pw{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 t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class dw{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,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossloss_percent",0);$(this,"_grossprofit",0);$(this,"_grossprofit_percent",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(){this._calcMaxDrawdownAndMaxRunup()}_calcMaxDrawdownAndMaxRunup(){let t=0,e=0;const{high:r,low:n,close:i}=this._variables;let a=0,l=this._netprofit;for(const g of this._orders){const{in_price:y,qty:m=0,commission:w=0,original_qty:v=0,direction:x,profit:b=0}=g,N=x===ue.long?1:-1,E=(r-y)*m,C=(n-y)*m,M=this._getCommission(i,m),S=w*m/v,T=N===1?E:-C,F=N===1?-C:E;a+=b+S+M,t+=F+S,e+=T,l+=S}this._openprofit=a;const c=this.initial_capital,[h,p]=this._historyOrders.reduce((g,y)=>{let[m,w]=g;const{profit:v=0,total_profit:x=0}=y;return m+=v,w=Math.min(x+c,w),[m,w]},[0,c]);t-=h,e=c+l-p+e;const f=t/this.initial_capital*100;this._max_drawdown<t&&(this._max_drawdown=t),f>this._max_drawdown_percent&&(this._max_drawdown_percent=f);const d=e/(this.initial_capital+l)*100;e>this._max_runup&&(this._max_runup=e),d>this._max_runup_percent&&(this._max_runup_percent=d)}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,i,a,l,c]=this._orders.reduce(([h,p,f,d,g,y,m],w)=>{const{direction:v,qty:x=0,in_price:b,commission:N=0}=w;return v===ue.long?(h+=x,p+=x,y+=x):(h+=x,f+=x,y-=x),d+=x*b,g+=b,m+=N,[h,p,f,d,g,y,m]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=i,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,i,a,l,c]=this._historyOrders.reduce((p,f)=>{let[d,g,y,m,w,v]=p;const{profit:x=0,profit_percent:b=0}=f;return d+=x,g+=b,x<0?(y+=x,m+=b):(w+=x,v+=b),[d,g,y,m,w,v]},[0,0,0,0,0,0]),h=this._orders.reduce((p,f)=>{const{commission:d=0,qty:g=0,original_qty:y=0}=f,m=d*g/y;return p+m},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-h,this._grossloss=i-h,this._grossprofit=l,this._eventrades=this._historyOrders.filter(p=>p.profit===0).length,this._losstrades=this._historyOrders.filter(p=>(p.profit||0)<0).length,this._wintrades=this._historyOrders.filter(p=>(p.profit||0)>0).length}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(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}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(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}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:i=0}=this._options,a=this._orders[0].direction===ue.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[h,p]=this._orders.reduce((f,d)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=d,x=m*w;if(g+=x,i){let b=0;switch(n){case nr.percent:b=(x+w*c)*i/100;break;case nr.cashPerContract:b=w*i*2;break;case nr.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(h-(t+this._netprofit-p))*a/this._position_size/(1-a*l)}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,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}}class _w{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 i=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=i),this._preValue.accdist=i,i}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,i=(2*t-r-e)/((r-e)*n);return this._preValue.iii=i,i}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:i}=this._currentData,a=(t-i)/(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 i=Math.max(e,n),a=Math.min(r,n),l=t-n,h=(l>0?t-a:l<0?t-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=h),this._preValue.wad=h,h}get vwap(){var p,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:i}=this._preVwap;if(((f=(p=self.workerStorage)==null?void 0:p.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(i=!0,r=n=0),!i)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:i});const h=l/c;return this._preValue.vwap=h,h}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i<r?l+(n-e)/e*l:l:a=l,!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:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class mw{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]=ys(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 gw{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,i;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?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_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 vw{constructor(t){$(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return fi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){}get tickerid(){}get timezone(){}get type(){}get volumetype(){return"n/a"}}class yw{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class ww{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(Wp),ee.extend(Sl),ee.extend(kp);class oh{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._cacheData={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 hw,this._timeframe=new mw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new _w(t),this._polyline=new Fi,this._label=new Fi,this._line=new Fi,this._linefill=new Fi,this._box=new Fi,this._table=new Fi(1),this._strategy=new dw(this),this._session=new pw(this),this.syminfo=new vw(this),this.chart=new gw(this),this.earnings=new ww(this),this.dividends=new yw(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 ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()+1}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=ys(this._period);return this._isRealTimeBar?void 0:ee(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}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:i}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),i&&this._polyline.setMaxLen(i)}getTimeTradingday(t,e){const[r,n]=ys(e),i=ee(t);return["M","w","y","d"].includes(n)?i.valueOf():(i.subtract(this._offsetTime,"h"),i.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){const{interval:e="1D",offsetTime:r=5,mintick:n,chart:i}=t;this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(i)}updateData(t){const{barIndex:e,c:r,o:n,h:i,l:a,volume:l,time:c,lastBarIndex:h,lastBarTime:p,complete:f,time_tradingday:d}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(i),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._timeTradingday=d,this._currentBarTime=c*1e3,this._lastBarIndex=h,this._barIndex=e,this._lastBarTime=p*1e3,this._barstate.update(e,h,f,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<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 Rp(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}`;return r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const i=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[i]||this._cacheData.varipData[i]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[i]=r,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=r[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Fe.BOX:this._setChartDraw(e,this._box);break;case Fe.LINE:this._setChartDraw(e,this._line);break;case Fe.POLYLINE:this._setChartDraw(e,this._polyline);break;case Fe.LABEL:this._setChartDraw(e,this._label);break;case Fe.LINEFILL:this._setChartDraw(e,this._linefill);break;case Fe.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t);e.delete(t),e.set(t,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)?Xr.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)}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 ao.name:case th.name:case co.name:case eh.name:case uo.name:case lo.name:t==null||t.delete();break}}}class Fi{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}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[i,a]of this._all){const{isVar:l,id:c,bar_index:h}=a;if(h===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const i=r.filter(a=>a.endsWith(`_${n}`));for(const a of i){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}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){this._all.delete(t),this._allInstance.delete(t)}}/**
|
65
|
+
${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:i}=t;const{__period:a,syminfo:{ticker:l,tickerid:c},mintick:p}=this._variables;if((n===a||n==="")&&(r===l||r===c)){const{close:g,open:y,high:m,low:w,bar_index:v,last_bar_index:x,last_bar_time:b,_isRealTimeBar:N,volume:E,time:A,time_tradingday:M}=this._variables;return{barIndex:v,c:g,o:y,h:m,l:w,volume:E,lastBarIndex:x,lastBarTime:b/1e3,complete:N,time_tradingday:M,time:A/1e3,interval:a,mintick:p}}const h=`${r}--${n||a}`,f=self.workerStorage.get(`request_${this._scriptId}_data`),d=self.workerStorage.get(`request_${this._scriptId}_list`);if(f!=null&&f.has(h)){d==null||d.delete(h);const{index:g=0,periodStamp:y=Qr(this._variables.__period)*1e3}=this._cacheData.get(e)||{},m=(f.get(h)||[]).slice(g),w=this._variables.time,v=y+w,x=m.length-1,b={lastBarIndex:m[x].barindex||x,lastBarTime:m[x].time,interval:a,mintick:p};for(const[N,E]of m.entries()){let{time:A,barindex:M}=E;if(A=A*1e3,A>=v){this._cacheData.set(e,{index:N,periodStamp:y});return}if(A>=w)return this._cacheData.set(e,{index:N+1,periodStamp:y}),{...E,barIndex:M||N,...b}}this._cacheData.set(e,{index:m.length,periodStamp:y})}else(d==null?void 0:d.get(h))||d==null||d.set(h,{id:h,calc_bars_count:i,symbol:r,timeframe:n||a})}_getDependCodes(t,e,r,n,i,a){for(const l of t){if(!l.isArg){const c=e.filter(h=>{var f;return(f=h==null?void 0:h.depends)==null?void 0:f.some(d=>d.name===l.name&&d.scope===l.scope&&d.isAgainAssign)});for(const h of c){const{code:f,depends:d}=h;if(!r.includes(f)&&(r.unshift(f),d!=null&&d.length)){for(const g of d)g.memberCode&&a.push(g.memberCode);this._getDependCodes(d,e,r,n,i,a)}}const p=e.find(h=>{var f;return((f=h.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&h.methodName===l.functionName)||h.funcName===l.name});if(p){const{code:h,depends:f}=p,d=r.findIndex(g=>g===h);if(d!==-1&&r.splice(d,1),r.unshift(h),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,e,r,n,i,a)}continue}}i.some(c=>c.name===l.name)||i.push(l)}}_runScripts(t,e,r,n,i){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h}=self.workerStorage.get(a)||{};const{interval:f,mintick:d,...g}=i||{};r&&(l=new oh(a),c=new Qf,p=new sh(this._variables.mintick||1e-5,l,this._scriptId),h=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),l.updateOptions({interval:f,mintick:d||1e-5}),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h})),l.updateData(g),p.update({barIndex:(g==null?void 0:g.barindex)||0});const y=h(l,c,p,n||[],e);return p.endExecution(),y}}let uw=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 lw{constructor(t){$(this,"_logs");$(this,"_variables");$(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}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:i,formatString:a}=t,{time:l,bar_index:c}=this._variables;let p=i;a&&Array.isArray(e)&&e.length&&(p=a.replace(/{(\d+)}/g,(h,f)=>{let d=e[f];return typeof d=="number"&&(d=this._intlFormat.format(parseFloat(d.toFixed(3)))),typeof d=="object"&&(d.isArray?d=JSON.stringify(d._value):d=d.toString()),d!==void 0?d:h})),p&&this._logs.push({message:`[${ee(l).format()}]: ${p}`,time:l,barIndex:c,type:r})}}class cw{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class fw{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Xr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[i,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(i),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(i),type:r};l?l.push(c):this._errors.set(e,[c])}}class hw{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}}class pw{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 t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class dw{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,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossloss_percent",0);$(this,"_grossprofit",0);$(this,"_grossprofit_percent",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(){this._calcMaxDrawdownAndMaxRunup()}_calcMaxDrawdownAndMaxRunup(){let t=0,e=0;const{high:r,low:n,close:i}=this._variables;let a=0,l=this._netprofit;for(const g of this._orders){const{in_price:y,qty:m=0,commission:w=0,original_qty:v=0,direction:x,profit:b=0}=g,N=x===ue.long?1:-1,E=(r-y)*m,A=(n-y)*m,M=this._getCommission(i,m),S=w*m/v,T=N===1?E:-A,F=N===1?-A:E;a+=b+S+M,t+=F+S,e+=T,l+=S}this._openprofit=a;const c=this.initial_capital,[p,h]=this._historyOrders.reduce((g,y)=>{let[m,w]=g;const{profit:v=0,total_profit:x=0,last_commission:b=0}=y;return m+=v,w=Math.min(x+b+c,w),[m,w]},[0,c]);t-=p,e=c+l-h+e;const f=t/this.initial_capital*100;this._max_drawdown<t&&(this._max_drawdown=t),f>this._max_drawdown_percent&&(this._max_drawdown_percent=f);const d=e/this.initial_capital*100;e>this._max_runup&&(this._max_runup=e),d>this._max_runup_percent&&(this._max_runup_percent=d)}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,i,a,l,c]=this._orders.reduce(([p,h,f,d,g,y,m],w)=>{const{direction:v,qty:x=0,in_price:b,commission:N=0}=w;return v===ue.long?(p+=x,h+=x,y+=x):(p+=x,f+=x,y-=x),d+=x*b,g+=b,m+=N,[p,h,f,d,g,y,m]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=i,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,i,a,l,c]=this._historyOrders.reduce((h,f)=>{let[d,g,y,m,w,v]=h;const{profit:x=0,profit_percent:b=0}=f;return d+=x,g+=b,x<0?(y+=x,m+=b):(w+=x,v+=b),[d,g,y,m,w,v]},[0,0,0,0,0,0]),p=this._orders.reduce((h,f)=>{const{commission:d=0,qty:g=0,original_qty:y=0}=f,m=d*g/y;return h+m},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-p,this._grossloss=i-p,this._grossprofit=l,this._eventrades=this._historyOrders.filter(h=>h.profit===0).length,this._losstrades=this._historyOrders.filter(h=>(h.profit||0)<0).length,this._wintrades=this._historyOrders.filter(h=>(h.profit||0)>0).length}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(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}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(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}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:i=0}=this._options,a=this._orders[0].direction===ue.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[p,h]=this._orders.reduce((f,d)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=d,x=m*w;if(g+=x,i){let b=0;switch(n){case nr.percent:b=(x+w*c)*i/100;break;case nr.cashPerContract:b=w*i*2;break;case nr.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(p-(t+this._netprofit-h))*a/this._position_size/(1-a*l)}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,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}}class _w{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 i=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=i),this._preValue.accdist=i,i}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,i=(2*t-r-e)/((r-e)*n);return this._preValue.iii=i,i}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:i}=this._currentData,a=(t-i)/(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 i=Math.max(e,n),a=Math.min(r,n),l=t-n,p=(l>0?t-a:l<0?t-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=p),this._preValue.wad=p,p}get vwap(){var h,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:i}=this._preVwap;if(((f=(h=self.workerStorage)==null?void 0:h.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(i=!0,r=n=0),!i)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:i});const p=l/c;return this._preValue.vwap=p,p}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i<r?l+(n-e)/e*l:l:a=l,!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:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class mw{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]=ys(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 gw{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,i;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?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_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 vw{constructor(t){$(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return fi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){return""}get tickerid(){return""}get timezone(){}get type(){}get volumetype(){return"n/a"}}class yw{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class ww{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(Wp),ee.extend(Sl),ee.extend(kp);class oh{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._cacheData={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 hw,this._timeframe=new mw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new _w(t),this._polyline=new Fi,this._label=new Fi,this._line=new Fi,this._linefill=new Fi,this._box=new Fi,this._table=new Fi(1),this._strategy=new dw(this),this._session=new pw(this),this.syminfo=new vw(this),this.chart=new gw(this),this.earnings=new ww(this),this.dividends=new yw(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 ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()+1}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=ys(this._period);return this._isRealTimeBar?void 0:ee(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}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:i}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),i&&this._polyline.setMaxLen(i)}getTimeTradingday(t,e){const[r,n]=ys(e),i=ee(t);return["M","w","y","d"].includes(n)?i.valueOf():(i.subtract(this._offsetTime,"h"),i.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){const{interval:e="1D",offsetTime:r=5,mintick:n,chart:i}=t;this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(i)}updateData(t){const{barIndex:e,c:r,o:n,h:i,l:a,volume:l,time:c,lastBarIndex:p,lastBarTime:h,complete:f,time_tradingday:d}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(i),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._timeTradingday=d,this._currentBarTime=c*1e3,this._lastBarIndex=p,this._barIndex=e,this._lastBarTime=h*1e3,this._barstate.update(e,p,f,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<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 Rp(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}`;return r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const i=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[i]||this._cacheData.varipData[i]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[i]=r,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=r[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Fe.BOX:this._setChartDraw(e,this._box);break;case Fe.LINE:this._setChartDraw(e,this._line);break;case Fe.POLYLINE:this._setChartDraw(e,this._polyline);break;case Fe.LABEL:this._setChartDraw(e,this._label);break;case Fe.LINEFILL:this._setChartDraw(e,this._linefill);break;case Fe.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t);e.delete(t),e.set(t,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)?Xr.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)}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 ao.name:case th.name:case co.name:case eh.name:case uo.name:case lo.name:t==null||t.delete();break}}}class Fi{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}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[i,a]of this._all){const{isVar:l,id:c,bar_index:p}=a;if(p===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const i=r.filter(a=>a.endsWith(`_${n}`));for(const a of i){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}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){this._all.delete(t),this._allInstance.delete(t)}}/**
|
66
66
|
* @license
|
67
67
|
* Copyright 2019 Google LLC
|
68
68
|
* SPDX-License-Identifier: Apache-2.0
|
69
|
-
*/const ah=Symbol("Comlink.proxy"),Dw=Symbol("Comlink.endpoint"),bw=Symbol("Comlink.releaseProxy"),Ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),uh=s=>typeof s=="object"&&s!==null||typeof s=="function",xw={canHandle:s=>uh(s)&&s[ah],serialize(s){const{port1:t,port2:e}=new MessageChannel;return Wa(s,t),[e,[e]]},deserialize(s){return s.start(),Fw(s)}},Ew={canHandle:s=>uh(s)&&fo in s,serialize({value:s}){let t;return s instanceof Error?t={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:t={isError:!1,value:s},[t,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},lh=new Map([["proxy",xw],["throw",Ew]]);function Aw(s,t){for(const e of s)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Wa(s,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Aw(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Qn);let
|
69
|
+
*/const ah=Symbol("Comlink.proxy"),Dw=Symbol("Comlink.endpoint"),bw=Symbol("Comlink.releaseProxy"),Ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),uh=s=>typeof s=="object"&&s!==null||typeof s=="function",xw={canHandle:s=>uh(s)&&s[ah],serialize(s){const{port1:t,port2:e}=new MessageChannel;return Wa(s,t),[e,[e]]},deserialize(s){return s.start(),Fw(s)}},Ew={canHandle:s=>uh(s)&&fo in s,serialize({value:s}){let t;return s instanceof Error?t={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:t={isError:!1,value:s},[t,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},lh=new Map([["proxy",xw],["throw",Ew]]);function Aw(s,t){for(const e of s)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Wa(s,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Aw(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Qn);let p;try{const h=l.slice(0,-1).reduce((d,g)=>d[g],s),f=l.reduce((d,g)=>d[g],s);switch(a){case"GET":p=f;break;case"SET":h[l.slice(-1)[0]]=Qn(n.data.value),p=!0;break;case"APPLY":p=f.apply(h,c);break;case"CONSTRUCT":{const d=new f(...c);p=Ow(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;Wa(s,g),p=Bw(d,[d])}break;case"RELEASE":p=void 0;break;default:return}}catch(h){p={value:h,[fo]:0}}Promise.resolve(p).catch(h=>({value:h,[fo]:0})).then(h=>{const[f,d]=mo(h);t.postMessage(Object.assign(Object.assign({},f),{id:i}),d),a==="RELEASE"&&(t.removeEventListener("message",r),ch(t),Ua in s&&typeof s[Ua]=="function"&&s[Ua]())}).catch(h=>{const[f,d]=mo({value:new TypeError("Unserializable return value"),[fo]:0});t.postMessage(Object.assign(Object.assign({},f),{id:i}),d)})}),t.start&&t.start()}function Cw(s){return s.constructor.name==="MessagePort"}function ch(s){Cw(s)&&s.close()}function Fw(s,t){return ja(s,[],t)}function ho(s){if(s)throw new Error("Proxy has been released and is not useable")}function fh(s){return Mi(s,{type:"RELEASE"}).then(()=>{ch(s)})}const po=new WeakMap,_o="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const t=(po.get(s)||0)-1;po.set(s,t),t===0&&fh(s)});function Mw(s,t){const e=(po.get(t)||0)+1;po.set(t,e),_o&&_o.register(s,t,s)}function Nw(s){_o&&_o.unregister(s)}function ja(s,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(i,a){if(ho(r),a===bw)return()=>{Nw(n),fh(s),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=Mi(s,{type:"GET",path:t.map(c=>c.toString())}).then(Qn);return l.then.bind(l)}return ja(s,[...t,a])},set(i,a,l){ho(r);const[c,p]=mo(l);return Mi(s,{type:"SET",path:[...t,a].map(h=>h.toString()),value:c},p).then(Qn)},apply(i,a,l){ho(r);const c=t[t.length-1];if(c===Dw)return Mi(s,{type:"ENDPOINT"}).then(Qn);if(c==="bind")return ja(s,t.slice(0,-1));const[p,h]=hh(l);return Mi(s,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:p},h).then(Qn)},construct(i,a){ho(r);const[l,c]=hh(a);return Mi(s,{type:"CONSTRUCT",path:t.map(p=>p.toString()),argumentList:l},c).then(Qn)}});return Mw(n,s),n}function Sw(s){return Array.prototype.concat.apply([],s)}function hh(s){const t=s.map(mo);return[t.map(e=>e[0]),Sw(t.map(e=>e[1]))]}const ph=new WeakMap;function Bw(s,t){return ph.set(s,t),s}function Ow(s){return Object.assign(s,{[ah]:!0})}function mo(s){for(const[t,e]of lh)if(e.canHandle(s)){const[r,n]=e.serialize(s);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:s},ph.get(s)||[]]}function Qn(s){switch(s.type){case"HANDLER":return lh.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Mi(s,t,e){return new Promise(r=>{const n=Iw();s.addEventListener("message",function i(a){!a.data||!a.data.id||a.data.id!==n||(s.removeEventListener("message",i),r(a.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:n},t),e)})}function Iw(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class Tw{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()}}function $w(s,t,e){var x;const{data:r,isPreParser:n,id:i="default",syminfo:a,interval:l,inputs:c,chart:p,strategy:h}=t;self.workerStorage||(self.workerStorage=new Tw);let{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}=self.workerStorage.get(i)||{},m=[];e&&(f=new oh(i),d=new Qf,g=new sh((a==null?void 0:a.mintick)||1e-5,f,i),y=new Function("$_var","$_const","$_func",s),self.workerStorage.set(i,{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}),self.workerStorage.set(`request_${i}`,new Map),self.workerStorage.set(`request_${i}_data`,new Map),self.workerStorage.set(`request_${i}_list`,new Map));let w=[];if(n)y(f,d,g);else if(r&&r.length){const b=r.length-1;f.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:p}),g.updateOptions({inputs:c,strategy:h});try{for(const[N,E]of r.entries()){const{barindex:A}=E;!e&&(A||A===0)&&(m.push(A),f.clearDrawCache(A)),f.updateData(Object.assign(E,{barIndex:A||N,lastBarIndex:r[b].barindex||b,lastBarTime:r[b].time})),g.update({barIndex:A||N}),y(f,d,g),g.endExecution();const M=g.errors;if(M.length&&M.some(S=>S.type===zt.Error))return{status:1,errors:M}}w=[...((x=self.workerStorage.get(`request_${i}_list`))==null?void 0:x.values())||[]],w.length&&self.workerStorage.delete(`request_${i}_list`)}catch(N){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:N==null?void 0:N.message,type:zt.Error}]}}}const v=g.errors;return v.length&&v.some(b=>b.type===zt.Error)?{status:1,errors:v}:{status:0,requestList:w,errors:v,options:{...g.options(m),id:i}}}function Lw(s){self==null||self.workerStorage.deleteStartwidthKey(s),self==null||self.workerStorage.delete(`inputs_${s}`),self==null||self.workerStorage.delete(`strategy_${s}`),self==null||self.workerStorage.delete(`request_${s}`),self==null||self.workerStorage.delete(`request_${s}_data`),self==null||self.workerStorage.delete(`request_${s}_list`)}Wa({runScript:$w,removeScript:Lw})})();
|