@guihz/trading-vue-editor-tes 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/assets/editor.worker-CT5Cb1wO.js +11 -0
- package/lib/assets/{parserTccWorker-cJ5nOv5I.js → parserTccWorker-BhMZL9OL.js} +39 -38
- package/lib/assets/scriptsRunWorker-DHT6psBx.js +66 -0
- package/lib/components/editor/parseScript/buildInConstants.d.ts +51 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/box.d.ts +99 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/chartPoint.d.ts +27 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/index.d.ts +9 -1
- package/lib/components/editor/parseScript/buildInFuncNamespace/label.d.ts +77 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/line.d.ts +81 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/linefill.d.ts +37 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/polyline.d.ts +31 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/ta.d.ts +4 -3
- package/lib/components/editor/parseScript/buildInFuncNamespace/table.d.ts +94 -0
- package/lib/components/editor/parseScript/constants.d.ts +3 -0
- package/lib/components/editor/parseScript/type.d.ts +1 -0
- package/lib/components/editor/parseScript/visitorParser.d.ts +2 -0
- package/lib/components/editor/type/index.d.ts +2 -0
- package/lib/trading-vue-editor.js +1876 -1852
- package/lib/trading-vue-editor.umd.cjs +32 -32
- package/package.json +1 -1
- package/lib/assets/scriptsRunWorker-B4O7gGzE.js +0 -66
- package/lib/components/editor/parseScript/buildInVariables.d.ts +0 -124
@@ -1,66 +0,0 @@
|
|
1
|
-
var eF=Object.defineProperty;var rF=(kt,Zt,De)=>Zt in kt?eF(kt,Zt,{enumerable:!0,configurable:!0,writable:!0,value:De}):kt[Zt]=De;var ut=(kt,Zt,De)=>(rF(kt,typeof Zt!="symbol"?Zt+"":Zt,De),De),hf=(kt,Zt,De)=>{if(!Zt.has(kt))throw TypeError("Cannot "+De)};var Tr=(kt,Zt,De)=>(hf(kt,Zt,"read from private field"),De?De.call(kt):Zt.get(kt)),pf=(kt,Zt,De)=>{if(Zt.has(kt))throw TypeError("Cannot add the same private member more than once");Zt instanceof WeakSet?Zt.add(kt):Zt.set(kt,De)},ju=(kt,Zt,De,Fn)=>(hf(kt,Zt,"write to private field"),Fn?Fn.call(kt,De):Zt.set(kt,De),De);var df=(kt,Zt,De)=>(hf(kt,Zt,"access private method"),De);(function(){"use strict";var Li,mf,ci,ze;var kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function De(i){if(i.__esModule)return i;var t=i.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),e}var Fn={exports:{}};/**
|
2
|
-
* @license
|
3
|
-
* Lodash <https://lodash.com/>
|
4
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
5
|
-
* Released under MIT license <https://lodash.com/license>
|
6
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
7
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
8
|
-
*/Fn.exports,function(i,t){(function(){var e,r="4.17.21",n=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",f="Invalid `variable` option passed into `_.template`",l="__lodash_hash_undefined__",p=500,h="__lodash_placeholder__",c=1,m=2,w=4,D=1,v=2,y=1,g=2,A=4,E=8,S=16,C=32,M=64,x=128,N=256,$=512,F=30,I="...",R=800,q=16,U=1,W=2,P=3,G=1/0,j=9007199254740991,H=17976931348623157e292,V=NaN,ct=4294967295,gt=ct-1,ft=ct>>>1,_t=[["ary",x],["bind",y],["bindKey",g],["curry",E],["curryRight",S],["flip",$],["partial",C],["partialRight",M],["rearg",N]],yt="[object Arguments]",Nt="[object Array]",Et="[object AsyncFunction]",ee="[object Boolean]",It="[object Date]",xt="[object DOMException]",ie="[object Error]",Xt="[object Function]",zt="[object GeneratorFunction]",Gt="[object Map]",Fe="[object Number]",er="[object Null]",xe="[object Object]",jr="[object Promise]",pn="[object Proxy]",Gr="[object RegExp]",rr="[object Set]",dn="[object String]",O="[object Symbol]",Z="[object Undefined]",K="[object WeakMap]",rt="[object WeakSet]",it="[object ArrayBuffer]",et="[object DataView]",lt="[object Float32Array]",at="[object Float64Array]",ht="[object Int8Array]",ot="[object Int16Array]",Kt="[object Int32Array]",Ht="[object Uint8Array]",pe="[object Uint8ClampedArray]",Ie="[object Uint16Array]",Se="[object Uint32Array]",nr=/\b__p \+= '';/g,ir=/\b(__p \+=) '' \+/g,mn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ln=/&(?:amp|lt|gt|quot|#39);/g,ru=/[&<>"']/g,Io=RegExp(Ln.source),To=RegExp(ru.source),$o=/<%-([\s\S]+?)%>/g,Oo=/<%([\s\S]+?)%>/g,nu=/<%=([\s\S]+?)%>/g,Ro=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lo=/^\w*$/,Po=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pi=/[\\^$.*+?()[\]{}|]/g,zo=RegExp(Pi.source),zi=/^\s+/,Uo=/\s/,qo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Wo=/\{\n\/\* \[wrapped with (.+)\] \*/,ko=/,? & /,Yo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Zo=/[()=,{}\[\]\/\s]/,jo=/\\(\\)?/g,Go=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,iu=/\w*$/,Ko=/^[-+]0x[0-9a-f]+$/i,Jo=/^0b[01]+$/i,Xo=/^\[object .+?Constructor\]$/,Ho=/^0o[0-7]+$/i,Qo=/^(?:0|[1-9]\d*)$/,Vo=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,li=/($^)/,Pn=/['\n\r\u2028\u2029\\]/g,Yt="\\ud800-\\udfff",Ue="\\u0300-\\u036f",ta="\\ufe20-\\ufe2f",hi="\\u20d0-\\u20ff",vn=Ue+ta+hi,su="\\u2700-\\u27bf",jl="a-z\\xdf-\\xf6\\xf8-\\xff",H_="\\xac\\xb1\\xd7\\xf7",Q_="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",V_="\\u2000-\\u206f",tD=" \\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",Gl="A-Z\\xc0-\\xd6\\xd8-\\xde",Kl="\\ufe0e\\ufe0f",Jl=H_+Q_+V_+tD,ea="['’]",eD="["+Yt+"]",Xl="["+Jl+"]",uu="["+vn+"]",Hl="\\d+",rD="["+su+"]",Ql="["+jl+"]",Vl="[^"+Yt+Jl+Hl+su+jl+Gl+"]",ra="\\ud83c[\\udffb-\\udfff]",nD="(?:"+uu+"|"+ra+")",th="[^"+Yt+"]",na="(?:\\ud83c[\\udde6-\\uddff]){2}",ia="[\\ud800-\\udbff][\\udc00-\\udfff]",pi="["+Gl+"]",eh="\\u200d",rh="(?:"+Ql+"|"+Vl+")",iD="(?:"+pi+"|"+Vl+")",nh="(?:"+ea+"(?:d|ll|m|re|s|t|ve))?",ih="(?:"+ea+"(?:D|LL|M|RE|S|T|VE))?",sh=nD+"?",uh="["+Kl+"]?",sD="(?:"+eh+"(?:"+[th,na,ia].join("|")+")"+uh+sh+")*",uD="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",oD="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",oh=uh+sh+sD,aD="(?:"+[rD,na,ia].join("|")+")"+oh,fD="(?:"+[th+uu+"?",uu,na,ia,eD].join("|")+")",cD=RegExp(ea,"g"),lD=RegExp(uu,"g"),sa=RegExp(ra+"(?="+ra+")|"+fD+oh,"g"),hD=RegExp([pi+"?"+Ql+"+"+nh+"(?="+[Xl,pi,"$"].join("|")+")",iD+"+"+ih+"(?="+[Xl,pi+rh,"$"].join("|")+")",pi+"?"+rh+"+"+nh,pi+"+"+ih,oD,uD,Hl,aD].join("|"),"g"),pD=RegExp("["+eh+Yt+vn+Kl+"]"),dD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,mD=["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"],vD=-1,le={};le[lt]=le[at]=le[ht]=le[ot]=le[Kt]=le[Ht]=le[pe]=le[Ie]=le[Se]=!0,le[yt]=le[Nt]=le[it]=le[ee]=le[et]=le[It]=le[ie]=le[Xt]=le[Gt]=le[Fe]=le[xe]=le[Gr]=le[rr]=le[dn]=le[K]=!1;var fe={};fe[yt]=fe[Nt]=fe[it]=fe[et]=fe[ee]=fe[It]=fe[lt]=fe[at]=fe[ht]=fe[ot]=fe[Kt]=fe[Gt]=fe[Fe]=fe[xe]=fe[Gr]=fe[rr]=fe[dn]=fe[O]=fe[Ht]=fe[pe]=fe[Ie]=fe[Se]=!0,fe[ie]=fe[Xt]=fe[K]=!1;var gD={À:"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"},wD={"&":"&","<":"<",">":">",'"':""","'":"'"},_D={"&":"&","<":"<",">":">",""":'"',"'":"'"},DD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},yD=parseFloat,ED=parseInt,ah=typeof kt=="object"&&kt&&kt.Object===Object&&kt,AD=typeof self=="object"&&self&&self.Object===Object&&self,Re=ah||AD||Function("return this")(),ua=t&&!t.nodeType&&t,zn=ua&&!0&&i&&!i.nodeType&&i,fh=zn&&zn.exports===ua,oa=fh&&ah.process,mr=function(){try{var k=zn&&zn.require&&zn.require("util").types;return k||oa&&oa.binding&&oa.binding("util")}catch{}}(),ch=mr&&mr.isArrayBuffer,lh=mr&&mr.isDate,hh=mr&&mr.isMap,ph=mr&&mr.isRegExp,dh=mr&&mr.isSet,mh=mr&&mr.isTypedArray;function sr(k,X,J){switch(J.length){case 0:return k.call(X);case 1:return k.call(X,J[0]);case 2:return k.call(X,J[0],J[1]);case 3:return k.call(X,J[0],J[1],J[2])}return k.apply(X,J)}function bD(k,X,J,vt){for(var Bt=-1,Jt=k==null?0:k.length;++Bt<Jt;){var Ne=k[Bt];X(vt,Ne,J(Ne),k)}return vt}function vr(k,X){for(var J=-1,vt=k==null?0:k.length;++J<vt&&X(k[J],J,k)!==!1;);return k}function CD(k,X){for(var J=k==null?0:k.length;J--&&X(k[J],J,k)!==!1;);return k}function vh(k,X){for(var J=-1,vt=k==null?0:k.length;++J<vt;)if(!X(k[J],J,k))return!1;return!0}function gn(k,X){for(var J=-1,vt=k==null?0:k.length,Bt=0,Jt=[];++J<vt;){var Ne=k[J];X(Ne,J,k)&&(Jt[Bt++]=Ne)}return Jt}function ou(k,X){var J=k==null?0:k.length;return!!J&&di(k,X,0)>-1}function aa(k,X,J){for(var vt=-1,Bt=k==null?0:k.length;++vt<Bt;)if(J(X,k[vt]))return!0;return!1}function de(k,X){for(var J=-1,vt=k==null?0:k.length,Bt=Array(vt);++J<vt;)Bt[J]=X(k[J],J,k);return Bt}function wn(k,X){for(var J=-1,vt=X.length,Bt=k.length;++J<vt;)k[Bt+J]=X[J];return k}function fa(k,X,J,vt){var Bt=-1,Jt=k==null?0:k.length;for(vt&&Jt&&(J=k[++Bt]);++Bt<Jt;)J=X(J,k[Bt],Bt,k);return J}function FD(k,X,J,vt){var Bt=k==null?0:k.length;for(vt&&Bt&&(J=k[--Bt]);Bt--;)J=X(J,k[Bt],Bt,k);return J}function ca(k,X){for(var J=-1,vt=k==null?0:k.length;++J<vt;)if(X(k[J],J,k))return!0;return!1}var MD=la("length");function xD(k){return k.split("")}function SD(k){return k.match(Yo)||[]}function gh(k,X,J){var vt;return J(k,function(Bt,Jt,Ne){if(X(Bt,Jt,Ne))return vt=Jt,!1}),vt}function au(k,X,J,vt){for(var Bt=k.length,Jt=J+(vt?1:-1);vt?Jt--:++Jt<Bt;)if(X(k[Jt],Jt,k))return Jt;return-1}function di(k,X,J){return X===X?qD(k,X,J):au(k,wh,J)}function ND(k,X,J,vt){for(var Bt=J-1,Jt=k.length;++Bt<Jt;)if(vt(k[Bt],X))return Bt;return-1}function wh(k){return k!==k}function _h(k,X){var J=k==null?0:k.length;return J?pa(k,X)/J:V}function la(k){return function(X){return X==null?e:X[k]}}function ha(k){return function(X){return k==null?e:k[X]}}function Dh(k,X,J,vt,Bt){return Bt(k,function(Jt,Ne,oe){J=vt?(vt=!1,Jt):X(J,Jt,Ne,oe)}),J}function BD(k,X){var J=k.length;for(k.sort(X);J--;)k[J]=k[J].value;return k}function pa(k,X){for(var J,vt=-1,Bt=k.length;++vt<Bt;){var Jt=X(k[vt]);Jt!==e&&(J=J===e?Jt:J+Jt)}return J}function da(k,X){for(var J=-1,vt=Array(k);++J<k;)vt[J]=X(J);return vt}function ID(k,X){return de(X,function(J){return[J,k[J]]})}function yh(k){return k&&k.slice(0,Ch(k)+1).replace(zi,"")}function ur(k){return function(X){return k(X)}}function ma(k,X){return de(X,function(J){return k[J]})}function Ui(k,X){return k.has(X)}function Eh(k,X){for(var J=-1,vt=k.length;++J<vt&&di(X,k[J],0)>-1;);return J}function Ah(k,X){for(var J=k.length;J--&&di(X,k[J],0)>-1;);return J}function TD(k,X){for(var J=k.length,vt=0;J--;)k[J]===X&&++vt;return vt}var $D=ha(gD),OD=ha(wD);function RD(k){return"\\"+DD[k]}function LD(k,X){return k==null?e:k[X]}function mi(k){return pD.test(k)}function PD(k){return dD.test(k)}function zD(k){for(var X,J=[];!(X=k.next()).done;)J.push(X.value);return J}function va(k){var X=-1,J=Array(k.size);return k.forEach(function(vt,Bt){J[++X]=[Bt,vt]}),J}function bh(k,X){return function(J){return k(X(J))}}function _n(k,X){for(var J=-1,vt=k.length,Bt=0,Jt=[];++J<vt;){var Ne=k[J];(Ne===X||Ne===h)&&(k[J]=h,Jt[Bt++]=J)}return Jt}function fu(k){var X=-1,J=Array(k.size);return k.forEach(function(vt){J[++X]=vt}),J}function UD(k){var X=-1,J=Array(k.size);return k.forEach(function(vt){J[++X]=[vt,vt]}),J}function qD(k,X,J){for(var vt=J-1,Bt=k.length;++vt<Bt;)if(k[vt]===X)return vt;return-1}function WD(k,X,J){for(var vt=J+1;vt--;)if(k[vt]===X)return vt;return vt}function vi(k){return mi(k)?YD(k):MD(k)}function Sr(k){return mi(k)?ZD(k):xD(k)}function Ch(k){for(var X=k.length;X--&&Uo.test(k.charAt(X)););return X}var kD=ha(_D);function YD(k){for(var X=sa.lastIndex=0;sa.test(k);)++X;return X}function ZD(k){return k.match(sa)||[]}function jD(k){return k.match(hD)||[]}var GD=function k(X){X=X==null?Re:gi.defaults(Re.Object(),X,gi.pick(Re,mD));var J=X.Array,vt=X.Date,Bt=X.Error,Jt=X.Function,Ne=X.Math,oe=X.Object,ga=X.RegExp,KD=X.String,gr=X.TypeError,cu=J.prototype,JD=Jt.prototype,wi=oe.prototype,lu=X["__core-js_shared__"],hu=JD.toString,re=wi.hasOwnProperty,XD=0,Fh=function(){var u=/[^.]+$/.exec(lu&&lu.keys&&lu.keys.IE_PROTO||"");return u?"Symbol(src)_1."+u:""}(),pu=wi.toString,HD=hu.call(oe),QD=Re._,VD=ga("^"+hu.call(re).replace(Pi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),du=fh?X.Buffer:e,Dn=X.Symbol,mu=X.Uint8Array,Mh=du?du.allocUnsafe:e,vu=bh(oe.getPrototypeOf,oe),xh=oe.create,Sh=wi.propertyIsEnumerable,gu=cu.splice,Nh=Dn?Dn.isConcatSpreadable:e,qi=Dn?Dn.iterator:e,Un=Dn?Dn.toStringTag:e,wu=function(){try{var u=Zn(oe,"defineProperty");return u({},"",{}),u}catch{}}(),ty=X.clearTimeout!==Re.clearTimeout&&X.clearTimeout,ey=vt&&vt.now!==Re.Date.now&&vt.now,ry=X.setTimeout!==Re.setTimeout&&X.setTimeout,_u=Ne.ceil,Du=Ne.floor,wa=oe.getOwnPropertySymbols,ny=du?du.isBuffer:e,Bh=X.isFinite,iy=cu.join,sy=bh(oe.keys,oe),Be=Ne.max,qe=Ne.min,uy=vt.now,oy=X.parseInt,Ih=Ne.random,ay=cu.reverse,_a=Zn(X,"DataView"),Wi=Zn(X,"Map"),Da=Zn(X,"Promise"),_i=Zn(X,"Set"),ki=Zn(X,"WeakMap"),Yi=Zn(oe,"create"),yu=ki&&new ki,Di={},fy=jn(_a),cy=jn(Wi),ly=jn(Da),hy=jn(_i),py=jn(ki),Eu=Dn?Dn.prototype:e,Zi=Eu?Eu.valueOf:e,Th=Eu?Eu.toString:e;function B(u){if(_e(u)&&!Tt(u)&&!(u instanceof qt)){if(u instanceof wr)return u;if(re.call(u,"__wrapped__"))return $0(u)}return new wr(u)}var yi=function(){function u(){}return function(o){if(!ge(o))return{};if(xh)return xh(o);u.prototype=o;var d=new u;return u.prototype=e,d}}();function Au(){}function wr(u,o){this.__wrapped__=u,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=e}B.templateSettings={escape:$o,evaluate:Oo,interpolate:nu,variable:"",imports:{_:B}},B.prototype=Au.prototype,B.prototype.constructor=B,wr.prototype=yi(Au.prototype),wr.prototype.constructor=wr;function qt(u){this.__wrapped__=u,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function dy(){var u=new qt(this.__wrapped__);return u.__actions__=Ke(this.__actions__),u.__dir__=this.__dir__,u.__filtered__=this.__filtered__,u.__iteratees__=Ke(this.__iteratees__),u.__takeCount__=this.__takeCount__,u.__views__=Ke(this.__views__),u}function my(){if(this.__filtered__){var u=new qt(this);u.__dir__=-1,u.__filtered__=!0}else u=this.clone(),u.__dir__*=-1;return u}function vy(){var u=this.__wrapped__.value(),o=this.__dir__,d=Tt(u),_=o<0,b=d?u.length:0,T=xE(0,b,this.__views__),L=T.start,z=T.end,Y=z-L,Q=_?z:L-1,tt=this.__iteratees__,st=tt.length,dt=0,wt=qe(Y,this.__takeCount__);if(!d||!_&&b==Y&&wt==Y)return n0(u,this.__actions__);var Ct=[];t:for(;Y--&&dt<wt;){Q+=o;for(var Rt=-1,Ft=u[Q];++Rt<st;){var Ut=tt[Rt],Wt=Ut.iteratee,fr=Ut.type,Ze=Wt(Ft);if(fr==W)Ft=Ze;else if(!Ze){if(fr==U)continue t;break t}}Ct[dt++]=Ft}return Ct}qt.prototype=yi(Au.prototype),qt.prototype.constructor=qt;function qn(u){var o=-1,d=u==null?0:u.length;for(this.clear();++o<d;){var _=u[o];this.set(_[0],_[1])}}function gy(){this.__data__=Yi?Yi(null):{},this.size=0}function wy(u){var o=this.has(u)&&delete this.__data__[u];return this.size-=o?1:0,o}function _y(u){var o=this.__data__;if(Yi){var d=o[u];return d===l?e:d}return re.call(o,u)?o[u]:e}function Dy(u){var o=this.__data__;return Yi?o[u]!==e:re.call(o,u)}function yy(u,o){var d=this.__data__;return this.size+=this.has(u)?0:1,d[u]=Yi&&o===e?l:o,this}qn.prototype.clear=gy,qn.prototype.delete=wy,qn.prototype.get=_y,qn.prototype.has=Dy,qn.prototype.set=yy;function Kr(u){var o=-1,d=u==null?0:u.length;for(this.clear();++o<d;){var _=u[o];this.set(_[0],_[1])}}function Ey(){this.__data__=[],this.size=0}function Ay(u){var o=this.__data__,d=bu(o,u);if(d<0)return!1;var _=o.length-1;return d==_?o.pop():gu.call(o,d,1),--this.size,!0}function by(u){var o=this.__data__,d=bu(o,u);return d<0?e:o[d][1]}function Cy(u){return bu(this.__data__,u)>-1}function Fy(u,o){var d=this.__data__,_=bu(d,u);return _<0?(++this.size,d.push([u,o])):d[_][1]=o,this}Kr.prototype.clear=Ey,Kr.prototype.delete=Ay,Kr.prototype.get=by,Kr.prototype.has=Cy,Kr.prototype.set=Fy;function Jr(u){var o=-1,d=u==null?0:u.length;for(this.clear();++o<d;){var _=u[o];this.set(_[0],_[1])}}function My(){this.size=0,this.__data__={hash:new qn,map:new(Wi||Kr),string:new qn}}function xy(u){var o=Ru(this,u).delete(u);return this.size-=o?1:0,o}function Sy(u){return Ru(this,u).get(u)}function Ny(u){return Ru(this,u).has(u)}function By(u,o){var d=Ru(this,u),_=d.size;return d.set(u,o),this.size+=d.size==_?0:1,this}Jr.prototype.clear=My,Jr.prototype.delete=xy,Jr.prototype.get=Sy,Jr.prototype.has=Ny,Jr.prototype.set=By;function Wn(u){var o=-1,d=u==null?0:u.length;for(this.__data__=new Jr;++o<d;)this.add(u[o])}function Iy(u){return this.__data__.set(u,l),this}function Ty(u){return this.__data__.has(u)}Wn.prototype.add=Wn.prototype.push=Iy,Wn.prototype.has=Ty;function Nr(u){var o=this.__data__=new Kr(u);this.size=o.size}function $y(){this.__data__=new Kr,this.size=0}function Oy(u){var o=this.__data__,d=o.delete(u);return this.size=o.size,d}function Ry(u){return this.__data__.get(u)}function Ly(u){return this.__data__.has(u)}function Py(u,o){var d=this.__data__;if(d instanceof Kr){var _=d.__data__;if(!Wi||_.length<n-1)return _.push([u,o]),this.size=++d.size,this;d=this.__data__=new Jr(_)}return d.set(u,o),this.size=d.size,this}Nr.prototype.clear=$y,Nr.prototype.delete=Oy,Nr.prototype.get=Ry,Nr.prototype.has=Ly,Nr.prototype.set=Py;function $h(u,o){var d=Tt(u),_=!d&&Gn(u),b=!d&&!_&&Cn(u),T=!d&&!_&&!b&&Ci(u),L=d||_||b||T,z=L?da(u.length,KD):[],Y=z.length;for(var Q in u)(o||re.call(u,Q))&&!(L&&(Q=="length"||b&&(Q=="offset"||Q=="parent")||T&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||Vr(Q,Y)))&&z.push(Q);return z}function Oh(u){var o=u.length;return o?u[Ba(0,o-1)]:e}function zy(u,o){return Lu(Ke(u),kn(o,0,u.length))}function Uy(u){return Lu(Ke(u))}function ya(u,o,d){(d!==e&&!Br(u[o],d)||d===e&&!(o in u))&&Xr(u,o,d)}function ji(u,o,d){var _=u[o];(!(re.call(u,o)&&Br(_,d))||d===e&&!(o in u))&&Xr(u,o,d)}function bu(u,o){for(var d=u.length;d--;)if(Br(u[d][0],o))return d;return-1}function qy(u,o,d,_){return yn(u,function(b,T,L){o(_,b,d(b),L)}),_}function Rh(u,o){return u&&Ur(o,Te(o),u)}function Wy(u,o){return u&&Ur(o,Xe(o),u)}function Xr(u,o,d){o=="__proto__"&&wu?wu(u,o,{configurable:!0,enumerable:!0,value:d,writable:!0}):u[o]=d}function Ea(u,o){for(var d=-1,_=o.length,b=J(_),T=u==null;++d<_;)b[d]=T?e:rf(u,o[d]);return b}function kn(u,o,d){return u===u&&(d!==e&&(u=u<=d?u:d),o!==e&&(u=u>=o?u:o)),u}function _r(u,o,d,_,b,T){var L,z=o&c,Y=o&m,Q=o&w;if(d&&(L=b?d(u,_,b,T):d(u)),L!==e)return L;if(!ge(u))return u;var tt=Tt(u);if(tt){if(L=NE(u),!z)return Ke(u,L)}else{var st=We(u),dt=st==Xt||st==zt;if(Cn(u))return u0(u,z);if(st==xe||st==yt||dt&&!b){if(L=Y||dt?{}:C0(u),!z)return Y?_E(u,Wy(L,u)):wE(u,Rh(L,u))}else{if(!fe[st])return b?u:{};L=BE(u,st,z)}}T||(T=new Nr);var wt=T.get(u);if(wt)return wt;T.set(u,L),tp(u)?u.forEach(function(Ft){L.add(_r(Ft,o,d,Ft,u,T))}):Q0(u)&&u.forEach(function(Ft,Ut){L.set(Ut,_r(Ft,o,d,Ut,u,T))});var Ct=Q?Y?Wa:qa:Y?Xe:Te,Rt=tt?e:Ct(u);return vr(Rt||u,function(Ft,Ut){Rt&&(Ut=Ft,Ft=u[Ut]),ji(L,Ut,_r(Ft,o,d,Ut,u,T))}),L}function ky(u){var o=Te(u);return function(d){return Lh(d,u,o)}}function Lh(u,o,d){var _=d.length;if(u==null)return!_;for(u=oe(u);_--;){var b=d[_],T=o[b],L=u[b];if(L===e&&!(b in u)||!T(L))return!1}return!0}function Ph(u,o,d){if(typeof u!="function")throw new gr(a);return Vi(function(){u.apply(e,d)},o)}function Gi(u,o,d,_){var b=-1,T=ou,L=!0,z=u.length,Y=[],Q=o.length;if(!z)return Y;d&&(o=de(o,ur(d))),_?(T=aa,L=!1):o.length>=n&&(T=Ui,L=!1,o=new Wn(o));t:for(;++b<z;){var tt=u[b],st=d==null?tt:d(tt);if(tt=_||tt!==0?tt:0,L&&st===st){for(var dt=Q;dt--;)if(o[dt]===st)continue t;Y.push(tt)}else T(o,st,_)||Y.push(tt)}return Y}var yn=l0(zr),zh=l0(ba,!0);function Yy(u,o){var d=!0;return yn(u,function(_,b,T){return d=!!o(_,b,T),d}),d}function Cu(u,o,d){for(var _=-1,b=u.length;++_<b;){var T=u[_],L=o(T);if(L!=null&&(z===e?L===L&&!ar(L):d(L,z)))var z=L,Y=T}return Y}function Zy(u,o,d,_){var b=u.length;for(d=Ot(d),d<0&&(d=-d>b?0:b+d),_=_===e||_>b?b:Ot(_),_<0&&(_+=b),_=d>_?0:rp(_);d<_;)u[d++]=o;return u}function Uh(u,o){var d=[];return yn(u,function(_,b,T){o(_,b,T)&&d.push(_)}),d}function Le(u,o,d,_,b){var T=-1,L=u.length;for(d||(d=TE),b||(b=[]);++T<L;){var z=u[T];o>0&&d(z)?o>1?Le(z,o-1,d,_,b):wn(b,z):_||(b[b.length]=z)}return b}var Aa=h0(),qh=h0(!0);function zr(u,o){return u&&Aa(u,o,Te)}function ba(u,o){return u&&qh(u,o,Te)}function Fu(u,o){return gn(o,function(d){return tn(u[d])})}function Yn(u,o){o=An(o,u);for(var d=0,_=o.length;u!=null&&d<_;)u=u[qr(o[d++])];return d&&d==_?u:e}function Wh(u,o,d){var _=o(u);return Tt(u)?_:wn(_,d(u))}function ke(u){return u==null?u===e?Z:er:Un&&Un in oe(u)?ME(u):UE(u)}function Ca(u,o){return u>o}function jy(u,o){return u!=null&&re.call(u,o)}function Gy(u,o){return u!=null&&o in oe(u)}function Ky(u,o,d){return u>=qe(o,d)&&u<Be(o,d)}function Fa(u,o,d){for(var _=d?aa:ou,b=u[0].length,T=u.length,L=T,z=J(T),Y=1/0,Q=[];L--;){var tt=u[L];L&&o&&(tt=de(tt,ur(o))),Y=qe(tt.length,Y),z[L]=!d&&(o||b>=120&&tt.length>=120)?new Wn(L&&tt):e}tt=u[0];var st=-1,dt=z[0];t:for(;++st<b&&Q.length<Y;){var wt=tt[st],Ct=o?o(wt):wt;if(wt=d||wt!==0?wt:0,!(dt?Ui(dt,Ct):_(Q,Ct,d))){for(L=T;--L;){var Rt=z[L];if(!(Rt?Ui(Rt,Ct):_(u[L],Ct,d)))continue t}dt&&dt.push(Ct),Q.push(wt)}}return Q}function Jy(u,o,d,_){return zr(u,function(b,T,L){o(_,d(b),T,L)}),_}function Ki(u,o,d){o=An(o,u),u=S0(u,o);var _=u==null?u:u[qr(yr(o))];return _==null?e:sr(_,u,d)}function kh(u){return _e(u)&&ke(u)==yt}function Xy(u){return _e(u)&&ke(u)==it}function Hy(u){return _e(u)&&ke(u)==It}function Ji(u,o,d,_,b){return u===o?!0:u==null||o==null||!_e(u)&&!_e(o)?u!==u&&o!==o:Qy(u,o,d,_,Ji,b)}function Qy(u,o,d,_,b,T){var L=Tt(u),z=Tt(o),Y=L?Nt:We(u),Q=z?Nt:We(o);Y=Y==yt?xe:Y,Q=Q==yt?xe:Q;var tt=Y==xe,st=Q==xe,dt=Y==Q;if(dt&&Cn(u)){if(!Cn(o))return!1;L=!0,tt=!1}if(dt&&!tt)return T||(T=new Nr),L||Ci(u)?E0(u,o,d,_,b,T):CE(u,o,Y,d,_,b,T);if(!(d&D)){var wt=tt&&re.call(u,"__wrapped__"),Ct=st&&re.call(o,"__wrapped__");if(wt||Ct){var Rt=wt?u.value():u,Ft=Ct?o.value():o;return T||(T=new Nr),b(Rt,Ft,d,_,T)}}return dt?(T||(T=new Nr),FE(u,o,d,_,b,T)):!1}function Vy(u){return _e(u)&&We(u)==Gt}function Ma(u,o,d,_){var b=d.length,T=b,L=!_;if(u==null)return!T;for(u=oe(u);b--;){var z=d[b];if(L&&z[2]?z[1]!==u[z[0]]:!(z[0]in u))return!1}for(;++b<T;){z=d[b];var Y=z[0],Q=u[Y],tt=z[1];if(L&&z[2]){if(Q===e&&!(Y in u))return!1}else{var st=new Nr;if(_)var dt=_(Q,tt,Y,u,o,st);if(!(dt===e?Ji(tt,Q,D|v,_,st):dt))return!1}}return!0}function Yh(u){if(!ge(u)||OE(u))return!1;var o=tn(u)?VD:Xo;return o.test(jn(u))}function tE(u){return _e(u)&&ke(u)==Gr}function eE(u){return _e(u)&&We(u)==rr}function rE(u){return _e(u)&&ku(u.length)&&!!le[ke(u)]}function Zh(u){return typeof u=="function"?u:u==null?He:typeof u=="object"?Tt(u)?Kh(u[0],u[1]):Gh(u):pp(u)}function xa(u){if(!Qi(u))return sy(u);var o=[];for(var d in oe(u))re.call(u,d)&&d!="constructor"&&o.push(d);return o}function nE(u){if(!ge(u))return zE(u);var o=Qi(u),d=[];for(var _ in u)_=="constructor"&&(o||!re.call(u,_))||d.push(_);return d}function Sa(u,o){return u<o}function jh(u,o){var d=-1,_=Je(u)?J(u.length):[];return yn(u,function(b,T,L){_[++d]=o(b,T,L)}),_}function Gh(u){var o=Ya(u);return o.length==1&&o[0][2]?M0(o[0][0],o[0][1]):function(d){return d===u||Ma(d,u,o)}}function Kh(u,o){return ja(u)&&F0(o)?M0(qr(u),o):function(d){var _=rf(d,u);return _===e&&_===o?nf(d,u):Ji(o,_,D|v)}}function Mu(u,o,d,_,b){u!==o&&Aa(o,function(T,L){if(b||(b=new Nr),ge(T))iE(u,o,L,d,Mu,_,b);else{var z=_?_(Ka(u,L),T,L+"",u,o,b):e;z===e&&(z=T),ya(u,L,z)}},Xe)}function iE(u,o,d,_,b,T,L){var z=Ka(u,d),Y=Ka(o,d),Q=L.get(Y);if(Q){ya(u,d,Q);return}var tt=T?T(z,Y,d+"",u,o,L):e,st=tt===e;if(st){var dt=Tt(Y),wt=!dt&&Cn(Y),Ct=!dt&&!wt&&Ci(Y);tt=Y,dt||wt||Ct?Tt(z)?tt=z:Ee(z)?tt=Ke(z):wt?(st=!1,tt=u0(Y,!0)):Ct?(st=!1,tt=o0(Y,!0)):tt=[]:ts(Y)||Gn(Y)?(tt=z,Gn(z)?tt=np(z):(!ge(z)||tn(z))&&(tt=C0(Y))):st=!1}st&&(L.set(Y,tt),b(tt,Y,_,T,L),L.delete(Y)),ya(u,d,tt)}function Jh(u,o){var d=u.length;if(d)return o+=o<0?d:0,Vr(o,d)?u[o]:e}function Xh(u,o,d){o.length?o=de(o,function(T){return Tt(T)?function(L){return Yn(L,T.length===1?T[0]:T)}:T}):o=[He];var _=-1;o=de(o,ur(bt()));var b=jh(u,function(T,L,z){var Y=de(o,function(Q){return Q(T)});return{criteria:Y,index:++_,value:T}});return BD(b,function(T,L){return gE(T,L,d)})}function sE(u,o){return Hh(u,o,function(d,_){return nf(u,_)})}function Hh(u,o,d){for(var _=-1,b=o.length,T={};++_<b;){var L=o[_],z=Yn(u,L);d(z,L)&&Xi(T,An(L,u),z)}return T}function uE(u){return function(o){return Yn(o,u)}}function Na(u,o,d,_){var b=_?ND:di,T=-1,L=o.length,z=u;for(u===o&&(o=Ke(o)),d&&(z=de(u,ur(d)));++T<L;)for(var Y=0,Q=o[T],tt=d?d(Q):Q;(Y=b(z,tt,Y,_))>-1;)z!==u&&gu.call(z,Y,1),gu.call(u,Y,1);return u}function Qh(u,o){for(var d=u?o.length:0,_=d-1;d--;){var b=o[d];if(d==_||b!==T){var T=b;Vr(b)?gu.call(u,b,1):$a(u,b)}}return u}function Ba(u,o){return u+Du(Ih()*(o-u+1))}function oE(u,o,d,_){for(var b=-1,T=Be(_u((o-u)/(d||1)),0),L=J(T);T--;)L[_?T:++b]=u,u+=d;return L}function Ia(u,o){var d="";if(!u||o<1||o>j)return d;do o%2&&(d+=u),o=Du(o/2),o&&(u+=u);while(o);return d}function Lt(u,o){return Ja(x0(u,o,He),u+"")}function aE(u){return Oh(Fi(u))}function fE(u,o){var d=Fi(u);return Lu(d,kn(o,0,d.length))}function Xi(u,o,d,_){if(!ge(u))return u;o=An(o,u);for(var b=-1,T=o.length,L=T-1,z=u;z!=null&&++b<T;){var Y=qr(o[b]),Q=d;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return u;if(b!=L){var tt=z[Y];Q=_?_(tt,Y,z):e,Q===e&&(Q=ge(tt)?tt:Vr(o[b+1])?[]:{})}ji(z,Y,Q),z=z[Y]}return u}var Vh=yu?function(u,o){return yu.set(u,o),u}:He,cE=wu?function(u,o){return wu(u,"toString",{configurable:!0,enumerable:!1,value:uf(o),writable:!0})}:He;function lE(u){return Lu(Fi(u))}function Dr(u,o,d){var _=-1,b=u.length;o<0&&(o=-o>b?0:b+o),d=d>b?b:d,d<0&&(d+=b),b=o>d?0:d-o>>>0,o>>>=0;for(var T=J(b);++_<b;)T[_]=u[_+o];return T}function hE(u,o){var d;return yn(u,function(_,b,T){return d=o(_,b,T),!d}),!!d}function xu(u,o,d){var _=0,b=u==null?_:u.length;if(typeof o=="number"&&o===o&&b<=ft){for(;_<b;){var T=_+b>>>1,L=u[T];L!==null&&!ar(L)&&(d?L<=o:L<o)?_=T+1:b=T}return b}return Ta(u,o,He,d)}function Ta(u,o,d,_){var b=0,T=u==null?0:u.length;if(T===0)return 0;o=d(o);for(var L=o!==o,z=o===null,Y=ar(o),Q=o===e;b<T;){var tt=Du((b+T)/2),st=d(u[tt]),dt=st!==e,wt=st===null,Ct=st===st,Rt=ar(st);if(L)var Ft=_||Ct;else Q?Ft=Ct&&(_||dt):z?Ft=Ct&&dt&&(_||!wt):Y?Ft=Ct&&dt&&!wt&&(_||!Rt):wt||Rt?Ft=!1:Ft=_?st<=o:st<o;Ft?b=tt+1:T=tt}return qe(T,gt)}function t0(u,o){for(var d=-1,_=u.length,b=0,T=[];++d<_;){var L=u[d],z=o?o(L):L;if(!d||!Br(z,Y)){var Y=z;T[b++]=L===0?0:L}}return T}function e0(u){return typeof u=="number"?u:ar(u)?V:+u}function or(u){if(typeof u=="string")return u;if(Tt(u))return de(u,or)+"";if(ar(u))return Th?Th.call(u):"";var o=u+"";return o=="0"&&1/u==-G?"-0":o}function En(u,o,d){var _=-1,b=ou,T=u.length,L=!0,z=[],Y=z;if(d)L=!1,b=aa;else if(T>=n){var Q=o?null:AE(u);if(Q)return fu(Q);L=!1,b=Ui,Y=new Wn}else Y=o?[]:z;t:for(;++_<T;){var tt=u[_],st=o?o(tt):tt;if(tt=d||tt!==0?tt:0,L&&st===st){for(var dt=Y.length;dt--;)if(Y[dt]===st)continue t;o&&Y.push(st),z.push(tt)}else b(Y,st,d)||(Y!==z&&Y.push(st),z.push(tt))}return z}function $a(u,o){return o=An(o,u),u=S0(u,o),u==null||delete u[qr(yr(o))]}function r0(u,o,d,_){return Xi(u,o,d(Yn(u,o)),_)}function Su(u,o,d,_){for(var b=u.length,T=_?b:-1;(_?T--:++T<b)&&o(u[T],T,u););return d?Dr(u,_?0:T,_?T+1:b):Dr(u,_?T+1:0,_?b:T)}function n0(u,o){var d=u;return d instanceof qt&&(d=d.value()),fa(o,function(_,b){return b.func.apply(b.thisArg,wn([_],b.args))},d)}function Oa(u,o,d){var _=u.length;if(_<2)return _?En(u[0]):[];for(var b=-1,T=J(_);++b<_;)for(var L=u[b],z=-1;++z<_;)z!=b&&(T[b]=Gi(T[b]||L,u[z],o,d));return En(Le(T,1),o,d)}function i0(u,o,d){for(var _=-1,b=u.length,T=o.length,L={};++_<b;){var z=_<T?o[_]:e;d(L,u[_],z)}return L}function Ra(u){return Ee(u)?u:[]}function La(u){return typeof u=="function"?u:He}function An(u,o){return Tt(u)?u:ja(u,o)?[u]:T0(Qt(u))}var pE=Lt;function bn(u,o,d){var _=u.length;return d=d===e?_:d,!o&&d>=_?u:Dr(u,o,d)}var s0=ty||function(u){return Re.clearTimeout(u)};function u0(u,o){if(o)return u.slice();var d=u.length,_=Mh?Mh(d):new u.constructor(d);return u.copy(_),_}function Pa(u){var o=new u.constructor(u.byteLength);return new mu(o).set(new mu(u)),o}function dE(u,o){var d=o?Pa(u.buffer):u.buffer;return new u.constructor(d,u.byteOffset,u.byteLength)}function mE(u){var o=new u.constructor(u.source,iu.exec(u));return o.lastIndex=u.lastIndex,o}function vE(u){return Zi?oe(Zi.call(u)):{}}function o0(u,o){var d=o?Pa(u.buffer):u.buffer;return new u.constructor(d,u.byteOffset,u.length)}function a0(u,o){if(u!==o){var d=u!==e,_=u===null,b=u===u,T=ar(u),L=o!==e,z=o===null,Y=o===o,Q=ar(o);if(!z&&!Q&&!T&&u>o||T&&L&&Y&&!z&&!Q||_&&L&&Y||!d&&Y||!b)return 1;if(!_&&!T&&!Q&&u<o||Q&&d&&b&&!_&&!T||z&&d&&b||!L&&b||!Y)return-1}return 0}function gE(u,o,d){for(var _=-1,b=u.criteria,T=o.criteria,L=b.length,z=d.length;++_<L;){var Y=a0(b[_],T[_]);if(Y){if(_>=z)return Y;var Q=d[_];return Y*(Q=="desc"?-1:1)}}return u.index-o.index}function f0(u,o,d,_){for(var b=-1,T=u.length,L=d.length,z=-1,Y=o.length,Q=Be(T-L,0),tt=J(Y+Q),st=!_;++z<Y;)tt[z]=o[z];for(;++b<L;)(st||b<T)&&(tt[d[b]]=u[b]);for(;Q--;)tt[z++]=u[b++];return tt}function c0(u,o,d,_){for(var b=-1,T=u.length,L=-1,z=d.length,Y=-1,Q=o.length,tt=Be(T-z,0),st=J(tt+Q),dt=!_;++b<tt;)st[b]=u[b];for(var wt=b;++Y<Q;)st[wt+Y]=o[Y];for(;++L<z;)(dt||b<T)&&(st[wt+d[L]]=u[b++]);return st}function Ke(u,o){var d=-1,_=u.length;for(o||(o=J(_));++d<_;)o[d]=u[d];return o}function Ur(u,o,d,_){var b=!d;d||(d={});for(var T=-1,L=o.length;++T<L;){var z=o[T],Y=_?_(d[z],u[z],z,d,u):e;Y===e&&(Y=u[z]),b?Xr(d,z,Y):ji(d,z,Y)}return d}function wE(u,o){return Ur(u,Za(u),o)}function _E(u,o){return Ur(u,A0(u),o)}function Nu(u,o){return function(d,_){var b=Tt(d)?bD:qy,T=o?o():{};return b(d,u,bt(_,2),T)}}function Ei(u){return Lt(function(o,d){var _=-1,b=d.length,T=b>1?d[b-1]:e,L=b>2?d[2]:e;for(T=u.length>3&&typeof T=="function"?(b--,T):e,L&&Ye(d[0],d[1],L)&&(T=b<3?e:T,b=1),o=oe(o);++_<b;){var z=d[_];z&&u(o,z,_,T)}return o})}function l0(u,o){return function(d,_){if(d==null)return d;if(!Je(d))return u(d,_);for(var b=d.length,T=o?b:-1,L=oe(d);(o?T--:++T<b)&&_(L[T],T,L)!==!1;);return d}}function h0(u){return function(o,d,_){for(var b=-1,T=oe(o),L=_(o),z=L.length;z--;){var Y=L[u?z:++b];if(d(T[Y],Y,T)===!1)break}return o}}function DE(u,o,d){var _=o&y,b=Hi(u);function T(){var L=this&&this!==Re&&this instanceof T?b:u;return L.apply(_?d:this,arguments)}return T}function p0(u){return function(o){o=Qt(o);var d=mi(o)?Sr(o):e,_=d?d[0]:o.charAt(0),b=d?bn(d,1).join(""):o.slice(1);return _[u]()+b}}function Ai(u){return function(o){return fa(lp(cp(o).replace(cD,"")),u,"")}}function Hi(u){return function(){var o=arguments;switch(o.length){case 0:return new u;case 1:return new u(o[0]);case 2:return new u(o[0],o[1]);case 3:return new u(o[0],o[1],o[2]);case 4:return new u(o[0],o[1],o[2],o[3]);case 5:return new u(o[0],o[1],o[2],o[3],o[4]);case 6:return new u(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new u(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var d=yi(u.prototype),_=u.apply(d,o);return ge(_)?_:d}}function yE(u,o,d){var _=Hi(u);function b(){for(var T=arguments.length,L=J(T),z=T,Y=bi(b);z--;)L[z]=arguments[z];var Q=T<3&&L[0]!==Y&&L[T-1]!==Y?[]:_n(L,Y);if(T-=Q.length,T<d)return w0(u,o,Bu,b.placeholder,e,L,Q,e,e,d-T);var tt=this&&this!==Re&&this instanceof b?_:u;return sr(tt,this,L)}return b}function d0(u){return function(o,d,_){var b=oe(o);if(!Je(o)){var T=bt(d,3);o=Te(o),d=function(z){return T(b[z],z,b)}}var L=u(o,d,_);return L>-1?b[T?o[L]:L]:e}}function m0(u){return Qr(function(o){var d=o.length,_=d,b=wr.prototype.thru;for(u&&o.reverse();_--;){var T=o[_];if(typeof T!="function")throw new gr(a);if(b&&!L&&Ou(T)=="wrapper")var L=new wr([],!0)}for(_=L?_:d;++_<d;){T=o[_];var z=Ou(T),Y=z=="wrapper"?ka(T):e;Y&&Ga(Y[0])&&Y[1]==(x|E|C|N)&&!Y[4].length&&Y[9]==1?L=L[Ou(Y[0])].apply(L,Y[3]):L=T.length==1&&Ga(T)?L[z]():L.thru(T)}return function(){var Q=arguments,tt=Q[0];if(L&&Q.length==1&&Tt(tt))return L.plant(tt).value();for(var st=0,dt=d?o[st].apply(this,Q):tt;++st<d;)dt=o[st].call(this,dt);return dt}})}function Bu(u,o,d,_,b,T,L,z,Y,Q){var tt=o&x,st=o&y,dt=o&g,wt=o&(E|S),Ct=o&$,Rt=dt?e:Hi(u);function Ft(){for(var Ut=arguments.length,Wt=J(Ut),fr=Ut;fr--;)Wt[fr]=arguments[fr];if(wt)var Ze=bi(Ft),cr=TD(Wt,Ze);if(_&&(Wt=f0(Wt,_,b,wt)),T&&(Wt=c0(Wt,T,L,wt)),Ut-=cr,wt&&Ut<Q){var Ae=_n(Wt,Ze);return w0(u,o,Bu,Ft.placeholder,d,Wt,Ae,z,Y,Q-Ut)}var Ir=st?d:this,rn=dt?Ir[u]:u;return Ut=Wt.length,z?Wt=qE(Wt,z):Ct&&Ut>1&&Wt.reverse(),tt&&Y<Ut&&(Wt.length=Y),this&&this!==Re&&this instanceof Ft&&(rn=Rt||Hi(rn)),rn.apply(Ir,Wt)}return Ft}function v0(u,o){return function(d,_){return Jy(d,u,o(_),{})}}function Iu(u,o){return function(d,_){var b;if(d===e&&_===e)return o;if(d!==e&&(b=d),_!==e){if(b===e)return _;typeof d=="string"||typeof _=="string"?(d=or(d),_=or(_)):(d=e0(d),_=e0(_)),b=u(d,_)}return b}}function za(u){return Qr(function(o){return o=de(o,ur(bt())),Lt(function(d){var _=this;return u(o,function(b){return sr(b,_,d)})})})}function Tu(u,o){o=o===e?" ":or(o);var d=o.length;if(d<2)return d?Ia(o,u):o;var _=Ia(o,_u(u/vi(o)));return mi(o)?bn(Sr(_),0,u).join(""):_.slice(0,u)}function EE(u,o,d,_){var b=o&y,T=Hi(u);function L(){for(var z=-1,Y=arguments.length,Q=-1,tt=_.length,st=J(tt+Y),dt=this&&this!==Re&&this instanceof L?T:u;++Q<tt;)st[Q]=_[Q];for(;Y--;)st[Q++]=arguments[++z];return sr(dt,b?d:this,st)}return L}function g0(u){return function(o,d,_){return _&&typeof _!="number"&&Ye(o,d,_)&&(d=_=e),o=en(o),d===e?(d=o,o=0):d=en(d),_=_===e?o<d?1:-1:en(_),oE(o,d,_,u)}}function $u(u){return function(o,d){return typeof o=="string"&&typeof d=="string"||(o=Er(o),d=Er(d)),u(o,d)}}function w0(u,o,d,_,b,T,L,z,Y,Q){var tt=o&E,st=tt?L:e,dt=tt?e:L,wt=tt?T:e,Ct=tt?e:T;o|=tt?C:M,o&=~(tt?M:C),o&A||(o&=~(y|g));var Rt=[u,o,b,wt,st,Ct,dt,z,Y,Q],Ft=d.apply(e,Rt);return Ga(u)&&N0(Ft,Rt),Ft.placeholder=_,B0(Ft,u,o)}function Ua(u){var o=Ne[u];return function(d,_){if(d=Er(d),_=_==null?0:qe(Ot(_),292),_&&Bh(d)){var b=(Qt(d)+"e").split("e"),T=o(b[0]+"e"+(+b[1]+_));return b=(Qt(T)+"e").split("e"),+(b[0]+"e"+(+b[1]-_))}return o(d)}}var AE=_i&&1/fu(new _i([,-0]))[1]==G?function(u){return new _i(u)}:ff;function _0(u){return function(o){var d=We(o);return d==Gt?va(o):d==rr?UD(o):ID(o,u(o))}}function Hr(u,o,d,_,b,T,L,z){var Y=o&g;if(!Y&&typeof u!="function")throw new gr(a);var Q=_?_.length:0;if(Q||(o&=~(C|M),_=b=e),L=L===e?L:Be(Ot(L),0),z=z===e?z:Ot(z),Q-=b?b.length:0,o&M){var tt=_,st=b;_=b=e}var dt=Y?e:ka(u),wt=[u,o,d,_,b,tt,st,T,L,z];if(dt&&PE(wt,dt),u=wt[0],o=wt[1],d=wt[2],_=wt[3],b=wt[4],z=wt[9]=wt[9]===e?Y?0:u.length:Be(wt[9]-Q,0),!z&&o&(E|S)&&(o&=~(E|S)),!o||o==y)var Ct=DE(u,o,d);else o==E||o==S?Ct=yE(u,o,z):(o==C||o==(y|C))&&!b.length?Ct=EE(u,o,d,_):Ct=Bu.apply(e,wt);var Rt=dt?Vh:N0;return B0(Rt(Ct,wt),u,o)}function D0(u,o,d,_){return u===e||Br(u,wi[d])&&!re.call(_,d)?o:u}function y0(u,o,d,_,b,T){return ge(u)&&ge(o)&&(T.set(o,u),Mu(u,o,e,y0,T),T.delete(o)),u}function bE(u){return ts(u)?e:u}function E0(u,o,d,_,b,T){var L=d&D,z=u.length,Y=o.length;if(z!=Y&&!(L&&Y>z))return!1;var Q=T.get(u),tt=T.get(o);if(Q&&tt)return Q==o&&tt==u;var st=-1,dt=!0,wt=d&v?new Wn:e;for(T.set(u,o),T.set(o,u);++st<z;){var Ct=u[st],Rt=o[st];if(_)var Ft=L?_(Rt,Ct,st,o,u,T):_(Ct,Rt,st,u,o,T);if(Ft!==e){if(Ft)continue;dt=!1;break}if(wt){if(!ca(o,function(Ut,Wt){if(!Ui(wt,Wt)&&(Ct===Ut||b(Ct,Ut,d,_,T)))return wt.push(Wt)})){dt=!1;break}}else if(!(Ct===Rt||b(Ct,Rt,d,_,T))){dt=!1;break}}return T.delete(u),T.delete(o),dt}function CE(u,o,d,_,b,T,L){switch(d){case et:if(u.byteLength!=o.byteLength||u.byteOffset!=o.byteOffset)return!1;u=u.buffer,o=o.buffer;case it:return!(u.byteLength!=o.byteLength||!T(new mu(u),new mu(o)));case ee:case It:case Fe:return Br(+u,+o);case ie:return u.name==o.name&&u.message==o.message;case Gr:case dn:return u==o+"";case Gt:var z=va;case rr:var Y=_&D;if(z||(z=fu),u.size!=o.size&&!Y)return!1;var Q=L.get(u);if(Q)return Q==o;_|=v,L.set(u,o);var tt=E0(z(u),z(o),_,b,T,L);return L.delete(u),tt;case O:if(Zi)return Zi.call(u)==Zi.call(o)}return!1}function FE(u,o,d,_,b,T){var L=d&D,z=qa(u),Y=z.length,Q=qa(o),tt=Q.length;if(Y!=tt&&!L)return!1;for(var st=Y;st--;){var dt=z[st];if(!(L?dt in o:re.call(o,dt)))return!1}var wt=T.get(u),Ct=T.get(o);if(wt&&Ct)return wt==o&&Ct==u;var Rt=!0;T.set(u,o),T.set(o,u);for(var Ft=L;++st<Y;){dt=z[st];var Ut=u[dt],Wt=o[dt];if(_)var fr=L?_(Wt,Ut,dt,o,u,T):_(Ut,Wt,dt,u,o,T);if(!(fr===e?Ut===Wt||b(Ut,Wt,d,_,T):fr)){Rt=!1;break}Ft||(Ft=dt=="constructor")}if(Rt&&!Ft){var Ze=u.constructor,cr=o.constructor;Ze!=cr&&"constructor"in u&&"constructor"in o&&!(typeof Ze=="function"&&Ze instanceof Ze&&typeof cr=="function"&&cr instanceof cr)&&(Rt=!1)}return T.delete(u),T.delete(o),Rt}function Qr(u){return Ja(x0(u,e,L0),u+"")}function qa(u){return Wh(u,Te,Za)}function Wa(u){return Wh(u,Xe,A0)}var ka=yu?function(u){return yu.get(u)}:ff;function Ou(u){for(var o=u.name+"",d=Di[o],_=re.call(Di,o)?d.length:0;_--;){var b=d[_],T=b.func;if(T==null||T==u)return b.name}return o}function bi(u){var o=re.call(B,"placeholder")?B:u;return o.placeholder}function bt(){var u=B.iteratee||of;return u=u===of?Zh:u,arguments.length?u(arguments[0],arguments[1]):u}function Ru(u,o){var d=u.__data__;return $E(o)?d[typeof o=="string"?"string":"hash"]:d.map}function Ya(u){for(var o=Te(u),d=o.length;d--;){var _=o[d],b=u[_];o[d]=[_,b,F0(b)]}return o}function Zn(u,o){var d=LD(u,o);return Yh(d)?d:e}function ME(u){var o=re.call(u,Un),d=u[Un];try{u[Un]=e;var _=!0}catch{}var b=pu.call(u);return _&&(o?u[Un]=d:delete u[Un]),b}var Za=wa?function(u){return u==null?[]:(u=oe(u),gn(wa(u),function(o){return Sh.call(u,o)}))}:cf,A0=wa?function(u){for(var o=[];u;)wn(o,Za(u)),u=vu(u);return o}:cf,We=ke;(_a&&We(new _a(new ArrayBuffer(1)))!=et||Wi&&We(new Wi)!=Gt||Da&&We(Da.resolve())!=jr||_i&&We(new _i)!=rr||ki&&We(new ki)!=K)&&(We=function(u){var o=ke(u),d=o==xe?u.constructor:e,_=d?jn(d):"";if(_)switch(_){case fy:return et;case cy:return Gt;case ly:return jr;case hy:return rr;case py:return K}return o});function xE(u,o,d){for(var _=-1,b=d.length;++_<b;){var T=d[_],L=T.size;switch(T.type){case"drop":u+=L;break;case"dropRight":o-=L;break;case"take":o=qe(o,u+L);break;case"takeRight":u=Be(u,o-L);break}}return{start:u,end:o}}function SE(u){var o=u.match(Wo);return o?o[1].split(ko):[]}function b0(u,o,d){o=An(o,u);for(var _=-1,b=o.length,T=!1;++_<b;){var L=qr(o[_]);if(!(T=u!=null&&d(u,L)))break;u=u[L]}return T||++_!=b?T:(b=u==null?0:u.length,!!b&&ku(b)&&Vr(L,b)&&(Tt(u)||Gn(u)))}function NE(u){var o=u.length,d=new u.constructor(o);return o&&typeof u[0]=="string"&&re.call(u,"index")&&(d.index=u.index,d.input=u.input),d}function C0(u){return typeof u.constructor=="function"&&!Qi(u)?yi(vu(u)):{}}function BE(u,o,d){var _=u.constructor;switch(o){case it:return Pa(u);case ee:case It:return new _(+u);case et:return dE(u,d);case lt:case at:case ht:case ot:case Kt:case Ht:case pe:case Ie:case Se:return o0(u,d);case Gt:return new _;case Fe:case dn:return new _(u);case Gr:return mE(u);case rr:return new _;case O:return vE(u)}}function IE(u,o){var d=o.length;if(!d)return u;var _=d-1;return o[_]=(d>1?"& ":"")+o[_],o=o.join(d>2?", ":" "),u.replace(qo,`{
|
9
|
-
/* [wrapped with `+o+`] */
|
10
|
-
`)}function TE(u){return Tt(u)||Gn(u)||!!(Nh&&u&&u[Nh])}function Vr(u,o){var d=typeof u;return o=o??j,!!o&&(d=="number"||d!="symbol"&&Qo.test(u))&&u>-1&&u%1==0&&u<o}function Ye(u,o,d){if(!ge(d))return!1;var _=typeof o;return(_=="number"?Je(d)&&Vr(o,d.length):_=="string"&&o in d)?Br(d[o],u):!1}function ja(u,o){if(Tt(u))return!1;var d=typeof u;return d=="number"||d=="symbol"||d=="boolean"||u==null||ar(u)?!0:Lo.test(u)||!Ro.test(u)||o!=null&&u in oe(o)}function $E(u){var o=typeof u;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?u!=="__proto__":u===null}function Ga(u){var o=Ou(u),d=B[o];if(typeof d!="function"||!(o in qt.prototype))return!1;if(u===d)return!0;var _=ka(d);return!!_&&u===_[0]}function OE(u){return!!Fh&&Fh in u}var RE=lu?tn:lf;function Qi(u){var o=u&&u.constructor,d=typeof o=="function"&&o.prototype||wi;return u===d}function F0(u){return u===u&&!ge(u)}function M0(u,o){return function(d){return d==null?!1:d[u]===o&&(o!==e||u in oe(d))}}function LE(u){var o=qu(u,function(_){return d.size===p&&d.clear(),_}),d=o.cache;return o}function PE(u,o){var d=u[1],_=o[1],b=d|_,T=b<(y|g|x),L=_==x&&d==E||_==x&&d==N&&u[7].length<=o[8]||_==(x|N)&&o[7].length<=o[8]&&d==E;if(!(T||L))return u;_&y&&(u[2]=o[2],b|=d&y?0:A);var z=o[3];if(z){var Y=u[3];u[3]=Y?f0(Y,z,o[4]):z,u[4]=Y?_n(u[3],h):o[4]}return z=o[5],z&&(Y=u[5],u[5]=Y?c0(Y,z,o[6]):z,u[6]=Y?_n(u[5],h):o[6]),z=o[7],z&&(u[7]=z),_&x&&(u[8]=u[8]==null?o[8]:qe(u[8],o[8])),u[9]==null&&(u[9]=o[9]),u[0]=o[0],u[1]=b,u}function zE(u){var o=[];if(u!=null)for(var d in oe(u))o.push(d);return o}function UE(u){return pu.call(u)}function x0(u,o,d){return o=Be(o===e?u.length-1:o,0),function(){for(var _=arguments,b=-1,T=Be(_.length-o,0),L=J(T);++b<T;)L[b]=_[o+b];b=-1;for(var z=J(o+1);++b<o;)z[b]=_[b];return z[o]=d(L),sr(u,this,z)}}function S0(u,o){return o.length<2?u:Yn(u,Dr(o,0,-1))}function qE(u,o){for(var d=u.length,_=qe(o.length,d),b=Ke(u);_--;){var T=o[_];u[_]=Vr(T,d)?b[T]:e}return u}function Ka(u,o){if(!(o==="constructor"&&typeof u[o]=="function")&&o!="__proto__")return u[o]}var N0=I0(Vh),Vi=ry||function(u,o){return Re.setTimeout(u,o)},Ja=I0(cE);function B0(u,o,d){var _=o+"";return Ja(u,IE(_,WE(SE(_),d)))}function I0(u){var o=0,d=0;return function(){var _=uy(),b=q-(_-d);if(d=_,b>0){if(++o>=R)return arguments[0]}else o=0;return u.apply(e,arguments)}}function Lu(u,o){var d=-1,_=u.length,b=_-1;for(o=o===e?_:o;++d<o;){var T=Ba(d,b),L=u[T];u[T]=u[d],u[d]=L}return u.length=o,u}var T0=LE(function(u){var o=[];return u.charCodeAt(0)===46&&o.push(""),u.replace(Po,function(d,_,b,T){o.push(b?T.replace(jo,"$1"):_||d)}),o});function qr(u){if(typeof u=="string"||ar(u))return u;var o=u+"";return o=="0"&&1/u==-G?"-0":o}function jn(u){if(u!=null){try{return hu.call(u)}catch{}try{return u+""}catch{}}return""}function WE(u,o){return vr(_t,function(d){var _="_."+d[0];o&d[1]&&!ou(u,_)&&u.push(_)}),u.sort()}function $0(u){if(u instanceof qt)return u.clone();var o=new wr(u.__wrapped__,u.__chain__);return o.__actions__=Ke(u.__actions__),o.__index__=u.__index__,o.__values__=u.__values__,o}function kE(u,o,d){(d?Ye(u,o,d):o===e)?o=1:o=Be(Ot(o),0);var _=u==null?0:u.length;if(!_||o<1)return[];for(var b=0,T=0,L=J(_u(_/o));b<_;)L[T++]=Dr(u,b,b+=o);return L}function YE(u){for(var o=-1,d=u==null?0:u.length,_=0,b=[];++o<d;){var T=u[o];T&&(b[_++]=T)}return b}function ZE(){var u=arguments.length;if(!u)return[];for(var o=J(u-1),d=arguments[0],_=u;_--;)o[_-1]=arguments[_];return wn(Tt(d)?Ke(d):[d],Le(o,1))}var jE=Lt(function(u,o){return Ee(u)?Gi(u,Le(o,1,Ee,!0)):[]}),GE=Lt(function(u,o){var d=yr(o);return Ee(d)&&(d=e),Ee(u)?Gi(u,Le(o,1,Ee,!0),bt(d,2)):[]}),KE=Lt(function(u,o){var d=yr(o);return Ee(d)&&(d=e),Ee(u)?Gi(u,Le(o,1,Ee,!0),e,d):[]});function JE(u,o,d){var _=u==null?0:u.length;return _?(o=d||o===e?1:Ot(o),Dr(u,o<0?0:o,_)):[]}function XE(u,o,d){var _=u==null?0:u.length;return _?(o=d||o===e?1:Ot(o),o=_-o,Dr(u,0,o<0?0:o)):[]}function HE(u,o){return u&&u.length?Su(u,bt(o,3),!0,!0):[]}function QE(u,o){return u&&u.length?Su(u,bt(o,3),!0):[]}function VE(u,o,d,_){var b=u==null?0:u.length;return b?(d&&typeof d!="number"&&Ye(u,o,d)&&(d=0,_=b),Zy(u,o,d,_)):[]}function O0(u,o,d){var _=u==null?0:u.length;if(!_)return-1;var b=d==null?0:Ot(d);return b<0&&(b=Be(_+b,0)),au(u,bt(o,3),b)}function R0(u,o,d){var _=u==null?0:u.length;if(!_)return-1;var b=_-1;return d!==e&&(b=Ot(d),b=d<0?Be(_+b,0):qe(b,_-1)),au(u,bt(o,3),b,!0)}function L0(u){var o=u==null?0:u.length;return o?Le(u,1):[]}function tA(u){var o=u==null?0:u.length;return o?Le(u,G):[]}function eA(u,o){var d=u==null?0:u.length;return d?(o=o===e?1:Ot(o),Le(u,o)):[]}function rA(u){for(var o=-1,d=u==null?0:u.length,_={};++o<d;){var b=u[o];_[b[0]]=b[1]}return _}function P0(u){return u&&u.length?u[0]:e}function nA(u,o,d){var _=u==null?0:u.length;if(!_)return-1;var b=d==null?0:Ot(d);return b<0&&(b=Be(_+b,0)),di(u,o,b)}function iA(u){var o=u==null?0:u.length;return o?Dr(u,0,-1):[]}var sA=Lt(function(u){var o=de(u,Ra);return o.length&&o[0]===u[0]?Fa(o):[]}),uA=Lt(function(u){var o=yr(u),d=de(u,Ra);return o===yr(d)?o=e:d.pop(),d.length&&d[0]===u[0]?Fa(d,bt(o,2)):[]}),oA=Lt(function(u){var o=yr(u),d=de(u,Ra);return o=typeof o=="function"?o:e,o&&d.pop(),d.length&&d[0]===u[0]?Fa(d,e,o):[]});function aA(u,o){return u==null?"":iy.call(u,o)}function yr(u){var o=u==null?0:u.length;return o?u[o-1]:e}function fA(u,o,d){var _=u==null?0:u.length;if(!_)return-1;var b=_;return d!==e&&(b=Ot(d),b=b<0?Be(_+b,0):qe(b,_-1)),o===o?WD(u,o,b):au(u,wh,b,!0)}function cA(u,o){return u&&u.length?Jh(u,Ot(o)):e}var lA=Lt(z0);function z0(u,o){return u&&u.length&&o&&o.length?Na(u,o):u}function hA(u,o,d){return u&&u.length&&o&&o.length?Na(u,o,bt(d,2)):u}function pA(u,o,d){return u&&u.length&&o&&o.length?Na(u,o,e,d):u}var dA=Qr(function(u,o){var d=u==null?0:u.length,_=Ea(u,o);return Qh(u,de(o,function(b){return Vr(b,d)?+b:b}).sort(a0)),_});function mA(u,o){var d=[];if(!(u&&u.length))return d;var _=-1,b=[],T=u.length;for(o=bt(o,3);++_<T;){var L=u[_];o(L,_,u)&&(d.push(L),b.push(_))}return Qh(u,b),d}function Xa(u){return u==null?u:ay.call(u)}function vA(u,o,d){var _=u==null?0:u.length;return _?(d&&typeof d!="number"&&Ye(u,o,d)?(o=0,d=_):(o=o==null?0:Ot(o),d=d===e?_:Ot(d)),Dr(u,o,d)):[]}function gA(u,o){return xu(u,o)}function wA(u,o,d){return Ta(u,o,bt(d,2))}function _A(u,o){var d=u==null?0:u.length;if(d){var _=xu(u,o);if(_<d&&Br(u[_],o))return _}return-1}function DA(u,o){return xu(u,o,!0)}function yA(u,o,d){return Ta(u,o,bt(d,2),!0)}function EA(u,o){var d=u==null?0:u.length;if(d){var _=xu(u,o,!0)-1;if(Br(u[_],o))return _}return-1}function AA(u){return u&&u.length?t0(u):[]}function bA(u,o){return u&&u.length?t0(u,bt(o,2)):[]}function CA(u){var o=u==null?0:u.length;return o?Dr(u,1,o):[]}function FA(u,o,d){return u&&u.length?(o=d||o===e?1:Ot(o),Dr(u,0,o<0?0:o)):[]}function MA(u,o,d){var _=u==null?0:u.length;return _?(o=d||o===e?1:Ot(o),o=_-o,Dr(u,o<0?0:o,_)):[]}function xA(u,o){return u&&u.length?Su(u,bt(o,3),!1,!0):[]}function SA(u,o){return u&&u.length?Su(u,bt(o,3)):[]}var NA=Lt(function(u){return En(Le(u,1,Ee,!0))}),BA=Lt(function(u){var o=yr(u);return Ee(o)&&(o=e),En(Le(u,1,Ee,!0),bt(o,2))}),IA=Lt(function(u){var o=yr(u);return o=typeof o=="function"?o:e,En(Le(u,1,Ee,!0),e,o)});function TA(u){return u&&u.length?En(u):[]}function $A(u,o){return u&&u.length?En(u,bt(o,2)):[]}function OA(u,o){return o=typeof o=="function"?o:e,u&&u.length?En(u,e,o):[]}function Ha(u){if(!(u&&u.length))return[];var o=0;return u=gn(u,function(d){if(Ee(d))return o=Be(d.length,o),!0}),da(o,function(d){return de(u,la(d))})}function U0(u,o){if(!(u&&u.length))return[];var d=Ha(u);return o==null?d:de(d,function(_){return sr(o,e,_)})}var RA=Lt(function(u,o){return Ee(u)?Gi(u,o):[]}),LA=Lt(function(u){return Oa(gn(u,Ee))}),PA=Lt(function(u){var o=yr(u);return Ee(o)&&(o=e),Oa(gn(u,Ee),bt(o,2))}),zA=Lt(function(u){var o=yr(u);return o=typeof o=="function"?o:e,Oa(gn(u,Ee),e,o)}),UA=Lt(Ha);function qA(u,o){return i0(u||[],o||[],ji)}function WA(u,o){return i0(u||[],o||[],Xi)}var kA=Lt(function(u){var o=u.length,d=o>1?u[o-1]:e;return d=typeof d=="function"?(u.pop(),d):e,U0(u,d)});function q0(u){var o=B(u);return o.__chain__=!0,o}function YA(u,o){return o(u),u}function Pu(u,o){return o(u)}var ZA=Qr(function(u){var o=u.length,d=o?u[0]:0,_=this.__wrapped__,b=function(T){return Ea(T,u)};return o>1||this.__actions__.length||!(_ instanceof qt)||!Vr(d)?this.thru(b):(_=_.slice(d,+d+(o?1:0)),_.__actions__.push({func:Pu,args:[b],thisArg:e}),new wr(_,this.__chain__).thru(function(T){return o&&!T.length&&T.push(e),T}))});function jA(){return q0(this)}function GA(){return new wr(this.value(),this.__chain__)}function KA(){this.__values__===e&&(this.__values__=ep(this.value()));var u=this.__index__>=this.__values__.length,o=u?e:this.__values__[this.__index__++];return{done:u,value:o}}function JA(){return this}function XA(u){for(var o,d=this;d instanceof Au;){var _=$0(d);_.__index__=0,_.__values__=e,o?b.__wrapped__=_:o=_;var b=_;d=d.__wrapped__}return b.__wrapped__=u,o}function HA(){var u=this.__wrapped__;if(u instanceof qt){var o=u;return this.__actions__.length&&(o=new qt(this)),o=o.reverse(),o.__actions__.push({func:Pu,args:[Xa],thisArg:e}),new wr(o,this.__chain__)}return this.thru(Xa)}function QA(){return n0(this.__wrapped__,this.__actions__)}var VA=Nu(function(u,o,d){re.call(u,d)?++u[d]:Xr(u,d,1)});function tb(u,o,d){var _=Tt(u)?vh:Yy;return d&&Ye(u,o,d)&&(o=e),_(u,bt(o,3))}function eb(u,o){var d=Tt(u)?gn:Uh;return d(u,bt(o,3))}var rb=d0(O0),nb=d0(R0);function ib(u,o){return Le(zu(u,o),1)}function sb(u,o){return Le(zu(u,o),G)}function ub(u,o,d){return d=d===e?1:Ot(d),Le(zu(u,o),d)}function W0(u,o){var d=Tt(u)?vr:yn;return d(u,bt(o,3))}function k0(u,o){var d=Tt(u)?CD:zh;return d(u,bt(o,3))}var ob=Nu(function(u,o,d){re.call(u,d)?u[d].push(o):Xr(u,d,[o])});function ab(u,o,d,_){u=Je(u)?u:Fi(u),d=d&&!_?Ot(d):0;var b=u.length;return d<0&&(d=Be(b+d,0)),Yu(u)?d<=b&&u.indexOf(o,d)>-1:!!b&&di(u,o,d)>-1}var fb=Lt(function(u,o,d){var _=-1,b=typeof o=="function",T=Je(u)?J(u.length):[];return yn(u,function(L){T[++_]=b?sr(o,L,d):Ki(L,o,d)}),T}),cb=Nu(function(u,o,d){Xr(u,d,o)});function zu(u,o){var d=Tt(u)?de:jh;return d(u,bt(o,3))}function lb(u,o,d,_){return u==null?[]:(Tt(o)||(o=o==null?[]:[o]),d=_?e:d,Tt(d)||(d=d==null?[]:[d]),Xh(u,o,d))}var hb=Nu(function(u,o,d){u[d?0:1].push(o)},function(){return[[],[]]});function pb(u,o,d){var _=Tt(u)?fa:Dh,b=arguments.length<3;return _(u,bt(o,4),d,b,yn)}function db(u,o,d){var _=Tt(u)?FD:Dh,b=arguments.length<3;return _(u,bt(o,4),d,b,zh)}function mb(u,o){var d=Tt(u)?gn:Uh;return d(u,Wu(bt(o,3)))}function vb(u){var o=Tt(u)?Oh:aE;return o(u)}function gb(u,o,d){(d?Ye(u,o,d):o===e)?o=1:o=Ot(o);var _=Tt(u)?zy:fE;return _(u,o)}function wb(u){var o=Tt(u)?Uy:lE;return o(u)}function _b(u){if(u==null)return 0;if(Je(u))return Yu(u)?vi(u):u.length;var o=We(u);return o==Gt||o==rr?u.size:xa(u).length}function Db(u,o,d){var _=Tt(u)?ca:hE;return d&&Ye(u,o,d)&&(o=e),_(u,bt(o,3))}var yb=Lt(function(u,o){if(u==null)return[];var d=o.length;return d>1&&Ye(u,o[0],o[1])?o=[]:d>2&&Ye(o[0],o[1],o[2])&&(o=[o[0]]),Xh(u,Le(o,1),[])}),Uu=ey||function(){return Re.Date.now()};function Eb(u,o){if(typeof o!="function")throw new gr(a);return u=Ot(u),function(){if(--u<1)return o.apply(this,arguments)}}function Y0(u,o,d){return o=d?e:o,o=u&&o==null?u.length:o,Hr(u,x,e,e,e,e,o)}function Z0(u,o){var d;if(typeof o!="function")throw new gr(a);return u=Ot(u),function(){return--u>0&&(d=o.apply(this,arguments)),u<=1&&(o=e),d}}var Qa=Lt(function(u,o,d){var _=y;if(d.length){var b=_n(d,bi(Qa));_|=C}return Hr(u,_,o,d,b)}),j0=Lt(function(u,o,d){var _=y|g;if(d.length){var b=_n(d,bi(j0));_|=C}return Hr(o,_,u,d,b)});function G0(u,o,d){o=d?e:o;var _=Hr(u,E,e,e,e,e,e,o);return _.placeholder=G0.placeholder,_}function K0(u,o,d){o=d?e:o;var _=Hr(u,S,e,e,e,e,e,o);return _.placeholder=K0.placeholder,_}function J0(u,o,d){var _,b,T,L,z,Y,Q=0,tt=!1,st=!1,dt=!0;if(typeof u!="function")throw new gr(a);o=Er(o)||0,ge(d)&&(tt=!!d.leading,st="maxWait"in d,T=st?Be(Er(d.maxWait)||0,o):T,dt="trailing"in d?!!d.trailing:dt);function wt(Ae){var Ir=_,rn=b;return _=b=e,Q=Ae,L=u.apply(rn,Ir),L}function Ct(Ae){return Q=Ae,z=Vi(Ut,o),tt?wt(Ae):L}function Rt(Ae){var Ir=Ae-Y,rn=Ae-Q,dp=o-Ir;return st?qe(dp,T-rn):dp}function Ft(Ae){var Ir=Ae-Y,rn=Ae-Q;return Y===e||Ir>=o||Ir<0||st&&rn>=T}function Ut(){var Ae=Uu();if(Ft(Ae))return Wt(Ae);z=Vi(Ut,Rt(Ae))}function Wt(Ae){return z=e,dt&&_?wt(Ae):(_=b=e,L)}function fr(){z!==e&&s0(z),Q=0,_=Y=b=z=e}function Ze(){return z===e?L:Wt(Uu())}function cr(){var Ae=Uu(),Ir=Ft(Ae);if(_=arguments,b=this,Y=Ae,Ir){if(z===e)return Ct(Y);if(st)return s0(z),z=Vi(Ut,o),wt(Y)}return z===e&&(z=Vi(Ut,o)),L}return cr.cancel=fr,cr.flush=Ze,cr}var Ab=Lt(function(u,o){return Ph(u,1,o)}),bb=Lt(function(u,o,d){return Ph(u,Er(o)||0,d)});function Cb(u){return Hr(u,$)}function qu(u,o){if(typeof u!="function"||o!=null&&typeof o!="function")throw new gr(a);var d=function(){var _=arguments,b=o?o.apply(this,_):_[0],T=d.cache;if(T.has(b))return T.get(b);var L=u.apply(this,_);return d.cache=T.set(b,L)||T,L};return d.cache=new(qu.Cache||Jr),d}qu.Cache=Jr;function Wu(u){if(typeof u!="function")throw new gr(a);return function(){var o=arguments;switch(o.length){case 0:return!u.call(this);case 1:return!u.call(this,o[0]);case 2:return!u.call(this,o[0],o[1]);case 3:return!u.call(this,o[0],o[1],o[2])}return!u.apply(this,o)}}function Fb(u){return Z0(2,u)}var Mb=pE(function(u,o){o=o.length==1&&Tt(o[0])?de(o[0],ur(bt())):de(Le(o,1),ur(bt()));var d=o.length;return Lt(function(_){for(var b=-1,T=qe(_.length,d);++b<T;)_[b]=o[b].call(this,_[b]);return sr(u,this,_)})}),Va=Lt(function(u,o){var d=_n(o,bi(Va));return Hr(u,C,e,o,d)}),X0=Lt(function(u,o){var d=_n(o,bi(X0));return Hr(u,M,e,o,d)}),xb=Qr(function(u,o){return Hr(u,N,e,e,e,o)});function Sb(u,o){if(typeof u!="function")throw new gr(a);return o=o===e?o:Ot(o),Lt(u,o)}function Nb(u,o){if(typeof u!="function")throw new gr(a);return o=o==null?0:Be(Ot(o),0),Lt(function(d){var _=d[o],b=bn(d,0,o);return _&&wn(b,_),sr(u,this,b)})}function Bb(u,o,d){var _=!0,b=!0;if(typeof u!="function")throw new gr(a);return ge(d)&&(_="leading"in d?!!d.leading:_,b="trailing"in d?!!d.trailing:b),J0(u,o,{leading:_,maxWait:o,trailing:b})}function Ib(u){return Y0(u,1)}function Tb(u,o){return Va(La(o),u)}function $b(){if(!arguments.length)return[];var u=arguments[0];return Tt(u)?u:[u]}function Ob(u){return _r(u,w)}function Rb(u,o){return o=typeof o=="function"?o:e,_r(u,w,o)}function Lb(u){return _r(u,c|w)}function Pb(u,o){return o=typeof o=="function"?o:e,_r(u,c|w,o)}function zb(u,o){return o==null||Lh(u,o,Te(o))}function Br(u,o){return u===o||u!==u&&o!==o}var Ub=$u(Ca),qb=$u(function(u,o){return u>=o}),Gn=kh(function(){return arguments}())?kh:function(u){return _e(u)&&re.call(u,"callee")&&!Sh.call(u,"callee")},Tt=J.isArray,Wb=ch?ur(ch):Xy;function Je(u){return u!=null&&ku(u.length)&&!tn(u)}function Ee(u){return _e(u)&&Je(u)}function kb(u){return u===!0||u===!1||_e(u)&&ke(u)==ee}var Cn=ny||lf,Yb=lh?ur(lh):Hy;function Zb(u){return _e(u)&&u.nodeType===1&&!ts(u)}function jb(u){if(u==null)return!0;if(Je(u)&&(Tt(u)||typeof u=="string"||typeof u.splice=="function"||Cn(u)||Ci(u)||Gn(u)))return!u.length;var o=We(u);if(o==Gt||o==rr)return!u.size;if(Qi(u))return!xa(u).length;for(var d in u)if(re.call(u,d))return!1;return!0}function Gb(u,o){return Ji(u,o)}function Kb(u,o,d){d=typeof d=="function"?d:e;var _=d?d(u,o):e;return _===e?Ji(u,o,e,d):!!_}function tf(u){if(!_e(u))return!1;var o=ke(u);return o==ie||o==xt||typeof u.message=="string"&&typeof u.name=="string"&&!ts(u)}function Jb(u){return typeof u=="number"&&Bh(u)}function tn(u){if(!ge(u))return!1;var o=ke(u);return o==Xt||o==zt||o==Et||o==pn}function H0(u){return typeof u=="number"&&u==Ot(u)}function ku(u){return typeof u=="number"&&u>-1&&u%1==0&&u<=j}function ge(u){var o=typeof u;return u!=null&&(o=="object"||o=="function")}function _e(u){return u!=null&&typeof u=="object"}var Q0=hh?ur(hh):Vy;function Xb(u,o){return u===o||Ma(u,o,Ya(o))}function Hb(u,o,d){return d=typeof d=="function"?d:e,Ma(u,o,Ya(o),d)}function Qb(u){return V0(u)&&u!=+u}function Vb(u){if(RE(u))throw new Bt(s);return Yh(u)}function t2(u){return u===null}function e2(u){return u==null}function V0(u){return typeof u=="number"||_e(u)&&ke(u)==Fe}function ts(u){if(!_e(u)||ke(u)!=xe)return!1;var o=vu(u);if(o===null)return!0;var d=re.call(o,"constructor")&&o.constructor;return typeof d=="function"&&d instanceof d&&hu.call(d)==HD}var ef=ph?ur(ph):tE;function r2(u){return H0(u)&&u>=-j&&u<=j}var tp=dh?ur(dh):eE;function Yu(u){return typeof u=="string"||!Tt(u)&&_e(u)&&ke(u)==dn}function ar(u){return typeof u=="symbol"||_e(u)&&ke(u)==O}var Ci=mh?ur(mh):rE;function n2(u){return u===e}function i2(u){return _e(u)&&We(u)==K}function s2(u){return _e(u)&&ke(u)==rt}var u2=$u(Sa),o2=$u(function(u,o){return u<=o});function ep(u){if(!u)return[];if(Je(u))return Yu(u)?Sr(u):Ke(u);if(qi&&u[qi])return zD(u[qi]());var o=We(u),d=o==Gt?va:o==rr?fu:Fi;return d(u)}function en(u){if(!u)return u===0?u:0;if(u=Er(u),u===G||u===-G){var o=u<0?-1:1;return o*H}return u===u?u:0}function Ot(u){var o=en(u),d=o%1;return o===o?d?o-d:o:0}function rp(u){return u?kn(Ot(u),0,ct):0}function Er(u){if(typeof u=="number")return u;if(ar(u))return V;if(ge(u)){var o=typeof u.valueOf=="function"?u.valueOf():u;u=ge(o)?o+"":o}if(typeof u!="string")return u===0?u:+u;u=yh(u);var d=Jo.test(u);return d||Ho.test(u)?ED(u.slice(2),d?2:8):Ko.test(u)?V:+u}function np(u){return Ur(u,Xe(u))}function a2(u){return u?kn(Ot(u),-j,j):u===0?u:0}function Qt(u){return u==null?"":or(u)}var f2=Ei(function(u,o){if(Qi(o)||Je(o)){Ur(o,Te(o),u);return}for(var d in o)re.call(o,d)&&ji(u,d,o[d])}),ip=Ei(function(u,o){Ur(o,Xe(o),u)}),Zu=Ei(function(u,o,d,_){Ur(o,Xe(o),u,_)}),c2=Ei(function(u,o,d,_){Ur(o,Te(o),u,_)}),l2=Qr(Ea);function h2(u,o){var d=yi(u);return o==null?d:Rh(d,o)}var p2=Lt(function(u,o){u=oe(u);var d=-1,_=o.length,b=_>2?o[2]:e;for(b&&Ye(o[0],o[1],b)&&(_=1);++d<_;)for(var T=o[d],L=Xe(T),z=-1,Y=L.length;++z<Y;){var Q=L[z],tt=u[Q];(tt===e||Br(tt,wi[Q])&&!re.call(u,Q))&&(u[Q]=T[Q])}return u}),d2=Lt(function(u){return u.push(e,y0),sr(sp,e,u)});function m2(u,o){return gh(u,bt(o,3),zr)}function v2(u,o){return gh(u,bt(o,3),ba)}function g2(u,o){return u==null?u:Aa(u,bt(o,3),Xe)}function w2(u,o){return u==null?u:qh(u,bt(o,3),Xe)}function _2(u,o){return u&&zr(u,bt(o,3))}function D2(u,o){return u&&ba(u,bt(o,3))}function y2(u){return u==null?[]:Fu(u,Te(u))}function E2(u){return u==null?[]:Fu(u,Xe(u))}function rf(u,o,d){var _=u==null?e:Yn(u,o);return _===e?d:_}function A2(u,o){return u!=null&&b0(u,o,jy)}function nf(u,o){return u!=null&&b0(u,o,Gy)}var b2=v0(function(u,o,d){o!=null&&typeof o.toString!="function"&&(o=pu.call(o)),u[o]=d},uf(He)),C2=v0(function(u,o,d){o!=null&&typeof o.toString!="function"&&(o=pu.call(o)),re.call(u,o)?u[o].push(d):u[o]=[d]},bt),F2=Lt(Ki);function Te(u){return Je(u)?$h(u):xa(u)}function Xe(u){return Je(u)?$h(u,!0):nE(u)}function M2(u,o){var d={};return o=bt(o,3),zr(u,function(_,b,T){Xr(d,o(_,b,T),_)}),d}function x2(u,o){var d={};return o=bt(o,3),zr(u,function(_,b,T){Xr(d,b,o(_,b,T))}),d}var S2=Ei(function(u,o,d){Mu(u,o,d)}),sp=Ei(function(u,o,d,_){Mu(u,o,d,_)}),N2=Qr(function(u,o){var d={};if(u==null)return d;var _=!1;o=de(o,function(T){return T=An(T,u),_||(_=T.length>1),T}),Ur(u,Wa(u),d),_&&(d=_r(d,c|m|w,bE));for(var b=o.length;b--;)$a(d,o[b]);return d});function B2(u,o){return up(u,Wu(bt(o)))}var I2=Qr(function(u,o){return u==null?{}:sE(u,o)});function up(u,o){if(u==null)return{};var d=de(Wa(u),function(_){return[_]});return o=bt(o),Hh(u,d,function(_,b){return o(_,b[0])})}function T2(u,o,d){o=An(o,u);var _=-1,b=o.length;for(b||(b=1,u=e);++_<b;){var T=u==null?e:u[qr(o[_])];T===e&&(_=b,T=d),u=tn(T)?T.call(u):T}return u}function $2(u,o,d){return u==null?u:Xi(u,o,d)}function O2(u,o,d,_){return _=typeof _=="function"?_:e,u==null?u:Xi(u,o,d,_)}var op=_0(Te),ap=_0(Xe);function R2(u,o,d){var _=Tt(u),b=_||Cn(u)||Ci(u);if(o=bt(o,4),d==null){var T=u&&u.constructor;b?d=_?new T:[]:ge(u)?d=tn(T)?yi(vu(u)):{}:d={}}return(b?vr:zr)(u,function(L,z,Y){return o(d,L,z,Y)}),d}function L2(u,o){return u==null?!0:$a(u,o)}function P2(u,o,d){return u==null?u:r0(u,o,La(d))}function z2(u,o,d,_){return _=typeof _=="function"?_:e,u==null?u:r0(u,o,La(d),_)}function Fi(u){return u==null?[]:ma(u,Te(u))}function U2(u){return u==null?[]:ma(u,Xe(u))}function q2(u,o,d){return d===e&&(d=o,o=e),d!==e&&(d=Er(d),d=d===d?d:0),o!==e&&(o=Er(o),o=o===o?o:0),kn(Er(u),o,d)}function W2(u,o,d){return o=en(o),d===e?(d=o,o=0):d=en(d),u=Er(u),Ky(u,o,d)}function k2(u,o,d){if(d&&typeof d!="boolean"&&Ye(u,o,d)&&(o=d=e),d===e&&(typeof o=="boolean"?(d=o,o=e):typeof u=="boolean"&&(d=u,u=e)),u===e&&o===e?(u=0,o=1):(u=en(u),o===e?(o=u,u=0):o=en(o)),u>o){var _=u;u=o,o=_}if(d||u%1||o%1){var b=Ih();return qe(u+b*(o-u+yD("1e-"+((b+"").length-1))),o)}return Ba(u,o)}var Y2=Ai(function(u,o,d){return o=o.toLowerCase(),u+(d?fp(o):o)});function fp(u){return sf(Qt(u).toLowerCase())}function cp(u){return u=Qt(u),u&&u.replace(Vo,$D).replace(lD,"")}function Z2(u,o,d){u=Qt(u),o=or(o);var _=u.length;d=d===e?_:kn(Ot(d),0,_);var b=d;return d-=o.length,d>=0&&u.slice(d,b)==o}function j2(u){return u=Qt(u),u&&To.test(u)?u.replace(ru,OD):u}function G2(u){return u=Qt(u),u&&zo.test(u)?u.replace(Pi,"\\$&"):u}var K2=Ai(function(u,o,d){return u+(d?"-":"")+o.toLowerCase()}),J2=Ai(function(u,o,d){return u+(d?" ":"")+o.toLowerCase()}),X2=p0("toLowerCase");function H2(u,o,d){u=Qt(u),o=Ot(o);var _=o?vi(u):0;if(!o||_>=o)return u;var b=(o-_)/2;return Tu(Du(b),d)+u+Tu(_u(b),d)}function Q2(u,o,d){u=Qt(u),o=Ot(o);var _=o?vi(u):0;return o&&_<o?u+Tu(o-_,d):u}function V2(u,o,d){u=Qt(u),o=Ot(o);var _=o?vi(u):0;return o&&_<o?Tu(o-_,d)+u:u}function tC(u,o,d){return d||o==null?o=0:o&&(o=+o),oy(Qt(u).replace(zi,""),o||0)}function eC(u,o,d){return(d?Ye(u,o,d):o===e)?o=1:o=Ot(o),Ia(Qt(u),o)}function rC(){var u=arguments,o=Qt(u[0]);return u.length<3?o:o.replace(u[1],u[2])}var nC=Ai(function(u,o,d){return u+(d?"_":"")+o.toLowerCase()});function iC(u,o,d){return d&&typeof d!="number"&&Ye(u,o,d)&&(o=d=e),d=d===e?ct:d>>>0,d?(u=Qt(u),u&&(typeof o=="string"||o!=null&&!ef(o))&&(o=or(o),!o&&mi(u))?bn(Sr(u),0,d):u.split(o,d)):[]}var sC=Ai(function(u,o,d){return u+(d?" ":"")+sf(o)});function uC(u,o,d){return u=Qt(u),d=d==null?0:kn(Ot(d),0,u.length),o=or(o),u.slice(d,d+o.length)==o}function oC(u,o,d){var _=B.templateSettings;d&&Ye(u,o,d)&&(o=e),u=Qt(u),o=Zu({},o,_,D0);var b=Zu({},o.imports,_.imports,D0),T=Te(b),L=ma(b,T),z,Y,Q=0,tt=o.interpolate||li,st="__p += '",dt=ga((o.escape||li).source+"|"+tt.source+"|"+(tt===nu?Go:li).source+"|"+(o.evaluate||li).source+"|$","g"),wt="//# sourceURL="+(re.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++vD+"]")+`
|
11
|
-
`;u.replace(dt,function(Ft,Ut,Wt,fr,Ze,cr){return Wt||(Wt=fr),st+=u.slice(Q,cr).replace(Pn,RD),Ut&&(z=!0,st+=`' +
|
12
|
-
__e(`+Ut+`) +
|
13
|
-
'`),Ze&&(Y=!0,st+=`';
|
14
|
-
`+Ze+`;
|
15
|
-
__p += '`),Wt&&(st+=`' +
|
16
|
-
((__t = (`+Wt+`)) == null ? '' : __t) +
|
17
|
-
'`),Q=cr+Ft.length,Ft}),st+=`';
|
18
|
-
`;var Ct=re.call(o,"variable")&&o.variable;if(!Ct)st=`with (obj) {
|
19
|
-
`+st+`
|
20
|
-
}
|
21
|
-
`;else if(Zo.test(Ct))throw new Bt(f);st=(Y?st.replace(nr,""):st).replace(ir,"$1").replace(mn,"$1;"),st="function("+(Ct||"obj")+`) {
|
22
|
-
`+(Ct?"":`obj || (obj = {});
|
23
|
-
`)+"var __t, __p = ''"+(z?", __e = _.escape":"")+(Y?`, __j = Array.prototype.join;
|
24
|
-
function print() { __p += __j.call(arguments, '') }
|
25
|
-
`:`;
|
26
|
-
`)+st+`return __p
|
27
|
-
}`;var Rt=hp(function(){return Jt(T,wt+"return "+st).apply(e,L)});if(Rt.source=st,tf(Rt))throw Rt;return Rt}function aC(u){return Qt(u).toLowerCase()}function fC(u){return Qt(u).toUpperCase()}function cC(u,o,d){if(u=Qt(u),u&&(d||o===e))return yh(u);if(!u||!(o=or(o)))return u;var _=Sr(u),b=Sr(o),T=Eh(_,b),L=Ah(_,b)+1;return bn(_,T,L).join("")}function lC(u,o,d){if(u=Qt(u),u&&(d||o===e))return u.slice(0,Ch(u)+1);if(!u||!(o=or(o)))return u;var _=Sr(u),b=Ah(_,Sr(o))+1;return bn(_,0,b).join("")}function hC(u,o,d){if(u=Qt(u),u&&(d||o===e))return u.replace(zi,"");if(!u||!(o=or(o)))return u;var _=Sr(u),b=Eh(_,Sr(o));return bn(_,b).join("")}function pC(u,o){var d=F,_=I;if(ge(o)){var b="separator"in o?o.separator:b;d="length"in o?Ot(o.length):d,_="omission"in o?or(o.omission):_}u=Qt(u);var T=u.length;if(mi(u)){var L=Sr(u);T=L.length}if(d>=T)return u;var z=d-vi(_);if(z<1)return _;var Y=L?bn(L,0,z).join(""):u.slice(0,z);if(b===e)return Y+_;if(L&&(z+=Y.length-z),ef(b)){if(u.slice(z).search(b)){var Q,tt=Y;for(b.global||(b=ga(b.source,Qt(iu.exec(b))+"g")),b.lastIndex=0;Q=b.exec(tt);)var st=Q.index;Y=Y.slice(0,st===e?z:st)}}else if(u.indexOf(or(b),z)!=z){var dt=Y.lastIndexOf(b);dt>-1&&(Y=Y.slice(0,dt))}return Y+_}function dC(u){return u=Qt(u),u&&Io.test(u)?u.replace(Ln,kD):u}var mC=Ai(function(u,o,d){return u+(d?" ":"")+o.toUpperCase()}),sf=p0("toUpperCase");function lp(u,o,d){return u=Qt(u),o=d?e:o,o===e?PD(u)?jD(u):SD(u):u.match(o)||[]}var hp=Lt(function(u,o){try{return sr(u,e,o)}catch(d){return tf(d)?d:new Bt(d)}}),vC=Qr(function(u,o){return vr(o,function(d){d=qr(d),Xr(u,d,Qa(u[d],u))}),u});function gC(u){var o=u==null?0:u.length,d=bt();return u=o?de(u,function(_){if(typeof _[1]!="function")throw new gr(a);return[d(_[0]),_[1]]}):[],Lt(function(_){for(var b=-1;++b<o;){var T=u[b];if(sr(T[0],this,_))return sr(T[1],this,_)}})}function wC(u){return ky(_r(u,c))}function uf(u){return function(){return u}}function _C(u,o){return u==null||u!==u?o:u}var DC=m0(),yC=m0(!0);function He(u){return u}function of(u){return Zh(typeof u=="function"?u:_r(u,c))}function EC(u){return Gh(_r(u,c))}function AC(u,o){return Kh(u,_r(o,c))}var bC=Lt(function(u,o){return function(d){return Ki(d,u,o)}}),CC=Lt(function(u,o){return function(d){return Ki(u,d,o)}});function af(u,o,d){var _=Te(o),b=Fu(o,_);d==null&&!(ge(o)&&(b.length||!_.length))&&(d=o,o=u,u=this,b=Fu(o,Te(o)));var T=!(ge(d)&&"chain"in d)||!!d.chain,L=tn(u);return vr(b,function(z){var Y=o[z];u[z]=Y,L&&(u.prototype[z]=function(){var Q=this.__chain__;if(T||Q){var tt=u(this.__wrapped__),st=tt.__actions__=Ke(this.__actions__);return st.push({func:Y,args:arguments,thisArg:u}),tt.__chain__=Q,tt}return Y.apply(u,wn([this.value()],arguments))})}),u}function FC(){return Re._===this&&(Re._=QD),this}function ff(){}function MC(u){return u=Ot(u),Lt(function(o){return Jh(o,u)})}var xC=za(de),SC=za(vh),NC=za(ca);function pp(u){return ja(u)?la(qr(u)):uE(u)}function BC(u){return function(o){return u==null?e:Yn(u,o)}}var IC=g0(),TC=g0(!0);function cf(){return[]}function lf(){return!1}function $C(){return{}}function OC(){return""}function RC(){return!0}function LC(u,o){if(u=Ot(u),u<1||u>j)return[];var d=ct,_=qe(u,ct);o=bt(o),u-=ct;for(var b=da(_,o);++d<u;)o(d);return b}function PC(u){return Tt(u)?de(u,qr):ar(u)?[u]:Ke(T0(Qt(u)))}function zC(u){var o=++XD;return Qt(u)+o}var UC=Iu(function(u,o){return u+o},0),qC=Ua("ceil"),WC=Iu(function(u,o){return u/o},1),kC=Ua("floor");function YC(u){return u&&u.length?Cu(u,He,Ca):e}function ZC(u,o){return u&&u.length?Cu(u,bt(o,2),Ca):e}function jC(u){return _h(u,He)}function GC(u,o){return _h(u,bt(o,2))}function KC(u){return u&&u.length?Cu(u,He,Sa):e}function JC(u,o){return u&&u.length?Cu(u,bt(o,2),Sa):e}var XC=Iu(function(u,o){return u*o},1),HC=Ua("round"),QC=Iu(function(u,o){return u-o},0);function VC(u){return u&&u.length?pa(u,He):0}function tF(u,o){return u&&u.length?pa(u,bt(o,2)):0}return B.after=Eb,B.ary=Y0,B.assign=f2,B.assignIn=ip,B.assignInWith=Zu,B.assignWith=c2,B.at=l2,B.before=Z0,B.bind=Qa,B.bindAll=vC,B.bindKey=j0,B.castArray=$b,B.chain=q0,B.chunk=kE,B.compact=YE,B.concat=ZE,B.cond=gC,B.conforms=wC,B.constant=uf,B.countBy=VA,B.create=h2,B.curry=G0,B.curryRight=K0,B.debounce=J0,B.defaults=p2,B.defaultsDeep=d2,B.defer=Ab,B.delay=bb,B.difference=jE,B.differenceBy=GE,B.differenceWith=KE,B.drop=JE,B.dropRight=XE,B.dropRightWhile=HE,B.dropWhile=QE,B.fill=VE,B.filter=eb,B.flatMap=ib,B.flatMapDeep=sb,B.flatMapDepth=ub,B.flatten=L0,B.flattenDeep=tA,B.flattenDepth=eA,B.flip=Cb,B.flow=DC,B.flowRight=yC,B.fromPairs=rA,B.functions=y2,B.functionsIn=E2,B.groupBy=ob,B.initial=iA,B.intersection=sA,B.intersectionBy=uA,B.intersectionWith=oA,B.invert=b2,B.invertBy=C2,B.invokeMap=fb,B.iteratee=of,B.keyBy=cb,B.keys=Te,B.keysIn=Xe,B.map=zu,B.mapKeys=M2,B.mapValues=x2,B.matches=EC,B.matchesProperty=AC,B.memoize=qu,B.merge=S2,B.mergeWith=sp,B.method=bC,B.methodOf=CC,B.mixin=af,B.negate=Wu,B.nthArg=MC,B.omit=N2,B.omitBy=B2,B.once=Fb,B.orderBy=lb,B.over=xC,B.overArgs=Mb,B.overEvery=SC,B.overSome=NC,B.partial=Va,B.partialRight=X0,B.partition=hb,B.pick=I2,B.pickBy=up,B.property=pp,B.propertyOf=BC,B.pull=lA,B.pullAll=z0,B.pullAllBy=hA,B.pullAllWith=pA,B.pullAt=dA,B.range=IC,B.rangeRight=TC,B.rearg=xb,B.reject=mb,B.remove=mA,B.rest=Sb,B.reverse=Xa,B.sampleSize=gb,B.set=$2,B.setWith=O2,B.shuffle=wb,B.slice=vA,B.sortBy=yb,B.sortedUniq=AA,B.sortedUniqBy=bA,B.split=iC,B.spread=Nb,B.tail=CA,B.take=FA,B.takeRight=MA,B.takeRightWhile=xA,B.takeWhile=SA,B.tap=YA,B.throttle=Bb,B.thru=Pu,B.toArray=ep,B.toPairs=op,B.toPairsIn=ap,B.toPath=PC,B.toPlainObject=np,B.transform=R2,B.unary=Ib,B.union=NA,B.unionBy=BA,B.unionWith=IA,B.uniq=TA,B.uniqBy=$A,B.uniqWith=OA,B.unset=L2,B.unzip=Ha,B.unzipWith=U0,B.update=P2,B.updateWith=z2,B.values=Fi,B.valuesIn=U2,B.without=RA,B.words=lp,B.wrap=Tb,B.xor=LA,B.xorBy=PA,B.xorWith=zA,B.zip=UA,B.zipObject=qA,B.zipObjectDeep=WA,B.zipWith=kA,B.entries=op,B.entriesIn=ap,B.extend=ip,B.extendWith=Zu,af(B,B),B.add=UC,B.attempt=hp,B.camelCase=Y2,B.capitalize=fp,B.ceil=qC,B.clamp=q2,B.clone=Ob,B.cloneDeep=Lb,B.cloneDeepWith=Pb,B.cloneWith=Rb,B.conformsTo=zb,B.deburr=cp,B.defaultTo=_C,B.divide=WC,B.endsWith=Z2,B.eq=Br,B.escape=j2,B.escapeRegExp=G2,B.every=tb,B.find=rb,B.findIndex=O0,B.findKey=m2,B.findLast=nb,B.findLastIndex=R0,B.findLastKey=v2,B.floor=kC,B.forEach=W0,B.forEachRight=k0,B.forIn=g2,B.forInRight=w2,B.forOwn=_2,B.forOwnRight=D2,B.get=rf,B.gt=Ub,B.gte=qb,B.has=A2,B.hasIn=nf,B.head=P0,B.identity=He,B.includes=ab,B.indexOf=nA,B.inRange=W2,B.invoke=F2,B.isArguments=Gn,B.isArray=Tt,B.isArrayBuffer=Wb,B.isArrayLike=Je,B.isArrayLikeObject=Ee,B.isBoolean=kb,B.isBuffer=Cn,B.isDate=Yb,B.isElement=Zb,B.isEmpty=jb,B.isEqual=Gb,B.isEqualWith=Kb,B.isError=tf,B.isFinite=Jb,B.isFunction=tn,B.isInteger=H0,B.isLength=ku,B.isMap=Q0,B.isMatch=Xb,B.isMatchWith=Hb,B.isNaN=Qb,B.isNative=Vb,B.isNil=e2,B.isNull=t2,B.isNumber=V0,B.isObject=ge,B.isObjectLike=_e,B.isPlainObject=ts,B.isRegExp=ef,B.isSafeInteger=r2,B.isSet=tp,B.isString=Yu,B.isSymbol=ar,B.isTypedArray=Ci,B.isUndefined=n2,B.isWeakMap=i2,B.isWeakSet=s2,B.join=aA,B.kebabCase=K2,B.last=yr,B.lastIndexOf=fA,B.lowerCase=J2,B.lowerFirst=X2,B.lt=u2,B.lte=o2,B.max=YC,B.maxBy=ZC,B.mean=jC,B.meanBy=GC,B.min=KC,B.minBy=JC,B.stubArray=cf,B.stubFalse=lf,B.stubObject=$C,B.stubString=OC,B.stubTrue=RC,B.multiply=XC,B.nth=cA,B.noConflict=FC,B.noop=ff,B.now=Uu,B.pad=H2,B.padEnd=Q2,B.padStart=V2,B.parseInt=tC,B.random=k2,B.reduce=pb,B.reduceRight=db,B.repeat=eC,B.replace=rC,B.result=T2,B.round=HC,B.runInContext=k,B.sample=vb,B.size=_b,B.snakeCase=nC,B.some=Db,B.sortedIndex=gA,B.sortedIndexBy=wA,B.sortedIndexOf=_A,B.sortedLastIndex=DA,B.sortedLastIndexBy=yA,B.sortedLastIndexOf=EA,B.startCase=sC,B.startsWith=uC,B.subtract=QC,B.sum=VC,B.sumBy=tF,B.template=oC,B.times=LC,B.toFinite=en,B.toInteger=Ot,B.toLength=rp,B.toLower=aC,B.toNumber=Er,B.toSafeInteger=a2,B.toString=Qt,B.toUpper=fC,B.trim=cC,B.trimEnd=lC,B.trimStart=hC,B.truncate=pC,B.unescape=dC,B.uniqueId=zC,B.upperCase=mC,B.upperFirst=sf,B.each=W0,B.eachRight=k0,B.first=P0,af(B,function(){var u={};return zr(B,function(o,d){re.call(B.prototype,d)||(u[d]=o)}),u}(),{chain:!1}),B.VERSION=r,vr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(u){B[u].placeholder=B}),vr(["drop","take"],function(u,o){qt.prototype[u]=function(d){d=d===e?1:Be(Ot(d),0);var _=this.__filtered__&&!o?new qt(this):this.clone();return _.__filtered__?_.__takeCount__=qe(d,_.__takeCount__):_.__views__.push({size:qe(d,ct),type:u+(_.__dir__<0?"Right":"")}),_},qt.prototype[u+"Right"]=function(d){return this.reverse()[u](d).reverse()}}),vr(["filter","map","takeWhile"],function(u,o){var d=o+1,_=d==U||d==P;qt.prototype[u]=function(b){var T=this.clone();return T.__iteratees__.push({iteratee:bt(b,3),type:d}),T.__filtered__=T.__filtered__||_,T}}),vr(["head","last"],function(u,o){var d="take"+(o?"Right":"");qt.prototype[u]=function(){return this[d](1).value()[0]}}),vr(["initial","tail"],function(u,o){var d="drop"+(o?"":"Right");qt.prototype[u]=function(){return this.__filtered__?new qt(this):this[d](1)}}),qt.prototype.compact=function(){return this.filter(He)},qt.prototype.find=function(u){return this.filter(u).head()},qt.prototype.findLast=function(u){return this.reverse().find(u)},qt.prototype.invokeMap=Lt(function(u,o){return typeof u=="function"?new qt(this):this.map(function(d){return Ki(d,u,o)})}),qt.prototype.reject=function(u){return this.filter(Wu(bt(u)))},qt.prototype.slice=function(u,o){u=Ot(u);var d=this;return d.__filtered__&&(u>0||o<0)?new qt(d):(u<0?d=d.takeRight(-u):u&&(d=d.drop(u)),o!==e&&(o=Ot(o),d=o<0?d.dropRight(-o):d.take(o-u)),d)},qt.prototype.takeRightWhile=function(u){return this.reverse().takeWhile(u).reverse()},qt.prototype.toArray=function(){return this.take(ct)},zr(qt.prototype,function(u,o){var d=/^(?:filter|find|map|reject)|While$/.test(o),_=/^(?:head|last)$/.test(o),b=B[_?"take"+(o=="last"?"Right":""):o],T=_||/^find/.test(o);b&&(B.prototype[o]=function(){var L=this.__wrapped__,z=_?[1]:arguments,Y=L instanceof qt,Q=z[0],tt=Y||Tt(L),st=function(Ut){var Wt=b.apply(B,wn([Ut],z));return _&&dt?Wt[0]:Wt};tt&&d&&typeof Q=="function"&&Q.length!=1&&(Y=tt=!1);var dt=this.__chain__,wt=!!this.__actions__.length,Ct=T&&!dt,Rt=Y&&!wt;if(!T&&tt){L=Rt?L:new qt(this);var Ft=u.apply(L,z);return Ft.__actions__.push({func:Pu,args:[st],thisArg:e}),new wr(Ft,dt)}return Ct&&Rt?u.apply(this,z):(Ft=this.thru(st),Ct?_?Ft.value()[0]:Ft.value():Ft)})}),vr(["pop","push","shift","sort","splice","unshift"],function(u){var o=cu[u],d=/^(?:push|sort|unshift)$/.test(u)?"tap":"thru",_=/^(?:pop|shift)$/.test(u);B.prototype[u]=function(){var b=arguments;if(_&&!this.__chain__){var T=this.value();return o.apply(Tt(T)?T:[],b)}return this[d](function(L){return o.apply(Tt(L)?L:[],b)})}}),zr(qt.prototype,function(u,o){var d=B[o];if(d){var _=d.name+"";re.call(Di,_)||(Di[_]=[]),Di[_].push({name:o,func:d})}}),Di[Bu(e,g).name]=[{name:"wrapper",func:e}],qt.prototype.clone=dy,qt.prototype.reverse=my,qt.prototype.value=vy,B.prototype.at=ZA,B.prototype.chain=jA,B.prototype.commit=GA,B.prototype.next=KA,B.prototype.plant=XA,B.prototype.reverse=HA,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=QA,B.prototype.first=B.prototype.head,qi&&(B.prototype[qi]=JA),B},gi=GD();zn?((zn.exports=gi)._=gi,ua._=gi):Re._=gi}).call(kt)}(Fn,Fn.exports);var Ar=Fn.exports;class mp{constructor(t,e){ut(this,"_defaultParams");ut(this,"_UserTypeFileds");ut(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Ar.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Ar.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){ut(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Ar.cloneDeep(this)}}}}var vf={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(kt,function(){var e=1e3,r=6e4,n=36e5,s="millisecond",a="second",f="minute",l="hour",p="day",h="week",c="month",m="quarter",w="year",D="date",v="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,g=/\[([^\]]+)]|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,A={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(U){var W=["th","st","nd","rd"],P=U%100;return"["+U+(W[(P-20)%10]||W[P]||W[0])+"]"}},E=function(U,W,P){var G=String(U);return!G||G.length>=W?U:""+Array(W+1-G.length).join(P)+U},S={s:E,z:function(U){var W=-U.utcOffset(),P=Math.abs(W),G=Math.floor(P/60),j=P%60;return(W<=0?"+":"-")+E(G,2,"0")+":"+E(j,2,"0")},m:function U(W,P){if(W.date()<P.date())return-U(P,W);var G=12*(P.year()-W.year())+(P.month()-W.month()),j=W.clone().add(G,c),H=P-j<0,V=W.clone().add(G+(H?-1:1),c);return+(-(G+(P-j)/(H?j-V:V-j))||0)},a:function(U){return U<0?Math.ceil(U)||0:Math.floor(U)},p:function(U){return{M:c,y:w,w:h,d:p,D,h:l,m:f,s:a,ms:s,Q:m}[U]||String(U||"").toLowerCase().replace(/s$/,"")},u:function(U){return U===void 0}},C="en",M={};M[C]=A;var x="$isDayjsObject",N=function(U){return U instanceof R||!(!U||!U[x])},$=function U(W,P,G){var j;if(!W)return C;if(typeof W=="string"){var H=W.toLowerCase();M[H]&&(j=H),P&&(M[H]=P,j=H);var V=W.split("-");if(!j&&V.length>1)return U(V[0])}else{var ct=W.name;M[ct]=W,j=ct}return!G&&j&&(C=j),j||!G&&C},F=function(U,W){if(N(U))return U.clone();var P=typeof W=="object"?W:{};return P.date=U,P.args=arguments,new R(P)},I=S;I.l=$,I.i=N,I.w=function(U,W){return F(U,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var R=function(){function U(P){this.$L=$(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[x]=!0}var W=U.prototype;return W.parse=function(P){this.$d=function(G){var j=G.date,H=G.utc;if(j===null)return new Date(NaN);if(I.u(j))return new Date;if(j instanceof Date)return new Date(j);if(typeof j=="string"&&!/Z$/i.test(j)){var V=j.match(y);if(V){var ct=V[2]-1||0,gt=(V[7]||"0").substring(0,3);return H?new Date(Date.UTC(V[1],ct,V[3]||1,V[4]||0,V[5]||0,V[6]||0,gt)):new Date(V[1],ct,V[3]||1,V[4]||0,V[5]||0,V[6]||0,gt)}}return new Date(j)}(P),this.init()},W.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},W.$utils=function(){return I},W.isValid=function(){return this.$d.toString()!==v},W.isSame=function(P,G){var j=F(P);return this.startOf(G)<=j&&j<=this.endOf(G)},W.isAfter=function(P,G){return F(P)<this.startOf(G)},W.isBefore=function(P,G){return this.endOf(G)<F(P)},W.$g=function(P,G,j){return I.u(P)?this[G]:this.set(j,P)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(P,G){var j=this,H=!!I.u(G)||G,V=I.p(P),ct=function(It,xt){var ie=I.w(j.$u?Date.UTC(j.$y,xt,It):new Date(j.$y,xt,It),j);return H?ie:ie.endOf(p)},gt=function(It,xt){return I.w(j.toDate()[It].apply(j.toDate("s"),(H?[0,0,0,0]:[23,59,59,999]).slice(xt)),j)},ft=this.$W,_t=this.$M,yt=this.$D,Nt="set"+(this.$u?"UTC":"");switch(V){case w:return H?ct(1,0):ct(31,11);case c:return H?ct(1,_t):ct(0,_t+1);case h:var Et=this.$locale().weekStart||0,ee=(ft<Et?ft+7:ft)-Et;return ct(H?yt-ee:yt+(6-ee),_t);case p:case D:return gt(Nt+"Hours",0);case l:return gt(Nt+"Minutes",1);case f:return gt(Nt+"Seconds",2);case a:return gt(Nt+"Milliseconds",3);default:return this.clone()}},W.endOf=function(P){return this.startOf(P,!1)},W.$set=function(P,G){var j,H=I.p(P),V="set"+(this.$u?"UTC":""),ct=(j={},j[p]=V+"Date",j[D]=V+"Date",j[c]=V+"Month",j[w]=V+"FullYear",j[l]=V+"Hours",j[f]=V+"Minutes",j[a]=V+"Seconds",j[s]=V+"Milliseconds",j)[H],gt=H===p?this.$D+(G-this.$W):G;if(H===c||H===w){var ft=this.clone().set(D,1);ft.$d[ct](gt),ft.init(),this.$d=ft.set(D,Math.min(this.$D,ft.daysInMonth())).$d}else ct&&this.$d[ct](gt);return this.init(),this},W.set=function(P,G){return this.clone().$set(P,G)},W.get=function(P){return this[I.p(P)]()},W.add=function(P,G){var j,H=this;P=Number(P);var V=I.p(G),ct=function(_t){var yt=F(H);return I.w(yt.date(yt.date()+Math.round(_t*P)),H)};if(V===c)return this.set(c,this.$M+P);if(V===w)return this.set(w,this.$y+P);if(V===p)return ct(1);if(V===h)return ct(7);var gt=(j={},j[f]=r,j[l]=n,j[a]=e,j)[V]||1,ft=this.$d.getTime()+P*gt;return I.w(ft,this)},W.subtract=function(P,G){return this.add(-1*P,G)},W.format=function(P){var G=this,j=this.$locale();if(!this.isValid())return j.invalidDate||v;var H=P||"YYYY-MM-DDTHH:mm:ssZ",V=I.z(this),ct=this.$H,gt=this.$m,ft=this.$M,_t=j.weekdays,yt=j.months,Nt=j.meridiem,Et=function(xt,ie,Xt,zt){return xt&&(xt[ie]||xt(G,H))||Xt[ie].slice(0,zt)},ee=function(xt){return I.s(ct%12||12,xt,"0")},It=Nt||function(xt,ie,Xt){var zt=xt<12?"AM":"PM";return Xt?zt.toLowerCase():zt};return H.replace(g,function(xt,ie){return ie||function(Xt){switch(Xt){case"YY":return String(G.$y).slice(-2);case"YYYY":return I.s(G.$y,4,"0");case"M":return ft+1;case"MM":return I.s(ft+1,2,"0");case"MMM":return Et(j.monthsShort,ft,yt,3);case"MMMM":return Et(yt,ft);case"D":return G.$D;case"DD":return I.s(G.$D,2,"0");case"d":return String(G.$W);case"dd":return Et(j.weekdaysMin,G.$W,_t,2);case"ddd":return Et(j.weekdaysShort,G.$W,_t,3);case"dddd":return _t[G.$W];case"H":return String(ct);case"HH":return I.s(ct,2,"0");case"h":return ee(1);case"hh":return ee(2);case"a":return It(ct,gt,!0);case"A":return It(ct,gt,!1);case"m":return String(gt);case"mm":return I.s(gt,2,"0");case"s":return String(G.$s);case"ss":return I.s(G.$s,2,"0");case"SSS":return I.s(G.$ms,3,"0");case"Z":return V}return null}(xt)||V.replace(":","")})},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(P,G,j){var H,V=this,ct=I.p(G),gt=F(P),ft=(gt.utcOffset()-this.utcOffset())*r,_t=this-gt,yt=function(){return I.m(V,gt)};switch(ct){case w:H=yt()/12;break;case c:H=yt();break;case m:H=yt()/3;break;case h:H=(_t-ft)/6048e5;break;case p:H=(_t-ft)/864e5;break;case l:H=_t/n;break;case f:H=_t/r;break;case a:H=_t/e;break;default:H=_t}return j?H:I.a(H)},W.daysInMonth=function(){return this.endOf(c).$D},W.$locale=function(){return M[this.$L]},W.locale=function(P,G){if(!P)return this.$L;var j=this.clone(),H=$(P,G,!0);return H&&(j.$L=H),j},W.clone=function(){return I.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()},U}(),q=R.prototype;return F.prototype=q,[["$ms",s],["$s",a],["$m",f],["$H",l],["$W",p],["$M",c],["$y",w],["$D",D]].forEach(function(U){q[U[1]]=function(W){return this.$g(W,U[0],U[1])}}),F.extend=function(U,W){return U.$i||(U(W,R,F),U.$i=!0),F},F.locale=$,F.isDayjs=N,F.unix=function(U){return F(1e3*U)},F.en=M[C],F.Ls=M,F.p={},F})})(vf);var vp=vf.exports,ne=Zt(vp),gf={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(kt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,a,f){var l=a.prototype;f.utc=function(v){var y={date:v,utc:!0,args:arguments};return new a(y)},l.utc=function(v){var y=f(this.toDate(),{locale:this.$L,utc:!0});return v?y.add(this.utcOffset(),e):y},l.local=function(){return f(this.toDate(),{locale:this.$L,utc:!1})};var p=l.parse;l.parse=function(v){v.utc&&(this.$u=!0),this.$utils().u(v.$offset)||(this.$offset=v.$offset),p.call(this,v)};var h=l.init;l.init=function(){if(this.$u){var v=this.$d;this.$y=v.getUTCFullYear(),this.$M=v.getUTCMonth(),this.$D=v.getUTCDate(),this.$W=v.getUTCDay(),this.$H=v.getUTCHours(),this.$m=v.getUTCMinutes(),this.$s=v.getUTCSeconds(),this.$ms=v.getUTCMilliseconds()}else h.call(this)};var c=l.utcOffset;l.utcOffset=function(v,y){var g=this.$utils().u;if(g(v))return this.$u?0:g(this.$offset)?c.call(this):this.$offset;if(typeof v=="string"&&(v=function(C){C===void 0&&(C="");var M=C.match(r);if(!M)return null;var x=(""+M[0]).match(n)||["-",0,0],N=x[0],$=60*+x[1]+ +x[2];return $===0?0:N==="+"?$:-$}(v),v===null))return this;var A=Math.abs(v)<=16?60*v:v,E=this;if(y)return E.$offset=A,E.$u=v===0,E;if(v!==0){var S=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(E=this.local().add(A+S,e)).$offset=A,E.$x.$localOffset=S}else E=this.utc();return E};var m=l.format;l.format=function(v){var y=v||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return m.call(this,y)},l.valueOf=function(){var v=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*v},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var w=l.toDate;l.toDate=function(v){return v==="s"&&this.$offset?f(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():w.call(this)};var D=l.diff;l.diff=function(v,y,g){if(v&&this.$u===v.$u)return D.call(this,v,y,g);var A=this.local(),E=f(v).local();return D.call(A,E,y,g)}}})})(gf);var gp=gf.exports,wp=Zt(gp),wf={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(kt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,s,a){var f,l=function(m,w,D){D===void 0&&(D={});var v=new Date(m),y=function(g,A){A===void 0&&(A={});var E=A.timeZoneName||"short",S=g+"|"+E,C=r[S];return C||(C=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:g,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:E}),r[S]=C),C}(w,D);return y.formatToParts(v)},p=function(m,w){for(var D=l(m,w),v=[],y=0;y<D.length;y+=1){var g=D[y],A=g.type,E=g.value,S=e[A];S>=0&&(v[S]=parseInt(E,10))}var C=v[3],M=C===24?0:C,x=v[0]+"-"+v[1]+"-"+v[2]+" "+M+":"+v[4]+":"+v[5]+":000",N=+m;return(a.utc(x).valueOf()-(N-=N%1e3))/6e4},h=s.prototype;h.tz=function(m,w){m===void 0&&(m=f);var D=this.utcOffset(),v=this.toDate(),y=v.toLocaleString("en-US",{timeZone:m}),g=Math.round((v-new Date(y))/1e3/60),A=a(y,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(v.getTimezoneOffset()/15)-g,!0);if(w){var E=A.utcOffset();A=A.add(D-E,"minute")}return A.$x.$timezone=m,A},h.offsetName=function(m){var w=this.$x.$timezone||a.tz.guess(),D=l(this.valueOf(),w,{timeZoneName:m}).find(function(v){return v.type.toLowerCase()==="timezonename"});return D&&D.value};var c=h.startOf;h.startOf=function(m,w){if(!this.$x||!this.$x.$timezone)return c.call(this,m,w);var D=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return c.call(D,m,w).tz(this.$x.$timezone,!0)},a.tz=function(m,w,D){var v=D&&w,y=D||w||f,g=p(+a(),y);if(typeof m!="string")return a(m).tz(y);var A=function(M,x,N){var $=M-60*x*1e3,F=p($,N);if(x===F)return[$,x];var I=p($-=60*(F-x)*1e3,N);return F===I?[$,F]:[M-60*Math.min(F,I)*1e3,Math.max(F,I)]}(a.utc(m,v).valueOf(),g,y),E=A[0],S=A[1],C=a(E).utcOffset(S);return C.$x.$timezone=y,C},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(m){f=m}}})})(wf);var _p=wf.exports,Dp=Zt(_p),_f={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(kt,function(){var e="week",r="year";return function(n,s,a){var f=s.prototype;f.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-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),c=a(this).endOf(e);if(h.isBefore(c))return 1}var m=a(this).startOf(r).date(p).startOf(e).subtract(1,"millisecond"),w=this.diff(m,e,!0);return w<0?a(this).startOf("week").week():Math.ceil(w)},f.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}})})(_f);var yp=_f.exports,Ep=Zt(yp);function es(i){const t=parseInt(i)||1;let e=i.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function Ap(i){const t=/([+-])(\d{2})(\d{2})/,e=i.match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,s]=e;return(r==="+"?1:-1)*(parseInt(n,10)*60+parseInt(s,10))}function br(i,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ne(i).utcOffset(Ap(t)):ne(i).tz(t)}function Mn(i){const[t,e]=es(i);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)}ne.extend(Ep),ne.extend(wp),ne.extend(Dp);class bp{constructor(){ut(this,"_cacheData");ut(this,"_barIndex");ut(this,"_isRealTimeBar");ut(this,"_barstate");ut(this,"_priceVariables");ut(this,"_lastBarIndex");ut(this,"_currentBarTime");ut(this,"_lastBarTime");ut(this,"_period");ut(this,"_offsetTime");ut(this,"_timeframe");ut(this,"_ta");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 Cp,this._timeframe=new Fp,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new Mp}get ta(){return this._ta}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 ne(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ne(this._currentBarTime).minute()}get second(){return ne(this._currentBarTime).second()}get month(){return ne(this._currentBarTime).month()+1}get year(){return ne(this._currentBarTime).year()}get dayofweek(){return ne(this._currentBarTime).day()+1}get dayofmonth(){return ne(this._currentBarTime).date()}get weekofyear(){return ne(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=es(this._period);return this._isRealTimeBar?void 0:ne(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}getTimeTradingday(t,e){const[r,n]=es(e),s=ne(t).add(r,n);return["M","w","y"].includes(n)?s.subtract(1,"d").valueOf():s.startOf("d").add(this._offsetTime,"h").valueOf()}updateData(t){const{barIndex:e,close:r,open:n,high:s,low:a,volume:f,lastBarIndex:l,time:p,lastBarTime:h,period:c="1D",offsetTime:m=5}=t;this._priceVariables={close:r,open:n,high:s,low:a,volume:f},e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._currentBarTime=p,this._lastBarIndex=l,this._barIndex=e,this._lastBarTime=h,this._period=c,this._offsetTime=m,this._timeframe.update(c),this._barstate.update(e,l,!1,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){let n=this._cacheData[t]||[];n[this._barIndex]=r,n=n.filter(()=>!0);const s=n[n.length-1-e];return this._cacheData[t]=n,s}setCacheData(t,e){const r=this._cacheData[t]||[];r[this._barIndex]=e,this._cacheData[t]=r}getTypeInstance(t,e){return new mp(t,e)}getVarValue(t,e,r){const n=`${t}_${e}`,s=r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n];if(s)return s}setVarValue(t,e,r,n){const s=`${t}_${e}`;let a;switch(typeof r=="object"&&r&&(n="var",a=r.varipKeys),n){case"var":if(this._isRealTimeBar){const f=Ar.cloneDeep(r);if(this._cacheData.varNewData[s]=f,a&&a.length)for(const l of a)this._cacheData.varData[s][l]=f[l]}else this._cacheData.varData[s]=r;break;case"varip":this._cacheData.varipData[s]=r;break}return r}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Ar.uniq([...t,...e]):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):t-e}}class Cp{constructor(){ut(this,"_isMarketOpen");ut(this,"_currentBarIndex");ut(this,"_totalBarIndex");ut(this,"_isRealTimeBar");ut(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 Fp{constructor(){ut(this,"_period");ut(this,"_multiplier");ut(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=es(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 Mp{constructor(){ut(this,"_preAccdist");ut(this,"_preNvi");ut(this,"_prePvi");ut(this,"_preObv");ut(this,"_prePvt");ut(this,"_preWad");ut(this,"_preVwap");ut(this,"_preValue");ut(this,"_currentData");ut(this,"_preData");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={}}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const s=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=s),this._preValue.accdist=s,s}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,s=(2*t-r-e)/((r-e)*n);return this._preValue.iii=s,s}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:s}=this._currentData,a=(t-s)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const s=Math.max(e,n),a=Math.min(r,n),f=t-n,p=(f>0?t-a:f<0?t-s:0)+this._preWad;return!this.isRealTime&&(this._preWad=p),this._preValue.wad=p,p}get vwap(){if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:s}=this._preVwap;if(self.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin")&&(s=!0,r=n=0),!s)return;const f=t*e+r,l=e+n;!this.isRealTime&&(this._preVwap={sum:f,sumV:l,isReset:s});const p=f/l;return this._preValue.vwap=p,p}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const f=t||1;return n&&e?a=s<r?f+(n-e)/e*f:f:a=f,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const f=t||1;return n&&e?a=s>r?f+(n-e)/e*f:f:a=f,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}var $r=(i=>(i.BOOL="bool",i.INT="int",i.FLOAT="float",i.ARRAY="array",i.BOX="box",i.CHART_POINT="chart.point",i.COLOR="color",i.CONST="const",i.LABEL="label",i.LINE="line",i.LINEFILL="linefill",i.MAP="map",i.MATRIX="matrix",i.POLYLINE="polyline",i.SERIES="series",i.SIMPLE="simple",i.STRING="string",i.TABLE="table",i.UNDETERMINED="undetermined type",i.INPUT="input",i.NA="na",i.VOID="void",i))($r||{}),rs=(i=>(i.dividends="dividends",i.none="none",i.splits="splits",i))(rs||{}),ns=(i=>(i.freqAll="freq_all",i.freqOncePerBar="freq_once_per_bar",i.freqOncePerBarClose="freq_once_per_bar_close",i))(ns||{}),Mi=(i=>(i.gapsOff="gaps_off",i.gapsOn="gaps_on",i.lookaheadOff="lookahead_off",i.lookaheadOn="lookahead_on",i))(Mi||{}),Cr=(i=>(i.all="all",i.dataWindow="data_window",i.none="none",i.pane="pane",i.priceScale="price_scale",i.statusLine="status_line",i))(Cr||{}),xi=(i=>(i.both="both",i.left="left",i.none="none",i.right="right",i))(xi||{}),Kn=(i=>(i.inherit="inherit",i.mintick="mintick",i.percent="percent",i.price="price",i.volume="volume",i))(Kn||{}),is=(i=>(i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(is||{}),we=(i=>(i.styleArrowdown="style_arrowdown",i.styleArrowup="style_arrowup",i.styleCircle="style_circle",i.styleCross="style_cross",i.styleDiamond="style_diamond",i.styleFlag="style_flag",i.styleLabelCenter="style_label_center",i.styleLabelDown="style_label_down",i.styleLabelLeft="style_label_left",i.styleLabelLowerLeft="style_label_lower_left",i.styleLabelLowerRight="style_label_lower_right",i.styleLabelRight="style_label_right",i.styleLabelUp="style_label_up",i.styleLabelUpperLeft="style_label_upper_left",i.styleLabelUpperRight="style_label_upper_right",i.styleNone="style_none",i.styleSquare="style_square",i.styleTextOutline="style_text_outline",i.styleTriangledown="style_triangledown",i.styleTriangleup="style_triangleup",i.styleXcross="style_xcross",i))(we||{}),xn=(i=>(i.styleArrowBoth="style_arrow_both",i.styleArrowLeft="style_arrow_left",i.styleArrowRight="style_arrow_right",i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(xn||{}),Jn=(i=>(i.abovebar="abovebar",i.absolute="absolute",i.belowbar="belowbar",i.bottom="bottom",i.top="top",i))(Jn||{}),Sn=(i=>(i.ascending="ascending",i.descending="descending",i))(Sn||{}),lr=(i=>(i.styleArea="Area",i.styleAreabr="Area With Breaks",i.styleCircles="Circles",i.styleColumns="Columns",i.styleCross="Cross",i.styleHistogram="Histogram",i.styleLine="Line",i.styleLinebr="Line With Breaks",i.styleStepline="Step Line",i.styleSteplineDiamond="Step Line With Diamonds",i.styleSteplinebr="Step line with Breaks",i))(lr||{}),Or=(i=>(i.bottomCenter="bottom_center",i.bottomLeft="bottom_left",i.bottomRight="bottom_right",i.middleCenter="middle_center",i.middleLeft="middle_left",i.middleRight="middle_right",i.topCenter="top_center",i.topLeft="top_left",i.topRight="top_right",i))(Or||{}),ss=(i=>(i.left="left",i.none="none",i.right="right",i))(ss||{}),Gu=(i=>(i.extended="extended",i.regular="regular",i))(Gu||{}),Qe=(i=>(i.arrowdown="arrowdown",i.arrowup="arrowup",i.circle="circle",i.cross="cross",i.diamond="diamond",i.flag="flag",i.labeldown="labeldown",i.labelup="labelup",i.square="square",i.triangledown="triangledown",i.triangleup="triangleup",i.xcross="xcross",i))(Qe||{}),Nn=(i=>(i.auto="auto",i.huge="huge",i.large="large",i.normal="normal",i.small="small",i.tiny="tiny",i))(Nn||{}),us=(i=>(i.cash="cash",i.fixed="fixed",i.percentOfEquity="percent_of_equity",i))(us||{}),os=(i=>(i.cashPerContract="cash_per_contract",i.cashPerOrder="cash_per_order",i.percent="percent",i))(os||{}),as=(i=>(i.all="all",i.long="long",i.short="short",i))(as||{}),fs=(i=>(i.cancel="cancel",i.none="none",i.reduce="reduce",i))(fs||{}),nn=(i=>(i.alignBottom="align_bottom",i.alignCenter="align_center",i.alignLeft="align_left",i.alignRight="align_right",i.alignTop="align_top",i.wrapAuto="wrap_auto",i.wrapNone="wrap_none",i))(nn||{}),Ku=(i=>(i.bar_index="bar_index",i.bar_time="bar_time",i))(Ku||{}),cs=(i=>(i.abovebar="abovebar",i.belowbar="belowbar",i.price="price",i))(cs||{}),ls=(i=>(i.actual="actual",i.estimate="estimate",i.standardized="standardized",i))(ls||{}),Bn=(i=>(i.traditional="Traditional",i.fibonacci="Fibonacci",i.woodie="Woodie",i.classic="Classic",i.dm="DM",i.camarilla="Camarilla",i))(Bn||{});const xp={freq_all:ns.freqAll,freq_once_per_bar:ns.freqOncePerBar,freq_once_per_bar_close:ns.freqOncePerBarClose},Sp={gaps_off:Mi.gapsOff,gaps_on:Mi.gapsOn,lookahead_off:Mi.lookaheadOff,lookahead_on:Mi.lookaheadOn},Np={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"},Bp={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"},Ip={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Tp={all:[Cr.dataWindow,Cr.pane,Cr.priceScale,Cr.statusLine],data_window:[Cr.dataWindow],none:[],pane:[Cr.pane],price_scale:[Cr.priceScale],status_line:[Cr.statusLine]},$p={both:xi.both,left:xi.left,none:xi.none,right:xi.right},Op={inherit:Kn.inherit,mintick:Kn.mintick,percent:Kn.percent,price:Kn.price,volume:Kn.volume},Rp={style_solid:is.styleSolid,style_dashed:is.styleDashed,style_dotted:is.styleDotted},Lp={style_arrowdown:we.styleArrowdown,style_arrowup:we.styleArrowup,style_circle:we.styleCircle,style_cross:we.styleCross,style_diamond:we.styleDiamond,style_flag:we.styleFlag,style_label_center:we.styleLabelCenter,style_label_down:we.styleLabelDown,style_label_left:we.styleLabelLeft,style_label_lower_left:we.styleLabelLowerLeft,style_label_lower_right:we.styleLabelLowerRight,style_label_right:we.styleLabelRight,style_label_up:we.styleLabelUp,style_label_upper_left:we.styleLabelUpperLeft,style_label_upper_right:we.styleLabelUpperRight,style_none:we.styleNone,style_square:we.styleSquare,style_text_outline:we.styleTextOutline,style_triangledown:we.styleTriangledown,style_triangleup:we.styleTriangleup,style_xcross:we.styleXcross},Pp={style_arrow_both:xn.styleArrowBoth,style_arrow_left:xn.styleArrowLeft,style_arrow_right:xn.styleArrowRight,style_dashed:xn.styleDashed,style_dotted:xn.styleDotted,style_solid:xn.styleSolid},zp={abovebar:Jn.abovebar,absolute:Jn.absolute,belowbar:Jn.belowbar,bottom:Jn.bottom,top:Jn.top},Up={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},qp={style_area:lr.styleArea,style_areabr:lr.styleAreabr,style_circles:lr.styleCircles,style_columns:lr.styleColumns,style_cross:lr.styleCross,style_histogram:lr.styleHistogram,style_line:lr.styleLine,style_linebr:lr.styleLinebr,style_stepline:lr.styleStepline,style_stepline_diamond:lr.styleSteplineDiamond,style_steplinebr:lr.styleSteplinebr},Wp={bottom_center:Or.bottomCenter,bottom_left:Or.bottomLeft,bottom_right:Or.bottomRight,middle_center:Or.middleCenter,middle_left:Or.middleLeft,middle_right:Or.middleRight,top_center:Or.topCenter,top_left:Or.topLeft,top_right:Or.topRight},kp={left:ss.left,none:ss.none,right:ss.right},Yp={arrowdown:Qe.arrowdown,arrowup:Qe.arrowup,circle:Qe.circle,cross:Qe.cross,diamond:Qe.diamond,flag:Qe.flag,labeldown:Qe.labeldown,labelup:Qe.labelup,square:Qe.square,triangledown:Qe.triangledown,triangleup:Qe.triangleup,xcross:Qe.xcross},Zp={auto:Nn.auto,huge:Nn.huge,large:Nn.large,normal:Nn.normal,small:Nn.small,tiny:Nn.tiny},jp={cash:us.cash,fixed:us.fixed,percent_of_equity:us.percentOfEquity,commission:{cash_per_contract:os.cashPerContract,cash_per_order:os.cashPerOrder,percent:os.percent},direction:{all:as.all,long:as.long,short:as.short},oca:{cancel:fs.cancel,none:fs.none,reduce:fs.reduce}},Gp={align_bottom:nn.alignBottom,align_center:nn.alignCenter,align_left:nn.alignLeft,align_right:nn.alignRight,align_top:nn.alignTop,wrap_auto:nn.wrapAuto,wrap_none:nn.wrapNone},Kp={bar_index:Ku.bar_index,bar_time:Ku.bar_time},Jp={abovebar:cs.abovebar,belowbar:cs.belowbar,price:cs.price},Xp={actual:ls.actual,estimate:ls.estimate,standardized:ls.standardized};class Hp{constructor(){ut(this,"adjustment",{dividends:rs.dividends,none:rs.none,splits:rs.splits});ut(this,"alert",xp);ut(this,"barmerge",Sp);ut(this,"color",Np);ut(this,"currency",Bp);ut(this,"dayofweek",Ip);ut(this,"earnings",Xp);ut(this,"display",Tp);ut(this,"extend",$p);ut(this,"font",{family_default:"SimSun",family_monospace:"Monospace"});ut(this,"format",Op);ut(this,"hline",Rp);ut(this,"label",Lp);ut(this,"line",Pp);ut(this,"location",zp);ut(this,"math",Up);ut(this,"order",{ascending:Sn.ascending,descending:Sn.descending});ut(this,"plot",qp);ut(this,"position",Wp);ut(this,"scale",kp);ut(this,"session",{extended:Gu.extended,regular:Gu.regular});ut(this,"shape",Yp);ut(this,"size",Zp);ut(this,"splits",{denominator:"denominator",numerator:"numerator"});ut(this,"strategy",jp);ut(this,"text",Gp);ut(this,"xloc",Kp);ut(this,"yloc",Jp)}updateData(){}}var Df={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(kt,function(){return function(e,r,n){r.prototype.isBetween=function(s,a,f,l){var p=n(s),h=n(a),c=(l=l||"()")[0]==="(",m=l[1]===")";return(c?this.isAfter(p,f):!this.isBefore(p,f))&&(m?this.isBefore(h,f):!this.isAfter(h,f))||(c?this.isBefore(p,f):!this.isAfter(p,f))&&(m?this.isAfter(h,f):!this.isBefore(h,f))}}})})(Df);var Qp=Df.exports,Vp=Zt(Qp),yf={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(kt,function(){return function(e,r,n){var s=r.prototype,a=function(m){var w,D=m.date,v=m.utc,y={};if(!((w=D)===null||w instanceof Date||w instanceof Array||s.$utils().u(w)||w.constructor.name!=="Object")){if(!Object.keys(D).length)return new Date;var g=v?n.utc():n();Object.keys(D).forEach(function($){var F,I;y[F=$,I=s.$utils().p(F),I==="date"?"day":I]=D[$]});var A=y.day||(y.year||y.month>=0?1:g.date()),E=y.year||g.year(),S=y.month>=0?y.month:y.year||y.day?0:g.month(),C=y.hour||0,M=y.minute||0,x=y.second||0,N=y.millisecond||0;return v?new Date(Date.UTC(E,S,A,C,M,x,N)):new Date(E,S,A,C,M,x,N)}return D},f=s.parse;s.parse=function(m){m.date=a.bind(this)(m),f.bind(this)(m)};var l=s.set,p=s.add,h=s.subtract,c=function(m,w,D,v){v===void 0&&(v=1);var y=Object.keys(w),g=this;return y.forEach(function(A){g=m.bind(g)(w[A]*v,A)}),g};s.set=function(m,w){return w=w===void 0?m:w,m.constructor.name==="Object"?c.bind(this)(function(D,v){return l.bind(this)(v,D)},w,m):l.bind(this)(m,w)},s.add=function(m,w){return m.constructor.name==="Object"?c.bind(this)(p,m,w):p.bind(this)(m,w)},s.subtract=function(m,w){return m.constructor.name==="Object"?c.bind(this)(p,m,w,-1):h.bind(this)(m,w)}}})})(yf);var td=yf.exports,ed=Zt(td),Ef={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(kt,function(){var e,r,n=1e3,s=6e4,a=36e5,f=864e5,l=/\[([^\]]+)]|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,c=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,m={years:p,months:h,days:f,hours:a,minutes:s,seconds:n,milliseconds:1,weeks:6048e5},w=function(M){return M instanceof S},D=function(M,x,N){return new S(M,N,x.$l)},v=function(M){return r.p(M)+"s"},y=function(M){return M<0},g=function(M){return y(M)?Math.ceil(M):Math.floor(M)},A=function(M){return Math.abs(M)},E=function(M,x){return M?y(M)?{negative:!0,format:""+A(M)+x}:{negative:!1,format:""+M+x}:{negative:!1,format:""}},S=function(){function M(N,$,F){var I=this;if(this.$d={},this.$l=F,N===void 0&&(this.$ms=0,this.parseFromMilliseconds()),$)return D(N*m[v($)],this);if(typeof N=="number")return this.$ms=N,this.parseFromMilliseconds(),this;if(typeof N=="object")return Object.keys(N).forEach(function(U){I.$d[v(U)]=N[U]}),this.calMilliseconds(),this;if(typeof N=="string"){var R=N.match(c);if(R){var q=R.slice(2).map(function(U){return U!=null?Number(U):0});return this.$d.years=q[0],this.$d.months=q[1],this.$d.weeks=q[2],this.$d.days=q[3],this.$d.hours=q[4],this.$d.minutes=q[5],this.$d.seconds=q[6],this.calMilliseconds(),this}}return this}var x=M.prototype;return x.calMilliseconds=function(){var N=this;this.$ms=Object.keys(this.$d).reduce(function($,F){return $+(N.$d[F]||0)*m[F]},0)},x.parseFromMilliseconds=function(){var N=this.$ms;this.$d.years=g(N/p),N%=p,this.$d.months=g(N/h),N%=h,this.$d.days=g(N/f),N%=f,this.$d.hours=g(N/a),N%=a,this.$d.minutes=g(N/s),N%=s,this.$d.seconds=g(N/n),N%=n,this.$d.milliseconds=N},x.toISOString=function(){var N=E(this.$d.years,"Y"),$=E(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var I=E(F,"D"),R=E(this.$d.hours,"H"),q=E(this.$d.minutes,"M"),U=this.$d.seconds||0;this.$d.milliseconds&&(U+=this.$d.milliseconds/1e3,U=Math.round(1e3*U)/1e3);var W=E(U,"S"),P=N.negative||$.negative||I.negative||R.negative||q.negative||W.negative,G=R.format||q.format||W.format?"T":"",j=(P?"-":"")+"P"+N.format+$.format+I.format+G+R.format+q.format+W.format;return j==="P"||j==="-P"?"P0D":j},x.toJSON=function(){return this.toISOString()},x.format=function(N){var $=N||"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 $.replace(l,function(I,R){return R||String(F[I])})},x.as=function(N){return this.$ms/m[v(N)]},x.get=function(N){var $=this.$ms,F=v(N);return F==="milliseconds"?$%=1e3:$=F==="weeks"?g($/m[F]):this.$d[F],$||0},x.add=function(N,$,F){var I;return I=$?N*m[v($)]:w(N)?N.$ms:D(N,this).$ms,D(this.$ms+I*(F?-1:1),this)},x.subtract=function(N,$){return this.add(N,$,!0)},x.locale=function(N){var $=this.clone();return $.$l=N,$},x.clone=function(){return D(this.$ms,this)},x.humanize=function(N){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!N)},x.valueOf=function(){return this.asMilliseconds()},x.milliseconds=function(){return this.get("milliseconds")},x.asMilliseconds=function(){return this.as("milliseconds")},x.seconds=function(){return this.get("seconds")},x.asSeconds=function(){return this.as("seconds")},x.minutes=function(){return this.get("minutes")},x.asMinutes=function(){return this.as("minutes")},x.hours=function(){return this.get("hours")},x.asHours=function(){return this.as("hours")},x.days=function(){return this.get("days")},x.asDays=function(){return this.as("days")},x.weeks=function(){return this.get("weeks")},x.asWeeks=function(){return this.as("weeks")},x.months=function(){return this.get("months")},x.asMonths=function(){return this.as("months")},x.years=function(){return this.get("years")},x.asYears=function(){return this.as("years")},M}(),C=function(M,x,N){return M.add(x.years()*N,"y").add(x.months()*N,"M").add(x.days()*N,"d").add(x.hours()*N,"h").add(x.minutes()*N,"m").add(x.seconds()*N,"s").add(x.milliseconds()*N,"ms")};return function(M,x,N){e=N,r=N().$utils(),N.duration=function(I,R){var q=N.locale();return D(I,{$l:q},R)},N.isDuration=w;var $=x.prototype.add,F=x.prototype.subtract;x.prototype.add=function(I,R){return w(I)?C(this,I,1):$.bind(this)(I,R)},x.prototype.subtract=function(I,R){return w(I)?C(this,I,-1):F.bind(this)(I,R)}}})})(Ef);var rd=Ef.exports,nd=Zt(rd);class id{new({size:t,initial_value:e}={}){return new Vt(t,e)}new_float({size:t,initial_value:e}={}){return new Vt(t,e)}new_int({size:t,initial_value:e}={}){return new Vt(t,e)}new_color({size:t,initial_value:e}={}){return new Vt(t,e)}new_bool({size:t,initial_value:e}={}){return new Vt(t,e)}new_string({size:t,initial_value:e}={}){return new Vt(t,e)}new_line({size:t,initial_value:e}={}){return new Vt(t,e)}new_box({size:t,initial_value:e}={}){return new Vt(t,e)}new_table({size:t,initial_value:e}={}){return new Vt(t,e)}new_linefill({size:t,initial_value:e}={}){return new Vt(t,e)}new_label({size:t,initial_value:e}={}){return new Vt(t,e)}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}){return t==null?void 0:t.abs()}avg({id:t}){return t==null?void 0:t.avg()}binary_search({id:t,val:e}){return t==null?void 0:t.binary_search({val:e})}binary_search_leftmost({id:t,val:e}){return t==null?void 0:t.binary_search_leftmost({val:e})}binary_search_rightmost({id:t,val:e}){return t==null?void 0:t.binary_search_rightmost({val:e})}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}){return t==null?void 0:t.covariance({id2:e,biased:r})}every({id:t}){return t==null?void 0:t.every()}from(t,e){const r=new Vt;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}){return t==null?void 0:t.join({separator:e})}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}){return t==null?void 0:t.max({nth:e})}median({id:t}){return t==null?void 0:t.median()}min({id:t,nth:e}){return t==null?void 0:t.min({nth:e})}mode({id:t}){return t==null?void 0:t.mode()}percentile_linear_interpolation({id:t,percentage:e}){return t==null?void 0:t.percentile_linear_interpolation({percentage:e})}percentile_nearest_rank({id:t,percentage:e}){return t==null?void 0:t.percentile_nearest_rank({percentage:e})}percentrank({id:t,index:e}){return t==null?void 0:t.percentrank({index:e})}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t}){return t==null?void 0:t.range()}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}){return t==null?void 0:t.some()}sort({id:t,order:e}){t==null||t.sort({order:e})}sort_indices({id:t,order:e}){return t==null?void 0:t.sort_indices({order:e})}standardize({id:t}){return t==null?void 0:t.standardize()}stdev({id:t,biased:e}){return t==null?void 0:t.stdev({biased:e})}sum({id:t}){return t==null?void 0:t.sum()}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e}){return t==null?void 0:t.variance({biased:e})}}class Vt{constructor(t=0,e){ut(this,"_arrInstance");this._arrInstance=Array.from(new Array(t||0),()=>Ar.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Ar.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Vt;return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Vt;return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(){const t=new Vt;this._verifySimpleType("number","abs","int/float");const e=this._arrInstance.map(r=>Math.abs(r));return t._copyData(e),t}avg(){return this._verifySimpleType("number","avg","int/float"),Ar.mean(this._arrInstance)}binary_search({val:t}){return this._verifySimpleType("number","binary_search","int/float"),this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t}){return this._verifySimpleType("number","binary_search_leftmost","int/float"),this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t}){return this._verifySimpleType("number","binary_search_rightmost","int/float"),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}){return this._verifySimpleType("number","covariance","int/float"),this._verifySimpleType("number","covariance","int/float",t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e)}every(){return this._verifySimpleType("number|boolean","every","int/float/bool"),this._arrInstance.every(t=>!!t)}fill({value:t,index_from:e,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index: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}){this._arrInstance.splice(t,0,e)}join({separator:t}={}){return this._verifySimpleType("number|string","join","int/float/string"),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={}){return this._verifySimpleType("number","max","int/float"),this._maxNth([...this._arrInstance],t)}median(){return this._verifySimpleType("number","median","int/float"),this._median([...this._arrInstance])}min({nth:t}={}){return this._verifySimpleType("number","min","int/float"),this._minNth([...this._arrInstance],t)}mode(){return this._verifySimpleType("number","mode","int/float"),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t}){return this._verifySimpleType("number","percentile_linear_interpolation","int/float"),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t}){return this._verifySimpleType("number","percentile_nearest_rank","int/float"),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t}){return this._verifySimpleType("number","percentrank","int/float"),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(){if(this._arrInstance.length===0)throw new Error("Array must not be empty");this._verifySimpleType("number","range","int/float");const t=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-t}remove({index:t}){return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){this._arrInstance[t]=e}shift(){return this._arrInstance.shift()}some(){return this._verifySimpleType("number|boolean","some","int/float/bool"),this._arrInstance.some(t=>!!t)}sort({order:t}={}){this._verifySimpleType("number","sort","int/float"),this._arrInstance.sort((e,r)=>t!==Sn.descending?e-r:r-e)}sort_indices({order:t}={}){this._verifySimpleType("number","sort_indices","int/float");const e=this._arrInstance.map((n,s)=>s);e.sort((n,s)=>t!==Sn.descending?this._arrInstance[n]-this._arrInstance[s]:this._arrInstance[s]-this._arrInstance[n]);const r=new Vt;return r._copyData(e),r}standardize(){this._verifySimpleType("number","standardize","int/float");const t=new Vt;return t._copyData(this._standardizeArray([...this._arrInstance])),t}stdev({biased:t}={}){return this._verifySimpleType("number","stdev","int/float"),this._calculateStandardDeviations([...this._arrInstance],t)}sum(){return this._verifySimpleType("number","sum","int/float"),this._arrInstance.reduce((e,r)=>e+r,0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={}){return this._verifySimpleType("number","variance","int/float"),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){if(t.length===0)throw new Error("Array must not be empty");const r=t.reduce((a,f)=>a+f,0)/t.length,n=t.reduce((a,f)=>a+(f-r)**2,0),s=n/t.length;return e?s:t.length>1?n/(t.length-1):s}_calculateStandardDeviations(t,e=!0){if(t.length===0)throw new Error("Array must not be empty");const r=t.reduce((a,f)=>a+f,0)/t.length,n=t.reduce((a,f)=>{const l=f-r;return a+l*l},0),s=Math.sqrt(n/t.length);return e?s:t.length>1?Math.sqrt(n/(t.length-1)):s}_standardizeArray(t){const e=t.reduce((s,a)=>s+a,0)/t.length,r=Math.sqrt(t.reduce((s,a)=>s+Math.pow(a-e,2),0)/t.length);return t.map(s=>(s-e)/r)}_getPercentileRank(t,e=0){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){if(t.length===0||e<0||e>100)throw new Error("Invalid percentile or empty array");const r=t.slice().sort((a,f)=>a-f),n=e/100*r.length,s=Math.ceil(n)-1;return r[s>=r.length?r.length-1:s]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100)return;t.sort(function(s,a){return s-a});const r=t.length;e/=100;const n=1/(r*2);if(e<=n)return t[0];if(e>=1-1/(r*2))return t[r-1];for(const[s,a]of t.entries()){const f=t[s-1];if(e<(s+.5)/r)return f+(a-f)*(e-(s-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const s of t)e[s]=(e[s]||0)+1,r=Math.max(r,e[s]);for(const s in e)e[s]===r&&n.push(Number(s));return Math.min(...r===1?t:n)}_median(t){t.sort(function(r,n){return r-n});const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}_minNth(t,e=0){return t.sort(function(r,n){return r-n}),t[e]}_maxNth(t,e=0){return t.sort(function(r,n){return n-r}),t[e]}_setElements(t,e,r=0,n){n===void 0&&(n=t.length);for(let s=r;s<n;s++)t[s]=e;return t}_covariance(t,e,r=!1){if(t.length!=e.length)throw"Arrays have different lengths";const n=t.reduce((f,l)=>f+l,0)/t.length,s=e.reduce((f,l)=>f+l,0)/e.length;let a=0;for(let f=0;f<t.length;f++)a+=(t[f]-n)*(e[f]-s);return r?a/t.length:a/(t.length-1)}_verifySimpleType(t,e,r,n=this._arrInstance){if(n.some(a=>!t.split("|").includes(typeof a)))throw Error(`数组类型错误,array.${e}方法只能使用${r}类型数组!`)}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const s=Math.floor((r+n)/2);if(t[s]===e)return s;t[s]<e?r=s+1:n=s-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<e?r=a+1:n=a-1}return s.length?Math.min(...s):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<=e?r=a+1:n=a-1}return s.length?Math.max(...s):r}}class sd{constructor(t){ut(this,"_randomNums");ut(this,"_mintick");ut(this,"_cacheData");ut(this,"_barIndex");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){return Math.abs(t)}acos({angle:t}){const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Ar.mean(e)}ceil({number:t}){return Math.ceil(t)}floor({number:t}){return Math.floor(t)}cos({angle:t}){const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){return Math.exp(t)}log({number:t}){return Math.log(t)}log10({number:t}){return Math.log10(t)}max(t,e){return Math.max(...e)}min(t,e){return Math.min(...e)}pow({base:t,exponent:e}){return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r}){if(r&&this._randomNums[r])return this._randomNums[r];if(t>=e)throw new Error("min must be less than max");let n;do n=Math.random()*(e-t)+t;while(n===t||n===e);return r&&(this._randomNums[r]=n),n}round({number:t,precision:e}){return e?Number(t==null?void 0:t.toFixed(e)):Math.round(t)}round_to_mintick({number:t}){return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){return t&&Math.sign(t)}sqrt({number:t}){return Math.sqrt(t)}sum({source:t,length:e=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=t,this._cacheData[`sum_${r}`]=n;const s=n.filter(()=>!0);if(!(s.length<e))return Ar.sum(s.slice(-e))}todegrees({radians:t}){return t*(180/Math.PI)}toradians({degrees:t}){const e=t*(Math.PI/180);return Number(e.toFixed(2))}}function hs(){return hs=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},hs.apply(this,arguments)}var Af={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function ae(i){return typeof i=="number"}function ye(i){return!i||typeof i!="object"||typeof i.constructor!="function"?!1:i.isBigNumber===!0&&typeof i.constructor.prototype=="object"&&i.constructor.prototype.isBigNumber===!0||typeof i.constructor.isDecimal=="function"&&i.constructor.isDecimal(i)===!0}function bf(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isComplex===!0||!1}function Cf(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isFraction===!0||!1}function Ff(i){return i&&i.constructor.prototype.isUnit===!0||!1}function Rr(i){return typeof i=="string"}var me=Array.isArray;function ce(i){return i&&i.constructor.prototype.isMatrix===!0||!1}function Si(i){return Array.isArray(i)||ce(i)}function ud(i){return i&&i.isDenseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function od(i){return i&&i.isSparseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function ad(i){return i&&i.constructor.prototype.isRange===!0||!1}function Ju(i){return i&&i.constructor.prototype.isIndex===!0||!1}function fd(i){return typeof i=="boolean"}function cd(i){return i&&i.constructor.prototype.isResultSet===!0||!1}function ld(i){return i&&i.constructor.prototype.isHelp===!0||!1}function hd(i){return typeof i=="function"}function pd(i){return i instanceof Date}function dd(i){return i instanceof RegExp}function Xu(i){return!!(i&&typeof i=="object"&&i.constructor===Object&&!bf(i)&&!Cf(i))}function md(i){return i===null}function vd(i){return i===void 0}function gd(i){return i&&i.isAccessorNode===!0&&i.constructor.prototype.isNode===!0||!1}function wd(i){return i&&i.isArrayNode===!0&&i.constructor.prototype.isNode===!0||!1}function _d(i){return i&&i.isAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Dd(i){return i&&i.isBlockNode===!0&&i.constructor.prototype.isNode===!0||!1}function yd(i){return i&&i.isConditionalNode===!0&&i.constructor.prototype.isNode===!0||!1}function Ed(i){return i&&i.isConstantNode===!0&&i.constructor.prototype.isNode===!0||!1}function Ad(i){return i&&i.isFunctionAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function bd(i){return i&&i.isFunctionNode===!0&&i.constructor.prototype.isNode===!0||!1}function Cd(i){return i&&i.isIndexNode===!0&&i.constructor.prototype.isNode===!0||!1}function Fd(i){return i&&i.isNode===!0&&i.constructor.prototype.isNode===!0||!1}function Md(i){return i&&i.isObjectNode===!0&&i.constructor.prototype.isNode===!0||!1}function xd(i){return i&&i.isOperatorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Sd(i){return i&&i.isParenthesisNode===!0&&i.constructor.prototype.isNode===!0||!1}function Nd(i){return i&&i.isRangeNode===!0&&i.constructor.prototype.isNode===!0||!1}function Bd(i){return i&&i.isRelationalNode===!0&&i.constructor.prototype.isNode===!0||!1}function Id(i){return i&&i.isSymbolNode===!0&&i.constructor.prototype.isNode===!0||!1}function Td(i){return i&&i.constructor.prototype.isChain===!0||!1}function sn(i){var t=typeof i;return t==="object"?i===null?"null":ye(i)?"BigNumber":i.constructor&&i.constructor.name?i.constructor.name:"Object":t}function te(i){var t=typeof i;if(t==="number"||t==="string"||t==="boolean"||i===null||i===void 0)return i;if(typeof i.clone=="function")return i.clone();if(Array.isArray(i))return i.map(function(e){return te(e)});if(i instanceof Date)return new Date(i.valueOf());if(ye(i))return i;if(Xu(i))return $d(i,te);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(i,")"))}function $d(i,t){var e={};for(var r in i)Ni(i,r)&&(e[r]=t(i[r]));return e}function Mf(i,t){for(var e in t)Ni(t,e)&&(i[e]=t[e]);return i}function Xn(i,t){var e,r,n;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(r=0,n=i.length;r<n;r++)if(!Xn(i[r],t[r]))return!1;return!0}else{if(typeof i=="function")return i===t;if(i instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in i)if(!(e in t)||!Xn(i[e],t[e]))return!1;for(e in t)if(!(e in i))return!1;return!0}else return i===t}}function Ni(i,t){return i&&Object.hasOwnProperty.call(i,t)}function Od(i,t){for(var e={},r=0;r<t.length;r++){var n=t[r],s=i[n];s!==void 0&&(e[n]=s)}return e}var Rd=["Matrix","Array"],Ld=["number","BigNumber","Fraction"],Ve=function(t){if(t)throw new Error(`The global config is readonly.
|
28
|
-
Please create a mathjs instance if you want to change the default configuration.
|
29
|
-
Example:
|
30
|
-
|
31
|
-
import { create, all } from 'mathjs';
|
32
|
-
const mathjs = create(all);
|
33
|
-
mathjs.config({ number: 'BigNumber' });
|
34
|
-
`);return Object.freeze(Af)};hs(Ve,Af,{MATRIX_OPTIONS:Rd,NUMBER_OPTIONS:Ld});function xf(){return!0}function hr(){return!1}function Hn(){}const Sf="Argument is not a typed-function.";function Nf(){function i(O){return typeof O=="object"&&O!==null&&O.constructor===Object}const t=[{name:"number",test:function(O){return typeof O=="number"}},{name:"string",test:function(O){return typeof O=="string"}},{name:"boolean",test:function(O){return typeof O=="boolean"}},{name:"Function",test:function(O){return typeof O=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(O){return O instanceof Date}},{name:"RegExp",test:function(O){return O instanceof RegExp}},{name:"Object",test:i},{name:"null",test:function(O){return O===null}},{name:"undefined",test:function(O){return O===void 0}}],e={name:"any",test:xf,isAny:!0};let r,n,s=0,a={createCount:0};function f(O){const Z=r.get(O);if(Z)return Z;let K='Unknown type "'+O+'"';const rt=O.toLowerCase();let it;for(it of n)if(it.toLowerCase()===rt){K+='. Did you mean "'+it+'" ?';break}throw new TypeError(K)}function l(O){let Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const K=Z?f(Z).index:n.length,rt=[];for(let et=0;et<O.length;++et){if(!O[et]||typeof O[et].name!="string"||typeof O[et].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const lt=O[et].name;if(r.has(lt))throw new TypeError('Duplicate type name "'+lt+'"');rt.push(lt),r.set(lt,{name:lt,test:O[et].test,isAny:O[et].isAny,index:K+et,conversionsTo:[]})}const it=n.slice(K);n=n.slice(0,K).concat(rt).concat(it);for(let et=K+rt.length;et<n.length;++et)r.get(n[et]).index=et}function p(){r=new Map,n=[],s=0,l([e],!1)}p(),l(t);function h(){let O;for(O of n)r.get(O).conversionsTo=[];s=0}function c(O){const Z=n.filter(K=>{const rt=r.get(K);return!rt.isAny&&rt.test(O)});return Z.length?Z:["any"]}function m(O){return O&&typeof O=="function"&&"_typedFunctionData"in O}function w(O,Z,K){if(!m(O))throw new TypeError(Sf);const rt=K&&K.exact,it=Array.isArray(Z)?Z.join(","):Z,et=S(it),lt=y(et);if(!rt||lt in O.signatures){const Kt=O._typedFunctionData.signatureMap.get(lt);if(Kt)return Kt}const at=et.length;let ht;if(rt){ht=[];let Kt;for(Kt in O.signatures)ht.push(O._typedFunctionData.signatureMap.get(Kt))}else ht=O._typedFunctionData.signatures;for(let Kt=0;Kt<at;++Kt){const Ht=et[Kt],pe=[];let Ie;for(Ie of ht){const Se=N(Ie.params,Kt);if(!(!Se||Ht.restParam&&!Se.restParam)){if(!Se.hasAny){const nr=E(Se);if(Ht.types.some(ir=>!nr.has(ir.name)))continue}pe.push(Ie)}}if(ht=pe,ht.length===0)break}let ot;for(ot of ht)if(ot.params.length<=at)return ot;throw new TypeError("Signature not found (signature: "+(O.name||"unnamed")+"("+y(et,", ")+"))")}function D(O,Z,K){return w(O,Z,K).implementation}function v(O,Z){const K=f(Z);if(K.test(O))return O;const rt=K.conversionsTo;if(rt.length===0)throw new Error("There are no conversions to "+Z+" defined.");for(let it=0;it<rt.length;it++)if(f(rt[it].from).test(O))return rt[it].convert(O);throw new Error("Cannot convert "+O+" to "+Z)}function y(O){let Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return O.map(K=>K.name).join(Z)}function g(O){const Z=O.indexOf("...")===0,rt=(Z?O.length>3?O.slice(3):"any":O).split("|").map(at=>f(at.trim()));let it=!1,et=Z?"...":"";return{types:rt.map(function(at){return it=at.isAny||it,et+=at.name+"|",{name:at.name,typeIndex:at.index,test:at.test,isAny:at.isAny,conversion:null,conversionIndex:-1}}),name:et.slice(0,-1),hasAny:it,hasConversion:!1,restParam:Z}}function A(O){const Z=O.types.map(lt=>lt.name),K=G(Z);let rt=O.hasAny,it=O.name;const et=K.map(function(lt){const at=f(lt.from);return rt=at.isAny||rt,it+="|"+lt.from,{name:lt.from,typeIndex:at.index,test:at.test,isAny:at.isAny,conversion:lt,conversionIndex:lt.index}});return{types:O.types.concat(et),name:it,hasAny:rt,hasConversion:et.length>0,restParam:O.restParam}}function E(O){return O.typeSet||(O.typeSet=new Set,O.types.forEach(Z=>O.typeSet.add(Z.name))),O.typeSet}function S(O){const Z=[];if(typeof O!="string")throw new TypeError("Signatures must be strings");const K=O.trim();if(K==="")return Z;const rt=K.split(",");for(let it=0;it<rt.length;++it){const et=g(rt[it].trim());if(et.restParam&&it!==rt.length-1)throw new SyntaxError('Unexpected rest parameter "'+rt[it]+'": only allowed for the last parameter');if(et.types.length===0)return null;Z.push(et)}return Z}function C(O){const Z=It(O);return Z?Z.restParam:!1}function M(O){if(!O||O.types.length===0)return xf;if(O.types.length===1)return f(O.types[0].name).test;if(O.types.length===2){const Z=f(O.types[0].name).test,K=f(O.types[1].name).test;return function(it){return Z(it)||K(it)}}else{const Z=O.types.map(function(K){return f(K.name).test});return function(rt){for(let it=0;it<Z.length;it++)if(Z[it](rt))return!0;return!1}}}function x(O){let Z,K,rt;if(C(O)){Z=ee(O).map(M);const it=Z.length,et=M(It(O)),lt=function(at){for(let ht=it;ht<at.length;ht++)if(!et(at[ht]))return!1;return!0};return function(ht){for(let ot=0;ot<Z.length;ot++)if(!Z[ot](ht[ot]))return!1;return lt(ht)&&ht.length>=it+1}}else return O.length===0?function(et){return et.length===0}:O.length===1?(K=M(O[0]),function(et){return K(et[0])&&et.length===1}):O.length===2?(K=M(O[0]),rt=M(O[1]),function(et){return K(et[0])&&rt(et[1])&&et.length===2}):(Z=O.map(M),function(et){for(let lt=0;lt<Z.length;lt++)if(!Z[lt](et[lt]))return!1;return et.length===Z.length})}function N(O,Z){return Z<O.length?O[Z]:C(O)?It(O):null}function $(O,Z){const K=N(O,Z);return K?E(K):new Set}function F(O){return O.conversion===null||O.conversion===void 0}function I(O,Z){const K=new Set;return O.forEach(rt=>{const it=$(rt.params,Z);let et;for(et of it)K.add(et)}),K.has("any")?["any"]:Array.from(K)}function R(O,Z,K){let rt,it;const et=O||"unnamed";let lt=K,at;for(at=0;at<Z.length;at++){const Ht=[];if(lt.forEach(pe=>{const Ie=N(pe.params,at),Se=M(Ie);(at<pe.params.length||C(pe.params))&&Se(Z[at])&&Ht.push(pe)}),Ht.length===0){if(it=I(lt,at),it.length>0){const pe=c(Z[at]);return rt=new TypeError("Unexpected type of argument in function "+et+" (expected: "+it.join(" or ")+", actual: "+pe.join(" | ")+", index: "+at+")"),rt.data={category:"wrongType",fn:et,index:at,actual:pe,expected:it},rt}}else lt=Ht}const ht=lt.map(function(Ht){return C(Ht.params)?1/0:Ht.params.length});if(Z.length<Math.min.apply(null,ht))return it=I(lt,at),rt=new TypeError("Too few arguments in function "+et+" (expected: "+it.join(" or ")+", index: "+Z.length+")"),rt.data={category:"tooFewArgs",fn:et,index:Z.length,expected:it},rt;const ot=Math.max.apply(null,ht);if(Z.length>ot)return rt=new TypeError("Too many arguments in function "+et+" (expected: "+ot+", actual: "+Z.length+")"),rt.data={category:"tooManyArgs",fn:et,index:Z.length,expectedLength:ot},rt;const Kt=[];for(let Ht=0;Ht<Z.length;++Ht)Kt.push(c(Z[Ht]).join("|"));return rt=new TypeError('Arguments of type "'+Kt.join(", ")+'" do not match any of the defined signatures of function '+et+"."),rt.data={category:"mismatch",actual:Kt},rt}function q(O){let Z=n.length+1;for(let K=0;K<O.types.length;K++)F(O.types[K])&&(Z=Math.min(Z,O.types[K].typeIndex));return Z}function U(O){let Z=s+1;for(let K=0;K<O.types.length;K++)F(O.types[K])||(Z=Math.min(Z,O.types[K].conversionIndex));return Z}function W(O,Z){if(O.hasAny){if(!Z.hasAny)return 1}else if(Z.hasAny)return-1;if(O.restParam){if(!Z.restParam)return 1}else if(Z.restParam)return-1;if(O.hasConversion){if(!Z.hasConversion)return 1}else if(Z.hasConversion)return-1;const K=q(O)-q(Z);if(K<0)return-1;if(K>0)return 1;const rt=U(O)-U(Z);return rt<0?-1:rt>0?1:0}function P(O,Z){const K=O.params,rt=Z.params,it=It(K),et=It(rt),lt=C(K),at=C(rt);if(lt&&it.hasAny){if(!at||!et.hasAny)return 1}else if(at&&et.hasAny)return-1;let ht=0,ot=0,Kt;for(Kt of K)Kt.hasAny&&++ht,Kt.hasConversion&&++ot;let Ht=0,pe=0;for(Kt of rt)Kt.hasAny&&++Ht,Kt.hasConversion&&++pe;if(ht!==Ht)return ht-Ht;if(lt&&it.hasConversion){if(!at||!et.hasConversion)return 1}else if(at&&et.hasConversion)return-1;if(ot!==pe)return ot-pe;if(lt){if(!at)return 1}else if(at)return-1;const Ie=(K.length-rt.length)*(lt?-1:1);if(Ie!==0)return Ie;const Se=[];let nr=0;for(let mn=0;mn<K.length;++mn){const Ln=W(K[mn],rt[mn]);Se.push(Ln),nr+=Ln}if(nr!==0)return nr;let ir;for(ir of Se)if(ir!==0)return ir;return 0}function G(O){if(O.length===0)return[];const Z=O.map(f);O.length>1&&Z.sort((it,et)=>it.index-et.index);let K=Z[0].conversionsTo;if(O.length===1)return K;K=K.concat([]);const rt=new Set(O);for(let it=1;it<Z.length;++it){let et;for(et of Z[it].conversionsTo)rt.has(et.from)||(K.push(et),rt.add(et.from))}return K}function j(O,Z){let K=Z;if(O.some(it=>it.hasConversion)){const it=C(O),et=O.map(H);K=function(){const at=[],ht=it?arguments.length-1:arguments.length;for(let ot=0;ot<ht;ot++)at[ot]=et[ot](arguments[ot]);return it&&(at[ht]=arguments[ht].map(et[ht])),Z.apply(this,at)}}let rt=K;if(C(O)){const it=O.length-1;rt=function(){return K.apply(this,xt(arguments,0,it).concat([xt(arguments,it)]))}}return rt}function H(O){let Z,K,rt,it;const et=[],lt=[];switch(O.types.forEach(function(at){at.conversion&&(et.push(f(at.conversion.from).test),lt.push(at.conversion.convert))}),lt.length){case 0:return function(ht){return ht};case 1:return Z=et[0],rt=lt[0],function(ht){return Z(ht)?rt(ht):ht};case 2:return Z=et[0],K=et[1],rt=lt[0],it=lt[1],function(ht){return Z(ht)?rt(ht):K(ht)?it(ht):ht};default:return function(ht){for(let ot=0;ot<lt.length;ot++)if(et[ot](ht))return lt[ot](ht);return ht}}}function V(O){function Z(K,rt,it){if(rt<K.length){const et=K[rt];let lt=[];if(et.restParam){const at=et.types.filter(F);at.length<et.types.length&<.push({types:at,name:"..."+at.map(ht=>ht.name).join("|"),hasAny:at.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),lt.push(et)}else lt=et.types.map(function(at){return{types:[at],name:at.name,hasAny:at.isAny,hasConversion:at.conversion,restParam:!1}});return Xt(lt,function(at){return Z(K,rt+1,it.concat([at]))})}else return[it]}return Z(O,0,[])}function ct(O,Z){const K=Math.max(O.length,Z.length);for(let at=0;at<K;at++){const ht=$(O,at),ot=$(Z,at);let Kt=!1,Ht;for(Ht of ot)if(ht.has(Ht)){Kt=!0;break}if(!Kt)return!1}const rt=O.length,it=Z.length,et=C(O),lt=C(Z);return et?lt?rt===it:it>=rt:lt?rt>=it:rt===it}function gt(O){return O.map(Z=>xe(Z)?Fe(Z.referToSelf.callback):er(Z)?Gt(Z.referTo.references,Z.referTo.callback):Z)}function ft(O,Z,K){const rt=[];let it;for(it of O){let et=K[it];if(typeof et!="number")throw new TypeError('No definition for referenced signature "'+it+'"');if(et=Z[et],typeof et!="function")return!1;rt.push(et)}return rt}function _t(O,Z,K){const rt=gt(O),it=new Array(rt.length).fill(!1);let et=!0;for(;et;){et=!1;let lt=!0;for(let at=0;at<rt.length;++at){if(it[at])continue;const ht=rt[at];if(xe(ht))rt[at]=ht.referToSelf.callback(K),rt[at].referToSelf=ht.referToSelf,it[at]=!0,lt=!1;else if(er(ht)){const ot=ft(ht.referTo.references,rt,Z);ot?(rt[at]=ht.referTo.callback.apply(this,ot),rt[at].referTo=ht.referTo,it[at]=!0,lt=!1):et=!0}}if(lt&&et)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return rt}function yt(O){const Z=/\bthis(\(|\.signatures\b)/;Object.keys(O).forEach(K=>{const rt=O[K];if(Z.test(rt.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 Nt(O,Z){if(a.createCount++,Object.keys(Z).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&yt(Z);const K=[],rt=[],it={},et=[];let lt;for(lt in Z){if(!Object.prototype.hasOwnProperty.call(Z,lt))continue;const Yt=S(lt);if(!Yt)continue;K.forEach(function(vn){if(ct(vn,Yt))throw new TypeError('Conflicting signatures "'+y(vn)+'" and "'+y(Yt)+'".')}),K.push(Yt);const Ue=rt.length;rt.push(Z[lt]);const ta=Yt.map(A);let hi;for(hi of V(ta)){const vn=y(hi);et.push({params:hi,name:vn,fn:Ue}),hi.every(su=>!su.hasConversion)&&(it[vn]=Ue)}}et.sort(P);const at=_t(rt,it,Pn);let ht;for(ht in it)Object.prototype.hasOwnProperty.call(it,ht)&&(it[ht]=at[it[ht]]);const ot=[],Kt=new Map;for(ht of et)Kt.has(ht.name)||(ht.fn=at[ht.fn],ot.push(ht),Kt.set(ht.name,ht));const Ht=ot[0]&&ot[0].params.length<=2&&!C(ot[0].params),pe=ot[1]&&ot[1].params.length<=2&&!C(ot[1].params),Ie=ot[2]&&ot[2].params.length<=2&&!C(ot[2].params),Se=ot[3]&&ot[3].params.length<=2&&!C(ot[3].params),nr=ot[4]&&ot[4].params.length<=2&&!C(ot[4].params),ir=ot[5]&&ot[5].params.length<=2&&!C(ot[5].params),mn=Ht&&pe&&Ie&&Se&&nr&&ir;for(let Yt=0;Yt<ot.length;++Yt)ot[Yt].test=x(ot[Yt].params);const Ln=Ht?M(ot[0].params[0]):hr,ru=pe?M(ot[1].params[0]):hr,Io=Ie?M(ot[2].params[0]):hr,To=Se?M(ot[3].params[0]):hr,$o=nr?M(ot[4].params[0]):hr,Oo=ir?M(ot[5].params[0]):hr,nu=Ht?M(ot[0].params[1]):hr,Ro=pe?M(ot[1].params[1]):hr,Lo=Ie?M(ot[2].params[1]):hr,Po=Se?M(ot[3].params[1]):hr,Pi=nr?M(ot[4].params[1]):hr,zo=ir?M(ot[5].params[1]):hr;for(let Yt=0;Yt<ot.length;++Yt)ot[Yt].implementation=j(ot[Yt].params,ot[Yt].fn);const zi=Ht?ot[0].implementation:Hn,Uo=pe?ot[1].implementation:Hn,qo=Ie?ot[2].implementation:Hn,Wo=Se?ot[3].implementation:Hn,ko=nr?ot[4].implementation:Hn,Yo=ir?ot[5].implementation:Hn,Zo=Ht?ot[0].params.length:-1,jo=pe?ot[1].params.length:-1,Go=Ie?ot[2].params.length:-1,iu=Se?ot[3].params.length:-1,Ko=nr?ot[4].params.length:-1,Jo=ir?ot[5].params.length:-1,Xo=mn?6:0,Ho=ot.length,Qo=ot.map(Yt=>Yt.test),Vo=ot.map(Yt=>Yt.implementation),li=function(){for(let Ue=Xo;Ue<Ho;Ue++)if(Qo[Ue](arguments))return Vo[Ue].apply(this,arguments);return a.onMismatch(O,arguments,ot)};function Pn(Yt,Ue){return arguments.length===Zo&&Ln(Yt)&&nu(Ue)?zi.apply(this,arguments):arguments.length===jo&&ru(Yt)&&Ro(Ue)?Uo.apply(this,arguments):arguments.length===Go&&Io(Yt)&&Lo(Ue)?qo.apply(this,arguments):arguments.length===iu&&To(Yt)&&Po(Ue)?Wo.apply(this,arguments):arguments.length===Ko&&$o(Yt)&&Pi(Ue)?ko.apply(this,arguments):arguments.length===Jo&&Oo(Yt)&&zo(Ue)?Yo.apply(this,arguments):li.apply(this,arguments)}try{Object.defineProperty(Pn,"name",{value:O})}catch{}return Pn.signatures=it,Pn._typedFunctionData={signatures:ot,signatureMap:Kt},Pn}function Et(O,Z,K){throw R(O,Z,K)}function ee(O){return xt(O,0,O.length-1)}function It(O){return O[O.length-1]}function xt(O,Z,K){return Array.prototype.slice.call(O,Z,K)}function ie(O,Z){for(let K=0;K<O.length;K++)if(Z(O[K]))return O[K]}function Xt(O,Z){return Array.prototype.concat.apply([],O.map(Z))}function zt(){const O=ee(arguments).map(K=>y(S(K))),Z=It(arguments);if(typeof Z!="function")throw new TypeError("Callback function expected as last argument");return Gt(O,Z)}function Gt(O,Z){return{referTo:{references:O,callback:Z}}}function Fe(O){if(typeof O!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:O}}}function er(O){return O&&typeof O.referTo=="object"&&Array.isArray(O.referTo.references)&&typeof O.referTo.callback=="function"}function xe(O){return O&&typeof O.referToSelf=="object"&&typeof O.referToSelf.callback=="function"}function jr(O,Z){if(!O)return Z;if(Z&&Z!==O){const K=new Error("Function names do not match (expected: "+O+", actual: "+Z+")");throw K.data={actual:Z,expected:O},K}return O}function pn(O){let Z;for(const K in O)Object.prototype.hasOwnProperty.call(O,K)&&(m(O[K])||typeof O[K].signature=="string")&&(Z=jr(Z,O[K].name));return Z}function Gr(O,Z){let K;for(K in Z)if(Object.prototype.hasOwnProperty.call(Z,K)){if(K in O&&Z[K]!==O[K]){const rt=new Error('Signature "'+K+'" is defined twice');throw rt.data={signature:K,sourceFunction:Z[K],destFunction:O[K]},rt}O[K]=Z[K]}}const rr=a;a=function(O){const Z=typeof O=="string",K=Z?1:0;let rt=Z?O:"";const it={};for(let et=K;et<arguments.length;++et){const lt=arguments[et];let at={},ht;if(typeof lt=="function"?(ht=lt.name,typeof lt.signature=="string"?at[lt.signature]=lt:m(lt)&&(at=lt.signatures)):i(lt)&&(at=lt,Z||(ht=pn(lt))),Object.keys(at).length===0){const ot=new TypeError("Argument to 'typed' at index "+et+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw ot.data={index:et,argument:lt},ot}Z||(rt=jr(rt,ht)),Gr(it,at)}return Nt(rt||"",it)},a.create=Nf,a.createCount=rr.createCount,a.onMismatch=Et,a.throwMismatchError=Et,a.createError=R,a.clear=p,a.clearConversions=h,a.addTypes=l,a._findType=f,a.referTo=zt,a.referToSelf=Fe,a.convert=v,a.findSignature=w,a.find=D,a.isTypedFunction=m,a.warnAgainstDeprecatedThis=!0,a.addType=function(O,Z){let K="any";Z!==!1&&r.has("Object")&&(K="Object"),a.addTypes([O],K)};function dn(O){if(!O||typeof O.from!="string"||typeof O.to!="string"||typeof O.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(O.to===O.from)throw new SyntaxError('Illegal to define conversion from "'+O.from+'" to itself.')}return a.addConversion=function(O){dn(O);const Z=f(O.to);if(Z.conversionsTo.every(function(K){return K.from!==O.from}))Z.conversionsTo.push({from:O.from,convert:O.convert,index:s++});else throw new Error('There is already a conversion from "'+O.from+'" to "'+Z.name+'"')},a.addConversions=function(O){O.forEach(a.addConversion)},a.removeConversion=function(O){dn(O);const Z=f(O.to),K=ie(Z.conversionsTo,it=>it.from===O.from);if(!K)throw new Error("Attempt to remove nonexistent conversion from "+O.from+" to "+O.to);if(K.convert!==O.convert)throw new Error("Conversion to remove does not match existing conversion");const rt=Z.conversionsTo.indexOf(K);Z.conversionsTo.splice(rt,1)},a.resolve=function(O,Z){if(!m(O))throw new TypeError(Sf);const K=O._typedFunctionData.signatures;for(let rt=0;rt<K.length;++rt)if(K[rt].test(Z))return K[rt];return null},a}var Bf=Nf();function he(i){return typeof i=="boolean"?!0:isFinite(i)?i===Math.round(i):!1}function Hu(i,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!he(e))throw new Error("size must be an integer");if(i>2**(e-1)-1||i<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!he(i))throw new Error("Value must be an integer");i<0&&(i=i+2**e),s="i".concat(e)}var a="";return i<0&&(i=-i,a="-"),"".concat(a).concat(n).concat(i.toString(t)).concat(s)}function Qu(i,t){if(typeof t=="function")return t(i);if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(isNaN(i))return"NaN";var{notation:e,precision:r,wordSize:n}=If(t);switch(e){case"fixed":return zd(i,r);case"exponential":return Tf(i,r);case"engineering":return Pd(i,r);case"bin":return Hu(i,2,n);case"oct":return Hu(i,8,n);case"hex":return Hu(i,16,n);case"auto":return Ud(i,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],a=arguments[4];return s!=="."?s+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function If(i){var t="auto",e,r;if(i!==void 0)if(ae(i))e=i;else if(ye(i))e=i.toNumber();else if(Xu(i))i.precision!==void 0&&(e=$f(i.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),i.wordSize!==void 0&&(r=$f(i.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),i.notation&&(t=i.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function ps(i){var t=String(i).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+i);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),s=r.indexOf(".");n+=s!==-1?s-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(f){return n-=f.length,""}).replace(/0*$/,"").split("").map(function(f){return parseInt(f)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function Pd(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ps(i),r=ds(e,t),n=r.exponent,s=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(ae(t))for(;t>s.length||n-a+1>s.length;)s.push(0);else for(var f=Math.abs(n-a)-(s.length-1),l=0;l<f;l++)s.push(0);for(var p=Math.abs(n-a),h=1;p>0;)h++,p--;var c=s.slice(h).join(""),m=ae(t)&&c.length||c.match(/[1-9]/)?"."+c:"",w=s.slice(0,h).join("")+m+"e"+(n>=0?"+":"")+a.toString();return r.sign+w}function zd(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ps(i),r=typeof t=="number"?ds(e,e.exponent+1+t):e,n=r.coefficients,s=r.exponent+1,a=s+(t||0);return n.length<a&&(n=n.concat(Qn(a-n.length))),s<0&&(n=Qn(-s+1).concat(n),s=1),s<n.length&&n.splice(s,0,s===0?"0.":"."),r.sign+n.join("")}function Tf(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ps(i),r=t?ds(e,t):e,n=r.coefficients,s=r.exponent;n.length<t&&(n=n.concat(Qn(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(s>=0?"+":"")+s}function Ud(i,t,e){if(isNaN(i)||!isFinite(i))return String(i);var r=Of(e==null?void 0:e.lowerExp,-3),n=Of(e==null?void 0:e.upperExp,5),s=ps(i),a=t?ds(s,t):s;if(a.exponent<r||a.exponent>=n)return Tf(i,t);var f=a.coefficients,l=a.exponent;f.length<t&&(f=f.concat(Qn(t-f.length))),f=f.concat(Qn(l-f.length+1+(f.length<t?t-f.length:0))),f=Qn(-l).concat(f);var p=l>0?l:0;return p<f.length-1&&f.splice(p+1,0,"."),a.sign+f.join("")}function ds(i,t){for(var e={sign:i.sign,coefficients:i.coefficients,exponent:i.exponent},r=e.coefficients;t<=0;)r.unshift(0),e.exponent++,t++;if(r.length>t){var n=r.splice(t,r.length-t);if(n[0]>=5){var s=t-1;for(r[s]++;r[s]===10;)r.pop(),s===0&&(r.unshift(0),e.exponent++,s++),s--,r[s]++}}return e}function Qn(i){for(var t=[],e=0;e<i;e++)t.push(0);return t}function qd(i){return i.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Wd=Number.EPSILON||2220446049250313e-31;function In(i,t,e){if(e==null)return i===t;if(i===t)return!0;if(isNaN(i)||isNaN(t))return!1;if(isFinite(i)&&isFinite(t)){var r=Math.abs(i-t);return r<=Wd?!0:r<=Math.max(Math.abs(i),Math.abs(t))*e}return!1}function $f(i,t){if(ae(i))return i;if(ye(i))return i.toNumber();t()}function Of(i,t){return ae(i)?i:ye(i)?i.toNumber():t}function Vu(i,t,e){var r=i.constructor,n=new r(2),s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!he(e))throw new Error("size must be an integer");if(i.greaterThan(n.pow(e-1).sub(1))||i.lessThan(n.pow(e-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!i.isInteger())throw new Error("Value must be an integer");i.lessThan(0)&&(i=i.add(n.pow(e))),s="i".concat(e)}switch(t){case 2:return"".concat(i.toBinary()).concat(s);case 8:return"".concat(i.toOctal()).concat(s);case 16:return"".concat(i.toHexadecimal()).concat(s);default:throw new Error("Base ".concat(t," not supported "))}}function kd(i,t){if(typeof t=="function")return t(i);if(!i.isFinite())return i.isNaN()?"NaN":i.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=If(t);switch(e){case"fixed":return Zd(i,r);case"exponential":return Rf(i,r);case"engineering":return Yd(i,r);case"bin":return Vu(i,2,n);case"oct":return Vu(i,8,n);case"hex":return Vu(i,16,n);case"auto":{var s=Lf(t==null?void 0:t.lowerExp,-3),a=Lf(t==null?void 0:t.upperExp,5);if(i.isZero())return"0";var f,l=i.toSignificantDigits(r),p=l.e;return p>=s&&p<a?f=l.toFixed():f=Rf(i,r),f.replace(/((\.\d*?)(0+))($|e)/,function(){var h=arguments[2],c=arguments[4];return h!=="."?h+c:c})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Yd(i,t){var e=i.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=i.mul(Math.pow(10,-r)),s=n.toPrecision(t);if(s.indexOf("e")!==-1){var a=i.constructor;s=new a(s).toFixed()}return s+"e"+(e>=0?"+":"")+r.toString()}function Rf(i,t){return t!==void 0?i.toExponential(t-1):i.toExponential()}function Zd(i,t){return i.toFixed(t)}function Lf(i,t){return ae(i)?i:ye(i)?i.toNumber():t}function se(i,t){var e=jd(i,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function jd(i,t){if(typeof i=="number")return Qu(i,t);if(ye(i))return kd(i,t);if(Gd(i))return!t||t.fraction!=="decimal"?i.s*i.n+"/"+i.d:i.toString();if(Array.isArray(i))return Uf(i,t);if(Rr(i))return Pf(i);if(typeof i=="function")return i.syntax?String(i.syntax):"function";if(i&&typeof i=="object"){if(typeof i.format=="function")return i.format(t);if(i&&i.toString(t)!=={}.toString())return i.toString(t);var e=Object.keys(i).map(r=>Pf(r)+": "+se(i[r],t));return"{"+e.join(", ")+"}"}return String(i)}function Pf(i){for(var t=String(i),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in zf?zf[n]:n,r++}return'"'+e+'"'}var zf={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Uf(i,t){if(Array.isArray(i)){for(var e="[",r=i.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=Uf(i[n],t);return e+="]",e}else return se(i,t)}function Gd(i){return i&&typeof i=="object"&&typeof i.s=="number"&&typeof i.n=="number"&&typeof i.d=="number"||!1}function jt(i,t,e){if(!(this instanceof jt))throw new SyntaxError("Constructor must be called with the new operator");this.actual=i,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(i)?"["+i.join(", ")+"]":i)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}jt.prototype=new RangeError,jt.prototype.constructor=RangeError,jt.prototype.name="DimensionError",jt.prototype.isDimensionError=!0;function un(i,t,e){if(!(this instanceof un))throw new SyntaxError("Constructor must be called with the new operator");this.index=i,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}un.prototype=new RangeError,un.prototype.constructor=RangeError,un.prototype.name="IndexError",un.prototype.isIndexError=!0;function be(i){for(var t=[];Array.isArray(i);)t.push(i.length),i=i[0];return t}function qf(i,t,e){var r,n=i.length;if(n!==t[e])throw new jt(n,t[e]);if(e<t.length-1){var s=e+1;for(r=0;r<n;r++){var a=i[r];if(!Array.isArray(a))throw new jt(t.length-1,t.length,"<");qf(i[r],t,s)}}else for(r=0;r<n;r++)if(Array.isArray(i[r]))throw new jt(t.length+1,t.length,">")}function Wf(i,t){var e=t.length===0;if(e){if(Array.isArray(i))throw new jt(i.length,0)}else qf(i,t,0)}function ve(i,t){if(i!==void 0){if(!ae(i)||!he(i))throw new TypeError("Index must be an integer (value: "+i+")");if(i<0||typeof t=="number"&&i>=t)throw new un(i,t)}}function to(i,t,e){if(!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(n){if(!ae(n)||!he(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+se(t)+")")}),(ae(i)||ye(i))&&(i=[i]);var r=e!==void 0?e:0;return eo(i,t,0,r),i}function eo(i,t,e,r){var n,s,a=i.length,f=t[e],l=Math.min(a,f);if(i.length=f,e<t.length-1){var p=e+1;for(n=0;n<l;n++)s=i[n],Array.isArray(s)||(s=[s],i[n]=s),eo(s,t,p,r);for(n=l;n<f;n++)s=[],i[n]=s,eo(s,t,p,r)}else{for(n=0;n<l;n++)for(;Array.isArray(i[n]);)i[n]=i[n][0];for(n=l;n<f;n++)i[n]=r}}function ro(i,t){var e=io(i),r=e.length;if(!Array.isArray(i)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new jt(0,r,"!=");t=no(t,r);var n=kf(t);if(r!==n)throw new jt(n,r,"!=");try{return Kd(e,t)}catch(s){throw s instanceof jt?new jt(n,r,"!="):s}}function no(i,t){var e=kf(i),r=i.slice(),n=-1,s=i.indexOf(n),a=i.indexOf(n,s+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var f=s>=0,l=t%e===0;if(f)if(l)r[s]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function kf(i){return i.reduce((t,e)=>t*e,1)}function Kd(i,t){for(var e=i,r,n=t.length-1;n>0;n--){var s=t[n];r=[];for(var a=e.length/s,f=0;f<a;f++)r.push(e.slice(f*s,(f+1)*s));e=r}return e}function Yf(i,t,e,r){var n=r||be(i);if(e)for(var s=0;s<e;s++)i=[i],n.unshift(1);for(i=Zf(i,t,0);n.length<t;)n.push(1);return i}function Zf(i,t,e){var r,n;if(Array.isArray(i)){var s=e+1;for(r=0,n=i.length;r<n;r++)i[r]=Zf(i[r],t,s)}else for(var a=e;a<t;a++)i=[i];return i}function io(i){if(!Array.isArray(i))return i;var t=[];return i.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function ms(i,t){for(var e,r=0,n=0;n<i.length;n++){var s=i[n],a=Array.isArray(s);if(n===0&&a&&(r=s.length),a&&s.length!==r)return;var f=a?ms(s,t):t(s);if(e===void 0)e=f;else if(e!==f)return"mixed"}return e}function jf(i,t,e,r){if(r<e){if(i.length!==t.length)throw new jt(i.length,t.length);for(var n=[],s=0;s<i.length;s++)n[s]=jf(i[s],t[s],e,r+1);return n}else return i.concat(t)}function Gf(){var i=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(i.length===1)return i[0];if(i.length>1)return i.slice(1).reduce(function(e,r){return jf(e,r,t,0)},i[0]);throw new Error("Wrong number of arguments in function concat")}function Jd(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];for(var r=t.map(m=>m.length),n=Math.max(...r),s=new Array(n).fill(null),a=0;a<t.length;a++)for(var f=t[a],l=r[a],p=0;p<l;p++){var h=n-l+p;f[p]>s[h]&&(s[h]=f[p])}for(var c=0;c<t.length;c++)vs(t[c],s);return s}function vs(i,t){for(var e=t.length,r=i.length,n=0;n<r;n++){var s=e-r+n;if(i[n]<t[s]&&i[n]>1||i[n]>t[s])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(r," with size ").concat(i[n]," to size ").concat(t[s]))}}function Kf(i,t){var e=be(i);if(Xn(e,t))return i;vs(e,t);var r=Jd(e,t),n=r.length,s=[...Array(n-e.length).fill(1),...e],a=Hd(i);e.length<n&&(a=ro(a,s),e=be(a));for(var f=0;f<n;f++)e[f]<r[f]&&(a=Xd(a,r[f],f),e=be(a));return a}function Xd(i,t,e){return Gf(...Array(t).fill(i),e)}function Hd(i){return hs([],i)}function mt(i,t,e,r){function n(s){var a=Od(s,t.map(tm));return Qd(i,t,s),e(a)}return n.isFactory=!0,n.fn=i,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Qd(i,t,e){var r=t.filter(s=>!Vd(s)).every(s=>e[s]!==void 0);if(!r){var n=t.filter(s=>e[s]===void 0);throw new Error('Cannot create function "'.concat(i,'", ')+"some dependencies are missing: ".concat(n.map(s=>'"'.concat(s,'"')).join(", "),"."))}}function Vd(i){return i&&i[0]==="?"}function tm(i){return i&&i[0]==="?"?i.slice(1):i}function em(i,t){if(Xf(i)&&Jf(i,t))return i[t];throw typeof i[t]=="function"&&im(i,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function rm(i,t,e){if(Xf(i)&&Jf(i,t))return i[t]=e,e;throw new Error('No access to property "'+t+'"')}function nm(i,t){return t in i}function Jf(i,t){return!i||typeof i!="object"?!1:Ni(sm,t)?!0:!(t in Object.prototype||t in Function.prototype)}function im(i,t){return i==null||typeof i[t]!="function"||Ni(i,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(i)?!1:Ni(um,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Xf(i){return typeof i=="object"&&i&&i.constructor===Object}var sm={length:!0,name:!0},um={toString:!0,valueOf:!0,toLocaleString:!0};class om{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return em(this.wrappedObject,t)}set(t,e){return rm(this.wrappedObject,t,e),this}has(t){return nm(this.wrappedObject,t)}entries(){return am(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 am(i,t){return{next:()=>{var e=i.next();return e.done?e:{value:t(e.value),done:!1}}}}function fm(i){return i?i instanceof Map||i instanceof om||typeof i.set=="function"&&typeof i.get=="function"&&typeof i.keys=="function"&&typeof i.has=="function":!1}var Hf=function(){return Hf=Bf.create,Bf},cm=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],lm=mt("typed",cm,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:s}=t,a=Hf();return a.clear(),a.addTypes([{name:"number",test:ae},{name:"Complex",test:bf},{name:"BigNumber",test:ye},{name:"Fraction",test:Cf},{name:"Unit",test:Ff},{name:"identifier",test:f=>Rr&&/^(?:[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(f)},{name:"string",test:Rr},{name:"Chain",test:Td},{name:"Array",test:me},{name:"Matrix",test:ce},{name:"DenseMatrix",test:ud},{name:"SparseMatrix",test:od},{name:"Range",test:ad},{name:"Index",test:Ju},{name:"boolean",test:fd},{name:"ResultSet",test:cd},{name:"Help",test:ld},{name:"function",test:hd},{name:"Date",test:pd},{name:"RegExp",test:dd},{name:"null",test:md},{name:"undefined",test:vd},{name:"AccessorNode",test:gd},{name:"ArrayNode",test:wd},{name:"AssignmentNode",test:_d},{name:"BlockNode",test:Dd},{name:"ConditionalNode",test:yd},{name:"ConstantNode",test:Ed},{name:"FunctionNode",test:bd},{name:"FunctionAssignmentNode",test:Ad},{name:"IndexNode",test:Cd},{name:"Node",test:Fd},{name:"ObjectNode",test:Md},{name:"OperatorNode",test:xd},{name:"ParenthesisNode",test:Sd},{name:"RangeNode",test:Nd},{name:"RelationalNode",test:Bd},{name:"SymbolNode",test:Id},{name:"Map",test:fm},{name:"Object",test:Xu}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(e||so(l),qd(l)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+l+"). Use function bignumber(x) to convert to BigNumber.");return new e(l)}},{from:"number",to:"Complex",convert:function(l){return r||gs(l),new r(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return r||gs(l),new r(l.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(l){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(l){return r||gs(l),new r(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){s||uo(l);var p=new s(l);if(p.valueOf()!==l)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+l+"). Use function fraction(x) to convert to Fraction.");return p}},{from:"string",to:"number",convert:function(l){var p=Number(l);if(isNaN(p))throw new Error('Cannot convert "'+l+'" to a number');return p}},{from:"string",to:"BigNumber",convert:function(l){e||so(l);try{return new e(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){s||uo(l);try{return new s(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){r||gs(l);try{return new r(l)}catch{throw new Error('Cannot convert "'+l+'" to Complex')}}},{from:"boolean",to:"number",convert:function(l){return+l}},{from:"boolean",to:"BigNumber",convert:function(l){return e||so(l),new e(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return s||uo(l),new s(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||hm(),new n(l)}},{from:"Matrix",to:"Array",convert:function(l){return l.valueOf()}}]),a.onMismatch=(f,l,p)=>{var h=a.createError(f,l,p);if(["wrongType","mismatch"].includes(h.data.category)&&l.length===1&&Si(l[0])&&p.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=h.data,c}throw h},a.onMismatch=(f,l,p)=>{var h=a.createError(f,l,p);if(["wrongType","mismatch"].includes(h.data.category)&&l.length===1&&Si(l[0])&&p.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=h.data,c}throw h},a});function so(i){throw new Error("Cannot convert value ".concat(i," into a BigNumber: no class 'BigNumber' provided"))}function gs(i){throw new Error("Cannot convert value ".concat(i," into a Complex number: no class 'Complex' provided"))}function hm(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function uo(i){throw new Error("Cannot convert value ".concat(i," into a Fraction, no class 'Fraction' provided."))}/*!
|
35
|
-
* decimal.js v10.4.3
|
36
|
-
* An arbitrary-precision Decimal type for JavaScript.
|
37
|
-
* https://github.com/MikeMcl/decimal.js
|
38
|
-
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
|
39
|
-
* MIT Licence
|
40
|
-
*/var Vn=9e15,on=1e9,oo="0123456789abcdef",ws="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",_s="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ao={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Vn,maxE:Vn,crypto:!1},Qf,Wr,St=!0,Ds="[DecimalError] ",an=Ds+"Invalid argument: ",Vf=Ds+"Precision limit exceeded",tc=Ds+"crypto unavailable",ec="[object Decimal]",Pe=Math.floor,Me=Math.pow,pm=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,dm=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,mm=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,rc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Fr=1e7,At=7,vm=9007199254740991,gm=ws.length-1,fo=_s.length-1,nt={toStringTag:ec};nt.absoluteValue=nt.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),Dt(i)},nt.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},nt.clampedTo=nt.clamp=function(i,t){var e,r=this,n=r.constructor;if(i=new n(i),t=new n(t),!i.s||!t.s)return new n(NaN);if(i.gt(t))throw Error(an+t);return e=r.cmp(i),e<0?i:r.cmp(t)>0?t:new n(r)},nt.comparedTo=nt.cmp=function(i){var t,e,r,n,s=this,a=s.d,f=(i=new s.constructor(i)).d,l=s.s,p=i.s;if(!a||!f)return!l||!p?NaN:l!==p?l:a===f?0:!a^l<0?1:-1;if(!a[0]||!f[0])return a[0]?l:f[0]?-p:0;if(l!==p)return l;if(s.e!==i.e)return s.e>i.e^l<0?1:-1;for(r=a.length,n=f.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==f[t])return a[t]>f[t]^l<0?1:-1;return r===n?0:r>n^l<0?1:-1},nt.cosine=nt.cos=function(){var i,t,e=this,r=e.constructor;return e.d?e.d[0]?(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+At,r.rounding=1,e=wm(r,ac(r,e)),r.precision=i,r.rounding=t,Dt(Wr==2||Wr==3?e.neg():e,i,t,!0)):new r(1):new r(NaN)},nt.cubeRoot=nt.cbrt=function(){var i,t,e,r,n,s,a,f,l,p,h=this,c=h.constructor;if(!h.isFinite()||h.isZero())return new c(h);for(St=!1,s=h.s*Me(h.s*h,1/3),!s||Math.abs(s)==1/0?(e=$e(h.d),i=h.e,(s=(i-e.length+1)%3)&&(e+=s==1||s==-2?"0":"00"),s=Me(e,1/3),i=Pe((i+1)/3)-(i%3==(i<0?-1:2)),s==1/0?e="5e"+i:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),r=new c(e),r.s=h.s):r=new c(s.toString()),a=(i=c.precision)+3;;)if(f=r,l=f.times(f).times(f),p=l.plus(h),r=ue(p.plus(h).times(f),p.plus(l),a+2,1),$e(f.d).slice(0,a)===(e=$e(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(f,i+1,0),f.times(f).times(f).eq(h))){r=f;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,i+1,1),t=!r.times(r).times(r).eq(h));break}return St=!0,Dt(r,i,c.rounding,t)},nt.decimalPlaces=nt.dp=function(){var i,t=this.d,e=NaN;if(t){if(i=t.length-1,e=(i-Pe(this.e/At))*At,i=t[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e},nt.dividedBy=nt.div=function(i){return ue(this,new this.constructor(i))},nt.dividedToIntegerBy=nt.divToInt=function(i){var t=this,e=t.constructor;return Dt(ue(t,new e(i),0,1,1),e.precision,e.rounding)},nt.equals=nt.eq=function(i){return this.cmp(i)===0},nt.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},nt.greaterThan=nt.gt=function(i){return this.cmp(i)>0},nt.greaterThanOrEqualTo=nt.gte=function(i){var t=this.cmp(i);return t==1||t===0},nt.hyperbolicCosine=nt.cosh=function(){var i,t,e,r,n,s=this,a=s.constructor,f=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return f;e=a.precision,r=a.rounding,a.precision=e+Math.max(s.e,s.sd())+4,a.rounding=1,n=s.d.length,n<32?(i=Math.ceil(n/3),t=(1/bs(4,i)).toString()):(i=16,t="2.3283064365386962890625e-10"),s=ti(a,1,s.times(t),new a(1),!0);for(var l,p=i,h=new a(8);p--;)l=s.times(s),s=f.minus(l.times(h.minus(l.times(h))));return Dt(s,a.precision=e,a.rounding=r,!0)},nt.hyperbolicSine=nt.sinh=function(){var i,t,e,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<3)n=ti(s,2,n,n,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,n=n.times(1/bs(5,i)),n=ti(s,2,n,n,!0);for(var a,f=new s(5),l=new s(16),p=new s(20);i--;)a=n.times(n),n=n.times(f.plus(a.times(l.times(a).plus(p))))}return s.precision=t,s.rounding=e,Dt(n,t,e,!0)},nt.hyperbolicTangent=nt.tanh=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+7,r.rounding=1,ue(e.sinh(),e.cosh(),r.precision=i,r.rounding=t)):new r(e.s)},nt.inverseCosine=nt.acos=function(){var i,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,s=e.rounding;return r!==-1?r===0?t.isNeg()?Mr(e,n,s):new e(0):new e(NaN):t.isZero()?Mr(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),i=Mr(e,n+4,s).times(.5),e.precision=n,e.rounding=s,i.minus(t))},nt.inverseHyperbolicCosine=nt.acosh=function(){var i,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(i=r.precision,t=r.rounding,r.precision=i+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,St=!1,e=e.times(e).minus(1).sqrt().plus(e),St=!0,r.precision=i,r.rounding=t,e.ln()):new r(e)},nt.inverseHyperbolicSine=nt.asinh=function(){var i,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,St=!1,e=e.times(e).plus(1).sqrt().plus(e),St=!0,r.precision=i,r.rounding=t,e.ln())},nt.inverseHyperbolicTangent=nt.atanh=function(){var i,t,e,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(i=s.precision,t=s.rounding,r=n.sd(),Math.max(r,i)<2*-n.e-1?Dt(new s(n),i,t,!0):(s.precision=e=r-n.e,n=ue(n.plus(1),new s(1).minus(n),e+i,1),s.precision=i+4,s.rounding=1,n=n.ln(),s.precision=i,s.rounding=t,n.times(.5))):new s(NaN)},nt.inverseSine=nt.asin=function(){var i,t,e,r,n=this,s=n.constructor;return n.isZero()?new s(n):(t=n.abs().cmp(1),e=s.precision,r=s.rounding,t!==-1?t===0?(i=Mr(s,e+4,r).times(.5),i.s=n.s,i):new s(NaN):(s.precision=e+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=r,n.times(2)))},nt.inverseTangent=nt.atan=function(){var i,t,e,r,n,s,a,f,l,p=this,h=p.constructor,c=h.precision,m=h.rounding;if(p.isFinite()){if(p.isZero())return new h(p);if(p.abs().eq(1)&&c+4<=fo)return a=Mr(h,c+4,m).times(.25),a.s=p.s,a}else{if(!p.s)return new h(NaN);if(c+4<=fo)return a=Mr(h,c+4,m).times(.5),a.s=p.s,a}for(h.precision=f=c+10,h.rounding=1,e=Math.min(28,f/At+2|0),i=e;i;--i)p=p.div(p.times(p).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(f/At),r=1,l=p.times(p),a=new h(p),n=p;i!==-1;)if(n=n.times(l),s=a.minus(n.div(r+=2)),n=n.times(l),a=s.plus(n.div(r+=2)),a.d[t]!==void 0)for(i=t;a.d[i]===s.d[i]&&i--;);return e&&(a=a.times(2<<e-1)),St=!0,Dt(a,h.precision=c,h.rounding=m,!0)},nt.isFinite=function(){return!!this.d},nt.isInteger=nt.isInt=function(){return!!this.d&&Pe(this.e/At)>this.d.length-2},nt.isNaN=function(){return!this.s},nt.isNegative=nt.isNeg=function(){return this.s<0},nt.isPositive=nt.isPos=function(){return this.s>0},nt.isZero=function(){return!!this.d&&this.d[0]===0},nt.lessThan=nt.lt=function(i){return this.cmp(i)<0},nt.lessThanOrEqualTo=nt.lte=function(i){return this.cmp(i)<1},nt.logarithm=nt.log=function(i){var t,e,r,n,s,a,f,l,p=this,h=p.constructor,c=h.precision,m=h.rounding,w=5;if(i==null)i=new h(10),t=!0;else{if(i=new h(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new h(NaN);t=i.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)s=!0;else{for(n=e[0];n%10===0;)n/=10;s=n!==1}if(St=!1,f=c+w,a=cn(p,f),r=t?As(h,f+10):cn(i,f),l=ue(a,r,f,1),Bi(l.d,n=c,m))do if(f+=10,a=cn(p,f),r=t?As(h,f+10):cn(i,f),l=ue(a,r,f,1),!s){+$e(l.d).slice(n+1,n+15)+1==1e14&&(l=Dt(l,c+1,0));break}while(Bi(l.d,n+=10,m));return St=!0,Dt(l,c,m)},nt.minus=nt.sub=function(i){var t,e,r,n,s,a,f,l,p,h,c,m,w=this,D=w.constructor;if(i=new D(i),!w.d||!i.d)return!w.s||!i.s?i=new D(NaN):w.d?i.s=-i.s:i=new D(i.d||w.s!==i.s?w:NaN),i;if(w.s!=i.s)return i.s=-i.s,w.plus(i);if(p=w.d,m=i.d,f=D.precision,l=D.rounding,!p[0]||!m[0]){if(m[0])i.s=-i.s;else if(p[0])i=new D(w);else return new D(l===3?-0:0);return St?Dt(i,f,l):i}if(e=Pe(i.e/At),h=Pe(w.e/At),p=p.slice(),s=h-e,s){for(c=s<0,c?(t=p,s=-s,a=m.length):(t=m,e=h,a=p.length),r=Math.max(Math.ceil(f/At),a)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=p.length,a=m.length,c=r<a,c&&(a=r),r=0;r<a;r++)if(p[r]!=m[r]){c=p[r]<m[r];break}s=0}for(c&&(t=p,p=m,m=t,i.s=-i.s),a=p.length,r=m.length-a;r>0;--r)p[a++]=0;for(r=m.length;r>s;){if(p[--r]<m[r]){for(n=r;n&&p[--n]===0;)p[n]=Fr-1;--p[n],p[r]+=Fr}p[r]-=m[r]}for(;p[--a]===0;)p.pop();for(;p[0]===0;p.shift())--e;return p[0]?(i.d=p,i.e=Es(p,e),St?Dt(i,f,l):i):new D(l===3?-0:0)},nt.modulo=nt.mod=function(i){var t,e=this,r=e.constructor;return i=new r(i),!e.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(St=!1,r.modulo==9?(t=ue(e,i.abs(),0,3,1),t.s*=i.s):t=ue(e,i,0,r.modulo,1),t=t.times(i),St=!0,e.minus(t))},nt.naturalExponential=nt.exp=function(){return co(this)},nt.naturalLogarithm=nt.ln=function(){return cn(this)},nt.negated=nt.neg=function(){var i=new this.constructor(this);return i.s=-i.s,Dt(i)},nt.plus=nt.add=function(i){var t,e,r,n,s,a,f,l,p,h,c=this,m=c.constructor;if(i=new m(i),!c.d||!i.d)return!c.s||!i.s?i=new m(NaN):c.d||(i=new m(i.d||c.s===i.s?c:NaN)),i;if(c.s!=i.s)return i.s=-i.s,c.minus(i);if(p=c.d,h=i.d,f=m.precision,l=m.rounding,!p[0]||!h[0])return h[0]||(i=new m(c)),St?Dt(i,f,l):i;if(s=Pe(c.e/At),r=Pe(i.e/At),p=p.slice(),n=s-r,n){for(n<0?(e=p,n=-n,a=h.length):(e=h,r=s,a=p.length),s=Math.ceil(f/At),a=s>a?s+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)/Fr|0,p[n]%=Fr;for(t&&(p.unshift(t),++r),a=p.length;p[--a]==0;)p.pop();return i.d=p,i.e=Es(p,r),St?Dt(i,f,l):i},nt.precision=nt.sd=function(i){var t,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(an+i);return e.d?(t=nc(e.d),i&&e.e+1>t&&(t=e.e+1)):t=NaN,t},nt.round=function(){var i=this,t=i.constructor;return Dt(new t(i),i.e+1,t.rounding)},nt.sine=nt.sin=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+At,r.rounding=1,e=Dm(r,ac(r,e)),r.precision=i,r.rounding=t,Dt(Wr>2?e.neg():e,i,t,!0)):new r(NaN)},nt.squareRoot=nt.sqrt=function(){var i,t,e,r,n,s,a=this,f=a.d,l=a.e,p=a.s,h=a.constructor;if(p!==1||!f||!f[0])return new h(!p||p<0&&(!f||f[0])?NaN:f?a:1/0);for(St=!1,p=Math.sqrt(+a),p==0||p==1/0?(t=$e(f),(t.length+l)%2==0&&(t+="0"),p=Math.sqrt(t),l=Pe((l+1)/2)-(l<0||l%2),p==1/0?t="5e"+l:(t=p.toExponential(),t=t.slice(0,t.indexOf("e")+1)+l),r=new h(t)):r=new h(p.toString()),e=(l=h.precision)+3;;)if(s=r,r=s.plus(ue(a,s,e+2,1)).times(.5),$e(s.d).slice(0,e)===(t=$e(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(s,l+1,0),s.times(s).eq(a))){r=s;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,l+1,1),i=!r.times(r).eq(a));break}return St=!0,Dt(r,l,h.rounding,i)},nt.tangent=nt.tan=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+10,r.rounding=1,e=e.sin(),e.s=1,e=ue(e,new r(1).minus(e.times(e)).sqrt(),i+10,0),r.precision=i,r.rounding=t,Dt(Wr==2||Wr==4?e.neg():e,i,t,!0)):new r(NaN)},nt.times=nt.mul=function(i){var t,e,r,n,s,a,f,l,p,h=this,c=h.constructor,m=h.d,w=(i=new c(i)).d;if(i.s*=h.s,!m||!m[0]||!w||!w[0])return new c(!i.s||m&&!m[0]&&!w||w&&!w[0]&&!m?NaN:!m||!w?i.s/0:i.s*0);for(e=Pe(h.e/At)+Pe(i.e/At),l=m.length,p=w.length,l<p&&(s=m,m=w,w=s,a=l,l=p,p=a),s=[],a=l+p,r=a;r--;)s.push(0);for(r=p;--r>=0;){for(t=0,n=l+r;n>r;)f=s[n]+w[r]*m[n-r-1]+t,s[n--]=f%Fr|0,t=f/Fr|0;s[n]=(s[n]+t)%Fr|0}for(;!s[--a];)s.pop();return t?++e:s.shift(),i.d=s,i.e=Es(s,e),St?Dt(i,c.precision,c.rounding):i},nt.toBinary=function(i,t){return ho(this,2,i,t)},nt.toDecimalPlaces=nt.toDP=function(i,t){var e=this,r=e.constructor;return e=new r(e),i===void 0?e:(je(i,0,on),t===void 0?t=r.rounding:je(t,0,8),Dt(e,i+e.e+1,t))},nt.toExponential=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=Lr(r,!0):(je(i,0,on),t===void 0?t=n.rounding:je(t,0,8),r=Dt(new n(r),i+1,t),e=Lr(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+e:e},nt.toFixed=function(i,t){var e,r,n=this,s=n.constructor;return i===void 0?e=Lr(n):(je(i,0,on),t===void 0?t=s.rounding:je(t,0,8),r=Dt(new s(n),i+n.e+1,t),e=Lr(r,!1,i+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},nt.toFraction=function(i){var t,e,r,n,s,a,f,l,p,h,c,m,w=this,D=w.d,v=w.constructor;if(!D)return new v(w);if(p=e=new v(1),r=l=new v(0),t=new v(r),s=t.e=nc(D)-w.e-1,a=s%At,t.d[0]=Me(10,a<0?At+a:a),i==null)i=s>0?t:p;else{if(f=new v(i),!f.isInt()||f.lt(p))throw Error(an+f);i=f.gt(t)?s>0?t:p:f}for(St=!1,f=new v($e(D)),h=v.precision,v.precision=s=D.length*At*2;c=ue(f,t,0,1,1),n=e.plus(c.times(r)),n.cmp(i)!=1;)e=r,r=n,n=p,p=l.plus(c.times(n)),l=n,n=t,t=f.minus(c.times(n)),f=n;return n=ue(i.minus(e),r,0,1,1),l=l.plus(n.times(p)),e=e.plus(n.times(r)),l.s=p.s=w.s,m=ue(p,r,s,1).minus(w).abs().cmp(ue(l,e,s,1).minus(w).abs())<1?[p,r]:[l,e],v.precision=h,St=!0,m},nt.toHexadecimal=nt.toHex=function(i,t){return ho(this,16,i,t)},nt.toNearest=function(i,t){var e=this,r=e.constructor;if(e=new r(e),i==null){if(!e.d)return e;i=new r(1),t=r.rounding}else{if(i=new r(i),t===void 0?t=r.rounding:je(t,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(St=!1,e=ue(e,i,0,t,1).times(i),St=!0,Dt(e)):(i.s=e.s,e=i),e},nt.toNumber=function(){return+this},nt.toOctal=function(i,t){return ho(this,8,i,t)},nt.toPower=nt.pow=function(i){var t,e,r,n,s,a,f=this,l=f.constructor,p=+(i=new l(i));if(!f.d||!i.d||!f.d[0]||!i.d[0])return new l(Me(+f,p));if(f=new l(f),f.eq(1))return f;if(r=l.precision,s=l.rounding,i.eq(1))return Dt(f,r,s);if(t=Pe(i.e/At),t>=i.d.length-1&&(e=p<0?-p:p)<=vm)return n=ic(l,f,e,r),i.s<0?new l(1).div(n):Dt(n,r,s);if(a=f.s,a<0){if(t<i.d.length-1)return new l(NaN);if(i.d[t]&1||(a=1),f.e==0&&f.d[0]==1&&f.d.length==1)return f.s=a,f}return e=Me(+f,p),t=e==0||!isFinite(e)?Pe(p*(Math.log("0."+$e(f.d))/Math.LN10+f.e+1)):new l(e+"").e,t>l.maxE+1||t<l.minE-1?new l(t>0?a/0:0):(St=!1,l.rounding=f.s=1,e=Math.min(12,(t+"").length),n=co(i.times(cn(f,r+e)),r),n.d&&(n=Dt(n,r+5,1),Bi(n.d,r,s)&&(t=r+10,n=Dt(co(i.times(cn(f,t+e)),t),t+5,1),+$e(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,St=!0,l.rounding=s,Dt(n,r,s))},nt.toPrecision=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=Lr(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(je(i,1,on),t===void 0?t=n.rounding:je(t,0,8),r=Dt(new n(r),i,t),e=Lr(r,i<=r.e||r.e<=n.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+e:e},nt.toSignificantDigits=nt.toSD=function(i,t){var e=this,r=e.constructor;return i===void 0?(i=r.precision,t=r.rounding):(je(i,1,on),t===void 0?t=r.rounding:je(t,0,8)),Dt(new r(e),i,t)},nt.toString=function(){var i=this,t=i.constructor,e=Lr(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e},nt.truncated=nt.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},nt.valueOf=nt.toJSON=function(){var i=this,t=i.constructor,e=Lr(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()?"-"+e:e};function $e(i){var t,e,r,n=i.length-1,s="",a=i[0];if(n>0){for(s+=a,t=1;t<n;t++)r=i[t]+"",e=At-r.length,e&&(s+=fn(e)),s+=r;a=i[t],r=a+"",e=At-r.length,e&&(s+=fn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}function je(i,t,e){if(i!==~~i||i<t||i>e)throw Error(an+i)}function Bi(i,t,e,r){var n,s,a,f;for(s=i[0];s>=10;s/=10)--t;return--t<0?(t+=At,n=0):(n=Math.ceil((t+1)/At),t%=At),s=Me(10,At-t),f=i[n]%s|0,r==null?t<3?(t==0?f=f/100|0:t==1&&(f=f/10|0),a=e<4&&f==99999||e>3&&f==49999||f==5e4||f==0):a=(e<4&&f+1==s||e>3&&f+1==s/2)&&(i[n+1]/s/100|0)==Me(10,t-2)-1||(f==s/2||f==0)&&(i[n+1]/s/100|0)==0:t<4?(t==0?f=f/1e3|0:t==1?f=f/100|0:t==2&&(f=f/10|0),a=(r||e<4)&&f==9999||!r&&e>3&&f==4999):a=((r||e<4)&&f+1==s||!r&&e>3&&f+1==s/2)&&(i[n+1]/s/1e3|0)==Me(10,t-3)-1,a}function ys(i,t,e){for(var r,n=[0],s,a=0,f=i.length;a<f;){for(s=n.length;s--;)n[s]*=t;for(n[0]+=oo.indexOf(i.charAt(a++)),r=0;r<n.length;r++)n[r]>e-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/e|0,n[r]%=e)}return n.reverse()}function wm(i,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/bs(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i.precision+=e,t=ti(i,1,t.times(n),new i(1));for(var s=e;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return i.precision-=e,t}var ue=function(){function i(r,n,s){var a,f=0,l=r.length;for(r=r.slice();l--;)a=r[l]*n+f,r[l]=a%s|0,f=a/s|0;return f&&r.unshift(f),r}function t(r,n,s,a){var f,l;if(s!=a)l=s>a?1:-1;else for(f=l=0;f<s;f++)if(r[f]!=n[f]){l=r[f]>n[f]?1:-1;break}return l}function e(r,n,s,a){for(var f=0;s--;)r[s]-=f,f=r[s]<n[s]?1:0,r[s]=f*a+r[s]-n[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,s,a,f,l){var p,h,c,m,w,D,v,y,g,A,E,S,C,M,x,N,$,F,I,R,q=r.constructor,U=r.s==n.s?1:-1,W=r.d,P=n.d;if(!W||!W[0]||!P||!P[0])return new q(!r.s||!n.s||(W?P&&W[0]==P[0]:!P)?NaN:W&&W[0]==0||!P?U*0:U/0);for(l?(w=1,h=r.e-n.e):(l=Fr,w=At,h=Pe(r.e/w)-Pe(n.e/w)),I=P.length,$=W.length,g=new q(U),A=g.d=[],c=0;P[c]==(W[c]||0);c++);if(P[c]>(W[c]||0)&&h--,s==null?(M=s=q.precision,a=q.rounding):f?M=s+(r.e-n.e)+1:M=s,M<0)A.push(1),D=!0;else{if(M=M/w+2|0,c=0,I==1){for(m=0,P=P[0],M++;(c<$||m)&&M--;c++)x=m*l+(W[c]||0),A[c]=x/P|0,m=x%P|0;D=m||c<$}else{for(m=l/(P[0]+1)|0,m>1&&(P=i(P,m,l),W=i(W,m,l),I=P.length,$=W.length),N=I,E=W.slice(0,I),S=E.length;S<I;)E[S++]=0;R=P.slice(),R.unshift(0),F=P[0],P[1]>=l/2&&++F;do m=0,p=t(P,E,I,S),p<0?(C=E[0],I!=S&&(C=C*l+(E[1]||0)),m=C/F|0,m>1?(m>=l&&(m=l-1),v=i(P,m,l),y=v.length,S=E.length,p=t(v,E,y,S),p==1&&(m--,e(v,I<y?R:P,y,l))):(m==0&&(p=m=1),v=P.slice()),y=v.length,y<S&&v.unshift(0),e(E,v,S,l),p==-1&&(S=E.length,p=t(P,E,I,S),p<1&&(m++,e(E,I<S?R:P,S,l))),S=E.length):p===0&&(m++,E=[0]),A[c++]=m,p&&E[0]?E[S++]=W[N]||0:(E=[W[N]],S=1);while((N++<$||E[0]!==void 0)&&M--);D=E[0]!==void 0}A[0]||A.shift()}if(w==1)g.e=h,Qf=D;else{for(c=1,m=A[0];m>=10;m/=10)c++;g.e=c+h*w-1,Dt(g,f?s+g.e+1:s,a,D)}return g}}();function Dt(i,t,e,r){var n,s,a,f,l,p,h,c,m,w=i.constructor;t:if(t!=null){if(c=i.d,!c)return i;for(n=1,f=c[0];f>=10;f/=10)n++;if(s=t-n,s<0)s+=At,a=t,h=c[m=0],l=h/Me(10,n-a-1)%10|0;else if(m=Math.ceil((s+1)/At),f=c.length,m>=f)if(r){for(;f++<=m;)c.push(0);h=l=0,n=1,s%=At,a=s-At+1}else break t;else{for(h=f=c[m],n=1;f>=10;f/=10)n++;s%=At,a=s-At+n,l=a<0?0:h/Me(10,n-a-1)%10|0}if(r=r||t<0||c[m+1]!==void 0||(a<0?h:h%Me(10,n-a-1)),p=e<4?(l||r)&&(e==0||e==(i.s<0?3:2)):l>5||l==5&&(e==4||r||e==6&&(s>0?a>0?h/Me(10,n-a):0:c[m-1])%10&1||e==(i.s<0?8:7)),t<1||!c[0])return c.length=0,p?(t-=i.e+1,c[0]=Me(10,(At-t%At)%At),i.e=-t||0):c[0]=i.e=0,i;if(s==0?(c.length=m,f=1,m--):(c.length=m+1,f=Me(10,At-s),c[m]=a>0?(h/Me(10,n-a)%Me(10,a)|0)*f:0),p)for(;;)if(m==0){for(s=1,a=c[0];a>=10;a/=10)s++;for(a=c[0]+=f,f=1;a>=10;a/=10)f++;s!=f&&(i.e++,c[0]==Fr&&(c[0]=1));break}else{if(c[m]+=f,c[m]!=Fr)break;c[m--]=0,f=1}for(s=c.length;c[--s]===0;)c.pop()}return St&&(i.e>w.maxE?(i.d=null,i.e=NaN):i.e<w.minE&&(i.e=0,i.d=[0])),i}function Lr(i,t,e){if(!i.isFinite())return oc(i);var r,n=i.e,s=$e(i.d),a=s.length;return t?(e&&(r=e-a)>0?s=s.charAt(0)+"."+s.slice(1)+fn(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i.e<0?"e":"e+")+i.e):n<0?(s="0."+fn(-n-1)+s,e&&(r=e-a)>0&&(s+=fn(r))):n>=a?(s+=fn(n+1-a),e&&(r=e-n-1)>0&&(s=s+"."+fn(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(s+="."),s+=fn(r))),s}function Es(i,t){var e=i[0];for(t*=At;e>=10;e/=10)t++;return t}function As(i,t,e){if(t>gm)throw St=!0,e&&(i.precision=e),Error(Vf);return Dt(new i(ws),t,1,!0)}function Mr(i,t,e){if(t>fo)throw Error(Vf);return Dt(new i(_s),t,e,!0)}function nc(i){var t=i.length-1,e=t*At+1;if(t=i[t],t){for(;t%10==0;t/=10)e--;for(t=i[0];t>=10;t/=10)e++}return e}function fn(i){for(var t="";i--;)t+="0";return t}function ic(i,t,e,r){var n,s=new i(1),a=Math.ceil(r/At+4);for(St=!1;;){if(e%2&&(s=s.times(t),fc(s.d,a)&&(n=!0)),e=Pe(e/2),e===0){e=s.d.length-1,n&&s.d[e]===0&&++s.d[e];break}t=t.times(t),fc(t.d,a)}return St=!0,s}function sc(i){return i.d[i.d.length-1]&1}function uc(i,t,e){for(var r,n=new i(t[0]),s=0;++s<t.length;)if(r=new i(t[s]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function co(i,t){var e,r,n,s,a,f,l,p=0,h=0,c=0,m=i.constructor,w=m.rounding,D=m.precision;if(!i.d||!i.d[0]||i.e>17)return new m(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(t==null?(St=!1,l=D):l=t,f=new m(.03125);i.e>-2;)i=i.times(f),c+=5;for(r=Math.log(Me(2,c))/Math.LN10*2+5|0,l+=r,e=s=a=new m(1),m.precision=l;;){if(s=Dt(s.times(i),l,1),e=e.times(++h),f=a.plus(ue(s,e,l,1)),$e(f.d).slice(0,l)===$e(a.d).slice(0,l)){for(n=c;n--;)a=Dt(a.times(a),l,1);if(t==null)if(p<3&&Bi(a.d,l-r,w,p))m.precision=l+=10,e=s=f=new m(1),h=0,p++;else return Dt(a,m.precision=D,w,St=!0);else return m.precision=D,a}a=f}}function cn(i,t){var e,r,n,s,a,f,l,p,h,c,m,w=1,D=10,v=i,y=v.d,g=v.constructor,A=g.rounding,E=g.precision;if(v.s<0||!y||!y[0]||!v.e&&y[0]==1&&y.length==1)return new g(y&&!y[0]?-1/0:v.s!=1?NaN:y?0:v);if(t==null?(St=!1,h=E):h=t,g.precision=h+=D,e=$e(y),r=e.charAt(0),Math.abs(s=v.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)v=v.times(i),e=$e(v.d),r=e.charAt(0),w++;s=v.e,r>1?(v=new g("0."+e),s++):v=new g(r+"."+e.slice(1))}else return p=As(g,h+2,E).times(s+""),v=cn(new g(r+"."+e.slice(1)),h-D).plus(p),g.precision=E,t==null?Dt(v,E,A,St=!0):v;for(c=v,l=a=v=ue(v.minus(1),v.plus(1),h,1),m=Dt(v.times(v),h,1),n=3;;){if(a=Dt(a.times(m),h,1),p=l.plus(ue(a,new g(n),h,1)),$e(p.d).slice(0,h)===$e(l.d).slice(0,h))if(l=l.times(2),s!==0&&(l=l.plus(As(g,h+2,E).times(s+""))),l=ue(l,new g(w),h,1),t==null)if(Bi(l.d,h-D,A,f))g.precision=h+=D,p=a=v=ue(c.minus(1),c.plus(1),h,1),m=Dt(v.times(v),h,1),n=f=1;else return Dt(l,g.precision=E,A,St=!0);else return g.precision=E,l;l=p,n+=2}}function oc(i){return String(i.s*i.s/0)}function lo(i,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,i.e=e=e-r-1,i.d=[],r=(e+1)%At,e<0&&(r+=At),r<n){for(r&&i.d.push(+t.slice(0,r)),n-=At;r<n;)i.d.push(+t.slice(r,r+=At));t=t.slice(r),r=At-t.length}else r-=n;for(;r--;)t+="0";i.d.push(+t),St&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function _m(i,t){var e,r,n,s,a,f,l,p,h;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),rc.test(t))return lo(i,t)}else if(t==="Infinity"||t==="NaN")return+t||(i.s=NaN),i.e=NaN,i.d=null,i;if(dm.test(t))e=16,t=t.toLowerCase();else if(pm.test(t))e=2;else if(mm.test(t))e=8;else throw Error(an+t);for(s=t.search(/p/i),s>0?(l=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),a=s>=0,r=i.constructor,a&&(t=t.replace(".",""),f=t.length,s=f-s,n=ic(r,new r(e),s,s*2)),p=ys(t,e,Fr),h=p.length-1,s=h;p[s]===0;--s)p.pop();return s<0?new r(i.s*0):(i.e=Es(p,h),i.d=p,St=!1,a&&(i=ue(i,n,f*4)),l&&(i=i.times(Math.abs(l)<54?Me(2,l):ei.pow(2,l))),St=!0,i)}function Dm(i,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:ti(i,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/bs(5,e)),t=ti(i,2,t,t);for(var n,s=new i(5),a=new i(16),f=new i(20);e--;)n=t.times(t),t=t.times(s.plus(n.times(a.times(n).minus(f))));return t}function ti(i,t,e,r,n){var s,a,f,l,p=i.precision,h=Math.ceil(p/At);for(St=!1,l=e.times(e),f=new i(r);;){if(a=ue(f.times(l),new i(t++*t++),p,1),f=n?r.plus(a):r.minus(a),r=ue(a.times(l),new i(t++*t++),p,1),a=f.plus(r),a.d[h]!==void 0){for(s=h;a.d[s]===f.d[s]&&s--;);if(s==-1)break}s=f,f=r,r=a,a=s}return St=!0,a.d.length=h+1,a}function bs(i,t){for(var e=i;--t;)e*=i;return e}function ac(i,t){var e,r=t.s<0,n=Mr(i,i.precision,1),s=n.times(.5);if(t=t.abs(),t.lte(s))return Wr=r?4:1,t;if(e=t.divToInt(n),e.isZero())Wr=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(s))return Wr=sc(e)?r?2:3:r?4:1,t;Wr=sc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function ho(i,t,e,r){var n,s,a,f,l,p,h,c,m,w=i.constructor,D=e!==void 0;if(D?(je(e,1,on),r===void 0?r=w.rounding:je(r,0,8)):(e=w.precision,r=w.rounding),!i.isFinite())h=oc(i);else{for(h=Lr(i),a=h.indexOf("."),D?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(h=h.replace(".",""),m=new w(1),m.e=h.length-a,m.d=ys(Lr(m),10,n),m.e=m.d.length),c=ys(h,10,n),s=l=c.length;c[--l]==0;)c.pop();if(!c[0])h=D?"0p+0":"0";else{if(a<0?s--:(i=new w(i),i.d=c,i.e=s,i=ue(i,m,e,r,0,n),c=i.d,s=i.e,p=Qf),a=c[e],f=n/2,p=p||c[e+1]!==void 0,p=r<4?(a!==void 0||p)&&(r===0||r===(i.s<0?3:2)):a>f||a===f&&(r===4||p||r===6&&c[e-1]&1||r===(i.s<0?8:7)),c.length=e,p)for(;++c[--e]>n-1;)c[e]=0,e||(++s,c.unshift(1));for(l=c.length;!c[l-1];--l);for(a=0,h="";a<l;a++)h+=oo.charAt(c[a]);if(D){if(l>1)if(t==16||t==8){for(a=t==16?4:3,--l;l%a;l++)h+="0";for(c=ys(h,n,t),l=c.length;!c[l-1];--l);for(a=1,h="1.";a<l;a++)h+=oo.charAt(c[a])}else h=h.charAt(0)+"."+h.slice(1);h=h+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)h="0"+h;h="0."+h}else if(++s>l)for(s-=l;s--;)h+="0";else s<l&&(h=h.slice(0,s)+"."+h.slice(s))}h=(t==16?"0x":t==2?"0b":t==8?"0o":"")+h}return i.s<0?"-"+h:h}function fc(i,t){if(i.length>t)return i.length=t,!0}function ym(i){return new this(i).abs()}function Em(i){return new this(i).acos()}function Am(i){return new this(i).acosh()}function bm(i,t){return new this(i).plus(t)}function Cm(i){return new this(i).asin()}function Fm(i){return new this(i).asinh()}function Mm(i){return new this(i).atan()}function xm(i){return new this(i).atanh()}function Sm(i,t){i=new this(i),t=new this(t);var e,r=this.precision,n=this.rounding,s=r+4;return!i.s||!t.s?e=new this(NaN):!i.d&&!t.d?(e=Mr(this,s,1).times(t.s>0?.25:.75),e.s=i.s):!t.d||i.isZero()?(e=t.s<0?Mr(this,r,n):new this(0),e.s=i.s):!i.d||t.isZero()?(e=Mr(this,s,1).times(.5),e.s=i.s):t.s<0?(this.precision=s,this.rounding=1,e=this.atan(ue(i,t,s,1)),t=Mr(this,s,1),this.precision=r,this.rounding=n,e=i.s<0?e.minus(t):e.plus(t)):e=this.atan(ue(i,t,s,1)),e}function Nm(i){return new this(i).cbrt()}function Bm(i){return Dt(i=new this(i),i.e+1,2)}function Im(i,t,e){return new this(i).clamp(t,e)}function Tm(i){if(!i||typeof i!="object")throw Error(Ds+"Object expected");var t,e,r,n=i.defaults===!0,s=["precision",1,on,"rounding",0,8,"toExpNeg",-Vn,0,"toExpPos",0,Vn,"maxE",0,Vn,"minE",-Vn,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],n&&(this[e]=ao[e]),(r=i[e])!==void 0)if(Pe(r)===r&&r>=s[t+1]&&r<=s[t+2])this[e]=r;else throw Error(an+e+": "+r);if(e="crypto",n&&(this[e]=ao[e]),(r=i[e])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(tc);else this[e]=!1;else throw Error(an+e+": "+r);return this}function $m(i){return new this(i).cos()}function Om(i){return new this(i).cosh()}function cc(i){var t,e,r;function n(s){var a,f,l,p=this;if(!(p instanceof n))return new n(s);if(p.constructor=n,lc(s)){p.s=s.s,St?!s.d||s.e>n.maxE?(p.e=NaN,p.d=null):s.e<n.minE?(p.e=0,p.d=[0]):(p.e=s.e,p.d=s.d.slice()):(p.e=s.e,p.d=s.d?s.d.slice():s.d);return}if(l=typeof s,l==="number"){if(s===0){p.s=1/s<0?-1:1,p.e=0,p.d=[0];return}if(s<0?(s=-s,p.s=-1):p.s=1,s===~~s&&s<1e7){for(a=0,f=s;f>=10;f/=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=[s]):(p.e=a,p.d=[s]);return}else if(s*0!==0){s||(p.s=NaN),p.e=NaN,p.d=null;return}return lo(p,s.toString())}else if(l!=="string")throw Error(an+s);return(f=s.charCodeAt(0))===45?(s=s.slice(1),p.s=-1):(f===43&&(s=s.slice(1)),p.s=1),rc.test(s)?lo(p,s):_m(p,s)}if(n.prototype=nt,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=Tm,n.clone=cc,n.isDecimal=lc,n.abs=ym,n.acos=Em,n.acosh=Am,n.add=bm,n.asin=Cm,n.asinh=Fm,n.atan=Mm,n.atanh=xm,n.atan2=Sm,n.cbrt=Nm,n.ceil=Bm,n.clamp=Im,n.cos=$m,n.cosh=Om,n.div=Rm,n.exp=Lm,n.floor=Pm,n.hypot=zm,n.ln=Um,n.log=qm,n.log10=km,n.log2=Wm,n.max=Ym,n.min=Zm,n.mod=jm,n.mul=Gm,n.pow=Km,n.random=Jm,n.round=Xm,n.sign=Hm,n.sin=Qm,n.sinh=Vm,n.sqrt=tv,n.sub=ev,n.sum=rv,n.tan=nv,n.tanh=iv,n.trunc=sv,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)i.hasOwnProperty(e=r[t++])||(i[e]=this[e]);return n.config(i),n}function Rm(i,t){return new this(i).div(t)}function Lm(i){return new this(i).exp()}function Pm(i){return Dt(i=new this(i),i.e+1,3)}function zm(){var i,t,e=new this(0);for(St=!1,i=0;i<arguments.length;)if(t=new this(arguments[i++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return St=!0,new this(1/0);e=t}return St=!0,e.sqrt()}function lc(i){return i instanceof ei||i&&i.toStringTag===ec||!1}function Um(i){return new this(i).ln()}function qm(i,t){return new this(i).log(t)}function Wm(i){return new this(i).log(2)}function km(i){return new this(i).log(10)}function Ym(){return uc(this,arguments,"lt")}function Zm(){return uc(this,arguments,"gt")}function jm(i,t){return new this(i).mod(t)}function Gm(i,t){return new this(i).mul(t)}function Km(i,t){return new this(i).pow(t)}function Jm(i){var t,e,r,n,s=0,a=new this(1),f=[];if(i===void 0?i=this.precision:je(i,1,on),r=Math.ceil(i/At),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)n=t[s],n>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:f[s++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)n=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,s):(f.push(n%1e7),s+=4);s=r/4}else throw Error(tc);else for(;s<r;)f[s++]=Math.random()*1e7|0;for(r=f[--s],i%=At,r&&i&&(n=Me(10,At-i),f[s]=(r/n|0)*n);f[s]===0;s--)f.pop();if(s<0)e=0,f=[0];else{for(e=-1;f[0]===0;e-=At)f.shift();for(r=1,n=f[0];n>=10;n/=10)r++;r<At&&(e-=At-r)}return a.e=e,a.d=f,a}function Xm(i){return Dt(i=new this(i),i.e+1,this.rounding)}function Hm(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Qm(i){return new this(i).sin()}function Vm(i){return new this(i).sinh()}function tv(i){return new this(i).sqrt()}function ev(i,t){return new this(i).sub(t)}function rv(){var i=0,t=arguments,e=new this(t[i]);for(St=!1;e.s&&++i<t.length;)e=e.plus(t[i]);return St=!0,Dt(e,this.precision,this.rounding)}function nv(i){return new this(i).tan()}function iv(i){return new this(i).tanh()}function sv(i){return Dt(i=new this(i),i.e+1,1)}nt[Symbol.for("nodejs.util.inspect.custom")]=nt.toString,nt[Symbol.toStringTag]="Decimal";var ei=nt.constructor=cc(ao);ws=new ei(ws),_s=new ei(_s);var uv="BigNumber",ov=["?on","config"],av=mt(uv,ov,i=>{var{on:t,config:e}=i,r=ei.clone({precision:e.precision,modulo:ei.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},t&&t("config",function(n,s){n.precision!==s.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),hc={exports:{}};/**
|
41
|
-
* @license Complex.js v2.1.1 12/05/2020
|
42
|
-
*
|
43
|
-
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
44
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
45
|
-
**/(function(i,t){(function(e){var r=Math.cosh||function(c){return Math.abs(c)<1e-9?1-c:(Math.exp(c)+Math.exp(-c))*.5},n=Math.sinh||function(c){return Math.abs(c)<1e-9?c:(Math.exp(c)-Math.exp(-c))*.5},s=function(c){var m=Math.PI/4;if(-m>c||c>m)return Math.cos(c)-1;var w=c*c;return w*(w*(w*(w*(w*(w*(w*(w/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(c,m){var w=Math.abs(c),D=Math.abs(m);return w<3e3&&D<3e3?Math.sqrt(w*w+D*D):(w<D?(w=D,D=c/m):D=m/c,w*Math.sqrt(1+D*D))},f=function(){throw SyntaxError("Invalid Param")};function l(c,m){var w=Math.abs(c),D=Math.abs(m);return c===0?Math.log(D):m===0?Math.log(w):w<3e3&&D<3e3?Math.log(c*c+m*m)*.5:(c=c/2,m=m/2,.5*Math.log(c*c+m*m)+Math.LN2)}var p=function(c,m){var w={re:0,im:0};if(c==null)w.re=w.im=0;else if(m!==void 0)w.re=c,w.im=m;else switch(typeof c){case"object":if("im"in c&&"re"in c)w.re=c.re,w.im=c.im;else if("abs"in c&&"arg"in c){if(!Number.isFinite(c.abs)&&Number.isFinite(c.arg))return h.INFINITY;w.re=c.abs*Math.cos(c.arg),w.im=c.abs*Math.sin(c.arg)}else if("r"in c&&"phi"in c){if(!Number.isFinite(c.r)&&Number.isFinite(c.phi))return h.INFINITY;w.re=c.r*Math.cos(c.phi),w.im=c.r*Math.sin(c.phi)}else c.length===2?(w.re=c[0],w.im=c[1]):f();break;case"string":w.im=w.re=0;var D=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),v=1,y=0;D===null&&f();for(var g=0;g<D.length;g++){var A=D[g];A===" "||A===" "||A===`
|
46
|
-
`||(A==="+"?v++:A==="-"?y++:A==="i"||A==="I"?(v+y===0&&f(),D[g+1]!==" "&&!isNaN(D[g+1])?(w.im+=parseFloat((y%2?"-":"")+D[g+1]),g++):w.im+=parseFloat((y%2?"-":"")+"1"),v=y=0):((v+y===0||isNaN(A))&&f(),D[g+1]==="i"||D[g+1]==="I"?(w.im+=parseFloat((y%2?"-":"")+A),g++):w.re+=parseFloat((y%2?"-":"")+A),v=y=0))}v+y>0&&f();break;case"number":w.im=0,w.re=c;break;default:f()}return isNaN(w.re)||isNaN(w.im),w};function h(c,m){if(!(this instanceof h))return new h(c,m);var w=p(c,m);this.re=w.re,this.im=w.im}h.prototype={re:0,im:0,sign:function(){var c=this.abs();return new h(this.re/c,this.im/c)},add:function(c,m){var w=new h(c,m);return this.isInfinite()&&w.isInfinite()?h.NAN:this.isInfinite()||w.isInfinite()?h.INFINITY:new h(this.re+w.re,this.im+w.im)},sub:function(c,m){var w=new h(c,m);return this.isInfinite()&&w.isInfinite()?h.NAN:this.isInfinite()||w.isInfinite()?h.INFINITY:new h(this.re-w.re,this.im-w.im)},mul:function(c,m){var w=new h(c,m);return this.isInfinite()&&w.isZero()||this.isZero()&&w.isInfinite()?h.NAN:this.isInfinite()||w.isInfinite()?h.INFINITY:w.im===0&&this.im===0?new h(this.re*w.re,0):new h(this.re*w.re-this.im*w.im,this.re*w.im+this.im*w.re)},div:function(c,m){var w=new h(c,m);if(this.isZero()&&w.isZero()||this.isInfinite()&&w.isInfinite())return h.NAN;if(this.isInfinite()||w.isZero())return h.INFINITY;if(this.isZero()||w.isInfinite())return h.ZERO;c=this.re,m=this.im;var D=w.re,v=w.im,y,g;return v===0?new h(c/D,m/D):Math.abs(D)<Math.abs(v)?(g=D/v,y=D*g+v,new h((c*g+m)/y,(m*g-c)/y)):(g=v/D,y=v*g+D,new h((c+m*g)/y,(m-c*g)/y))},pow:function(c,m){var w=new h(c,m);if(c=this.re,m=this.im,w.isZero())return h.ONE;if(w.im===0){if(m===0&&c>0)return new h(Math.pow(c,w.re),0);if(c===0)switch((w.re%4+4)%4){case 0:return new h(Math.pow(m,w.re),0);case 1:return new h(0,Math.pow(m,w.re));case 2:return new h(-Math.pow(m,w.re),0);case 3:return new h(0,-Math.pow(m,w.re))}}if(c===0&&m===0&&w.re>0&&w.im>=0)return h.ZERO;var D=Math.atan2(m,c),v=l(c,m);return c=Math.exp(w.re*v-w.im*D),m=w.im*v+w.re*D,new h(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,w=this.abs(),D,v;if(c>=0){if(m===0)return new h(Math.sqrt(c),0);D=.5*Math.sqrt(2*(w+c))}else D=Math.abs(m)/Math.sqrt(2*(w-c));return c<=0?v=.5*Math.sqrt(2*(w-c)):v=Math.abs(m)/Math.sqrt(2*(w+c)),new h(D,m<0?-v:v)},exp:function(){var c=Math.exp(this.re);return this.im,new h(c*Math.cos(this.im),c*Math.sin(this.im))},expm1:function(){var c=this.re,m=this.im;return new h(Math.expm1(c)*Math.cos(m)+s(m),Math.exp(c)*Math.sin(m))},log:function(){var c=this.re,m=this.im;return new h(l(c,m),Math.atan2(m,c))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,m=this.im;return new h(Math.sin(c)*r(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new h(Math.cos(c)*r(m),-Math.sin(c)*n(m))},tan:function(){var c=2*this.re,m=2*this.im,w=Math.cos(c)+r(m);return new h(Math.sin(c)/w,n(m)/w)},cot:function(){var c=2*this.re,m=2*this.im,w=Math.cos(c)-r(m);return new h(-Math.sin(c)/w,n(m)/w)},sec:function(){var c=this.re,m=this.im,w=.5*r(2*m)+.5*Math.cos(2*c);return new h(Math.cos(c)*r(m)/w,Math.sin(c)*n(m)/w)},csc:function(){var c=this.re,m=this.im,w=.5*r(2*m)-.5*Math.cos(2*c);return new h(Math.sin(c)*r(m)/w,-Math.cos(c)*n(m)/w)},asin:function(){var c=this.re,m=this.im,w=new h(m*m-c*c+1,-2*c*m).sqrt(),D=new h(w.re-m,w.im+c).log();return new h(D.im,-D.re)},acos:function(){var c=this.re,m=this.im,w=new h(m*m-c*c+1,-2*c*m).sqrt(),D=new h(w.re-m,w.im+c).log();return new h(Math.PI/2-D.im,D.re)},atan:function(){var c=this.re,m=this.im;if(c===0){if(m===1)return new h(0,1/0);if(m===-1)return new h(0,-1/0)}var w=c*c+(1-m)*(1-m),D=new h((1-m*m-c*c)/w,-2*c/w).log();return new h(-.5*D.im,.5*D.re)},acot:function(){var c=this.re,m=this.im;if(m===0)return new h(Math.atan2(1,c),0);var w=c*c+m*m;return w!==0?new h(c/w,-m/w).atan():new h(c!==0?c/0:0,m!==0?-m/0:0).atan()},asec:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new h(0,1/0);var w=c*c+m*m;return w!==0?new h(c/w,-m/w).acos():new h(c!==0?c/0:0,m!==0?-m/0:0).acos()},acsc:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new h(Math.PI/2,1/0);var w=c*c+m*m;return w!==0?new h(c/w,-m/w).asin():new h(c!==0?c/0:0,m!==0?-m/0:0).asin()},sinh:function(){var c=this.re,m=this.im;return new h(n(c)*Math.cos(m),r(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new h(r(c)*Math.cos(m),n(c)*Math.sin(m))},tanh:function(){var c=2*this.re,m=2*this.im,w=r(c)+Math.cos(m);return new h(n(c)/w,Math.sin(m)/w)},coth:function(){var c=2*this.re,m=2*this.im,w=r(c)-Math.cos(m);return new h(n(c)/w,-Math.sin(m)/w)},csch:function(){var c=this.re,m=this.im,w=Math.cos(2*m)-r(2*c);return new h(-2*n(c)*Math.cos(m)/w,2*r(c)*Math.sin(m)/w)},sech:function(){var c=this.re,m=this.im,w=Math.cos(2*m)+r(2*c);return new h(2*r(c)*Math.cos(m)/w,-2*n(c)*Math.sin(m)/w)},asinh:function(){var c=this.im;this.im=-this.re,this.re=c;var m=this.asin();return this.re=-this.im,this.im=c,c=m.re,m.re=-m.im,m.im=c,m},acosh:function(){var c=this.acos();if(c.im<=0){var m=c.re;c.re=-c.im,c.im=m}else{var m=c.im;c.im=-c.re,c.re=m}return c},atanh:function(){var c=this.re,m=this.im,w=c>1&&m===0,D=1-c,v=1+c,y=D*D+m*m,g=y!==0?new h((v*D-m*m)/y,(m*D+v*m)/y):new h(c!==-1?c/0:0,m!==0?m/0:0),A=g.re;return g.re=l(g.re,g.im)/2,g.im=Math.atan2(g.im,A)/2,w&&(g.im=-g.im),g},acoth:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new h(0,Math.PI/2);var w=c*c+m*m;return w!==0?new h(c/w,-m/w).atanh():new h(c!==0?c/0:0,m!==0?-m/0:0).atanh()},acsch:function(){var c=this.re,m=this.im;if(m===0)return new h(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var w=c*c+m*m;return w!==0?new h(c/w,-m/w).asinh():new h(c!==0?c/0:0,m!==0?-m/0:0).asinh()},asech:function(){var c=this.re,m=this.im;if(this.isZero())return h.INFINITY;var w=c*c+m*m;return w!==0?new h(c/w,-m/w).acosh():new h(c!==0?c/0:0,m!==0?-m/0:0).acosh()},inverse:function(){if(this.isZero())return h.INFINITY;if(this.isInfinite())return h.ZERO;var c=this.re,m=this.im,w=c*c+m*m;return new h(c/w,-m/w)},conjugate:function(){return new h(this.re,-this.im)},neg:function(){return new h(-this.re,-this.im)},ceil:function(c){return c=Math.pow(10,c||0),new h(Math.ceil(this.re*c)/c,Math.ceil(this.im*c)/c)},floor:function(c){return c=Math.pow(10,c||0),new h(Math.floor(this.re*c)/c,Math.floor(this.im*c)/c)},round:function(c){return c=Math.pow(10,c||0),new h(Math.round(this.re*c)/c,Math.round(this.im*c)/c)},equals:function(c,m){var w=new h(c,m);return Math.abs(w.re-this.re)<=h.EPSILON&&Math.abs(w.im-this.im)<=h.EPSILON},clone:function(){return new h(this.re,this.im)},toString:function(){var c=this.re,m=this.im,w="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<h.EPSILON&&(c=0),Math.abs(m)<h.EPSILON&&(m=0),m===0?w+c:(c!==0?(w+=c,w+=" ",m<0?(m=-m,w+="-"):w+="+",w+=" "):m<0&&(m=-m,w+="-"),m!==1&&(w+=m),w+"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,i.exports=h})()})(hc);var fv=hc.exports,Oe=Zt(fv),cv="Complex",lv=[],hv=mt(cv,lv,()=>(Object.defineProperty(Oe,"name",{value:"Complex"}),Oe.prototype.constructor=Oe,Oe.prototype.type="Complex",Oe.prototype.isComplex=!0,Oe.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Oe.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Oe.prototype.format=function(i){var t="",e=this.im,r=this.re,n=Qu(this.re,i),s=Qu(this.im,i),a=ae(i)?i:i?i.precision:null;if(a!==null){var f=Math.pow(10,-a);Math.abs(r/e)<f&&(r=0),Math.abs(e/r)<f&&(e=0)}return e===0?t=n:r===0?e===1?t="i":e===-1?t="-i":t=s+"i":e<0?e===-1?t=n+" - i":t=n+" - "+s.substring(1)+"i":e===1?t=n+" + i":t=n+" + "+s+"i",t},Oe.fromPolar=function(i){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return Oe(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(ae(e)){if(Ff(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),ae(r))return new Oe({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")}},Oe.prototype.valueOf=Oe.prototype.toString,Oe.fromJSON=function(i){return new Oe(i)},Oe.compare=function(i,t){return i.re>t.re?1:i.re<t.re?-1:i.im>t.im?1:i.im<t.im?-1:0},Oe),{isClass:!0}),pc={exports:{}};/**
|
47
|
-
* @license Fraction.js v4.3.0 20/08/2023
|
48
|
-
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
49
|
-
*
|
50
|
-
* Copyright (c) 2023, Robert Eisele (robert@raw.org)
|
51
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
52
|
-
**/(function(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(g,A){if(isNaN(g=parseInt(g,10)))throw v();return g*A}function a(g,A){if(A===0)throw D();var E=Object.create(w.prototype);E.s=g<0?-1:1,g=g<0?-g:g;var S=m(g,A);return E.n=g/S,E.d=A/S,E}function f(g){for(var A={},E=g,S=2,C=4;C<=E;){for(;E%S===0;)E/=S,A[S]=(A[S]||0)+1;C+=1+2*S++}return E!==g?E>1&&(A[E]=(A[E]||0)+1):A[g]=(A[g]||0)+1,A}var l=function(g,A){var E=0,S=1,C=1,M=0,x=0,N=0,$=1,F=1,I=0,R=1,q=1,U=1,W=1e7,P;if(g!=null)if(A!==void 0){if(E=g,S=A,C=E*S,E%1!==0||S%1!==0)throw y()}else switch(typeof g){case"object":{if("d"in g&&"n"in g)E=g.n,S=g.d,"s"in g&&(E*=g.s);else if(0 in g)E=g[0],1 in g&&(S=g[1]);else throw v();C=E*S;break}case"number":{if(g<0&&(C=g,g=-g),g%1===0)E=g;else if(g>0){for(g>=1&&(F=Math.pow(10,Math.floor(1+Math.log(g)/Math.LN10)),g/=F);R<=W&&U<=W;)if(P=(I+q)/(R+U),g===P){R+U<=W?(E=I+q,S=R+U):U>R?(E=q,S=U):(E=I,S=R);break}else g>P?(I+=q,R+=U):(q+=I,U+=R),R>W?(E=q,S=U):(E=I,S=R);E*=F}else(isNaN(g)||isNaN(A))&&(S=E=NaN);break}case"string":{if(R=g.match(/\d+|./g),R===null)throw v();if(R[I]==="-"?(C=-1,I++):R[I]==="+"&&I++,R.length===I+1?x=s(R[I++],C):R[I+1]==="."||R[I]==="."?(R[I]!=="."&&(M=s(R[I++],C)),I++,(I+1===R.length||R[I+1]==="("&&R[I+3]===")"||R[I+1]==="'"&&R[I+3]==="'")&&(x=s(R[I],C),$=Math.pow(10,R[I].length),I++),(R[I]==="("&&R[I+2]===")"||R[I]==="'"&&R[I+2]==="'")&&(N=s(R[I+1],C),F=Math.pow(10,R[I+1].length)-1,I+=3)):R[I+1]==="/"||R[I+1]===":"?(x=s(R[I],C),$=s(R[I+2],1),I+=3):R[I+3]==="/"&&R[I+1]===" "&&(M=s(R[I],C),x=s(R[I+2],C),$=s(R[I+4],1),I+=5),R.length<=I){S=$*F,C=E=N+S*M+F*x;break}}default:throw v()}if(S===0)throw D();n.s=C<0?-1:1,n.n=Math.abs(E),n.d=Math.abs(S)};function p(g,A,E){for(var S=1;A>0;g=g*g%E,A>>=1)A&1&&(S=S*g%E);return S}function h(g,A){for(;A%2===0;A/=2);for(;A%5===0;A/=5);if(A===1)return 0;for(var E=10%A,S=1;E!==1;S++)if(E=E*10%A,S>r)return 0;return S}function c(g,A,E){for(var S=1,C=p(10,E,A),M=0;M<300;M++){if(S===C)return M;S=S*10%A,C=C*10%A}return 0}function m(g,A){if(!g)return A;if(!A)return g;for(;;){if(g%=A,!g)return A;if(A%=g,!A)return g}}function w(g,A){if(l(g,A),this instanceof w)g=m(n.d,n.n),this.s=n.s,this.n=n.n/g,this.d=n.d/g;else return a(n.s*n.n,n.d)}var D=function(){return new Error("Division by Zero")},v=function(){return new Error("Invalid argument")},y=function(){return new Error("Parameters must be integer")};w.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(g,A){return l(g,A),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(g,A){return l(g,A),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(g,A){return l(g,A),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(g,A){return l(g,A),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(g,A){if(isNaN(this.n)||isNaN(this.d))return new w(NaN);if(g===void 0)return a(this.s*this.n%this.d,1);if(l(g,A),n.n===0&&this.d===0)throw D();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(g,A){return l(g,A),a(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(g,A){return l(g,A),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(g){return g=Math.pow(10,g||0),isNaN(this.n)||isNaN(this.d)?new w(NaN):a(Math.ceil(g*this.s*this.n/this.d),g)},floor:function(g){return g=Math.pow(10,g||0),isNaN(this.n)||isNaN(this.d)?new w(NaN):a(Math.floor(g*this.s*this.n/this.d),g)},round:function(g){return g=Math.pow(10,g||0),isNaN(this.n)||isNaN(this.d)?new w(NaN):a(Math.round(g*this.s*this.n/this.d),g)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(g,A){if(l(g,A),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 E=f(this.n),S=f(this.d),C=1,M=1;for(var x in E)if(x!=="1"){if(x==="0"){C=0;break}if(E[x]*=n.n,E[x]%n.d===0)E[x]/=n.d;else return null;C*=Math.pow(x,E[x])}for(var x in S)if(x!=="1"){if(S[x]*=n.n,S[x]%n.d===0)S[x]/=n.d;else return null;M*=Math.pow(x,S[x])}return n.s<0?a(M,C):a(C,M)},equals:function(g,A){return l(g,A),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(g,A){l(g,A);var E=this.s*this.n*n.d-n.s*n.n*this.d;return(0<E)-(E<0)},simplify:function(g){if(isNaN(this.n)||isNaN(this.d))return this;g=g||.001;for(var A=this.abs(),E=A.toContinued(),S=1;S<E.length;S++){for(var C=a(E[S-1],1),M=S-2;M>=0;M--)C=C.inverse().add(E[M]);if(Math.abs(C.sub(A).valueOf())<g)return C.mul(this.s)}return this},divisible:function(g,A){return l(g,A),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(g){var A,E="",S=this.n,C=this.d;return this.s<0&&(E+="-"),C===1?E+=S:(g&&(A=Math.floor(S/C))>0&&(E+=A,E+=" ",S%=C),E+=S,E+="/",E+=C),E},toLatex:function(g){var A,E="",S=this.n,C=this.d;return this.s<0&&(E+="-"),C===1?E+=S:(g&&(A=Math.floor(S/C))>0&&(E+=A,S%=C),E+="\\frac{",E+=S,E+="}{",E+=C,E+="}"),E},toContinued:function(){var g,A=this.n,E=this.d,S=[];if(isNaN(A)||isNaN(E))return S;do S.push(Math.floor(A/E)),g=A%E,A=E,E=g;while(A!==1);return S},toString:function(g){var A=this.n,E=this.d;if(isNaN(A)||isNaN(E))return"NaN";g=g||15;var S=h(A,E),C=c(A,E,S),M=this.s<0?"-":"";if(M+=A/E|0,A%=E,A*=10,A&&(M+="."),S){for(var x=C;x--;)M+=A/E|0,A%=E,A*=10;M+="(";for(var x=S;x--;)M+=A/E|0,A%=E,A*=10;M+=")"}else for(var x=g;A&&x--;)M+=A/E|0,A%=E,A*=10;return M}},Object.defineProperty(w,"__esModule",{value:!0}),w.default=w,w.Fraction=w,i.exports=w})()})(pc);var pv=pc.exports,kr=Zt(pv),dv="Fraction",mv=[],vv=mt(dv,mv,()=>(Object.defineProperty(kr,"name",{value:"Fraction"}),kr.prototype.constructor=kr,kr.prototype.type="Fraction",kr.prototype.isFraction=!0,kr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},kr.fromJSON=function(i){return new kr(i)},kr),{isClass:!0}),gv="Matrix",wv=[],_v=mt(gv,wv,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function dc(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Dv="DenseMatrix",yv=["Matrix"],Ev=mt(Dv,yv,i=>{var{Matrix:t}=i;function e(h,c){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Rr(c))throw new Error("Invalid datatype: "+c);if(ce(h))h.type==="DenseMatrix"?(this._data=te(h._data),this._size=te(h._size),this._datatype=c||h._datatype):(this._data=h.toArray(),this._size=h.size(),this._datatype=c||h._datatype);else if(h&&me(h.data)&&me(h.size))this._data=h.data,this._size=h.size,Wf(this._data,this._size),this._datatype=c||h.datatype;else if(me(h))this._data=p(h),this._size=be(this._data),Wf(this._data,this._size),this._datatype=c;else{if(h)throw new TypeError("Unsupported type of data ("+sn(h)+")");this._data=[],this._size=[0],this._datatype=c}}e.prototype=new t,e.prototype.createDenseMatrix=function(h,c){return new e(h,c)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return ms(this._data,sn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(h,c){return new e(h,c)},e.prototype.subset=function(h,c,m){switch(arguments.length){case 1:return r(this,h);case 2:case 3:return s(this,h,c,m);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(h){if(!me(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new jt(h.length,this._size.length);for(var c=0;c<h.length;c++)ve(h[c],this._size[c]);for(var m=this._data,w=0,D=h.length;w<D;w++){var v=h[w];ve(v,m.length),m=m[v]}return m},e.prototype.set=function(h,c,m){if(!me(h))throw new TypeError("Array expected");if(h.length<this._size.length)throw new jt(h.length,this._size.length,"<");var w,D,v,y=h.map(function(A){return A+1});l(this,y,m);var g=this._data;for(w=0,D=h.length-1;w<D;w++)v=h[w],ve(v,g.length),g=g[v];return v=h[h.length-1],ve(v,g.length),g[v]=c,this};function r(h,c){if(!Ju(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return h.get(c.min());var w=c.size();if(w.length!==h._size.length)throw new jt(w.length,h._size.length);for(var D=c.min(),v=c.max(),y=0,g=h._size.length;y<g;y++)ve(D[y],h._size[y]),ve(v[y],h._size[y]);return new e(n(h._data,c,w.length,0),h._datatype)}function n(h,c,m,w){var D=w===m-1,v=c.dimension(w);return D?v.map(function(y){return ve(y,h.length),h[y]}).valueOf():v.map(function(y){ve(y,h.length);var g=h[y];return n(g,c,m,w+1)}).valueOf()}function s(h,c,m,w){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var D=c.size(),v=c.isScalar(),y;if(ce(m)?(y=m.size(),m=m.valueOf()):y=be(m),v){if(y.length!==0)throw new TypeError("Scalar expected");h.set(c.min(),m,w)}else{if(!Xn(y,D))try{y.length===0?m=Kf([m],D):m=Kf(m,D),y=be(m)}catch{}if(D.length<h._size.length)throw new jt(D.length,h._size.length,"<");if(y.length<D.length){for(var g=0,A=0;D[g]===1&&y[g]===1;)g++;for(;D[g]===1;)A++,g++;m=Yf(m,D.length,A,y)}if(!Xn(D,y))throw new jt(D,y,">");var E=c.max().map(function(M){return M+1});l(h,E,w);var S=D.length,C=0;a(h._data,c,m,S,C)}return h}function a(h,c,m,w,D){var v=D===w-1,y=c.dimension(D);v?y.forEach(function(g,A){ve(g),h[g]=m[A[0]]}):y.forEach(function(g,A){ve(g),a(h[g],c,m[A[0]],w,D+1)})}e.prototype.resize=function(h,c,m){if(!Si(h))throw new TypeError("Array or Matrix expected");var w=h.valueOf().map(v=>Array.isArray(v)&&v.length===1?v[0]:v),D=m?this.clone():this;return f(D,w,c)};function f(h,c,m){if(c.length===0){for(var w=h._data;me(w);)w=w[0];return w}return h._size=c.slice(0),h._data=to(h._data,h._size,m),h}e.prototype.reshape=function(h,c){var m=c?this.clone():this;m._data=ro(m._data,h);var w=m._size.reduce((D,v)=>D*v);return m._size=no(h,w),m};function l(h,c,m){for(var w=h._size.slice(0),D=!1;w.length<c.length;)w.push(0),D=!0;for(var v=0,y=c.length;v<y;v++)c[v]>w[v]&&(w[v]=c[v],D=!0);D&&f(h,w,m)}e.prototype.clone=function(){var h=new e({data:te(this._data),size:te(this._size),datatype:this._datatype});return h},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(h){var c=this,m=dc(h),w=function y(g,A){return me(g)?g.map(function(E,S){return y(E,A.concat(S))}):m===1?h(g):m===2?h(g,A):h(g,A,c)},D=w(this._data,[]),v=this._datatype!==void 0?ms(D,sn):void 0;return new e(D,v)},e.prototype.forEach=function(h){var c=this,m=function w(D,v){me(D)?D.forEach(function(y,g){w(y,v.concat(g))}):h(D,v,c)};m(this._data,[])},e.prototype[Symbol.iterator]=function*(){var h=function*c(m,w){if(me(m))for(var D=0;D<m.length;D++)yield*c(m[D],w.concat(D));else yield{value:m,index:w}};yield*h(this._data,[])},e.prototype.rows=function(){var h=[],c=this.size();if(c.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var w of m)h.push(new e([w],this._datatype));return h},e.prototype.columns=function(){var h=this,c=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var w=this._data,D=function(g){var A=w.map(E=>[E[g]]);c.push(new e(A,h._datatype))},v=0;v<m[1];v++)D(v);return c},e.prototype.toArray=function(){return te(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(h){return se(this._data,h)},e.prototype.toString=function(){return se(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(ye(h)&&(h=h.toNumber()),!ae(h)||!he(h))throw new TypeError("The parameter k must be an integer number")}else h=0;for(var c=h>0?h:0,m=h<0?-h:0,w=this._size[0],D=this._size[1],v=Math.min(w-m,D-c),y=[],g=0;g<v;g++)y[g]=this._data[g+m][g+c];return new e({data:y,size:[v],datatype:this._datatype})},e.diagonal=function(h,c,m,w){if(!me(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(x){if(ye(x)&&(x=x.toNumber()),!ae(x)||!he(x)||x<1)throw new Error("Size values must be positive integers");return x}),m){if(ye(m)&&(m=m.toNumber()),!ae(m)||!he(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var D=m>0?m:0,v=m<0?-m:0,y=h[0],g=h[1],A=Math.min(y-v,g-D),E;if(me(c)){if(c.length!==A)throw new Error("Invalid value array length");E=function(N){return c[N]}}else if(ce(c)){var S=c.size();if(S.length!==1||S[0]!==A)throw new Error("Invalid matrix length");E=function(N){return c.get([N])}}else E=function(){return c};w||(w=ye(E(0))?E(0).mul(0):0);var C=[];if(h.length>0){C=to(C,h,w);for(var M=0;M<A;M++)C[M+v][M+D]=E(M)}return new e({data:C,size:[y,g]})},e.fromJSON=function(h){return new e(h)},e.prototype.swapRows=function(h,c){if(!ae(h)||!he(h)||!ae(c)||!he(c))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return ve(h,this._size[0]),ve(c,this._size[0]),e._swapRows(h,c,this._data),this},e._swapRows=function(h,c,m){var w=m[h];m[h]=m[c],m[c]=w};function p(h){return ce(h)?p(h.valueOf()):me(h)?h.map(p):h}return e},{isClass:!0});function Av(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(i[r][n]);s.push(a)}return s}function Cs(i){for(var t=0;t<i.length;t++)if(Si(i[t]))return!0;return!1}function Ii(i,t){ce(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?Ii(n,t):t(n)}}function xr(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return xr(r,t)}):t(i)}function po(i,t,e){var r=Array.isArray(i)?be(i):i.size();if(t<0||t>=r.length)throw new un(t,r.length);return ce(i)?i.create(Fs(i.valueOf(),t,e)):Fs(i,t,e)}function Fs(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=Av(i),n=[],r=0;r<a.length;r++)n[r]=Fs(a[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=Fs(i[r],t-1,e);return n}}var mc="isInteger",bv=["typed"],Cv=mt(mc,bv,i=>{var{typed:t}=i;return t(mc,{number:he,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>xr(r,e))})}),vc="number",Ms="number, number";function gc(i){return Math.abs(i)}gc.signature=vc;function wc(i,t){return i+t}wc.signature=Ms;function _c(i,t){return i-t}_c.signature=Ms;function Dc(i,t){return i*t}Dc.signature=Ms;function yc(i){return-i}yc.signature=vc;function Ec(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}Ec.signature=Ms;var Ac="number";function bc(i){return i===0}bc.signature=Ac;function Cc(i){return Number.isNaN(i)}Cc.signature=Ac;var Fc="isNumeric",Fv=["typed"],Mv=mt(Fc,Fv,i=>{var{typed:t}=i;return t(Fc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>xr(r,e))})}),Mc="isZero",xv=["typed"],Sv=mt(Mc,xv,i=>{var{typed:t}=i;return t(Mc,{number:bc,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>xr(r,e))})}),xc="isNaN",Nv=["typed"],Bv=mt(xc,Nv,i=>{var{typed:t}=i;return t(xc,{number:Cc,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 xr(r,Number.isNaN)}})});function xs(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function Iv(i,t,e){return In(i.re,t.re,e)&&In(i.im,t.im,e)}var Ss=mt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Ns="equalScalar",Tv=["typed","config"],$v=mt(Ns,Tv,i=>{var{typed:t,config:e}=i,r=Ss({typed:t});return t(Ns,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return In(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||xs(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return Iv(s,a,e.epsilon)}},r)});mt(Ns,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ns,{"number, number":function(n,s){return In(n,s,e.epsilon)}})});var Ov="SparseMatrix",Rv=["typed","equalScalar","Matrix"],Lv=mt(Ov,Rv,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(v,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!Rr(y))throw new Error("Invalid datatype: "+y);if(ce(v))s(this,v,y);else if(v&&me(v.index)&&me(v.ptr)&&me(v.size))this._values=v.values,this._index=v.index,this._ptr=v.ptr,this._size=v.size,this._datatype=y||v.datatype;else if(me(v))a(this,v,y);else{if(v)throw new TypeError("Unsupported type of data ("+sn(v)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function s(v,y,g){y.type==="SparseMatrix"?(v._values=y._values?te(y._values):void 0,v._index=te(y._index),v._ptr=te(y._ptr),v._size=te(y._size),v._datatype=g||y._datatype):a(v,y.valueOf(),g||y._datatype)}function a(v,y,g){v._values=[],v._index=[],v._ptr=[],v._datatype=g;var A=y.length,E=0,S=e,C=0;if(Rr(g)&&(S=t.find(e,[g,g])||e,C=t.convert(0,g)),A>0){var M=0;do{v._ptr.push(v._index.length);for(var x=0;x<A;x++){var N=y[x];if(me(N)){if(M===0&&E<N.length&&(E=N.length),M<N.length){var $=N[M];S($,C)||(v._values.push($),v._index.push(x))}}else M===0&&E<1&&(E=1),S(N,C)||(v._values.push(N),v._index.push(x))}M++}while(M<E)}v._ptr.push(v._index.length),v._size=[A,E]}n.prototype=new r,n.prototype.createSparseMatrix=function(v,y){return new n(v,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return ms(this._values,sn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(v,y){return new n(v,y)},n.prototype.density=function(){var v=this._size[0],y=this._size[1];return v!==0&&y!==0?this._index.length/(v*y):0},n.prototype.subset=function(v,y,g){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return f(this,v);case 2:case 3:return l(this,v,y,g);default:throw new SyntaxError("Wrong number of arguments")}};function f(v,y){if(!Ju(y))throw new TypeError("Invalid index");var g=y.isScalar();if(g)return v.get(y.min());var A=y.size();if(A.length!==v._size.length)throw new jt(A.length,v._size.length);var E,S,C,M,x=y.min(),N=y.max();for(E=0,S=v._size.length;E<S;E++)ve(x[E],v._size[E]),ve(N[E],v._size[E]);var $=v._values,F=v._index,I=v._ptr,R=y.dimension(0),q=y.dimension(1),U=[],W=[];R.forEach(function(H,V){W[H]=V[0],U[H]=!0});var P=$?[]:void 0,G=[],j=[];return q.forEach(function(H){for(j.push(G.length),C=I[H],M=I[H+1];C<M;C++)E=F[C],U[E]===!0&&(G.push(W[E]),P&&P.push($[C]))}),j.push(G.length),new n({values:P,index:G,ptr:j,size:A,datatype:v._datatype})}function l(v,y,g,A){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var E=y.size(),S=y.isScalar(),C;if(ce(g)?(C=g.size(),g=g.toArray()):C=be(g),S){if(C.length!==0)throw new TypeError("Scalar expected");v.set(y.min(),g,A)}else{if(E.length!==1&&E.length!==2)throw new jt(E.length,v._size.length,"<");if(C.length<E.length){for(var M=0,x=0;E[M]===1&&C[M]===1;)M++;for(;E[M]===1;)x++,M++;g=Yf(g,E.length,x,C)}if(!Xn(E,C))throw new jt(E,C,">");if(E.length===1){var N=y.dimension(0);N.forEach(function(I,R){ve(I),v.set([I,0],g[R[0]],A)})}else{var $=y.dimension(0),F=y.dimension(1);$.forEach(function(I,R){ve(I),F.forEach(function(q,U){ve(q),v.set([I,q],g[R[0]][U[0]],A)})})}}return v}n.prototype.get=function(v){if(!me(v))throw new TypeError("Array expected");if(v.length!==this._size.length)throw new jt(v.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=v[0],g=v[1];ve(y,this._size[0]),ve(g,this._size[1]);var A=p(y,this._ptr[g],this._ptr[g+1],this._index);return A<this._ptr[g+1]&&this._index[A]===y?this._values[A]:0},n.prototype.set=function(v,y,g){if(!me(v))throw new TypeError("Array expected");if(v.length!==this._size.length)throw new jt(v.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var A=v[0],E=v[1],S=this._size[0],C=this._size[1],M=e,x=0;Rr(this._datatype)&&(M=t.find(e,[this._datatype,this._datatype])||e,x=t.convert(0,this._datatype)),(A>S-1||E>C-1)&&(m(this,Math.max(A+1,S),Math.max(E+1,C),g),S=this._size[0],C=this._size[1]),ve(A,S),ve(E,C);var N=p(A,this._ptr[E],this._ptr[E+1],this._index);return N<this._ptr[E+1]&&this._index[N]===A?M(y,x)?h(N,E,this._values,this._index,this._ptr):this._values[N]=y:M(y,x)||c(N,A,E,y,this._values,this._index,this._ptr),this};function p(v,y,g,A){if(g-y===0)return g;for(var E=y;E<g;E++)if(A[E]===v)return E;return y}function h(v,y,g,A,E){g.splice(v,1),A.splice(v,1);for(var S=y+1;S<E.length;S++)E[S]--}function c(v,y,g,A,E,S,C){E.splice(v,0,A),S.splice(v,0,y);for(var M=g+1;M<C.length;M++)C[M]++}n.prototype.resize=function(v,y,g){if(!Si(v))throw new TypeError("Array or Matrix expected");var A=v.valueOf().map(S=>Array.isArray(S)&&S.length===1?S[0]:S);if(A.length!==2)throw new Error("Only two dimensions matrix are supported");A.forEach(function(S){if(!ae(S)||!he(S)||S<0)throw new TypeError("Invalid size, must contain positive integers (size: "+se(A)+")")});var E=g?this.clone():this;return m(E,A[0],A[1],y)};function m(v,y,g,A){var E=A||0,S=e,C=0;Rr(v._datatype)&&(S=t.find(e,[v._datatype,v._datatype])||e,C=t.convert(0,v._datatype),E=t.convert(E,v._datatype));var M=!S(E,C),x=v._size[0],N=v._size[1],$,F,I;if(g>N){for(F=N;F<g;F++)if(v._ptr[F]=v._values.length,M)for($=0;$<x;$++)v._values.push(E),v._index.push($);v._ptr[g]=v._values.length}else g<N&&(v._ptr.splice(g+1,N-g),v._values.splice(v._ptr[g],v._values.length),v._index.splice(v._ptr[g],v._index.length));if(N=g,y>x){if(M){var R=0;for(F=0;F<N;F++){v._ptr[F]=v._ptr[F]+R,I=v._ptr[F+1]+R;var q=0;for($=x;$<y;$++,q++)v._values.splice(I+q,0,E),v._index.splice(I+q,0,$),R++}v._ptr[N]=v._values.length}}else if(y<x){var U=0;for(F=0;F<N;F++){v._ptr[F]=v._ptr[F]-U;var W=v._ptr[F],P=v._ptr[F+1]-U;for(I=W;I<P;I++)$=v._index[I],$>y-1&&(v._values.splice(I,1),v._index.splice(I,1),U++)}v._ptr[F]=v._values.length}return v._size[0]=y,v._size[1]=g,v}n.prototype.reshape=function(v,y){if(!me(v))throw new TypeError("Array expected");if(v.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");v.forEach(function(H){if(!ae(H)||!he(H)||H<=-2||H===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+se(v)+")")});var g=this._size[0]*this._size[1];v=no(v,g);var A=v[0]*v[1];if(g!==A)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var E=y?this.clone():this;if(this._size[0]===v[0]&&this._size[1]===v[1])return E;for(var S=[],C=0;C<E._ptr.length;C++)for(var M=0;M<E._ptr[C+1]-E._ptr[C];M++)S.push(C);for(var x=E._values.slice(),N=E._index.slice(),$=0;$<E._index.length;$++){var F=N[$],I=S[$],R=F*E._size[1]+I;S[$]=R%v[1],N[$]=Math.floor(R/v[1])}E._values.length=0,E._index.length=0,E._ptr.length=v[1]+1,E._size=v.slice();for(var q=0;q<E._ptr.length;q++)E._ptr[q]=0;for(var U=0;U<x.length;U++){var W=N[U],P=S[U],G=x[U],j=p(W,E._ptr[P],E._ptr[P+1],E._index);c(j,W,P,G,E._values,E._index,E._ptr)}return E},n.prototype.clone=function(){var v=new n({values:this._values?te(this._values):void 0,index:te(this._index),ptr:te(this._ptr),size:te(this._size),datatype:this._datatype});return v},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(v,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var g=this,A=this._size[0],E=this._size[1],S=dc(v),C=function(x,N,$){return S===1?v(x):S===2?v(x,[N,$]):v(x,[N,$],g)};return w(this,0,A-1,0,E-1,C,y)};function w(v,y,g,A,E,S,C){var M=[],x=[],N=[],$=e,F=0;Rr(v._datatype)&&($=t.find(e,[v._datatype,v._datatype])||e,F=t.convert(0,v._datatype));for(var I=function(ft,_t,yt){ft=S(ft,_t,yt),$(ft,F)||(M.push(ft),x.push(_t))},R=A;R<=E;R++){N.push(M.length);var q=v._ptr[R],U=v._ptr[R+1];if(C)for(var W=q;W<U;W++){var P=v._index[W];P>=y&&P<=g&&I(v._values[W],P-y,R-A)}else{for(var G={},j=q;j<U;j++){var H=v._index[j];G[H]=v._values[j]}for(var V=y;V<=g;V++){var ct=V in G?G[V]:0;I(ct,V-y,R-A)}}}return N.push(M.length),new n({values:M,index:x,ptr:N,size:[g-y+1,E-A+1]})}n.prototype.forEach=function(v,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var g=this,A=this._size[0],E=this._size[1],S=0;S<E;S++){var C=this._ptr[S],M=this._ptr[S+1];if(y)for(var x=C;x<M;x++){var N=this._index[x];v(this._values[x],[N,S],g)}else{for(var $={},F=C;F<M;F++){var I=this._index[F];$[I]=this._values[F]}for(var R=0;R<A;R++){var q=R in $?$[R]:0;v(q,[R,S],g)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var v=this._size[1],y=0;y<v;y++)for(var g=this._ptr[y],A=this._ptr[y+1],E=g;E<A;E++){var S=this._index[E];yield{value:this._values[E],index:[S,y]}}},n.prototype.toArray=function(){return D(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return D(this._values,this._index,this._ptr,this._size,!1)};function D(v,y,g,A,E){var S=A[0],C=A[1],M=[],x,N;for(x=0;x<S;x++)for(M[x]=[],N=0;N<C;N++)M[x][N]=0;for(N=0;N<C;N++)for(var $=g[N],F=g[N+1],I=$;I<F;I++)x=y[I],M[x][N]=v?E?te(v[I]):v[I]:1;return M}return n.prototype.format=function(v){for(var y=this._size[0],g=this._size[1],A=this.density(),E="Sparse Matrix ["+se(y,v)+" x "+se(g,v)+"] density: "+se(A,v)+`
|
53
|
-
`,S=0;S<g;S++)for(var C=this._ptr[S],M=this._ptr[S+1],x=C;x<M;x++){var N=this._index[x];E+=`
|
54
|
-
(`+se(N,v)+", "+se(S,v)+") ==> "+(this._values?se(this._values[x],v):"X")}return E},n.prototype.toString=function(){return se(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(v){if(v){if(ye(v)&&(v=v.toNumber()),!ae(v)||!he(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var y=v>0?v:0,g=v<0?-v:0,A=this._size[0],E=this._size[1],S=Math.min(A-g,E-y),C=[],M=[],x=[];x[0]=0;for(var N=y;N<E&&C.length<S;N++)for(var $=this._ptr[N],F=this._ptr[N+1],I=$;I<F;I++){var R=this._index[I];if(R===N-y+g){C.push(this._values[I]),M[C.length-1]=R-g;break}}return x.push(C.length),new n({values:C,index:M,ptr:x,size:[S,1]})},n.fromJSON=function(v){return new n(v)},n.diagonal=function(v,y,g,A,E){if(!me(v))throw new TypeError("Array expected, size parameter");if(v.length!==2)throw new Error("Only two dimensions matrix are supported");if(v=v.map(function(H){if(ye(H)&&(H=H.toNumber()),!ae(H)||!he(H)||H<1)throw new Error("Size values must be positive integers");return H}),g){if(ye(g)&&(g=g.toNumber()),!ae(g)||!he(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var S=e,C=0;Rr(E)&&(S=t.find(e,[E,E])||e,C=t.convert(0,E));var M=g>0?g:0,x=g<0?-g:0,N=v[0],$=v[1],F=Math.min(N-x,$-M),I;if(me(y)){if(y.length!==F)throw new Error("Invalid value array length");I=function(V){return y[V]}}else if(ce(y)){var R=y.size();if(R.length!==1||R[0]!==F)throw new Error("Invalid matrix length");I=function(V){return y.get([V])}}else I=function(){return y};for(var q=[],U=[],W=[],P=0;P<$;P++){W.push(q.length);var G=P-M;if(G>=0&&G<F){var j=I(G);S(j,C)||(U.push(G+x),q.push(j))}}return W.push(q.length),new n({values:q,index:U,ptr:W,size:[N,$]})},n.prototype.swapRows=function(v,y){if(!ae(v)||!he(v)||!ae(y)||!he(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return ve(v,this._size[0]),ve(y,this._size[0]),n._swapRows(v,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(v,y,g,A,E){for(var S=A[v],C=A[v+1],M=S;M<C;M++)E(g[M],y[M])},n._swapRows=function(v,y,g,A,E,S){for(var C=0;C<g;C++){var M=S[C],x=S[C+1],N=p(v,M,x,E),$=p(y,M,x,E);if(N<x&&$<x&&E[N]===v&&E[$]===y){if(A){var F=A[N];A[N]=A[$],A[$]=F}continue}if(N<x&&E[N]===v&&($>=x||E[$]!==y)){var I=A?A[N]:void 0;E.splice($,0,y),A&&A.splice($,0,I),E.splice($<=N?N+1:N,1),A&&A.splice($<=N?N+1:N,1);continue}if($<x&&E[$]===y&&(N>=x||E[N]!==v)){var R=A?A[$]:void 0;E.splice(N,0,v),A&&A.splice(N,0,R),E.splice(N<=$?$+1:$,1),A&&A.splice(N<=$?$+1:$,1)}}},n},{isClass:!0}),Pv="number",zv=["typed"];function Uv(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function qv(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var Wv=mt(Pv,zv,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=Uv(n);if(s)return qv(s);var a=0,f=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);f&&(a=Number(f[2]),n=f[1]);var l=Number(n);if(isNaN(l))throw new SyntaxError('String "'+n+'" is not a valid number');if(f){if(l>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));l>=2**(a-1)&&(l=l-2**a)}return l},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>xr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),kv="bignumber",Yv=["typed","BigNumber"],Zv=mt(kv,Yv,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],f=e(s[1]),l=new e(2).pow(Number(a));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var p=new e(2).pow(Number(a)-1);return f.gte(p)?f.sub(l):f}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>xr(n,r))})}),jv="fraction",Gv=["typed","Fraction"],Kv=mt(jv,Gv,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>xr(n,r))})}),Sc="matrix",Jv=["typed","Matrix","DenseMatrix","SparseMatrix"],Xv=mt(Sc,Jv,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(Sc,{"":function(){return s([])},string:function(f){return s([],f)},"string, string":function(f,l){return s([],f,l)},Array:function(f){return s(f)},Matrix:function(f){return s(f,f.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,f,l){if(f==="dense"||f==="default"||f===void 0)return new r(a,l);if(f==="sparse")return new n(a,l);throw new TypeError("Unknown matrix type "+JSON.stringify(f)+".")}}),Nc="unaryMinus",Hv=["typed"],Qv=mt(Nc,Hv,i=>{var{typed:t}=i;return t(Nc,{number:yc,"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=>xr(r,e))})}),Bc="abs",Vv=["typed"],tg=mt(Bc,Vv,i=>{var{typed:t}=i;return t(Bc,{number:gc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>xr(r,e))})}),Ic="addScalar",eg=["typed"],rg=mt(Ic,eg,i=>{var{typed:t}=i;return t(Ic,{"number, number":wc,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Tc="subtractScalar",ng=["typed"],ig=mt(Tc,ng,i=>{var{typed:t}=i;return t(Tc,{"number, number":_c,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),sg="matAlgo11xS0s",ug=["typed","equalScalar"],mo=mt(sg,ug,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,f){var l=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var w=c[0],D=c[1],v,y=e,g=0,A=a;typeof m=="string"&&(v=m,y=t.find(e,[v,v]),g=t.convert(0,v),s=t.convert(s,v),A=t.find(a,[v,v]));for(var E=[],S=[],C=[],M=0;M<D;M++){C[M]=S.length;for(var x=h[M],N=h[M+1],$=x;$<N;$++){var F=p[$],I=f?A(s,l[$]):A(l[$],s);y(I,g)||(S.push(F),E.push(I))}}return C[D]=S.length,n.createSparseMatrix({values:E,index:S,ptr:C,size:[w,D],datatype:v})}}),og="matAlgo12xSfs",ag=["typed","DenseMatrix"],ri=mt(og,ag,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,f){var l=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var w=c[0],D=c[1],v,y=a;typeof m=="string"&&(v=m,s=t.convert(s,v),y=t.find(a,[v,v]));for(var g=[],A=[],E=[],S=0;S<D;S++){for(var C=S+1,M=h[S],x=h[S+1],N=M;N<x;N++){var $=p[N];A[$]=l[N],E[$]=C}for(var F=0;F<w;F++)S===0&&(g[F]=[]),E[F]===C?g[F][S]=f?y(s,A[F]):y(A[F],s):g[F][S]=f?y(s,0):y(0,s)}return new e({data:g,size:[w,D],datatype:v})}}),fg="matAlgo14xDs",cg=["typed"],vo=mt(fg,cg,i=>{var{typed:t}=i;return function(n,s,a,f){var l=n._data,p=n._size,h=n._datatype,c,m=a;typeof h=="string"&&(c=h,s=t.convert(s,c),m=t.find(a,[c,c]));var w=p.length>0?e(m,0,p,p[0],l,s,f):[];return n.createDenseMatrix({data:w,size:te(p),datatype:c})};function e(r,n,s,a,f,l,p){var h=[];if(n===s.length-1)for(var c=0;c<a;c++)h[c]=p?r(l,f[c]):r(f[c],l);else for(var m=0;m<a;m++)h[m]=e(r,n+1,s,s[n+1],f[m],l,p);return h}}),lg="matAlgo02xDS0",hg=["typed","equalScalar"],pg=mt(lg,hg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,f){var l=n._data,p=n._size,h=n._datatype||n.getDataType(),c=s._values,m=s._index,w=s._ptr,D=s._size,v=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==D.length)throw new jt(p.length,D.length);if(p[0]!==D[0]||p[1]!==D[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+D+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=p[0],g=p[1],A,E=e,S=0,C=a;typeof h=="string"&&h===v&&h!=="mixed"&&(A=h,E=t.find(e,[A,A]),S=t.convert(0,A),C=t.find(a,[A,A]));for(var M=[],x=[],N=[],$=0;$<g;$++){N[$]=x.length;for(var F=w[$],I=w[$+1],R=F;R<I;R++){var q=m[R],U=f?C(c[R],l[q][$]):C(l[q][$],c[R]);E(U,S)||(x.push(q),M.push(U))}}return N[g]=x.length,s.createSparseMatrix({values:M,index:x,ptr:N,size:[y,g],datatype:h===n._datatype&&v===s._datatype?A:void 0})}}),dg="matAlgo03xDSf",mg=["typed"],ni=mt(dg,mg,i=>{var{typed:t}=i;return function(r,n,s,a){var f=r._data,l=r._size,p=r._datatype||r.getDataType(),h=n._values,c=n._index,m=n._ptr,w=n._size,D=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(l.length!==w.length)throw new jt(l.length,w.length);if(l[0]!==w[0]||l[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+w+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var v=l[0],y=l[1],g,A=0,E=s;typeof p=="string"&&p===D&&p!=="mixed"&&(g=p,A=t.convert(0,g),E=t.find(s,[g,g]));for(var S=[],C=0;C<v;C++)S[C]=[];for(var M=[],x=[],N=0;N<y;N++){for(var $=N+1,F=m[N],I=m[N+1],R=F;R<I;R++){var q=c[R];M[q]=a?E(h[R],f[q][N]):E(f[q][N],h[R]),x[q]=$}for(var U=0;U<v;U++)x[U]===$?S[U][N]=M[U]:S[U][N]=a?E(A,f[U][N]):E(f[U][N],A)}return r.createDenseMatrix({data:S,size:[v,y],datatype:p===r._datatype&&D===n._datatype?g:void 0})}}),vg="matAlgo05xSfSf",gg=["typed","equalScalar"],$c=mt(vg,gg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var f=n._values,l=n._index,p=n._ptr,h=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,w=s._index,D=s._ptr,v=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==v.length)throw new jt(h.length,v.length);if(h[0]!==v[0]||h[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+v+")");var g=h[0],A=h[1],E,S=e,C=0,M=a;typeof c=="string"&&c===y&&c!=="mixed"&&(E=c,S=t.find(e,[E,E]),C=t.convert(0,E),M=t.find(a,[E,E]));var x=f&&m?[]:void 0,N=[],$=[],F=x?[]:void 0,I=x?[]:void 0,R=[],q=[],U,W,P,G;for(W=0;W<A;W++){$[W]=N.length;var j=W+1;for(P=p[W],G=p[W+1];P<G;P++)U=l[P],N.push(U),R[U]=j,F&&(F[U]=f[P]);for(P=D[W],G=D[W+1];P<G;P++)U=w[P],R[U]!==j&&N.push(U),q[U]=j,I&&(I[U]=m[P]);if(x)for(P=$[W];P<N.length;){U=N[P];var H=R[U],V=q[U];if(H===j||V===j){var ct=H===j?F[U]:C,gt=V===j?I[U]:C,ft=M(ct,gt);S(ft,C)?N.splice(P,1):(x.push(ft),P++)}}}return $[A]=N.length,n.createSparseMatrix({values:x,index:N,ptr:$,size:[g,A],datatype:c===n._datatype&&y===s._datatype?E:void 0})}}),wg="matAlgo13xDD",_g=["typed"],Dg=mt(wg,_g,i=>{var{typed:t}=i;return function(n,s,a){var f=n._data,l=n._size,p=n._datatype,h=s._data,c=s._size,m=s._datatype,w=[];if(l.length!==c.length)throw new jt(l.length,c.length);for(var D=0;D<l.length;D++){if(l[D]!==c[D])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");w[D]=l[D]}var v,y=a;typeof p=="string"&&p===m&&(v=p,y=t.find(a,[v,v]));var g=w.length>0?e(y,0,w,w[0],f,h):[];return n.createDenseMatrix({data:g,size:w,datatype:v})};function e(r,n,s,a,f,l){var p=[];if(n===s.length-1)for(var h=0;h<a;h++)p[h]=r(f[h],l[h]);else for(var c=0;c<a;c++)p[c]=e(r,n+1,s,s[n+1],f[c],l[c]);return p}}),yg="broadcast",Eg=["concat"],Ag=mt(yg,Eg,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((D,v)=>D===s._size[v]))return[n,s];for(var f=e(n._size,a,0),l=e(s._size,a,0),p=[],h=0;h<a;h++)p[h]=Math.max(f[h],l[h]);vs(f,p),vs(l,p);var c=n.clone(),m=s.clone();c._size.length<a?c.reshape(e(c._size,a,1)):m._size.length<a&&m.reshape(e(m._size,a,1));for(var w=0;w<a;w++)c._size[w]<p[w]&&(c=r(c,p[w],w)),m._size[w]<p[w]&&(m=r(m,p[w],w));return[c,m]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),bg="matrixAlgorithmSuite",Cg=["typed","matrix","concat"],Tn=mt(bg,Cg,i=>{var{typed:t,matrix:e,concat:r}=i,n=Dg({typed:t}),s=vo({typed:t}),a=Ag({concat:r});return function(l){var p=l.elop,h=l.SD||l.DS,c;p?(c={"DenseMatrix, DenseMatrix":(v,y)=>n(...a(v,y),p),"Array, Array":(v,y)=>n(...a(e(v),e(y)),p).valueOf(),"Array, DenseMatrix":(v,y)=>n(...a(e(v),y),p),"DenseMatrix, Array":(v,y)=>n(...a(v,e(y)),p)},l.SS&&(c["SparseMatrix, SparseMatrix"]=(v,y)=>l.SS(...a(v,y),p,!1)),l.DS&&(c["DenseMatrix, SparseMatrix"]=(v,y)=>l.DS(...a(v,y),p,!1),c["Array, SparseMatrix"]=(v,y)=>l.DS(...a(e(v),y),p,!1)),h&&(c["SparseMatrix, DenseMatrix"]=(v,y)=>h(...a(y,v),p,!0),c["SparseMatrix, Array"]=(v,y)=>h(...a(e(y),v),p,!0))):(c={"DenseMatrix, DenseMatrix":t.referToSelf(v=>(y,g)=>n(...a(y,g),v)),"Array, Array":t.referToSelf(v=>(y,g)=>n(...a(e(y),e(g)),v).valueOf()),"Array, DenseMatrix":t.referToSelf(v=>(y,g)=>n(...a(e(y),g),v)),"DenseMatrix, Array":t.referToSelf(v=>(y,g)=>n(...a(y,e(g)),v))},l.SS&&(c["SparseMatrix, SparseMatrix"]=t.referToSelf(v=>(y,g)=>l.SS(...a(y,g),v,!1))),l.DS&&(c["DenseMatrix, SparseMatrix"]=t.referToSelf(v=>(y,g)=>l.DS(...a(y,g),v,!1)),c["Array, SparseMatrix"]=t.referToSelf(v=>(y,g)=>l.DS(...a(e(y),g),v,!1))),h&&(c["SparseMatrix, DenseMatrix"]=t.referToSelf(v=>(y,g)=>h(...a(g,y),v,!0)),c["SparseMatrix, Array"]=t.referToSelf(v=>(y,g)=>h(...a(e(g),y),v,!0))));var m=l.scalar||"any",w=l.Ds||l.Ss;w&&(p?(c["DenseMatrix,"+m]=(v,y)=>s(v,y,p,!1),c[m+", DenseMatrix"]=(v,y)=>s(y,v,p,!0),c["Array,"+m]=(v,y)=>s(e(v),y,p,!1).valueOf(),c[m+", Array"]=(v,y)=>s(e(y),v,p,!0).valueOf()):(c["DenseMatrix,"+m]=t.referToSelf(v=>(y,g)=>s(y,g,v,!1)),c[m+", DenseMatrix"]=t.referToSelf(v=>(y,g)=>s(g,y,v,!0)),c["Array,"+m]=t.referToSelf(v=>(y,g)=>s(e(y),g,v,!1).valueOf()),c[m+", Array"]=t.referToSelf(v=>(y,g)=>s(e(g),y,v,!0).valueOf())));var D=l.sS!==void 0?l.sS:l.Ss;return p?(l.Ss&&(c["SparseMatrix,"+m]=(v,y)=>l.Ss(v,y,p,!1)),D&&(c[m+", SparseMatrix"]=(v,y)=>D(y,v,p,!0))):(l.Ss&&(c["SparseMatrix,"+m]=t.referToSelf(v=>(y,g)=>l.Ss(y,g,v,!1))),D&&(c[m+", SparseMatrix"]=t.referToSelf(v=>(y,g)=>D(g,y,v,!0)))),p&&p.signatures&&Mf(c,p.signatures),c}}),Fg="matAlgo01xDSid",Mg=["typed"],Oc=mt(Fg,Mg,i=>{var{typed:t}=i;return function(r,n,s,a){var f=r._data,l=r._size,p=r._datatype||r.getDataType(),h=n._values,c=n._index,m=n._ptr,w=n._size,D=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(l.length!==w.length)throw new jt(l.length,w.length);if(l[0]!==w[0]||l[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+w+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var v=l[0],y=l[1],g=typeof p=="string"&&p!=="mixed"&&p===D?p:void 0,A=g?t.find(s,[g,g]):s,E,S,C=[];for(E=0;E<v;E++)C[E]=[];var M=[],x=[];for(S=0;S<y;S++){for(var N=S+1,$=m[S],F=m[S+1],I=$;I<F;I++)E=c[I],M[E]=a?A(h[I],f[E][S]):A(f[E][S],h[I]),x[E]=N;for(E=0;E<v;E++)x[E]===N?C[E][S]=M[E]:C[E][S]=f[E][S]}return r.createDenseMatrix({data:C,size:[v,y],datatype:p===r._datatype&&D===n._datatype?g:void 0})}}),xg="matAlgo04xSidSid",Sg=["typed","equalScalar"],Ng=mt(xg,Sg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var f=n._values,l=n._index,p=n._ptr,h=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,w=s._index,D=s._ptr,v=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==v.length)throw new jt(h.length,v.length);if(h[0]!==v[0]||h[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+v+")");var g=h[0],A=h[1],E,S=e,C=0,M=a;typeof c=="string"&&c===y&&c!=="mixed"&&(E=c,S=t.find(e,[E,E]),C=t.convert(0,E),M=t.find(a,[E,E]));var x=f&&m?[]:void 0,N=[],$=[],F=f&&m?[]:void 0,I=f&&m?[]:void 0,R=[],q=[],U,W,P,G,j;for(W=0;W<A;W++){$[W]=N.length;var H=W+1;for(G=p[W],j=p[W+1],P=G;P<j;P++)U=l[P],N.push(U),R[U]=H,F&&(F[U]=f[P]);for(G=D[W],j=D[W+1],P=G;P<j;P++)if(U=w[P],R[U]===H){if(F){var V=M(F[U],m[P]);S(V,C)?R[U]=null:F[U]=V}}else N.push(U),q[U]=H,I&&(I[U]=m[P]);if(F&&I)for(P=$[W];P<N.length;)U=N[P],R[U]===H?(x[P]=F[U],P++):q[U]===H?(x[P]=I[U],P++):N.splice(P,1)}return $[A]=N.length,n.createSparseMatrix({values:x,index:N,ptr:$,size:[g,A],datatype:c===n._datatype&&y===s._datatype?E:void 0})}}),Bg="matAlgo10xSids",Ig=["typed","DenseMatrix"],Rc=mt(Bg,Ig,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,f){var l=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var w=c[0],D=c[1],v,y=a;typeof m=="string"&&(v=m,s=t.convert(s,v),y=t.find(a,[v,v]));for(var g=[],A=[],E=[],S=0;S<D;S++){for(var C=S+1,M=h[S],x=h[S+1],N=M;N<x;N++){var $=p[N];A[$]=l[N],E[$]=C}for(var F=0;F<w;F++)S===0&&(g[F]=[]),E[F]===C?g[F][S]=f?y(s,A[F]):y(A[F],s):g[F][S]=s}return new e({data:g,size:[w,D],datatype:v})}}),Tg="multiplyScalar",$g=["typed"],Og=mt(Tg,$g,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":Dc,"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)})}),Lc="multiply",Rg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Lg=mt(Lc,Rg,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,f=mo({typed:t,equalScalar:s}),l=vo({typed:t});function p(C,M){switch(C.length){case 1:switch(M.length){case 1:if(C[0]!==M[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(C[0]!==M[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+C[0]+") must match Matrix rows ("+M[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+M.length+" dimensions)")}break;case 2:switch(M.length){case 1:if(C[1]!==M[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+C[1]+") must match Vector length ("+M[0]+")");break;case 2:if(C[1]!==M[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+C[1]+") must match Matrix B rows ("+M[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+M.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+C.length+" dimensions)")}}function h(C,M,x){if(x===0)throw new Error("Cannot multiply two empty vectors");return a(C,M)}function c(C,M){if(M.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(C,M)}function m(C,M){var x=C._data,N=C._size,$=C._datatype||C.getDataType(),F=M._data,I=M._size,R=M._datatype||M.getDataType(),q=N[0],U=I[1],W,P=r,G=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&(W=$,P=t.find(r,[W,W]),G=t.find(n,[W,W]));for(var j=[],H=0;H<U;H++){for(var V=G(x[0],F[0][H]),ct=1;ct<q;ct++)V=P(V,G(x[ct],F[ct][H]));j[H]=V}return C.createDenseMatrix({data:j,size:[U],datatype:$===C._datatype&&R===M._datatype?W:void 0})}var w=t("_multiplyMatrixVector",{"DenseMatrix, any":v,"SparseMatrix, any":A}),D=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":g,"SparseMatrix, DenseMatrix":E,"SparseMatrix, SparseMatrix":S});function v(C,M){var x=C._data,N=C._size,$=C._datatype||C.getDataType(),F=M._data,I=M._datatype||M.getDataType(),R=N[0],q=N[1],U,W=r,P=n;$&&I&&$===I&&typeof $=="string"&&$!=="mixed"&&(U=$,W=t.find(r,[U,U]),P=t.find(n,[U,U]));for(var G=[],j=0;j<R;j++){for(var H=x[j],V=P(H[0],F[0]),ct=1;ct<q;ct++)V=W(V,P(H[ct],F[ct]));G[j]=V}return C.createDenseMatrix({data:G,size:[R],datatype:$===C._datatype&&I===M._datatype?U:void 0})}function y(C,M){var x=C._data,N=C._size,$=C._datatype||C.getDataType(),F=M._data,I=M._size,R=M._datatype||M.getDataType(),q=N[0],U=N[1],W=I[1],P,G=r,j=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&$!=="mixed"&&(P=$,G=t.find(r,[P,P]),j=t.find(n,[P,P]));for(var H=[],V=0;V<q;V++){var ct=x[V];H[V]=[];for(var gt=0;gt<W;gt++){for(var ft=j(ct[0],F[0][gt]),_t=1;_t<U;_t++)ft=G(ft,j(ct[_t],F[_t][gt]));H[V][gt]=ft}}return C.createDenseMatrix({data:H,size:[q,W],datatype:$===C._datatype&&R===M._datatype?P:void 0})}function g(C,M){var x=C._data,N=C._size,$=C._datatype||C.getDataType(),F=M._values,I=M._index,R=M._ptr,q=M._size,U=M._datatype||M._data===void 0?M._datatype:M.getDataType();if(!F)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=N[0],P=q[1],G,j=r,H=n,V=s,ct=0;$&&U&&$===U&&typeof $=="string"&&$!=="mixed"&&(G=$,j=t.find(r,[G,G]),H=t.find(n,[G,G]),V=t.find(s,[G,G]),ct=t.convert(0,G));for(var gt=[],ft=[],_t=[],yt=M.createSparseMatrix({values:gt,index:ft,ptr:_t,size:[W,P],datatype:$===C._datatype&&U===M._datatype?G:void 0}),Nt=0;Nt<P;Nt++){_t[Nt]=ft.length;var Et=R[Nt],ee=R[Nt+1];if(ee>Et)for(var It=0,xt=0;xt<W;xt++){for(var ie=xt+1,Xt=void 0,zt=Et;zt<ee;zt++){var Gt=I[zt];It!==ie?(Xt=H(x[xt][Gt],F[zt]),It=ie):Xt=j(Xt,H(x[xt][Gt],F[zt]))}It===ie&&!V(Xt,ct)&&(ft.push(xt),gt.push(Xt))}}return _t[P]=ft.length,yt}function A(C,M){var x=C._values,N=C._index,$=C._ptr,F=C._datatype||C._data===void 0?C._datatype:C.getDataType();if(!x)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=M._data,R=M._datatype||M.getDataType(),q=C._size[0],U=M._size[0],W=[],P=[],G=[],j,H=r,V=n,ct=s,gt=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(j=F,H=t.find(r,[j,j]),V=t.find(n,[j,j]),ct=t.find(s,[j,j]),gt=t.convert(0,j));var ft=[],_t=[];G[0]=0;for(var yt=0;yt<U;yt++){var Nt=I[yt];if(!ct(Nt,gt))for(var Et=$[yt],ee=$[yt+1],It=Et;It<ee;It++){var xt=N[It];_t[xt]?ft[xt]=H(ft[xt],V(Nt,x[It])):(_t[xt]=!0,P.push(xt),ft[xt]=V(Nt,x[It]))}}for(var ie=P.length,Xt=0;Xt<ie;Xt++){var zt=P[Xt];W[Xt]=ft[zt]}return G[1]=P.length,C.createSparseMatrix({values:W,index:P,ptr:G,size:[q,1],datatype:F===C._datatype&&R===M._datatype?j:void 0})}function E(C,M){var x=C._values,N=C._index,$=C._ptr,F=C._datatype||C._data===void 0?C._datatype:C.getDataType();if(!x)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=M._data,R=M._datatype||M.getDataType(),q=C._size[0],U=M._size[0],W=M._size[1],P,G=r,j=n,H=s,V=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(P=F,G=t.find(r,[P,P]),j=t.find(n,[P,P]),H=t.find(s,[P,P]),V=t.convert(0,P));for(var ct=[],gt=[],ft=[],_t=C.createSparseMatrix({values:ct,index:gt,ptr:ft,size:[q,W],datatype:F===C._datatype&&R===M._datatype?P:void 0}),yt=[],Nt=[],Et=0;Et<W;Et++){ft[Et]=gt.length;for(var ee=Et+1,It=0;It<U;It++){var xt=I[It][Et];if(!H(xt,V))for(var ie=$[It],Xt=$[It+1],zt=ie;zt<Xt;zt++){var Gt=N[zt];Nt[Gt]!==ee?(Nt[Gt]=ee,gt.push(Gt),yt[Gt]=j(xt,x[zt])):yt[Gt]=G(yt[Gt],j(xt,x[zt]))}}for(var Fe=ft[Et],er=gt.length,xe=Fe;xe<er;xe++){var jr=gt[xe];ct[xe]=yt[jr]}}return ft[W]=gt.length,_t}function S(C,M){var x=C._values,N=C._index,$=C._ptr,F=C._datatype||C._data===void 0?C._datatype:C.getDataType(),I=M._values,R=M._index,q=M._ptr,U=M._datatype||M._data===void 0?M._datatype:M.getDataType(),W=C._size[0],P=M._size[1],G=x&&I,j,H=r,V=n;F&&U&&F===U&&typeof F=="string"&&F!=="mixed"&&(j=F,H=t.find(r,[j,j]),V=t.find(n,[j,j]));for(var ct=G?[]:void 0,gt=[],ft=[],_t=C.createSparseMatrix({values:ct,index:gt,ptr:ft,size:[W,P],datatype:F===C._datatype&&U===M._datatype?j:void 0}),yt=G?[]:void 0,Nt=[],Et,ee,It,xt,ie,Xt,zt,Gt,Fe=0;Fe<P;Fe++){ft[Fe]=gt.length;var er=Fe+1;for(ie=q[Fe],Xt=q[Fe+1],xt=ie;xt<Xt;xt++)if(Gt=R[xt],G)for(ee=$[Gt],It=$[Gt+1],Et=ee;Et<It;Et++)zt=N[Et],Nt[zt]!==er?(Nt[zt]=er,gt.push(zt),yt[zt]=V(I[xt],x[Et])):yt[zt]=H(yt[zt],V(I[xt],x[Et]));else for(ee=$[Gt],It=$[Gt+1],Et=ee;Et<It;Et++)zt=N[Et],Nt[zt]!==er&&(Nt[zt]=er,gt.push(zt));if(G)for(var xe=ft[Fe],jr=gt.length,pn=xe;pn<jr;pn++){var Gr=gt[pn];ct[pn]=yt[Gr]}}return ft[P]=gt.length,_t}return t(Lc,n,{"Array, Array":t.referTo("Matrix, Matrix",C=>(M,x)=>{p(be(M),be(x));var N=C(e(M),e(x));return ce(N)?N.valueOf():N}),"Matrix, Matrix":function(M,x){var N=M.size(),$=x.size();return p(N,$),N.length===1?$.length===1?h(M,x,N[0]):c(M,x):$.length===1?w(M,x):D(M,x)},"Matrix, Array":t.referTo("Matrix,Matrix",C=>(M,x)=>C(M,e(x))),"Array, Matrix":t.referToSelf(C=>(M,x)=>C(e(M,x.storage()),x)),"SparseMatrix, any":function(M,x){return f(M,x,n,!1)},"DenseMatrix, any":function(M,x){return l(M,x,n,!1)},"any, SparseMatrix":function(M,x){return f(x,M,n,!0)},"any, DenseMatrix":function(M,x){return l(x,M,n,!0)},"Array, any":function(M,x){return l(e(M),x,n,!1).valueOf()},"any, Array":function(M,x){return l(e(x),M,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(C=>(M,x,N)=>{for(var $=C(M,x),F=0;F<N.length;F++)$=C($,N[F]);return $})})}),Pc="subtract",Pg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],zg=mt(Pc,Pg,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:f}=i,l=Oc({typed:t}),p=ni({typed:t}),h=$c({typed:t,equalScalar:r}),c=Rc({typed:t,DenseMatrix:a}),m=ri({typed:t,DenseMatrix:a}),w=Tn({typed:t,matrix:e,concat:f});return t(Pc,{"any, any":n},w({elop:n,SS:h,DS:l,SD:p,Ss:m,sS:c}))}),Ug="matAlgo07xSSf",qg=["typed","DenseMatrix"],Bs=mt(Ug,qg,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,f){var l=s._size,p=s._datatype||s._data===void 0?s._datatype:s.getDataType(),h=a._size,c=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(l.length!==h.length)throw new jt(l.length,h.length);if(l[0]!==h[0]||l[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+h+")");var m=l[0],w=l[1],D,v=0,y=f;typeof p=="string"&&p===c&&p!=="mixed"&&(D=p,v=t.convert(0,D),y=t.find(f,[D,D]));var g,A,E=[];for(g=0;g<m;g++)E[g]=[];var S=[],C=[],M=[],x=[];for(A=0;A<w;A++){var N=A+1;for(r(s,A,M,S,N),r(a,A,x,C,N),g=0;g<m;g++){var $=M[g]===N?S[g]:v,F=x[g]===N?C[g]:v;E[g][A]=y($,F)}}return new e({data:E,size:[m,w],datatype:p===s._datatype&&c===a._datatype?D:void 0})};function r(n,s,a,f,l){for(var p=n._values,h=n._index,c=n._ptr,m=c[s],w=c[s+1];m<w;m++){var D=h[m];a[D]=l,f[D]=p[m]}}}),zc="conj",Wg=["typed"],kg=mt(zc,Wg,i=>{var{typed:t}=i;return t(zc,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>xr(r,e))})}),Uc="concat",Yg=["typed","matrix","isInteger"],Zg=mt(Uc,Yg,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(Uc,{"...Array | Matrix | number | BigNumber":function(s){var a,f=s.length,l=-1,p,h=!1,c=[];for(a=0;a<f;a++){var m=s[a];if(ce(m)&&(h=!0),ae(m)||ye(m)){if(a!==f-1)throw new Error("Dimension must be specified as last argument");if(p=l,l=m.valueOf(),!r(l))throw new TypeError("Integer number expected for dimension");if(l<0||a>0&&l>p)throw new un(l,p+1)}else{var w=te(m).valueOf(),D=be(w);if(c[a]=w,p=l,l=D.length-1,a>0&&l!==p)throw new jt(p+1,l+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var v=c.shift();c.length;)v=Gf(v,c.shift(),l);return h?e(v):v},"...string":function(s){return s.join("")}})}),qc="count",jg=["typed","size","prod"],Gg=mt(qc,jg,i=>{var{typed:t,size:e,prod:r}=i;return t(qc,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Wc="identity",Kg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Jg=mt(Wc,Kg,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(Wc,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(h){return r(h)},"number | BigNumber":function(h){return l(h,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,c){return l(h,h,c)},"number | BigNumber, number | BigNumber":function(h,c){return l(h,c,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,c,m){return l(h,c,m)},Array:function(h){return f(h)},"Array, string":function(h,c){return f(h,c)},Matrix:function(h){return f(h.valueOf(),h.storage())},"Matrix, string":function(h,c){return f(h.valueOf(),c)}});function f(p,h){switch(p.length){case 0:return h?r(h):[];case 1:return l(p[0],p[0],h);case 2:return l(p[0],p[1],h);default:throw new Error("Vector containing two values expected")}}function l(p,h,c){var m=ye(p)||ye(h)?n:null;if(ye(p)&&(p=p.toNumber()),ye(h)&&(h=h.toNumber()),!he(p)||p<1)throw new Error("Parameters in function identity must be positive integers");if(!he(h)||h<1)throw new Error("Parameters in function identity must be positive integers");var w=m?new n(1):1,D=m?new m(0):0,v=[p,h];if(c){if(c==="sparse")return a.diagonal(v,w,0,D);if(c==="dense")return s.diagonal(v,w,0,D);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var y=to([],v,D),g=p<h?p:h,A=0;A<g;A++)y[A][A]=w;return y}}),kc="kron",Xg=["typed","matrix","multiplyScalar"],Hg=mt(kc,Xg,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(kc,{"Matrix, Matrix":function(a,f){return e(n(a.toArray(),f.toArray()))},"Matrix, Array":function(a,f){return e(n(a.toArray(),f))},"Array, Matrix":function(a,f){return e(n(a,f.toArray()))},"Array, Array":n});function n(s,a){if(be(s).length===1&&(s=[s]),be(a).length===1&&(a=[a]),be(s).length>2||be(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var f=[],l=[];return s.map(function(p){return a.map(function(h){return l=[],f.push(l),p.map(function(c){return h.map(function(m){return l.push(r(c,m))})})})})&&f}});function Qg(){throw new Error('No "bignumber" implementation available')}function Vg(){throw new Error('No "fraction" implementation available')}function t1(){throw new Error('No "matrix" implementation available')}var Yc="reshape",e1=["typed","isInteger","matrix"],r1=mt(Yc,e1,i=>{var{typed:t,isInteger:e}=i;return t(Yc,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),ro(n,s)}})}),Zc="size",n1=["typed","config","?matrix"],i1=mt(Zc,n1,i=>{var{typed:t,config:e,matrix:r}=i;return t(Zc,{Matrix:function(s){return s.create(s.size())},Array:be,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):t1()}})}),jc="transpose",s1=["typed","matrix"],u1=mt(jc,s1,i=>{var{typed:t,matrix:e}=i;return t(jc,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:te});function r(a){var f=a.size(),l;switch(f.length){case 1:l=a.clone();break;case 2:{var p=f[0],h=f[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+se(f)+")");switch(a.storage()){case"dense":l=n(a,p,h);break;case"sparse":l=s(a,p,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+se(f)+")")}return l}function n(a,f,l){for(var p=a._data,h=[],c,m=0;m<l;m++){c=h[m]=[];for(var w=0;w<f;w++)c[w]=te(p[w][m])}return a.createDenseMatrix({data:h,size:[l,f],datatype:a._datatype})}function s(a,f,l){for(var p=a._values,h=a._index,c=a._ptr,m=p?[]:void 0,w=[],D=[],v=[],y=0;y<f;y++)v[y]=0;var g,A,E;for(g=0,A=h.length;g<A;g++)v[h[g]]++;for(var S=0,C=0;C<f;C++)D.push(S),S+=v[C],v[C]=D[C];for(D.push(S),E=0;E<l;E++)for(var M=c[E],x=c[E+1],N=M;N<x;N++){var $=v[h[N]]++;w[$]=E,p&&(m[$]=te(p[N]))}return a.createSparseMatrix({values:m,index:w,ptr:D,size:[l,f],datatype:a._datatype})}}),Gc="ctranspose",o1=["typed","transpose","conj"],a1=mt(Gc,o1,i=>{var{typed:t,transpose:e,conj:r}=i;return t(Gc,{any:function(s){return r(e(s))}})}),Kc="mode",f1=["typed","isNaN","isNumeric"],c1=mt(Kc,f1,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(Kc,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=io(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var f={},l=[],p=0,h=0;h<s.length;h++){var c=s[h];if(r(c)&&e(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in f||(f[c]=0),f[c]++,f[c]===p?l.push(c):f[c]>p&&(p=f[c],l=[c])}return l}});function ln(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+sn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+sn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var Jc="prod",l1=["typed","config","multiplyScalar","numeric"],h1=mt(Jc,l1,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(Jc,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(f,l){throw new Error("prod(A, dim) is not yet supported")},"...":function(f){return s(f)}});function s(a){var f;if(Ii(a,function(l){try{f=f===void 0?l:r(f,l)}catch(p){throw ln(p,"prod",l)}}),typeof f=="string"&&(f=n(f,e.number)),f===void 0)throw new Error("Cannot calculate prod of an empty array");return f}}),p1="numeric",d1=["number","?bignumber","?fraction"],m1=mt(p1,d1,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):Qg,Fraction:r?a=>r(a):Vg};return function(f){var l=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=sn(f);if(!(h in n))throw new TypeError("Cannot convert "+f+' of type "'+h+'"; valid input types are '+Object.keys(n).join(", "));if(!(l in s))throw new TypeError("Cannot convert "+f+' to type "'+l+'"; valid output types are '+Object.keys(s).join(", "));return l===h?f:s[l](f)}}),Xc="divideScalar",v1=["typed","numeric"],g1=mt(Xc,v1,i=>{var{typed:t,numeric:e}=i;return t(Xc,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),Hc="pow",w1=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],_1=mt(Hc,w1,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:f,fraction:l,Complex:p}=i;return t(Hc,{"number, number":h,"Complex, Complex":function(D,v){return D.pow(v)},"BigNumber, BigNumber":function(D,v){return v.isInteger()||D>=0||e.predictable?D.pow(v):new p(D.toNumber(),0).pow(v.toNumber(),0)},"Fraction, Fraction":function(D,v){var y=D.pow(v);if(y!=null)return y;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return h(D.valueOf(),v.valueOf())},"Array, number":c,"Array, BigNumber":function(D,v){return c(D,v.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(D,v){return m(D,v.toNumber())},"Unit, number | BigNumber":function(D,v){return D.pow(v)}});function h(w,D){if(e.predictable&&!he(D)&&w<0)try{var v=l(D),y=f(v);if((D===y||Math.abs((D-y)/D)<1e-14)&&v.d%2===1)return(v.n%2===0?1:-1)*Math.pow(-w,D)}catch{}return e.predictable&&(w<-1&&D===1/0||w>-1&&w<0&&D===-1/0)?NaN:he(D)||w>=0||e.predictable?Ec(w,D):w*w<1&&D===1/0||w*w>1&&D===-1/0?0:new p(w,0).pow(D,0)}function c(w,D){if(!he(D))throw new TypeError("For A^b, b must be an integer (value is "+D+")");var v=be(w);if(v.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+v.length+" dimensions)");if(v[0]!==v[1])throw new Error("For A^b, A must be square (size is "+v[0]+"x"+v[1]+")");if(D<0)try{return c(a(w),-D)}catch(A){throw A.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 "+D+")"):A}for(var y=r(v[0]).valueOf(),g=w;D>=1;)(D&1)===1&&(y=n(g,y)),D>>=1,g=n(g,g);return y}function m(w,D){return s(c(w.valueOf(),D))}}),Qc="dotDivide",D1=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],y1=mt(Qc,D1,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,f=pg({typed:t,equalScalar:r}),l=ni({typed:t}),p=Bs({typed:t,DenseMatrix:s}),h=mo({typed:t,equalScalar:r}),c=ri({typed:t,DenseMatrix:s}),m=Tn({typed:t,matrix:e,concat:a});return t(Qc,m({elop:n,SS:p,DS:l,SD:f,Ss:h,sS:c}))}),Is="compare",E1=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],A1=mt(Is,E1,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:f,concat:l}=i,p=ni({typed:t}),h=$c({typed:t,equalScalar:r}),c=ri({typed:t,DenseMatrix:f}),m=Tn({typed:t,matrix:n,concat:l}),w=Ss({typed:t});return t(Is,b1({typed:t,config:e}),{"boolean, boolean":function(v,y){return v===y?0:v>y?1:-1},"BigNumber, BigNumber":function(v,y){return xs(v,y,e.epsilon)?new s(0):new s(v.cmp(y))},"Fraction, Fraction":function(v,y){return new a(v.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},w,m({SS:h,DS:p,Ss:c}))}),b1=mt(Is,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Is,{"number, number":function(n,s){return In(n,s,e.epsilon)?0:n>s?1:-1}})}),Ts="equal",C1=["typed","matrix","equalScalar","DenseMatrix","concat"],F1=mt(Ts,C1,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=ni({typed:t}),f=Bs({typed:t,DenseMatrix:n}),l=ri({typed:t,DenseMatrix:n}),p=Tn({typed:t,matrix:e,concat:s});return t(Ts,M1({typed:t,equalScalar:r}),p({elop:r,SS:f,DS:a,Ss:l}))}),M1=mt(Ts,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Ts,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),$s="smaller",x1=["typed","config","matrix","DenseMatrix","concat"],S1=mt($s,x1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=ni({typed:t}),f=Bs({typed:t,DenseMatrix:n}),l=ri({typed:t,DenseMatrix:n}),p=Tn({typed:t,matrix:r,concat:s}),h=Ss({typed:t});return t($s,N1({typed:t,config:e}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,w){return m.lt(w)&&!xs(m,w,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===-1,"Complex, Complex":function(m,w){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:f,DS:a,Ss:l}))}),N1=mt($s,["typed","config"],i=>{var{typed:t,config:e}=i;return t($s,{"number, number":function(n,s){return n<s&&!In(n,s,e.epsilon)}})}),Os="larger",B1=["typed","config","matrix","DenseMatrix","concat"],I1=mt(Os,B1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=ni({typed:t}),f=Bs({typed:t,DenseMatrix:n}),l=ri({typed:t,DenseMatrix:n}),p=Tn({typed:t,matrix:r,concat:s}),h=Ss({typed:t});return t(Os,T1({typed:t,config:e}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,w){return m.gt(w)&&!xs(m,w,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:f,DS:a,Ss:l}))}),T1=mt(Os,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Os,{"number, number":function(n,s){return n>s&&!In(n,s,e.epsilon)}})}),Vc="deepEqual",$1=["typed","equal"],O1=mt(Vc,$1,i=>{var{typed:t,equal:e}=i;return t(Vc,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var f=0;f<a;f++)if(!r(n[f],s[f]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),tl="partitionSelect",R1=["typed","isNumeric","isNaN","compare"],L1=mt(tl,R1,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(p,h)=>-n(p,h);return t(tl,{"Array | Matrix, number":function(h,c){return f(h,c,s)},"Array | Matrix, number, string":function(h,c,m){if(m==="asc")return f(h,c,s);if(m==="desc")return f(h,c,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":f});function f(p,h,c){if(!he(h)||h<0)throw new Error("k must be a non-negative integer");if(ce(p)){var m=p.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return l(p.valueOf(),h,c)}if(Array.isArray(p))return l(p,h,c)}function l(p,h,c){if(h>=p.length)throw new Error("k out of bounds");for(var m=0;m<p.length;m++)if(e(p[m])&&r(p[m]))return p[m];for(var w=0,D=p.length-1;w<D;){for(var v=w,y=D,g=p[Math.floor(Math.random()*(D-w+1))+w];v<y;)if(c(p[v],g)>=0){var A=p[y];p[y]=p[v],p[v]=A,--y}else++v;c(p[v],g)>0&&--v,h<=v?D=v:w=v+1}return p[h]}}),el="max",P1=["typed","config","numeric","larger"],z1=mt(el,P1,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(el,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){return po(l,p.valueOf(),s)},"...":function(l){if(Cs(l))throw new TypeError("Scalar values expected in function max");return a(l)}});function s(f,l){try{return n(f,l)?f:l}catch(p){throw ln(p,"max",l)}}function a(f){var l;if(Ii(f,function(p){try{isNaN(p)&&typeof p=="number"?l=NaN:(l===void 0||n(p,l))&&(l=p)}catch(h){throw ln(h,"max",p)}}),l===void 0)throw new Error("Cannot calculate max of an empty array");return typeof l=="string"&&(l=r(l,e.number)),l}}),rl="min",U1=["typed","config","numeric","smaller"],q1=mt(rl,U1,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(rl,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){return po(l,p.valueOf(),s)},"...":function(l){if(Cs(l))throw new TypeError("Scalar values expected in function min");return a(l)}});function s(f,l){try{return n(f,l)?f:l}catch(p){throw ln(p,"min",l)}}function a(f){var l;if(Ii(f,function(p){try{isNaN(p)&&typeof p=="number"?l=NaN:(l===void 0||n(p,l))&&(l=p)}catch(h){throw ln(h,"min",p)}}),l===void 0)throw new Error("Cannot calculate min of an empty array");return typeof l=="string"&&(l=r(l,e.number)),l}}),nl="add",W1=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],k1=mt(nl,W1,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:f}=i,l=Oc({typed:t}),p=Ng({typed:t,equalScalar:n}),h=Rc({typed:t,DenseMatrix:s}),c=Tn({typed:t,matrix:e,concat:f});return t(nl,{"any, any":r,"any, any, ...any":t.referToSelf(m=>(w,D,v)=>{for(var y=m(w,D),g=0;g<v.length;g++)y=m(y,v[g]);return y})},c({elop:r,DS:l,SS:p,Ss:h}))}),il="dot",Y1=["typed","addScalar","multiplyScalar","conj","size"],Z1=mt(il,Y1,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(il,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function a(h,c){var m=p(h),w=p(c),D,v;if(m.length===1)D=m[0];else if(m.length===2&&m[1]===1)D=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(w.length===1)v=w[0];else if(w.length===2&&w[1]===1)v=w[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+w.join(", ")+")");if(D!==v)throw new RangeError("Vectors must have equal length ("+D+" != "+v+")");if(D===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return D}function f(h,c){var m=a(h,c),w=ce(h)?h._data:h,D=ce(h)?h._datatype||h.getDataType():void 0,v=ce(c)?c._data:c,y=ce(c)?c._datatype||c.getDataType():void 0,g=p(h).length===2,A=p(c).length===2,E=e,S=r;if(D&&y&&D===y&&typeof D=="string"&&D!=="mixed"){var C=D;E=t.find(e,[C,C]),S=t.find(r,[C,C])}if(!g&&!A){for(var M=S(n(w[0]),v[0]),x=1;x<m;x++)M=E(M,S(n(w[x]),v[x]));return M}if(!g&&A){for(var N=S(n(w[0]),v[0][0]),$=1;$<m;$++)N=E(N,S(n(w[$]),v[$][0]));return N}if(g&&!A){for(var F=S(n(w[0][0]),v[0]),I=1;I<m;I++)F=E(F,S(n(w[I][0]),v[I]));return F}if(g&&A){for(var R=S(n(w[0][0]),v[0][0]),q=1;q<m;q++)R=E(R,S(n(w[q][0]),v[q][0]));return R}}function l(h,c){a(h,c);for(var m=h._index,w=h._values,D=c._index,v=c._values,y=0,g=e,A=r,E=0,S=0;E<m.length&&S<D.length;){var C=m[E],M=D[S];if(C<M){E++;continue}if(C>M){S++;continue}C===M&&(y=g(y,A(w[E],v[S])),E++,S++)}return y}function p(h){return ce(h)?h.size():s(h)}}),j1="trace",G1=["typed","matrix","add"],K1=mt(j1,G1,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(f){return n(e(f))},SparseMatrix:s,DenseMatrix:n,any:te});function n(a){var f=a._size,l=a._data;switch(f.length){case 1:if(f[0]===1)return te(l[0]);throw new RangeError("Matrix must be square (size: "+se(f)+")");case 2:{var p=f[0],h=f[1];if(p===h){for(var c=0,m=0;m<p;m++)c=r(c,l[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+se(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(f)+")")}}function s(a){var f=a._values,l=a._index,p=a._ptr,h=a._size,c=h[0],m=h[1];if(c===m){var w=0;if(f.length>0)for(var D=0;D<m;D++)for(var v=p[D],y=p[D+1],g=v;g<y;g++){var A=l[g];if(A===D){w=r(w,f[g]);break}if(A>D)break}return w}throw new RangeError("Matrix must be square (size: "+se(h)+")")}}),sl="det",J1=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],X1=mt(sl,J1,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:f}=i;return t(sl,{any:function(h){return te(h)},"Array | Matrix":function(h){var c;switch(ce(h)?c=h.size():Array.isArray(h)?(h=e(h),c=h.size()):c=[],c.length){case 0:return te(h);case 1:if(c[0]===1)return te(h.valueOf()[0]);if(c[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")");case 2:{var m=c[0],w=c[1];if(m===w)return l(h.clone().valueOf(),m);if(w===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(c)+")")}}});function l(p,h,c){if(h===1)return te(p[0][0]);if(h===2)return r(n(p[0][0],p[1][1]),n(p[1][0],p[0][1]));for(var m=!1,w=new Array(h).fill(0).map((x,N)=>N),D=0;D<h;D++){var v=w[D];if(a(p[v][D])){var y=void 0;for(y=D+1;y<h;y++)if(!a(p[w[y]][D])){v=w[y],w[y]=w[D],w[D]=v,m=!m;break}if(y===h)return p[v][D]}for(var g=p[v][D],A=D===0?1:p[w[D-1]][D-1],E=D+1;E<h;E++)for(var S=w[E],C=D+1;C<h;C++)p[S][C]=s(r(n(p[S][C],g),n(p[S][D],p[v][C])),A)}var M=p[w[h-1]][h-1];return m?f(M):M}}),ul="inv",H1=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Q1=mt(ul,H1,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:f,identity:l,abs:p}=i;return t(ul,{"Array | Matrix":function(m){var w=ce(m)?m.size():be(m);switch(w.length){case 1:if(w[0]===1)return ce(m)?e([r(1,m.valueOf()[0])]):[r(1,m[0])];throw new RangeError("Matrix must be square (size: "+se(w)+")");case 2:{var D=w[0],v=w[1];if(D===v)return ce(m)?e(h(m.valueOf(),D,v),m.storage()):h(m,D,v);throw new RangeError("Matrix must be square (size: "+se(w)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(w)+")")}},any:function(m){return r(1,m)}});function h(c,m,w){var D,v,y,g,A;if(m===1){if(g=c[0][0],g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,g)]]}else if(m===2){var E=f(c);if(E===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(c[1][1],E),r(a(c[0][1]),E)],[r(a(c[1][0]),E),r(c[0][0],E)]]}else{var S=c.concat();for(D=0;D<m;D++)S[D]=S[D].concat();for(var C=l(m).valueOf(),M=0;M<w;M++){var x=p(S[M][M]),N=M;for(D=M+1;D<m;)p(S[D][M])>x&&(x=p(S[D][M]),N=D),D++;if(x===0)throw Error("Cannot calculate inverse, determinant is zero");D=N,D!==M&&(A=S[M],S[M]=S[D],S[D]=A,A=C[M],C[M]=C[D],C[D]=A);var $=S[M],F=C[M];for(D=0;D<m;D++){var I=S[D],R=C[D];if(D!==M){if(I[M]!==0){for(y=r(a(I[M]),$[M]),v=M;v<w;v++)I[v]=n(I[v],s(y,$[v]));for(v=0;v<w;v++)R[v]=n(R[v],s(y,F[v]))}}else{for(y=$[M],v=M;v<w;v++)I[v]=r(I[v],y);for(v=0;v<w;v++)R[v]=r(R[v],y)}}}return C}}}),ol="pinv",V1=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],tw=mt(ol,V1,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:f,ctranspose:l,divideScalar:p,multiply:h,add:c,Complex:m}=i;return t(ol,{"Array | Matrix":function(E){var S=ce(E)?E.size():be(E);switch(S.length){case 1:return g(E)?l(E):S[0]===1?r(E):a(l(E),f(E,E));case 2:{if(g(E))return l(E);var C=S[0],M=S[1];if(C===M)try{return r(E)}catch(x){if(!(x instanceof Error&&x.message.match(/Cannot calculate inverse, determinant is zero/)))throw x}return ce(E)?e(w(E.valueOf(),C,M),E.storage()):w(E,C,M)}default:throw new RangeError("Matrix must be two dimensional (size: "+se(S)+")")}},any:function(E){return s(E,0)?te(E):p(1,E)}});function w(A,E,S){var{C,F:M}=v(A,E,S),x=h(r(h(l(C),C)),l(C)),N=h(l(M),r(h(M,l(M))));return h(N,x)}function D(A,E,S){for(var C=te(A),M=0,x=0;x<E;x++){if(S<=M)return C;for(var N=x;y(C[N][M]);)if(N++,E===N&&(N=x,M++,S===M))return C;[C[N],C[x]]=[C[x],C[N]];for(var $=C[x][M],F=0;F<S;F++)C[x][F]=a(C[x][F],$);for(var I=0;I<E;I++)if(I!==x){$=C[I][M];for(var R=0;R<S;R++)C[I][R]=c(C[I][R],h(-1,h($,C[x][R])))}M++}return C}function v(A,E,S){var C=D(A,E,S),M=A.map((N,$)=>N.filter((F,I)=>I<E&&!y(f(C[I],C[I])))),x=C.filter((N,$)=>!y(f(C[$],C[$])));return{C:M,F:x}}function y(A){return s(c(A,m(1,1)),c(0,m(1,1)))}function g(A){return n(c(A,m(1,1)),c(h(A,0),m(1,1)))}}),ew="divide",rw=["typed","matrix","multiply","equalScalar","divideScalar","inv"],nw=mt(ew,rw,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,f=mo({typed:t,equalScalar:n}),l=vo({typed:t});return t("divide",Mf({"Array | Matrix, Array | Matrix":function(h,c){return r(h,a(c))},"DenseMatrix, any":function(h,c){return l(h,c,s,!1)},"SparseMatrix, any":function(h,c){return f(h,c,s,!1)},"Array, any":function(h,c){return l(e(h),c,s,!1).valueOf()},"any, Array | Matrix":function(h,c){return r(h,a(c))}},s.signatures))}),al="sum",iw=["typed","config","add","numeric"],sw=mt(al,iw,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(al,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(l){if(Cs(l))throw new TypeError("Scalar values expected in function sum");return s(l)}});function s(f){var l;return Ii(f,function(p){try{l=l===void 0?p:r(l,p)}catch(h){throw ln(h,"sum",p)}}),l===void 0&&(l=n(0,e.number)),typeof l=="string"&&(l=n(l,e.number)),l}function a(f,l){try{var p=po(f,l,r);return p}catch(h){throw ln(h,"sum")}}}),fl="median",uw=["typed","add","divide","compare","partitionSelect"],ow=mt(fl,uw,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(p){try{p=io(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 c=h/2-1,m=s(p,c+1),w=p[c],D=0;D<c;++D)n(p[D],w)>0&&(w=p[D]);return l(w,m)}else{var v=s(p,(h-1)/2);return f(v)}}catch(y){throw ln(y,"median")}}var f=t({"number | BigNumber | Complex | Unit":function(h){return h}}),l=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,c){return r(e(h,c),2)}});return t(fl,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,c){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(Cs(h))throw new TypeError("Scalar values expected in function median");return a(h)}})}),Rs=av({config:Ve}),go=hv({}),wo=vv({}),_o=_v({}),Pr=Ev({Matrix:_o}),Mt=lm({BigNumber:Rs,Complex:go,DenseMatrix:Pr,Fraction:wo}),aw=tg({typed:Mt}),Ls=rg({typed:Mt}),fw=Zv({BigNumber:Rs,typed:Mt}),cl=kg({typed:Mt}),hn=$v({config:Ve,typed:Mt}),Ps=Cv({typed:Mt}),cw=Sv({typed:Mt}),zs=Og({typed:Mt}),ll=Wv({typed:Mt}),Do=Lv({Matrix:_o,equalScalar:hn,typed:Mt}),hl=ig({typed:Mt}),pl=Bv({typed:Mt}),yo=Qv({typed:Mt}),dl=Kv({Fraction:wo,typed:Mt}),ml=Mv({typed:Mt}),Ce=Xv({DenseMatrix:Pr,Matrix:_o,SparseMatrix:Do,typed:Mt}),vl=c1({isNaN:pl,isNumeric:ml,typed:Mt}),Ti=m1({bignumber:fw,fraction:dl,number:ll}),lw=h1({config:Ve,multiplyScalar:zs,numeric:Ti,typed:Mt}),hw=r1({isInteger:Ps,matrix:Ce,typed:Mt}),gl=i1({matrix:Ce,config:Ve,typed:Mt}),wl=u1({matrix:Ce,typed:Mt}),$n=Zg({isInteger:Ps,matrix:Ce,typed:Mt}),pw=Gg({prod:lw,size:gl,typed:Mt}),dw=a1({conj:cl,transpose:wl,typed:Mt}),$i=g1({numeric:Ti,typed:Mt}),mw=y1({DenseMatrix:Pr,concat:$n,divideScalar:$i,equalScalar:hn,matrix:Ce,typed:Mt}),_l=F1({DenseMatrix:Pr,concat:$n,equalScalar:hn,matrix:Ce,typed:Mt}),Dl=Jg({BigNumber:Rs,DenseMatrix:Pr,SparseMatrix:Do,config:Ve,matrix:Ce,typed:Mt}),vw=Hg({matrix:Ce,multiplyScalar:zs,typed:Mt}),gw=S1({DenseMatrix:Pr,concat:$n,config:Ve,matrix:Ce,typed:Mt}),ww=zg({DenseMatrix:Pr,concat:$n,equalScalar:hn,matrix:Ce,subtractScalar:hl,typed:Mt,unaryMinus:yo}),Oi=k1({DenseMatrix:Pr,SparseMatrix:Do,addScalar:Ls,concat:$n,equalScalar:hn,matrix:Ce,typed:Mt}),yl=A1({BigNumber:Rs,DenseMatrix:Pr,Fraction:wo,concat:$n,config:Ve,equalScalar:hn,matrix:Ce,typed:Mt}),_w=O1({equal:_l,typed:Mt}),El=Z1({addScalar:Ls,conj:cl,multiplyScalar:zs,size:gl,typed:Mt}),Dw=I1({DenseMatrix:Pr,concat:$n,config:Ve,matrix:Ce,typed:Mt}),Eo=q1({config:Ve,numeric:Ti,smaller:gw,typed:Mt}),ii=Lg({addScalar:Ls,dot:El,equalScalar:hn,matrix:Ce,multiplyScalar:zs,typed:Mt}),yw=L1({compare:yl,isNaN:pl,isNumeric:ml,typed:Mt}),Ew=sw({add:Oi,config:Ve,numeric:Ti,typed:Mt}),Aw=K1({add:Oi,matrix:Ce,typed:Mt}),Al=X1({divideScalar:$i,isZero:cw,matrix:Ce,multiply:ii,subtractScalar:hl,typed:Mt,unaryMinus:yo}),bw=z1({config:Ve,larger:Dw,numeric:Ti,typed:Mt}),Us=Q1({abs:aw,addScalar:Ls,det:Al,divideScalar:$i,identity:Dl,matrix:Ce,multiply:ii,typed:Mt,unaryMinus:yo}),Cw=tw({Complex:go,add:Oi,ctranspose:dw,deepEqual:_w,divideScalar:$i,dot:El,dotDivide:mw,equal:_l,inv:Us,matrix:Ce,multiply:ii,typed:Mt}),Fw=_1({Complex:go,config:Ve,fraction:dl,identity:Dl,inv:Us,matrix:Ce,multiply:ii,number:ll,typed:Mt}),Mw=nw({divideScalar:$i,equalScalar:hn,inv:Us,matrix:Ce,multiply:ii,typed:Mt}),bl=ow({add:Oi,compare:yl,divide:Mw,partitionSelect:yw,typed:Mt});class xw{constructor(t,e,r){ut(this,"_cacheData");ut(this,"_variables");ut(this,"_math");ut(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(t===void 0||e===void 0||r===void 0||n===void 0)return;const f=this._cacheDataList(t,e,`alma_${a}`);if(f===void 0)return;let l=r*(e-1);s&&(l=Math.floor(l));const p=e/n;let h=0,c=0;for(let m=0;m<=e-1;m++){const w=Math.exp(-1*Math.pow(m-l,2)/(2*Math.pow(p,2)));h+=w,c+=f[f.length-1-(e-m-1)]*w}return c/h}sma({source:t,length:e},r){if(t===void 0||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=Ew(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`sma_${r}`]=n;const{sum:s}=this._cacheData[`rma_${r}`]||{},a=1/e,f=s===void 0?this.sma({source:t,length:e},r):a*t+(1-a)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:f}),f}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:a,low:f}=this._variables,l=r===void 0?s-f:Math.max(Math.max(s-f,Math.abs(s-n)),Math.abs(f-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:a}),this.rma({source:l,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||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let f=0;for(let l=0;l<e;l++){const p=this._sum(s[s.length-1-l],-(a||0));f+=p*p}return r||e<=1?Math.sqrt(f/e):Math.sqrt(f/(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||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const f=r*a;return[s,s+f,s-f]}bbw({series:t,length:e,mult:r},n){if(t===void 0||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const f=r*a;return(s+f-(s-f))/s}cci({source:t,length:e},r){if(t===void 0||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){if(t===void 0)return;const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const s=n[n.length-1-e];return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let f=0;f<e;f++){const l=n[n.length-1-f];a+=l*(f+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||e===void 0||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),f=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||f===void 0||s===void 0)return;let l=0,p=0,h=0;for(let m=0;m<r;m++){const[w,D]=s[s.length-1-m],v=w-a,y=D-f;l+=v*y,p+=v*v,h+=y*y}return isNaN(p)||isNaN(l)||isNaN(h)?void 0:l/Math.sqrt(p*h)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){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||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let f=0;f<e;f++){const l=a[a.length-1-f];s+=Math.abs(l-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:a,close:f,PDMS:l,NDMS:p,TRS:h,ADX:c,count:m=0}=this._cacheData[n]||{},{low:w,high:D,close:v}=this._variables;if(s===void 0||a===void 0||f===void 0)return this._cacheData[n]={low:w,high:D,close:v,PDMS:l,NDMS:p,TRS:D-w,count:1},[void 0,void 0,void 0];let y=D-a,g=s-w;y=y>g&&y>0?y:0,g=g>y&&g>0?g:0,y===g&&(y=g=0);const A=Math.max(D-w,Math.abs(D-f),Math.abs(w-f));if(m<t)return this._cacheDataHandle(n,{low:w,high:D,close:v,PDMS:(l||0)+y,NDMS:(p||0)+g,TRS:(h||0)+A,count:m+1}),[void 0,void 0,void 0];{const E=l-l/t+y,S=p-p/t+g,C=h-h/t+A,M=E/C*100,x=S/C*100,N=Math.abs((M-x)/(M+x))*100;let $=N,F=[M,x,void 0];if(m+1-t<e){const I=m+1-t;$=((c||0)*(I-1)+N)/I}else $=(c*(e-1)+N)/e,F=[M,x,$];return this._cacheDataHandle(n,{low:w,high:D,close:v,PDMS:E,NDMS:S,TRS:C,ADX:$,count:m+1}),F}}ema({source:t,length:e},r){if(t===void 0||e===void 0)return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(s>e){const f=2/(e+1);n=n===void 0?t:f*t+(1-f)*(n||0)}else n=a;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const a=s.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(f=>f)}rising({source:t,length:e},r){if(t===void 0||e===void 0)return!1;const{source:n,risings:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const a=s.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(f=>f)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highest_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highest_${r}`]=n;const f=n.filter(()=>!0);if(!(f.length<e))return Math.max(...f.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highestbars_${r}`]=n;const f=n.filter(()=>!0);return f.length<e?void 0:f.slice(-e).reduce((p,h,c,m)=>h>=m[p]?c:p,0)-e+1}wma({source:t,length:e},r){if(e===void 0||t===void 0||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let f=0;f<e;f++){const l=(e-f)*e;s+=l,a+=n[n.length-1-f]*l}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:f,high:l,low:p}=this._variables,h=n?f.tr:l-p,c=this.ema({source:h,length:e},`range_${s}`);return[a,a+c*r,a-c*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:f,high:l,low:p}=this._variables,h=n?f.tr:l-p,c=this.ema({source:h,length:e},`range_${s}`);return(a+c*r-(a-c*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(w=>w!==void 0);let f=0,l=0,p=0,h=0;for(const[w,D]of a.entries())f+=w,l+=D,p+=w*D,h+=w*w;const c=(e*p-f*l)/(e*h-f*f);return(l-c*f)/e+c*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowest_${r}`]=n;const f=n.filter(()=>!0);if(!(f.length<e))return Math.min(...f.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowestbars_${r}`]=n;const f=n.filter(()=>!0);return f.length<e?void 0:f.slice(-e).reduce((p,h,c,m)=>h<=m[p]?c:p,0)-e+1}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),f=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||f===void 0)return[void 0,void 0,void 0];const l=a-f,p=this.ema({source:l,length:n},`macd_${s}`);if(p===void 0)return[l,p,void 0];const h=l-p;return[l,p,h]}max({source:t},e){if(t===void 0)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)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||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return bl(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),f=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(f===void 0||a===void 0))return 100-100/(1+f/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Eo(vl(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||t===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e)return;let a=s.length-e-1,f;for(;f===void 0&&a>=0;)f=s[a],a--;return f===void 0?f:t-f}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),f=a.length;r/=100;const l=1/(f*2);if(r<=l)return a[0];if(r>=1-1/(f*2))return a[f-1];for(const[p,h]of a.entries()){const c=a[p-1];if(r<(p+.5)/f)return c===void 0||h===void 0?void 0:c+(h-c)*(r-(p-.5)/f)/(1/f)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),f=r/100*a.length,l=Math.ceil(f)-1;return a[l>=a.length?a.length-1:l]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let f=0;for(let l=0;l<s.length;l++)s[l]!==void 0&&(s[l]<a||s[l]===a&&l<e)&&f++;return f/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Vt;let{close:a,open:f,low:l,high:p}=this._variables;const h=`pivot_point_levels_${n}`,{close:c,low:m,high:w,open:D,result:v}=this._cacheData[h]||{};if(!e&&(w&&m&&(p=Math.max(w,p),l=Math.min(m,l)),this._cacheDataHandle(h,{close:a,open:f,low:l,high:p,result:v}),!r))return s._value=v||[],s;const y={close:a,open:f,low:l,high:p};e===!0&&!r&&(a=c,f=D,l=m,p=w);const g=this._getPivotPointLevels(p,l,a,f,r,t);return this._cacheDataHandle(h,{...y,result:g}),s._value=g,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Bn.traditional:return this._traditional(t,e,r);case Bn.fibonacci:return this._fibonacci(t,e,r);case Bn.woodie:return s?[]:this._woodie(t,e);case Bn.classic:return this._classic(t,e,r);case Bn.dm:return this._DM(t,e,r,n);case Bn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),f=n*2+(t-2*e),l=n*3+(t-3*e),p=n*4+(t-4*e),h=n*2-t,c=n-(t-e),m=n*2-(2*t-e),w=n*3-(3*t-e),D=n*4-(4*t-e);return[n,s,h,a,c,f,m,l,w,p,D]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),f=n+.618*(t-e),l=n-.618*(t-e),p=n+(t-e),h=n-(t-e);return[n,s,a,f,l,p,h]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,f=n+(t-e),l=n-(t-e),p=t+2*(n-e),h=e-2*(t-n),c=p+(t-e),m=h-(t-e);return[n,s,a,f,l,p,h,c,m]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,f=n+(t-e),l=n-(t-e),p=n+2*(t-e),h=n-2*(t-e),c=n+3*(t-e),m=n-3*(t-e);return[n,s,a,f,l,p,h,c,m]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,f=s/2-e,l=s/2-t;return[a,f,l]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,f=r+1.1*(t-e)/6,l=r-1.1*(t-e)/6,p=r+1.1*(t-e)/4,h=r-1.1*(t-e)/4,c=r+1.1*(t-e)/2,m=r-1.1*(t-e)/2,w=t/e*r,D=r-(w-r);return[n,s,a,f,l,p,h,c,m,w,D]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),f=a[e];return Math.max(...a)===f?f:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),f=a[e];return Math.min(...a)===f?f:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`);if(!n)return;const s=n.filter(l=>l!==void 0).slice(-e),a=Math.max(...s),f=Math.min(...s);return a-f}roc({source:t,length:e},r){if(e===void 0||t===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),a=Math.max(n-t,0),f=this.rma({source:s,length:e},`rma1_${r}`),l=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(f===void 0||l===void 0))return 100-100/(1+f/l)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:a,high:f,preLow:l,preHigh:p,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:c,maxMin:m,acceleration:w,isBelow:D}=h,v=!1;const{close:y,low:g,high:A,bar_index:E}=this._variables;return E===1&&(y>s?(D=!0,m=A,c=a):(D=!1,m=g,c=f),v=!0,w=t),c=c+w*(m-c),D?c>g&&(v=!0,D=!1,c=Math.max(A,m||0),m=g,w=t):c<A&&(v=!0,D=!0,c=Math.min(g,m||0),m=A,w=t),v||(D?A>(m||0)&&(m=A,w=Math.min((w||0)+e,r)):g<(m||0)&&(m=g,w=Math.min((w||0)+e,r))),D?(c=Math.min(c,a),E>1&&(c=Math.min(c,l))):(c=Math.max(c,f),E>1&&(c=Math.max(c,p))),this._cacheDataHandle(`sar_${n}`,{high:A,close:y,low:g,preLow:a,preHigh:f,data:Object.assign(h,{result:c,maxMin:m,acceleration:w,isBelow:D})}),c}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||n<0)return;const a=this.lowest({source:r,length:n},s),f=this.highest({source:e,length:n},s);if(!(a===void 0||f===void 0))return 100*(this._variables.close-a)/(f-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:s}=this._variables,a=`supertrend_${r}`,{upperBand:f,lowerBand:l,superTrend:p,atr:h,close:c}=this._cacheData[a]||{},m=this.atr({length:e},r);if(m===void 0)return this._cacheDataHandle(a,{close:s}),[void 0,void 0];let w=n+t*m,D=n-t*m;const v=f||0,y=l||0;D=D>y||c<y?D:y,w=w<v||c>v?w:v;let g;h===void 0?g=1:p===v?g=s>w?-1:1:g=s<D?1:-1;const A=g===-1?D:w;return this._cacheDataHandle(a,{upperBand:w,lowerBand:D,superTrend:A,atr:m,close:s}),[A,g]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),f=this.ema({source:s,length:e},`ema1_${n}`);if(f===void 0)return;const l=this.ema({source:f,length:r},`ema2_${n}`),p=this.ema({source:a,length:e},`absema2_${n}`);if(l!==void 0)return l/p}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n);if(s===void 0)return;const a=t-s,f=this._math.sum({source:a*a,length:e},n);if(f!==void 0)return r||e<=1?f/e:f/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:a=0,sumV:f=0,count:l=0,isReset:p,list:h=[]}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=f=l=0,p=!0),!p)return r!==void 0?[]:void 0;const c=t*s+a,m=s+f,w=c/m;if(l++,r!==void 0){h.push(t);const D=h.slice(-l);let v=0;for(const E of D){const S=E-w;v+=S*S}const y=Math.sqrt(v/l);console.log(y,r,l);const g=y!==void 0&&!isNaN(y)?w+r*y:void 0,A=y!==void 0&&!isNaN(y)?w-r*y:void 0;return this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:l,isReset:p,list:h}),[w,g,A]}return this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:l,isReset:p}),w}vwma({source:t,length:e},r){if(t===void 0||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:f}=n,l=t[s];if(l!==void 0){if(a!==void 0&&l<a){t.splice(s,1),t.splice(f,0,l),n={currentIndex:f+1,currentVal:a};continue}n={currentIndex:s,currentVal:l}}}}return t}_cacheDataList(t,e,r){const n=this._cacheData[r]||[];n[this._variables.bar_index]=t,this._cacheData[r]=n;const s=n.filter(()=>!0);if(!(s.length<e))return s}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}$r.SERIES,$r.SIMPLE,$r.INPUT,$r.CONST,$r.INT,$r.FLOAT,$r.BOOL,$r.COLOR,$r.STRING;const Sw=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"];var qs=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(qs||{});class Nw{constructor(t,e){ut(this,"_cacheData");ut(this,"_variables");ut(this,"_errorListener");ut(this,"_count");ut(this,"_historyInputs");ut(this,"_name","inputs");this._cacheData={},this._variables=t,this._errorListener=e,this._count=-1,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){for(const e of t){const r=e.id;if(!this._cacheData[r])return;Object.assign(this._cacheData[r],{...e,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${e.index}`,{modifyDefval:e.sourceTypeName||e.defval})}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,"int")}bool(t,e){return this._cacheHandle(t,e,"bool")}color(t,e){return this._cacheHandle(t,e,"color")}time(t,e){return this._cacheHandle(t,e,"time")}float(t,e){return this._cacheHandle(t,e,"float")}price(t,e){return this._cacheHandle(t,e,"price")}source(t,e){return this._cacheHandle(t,e,"source")}string(t,e){return this._cacheHandle(t,e,"string")}symbol(t,e){return this._cacheHandle(t,e,"symbol")}session(t,e){return this._cacheHandle(t,e,"session")}text_area(t,e){return this._cacheHandle(t,e,"text_area")}timeframe(t,e){return this._cacheHandle(t,e,"timeframe")}_cacheHandle(t,e,r){const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(s)s.isModify?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t);else{const{defval:a,display:f}=t;this._displayVerify(e,f),this._count++,t={inputType:r,...t,index:this._count},this._cacheData[n]=t,this._judgeHistoryInputs(t),(r||t.inputType)==="source"?this._cacheData[n].options=Sw:t.options&&!t.options.includes(a)&&this._errorListener.addError(`input's defval should be in options, but '${a}' is not in [${t.options.toString()}]`,e,qs.Error)}return this._cacheData[n].defval}_judgeHistoryInputs(t){const{defval:e,sourceTypeName:r,index:n}=t;let s=r||e;const a=`in_${n}`,f=this._historyInputs[a];if(!f)self.workerStorage.setValue(this._name,a,{defval:s});else{const{defval:l,modifyDefval:p}=f;l===s?s=p||s:self.workerStorage.setValue(this._name,a,{defval:s})}r?t.sourceTypeName=s:t.defval=s}_displayVerify(t,e){!e||!e.length||e.includes(Cr.dataWindow)||e.includes(Cr.statusLine)||this._errorListener.addError("Invalid argument 'display' in 'input' call. Possible values: [display.none, display.data_window, display.status_line, display.all]",t,qs.Error)}getInputs(){var n;const t=Object.keys(this._cacheData),e=new Map,r=[];for(const s of t){const a=this._cacheData[s];a.id=s;const{group:f}=a;f?e.has(f)?(n=e.get(f))==null||n.push(a):e.set(f,[a]):r.push(a)}return[...this._getGroups(e),{inputs:r}]}_getGroups(t){const e=[];for(const[r,n]of t)e.push({name:r,inputs:n});return e}}class Bw{color({x:t}){return t}new({color:t,transp:e=100}){const{r,g:n,b:s}=this._parseColor(t);return`rgba(${Math.round(r)}, ${Math.round(n)}, ${Math.round(s)}, ${e/100})`}rgb({red:t,green:e,blue:r,transp:n=0}){return`rgba(${t}, ${e}, ${r}, ${n/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){const a=(t-e)/(r-e),f=Math.min(Math.max(a,0),1),{r:l,g:p,b:h,a:c}=this._parseColor(n),{r:m,g:w,b:D,a:v}=this._parseColor(s),y=l+f*(m-l),g=p+f*(w-p),A=h+f*(D-h),E=c+f*(v-c);return`rgba(${Math.round(y)}, ${Math.round(g)}, ${Math.round(A)}, ${E.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=(255-parseInt(a,16))/255:s=1}else{const a=this._parserRgbColor(t);e=a[0],r=a[1],n=a[2],s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var Pt={};const Iw=Object.prototype.toString;function Ri(i){const t=Iw.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var Tw=Object.freeze({__proto__:null,isAnyArray:Ri}),$w=De(Tw);function Ow(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Ri(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],f=r+1;f<s;f++)i[f]>a&&(a=i[f]);return a}function Rw(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Ri(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],f=r+1;f<s;f++)i[f]<a&&(a=i[f]);return a}function Lw(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Ri(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Ri(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=Rw(i),n=Ow(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,f=t.max,l=f===void 0?t.autoMinMax?n:1:f;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var p=(l-a)/(n-r),h=0;h<i.length;h++)e[h]=(i[h]-r)*p+a;return e}var Pw=Object.freeze({__proto__:null,default:Lw}),zw=De(Pw);Object.defineProperty(Pt,"__esModule",{value:!0});var Ge=$w,Cl=zw;const Ws=" ".repeat(2),Fl=" ".repeat(4);function Uw(){return Ml(this)}function Ml(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
|
55
|
-
${Ws}[
|
56
|
-
${Fl}${qw(i,e,r,n,s)}
|
57
|
-
${Ws}]
|
58
|
-
${Ws}rows: ${i.rows}
|
59
|
-
${Ws}columns: ${i.columns}
|
60
|
-
}`}function qw(i,t,e,r,n){const{rows:s,columns:a}=i,f=Math.min(s,t),l=Math.min(a,e),p=[];if(n==="auto"){n=!1;t:for(let h=0;h<f;h++)for(let c=0;c<l;c++)if(i.get(h,c)<0){n=!0;break t}}for(let h=0;h<f;h++){let c=[];for(let m=0;m<l;m++)c.push(Ww(i.get(h,m),r,n));p.push(`${c.join(" ")}`)}return l!==a&&(p[p.length-1]+=` ... ${a-e} more columns`),f!==s&&p.push(`... ${s-t} more rows`),p.join(`
|
61
|
-
${Fl}`)}function Ww(i,t,e){return(i>=0&&e?` ${xl(i,t-1)}`:xl(i,t)).padEnd(t)}function xl(i,t){let e=i.toString();if(e.length<=t)return e;let r=i.toFixed(t);if(r.length>t&&(r=i.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=i.toExponential(t);return n.length>t&&(n=i.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function kw(i,t){i.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},i.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r);return this},i.prototype.addM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r.get(n,s));return this},i.add=function(r,n){return new t(r).add(n)},i.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},i.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r);return this},i.prototype.subM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r.get(n,s));return this},i.sub=function(r,n){return new t(r).sub(n)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},i.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r);return this},i.prototype.mulM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r.get(n,s));return this},i.mul=function(r,n){return new t(r).mul(n)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},i.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r);return this},i.prototype.divM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r.get(n,s));return this},i.div=function(r,n){return new t(r).div(n)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},i.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r);return this},i.prototype.modM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r.get(n,s));return this},i.mod=function(r,n){return new t(r).mod(n)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},i.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r);return this},i.prototype.andM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r.get(n,s));return this},i.and=function(r,n){return new t(r).and(n)},i.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},i.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r);return this},i.prototype.orM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r.get(n,s));return this},i.or=function(r,n){return new t(r).or(n)},i.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},i.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r);return this},i.prototype.xorM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r.get(n,s));return this},i.xor=function(r,n){return new t(r).xor(n)},i.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},i.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r);return this},i.prototype.leftShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r.get(n,s));return this},i.leftShift=function(r,n){return new t(r).leftShift(n)},i.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},i.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r);return this},i.prototype.signPropagatingRightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r.get(n,s));return this},i.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},i.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},i.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r);return this},i.prototype.rightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r.get(n,s));return this},i.rightShift=function(r,n){return new t(r).rightShift(n)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},i.not=function(r){return new t(r).not()},i.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},i.abs=function(r){return new t(r).abs()},i.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},i.acos=function(r){return new t(r).acos()},i.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},i.acosh=function(r){return new t(r).acosh()},i.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},i.asin=function(r){return new t(r).asin()},i.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},i.asinh=function(r){return new t(r).asinh()},i.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},i.atan=function(r){return new t(r).atan()},i.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},i.atanh=function(r){return new t(r).atanh()},i.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},i.cbrt=function(r){return new t(r).cbrt()},i.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},i.ceil=function(r){return new t(r).ceil()},i.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},i.clz32=function(r){return new t(r).clz32()},i.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},i.cos=function(r){return new t(r).cos()},i.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},i.cosh=function(r){return new t(r).cosh()},i.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},i.exp=function(r){return new t(r).exp()},i.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},i.expm1=function(r){return new t(r).expm1()},i.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},i.floor=function(r){return new t(r).floor()},i.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},i.fround=function(r){return new t(r).fround()},i.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},i.log=function(r){return new t(r).log()},i.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},i.log1p=function(r){return new t(r).log1p()},i.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},i.log10=function(r){return new t(r).log10()},i.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},i.log2=function(r){return new t(r).log2()},i.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},i.round=function(r){return new t(r).round()},i.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},i.sign=function(r){return new t(r).sign()},i.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},i.sin=function(r){return new t(r).sin()},i.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},i.sinh=function(r){return new t(r).sinh()},i.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},i.sqrt=function(r){return new t(r).sqrt()},i.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},i.tan=function(r){return new t(r).tan()},i.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},i.tanh=function(r){return new t(r).tanh()},i.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},i.trunc=function(r){return new t(r).trunc()},i.pow=function(r,n){return new t(r).pow(n)},i.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},i.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r));return this},i.prototype.powM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r.get(n,s)));return this}}function pr(i,t,e){let r=e?i.rows:i.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function dr(i,t,e){let r=e?i.columns:i.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function si(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function ui(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Ao(i,t){if(!Ge.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.rows)throw new RangeError("row indices are out of range")}function bo(i,t){if(!Ge.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.columns)throw new RangeError("column indices are out of range")}function Co(i,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(Ys("startRow",t),Ys("endRow",e),Ys("startColumn",r),Ys("endColumn",n),t>e||r>n||t<0||t>=i.rows||e<0||e>=i.rows||r<0||r>=i.columns||n<0||n>=i.columns)throw new RangeError("Submatrix indices are out of range")}function ks(i,t=0){let e=[];for(let r=0;r<i;r++)e.push(t);return e}function Ys(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function oi(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function Yw(i){let t=ks(i.rows);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]+=i.get(e,r);return t}function Zw(i){let t=ks(i.columns);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]+=i.get(e,r);return t}function jw(i){let t=0;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t+=i.get(e,r);return t}function Gw(i){let t=ks(i.rows,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]*=i.get(e,r);return t}function Kw(i){let t=ks(i.columns,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]*=i.get(e,r);return t}function Jw(i){let t=1;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t*=i.get(e,r);return t}function Xw(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<r;a++){let f=0,l=0,p=0;for(let h=0;h<n;h++)p=i.get(a,h)-e[a],f+=p,l+=p*p;t?s.push((l-f*f/n)/(n-1)):s.push((l-f*f/n)/n)}return s}function Hw(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<n;a++){let f=0,l=0,p=0;for(let h=0;h<r;h++)p=i.get(h,a)-e[a],f+=p,l+=p*p;t?s.push((l-f*f/r)/(r-1)):s.push((l-f*f/r)/r)}return s}function Qw(i,t,e){const r=i.rows,n=i.columns,s=r*n;let a=0,f=0,l=0;for(let p=0;p<r;p++)for(let h=0;h<n;h++)l=i.get(p,h)-e,a+=l,f+=l*l;return t?(f-a*a/s)/(s-1):(f-a*a/s)/s}function Vw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[e])}function t_(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[r])}function e_(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t)}function r_(i){const t=[];for(let e=0;e<i.rows;e++){let r=0;for(let n=0;n<i.columns;n++)r+=Math.pow(i.get(e,n),2)/(i.columns-1);t.push(Math.sqrt(r))}return t}function n_(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[e])}function i_(i){const t=[];for(let e=0;e<i.columns;e++){let r=0;for(let n=0;n<i.rows;n++)r+=Math.pow(i.get(n,e),2)/(i.rows-1);t.push(Math.sqrt(r))}return t}function s_(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[r])}function u_(i){const t=i.size-1;let e=0;for(let r=0;r<i.columns;r++)for(let n=0;n<i.rows;n++)e+=Math.pow(i.get(n,r),2)/t;return Math.sqrt(e)}function o_(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t)}class $t{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let s=new pt(t,e);for(let a=0;a<t;a++)for(let f=0;f<e;f++)s.set(a,f,r[a*e+f]);return s}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 s=new pt(t,e);for(let a=0;a<t;a++)for(let f=0;f<e;f++)s.set(a,f,n());return s}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:s=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(n>=s)throw new RangeError("min must be smaller than max");let f=s-n,l=new pt(t,e);for(let p=0;p<t;p++)for(let h=0;h<e;h++){let c=n+Math.round(a()*f);l.set(p,h,c)}return l}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),s=this.zeros(t,e);for(let a=0;a<n;a++)s.set(a,a,r);return s}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let s=Math.min(n,e,r),a=this.zeros(e,r);for(let f=0;f<s;f++)a.set(f,f,t[f]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new pt(r,n);for(let a=0;a<r;a++)for(let f=0;f<n;f++)s.set(a,f,Math.min(t.get(a,f),e.get(a,f)));return s}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new this(r,n);for(let a=0;a<r;a++)for(let f=0;f<n;f++)s.set(a,f,Math.max(t.get(a,f),e.get(a,f)));return s}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,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);for(let a=e+1;a<this.rows;a++)this.get(t,a)!==0&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let s=e;s<t.rows;s++)t.get(s,r)>t.get(n,r)&&(n=s);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let s=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/s);for(let a=e+1;a<t.rows;a++){let f=t.get(a,r)/t.get(e,r);t.set(a,r,0);for(let l=r+1;l<t.columns;l++)t.set(a,l,t.get(a,l)-t.get(e,l)*f)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(t.maxRow(n)===0)n--;else{let s=0,a=!1;for(;s<r&&a===!1;)t.get(n,s)===1?a=!0:s++;for(let f=0;f<n;f++){let l=t.get(f,s);for(let p=s;p<e;p++){let h=t.get(f,p)-l*t.get(n,p);t.set(f,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 s=0;s<e;s++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*s,this.columns*a);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){pr(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){pr(this,t),e=si(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){pr(this,t),pr(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){dr(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){dr(this,t),e=ui(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){dr(this,t),dr(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=si(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=si(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=si(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=si(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=ui(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=ui(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=ui(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=ui(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){pr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){dr(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(){oi(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(){oi(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(pr(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){pr(this,t),oi(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(pr(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){pr(this,t),oi(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(dr(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){dr(this,t),oi(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(dr(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){dr(this,t),oi(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,s=new pt(e,n),a=new Float64Array(r);for(let f=0;f<n;f++){for(let l=0;l<r;l++)a[l]=t.get(l,f);for(let l=0;l<e;l++){let p=0;for(let h=0;h<r;h++)p+=this.get(l,h)*a[h];s.set(l,f,p)}}return s}strassen2x2(t){t=pt.checkMatrix(t);let e=new pt(2,2);const r=this.get(0,0),n=t.get(0,0),s=this.get(0,1),a=t.get(0,1),f=this.get(1,0),l=t.get(1,0),p=this.get(1,1),h=t.get(1,1),c=(r+p)*(n+h),m=(f+p)*n,w=r*(a-h),D=p*(l-n),v=(r+s)*h,y=(f-r)*(n+a),g=(s-p)*(l+h),A=c+D-v+g,E=w+v,S=m+D,C=c-m+w+y;return e.set(0,0,A),e.set(0,1,E),e.set(1,0,S),e.set(1,1,C),e}strassen3x3(t){t=pt.checkMatrix(t);let e=new pt(3,3);const r=this.get(0,0),n=this.get(0,1),s=this.get(0,2),a=this.get(1,0),f=this.get(1,1),l=this.get(1,2),p=this.get(2,0),h=this.get(2,1),c=this.get(2,2),m=t.get(0,0),w=t.get(0,1),D=t.get(0,2),v=t.get(1,0),y=t.get(1,1),g=t.get(1,2),A=t.get(2,0),E=t.get(2,1),S=t.get(2,2),C=(r+n+s-a-f-h-c)*y,M=(r-a)*(-w+y),x=f*(-m+w+v-y-g-A+S),N=(-r+a+f)*(m-w+y),$=(a+f)*(-m+w),F=r*m,I=(-r+p+h)*(m-D+g),R=(-r+p)*(D-g),q=(p+h)*(-m+D),U=(r+n+s-f-l-p-h)*g,W=h*(-m+D+v-y-g-A+E),P=(-s+h+c)*(y+A-E),G=(s-c)*(y-E),j=s*A,H=(h+c)*(-A+E),V=(-s+f+l)*(g+A-S),ct=(s-l)*(g-S),gt=(f+l)*(-A+S),ft=n*v,_t=l*E,yt=a*D,Nt=p*w,Et=c*S,ee=F+j+ft,It=C+N+$+F+P+j+H,xt=F+I+q+U+j+V+gt,ie=M+x+N+F+j+V+ct,Xt=M+N+$+F+_t,zt=j+V+ct+gt+yt,Gt=F+I+R+W+P+G+j,Fe=P+G+j+H+Nt,er=F+I+R+q+Et;return e.set(0,0,ee),e.set(0,1,It),e.set(0,2,xt),e.set(1,0,ie),e.set(1,1,Xt),e.set(1,2,zt),e.set(2,0,Gt),e.set(2,1,Fe),e.set(2,2,er),e}mmulStrassen(t){t=pt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,s=t.rows,a=t.columns;n!==s&&console.warn(`Multiplying ${r} x ${n} and ${s} x ${a} matrix: dimensions do not match.`);function f(c,m,w){let D=c.rows,v=c.columns;if(D===m&&v===w)return c;{let y=$t.zeros(m,w);return y=y.setSubMatrix(c,0,0),y}}let l=Math.max(r,s),p=Math.max(n,a);e=f(e,l,p),t=f(t,l,p);function h(c,m,w,D){if(w<=512||D<=512)return c.mmul(m);w%2===1&&D%2===1?(c=f(c,w+1,D+1),m=f(m,w+1,D+1)):w%2===1?(c=f(c,w+1,D),m=f(m,w+1,D)):D%2===1&&(c=f(c,w,D+1),m=f(m,w,D+1));let v=parseInt(c.rows/2,10),y=parseInt(c.columns/2,10),g=c.subMatrix(0,v-1,0,y-1),A=m.subMatrix(0,v-1,0,y-1),E=c.subMatrix(0,v-1,y,c.columns-1),S=m.subMatrix(0,v-1,y,m.columns-1),C=c.subMatrix(v,c.rows-1,0,y-1),M=m.subMatrix(v,m.rows-1,0,y-1),x=c.subMatrix(v,c.rows-1,y,c.columns-1),N=m.subMatrix(v,m.rows-1,y,m.columns-1),$=h($t.add(g,x),$t.add(A,N),v,y),F=h($t.add(C,x),A,v,y),I=h(g,$t.sub(S,N),v,y),R=h(x,$t.sub(M,A),v,y),q=h($t.add(g,E),N,v,y),U=h($t.sub(C,g),$t.add(A,S),v,y),W=h($t.sub(E,x),$t.add(M,N),v,y),P=$t.add($,R);P.sub(q),P.add(W);let G=$t.add(I,q),j=$t.add(F,R),H=$t.sub($,F);H.add(I),H.add(U);let V=$t.zeros(2*P.rows,2*P.columns);return V=V.setSubMatrix(P,0,0),V=V.setSubMatrix(G,P.rows,0),V=V.setSubMatrix(j,0,P.columns),V=V.setSubMatrix(H,P.rows,P.columns),V.subMatrix(0,w-1,0,D-1)}return h(e,t,l,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 s=0;s<this.rows;s++){const a=this.getRow(s);a.length>0&&Cl(a,{min:e,max:r,output:a}),n.setRow(s,a)}return n}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new pt(this.rows,this.columns);for(let s=0;s<this.columns;s++){const a=this.getColumn(s);a.length&&Cl(a,{min:e,max:r,output:a}),n.setColumn(s,a)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let n=this.get(e,r),s=this.get(e,this.columns-1-r);this.set(e,r,s),this.set(e,this.columns-1-r,n)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let n=this.get(r,e),s=this.get(this.rows-1-r,e);this.set(r,e,s),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=pt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,s=t.columns,a=new pt(e*n,r*s);for(let f=0;f<e;f++)for(let l=0;l<r;l++)for(let p=0;p<n;p++)for(let h=0;h<s;h++)a.set(n*f+p,s*l+h,this.get(f,l)*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)),s=pt.eye(e,e).kroneckerProduct(t);return n.add(s)}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=Sl){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Sl){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Co(this,t,e,r,n);let s=new pt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let f=r;f<=n;f++)s.set(a-t,f-r,this.get(a,f));return s}subMatrixRow(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new pt(t.length,r-e+1);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);n.set(s,a-e,this.get(t[s],a))}return n}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new pt(r-e+1,t.length);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);n.set(a-e,s,this.get(a,t[s]))}return n}setSubMatrix(t,e,r){if(t=pt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,s=r+t.columns-1;Co(this,e,n,r,s);for(let a=0;a<t.rows;a++)for(let f=0;f<t.columns;f++)this.set(e+a,r+f,t.get(a,f));return this}selection(t,e){Ao(this,t),bo(this,e);let r=new pt(t.length,e.length);for(let n=0;n<t.length;n++){let s=t[n];for(let a=0;a<e.length;a++){let f=e[a];r.set(n,a,this.get(s,f))}}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,s]of t.entries())e.set(r,n,s);return e}sum(t){switch(t){case"row":return Yw(this);case"column":return Zw(this);case void 0:return jw(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return Gw(this);case"column":return Kw(this);case void 0:return Jw(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(!Ge.isAnyArray(n))throw new TypeError("mean must be an array");return Xw(this,r,n)}case"column":{if(!Ge.isAnyArray(n))throw new TypeError("mean must be an array");return Hw(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return Qw(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(!Ge.isAnyArray(r))throw new TypeError("center must be an array");return Vw(this,r),this}case"column":{if(!Ge.isAnyArray(r))throw new TypeError("center must be an array");return t_(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return e_(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=r_(this);else if(!Ge.isAnyArray(r))throw new TypeError("scale must be an array");return n_(this,r),this}case"column":{if(r===void 0)r=i_(this);else if(!Ge.isAnyArray(r))throw new TypeError("scale must be an array");return s_(this,r),this}case void 0:{if(r===void 0)r=u_(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return o_(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return Ml(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")]=Uw);function Sl(i,t){return i-t}function a_(i){return i.every(t=>typeof t=="number")}$t.random=$t.rand,$t.randomInt=$t.randInt,$t.diagonal=$t.diag,$t.prototype.diagonal=$t.prototype.diag,$t.identity=$t.eye,$t.prototype.negate=$t.prototype.neg,$t.prototype.tensorProduct=$t.prototype.kroneckerProduct;let pt=(ci=class extends $t{constructor(e,r){super();pf(this,Li);ut(this,"data");if(ci.isMatrix(e))df(this,Li,mf).call(this,e.rows,e.columns),ci.copy(e,this);else if(Number.isInteger(e)&&e>=0)df(this,Li,mf).call(this,e,r);else if(Ge.isAnyArray(e)){const n=e;if(e=n.length,r=e?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s<e;s++){if(n[s].length!==r)throw new RangeError("Inconsistent array dimensions");if(!a_(n[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[s]))}this.rows=e,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(e,r,n){return this.data[e][r]=n,this}get(e,r){return this.data[e][r]}removeRow(e){return pr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),pr(this,e,!0),r=Float64Array.from(si(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){dr(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let s=0;s<e;s++)n[s]=this.data[r][s];for(let s=e+1;s<this.columns;s++)n[s-1]=this.data[r][s];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),dr(this,e,!0),r=ui(this,r);for(let n=0;n<this.rows;n++){const s=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)s[a]=this.data[n][a];for(s[a++]=r[n];a<this.columns+1;a++)s[a]=this.data[n][a-1];this.data[n]=s}return this.columns+=1,this}},Li=new WeakSet,mf=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},ci);kw($t,pt);const eu=class eu extends $t{constructor(e){super();pf(this,ze,void 0);if(pt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ju(this,ze,pt.copy(e,new pt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ju(this,ze,new pt(e,e));else if(ju(this,ze,new pt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Tr(this,ze).size}get rows(){return Tr(this,ze).rows}get columns(){return Tr(this,ze).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 eu(this.diagonalSize);for(const[r,n,s]of this.upperRightEntries())e.set(r,n,s);return e}toMatrix(){return new pt(this)}get(e,r){return Tr(this,ze).get(e,r)}set(e,r,n){return Tr(this,ze).set(e,r,n),Tr(this,ze).set(r,e,n),this}removeCross(e){return Tr(this,ze).removeRow(e),Tr(this,ze).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Tr(this,ze).addRow(e,n),Tr(this,ze).addColumn(e,r),this}applyMask(e){if(e.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,s]of e.entries())s||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let n=0,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=e&&(n=++s);return r}static fromCompact(e){const r=e.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(e)}`);const s=new eu(n);for(let a=0,f=0,l=0;l<r;l++)s.set(a,f,e[l]),++a>=n&&(a=++f);return s}*upperRightEntries(){for(let e=0,r=0;e<this.diagonalSize;void 0){const n=this.get(e,r);yield[e,r,n],++r>=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e<this.diagonalSize;void 0)yield this.get(e,r),++r>=this.diagonalSize&&(r=++e)}};ze=new WeakMap;let On=eu;On.prototype.klassType="SymmetricMatrix";class Zs extends On{static isDistanceMatrix(t){return On.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 On(this)}clone(){const t=new Zs(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let n=1,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=t&&(n=++s+1);return r}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let s=1,a=0,f=0;f<e;f++)n.set(s,a,t[f]),++s>=r&&(s=++a+1);return n}}Zs.prototype.klassSubType="DistanceMatrix";class Yr extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class f_ extends Yr{constructor(t,e){dr(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 c_ extends Yr{constructor(t,e){bo(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 l_ extends Yr{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 h_ extends Yr{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 p_ extends Yr{constructor(t,e){pr(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 d_ extends Yr{constructor(t,e){Ao(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 js extends Yr{constructor(t,e,r){Ao(t,e),bo(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 m_ extends Yr{constructor(t,e,r,n,s){Co(t,e,r,n,s),super(t,r-e+1,s-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class v_ extends Yr{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 Nl 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 tr 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 g_(i,t){if(Ge.isAnyArray(i))return i[0]&&Ge.isAnyArray(i[0])?new tr(i):new Nl(i,t);throw new Error("the argument is not an array")}class Gs{constructor(t){t=tr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,s=new Float64Array(r),a=1,f,l,p,h,c,m,w,D,v;for(f=0;f<r;f++)s[f]=f;for(D=new Float64Array(r),l=0;l<n;l++){for(f=0;f<r;f++)D[f]=e.get(f,l);for(f=0;f<r;f++){for(v=Math.min(f,l),c=0,p=0;p<v;p++)c+=e.get(f,p)*D[p];D[f]-=c,e.set(f,l,D[f])}for(h=l,f=l+1;f<r;f++)Math.abs(D[f])>Math.abs(D[h])&&(h=f);if(h!==l){for(p=0;p<n;p++)m=e.get(h,p),e.set(h,p,e.get(l,p)),e.set(l,p,m);w=s[h],s[h]=s[l],s[l]=w,a=-a}if(l<r&&e.get(l,l)!==0)for(f=l+1;f<r;f++)e.set(f,l,e.get(f,l)/e.get(l,l))}this.LU=e,this.pivotVector=s,this.pivotSign=a}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(t.get(r,r)===0)return!0;return!1}solve(t){t=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,s=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,f,l,p;for(p=0;p<a;p++)for(f=p+1;f<a;f++)for(l=0;l<n;l++)s.set(f,l,s.get(f,l)-s.get(p,l)*e.get(f,p));for(p=a-1;p>=0;p--){for(l=0;l<n;l++)s.set(p,l,s.get(p,l)/e.get(p,p));for(f=0;f<p;f++)for(l=0;l<n;l++)s.set(f,l,s.get(f,l)-s.get(p,l)*e.get(f,p))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s>a?n.set(s,a,t.get(s,a)):s===a?n.set(s,a,1):n.set(s,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s<=a?n.set(s,a,t.get(s,a)):n.set(s,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Zr(i,t){let e=0;return Math.abs(i)>Math.abs(t)?(e=t/i,Math.abs(i)*Math.sqrt(1+e*e)):t!==0?(e=i/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class Fo{constructor(t){t=tr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,s=new Float64Array(n),a,f,l,p;for(l=0;l<n;l++){let h=0;for(a=l;a<r;a++)h=Zr(h,e.get(a,l));if(h!==0){for(e.get(l,l)<0&&(h=-h),a=l;a<r;a++)e.set(a,l,e.get(a,l)/h);for(e.set(l,l,e.get(l,l)+1),f=l+1;f<n;f++){for(p=0,a=l;a<r;a++)p+=e.get(a,l)*e.get(a,f);for(p=-p/e.get(l,l),a=l;a<r;a++)e.set(a,f,e.get(a,f)+p*e.get(a,l))}}s[l]=-h}this.QR=e,this.Rdiag=s}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,s=t.clone(),a=e.columns,f,l,p,h;for(p=0;p<a;p++)for(l=0;l<n;l++){for(h=0,f=p;f<r;f++)h+=e.get(f,p)*s.get(f,l);for(h=-h/e.get(p,p),f=p;f<r;f++)s.set(f,l,s.get(f,l)+h*e.get(f,p))}for(p=a-1;p>=0;p--){for(l=0;l<n;l++)s.set(p,l,s.get(p,l)/this.Rdiag[p]);for(f=0;f<p;f++)for(l=0;l<n;l++)s.set(f,l,s.get(f,l)-s.get(p,l)*e.get(f,p))}return s.subMatrix(0,a-1,0,n-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,r=new pt(e,e),n,s;for(n=0;n<e;n++)for(s=0;s<e;s++)n<s?r.set(n,s,t.get(n,s)):n===s?r.set(n,s,this.Rdiag[n]):r.set(n,s,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new pt(e,r),s,a,f,l;for(f=r-1;f>=0;f--){for(s=0;s<e;s++)n.set(s,f,0);for(n.set(f,f,1),a=f;a<r;a++)if(t.get(f,f)!==0){for(l=0,s=f;s<e;s++)l+=t.get(s,f)*n.get(s,a);for(l=-l/t.get(f,f),s=f;s<e;s++)n.set(s,a,n.get(s,a)+l*t.get(s,f))}}return n}}class ai{constructor(t,e={}){if(t=tr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:a=!0,autoTranspose:f=!1}=e;let l=!!s,p=!!a,h=!1,c;if(r<n)if(!f)c=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{c=t.transpose(),r=c.rows,n=c.columns,h=!0;let F=l;l=p,p=F}else c=t.clone();let m=Math.min(r,n),w=Math.min(r+1,n),D=new Float64Array(w),v=new pt(r,m),y=new pt(n,n),g=new Float64Array(n),A=new Float64Array(r),E=new Float64Array(w);for(let F=0;F<w;F++)E[F]=F;let S=Math.min(r-1,n),C=Math.max(0,Math.min(n-2,r)),M=Math.max(S,C);for(let F=0;F<M;F++){if(F<S){D[F]=0;for(let I=F;I<r;I++)D[F]=Zr(D[F],c.get(I,F));if(D[F]!==0){c.get(F,F)<0&&(D[F]=-D[F]);for(let I=F;I<r;I++)c.set(I,F,c.get(I,F)/D[F]);c.set(F,F,c.get(F,F)+1)}D[F]=-D[F]}for(let I=F+1;I<n;I++){if(F<S&&D[F]!==0){let R=0;for(let q=F;q<r;q++)R+=c.get(q,F)*c.get(q,I);R=-R/c.get(F,F);for(let q=F;q<r;q++)c.set(q,I,c.get(q,I)+R*c.get(q,F))}g[I]=c.get(F,I)}if(l&&F<S)for(let I=F;I<r;I++)v.set(I,F,c.get(I,F));if(F<C){g[F]=0;for(let I=F+1;I<n;I++)g[F]=Zr(g[F],g[I]);if(g[F]!==0){g[F+1]<0&&(g[F]=0-g[F]);for(let I=F+1;I<n;I++)g[I]/=g[F];g[F+1]+=1}if(g[F]=-g[F],F+1<r&&g[F]!==0){for(let I=F+1;I<r;I++)A[I]=0;for(let I=F+1;I<r;I++)for(let R=F+1;R<n;R++)A[I]+=g[R]*c.get(I,R);for(let I=F+1;I<n;I++){let R=-g[I]/g[F+1];for(let q=F+1;q<r;q++)c.set(q,I,c.get(q,I)+R*A[q])}}if(p)for(let I=F+1;I<n;I++)y.set(I,F,g[I])}}let x=Math.min(n,r+1);if(S<n&&(D[S]=c.get(S,S)),r<x&&(D[x-1]=0),C+1<x&&(g[C]=c.get(C,x-1)),g[x-1]=0,l){for(let F=S;F<m;F++){for(let I=0;I<r;I++)v.set(I,F,0);v.set(F,F,1)}for(let F=S-1;F>=0;F--)if(D[F]!==0){for(let I=F+1;I<m;I++){let R=0;for(let q=F;q<r;q++)R+=v.get(q,F)*v.get(q,I);R=-R/v.get(F,F);for(let q=F;q<r;q++)v.set(q,I,v.get(q,I)+R*v.get(q,F))}for(let I=F;I<r;I++)v.set(I,F,-v.get(I,F));v.set(F,F,1+v.get(F,F));for(let I=0;I<F-1;I++)v.set(I,F,0)}else{for(let I=0;I<r;I++)v.set(I,F,0);v.set(F,F,1)}}if(p)for(let F=n-1;F>=0;F--){if(F<C&&g[F]!==0)for(let I=F+1;I<n;I++){let R=0;for(let q=F+1;q<n;q++)R+=y.get(q,F)*y.get(q,I);R=-R/y.get(F+1,F);for(let q=F+1;q<n;q++)y.set(q,I,y.get(q,I)+R*y.get(q,F))}for(let I=0;I<n;I++)y.set(I,F,0);y.set(F,F,1)}let N=x-1,$=Number.EPSILON;for(;x>0;){let F,I;for(F=x-2;F>=-1&&F!==-1;F--){const R=Number.MIN_VALUE+$*Math.abs(D[F]+Math.abs(D[F+1]));if(Math.abs(g[F])<=R||Number.isNaN(g[F])){g[F]=0;break}}if(F===x-2)I=4;else{let R;for(R=x-1;R>=F&&R!==F;R--){let q=(R!==x?Math.abs(g[R]):0)+(R!==F+1?Math.abs(g[R-1]):0);if(Math.abs(D[R])<=$*q){D[R]=0;break}}R===F?I=3:R===x-1?I=1:(I=2,F=R)}switch(F++,I){case 1:{let R=g[x-2];g[x-2]=0;for(let q=x-2;q>=F;q--){let U=Zr(D[q],R),W=D[q]/U,P=R/U;if(D[q]=U,q!==F&&(R=-P*g[q-1],g[q-1]=W*g[q-1]),p)for(let G=0;G<n;G++)U=W*y.get(G,q)+P*y.get(G,x-1),y.set(G,x-1,-P*y.get(G,q)+W*y.get(G,x-1)),y.set(G,q,U)}break}case 2:{let R=g[F-1];g[F-1]=0;for(let q=F;q<x;q++){let U=Zr(D[q],R),W=D[q]/U,P=R/U;if(D[q]=U,R=-P*g[q],g[q]=W*g[q],l)for(let G=0;G<r;G++)U=W*v.get(G,q)+P*v.get(G,F-1),v.set(G,F-1,-P*v.get(G,q)+W*v.get(G,F-1)),v.set(G,q,U)}break}case 3:{const R=Math.max(Math.abs(D[x-1]),Math.abs(D[x-2]),Math.abs(g[x-2]),Math.abs(D[F]),Math.abs(g[F])),q=D[x-1]/R,U=D[x-2]/R,W=g[x-2]/R,P=D[F]/R,G=g[F]/R,j=((U+q)*(U-q)+W*W)/2,H=q*W*(q*W);let V=0;(j!==0||H!==0)&&(j<0?V=0-Math.sqrt(j*j+H):V=Math.sqrt(j*j+H),V=H/(j+V));let ct=(P+q)*(P-q)+V,gt=P*G;for(let ft=F;ft<x-1;ft++){let _t=Zr(ct,gt);_t===0&&(_t=Number.MIN_VALUE);let yt=ct/_t,Nt=gt/_t;if(ft!==F&&(g[ft-1]=_t),ct=yt*D[ft]+Nt*g[ft],g[ft]=yt*g[ft]-Nt*D[ft],gt=Nt*D[ft+1],D[ft+1]=yt*D[ft+1],p)for(let Et=0;Et<n;Et++)_t=yt*y.get(Et,ft)+Nt*y.get(Et,ft+1),y.set(Et,ft+1,-Nt*y.get(Et,ft)+yt*y.get(Et,ft+1)),y.set(Et,ft,_t);if(_t=Zr(ct,gt),_t===0&&(_t=Number.MIN_VALUE),yt=ct/_t,Nt=gt/_t,D[ft]=_t,ct=yt*g[ft]+Nt*D[ft+1],D[ft+1]=-Nt*g[ft]+yt*D[ft+1],gt=Nt*g[ft+1],g[ft+1]=yt*g[ft+1],l&&ft<r-1)for(let Et=0;Et<r;Et++)_t=yt*v.get(Et,ft)+Nt*v.get(Et,ft+1),v.set(Et,ft+1,-Nt*v.get(Et,ft)+yt*v.get(Et,ft+1)),v.set(Et,ft,_t)}g[x-2]=ct;break}case 4:{if(D[F]<=0&&(D[F]=D[F]<0?-D[F]:0,p))for(let R=0;R<=N;R++)y.set(R,F,-y.get(R,F));for(;F<N&&!(D[F]>=D[F+1]);){let R=D[F];if(D[F]=D[F+1],D[F+1]=R,p&&F<n-1)for(let q=0;q<n;q++)R=y.get(q,F+1),y.set(q,F+1,y.get(q,F)),y.set(q,F,R);if(l&&F<r-1)for(let q=0;q<r;q++)R=v.get(q,F+1),v.set(q,F+1,v.get(q,F)),v.set(q,F,R);F++}x--;break}}}if(h){let F=y;y=v,v=F}this.m=r,this.n=n,this.s=D,this.U=v,this.V=y}solve(t){let e=t,r=this.threshold,n=this.s.length,s=pt.zeros(n,n);for(let m=0;m<n;m++)Math.abs(this.s[m])<=r?s.set(m,m,0):s.set(m,m,1/this.s[m]);let a=this.U,f=this.rightSingularVectors,l=f.mmul(s),p=f.rows,h=a.rows,c=pt.zeros(p,h);for(let m=0;m<p;m++)for(let w=0;w<h;w++){let D=0;for(let v=0;v<n;v++)D+=l.get(m,v)*a.get(w,v);c.set(m,w,D)}return c.mmul(e)}solveForDiagonal(t){return this.solve(pt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,s=new pt(r,this.s.length);for(let h=0;h<r;h++)for(let c=0;c<n;c++)Math.abs(this.s[c])>e&&s.set(h,c,t.get(h,c)/this.s[c]);let a=this.U,f=a.rows,l=a.columns,p=new pt(r,f);for(let h=0;h<r;h++)for(let c=0;c<f;c++){let m=0;for(let w=0;w<l;w++)m+=s.get(h,w)*a.get(c,w);p.set(h,c,m)}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,s=r.length;n<s;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return pt.diag(this.s)}}function w_(i,t=!1){return i=tr.checkMatrix(i),t?new ai(i).inverse():Bl(i,pt.eye(i.rows))}function Bl(i,t,e=!1){return i=tr.checkMatrix(i),t=tr.checkMatrix(t),e?new ai(i).solve(t):i.isSquare()?new Gs(i).solve(t):new Fo(i).solve(t)}function Ks(i){if(i=pt.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let t,e,r,n;if(i.columns===2)return t=i.get(0,0),e=i.get(0,1),r=i.get(1,0),n=i.get(1,1),t*n-e*r;if(i.columns===3){let s,a,f;return s=new js(i,[1,2],[1,2]),a=new js(i,[1,2],[0,2]),f=new js(i,[1,2],[0,1]),t=i.get(0,0),e=i.get(0,1),r=i.get(0,2),t*Ks(s)-e*Ks(a)+r*Ks(f)}else return new Gs(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function __(i,t){let e=[];for(let r=0;r<i;r++)r!==t&&e.push(r);return e}function D_(i,t,e,r=1e-9,n=1e-9){if(i>n)return new Array(t.rows+1).fill(0);{let s=t.addRow(e,[0]);for(let a=0;a<s.rows;a++)Math.abs(s.get(a,0))<r&&s.set(a,0,0);return s.to1DArray()}}function y_(i,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;i=pt.checkMatrix(i);let n=i.rows,s=new pt(n,n);for(let a=0;a<n;a++){let f=pt.columnVector(i.getRow(a)),l=i.subMatrixRow(__(n,a)).transpose(),h=new ai(l).solve(f),c=pt.sub(f,l.mmul(h)).abs().max();s.setRow(a,D_(c,h,a,e,r))}return s}function E_(i,t=Number.EPSILON){if(i=pt.checkMatrix(i),i.isEmpty())return i.transpose();let e=new ai(i,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,s=e.diagonal;for(let a=0;a<s.length;a++)Math.abs(s[a])>t?s[a]=1/s[a]:s[a]=0;return n.mmul(pt.diag(s).mmul(r.transpose()))}function A_(i,t=i,e={}){i=new pt(i);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!Ge.isAnyArray(t)?(e=t,t=i,r=!0):t=new pt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(i=i.center("column"),r||(t=t.center("column")));const s=i.transpose().mmul(t);for(let a=0;a<s.rows;a++)for(let f=0;f<s.columns;f++)s.set(a,f,s.get(a,f)*(1/(i.rows-1)));return s}function b_(i,t=i,e={}){i=new pt(i);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!Ge.isAnyArray(t)?(e=t,t=i,r=!0):t=new pt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=e;n&&(i.center("column"),r||t.center("column")),s&&(i.scale("column"),r||t.scale("column"));const a=i.standardDeviation("column",{unbiased:!0}),f=r?a:t.standardDeviation("column",{unbiased:!0}),l=i.transpose().mmul(t);for(let p=0;p<l.rows;p++)for(let h=0;h<l.columns;h++)l.set(p,h,l.get(p,h)*(1/(a[p]*f[h]))*(1/(i.rows-1)));return l}let Il=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=tr.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n=t.columns,s=new pt(n,n),a=new Float64Array(n),f=new Float64Array(n),l=t,p,h,c=!1;if(r?c=!0:c=t.isSymmetric(),c){for(p=0;p<n;p++)for(h=0;h<n;h++)s.set(p,h,l.get(p,h));C_(n,f,a,s),F_(n,f,a,s)}else{let m=new pt(n,n),w=new Float64Array(n);for(h=0;h<n;h++)for(p=0;p<n;p++)m.set(p,h,l.get(p,h));M_(n,m,w,s),x_(n,f,a,s,m)}this.n=n,this.e=f,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,r=this.d,n=new pt(t,t),s,a;for(s=0;s<t;s++){for(a=0;a<t;a++)n.set(s,a,0);n.set(s,s,r[s]),e[s]>0?n.set(s,s+1,e[s]):e[s]<0&&n.set(s,s-1,e[s])}return n}};function C_(i,t,e,r){let n,s,a,f,l,p,h,c;for(l=0;l<i;l++)e[l]=r.get(i-1,l);for(f=i-1;f>0;f--){for(c=0,a=0,p=0;p<f;p++)c=c+Math.abs(e[p]);if(c===0)for(t[f]=e[f-1],l=0;l<f;l++)e[l]=r.get(f-1,l),r.set(f,l,0),r.set(l,f,0);else{for(p=0;p<f;p++)e[p]/=c,a+=e[p]*e[p];for(n=e[f-1],s=Math.sqrt(a),n>0&&(s=-s),t[f]=c*s,a=a-n*s,e[f-1]=n-s,l=0;l<f;l++)t[l]=0;for(l=0;l<f;l++){for(n=e[l],r.set(l,f,n),s=t[l]+r.get(l,l)*n,p=l+1;p<=f-1;p++)s+=r.get(p,l)*e[p],t[p]+=r.get(p,l)*n;t[l]=s}for(n=0,l=0;l<f;l++)t[l]/=a,n+=t[l]*e[l];for(h=n/(a+a),l=0;l<f;l++)t[l]-=h*e[l];for(l=0;l<f;l++){for(n=e[l],s=t[l],p=l;p<=f-1;p++)r.set(p,l,r.get(p,l)-(n*t[p]+s*e[p]));e[l]=r.get(f-1,l),r.set(f,l,0)}}e[f]=a}for(f=0;f<i-1;f++){if(r.set(i-1,f,r.get(f,f)),r.set(f,f,1),a=e[f+1],a!==0){for(p=0;p<=f;p++)e[p]=r.get(p,f+1)/a;for(l=0;l<=f;l++){for(s=0,p=0;p<=f;p++)s+=r.get(p,f+1)*r.get(p,l);for(p=0;p<=f;p++)r.set(p,l,r.get(p,l)-s*e[p])}}for(p=0;p<=f;p++)r.set(p,f+1,0)}for(l=0;l<i;l++)e[l]=r.get(i-1,l),r.set(i-1,l,0);r.set(i-1,i-1,1),t[0]=0}function F_(i,t,e,r){let n,s,a,f,l,p,h,c,m,w,D,v,y,g,A,E;for(a=1;a<i;a++)t[a-1]=t[a];t[i-1]=0;let S=0,C=0,M=Number.EPSILON;for(p=0;p<i;p++){for(C=Math.max(C,Math.abs(e[p])+Math.abs(t[p])),h=p;h<i&&!(Math.abs(t[h])<=M*C);)h++;if(h>p)do{for(n=e[p],c=(e[p+1]-n)/(2*t[p]),m=Zr(c,1),c<0&&(m=-m),e[p]=t[p]/(c+m),e[p+1]=t[p]*(c+m),w=e[p+1],s=n-e[p],a=p+2;a<i;a++)e[a]-=s;for(S=S+s,c=e[h],D=1,v=D,y=D,g=t[p+1],A=0,E=0,a=h-1;a>=p;a--)for(y=v,v=D,E=A,n=D*t[a],s=D*c,m=Zr(c,t[a]),t[a+1]=A*m,A=t[a]/m,D=c/m,c=D*e[a]-A*n,e[a+1]=s+A*(D*n+A*e[a]),l=0;l<i;l++)s=r.get(l,a+1),r.set(l,a+1,A*r.get(l,a)+D*s),r.set(l,a,D*r.get(l,a)-A*s);c=-A*E*y*g*t[p]/w,t[p]=A*c,e[p]=D*c}while(Math.abs(t[p])>M*C);e[p]=e[p]+S,t[p]=0}for(a=0;a<i-1;a++){for(l=a,c=e[a],f=a+1;f<i;f++)e[f]<c&&(l=f,c=e[f]);if(l!==a)for(e[l]=e[a],e[a]=c,f=0;f<i;f++)c=r.get(f,a),r.set(f,a,r.get(f,l)),r.set(f,l,c)}}function M_(i,t,e,r){let n=0,s=i-1,a,f,l,p,h,c,m;for(c=n+1;c<=s-1;c++){for(m=0,p=c;p<=s;p++)m=m+Math.abs(t.get(p,c-1));if(m!==0){for(l=0,p=s;p>=c;p--)e[p]=t.get(p,c-1)/m,l+=e[p]*e[p];for(f=Math.sqrt(l),e[c]>0&&(f=-f),l=l-e[c]*f,e[c]=e[c]-f,h=c;h<i;h++){for(a=0,p=s;p>=c;p--)a+=e[p]*t.get(p,h);for(a=a/l,p=c;p<=s;p++)t.set(p,h,t.get(p,h)-a*e[p])}for(p=0;p<=s;p++){for(a=0,h=s;h>=c;h--)a+=e[h]*t.get(p,h);for(a=a/l,h=c;h<=s;h++)t.set(p,h,t.get(p,h)-a*e[h])}e[c]=m*e[c],t.set(c,c-1,m*f)}}for(p=0;p<i;p++)for(h=0;h<i;h++)r.set(p,h,p===h?1:0);for(c=s-1;c>=n+1;c--)if(t.get(c,c-1)!==0){for(p=c+1;p<=s;p++)e[p]=t.get(p,c-1);for(h=c;h<=s;h++){for(f=0,p=c;p<=s;p++)f+=e[p]*r.get(p,h);for(f=f/e[c]/t.get(c,c-1),p=c;p<=s;p++)r.set(p,h,r.get(p,h)+f*e[p])}}}function x_(i,t,e,r,n){let s=i-1,a=0,f=i-1,l=Number.EPSILON,p=0,h=0,c=0,m=0,w=0,D=0,v=0,y=0,g,A,E,S,C,M,x,N,$,F,I,R,q,U,W;for(g=0;g<i;g++)for((g<a||g>f)&&(e[g]=n.get(g,g),t[g]=0),A=Math.max(g-1,0);A<i;A++)h=h+Math.abs(n.get(g,A));for(;s>=a;){for(S=s;S>a&&(D=Math.abs(n.get(S-1,S-1))+Math.abs(n.get(S,S)),D===0&&(D=h),!(Math.abs(n.get(S,S-1))<l*D));)S--;if(S===s)n.set(s,s,n.get(s,s)+p),e[s]=n.get(s,s),t[s]=0,s--,y=0;else if(S===s-1){if(x=n.get(s,s-1)*n.get(s-1,s),c=(n.get(s-1,s-1)-n.get(s,s))/2,m=c*c+x,v=Math.sqrt(Math.abs(m)),n.set(s,s,n.get(s,s)+p),n.set(s-1,s-1,n.get(s-1,s-1)+p),N=n.get(s,s),m>=0){for(v=c>=0?c+v:c-v,e[s-1]=N+v,e[s]=e[s-1],v!==0&&(e[s]=N-x/v),t[s-1]=0,t[s]=0,N=n.get(s,s-1),D=Math.abs(N)+Math.abs(v),c=N/D,m=v/D,w=Math.sqrt(c*c+m*m),c=c/w,m=m/w,A=s-1;A<i;A++)v=n.get(s-1,A),n.set(s-1,A,m*v+c*n.get(s,A)),n.set(s,A,m*n.get(s,A)-c*v);for(g=0;g<=s;g++)v=n.get(g,s-1),n.set(g,s-1,m*v+c*n.get(g,s)),n.set(g,s,m*n.get(g,s)-c*v);for(g=a;g<=f;g++)v=r.get(g,s-1),r.set(g,s-1,m*v+c*r.get(g,s)),r.set(g,s,m*r.get(g,s)-c*v)}else e[s-1]=N+c,e[s]=N+c,t[s-1]=v,t[s]=-v;s=s-2,y=0}else{if(N=n.get(s,s),$=0,x=0,S<s&&($=n.get(s-1,s-1),x=n.get(s,s-1)*n.get(s-1,s)),y===10){for(p+=N,g=a;g<=s;g++)n.set(g,g,n.get(g,g)-N);D=Math.abs(n.get(s,s-1))+Math.abs(n.get(s-1,s-2)),N=$=.75*D,x=-.4375*D*D}if(y===30&&(D=($-N)/2,D=D*D+x,D>0)){for(D=Math.sqrt(D),$<N&&(D=-D),D=N-x/(($-N)/2+D),g=a;g<=s;g++)n.set(g,g,n.get(g,g)-D);p+=D,N=$=x=.964}for(y=y+1,C=s-2;C>=S&&(v=n.get(C,C),w=N-v,D=$-v,c=(w*D-x)/n.get(C+1,C)+n.get(C,C+1),m=n.get(C+1,C+1)-v-w-D,w=n.get(C+2,C+1),D=Math.abs(c)+Math.abs(m)+Math.abs(w),c=c/D,m=m/D,w=w/D,!(C===S||Math.abs(n.get(C,C-1))*(Math.abs(m)+Math.abs(w))<l*(Math.abs(c)*(Math.abs(n.get(C-1,C-1))+Math.abs(v)+Math.abs(n.get(C+1,C+1))))));)C--;for(g=C+2;g<=s;g++)n.set(g,g-2,0),g>C+2&&n.set(g,g-3,0);for(E=C;E<=s-1&&(U=E!==s-1,E!==C&&(c=n.get(E,E-1),m=n.get(E+1,E-1),w=U?n.get(E+2,E-1):0,N=Math.abs(c)+Math.abs(m)+Math.abs(w),N!==0&&(c=c/N,m=m/N,w=w/N)),N!==0);E++)if(D=Math.sqrt(c*c+m*m+w*w),c<0&&(D=-D),D!==0){for(E!==C?n.set(E,E-1,-D*N):S!==C&&n.set(E,E-1,-n.get(E,E-1)),c=c+D,N=c/D,$=m/D,v=w/D,m=m/c,w=w/c,A=E;A<i;A++)c=n.get(E,A)+m*n.get(E+1,A),U&&(c=c+w*n.get(E+2,A),n.set(E+2,A,n.get(E+2,A)-c*v)),n.set(E,A,n.get(E,A)-c*N),n.set(E+1,A,n.get(E+1,A)-c*$);for(g=0;g<=Math.min(s,E+3);g++)c=N*n.get(g,E)+$*n.get(g,E+1),U&&(c=c+v*n.get(g,E+2),n.set(g,E+2,n.get(g,E+2)-c*w)),n.set(g,E,n.get(g,E)-c),n.set(g,E+1,n.get(g,E+1)-c*m);for(g=a;g<=f;g++)c=N*r.get(g,E)+$*r.get(g,E+1),U&&(c=c+v*r.get(g,E+2),r.set(g,E+2,r.get(g,E+2)-c*w)),r.set(g,E,r.get(g,E)-c),r.set(g,E+1,r.get(g,E+1)-c*m)}}}if(h!==0){for(s=i-1;s>=0;s--)if(c=e[s],m=t[s],m===0)for(S=s,n.set(s,s,1),g=s-1;g>=0;g--){for(x=n.get(g,g)-c,w=0,A=S;A<=s;A++)w=w+n.get(g,A)*n.get(A,s);if(t[g]<0)v=x,D=w;else if(S=g,t[g]===0?n.set(g,s,x!==0?-w/x:-w/(l*h)):(N=n.get(g,g+1),$=n.get(g+1,g),m=(e[g]-c)*(e[g]-c)+t[g]*t[g],M=(N*D-v*w)/m,n.set(g,s,M),n.set(g+1,s,Math.abs(N)>Math.abs(v)?(-w-x*M)/N:(-D-$*M)/v)),M=Math.abs(n.get(g,s)),l*M*M>1)for(A=g;A<=s;A++)n.set(A,s,n.get(A,s)/M)}else if(m<0)for(S=s-1,Math.abs(n.get(s,s-1))>Math.abs(n.get(s-1,s))?(n.set(s-1,s-1,m/n.get(s,s-1)),n.set(s-1,s,-(n.get(s,s)-c)/n.get(s,s-1))):(W=Js(0,-n.get(s-1,s),n.get(s-1,s-1)-c,m),n.set(s-1,s-1,W[0]),n.set(s-1,s,W[1])),n.set(s,s-1,0),n.set(s,s,1),g=s-2;g>=0;g--){for(F=0,I=0,A=S;A<=s;A++)F=F+n.get(g,A)*n.get(A,s-1),I=I+n.get(g,A)*n.get(A,s);if(x=n.get(g,g)-c,t[g]<0)v=x,w=F,D=I;else if(S=g,t[g]===0?(W=Js(-F,-I,x,m),n.set(g,s-1,W[0]),n.set(g,s,W[1])):(N=n.get(g,g+1),$=n.get(g+1,g),R=(e[g]-c)*(e[g]-c)+t[g]*t[g]-m*m,q=(e[g]-c)*2*m,R===0&&q===0&&(R=l*h*(Math.abs(x)+Math.abs(m)+Math.abs(N)+Math.abs($)+Math.abs(v))),W=Js(N*w-v*F+m*I,N*D-v*I-m*F,R,q),n.set(g,s-1,W[0]),n.set(g,s,W[1]),Math.abs(N)>Math.abs(v)+Math.abs(m)?(n.set(g+1,s-1,(-F-x*n.get(g,s-1)+m*n.get(g,s))/N),n.set(g+1,s,(-I-x*n.get(g,s)-m*n.get(g,s-1))/N)):(W=Js(-w-$*n.get(g,s-1),-D-$*n.get(g,s),v,m),n.set(g+1,s-1,W[0]),n.set(g+1,s,W[1]))),M=Math.max(Math.abs(n.get(g,s-1)),Math.abs(n.get(g,s))),l*M*M>1)for(A=g;A<=s;A++)n.set(A,s-1,n.get(A,s-1)/M),n.set(A,s,n.get(A,s)/M)}for(g=0;g<i;g++)if(g<a||g>f)for(A=g;A<i;A++)r.set(g,A,n.get(g,A));for(A=i-1;A>=a;A--)for(g=a;g<=f;g++){for(v=0,E=a;E<=Math.min(A,f);E++)v=v+r.get(g,E)*n.get(E,A);r.set(g,A,v)}}}function Js(i,t,e,r){let n,s;return Math.abs(e)>Math.abs(r)?(n=r/e,s=e+n*r,[(i+n*t)/s,(t-n*i)/s]):(n=e/r,s=r+n*e,[(n*i+t)/s,(n*t-i)/s])}class Tl{constructor(t){if(t=tr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new pt(r,r),s=!0,a,f,l;for(f=0;f<r;f++){let p=0;for(l=0;l<f;l++){let h=0;for(a=0;a<l;a++)h+=n.get(l,a)*n.get(f,a);h=(e.get(f,l)-h)/n.get(l,l),n.set(f,l,h),p=p+h*h}for(p=e.get(f,f)-p,s&=p>0,n.set(f,f,Math.sqrt(Math.max(p,0))),l=f+1;l<r;l++)n.set(f,l,0)}this.L=n,this.positiveDefinite=!!s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=tr.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=t.columns,s=t.clone(),a,f,l;for(l=0;l<r;l++)for(f=0;f<n;f++){for(a=0;a<l;a++)s.set(l,f,s.get(l,f)-s.get(a,f)*e.get(l,a));s.set(l,f,s.get(l,f)/e.get(l,l))}for(l=r-1;l>=0;l--)for(f=0;f<n;f++){for(a=l+1;a<r;a++)s.set(l,f,s.get(l,f)-s.get(a,f)*e.get(a,l));s.set(l,f,s.get(l,f)/e.get(l,l))}return s}get lowerTriangularMatrix(){return this.L}}class $l{constructor(t,e={}){t=tr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:s=1e3,terminationCriteria:a=1e-10}=e;let f;if(r){if(Ge.isAnyArray(r)&&typeof r[0]=="number"?r=pt.columnVector(r):r=tr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");f=r.getColumnVector(0)}else f=t.getColumnVector(0);let l=1,p,h,c,m;for(let w=0;w<s&&l>a;w++)c=t.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0)),c=c.div(c.norm()),p=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),w>0&&(l=p.clone().sub(m).pow(2).sum()),m=p.clone(),r?(h=r.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),h=h.div(h.norm()),f=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):f=p;if(r){let w=t.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0));w=w.div(w.norm());let D=t.clone().sub(p.clone().mmul(w.transpose())),v=f.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),y=r.clone().sub(p.clone().mulS(v.get(0,0)).mmul(h.transpose()));this.t=p,this.p=w.transpose(),this.w=c.transpose(),this.q=h,this.u=f,this.s=p.transpose().mmul(p),this.xResidual=D,this.yResidual=y,this.betas=v}else this.w=c.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(c.transpose()))}}Pt.AbstractMatrix=$t,Pt.CHO=Tl,Pt.CholeskyDecomposition=Tl,Pt.DistanceMatrix=Zs,Pt.EVD=Il;var S_=Pt.EigenvalueDecomposition=Il;Pt.LU=Gs,Pt.LuDecomposition=Gs;var Ol=Pt.Matrix=pt;Pt.MatrixColumnSelectionView=c_,Pt.MatrixColumnView=f_,Pt.MatrixFlipColumnView=l_,Pt.MatrixFlipRowView=h_,Pt.MatrixRowSelectionView=d_,Pt.MatrixRowView=p_,Pt.MatrixSelectionView=js,Pt.MatrixSubView=m_,Pt.MatrixTransposeView=v_,Pt.NIPALS=$l,Pt.Nipals=$l,Pt.QR=Fo,Pt.QrDecomposition=Fo,Pt.SVD=ai,Pt.SingularValueDecomposition=ai,Pt.SymmetricMatrix=On,Pt.WrapperMatrix1D=Nl,Pt.WrapperMatrix2D=tr,Pt.correlation=b_,Pt.covariance=A_;var Rl=Pt.default=pt;Pt.determinant=Ks,Pt.inverse=w_,Pt.linearDependencies=y_,Pt.pseudoInverse=E_,Pt.solve=Bl,Pt.wrap=g_;const Ll=S_,Pl=Ol;Rl.Matrix&&Rl.Matrix;class N_{new({rows:t,columns:e,initial_value:r}={}){return new Mo(t,e,r)}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({id:t,id2:e}){return t==null?void 0:t.sum({id2:e})}copy({id:t}){return t==null?void 0:t.copy()}diff({id:t,id2:e}){return t==null?void 0:t.diff({id2:e})}rows({id:t}){return t==null?void 0:t.rows()}columns({id:t}){return t==null?void 0:t.columns()}fill({id:t,value:e,from_row:r,to_row:n,from_column:s,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:s,to_column:a})}kron({id:t,id2:e}){return t==null?void 0:t.kron({id2:e})}mode({id:t}){return t==null?void 0:t.mode()}mult({id: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({id: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}){return t==null?void 0:t.reshape({rows:e,columns:r})}reverse({id:t}){t==null||t.reverse()}is_binary({id:t}){return t==null?void 0:t.is_binary()}is_square({id:t}){return t==null?void 0:t.is_square()}submatrix({id:t,from_row:e,to_row:r,from_column:n,to_column:s}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:s})}swap_rows({id:t,row1:e,row2:r}){t==null||t.swap_rows({row1:e,row2:r})}transpose({id:t}){return t==null?void 0:t.transpose()}remove_col({id:t,column:e}){return t==null?void 0:t.remove_col({column:e})}remove_row({id:t,row:e}){return t==null?void 0:t.remove_row({row:e})}eigenvalues({id:t}){return t==null?void 0:t.eigenvalues()}is_diagonal({id:t}){return t==null?void 0:t.is_diagonal()}is_identity({id:t}){return t==null?void 0:t.is_identity()}eigenvectors({id:t}){return t==null?void 0:t.eigenvectors()}is_symmetric({id:t}){return t==null?void 0:t.is_symmetric()}swap_columns({id:t,column1:e,column2:r}){t==null||t.swap_columns({column1:e,column2:r})}is_stochastic({id:t}){return t==null?void 0:t.is_stochastic()}is_triangular({id:t}){return t==null?void 0:t.is_triangular()}elements_count({id:t}){return t==null?void 0:t.elements_count()}is_antidiagonal({id:t}){return t==null?void 0:t.is_antidiagonal()}is_antisymmetric({id:t}){return t==null?void 0:t.is_antisymmetric()}}class Mo{constructor(t=0,e=0,r=void 0){ut(this,"_matrixInstance");this._matrixInstance=this._createMatrix(t,e,r)}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 Vt(e,r))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const s of n._value)t+=s,e+=1;return t/e}col({column:t=0}){const e=[];for(const n of this._matrixInstance)e.push(n._value[t]);const r=new Vt;return r._value=e,r}det(){return Al(this._matrixArray)}get({row:t,column:e=0}){return this._matrixInstance[t]._value[e]}inv(){const t=Us(this._matrixArray);return this._newMatrix(t)}max(){return bw(this._matrixArray)}min(){return Eo(this._matrixArray)}pow({power:t}){const e=Fw(this._matrixArray,t);return this._newMatrix(e)}row({row:t=0}){return this._matrixInstance[t]}set({row:t,column:e,value:r}){this._matrixInstance[t]._value[e]=r}sum({id2:t}){const e=Oi(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=ww(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=0,to_row:r=this.rows(),from_column:n=0,to_column:s=this.columns()}={}){for(const[a,f]of this._matrixInstance.entries())for(const[l]of f._value.entries())a<r&&a>=e&&l>=n&&l<s&&(f._value[l]=t)}kron({id2:t}){const e=vw(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return Eo(vl(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=ii(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=Cw(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t=0,order:e=Sn.ascending}={}){this._matrixInstance.sort((r,n)=>{const s=r._value[t],a=n._value[t];return e!==Sn.descending?s-a:a-s})}trace(){return Aw(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return bl(this._matrixArray)}add_col({column:t=this.columns(),array_id:e}={}){for(const[r,n]of this._matrixInstance.entries())n._value[t]=e?e._value[r]:void 0}add_row({row:t,array_id:e}){this._matrixInstance.splice(t||this.rows(),0,e||new Vt(this.columns()))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t,columns:e}){const r=hw(this._matrixArray,[t,e]);this._matrixInstance=r.map(n=>{const s=new Vt;return s._value=[...n],s})}reverse(){this._matrixInstance.reverse();for(const t of this._matrixInstance)t._value.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=0,to_row:e=this.rows(),from_column:r=0,to_column:n=this.columns()}={}){const s=this._matrixArray.splice(t,e-1),a=[];for(const f of s)a.push(f.splice(r,n-1));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=wl(this._matrixArray);return this._newMatrix(t)}remove_col({column:t=this.columns()}={}){const e=[];for(const n of this._matrixInstance){const s=n._value.splice(t,1);e.push(s[0])}const r=new Vt;return r._value=e,r}remove_row({row:t=this.rows()}={}){return this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new Ll(new Pl(this._matrixArray)),e=new Vt;return e._value=t.realEigenvalues,e}is_diagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0)return!1;return!0}is_identity(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0||n===s&&r[n][s]!==1)return!1;return!0}eigenvectors(){const t=new Ll(new Pl(this._matrixArray));return this._newMatrix(t.eigenvectorMatrix.to2DArray())}is_symmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=n+1;s<e;s++)if(r[n][s]!==r[s][n])return!1;return!0}swap_columns({column1:t,column2:e}){for(const r of this._matrixInstance){const n=r._value[t],s=r._value[e];r._value[t]=s,r._value[e]=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 pw(this._matrixArray)}is_antidiagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n+s!==t-1&&r[n][s]!==0)return!1;return!0}is_antisymmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n!==s&&r[n][s]!==-r[s][n])return!1;return!0}_isUpperTriangular(t){const e=this._matrixArray;for(let r=1;r<t;r++)for(let n=0;n<r;n++)if(e[r][n]!==0)return!1;return!0}_isLowerTriangular(t){const e=this._matrixArray;for(let r=0;r<t-1;r++)for(let n=r+1;n<t;n++)if(e[r][n]!==0)return!1;return!0}_newMatrix(t){const e=new Mo;return e._value=t.map(r=>{const n=new Vt;return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,s=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let f=a;for(;f<r&&s[f][a]===0;)f++;if(f===r)continue;if(f!==a){const p=s[f];s[f]=s[a],s[a]=p}const l=s[a][a];for(let p=0;p<n;p++)s[a][p]/=l;for(let p=a+1;p<r;p++){const h=s[p][a];s[p]=s[p].map((c,m)=>c-h*s[a][m]),s[p][a]=0}}for(let a=0;a<r;a++)s[a].some(f=>Number(f.toFixed(8))!==0)&&e++;return e}}class B_{constructor(t){ut(this,"_variables");ut(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){const r=Mn(t),n=Mn(this._variables.timeframe.period);if(r<n)return!0;const s=`change_${e}`,a=this._cacheData[s],f=this._variables.time*1e3;if(a){if(a.offset){if(a.currentTime+a.offset<=f)return this._cacheData[s]={currentTime:f,offset:0},!0}else if(a.currentTime+r*1e3<=f)return this._cacheData[s]={currentTime:f,offset:0},!0}else{const l=this._calcTimeOffset(f,t);return this._cacheData[s]={currentTime:f,offset:l},!1}return!1}in_seconds({timeframe:t}={}){return Mn(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=ne.duration(e);if(r.years())return"12M";const s=r.asMonths();if(Ps(s))return`${s}M`;const a=r.asWeeks();if(Ps(a))return`${a}M`;const f=r.asDays();if(f>=1)return`${Math.ceil(f)}D`;const l=r.asMinutes();if(l>=1)return`${Math.ceil(l)}`;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 f=ne(t).day();e="1D",f!==1&&(r=(8-f)*60*60*24*1e3)}else if(e.includes("M")){const f=ne(t).date();e="1D";const l=ne(t).daysInMonth();f!==1&&(r=(l-f+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),s=Mn(e)*1e3,a=t-n-Math.floor((t-n)/s)*s;return r?r-a:a}}class I_{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 Vt;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=0,separator:r=""}){return Array.from(new Array(e),()=>t).join(r)}replace({source:t,target:e,replacement:r,occurrence:n=0}){let s=-1;for(let a=0;a<n+1&&(s=t.indexOf(e,s+1),s!==-1);a++);return s!==-1?t.substring(0,s)+r+t.substring(s+e.length):t}contains({source:t,str:e}){return t==null?void 0:t.includes(e)}endswith({source:t,str:e}){return t==null?void 0:t.endsWith(e)}tonumber({string:t}){if(/[^\d.]/.test(t))return;const e=parseFloat(t);return isNaN(e)?void 0:e}tostring({value:t,format:e}){if(t===void 0)return"NaN";if(typeof t=="object"){if(t.isArray)return this._arrToStr(t._value,e);if(t.isMatrix){const r=[];for(const n of t._matrixArray)r.push(this._arrToStr(n,e));return r.join(`
|
62
|
-
`)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return this._formatNumber(t,e)}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._formatNumber(n,e):n).toString()}]`}substring({source:t,begin_pos:e=0,end_pos:r}){return 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 br(t,r).format(e)}replace_all({source:t,target:e,replacement:r}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_formatNumber(t,e){if(!e)return t;switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:const r=e.split(".")[1],n=r?r.length:0;return parseFloat(t.toFixed(n))}}_strFormat(t,e){let r=t;return e.forEach((n,s)=>{if(typeof n=="number"){const a=`\\{\\s*${s}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,f=t.match(new RegExp(a));if(f){const l=f[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(n,l)))}else r=r.replace(new RegExp(`\\{${s}\\}`,"g"),String(n))}else r=r.replace(new RegExp(`\\{${s}\\}`,"g"),n)}),r}}class T_{new(){return new xo}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 xo{constructor(){ut(this,"_mapInstance");this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new xo;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 Vt;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 Vt;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 $_{constructor(){ut(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Ar.flatMap([...this._errors.values()])}addError(t,e,r){const[n,s]=e.split("_").slice(-2),a=this._errors.get(e),f={message:t,endLineNumber:Number(n),startColumn:Number(s),endColumn:Number(s),startLineNumber:Number(n),type:r};a?a.push(f):this._errors.set(e,[f])}}ne.extend(Vp),ne.extend(ed),ne.extend(nd);class O_{constructor(t,e){ut(this,"array");ut(this,"color");ut(this,"math");ut(this,"str");ut(this,"map");ut(this,"matrix");ut(this,"timeframe");ut(this,"ta");ut(this,"input");ut(this,"_variables");ut(this,"_cacheData");ut(this,"_options");ut(this,"_errorListener");ut(this,"_plots");this._variables=e,this.array=new id,this.math=new sd(t),this.color=new Bw,this.str=new I_,this.map=new T_,this.timeframe=new B_(e),this.matrix=new N_,this.ta=new xw(e,this.math,this.timeframe),this._cacheData={},this._options={},this._errorListener=new $_,this.input=new Nw(e,this._errorListener),this._plots=new Map}get errors(){return this._errorListener.errors}get options(){const t=this.input.getInputs();return Object.assign(this._options,{inputGroups:t,plots:[...this._plots.values()]})}update(t){const{barIndex:e,inputs:r}=t;r&&r.length&&this.input.update(r),this.math.update(e)}indicator(t){this._variables.bar_index||(this._options.scriptType="indicator",this._options.indicator=t)}plot(t,e){const{series:r,color:n,seriesColors:s,...a}=t,{bar_index:f}=this._variables,l=`plot_${e}`,p=this._plots.get(l),h=(p==null?void 0:p.data)||[],c=r!==void 0&&isNaN(r)?void 0:r;if(h[f]=c,s!=null&&s.length&&(this._seriesColorHandle(t,l),h[f]={value:c,itemStyle:{color:n}}),!p){const m=n?[n]:void 0;this._plots.set(l,{editable:!0,...a,colors:m,data:h,id:l})}}_seriesColorHandle(t,e){var s,a;const{seriesColors:r}=t,n=this._plots.get(e);if(n&&r!=null&&r.length)for(const f of r){if((s=n.gradientColorKeys)!=null&&s.includes(f))continue;const l=t[f],p=n[`${f}s`]||[];p.includes(l)||(p.push(l),n[`${f}s`]=p,p.length>5&&(n[`${f}s`]=[],(a=n.gradientColorKeys)==null||a.push(f)))}}plotbar(t,e){const{open:r,close:n,low:s,high:a,color:f,seriesColors:l,...p}=t,{bar_index:h}=this._variables,c=`plotbar_${e}`,m=this._plots.get(c),w=(m==null?void 0:m.data)||[],D=n!==void 0&&isNaN(n)?void 0:n,v=r!==void 0&&isNaN(r)?void 0:r,y=s!==void 0&&isNaN(s)?void 0:s,g=a!==void 0&&isNaN(a)?void 0:a,A=[v,D,y,g];if(w[h]=A,l!=null&&l.length&&(this._seriesColorHandle(t,c),w[h]={value:A,itemStyle:{color:f}}),!m){const E=f?[f]:void 0;this._plots.set(c,{editable:!0,...p,colors:E,data:w,id:c})}}plotchar(t,e){const{series:r,color:n,textcolor:s,...a}=t,{bar_index:f}=this._variables,l=`plotchar_${e}`,p=this._plots.get(l),h=(p==null?void 0:p.data)||[];h[f]={value:r,color:n,textcolor:s},p||this._plots.set(l,{editable:!0,...a,data:h,id:l})}plotarrow(t,e){const{series:r,colorup:n,colordown:s,...a}=t,{bar_index:f}=this._variables,l=`plotarrow_${e}`,p=this._plots.get(l),h=(p==null?void 0:p.data)||[];h[f]={value:r!==void 0&&isNaN(r)?void 0:r,colorup:n,colordown:s},p||this._plots.set(l,{editable:!0,...a,data:h,id:l})}plotshape(t,e){const{series:r,color:n,textcolor:s,...a}=t,{bar_index:f}=this._variables,l=`plotshape_${e}`,p=this._plots.get(l),h=(p==null?void 0:p.data)||[];h[f]={value:r,color:n,textcolor:s},p||this._plots.set(l,{editable:!0,...a,data:h,id:l})}plotcandle(t,e){const{wickcolor:r,bordercolor:n,color:s,close:a,open:f,low:l,high:p,...h}=t,{bar_index:c}=this._variables,m=`plotcandle_${e}`,w=this._plots.get(m),D=(w==null?void 0:w.data)||[],v=a!==void 0&&isNaN(a)?void 0:a,y=f!==void 0&&isNaN(f)?void 0:f,g=l!==void 0&&isNaN(l)?void 0:l,A=p!==void 0&&isNaN(p)?void 0:p,E=[y,v,g,A];D[c]={value:E,wickcolor:r,bordercolor:n,color:s},w||this._plots.set(m,{editable:!0,...h,data:D,id:m})}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}nz({source:t,replacement:e}){return t!==void 0&&!isNaN(t)?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._variables.time_close&&this._timeHandle(this._variables.time_close,s,t,e,r,n)}timestamp({dateString:t,timezone:e,year:r,month:n,day:s,hour:a=0,minute:f=0,second:l=0}){if(t)return ne(t).valueOf();let p=ne({year:r,month:n,day:s,hour:a,minute:f,second:l});return e&&(p=br(p.valueOf(),e)),p.valueOf()}weekofyear({time:t,timezone:e}){return br(t,e).week()}year({time:t,timezone:e}){return br(t,e).year()}second({time:t,timezone:e}){return br(t,e).second()}month({time:t,timezone:e}){return br(t,e).month()+1}minute({time:t,timezone:e}){return br(t,e).minute()}hour({time:t,timezone:e}){return br(t,e).hour()}dayofweek({time:t,timezone:e}){return br(t,e).day()+1}dayofmonth({time:t,timezone:e}){return br(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Mn(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,s,a=0){const f=r||this._variables.timeframe.period,l=Mn(f),p=Mn(this._variables.timeframe.period);let h;if(l<=p)h=t;else{const c=`time_${e}`,m=this._cacheData[c];if(m)m.currentTime+l*1e3-m.offset<=t?(h=t,this._cacheData[c]={currentTime:t,offset:0}):h=m;else{const w=this._calcTimeOffset(t,f);this._cacheData[c]={currentTime:t,offset:w},h=t}}if(n){const{timePeriods:c,weeks:m}=this._parserSession(n),w=ne(t).format("YYYY-MM-DD"),D=h;h=void 0;for(const y of c){const[g,A]=y;if(ne(t).isBetween(`${w} ${g}`,`${w} ${A}`,"hour")){ne(D).isBetween(`${w} ${g}`,`${w} ${A}`,"hour")?h=D:h=ne(`${w} ${g}`).valueOf();break}}const v=this._variables.dayofweek;h&&!m.includes(v)&&(h=void 0)}return s&&(h=h&&br(h,s).valueOf()),h&&h-a*p*1e3}_parserSession(t){const e=t.split(":"),r=e[0],s=(e[1]||"1234567").split("").map(f=>{const l=parseInt(f,10);if(l<1||l>7)throw new Error(`Invalid day of week: ${f}`);return l});return{timePeriods:r.split(",").map(f=>{const l=f.split("-");if(l.length!==2)throw new Error(`Invalid time period: ${f}`);return[this._processTime(l[0]),this._processTime(l[1])]}),weeks:s}}_processTime(t){const e=parseInt(t.slice(0,2),10),r=parseInt(t.slice(2),10);if(!(e>=0&&e<=23)&&r>=0&&r<=59)throw new Error("Invalid time: Time must be within 00:00 to 23:59");return`${e}:${r}`}}/**
|
63
|
-
* @license
|
64
|
-
* Copyright 2019 Google LLC
|
65
|
-
* SPDX-License-Identifier: Apache-2.0
|
66
|
-
*/const zl=Symbol("Comlink.proxy"),R_=Symbol("Comlink.endpoint"),L_=Symbol("Comlink.releaseProxy"),So=Symbol("Comlink.finalizer"),Xs=Symbol("Comlink.thrown"),Ul=i=>typeof i=="object"&&i!==null||typeof i=="function",P_={canHandle:i=>Ul(i)&&i[zl],serialize(i){const{port1:t,port2:e}=new MessageChannel;return No(i,t),[e,[e]]},deserialize(i){return i.start(),W_(i)}},z_={canHandle:i=>Ul(i)&&Xs in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},ql=new Map([["proxy",P_],["throw",z_]]);function U_(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function No(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!U_(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:f}=Object.assign({path:[]},n.data),l=(n.data.argumentList||[]).map(Rn);let p;try{const h=f.slice(0,-1).reduce((m,w)=>m[w],i),c=f.reduce((m,w)=>m[w],i);switch(a){case"GET":p=c;break;case"SET":h[f.slice(-1)[0]]=Rn(n.data.value),p=!0;break;case"APPLY":p=c.apply(h,l);break;case"CONSTRUCT":{const m=new c(...l);p=G_(m)}break;case"ENDPOINT":{const{port1:m,port2:w}=new MessageChannel;No(i,w),p=j_(m,[m])}break;case"RELEASE":p=void 0;break;default:return}}catch(h){p={value:h,[Xs]:0}}Promise.resolve(p).catch(h=>({value:h,[Xs]:0})).then(h=>{const[c,m]=tu(h);t.postMessage(Object.assign(Object.assign({},c),{id:s}),m),a==="RELEASE"&&(t.removeEventListener("message",r),Wl(t),So in i&&typeof i[So]=="function"&&i[So]())}).catch(h=>{const[c,m]=tu({value:new TypeError("Unserializable return value"),[Xs]:0});t.postMessage(Object.assign(Object.assign({},c),{id:s}),m)})}),t.start&&t.start()}function q_(i){return i.constructor.name==="MessagePort"}function Wl(i){q_(i)&&i.close()}function W_(i,t){return Bo(i,[],t)}function Hs(i){if(i)throw new Error("Proxy has been released and is not useable")}function kl(i){return fi(i,{type:"RELEASE"}).then(()=>{Wl(i)})}const Qs=new WeakMap,Vs="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(Qs.get(i)||0)-1;Qs.set(i,t),t===0&&kl(i)});function k_(i,t){const e=(Qs.get(t)||0)+1;Qs.set(t,e),Vs&&Vs.register(i,t,i)}function Y_(i){Vs&&Vs.unregister(i)}function Bo(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(Hs(r),a===L_)return()=>{Y_(n),kl(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const f=fi(i,{type:"GET",path:t.map(l=>l.toString())}).then(Rn);return f.then.bind(f)}return Bo(i,[...t,a])},set(s,a,f){Hs(r);const[l,p]=tu(f);return fi(i,{type:"SET",path:[...t,a].map(h=>h.toString()),value:l},p).then(Rn)},apply(s,a,f){Hs(r);const l=t[t.length-1];if(l===R_)return fi(i,{type:"ENDPOINT"}).then(Rn);if(l==="bind")return Bo(i,t.slice(0,-1));const[p,h]=Yl(f);return fi(i,{type:"APPLY",path:t.map(c=>c.toString()),argumentList:p},h).then(Rn)},construct(s,a){Hs(r);const[f,l]=Yl(a);return fi(i,{type:"CONSTRUCT",path:t.map(p=>p.toString()),argumentList:f},l).then(Rn)}});return k_(n,i),n}function Z_(i){return Array.prototype.concat.apply([],i)}function Yl(i){const t=i.map(tu);return[t.map(e=>e[0]),Z_(t.map(e=>e[1]))]}const Zl=new WeakMap;function j_(i,t){return Zl.set(i,t),i}function G_(i){return Object.assign(i,{[zl]:!0})}function tu(i){for(const[t,e]of ql)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},Zl.get(i)||[]]}function Rn(i){switch(i.type){case"HANDLER":return ql.get(i.name).deserialize(i.value);case"RAW":return i.value}}function fi(i,t,e){return new Promise(r=>{const n=K_();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function K_(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class J_{constructor(){ut(this,"_cache");ut(this,"_data");this._cache=new Map,this._data=[]}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}setData(t){this._data=t}updateData(t){var a,f;const e=t[0];if(!e||!e.time)return;const r=e.time;let n=this._data.length-1,s=((a=this._data[n])==null?void 0:a.time)||0;for(;s>r;)n--,s=((f=this._data[n])==null?void 0:f.time)||0;s===r?this._data.splice(n,t.length,...t):this._data.splice(n+1,t.length,...t)}getData(t=0,e){return this._data.slice(t,e)}}function X_(i,t,e){const{data:r,isPreParser:n}=t;if(e?(self.workerStorage||(self.workerStorage=new J_),self.builtInGather=new bp,self.buildinConstants=new Hp,self.buildInFunctions=new O_(4,self.builtInGather),self.tradingvueFunc=new Function("$_var","$_const","$_func",i),self.workerStorage.setData(r)):self.workerStorage.updateData(r),n)self.tradingvueFunc(self.builtInGather,self.buildinConstants,self.buildInFunctions);else if(r&&r.length){const a=r.length;for(const[f,l]of r.entries())self.builtInGather.updateData(Object.assign(l,{barIndex:f,lastBarIndex:a-1,lastBarTime:r[a-1].time})),self.buildInFunctions.update({barIndex:f}),self.tradingvueFunc(self.builtInGather,self.buildinConstants,self.buildInFunctions)}const s=self.buildInFunctions.errors;return s.length&&s.some(a=>a.type===qs.Error)?{status:1,errors:s}:{status:0,options:self.buildInFunctions.options}}No(X_)})();
|