@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.
Files changed (22) hide show
  1. package/lib/assets/editor.worker-CT5Cb1wO.js +11 -0
  2. package/lib/assets/{parserTccWorker-cJ5nOv5I.js → parserTccWorker-BhMZL9OL.js} +39 -38
  3. package/lib/assets/scriptsRunWorker-DHT6psBx.js +66 -0
  4. package/lib/components/editor/parseScript/buildInConstants.d.ts +51 -0
  5. package/lib/components/editor/parseScript/buildInFuncNamespace/box.d.ts +99 -0
  6. package/lib/components/editor/parseScript/buildInFuncNamespace/chartPoint.d.ts +27 -0
  7. package/lib/components/editor/parseScript/buildInFuncNamespace/index.d.ts +9 -1
  8. package/lib/components/editor/parseScript/buildInFuncNamespace/label.d.ts +77 -0
  9. package/lib/components/editor/parseScript/buildInFuncNamespace/line.d.ts +81 -0
  10. package/lib/components/editor/parseScript/buildInFuncNamespace/linefill.d.ts +37 -0
  11. package/lib/components/editor/parseScript/buildInFuncNamespace/polyline.d.ts +31 -0
  12. package/lib/components/editor/parseScript/buildInFuncNamespace/ta.d.ts +4 -3
  13. package/lib/components/editor/parseScript/buildInFuncNamespace/table.d.ts +94 -0
  14. package/lib/components/editor/parseScript/constants.d.ts +3 -0
  15. package/lib/components/editor/parseScript/type.d.ts +1 -0
  16. package/lib/components/editor/parseScript/visitorParser.d.ts +2 -0
  17. package/lib/components/editor/type/index.d.ts +2 -0
  18. package/lib/trading-vue-editor.js +1876 -1852
  19. package/lib/trading-vue-editor.umd.cjs +32 -32
  20. package/package.json +1 -1
  21. package/lib/assets/scriptsRunWorker-B4O7gGzE.js +0 -66
  22. package/lib/components/editor/parseScript/buildInVariables.d.ts +0 -124
@@ -0,0 +1,66 @@
1
+ var vC=Object.defineProperty;var _C=(Wt,Zt,De)=>Zt in Wt?vC(Wt,Zt,{enumerable:!0,configurable:!0,writable:!0,value:De}):Wt[Zt]=De;var K=(Wt,Zt,De)=>(_C(Wt,typeof Zt!="symbol"?Zt+"":Zt,De),De),Df=(Wt,Zt,De)=>{if(!Zt.has(Wt))throw TypeError("Cannot "+De)};var Rr=(Wt,Zt,De)=>(Df(Wt,Zt,"read from private field"),De?De.call(Wt):Zt.get(Wt)),yf=(Wt,Zt,De)=>{if(Zt.has(Wt))throw TypeError("Cannot add the same private member more than once");Zt instanceof WeakSet?Zt.add(Wt):Zt.set(Wt,De)},eu=(Wt,Zt,De,Nn)=>(Df(Wt,Zt,"write to private field"),Nn?Nn.call(Wt,De):Zt.set(Wt,De),De);var bf=(Wt,Zt,De)=>(Df(Wt,Zt,"access private method"),De);(function(){"use strict";var ji,Ef,di,qe;var Wt=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 Nn={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
+ */Nn.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,d=2,_=4,D=1,g=2,y=1,v=2,E=4,b=8,N=16,x=32,F=64,M=128,S=256,$=512,C=30,I="...",R=800,U=16,q=1,k=2,P=3,G=1/0,j=9007199254740991,Q=17976931348623157e292,tt=NaN,lt=4294967295,vt=lt-1,ft=lt>>>1,wt=[["ary",M],["bind",y],["bindKey",v],["curry",b],["curryRight",N],["flip",$],["partial",x],["partialRight",F],["rearg",S]],yt="[object Arguments]",St="[object Array]",bt="[object AsyncFunction]",ee="[object Boolean]",It="[object Date]",Mt="[object DOMException]",ie="[object Error]",Ht="[object Function]",zt="[object GeneratorFunction]",Gt="[object Map]",Ce="[object Number]",nr="[object Null]",Me="[object Object]",Xr="[object Promise]",gn="[object Proxy]",Hr="[object RegExp]",ir="[object Set]",vn="[object String]",O="[object Symbol]",Z="[object Undefined]",J="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ct="[object Float32Array]",at="[object Float64Array]",ht="[object Int8Array]",ut="[object Int16Array]",Kt="[object Int32Array]",Qt="[object Uint8Array]",pe="[object Uint8ClampedArray]",Te="[object Uint16Array]",Ne="[object Uint32Array]",sr=/\b__p \+= '';/g,or=/\b(__p \+=) '' \+/g,_n=/(__e\(.*?\)|\b__t\)) \+\n'';/g,qn=/&(?:amp|lt|gt|quot|#39);/g,lo=/[&<>"']/g,qu=RegExp(qn.source),Uu=RegExp(lo.source),ku=/<%-([\s\S]+?)%>/g,Wu=/<%([\s\S]+?)%>/g,co=/<%=([\s\S]+?)%>/g,Yu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zu=/^\w*$/,ju=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gi=/[\\^$.*+?()[\]{}|]/g,Gu=RegExp(Gi.source),Ki=/^\s+/,Ku=/\s/,Ju=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Xu=/\{\n\/\* \[wrapped with (.+)\] \*/,Hu=/,? & /,Qu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Vu=/[()=,{}\[\]\/\s]/,ta=/\\(\\)?/g,ea=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ho=/\w*$/,ra=/^[-+]0x[0-9a-f]+$/i,na=/^0b[01]+$/i,ia=/^\[object .+?Constructor\]$/,sa=/^0o[0-7]+$/i,oa=/^(?:0|[1-9]\d*)$/,ua=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,gi=/($^)/,Un=/['\n\r\u2028\u2029\\]/g,Yt="\\ud800-\\udfff",Ue="\\u0300-\\u036f",aa="\\ufe20-\\ufe2f",vi="\\u20d0-\\u20ff",wn=Ue+aa+vi,po="\\u2700-\\u27bf",eh="a-z\\xdf-\\xf6\\xf8-\\xff",pD="\\xac\\xb1\\xd7\\xf7",mD="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",dD="\\u2000-\\u206f",gD=" \\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",rh="A-Z\\xc0-\\xd6\\xd8-\\xde",nh="\\ufe0e\\ufe0f",ih=pD+mD+dD+gD,fa="['’]",vD="["+Yt+"]",sh="["+ih+"]",mo="["+wn+"]",oh="\\d+",_D="["+po+"]",uh="["+eh+"]",ah="[^"+Yt+ih+oh+po+eh+rh+"]",la="\\ud83c[\\udffb-\\udfff]",wD="(?:"+mo+"|"+la+")",fh="[^"+Yt+"]",ca="(?:\\ud83c[\\udde6-\\uddff]){2}",ha="[\\ud800-\\udbff][\\udc00-\\udfff]",_i="["+rh+"]",lh="\\u200d",ch="(?:"+uh+"|"+ah+")",DD="(?:"+_i+"|"+ah+")",hh="(?:"+fa+"(?:d|ll|m|re|s|t|ve))?",ph="(?:"+fa+"(?:D|LL|M|RE|S|T|VE))?",mh=wD+"?",dh="["+nh+"]?",yD="(?:"+lh+"(?:"+[fh,ca,ha].join("|")+")"+dh+mh+")*",bD="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ED="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",gh=dh+mh+yD,AD="(?:"+[_D,ca,ha].join("|")+")"+gh,xD="(?:"+[fh+mo+"?",mo,ca,ha,vD].join("|")+")",CD=RegExp(fa,"g"),FD=RegExp(mo,"g"),pa=RegExp(la+"(?="+la+")|"+xD+gh,"g"),MD=RegExp([_i+"?"+uh+"+"+hh+"(?="+[sh,_i,"$"].join("|")+")",DD+"+"+ph+"(?="+[sh,_i+ch,"$"].join("|")+")",_i+"?"+ch+"+"+hh,_i+"+"+ph,ED,bD,oh,AD].join("|"),"g"),ND=RegExp("["+lh+Yt+wn+nh+"]"),SD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,BD=["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"],ID=-1,ce={};ce[ct]=ce[at]=ce[ht]=ce[ut]=ce[Kt]=ce[Qt]=ce[pe]=ce[Te]=ce[Ne]=!0,ce[yt]=ce[St]=ce[st]=ce[ee]=ce[rt]=ce[It]=ce[ie]=ce[Ht]=ce[Gt]=ce[Ce]=ce[Me]=ce[Hr]=ce[ir]=ce[vn]=ce[J]=!1;var fe={};fe[yt]=fe[St]=fe[st]=fe[rt]=fe[ee]=fe[It]=fe[ct]=fe[at]=fe[ht]=fe[ut]=fe[Kt]=fe[Gt]=fe[Ce]=fe[Me]=fe[Hr]=fe[ir]=fe[vn]=fe[O]=fe[Qt]=fe[pe]=fe[Te]=fe[Ne]=!0,fe[ie]=fe[Ht]=fe[J]=!1;var TD={À:"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"},$D={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},OD={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},RD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},LD=parseFloat,PD=parseInt,vh=typeof Wt=="object"&&Wt&&Wt.Object===Object&&Wt,zD=typeof self=="object"&&self&&self.Object===Object&&self,Le=vh||zD||Function("return this")(),ma=t&&!t.nodeType&&t,kn=ma&&!0&&i&&!i.nodeType&&i,_h=kn&&kn.exports===ma,da=_h&&vh.process,vr=function(){try{var W=kn&&kn.require&&kn.require("util").types;return W||da&&da.binding&&da.binding("util")}catch{}}(),wh=vr&&vr.isArrayBuffer,Dh=vr&&vr.isDate,yh=vr&&vr.isMap,bh=vr&&vr.isRegExp,Eh=vr&&vr.isSet,Ah=vr&&vr.isTypedArray;function ur(W,H,X){switch(X.length){case 0:return W.call(H);case 1:return W.call(H,X[0]);case 2:return W.call(H,X[0],X[1]);case 3:return W.call(H,X[0],X[1],X[2])}return W.apply(H,X)}function qD(W,H,X,gt){for(var Bt=-1,Jt=W==null?0:W.length;++Bt<Jt;){var Se=W[Bt];H(gt,Se,X(Se),W)}return gt}function _r(W,H){for(var X=-1,gt=W==null?0:W.length;++X<gt&&H(W[X],X,W)!==!1;);return W}function UD(W,H){for(var X=W==null?0:W.length;X--&&H(W[X],X,W)!==!1;);return W}function xh(W,H){for(var X=-1,gt=W==null?0:W.length;++X<gt;)if(!H(W[X],X,W))return!1;return!0}function Dn(W,H){for(var X=-1,gt=W==null?0:W.length,Bt=0,Jt=[];++X<gt;){var Se=W[X];H(Se,X,W)&&(Jt[Bt++]=Se)}return Jt}function go(W,H){var X=W==null?0:W.length;return!!X&&wi(W,H,0)>-1}function ga(W,H,X){for(var gt=-1,Bt=W==null?0:W.length;++gt<Bt;)if(X(H,W[gt]))return!0;return!1}function me(W,H){for(var X=-1,gt=W==null?0:W.length,Bt=Array(gt);++X<gt;)Bt[X]=H(W[X],X,W);return Bt}function yn(W,H){for(var X=-1,gt=H.length,Bt=W.length;++X<gt;)W[Bt+X]=H[X];return W}function va(W,H,X,gt){var Bt=-1,Jt=W==null?0:W.length;for(gt&&Jt&&(X=W[++Bt]);++Bt<Jt;)X=H(X,W[Bt],Bt,W);return X}function kD(W,H,X,gt){var Bt=W==null?0:W.length;for(gt&&Bt&&(X=W[--Bt]);Bt--;)X=H(X,W[Bt],Bt,W);return X}function _a(W,H){for(var X=-1,gt=W==null?0:W.length;++X<gt;)if(H(W[X],X,W))return!0;return!1}var WD=wa("length");function YD(W){return W.split("")}function ZD(W){return W.match(Qu)||[]}function Ch(W,H,X){var gt;return X(W,function(Bt,Jt,Se){if(H(Bt,Jt,Se))return gt=Jt,!1}),gt}function vo(W,H,X,gt){for(var Bt=W.length,Jt=X+(gt?1:-1);gt?Jt--:++Jt<Bt;)if(H(W[Jt],Jt,W))return Jt;return-1}function wi(W,H,X){return H===H?ny(W,H,X):vo(W,Fh,X)}function jD(W,H,X,gt){for(var Bt=X-1,Jt=W.length;++Bt<Jt;)if(gt(W[Bt],H))return Bt;return-1}function Fh(W){return W!==W}function Mh(W,H){var X=W==null?0:W.length;return X?ya(W,H)/X:tt}function wa(W){return function(H){return H==null?e:H[W]}}function Da(W){return function(H){return W==null?e:W[H]}}function Nh(W,H,X,gt,Bt){return Bt(W,function(Jt,Se,ue){X=gt?(gt=!1,Jt):H(X,Jt,Se,ue)}),X}function GD(W,H){var X=W.length;for(W.sort(H);X--;)W[X]=W[X].value;return W}function ya(W,H){for(var X,gt=-1,Bt=W.length;++gt<Bt;){var Jt=H(W[gt]);Jt!==e&&(X=X===e?Jt:X+Jt)}return X}function ba(W,H){for(var X=-1,gt=Array(W);++X<W;)gt[X]=H(X);return gt}function KD(W,H){return me(H,function(X){return[X,W[X]]})}function Sh(W){return W&&W.slice(0,$h(W)+1).replace(Ki,"")}function ar(W){return function(H){return W(H)}}function Ea(W,H){return me(H,function(X){return W[X]})}function Ji(W,H){return W.has(H)}function Bh(W,H){for(var X=-1,gt=W.length;++X<gt&&wi(H,W[X],0)>-1;);return X}function Ih(W,H){for(var X=W.length;X--&&wi(H,W[X],0)>-1;);return X}function JD(W,H){for(var X=W.length,gt=0;X--;)W[X]===H&&++gt;return gt}var XD=Da(TD),HD=Da($D);function QD(W){return"\\"+RD[W]}function VD(W,H){return W==null?e:W[H]}function Di(W){return ND.test(W)}function ty(W){return SD.test(W)}function ey(W){for(var H,X=[];!(H=W.next()).done;)X.push(H.value);return X}function Aa(W){var H=-1,X=Array(W.size);return W.forEach(function(gt,Bt){X[++H]=[Bt,gt]}),X}function Th(W,H){return function(X){return W(H(X))}}function bn(W,H){for(var X=-1,gt=W.length,Bt=0,Jt=[];++X<gt;){var Se=W[X];(Se===H||Se===h)&&(W[X]=h,Jt[Bt++]=X)}return Jt}function _o(W){var H=-1,X=Array(W.size);return W.forEach(function(gt){X[++H]=gt}),X}function ry(W){var H=-1,X=Array(W.size);return W.forEach(function(gt){X[++H]=[gt,gt]}),X}function ny(W,H,X){for(var gt=X-1,Bt=W.length;++gt<Bt;)if(W[gt]===H)return gt;return-1}function iy(W,H,X){for(var gt=X+1;gt--;)if(W[gt]===H)return gt;return gt}function yi(W){return Di(W)?oy(W):WD(W)}function Ir(W){return Di(W)?uy(W):YD(W)}function $h(W){for(var H=W.length;H--&&Ku.test(W.charAt(H)););return H}var sy=Da(OD);function oy(W){for(var H=pa.lastIndex=0;pa.test(W);)++H;return H}function uy(W){return W.match(pa)||[]}function ay(W){return W.match(MD)||[]}var fy=function W(H){H=H==null?Le:bi.defaults(Le.Object(),H,bi.pick(Le,BD));var X=H.Array,gt=H.Date,Bt=H.Error,Jt=H.Function,Se=H.Math,ue=H.Object,xa=H.RegExp,ly=H.String,wr=H.TypeError,wo=X.prototype,cy=Jt.prototype,Ei=ue.prototype,Do=H["__core-js_shared__"],yo=cy.toString,re=Ei.hasOwnProperty,hy=0,Oh=function(){var o=/[^.]+$/.exec(Do&&Do.keys&&Do.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),bo=Ei.toString,py=yo.call(ue),my=Le._,dy=xa("^"+yo.call(re).replace(Gi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Eo=_h?H.Buffer:e,En=H.Symbol,Ao=H.Uint8Array,Rh=Eo?Eo.allocUnsafe:e,xo=Th(ue.getPrototypeOf,ue),Lh=ue.create,Ph=Ei.propertyIsEnumerable,Co=wo.splice,zh=En?En.isConcatSpreadable:e,Xi=En?En.iterator:e,Wn=En?En.toStringTag:e,Fo=function(){try{var o=Kn(ue,"defineProperty");return o({},"",{}),o}catch{}}(),gy=H.clearTimeout!==Le.clearTimeout&&H.clearTimeout,vy=gt&&gt.now!==Le.Date.now&&gt.now,_y=H.setTimeout!==Le.setTimeout&&H.setTimeout,Mo=Se.ceil,No=Se.floor,Ca=ue.getOwnPropertySymbols,wy=Eo?Eo.isBuffer:e,qh=H.isFinite,Dy=wo.join,yy=Th(ue.keys,ue),Be=Se.max,ke=Se.min,by=gt.now,Ey=H.parseInt,Uh=Se.random,Ay=wo.reverse,Fa=Kn(H,"DataView"),Hi=Kn(H,"Map"),Ma=Kn(H,"Promise"),Ai=Kn(H,"Set"),Qi=Kn(H,"WeakMap"),Vi=Kn(ue,"create"),So=Qi&&new Qi,xi={},xy=Jn(Fa),Cy=Jn(Hi),Fy=Jn(Ma),My=Jn(Ai),Ny=Jn(Qi),Bo=En?En.prototype:e,ts=Bo?Bo.valueOf:e,kh=Bo?Bo.toString:e;function B(o){if(we(o)&&!Tt(o)&&!(o instanceof Ut)){if(o instanceof Dr)return o;if(re.call(o,"__wrapped__"))return W0(o)}return new Dr(o)}var Ci=function(){function o(){}return function(u){if(!_e(u))return{};if(Lh)return Lh(u);o.prototype=u;var m=new o;return o.prototype=e,m}}();function Io(){}function Dr(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}B.templateSettings={escape:ku,evaluate:Wu,interpolate:co,variable:"",imports:{_:B}},B.prototype=Io.prototype,B.prototype.constructor=B,Dr.prototype=Ci(Io.prototype),Dr.prototype.constructor=Dr;function Ut(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=lt,this.__views__=[]}function Sy(){var o=new Ut(this.__wrapped__);return o.__actions__=Xe(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=Xe(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=Xe(this.__views__),o}function By(){if(this.__filtered__){var o=new Ut(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function Iy(){var o=this.__wrapped__.value(),u=this.__dir__,m=Tt(o),w=u<0,A=m?o.length:0,T=Yb(0,A,this.__views__),L=T.start,z=T.end,Y=z-L,V=w?z:L-1,et=this.__iteratees__,ot=et.length,mt=0,_t=ke(Y,this.__takeCount__);if(!m||!w&&A==Y&&_t==Y)return h0(o,this.__actions__);var xt=[];t:for(;Y--&&mt<_t;){V+=u;for(var Rt=-1,Ct=o[V];++Rt<ot;){var qt=et[Rt],kt=qt.iteratee,cr=qt.type,je=kt(Ct);if(cr==k)Ct=je;else if(!je){if(cr==q)continue t;break t}}xt[mt++]=Ct}return xt}Ut.prototype=Ci(Io.prototype),Ut.prototype.constructor=Ut;function Yn(o){var u=-1,m=o==null?0:o.length;for(this.clear();++u<m;){var w=o[u];this.set(w[0],w[1])}}function Ty(){this.__data__=Vi?Vi(null):{},this.size=0}function $y(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function Oy(o){var u=this.__data__;if(Vi){var m=u[o];return m===l?e:m}return re.call(u,o)?u[o]:e}function Ry(o){var u=this.__data__;return Vi?u[o]!==e:re.call(u,o)}function Ly(o,u){var m=this.__data__;return this.size+=this.has(o)?0:1,m[o]=Vi&&u===e?l:u,this}Yn.prototype.clear=Ty,Yn.prototype.delete=$y,Yn.prototype.get=Oy,Yn.prototype.has=Ry,Yn.prototype.set=Ly;function Qr(o){var u=-1,m=o==null?0:o.length;for(this.clear();++u<m;){var w=o[u];this.set(w[0],w[1])}}function Py(){this.__data__=[],this.size=0}function zy(o){var u=this.__data__,m=To(u,o);if(m<0)return!1;var w=u.length-1;return m==w?u.pop():Co.call(u,m,1),--this.size,!0}function qy(o){var u=this.__data__,m=To(u,o);return m<0?e:u[m][1]}function Uy(o){return To(this.__data__,o)>-1}function ky(o,u){var m=this.__data__,w=To(m,o);return w<0?(++this.size,m.push([o,u])):m[w][1]=u,this}Qr.prototype.clear=Py,Qr.prototype.delete=zy,Qr.prototype.get=qy,Qr.prototype.has=Uy,Qr.prototype.set=ky;function Vr(o){var u=-1,m=o==null?0:o.length;for(this.clear();++u<m;){var w=o[u];this.set(w[0],w[1])}}function Wy(){this.size=0,this.__data__={hash:new Yn,map:new(Hi||Qr),string:new Yn}}function Yy(o){var u=Zo(this,o).delete(o);return this.size-=u?1:0,u}function Zy(o){return Zo(this,o).get(o)}function jy(o){return Zo(this,o).has(o)}function Gy(o,u){var m=Zo(this,o),w=m.size;return m.set(o,u),this.size+=m.size==w?0:1,this}Vr.prototype.clear=Wy,Vr.prototype.delete=Yy,Vr.prototype.get=Zy,Vr.prototype.has=jy,Vr.prototype.set=Gy;function Zn(o){var u=-1,m=o==null?0:o.length;for(this.__data__=new Vr;++u<m;)this.add(o[u])}function Ky(o){return this.__data__.set(o,l),this}function Jy(o){return this.__data__.has(o)}Zn.prototype.add=Zn.prototype.push=Ky,Zn.prototype.has=Jy;function Tr(o){var u=this.__data__=new Qr(o);this.size=u.size}function Xy(){this.__data__=new Qr,this.size=0}function Hy(o){var u=this.__data__,m=u.delete(o);return this.size=u.size,m}function Qy(o){return this.__data__.get(o)}function Vy(o){return this.__data__.has(o)}function tb(o,u){var m=this.__data__;if(m instanceof Qr){var w=m.__data__;if(!Hi||w.length<n-1)return w.push([o,u]),this.size=++m.size,this;m=this.__data__=new Vr(w)}return m.set(o,u),this.size=m.size,this}Tr.prototype.clear=Xy,Tr.prototype.delete=Hy,Tr.prototype.get=Qy,Tr.prototype.has=Vy,Tr.prototype.set=tb;function Wh(o,u){var m=Tt(o),w=!m&&Xn(o),A=!m&&!w&&Mn(o),T=!m&&!w&&!A&&Si(o),L=m||w||A||T,z=L?ba(o.length,ly):[],Y=z.length;for(var V in o)(u||re.call(o,V))&&!(L&&(V=="length"||A&&(V=="offset"||V=="parent")||T&&(V=="buffer"||V=="byteLength"||V=="byteOffset")||nn(V,Y)))&&z.push(V);return z}function Yh(o){var u=o.length;return u?o[za(0,u-1)]:e}function eb(o,u){return jo(Xe(o),jn(u,0,o.length))}function rb(o){return jo(Xe(o))}function Na(o,u,m){(m!==e&&!$r(o[u],m)||m===e&&!(u in o))&&tn(o,u,m)}function es(o,u,m){var w=o[u];(!(re.call(o,u)&&$r(w,m))||m===e&&!(u in o))&&tn(o,u,m)}function To(o,u){for(var m=o.length;m--;)if($r(o[m][0],u))return m;return-1}function nb(o,u,m,w){return An(o,function(A,T,L){u(w,A,m(A),L)}),w}function Zh(o,u){return o&&Yr(u,$e(u),o)}function ib(o,u){return o&&Yr(u,Qe(u),o)}function tn(o,u,m){u=="__proto__"&&Fo?Fo(o,u,{configurable:!0,enumerable:!0,value:m,writable:!0}):o[u]=m}function Sa(o,u){for(var m=-1,w=u.length,A=X(w),T=o==null;++m<w;)A[m]=T?e:cf(o,u[m]);return A}function jn(o,u,m){return o===o&&(m!==e&&(o=o<=m?o:m),u!==e&&(o=o>=u?o:u)),o}function yr(o,u,m,w,A,T){var L,z=u&c,Y=u&d,V=u&_;if(m&&(L=A?m(o,w,A,T):m(o)),L!==e)return L;if(!_e(o))return o;var et=Tt(o);if(et){if(L=jb(o),!z)return Xe(o,L)}else{var ot=We(o),mt=ot==Ht||ot==zt;if(Mn(o))return d0(o,z);if(ot==Me||ot==yt||mt&&!A){if(L=Y||mt?{}:$0(o),!z)return Y?Ob(o,ib(L,o)):$b(o,Zh(L,o))}else{if(!fe[ot])return A?o:{};L=Gb(o,ot,z)}}T||(T=new Tr);var _t=T.get(o);if(_t)return _t;T.set(o,L),fp(o)?o.forEach(function(Ct){L.add(yr(Ct,u,m,Ct,o,T))}):up(o)&&o.forEach(function(Ct,qt){L.set(qt,yr(Ct,u,m,qt,o,T))});var xt=V?Y?Xa:Ja:Y?Qe:$e,Rt=et?e:xt(o);return _r(Rt||o,function(Ct,qt){Rt&&(qt=Ct,Ct=o[qt]),es(L,qt,yr(Ct,u,m,qt,o,T))}),L}function sb(o){var u=$e(o);return function(m){return jh(m,o,u)}}function jh(o,u,m){var w=m.length;if(o==null)return!w;for(o=ue(o);w--;){var A=m[w],T=u[A],L=o[A];if(L===e&&!(A in o)||!T(L))return!1}return!0}function Gh(o,u,m){if(typeof o!="function")throw new wr(a);return as(function(){o.apply(e,m)},u)}function rs(o,u,m,w){var A=-1,T=go,L=!0,z=o.length,Y=[],V=u.length;if(!z)return Y;m&&(u=me(u,ar(m))),w?(T=ga,L=!1):u.length>=n&&(T=Ji,L=!1,u=new Zn(u));t:for(;++A<z;){var et=o[A],ot=m==null?et:m(et);if(et=w||et!==0?et:0,L&&ot===ot){for(var mt=V;mt--;)if(u[mt]===ot)continue t;Y.push(et)}else T(u,ot,w)||Y.push(et)}return Y}var An=D0(Wr),Kh=D0(Ia,!0);function ob(o,u){var m=!0;return An(o,function(w,A,T){return m=!!u(w,A,T),m}),m}function $o(o,u,m){for(var w=-1,A=o.length;++w<A;){var T=o[w],L=u(T);if(L!=null&&(z===e?L===L&&!lr(L):m(L,z)))var z=L,Y=T}return Y}function ub(o,u,m,w){var A=o.length;for(m=Ot(m),m<0&&(m=-m>A?0:A+m),w=w===e||w>A?A:Ot(w),w<0&&(w+=A),w=m>w?0:cp(w);m<w;)o[m++]=u;return o}function Jh(o,u){var m=[];return An(o,function(w,A,T){u(w,A,T)&&m.push(w)}),m}function Pe(o,u,m,w,A){var T=-1,L=o.length;for(m||(m=Jb),A||(A=[]);++T<L;){var z=o[T];u>0&&m(z)?u>1?Pe(z,u-1,m,w,A):yn(A,z):w||(A[A.length]=z)}return A}var Ba=y0(),Xh=y0(!0);function Wr(o,u){return o&&Ba(o,u,$e)}function Ia(o,u){return o&&Xh(o,u,$e)}function Oo(o,u){return Dn(u,function(m){return sn(o[m])})}function Gn(o,u){u=Cn(u,o);for(var m=0,w=u.length;o!=null&&m<w;)o=o[Zr(u[m++])];return m&&m==w?o:e}function Hh(o,u,m){var w=u(o);return Tt(o)?w:yn(w,m(o))}function Ye(o){return o==null?o===e?Z:nr:Wn&&Wn in ue(o)?Wb(o):rE(o)}function Ta(o,u){return o>u}function ab(o,u){return o!=null&&re.call(o,u)}function fb(o,u){return o!=null&&u in ue(o)}function lb(o,u,m){return o>=ke(u,m)&&o<Be(u,m)}function $a(o,u,m){for(var w=m?ga:go,A=o[0].length,T=o.length,L=T,z=X(T),Y=1/0,V=[];L--;){var et=o[L];L&&u&&(et=me(et,ar(u))),Y=ke(et.length,Y),z[L]=!m&&(u||A>=120&&et.length>=120)?new Zn(L&&et):e}et=o[0];var ot=-1,mt=z[0];t:for(;++ot<A&&V.length<Y;){var _t=et[ot],xt=u?u(_t):_t;if(_t=m||_t!==0?_t:0,!(mt?Ji(mt,xt):w(V,xt,m))){for(L=T;--L;){var Rt=z[L];if(!(Rt?Ji(Rt,xt):w(o[L],xt,m)))continue t}mt&&mt.push(xt),V.push(_t)}}return V}function cb(o,u,m,w){return Wr(o,function(A,T,L){u(w,m(A),T,L)}),w}function ns(o,u,m){u=Cn(u,o),o=P0(o,u);var w=o==null?o:o[Zr(Er(u))];return w==null?e:ur(w,o,m)}function Qh(o){return we(o)&&Ye(o)==yt}function hb(o){return we(o)&&Ye(o)==st}function pb(o){return we(o)&&Ye(o)==It}function is(o,u,m,w,A){return o===u?!0:o==null||u==null||!we(o)&&!we(u)?o!==o&&u!==u:mb(o,u,m,w,is,A)}function mb(o,u,m,w,A,T){var L=Tt(o),z=Tt(u),Y=L?St:We(o),V=z?St:We(u);Y=Y==yt?Me:Y,V=V==yt?Me:V;var et=Y==Me,ot=V==Me,mt=Y==V;if(mt&&Mn(o)){if(!Mn(u))return!1;L=!0,et=!1}if(mt&&!et)return T||(T=new Tr),L||Si(o)?B0(o,u,m,w,A,T):Ub(o,u,Y,m,w,A,T);if(!(m&D)){var _t=et&&re.call(o,"__wrapped__"),xt=ot&&re.call(u,"__wrapped__");if(_t||xt){var Rt=_t?o.value():o,Ct=xt?u.value():u;return T||(T=new Tr),A(Rt,Ct,m,w,T)}}return mt?(T||(T=new Tr),kb(o,u,m,w,A,T)):!1}function db(o){return we(o)&&We(o)==Gt}function Oa(o,u,m,w){var A=m.length,T=A,L=!w;if(o==null)return!T;for(o=ue(o);A--;){var z=m[A];if(L&&z[2]?z[1]!==o[z[0]]:!(z[0]in o))return!1}for(;++A<T;){z=m[A];var Y=z[0],V=o[Y],et=z[1];if(L&&z[2]){if(V===e&&!(Y in o))return!1}else{var ot=new Tr;if(w)var mt=w(V,et,Y,o,u,ot);if(!(mt===e?is(et,V,D|g,w,ot):mt))return!1}}return!0}function Vh(o){if(!_e(o)||Hb(o))return!1;var u=sn(o)?dy:ia;return u.test(Jn(o))}function gb(o){return we(o)&&Ye(o)==Hr}function vb(o){return we(o)&&We(o)==ir}function _b(o){return we(o)&&Qo(o.length)&&!!ce[Ye(o)]}function t0(o){return typeof o=="function"?o:o==null?Ve:typeof o=="object"?Tt(o)?n0(o[0],o[1]):r0(o):bp(o)}function Ra(o){if(!us(o))return yy(o);var u=[];for(var m in ue(o))re.call(o,m)&&m!="constructor"&&u.push(m);return u}function wb(o){if(!_e(o))return eE(o);var u=us(o),m=[];for(var w in o)w=="constructor"&&(u||!re.call(o,w))||m.push(w);return m}function La(o,u){return o<u}function e0(o,u){var m=-1,w=He(o)?X(o.length):[];return An(o,function(A,T,L){w[++m]=u(A,T,L)}),w}function r0(o){var u=Qa(o);return u.length==1&&u[0][2]?R0(u[0][0],u[0][1]):function(m){return m===o||Oa(m,o,u)}}function n0(o,u){return tf(o)&&O0(u)?R0(Zr(o),u):function(m){var w=cf(m,o);return w===e&&w===u?hf(m,o):is(u,w,D|g)}}function Ro(o,u,m,w,A){o!==u&&Ba(u,function(T,L){if(A||(A=new Tr),_e(T))Db(o,u,L,m,Ro,w,A);else{var z=w?w(rf(o,L),T,L+"",o,u,A):e;z===e&&(z=T),Na(o,L,z)}},Qe)}function Db(o,u,m,w,A,T,L){var z=rf(o,m),Y=rf(u,m),V=L.get(Y);if(V){Na(o,m,V);return}var et=T?T(z,Y,m+"",o,u,L):e,ot=et===e;if(ot){var mt=Tt(Y),_t=!mt&&Mn(Y),xt=!mt&&!_t&&Si(Y);et=Y,mt||_t||xt?Tt(z)?et=z:be(z)?et=Xe(z):_t?(ot=!1,et=d0(Y,!0)):xt?(ot=!1,et=g0(Y,!0)):et=[]:fs(Y)||Xn(Y)?(et=z,Xn(z)?et=hp(z):(!_e(z)||sn(z))&&(et=$0(Y))):ot=!1}ot&&(L.set(Y,et),A(et,Y,w,T,L),L.delete(Y)),Na(o,m,et)}function i0(o,u){var m=o.length;if(m)return u+=u<0?m:0,nn(u,m)?o[u]:e}function s0(o,u,m){u.length?u=me(u,function(T){return Tt(T)?function(L){return Gn(L,T.length===1?T[0]:T)}:T}):u=[Ve];var w=-1;u=me(u,ar(At()));var A=e0(o,function(T,L,z){var Y=me(u,function(V){return V(T)});return{criteria:Y,index:++w,value:T}});return GD(A,function(T,L){return Tb(T,L,m)})}function yb(o,u){return o0(o,u,function(m,w){return hf(o,w)})}function o0(o,u,m){for(var w=-1,A=u.length,T={};++w<A;){var L=u[w],z=Gn(o,L);m(z,L)&&ss(T,Cn(L,o),z)}return T}function bb(o){return function(u){return Gn(u,o)}}function Pa(o,u,m,w){var A=w?jD:wi,T=-1,L=u.length,z=o;for(o===u&&(u=Xe(u)),m&&(z=me(o,ar(m)));++T<L;)for(var Y=0,V=u[T],et=m?m(V):V;(Y=A(z,et,Y,w))>-1;)z!==o&&Co.call(z,Y,1),Co.call(o,Y,1);return o}function u0(o,u){for(var m=o?u.length:0,w=m-1;m--;){var A=u[m];if(m==w||A!==T){var T=A;nn(A)?Co.call(o,A,1):ka(o,A)}}return o}function za(o,u){return o+No(Uh()*(u-o+1))}function Eb(o,u,m,w){for(var A=-1,T=Be(Mo((u-o)/(m||1)),0),L=X(T);T--;)L[w?T:++A]=o,o+=m;return L}function qa(o,u){var m="";if(!o||u<1||u>j)return m;do u%2&&(m+=o),u=No(u/2),u&&(o+=o);while(u);return m}function Lt(o,u){return nf(L0(o,u,Ve),o+"")}function Ab(o){return Yh(Bi(o))}function xb(o,u){var m=Bi(o);return jo(m,jn(u,0,m.length))}function ss(o,u,m,w){if(!_e(o))return o;u=Cn(u,o);for(var A=-1,T=u.length,L=T-1,z=o;z!=null&&++A<T;){var Y=Zr(u[A]),V=m;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return o;if(A!=L){var et=z[Y];V=w?w(et,Y,z):e,V===e&&(V=_e(et)?et:nn(u[A+1])?[]:{})}es(z,Y,V),z=z[Y]}return o}var a0=So?function(o,u){return So.set(o,u),o}:Ve,Cb=Fo?function(o,u){return Fo(o,"toString",{configurable:!0,enumerable:!1,value:mf(u),writable:!0})}:Ve;function Fb(o){return jo(Bi(o))}function br(o,u,m){var w=-1,A=o.length;u<0&&(u=-u>A?0:A+u),m=m>A?A:m,m<0&&(m+=A),A=u>m?0:m-u>>>0,u>>>=0;for(var T=X(A);++w<A;)T[w]=o[w+u];return T}function Mb(o,u){var m;return An(o,function(w,A,T){return m=u(w,A,T),!m}),!!m}function Lo(o,u,m){var w=0,A=o==null?w:o.length;if(typeof u=="number"&&u===u&&A<=ft){for(;w<A;){var T=w+A>>>1,L=o[T];L!==null&&!lr(L)&&(m?L<=u:L<u)?w=T+1:A=T}return A}return Ua(o,u,Ve,m)}function Ua(o,u,m,w){var A=0,T=o==null?0:o.length;if(T===0)return 0;u=m(u);for(var L=u!==u,z=u===null,Y=lr(u),V=u===e;A<T;){var et=No((A+T)/2),ot=m(o[et]),mt=ot!==e,_t=ot===null,xt=ot===ot,Rt=lr(ot);if(L)var Ct=w||xt;else V?Ct=xt&&(w||mt):z?Ct=xt&&mt&&(w||!_t):Y?Ct=xt&&mt&&!_t&&(w||!Rt):_t||Rt?Ct=!1:Ct=w?ot<=u:ot<u;Ct?A=et+1:T=et}return ke(T,vt)}function f0(o,u){for(var m=-1,w=o.length,A=0,T=[];++m<w;){var L=o[m],z=u?u(L):L;if(!m||!$r(z,Y)){var Y=z;T[A++]=L===0?0:L}}return T}function l0(o){return typeof o=="number"?o:lr(o)?tt:+o}function fr(o){if(typeof o=="string")return o;if(Tt(o))return me(o,fr)+"";if(lr(o))return kh?kh.call(o):"";var u=o+"";return u=="0"&&1/o==-G?"-0":u}function xn(o,u,m){var w=-1,A=go,T=o.length,L=!0,z=[],Y=z;if(m)L=!1,A=ga;else if(T>=n){var V=u?null:zb(o);if(V)return _o(V);L=!1,A=Ji,Y=new Zn}else Y=u?[]:z;t:for(;++w<T;){var et=o[w],ot=u?u(et):et;if(et=m||et!==0?et:0,L&&ot===ot){for(var mt=Y.length;mt--;)if(Y[mt]===ot)continue t;u&&Y.push(ot),z.push(et)}else A(Y,ot,m)||(Y!==z&&Y.push(ot),z.push(et))}return z}function ka(o,u){return u=Cn(u,o),o=P0(o,u),o==null||delete o[Zr(Er(u))]}function c0(o,u,m,w){return ss(o,u,m(Gn(o,u)),w)}function Po(o,u,m,w){for(var A=o.length,T=w?A:-1;(w?T--:++T<A)&&u(o[T],T,o););return m?br(o,w?0:T,w?T+1:A):br(o,w?T+1:0,w?A:T)}function h0(o,u){var m=o;return m instanceof Ut&&(m=m.value()),va(u,function(w,A){return A.func.apply(A.thisArg,yn([w],A.args))},m)}function Wa(o,u,m){var w=o.length;if(w<2)return w?xn(o[0]):[];for(var A=-1,T=X(w);++A<w;)for(var L=o[A],z=-1;++z<w;)z!=A&&(T[A]=rs(T[A]||L,o[z],u,m));return xn(Pe(T,1),u,m)}function p0(o,u,m){for(var w=-1,A=o.length,T=u.length,L={};++w<A;){var z=w<T?u[w]:e;m(L,o[w],z)}return L}function Ya(o){return be(o)?o:[]}function Za(o){return typeof o=="function"?o:Ve}function Cn(o,u){return Tt(o)?o:tf(o,u)?[o]:k0(Vt(o))}var Nb=Lt;function Fn(o,u,m){var w=o.length;return m=m===e?w:m,!u&&m>=w?o:br(o,u,m)}var m0=gy||function(o){return Le.clearTimeout(o)};function d0(o,u){if(u)return o.slice();var m=o.length,w=Rh?Rh(m):new o.constructor(m);return o.copy(w),w}function ja(o){var u=new o.constructor(o.byteLength);return new Ao(u).set(new Ao(o)),u}function Sb(o,u){var m=u?ja(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.byteLength)}function Bb(o){var u=new o.constructor(o.source,ho.exec(o));return u.lastIndex=o.lastIndex,u}function Ib(o){return ts?ue(ts.call(o)):{}}function g0(o,u){var m=u?ja(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.length)}function v0(o,u){if(o!==u){var m=o!==e,w=o===null,A=o===o,T=lr(o),L=u!==e,z=u===null,Y=u===u,V=lr(u);if(!z&&!V&&!T&&o>u||T&&L&&Y&&!z&&!V||w&&L&&Y||!m&&Y||!A)return 1;if(!w&&!T&&!V&&o<u||V&&m&&A&&!w&&!T||z&&m&&A||!L&&A||!Y)return-1}return 0}function Tb(o,u,m){for(var w=-1,A=o.criteria,T=u.criteria,L=A.length,z=m.length;++w<L;){var Y=v0(A[w],T[w]);if(Y){if(w>=z)return Y;var V=m[w];return Y*(V=="desc"?-1:1)}}return o.index-u.index}function _0(o,u,m,w){for(var A=-1,T=o.length,L=m.length,z=-1,Y=u.length,V=Be(T-L,0),et=X(Y+V),ot=!w;++z<Y;)et[z]=u[z];for(;++A<L;)(ot||A<T)&&(et[m[A]]=o[A]);for(;V--;)et[z++]=o[A++];return et}function w0(o,u,m,w){for(var A=-1,T=o.length,L=-1,z=m.length,Y=-1,V=u.length,et=Be(T-z,0),ot=X(et+V),mt=!w;++A<et;)ot[A]=o[A];for(var _t=A;++Y<V;)ot[_t+Y]=u[Y];for(;++L<z;)(mt||A<T)&&(ot[_t+m[L]]=o[A++]);return ot}function Xe(o,u){var m=-1,w=o.length;for(u||(u=X(w));++m<w;)u[m]=o[m];return u}function Yr(o,u,m,w){var A=!m;m||(m={});for(var T=-1,L=u.length;++T<L;){var z=u[T],Y=w?w(m[z],o[z],z,m,o):e;Y===e&&(Y=o[z]),A?tn(m,z,Y):es(m,z,Y)}return m}function $b(o,u){return Yr(o,Va(o),u)}function Ob(o,u){return Yr(o,I0(o),u)}function zo(o,u){return function(m,w){var A=Tt(m)?qD:nb,T=u?u():{};return A(m,o,At(w,2),T)}}function Fi(o){return Lt(function(u,m){var w=-1,A=m.length,T=A>1?m[A-1]:e,L=A>2?m[2]:e;for(T=o.length>3&&typeof T=="function"?(A--,T):e,L&&Ze(m[0],m[1],L)&&(T=A<3?e:T,A=1),u=ue(u);++w<A;){var z=m[w];z&&o(u,z,w,T)}return u})}function D0(o,u){return function(m,w){if(m==null)return m;if(!He(m))return o(m,w);for(var A=m.length,T=u?A:-1,L=ue(m);(u?T--:++T<A)&&w(L[T],T,L)!==!1;);return m}}function y0(o){return function(u,m,w){for(var A=-1,T=ue(u),L=w(u),z=L.length;z--;){var Y=L[o?z:++A];if(m(T[Y],Y,T)===!1)break}return u}}function Rb(o,u,m){var w=u&y,A=os(o);function T(){var L=this&&this!==Le&&this instanceof T?A:o;return L.apply(w?m:this,arguments)}return T}function b0(o){return function(u){u=Vt(u);var m=Di(u)?Ir(u):e,w=m?m[0]:u.charAt(0),A=m?Fn(m,1).join(""):u.slice(1);return w[o]()+A}}function Mi(o){return function(u){return va(Dp(wp(u).replace(CD,"")),o,"")}}function os(o){return function(){var u=arguments;switch(u.length){case 0:return new o;case 1:return new o(u[0]);case 2:return new o(u[0],u[1]);case 3:return new o(u[0],u[1],u[2]);case 4:return new o(u[0],u[1],u[2],u[3]);case 5:return new o(u[0],u[1],u[2],u[3],u[4]);case 6:return new o(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new o(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var m=Ci(o.prototype),w=o.apply(m,u);return _e(w)?w:m}}function Lb(o,u,m){var w=os(o);function A(){for(var T=arguments.length,L=X(T),z=T,Y=Ni(A);z--;)L[z]=arguments[z];var V=T<3&&L[0]!==Y&&L[T-1]!==Y?[]:bn(L,Y);if(T-=V.length,T<m)return F0(o,u,qo,A.placeholder,e,L,V,e,e,m-T);var et=this&&this!==Le&&this instanceof A?w:o;return ur(et,this,L)}return A}function E0(o){return function(u,m,w){var A=ue(u);if(!He(u)){var T=At(m,3);u=$e(u),m=function(z){return T(A[z],z,A)}}var L=o(u,m,w);return L>-1?A[T?u[L]:L]:e}}function A0(o){return rn(function(u){var m=u.length,w=m,A=Dr.prototype.thru;for(o&&u.reverse();w--;){var T=u[w];if(typeof T!="function")throw new wr(a);if(A&&!L&&Yo(T)=="wrapper")var L=new Dr([],!0)}for(w=L?w:m;++w<m;){T=u[w];var z=Yo(T),Y=z=="wrapper"?Ha(T):e;Y&&ef(Y[0])&&Y[1]==(M|b|x|S)&&!Y[4].length&&Y[9]==1?L=L[Yo(Y[0])].apply(L,Y[3]):L=T.length==1&&ef(T)?L[z]():L.thru(T)}return function(){var V=arguments,et=V[0];if(L&&V.length==1&&Tt(et))return L.plant(et).value();for(var ot=0,mt=m?u[ot].apply(this,V):et;++ot<m;)mt=u[ot].call(this,mt);return mt}})}function qo(o,u,m,w,A,T,L,z,Y,V){var et=u&M,ot=u&y,mt=u&v,_t=u&(b|N),xt=u&$,Rt=mt?e:os(o);function Ct(){for(var qt=arguments.length,kt=X(qt),cr=qt;cr--;)kt[cr]=arguments[cr];if(_t)var je=Ni(Ct),hr=JD(kt,je);if(w&&(kt=_0(kt,w,A,_t)),T&&(kt=w0(kt,T,L,_t)),qt-=hr,_t&&qt<V){var Ee=bn(kt,je);return F0(o,u,qo,Ct.placeholder,m,kt,Ee,z,Y,V-qt)}var Or=ot?m:this,un=mt?Or[o]:o;return qt=kt.length,z?kt=nE(kt,z):xt&&qt>1&&kt.reverse(),et&&Y<qt&&(kt.length=Y),this&&this!==Le&&this instanceof Ct&&(un=Rt||os(un)),un.apply(Or,kt)}return Ct}function x0(o,u){return function(m,w){return cb(m,o,u(w),{})}}function Uo(o,u){return function(m,w){var A;if(m===e&&w===e)return u;if(m!==e&&(A=m),w!==e){if(A===e)return w;typeof m=="string"||typeof w=="string"?(m=fr(m),w=fr(w)):(m=l0(m),w=l0(w)),A=o(m,w)}return A}}function Ga(o){return rn(function(u){return u=me(u,ar(At())),Lt(function(m){var w=this;return o(u,function(A){return ur(A,w,m)})})})}function ko(o,u){u=u===e?" ":fr(u);var m=u.length;if(m<2)return m?qa(u,o):u;var w=qa(u,Mo(o/yi(u)));return Di(u)?Fn(Ir(w),0,o).join(""):w.slice(0,o)}function Pb(o,u,m,w){var A=u&y,T=os(o);function L(){for(var z=-1,Y=arguments.length,V=-1,et=w.length,ot=X(et+Y),mt=this&&this!==Le&&this instanceof L?T:o;++V<et;)ot[V]=w[V];for(;Y--;)ot[V++]=arguments[++z];return ur(mt,A?m:this,ot)}return L}function C0(o){return function(u,m,w){return w&&typeof w!="number"&&Ze(u,m,w)&&(m=w=e),u=on(u),m===e?(m=u,u=0):m=on(m),w=w===e?u<m?1:-1:on(w),Eb(u,m,w,o)}}function Wo(o){return function(u,m){return typeof u=="string"&&typeof m=="string"||(u=Ar(u),m=Ar(m)),o(u,m)}}function F0(o,u,m,w,A,T,L,z,Y,V){var et=u&b,ot=et?L:e,mt=et?e:L,_t=et?T:e,xt=et?e:T;u|=et?x:F,u&=~(et?F:x),u&E||(u&=~(y|v));var Rt=[o,u,A,_t,ot,xt,mt,z,Y,V],Ct=m.apply(e,Rt);return ef(o)&&z0(Ct,Rt),Ct.placeholder=w,q0(Ct,o,u)}function Ka(o){var u=Se[o];return function(m,w){if(m=Ar(m),w=w==null?0:ke(Ot(w),292),w&&qh(m)){var A=(Vt(m)+"e").split("e"),T=u(A[0]+"e"+(+A[1]+w));return A=(Vt(T)+"e").split("e"),+(A[0]+"e"+(+A[1]-w))}return u(m)}}var zb=Ai&&1/_o(new Ai([,-0]))[1]==G?function(o){return new Ai(o)}:vf;function M0(o){return function(u){var m=We(u);return m==Gt?Aa(u):m==ir?ry(u):KD(u,o(u))}}function en(o,u,m,w,A,T,L,z){var Y=u&v;if(!Y&&typeof o!="function")throw new wr(a);var V=w?w.length:0;if(V||(u&=~(x|F),w=A=e),L=L===e?L:Be(Ot(L),0),z=z===e?z:Ot(z),V-=A?A.length:0,u&F){var et=w,ot=A;w=A=e}var mt=Y?e:Ha(o),_t=[o,u,m,w,A,et,ot,T,L,z];if(mt&&tE(_t,mt),o=_t[0],u=_t[1],m=_t[2],w=_t[3],A=_t[4],z=_t[9]=_t[9]===e?Y?0:o.length:Be(_t[9]-V,0),!z&&u&(b|N)&&(u&=~(b|N)),!u||u==y)var xt=Rb(o,u,m);else u==b||u==N?xt=Lb(o,u,z):(u==x||u==(y|x))&&!A.length?xt=Pb(o,u,m,w):xt=qo.apply(e,_t);var Rt=mt?a0:z0;return q0(Rt(xt,_t),o,u)}function N0(o,u,m,w){return o===e||$r(o,Ei[m])&&!re.call(w,m)?u:o}function S0(o,u,m,w,A,T){return _e(o)&&_e(u)&&(T.set(u,o),Ro(o,u,e,S0,T),T.delete(u)),o}function qb(o){return fs(o)?e:o}function B0(o,u,m,w,A,T){var L=m&D,z=o.length,Y=u.length;if(z!=Y&&!(L&&Y>z))return!1;var V=T.get(o),et=T.get(u);if(V&&et)return V==u&&et==o;var ot=-1,mt=!0,_t=m&g?new Zn:e;for(T.set(o,u),T.set(u,o);++ot<z;){var xt=o[ot],Rt=u[ot];if(w)var Ct=L?w(Rt,xt,ot,u,o,T):w(xt,Rt,ot,o,u,T);if(Ct!==e){if(Ct)continue;mt=!1;break}if(_t){if(!_a(u,function(qt,kt){if(!Ji(_t,kt)&&(xt===qt||A(xt,qt,m,w,T)))return _t.push(kt)})){mt=!1;break}}else if(!(xt===Rt||A(xt,Rt,m,w,T))){mt=!1;break}}return T.delete(o),T.delete(u),mt}function Ub(o,u,m,w,A,T,L){switch(m){case rt:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case st:return!(o.byteLength!=u.byteLength||!T(new Ao(o),new Ao(u)));case ee:case It:case Ce:return $r(+o,+u);case ie:return o.name==u.name&&o.message==u.message;case Hr:case vn:return o==u+"";case Gt:var z=Aa;case ir:var Y=w&D;if(z||(z=_o),o.size!=u.size&&!Y)return!1;var V=L.get(o);if(V)return V==u;w|=g,L.set(o,u);var et=B0(z(o),z(u),w,A,T,L);return L.delete(o),et;case O:if(ts)return ts.call(o)==ts.call(u)}return!1}function kb(o,u,m,w,A,T){var L=m&D,z=Ja(o),Y=z.length,V=Ja(u),et=V.length;if(Y!=et&&!L)return!1;for(var ot=Y;ot--;){var mt=z[ot];if(!(L?mt in u:re.call(u,mt)))return!1}var _t=T.get(o),xt=T.get(u);if(_t&&xt)return _t==u&&xt==o;var Rt=!0;T.set(o,u),T.set(u,o);for(var Ct=L;++ot<Y;){mt=z[ot];var qt=o[mt],kt=u[mt];if(w)var cr=L?w(kt,qt,mt,u,o,T):w(qt,kt,mt,o,u,T);if(!(cr===e?qt===kt||A(qt,kt,m,w,T):cr)){Rt=!1;break}Ct||(Ct=mt=="constructor")}if(Rt&&!Ct){var je=o.constructor,hr=u.constructor;je!=hr&&"constructor"in o&&"constructor"in u&&!(typeof je=="function"&&je instanceof je&&typeof hr=="function"&&hr instanceof hr)&&(Rt=!1)}return T.delete(o),T.delete(u),Rt}function rn(o){return nf(L0(o,e,j0),o+"")}function Ja(o){return Hh(o,$e,Va)}function Xa(o){return Hh(o,Qe,I0)}var Ha=So?function(o){return So.get(o)}:vf;function Yo(o){for(var u=o.name+"",m=xi[u],w=re.call(xi,u)?m.length:0;w--;){var A=m[w],T=A.func;if(T==null||T==o)return A.name}return u}function Ni(o){var u=re.call(B,"placeholder")?B:o;return u.placeholder}function At(){var o=B.iteratee||df;return o=o===df?t0:o,arguments.length?o(arguments[0],arguments[1]):o}function Zo(o,u){var m=o.__data__;return Xb(u)?m[typeof u=="string"?"string":"hash"]:m.map}function Qa(o){for(var u=$e(o),m=u.length;m--;){var w=u[m],A=o[w];u[m]=[w,A,O0(A)]}return u}function Kn(o,u){var m=VD(o,u);return Vh(m)?m:e}function Wb(o){var u=re.call(o,Wn),m=o[Wn];try{o[Wn]=e;var w=!0}catch{}var A=bo.call(o);return w&&(u?o[Wn]=m:delete o[Wn]),A}var Va=Ca?function(o){return o==null?[]:(o=ue(o),Dn(Ca(o),function(u){return Ph.call(o,u)}))}:_f,I0=Ca?function(o){for(var u=[];o;)yn(u,Va(o)),o=xo(o);return u}:_f,We=Ye;(Fa&&We(new Fa(new ArrayBuffer(1)))!=rt||Hi&&We(new Hi)!=Gt||Ma&&We(Ma.resolve())!=Xr||Ai&&We(new Ai)!=ir||Qi&&We(new Qi)!=J)&&(We=function(o){var u=Ye(o),m=u==Me?o.constructor:e,w=m?Jn(m):"";if(w)switch(w){case xy:return rt;case Cy:return Gt;case Fy:return Xr;case My:return ir;case Ny:return J}return u});function Yb(o,u,m){for(var w=-1,A=m.length;++w<A;){var T=m[w],L=T.size;switch(T.type){case"drop":o+=L;break;case"dropRight":u-=L;break;case"take":u=ke(u,o+L);break;case"takeRight":o=Be(o,u-L);break}}return{start:o,end:u}}function Zb(o){var u=o.match(Xu);return u?u[1].split(Hu):[]}function T0(o,u,m){u=Cn(u,o);for(var w=-1,A=u.length,T=!1;++w<A;){var L=Zr(u[w]);if(!(T=o!=null&&m(o,L)))break;o=o[L]}return T||++w!=A?T:(A=o==null?0:o.length,!!A&&Qo(A)&&nn(L,A)&&(Tt(o)||Xn(o)))}function jb(o){var u=o.length,m=new o.constructor(u);return u&&typeof o[0]=="string"&&re.call(o,"index")&&(m.index=o.index,m.input=o.input),m}function $0(o){return typeof o.constructor=="function"&&!us(o)?Ci(xo(o)):{}}function Gb(o,u,m){var w=o.constructor;switch(u){case st:return ja(o);case ee:case It:return new w(+o);case rt:return Sb(o,m);case ct:case at:case ht:case ut:case Kt:case Qt:case pe:case Te:case Ne:return g0(o,m);case Gt:return new w;case Ce:case vn:return new w(o);case Hr:return Bb(o);case ir:return new w;case O:return Ib(o)}}function Kb(o,u){var m=u.length;if(!m)return o;var w=m-1;return u[w]=(m>1?"& ":"")+u[w],u=u.join(m>2?", ":" "),o.replace(Ju,`{
9
+ /* [wrapped with `+u+`] */
10
+ `)}function Jb(o){return Tt(o)||Xn(o)||!!(zh&&o&&o[zh])}function nn(o,u){var m=typeof o;return u=u??j,!!u&&(m=="number"||m!="symbol"&&oa.test(o))&&o>-1&&o%1==0&&o<u}function Ze(o,u,m){if(!_e(m))return!1;var w=typeof u;return(w=="number"?He(m)&&nn(u,m.length):w=="string"&&u in m)?$r(m[u],o):!1}function tf(o,u){if(Tt(o))return!1;var m=typeof o;return m=="number"||m=="symbol"||m=="boolean"||o==null||lr(o)?!0:Zu.test(o)||!Yu.test(o)||u!=null&&o in ue(u)}function Xb(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function ef(o){var u=Yo(o),m=B[u];if(typeof m!="function"||!(u in Ut.prototype))return!1;if(o===m)return!0;var w=Ha(m);return!!w&&o===w[0]}function Hb(o){return!!Oh&&Oh in o}var Qb=Do?sn:wf;function us(o){var u=o&&o.constructor,m=typeof u=="function"&&u.prototype||Ei;return o===m}function O0(o){return o===o&&!_e(o)}function R0(o,u){return function(m){return m==null?!1:m[o]===u&&(u!==e||o in ue(m))}}function Vb(o){var u=Xo(o,function(w){return m.size===p&&m.clear(),w}),m=u.cache;return u}function tE(o,u){var m=o[1],w=u[1],A=m|w,T=A<(y|v|M),L=w==M&&m==b||w==M&&m==S&&o[7].length<=u[8]||w==(M|S)&&u[7].length<=u[8]&&m==b;if(!(T||L))return o;w&y&&(o[2]=u[2],A|=m&y?0:E);var z=u[3];if(z){var Y=o[3];o[3]=Y?_0(Y,z,u[4]):z,o[4]=Y?bn(o[3],h):u[4]}return z=u[5],z&&(Y=o[5],o[5]=Y?w0(Y,z,u[6]):z,o[6]=Y?bn(o[5],h):u[6]),z=u[7],z&&(o[7]=z),w&M&&(o[8]=o[8]==null?u[8]:ke(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=A,o}function eE(o){var u=[];if(o!=null)for(var m in ue(o))u.push(m);return u}function rE(o){return bo.call(o)}function L0(o,u,m){return u=Be(u===e?o.length-1:u,0),function(){for(var w=arguments,A=-1,T=Be(w.length-u,0),L=X(T);++A<T;)L[A]=w[u+A];A=-1;for(var z=X(u+1);++A<u;)z[A]=w[A];return z[u]=m(L),ur(o,this,z)}}function P0(o,u){return u.length<2?o:Gn(o,br(u,0,-1))}function nE(o,u){for(var m=o.length,w=ke(u.length,m),A=Xe(o);w--;){var T=u[w];o[w]=nn(T,m)?A[T]:e}return o}function rf(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var z0=U0(a0),as=_y||function(o,u){return Le.setTimeout(o,u)},nf=U0(Cb);function q0(o,u,m){var w=u+"";return nf(o,Kb(w,iE(Zb(w),m)))}function U0(o){var u=0,m=0;return function(){var w=by(),A=U-(w-m);if(m=w,A>0){if(++u>=R)return arguments[0]}else u=0;return o.apply(e,arguments)}}function jo(o,u){var m=-1,w=o.length,A=w-1;for(u=u===e?w:u;++m<u;){var T=za(m,A),L=o[T];o[T]=o[m],o[m]=L}return o.length=u,o}var k0=Vb(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(ju,function(m,w,A,T){u.push(A?T.replace(ta,"$1"):w||m)}),u});function Zr(o){if(typeof o=="string"||lr(o))return o;var u=o+"";return u=="0"&&1/o==-G?"-0":u}function Jn(o){if(o!=null){try{return yo.call(o)}catch{}try{return o+""}catch{}}return""}function iE(o,u){return _r(wt,function(m){var w="_."+m[0];u&m[1]&&!go(o,w)&&o.push(w)}),o.sort()}function W0(o){if(o instanceof Ut)return o.clone();var u=new Dr(o.__wrapped__,o.__chain__);return u.__actions__=Xe(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function sE(o,u,m){(m?Ze(o,u,m):u===e)?u=1:u=Be(Ot(u),0);var w=o==null?0:o.length;if(!w||u<1)return[];for(var A=0,T=0,L=X(Mo(w/u));A<w;)L[T++]=br(o,A,A+=u);return L}function oE(o){for(var u=-1,m=o==null?0:o.length,w=0,A=[];++u<m;){var T=o[u];T&&(A[w++]=T)}return A}function uE(){var o=arguments.length;if(!o)return[];for(var u=X(o-1),m=arguments[0],w=o;w--;)u[w-1]=arguments[w];return yn(Tt(m)?Xe(m):[m],Pe(u,1))}var aE=Lt(function(o,u){return be(o)?rs(o,Pe(u,1,be,!0)):[]}),fE=Lt(function(o,u){var m=Er(u);return be(m)&&(m=e),be(o)?rs(o,Pe(u,1,be,!0),At(m,2)):[]}),lE=Lt(function(o,u){var m=Er(u);return be(m)&&(m=e),be(o)?rs(o,Pe(u,1,be,!0),e,m):[]});function cE(o,u,m){var w=o==null?0:o.length;return w?(u=m||u===e?1:Ot(u),br(o,u<0?0:u,w)):[]}function hE(o,u,m){var w=o==null?0:o.length;return w?(u=m||u===e?1:Ot(u),u=w-u,br(o,0,u<0?0:u)):[]}function pE(o,u){return o&&o.length?Po(o,At(u,3),!0,!0):[]}function mE(o,u){return o&&o.length?Po(o,At(u,3),!0):[]}function dE(o,u,m,w){var A=o==null?0:o.length;return A?(m&&typeof m!="number"&&Ze(o,u,m)&&(m=0,w=A),ub(o,u,m,w)):[]}function Y0(o,u,m){var w=o==null?0:o.length;if(!w)return-1;var A=m==null?0:Ot(m);return A<0&&(A=Be(w+A,0)),vo(o,At(u,3),A)}function Z0(o,u,m){var w=o==null?0:o.length;if(!w)return-1;var A=w-1;return m!==e&&(A=Ot(m),A=m<0?Be(w+A,0):ke(A,w-1)),vo(o,At(u,3),A,!0)}function j0(o){var u=o==null?0:o.length;return u?Pe(o,1):[]}function gE(o){var u=o==null?0:o.length;return u?Pe(o,G):[]}function vE(o,u){var m=o==null?0:o.length;return m?(u=u===e?1:Ot(u),Pe(o,u)):[]}function _E(o){for(var u=-1,m=o==null?0:o.length,w={};++u<m;){var A=o[u];w[A[0]]=A[1]}return w}function G0(o){return o&&o.length?o[0]:e}function wE(o,u,m){var w=o==null?0:o.length;if(!w)return-1;var A=m==null?0:Ot(m);return A<0&&(A=Be(w+A,0)),wi(o,u,A)}function DE(o){var u=o==null?0:o.length;return u?br(o,0,-1):[]}var yE=Lt(function(o){var u=me(o,Ya);return u.length&&u[0]===o[0]?$a(u):[]}),bE=Lt(function(o){var u=Er(o),m=me(o,Ya);return u===Er(m)?u=e:m.pop(),m.length&&m[0]===o[0]?$a(m,At(u,2)):[]}),EE=Lt(function(o){var u=Er(o),m=me(o,Ya);return u=typeof u=="function"?u:e,u&&m.pop(),m.length&&m[0]===o[0]?$a(m,e,u):[]});function AE(o,u){return o==null?"":Dy.call(o,u)}function Er(o){var u=o==null?0:o.length;return u?o[u-1]:e}function xE(o,u,m){var w=o==null?0:o.length;if(!w)return-1;var A=w;return m!==e&&(A=Ot(m),A=A<0?Be(w+A,0):ke(A,w-1)),u===u?iy(o,u,A):vo(o,Fh,A,!0)}function CE(o,u){return o&&o.length?i0(o,Ot(u)):e}var FE=Lt(K0);function K0(o,u){return o&&o.length&&u&&u.length?Pa(o,u):o}function ME(o,u,m){return o&&o.length&&u&&u.length?Pa(o,u,At(m,2)):o}function NE(o,u,m){return o&&o.length&&u&&u.length?Pa(o,u,e,m):o}var SE=rn(function(o,u){var m=o==null?0:o.length,w=Sa(o,u);return u0(o,me(u,function(A){return nn(A,m)?+A:A}).sort(v0)),w});function BE(o,u){var m=[];if(!(o&&o.length))return m;var w=-1,A=[],T=o.length;for(u=At(u,3);++w<T;){var L=o[w];u(L,w,o)&&(m.push(L),A.push(w))}return u0(o,A),m}function sf(o){return o==null?o:Ay.call(o)}function IE(o,u,m){var w=o==null?0:o.length;return w?(m&&typeof m!="number"&&Ze(o,u,m)?(u=0,m=w):(u=u==null?0:Ot(u),m=m===e?w:Ot(m)),br(o,u,m)):[]}function TE(o,u){return Lo(o,u)}function $E(o,u,m){return Ua(o,u,At(m,2))}function OE(o,u){var m=o==null?0:o.length;if(m){var w=Lo(o,u);if(w<m&&$r(o[w],u))return w}return-1}function RE(o,u){return Lo(o,u,!0)}function LE(o,u,m){return Ua(o,u,At(m,2),!0)}function PE(o,u){var m=o==null?0:o.length;if(m){var w=Lo(o,u,!0)-1;if($r(o[w],u))return w}return-1}function zE(o){return o&&o.length?f0(o):[]}function qE(o,u){return o&&o.length?f0(o,At(u,2)):[]}function UE(o){var u=o==null?0:o.length;return u?br(o,1,u):[]}function kE(o,u,m){return o&&o.length?(u=m||u===e?1:Ot(u),br(o,0,u<0?0:u)):[]}function WE(o,u,m){var w=o==null?0:o.length;return w?(u=m||u===e?1:Ot(u),u=w-u,br(o,u<0?0:u,w)):[]}function YE(o,u){return o&&o.length?Po(o,At(u,3),!1,!0):[]}function ZE(o,u){return o&&o.length?Po(o,At(u,3)):[]}var jE=Lt(function(o){return xn(Pe(o,1,be,!0))}),GE=Lt(function(o){var u=Er(o);return be(u)&&(u=e),xn(Pe(o,1,be,!0),At(u,2))}),KE=Lt(function(o){var u=Er(o);return u=typeof u=="function"?u:e,xn(Pe(o,1,be,!0),e,u)});function JE(o){return o&&o.length?xn(o):[]}function XE(o,u){return o&&o.length?xn(o,At(u,2)):[]}function HE(o,u){return u=typeof u=="function"?u:e,o&&o.length?xn(o,e,u):[]}function of(o){if(!(o&&o.length))return[];var u=0;return o=Dn(o,function(m){if(be(m))return u=Be(m.length,u),!0}),ba(u,function(m){return me(o,wa(m))})}function J0(o,u){if(!(o&&o.length))return[];var m=of(o);return u==null?m:me(m,function(w){return ur(u,e,w)})}var QE=Lt(function(o,u){return be(o)?rs(o,u):[]}),VE=Lt(function(o){return Wa(Dn(o,be))}),tA=Lt(function(o){var u=Er(o);return be(u)&&(u=e),Wa(Dn(o,be),At(u,2))}),eA=Lt(function(o){var u=Er(o);return u=typeof u=="function"?u:e,Wa(Dn(o,be),e,u)}),rA=Lt(of);function nA(o,u){return p0(o||[],u||[],es)}function iA(o,u){return p0(o||[],u||[],ss)}var sA=Lt(function(o){var u=o.length,m=u>1?o[u-1]:e;return m=typeof m=="function"?(o.pop(),m):e,J0(o,m)});function X0(o){var u=B(o);return u.__chain__=!0,u}function oA(o,u){return u(o),o}function Go(o,u){return u(o)}var uA=rn(function(o){var u=o.length,m=u?o[0]:0,w=this.__wrapped__,A=function(T){return Sa(T,o)};return u>1||this.__actions__.length||!(w instanceof Ut)||!nn(m)?this.thru(A):(w=w.slice(m,+m+(u?1:0)),w.__actions__.push({func:Go,args:[A],thisArg:e}),new Dr(w,this.__chain__).thru(function(T){return u&&!T.length&&T.push(e),T}))});function aA(){return X0(this)}function fA(){return new Dr(this.value(),this.__chain__)}function lA(){this.__values__===e&&(this.__values__=lp(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function cA(){return this}function hA(o){for(var u,m=this;m instanceof Io;){var w=W0(m);w.__index__=0,w.__values__=e,u?A.__wrapped__=w:u=w;var A=w;m=m.__wrapped__}return A.__wrapped__=o,u}function pA(){var o=this.__wrapped__;if(o instanceof Ut){var u=o;return this.__actions__.length&&(u=new Ut(this)),u=u.reverse(),u.__actions__.push({func:Go,args:[sf],thisArg:e}),new Dr(u,this.__chain__)}return this.thru(sf)}function mA(){return h0(this.__wrapped__,this.__actions__)}var dA=zo(function(o,u,m){re.call(o,m)?++o[m]:tn(o,m,1)});function gA(o,u,m){var w=Tt(o)?xh:ob;return m&&Ze(o,u,m)&&(u=e),w(o,At(u,3))}function vA(o,u){var m=Tt(o)?Dn:Jh;return m(o,At(u,3))}var _A=E0(Y0),wA=E0(Z0);function DA(o,u){return Pe(Ko(o,u),1)}function yA(o,u){return Pe(Ko(o,u),G)}function bA(o,u,m){return m=m===e?1:Ot(m),Pe(Ko(o,u),m)}function H0(o,u){var m=Tt(o)?_r:An;return m(o,At(u,3))}function Q0(o,u){var m=Tt(o)?UD:Kh;return m(o,At(u,3))}var EA=zo(function(o,u,m){re.call(o,m)?o[m].push(u):tn(o,m,[u])});function AA(o,u,m,w){o=He(o)?o:Bi(o),m=m&&!w?Ot(m):0;var A=o.length;return m<0&&(m=Be(A+m,0)),Vo(o)?m<=A&&o.indexOf(u,m)>-1:!!A&&wi(o,u,m)>-1}var xA=Lt(function(o,u,m){var w=-1,A=typeof u=="function",T=He(o)?X(o.length):[];return An(o,function(L){T[++w]=A?ur(u,L,m):ns(L,u,m)}),T}),CA=zo(function(o,u,m){tn(o,m,u)});function Ko(o,u){var m=Tt(o)?me:e0;return m(o,At(u,3))}function FA(o,u,m,w){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),m=w?e:m,Tt(m)||(m=m==null?[]:[m]),s0(o,u,m))}var MA=zo(function(o,u,m){o[m?0:1].push(u)},function(){return[[],[]]});function NA(o,u,m){var w=Tt(o)?va:Nh,A=arguments.length<3;return w(o,At(u,4),m,A,An)}function SA(o,u,m){var w=Tt(o)?kD:Nh,A=arguments.length<3;return w(o,At(u,4),m,A,Kh)}function BA(o,u){var m=Tt(o)?Dn:Jh;return m(o,Ho(At(u,3)))}function IA(o){var u=Tt(o)?Yh:Ab;return u(o)}function TA(o,u,m){(m?Ze(o,u,m):u===e)?u=1:u=Ot(u);var w=Tt(o)?eb:xb;return w(o,u)}function $A(o){var u=Tt(o)?rb:Fb;return u(o)}function OA(o){if(o==null)return 0;if(He(o))return Vo(o)?yi(o):o.length;var u=We(o);return u==Gt||u==ir?o.size:Ra(o).length}function RA(o,u,m){var w=Tt(o)?_a:Mb;return m&&Ze(o,u,m)&&(u=e),w(o,At(u,3))}var LA=Lt(function(o,u){if(o==null)return[];var m=u.length;return m>1&&Ze(o,u[0],u[1])?u=[]:m>2&&Ze(u[0],u[1],u[2])&&(u=[u[0]]),s0(o,Pe(u,1),[])}),Jo=vy||function(){return Le.Date.now()};function PA(o,u){if(typeof u!="function")throw new wr(a);return o=Ot(o),function(){if(--o<1)return u.apply(this,arguments)}}function V0(o,u,m){return u=m?e:u,u=o&&u==null?o.length:u,en(o,M,e,e,e,e,u)}function tp(o,u){var m;if(typeof u!="function")throw new wr(a);return o=Ot(o),function(){return--o>0&&(m=u.apply(this,arguments)),o<=1&&(u=e),m}}var uf=Lt(function(o,u,m){var w=y;if(m.length){var A=bn(m,Ni(uf));w|=x}return en(o,w,u,m,A)}),ep=Lt(function(o,u,m){var w=y|v;if(m.length){var A=bn(m,Ni(ep));w|=x}return en(u,w,o,m,A)});function rp(o,u,m){u=m?e:u;var w=en(o,b,e,e,e,e,e,u);return w.placeholder=rp.placeholder,w}function np(o,u,m){u=m?e:u;var w=en(o,N,e,e,e,e,e,u);return w.placeholder=np.placeholder,w}function ip(o,u,m){var w,A,T,L,z,Y,V=0,et=!1,ot=!1,mt=!0;if(typeof o!="function")throw new wr(a);u=Ar(u)||0,_e(m)&&(et=!!m.leading,ot="maxWait"in m,T=ot?Be(Ar(m.maxWait)||0,u):T,mt="trailing"in m?!!m.trailing:mt);function _t(Ee){var Or=w,un=A;return w=A=e,V=Ee,L=o.apply(un,Or),L}function xt(Ee){return V=Ee,z=as(qt,u),et?_t(Ee):L}function Rt(Ee){var Or=Ee-Y,un=Ee-V,Ep=u-Or;return ot?ke(Ep,T-un):Ep}function Ct(Ee){var Or=Ee-Y,un=Ee-V;return Y===e||Or>=u||Or<0||ot&&un>=T}function qt(){var Ee=Jo();if(Ct(Ee))return kt(Ee);z=as(qt,Rt(Ee))}function kt(Ee){return z=e,mt&&w?_t(Ee):(w=A=e,L)}function cr(){z!==e&&m0(z),V=0,w=Y=A=z=e}function je(){return z===e?L:kt(Jo())}function hr(){var Ee=Jo(),Or=Ct(Ee);if(w=arguments,A=this,Y=Ee,Or){if(z===e)return xt(Y);if(ot)return m0(z),z=as(qt,u),_t(Y)}return z===e&&(z=as(qt,u)),L}return hr.cancel=cr,hr.flush=je,hr}var zA=Lt(function(o,u){return Gh(o,1,u)}),qA=Lt(function(o,u,m){return Gh(o,Ar(u)||0,m)});function UA(o){return en(o,$)}function Xo(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new wr(a);var m=function(){var w=arguments,A=u?u.apply(this,w):w[0],T=m.cache;if(T.has(A))return T.get(A);var L=o.apply(this,w);return m.cache=T.set(A,L)||T,L};return m.cache=new(Xo.Cache||Vr),m}Xo.Cache=Vr;function Ho(o){if(typeof o!="function")throw new wr(a);return function(){var u=arguments;switch(u.length){case 0:return!o.call(this);case 1:return!o.call(this,u[0]);case 2:return!o.call(this,u[0],u[1]);case 3:return!o.call(this,u[0],u[1],u[2])}return!o.apply(this,u)}}function kA(o){return tp(2,o)}var WA=Nb(function(o,u){u=u.length==1&&Tt(u[0])?me(u[0],ar(At())):me(Pe(u,1),ar(At()));var m=u.length;return Lt(function(w){for(var A=-1,T=ke(w.length,m);++A<T;)w[A]=u[A].call(this,w[A]);return ur(o,this,w)})}),af=Lt(function(o,u){var m=bn(u,Ni(af));return en(o,x,e,u,m)}),sp=Lt(function(o,u){var m=bn(u,Ni(sp));return en(o,F,e,u,m)}),YA=rn(function(o,u){return en(o,S,e,e,e,u)});function ZA(o,u){if(typeof o!="function")throw new wr(a);return u=u===e?u:Ot(u),Lt(o,u)}function jA(o,u){if(typeof o!="function")throw new wr(a);return u=u==null?0:Be(Ot(u),0),Lt(function(m){var w=m[u],A=Fn(m,0,u);return w&&yn(A,w),ur(o,this,A)})}function GA(o,u,m){var w=!0,A=!0;if(typeof o!="function")throw new wr(a);return _e(m)&&(w="leading"in m?!!m.leading:w,A="trailing"in m?!!m.trailing:A),ip(o,u,{leading:w,maxWait:u,trailing:A})}function KA(o){return V0(o,1)}function JA(o,u){return af(Za(u),o)}function XA(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function HA(o){return yr(o,_)}function QA(o,u){return u=typeof u=="function"?u:e,yr(o,_,u)}function VA(o){return yr(o,c|_)}function tx(o,u){return u=typeof u=="function"?u:e,yr(o,c|_,u)}function ex(o,u){return u==null||jh(o,u,$e(u))}function $r(o,u){return o===u||o!==o&&u!==u}var rx=Wo(Ta),nx=Wo(function(o,u){return o>=u}),Xn=Qh(function(){return arguments}())?Qh:function(o){return we(o)&&re.call(o,"callee")&&!Ph.call(o,"callee")},Tt=X.isArray,ix=wh?ar(wh):hb;function He(o){return o!=null&&Qo(o.length)&&!sn(o)}function be(o){return we(o)&&He(o)}function sx(o){return o===!0||o===!1||we(o)&&Ye(o)==ee}var Mn=wy||wf,ox=Dh?ar(Dh):pb;function ux(o){return we(o)&&o.nodeType===1&&!fs(o)}function ax(o){if(o==null)return!0;if(He(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||Mn(o)||Si(o)||Xn(o)))return!o.length;var u=We(o);if(u==Gt||u==ir)return!o.size;if(us(o))return!Ra(o).length;for(var m in o)if(re.call(o,m))return!1;return!0}function fx(o,u){return is(o,u)}function lx(o,u,m){m=typeof m=="function"?m:e;var w=m?m(o,u):e;return w===e?is(o,u,e,m):!!w}function ff(o){if(!we(o))return!1;var u=Ye(o);return u==ie||u==Mt||typeof o.message=="string"&&typeof o.name=="string"&&!fs(o)}function cx(o){return typeof o=="number"&&qh(o)}function sn(o){if(!_e(o))return!1;var u=Ye(o);return u==Ht||u==zt||u==bt||u==gn}function op(o){return typeof o=="number"&&o==Ot(o)}function Qo(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=j}function _e(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function we(o){return o!=null&&typeof o=="object"}var up=yh?ar(yh):db;function hx(o,u){return o===u||Oa(o,u,Qa(u))}function px(o,u,m){return m=typeof m=="function"?m:e,Oa(o,u,Qa(u),m)}function mx(o){return ap(o)&&o!=+o}function dx(o){if(Qb(o))throw new Bt(s);return Vh(o)}function gx(o){return o===null}function vx(o){return o==null}function ap(o){return typeof o=="number"||we(o)&&Ye(o)==Ce}function fs(o){if(!we(o)||Ye(o)!=Me)return!1;var u=xo(o);if(u===null)return!0;var m=re.call(u,"constructor")&&u.constructor;return typeof m=="function"&&m instanceof m&&yo.call(m)==py}var lf=bh?ar(bh):gb;function _x(o){return op(o)&&o>=-j&&o<=j}var fp=Eh?ar(Eh):vb;function Vo(o){return typeof o=="string"||!Tt(o)&&we(o)&&Ye(o)==vn}function lr(o){return typeof o=="symbol"||we(o)&&Ye(o)==O}var Si=Ah?ar(Ah):_b;function wx(o){return o===e}function Dx(o){return we(o)&&We(o)==J}function yx(o){return we(o)&&Ye(o)==nt}var bx=Wo(La),Ex=Wo(function(o,u){return o<=u});function lp(o){if(!o)return[];if(He(o))return Vo(o)?Ir(o):Xe(o);if(Xi&&o[Xi])return ey(o[Xi]());var u=We(o),m=u==Gt?Aa:u==ir?_o:Bi;return m(o)}function on(o){if(!o)return o===0?o:0;if(o=Ar(o),o===G||o===-G){var u=o<0?-1:1;return u*Q}return o===o?o:0}function Ot(o){var u=on(o),m=u%1;return u===u?m?u-m:u:0}function cp(o){return o?jn(Ot(o),0,lt):0}function Ar(o){if(typeof o=="number")return o;if(lr(o))return tt;if(_e(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=_e(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=Sh(o);var m=na.test(o);return m||sa.test(o)?PD(o.slice(2),m?2:8):ra.test(o)?tt:+o}function hp(o){return Yr(o,Qe(o))}function Ax(o){return o?jn(Ot(o),-j,j):o===0?o:0}function Vt(o){return o==null?"":fr(o)}var xx=Fi(function(o,u){if(us(u)||He(u)){Yr(u,$e(u),o);return}for(var m in u)re.call(u,m)&&es(o,m,u[m])}),pp=Fi(function(o,u){Yr(u,Qe(u),o)}),tu=Fi(function(o,u,m,w){Yr(u,Qe(u),o,w)}),Cx=Fi(function(o,u,m,w){Yr(u,$e(u),o,w)}),Fx=rn(Sa);function Mx(o,u){var m=Ci(o);return u==null?m:Zh(m,u)}var Nx=Lt(function(o,u){o=ue(o);var m=-1,w=u.length,A=w>2?u[2]:e;for(A&&Ze(u[0],u[1],A)&&(w=1);++m<w;)for(var T=u[m],L=Qe(T),z=-1,Y=L.length;++z<Y;){var V=L[z],et=o[V];(et===e||$r(et,Ei[V])&&!re.call(o,V))&&(o[V]=T[V])}return o}),Sx=Lt(function(o){return o.push(e,S0),ur(mp,e,o)});function Bx(o,u){return Ch(o,At(u,3),Wr)}function Ix(o,u){return Ch(o,At(u,3),Ia)}function Tx(o,u){return o==null?o:Ba(o,At(u,3),Qe)}function $x(o,u){return o==null?o:Xh(o,At(u,3),Qe)}function Ox(o,u){return o&&Wr(o,At(u,3))}function Rx(o,u){return o&&Ia(o,At(u,3))}function Lx(o){return o==null?[]:Oo(o,$e(o))}function Px(o){return o==null?[]:Oo(o,Qe(o))}function cf(o,u,m){var w=o==null?e:Gn(o,u);return w===e?m:w}function zx(o,u){return o!=null&&T0(o,u,ab)}function hf(o,u){return o!=null&&T0(o,u,fb)}var qx=x0(function(o,u,m){u!=null&&typeof u.toString!="function"&&(u=bo.call(u)),o[u]=m},mf(Ve)),Ux=x0(function(o,u,m){u!=null&&typeof u.toString!="function"&&(u=bo.call(u)),re.call(o,u)?o[u].push(m):o[u]=[m]},At),kx=Lt(ns);function $e(o){return He(o)?Wh(o):Ra(o)}function Qe(o){return He(o)?Wh(o,!0):wb(o)}function Wx(o,u){var m={};return u=At(u,3),Wr(o,function(w,A,T){tn(m,u(w,A,T),w)}),m}function Yx(o,u){var m={};return u=At(u,3),Wr(o,function(w,A,T){tn(m,A,u(w,A,T))}),m}var Zx=Fi(function(o,u,m){Ro(o,u,m)}),mp=Fi(function(o,u,m,w){Ro(o,u,m,w)}),jx=rn(function(o,u){var m={};if(o==null)return m;var w=!1;u=me(u,function(T){return T=Cn(T,o),w||(w=T.length>1),T}),Yr(o,Xa(o),m),w&&(m=yr(m,c|d|_,qb));for(var A=u.length;A--;)ka(m,u[A]);return m});function Gx(o,u){return dp(o,Ho(At(u)))}var Kx=rn(function(o,u){return o==null?{}:yb(o,u)});function dp(o,u){if(o==null)return{};var m=me(Xa(o),function(w){return[w]});return u=At(u),o0(o,m,function(w,A){return u(w,A[0])})}function Jx(o,u,m){u=Cn(u,o);var w=-1,A=u.length;for(A||(A=1,o=e);++w<A;){var T=o==null?e:o[Zr(u[w])];T===e&&(w=A,T=m),o=sn(T)?T.call(o):T}return o}function Xx(o,u,m){return o==null?o:ss(o,u,m)}function Hx(o,u,m,w){return w=typeof w=="function"?w:e,o==null?o:ss(o,u,m,w)}var gp=M0($e),vp=M0(Qe);function Qx(o,u,m){var w=Tt(o),A=w||Mn(o)||Si(o);if(u=At(u,4),m==null){var T=o&&o.constructor;A?m=w?new T:[]:_e(o)?m=sn(T)?Ci(xo(o)):{}:m={}}return(A?_r:Wr)(o,function(L,z,Y){return u(m,L,z,Y)}),m}function Vx(o,u){return o==null?!0:ka(o,u)}function t2(o,u,m){return o==null?o:c0(o,u,Za(m))}function e2(o,u,m,w){return w=typeof w=="function"?w:e,o==null?o:c0(o,u,Za(m),w)}function Bi(o){return o==null?[]:Ea(o,$e(o))}function r2(o){return o==null?[]:Ea(o,Qe(o))}function n2(o,u,m){return m===e&&(m=u,u=e),m!==e&&(m=Ar(m),m=m===m?m:0),u!==e&&(u=Ar(u),u=u===u?u:0),jn(Ar(o),u,m)}function i2(o,u,m){return u=on(u),m===e?(m=u,u=0):m=on(m),o=Ar(o),lb(o,u,m)}function s2(o,u,m){if(m&&typeof m!="boolean"&&Ze(o,u,m)&&(u=m=e),m===e&&(typeof u=="boolean"?(m=u,u=e):typeof o=="boolean"&&(m=o,o=e)),o===e&&u===e?(o=0,u=1):(o=on(o),u===e?(u=o,o=0):u=on(u)),o>u){var w=o;o=u,u=w}if(m||o%1||u%1){var A=Uh();return ke(o+A*(u-o+LD("1e-"+((A+"").length-1))),u)}return za(o,u)}var o2=Mi(function(o,u,m){return u=u.toLowerCase(),o+(m?_p(u):u)});function _p(o){return pf(Vt(o).toLowerCase())}function wp(o){return o=Vt(o),o&&o.replace(ua,XD).replace(FD,"")}function u2(o,u,m){o=Vt(o),u=fr(u);var w=o.length;m=m===e?w:jn(Ot(m),0,w);var A=m;return m-=u.length,m>=0&&o.slice(m,A)==u}function a2(o){return o=Vt(o),o&&Uu.test(o)?o.replace(lo,HD):o}function f2(o){return o=Vt(o),o&&Gu.test(o)?o.replace(Gi,"\\$&"):o}var l2=Mi(function(o,u,m){return o+(m?"-":"")+u.toLowerCase()}),c2=Mi(function(o,u,m){return o+(m?" ":"")+u.toLowerCase()}),h2=b0("toLowerCase");function p2(o,u,m){o=Vt(o),u=Ot(u);var w=u?yi(o):0;if(!u||w>=u)return o;var A=(u-w)/2;return ko(No(A),m)+o+ko(Mo(A),m)}function m2(o,u,m){o=Vt(o),u=Ot(u);var w=u?yi(o):0;return u&&w<u?o+ko(u-w,m):o}function d2(o,u,m){o=Vt(o),u=Ot(u);var w=u?yi(o):0;return u&&w<u?ko(u-w,m)+o:o}function g2(o,u,m){return m||u==null?u=0:u&&(u=+u),Ey(Vt(o).replace(Ki,""),u||0)}function v2(o,u,m){return(m?Ze(o,u,m):u===e)?u=1:u=Ot(u),qa(Vt(o),u)}function _2(){var o=arguments,u=Vt(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var w2=Mi(function(o,u,m){return o+(m?"_":"")+u.toLowerCase()});function D2(o,u,m){return m&&typeof m!="number"&&Ze(o,u,m)&&(u=m=e),m=m===e?lt:m>>>0,m?(o=Vt(o),o&&(typeof u=="string"||u!=null&&!lf(u))&&(u=fr(u),!u&&Di(o))?Fn(Ir(o),0,m):o.split(u,m)):[]}var y2=Mi(function(o,u,m){return o+(m?" ":"")+pf(u)});function b2(o,u,m){return o=Vt(o),m=m==null?0:jn(Ot(m),0,o.length),u=fr(u),o.slice(m,m+u.length)==u}function E2(o,u,m){var w=B.templateSettings;m&&Ze(o,u,m)&&(u=e),o=Vt(o),u=tu({},u,w,N0);var A=tu({},u.imports,w.imports,N0),T=$e(A),L=Ea(A,T),z,Y,V=0,et=u.interpolate||gi,ot="__p += '",mt=xa((u.escape||gi).source+"|"+et.source+"|"+(et===co?ea:gi).source+"|"+(u.evaluate||gi).source+"|$","g"),_t="//# sourceURL="+(re.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ID+"]")+`
11
+ `;o.replace(mt,function(Ct,qt,kt,cr,je,hr){return kt||(kt=cr),ot+=o.slice(V,hr).replace(Un,QD),qt&&(z=!0,ot+=`' +
12
+ __e(`+qt+`) +
13
+ '`),je&&(Y=!0,ot+=`';
14
+ `+je+`;
15
+ __p += '`),kt&&(ot+=`' +
16
+ ((__t = (`+kt+`)) == null ? '' : __t) +
17
+ '`),V=hr+Ct.length,Ct}),ot+=`';
18
+ `;var xt=re.call(u,"variable")&&u.variable;if(!xt)ot=`with (obj) {
19
+ `+ot+`
20
+ }
21
+ `;else if(Vu.test(xt))throw new Bt(f);ot=(Y?ot.replace(sr,""):ot).replace(or,"$1").replace(_n,"$1;"),ot="function("+(xt||"obj")+`) {
22
+ `+(xt?"":`obj || (obj = {});
23
+ `)+"var __t, __p = ''"+(z?", __e = _.escape":"")+(Y?`, __j = Array.prototype.join;
24
+ function print() { __p += __j.call(arguments, '') }
25
+ `:`;
26
+ `)+ot+`return __p
27
+ }`;var Rt=yp(function(){return Jt(T,_t+"return "+ot).apply(e,L)});if(Rt.source=ot,ff(Rt))throw Rt;return Rt}function A2(o){return Vt(o).toLowerCase()}function x2(o){return Vt(o).toUpperCase()}function C2(o,u,m){if(o=Vt(o),o&&(m||u===e))return Sh(o);if(!o||!(u=fr(u)))return o;var w=Ir(o),A=Ir(u),T=Bh(w,A),L=Ih(w,A)+1;return Fn(w,T,L).join("")}function F2(o,u,m){if(o=Vt(o),o&&(m||u===e))return o.slice(0,$h(o)+1);if(!o||!(u=fr(u)))return o;var w=Ir(o),A=Ih(w,Ir(u))+1;return Fn(w,0,A).join("")}function M2(o,u,m){if(o=Vt(o),o&&(m||u===e))return o.replace(Ki,"");if(!o||!(u=fr(u)))return o;var w=Ir(o),A=Bh(w,Ir(u));return Fn(w,A).join("")}function N2(o,u){var m=C,w=I;if(_e(u)){var A="separator"in u?u.separator:A;m="length"in u?Ot(u.length):m,w="omission"in u?fr(u.omission):w}o=Vt(o);var T=o.length;if(Di(o)){var L=Ir(o);T=L.length}if(m>=T)return o;var z=m-yi(w);if(z<1)return w;var Y=L?Fn(L,0,z).join(""):o.slice(0,z);if(A===e)return Y+w;if(L&&(z+=Y.length-z),lf(A)){if(o.slice(z).search(A)){var V,et=Y;for(A.global||(A=xa(A.source,Vt(ho.exec(A))+"g")),A.lastIndex=0;V=A.exec(et);)var ot=V.index;Y=Y.slice(0,ot===e?z:ot)}}else if(o.indexOf(fr(A),z)!=z){var mt=Y.lastIndexOf(A);mt>-1&&(Y=Y.slice(0,mt))}return Y+w}function S2(o){return o=Vt(o),o&&qu.test(o)?o.replace(qn,sy):o}var B2=Mi(function(o,u,m){return o+(m?" ":"")+u.toUpperCase()}),pf=b0("toUpperCase");function Dp(o,u,m){return o=Vt(o),u=m?e:u,u===e?ty(o)?ay(o):ZD(o):o.match(u)||[]}var yp=Lt(function(o,u){try{return ur(o,e,u)}catch(m){return ff(m)?m:new Bt(m)}}),I2=rn(function(o,u){return _r(u,function(m){m=Zr(m),tn(o,m,uf(o[m],o))}),o});function T2(o){var u=o==null?0:o.length,m=At();return o=u?me(o,function(w){if(typeof w[1]!="function")throw new wr(a);return[m(w[0]),w[1]]}):[],Lt(function(w){for(var A=-1;++A<u;){var T=o[A];if(ur(T[0],this,w))return ur(T[1],this,w)}})}function $2(o){return sb(yr(o,c))}function mf(o){return function(){return o}}function O2(o,u){return o==null||o!==o?u:o}var R2=A0(),L2=A0(!0);function Ve(o){return o}function df(o){return t0(typeof o=="function"?o:yr(o,c))}function P2(o){return r0(yr(o,c))}function z2(o,u){return n0(o,yr(u,c))}var q2=Lt(function(o,u){return function(m){return ns(m,o,u)}}),U2=Lt(function(o,u){return function(m){return ns(o,m,u)}});function gf(o,u,m){var w=$e(u),A=Oo(u,w);m==null&&!(_e(u)&&(A.length||!w.length))&&(m=u,u=o,o=this,A=Oo(u,$e(u)));var T=!(_e(m)&&"chain"in m)||!!m.chain,L=sn(o);return _r(A,function(z){var Y=u[z];o[z]=Y,L&&(o.prototype[z]=function(){var V=this.__chain__;if(T||V){var et=o(this.__wrapped__),ot=et.__actions__=Xe(this.__actions__);return ot.push({func:Y,args:arguments,thisArg:o}),et.__chain__=V,et}return Y.apply(o,yn([this.value()],arguments))})}),o}function k2(){return Le._===this&&(Le._=my),this}function vf(){}function W2(o){return o=Ot(o),Lt(function(u){return i0(u,o)})}var Y2=Ga(me),Z2=Ga(xh),j2=Ga(_a);function bp(o){return tf(o)?wa(Zr(o)):bb(o)}function G2(o){return function(u){return o==null?e:Gn(o,u)}}var K2=C0(),J2=C0(!0);function _f(){return[]}function wf(){return!1}function X2(){return{}}function H2(){return""}function Q2(){return!0}function V2(o,u){if(o=Ot(o),o<1||o>j)return[];var m=lt,w=ke(o,lt);u=At(u),o-=lt;for(var A=ba(w,u);++m<o;)u(m);return A}function tC(o){return Tt(o)?me(o,Zr):lr(o)?[o]:Xe(k0(Vt(o)))}function eC(o){var u=++hy;return Vt(o)+u}var rC=Uo(function(o,u){return o+u},0),nC=Ka("ceil"),iC=Uo(function(o,u){return o/u},1),sC=Ka("floor");function oC(o){return o&&o.length?$o(o,Ve,Ta):e}function uC(o,u){return o&&o.length?$o(o,At(u,2),Ta):e}function aC(o){return Mh(o,Ve)}function fC(o,u){return Mh(o,At(u,2))}function lC(o){return o&&o.length?$o(o,Ve,La):e}function cC(o,u){return o&&o.length?$o(o,At(u,2),La):e}var hC=Uo(function(o,u){return o*u},1),pC=Ka("round"),mC=Uo(function(o,u){return o-u},0);function dC(o){return o&&o.length?ya(o,Ve):0}function gC(o,u){return o&&o.length?ya(o,At(u,2)):0}return B.after=PA,B.ary=V0,B.assign=xx,B.assignIn=pp,B.assignInWith=tu,B.assignWith=Cx,B.at=Fx,B.before=tp,B.bind=uf,B.bindAll=I2,B.bindKey=ep,B.castArray=XA,B.chain=X0,B.chunk=sE,B.compact=oE,B.concat=uE,B.cond=T2,B.conforms=$2,B.constant=mf,B.countBy=dA,B.create=Mx,B.curry=rp,B.curryRight=np,B.debounce=ip,B.defaults=Nx,B.defaultsDeep=Sx,B.defer=zA,B.delay=qA,B.difference=aE,B.differenceBy=fE,B.differenceWith=lE,B.drop=cE,B.dropRight=hE,B.dropRightWhile=pE,B.dropWhile=mE,B.fill=dE,B.filter=vA,B.flatMap=DA,B.flatMapDeep=yA,B.flatMapDepth=bA,B.flatten=j0,B.flattenDeep=gE,B.flattenDepth=vE,B.flip=UA,B.flow=R2,B.flowRight=L2,B.fromPairs=_E,B.functions=Lx,B.functionsIn=Px,B.groupBy=EA,B.initial=DE,B.intersection=yE,B.intersectionBy=bE,B.intersectionWith=EE,B.invert=qx,B.invertBy=Ux,B.invokeMap=xA,B.iteratee=df,B.keyBy=CA,B.keys=$e,B.keysIn=Qe,B.map=Ko,B.mapKeys=Wx,B.mapValues=Yx,B.matches=P2,B.matchesProperty=z2,B.memoize=Xo,B.merge=Zx,B.mergeWith=mp,B.method=q2,B.methodOf=U2,B.mixin=gf,B.negate=Ho,B.nthArg=W2,B.omit=jx,B.omitBy=Gx,B.once=kA,B.orderBy=FA,B.over=Y2,B.overArgs=WA,B.overEvery=Z2,B.overSome=j2,B.partial=af,B.partialRight=sp,B.partition=MA,B.pick=Kx,B.pickBy=dp,B.property=bp,B.propertyOf=G2,B.pull=FE,B.pullAll=K0,B.pullAllBy=ME,B.pullAllWith=NE,B.pullAt=SE,B.range=K2,B.rangeRight=J2,B.rearg=YA,B.reject=BA,B.remove=BE,B.rest=ZA,B.reverse=sf,B.sampleSize=TA,B.set=Xx,B.setWith=Hx,B.shuffle=$A,B.slice=IE,B.sortBy=LA,B.sortedUniq=zE,B.sortedUniqBy=qE,B.split=D2,B.spread=jA,B.tail=UE,B.take=kE,B.takeRight=WE,B.takeRightWhile=YE,B.takeWhile=ZE,B.tap=oA,B.throttle=GA,B.thru=Go,B.toArray=lp,B.toPairs=gp,B.toPairsIn=vp,B.toPath=tC,B.toPlainObject=hp,B.transform=Qx,B.unary=KA,B.union=jE,B.unionBy=GE,B.unionWith=KE,B.uniq=JE,B.uniqBy=XE,B.uniqWith=HE,B.unset=Vx,B.unzip=of,B.unzipWith=J0,B.update=t2,B.updateWith=e2,B.values=Bi,B.valuesIn=r2,B.without=QE,B.words=Dp,B.wrap=JA,B.xor=VE,B.xorBy=tA,B.xorWith=eA,B.zip=rA,B.zipObject=nA,B.zipObjectDeep=iA,B.zipWith=sA,B.entries=gp,B.entriesIn=vp,B.extend=pp,B.extendWith=tu,gf(B,B),B.add=rC,B.attempt=yp,B.camelCase=o2,B.capitalize=_p,B.ceil=nC,B.clamp=n2,B.clone=HA,B.cloneDeep=VA,B.cloneDeepWith=tx,B.cloneWith=QA,B.conformsTo=ex,B.deburr=wp,B.defaultTo=O2,B.divide=iC,B.endsWith=u2,B.eq=$r,B.escape=a2,B.escapeRegExp=f2,B.every=gA,B.find=_A,B.findIndex=Y0,B.findKey=Bx,B.findLast=wA,B.findLastIndex=Z0,B.findLastKey=Ix,B.floor=sC,B.forEach=H0,B.forEachRight=Q0,B.forIn=Tx,B.forInRight=$x,B.forOwn=Ox,B.forOwnRight=Rx,B.get=cf,B.gt=rx,B.gte=nx,B.has=zx,B.hasIn=hf,B.head=G0,B.identity=Ve,B.includes=AA,B.indexOf=wE,B.inRange=i2,B.invoke=kx,B.isArguments=Xn,B.isArray=Tt,B.isArrayBuffer=ix,B.isArrayLike=He,B.isArrayLikeObject=be,B.isBoolean=sx,B.isBuffer=Mn,B.isDate=ox,B.isElement=ux,B.isEmpty=ax,B.isEqual=fx,B.isEqualWith=lx,B.isError=ff,B.isFinite=cx,B.isFunction=sn,B.isInteger=op,B.isLength=Qo,B.isMap=up,B.isMatch=hx,B.isMatchWith=px,B.isNaN=mx,B.isNative=dx,B.isNil=vx,B.isNull=gx,B.isNumber=ap,B.isObject=_e,B.isObjectLike=we,B.isPlainObject=fs,B.isRegExp=lf,B.isSafeInteger=_x,B.isSet=fp,B.isString=Vo,B.isSymbol=lr,B.isTypedArray=Si,B.isUndefined=wx,B.isWeakMap=Dx,B.isWeakSet=yx,B.join=AE,B.kebabCase=l2,B.last=Er,B.lastIndexOf=xE,B.lowerCase=c2,B.lowerFirst=h2,B.lt=bx,B.lte=Ex,B.max=oC,B.maxBy=uC,B.mean=aC,B.meanBy=fC,B.min=lC,B.minBy=cC,B.stubArray=_f,B.stubFalse=wf,B.stubObject=X2,B.stubString=H2,B.stubTrue=Q2,B.multiply=hC,B.nth=CE,B.noConflict=k2,B.noop=vf,B.now=Jo,B.pad=p2,B.padEnd=m2,B.padStart=d2,B.parseInt=g2,B.random=s2,B.reduce=NA,B.reduceRight=SA,B.repeat=v2,B.replace=_2,B.result=Jx,B.round=pC,B.runInContext=W,B.sample=IA,B.size=OA,B.snakeCase=w2,B.some=RA,B.sortedIndex=TE,B.sortedIndexBy=$E,B.sortedIndexOf=OE,B.sortedLastIndex=RE,B.sortedLastIndexBy=LE,B.sortedLastIndexOf=PE,B.startCase=y2,B.startsWith=b2,B.subtract=mC,B.sum=dC,B.sumBy=gC,B.template=E2,B.times=V2,B.toFinite=on,B.toInteger=Ot,B.toLength=cp,B.toLower=A2,B.toNumber=Ar,B.toSafeInteger=Ax,B.toString=Vt,B.toUpper=x2,B.trim=C2,B.trimEnd=F2,B.trimStart=M2,B.truncate=N2,B.unescape=S2,B.uniqueId=eC,B.upperCase=B2,B.upperFirst=pf,B.each=H0,B.eachRight=Q0,B.first=G0,gf(B,function(){var o={};return Wr(B,function(u,m){re.call(B.prototype,m)||(o[m]=u)}),o}(),{chain:!1}),B.VERSION=r,_r(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),_r(["drop","take"],function(o,u){Ut.prototype[o]=function(m){m=m===e?1:Be(Ot(m),0);var w=this.__filtered__&&!u?new Ut(this):this.clone();return w.__filtered__?w.__takeCount__=ke(m,w.__takeCount__):w.__views__.push({size:ke(m,lt),type:o+(w.__dir__<0?"Right":"")}),w},Ut.prototype[o+"Right"]=function(m){return this.reverse()[o](m).reverse()}}),_r(["filter","map","takeWhile"],function(o,u){var m=u+1,w=m==q||m==P;Ut.prototype[o]=function(A){var T=this.clone();return T.__iteratees__.push({iteratee:At(A,3),type:m}),T.__filtered__=T.__filtered__||w,T}}),_r(["head","last"],function(o,u){var m="take"+(u?"Right":"");Ut.prototype[o]=function(){return this[m](1).value()[0]}}),_r(["initial","tail"],function(o,u){var m="drop"+(u?"":"Right");Ut.prototype[o]=function(){return this.__filtered__?new Ut(this):this[m](1)}}),Ut.prototype.compact=function(){return this.filter(Ve)},Ut.prototype.find=function(o){return this.filter(o).head()},Ut.prototype.findLast=function(o){return this.reverse().find(o)},Ut.prototype.invokeMap=Lt(function(o,u){return typeof o=="function"?new Ut(this):this.map(function(m){return ns(m,o,u)})}),Ut.prototype.reject=function(o){return this.filter(Ho(At(o)))},Ut.prototype.slice=function(o,u){o=Ot(o);var m=this;return m.__filtered__&&(o>0||u<0)?new Ut(m):(o<0?m=m.takeRight(-o):o&&(m=m.drop(o)),u!==e&&(u=Ot(u),m=u<0?m.dropRight(-u):m.take(u-o)),m)},Ut.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Ut.prototype.toArray=function(){return this.take(lt)},Wr(Ut.prototype,function(o,u){var m=/^(?:filter|find|map|reject)|While$/.test(u),w=/^(?:head|last)$/.test(u),A=B[w?"take"+(u=="last"?"Right":""):u],T=w||/^find/.test(u);A&&(B.prototype[u]=function(){var L=this.__wrapped__,z=w?[1]:arguments,Y=L instanceof Ut,V=z[0],et=Y||Tt(L),ot=function(qt){var kt=A.apply(B,yn([qt],z));return w&&mt?kt[0]:kt};et&&m&&typeof V=="function"&&V.length!=1&&(Y=et=!1);var mt=this.__chain__,_t=!!this.__actions__.length,xt=T&&!mt,Rt=Y&&!_t;if(!T&&et){L=Rt?L:new Ut(this);var Ct=o.apply(L,z);return Ct.__actions__.push({func:Go,args:[ot],thisArg:e}),new Dr(Ct,mt)}return xt&&Rt?o.apply(this,z):(Ct=this.thru(ot),xt?w?Ct.value()[0]:Ct.value():Ct)})}),_r(["pop","push","shift","sort","splice","unshift"],function(o){var u=wo[o],m=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",w=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var A=arguments;if(w&&!this.__chain__){var T=this.value();return u.apply(Tt(T)?T:[],A)}return this[m](function(L){return u.apply(Tt(L)?L:[],A)})}}),Wr(Ut.prototype,function(o,u){var m=B[u];if(m){var w=m.name+"";re.call(xi,w)||(xi[w]=[]),xi[w].push({name:u,func:m})}}),xi[qo(e,v).name]=[{name:"wrapper",func:e}],Ut.prototype.clone=Sy,Ut.prototype.reverse=By,Ut.prototype.value=Iy,B.prototype.at=uA,B.prototype.chain=aA,B.prototype.commit=fA,B.prototype.next=lA,B.prototype.plant=hA,B.prototype.reverse=pA,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=mA,B.prototype.first=B.prototype.head,Xi&&(B.prototype[Xi]=cA),B},bi=fy();kn?((kn.exports=bi)._=bi,ma._=bi):Le._=bi}).call(Wt)}(Nn,Nn.exports);var xr=Nn.exports;class Ap{constructor(t,e){K(this,"_defaultParams");K(this,"_UserTypeFileds");K(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return xr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(xr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){K(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return xr.cloneDeep(this)}}}}var Af={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){var e=1e3,r=6e4,n=36e5,s="millisecond",a="second",f="minute",l="hour",p="day",h="week",c="month",d="quarter",_="year",D="date",g="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,E={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(q){var k=["th","st","nd","rd"],P=q%100;return"["+q+(k[(P-20)%10]||k[P]||k[0])+"]"}},b=function(q,k,P){var G=String(q);return!G||G.length>=k?q:""+Array(k+1-G.length).join(P)+q},N={s:b,z:function(q){var k=-q.utcOffset(),P=Math.abs(k),G=Math.floor(P/60),j=P%60;return(k<=0?"+":"-")+b(G,2,"0")+":"+b(j,2,"0")},m:function q(k,P){if(k.date()<P.date())return-q(P,k);var G=12*(P.year()-k.year())+(P.month()-k.month()),j=k.clone().add(G,c),Q=P-j<0,tt=k.clone().add(G+(Q?-1:1),c);return+(-(G+(P-j)/(Q?j-tt:tt-j))||0)},a:function(q){return q<0?Math.ceil(q)||0:Math.floor(q)},p:function(q){return{M:c,y:_,w:h,d:p,D,h:l,m:f,s:a,ms:s,Q:d}[q]||String(q||"").toLowerCase().replace(/s$/,"")},u:function(q){return q===void 0}},x="en",F={};F[x]=E;var M="$isDayjsObject",S=function(q){return q instanceof R||!(!q||!q[M])},$=function q(k,P,G){var j;if(!k)return x;if(typeof k=="string"){var Q=k.toLowerCase();F[Q]&&(j=Q),P&&(F[Q]=P,j=Q);var tt=k.split("-");if(!j&&tt.length>1)return q(tt[0])}else{var lt=k.name;F[lt]=k,j=lt}return!G&&j&&(x=j),j||!G&&x},C=function(q,k){if(S(q))return q.clone();var P=typeof k=="object"?k:{};return P.date=q,P.args=arguments,new R(P)},I=N;I.l=$,I.i=S,I.w=function(q,k){return C(q,{locale:k.$L,utc:k.$u,x:k.$x,$offset:k.$offset})};var R=function(){function q(P){this.$L=$(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[M]=!0}var k=q.prototype;return k.parse=function(P){this.$d=function(G){var j=G.date,Q=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 tt=j.match(y);if(tt){var lt=tt[2]-1||0,vt=(tt[7]||"0").substring(0,3);return Q?new Date(Date.UTC(tt[1],lt,tt[3]||1,tt[4]||0,tt[5]||0,tt[6]||0,vt)):new Date(tt[1],lt,tt[3]||1,tt[4]||0,tt[5]||0,tt[6]||0,vt)}}return new Date(j)}(P),this.init()},k.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()},k.$utils=function(){return I},k.isValid=function(){return this.$d.toString()!==g},k.isSame=function(P,G){var j=C(P);return this.startOf(G)<=j&&j<=this.endOf(G)},k.isAfter=function(P,G){return C(P)<this.startOf(G)},k.isBefore=function(P,G){return this.endOf(G)<C(P)},k.$g=function(P,G,j){return I.u(P)?this[G]:this.set(j,P)},k.unix=function(){return Math.floor(this.valueOf()/1e3)},k.valueOf=function(){return this.$d.getTime()},k.startOf=function(P,G){var j=this,Q=!!I.u(G)||G,tt=I.p(P),lt=function(It,Mt){var ie=I.w(j.$u?Date.UTC(j.$y,Mt,It):new Date(j.$y,Mt,It),j);return Q?ie:ie.endOf(p)},vt=function(It,Mt){return I.w(j.toDate()[It].apply(j.toDate("s"),(Q?[0,0,0,0]:[23,59,59,999]).slice(Mt)),j)},ft=this.$W,wt=this.$M,yt=this.$D,St="set"+(this.$u?"UTC":"");switch(tt){case _:return Q?lt(1,0):lt(31,11);case c:return Q?lt(1,wt):lt(0,wt+1);case h:var bt=this.$locale().weekStart||0,ee=(ft<bt?ft+7:ft)-bt;return lt(Q?yt-ee:yt+(6-ee),wt);case p:case D:return vt(St+"Hours",0);case l:return vt(St+"Minutes",1);case f:return vt(St+"Seconds",2);case a:return vt(St+"Milliseconds",3);default:return this.clone()}},k.endOf=function(P){return this.startOf(P,!1)},k.$set=function(P,G){var j,Q=I.p(P),tt="set"+(this.$u?"UTC":""),lt=(j={},j[p]=tt+"Date",j[D]=tt+"Date",j[c]=tt+"Month",j[_]=tt+"FullYear",j[l]=tt+"Hours",j[f]=tt+"Minutes",j[a]=tt+"Seconds",j[s]=tt+"Milliseconds",j)[Q],vt=Q===p?this.$D+(G-this.$W):G;if(Q===c||Q===_){var ft=this.clone().set(D,1);ft.$d[lt](vt),ft.init(),this.$d=ft.set(D,Math.min(this.$D,ft.daysInMonth())).$d}else lt&&this.$d[lt](vt);return this.init(),this},k.set=function(P,G){return this.clone().$set(P,G)},k.get=function(P){return this[I.p(P)]()},k.add=function(P,G){var j,Q=this;P=Number(P);var tt=I.p(G),lt=function(wt){var yt=C(Q);return I.w(yt.date(yt.date()+Math.round(wt*P)),Q)};if(tt===c)return this.set(c,this.$M+P);if(tt===_)return this.set(_,this.$y+P);if(tt===p)return lt(1);if(tt===h)return lt(7);var vt=(j={},j[f]=r,j[l]=n,j[a]=e,j)[tt]||1,ft=this.$d.getTime()+P*vt;return I.w(ft,this)},k.subtract=function(P,G){return this.add(-1*P,G)},k.format=function(P){var G=this,j=this.$locale();if(!this.isValid())return j.invalidDate||g;var Q=P||"YYYY-MM-DDTHH:mm:ssZ",tt=I.z(this),lt=this.$H,vt=this.$m,ft=this.$M,wt=j.weekdays,yt=j.months,St=j.meridiem,bt=function(Mt,ie,Ht,zt){return Mt&&(Mt[ie]||Mt(G,Q))||Ht[ie].slice(0,zt)},ee=function(Mt){return I.s(lt%12||12,Mt,"0")},It=St||function(Mt,ie,Ht){var zt=Mt<12?"AM":"PM";return Ht?zt.toLowerCase():zt};return Q.replace(v,function(Mt,ie){return ie||function(Ht){switch(Ht){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 bt(j.monthsShort,ft,yt,3);case"MMMM":return bt(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 bt(j.weekdaysMin,G.$W,wt,2);case"ddd":return bt(j.weekdaysShort,G.$W,wt,3);case"dddd":return wt[G.$W];case"H":return String(lt);case"HH":return I.s(lt,2,"0");case"h":return ee(1);case"hh":return ee(2);case"a":return It(lt,vt,!0);case"A":return It(lt,vt,!1);case"m":return String(vt);case"mm":return I.s(vt,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 tt}return null}(Mt)||tt.replace(":","")})},k.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},k.diff=function(P,G,j){var Q,tt=this,lt=I.p(G),vt=C(P),ft=(vt.utcOffset()-this.utcOffset())*r,wt=this-vt,yt=function(){return I.m(tt,vt)};switch(lt){case _:Q=yt()/12;break;case c:Q=yt();break;case d:Q=yt()/3;break;case h:Q=(wt-ft)/6048e5;break;case p:Q=(wt-ft)/864e5;break;case l:Q=wt/n;break;case f:Q=wt/r;break;case a:Q=wt/e;break;default:Q=wt}return j?Q:I.a(Q)},k.daysInMonth=function(){return this.endOf(c).$D},k.$locale=function(){return F[this.$L]},k.locale=function(P,G){if(!P)return this.$L;var j=this.clone(),Q=$(P,G,!0);return Q&&(j.$L=Q),j},k.clone=function(){return I.w(this.$d,this)},k.toDate=function(){return new Date(this.valueOf())},k.toJSON=function(){return this.isValid()?this.toISOString():null},k.toISOString=function(){return this.$d.toISOString()},k.toString=function(){return this.$d.toUTCString()},q}(),U=R.prototype;return C.prototype=U,[["$ms",s],["$s",a],["$m",f],["$H",l],["$W",p],["$M",c],["$y",_],["$D",D]].forEach(function(q){U[q[1]]=function(k){return this.$g(k,q[0],q[1])}}),C.extend=function(q,k){return q.$i||(q(k,R,C),q.$i=!0),C},C.locale=$,C.isDayjs=S,C.unix=function(q){return C(1e3*q)},C.en=F[x],C.Ls=F,C.p={},C})})(Af);var xp=Af.exports,ne=Zt(xp),xf={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,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(g){var y={date:g,utc:!0,args:arguments};return new a(y)},l.utc=function(g){var y=f(this.toDate(),{locale:this.$L,utc:!0});return g?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(g){g.utc&&(this.$u=!0),this.$utils().u(g.$offset)||(this.$offset=g.$offset),p.call(this,g)};var h=l.init;l.init=function(){if(this.$u){var g=this.$d;this.$y=g.getUTCFullYear(),this.$M=g.getUTCMonth(),this.$D=g.getUTCDate(),this.$W=g.getUTCDay(),this.$H=g.getUTCHours(),this.$m=g.getUTCMinutes(),this.$s=g.getUTCSeconds(),this.$ms=g.getUTCMilliseconds()}else h.call(this)};var c=l.utcOffset;l.utcOffset=function(g,y){var v=this.$utils().u;if(v(g))return this.$u?0:v(this.$offset)?c.call(this):this.$offset;if(typeof g=="string"&&(g=function(x){x===void 0&&(x="");var F=x.match(r);if(!F)return null;var M=(""+F[0]).match(n)||["-",0,0],S=M[0],$=60*+M[1]+ +M[2];return $===0?0:S==="+"?$:-$}(g),g===null))return this;var E=Math.abs(g)<=16?60*g:g,b=this;if(y)return b.$offset=E,b.$u=g===0,b;if(g!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(E+N,e)).$offset=E,b.$x.$localOffset=N}else b=this.utc();return b};var d=l.format;l.format=function(g){var y=g||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,y)},l.valueOf=function(){var g=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*g},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var _=l.toDate;l.toDate=function(g){return g==="s"&&this.$offset?f(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():_.call(this)};var D=l.diff;l.diff=function(g,y,v){if(g&&this.$u===g.$u)return D.call(this,g,y,v);var E=this.local(),b=f(g).local();return D.call(E,b,y,v)}}})})(xf);var Cp=xf.exports,Fp=Zt(Cp),Cf={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,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(d,_,D){D===void 0&&(D={});var g=new Date(d),y=function(v,E){E===void 0&&(E={});var b=E.timeZoneName||"short",N=v+"|"+b,x=r[N];return x||(x=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[N]=x),x}(_,D);return y.formatToParts(g)},p=function(d,_){for(var D=l(d,_),g=[],y=0;y<D.length;y+=1){var v=D[y],E=v.type,b=v.value,N=e[E];N>=0&&(g[N]=parseInt(b,10))}var x=g[3],F=x===24?0:x,M=g[0]+"-"+g[1]+"-"+g[2]+" "+F+":"+g[4]+":"+g[5]+":000",S=+d;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},h=s.prototype;h.tz=function(d,_){d===void 0&&(d=f);var D=this.utcOffset(),g=this.toDate(),y=g.toLocaleString("en-US",{timeZone:d}),v=Math.round((g-new Date(y))/1e3/60),E=a(y,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(g.getTimezoneOffset()/15)-v,!0);if(_){var b=E.utcOffset();E=E.add(D-b,"minute")}return E.$x.$timezone=d,E},h.offsetName=function(d){var _=this.$x.$timezone||a.tz.guess(),D=l(this.valueOf(),_,{timeZoneName:d}).find(function(g){return g.type.toLowerCase()==="timezonename"});return D&&D.value};var c=h.startOf;h.startOf=function(d,_){if(!this.$x||!this.$x.$timezone)return c.call(this,d,_);var D=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return c.call(D,d,_).tz(this.$x.$timezone,!0)},a.tz=function(d,_,D){var g=D&&_,y=D||_||f,v=p(+a(),y);if(typeof d!="string")return a(d).tz(y);var E=function(F,M,S){var $=F-60*M*1e3,C=p($,S);if(M===C)return[$,M];var I=p($-=60*(C-M)*1e3,S);return C===I?[$,C]:[F-60*Math.min(C,I)*1e3,Math.max(C,I)]}(a.utc(d,g).valueOf(),v,y),b=E[0],N=E[1],x=a(b).utcOffset(N);return x.$x.$timezone=y,x},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(d){f=d}}})})(Cf);var Mp=Cf.exports,Np=Zt(Mp),Ff={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,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 d=a(this).startOf(r).date(p).startOf(e).subtract(1,"millisecond"),_=this.diff(d,e,!0);return _<0?a(this).startOf("week").week():Math.ceil(_)},f.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}})})(Ff);var Sp=Ff.exports,Bp=Zt(Sp);function ls(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 Ip(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 Cr(i,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ne(i).utcOffset(Ip(t)):ne(i).tz(t)}function Sn(i){const[t,e]=ls(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)}var Lr=(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))(Lr||{}),cs=(i=>(i.dividends="dividends",i.none="none",i.splits="splits",i))(cs||{}),hs=(i=>(i.freqAll="freq_all",i.freqOncePerBar="freq_once_per_bar",i.freqOncePerBarClose="freq_once_per_bar_close",i))(hs||{}),Ii=(i=>(i.gapsOff="gaps_off",i.gapsOn="gaps_on",i.lookaheadOff="lookahead_off",i.lookaheadOn="lookahead_on",i))(Ii||{}),Fr=(i=>(i.all="all",i.dataWindow="data_window",i.none="none",i.pane="pane",i.priceScale="price_scale",i.statusLine="status_line",i))(Fr||{}),Bn=(i=>(i.both="both",i.left="left",i.none="none",i.right="right",i))(Bn||{}),Hn=(i=>(i.inherit="inherit",i.mintick="mintick",i.percent="percent",i.price="price",i.volume="volume",i))(Hn||{}),ps=(i=>(i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(ps||{}),de=(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))(de||{}),Pr=(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))(Pr||{}),Qn=(i=>(i.abovebar="abovebar",i.absolute="absolute",i.belowbar="belowbar",i.bottom="bottom",i.top="top",i))(Qn||{}),In=(i=>(i.ascending="ascending",i.descending="descending",i))(In||{}),pr=(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))(pr||{}),Mr=(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))(Mr||{}),ms=(i=>(i.left="left",i.none="none",i.right="right",i))(ms||{}),ru=(i=>(i.extended="extended",i.regular="regular",i))(ru||{}),tr=(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))(tr||{}),zr=(i=>(i.auto="auto",i.huge="huge",i.large="large",i.normal="normal",i.small="small",i.tiny="tiny",i))(zr||{}),ds=(i=>(i.cash="cash",i.fixed="fixed",i.percentOfEquity="percent_of_equity",i))(ds||{}),gs=(i=>(i.cashPerContract="cash_per_contract",i.cashPerOrder="cash_per_order",i.percent="percent",i))(gs||{}),vs=(i=>(i.all="all",i.long="long",i.short="short",i))(vs||{}),_s=(i=>(i.cancel="cancel",i.none="none",i.reduce="reduce",i))(_s||{}),Ge=(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))(Ge||{}),Ie=(i=>(i.bar_index="bar_index",i.bar_time="bar_time",i))(Ie||{}),Ti=(i=>(i.abovebar="abovebar",i.belowbar="belowbar",i.price="price",i))(Ti||{}),ws=(i=>(i.actual="actual",i.estimate="estimate",i.standardized="standardized",i))(ws||{}),Tn=(i=>(i.traditional="Traditional",i.fibonacci="Fibonacci",i.woodie="Woodie",i.classic="Classic",i.dm="DM",i.camarilla="Camarilla",i))(Tn||{});class Tp{new({size:t,initial_value:e}={}){return new Xt(t,e)}new_float({size:t,initial_value:e}={}){return new Xt(t,e)}new_int({size:t,initial_value:e}={}){return new Xt(t,e)}new_color({size:t,initial_value:e}={}){return new Xt(t,e)}new_bool({size:t,initial_value:e}={}){return new Xt(t,e)}new_string({size:t,initial_value:e}={}){return new Xt(t,e)}new_line({size:t,initial_value:e}={}){return new Xt(t,e)}new_box({size:t,initial_value:e}={}){return new Xt(t,e)}new_table({size:t,initial_value:e}={}){return new Xt(t,e)}new_linefill({size:t,initial_value:e}={}){return new Xt(t,e)}new_label({size:t,initial_value:e}={}){return new Xt(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 Xt;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 Xt{constructor(t=0,e){K(this,"_arrInstance");this._arrInstance=Array.from(new Array(t||0),()=>xr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=xr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Xt;return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Xt;return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(){const t=new Xt;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"),xr.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!==In.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!==In.descending?this._arrInstance[n]-this._arrInstance[s]:this._arrInstance[s]-this._arrInstance[n]);const r=new Xt;return r._copyData(e),r}standardize(){this._verifySimpleType("number","standardize","int/float");const t=new Xt;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 $p{constructor(t){K(this,"_randomNums");K(this,"_mintick");K(this,"_cacheData");K(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 xr.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 xr.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 Ds(){return Ds=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},Ds.apply(this,arguments)}var Mf={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 Nf(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isComplex===!0||!1}function Sf(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isFraction===!0||!1}function Bf(i){return i&&i.constructor.prototype.isUnit===!0||!1}function qr(i){return typeof i=="string"}var ge=Array.isArray;function le(i){return i&&i.constructor.prototype.isMatrix===!0||!1}function $i(i){return Array.isArray(i)||le(i)}function Op(i){return i&&i.isDenseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function Rp(i){return i&&i.isSparseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function Lp(i){return i&&i.constructor.prototype.isRange===!0||!1}function nu(i){return i&&i.constructor.prototype.isIndex===!0||!1}function Pp(i){return typeof i=="boolean"}function zp(i){return i&&i.constructor.prototype.isResultSet===!0||!1}function qp(i){return i&&i.constructor.prototype.isHelp===!0||!1}function Up(i){return typeof i=="function"}function kp(i){return i instanceof Date}function Wp(i){return i instanceof RegExp}function iu(i){return!!(i&&typeof i=="object"&&i.constructor===Object&&!Nf(i)&&!Sf(i))}function Yp(i){return i===null}function Zp(i){return i===void 0}function jp(i){return i&&i.isAccessorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Gp(i){return i&&i.isArrayNode===!0&&i.constructor.prototype.isNode===!0||!1}function Kp(i){return i&&i.isAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Jp(i){return i&&i.isBlockNode===!0&&i.constructor.prototype.isNode===!0||!1}function Xp(i){return i&&i.isConditionalNode===!0&&i.constructor.prototype.isNode===!0||!1}function Hp(i){return i&&i.isConstantNode===!0&&i.constructor.prototype.isNode===!0||!1}function Qp(i){return i&&i.isFunctionAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Vp(i){return i&&i.isFunctionNode===!0&&i.constructor.prototype.isNode===!0||!1}function tm(i){return i&&i.isIndexNode===!0&&i.constructor.prototype.isNode===!0||!1}function em(i){return i&&i.isNode===!0&&i.constructor.prototype.isNode===!0||!1}function rm(i){return i&&i.isObjectNode===!0&&i.constructor.prototype.isNode===!0||!1}function nm(i){return i&&i.isOperatorNode===!0&&i.constructor.prototype.isNode===!0||!1}function im(i){return i&&i.isParenthesisNode===!0&&i.constructor.prototype.isNode===!0||!1}function sm(i){return i&&i.isRangeNode===!0&&i.constructor.prototype.isNode===!0||!1}function om(i){return i&&i.isRelationalNode===!0&&i.constructor.prototype.isNode===!0||!1}function um(i){return i&&i.isSymbolNode===!0&&i.constructor.prototype.isNode===!0||!1}function am(i){return i&&i.constructor.prototype.isChain===!0||!1}function an(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(iu(i))return fm(i,te);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(i,")"))}function fm(i,t){var e={};for(var r in i)Oi(i,r)&&(e[r]=t(i[r]));return e}function If(i,t){for(var e in t)Oi(t,e)&&(i[e]=t[e]);return i}function Vn(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(!Vn(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)||!Vn(i[e],t[e]))return!1;for(e in t)if(!(e in i))return!1;return!0}else return i===t}}function Oi(i,t){return i&&Object.hasOwnProperty.call(i,t)}function lm(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 cm=["Matrix","Array"],hm=["number","BigNumber","Fraction"],er=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(Mf)};Ds(er,Mf,{MATRIX_OPTIONS:cm,NUMBER_OPTIONS:hm});function Tf(){return!0}function mr(){return!1}function ti(){}const $f="Argument is not a typed-function.";function Of(){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:Tf,isAny:!0};let r,n,s=0,a={createCount:0};function f(O){const Z=r.get(O);if(Z)return Z;let J='Unknown type "'+O+'"';const nt=O.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){J+='. Did you mean "'+st+'" ?';break}throw new TypeError(J)}function l(O){let Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const J=Z?f(Z).index:n.length,nt=[];for(let rt=0;rt<O.length;++rt){if(!O[rt]||typeof O[rt].name!="string"||typeof O[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ct=O[rt].name;if(r.has(ct))throw new TypeError('Duplicate type name "'+ct+'"');nt.push(ct),r.set(ct,{name:ct,test:O[rt].test,isAny:O[rt].isAny,index:J+rt,conversionsTo:[]})}const st=n.slice(J);n=n.slice(0,J).concat(nt).concat(st);for(let rt=J+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}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(J=>{const nt=r.get(J);return!nt.isAny&&nt.test(O)});return Z.length?Z:["any"]}function d(O){return O&&typeof O=="function"&&"_typedFunctionData"in O}function _(O,Z,J){if(!d(O))throw new TypeError($f);const nt=J&&J.exact,st=Array.isArray(Z)?Z.join(","):Z,rt=N(st),ct=y(rt);if(!nt||ct in O.signatures){const Kt=O._typedFunctionData.signatureMap.get(ct);if(Kt)return Kt}const at=rt.length;let ht;if(nt){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 Qt=rt[Kt],pe=[];let Te;for(Te of ht){const Ne=S(Te.params,Kt);if(!(!Ne||Qt.restParam&&!Ne.restParam)){if(!Ne.hasAny){const sr=b(Ne);if(Qt.types.some(or=>!sr.has(or.name)))continue}pe.push(Te)}}if(ht=pe,ht.length===0)break}let ut;for(ut of ht)if(ut.params.length<=at)return ut;throw new TypeError("Signature not found (signature: "+(O.name||"unnamed")+"("+y(rt,", ")+"))")}function D(O,Z,J){return _(O,Z,J).implementation}function g(O,Z){const J=f(Z);if(J.test(O))return O;const nt=J.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+Z+" defined.");for(let st=0;st<nt.length;st++)if(f(nt[st].from).test(O))return nt[st].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(J=>J.name).join(Z)}function v(O){const Z=O.indexOf("...")===0,nt=(Z?O.length>3?O.slice(3):"any":O).split("|").map(at=>f(at.trim()));let st=!1,rt=Z?"...":"";return{types:nt.map(function(at){return st=at.isAny||st,rt+=at.name+"|",{name:at.name,typeIndex:at.index,test:at.test,isAny:at.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:Z}}function E(O){const Z=O.types.map(ct=>ct.name),J=G(Z);let nt=O.hasAny,st=O.name;const rt=J.map(function(ct){const at=f(ct.from);return nt=at.isAny||nt,st+="|"+ct.from,{name:ct.from,typeIndex:at.index,test:at.test,isAny:at.isAny,conversion:ct,conversionIndex:ct.index}});return{types:O.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:O.restParam}}function b(O){return O.typeSet||(O.typeSet=new Set,O.types.forEach(Z=>O.typeSet.add(Z.name))),O.typeSet}function N(O){const Z=[];if(typeof O!="string")throw new TypeError("Signatures must be strings");const J=O.trim();if(J==="")return Z;const nt=J.split(",");for(let st=0;st<nt.length;++st){const rt=v(nt[st].trim());if(rt.restParam&&st!==nt.length-1)throw new SyntaxError('Unexpected rest parameter "'+nt[st]+'": only allowed for the last parameter');if(rt.types.length===0)return null;Z.push(rt)}return Z}function x(O){const Z=It(O);return Z?Z.restParam:!1}function F(O){if(!O||O.types.length===0)return Tf;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,J=f(O.types[1].name).test;return function(st){return Z(st)||J(st)}}else{const Z=O.types.map(function(J){return f(J.name).test});return function(nt){for(let st=0;st<Z.length;st++)if(Z[st](nt))return!0;return!1}}}function M(O){let Z,J,nt;if(x(O)){Z=ee(O).map(F);const st=Z.length,rt=F(It(O)),ct=function(at){for(let ht=st;ht<at.length;ht++)if(!rt(at[ht]))return!1;return!0};return function(ht){for(let ut=0;ut<Z.length;ut++)if(!Z[ut](ht[ut]))return!1;return ct(ht)&&ht.length>=st+1}}else return O.length===0?function(rt){return rt.length===0}:O.length===1?(J=F(O[0]),function(rt){return J(rt[0])&&rt.length===1}):O.length===2?(J=F(O[0]),nt=F(O[1]),function(rt){return J(rt[0])&&nt(rt[1])&&rt.length===2}):(Z=O.map(F),function(rt){for(let ct=0;ct<Z.length;ct++)if(!Z[ct](rt[ct]))return!1;return rt.length===Z.length})}function S(O,Z){return Z<O.length?O[Z]:x(O)?It(O):null}function $(O,Z){const J=S(O,Z);return J?b(J):new Set}function C(O){return O.conversion===null||O.conversion===void 0}function I(O,Z){const J=new Set;return O.forEach(nt=>{const st=$(nt.params,Z);let rt;for(rt of st)J.add(rt)}),J.has("any")?["any"]:Array.from(J)}function R(O,Z,J){let nt,st;const rt=O||"unnamed";let ct=J,at;for(at=0;at<Z.length;at++){const Qt=[];if(ct.forEach(pe=>{const Te=S(pe.params,at),Ne=F(Te);(at<pe.params.length||x(pe.params))&&Ne(Z[at])&&Qt.push(pe)}),Qt.length===0){if(st=I(ct,at),st.length>0){const pe=c(Z[at]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+pe.join(" | ")+", index: "+at+")"),nt.data={category:"wrongType",fn:rt,index:at,actual:pe,expected:st},nt}}else ct=Qt}const ht=ct.map(function(Qt){return x(Qt.params)?1/0:Qt.params.length});if(Z.length<Math.min.apply(null,ht))return st=I(ct,at),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+Z.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:Z.length,expected:st},nt;const ut=Math.max.apply(null,ht);if(Z.length>ut)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+ut+", actual: "+Z.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:Z.length,expectedLength:ut},nt;const Kt=[];for(let Qt=0;Qt<Z.length;++Qt)Kt.push(c(Z[Qt]).join("|"));return nt=new TypeError('Arguments of type "'+Kt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Kt},nt}function U(O){let Z=n.length+1;for(let J=0;J<O.types.length;J++)C(O.types[J])&&(Z=Math.min(Z,O.types[J].typeIndex));return Z}function q(O){let Z=s+1;for(let J=0;J<O.types.length;J++)C(O.types[J])||(Z=Math.min(Z,O.types[J].conversionIndex));return Z}function k(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 J=U(O)-U(Z);if(J<0)return-1;if(J>0)return 1;const nt=q(O)-q(Z);return nt<0?-1:nt>0?1:0}function P(O,Z){const J=O.params,nt=Z.params,st=It(J),rt=It(nt),ct=x(J),at=x(nt);if(ct&&st.hasAny){if(!at||!rt.hasAny)return 1}else if(at&&rt.hasAny)return-1;let ht=0,ut=0,Kt;for(Kt of J)Kt.hasAny&&++ht,Kt.hasConversion&&++ut;let Qt=0,pe=0;for(Kt of nt)Kt.hasAny&&++Qt,Kt.hasConversion&&++pe;if(ht!==Qt)return ht-Qt;if(ct&&st.hasConversion){if(!at||!rt.hasConversion)return 1}else if(at&&rt.hasConversion)return-1;if(ut!==pe)return ut-pe;if(ct){if(!at)return 1}else if(at)return-1;const Te=(J.length-nt.length)*(ct?-1:1);if(Te!==0)return Te;const Ne=[];let sr=0;for(let _n=0;_n<J.length;++_n){const qn=k(J[_n],nt[_n]);Ne.push(qn),sr+=qn}if(sr!==0)return sr;let or;for(or of Ne)if(or!==0)return or;return 0}function G(O){if(O.length===0)return[];const Z=O.map(f);O.length>1&&Z.sort((st,rt)=>st.index-rt.index);let J=Z[0].conversionsTo;if(O.length===1)return J;J=J.concat([]);const nt=new Set(O);for(let st=1;st<Z.length;++st){let rt;for(rt of Z[st].conversionsTo)nt.has(rt.from)||(J.push(rt),nt.add(rt.from))}return J}function j(O,Z){let J=Z;if(O.some(st=>st.hasConversion)){const st=x(O),rt=O.map(Q);J=function(){const at=[],ht=st?arguments.length-1:arguments.length;for(let ut=0;ut<ht;ut++)at[ut]=rt[ut](arguments[ut]);return st&&(at[ht]=arguments[ht].map(rt[ht])),Z.apply(this,at)}}let nt=J;if(x(O)){const st=O.length-1;nt=function(){return J.apply(this,Mt(arguments,0,st).concat([Mt(arguments,st)]))}}return nt}function Q(O){let Z,J,nt,st;const rt=[],ct=[];switch(O.types.forEach(function(at){at.conversion&&(rt.push(f(at.conversion.from).test),ct.push(at.conversion.convert))}),ct.length){case 0:return function(ht){return ht};case 1:return Z=rt[0],nt=ct[0],function(ht){return Z(ht)?nt(ht):ht};case 2:return Z=rt[0],J=rt[1],nt=ct[0],st=ct[1],function(ht){return Z(ht)?nt(ht):J(ht)?st(ht):ht};default:return function(ht){for(let ut=0;ut<ct.length;ut++)if(rt[ut](ht))return ct[ut](ht);return ht}}}function tt(O){function Z(J,nt,st){if(nt<J.length){const rt=J[nt];let ct=[];if(rt.restParam){const at=rt.types.filter(C);at.length<rt.types.length&&ct.push({types:at,name:"..."+at.map(ht=>ht.name).join("|"),hasAny:at.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ct.push(rt)}else ct=rt.types.map(function(at){return{types:[at],name:at.name,hasAny:at.isAny,hasConversion:at.conversion,restParam:!1}});return Ht(ct,function(at){return Z(J,nt+1,st.concat([at]))})}else return[st]}return Z(O,0,[])}function lt(O,Z){const J=Math.max(O.length,Z.length);for(let at=0;at<J;at++){const ht=$(O,at),ut=$(Z,at);let Kt=!1,Qt;for(Qt of ut)if(ht.has(Qt)){Kt=!0;break}if(!Kt)return!1}const nt=O.length,st=Z.length,rt=x(O),ct=x(Z);return rt?ct?nt===st:st>=nt:ct?nt>=st:nt===st}function vt(O){return O.map(Z=>Me(Z)?Ce(Z.referToSelf.callback):nr(Z)?Gt(Z.referTo.references,Z.referTo.callback):Z)}function ft(O,Z,J){const nt=[];let st;for(st of O){let rt=J[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=Z[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function wt(O,Z,J){const nt=vt(O),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ct=!0;for(let at=0;at<nt.length;++at){if(st[at])continue;const ht=nt[at];if(Me(ht))nt[at]=ht.referToSelf.callback(J),nt[at].referToSelf=ht.referToSelf,st[at]=!0,ct=!1;else if(nr(ht)){const ut=ft(ht.referTo.references,nt,Z);ut?(nt[at]=ht.referTo.callback.apply(this,ut),nt[at].referTo=ht.referTo,st[at]=!0,ct=!1):rt=!0}}if(ct&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function yt(O){const Z=/\bthis(\(|\.signatures\b)/;Object.keys(O).forEach(J=>{const nt=O[J];if(Z.test(nt.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function St(O,Z){if(a.createCount++,Object.keys(Z).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&yt(Z);const J=[],nt=[],st={},rt=[];let ct;for(ct in Z){if(!Object.prototype.hasOwnProperty.call(Z,ct))continue;const Yt=N(ct);if(!Yt)continue;J.forEach(function(wn){if(lt(wn,Yt))throw new TypeError('Conflicting signatures "'+y(wn)+'" and "'+y(Yt)+'".')}),J.push(Yt);const Ue=nt.length;nt.push(Z[ct]);const aa=Yt.map(E);let vi;for(vi of tt(aa)){const wn=y(vi);rt.push({params:vi,name:wn,fn:Ue}),vi.every(po=>!po.hasConversion)&&(st[wn]=Ue)}}rt.sort(P);const at=wt(nt,st,Un);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=at[st[ht]]);const ut=[],Kt=new Map;for(ht of rt)Kt.has(ht.name)||(ht.fn=at[ht.fn],ut.push(ht),Kt.set(ht.name,ht));const Qt=ut[0]&&ut[0].params.length<=2&&!x(ut[0].params),pe=ut[1]&&ut[1].params.length<=2&&!x(ut[1].params),Te=ut[2]&&ut[2].params.length<=2&&!x(ut[2].params),Ne=ut[3]&&ut[3].params.length<=2&&!x(ut[3].params),sr=ut[4]&&ut[4].params.length<=2&&!x(ut[4].params),or=ut[5]&&ut[5].params.length<=2&&!x(ut[5].params),_n=Qt&&pe&&Te&&Ne&&sr&&or;for(let Yt=0;Yt<ut.length;++Yt)ut[Yt].test=M(ut[Yt].params);const qn=Qt?F(ut[0].params[0]):mr,lo=pe?F(ut[1].params[0]):mr,qu=Te?F(ut[2].params[0]):mr,Uu=Ne?F(ut[3].params[0]):mr,ku=sr?F(ut[4].params[0]):mr,Wu=or?F(ut[5].params[0]):mr,co=Qt?F(ut[0].params[1]):mr,Yu=pe?F(ut[1].params[1]):mr,Zu=Te?F(ut[2].params[1]):mr,ju=Ne?F(ut[3].params[1]):mr,Gi=sr?F(ut[4].params[1]):mr,Gu=or?F(ut[5].params[1]):mr;for(let Yt=0;Yt<ut.length;++Yt)ut[Yt].implementation=j(ut[Yt].params,ut[Yt].fn);const Ki=Qt?ut[0].implementation:ti,Ku=pe?ut[1].implementation:ti,Ju=Te?ut[2].implementation:ti,Xu=Ne?ut[3].implementation:ti,Hu=sr?ut[4].implementation:ti,Qu=or?ut[5].implementation:ti,Vu=Qt?ut[0].params.length:-1,ta=pe?ut[1].params.length:-1,ea=Te?ut[2].params.length:-1,ho=Ne?ut[3].params.length:-1,ra=sr?ut[4].params.length:-1,na=or?ut[5].params.length:-1,ia=_n?6:0,sa=ut.length,oa=ut.map(Yt=>Yt.test),ua=ut.map(Yt=>Yt.implementation),gi=function(){for(let Ue=ia;Ue<sa;Ue++)if(oa[Ue](arguments))return ua[Ue].apply(this,arguments);return a.onMismatch(O,arguments,ut)};function Un(Yt,Ue){return arguments.length===Vu&&qn(Yt)&&co(Ue)?Ki.apply(this,arguments):arguments.length===ta&&lo(Yt)&&Yu(Ue)?Ku.apply(this,arguments):arguments.length===ea&&qu(Yt)&&Zu(Ue)?Ju.apply(this,arguments):arguments.length===ho&&Uu(Yt)&&ju(Ue)?Xu.apply(this,arguments):arguments.length===ra&&ku(Yt)&&Gi(Ue)?Hu.apply(this,arguments):arguments.length===na&&Wu(Yt)&&Gu(Ue)?Qu.apply(this,arguments):gi.apply(this,arguments)}try{Object.defineProperty(Un,"name",{value:O})}catch{}return Un.signatures=st,Un._typedFunctionData={signatures:ut,signatureMap:Kt},Un}function bt(O,Z,J){throw R(O,Z,J)}function ee(O){return Mt(O,0,O.length-1)}function It(O){return O[O.length-1]}function Mt(O,Z,J){return Array.prototype.slice.call(O,Z,J)}function ie(O,Z){for(let J=0;J<O.length;J++)if(Z(O[J]))return O[J]}function Ht(O,Z){return Array.prototype.concat.apply([],O.map(Z))}function zt(){const O=ee(arguments).map(J=>y(N(J))),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 Ce(O){if(typeof O!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:O}}}function nr(O){return O&&typeof O.referTo=="object"&&Array.isArray(O.referTo.references)&&typeof O.referTo.callback=="function"}function Me(O){return O&&typeof O.referToSelf=="object"&&typeof O.referToSelf.callback=="function"}function Xr(O,Z){if(!O)return Z;if(Z&&Z!==O){const J=new Error("Function names do not match (expected: "+O+", actual: "+Z+")");throw J.data={actual:Z,expected:O},J}return O}function gn(O){let Z;for(const J in O)Object.prototype.hasOwnProperty.call(O,J)&&(d(O[J])||typeof O[J].signature=="string")&&(Z=Xr(Z,O[J].name));return Z}function Hr(O,Z){let J;for(J in Z)if(Object.prototype.hasOwnProperty.call(Z,J)){if(J in O&&Z[J]!==O[J]){const nt=new Error('Signature "'+J+'" is defined twice');throw nt.data={signature:J,sourceFunction:Z[J],destFunction:O[J]},nt}O[J]=Z[J]}}const ir=a;a=function(O){const Z=typeof O=="string",J=Z?1:0;let nt=Z?O:"";const st={};for(let rt=J;rt<arguments.length;++rt){const ct=arguments[rt];let at={},ht;if(typeof ct=="function"?(ht=ct.name,typeof ct.signature=="string"?at[ct.signature]=ct:d(ct)&&(at=ct.signatures)):i(ct)&&(at=ct,Z||(ht=gn(ct))),Object.keys(at).length===0){const ut=new TypeError("Argument to 'typed' at index "+rt+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw ut.data={index:rt,argument:ct},ut}Z||(nt=Xr(nt,ht)),Hr(st,at)}return St(nt||"",st)},a.create=Of,a.createCount=ir.createCount,a.onMismatch=bt,a.throwMismatchError=bt,a.createError=R,a.clear=p,a.clearConversions=h,a.addTypes=l,a._findType=f,a.referTo=zt,a.referToSelf=Ce,a.convert=g,a.findSignature=_,a.find=D,a.isTypedFunction=d,a.warnAgainstDeprecatedThis=!0,a.addType=function(O,Z){let J="any";Z!==!1&&r.has("Object")&&(J="Object"),a.addTypes([O],J)};function vn(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){vn(O);const Z=f(O.to);if(Z.conversionsTo.every(function(J){return J.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){vn(O);const Z=f(O.to),J=ie(Z.conversionsTo,st=>st.from===O.from);if(!J)throw new Error("Attempt to remove nonexistent conversion from "+O.from+" to "+O.to);if(J.convert!==O.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=Z.conversionsTo.indexOf(J);Z.conversionsTo.splice(nt,1)},a.resolve=function(O,Z){if(!d(O))throw new TypeError($f);const J=O._typedFunctionData.signatures;for(let nt=0;nt<J.length;++nt)if(J[nt].test(Z))return J[nt];return null},a}var Rf=Of();function he(i){return typeof i=="boolean"?!0:isFinite(i)?i===Math.round(i):!1}function su(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 ou(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}=Lf(t);switch(e){case"fixed":return mm(i,r);case"exponential":return Pf(i,r);case"engineering":return pm(i,r);case"bin":return su(i,2,n);case"oct":return su(i,8,n);case"hex":return su(i,16,n);case"auto":return dm(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 Lf(i){var t="auto",e,r;if(i!==void 0)if(ae(i))e=i;else if(ye(i))e=i.toNumber();else if(iu(i))i.precision!==void 0&&(e=zf(i.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),i.wordSize!==void 0&&(r=zf(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 ys(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 pm(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ys(i),r=bs(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(""),d=ae(t)&&c.length||c.match(/[1-9]/)?"."+c:"",_=s.slice(0,h).join("")+d+"e"+(n>=0?"+":"")+a.toString();return r.sign+_}function mm(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ys(i),r=typeof t=="number"?bs(e,e.exponent+1+t):e,n=r.coefficients,s=r.exponent+1,a=s+(t||0);return n.length<a&&(n=n.concat(ei(a-n.length))),s<0&&(n=ei(-s+1).concat(n),s=1),s<n.length&&n.splice(s,0,s===0?"0.":"."),r.sign+n.join("")}function Pf(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ys(i),r=t?bs(e,t):e,n=r.coefficients,s=r.exponent;n.length<t&&(n=n.concat(ei(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(s>=0?"+":"")+s}function dm(i,t,e){if(isNaN(i)||!isFinite(i))return String(i);var r=qf(e==null?void 0:e.lowerExp,-3),n=qf(e==null?void 0:e.upperExp,5),s=ys(i),a=t?bs(s,t):s;if(a.exponent<r||a.exponent>=n)return Pf(i,t);var f=a.coefficients,l=a.exponent;f.length<t&&(f=f.concat(ei(t-f.length))),f=f.concat(ei(l-f.length+1+(f.length<t?t-f.length:0))),f=ei(-l).concat(f);var p=l>0?l:0;return p<f.length-1&&f.splice(p+1,0,"."),a.sign+f.join("")}function bs(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 ei(i){for(var t=[],e=0;e<i;e++)t.push(0);return t}function gm(i){return i.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var vm=Number.EPSILON||2220446049250313e-31;function $n(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<=vm?!0:r<=Math.max(Math.abs(i),Math.abs(t))*e}return!1}function zf(i,t){if(ae(i))return i;if(ye(i))return i.toNumber();t()}function qf(i,t){return ae(i)?i:ye(i)?i.toNumber():t}function uu(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 _m(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}=Lf(t);switch(e){case"fixed":return Dm(i,r);case"exponential":return Uf(i,r);case"engineering":return wm(i,r);case"bin":return uu(i,2,n);case"oct":return uu(i,8,n);case"hex":return uu(i,16,n);case"auto":{var s=kf(t==null?void 0:t.lowerExp,-3),a=kf(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=Uf(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 wm(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 Uf(i,t){return t!==void 0?i.toExponential(t-1):i.toExponential()}function Dm(i,t){return i.toFixed(t)}function kf(i,t){return ae(i)?i:ye(i)?i.toNumber():t}function se(i,t){var e=ym(i,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function ym(i,t){if(typeof i=="number")return ou(i,t);if(ye(i))return _m(i,t);if(bm(i))return!t||t.fraction!=="decimal"?i.s*i.n+"/"+i.d:i.toString();if(Array.isArray(i))return Zf(i,t);if(qr(i))return Wf(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=>Wf(r)+": "+se(i[r],t));return"{"+e.join(", ")+"}"}return String(i)}function Wf(i){for(var t=String(i),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Yf?Yf[n]:n,r++}return'"'+e+'"'}var Yf={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Zf(i,t){if(Array.isArray(i)){for(var e="[",r=i.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=Zf(i[n],t);return e+="]",e}else return se(i,t)}function bm(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 fn(i,t,e){if(!(this instanceof fn))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}fn.prototype=new RangeError,fn.prototype.constructor=RangeError,fn.prototype.name="IndexError",fn.prototype.isIndexError=!0;function Ae(i){for(var t=[];Array.isArray(i);)t.push(i.length),i=i[0];return t}function jf(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,"<");jf(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 Gf(i,t){var e=t.length===0;if(e){if(Array.isArray(i))throw new jt(i.length,0)}else jf(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 fn(i,t)}}function au(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 fu(i,t,0,r),i}function fu(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),fu(s,t,p,r);for(n=l;n<f;n++)s=[],i[n]=s,fu(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 lu(i,t){var e=hu(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=cu(t,r);var n=Kf(t);if(r!==n)throw new jt(n,r,"!=");try{return Em(e,t)}catch(s){throw s instanceof jt?new jt(n,r,"!="):s}}function cu(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 Em(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 Jf(i,t,e,r){var n=r||Ae(i);if(e)for(var s=0;s<e;s++)i=[i],n.unshift(1);for(i=Xf(i,t,0);n.length<t;)n.push(1);return i}function Xf(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]=Xf(i[r],t,s)}else for(var a=e;a<t;a++)i=[i];return i}function hu(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 Es(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?Es(s,t):t(s);if(e===void 0)e=f;else if(e!==f)return"mixed"}return e}function Hf(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]=Hf(i[s],t[s],e,r+1);return n}else return i.concat(t)}function Qf(){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 Hf(e,r,t,0)},i[0]);throw new Error("Wrong number of arguments in function concat")}function Am(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];for(var r=t.map(d=>d.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++)As(t[c],s);return s}function As(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 Vf(i,t){var e=Ae(i);if(Vn(e,t))return i;As(e,t);var r=Am(e,t),n=r.length,s=[...Array(n-e.length).fill(1),...e],a=Cm(i);e.length<n&&(a=lu(a,s),e=Ae(a));for(var f=0;f<n;f++)e[f]<r[f]&&(a=xm(a,r[f],f),e=Ae(a));return a}function xm(i,t,e){return Qf(...Array(t).fill(i),e)}function Cm(i){return Ds([],i)}function dt(i,t,e,r){function n(s){var a=lm(s,t.map(Nm));return Fm(i,t,s),e(a)}return n.isFactory=!0,n.fn=i,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Fm(i,t,e){var r=t.filter(s=>!Mm(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 Mm(i){return i&&i[0]==="?"}function Nm(i){return i&&i[0]==="?"?i.slice(1):i}function Sm(i,t){if(el(i)&&tl(i,t))return i[t];throw typeof i[t]=="function"&&Tm(i,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Bm(i,t,e){if(el(i)&&tl(i,t))return i[t]=e,e;throw new Error('No access to property "'+t+'"')}function Im(i,t){return t in i}function tl(i,t){return!i||typeof i!="object"?!1:Oi($m,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Tm(i,t){return i==null||typeof i[t]!="function"||Oi(i,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(i)?!1:Oi(Om,t)?!0:!(t in Object.prototype||t in Function.prototype)}function el(i){return typeof i=="object"&&i&&i.constructor===Object}var $m={length:!0,name:!0},Om={toString:!0,valueOf:!0,toLocaleString:!0};class Rm{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Sm(this.wrappedObject,t)}set(t,e){return Bm(this.wrappedObject,t,e),this}has(t){return Im(this.wrappedObject,t)}entries(){return Lm(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 Lm(i,t){return{next:()=>{var e=i.next();return e.done?e:{value:t(e.value),done:!1}}}}function Pm(i){return i?i instanceof Map||i instanceof Rm||typeof i.set=="function"&&typeof i.get=="function"&&typeof i.keys=="function"&&typeof i.has=="function":!1}var rl=function(){return rl=Rf.create,Rf},zm=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],qm=dt("typed",zm,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:s}=t,a=rl();return a.clear(),a.addTypes([{name:"number",test:ae},{name:"Complex",test:Nf},{name:"BigNumber",test:ye},{name:"Fraction",test:Sf},{name:"Unit",test:Bf},{name:"identifier",test:f=>qr&&/^(?:[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:qr},{name:"Chain",test:am},{name:"Array",test:ge},{name:"Matrix",test:le},{name:"DenseMatrix",test:Op},{name:"SparseMatrix",test:Rp},{name:"Range",test:Lp},{name:"Index",test:nu},{name:"boolean",test:Pp},{name:"ResultSet",test:zp},{name:"Help",test:qp},{name:"function",test:Up},{name:"Date",test:kp},{name:"RegExp",test:Wp},{name:"null",test:Yp},{name:"undefined",test:Zp},{name:"AccessorNode",test:jp},{name:"ArrayNode",test:Gp},{name:"AssignmentNode",test:Kp},{name:"BlockNode",test:Jp},{name:"ConditionalNode",test:Xp},{name:"ConstantNode",test:Hp},{name:"FunctionNode",test:Vp},{name:"FunctionAssignmentNode",test:Qp},{name:"IndexNode",test:tm},{name:"Node",test:em},{name:"ObjectNode",test:rm},{name:"OperatorNode",test:nm},{name:"ParenthesisNode",test:im},{name:"RangeNode",test:sm},{name:"RelationalNode",test:om},{name:"SymbolNode",test:um},{name:"Map",test:Pm},{name:"Object",test:iu}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(e||pu(l),gm(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||xs(l),new r(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return r||xs(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||xs(l),new r(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){s||mu(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||pu(l);try{return new e(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){s||mu(l);try{return new s(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){r||xs(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||pu(l),new e(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return s||mu(l),new s(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||Um(),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&&$i(l[0])&&p.some(d=>!d.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&&$i(l[0])&&p.some(d=>!d.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 pu(i){throw new Error("Cannot convert value ".concat(i," into a BigNumber: no class 'BigNumber' provided"))}function xs(i){throw new Error("Cannot convert value ".concat(i," into a Complex number: no class 'Complex' provided"))}function Um(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function mu(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 ri=9e15,ln=1e9,du="0123456789abcdef",Cs="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Fs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",gu={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ri,maxE:ri,crypto:!1},nl,jr,Nt=!0,Ms="[DecimalError] ",cn=Ms+"Invalid argument: ",il=Ms+"Precision limit exceeded",sl=Ms+"crypto unavailable",ol="[object Decimal]",ze=Math.floor,Fe=Math.pow,km=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Wm=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ym=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ul=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Nr=1e7,Et=7,Zm=9007199254740991,jm=Cs.length-1,vu=Fs.length-1,it={toStringTag:ol};it.absoluteValue=it.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),Dt(i)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(i,t){var e,r=this,n=r.constructor;if(i=new n(i),t=new n(t),!i.s||!t.s)return new n(NaN);if(i.gt(t))throw Error(cn+t);return e=r.cmp(i),e<0?i:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(i){var t,e,r,n,s=this,a=s.d,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},it.cosine=it.cos=function(){var i,t,e=this,r=e.constructor;return e.d?e.d[0]?(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Gm(r,pl(r,e)),r.precision=i,r.rounding=t,Dt(jr==2||jr==3?e.neg():e,i,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var i,t,e,r,n,s,a,f,l,p,h=this,c=h.constructor;if(!h.isFinite()||h.isZero())return new c(h);for(Nt=!1,s=h.s*Fe(h.s*h,1/3),!s||Math.abs(s)==1/0?(e=Oe(h.d),i=h.e,(s=(i-e.length+1)%3)&&(e+=s==1||s==-2?"0":"00"),s=Fe(e,1/3),i=ze((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=oe(p.plus(h).times(f),p.plus(l),a+2,1),Oe(f.d).slice(0,a)===(e=Oe(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 Nt=!0,Dt(r,i,c.rounding,t)},it.decimalPlaces=it.dp=function(){var i,t=this.d,e=NaN;if(t){if(i=t.length-1,e=(i-ze(this.e/Et))*Et,i=t[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(i){return oe(this,new this.constructor(i))},it.dividedToIntegerBy=it.divToInt=function(i){var t=this,e=t.constructor;return Dt(oe(t,new e(i),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(i){return this.cmp(i)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(i){return this.cmp(i)>0},it.greaterThanOrEqualTo=it.gte=function(i){var t=this.cmp(i);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var i,t,e,r,n,s=this,a=s.constructor,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/Is(4,i)).toString()):(i=16,t="2.3283064365386962890625e-10"),s=ni(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)},it.hyperbolicSine=it.sinh=function(){var i,t,e,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<3)n=ni(s,2,n,n,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,n=n.times(1/Is(5,i)),n=ni(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)},it.hyperbolicTangent=it.tanh=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+7,r.rounding=1,oe(e.sinh(),e.cosh(),r.precision=i,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var i,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,s=e.rounding;return r!==-1?r===0?t.isNeg()?Sr(e,n,s):new e(0):new e(NaN):t.isZero()?Sr(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),i=Sr(e,n+4,s).times(.5),e.precision=n,e.rounding=s,i.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var i,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(i=r.precision,t=r.rounding,r.precision=i+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,Nt=!1,e=e.times(e).minus(1).sqrt().plus(e),Nt=!0,r.precision=i,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var i,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,Nt=!1,e=e.times(e).plus(1).sqrt().plus(e),Nt=!0,r.precision=i,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var i,t,e,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(i=s.precision,t=s.rounding,r=n.sd(),Math.max(r,i)<2*-n.e-1?Dt(new s(n),i,t,!0):(s.precision=e=r-n.e,n=oe(n.plus(1),new s(1).minus(n),e+i,1),s.precision=i+4,s.rounding=1,n=n.ln(),s.precision=i,s.rounding=t,n.times(.5))):new s(NaN)},it.inverseSine=it.asin=function(){var i,t,e,r,n=this,s=n.constructor;return n.isZero()?new s(n):(t=n.abs().cmp(1),e=s.precision,r=s.rounding,t!==-1?t===0?(i=Sr(s,e+4,r).times(.5),i.s=n.s,i):new s(NaN):(s.precision=e+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var i,t,e,r,n,s,a,f,l,p=this,h=p.constructor,c=h.precision,d=h.rounding;if(p.isFinite()){if(p.isZero())return new h(p);if(p.abs().eq(1)&&c+4<=vu)return a=Sr(h,c+4,d).times(.25),a.s=p.s,a}else{if(!p.s)return new h(NaN);if(c+4<=vu)return a=Sr(h,c+4,d).times(.5),a.s=p.s,a}for(h.precision=f=c+10,h.rounding=1,e=Math.min(28,f/Et+2|0),i=e;i;--i)p=p.div(p.times(p).plus(1).sqrt().plus(1));for(Nt=!1,t=Math.ceil(f/Et),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)),Nt=!0,Dt(a,h.precision=c,h.rounding=d,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&ze(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(i){return this.cmp(i)<0},it.lessThanOrEqualTo=it.lte=function(i){return this.cmp(i)<1},it.logarithm=it.log=function(i){var t,e,r,n,s,a,f,l,p=this,h=p.constructor,c=h.precision,d=h.rounding,_=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(Nt=!1,f=c+_,a=pn(p,f),r=t?Bs(h,f+10):pn(i,f),l=oe(a,r,f,1),Ri(l.d,n=c,d))do if(f+=10,a=pn(p,f),r=t?Bs(h,f+10):pn(i,f),l=oe(a,r,f,1),!s){+Oe(l.d).slice(n+1,n+15)+1==1e14&&(l=Dt(l,c+1,0));break}while(Ri(l.d,n+=10,d));return Nt=!0,Dt(l,c,d)},it.minus=it.sub=function(i){var t,e,r,n,s,a,f,l,p,h,c,d,_=this,D=_.constructor;if(i=new D(i),!_.d||!i.d)return!_.s||!i.s?i=new D(NaN):_.d?i.s=-i.s:i=new D(i.d||_.s!==i.s?_:NaN),i;if(_.s!=i.s)return i.s=-i.s,_.plus(i);if(p=_.d,d=i.d,f=D.precision,l=D.rounding,!p[0]||!d[0]){if(d[0])i.s=-i.s;else if(p[0])i=new D(_);else return new D(l===3?-0:0);return Nt?Dt(i,f,l):i}if(e=ze(i.e/Et),h=ze(_.e/Et),p=p.slice(),s=h-e,s){for(c=s<0,c?(t=p,s=-s,a=d.length):(t=d,e=h,a=p.length),r=Math.max(Math.ceil(f/Et),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=d.length,c=r<a,c&&(a=r),r=0;r<a;r++)if(p[r]!=d[r]){c=p[r]<d[r];break}s=0}for(c&&(t=p,p=d,d=t,i.s=-i.s),a=p.length,r=d.length-a;r>0;--r)p[a++]=0;for(r=d.length;r>s;){if(p[--r]<d[r]){for(n=r;n&&p[--n]===0;)p[n]=Nr-1;--p[n],p[r]+=Nr}p[r]-=d[r]}for(;p[--a]===0;)p.pop();for(;p[0]===0;p.shift())--e;return p[0]?(i.d=p,i.e=Ss(p,e),Nt?Dt(i,f,l):i):new D(l===3?-0:0)},it.modulo=it.mod=function(i){var t,e=this,r=e.constructor;return i=new r(i),!e.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(Nt=!1,r.modulo==9?(t=oe(e,i.abs(),0,3,1),t.s*=i.s):t=oe(e,i,0,r.modulo,1),t=t.times(i),Nt=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return _u(this)},it.naturalLogarithm=it.ln=function(){return pn(this)},it.negated=it.neg=function(){var i=new this.constructor(this);return i.s=-i.s,Dt(i)},it.plus=it.add=function(i){var t,e,r,n,s,a,f,l,p,h,c=this,d=c.constructor;if(i=new d(i),!c.d||!i.d)return!c.s||!i.s?i=new d(NaN):c.d||(i=new d(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=d.precision,l=d.rounding,!p[0]||!h[0])return h[0]||(i=new d(c)),Nt?Dt(i,f,l):i;if(s=ze(c.e/Et),r=ze(i.e/Et),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/Et),a=s>a?s+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=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)/Nr|0,p[n]%=Nr;for(t&&(p.unshift(t),++r),a=p.length;p[--a]==0;)p.pop();return i.d=p,i.e=Ss(p,r),Nt?Dt(i,f,l):i},it.precision=it.sd=function(i){var t,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(cn+i);return e.d?(t=al(e.d),i&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var i=this,t=i.constructor;return Dt(new t(i),i.e+1,t.rounding)},it.sine=it.sin=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Jm(r,pl(r,e)),r.precision=i,r.rounding=t,Dt(jr>2?e.neg():e,i,t,!0)):new r(NaN)},it.squareRoot=it.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(Nt=!1,p=Math.sqrt(+a),p==0||p==1/0?(t=Oe(f),(t.length+l)%2==0&&(t+="0"),p=Math.sqrt(t),l=ze((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(oe(a,s,e+2,1)).times(.5),Oe(s.d).slice(0,e)===(t=Oe(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 Nt=!0,Dt(r,l,h.rounding,i)},it.tangent=it.tan=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+10,r.rounding=1,e=e.sin(),e.s=1,e=oe(e,new r(1).minus(e.times(e)).sqrt(),i+10,0),r.precision=i,r.rounding=t,Dt(jr==2||jr==4?e.neg():e,i,t,!0)):new r(NaN)},it.times=it.mul=function(i){var t,e,r,n,s,a,f,l,p,h=this,c=h.constructor,d=h.d,_=(i=new c(i)).d;if(i.s*=h.s,!d||!d[0]||!_||!_[0])return new c(!i.s||d&&!d[0]&&!_||_&&!_[0]&&!d?NaN:!d||!_?i.s/0:i.s*0);for(e=ze(h.e/Et)+ze(i.e/Et),l=d.length,p=_.length,l<p&&(s=d,d=_,_=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]+_[r]*d[n-r-1]+t,s[n--]=f%Nr|0,t=f/Nr|0;s[n]=(s[n]+t)%Nr|0}for(;!s[--a];)s.pop();return t?++e:s.shift(),i.d=s,i.e=Ss(s,e),Nt?Dt(i,c.precision,c.rounding):i},it.toBinary=function(i,t){return Du(this,2,i,t)},it.toDecimalPlaces=it.toDP=function(i,t){var e=this,r=e.constructor;return e=new r(e),i===void 0?e:(Ke(i,0,ln),t===void 0?t=r.rounding:Ke(t,0,8),Dt(e,i+e.e+1,t))},it.toExponential=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=Ur(r,!0):(Ke(i,0,ln),t===void 0?t=n.rounding:Ke(t,0,8),r=Dt(new n(r),i+1,t),e=Ur(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(i,t){var e,r,n=this,s=n.constructor;return i===void 0?e=Ur(n):(Ke(i,0,ln),t===void 0?t=s.rounding:Ke(t,0,8),r=Dt(new s(n),i+n.e+1,t),e=Ur(r,!1,i+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(i){var t,e,r,n,s,a,f,l,p,h,c,d,_=this,D=_.d,g=_.constructor;if(!D)return new g(_);if(p=e=new g(1),r=l=new g(0),t=new g(r),s=t.e=al(D)-_.e-1,a=s%Et,t.d[0]=Fe(10,a<0?Et+a:a),i==null)i=s>0?t:p;else{if(f=new g(i),!f.isInt()||f.lt(p))throw Error(cn+f);i=f.gt(t)?s>0?t:p:f}for(Nt=!1,f=new g(Oe(D)),h=g.precision,g.precision=s=D.length*Et*2;c=oe(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=oe(i.minus(e),r,0,1,1),l=l.plus(n.times(p)),e=e.plus(n.times(r)),l.s=p.s=_.s,d=oe(p,r,s,1).minus(_).abs().cmp(oe(l,e,s,1).minus(_).abs())<1?[p,r]:[l,e],g.precision=h,Nt=!0,d},it.toHexadecimal=it.toHex=function(i,t){return Du(this,16,i,t)},it.toNearest=function(i,t){var e=this,r=e.constructor;if(e=new r(e),i==null){if(!e.d)return e;i=new r(1),t=r.rounding}else{if(i=new r(i),t===void 0?t=r.rounding:Ke(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]?(Nt=!1,e=oe(e,i,0,t,1).times(i),Nt=!0,Dt(e)):(i.s=e.s,e=i),e},it.toNumber=function(){return+this},it.toOctal=function(i,t){return Du(this,8,i,t)},it.toPower=it.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(Fe(+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=ze(i.e/Et),t>=i.d.length-1&&(e=p<0?-p:p)<=Zm)return n=fl(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=Fe(+f,p),t=e==0||!isFinite(e)?ze(p*(Math.log("0."+Oe(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):(Nt=!1,l.rounding=f.s=1,e=Math.min(12,(t+"").length),n=_u(i.times(pn(f,r+e)),r),n.d&&(n=Dt(n,r+5,1),Ri(n.d,r,s)&&(t=r+10,n=Dt(_u(i.times(pn(f,t+e)),t),t+5,1),+Oe(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,Nt=!0,l.rounding=s,Dt(n,r,s))},it.toPrecision=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=Ur(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(Ke(i,1,ln),t===void 0?t=n.rounding:Ke(t,0,8),r=Dt(new n(r),i,t),e=Ur(r,i<=r.e||r.e<=n.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(i,t){var e=this,r=e.constructor;return i===void 0?(i=r.precision,t=r.rounding):(Ke(i,1,ln),t===void 0?t=r.rounding:Ke(t,0,8)),Dt(new r(e),i,t)},it.toString=function(){var i=this,t=i.constructor,e=Ur(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var i=this,t=i.constructor,e=Ur(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()?"-"+e:e};function Oe(i){var t,e,r,n=i.length-1,s="",a=i[0];if(n>0){for(s+=a,t=1;t<n;t++)r=i[t]+"",e=Et-r.length,e&&(s+=hn(e)),s+=r;a=i[t],r=a+"",e=Et-r.length,e&&(s+=hn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}function Ke(i,t,e){if(i!==~~i||i<t||i>e)throw Error(cn+i)}function Ri(i,t,e,r){var n,s,a,f;for(s=i[0];s>=10;s/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),s=Fe(10,Et-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)==Fe(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)==Fe(10,t-3)-1,a}function Ns(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]+=du.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 Gm(i,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Is(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i.precision+=e,t=ni(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 oe=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,d,_,D,g,y,v,E,b,N,x,F,M,S,$,C,I,R,U=r.constructor,q=r.s==n.s?1:-1,k=r.d,P=n.d;if(!k||!k[0]||!P||!P[0])return new U(!r.s||!n.s||(k?P&&k[0]==P[0]:!P)?NaN:k&&k[0]==0||!P?q*0:q/0);for(l?(_=1,h=r.e-n.e):(l=Nr,_=Et,h=ze(r.e/_)-ze(n.e/_)),I=P.length,$=k.length,v=new U(q),E=v.d=[],c=0;P[c]==(k[c]||0);c++);if(P[c]>(k[c]||0)&&h--,s==null?(F=s=U.precision,a=U.rounding):f?F=s+(r.e-n.e)+1:F=s,F<0)E.push(1),D=!0;else{if(F=F/_+2|0,c=0,I==1){for(d=0,P=P[0],F++;(c<$||d)&&F--;c++)M=d*l+(k[c]||0),E[c]=M/P|0,d=M%P|0;D=d||c<$}else{for(d=l/(P[0]+1)|0,d>1&&(P=i(P,d,l),k=i(k,d,l),I=P.length,$=k.length),S=I,b=k.slice(0,I),N=b.length;N<I;)b[N++]=0;R=P.slice(),R.unshift(0),C=P[0],P[1]>=l/2&&++C;do d=0,p=t(P,b,I,N),p<0?(x=b[0],I!=N&&(x=x*l+(b[1]||0)),d=x/C|0,d>1?(d>=l&&(d=l-1),g=i(P,d,l),y=g.length,N=b.length,p=t(g,b,y,N),p==1&&(d--,e(g,I<y?R:P,y,l))):(d==0&&(p=d=1),g=P.slice()),y=g.length,y<N&&g.unshift(0),e(b,g,N,l),p==-1&&(N=b.length,p=t(P,b,I,N),p<1&&(d++,e(b,I<N?R:P,N,l))),N=b.length):p===0&&(d++,b=[0]),E[c++]=d,p&&b[0]?b[N++]=k[S]||0:(b=[k[S]],N=1);while((S++<$||b[0]!==void 0)&&F--);D=b[0]!==void 0}E[0]||E.shift()}if(_==1)v.e=h,nl=D;else{for(c=1,d=E[0];d>=10;d/=10)c++;v.e=c+h*_-1,Dt(v,f?s+v.e+1:s,a,D)}return v}}();function Dt(i,t,e,r){var n,s,a,f,l,p,h,c,d,_=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+=Et,a=t,h=c[d=0],l=h/Fe(10,n-a-1)%10|0;else if(d=Math.ceil((s+1)/Et),f=c.length,d>=f)if(r){for(;f++<=d;)c.push(0);h=l=0,n=1,s%=Et,a=s-Et+1}else break t;else{for(h=f=c[d],n=1;f>=10;f/=10)n++;s%=Et,a=s-Et+n,l=a<0?0:h/Fe(10,n-a-1)%10|0}if(r=r||t<0||c[d+1]!==void 0||(a<0?h:h%Fe(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/Fe(10,n-a):0:c[d-1])%10&1||e==(i.s<0?8:7)),t<1||!c[0])return c.length=0,p?(t-=i.e+1,c[0]=Fe(10,(Et-t%Et)%Et),i.e=-t||0):c[0]=i.e=0,i;if(s==0?(c.length=d,f=1,d--):(c.length=d+1,f=Fe(10,Et-s),c[d]=a>0?(h/Fe(10,n-a)%Fe(10,a)|0)*f:0),p)for(;;)if(d==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]==Nr&&(c[0]=1));break}else{if(c[d]+=f,c[d]!=Nr)break;c[d--]=0,f=1}for(s=c.length;c[--s]===0;)c.pop()}return Nt&&(i.e>_.maxE?(i.d=null,i.e=NaN):i.e<_.minE&&(i.e=0,i.d=[0])),i}function Ur(i,t,e){if(!i.isFinite())return hl(i);var r,n=i.e,s=Oe(i.d),a=s.length;return t?(e&&(r=e-a)>0?s=s.charAt(0)+"."+s.slice(1)+hn(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i.e<0?"e":"e+")+i.e):n<0?(s="0."+hn(-n-1)+s,e&&(r=e-a)>0&&(s+=hn(r))):n>=a?(s+=hn(n+1-a),e&&(r=e-n-1)>0&&(s=s+"."+hn(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(s+="."),s+=hn(r))),s}function Ss(i,t){var e=i[0];for(t*=Et;e>=10;e/=10)t++;return t}function Bs(i,t,e){if(t>jm)throw Nt=!0,e&&(i.precision=e),Error(il);return Dt(new i(Cs),t,1,!0)}function Sr(i,t,e){if(t>vu)throw Error(il);return Dt(new i(Fs),t,e,!0)}function al(i){var t=i.length-1,e=t*Et+1;if(t=i[t],t){for(;t%10==0;t/=10)e--;for(t=i[0];t>=10;t/=10)e++}return e}function hn(i){for(var t="";i--;)t+="0";return t}function fl(i,t,e,r){var n,s=new i(1),a=Math.ceil(r/Et+4);for(Nt=!1;;){if(e%2&&(s=s.times(t),ml(s.d,a)&&(n=!0)),e=ze(e/2),e===0){e=s.d.length-1,n&&s.d[e]===0&&++s.d[e];break}t=t.times(t),ml(t.d,a)}return Nt=!0,s}function ll(i){return i.d[i.d.length-1]&1}function cl(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 _u(i,t){var e,r,n,s,a,f,l,p=0,h=0,c=0,d=i.constructor,_=d.rounding,D=d.precision;if(!i.d||!i.d[0]||i.e>17)return new d(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(t==null?(Nt=!1,l=D):l=t,f=new d(.03125);i.e>-2;)i=i.times(f),c+=5;for(r=Math.log(Fe(2,c))/Math.LN10*2+5|0,l+=r,e=s=a=new d(1),d.precision=l;;){if(s=Dt(s.times(i),l,1),e=e.times(++h),f=a.plus(oe(s,e,l,1)),Oe(f.d).slice(0,l)===Oe(a.d).slice(0,l)){for(n=c;n--;)a=Dt(a.times(a),l,1);if(t==null)if(p<3&&Ri(a.d,l-r,_,p))d.precision=l+=10,e=s=f=new d(1),h=0,p++;else return Dt(a,d.precision=D,_,Nt=!0);else return d.precision=D,a}a=f}}function pn(i,t){var e,r,n,s,a,f,l,p,h,c,d,_=1,D=10,g=i,y=g.d,v=g.constructor,E=v.rounding,b=v.precision;if(g.s<0||!y||!y[0]||!g.e&&y[0]==1&&y.length==1)return new v(y&&!y[0]?-1/0:g.s!=1?NaN:y?0:g);if(t==null?(Nt=!1,h=b):h=t,v.precision=h+=D,e=Oe(y),r=e.charAt(0),Math.abs(s=g.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)g=g.times(i),e=Oe(g.d),r=e.charAt(0),_++;s=g.e,r>1?(g=new v("0."+e),s++):g=new v(r+"."+e.slice(1))}else return p=Bs(v,h+2,b).times(s+""),g=pn(new v(r+"."+e.slice(1)),h-D).plus(p),v.precision=b,t==null?Dt(g,b,E,Nt=!0):g;for(c=g,l=a=g=oe(g.minus(1),g.plus(1),h,1),d=Dt(g.times(g),h,1),n=3;;){if(a=Dt(a.times(d),h,1),p=l.plus(oe(a,new v(n),h,1)),Oe(p.d).slice(0,h)===Oe(l.d).slice(0,h))if(l=l.times(2),s!==0&&(l=l.plus(Bs(v,h+2,b).times(s+""))),l=oe(l,new v(_),h,1),t==null)if(Ri(l.d,h-D,E,f))v.precision=h+=D,p=a=g=oe(c.minus(1),c.plus(1),h,1),d=Dt(g.times(g),h,1),n=f=1;else return Dt(l,v.precision=b,E,Nt=!0);else return v.precision=b,l;l=p,n+=2}}function hl(i){return String(i.s*i.s/0)}function wu(i,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,i.e=e=e-r-1,i.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&i.d.push(+t.slice(0,r)),n-=Et;r<n;)i.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";i.d.push(+t),Nt&&(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 Km(i,t){var e,r,n,s,a,f,l,p,h;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),ul.test(t))return wu(i,t)}else if(t==="Infinity"||t==="NaN")return+t||(i.s=NaN),i.e=NaN,i.d=null,i;if(Wm.test(t))e=16,t=t.toLowerCase();else if(km.test(t))e=2;else if(Ym.test(t))e=8;else throw Error(cn+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=fl(r,new r(e),s,s*2)),p=Ns(t,e,Nr),h=p.length-1,s=h;p[s]===0;--s)p.pop();return s<0?new r(i.s*0):(i.e=Ss(p,h),i.d=p,Nt=!1,a&&(i=oe(i,n,f*4)),l&&(i=i.times(Math.abs(l)<54?Fe(2,l):ii.pow(2,l))),Nt=!0,i)}function Jm(i,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:ni(i,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Is(5,e)),t=ni(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 ni(i,t,e,r,n){var s,a,f,l,p=i.precision,h=Math.ceil(p/Et);for(Nt=!1,l=e.times(e),f=new i(r);;){if(a=oe(f.times(l),new i(t++*t++),p,1),f=n?r.plus(a):r.minus(a),r=oe(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 Nt=!0,a.d.length=h+1,a}function Is(i,t){for(var e=i;--t;)e*=i;return e}function pl(i,t){var e,r=t.s<0,n=Sr(i,i.precision,1),s=n.times(.5);if(t=t.abs(),t.lte(s))return jr=r?4:1,t;if(e=t.divToInt(n),e.isZero())jr=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(s))return jr=ll(e)?r?2:3:r?4:1,t;jr=ll(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Du(i,t,e,r){var n,s,a,f,l,p,h,c,d,_=i.constructor,D=e!==void 0;if(D?(Ke(e,1,ln),r===void 0?r=_.rounding:Ke(r,0,8)):(e=_.precision,r=_.rounding),!i.isFinite())h=hl(i);else{for(h=Ur(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(".",""),d=new _(1),d.e=h.length-a,d.d=Ns(Ur(d),10,n),d.e=d.d.length),c=Ns(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 _(i),i.d=c,i.e=s,i=oe(i,d,e,r,0,n),c=i.d,s=i.e,p=nl),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+=du.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=Ns(h,n,t),l=c.length;!c[l-1];--l);for(a=1,h="1.";a<l;a++)h+=du.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 ml(i,t){if(i.length>t)return i.length=t,!0}function Xm(i){return new this(i).abs()}function Hm(i){return new this(i).acos()}function Qm(i){return new this(i).acosh()}function Vm(i,t){return new this(i).plus(t)}function td(i){return new this(i).asin()}function ed(i){return new this(i).asinh()}function rd(i){return new this(i).atan()}function nd(i){return new this(i).atanh()}function id(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=Sr(this,s,1).times(t.s>0?.25:.75),e.s=i.s):!t.d||i.isZero()?(e=t.s<0?Sr(this,r,n):new this(0),e.s=i.s):!i.d||t.isZero()?(e=Sr(this,s,1).times(.5),e.s=i.s):t.s<0?(this.precision=s,this.rounding=1,e=this.atan(oe(i,t,s,1)),t=Sr(this,s,1),this.precision=r,this.rounding=n,e=i.s<0?e.minus(t):e.plus(t)):e=this.atan(oe(i,t,s,1)),e}function sd(i){return new this(i).cbrt()}function od(i){return Dt(i=new this(i),i.e+1,2)}function ud(i,t,e){return new this(i).clamp(t,e)}function ad(i){if(!i||typeof i!="object")throw Error(Ms+"Object expected");var t,e,r,n=i.defaults===!0,s=["precision",1,ln,"rounding",0,8,"toExpNeg",-ri,0,"toExpPos",0,ri,"maxE",0,ri,"minE",-ri,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],n&&(this[e]=gu[e]),(r=i[e])!==void 0)if(ze(r)===r&&r>=s[t+1]&&r<=s[t+2])this[e]=r;else throw Error(cn+e+": "+r);if(e="crypto",n&&(this[e]=gu[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(sl);else this[e]=!1;else throw Error(cn+e+": "+r);return this}function fd(i){return new this(i).cos()}function ld(i){return new this(i).cosh()}function dl(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,gl(s)){p.s=s.s,Nt?!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++;Nt?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 wu(p,s.toString())}else if(l!=="string")throw Error(cn+s);return(f=s.charCodeAt(0))===45?(s=s.slice(1),p.s=-1):(f===43&&(s=s.slice(1)),p.s=1),ul.test(s)?wu(p,s):Km(p,s)}if(n.prototype=it,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=ad,n.clone=dl,n.isDecimal=gl,n.abs=Xm,n.acos=Hm,n.acosh=Qm,n.add=Vm,n.asin=td,n.asinh=ed,n.atan=rd,n.atanh=nd,n.atan2=id,n.cbrt=sd,n.ceil=od,n.clamp=ud,n.cos=fd,n.cosh=ld,n.div=cd,n.exp=hd,n.floor=pd,n.hypot=md,n.ln=dd,n.log=gd,n.log10=_d,n.log2=vd,n.max=wd,n.min=Dd,n.mod=yd,n.mul=bd,n.pow=Ed,n.random=Ad,n.round=xd,n.sign=Cd,n.sin=Fd,n.sinh=Md,n.sqrt=Nd,n.sub=Sd,n.sum=Bd,n.tan=Id,n.tanh=Td,n.trunc=$d,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 cd(i,t){return new this(i).div(t)}function hd(i){return new this(i).exp()}function pd(i){return Dt(i=new this(i),i.e+1,3)}function md(){var i,t,e=new this(0);for(Nt=!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 Nt=!0,new this(1/0);e=t}return Nt=!0,e.sqrt()}function gl(i){return i instanceof ii||i&&i.toStringTag===ol||!1}function dd(i){return new this(i).ln()}function gd(i,t){return new this(i).log(t)}function vd(i){return new this(i).log(2)}function _d(i){return new this(i).log(10)}function wd(){return cl(this,arguments,"lt")}function Dd(){return cl(this,arguments,"gt")}function yd(i,t){return new this(i).mod(t)}function bd(i,t){return new this(i).mul(t)}function Ed(i,t){return new this(i).pow(t)}function Ad(i){var t,e,r,n,s=0,a=new this(1),f=[];if(i===void 0?i=this.precision:Ke(i,1,ln),r=Math.ceil(i/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)n=t[s],n>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]: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(sl);else for(;s<r;)f[s++]=Math.random()*1e7|0;for(r=f[--s],i%=Et,r&&i&&(n=Fe(10,Et-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-=Et)f.shift();for(r=1,n=f[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=f,a}function xd(i){return Dt(i=new this(i),i.e+1,this.rounding)}function Cd(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Fd(i){return new this(i).sin()}function Md(i){return new this(i).sinh()}function Nd(i){return new this(i).sqrt()}function Sd(i,t){return new this(i).sub(t)}function Bd(){var i=0,t=arguments,e=new this(t[i]);for(Nt=!1;e.s&&++i<t.length;)e=e.plus(t[i]);return Nt=!0,Dt(e,this.precision,this.rounding)}function Id(i){return new this(i).tan()}function Td(i){return new this(i).tanh()}function $d(i){return Dt(i=new this(i),i.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var ii=it.constructor=dl(gu);Cs=new ii(Cs),Fs=new ii(Fs);var Od="BigNumber",Rd=["?on","config"],Ld=dt(Od,Rd,i=>{var{on:t,config:e}=i,r=ii.clone({precision:e.precision,modulo:ii.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}),vl={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 d=Math.PI/4;if(-d>c||c>d)return Math.cos(c)-1;var _=c*c;return _*(_*(_*(_*(_*(_*(_*(_/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(c,d){var _=Math.abs(c),D=Math.abs(d);return _<3e3&&D<3e3?Math.sqrt(_*_+D*D):(_<D?(_=D,D=c/d):D=d/c,_*Math.sqrt(1+D*D))},f=function(){throw SyntaxError("Invalid Param")};function l(c,d){var _=Math.abs(c),D=Math.abs(d);return c===0?Math.log(D):d===0?Math.log(_):_<3e3&&D<3e3?Math.log(c*c+d*d)*.5:(c=c/2,d=d/2,.5*Math.log(c*c+d*d)+Math.LN2)}var p=function(c,d){var _={re:0,im:0};if(c==null)_.re=_.im=0;else if(d!==void 0)_.re=c,_.im=d;else switch(typeof c){case"object":if("im"in c&&"re"in c)_.re=c.re,_.im=c.im;else if("abs"in c&&"arg"in c){if(!Number.isFinite(c.abs)&&Number.isFinite(c.arg))return h.INFINITY;_.re=c.abs*Math.cos(c.arg),_.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;_.re=c.r*Math.cos(c.phi),_.im=c.r*Math.sin(c.phi)}else c.length===2?(_.re=c[0],_.im=c[1]):f();break;case"string":_.im=_.re=0;var D=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),g=1,y=0;D===null&&f();for(var v=0;v<D.length;v++){var E=D[v];E===" "||E===" "||E===`
46
+ `||(E==="+"?g++:E==="-"?y++:E==="i"||E==="I"?(g+y===0&&f(),D[v+1]!==" "&&!isNaN(D[v+1])?(_.im+=parseFloat((y%2?"-":"")+D[v+1]),v++):_.im+=parseFloat((y%2?"-":"")+"1"),g=y=0):((g+y===0||isNaN(E))&&f(),D[v+1]==="i"||D[v+1]==="I"?(_.im+=parseFloat((y%2?"-":"")+E),v++):_.re+=parseFloat((y%2?"-":"")+E),g=y=0))}g+y>0&&f();break;case"number":_.im=0,_.re=c;break;default:f()}return isNaN(_.re)||isNaN(_.im),_};function h(c,d){if(!(this instanceof h))return new h(c,d);var _=p(c,d);this.re=_.re,this.im=_.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,d){var _=new h(c,d);return this.isInfinite()&&_.isInfinite()?h.NAN:this.isInfinite()||_.isInfinite()?h.INFINITY:new h(this.re+_.re,this.im+_.im)},sub:function(c,d){var _=new h(c,d);return this.isInfinite()&&_.isInfinite()?h.NAN:this.isInfinite()||_.isInfinite()?h.INFINITY:new h(this.re-_.re,this.im-_.im)},mul:function(c,d){var _=new h(c,d);return this.isInfinite()&&_.isZero()||this.isZero()&&_.isInfinite()?h.NAN:this.isInfinite()||_.isInfinite()?h.INFINITY:_.im===0&&this.im===0?new h(this.re*_.re,0):new h(this.re*_.re-this.im*_.im,this.re*_.im+this.im*_.re)},div:function(c,d){var _=new h(c,d);if(this.isZero()&&_.isZero()||this.isInfinite()&&_.isInfinite())return h.NAN;if(this.isInfinite()||_.isZero())return h.INFINITY;if(this.isZero()||_.isInfinite())return h.ZERO;c=this.re,d=this.im;var D=_.re,g=_.im,y,v;return g===0?new h(c/D,d/D):Math.abs(D)<Math.abs(g)?(v=D/g,y=D*v+g,new h((c*v+d)/y,(d*v-c)/y)):(v=g/D,y=g*v+D,new h((c+d*v)/y,(d-c*v)/y))},pow:function(c,d){var _=new h(c,d);if(c=this.re,d=this.im,_.isZero())return h.ONE;if(_.im===0){if(d===0&&c>0)return new h(Math.pow(c,_.re),0);if(c===0)switch((_.re%4+4)%4){case 0:return new h(Math.pow(d,_.re),0);case 1:return new h(0,Math.pow(d,_.re));case 2:return new h(-Math.pow(d,_.re),0);case 3:return new h(0,-Math.pow(d,_.re))}}if(c===0&&d===0&&_.re>0&&_.im>=0)return h.ZERO;var D=Math.atan2(d,c),g=l(c,d);return c=Math.exp(_.re*g-_.im*D),d=_.im*g+_.re*D,new h(c*Math.cos(d),c*Math.sin(d))},sqrt:function(){var c=this.re,d=this.im,_=this.abs(),D,g;if(c>=0){if(d===0)return new h(Math.sqrt(c),0);D=.5*Math.sqrt(2*(_+c))}else D=Math.abs(d)/Math.sqrt(2*(_-c));return c<=0?g=.5*Math.sqrt(2*(_-c)):g=Math.abs(d)/Math.sqrt(2*(_+c)),new h(D,d<0?-g:g)},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,d=this.im;return new h(Math.expm1(c)*Math.cos(d)+s(d),Math.exp(c)*Math.sin(d))},log:function(){var c=this.re,d=this.im;return new h(l(c,d),Math.atan2(d,c))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,d=this.im;return new h(Math.sin(c)*r(d),Math.cos(c)*n(d))},cos:function(){var c=this.re,d=this.im;return new h(Math.cos(c)*r(d),-Math.sin(c)*n(d))},tan:function(){var c=2*this.re,d=2*this.im,_=Math.cos(c)+r(d);return new h(Math.sin(c)/_,n(d)/_)},cot:function(){var c=2*this.re,d=2*this.im,_=Math.cos(c)-r(d);return new h(-Math.sin(c)/_,n(d)/_)},sec:function(){var c=this.re,d=this.im,_=.5*r(2*d)+.5*Math.cos(2*c);return new h(Math.cos(c)*r(d)/_,Math.sin(c)*n(d)/_)},csc:function(){var c=this.re,d=this.im,_=.5*r(2*d)-.5*Math.cos(2*c);return new h(Math.sin(c)*r(d)/_,-Math.cos(c)*n(d)/_)},asin:function(){var c=this.re,d=this.im,_=new h(d*d-c*c+1,-2*c*d).sqrt(),D=new h(_.re-d,_.im+c).log();return new h(D.im,-D.re)},acos:function(){var c=this.re,d=this.im,_=new h(d*d-c*c+1,-2*c*d).sqrt(),D=new h(_.re-d,_.im+c).log();return new h(Math.PI/2-D.im,D.re)},atan:function(){var c=this.re,d=this.im;if(c===0){if(d===1)return new h(0,1/0);if(d===-1)return new h(0,-1/0)}var _=c*c+(1-d)*(1-d),D=new h((1-d*d-c*c)/_,-2*c/_).log();return new h(-.5*D.im,.5*D.re)},acot:function(){var c=this.re,d=this.im;if(d===0)return new h(Math.atan2(1,c),0);var _=c*c+d*d;return _!==0?new h(c/_,-d/_).atan():new h(c!==0?c/0:0,d!==0?-d/0:0).atan()},asec:function(){var c=this.re,d=this.im;if(c===0&&d===0)return new h(0,1/0);var _=c*c+d*d;return _!==0?new h(c/_,-d/_).acos():new h(c!==0?c/0:0,d!==0?-d/0:0).acos()},acsc:function(){var c=this.re,d=this.im;if(c===0&&d===0)return new h(Math.PI/2,1/0);var _=c*c+d*d;return _!==0?new h(c/_,-d/_).asin():new h(c!==0?c/0:0,d!==0?-d/0:0).asin()},sinh:function(){var c=this.re,d=this.im;return new h(n(c)*Math.cos(d),r(c)*Math.sin(d))},cosh:function(){var c=this.re,d=this.im;return new h(r(c)*Math.cos(d),n(c)*Math.sin(d))},tanh:function(){var c=2*this.re,d=2*this.im,_=r(c)+Math.cos(d);return new h(n(c)/_,Math.sin(d)/_)},coth:function(){var c=2*this.re,d=2*this.im,_=r(c)-Math.cos(d);return new h(n(c)/_,-Math.sin(d)/_)},csch:function(){var c=this.re,d=this.im,_=Math.cos(2*d)-r(2*c);return new h(-2*n(c)*Math.cos(d)/_,2*r(c)*Math.sin(d)/_)},sech:function(){var c=this.re,d=this.im,_=Math.cos(2*d)+r(2*c);return new h(2*r(c)*Math.cos(d)/_,-2*n(c)*Math.sin(d)/_)},asinh:function(){var c=this.im;this.im=-this.re,this.re=c;var d=this.asin();return this.re=-this.im,this.im=c,c=d.re,d.re=-d.im,d.im=c,d},acosh:function(){var c=this.acos();if(c.im<=0){var d=c.re;c.re=-c.im,c.im=d}else{var d=c.im;c.im=-c.re,c.re=d}return c},atanh:function(){var c=this.re,d=this.im,_=c>1&&d===0,D=1-c,g=1+c,y=D*D+d*d,v=y!==0?new h((g*D-d*d)/y,(d*D+g*d)/y):new h(c!==-1?c/0:0,d!==0?d/0:0),E=v.re;return v.re=l(v.re,v.im)/2,v.im=Math.atan2(v.im,E)/2,_&&(v.im=-v.im),v},acoth:function(){var c=this.re,d=this.im;if(c===0&&d===0)return new h(0,Math.PI/2);var _=c*c+d*d;return _!==0?new h(c/_,-d/_).atanh():new h(c!==0?c/0:0,d!==0?-d/0:0).atanh()},acsch:function(){var c=this.re,d=this.im;if(d===0)return new h(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var _=c*c+d*d;return _!==0?new h(c/_,-d/_).asinh():new h(c!==0?c/0:0,d!==0?-d/0:0).asinh()},asech:function(){var c=this.re,d=this.im;if(this.isZero())return h.INFINITY;var _=c*c+d*d;return _!==0?new h(c/_,-d/_).acosh():new h(c!==0?c/0:0,d!==0?-d/0:0).acosh()},inverse:function(){if(this.isZero())return h.INFINITY;if(this.isInfinite())return h.ZERO;var c=this.re,d=this.im,_=c*c+d*d;return new h(c/_,-d/_)},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,d){var _=new h(c,d);return Math.abs(_.re-this.re)<=h.EPSILON&&Math.abs(_.im-this.im)<=h.EPSILON},clone:function(){return new h(this.re,this.im)},toString:function(){var c=this.re,d=this.im,_="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<h.EPSILON&&(c=0),Math.abs(d)<h.EPSILON&&(d=0),d===0?_+c:(c!==0?(_+=c,_+=" ",d<0?(d=-d,_+="-"):_+="+",_+=" "):d<0&&(d=-d,_+="-"),d!==1&&(_+=d),_+"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})()})(vl);var Pd=vl.exports,Re=Zt(Pd),zd="Complex",qd=[],Ud=dt(zd,qd,()=>(Object.defineProperty(Re,"name",{value:"Complex"}),Re.prototype.constructor=Re,Re.prototype.type="Complex",Re.prototype.isComplex=!0,Re.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Re.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Re.prototype.format=function(i){var t="",e=this.im,r=this.re,n=ou(this.re,i),s=ou(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},Re.fromPolar=function(i){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return Re(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(Bf(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),ae(r))return new Re({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")}},Re.prototype.valueOf=Re.prototype.toString,Re.fromJSON=function(i){return new Re(i)},Re.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},Re),{isClass:!0}),_l={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(v,E){if(isNaN(v=parseInt(v,10)))throw g();return v*E}function a(v,E){if(E===0)throw D();var b=Object.create(_.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var N=d(v,E);return b.n=v/N,b.d=E/N,b}function f(v){for(var E={},b=v,N=2,x=4;x<=b;){for(;b%N===0;)b/=N,E[N]=(E[N]||0)+1;x+=1+2*N++}return b!==v?b>1&&(E[b]=(E[b]||0)+1):E[v]=(E[v]||0)+1,E}var l=function(v,E){var b=0,N=1,x=1,F=0,M=0,S=0,$=1,C=1,I=0,R=1,U=1,q=1,k=1e7,P;if(v!=null)if(E!==void 0){if(b=v,N=E,x=b*N,b%1!==0||N%1!==0)throw y()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw g();x=b*N;break}case"number":{if(v<0&&(x=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(C=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=C);R<=k&&q<=k;)if(P=(I+U)/(R+q),v===P){R+q<=k?(b=I+U,N=R+q):q>R?(b=U,N=q):(b=I,N=R);break}else v>P?(I+=U,R+=q):(U+=I,q+=R),R>k?(b=U,N=q):(b=I,N=R);b*=C}else(isNaN(v)||isNaN(E))&&(N=b=NaN);break}case"string":{if(R=v.match(/\d+|./g),R===null)throw g();if(R[I]==="-"?(x=-1,I++):R[I]==="+"&&I++,R.length===I+1?M=s(R[I++],x):R[I+1]==="."||R[I]==="."?(R[I]!=="."&&(F=s(R[I++],x)),I++,(I+1===R.length||R[I+1]==="("&&R[I+3]===")"||R[I+1]==="'"&&R[I+3]==="'")&&(M=s(R[I],x),$=Math.pow(10,R[I].length),I++),(R[I]==="("&&R[I+2]===")"||R[I]==="'"&&R[I+2]==="'")&&(S=s(R[I+1],x),C=Math.pow(10,R[I+1].length)-1,I+=3)):R[I+1]==="/"||R[I+1]===":"?(M=s(R[I],x),$=s(R[I+2],1),I+=3):R[I+3]==="/"&&R[I+1]===" "&&(F=s(R[I],x),M=s(R[I+2],x),$=s(R[I+4],1),I+=5),R.length<=I){N=$*C,x=b=S+N*F+C*M;break}}default:throw g()}if(N===0)throw D();n.s=x<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function p(v,E,b){for(var N=1;E>0;v=v*v%b,E>>=1)E&1&&(N=N*v%b);return N}function h(v,E){for(;E%2===0;E/=2);for(;E%5===0;E/=5);if(E===1)return 0;for(var b=10%E,N=1;b!==1;N++)if(b=b*10%E,N>r)return 0;return N}function c(v,E,b){for(var N=1,x=p(10,b,E),F=0;F<300;F++){if(N===x)return F;N=N*10%E,x=x*10%E}return 0}function d(v,E){if(!v)return E;if(!E)return v;for(;;){if(v%=E,!v)return E;if(E%=v,!E)return v}}function _(v,E){if(l(v,E),this instanceof _)v=d(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var D=function(){return new Error("Division by Zero")},g=function(){return new Error("Invalid argument")},y=function(){return new Error("Parameters must be integer")};_.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,E){return l(v,E),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,E){return l(v,E),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,E){return l(v,E),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,E){return l(v,E),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,E){if(isNaN(this.n)||isNaN(this.d))return new _(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(l(v,E),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(v,E){return l(v,E),a(d(n.n,this.n)*d(n.d,this.d),n.d*this.d)},lcm:function(v,E){return l(v,E),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,d(n.n,this.n)*d(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new _(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new _(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new _(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,E){if(l(v,E),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=f(this.n),N=f(this.d),x=1,F=1;for(var M in b)if(M!=="1"){if(M==="0"){x=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;x*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;F*=Math.pow(M,N[M])}return n.s<0?a(F,x):a(x,F)},equals:function(v,E){return l(v,E),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,E){l(v,E);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var E=this.abs(),b=E.toContinued(),N=1;N<b.length;N++){for(var x=a(b[N-1],1),F=N-2;F>=0;F--)x=x.inverse().add(b[F]);if(Math.abs(x.sub(E).valueOf())<v)return x.mul(this.s)}return this},divisible:function(v,E){return l(v,E),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,b+=" ",N%=x),b+=N,b+="/",b+=x),b},toLatex:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,N%=x),b+="\\frac{",b+=N,b+="}{",b+=x,b+="}"),b},toContinued:function(){var v,E=this.n,b=this.d,N=[];if(isNaN(E)||isNaN(b))return N;do N.push(Math.floor(E/b)),v=E%b,E=b,b=v;while(E!==1);return N},toString:function(v){var E=this.n,b=this.d;if(isNaN(E)||isNaN(b))return"NaN";v=v||15;var N=h(E,b),x=c(E,b,N),F=this.s<0?"-":"";if(F+=E/b|0,E%=b,E*=10,E&&(F+="."),N){for(var M=x;M--;)F+=E/b|0,E%=b,E*=10;F+="(";for(var M=N;M--;)F+=E/b|0,E%=b,E*=10;F+=")"}else for(var M=v;E&&M--;)F+=E/b|0,E%=b,E*=10;return F}},Object.defineProperty(_,"__esModule",{value:!0}),_.default=_,_.Fraction=_,i.exports=_})()})(_l);var kd=_l.exports,Gr=Zt(kd),Wd="Fraction",Yd=[],Zd=dt(Wd,Yd,()=>(Object.defineProperty(Gr,"name",{value:"Fraction"}),Gr.prototype.constructor=Gr,Gr.prototype.type="Fraction",Gr.prototype.isFraction=!0,Gr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Gr.fromJSON=function(i){return new Gr(i)},Gr),{isClass:!0}),jd="Matrix",Gd=[],Kd=dt(jd,Gd,()=>{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 wl(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Jd="DenseMatrix",Xd=["Matrix"],Hd=dt(Jd,Xd,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&&!qr(c))throw new Error("Invalid datatype: "+c);if(le(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&&ge(h.data)&&ge(h.size))this._data=h.data,this._size=h.size,Gf(this._data,this._size),this._datatype=c||h.datatype;else if(ge(h))this._data=p(h),this._size=Ae(this._data),Gf(this._data,this._size),this._datatype=c;else{if(h)throw new TypeError("Unsupported type of data ("+an(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 Es(this._data,an)},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,d){switch(arguments.length){case 1:return r(this,h);case 2:case 3:return s(this,h,c,d);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(h){if(!ge(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 d=this._data,_=0,D=h.length;_<D;_++){var g=h[_];ve(g,d.length),d=d[g]}return d},e.prototype.set=function(h,c,d){if(!ge(h))throw new TypeError("Array expected");if(h.length<this._size.length)throw new jt(h.length,this._size.length,"<");var _,D,g,y=h.map(function(E){return E+1});l(this,y,d);var v=this._data;for(_=0,D=h.length-1;_<D;_++)g=h[_],ve(g,v.length),v=v[g];return g=h[h.length-1],ve(g,v.length),v[g]=c,this};function r(h,c){if(!nu(c))throw new TypeError("Invalid index");var d=c.isScalar();if(d)return h.get(c.min());var _=c.size();if(_.length!==h._size.length)throw new jt(_.length,h._size.length);for(var D=c.min(),g=c.max(),y=0,v=h._size.length;y<v;y++)ve(D[y],h._size[y]),ve(g[y],h._size[y]);return new e(n(h._data,c,_.length,0),h._datatype)}function n(h,c,d,_){var D=_===d-1,g=c.dimension(_);return D?g.map(function(y){return ve(y,h.length),h[y]}).valueOf():g.map(function(y){ve(y,h.length);var v=h[y];return n(v,c,d,_+1)}).valueOf()}function s(h,c,d,_){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var D=c.size(),g=c.isScalar(),y;if(le(d)?(y=d.size(),d=d.valueOf()):y=Ae(d),g){if(y.length!==0)throw new TypeError("Scalar expected");h.set(c.min(),d,_)}else{if(!Vn(y,D))try{y.length===0?d=Vf([d],D):d=Vf(d,D),y=Ae(d)}catch{}if(D.length<h._size.length)throw new jt(D.length,h._size.length,"<");if(y.length<D.length){for(var v=0,E=0;D[v]===1&&y[v]===1;)v++;for(;D[v]===1;)E++,v++;d=Jf(d,D.length,E,y)}if(!Vn(D,y))throw new jt(D,y,">");var b=c.max().map(function(F){return F+1});l(h,b,_);var N=D.length,x=0;a(h._data,c,d,N,x)}return h}function a(h,c,d,_,D){var g=D===_-1,y=c.dimension(D);g?y.forEach(function(v,E){ve(v),h[v]=d[E[0]]}):y.forEach(function(v,E){ve(v),a(h[v],c,d[E[0]],_,D+1)})}e.prototype.resize=function(h,c,d){if(!$i(h))throw new TypeError("Array or Matrix expected");var _=h.valueOf().map(g=>Array.isArray(g)&&g.length===1?g[0]:g),D=d?this.clone():this;return f(D,_,c)};function f(h,c,d){if(c.length===0){for(var _=h._data;ge(_);)_=_[0];return _}return h._size=c.slice(0),h._data=au(h._data,h._size,d),h}e.prototype.reshape=function(h,c){var d=c?this.clone():this;d._data=lu(d._data,h);var _=d._size.reduce((D,g)=>D*g);return d._size=cu(h,_),d};function l(h,c,d){for(var _=h._size.slice(0),D=!1;_.length<c.length;)_.push(0),D=!0;for(var g=0,y=c.length;g<y;g++)c[g]>_[g]&&(_[g]=c[g],D=!0);D&&f(h,_,d)}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,d=wl(h),_=function y(v,E){return ge(v)?v.map(function(b,N){return y(b,E.concat(N))}):d===1?h(v):d===2?h(v,E):h(v,E,c)},D=_(this._data,[]),g=this._datatype!==void 0?Es(D,an):void 0;return new e(D,g)},e.prototype.forEach=function(h){var c=this,d=function _(D,g){ge(D)?D.forEach(function(y,v){_(y,g.concat(v))}):h(D,g,c)};d(this._data,[])},e.prototype[Symbol.iterator]=function*(){var h=function*c(d,_){if(ge(d))for(var D=0;D<d.length;D++)yield*c(d[D],_.concat(D));else yield{value:d,index:_}};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 d=this._data;for(var _ of d)h.push(new e([_],this._datatype));return h},e.prototype.columns=function(){var h=this,c=[],d=this.size();if(d.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var _=this._data,D=function(v){var E=_.map(b=>[b[v]]);c.push(new e(E,h._datatype))},g=0;g<d[1];g++)D(g);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,d=h<0?-h:0,_=this._size[0],D=this._size[1],g=Math.min(_-d,D-c),y=[],v=0;v<g;v++)y[v]=this._data[v+d][v+c];return new e({data:y,size:[g],datatype:this._datatype})},e.diagonal=function(h,c,d,_){if(!ge(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(M){if(ye(M)&&(M=M.toNumber()),!ae(M)||!he(M)||M<1)throw new Error("Size values must be positive integers");return M}),d){if(ye(d)&&(d=d.toNumber()),!ae(d)||!he(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var D=d>0?d:0,g=d<0?-d:0,y=h[0],v=h[1],E=Math.min(y-g,v-D),b;if(ge(c)){if(c.length!==E)throw new Error("Invalid value array length");b=function(S){return c[S]}}else if(le(c)){var N=c.size();if(N.length!==1||N[0]!==E)throw new Error("Invalid matrix length");b=function(S){return c.get([S])}}else b=function(){return c};_||(_=ye(b(0))?b(0).mul(0):0);var x=[];if(h.length>0){x=au(x,h,_);for(var F=0;F<E;F++)x[F+g][F+D]=b(F)}return new e({data:x,size:[y,v]})},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,d){var _=d[h];d[h]=d[c],d[c]=_};function p(h){return le(h)?p(h.valueOf()):ge(h)?h.map(p):h}return e},{isClass:!0});function Qd(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 Ts(i){for(var t=0;t<i.length;t++)if($i(i[t]))return!0;return!1}function Li(i,t){le(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?Li(n,t):t(n)}}function Br(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Br(r,t)}):t(i)}function yu(i,t,e){var r=Array.isArray(i)?Ae(i):i.size();if(t<0||t>=r.length)throw new fn(t,r.length);return le(i)?i.create($s(i.valueOf(),t,e)):$s(i,t,e)}function $s(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=Qd(i),n=[],r=0;r<a.length;r++)n[r]=$s(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]=$s(i[r],t-1,e);return n}}var Dl="isInteger",Vd=["typed"],tg=dt(Dl,Vd,i=>{var{typed:t}=i;return t(Dl,{number:he,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Br(r,e))})}),yl="number",Os="number, number";function bl(i){return Math.abs(i)}bl.signature=yl;function El(i,t){return i+t}El.signature=Os;function Al(i,t){return i-t}Al.signature=Os;function xl(i,t){return i*t}xl.signature=Os;function Cl(i){return-i}Cl.signature=yl;function Fl(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}Fl.signature=Os;var Ml="number";function Nl(i){return i===0}Nl.signature=Ml;function Sl(i){return Number.isNaN(i)}Sl.signature=Ml;var Bl="isNumeric",eg=["typed"],rg=dt(Bl,eg,i=>{var{typed:t}=i;return t(Bl,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Br(r,e))})}),Il="isZero",ng=["typed"],ig=dt(Il,ng,i=>{var{typed:t}=i;return t(Il,{number:Nl,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=>Br(r,e))})}),Tl="isNaN",sg=["typed"],og=dt(Tl,sg,i=>{var{typed:t}=i;return t(Tl,{number:Sl,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 Br(r,Number.isNaN)}})});function Rs(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function ug(i,t,e){return $n(i.re,t.re,e)&&$n(i.im,t.im,e)}var Ls=dt("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)})}}),Ps="equalScalar",ag=["typed","config"],fg=dt(Ps,ag,i=>{var{typed:t,config:e}=i,r=Ls({typed:t});return t(Ps,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return $n(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||Rs(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return ug(s,a,e.epsilon)}},r)});dt(Ps,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ps,{"number, number":function(n,s){return $n(n,s,e.epsilon)}})});var lg="SparseMatrix",cg=["typed","equalScalar","Matrix"],hg=dt(lg,cg,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(g,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!qr(y))throw new Error("Invalid datatype: "+y);if(le(g))s(this,g,y);else if(g&&ge(g.index)&&ge(g.ptr)&&ge(g.size))this._values=g.values,this._index=g.index,this._ptr=g.ptr,this._size=g.size,this._datatype=y||g.datatype;else if(ge(g))a(this,g,y);else{if(g)throw new TypeError("Unsupported type of data ("+an(g)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function s(g,y,v){y.type==="SparseMatrix"?(g._values=y._values?te(y._values):void 0,g._index=te(y._index),g._ptr=te(y._ptr),g._size=te(y._size),g._datatype=v||y._datatype):a(g,y.valueOf(),v||y._datatype)}function a(g,y,v){g._values=[],g._index=[],g._ptr=[],g._datatype=v;var E=y.length,b=0,N=e,x=0;if(qr(v)&&(N=t.find(e,[v,v])||e,x=t.convert(0,v)),E>0){var F=0;do{g._ptr.push(g._index.length);for(var M=0;M<E;M++){var S=y[M];if(ge(S)){if(F===0&&b<S.length&&(b=S.length),F<S.length){var $=S[F];N($,x)||(g._values.push($),g._index.push(M))}}else F===0&&b<1&&(b=1),N(S,x)||(g._values.push(S),g._index.push(M))}F++}while(F<b)}g._ptr.push(g._index.length),g._size=[E,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(g,y){return new n(g,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Es(this._values,an)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(g,y){return new n(g,y)},n.prototype.density=function(){var g=this._size[0],y=this._size[1];return g!==0&&y!==0?this._index.length/(g*y):0},n.prototype.subset=function(g,y,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return f(this,g);case 2:case 3:return l(this,g,y,v);default:throw new SyntaxError("Wrong number of arguments")}};function f(g,y){if(!nu(y))throw new TypeError("Invalid index");var v=y.isScalar();if(v)return g.get(y.min());var E=y.size();if(E.length!==g._size.length)throw new jt(E.length,g._size.length);var b,N,x,F,M=y.min(),S=y.max();for(b=0,N=g._size.length;b<N;b++)ve(M[b],g._size[b]),ve(S[b],g._size[b]);var $=g._values,C=g._index,I=g._ptr,R=y.dimension(0),U=y.dimension(1),q=[],k=[];R.forEach(function(Q,tt){k[Q]=tt[0],q[Q]=!0});var P=$?[]:void 0,G=[],j=[];return U.forEach(function(Q){for(j.push(G.length),x=I[Q],F=I[Q+1];x<F;x++)b=C[x],q[b]===!0&&(G.push(k[b]),P&&P.push($[x]))}),j.push(G.length),new n({values:P,index:G,ptr:j,size:E,datatype:g._datatype})}function l(g,y,v,E){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var b=y.size(),N=y.isScalar(),x;if(le(v)?(x=v.size(),v=v.toArray()):x=Ae(v),N){if(x.length!==0)throw new TypeError("Scalar expected");g.set(y.min(),v,E)}else{if(b.length!==1&&b.length!==2)throw new jt(b.length,g._size.length,"<");if(x.length<b.length){for(var F=0,M=0;b[F]===1&&x[F]===1;)F++;for(;b[F]===1;)M++,F++;v=Jf(v,b.length,M,x)}if(!Vn(b,x))throw new jt(b,x,">");if(b.length===1){var S=y.dimension(0);S.forEach(function(I,R){ve(I),g.set([I,0],v[R[0]],E)})}else{var $=y.dimension(0),C=y.dimension(1);$.forEach(function(I,R){ve(I),C.forEach(function(U,q){ve(U),g.set([I,U],v[R[0]][q[0]],E)})})}}return g}n.prototype.get=function(g){if(!ge(g))throw new TypeError("Array expected");if(g.length!==this._size.length)throw new jt(g.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=g[0],v=g[1];ve(y,this._size[0]),ve(v,this._size[1]);var E=p(y,this._ptr[v],this._ptr[v+1],this._index);return E<this._ptr[v+1]&&this._index[E]===y?this._values[E]:0},n.prototype.set=function(g,y,v){if(!ge(g))throw new TypeError("Array expected");if(g.length!==this._size.length)throw new jt(g.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var E=g[0],b=g[1],N=this._size[0],x=this._size[1],F=e,M=0;qr(this._datatype)&&(F=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(E>N-1||b>x-1)&&(d(this,Math.max(E+1,N),Math.max(b+1,x),v),N=this._size[0],x=this._size[1]),ve(E,N),ve(b,x);var S=p(E,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===E?F(y,M)?h(S,b,this._values,this._index,this._ptr):this._values[S]=y:F(y,M)||c(S,E,b,y,this._values,this._index,this._ptr),this};function p(g,y,v,E){if(v-y===0)return v;for(var b=y;b<v;b++)if(E[b]===g)return b;return y}function h(g,y,v,E,b){v.splice(g,1),E.splice(g,1);for(var N=y+1;N<b.length;N++)b[N]--}function c(g,y,v,E,b,N,x){b.splice(g,0,E),N.splice(g,0,y);for(var F=v+1;F<x.length;F++)x[F]++}n.prototype.resize=function(g,y,v){if(!$i(g))throw new TypeError("Array or Matrix expected");var E=g.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(N){if(!ae(N)||!he(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+se(E)+")")});var b=v?this.clone():this;return d(b,E[0],E[1],y)};function d(g,y,v,E){var b=E||0,N=e,x=0;qr(g._datatype)&&(N=t.find(e,[g._datatype,g._datatype])||e,x=t.convert(0,g._datatype),b=t.convert(b,g._datatype));var F=!N(b,x),M=g._size[0],S=g._size[1],$,C,I;if(v>S){for(C=S;C<v;C++)if(g._ptr[C]=g._values.length,F)for($=0;$<M;$++)g._values.push(b),g._index.push($);g._ptr[v]=g._values.length}else v<S&&(g._ptr.splice(v+1,S-v),g._values.splice(g._ptr[v],g._values.length),g._index.splice(g._ptr[v],g._index.length));if(S=v,y>M){if(F){var R=0;for(C=0;C<S;C++){g._ptr[C]=g._ptr[C]+R,I=g._ptr[C+1]+R;var U=0;for($=M;$<y;$++,U++)g._values.splice(I+U,0,b),g._index.splice(I+U,0,$),R++}g._ptr[S]=g._values.length}}else if(y<M){var q=0;for(C=0;C<S;C++){g._ptr[C]=g._ptr[C]-q;var k=g._ptr[C],P=g._ptr[C+1]-q;for(I=k;I<P;I++)$=g._index[I],$>y-1&&(g._values.splice(I,1),g._index.splice(I,1),q++)}g._ptr[C]=g._values.length}return g._size[0]=y,g._size[1]=v,g}n.prototype.reshape=function(g,y){if(!ge(g))throw new TypeError("Array expected");if(g.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");g.forEach(function(Q){if(!ae(Q)||!he(Q)||Q<=-2||Q===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+se(g)+")")});var v=this._size[0]*this._size[1];g=cu(g,v);var E=g[0]*g[1];if(v!==E)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=y?this.clone():this;if(this._size[0]===g[0]&&this._size[1]===g[1])return b;for(var N=[],x=0;x<b._ptr.length;x++)for(var F=0;F<b._ptr[x+1]-b._ptr[x];F++)N.push(x);for(var M=b._values.slice(),S=b._index.slice(),$=0;$<b._index.length;$++){var C=S[$],I=N[$],R=C*b._size[1]+I;N[$]=R%g[1],S[$]=Math.floor(R/g[1])}b._values.length=0,b._index.length=0,b._ptr.length=g[1]+1,b._size=g.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var q=0;q<M.length;q++){var k=S[q],P=N[q],G=M[q],j=p(k,b._ptr[P],b._ptr[P+1],b._index);c(j,k,P,G,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var g=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 g},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(g,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,E=this._size[0],b=this._size[1],N=wl(g),x=function(M,S,$){return N===1?g(M):N===2?g(M,[S,$]):g(M,[S,$],v)};return _(this,0,E-1,0,b-1,x,y)};function _(g,y,v,E,b,N,x){var F=[],M=[],S=[],$=e,C=0;qr(g._datatype)&&($=t.find(e,[g._datatype,g._datatype])||e,C=t.convert(0,g._datatype));for(var I=function(ft,wt,yt){ft=N(ft,wt,yt),$(ft,C)||(F.push(ft),M.push(wt))},R=E;R<=b;R++){S.push(F.length);var U=g._ptr[R],q=g._ptr[R+1];if(x)for(var k=U;k<q;k++){var P=g._index[k];P>=y&&P<=v&&I(g._values[k],P-y,R-E)}else{for(var G={},j=U;j<q;j++){var Q=g._index[j];G[Q]=g._values[j]}for(var tt=y;tt<=v;tt++){var lt=tt in G?G[tt]:0;I(lt,tt-y,R-E)}}}return S.push(F.length),new n({values:F,index:M,ptr:S,size:[v-y+1,b-E+1]})}n.prototype.forEach=function(g,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,E=this._size[0],b=this._size[1],N=0;N<b;N++){var x=this._ptr[N],F=this._ptr[N+1];if(y)for(var M=x;M<F;M++){var S=this._index[M];g(this._values[M],[S,N],v)}else{for(var $={},C=x;C<F;C++){var I=this._index[C];$[I]=this._values[C]}for(var R=0;R<E;R++){var U=R in $?$[R]:0;g(U,[R,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var g=this._size[1],y=0;y<g;y++)for(var v=this._ptr[y],E=this._ptr[y+1],b=v;b<E;b++){var N=this._index[b];yield{value:this._values[b],index:[N,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(g,y,v,E,b){var N=E[0],x=E[1],F=[],M,S;for(M=0;M<N;M++)for(F[M]=[],S=0;S<x;S++)F[M][S]=0;for(S=0;S<x;S++)for(var $=v[S],C=v[S+1],I=$;I<C;I++)M=y[I],F[M][S]=g?b?te(g[I]):g[I]:1;return F}return n.prototype.format=function(g){for(var y=this._size[0],v=this._size[1],E=this.density(),b="Sparse Matrix ["+se(y,g)+" x "+se(v,g)+"] density: "+se(E,g)+`
53
+ `,N=0;N<v;N++)for(var x=this._ptr[N],F=this._ptr[N+1],M=x;M<F;M++){var S=this._index[M];b+=`
54
+ (`+se(S,g)+", "+se(N,g)+") ==> "+(this._values?se(this._values[M],g):"X")}return b},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(g){if(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 y=g>0?g:0,v=g<0?-g:0,E=this._size[0],b=this._size[1],N=Math.min(E-v,b-y),x=[],F=[],M=[];M[0]=0;for(var S=y;S<b&&x.length<N;S++)for(var $=this._ptr[S],C=this._ptr[S+1],I=$;I<C;I++){var R=this._index[I];if(R===S-y+v){x.push(this._values[I]),F[x.length-1]=R-v;break}}return M.push(x.length),new n({values:x,index:F,ptr:M,size:[N,1]})},n.fromJSON=function(g){return new n(g)},n.diagonal=function(g,y,v,E,b){if(!ge(g))throw new TypeError("Array expected, size parameter");if(g.length!==2)throw new Error("Only two dimensions matrix are supported");if(g=g.map(function(Q){if(ye(Q)&&(Q=Q.toNumber()),!ae(Q)||!he(Q)||Q<1)throw new Error("Size values must be positive integers");return Q}),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 N=e,x=0;qr(b)&&(N=t.find(e,[b,b])||e,x=t.convert(0,b));var F=v>0?v:0,M=v<0?-v:0,S=g[0],$=g[1],C=Math.min(S-M,$-F),I;if(ge(y)){if(y.length!==C)throw new Error("Invalid value array length");I=function(tt){return y[tt]}}else if(le(y)){var R=y.size();if(R.length!==1||R[0]!==C)throw new Error("Invalid matrix length");I=function(tt){return y.get([tt])}}else I=function(){return y};for(var U=[],q=[],k=[],P=0;P<$;P++){k.push(U.length);var G=P-F;if(G>=0&&G<C){var j=I(G);N(j,x)||(q.push(G+M),U.push(j))}}return k.push(U.length),new n({values:U,index:q,ptr:k,size:[S,$]})},n.prototype.swapRows=function(g,y){if(!ae(g)||!he(g)||!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(g,this._size[0]),ve(y,this._size[0]),n._swapRows(g,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(g,y,v,E,b){for(var N=E[g],x=E[g+1],F=N;F<x;F++)b(v[F],y[F])},n._swapRows=function(g,y,v,E,b,N){for(var x=0;x<v;x++){var F=N[x],M=N[x+1],S=p(g,F,M,b),$=p(y,F,M,b);if(S<M&&$<M&&b[S]===g&&b[$]===y){if(E){var C=E[S];E[S]=E[$],E[$]=C}continue}if(S<M&&b[S]===g&&($>=M||b[$]!==y)){var I=E?E[S]:void 0;b.splice($,0,y),E&&E.splice($,0,I),b.splice($<=S?S+1:S,1),E&&E.splice($<=S?S+1:S,1);continue}if($<M&&b[$]===y&&(S>=M||b[S]!==g)){var R=E?E[$]:void 0;b.splice(S,0,g),E&&E.splice(S,0,R),b.splice(S<=$?$+1:$,1),E&&E.splice(S<=$?$+1:$,1)}}},n},{isClass:!0}),pg="number",mg=["typed"];function dg(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function gg(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var vg=dt(pg,mg,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=dg(n);if(s)return gg(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=>Br(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),_g="bignumber",wg=["typed","BigNumber"],Dg=dt(_g,wg,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],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=>Br(n,r))})}),yg="fraction",bg=["typed","Fraction"],Eg=dt(yg,bg,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=>Br(n,r))})}),$l="matrix",Ag=["typed","Matrix","DenseMatrix","SparseMatrix"],xg=dt($l,Ag,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t($l,{"":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)+".")}}),Ol="unaryMinus",Cg=["typed"],Fg=dt(Ol,Cg,i=>{var{typed:t}=i;return t(Ol,{number:Cl,"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=>Br(r,e))})}),Rl="abs",Mg=["typed"],Ng=dt(Rl,Mg,i=>{var{typed:t}=i;return t(Rl,{number:bl,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Br(r,e))})}),Ll="addScalar",Sg=["typed"],Bg=dt(Ll,Sg,i=>{var{typed:t}=i;return t(Ll,{"number, number":El,"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})})}),Pl="subtractScalar",Ig=["typed"],Tg=dt(Pl,Ig,i=>{var{typed:t}=i;return t(Pl,{"number, number":Al,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),$g="matAlgo11xS0s",Og=["typed","equalScalar"],bu=dt($g,Og,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,d=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],D=c[1],g,y=e,v=0,E=a;typeof d=="string"&&(g=d,y=t.find(e,[g,g]),v=t.convert(0,g),s=t.convert(s,g),E=t.find(a,[g,g]));for(var b=[],N=[],x=[],F=0;F<D;F++){x[F]=N.length;for(var M=h[F],S=h[F+1],$=M;$<S;$++){var C=p[$],I=f?E(s,l[$]):E(l[$],s);y(I,v)||(N.push(C),b.push(I))}}return x[D]=N.length,n.createSparseMatrix({values:b,index:N,ptr:x,size:[_,D],datatype:g})}}),Rg="matAlgo12xSfs",Lg=["typed","DenseMatrix"],si=dt(Rg,Lg,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,d=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],D=c[1],g,y=a;typeof d=="string"&&(g=d,s=t.convert(s,g),y=t.find(a,[g,g]));for(var v=[],E=[],b=[],N=0;N<D;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var $=p[S];E[$]=l[S],b[$]=x}for(var C=0;C<_;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=f?y(s,E[C]):y(E[C],s):v[C][N]=f?y(s,0):y(0,s)}return new e({data:v,size:[_,D],datatype:g})}}),Pg="matAlgo14xDs",zg=["typed"],Eu=dt(Pg,zg,i=>{var{typed:t}=i;return function(n,s,a,f){var l=n._data,p=n._size,h=n._datatype,c,d=a;typeof h=="string"&&(c=h,s=t.convert(s,c),d=t.find(a,[c,c]));var _=p.length>0?e(d,0,p,p[0],l,s,f):[];return n.createDenseMatrix({data:_,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 d=0;d<a;d++)h[d]=e(r,n+1,s,s[n+1],f[d],l,p);return h}}),qg="matAlgo02xDS0",Ug=["typed","equalScalar"],kg=dt(qg,Ug,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,d=s._index,_=s._ptr,D=s._size,g=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],v=p[1],E,b=e,N=0,x=a;typeof h=="string"&&h===g&&h!=="mixed"&&(E=h,b=t.find(e,[E,E]),N=t.convert(0,E),x=t.find(a,[E,E]));for(var F=[],M=[],S=[],$=0;$<v;$++){S[$]=M.length;for(var C=_[$],I=_[$+1],R=C;R<I;R++){var U=d[R],q=f?x(c[R],l[U][$]):x(l[U][$],c[R]);b(q,N)||(M.push(U),F.push(q))}}return S[v]=M.length,s.createSparseMatrix({values:F,index:M,ptr:S,size:[y,v],datatype:h===n._datatype&&g===s._datatype?E:void 0})}}),Wg="matAlgo03xDSf",Yg=["typed"],oi=dt(Wg,Yg,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,d=n._ptr,_=n._size,D=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(l.length!==_.length)throw new jt(l.length,_.length);if(l[0]!==_[0]||l[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+_+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=l[0],y=l[1],v,E=0,b=s;typeof p=="string"&&p===D&&p!=="mixed"&&(v=p,E=t.convert(0,v),b=t.find(s,[v,v]));for(var N=[],x=0;x<g;x++)N[x]=[];for(var F=[],M=[],S=0;S<y;S++){for(var $=S+1,C=d[S],I=d[S+1],R=C;R<I;R++){var U=c[R];F[U]=a?b(h[R],f[U][S]):b(f[U][S],h[R]),M[U]=$}for(var q=0;q<g;q++)M[q]===$?N[q][S]=F[q]:N[q][S]=a?b(E,f[q][S]):b(f[q][S],E)}return r.createDenseMatrix({data:N,size:[g,y],datatype:p===r._datatype&&D===n._datatype?v:void 0})}}),Zg="matAlgo05xSfSf",jg=["typed","equalScalar"],zl=dt(Zg,jg,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(),d=s._values,_=s._index,D=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==g.length)throw new jt(h.length,g.length);if(h[0]!==g[0]||h[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+g+")");var v=h[0],E=h[1],b,N=e,x=0,F=a;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=f&&d?[]:void 0,S=[],$=[],C=M?[]:void 0,I=M?[]:void 0,R=[],U=[],q,k,P,G;for(k=0;k<E;k++){$[k]=S.length;var j=k+1;for(P=p[k],G=p[k+1];P<G;P++)q=l[P],S.push(q),R[q]=j,C&&(C[q]=f[P]);for(P=D[k],G=D[k+1];P<G;P++)q=_[P],R[q]!==j&&S.push(q),U[q]=j,I&&(I[q]=d[P]);if(M)for(P=$[k];P<S.length;){q=S[P];var Q=R[q],tt=U[q];if(Q===j||tt===j){var lt=Q===j?C[q]:x,vt=tt===j?I[q]:x,ft=F(lt,vt);N(ft,x)?S.splice(P,1):(M.push(ft),P++)}}}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[v,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),Gg="matAlgo13xDD",Kg=["typed"],Jg=dt(Gg,Kg,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,d=s._datatype,_=[];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+")");_[D]=l[D]}var g,y=a;typeof p=="string"&&p===d&&(g=p,y=t.find(a,[g,g]));var v=_.length>0?e(y,0,_,_[0],f,h):[];return n.createDenseMatrix({data:v,size:_,datatype:g})};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}}),Xg="broadcast",Hg=["concat"],Qg=dt(Xg,Hg,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,g)=>D===s._size[g]))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]);As(f,p),As(l,p);var c=n.clone(),d=s.clone();c._size.length<a?c.reshape(e(c._size,a,1)):d._size.length<a&&d.reshape(e(d._size,a,1));for(var _=0;_<a;_++)c._size[_]<p[_]&&(c=r(c,p[_],_)),d._size[_]<p[_]&&(d=r(d,p[_],_));return[c,d]};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)}}),Vg="matrixAlgorithmSuite",tv=["typed","matrix","concat"],On=dt(Vg,tv,i=>{var{typed:t,matrix:e,concat:r}=i,n=Jg({typed:t}),s=Eu({typed:t}),a=Qg({concat:r});return function(l){var p=l.elop,h=l.SD||l.DS,c;p?(c={"DenseMatrix, DenseMatrix":(g,y)=>n(...a(g,y),p),"Array, Array":(g,y)=>n(...a(e(g),e(y)),p).valueOf(),"Array, DenseMatrix":(g,y)=>n(...a(e(g),y),p),"DenseMatrix, Array":(g,y)=>n(...a(g,e(y)),p)},l.SS&&(c["SparseMatrix, SparseMatrix"]=(g,y)=>l.SS(...a(g,y),p,!1)),l.DS&&(c["DenseMatrix, SparseMatrix"]=(g,y)=>l.DS(...a(g,y),p,!1),c["Array, SparseMatrix"]=(g,y)=>l.DS(...a(e(g),y),p,!1)),h&&(c["SparseMatrix, DenseMatrix"]=(g,y)=>h(...a(y,g),p,!0),c["SparseMatrix, Array"]=(g,y)=>h(...a(e(y),g),p,!0))):(c={"DenseMatrix, DenseMatrix":t.referToSelf(g=>(y,v)=>n(...a(y,v),g)),"Array, Array":t.referToSelf(g=>(y,v)=>n(...a(e(y),e(v)),g).valueOf()),"Array, DenseMatrix":t.referToSelf(g=>(y,v)=>n(...a(e(y),v),g)),"DenseMatrix, Array":t.referToSelf(g=>(y,v)=>n(...a(y,e(v)),g))},l.SS&&(c["SparseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,v)=>l.SS(...a(y,v),g,!1))),l.DS&&(c["DenseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,v)=>l.DS(...a(y,v),g,!1)),c["Array, SparseMatrix"]=t.referToSelf(g=>(y,v)=>l.DS(...a(e(y),v),g,!1))),h&&(c["SparseMatrix, DenseMatrix"]=t.referToSelf(g=>(y,v)=>h(...a(v,y),g,!0)),c["SparseMatrix, Array"]=t.referToSelf(g=>(y,v)=>h(...a(e(v),y),g,!0))));var d=l.scalar||"any",_=l.Ds||l.Ss;_&&(p?(c["DenseMatrix,"+d]=(g,y)=>s(g,y,p,!1),c[d+", DenseMatrix"]=(g,y)=>s(y,g,p,!0),c["Array,"+d]=(g,y)=>s(e(g),y,p,!1).valueOf(),c[d+", Array"]=(g,y)=>s(e(y),g,p,!0).valueOf()):(c["DenseMatrix,"+d]=t.referToSelf(g=>(y,v)=>s(y,v,g,!1)),c[d+", DenseMatrix"]=t.referToSelf(g=>(y,v)=>s(v,y,g,!0)),c["Array,"+d]=t.referToSelf(g=>(y,v)=>s(e(y),v,g,!1).valueOf()),c[d+", Array"]=t.referToSelf(g=>(y,v)=>s(e(v),y,g,!0).valueOf())));var D=l.sS!==void 0?l.sS:l.Ss;return p?(l.Ss&&(c["SparseMatrix,"+d]=(g,y)=>l.Ss(g,y,p,!1)),D&&(c[d+", SparseMatrix"]=(g,y)=>D(y,g,p,!0))):(l.Ss&&(c["SparseMatrix,"+d]=t.referToSelf(g=>(y,v)=>l.Ss(y,v,g,!1))),D&&(c[d+", SparseMatrix"]=t.referToSelf(g=>(y,v)=>D(v,y,g,!0)))),p&&p.signatures&&If(c,p.signatures),c}}),ev="matAlgo01xDSid",rv=["typed"],ql=dt(ev,rv,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,d=n._ptr,_=n._size,D=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(l.length!==_.length)throw new jt(l.length,_.length);if(l[0]!==_[0]||l[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+_+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=l[0],y=l[1],v=typeof p=="string"&&p!=="mixed"&&p===D?p:void 0,E=v?t.find(s,[v,v]):s,b,N,x=[];for(b=0;b<g;b++)x[b]=[];var F=[],M=[];for(N=0;N<y;N++){for(var S=N+1,$=d[N],C=d[N+1],I=$;I<C;I++)b=c[I],F[b]=a?E(h[I],f[b][N]):E(f[b][N],h[I]),M[b]=S;for(b=0;b<g;b++)M[b]===S?x[b][N]=F[b]:x[b][N]=f[b][N]}return r.createDenseMatrix({data:x,size:[g,y],datatype:p===r._datatype&&D===n._datatype?v:void 0})}}),nv="matAlgo04xSidSid",iv=["typed","equalScalar"],sv=dt(nv,iv,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(),d=s._values,_=s._index,D=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==g.length)throw new jt(h.length,g.length);if(h[0]!==g[0]||h[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+g+")");var v=h[0],E=h[1],b,N=e,x=0,F=a;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=f&&d?[]:void 0,S=[],$=[],C=f&&d?[]:void 0,I=f&&d?[]:void 0,R=[],U=[],q,k,P,G,j;for(k=0;k<E;k++){$[k]=S.length;var Q=k+1;for(G=p[k],j=p[k+1],P=G;P<j;P++)q=l[P],S.push(q),R[q]=Q,C&&(C[q]=f[P]);for(G=D[k],j=D[k+1],P=G;P<j;P++)if(q=_[P],R[q]===Q){if(C){var tt=F(C[q],d[P]);N(tt,x)?R[q]=null:C[q]=tt}}else S.push(q),U[q]=Q,I&&(I[q]=d[P]);if(C&&I)for(P=$[k];P<S.length;)q=S[P],R[q]===Q?(M[P]=C[q],P++):U[q]===Q?(M[P]=I[q],P++):S.splice(P,1)}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[v,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),ov="matAlgo10xSids",uv=["typed","DenseMatrix"],Ul=dt(ov,uv,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,d=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],D=c[1],g,y=a;typeof d=="string"&&(g=d,s=t.convert(s,g),y=t.find(a,[g,g]));for(var v=[],E=[],b=[],N=0;N<D;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var $=p[S];E[$]=l[S],b[$]=x}for(var C=0;C<_;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=f?y(s,E[C]):y(E[C],s):v[C][N]=s}return new e({data:v,size:[_,D],datatype:g})}}),av="multiplyScalar",fv=["typed"],lv=dt(av,fv,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":xl,"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)})}),kl="multiply",cv=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],hv=dt(kl,cv,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,f=bu({typed:t,equalScalar:s}),l=Eu({typed:t});function p(x,F){switch(x.length){case 1:switch(F.length){case 1:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;case 2:switch(F.length){case 1:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+F[0]+")");break;case 2:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function h(x,F,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(x,F)}function c(x,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(x,F)}function d(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._size,R=F._datatype||F.getDataType(),U=S[0],q=I[1],k,P=r,G=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&(k=$,P=t.find(r,[k,k]),G=t.find(n,[k,k]));for(var j=[],Q=0;Q<q;Q++){for(var tt=G(M[0],C[0][Q]),lt=1;lt<U;lt++)tt=P(tt,G(M[lt],C[lt][Q]));j[Q]=tt}return x.createDenseMatrix({data:j,size:[q],datatype:$===x._datatype&&R===F._datatype?k:void 0})}var _=t("_multiplyMatrixVector",{"DenseMatrix, any":g,"SparseMatrix, any":E}),D=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function g(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._datatype||F.getDataType(),R=S[0],U=S[1],q,k=r,P=n;$&&I&&$===I&&typeof $=="string"&&$!=="mixed"&&(q=$,k=t.find(r,[q,q]),P=t.find(n,[q,q]));for(var G=[],j=0;j<R;j++){for(var Q=M[j],tt=P(Q[0],C[0]),lt=1;lt<U;lt++)tt=k(tt,P(Q[lt],C[lt]));G[j]=tt}return x.createDenseMatrix({data:G,size:[R],datatype:$===x._datatype&&I===F._datatype?q:void 0})}function y(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._size,R=F._datatype||F.getDataType(),U=S[0],q=S[1],k=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 Q=[],tt=0;tt<U;tt++){var lt=M[tt];Q[tt]=[];for(var vt=0;vt<k;vt++){for(var ft=j(lt[0],C[0][vt]),wt=1;wt<q;wt++)ft=G(ft,j(lt[wt],C[wt][vt]));Q[tt][vt]=ft}}return x.createDenseMatrix({data:Q,size:[U,k],datatype:$===x._datatype&&R===F._datatype?P:void 0})}function v(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._values,I=F._index,R=F._ptr,U=F._size,q=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var k=S[0],P=U[1],G,j=r,Q=n,tt=s,lt=0;$&&q&&$===q&&typeof $=="string"&&$!=="mixed"&&(G=$,j=t.find(r,[G,G]),Q=t.find(n,[G,G]),tt=t.find(s,[G,G]),lt=t.convert(0,G));for(var vt=[],ft=[],wt=[],yt=F.createSparseMatrix({values:vt,index:ft,ptr:wt,size:[k,P],datatype:$===x._datatype&&q===F._datatype?G:void 0}),St=0;St<P;St++){wt[St]=ft.length;var bt=R[St],ee=R[St+1];if(ee>bt)for(var It=0,Mt=0;Mt<k;Mt++){for(var ie=Mt+1,Ht=void 0,zt=bt;zt<ee;zt++){var Gt=I[zt];It!==ie?(Ht=Q(M[Mt][Gt],C[zt]),It=ie):Ht=j(Ht,Q(M[Mt][Gt],C[zt]))}It===ie&&!tt(Ht,lt)&&(ft.push(Mt),vt.push(Ht))}}return wt[P]=ft.length,yt}function E(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=F._data,R=F._datatype||F.getDataType(),U=x._size[0],q=F._size[0],k=[],P=[],G=[],j,Q=r,tt=n,lt=s,vt=0;C&&R&&C===R&&typeof C=="string"&&C!=="mixed"&&(j=C,Q=t.find(r,[j,j]),tt=t.find(n,[j,j]),lt=t.find(s,[j,j]),vt=t.convert(0,j));var ft=[],wt=[];G[0]=0;for(var yt=0;yt<q;yt++){var St=I[yt];if(!lt(St,vt))for(var bt=$[yt],ee=$[yt+1],It=bt;It<ee;It++){var Mt=S[It];wt[Mt]?ft[Mt]=Q(ft[Mt],tt(St,M[It])):(wt[Mt]=!0,P.push(Mt),ft[Mt]=tt(St,M[It]))}}for(var ie=P.length,Ht=0;Ht<ie;Ht++){var zt=P[Ht];k[Ht]=ft[zt]}return G[1]=P.length,x.createSparseMatrix({values:k,index:P,ptr:G,size:[U,1],datatype:C===x._datatype&&R===F._datatype?j:void 0})}function b(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=F._data,R=F._datatype||F.getDataType(),U=x._size[0],q=F._size[0],k=F._size[1],P,G=r,j=n,Q=s,tt=0;C&&R&&C===R&&typeof C=="string"&&C!=="mixed"&&(P=C,G=t.find(r,[P,P]),j=t.find(n,[P,P]),Q=t.find(s,[P,P]),tt=t.convert(0,P));for(var lt=[],vt=[],ft=[],wt=x.createSparseMatrix({values:lt,index:vt,ptr:ft,size:[U,k],datatype:C===x._datatype&&R===F._datatype?P:void 0}),yt=[],St=[],bt=0;bt<k;bt++){ft[bt]=vt.length;for(var ee=bt+1,It=0;It<q;It++){var Mt=I[It][bt];if(!Q(Mt,tt))for(var ie=$[It],Ht=$[It+1],zt=ie;zt<Ht;zt++){var Gt=S[zt];St[Gt]!==ee?(St[Gt]=ee,vt.push(Gt),yt[Gt]=j(Mt,M[zt])):yt[Gt]=G(yt[Gt],j(Mt,M[zt]))}}for(var Ce=ft[bt],nr=vt.length,Me=Ce;Me<nr;Me++){var Xr=vt[Me];lt[Me]=yt[Xr]}}return ft[k]=vt.length,wt}function N(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType(),I=F._values,R=F._index,U=F._ptr,q=F._datatype||F._data===void 0?F._datatype:F.getDataType(),k=x._size[0],P=F._size[1],G=M&&I,j,Q=r,tt=n;C&&q&&C===q&&typeof C=="string"&&C!=="mixed"&&(j=C,Q=t.find(r,[j,j]),tt=t.find(n,[j,j]));for(var lt=G?[]:void 0,vt=[],ft=[],wt=x.createSparseMatrix({values:lt,index:vt,ptr:ft,size:[k,P],datatype:C===x._datatype&&q===F._datatype?j:void 0}),yt=G?[]:void 0,St=[],bt,ee,It,Mt,ie,Ht,zt,Gt,Ce=0;Ce<P;Ce++){ft[Ce]=vt.length;var nr=Ce+1;for(ie=U[Ce],Ht=U[Ce+1],Mt=ie;Mt<Ht;Mt++)if(Gt=R[Mt],G)for(ee=$[Gt],It=$[Gt+1],bt=ee;bt<It;bt++)zt=S[bt],St[zt]!==nr?(St[zt]=nr,vt.push(zt),yt[zt]=tt(I[Mt],M[bt])):yt[zt]=Q(yt[zt],tt(I[Mt],M[bt]));else for(ee=$[Gt],It=$[Gt+1],bt=ee;bt<It;bt++)zt=S[bt],St[zt]!==nr&&(St[zt]=nr,vt.push(zt));if(G)for(var Me=ft[Ce],Xr=vt.length,gn=Me;gn<Xr;gn++){var Hr=vt[gn];lt[gn]=yt[Hr]}}return ft[P]=vt.length,wt}return t(kl,n,{"Array, Array":t.referTo("Matrix, Matrix",x=>(F,M)=>{p(Ae(F),Ae(M));var S=x(e(F),e(M));return le(S)?S.valueOf():S}),"Matrix, Matrix":function(F,M){var S=F.size(),$=M.size();return p(S,$),S.length===1?$.length===1?h(F,M,S[0]):c(F,M):$.length===1?_(F,M):D(F,M)},"Matrix, Array":t.referTo("Matrix,Matrix",x=>(F,M)=>x(F,e(M))),"Array, Matrix":t.referToSelf(x=>(F,M)=>x(e(F,M.storage()),M)),"SparseMatrix, any":function(F,M){return f(F,M,n,!1)},"DenseMatrix, any":function(F,M){return l(F,M,n,!1)},"any, SparseMatrix":function(F,M){return f(M,F,n,!0)},"any, DenseMatrix":function(F,M){return l(M,F,n,!0)},"Array, any":function(F,M){return l(e(F),M,n,!1).valueOf()},"any, Array":function(F,M){return l(e(M),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(x=>(F,M,S)=>{for(var $=x(F,M),C=0;C<S.length;C++)$=x($,S[C]);return $})})}),Wl="subtract",pv=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],mv=dt(Wl,pv,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:f}=i,l=ql({typed:t}),p=oi({typed:t}),h=zl({typed:t,equalScalar:r}),c=Ul({typed:t,DenseMatrix:a}),d=si({typed:t,DenseMatrix:a}),_=On({typed:t,matrix:e,concat:f});return t(Wl,{"any, any":n},_({elop:n,SS:h,DS:l,SD:p,Ss:d,sS:c}))}),dv="matAlgo07xSSf",gv=["typed","DenseMatrix"],zs=dt(dv,gv,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 d=l[0],_=l[1],D,g=0,y=f;typeof p=="string"&&p===c&&p!=="mixed"&&(D=p,g=t.convert(0,D),y=t.find(f,[D,D]));var v,E,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],x=[],F=[],M=[];for(E=0;E<_;E++){var S=E+1;for(r(s,E,F,N,S),r(a,E,M,x,S),v=0;v<d;v++){var $=F[v]===S?N[v]:g,C=M[v]===S?x[v]:g;b[v][E]=y($,C)}}return new e({data:b,size:[d,_],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,d=c[s],_=c[s+1];d<_;d++){var D=h[d];a[D]=l,f[D]=p[d]}}}),Yl="conj",vv=["typed"],_v=dt(Yl,vv,i=>{var{typed:t}=i;return t(Yl,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Br(r,e))})}),Zl="concat",wv=["typed","matrix","isInteger"],Dv=dt(Zl,wv,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(Zl,{"...Array | Matrix | number | BigNumber":function(s){var a,f=s.length,l=-1,p,h=!1,c=[];for(a=0;a<f;a++){var d=s[a];if(le(d)&&(h=!0),ae(d)||ye(d)){if(a!==f-1)throw new Error("Dimension must be specified as last argument");if(p=l,l=d.valueOf(),!r(l))throw new TypeError("Integer number expected for dimension");if(l<0||a>0&&l>p)throw new fn(l,p+1)}else{var _=te(d).valueOf(),D=Ae(_);if(c[a]=_,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 g=c.shift();c.length;)g=Qf(g,c.shift(),l);return h?e(g):g},"...string":function(s){return s.join("")}})}),jl="count",yv=["typed","size","prod"],bv=dt(jl,yv,i=>{var{typed:t,size:e,prod:r}=i;return t(jl,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Gl="identity",Ev=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Av=dt(Gl,Ev,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(Gl,{"":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,d){return l(h,c,d)},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 d=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 _=d?new n(1):1,D=d?new d(0):0,g=[p,h];if(c){if(c==="sparse")return a.diagonal(g,_,0,D);if(c==="dense")return s.diagonal(g,_,0,D);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var y=au([],g,D),v=p<h?p:h,E=0;E<v;E++)y[E][E]=_;return y}}),Kl="kron",xv=["typed","matrix","multiplyScalar"],Cv=dt(Kl,xv,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Kl,{"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(Ae(s).length===1&&(s=[s]),Ae(a).length===1&&(a=[a]),Ae(s).length>2||Ae(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(d){return l.push(r(c,d))})})})})&&f}});function Fv(){throw new Error('No "bignumber" implementation available')}function Mv(){throw new Error('No "fraction" implementation available')}function Nv(){throw new Error('No "matrix" implementation available')}var Jl="reshape",Sv=["typed","isInteger","matrix"],Bv=dt(Jl,Sv,i=>{var{typed:t,isInteger:e}=i;return t(Jl,{"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)}),lu(n,s)}})}),Xl="size",Iv=["typed","config","?matrix"],Tv=dt(Xl,Iv,i=>{var{typed:t,config:e,matrix:r}=i;return t(Xl,{Matrix:function(s){return s.create(s.size())},Array:Ae,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([]):Nv()}})}),Hl="transpose",$v=["typed","matrix"],Ov=dt(Hl,$v,i=>{var{typed:t,matrix:e}=i;return t(Hl,{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,d=0;d<l;d++){c=h[d]=[];for(var _=0;_<f;_++)c[_]=te(p[_][d])}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,d=p?[]:void 0,_=[],D=[],g=[],y=0;y<f;y++)g[y]=0;var v,E,b;for(v=0,E=h.length;v<E;v++)g[h[v]]++;for(var N=0,x=0;x<f;x++)D.push(N),N+=g[x],g[x]=D[x];for(D.push(N),b=0;b<l;b++)for(var F=c[b],M=c[b+1],S=F;S<M;S++){var $=g[h[S]]++;_[$]=b,p&&(d[$]=te(p[S]))}return a.createSparseMatrix({values:d,index:_,ptr:D,size:[l,f],datatype:a._datatype})}}),Ql="ctranspose",Rv=["typed","transpose","conj"],Lv=dt(Ql,Rv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(Ql,{any:function(s){return r(e(s))}})}),Vl="mode",Pv=["typed","isNaN","isNumeric"],zv=dt(Vl,Pv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(Vl,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=hu(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 mn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+an(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: "+an(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var tc="prod",qv=["typed","config","multiplyScalar","numeric"],Uv=dt(tc,qv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(tc,{"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(Li(a,function(l){try{f=f===void 0?l:r(f,l)}catch(p){throw mn(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}}),kv="numeric",Wv=["number","?bignumber","?fraction"],Yv=dt(kv,Wv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):Fv,Fraction:r?a=>r(a):Mv};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=an(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)}}),ec="divideScalar",Zv=["typed","numeric"],jv=dt(ec,Zv,i=>{var{typed:t,numeric:e}=i;return t(ec,{"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)})}),rc="pow",Gv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Kv=dt(rc,Gv,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:f,fraction:l,Complex:p}=i;return t(rc,{"number, number":h,"Complex, Complex":function(D,g){return D.pow(g)},"BigNumber, BigNumber":function(D,g){return g.isInteger()||D>=0||e.predictable?D.pow(g):new p(D.toNumber(),0).pow(g.toNumber(),0)},"Fraction, Fraction":function(D,g){var y=D.pow(g);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(),g.valueOf())},"Array, number":c,"Array, BigNumber":function(D,g){return c(D,g.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(D,g){return d(D,g.toNumber())},"Unit, number | BigNumber":function(D,g){return D.pow(g)}});function h(_,D){if(e.predictable&&!he(D)&&_<0)try{var g=l(D),y=f(g);if((D===y||Math.abs((D-y)/D)<1e-14)&&g.d%2===1)return(g.n%2===0?1:-1)*Math.pow(-_,D)}catch{}return e.predictable&&(_<-1&&D===1/0||_>-1&&_<0&&D===-1/0)?NaN:he(D)||_>=0||e.predictable?Fl(_,D):_*_<1&&D===1/0||_*_>1&&D===-1/0?0:new p(_,0).pow(D,0)}function c(_,D){if(!he(D))throw new TypeError("For A^b, b must be an integer (value is "+D+")");var g=Ae(_);if(g.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+g.length+" dimensions)");if(g[0]!==g[1])throw new Error("For A^b, A must be square (size is "+g[0]+"x"+g[1]+")");if(D<0)try{return c(a(_),-D)}catch(E){throw E.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+")"):E}for(var y=r(g[0]).valueOf(),v=_;D>=1;)(D&1)===1&&(y=n(v,y)),D>>=1,v=n(v,v);return y}function d(_,D){return s(c(_.valueOf(),D))}}),nc="dotDivide",Jv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Xv=dt(nc,Jv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,f=kg({typed:t,equalScalar:r}),l=oi({typed:t}),p=zs({typed:t,DenseMatrix:s}),h=bu({typed:t,equalScalar:r}),c=si({typed:t,DenseMatrix:s}),d=On({typed:t,matrix:e,concat:a});return t(nc,d({elop:n,SS:p,DS:l,SD:f,Ss:h,sS:c}))}),qs="compare",Hv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],Qv=dt(qs,Hv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:f,concat:l}=i,p=oi({typed:t}),h=zl({typed:t,equalScalar:r}),c=si({typed:t,DenseMatrix:f}),d=On({typed:t,matrix:n,concat:l}),_=Ls({typed:t});return t(qs,Vv({typed:t,config:e}),{"boolean, boolean":function(g,y){return g===y?0:g>y?1:-1},"BigNumber, BigNumber":function(g,y){return Rs(g,y,e.epsilon)?new s(0):new s(g.cmp(y))},"Fraction, Fraction":function(g,y){return new a(g.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},_,d({SS:h,DS:p,Ss:c}))}),Vv=dt(qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(qs,{"number, number":function(n,s){return $n(n,s,e.epsilon)?0:n>s?1:-1}})}),Us="equal",t1=["typed","matrix","equalScalar","DenseMatrix","concat"],e1=dt(Us,t1,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=oi({typed:t}),f=zs({typed:t,DenseMatrix:n}),l=si({typed:t,DenseMatrix:n}),p=On({typed:t,matrix:e,concat:s});return t(Us,r1({typed:t,equalScalar:r}),p({elop:r,SS:f,DS:a,Ss:l}))}),r1=dt(Us,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Us,{"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)}})}),ks="smaller",n1=["typed","config","matrix","DenseMatrix","concat"],i1=dt(ks,n1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=oi({typed:t}),f=zs({typed:t,DenseMatrix:n}),l=si({typed:t,DenseMatrix:n}),p=On({typed:t,matrix:r,concat:s}),h=Ls({typed:t});return t(ks,s1({typed:t,config:e}),{"boolean, boolean":(c,d)=>c<d,"BigNumber, BigNumber":function(d,_){return d.lt(_)&&!Rs(d,_,e.epsilon)},"Fraction, Fraction":(c,d)=>c.compare(d)===-1,"Complex, Complex":function(d,_){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:f,DS:a,Ss:l}))}),s1=dt(ks,["typed","config"],i=>{var{typed:t,config:e}=i;return t(ks,{"number, number":function(n,s){return n<s&&!$n(n,s,e.epsilon)}})}),Ws="larger",o1=["typed","config","matrix","DenseMatrix","concat"],u1=dt(Ws,o1,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=oi({typed:t}),f=zs({typed:t,DenseMatrix:n}),l=si({typed:t,DenseMatrix:n}),p=On({typed:t,matrix:r,concat:s}),h=Ls({typed:t});return t(Ws,a1({typed:t,config:e}),{"boolean, boolean":(c,d)=>c>d,"BigNumber, BigNumber":function(d,_){return d.gt(_)&&!Rs(d,_,e.epsilon)},"Fraction, Fraction":(c,d)=>c.compare(d)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:f,DS:a,Ss:l}))}),a1=dt(Ws,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ws,{"number, number":function(n,s){return n>s&&!$n(n,s,e.epsilon)}})}),ic="deepEqual",f1=["typed","equal"],l1=dt(ic,f1,i=>{var{typed:t,equal:e}=i;return t(ic,{"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)}}),sc="partitionSelect",c1=["typed","isNumeric","isNaN","compare"],h1=dt(sc,c1,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(p,h)=>-n(p,h);return t(sc,{"Array | Matrix, number":function(h,c){return f(h,c,s)},"Array | Matrix, number, string":function(h,c,d){if(d==="asc")return f(h,c,s);if(d==="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(le(p)){var d=p.size();if(d.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 d=0;d<p.length;d++)if(e(p[d])&&r(p[d]))return p[d];for(var _=0,D=p.length-1;_<D;){for(var g=_,y=D,v=p[Math.floor(Math.random()*(D-_+1))+_];g<y;)if(c(p[g],v)>=0){var E=p[y];p[y]=p[g],p[g]=E,--y}else++g;c(p[g],v)>0&&--g,h<=g?D=g:_=g+1}return p[h]}}),oc="max",p1=["typed","config","numeric","larger"],m1=dt(oc,p1,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(oc,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){return yu(l,p.valueOf(),s)},"...":function(l){if(Ts(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 mn(p,"max",l)}}function a(f){var l;if(Li(f,function(p){try{isNaN(p)&&typeof p=="number"?l=NaN:(l===void 0||n(p,l))&&(l=p)}catch(h){throw mn(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}}),uc="min",d1=["typed","config","numeric","smaller"],g1=dt(uc,d1,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(uc,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){return yu(l,p.valueOf(),s)},"...":function(l){if(Ts(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 mn(p,"min",l)}}function a(f){var l;if(Li(f,function(p){try{isNaN(p)&&typeof p=="number"?l=NaN:(l===void 0||n(p,l))&&(l=p)}catch(h){throw mn(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}}),ac="add",v1=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],_1=dt(ac,v1,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:f}=i,l=ql({typed:t}),p=sv({typed:t,equalScalar:n}),h=Ul({typed:t,DenseMatrix:s}),c=On({typed:t,matrix:e,concat:f});return t(ac,{"any, any":r,"any, any, ...any":t.referToSelf(d=>(_,D,g)=>{for(var y=d(_,D),v=0;v<g.length;v++)y=d(y,g[v]);return y})},c({elop:r,DS:l,SS:p,Ss:h}))}),fc="dot",w1=["typed","addScalar","multiplyScalar","conj","size"],D1=dt(fc,w1,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(fc,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function a(h,c){var d=p(h),_=p(c),D,g;if(d.length===1)D=d[0];else if(d.length===2&&d[1]===1)D=d[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+d.join(", ")+")");if(_.length===1)g=_[0];else if(_.length===2&&_[1]===1)g=_[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+_.join(", ")+")");if(D!==g)throw new RangeError("Vectors must have equal length ("+D+" != "+g+")");if(D===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return D}function f(h,c){var d=a(h,c),_=le(h)?h._data:h,D=le(h)?h._datatype||h.getDataType():void 0,g=le(c)?c._data:c,y=le(c)?c._datatype||c.getDataType():void 0,v=p(h).length===2,E=p(c).length===2,b=e,N=r;if(D&&y&&D===y&&typeof D=="string"&&D!=="mixed"){var x=D;b=t.find(e,[x,x]),N=t.find(r,[x,x])}if(!v&&!E){for(var F=N(n(_[0]),g[0]),M=1;M<d;M++)F=b(F,N(n(_[M]),g[M]));return F}if(!v&&E){for(var S=N(n(_[0]),g[0][0]),$=1;$<d;$++)S=b(S,N(n(_[$]),g[$][0]));return S}if(v&&!E){for(var C=N(n(_[0][0]),g[0]),I=1;I<d;I++)C=b(C,N(n(_[I][0]),g[I]));return C}if(v&&E){for(var R=N(n(_[0][0]),g[0][0]),U=1;U<d;U++)R=b(R,N(n(_[U][0]),g[U][0]));return R}}function l(h,c){a(h,c);for(var d=h._index,_=h._values,D=c._index,g=c._values,y=0,v=e,E=r,b=0,N=0;b<d.length&&N<D.length;){var x=d[b],F=D[N];if(x<F){b++;continue}if(x>F){N++;continue}x===F&&(y=v(y,E(_[b],g[N])),b++,N++)}return y}function p(h){return le(h)?h.size():s(h)}}),y1="trace",b1=["typed","matrix","add"],E1=dt(y1,b1,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,d=0;d<p;d++)c=r(c,l[d][d]);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],d=h[1];if(c===d){var _=0;if(f.length>0)for(var D=0;D<d;D++)for(var g=p[D],y=p[D+1],v=g;v<y;v++){var E=l[v];if(E===D){_=r(_,f[v]);break}if(E>D)break}return _}throw new RangeError("Matrix must be square (size: "+se(h)+")")}}),lc="det",A1=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],x1=dt(lc,A1,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:f}=i;return t(lc,{any:function(h){return te(h)},"Array | Matrix":function(h){var c;switch(le(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 d=c[0],_=c[1];if(d===_)return l(h.clone().valueOf(),d);if(_===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 d=!1,_=new Array(h).fill(0).map((M,S)=>S),D=0;D<h;D++){var g=_[D];if(a(p[g][D])){var y=void 0;for(y=D+1;y<h;y++)if(!a(p[_[y]][D])){g=_[y],_[y]=_[D],_[D]=g,d=!d;break}if(y===h)return p[g][D]}for(var v=p[g][D],E=D===0?1:p[_[D-1]][D-1],b=D+1;b<h;b++)for(var N=_[b],x=D+1;x<h;x++)p[N][x]=s(r(n(p[N][x],v),n(p[N][D],p[g][x])),E)}var F=p[_[h-1]][h-1];return d?f(F):F}}),cc="inv",C1=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],F1=dt(cc,C1,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:f,identity:l,abs:p}=i;return t(cc,{"Array | Matrix":function(d){var _=le(d)?d.size():Ae(d);switch(_.length){case 1:if(_[0]===1)return le(d)?e([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+se(_)+")");case 2:{var D=_[0],g=_[1];if(D===g)return le(d)?e(h(d.valueOf(),D,g),d.storage()):h(d,D,g);throw new RangeError("Matrix must be square (size: "+se(_)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(_)+")")}},any:function(d){return r(1,d)}});function h(c,d,_){var D,g,y,v,E;if(d===1){if(v=c[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(d===2){var b=f(c);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(c[1][1],b),r(a(c[0][1]),b)],[r(a(c[1][0]),b),r(c[0][0],b)]]}else{var N=c.concat();for(D=0;D<d;D++)N[D]=N[D].concat();for(var x=l(d).valueOf(),F=0;F<_;F++){var M=p(N[F][F]),S=F;for(D=F+1;D<d;)p(N[D][F])>M&&(M=p(N[D][F]),S=D),D++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");D=S,D!==F&&(E=N[F],N[F]=N[D],N[D]=E,E=x[F],x[F]=x[D],x[D]=E);var $=N[F],C=x[F];for(D=0;D<d;D++){var I=N[D],R=x[D];if(D!==F){if(I[F]!==0){for(y=r(a(I[F]),$[F]),g=F;g<_;g++)I[g]=n(I[g],s(y,$[g]));for(g=0;g<_;g++)R[g]=n(R[g],s(y,C[g]))}}else{for(y=$[F],g=F;g<_;g++)I[g]=r(I[g],y);for(g=0;g<_;g++)R[g]=r(R[g],y)}}}return x}}}),hc="pinv",M1=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],N1=dt(hc,M1,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:d}=i;return t(hc,{"Array | Matrix":function(b){var N=le(b)?b.size():Ae(b);switch(N.length){case 1:return v(b)?l(b):N[0]===1?r(b):a(l(b),f(b,b));case 2:{if(v(b))return l(b);var x=N[0],F=N[1];if(x===F)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return le(b)?e(_(b.valueOf(),x,F),b.storage()):_(b,x,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+se(N)+")")}},any:function(b){return s(b,0)?te(b):p(1,b)}});function _(E,b,N){var{C:x,F}=g(E,b,N),M=h(r(h(l(x),x)),l(x)),S=h(l(F),r(h(F,l(F))));return h(S,M)}function D(E,b,N){for(var x=te(E),F=0,M=0;M<b;M++){if(N<=F)return x;for(var S=M;y(x[S][F]);)if(S++,b===S&&(S=M,F++,N===F))return x;[x[S],x[M]]=[x[M],x[S]];for(var $=x[M][F],C=0;C<N;C++)x[M][C]=a(x[M][C],$);for(var I=0;I<b;I++)if(I!==M){$=x[I][F];for(var R=0;R<N;R++)x[I][R]=c(x[I][R],h(-1,h($,x[M][R])))}F++}return x}function g(E,b,N){var x=D(E,b,N),F=E.map((S,$)=>S.filter((C,I)=>I<b&&!y(f(x[I],x[I])))),M=x.filter((S,$)=>!y(f(x[$],x[$])));return{C:F,F:M}}function y(E){return s(c(E,d(1,1)),c(0,d(1,1)))}function v(E){return n(c(E,d(1,1)),c(h(E,0),d(1,1)))}}),S1="divide",B1=["typed","matrix","multiply","equalScalar","divideScalar","inv"],I1=dt(S1,B1,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,f=bu({typed:t,equalScalar:n}),l=Eu({typed:t});return t("divide",If({"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))}),pc="sum",T1=["typed","config","add","numeric"],$1=dt(pc,T1,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(pc,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(l){if(Ts(l))throw new TypeError("Scalar values expected in function sum");return s(l)}});function s(f){var l;return Li(f,function(p){try{l=l===void 0?p:r(l,p)}catch(h){throw mn(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=yu(f,l,r);return p}catch(h){throw mn(h,"sum")}}}),mc="median",O1=["typed","add","divide","compare","partitionSelect"],R1=dt(mc,O1,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(p){try{p=hu(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,d=s(p,c+1),_=p[c],D=0;D<c;++D)n(p[D],_)>0&&(_=p[D]);return l(_,d)}else{var g=s(p,(h-1)/2);return f(g)}}catch(y){throw mn(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(mc,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,c){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(Ts(h))throw new TypeError("Scalar values expected in function median");return a(h)}})}),Ys=Ld({config:er}),Au=Ud({}),xu=Zd({}),Cu=Kd({}),kr=Hd({Matrix:Cu}),Ft=qm({BigNumber:Ys,Complex:Au,DenseMatrix:kr,Fraction:xu}),L1=Ng({typed:Ft}),Zs=Bg({typed:Ft}),P1=Dg({BigNumber:Ys,typed:Ft}),dc=_v({typed:Ft}),dn=fg({config:er,typed:Ft}),js=tg({typed:Ft}),z1=ig({typed:Ft}),Gs=lv({typed:Ft}),gc=vg({typed:Ft}),Fu=hg({Matrix:Cu,equalScalar:dn,typed:Ft}),vc=Tg({typed:Ft}),_c=og({typed:Ft}),Mu=Fg({typed:Ft}),wc=Eg({Fraction:xu,typed:Ft}),Dc=rg({typed:Ft}),xe=xg({DenseMatrix:kr,Matrix:Cu,SparseMatrix:Fu,typed:Ft}),yc=zv({isNaN:_c,isNumeric:Dc,typed:Ft}),Pi=Yv({bignumber:P1,fraction:wc,number:gc}),q1=Uv({config:er,multiplyScalar:Gs,numeric:Pi,typed:Ft}),U1=Bv({isInteger:js,matrix:xe,typed:Ft}),bc=Tv({matrix:xe,config:er,typed:Ft}),Ec=Ov({matrix:xe,typed:Ft}),Rn=Dv({isInteger:js,matrix:xe,typed:Ft}),k1=bv({prod:q1,size:bc,typed:Ft}),W1=Lv({conj:dc,transpose:Ec,typed:Ft}),zi=jv({numeric:Pi,typed:Ft}),Y1=Xv({DenseMatrix:kr,concat:Rn,divideScalar:zi,equalScalar:dn,matrix:xe,typed:Ft}),Ac=e1({DenseMatrix:kr,concat:Rn,equalScalar:dn,matrix:xe,typed:Ft}),xc=Av({BigNumber:Ys,DenseMatrix:kr,SparseMatrix:Fu,config:er,matrix:xe,typed:Ft}),Z1=Cv({matrix:xe,multiplyScalar:Gs,typed:Ft}),j1=i1({DenseMatrix:kr,concat:Rn,config:er,matrix:xe,typed:Ft}),G1=mv({DenseMatrix:kr,concat:Rn,equalScalar:dn,matrix:xe,subtractScalar:vc,typed:Ft,unaryMinus:Mu}),qi=_1({DenseMatrix:kr,SparseMatrix:Fu,addScalar:Zs,concat:Rn,equalScalar:dn,matrix:xe,typed:Ft}),Cc=Qv({BigNumber:Ys,DenseMatrix:kr,Fraction:xu,concat:Rn,config:er,equalScalar:dn,matrix:xe,typed:Ft}),K1=l1({equal:Ac,typed:Ft}),Fc=D1({addScalar:Zs,conj:dc,multiplyScalar:Gs,size:bc,typed:Ft}),J1=u1({DenseMatrix:kr,concat:Rn,config:er,matrix:xe,typed:Ft}),Nu=g1({config:er,numeric:Pi,smaller:j1,typed:Ft}),ui=hv({addScalar:Zs,dot:Fc,equalScalar:dn,matrix:xe,multiplyScalar:Gs,typed:Ft}),X1=h1({compare:Cc,isNaN:_c,isNumeric:Dc,typed:Ft}),H1=$1({add:qi,config:er,numeric:Pi,typed:Ft}),Q1=E1({add:qi,matrix:xe,typed:Ft}),Mc=x1({divideScalar:zi,isZero:z1,matrix:xe,multiply:ui,subtractScalar:vc,typed:Ft,unaryMinus:Mu}),V1=m1({config:er,larger:J1,numeric:Pi,typed:Ft}),Ks=F1({abs:L1,addScalar:Zs,det:Mc,divideScalar:zi,identity:xc,matrix:xe,multiply:ui,typed:Ft,unaryMinus:Mu}),t_=N1({Complex:Au,add:qi,ctranspose:W1,deepEqual:K1,divideScalar:zi,dot:Fc,dotDivide:Y1,equal:Ac,inv:Ks,matrix:xe,multiply:ui,typed:Ft}),e_=Kv({Complex:Au,config:er,fraction:wc,identity:xc,inv:Ks,matrix:xe,multiply:ui,number:gc,typed:Ft}),r_=I1({divideScalar:zi,equalScalar:dn,inv:Ks,matrix:xe,multiply:ui,typed:Ft}),Nc=R1({add:qi,compare:Cc,divide:r_,partitionSelect:X1,typed:Ft});class n_{constructor(t,e,r){K(this,"_cacheData");K(this,"_variables");K(this,"_math");K(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(e===void 0||r===void 0||n===void 0)return;const 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 d=0;d<=e-1;d++){const _=Math.exp(-1*Math.pow(d-l,2)/(2*Math.pow(p,2)));h+=_,c+=f[f.length-1-(e-d-1)]*_}return c/h}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=H1(...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||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let 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||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const f=r*a;return[s,s+f,s-f]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const f=r*a;return(s+f-(s-f))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let 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||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),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 d=0;d<r;d++){const[_,D]=s[s.length-1-d],g=_-a,y=D-f;l+=g*y,p+=g*g,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!1;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!1;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!1;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){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let 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:d=0}=this._cacheData[n]||{},{low:_,high:D,close:g}=this._variables;if(s===void 0||a===void 0||f===void 0)return this._cacheData[n]={low:_,high:D,close:g,PDMS:l,NDMS:p,TRS:D-_,count:1},[void 0,void 0,void 0];let y=D-a,v=s-_;y=y>v&&y>0?y:0,v=v>y&&v>0?v:0,y===v&&(y=v=0);const E=Math.max(D-_,Math.abs(D-f),Math.abs(_-f));if(d<t)return this._cacheDataHandle(n,{low:_,high:D,close:g,PDMS:(l||0)+y,NDMS:(p||0)+v,TRS:(h||0)+E,count:d+1}),[void 0,void 0,void 0];{const b=l-l/t+y,N=p-p/t+v,x=h-h/t+E,F=b/x*100,M=N/x*100,S=Math.abs((F-M)/(F+M))*100;let $=S,C=[F,M,void 0];if(d+1-t<e){const I=d+1-t;$=((c||0)*(I-1)+S)/I}else $=(c*(e-1)+S)/e,C=[F,M,$];return this._cacheDataHandle(n,{low:_,high:D,close:g,PDMS:b,NDMS:N,TRS:x,ADX:$,count:d+1}),C}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))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||isNaN(t)||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||isNaN(t)||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||t===void 0||isNaN(t)||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||t===void 0||isNaN(t)||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,d)=>h>=d[p]?c:p,0)-e+1}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let 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||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta: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||isNaN(t)||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(_=>_!==void 0);let f=0,l=0,p=0,h=0;for(const[_,D]of a.entries())f+=_,l+=D,p+=_*D,h+=_*_;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||t===void 0||isNaN(t)||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||t===void 0||isNaN(t)||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,d)=>h<=d[p]?c:p,0)-e+1}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),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||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Nc(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),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||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Nu(yc(n.slice(-e)))}mom({source:t,length:e},r){if(e===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||t===void 0||isNaN(t))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||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),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 Xt;let{close:a,open:f,low:l,high:p}=this._variables;const h=`pivot_point_levels_${n}`,{close:c,low:d,high:_,open:D,result:g}=this._cacheData[h]||{};if(!e&&(_&&d&&(p=Math.max(_,p),l=Math.min(d,l)),this._cacheDataHandle(h,{close:a,open:f,low:l,high:p,result:g}),!r))return s._value=g||[],s;const y={close:a,open:f,low:l,high:p};e===!0&&!r&&(a=c,f=D,l=d,p=_);const v=this._getPivotPointLevels(p,l,a,f,r,t);return this._cacheDataHandle(h,{...y,result:v}),s._value=v,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 Tn.traditional:return this._traditional(t,e,r);case Tn.fibonacci:return this._fibonacci(t,e,r);case Tn.woodie:return s?[]:this._woodie(t,e);case Tn.classic:return this._classic(t,e,r);case Tn.dm:return this._DM(t,e,r,n);case Tn.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),d=n*2-(2*t-e),_=n*3-(3*t-e),D=n*4-(4*t-e);return[n,s,h,a,c,f,d,l,_,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),d=h-(t-e);return[n,s,a,f,l,p,h,c,d]}_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),d=n-3*(t-e);return[n,s,a,f,l,p,h,c,d]}_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,d=r-1.1*(t-e)/2,_=t/e*r,D=r-(_-r);return[n,s,a,f,l,p,h,c,d,_,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||isNaN(t)||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||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{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:d,acceleration:_,isBelow:D}=h,g=!1;const{close:y,low:v,high:E,bar_index:b}=this._variables;return b===1&&(y>s?(D=!0,d=E,c=a):(D=!1,d=v,c=f),g=!0,_=t),c=c+_*(d-c),D?c>v&&(g=!0,D=!1,c=Math.max(E,d||0),d=v,_=t):c<E&&(g=!0,D=!0,c=Math.min(v,d||0),d=E,_=t),g||(D?E>(d||0)&&(d=E,_=Math.min((_||0)+e,r)):v<(d||0)&&(d=v,_=Math.min((_||0)+e,r))),D?(c=Math.min(c,a),b>1&&(c=Math.min(c,l))):(c=Math.max(c,f),b>1&&(c=Math.max(c,p))),this._cacheDataHandle(`sar_${n}`,{high:E,close:y,low:v,preLow:a,preHigh:f,data:Object.assign(h,{result:c,maxMin:d,acceleration:_,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||isNaN(t)||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]||{},d=this.atr({length:e},r);if(d===void 0)return this._cacheDataHandle(a,{close:s}),[void 0,void 0];let _=n+t*d,D=n-t*d;const g=f||0,y=l||0;D=D>y||c<y?D:y,_=_<g||c>g?_:g;let v;h===void 0?v=1:p===g?v=s>_?-1:1:v=s<D?1:-1;const E=v===-1?D:_;return this._cacheDataHandle(a,{upperBand:_,lowerBand:D,superTrend:E,atr:d,close:s}),[E,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high: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||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),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||isNaN(t)||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,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=f=l=h=0,p=!0),!p)return r!==void 0?[]:void 0;const c=t*s+a,d=s+f,_=c/d;return l++,r!==void 0?(h=s*Math.pow(t,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:d,count:l,isReset:p,sumS:h}),this._computeBands(h,d,r,_)):(this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:d,count:l,isReset:p}),_)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),f=a!==void 0&&!isNaN(a)?n+r*a:void 0,l=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,f,l]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex: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}))}}const i_={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an undefined object. The object is 'na'."};Lr.SERIES,Lr.SIMPLE,Lr.INPUT,Lr.CONST,Lr.INT,Lr.FLOAT,Lr.BOOL,Lr.COLOR,Lr.STRING;const s_=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"];var Ui=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(Ui||{});class o_{constructor(t,e){K(this,"_cacheData");K(this,"_variables");K(this,"_errorListener");K(this,"_count");K(this,"_historyInputs");K(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(t.defval===void 0&&this._errorListener.addError(i_.inputDefvalErr,e,Ui.Error),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=s_: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,Ui.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(Fr.dataWindow)||e.includes(Fr.statusLine)||this._errorListener.addError("Invalid argument 'display' in 'input' call. Possible values: [display.none, display.data_window, display.status_line, display.all]",t,Ui.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 u_{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:d,g:_,b:D,a:g}=this._parseColor(s),y=l+f*(d-l),v=p+f*(_-p),E=h+f*(D-h),b=c+f*(g-c);return`rgba(${Math.round(y)}, ${Math.round(v)}, ${Math.round(E)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=(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 a_=Object.prototype.toString;function ki(i){const t=a_.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var f_=Object.freeze({__proto__:null,isAnyArray:ki}),l_=De(f_);function c_(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ki(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 h_(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ki(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 p_(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ki(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(!ki(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=h_(i),n=c_(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 m_=Object.freeze({__proto__:null,default:p_}),d_=De(m_);Object.defineProperty(Pt,"__esModule",{value:!0});var Je=l_,Sc=d_;const Js=" ".repeat(2),Bc=" ".repeat(4);function g_(){return Ic(this)}function Ic(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
55
+ ${Js}[
56
+ ${Bc}${v_(i,e,r,n,s)}
57
+ ${Js}]
58
+ ${Js}rows: ${i.rows}
59
+ ${Js}columns: ${i.columns}
60
+ }`}function v_(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 d=0;d<l;d++)c.push(__(i.get(h,d),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
+ ${Bc}`)}function __(i,t,e){return(i>=0&&e?` ${Tc(i,t-1)}`:Tc(i,t)).padEnd(t)}function Tc(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 w_(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 dr(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 gr(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 ai(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 fi(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 Su(i,t){if(!Je.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 Bu(i,t){if(!Je.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 Iu(i,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(Hs("startRow",t),Hs("endRow",e),Hs("startColumn",r),Hs("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 Xs(i,t=0){let e=[];for(let r=0;r<i;r++)e.push(t);return e}function Hs(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function li(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function D_(i){let t=Xs(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 y_(i){let t=Xs(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 b_(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 E_(i){let t=Xs(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 A_(i){let t=Xs(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 x_(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 C_(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 F_(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 M_(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 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 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 B_(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 I_(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 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[e])}function $_(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 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[r])}function R_(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 L_(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){dr(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){dr(this,t),e=ai(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){dr(this,t),dr(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){gr(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){gr(this,t),e=fi(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){gr(this,t),gr(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=ai(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=ai(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=ai(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=ai(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=fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){dr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){gr(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(){li(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(){li(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(dr(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){dr(this,t),li(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(dr(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){dr(this,t),li(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(gr(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){gr(this,t),li(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(gr(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){gr(this,t),li(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),d=(f+p)*n,_=r*(a-h),D=p*(l-n),g=(r+s)*h,y=(f-r)*(n+a),v=(s-p)*(l+h),E=c+D-g+v,b=_+g,N=d+D,x=c-d+_+y;return e.set(0,0,E),e.set(0,1,b),e.set(1,0,N),e.set(1,1,x),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),d=t.get(0,0),_=t.get(0,1),D=t.get(0,2),g=t.get(1,0),y=t.get(1,1),v=t.get(1,2),E=t.get(2,0),b=t.get(2,1),N=t.get(2,2),x=(r+n+s-a-f-h-c)*y,F=(r-a)*(-_+y),M=f*(-d+_+g-y-v-E+N),S=(-r+a+f)*(d-_+y),$=(a+f)*(-d+_),C=r*d,I=(-r+p+h)*(d-D+v),R=(-r+p)*(D-v),U=(p+h)*(-d+D),q=(r+n+s-f-l-p-h)*v,k=h*(-d+D+g-y-v-E+b),P=(-s+h+c)*(y+E-b),G=(s-c)*(y-b),j=s*E,Q=(h+c)*(-E+b),tt=(-s+f+l)*(v+E-N),lt=(s-l)*(v-N),vt=(f+l)*(-E+N),ft=n*g,wt=l*b,yt=a*D,St=p*_,bt=c*N,ee=C+j+ft,It=x+S+$+C+P+j+Q,Mt=C+I+U+q+j+tt+vt,ie=F+M+S+C+j+tt+lt,Ht=F+S+$+C+wt,zt=j+tt+lt+vt+yt,Gt=C+I+R+k+P+G+j,Ce=P+G+j+Q+St,nr=C+I+R+U+bt;return e.set(0,0,ee),e.set(0,1,It),e.set(0,2,Mt),e.set(1,0,ie),e.set(1,1,Ht),e.set(1,2,zt),e.set(2,0,Gt),e.set(2,1,Ce),e.set(2,2,nr),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,d,_){let D=c.rows,g=c.columns;if(D===d&&g===_)return c;{let y=$t.zeros(d,_);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,d,_,D){if(_<=512||D<=512)return c.mmul(d);_%2===1&&D%2===1?(c=f(c,_+1,D+1),d=f(d,_+1,D+1)):_%2===1?(c=f(c,_+1,D),d=f(d,_+1,D)):D%2===1&&(c=f(c,_,D+1),d=f(d,_,D+1));let g=parseInt(c.rows/2,10),y=parseInt(c.columns/2,10),v=c.subMatrix(0,g-1,0,y-1),E=d.subMatrix(0,g-1,0,y-1),b=c.subMatrix(0,g-1,y,c.columns-1),N=d.subMatrix(0,g-1,y,d.columns-1),x=c.subMatrix(g,c.rows-1,0,y-1),F=d.subMatrix(g,d.rows-1,0,y-1),M=c.subMatrix(g,c.rows-1,y,c.columns-1),S=d.subMatrix(g,d.rows-1,y,d.columns-1),$=h($t.add(v,M),$t.add(E,S),g,y),C=h($t.add(x,M),E,g,y),I=h(v,$t.sub(N,S),g,y),R=h(M,$t.sub(F,E),g,y),U=h($t.add(v,b),S,g,y),q=h($t.sub(x,v),$t.add(E,N),g,y),k=h($t.sub(b,M),$t.add(F,S),g,y),P=$t.add($,R);P.sub(U),P.add(k);let G=$t.add(I,U),j=$t.add(C,R),Q=$t.sub($,C);Q.add(I),Q.add(q);let tt=$t.zeros(2*P.rows,2*P.columns);return tt=tt.setSubMatrix(P,0,0),tt=tt.setSubMatrix(G,P.rows,0),tt=tt.setSubMatrix(j,0,P.columns),tt=tt.setSubMatrix(Q,P.rows,P.columns),tt.subMatrix(0,_-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&&Sc(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&&Sc(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=$c){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=$c){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Iu(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;Iu(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){Su(this,t),Bu(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 D_(this);case"column":return y_(this);case void 0:return b_(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return E_(this);case"column":return A_(this);case void 0:return x_(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(!Je.isAnyArray(n))throw new TypeError("mean must be an array");return C_(this,r,n)}case"column":{if(!Je.isAnyArray(n))throw new TypeError("mean must be an array");return F_(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return M_(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(!Je.isAnyArray(r))throw new TypeError("center must be an array");return N_(this,r),this}case"column":{if(!Je.isAnyArray(r))throw new TypeError("center must be an array");return S_(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return B_(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=I_(this);else if(!Je.isAnyArray(r))throw new TypeError("scale must be an array");return T_(this,r),this}case"column":{if(r===void 0)r=$_(this);else if(!Je.isAnyArray(r))throw new TypeError("scale must be an array");return O_(this,r),this}case void 0:{if(r===void 0)r=R_(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return L_(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return Ic(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")]=g_);function $c(i,t){return i-t}function P_(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=(di=class extends $t{constructor(e,r){super();yf(this,ji);K(this,"data");if(di.isMatrix(e))bf(this,ji,Ef).call(this,e.rows,e.columns),di.copy(e,this);else if(Number.isInteger(e)&&e>=0)bf(this,ji,Ef).call(this,e,r);else if(Je.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(!P_(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 dr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),dr(this,e,!0),r=Float64Array.from(ai(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){gr(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),gr(this,e,!0),r=fi(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}},ji=new WeakSet,Ef=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},di);w_($t,pt);const fo=class fo extends $t{constructor(e){super();yf(this,qe,void 0);if(pt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");eu(this,qe,pt.copy(e,new pt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)eu(this,qe,new pt(e,e));else if(eu(this,qe,new pt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Rr(this,qe).size}get rows(){return Rr(this,qe).rows}get columns(){return Rr(this,qe).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 fo(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 Rr(this,qe).get(e,r)}set(e,r,n){return Rr(this,qe).set(e,r,n),Rr(this,qe).set(r,e,n),this}removeCross(e){return Rr(this,qe).removeRow(e),Rr(this,qe).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Rr(this,qe).addRow(e,n),Rr(this,qe).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 fo(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)}};qe=new WeakMap;let Ln=fo;Ln.prototype.klassType="SymmetricMatrix";class Qs extends Ln{static isDistanceMatrix(t){return Ln.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 Ln(this)}clone(){const t=new Qs(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}}Qs.prototype.klassSubType="DistanceMatrix";class Kr extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class z_ extends Kr{constructor(t,e){gr(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 q_ extends Kr{constructor(t,e){Bu(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 U_ extends Kr{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 k_ extends Kr{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 W_ extends Kr{constructor(t,e){dr(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 Y_ extends Kr{constructor(t,e){Su(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 Vs extends Kr{constructor(t,e,r){Su(t,e),Bu(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 Z_ extends Kr{constructor(t,e,r,n,s){Iu(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 j_ extends Kr{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 Oc 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 rr 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(Je.isAnyArray(i))return i[0]&&Je.isAnyArray(i[0])?new rr(i):new Oc(i,t);throw new Error("the argument is not an array")}class to{constructor(t){t=rr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,s=new Float64Array(r),a=1,f,l,p,h,c,d,_,D,g;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(g=Math.min(f,l),c=0,p=0;p<g;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++)d=e.get(h,p),e.set(h,p,e.get(l,p)),e.set(l,p,d);_=s[h],s[h]=s[l],s[l]=_,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 Jr(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 Tu{constructor(t){t=rr.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=Jr(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 ci{constructor(t,e={}){if(t=rr.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 C=l;l=p,p=C}else c=t.clone();let d=Math.min(r,n),_=Math.min(r+1,n),D=new Float64Array(_),g=new pt(r,d),y=new pt(n,n),v=new Float64Array(n),E=new Float64Array(r),b=new Float64Array(_);for(let C=0;C<_;C++)b[C]=C;let N=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),F=Math.max(N,x);for(let C=0;C<F;C++){if(C<N){D[C]=0;for(let I=C;I<r;I++)D[C]=Jr(D[C],c.get(I,C));if(D[C]!==0){c.get(C,C)<0&&(D[C]=-D[C]);for(let I=C;I<r;I++)c.set(I,C,c.get(I,C)/D[C]);c.set(C,C,c.get(C,C)+1)}D[C]=-D[C]}for(let I=C+1;I<n;I++){if(C<N&&D[C]!==0){let R=0;for(let U=C;U<r;U++)R+=c.get(U,C)*c.get(U,I);R=-R/c.get(C,C);for(let U=C;U<r;U++)c.set(U,I,c.get(U,I)+R*c.get(U,C))}v[I]=c.get(C,I)}if(l&&C<N)for(let I=C;I<r;I++)g.set(I,C,c.get(I,C));if(C<x){v[C]=0;for(let I=C+1;I<n;I++)v[C]=Jr(v[C],v[I]);if(v[C]!==0){v[C+1]<0&&(v[C]=0-v[C]);for(let I=C+1;I<n;I++)v[I]/=v[C];v[C+1]+=1}if(v[C]=-v[C],C+1<r&&v[C]!==0){for(let I=C+1;I<r;I++)E[I]=0;for(let I=C+1;I<r;I++)for(let R=C+1;R<n;R++)E[I]+=v[R]*c.get(I,R);for(let I=C+1;I<n;I++){let R=-v[I]/v[C+1];for(let U=C+1;U<r;U++)c.set(U,I,c.get(U,I)+R*E[U])}}if(p)for(let I=C+1;I<n;I++)y.set(I,C,v[I])}}let M=Math.min(n,r+1);if(N<n&&(D[N]=c.get(N,N)),r<M&&(D[M-1]=0),x+1<M&&(v[x]=c.get(x,M-1)),v[M-1]=0,l){for(let C=N;C<d;C++){for(let I=0;I<r;I++)g.set(I,C,0);g.set(C,C,1)}for(let C=N-1;C>=0;C--)if(D[C]!==0){for(let I=C+1;I<d;I++){let R=0;for(let U=C;U<r;U++)R+=g.get(U,C)*g.get(U,I);R=-R/g.get(C,C);for(let U=C;U<r;U++)g.set(U,I,g.get(U,I)+R*g.get(U,C))}for(let I=C;I<r;I++)g.set(I,C,-g.get(I,C));g.set(C,C,1+g.get(C,C));for(let I=0;I<C-1;I++)g.set(I,C,0)}else{for(let I=0;I<r;I++)g.set(I,C,0);g.set(C,C,1)}}if(p)for(let C=n-1;C>=0;C--){if(C<x&&v[C]!==0)for(let I=C+1;I<n;I++){let R=0;for(let U=C+1;U<n;U++)R+=y.get(U,C)*y.get(U,I);R=-R/y.get(C+1,C);for(let U=C+1;U<n;U++)y.set(U,I,y.get(U,I)+R*y.get(U,C))}for(let I=0;I<n;I++)y.set(I,C,0);y.set(C,C,1)}let S=M-1,$=Number.EPSILON;for(;M>0;){let C,I;for(C=M-2;C>=-1&&C!==-1;C--){const R=Number.MIN_VALUE+$*Math.abs(D[C]+Math.abs(D[C+1]));if(Math.abs(v[C])<=R||Number.isNaN(v[C])){v[C]=0;break}}if(C===M-2)I=4;else{let R;for(R=M-1;R>=C&&R!==C;R--){let U=(R!==M?Math.abs(v[R]):0)+(R!==C+1?Math.abs(v[R-1]):0);if(Math.abs(D[R])<=$*U){D[R]=0;break}}R===C?I=3:R===M-1?I=1:(I=2,C=R)}switch(C++,I){case 1:{let R=v[M-2];v[M-2]=0;for(let U=M-2;U>=C;U--){let q=Jr(D[U],R),k=D[U]/q,P=R/q;if(D[U]=q,U!==C&&(R=-P*v[U-1],v[U-1]=k*v[U-1]),p)for(let G=0;G<n;G++)q=k*y.get(G,U)+P*y.get(G,M-1),y.set(G,M-1,-P*y.get(G,U)+k*y.get(G,M-1)),y.set(G,U,q)}break}case 2:{let R=v[C-1];v[C-1]=0;for(let U=C;U<M;U++){let q=Jr(D[U],R),k=D[U]/q,P=R/q;if(D[U]=q,R=-P*v[U],v[U]=k*v[U],l)for(let G=0;G<r;G++)q=k*g.get(G,U)+P*g.get(G,C-1),g.set(G,C-1,-P*g.get(G,U)+k*g.get(G,C-1)),g.set(G,U,q)}break}case 3:{const R=Math.max(Math.abs(D[M-1]),Math.abs(D[M-2]),Math.abs(v[M-2]),Math.abs(D[C]),Math.abs(v[C])),U=D[M-1]/R,q=D[M-2]/R,k=v[M-2]/R,P=D[C]/R,G=v[C]/R,j=((q+U)*(q-U)+k*k)/2,Q=U*k*(U*k);let tt=0;(j!==0||Q!==0)&&(j<0?tt=0-Math.sqrt(j*j+Q):tt=Math.sqrt(j*j+Q),tt=Q/(j+tt));let lt=(P+U)*(P-U)+tt,vt=P*G;for(let ft=C;ft<M-1;ft++){let wt=Jr(lt,vt);wt===0&&(wt=Number.MIN_VALUE);let yt=lt/wt,St=vt/wt;if(ft!==C&&(v[ft-1]=wt),lt=yt*D[ft]+St*v[ft],v[ft]=yt*v[ft]-St*D[ft],vt=St*D[ft+1],D[ft+1]=yt*D[ft+1],p)for(let bt=0;bt<n;bt++)wt=yt*y.get(bt,ft)+St*y.get(bt,ft+1),y.set(bt,ft+1,-St*y.get(bt,ft)+yt*y.get(bt,ft+1)),y.set(bt,ft,wt);if(wt=Jr(lt,vt),wt===0&&(wt=Number.MIN_VALUE),yt=lt/wt,St=vt/wt,D[ft]=wt,lt=yt*v[ft]+St*D[ft+1],D[ft+1]=-St*v[ft]+yt*D[ft+1],vt=St*v[ft+1],v[ft+1]=yt*v[ft+1],l&&ft<r-1)for(let bt=0;bt<r;bt++)wt=yt*g.get(bt,ft)+St*g.get(bt,ft+1),g.set(bt,ft+1,-St*g.get(bt,ft)+yt*g.get(bt,ft+1)),g.set(bt,ft,wt)}v[M-2]=lt;break}case 4:{if(D[C]<=0&&(D[C]=D[C]<0?-D[C]:0,p))for(let R=0;R<=S;R++)y.set(R,C,-y.get(R,C));for(;C<S&&!(D[C]>=D[C+1]);){let R=D[C];if(D[C]=D[C+1],D[C+1]=R,p&&C<n-1)for(let U=0;U<n;U++)R=y.get(U,C+1),y.set(U,C+1,y.get(U,C)),y.set(U,C,R);if(l&&C<r-1)for(let U=0;U<r;U++)R=g.get(U,C+1),g.set(U,C+1,g.get(U,C)),g.set(U,C,R);C++}M--;break}}}if(h){let C=y;y=g,g=C}this.m=r,this.n=n,this.s=D,this.U=g,this.V=y}solve(t){let e=t,r=this.threshold,n=this.s.length,s=pt.zeros(n,n);for(let d=0;d<n;d++)Math.abs(this.s[d])<=r?s.set(d,d,0):s.set(d,d,1/this.s[d]);let a=this.U,f=this.rightSingularVectors,l=f.mmul(s),p=f.rows,h=a.rows,c=pt.zeros(p,h);for(let d=0;d<p;d++)for(let _=0;_<h;_++){let D=0;for(let g=0;g<n;g++)D+=l.get(d,g)*a.get(_,g);c.set(d,_,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 d=0;for(let _=0;_<l;_++)d+=s.get(h,_)*a.get(c,_);p.set(h,c,d)}return p}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,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 K_(i,t=!1){return i=rr.checkMatrix(i),t?new ci(i).inverse():Rc(i,pt.eye(i.rows))}function Rc(i,t,e=!1){return i=rr.checkMatrix(i),t=rr.checkMatrix(t),e?new ci(i).solve(t):i.isSquare()?new to(i).solve(t):new Tu(i).solve(t)}function eo(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 Vs(i,[1,2],[1,2]),a=new Vs(i,[1,2],[0,2]),f=new Vs(i,[1,2],[0,1]),t=i.get(0,0),e=i.get(0,1),r=i.get(0,2),t*eo(s)-e*eo(a)+r*eo(f)}else return new to(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function J_(i,t){let e=[];for(let r=0;r<i;r++)r!==t&&e.push(r);return e}function X_(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 H_(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(J_(n,a)).transpose(),h=new ci(l).solve(f),c=pt.sub(f,l.mmul(h)).abs().max();s.setRow(a,X_(c,h,a,e,r))}return s}function Q_(i,t=Number.EPSILON){if(i=pt.checkMatrix(i),i.isEmpty())return i.transpose();let e=new ci(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 V_(i,t=i,e={}){i=new pt(i);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!Je.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 tw(i,t=i,e={}){i=new pt(i);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!Je.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 Lc=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=rr.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));ew(n,f,a,s),rw(n,f,a,s)}else{let d=new pt(n,n),_=new Float64Array(n);for(h=0;h<n;h++)for(p=0;p<n;p++)d.set(p,h,l.get(p,h));nw(n,d,_,s),iw(n,f,a,s,d)}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 ew(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 rw(i,t,e,r){let n,s,a,f,l,p,h,c,d,_,D,g,y,v,E,b;for(a=1;a<i;a++)t[a-1]=t[a];t[i-1]=0;let N=0,x=0,F=Number.EPSILON;for(p=0;p<i;p++){for(x=Math.max(x,Math.abs(e[p])+Math.abs(t[p])),h=p;h<i&&!(Math.abs(t[h])<=F*x);)h++;if(h>p)do{for(n=e[p],c=(e[p+1]-n)/(2*t[p]),d=Jr(c,1),c<0&&(d=-d),e[p]=t[p]/(c+d),e[p+1]=t[p]*(c+d),_=e[p+1],s=n-e[p],a=p+2;a<i;a++)e[a]-=s;for(N=N+s,c=e[h],D=1,g=D,y=D,v=t[p+1],E=0,b=0,a=h-1;a>=p;a--)for(y=g,g=D,b=E,n=D*t[a],s=D*c,d=Jr(c,t[a]),t[a+1]=E*d,E=t[a]/d,D=c/d,c=D*e[a]-E*n,e[a+1]=s+E*(D*n+E*e[a]),l=0;l<i;l++)s=r.get(l,a+1),r.set(l,a+1,E*r.get(l,a)+D*s),r.set(l,a,D*r.get(l,a)-E*s);c=-E*b*y*v*t[p]/_,t[p]=E*c,e[p]=D*c}while(Math.abs(t[p])>F*x);e[p]=e[p]+N,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 nw(i,t,e,r){let n=0,s=i-1,a,f,l,p,h,c,d;for(c=n+1;c<=s-1;c++){for(d=0,p=c;p<=s;p++)d=d+Math.abs(t.get(p,c-1));if(d!==0){for(l=0,p=s;p>=c;p--)e[p]=t.get(p,c-1)/d,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]=d*e[c],t.set(c,c-1,d*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 iw(i,t,e,r,n){let s=i-1,a=0,f=i-1,l=Number.EPSILON,p=0,h=0,c=0,d=0,_=0,D=0,g=0,y=0,v,E,b,N,x,F,M,S,$,C,I,R,U,q,k;for(v=0;v<i;v++)for((v<a||v>f)&&(e[v]=n.get(v,v),t[v]=0),E=Math.max(v-1,0);E<i;E++)h=h+Math.abs(n.get(v,E));for(;s>=a;){for(N=s;N>a&&(D=Math.abs(n.get(N-1,N-1))+Math.abs(n.get(N,N)),D===0&&(D=h),!(Math.abs(n.get(N,N-1))<l*D));)N--;if(N===s)n.set(s,s,n.get(s,s)+p),e[s]=n.get(s,s),t[s]=0,s--,y=0;else if(N===s-1){if(M=n.get(s,s-1)*n.get(s-1,s),c=(n.get(s-1,s-1)-n.get(s,s))/2,d=c*c+M,g=Math.sqrt(Math.abs(d)),n.set(s,s,n.get(s,s)+p),n.set(s-1,s-1,n.get(s-1,s-1)+p),S=n.get(s,s),d>=0){for(g=c>=0?c+g:c-g,e[s-1]=S+g,e[s]=e[s-1],g!==0&&(e[s]=S-M/g),t[s-1]=0,t[s]=0,S=n.get(s,s-1),D=Math.abs(S)+Math.abs(g),c=S/D,d=g/D,_=Math.sqrt(c*c+d*d),c=c/_,d=d/_,E=s-1;E<i;E++)g=n.get(s-1,E),n.set(s-1,E,d*g+c*n.get(s,E)),n.set(s,E,d*n.get(s,E)-c*g);for(v=0;v<=s;v++)g=n.get(v,s-1),n.set(v,s-1,d*g+c*n.get(v,s)),n.set(v,s,d*n.get(v,s)-c*g);for(v=a;v<=f;v++)g=r.get(v,s-1),r.set(v,s-1,d*g+c*r.get(v,s)),r.set(v,s,d*r.get(v,s)-c*g)}else e[s-1]=S+c,e[s]=S+c,t[s-1]=g,t[s]=-g;s=s-2,y=0}else{if(S=n.get(s,s),$=0,M=0,N<s&&($=n.get(s-1,s-1),M=n.get(s,s-1)*n.get(s-1,s)),y===10){for(p+=S,v=a;v<=s;v++)n.set(v,v,n.get(v,v)-S);D=Math.abs(n.get(s,s-1))+Math.abs(n.get(s-1,s-2)),S=$=.75*D,M=-.4375*D*D}if(y===30&&(D=($-S)/2,D=D*D+M,D>0)){for(D=Math.sqrt(D),$<S&&(D=-D),D=S-M/(($-S)/2+D),v=a;v<=s;v++)n.set(v,v,n.get(v,v)-D);p+=D,S=$=M=.964}for(y=y+1,x=s-2;x>=N&&(g=n.get(x,x),_=S-g,D=$-g,c=(_*D-M)/n.get(x+1,x)+n.get(x,x+1),d=n.get(x+1,x+1)-g-_-D,_=n.get(x+2,x+1),D=Math.abs(c)+Math.abs(d)+Math.abs(_),c=c/D,d=d/D,_=_/D,!(x===N||Math.abs(n.get(x,x-1))*(Math.abs(d)+Math.abs(_))<l*(Math.abs(c)*(Math.abs(n.get(x-1,x-1))+Math.abs(g)+Math.abs(n.get(x+1,x+1))))));)x--;for(v=x+2;v<=s;v++)n.set(v,v-2,0),v>x+2&&n.set(v,v-3,0);for(b=x;b<=s-1&&(q=b!==s-1,b!==x&&(c=n.get(b,b-1),d=n.get(b+1,b-1),_=q?n.get(b+2,b-1):0,S=Math.abs(c)+Math.abs(d)+Math.abs(_),S!==0&&(c=c/S,d=d/S,_=_/S)),S!==0);b++)if(D=Math.sqrt(c*c+d*d+_*_),c<0&&(D=-D),D!==0){for(b!==x?n.set(b,b-1,-D*S):N!==x&&n.set(b,b-1,-n.get(b,b-1)),c=c+D,S=c/D,$=d/D,g=_/D,d=d/c,_=_/c,E=b;E<i;E++)c=n.get(b,E)+d*n.get(b+1,E),q&&(c=c+_*n.get(b+2,E),n.set(b+2,E,n.get(b+2,E)-c*g)),n.set(b,E,n.get(b,E)-c*S),n.set(b+1,E,n.get(b+1,E)-c*$);for(v=0;v<=Math.min(s,b+3);v++)c=S*n.get(v,b)+$*n.get(v,b+1),q&&(c=c+g*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-c*_)),n.set(v,b,n.get(v,b)-c),n.set(v,b+1,n.get(v,b+1)-c*d);for(v=a;v<=f;v++)c=S*r.get(v,b)+$*r.get(v,b+1),q&&(c=c+g*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-c*_)),r.set(v,b,r.get(v,b)-c),r.set(v,b+1,r.get(v,b+1)-c*d)}}}if(h!==0){for(s=i-1;s>=0;s--)if(c=e[s],d=t[s],d===0)for(N=s,n.set(s,s,1),v=s-1;v>=0;v--){for(M=n.get(v,v)-c,_=0,E=N;E<=s;E++)_=_+n.get(v,E)*n.get(E,s);if(t[v]<0)g=M,D=_;else if(N=v,t[v]===0?n.set(v,s,M!==0?-_/M:-_/(l*h)):(S=n.get(v,v+1),$=n.get(v+1,v),d=(e[v]-c)*(e[v]-c)+t[v]*t[v],F=(S*D-g*_)/d,n.set(v,s,F),n.set(v+1,s,Math.abs(S)>Math.abs(g)?(-_-M*F)/S:(-D-$*F)/g)),F=Math.abs(n.get(v,s)),l*F*F>1)for(E=v;E<=s;E++)n.set(E,s,n.get(E,s)/F)}else if(d<0)for(N=s-1,Math.abs(n.get(s,s-1))>Math.abs(n.get(s-1,s))?(n.set(s-1,s-1,d/n.get(s,s-1)),n.set(s-1,s,-(n.get(s,s)-c)/n.get(s,s-1))):(k=ro(0,-n.get(s-1,s),n.get(s-1,s-1)-c,d),n.set(s-1,s-1,k[0]),n.set(s-1,s,k[1])),n.set(s,s-1,0),n.set(s,s,1),v=s-2;v>=0;v--){for(C=0,I=0,E=N;E<=s;E++)C=C+n.get(v,E)*n.get(E,s-1),I=I+n.get(v,E)*n.get(E,s);if(M=n.get(v,v)-c,t[v]<0)g=M,_=C,D=I;else if(N=v,t[v]===0?(k=ro(-C,-I,M,d),n.set(v,s-1,k[0]),n.set(v,s,k[1])):(S=n.get(v,v+1),$=n.get(v+1,v),R=(e[v]-c)*(e[v]-c)+t[v]*t[v]-d*d,U=(e[v]-c)*2*d,R===0&&U===0&&(R=l*h*(Math.abs(M)+Math.abs(d)+Math.abs(S)+Math.abs($)+Math.abs(g))),k=ro(S*_-g*C+d*I,S*D-g*I-d*C,R,U),n.set(v,s-1,k[0]),n.set(v,s,k[1]),Math.abs(S)>Math.abs(g)+Math.abs(d)?(n.set(v+1,s-1,(-C-M*n.get(v,s-1)+d*n.get(v,s))/S),n.set(v+1,s,(-I-M*n.get(v,s)-d*n.get(v,s-1))/S)):(k=ro(-_-$*n.get(v,s-1),-D-$*n.get(v,s),g,d),n.set(v+1,s-1,k[0]),n.set(v+1,s,k[1]))),F=Math.max(Math.abs(n.get(v,s-1)),Math.abs(n.get(v,s))),l*F*F>1)for(E=v;E<=s;E++)n.set(E,s-1,n.get(E,s-1)/F),n.set(E,s,n.get(E,s)/F)}for(v=0;v<i;v++)if(v<a||v>f)for(E=v;E<i;E++)r.set(v,E,n.get(v,E));for(E=i-1;E>=a;E--)for(v=a;v<=f;v++){for(g=0,b=a;b<=Math.min(E,f);b++)g=g+r.get(v,b)*n.get(b,E);r.set(v,E,g)}}}function ro(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 Pc{constructor(t){if(t=rr.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=rr.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 zc{constructor(t,e={}){t=rr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:s=1e3,terminationCriteria:a=1e-10}=e;let f;if(r){if(Je.isAnyArray(r)&&typeof r[0]=="number"?r=pt.columnVector(r):r=rr.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,d;for(let _=0;_<s&&l>a;_++)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)),_>0&&(l=p.clone().sub(d).pow(2).sum()),d=p.clone(),r?(h=r.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),h=h.div(h.norm()),f=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):f=p;if(r){let _=t.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0));_=_.div(_.norm());let D=t.clone().sub(p.clone().mmul(_.transpose())),g=f.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),y=r.clone().sub(p.clone().mulS(g.get(0,0)).mmul(h.transpose()));this.t=p,this.p=_.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=g}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=Pc,Pt.CholeskyDecomposition=Pc,Pt.DistanceMatrix=Qs,Pt.EVD=Lc;var sw=Pt.EigenvalueDecomposition=Lc;Pt.LU=to,Pt.LuDecomposition=to;var qc=Pt.Matrix=pt;Pt.MatrixColumnSelectionView=q_,Pt.MatrixColumnView=z_,Pt.MatrixFlipColumnView=U_,Pt.MatrixFlipRowView=k_,Pt.MatrixRowSelectionView=Y_,Pt.MatrixRowView=W_,Pt.MatrixSelectionView=Vs,Pt.MatrixSubView=Z_,Pt.MatrixTransposeView=j_,Pt.NIPALS=zc,Pt.Nipals=zc,Pt.QR=Tu,Pt.QrDecomposition=Tu,Pt.SVD=ci,Pt.SingularValueDecomposition=ci,Pt.SymmetricMatrix=Ln,Pt.WrapperMatrix1D=Oc,Pt.WrapperMatrix2D=rr,Pt.correlation=tw,Pt.covariance=V_;var Uc=Pt.default=pt;Pt.determinant=eo,Pt.inverse=K_,Pt.linearDependencies=H_,Pt.pseudoInverse=Q_,Pt.solve=Rc,Pt.wrap=G_;const kc=sw,Wc=qc;Uc.Matrix&&Uc.Matrix;class ow{new({rows:t,columns:e,initial_value:r}={}){return new $u(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 $u{constructor(t=0,e=0,r=void 0){K(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 Xt(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 Xt;return r._value=e,r}det(){return Mc(this._matrixArray)}get({row:t,column:e=0}){return this._matrixInstance[t]._value[e]}inv(){const t=Ks(this._matrixArray);return this._newMatrix(t)}max(){return V1(this._matrixArray)}min(){return Nu(this._matrixArray)}pow({power:t}){const e=e_(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=qi(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=G1(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=Z1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return Nu(yc(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=ui(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=t_(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t=0,order:e=In.ascending}={}){this._matrixInstance.sort((r,n)=>{const s=r._value[t],a=n._value[t];return e!==In.descending?s-a:a-s})}trace(){return Q1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Nc(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 Xt(this.columns()))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t,columns:e}){const r=U1(this._matrixArray,[t,e]);this._matrixInstance=r.map(n=>{const s=new Xt;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=Ec(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 Xt;return r._value=e,r}remove_row({row:t=this.rows()}={}){return this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new kc(new Wc(this._matrixArray)),e=new Xt;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 kc(new Wc(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 k1(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 $u;return e._value=t.map(r=>{const n=new Xt;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,d)=>c-h*s[a][d]),s[p][a]=0}}for(let a=0;a<r;a++)s[a].some(f=>Number(f.toFixed(8))!==0)&&e++;return e}}class uw{constructor(t){K(this,"_variables");K(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){const r=Sn(t),n=Sn(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 Sn(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(js(s))return`${s}M`;const a=r.asWeeks();if(js(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=Sn(e)*1e3,a=t-n-Math.floor((t-n)/s)*s;return r?r-a:a}}class aw{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 Xt;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 Cr(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 fw{new(){return new Ou}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 Ou{constructor(){K(this,"_mapInstance");this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new Ou;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 Xt;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 Xt;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 lw{constructor(t){K(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Pn(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Pn(t,r,e)}copy({id:t}){const{price:e,time:r,index:n}=t||{};return new Pn(e,n,r)}from_index({price:t,index:e}){return new Pn(t,e)}from_time({price:t,time:e}){return new Pn(t,void 0,e)}}class Pn{constructor(t,e,r){K(this,"_index");K(this,"_price");K(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Pn(this._price,this._index,this._time)}}class cw{constructor(t){K(this,"_variables");K(this,"_defaultLabel",{text:"",xloc:Ie.bar_index,yloc:Ti.price,size:zr.normal,style:de.styleLabelDown,textalign:Ge.alignCenter});this._variables=t}new(t,e){const r=`label_${e}`,n={...this._defaultLabel,...t,id:r};t.point&&(n.x=n.xloc===Ie.bar_index?t.point.index:t.point.time,n.y=t.point.price);const s=new Wi(r,this._variables);return this._variables.label.add(r,n,s),s}label(t,e){return t.x?t.x:new Wi(e,this._variables)}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class Wi{constructor(t,e){K(this,"_id");K(this,"_variables");this._id=t,this._variables=e}copy(t){const e=`label_${t}`,r=this._getLabel(t),n=new Wi(e,this._variables);return r&&this._variables.label.add(e,{...r,id:e},n),n}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t)}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e)}set_yloc({yloc:t},e){const r=this._getLabel(e);r&&(r.yloc=t)}set_color({color:t},e){const r=this._getLabel(e);r&&(r.color=t)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===Ie.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t)}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t)}set_textcolor({textcolor:t},e){const r=this._getLabel(e);r&&(r.textcolor=t)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const hw={freq_all:hs.freqAll,freq_once_per_bar:hs.freqOncePerBar,freq_once_per_bar_close:hs.freqOncePerBarClose},pw={gaps_off:Ii.gapsOff,gaps_on:Ii.gapsOn,lookahead_off:Ii.lookaheadOff,lookahead_on:Ii.lookaheadOn},hi={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"},mw={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"},dw={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},gw={all:[Fr.dataWindow,Fr.pane,Fr.priceScale,Fr.statusLine],data_window:[Fr.dataWindow],none:[],pane:[Fr.pane],price_scale:[Fr.priceScale],status_line:[Fr.statusLine]},vw={both:Bn.both,left:Bn.left,none:Bn.none,right:Bn.right},_w={inherit:Hn.inherit,mintick:Hn.mintick,percent:Hn.percent,price:Hn.price,volume:Hn.volume},ww={style_solid:ps.styleSolid,style_dashed:ps.styleDashed,style_dotted:ps.styleDotted},Dw={style_arrowdown:de.styleArrowdown,style_arrowup:de.styleArrowup,style_circle:de.styleCircle,style_cross:de.styleCross,style_diamond:de.styleDiamond,style_flag:de.styleFlag,style_label_center:de.styleLabelCenter,style_label_down:de.styleLabelDown,style_label_left:de.styleLabelLeft,style_label_lower_left:de.styleLabelLowerLeft,style_label_lower_right:de.styleLabelLowerRight,style_label_right:de.styleLabelRight,style_label_up:de.styleLabelUp,style_label_upper_left:de.styleLabelUpperLeft,style_label_upper_right:de.styleLabelUpperRight,style_none:de.styleNone,style_square:de.styleSquare,style_text_outline:de.styleTextOutline,style_triangledown:de.styleTriangledown,style_triangleup:de.styleTriangleup,style_xcross:de.styleXcross},yw={style_arrow_both:Pr.styleArrowBoth,style_arrow_left:Pr.styleArrowLeft,style_arrow_right:Pr.styleArrowRight,style_dashed:Pr.styleDashed,style_dotted:Pr.styleDotted,style_solid:Pr.styleSolid},bw={abovebar:Qn.abovebar,absolute:Qn.absolute,belowbar:Qn.belowbar,bottom:Qn.bottom,top:Qn.top},Ew={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Aw={style_area:pr.styleArea,style_areabr:pr.styleAreabr,style_circles:pr.styleCircles,style_columns:pr.styleColumns,style_cross:pr.styleCross,style_histogram:pr.styleHistogram,style_line:pr.styleLine,style_linebr:pr.styleLinebr,style_stepline:pr.styleStepline,style_stepline_diamond:pr.styleSteplineDiamond,style_steplinebr:pr.styleSteplinebr},xw={bottom_center:Mr.bottomCenter,bottom_left:Mr.bottomLeft,bottom_right:Mr.bottomRight,middle_center:Mr.middleCenter,middle_left:Mr.middleLeft,middle_right:Mr.middleRight,top_center:Mr.topCenter,top_left:Mr.topLeft,top_right:Mr.topRight},Cw={left:ms.left,none:ms.none,right:ms.right},Fw={arrowdown:tr.arrowdown,arrowup:tr.arrowup,circle:tr.circle,cross:tr.cross,diamond:tr.diamond,flag:tr.flag,labeldown:tr.labeldown,labelup:tr.labelup,square:tr.square,triangledown:tr.triangledown,triangleup:tr.triangleup,xcross:tr.xcross},Mw={auto:zr.auto,huge:zr.huge,large:zr.large,normal:zr.normal,small:zr.small,tiny:zr.tiny},Nw={cash:ds.cash,fixed:ds.fixed,percent_of_equity:ds.percentOfEquity,commission:{cash_per_contract:gs.cashPerContract,cash_per_order:gs.cashPerOrder,percent:gs.percent},direction:{all:vs.all,long:vs.long,short:vs.short},oca:{cancel:_s.cancel,none:_s.none,reduce:_s.reduce}},Sw={align_bottom:Ge.alignBottom,align_center:Ge.alignCenter,align_left:Ge.alignLeft,align_right:Ge.alignRight,align_top:Ge.alignTop,wrap_auto:Ge.wrapAuto,wrap_none:Ge.wrapNone},Bw={bar_index:Ie.bar_index,bar_time:Ie.bar_time},Iw={abovebar:Ti.abovebar,belowbar:Ti.belowbar,price:Ti.price},Tw={actual:ws.actual,estimate:ws.estimate,standardized:ws.standardized};class $w{constructor(){K(this,"adjustment",{dividends:cs.dividends,none:cs.none,splits:cs.splits});K(this,"alert",hw);K(this,"barmerge",pw);K(this,"color",hi);K(this,"currency",mw);K(this,"dayofweek",dw);K(this,"earnings",Tw);K(this,"display",gw);K(this,"extend",vw);K(this,"font",{family_default:"SimSun",family_monospace:"Monospace"});K(this,"format",_w);K(this,"hline",ww);K(this,"label",Dw);K(this,"line",yw);K(this,"location",bw);K(this,"math",Ew);K(this,"order",{ascending:In.ascending,descending:In.descending});K(this,"plot",Aw);K(this,"position",xw);K(this,"scale",Cw);K(this,"session",{extended:ru.extended,regular:ru.regular});K(this,"shape",Fw);K(this,"size",Mw);K(this,"splits",{denominator:"denominator",numerator:"numerator"});K(this,"strategy",Nw);K(this,"text",Sw);K(this,"xloc",Bw);K(this,"yloc",Iw)}updateData(){}}class Ow{constructor(t){K(this,"_variables");K(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:Ie.bar_index,line_color:hi.blue,line_style:Pr.styleSolid,line_width:1});this._variables=t}new(t,e){const r=`polyline_${e}`,n=Object.assign({},this._defaultPolyline,t,{id:r}),s=new Yc(r,this._variables);return this._variables.polyline.add(r,n,s),s}delete({id:t}){t&&t.delete()}}class Yc{constructor(t,e){K(this,"_id");K(this,"_variables");this._variables=e,this._id=t}delete(){this._variables.polyline.delete(this._id)}}class Rw{constructor(t){K(this,"_variables");K(this,"_defaultLine",{xloc:Ie.bar_index,extend:Bn.none,style:Pr.styleSolid});this._variables=t}new({first_point:t,second_point:e,...r},n){const s=`line_${n}`,a={...this._defaultLine,...r,id:s};if(t&&e){const l=a.xloc===Ie.bar_index?t.index:t.time,p=a.xloc===Ie.bar_index?e.index:e.time;Object.assign(a,{x1:l,y1:t.price,x2:p,y2:e.price})}const f=new Yi(s,this._variables);return this._variables.line.add(s,a,f),f}line(t,e){return t.x?t.x:new Yi(e,this._variables)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class Yi{constructor(t,e){K(this,"_variables");K(this,"_id");this._id=t,this._variables=e}get data(){return this._variables.line.get(this._id)}copy(t){const e=`line_${t}`,r=this._getLine(t),n=new Yi(e,this._variables);return r&&this._variables.line.add(e,{...r,id:e},n),n}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===Ie.bar_index){const{x1:n,y1:s,x2:a,y2:f}=r;return n===void 0||a===void 0||s===void 0||f===void 0?void 0:(f-s)/(a-n)*(t-n)+s}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const s=this._getLine(n);s&&(s.xloc=t,s.x1=e,s.x2=r)}set_color({color:t},e){const r=this._getLine(e);r&&(r.color=t)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t)}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t)}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},f=r.xloc===Ie.bar_index?n:s,l=a;f&&(r.x1=f),l&&(r.y1=l)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},f=r.xloc===Ie.bar_index?n:s,l=a;f&&(r.x2=f),l&&(r.y2=l)}}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class Lw{constructor(t){K(this,"_variables");this._variables=t}new({line1:t,line2:e,color:r},n){const s=`linefill_${n}`,a=t==null?void 0:t.data,f=e==null?void 0:e.data;a&&(a.linefills=a.linefills||[],a.linefills.push(s)),f&&(f.linefills=f.linefills||[],f.linefills.push(s));const l=new no(this._variables,s,t,e);return(a||f)&&this._variables.linefill.add(s,{line1:a,line2:f,color:r,id:s},l),l}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class no{constructor(t,e,r,n){K(this,"_id");K(this,"_line1");K(this,"_line2");K(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}linefill(t,e){return t.x?t.x:new no(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:s}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),s&&(s.linefills=(r=s.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color({color:t}){const e=this._variables.linefill.get(this._id);e&&(e.color=t)}}class Pw{constructor(t){K(this,"_variables");K(this,"_defaultBox",{border_color:hi.blue,border_width:1,bgcolor:hi.blue,xloc:Ie.bar_index,extend:Bn.none,style:Pr.styleSolid,text:"",text_size:zr.auto,text_color:hi.black,text_halign:Ge.alignCenter,text_valign:Ge.alignCenter,text_wrap:Ge.wrapNone});this._variables=t}box({x:t},e){return t===void 0?new Zi(this._variables,e):t}new({top_left:t,bottom_right:e,...r},n){const s=`box_${n}`,a={...this._defaultBox,...r,id:s};if(t){const{price:l,time:p,index:h}=t;a.top=l,a.left=a.xloc===Ie.bar_index?h:p}if(e){const{price:l,time:p,index:h}=e;a.bottom=l,a.right=a.xloc===Ie.bar_index?h:p}const f=new Zi(this._variables,s);return this._variables.box.add(s,a,f),f}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e}){t==null||t.set_extend(e)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e}){t==null||t.set_border_style(e)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e}){t==null||t.set_text_size(e)}set_text_wrap({id:t,...e}){t==null||t.set_text_wrap(e)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e}){t==null||t.set_text_halign(e)}set_text_valign({id:t,...e}){t==null||t.set_text_valign(e)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e}){t==null||t.set_text_font_family(e)}}class Zi{constructor(t,e){K(this,"_id");K(this,"_variables");this._variables=t,this._id=e}copy(t){const e=`box_${t}`,r=this._getBox(),n=new Zi(this._variables,e);return r&&this._variables.box.add(e,{...r,id:e},n),n}delete(){this._variables.box.delete(this._id)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t}){const e=this._getBox();e&&(e.extend=t)}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t)}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t}){const e=this._getBox();e&&(e.text_size=t)}set_text_wrap({text_wrap:t}){const e=this._getBox();e&&(e.text_wrap=t)}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t)}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t}){const e=this._getBox();e&&(e.text_halign=t)}set_text_valign({text_valign:t}){const e=this._getBox();e&&(e.text_valign=t)}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.top=n,e.left=e.xloc===Ie.bar_index?r:s}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t)}set_border_style({style:t}){const e=this._getBox();e&&(e.border_style=t)}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.bottom=n,e.right=e.xloc===Ie.bar_index?r:s}}set_text_font_family({text_font_family:t}){const e=this._getBox();e&&(e.text_font_family=t)}_getBox(){return this._variables.box.get(this._id)}}class zw{constructor(t){K(this,"_variables");K(this,"_defaultTable",{position:Mr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t}table({x:t},e){return t||new Ru(this._variables,e)}new(t,e){const r=`table_${e}`,n={...this._defaultTable,...t,cell:[],id:r},s=new Ru(this._variables,r);return this._variables.table.add(r,n,s),s}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e}){t==null||t.set_position(e)}}class Ru{constructor(t,e){K(this,"_id");K(this,"_variables");K(this,"_defaultCell",{column:0,row:0,text:"",text_color:hi.black,text_halign:Ge.alignCenter,text_valign:Ge.alignCenter,text_size:zr.normal});this._variables=t,this._id=e}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,s=this._variables.table.get(this._id);if(s){const a=s.cell||[],f=a[n]||[];f[r]=e,a[n]=f,s.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r)}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0}){const s=this._variables.table.get(this._id);if(s){const a=s.cell;if(a)for(let f=e;f<=n;f++)for(let l=t;l<=r;l++){const p=a[f];p&&(p[l]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},s){if(t>r||e>n){console.log(`error ${s}: start_column > end_column or start_row > end_row`);return}const a=this._getTableItem(t,e);if(!a)return;this.clear({start_column:t,start_row:e,end_column:r,end_row:n});const f=this._variables.table.get(this._id);f.cell[e][t]={...a,isMerge:!0,merge_columns:r-t+1,merge_rows:n-e+1}}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t)}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t)}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t}){const e=this._variables.table.get(this._id);e&&(e.position=t)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class qw{constructor(){K(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return xr.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(Bp),ne.extend(Fp),ne.extend(Np);class Uw{constructor(){K(this,"_cacheData");K(this,"_barIndex");K(this,"_isRealTimeBar");K(this,"_barstate");K(this,"_priceVariables");K(this,"_lastBarIndex");K(this,"_currentBarTime");K(this,"_lastBarTime");K(this,"_period");K(this,"_offsetTime");K(this,"_timeframe");K(this,"_ta");K(this,"_polyline");K(this,"_label");K(this,"_line");K(this,"_linefill");K(this,"_box");K(this,"_table");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 kw,this._timeframe=new Ww,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new Yw,this._polyline=new pi,this._label=new pi,this._line=new pi,this._linefill=new pi,this._box=new pi,this._table=new pi}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get 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]=ls(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]=ls(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:d=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=d,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 Ap(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=xr.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)?xr.uniq([...t,...e]):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):t-e}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case Wi.name:case Yc.name:case Zi.name:case Ru.name:case Yi.name:case no.name:t==null||t.delete();break}}}class pi{constructor(t=50){K(this,"_all");K(this,"_allInstance");K(this,"_pseudoArrayAll");K(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Xt,this._maxLength=t}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()]}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){this._all.set(t,e),this._allInstance.set(t,r);const n=[...this._all.keys()];if(n.length>this._maxLength){const s=n.shift();s&&this.delete(s)}}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}class kw{constructor(){K(this,"_isMarketOpen");K(this,"_currentBarIndex");K(this,"_totalBarIndex");K(this,"_isRealTimeBar");K(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 Ww{constructor(){K(this,"_period");K(this,"_multiplier");K(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=ls(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 Yw{constructor(){K(this,"_preAccdist");K(this,"_preNvi");K(this,"_prePvi");K(this,"_preObv");K(this,"_prePvt");K(this,"_preWad");K(this,"_preVwap");K(this,"_preValue");K(this,"_currentData");K(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 Zc={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,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]==="(",d=l[1]===")";return(c?this.isAfter(p,f):!this.isBefore(p,f))&&(d?this.isBefore(h,f):!this.isAfter(h,f))||(c?this.isBefore(p,f):!this.isAfter(p,f))&&(d?this.isAfter(h,f):!this.isBefore(h,f))}}})})(Zc);var Zw=Zc.exports,jw=Zt(Zw),jc={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){return function(e,r,n){var s=r.prototype,a=function(d){var _,D=d.date,g=d.utc,y={};if(!((_=D)===null||_ instanceof Date||_ instanceof Array||s.$utils().u(_)||_.constructor.name!=="Object")){if(!Object.keys(D).length)return new Date;var v=g?n.utc():n();Object.keys(D).forEach(function($){var C,I;y[C=$,I=s.$utils().p(C),I==="date"?"day":I]=D[$]});var E=y.day||(y.year||y.month>=0?1:v.date()),b=y.year||v.year(),N=y.month>=0?y.month:y.year||y.day?0:v.month(),x=y.hour||0,F=y.minute||0,M=y.second||0,S=y.millisecond||0;return g?new Date(Date.UTC(b,N,E,x,F,M,S)):new Date(b,N,E,x,F,M,S)}return D},f=s.parse;s.parse=function(d){d.date=a.bind(this)(d),f.bind(this)(d)};var l=s.set,p=s.add,h=s.subtract,c=function(d,_,D,g){g===void 0&&(g=1);var y=Object.keys(_),v=this;return y.forEach(function(E){v=d.bind(v)(_[E]*g,E)}),v};s.set=function(d,_){return _=_===void 0?d:_,d.constructor.name==="Object"?c.bind(this)(function(D,g){return l.bind(this)(g,D)},_,d):l.bind(this)(d,_)},s.add=function(d,_){return d.constructor.name==="Object"?c.bind(this)(p,d,_):p.bind(this)(d,_)},s.subtract=function(d,_){return d.constructor.name==="Object"?c.bind(this)(p,d,_,-1):h.bind(this)(d,_)}}})})(jc);var Gw=jc.exports,Kw=Zt(Gw),Gc={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,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)?)?$/,d={years:p,months:h,days:f,hours:a,minutes:s,seconds:n,milliseconds:1,weeks:6048e5},_=function(F){return F instanceof N},D=function(F,M,S){return new N(F,S,M.$l)},g=function(F){return r.p(F)+"s"},y=function(F){return F<0},v=function(F){return y(F)?Math.ceil(F):Math.floor(F)},E=function(F){return Math.abs(F)},b=function(F,M){return F?y(F)?{negative:!0,format:""+E(F)+M}:{negative:!1,format:""+F+M}:{negative:!1,format:""}},N=function(){function F(S,$,C){var I=this;if(this.$d={},this.$l=C,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),$)return D(S*d[g($)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(q){I.$d[g(q)]=S[q]}),this.calMilliseconds(),this;if(typeof S=="string"){var R=S.match(c);if(R){var U=R.slice(2).map(function(q){return q!=null?Number(q):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var M=F.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function($,C){return $+(S.$d[C]||0)*d[C]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/p),S%=p,this.$d.months=v(S/h),S%=h,this.$d.days=v(S/f),S%=f,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/s),S%=s,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),$=b(this.$d.months,"M"),C=+this.$d.days||0;this.$d.weeks&&(C+=7*this.$d.weeks);var I=b(C,"D"),R=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),q=this.$d.seconds||0;this.$d.milliseconds&&(q+=this.$d.milliseconds/1e3,q=Math.round(1e3*q)/1e3);var k=b(q,"S"),P=S.negative||$.negative||I.negative||R.negative||U.negative||k.negative,G=R.format||U.format||k.format?"T":"",j=(P?"-":"")+"P"+S.format+$.format+I.format+G+R.format+U.format+k.format;return j==="P"||j==="-P"?"P0D":j},M.toJSON=function(){return this.toISOString()},M.format=function(S){var $=S||"YYYY-MM-DDTHH:mm:ss",C={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(C[I])})},M.as=function(S){return this.$ms/d[g(S)]},M.get=function(S){var $=this.$ms,C=g(S);return C==="milliseconds"?$%=1e3:$=C==="weeks"?v($/d[C]):this.$d[C],$||0},M.add=function(S,$,C){var I;return I=$?S*d[g($)]:_(S)?S.$ms:D(S,this).$ms,D(this.$ms+I*(C?-1:1),this)},M.subtract=function(S,$){return this.add(S,$,!0)},M.locale=function(S){var $=this.clone();return $.$l=S,$},M.clone=function(){return D(this.$ms,this)},M.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},M.valueOf=function(){return this.asMilliseconds()},M.milliseconds=function(){return this.get("milliseconds")},M.asMilliseconds=function(){return this.as("milliseconds")},M.seconds=function(){return this.get("seconds")},M.asSeconds=function(){return this.as("seconds")},M.minutes=function(){return this.get("minutes")},M.asMinutes=function(){return this.as("minutes")},M.hours=function(){return this.get("hours")},M.asHours=function(){return this.as("hours")},M.days=function(){return this.get("days")},M.asDays=function(){return this.as("days")},M.weeks=function(){return this.get("weeks")},M.asWeeks=function(){return this.as("weeks")},M.months=function(){return this.get("months")},M.asMonths=function(){return this.as("months")},M.years=function(){return this.get("years")},M.asYears=function(){return this.as("years")},F}(),x=function(F,M,S){return F.add(M.years()*S,"y").add(M.months()*S,"M").add(M.days()*S,"d").add(M.hours()*S,"h").add(M.minutes()*S,"m").add(M.seconds()*S,"s").add(M.milliseconds()*S,"ms")};return function(F,M,S){e=S,r=S().$utils(),S.duration=function(I,R){var U=S.locale();return D(I,{$l:U},R)},S.isDuration=_;var $=M.prototype.add,C=M.prototype.subtract;M.prototype.add=function(I,R){return _(I)?x(this,I,1):$.bind(this)(I,R)},M.prototype.subtract=function(I,R){return _(I)?x(this,I,-1):C.bind(this)(I,R)}}})})(Gc);var Jw=Gc.exports,Xw=Zt(Jw);ne.extend(jw),ne.extend(Kw),ne.extend(Xw);class Hw{constructor(t,e){K(this,"array");K(this,"color");K(this,"math");K(this,"str");K(this,"map");K(this,"matrix");K(this,"timeframe");K(this,"ta");K(this,"input");K(this,"_variables");K(this,"_cacheData");K(this,"_options");K(this,"_errorListener");K(this,"_plots");K(this,"chart");K(this,"line");K(this,"label");K(this,"polyline");K(this,"box");K(this,"table");K(this,"linefill");this._variables=e,this.array=new Tp,this.math=new $p(t),this.color=new u_,this.str=new aw,this.map=new fw,this.timeframe=new uw(e),this.matrix=new ow,this.ta=new n_(e,this.math,this.timeframe),this._cacheData={},this._options={},this._errorListener=new qw,this.input=new o_(e,this._errorListener),this._plots=new Map,this.chart={point:new lw(e)},this.line=new Rw(e),this.label=new cw(e),this.polyline=new Ow(e),this.box=new Pw(e),this.table=new zw(e),this.linefill=new Lw(e)}get errors(){return this._errorListener.errors}get options(){const t=this.input.getInputs();return Object.assign(this._options,{inputGroups:t,plots:[...this._plots.values()],draws:this._getDraws()})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:s,label:a}=this._variables,f={};return t.data.length&&(f.lines=t.data),e.data.length&&(f.linefills=e.data),r.data.length&&(f.tables=r.data),n.data.length&&(f.boxes=n.data),s.data.length&&(f.polylines=s.data),a.data.length&&(f.labels=a.data),Object.keys(f).length?f:void 0}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 d=n?[n]:void 0;this._plots.set(l,{editable:!0,...a,colors:d,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}`,d=this._plots.get(c),_=(d==null?void 0:d.data)||[],D=n!==void 0&&isNaN(n)?void 0:n,g=r!==void 0&&isNaN(r)?void 0:r,y=s!==void 0&&isNaN(s)?void 0:s,v=a!==void 0&&isNaN(a)?void 0:a,E=[g,D,y,v];if(_[h]=E,l!=null&&l.length&&(this._seriesColorHandle(t,c),_[h]={value:E,itemStyle:{color:f}}),!d){const b=f?[f]:void 0;this._plots.set(c,{editable:!0,...p,colors:b,data:_,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,d=`plotcandle_${e}`,_=this._plots.get(d),D=(_==null?void 0:_.data)||[],g=a!==void 0&&isNaN(a)?void 0:a,y=f!==void 0&&isNaN(f)?void 0:f,v=l!==void 0&&isNaN(l)?void 0:l,E=p!==void 0&&isNaN(p)?void 0:p,b=[y,g,v,E];D[c]={value:b,wickcolor:r,bordercolor:n,color:s},_||this._plots.set(d,{editable:!0,...h,data:D,id:d})}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=Cr(p.valueOf(),e)),p.valueOf()}weekofyear({time:t,timezone:e}){return Cr(t,e).week()}year({time:t,timezone:e}){return Cr(t,e).year()}second({time:t,timezone:e}){return Cr(t,e).second()}month({time:t,timezone:e}){return Cr(t,e).month()+1}minute({time:t,timezone:e}){return Cr(t,e).minute()}hour({time:t,timezone:e}){return Cr(t,e).hour()}dayofweek({time:t,timezone:e}){return Cr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return Cr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Sn(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=Sn(f),p=Sn(this._variables.timeframe.period);let h;if(l<=p)h=t;else{const c=`time_${e}`,d=this._cacheData[c];if(d)d.currentTime+l*1e3-d.offset<=t?(h=t,this._cacheData[c]={currentTime:t,offset:0}):h=d;else{const _=this._calcTimeOffset(t,f);this._cacheData[c]={currentTime:t,offset:_},h=t}}if(n){const{timePeriods:c,weeks:d}=this._parserSession(n),_=ne(t).format("YYYY-MM-DD"),D=h;h=void 0;for(const y of c){const[v,E]=y;if(ne(t).isBetween(`${_} ${v}`,`${_} ${E}`,"hour")){ne(D).isBetween(`${_} ${v}`,`${_} ${E}`,"hour")?h=D:h=ne(`${_} ${v}`).valueOf();break}}const g=this._variables.dayofweek;h&&!d.includes(g)&&(h=void 0)}return s&&(h=h&&Cr(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 Kc=Symbol("Comlink.proxy"),Qw=Symbol("Comlink.endpoint"),Vw=Symbol("Comlink.releaseProxy"),Lu=Symbol("Comlink.finalizer"),io=Symbol("Comlink.thrown"),Jc=i=>typeof i=="object"&&i!==null||typeof i=="function",tD={canHandle:i=>Jc(i)&&i[Kc],serialize(i){const{port1:t,port2:e}=new MessageChannel;return Pu(i,t),[e,[e]]},deserialize(i){return i.start(),iD(i)}},eD={canHandle:i=>Jc(i)&&io 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}},Xc=new Map([["proxy",tD],["throw",eD]]);function rD(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Pu(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!rD(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(zn);let p;try{const h=f.slice(0,-1).reduce((d,_)=>d[_],i),c=f.reduce((d,_)=>d[_],i);switch(a){case"GET":p=c;break;case"SET":h[f.slice(-1)[0]]=zn(n.data.value),p=!0;break;case"APPLY":p=c.apply(h,l);break;case"CONSTRUCT":{const d=new c(...l);p=fD(d)}break;case"ENDPOINT":{const{port1:d,port2:_}=new MessageChannel;Pu(i,_),p=aD(d,[d])}break;case"RELEASE":p=void 0;break;default:return}}catch(h){p={value:h,[io]:0}}Promise.resolve(p).catch(h=>({value:h,[io]:0})).then(h=>{const[c,d]=ao(h);t.postMessage(Object.assign(Object.assign({},c),{id:s}),d),a==="RELEASE"&&(t.removeEventListener("message",r),Hc(t),Lu in i&&typeof i[Lu]=="function"&&i[Lu]())}).catch(h=>{const[c,d]=ao({value:new TypeError("Unserializable return value"),[io]:0});t.postMessage(Object.assign(Object.assign({},c),{id:s}),d)})}),t.start&&t.start()}function nD(i){return i.constructor.name==="MessagePort"}function Hc(i){nD(i)&&i.close()}function iD(i,t){return zu(i,[],t)}function so(i){if(i)throw new Error("Proxy has been released and is not useable")}function Qc(i){return mi(i,{type:"RELEASE"}).then(()=>{Hc(i)})}const oo=new WeakMap,uo="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(oo.get(i)||0)-1;oo.set(i,t),t===0&&Qc(i)});function sD(i,t){const e=(oo.get(t)||0)+1;oo.set(t,e),uo&&uo.register(i,t,i)}function oD(i){uo&&uo.unregister(i)}function zu(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(so(r),a===Vw)return()=>{oD(n),Qc(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const f=mi(i,{type:"GET",path:t.map(l=>l.toString())}).then(zn);return f.then.bind(f)}return zu(i,[...t,a])},set(s,a,f){so(r);const[l,p]=ao(f);return mi(i,{type:"SET",path:[...t,a].map(h=>h.toString()),value:l},p).then(zn)},apply(s,a,f){so(r);const l=t[t.length-1];if(l===Qw)return mi(i,{type:"ENDPOINT"}).then(zn);if(l==="bind")return zu(i,t.slice(0,-1));const[p,h]=Vc(f);return mi(i,{type:"APPLY",path:t.map(c=>c.toString()),argumentList:p},h).then(zn)},construct(s,a){so(r);const[f,l]=Vc(a);return mi(i,{type:"CONSTRUCT",path:t.map(p=>p.toString()),argumentList:f},l).then(zn)}});return sD(n,i),n}function uD(i){return Array.prototype.concat.apply([],i)}function Vc(i){const t=i.map(ao);return[t.map(e=>e[0]),uD(t.map(e=>e[1]))]}const th=new WeakMap;function aD(i,t){return th.set(i,t),i}function fD(i){return Object.assign(i,{[Kc]:!0})}function ao(i){for(const[t,e]of Xc)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},th.get(i)||[]]}function zn(i){switch(i.type){case"HANDLER":return Xc.get(i.name).deserialize(i.value);case"RAW":return i.value}}function mi(i,t,e){return new Promise(r=>{const n=lD();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 lD(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class cD{constructor(){K(this,"_cache");K(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 hD(i,t,e){const{data:r,isPreParser:n}=t;if(e?(self.workerStorage||(self.workerStorage=new cD),self.builtInGather=new Uw,self.buildinConstants=new $w,self.buildInFunctions=new Hw(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===Ui.Error)?{status:1,errors:s}:{status:0,options:self.buildInFunctions.options}}Pu(hD)})();