@guihz/trading-vue-editor-tes 0.0.203 → 0.0.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/{parserTccWorker-jsFIW02M.js → parserTccWorker-CiI6FQtq.js} +1 -1
- package/lib/assets/scriptsRunWorker-7iEXpT-k.js +69 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/strategy.d.ts +16 -0
- package/lib/components/editor/parseScript/buildInVarNamespace/strategy.d.ts +2 -1
- package/lib/trading-vue-editor.js +769 -766
- package/lib/trading-vue-editor.umd.cjs +26 -26
- package/package.json +1 -1
- package/lib/assets/scriptsRunWorker-Bn8CAGnd.js +0 -69
@@ -0,0 +1,69 @@
|
|
1
|
+
var WF=Object.defineProperty;var jF=(Yt,Gt,Ne)=>Gt in Yt?WF(Yt,Gt,{enumerable:!0,configurable:!0,writable:!0,value:Ne}):Yt[Gt]=Ne;var $=(Yt,Gt,Ne)=>(jF(Yt,typeof Gt!="symbol"?Gt+"":Gt,Ne),Ne),El=(Yt,Gt,Ne)=>{if(!Gt.has(Yt))throw TypeError("Cannot "+Ne)};var Jr=(Yt,Gt,Ne)=>(El(Yt,Gt,"read from private field"),Ne?Ne.call(Yt):Gt.get(Yt)),Al=(Yt,Gt,Ne)=>{if(Gt.has(Yt))throw TypeError("Cannot add the same private member more than once");Gt instanceof WeakSet?Gt.add(Yt):Gt.set(Yt,Ne)},ua=(Yt,Gt,Ne,Vn)=>(El(Yt,Gt,"write to private field"),Vn?Vn.call(Yt,Ne):Gt.set(Yt,Ne),Ne);var Cl=(Yt,Gt,Ne)=>(El(Yt,Gt,"access private method"),Ne);(function(){"use strict";var es,Fl,Ni,Qe;var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gt(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ne(s){if(s.__esModule)return s;var t=s.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(s).forEach(function(r){var n=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return s[r]}})}),e}var Vn={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
|
+
*/Vn.exports,function(s,t){(function(){var e,r="4.17.21",n=200,i="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,d="__lodash_placeholder__",f=1,p=2,g=4,y=1,m=2,w=1,v=2,x=4,b=8,N=16,E=32,A=64,M=128,S=256,T=512,F=30,B="...",R=800,U=16,q=1,W=2,z=3,K=1/0,Z=9007199254740991,X=17976931348623157e292,Q=NaN,ct=4294967295,vt=ct-1,lt=ct>>>1,wt=[["ary",M],["bind",w],["bindKey",v],["curry",b],["curryRight",N],["flip",T],["partial",E],["partialRight",A],["rearg",S]],bt="[object Arguments]",Ot="[object Array]",xt="[object AsyncFunction]",ae="[object Boolean]",It="[object Date]",Nt="[object DOMException]",ce="[object Error]",re="[object Function]",qt="[object GeneratorFunction]",Jt="[object Map]",$e="[object Number]",vr="[object Null]",ze="[object Object]",dn="[object Promise]",Bn="[object Proxy]",pn="[object RegExp]",yr="[object Set]",In="[object String]",L="[object Symbol]",Y="[object Undefined]",G="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",at="[object Int16Array]",Xt="[object Int32Array]",ne="[object Uint8Array]",be="[object Uint8ClampedArray]",je="[object Uint16Array]",ke="[object Uint32Array]",wr=/\b__p \+= '';/g,Dr=/\b(__p \+=) '' \+/g,Tn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ti=/&(?:amp|lt|gt|quot|#39);/g,vo=/[&<>"']/g,Va=RegExp(ti.source),Ya=RegExp(vo.source),Za=/<%-([\s\S]+?)%>/g,Ka=/<%([\s\S]+?)%>/g,yo=/<%=([\s\S]+?)%>/g,Ga=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ha=/^\w*$/,Ja=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rs=/[\\^$.*+?()[\]{}|]/g,Xa=RegExp(rs.source),ns=/^\s+/,Qa=/\s/,tu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,eu=/\{\n\/\* \[wrapped with (.+)\] \*/,ru=/,? & /,nu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,iu=/[()=,{}\[\]\/\s]/,su=/\\(\\)?/g,ou=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,wo=/\w*$/,au=/^[-+]0x[0-9a-f]+$/i,uu=/^0b[01]+$/i,lu=/^\[object .+?Constructor\]$/,cu=/^0o[0-7]+$/i,fu=/^(?:0|[1-9]\d*)$/,hu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Si=/($^)/,ei=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",tr="\\u0300-\\u036f",du="\\ufe20-\\ufe2f",Oi="\\u20d0-\\u20ff",$n=tr+du+Oi,Do="\\u2700-\\u27bf",mh="a-z\\xdf-\\xf6\\xf8-\\xff",zw="\\xac\\xb1\\xd7\\xf7",kw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",qw="\\u2000-\\u206f",Uw=" \\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",gh="A-Z\\xc0-\\xd6\\xd8-\\xde",vh="\\ufe0e\\ufe0f",yh=zw+kw+qw+Uw,pu="['’]",Ww="["+Zt+"]",wh="["+yh+"]",bo="["+$n+"]",Dh="\\d+",jw="["+Do+"]",bh="["+mh+"]",xh="[^"+Zt+yh+Dh+Do+mh+gh+"]",_u="\\ud83c[\\udffb-\\udfff]",Vw="(?:"+bo+"|"+_u+")",Eh="[^"+Zt+"]",mu="(?:\\ud83c[\\udde6-\\uddff]){2}",gu="[\\ud800-\\udbff][\\udc00-\\udfff]",Bi="["+gh+"]",Ah="\\u200d",Ch="(?:"+bh+"|"+xh+")",Yw="(?:"+Bi+"|"+xh+")",Fh="(?:"+pu+"(?:d|ll|m|re|s|t|ve))?",Mh="(?:"+pu+"(?:D|LL|M|RE|S|T|VE))?",Nh=Vw+"?",Sh="["+vh+"]?",Zw="(?:"+Ah+"(?:"+[Eh,mu,gu].join("|")+")"+Sh+Nh+")*",Kw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Gw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Oh=Sh+Nh+Zw,Hw="(?:"+[jw,mu,gu].join("|")+")"+Oh,Jw="(?:"+[Eh+bo+"?",bo,mu,gu,Ww].join("|")+")",Xw=RegExp(pu,"g"),Qw=RegExp(bo,"g"),vu=RegExp(_u+"(?="+_u+")|"+Jw+Oh,"g"),tD=RegExp([Bi+"?"+bh+"+"+Fh+"(?="+[wh,Bi,"$"].join("|")+")",Yw+"+"+Mh+"(?="+[wh,Bi+Ch,"$"].join("|")+")",Bi+"?"+Ch+"+"+Fh,Bi+"+"+Mh,Gw,Kw,Dh,Hw].join("|"),"g"),eD=RegExp("["+Ah+Zt+$n+vh+"]"),rD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nD=["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,ye={};ye[ft]=ye[ut]=ye[ht]=ye[at]=ye[Xt]=ye[ne]=ye[be]=ye[je]=ye[ke]=!0,ye[bt]=ye[Ot]=ye[st]=ye[ae]=ye[rt]=ye[It]=ye[ce]=ye[re]=ye[Jt]=ye[$e]=ye[ze]=ye[pn]=ye[yr]=ye[In]=ye[G]=!1;var _e={};_e[bt]=_e[Ot]=_e[st]=_e[rt]=_e[ae]=_e[It]=_e[ft]=_e[ut]=_e[ht]=_e[at]=_e[Xt]=_e[Jt]=_e[$e]=_e[ze]=_e[pn]=_e[yr]=_e[In]=_e[L]=_e[ne]=_e[be]=_e[je]=_e[ke]=!0,_e[ce]=_e[re]=_e[G]=!1;var sD={À:"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"},oD={"&":"&","<":"<",">":">",'"':""","'":"'"},aD={"&":"&","<":"<",">":">",""":'"',"'":"'"},uD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lD=parseFloat,cD=parseInt,Bh=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt,fD=typeof self=="object"&&self&&self.Object===Object&&self,He=Bh||fD||Function("return this")(),yu=t&&!t.nodeType&&t,ri=yu&&!0&&s&&!s.nodeType&&s,Ih=ri&&ri.exports===yu,wu=Ih&&Bh.process,Br=function(){try{var j=ri&&ri.require&&ri.require("util").types;return j||wu&&wu.binding&&wu.binding("util")}catch{}}(),Th=Br&&Br.isArrayBuffer,$h=Br&&Br.isDate,Lh=Br&&Br.isMap,Rh=Br&&Br.isRegExp,Ph=Br&&Br.isSet,zh=Br&&Br.isTypedArray;function br(j,J,H){switch(H.length){case 0:return j.call(J);case 1:return j.call(J,H[0]);case 2:return j.call(J,H[0],H[1]);case 3:return j.call(J,H[0],H[1],H[2])}return j.apply(J,H)}function hD(j,J,H,gt){for(var Bt=-1,te=j==null?0:j.length;++Bt<te;){var qe=j[Bt];J(gt,qe,H(qe),j)}return gt}function Ir(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt&&J(j[H],H,j)!==!1;);return j}function dD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function kh(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(!J(j[H],H,j))return!1;return!0}function Ln(j,J){for(var H=-1,gt=j==null?0:j.length,Bt=0,te=[];++H<gt;){var qe=j[H];J(qe,H,j)&&(te[Bt++]=qe)}return te}function xo(j,J){var H=j==null?0:j.length;return!!H&&Ii(j,J,0)>-1}function Du(j,J,H){for(var gt=-1,Bt=j==null?0:j.length;++gt<Bt;)if(H(J,j[gt]))return!0;return!1}function xe(j,J){for(var H=-1,gt=j==null?0:j.length,Bt=Array(gt);++H<gt;)Bt[H]=J(j[H],H,j);return Bt}function Rn(j,J){for(var H=-1,gt=J.length,Bt=j.length;++H<gt;)j[Bt+H]=J[H];return j}function bu(j,J,H,gt){var Bt=-1,te=j==null?0:j.length;for(gt&&te&&(H=j[++Bt]);++Bt<te;)H=J(H,j[Bt],Bt,j);return H}function pD(j,J,H,gt){var Bt=j==null?0:j.length;for(gt&&Bt&&(H=j[--Bt]);Bt--;)H=J(H,j[Bt],Bt,j);return H}function xu(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(J(j[H],H,j))return!0;return!1}var _D=Eu("length");function mD(j){return j.split("")}function gD(j){return j.match(nu)||[]}function qh(j,J,H){var gt;return H(j,function(Bt,te,qe){if(J(Bt,te,qe))return gt=te,!1}),gt}function Eo(j,J,H,gt){for(var Bt=j.length,te=H+(gt?1:-1);gt?te--:++te<Bt;)if(J(j[te],te,j))return te;return-1}function Ii(j,J,H){return J===J?ND(j,J,H):Eo(j,Uh,H)}function vD(j,J,H,gt){for(var Bt=H-1,te=j.length;++Bt<te;)if(gt(j[Bt],J))return Bt;return-1}function Uh(j){return j!==j}function Wh(j,J){var H=j==null?0:j.length;return H?Cu(j,J)/H:Q}function Eu(j){return function(J){return J==null?e:J[j]}}function Au(j){return function(J){return j==null?e:j[J]}}function jh(j,J,H,gt,Bt){return Bt(j,function(te,qe,de){H=gt?(gt=!1,te):J(H,te,qe,de)}),H}function yD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Cu(j,J){for(var H,gt=-1,Bt=j.length;++gt<Bt;){var te=J(j[gt]);te!==e&&(H=H===e?te:H+te)}return H}function Fu(j,J){for(var H=-1,gt=Array(j);++H<j;)gt[H]=J(H);return gt}function wD(j,J){return xe(J,function(H){return[H,j[H]]})}function Vh(j){return j&&j.slice(0,Gh(j)+1).replace(ns,"")}function xr(j){return function(J){return j(J)}}function Mu(j,J){return xe(J,function(H){return j[H]})}function is(j,J){return j.has(J)}function Yh(j,J){for(var H=-1,gt=j.length;++H<gt&&Ii(J,j[H],0)>-1;);return H}function Zh(j,J){for(var H=j.length;H--&&Ii(J,j[H],0)>-1;);return H}function DD(j,J){for(var H=j.length,gt=0;H--;)j[H]===J&&++gt;return gt}var bD=Au(sD),xD=Au(oD);function ED(j){return"\\"+uD[j]}function AD(j,J){return j==null?e:j[J]}function Ti(j){return eD.test(j)}function CD(j){return rD.test(j)}function FD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function Nu(j){var J=-1,H=Array(j.size);return j.forEach(function(gt,Bt){H[++J]=[Bt,gt]}),H}function Kh(j,J){return function(H){return j(J(H))}}function Pn(j,J){for(var H=-1,gt=j.length,Bt=0,te=[];++H<gt;){var qe=j[H];(qe===J||qe===d)&&(j[H]=d,te[Bt++]=H)}return te}function Ao(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=gt}),H}function MD(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=[gt,gt]}),H}function ND(j,J,H){for(var gt=H-1,Bt=j.length;++gt<Bt;)if(j[gt]===J)return gt;return-1}function SD(j,J,H){for(var gt=H+1;gt--;)if(j[gt]===J)return gt;return gt}function $i(j){return Ti(j)?BD(j):_D(j)}function Zr(j){return Ti(j)?ID(j):mD(j)}function Gh(j){for(var J=j.length;J--&&Qa.test(j.charAt(J)););return J}var OD=Au(aD);function BD(j){for(var J=vu.lastIndex=0;vu.test(j);)++J;return J}function ID(j){return j.match(vu)||[]}function TD(j){return j.match(tD)||[]}var $D=function j(J){J=J==null?He:Li.defaults(He.Object(),J,Li.pick(He,nD));var H=J.Array,gt=J.Date,Bt=J.Error,te=J.Function,qe=J.Math,de=J.Object,Su=J.RegExp,LD=J.String,Tr=J.TypeError,Co=H.prototype,RD=te.prototype,Ri=de.prototype,Fo=J["__core-js_shared__"],Mo=RD.toString,ue=Ri.hasOwnProperty,PD=0,Hh=function(){var o=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),No=Ri.toString,zD=Mo.call(de),kD=He._,qD=Su("^"+Mo.call(ue).replace(rs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),So=Ih?J.Buffer:e,zn=J.Symbol,Oo=J.Uint8Array,Jh=So?So.allocUnsafe:e,Bo=Kh(de.getPrototypeOf,de),Xh=de.create,Qh=Ri.propertyIsEnumerable,Io=Co.splice,t0=zn?zn.isConcatSpreadable:e,ss=zn?zn.iterator:e,ni=zn?zn.toStringTag:e,To=function(){try{var o=ui(de,"defineProperty");return o({},"",{}),o}catch{}}(),UD=J.clearTimeout!==He.clearTimeout&&J.clearTimeout,WD=gt&>.now!==He.Date.now&>.now,jD=J.setTimeout!==He.setTimeout&&J.setTimeout,$o=qe.ceil,Lo=qe.floor,Ou=de.getOwnPropertySymbols,VD=So?So.isBuffer:e,e0=J.isFinite,YD=Co.join,ZD=Kh(de.keys,de),Ue=qe.max,er=qe.min,KD=gt.now,GD=J.parseInt,r0=qe.random,HD=Co.reverse,Bu=ui(J,"DataView"),os=ui(J,"Map"),Iu=ui(J,"Promise"),Pi=ui(J,"Set"),as=ui(J,"WeakMap"),us=ui(de,"create"),Ro=as&&new as,zi={},JD=li(Bu),XD=li(os),QD=li(Iu),tb=li(Pi),eb=li(as),Po=zn?zn.prototype:e,ls=Po?Po.valueOf:e,n0=Po?Po.toString:e;function O(o){if(Me(o)&&!Tt(o)&&!(o instanceof jt)){if(o instanceof $r)return o;if(ue.call(o,"__wrapped__"))return id(o)}return new $r(o)}var ki=function(){function o(){}return function(u){if(!Ce(u))return{};if(Xh)return Xh(u);o.prototype=u;var _=new o;return o.prototype=e,_}}();function zo(){}function $r(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}O.templateSettings={escape:Za,evaluate:Ka,interpolate:yo,variable:"",imports:{_:O}},O.prototype=zo.prototype,O.prototype.constructor=O,$r.prototype=ki(zo.prototype),$r.prototype.constructor=$r;function jt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function rb(){var o=new jt(this.__wrapped__);return o.__actions__=fr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=fr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=fr(this.__views__),o}function nb(){if(this.__filtered__){var o=new jt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function ib(){var o=this.__wrapped__.value(),u=this.__dir__,_=Tt(o),D=u<0,C=_?o.length:0,I=mx(0,C,this.__views__),P=I.start,k=I.end,V=k-P,tt=D?k:P-1,et=this.__iteratees__,ot=et.length,pt=0,yt=er(V,this.__takeCount__);if(!_||!D&&C==V&&yt==V)return F0(o,this.__actions__);var Ct=[];t:for(;V--&&pt<yt;){tt+=u;for(var Rt=-1,Ft=o[tt];++Rt<ot;){var Ut=et[Rt],Vt=Ut.iteratee,Cr=Ut.type,ar=Vt(Ft);if(Cr==W)Ft=ar;else if(!ar){if(Cr==q)continue t;break t}}Ct[pt++]=Ft}return Ct}jt.prototype=ki(zo.prototype),jt.prototype.constructor=jt;function ii(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function sb(){this.__data__=us?us(null):{},this.size=0}function ob(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function ab(o){var u=this.__data__;if(us){var _=u[o];return _===c?e:_}return ue.call(u,o)?u[o]:e}function ub(o){var u=this.__data__;return us?u[o]!==e:ue.call(u,o)}function lb(o,u){var _=this.__data__;return this.size+=this.has(o)?0:1,_[o]=us&&u===e?c:u,this}ii.prototype.clear=sb,ii.prototype.delete=ob,ii.prototype.get=ab,ii.prototype.has=ub,ii.prototype.set=lb;function _n(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function cb(){this.__data__=[],this.size=0}function fb(o){var u=this.__data__,_=ko(u,o);if(_<0)return!1;var D=u.length-1;return _==D?u.pop():Io.call(u,_,1),--this.size,!0}function hb(o){var u=this.__data__,_=ko(u,o);return _<0?e:u[_][1]}function db(o){return ko(this.__data__,o)>-1}function pb(o,u){var _=this.__data__,D=ko(_,o);return D<0?(++this.size,_.push([o,u])):_[D][1]=u,this}_n.prototype.clear=cb,_n.prototype.delete=fb,_n.prototype.get=hb,_n.prototype.has=db,_n.prototype.set=pb;function mn(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function _b(){this.size=0,this.__data__={hash:new ii,map:new(os||_n),string:new ii}}function mb(o){var u=Xo(this,o).delete(o);return this.size-=u?1:0,u}function gb(o){return Xo(this,o).get(o)}function vb(o){return Xo(this,o).has(o)}function yb(o,u){var _=Xo(this,o),D=_.size;return _.set(o,u),this.size+=_.size==D?0:1,this}mn.prototype.clear=_b,mn.prototype.delete=mb,mn.prototype.get=gb,mn.prototype.has=vb,mn.prototype.set=yb;function si(o){var u=-1,_=o==null?0:o.length;for(this.__data__=new mn;++u<_;)this.add(o[u])}function wb(o){return this.__data__.set(o,c),this}function Db(o){return this.__data__.has(o)}si.prototype.add=si.prototype.push=wb,si.prototype.has=Db;function Kr(o){var u=this.__data__=new _n(o);this.size=u.size}function bb(){this.__data__=new _n,this.size=0}function xb(o){var u=this.__data__,_=u.delete(o);return this.size=u.size,_}function Eb(o){return this.__data__.get(o)}function Ab(o){return this.__data__.has(o)}function Cb(o,u){var _=this.__data__;if(_ instanceof _n){var D=_.__data__;if(!os||D.length<n-1)return D.push([o,u]),this.size=++_.size,this;_=this.__data__=new mn(D)}return _.set(o,u),this.size=_.size,this}Kr.prototype.clear=bb,Kr.prototype.delete=xb,Kr.prototype.get=Eb,Kr.prototype.has=Ab,Kr.prototype.set=Cb;function i0(o,u){var _=Tt(o),D=!_&&ci(o),C=!_&&!D&&jn(o),I=!_&&!D&&!C&&ji(o),P=_||D||C||I,k=P?Fu(o.length,LD):[],V=k.length;for(var tt in o)(u||ue.call(o,tt))&&!(P&&(tt=="length"||C&&(tt=="offset"||tt=="parent")||I&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||wn(tt,V)))&&k.push(tt);return k}function s0(o){var u=o.length;return u?o[ju(0,u-1)]:e}function Fb(o,u){return Qo(fr(o),oi(u,0,o.length))}function Mb(o){return Qo(fr(o))}function Tu(o,u,_){(_!==e&&!Gr(o[u],_)||_===e&&!(u in o))&&gn(o,u,_)}function cs(o,u,_){var D=o[u];(!(ue.call(o,u)&&Gr(D,_))||_===e&&!(u in o))&&gn(o,u,_)}function ko(o,u){for(var _=o.length;_--;)if(Gr(o[_][0],u))return _;return-1}function Nb(o,u,_,D){return kn(o,function(C,I,P){u(D,C,_(C),P)}),D}function o0(o,u){return o&&sn(u,Ve(u),o)}function Sb(o,u){return o&&sn(u,dr(u),o)}function gn(o,u,_){u=="__proto__"&&To?To(o,u,{configurable:!0,enumerable:!0,value:_,writable:!0}):o[u]=_}function $u(o,u){for(var _=-1,D=u.length,C=H(D),I=o==null;++_<D;)C[_]=I?e:_l(o,u[_]);return C}function oi(o,u,_){return o===o&&(_!==e&&(o=o<=_?o:_),u!==e&&(o=o>=u?o:u)),o}function Lr(o,u,_,D,C,I){var P,k=u&f,V=u&p,tt=u&g;if(_&&(P=C?_(o,D,C,I):_(o)),P!==e)return P;if(!Ce(o))return o;var et=Tt(o);if(et){if(P=vx(o),!k)return fr(o,P)}else{var ot=rr(o),pt=ot==re||ot==qt;if(jn(o))return S0(o,k);if(ot==ze||ot==bt||pt&&!C){if(P=V||pt?{}:G0(o),!k)return V?ax(o,Sb(P,o)):ox(o,o0(P,o))}else{if(!_e[ot])return C?o:{};P=yx(o,ot,k)}}I||(I=new Kr);var yt=I.get(o);if(yt)return yt;I.set(o,P),Ed(o)?o.forEach(function(Ft){P.add(Lr(Ft,u,_,Ft,o,I))}):bd(o)&&o.forEach(function(Ft,Ut){P.set(Ut,Lr(Ft,u,_,Ut,o,I))});var Ct=tt?V?el:tl:V?dr:Ve,Rt=et?e:Ct(o);return Ir(Rt||o,function(Ft,Ut){Rt&&(Ut=Ft,Ft=o[Ut]),cs(P,Ut,Lr(Ft,u,_,Ut,o,I))}),P}function Ob(o){var u=Ve(o);return function(_){return a0(_,o,u)}}function a0(o,u,_){var D=_.length;if(o==null)return!D;for(o=de(o);D--;){var C=_[D],I=u[C],P=o[C];if(P===e&&!(C in o)||!I(P))return!1}return!0}function u0(o,u,_){if(typeof o!="function")throw new Tr(a);return gs(function(){o.apply(e,_)},u)}function fs(o,u,_,D){var C=-1,I=xo,P=!0,k=o.length,V=[],tt=u.length;if(!k)return V;_&&(u=xe(u,xr(_))),D?(I=Du,P=!1):u.length>=n&&(I=is,P=!1,u=new si(u));t:for(;++C<k;){var et=o[C],ot=_==null?et:_(et);if(et=D||et!==0?et:0,P&&ot===ot){for(var pt=tt;pt--;)if(u[pt]===ot)continue t;V.push(et)}else I(u,ot,D)||V.push(et)}return V}var kn=$0(nn),l0=$0(Ru,!0);function Bb(o,u){var _=!0;return kn(o,function(D,C,I){return _=!!u(D,C,I),_}),_}function qo(o,u,_){for(var D=-1,C=o.length;++D<C;){var I=o[D],P=u(I);if(P!=null&&(k===e?P===P&&!Ar(P):_(P,k)))var k=P,V=I}return V}function Ib(o,u,_,D){var C=o.length;for(_=Lt(_),_<0&&(_=-_>C?0:C+_),D=D===e||D>C?C:Lt(D),D<0&&(D+=C),D=_>D?0:Cd(D);_<D;)o[_++]=u;return o}function c0(o,u){var _=[];return kn(o,function(D,C,I){u(D,C,I)&&_.push(D)}),_}function Je(o,u,_,D,C){var I=-1,P=o.length;for(_||(_=Dx),C||(C=[]);++I<P;){var k=o[I];u>0&&_(k)?u>1?Je(k,u-1,_,D,C):Rn(C,k):D||(C[C.length]=k)}return C}var Lu=L0(),f0=L0(!0);function nn(o,u){return o&&Lu(o,u,Ve)}function Ru(o,u){return o&&f0(o,u,Ve)}function Uo(o,u){return Ln(u,function(_){return Dn(o[_])})}function ai(o,u){u=Un(u,o);for(var _=0,D=u.length;o!=null&&_<D;)o=o[on(u[_++])];return _&&_==D?o:e}function h0(o,u,_){var D=u(o);return Tt(o)?D:Rn(D,_(o))}function sr(o){return o==null?o===e?Y:vr:ni&&ni in de(o)?_x(o):Mx(o)}function Pu(o,u){return o>u}function Tb(o,u){return o!=null&&ue.call(o,u)}function $b(o,u){return o!=null&&u in de(o)}function Lb(o,u,_){return o>=er(u,_)&&o<Ue(u,_)}function zu(o,u,_){for(var D=_?Du:xo,C=o[0].length,I=o.length,P=I,k=H(I),V=1/0,tt=[];P--;){var et=o[P];P&&u&&(et=xe(et,xr(u))),V=er(et.length,V),k[P]=!_&&(u||C>=120&&et.length>=120)?new si(P&&et):e}et=o[0];var ot=-1,pt=k[0];t:for(;++ot<C&&tt.length<V;){var yt=et[ot],Ct=u?u(yt):yt;if(yt=_||yt!==0?yt:0,!(pt?is(pt,Ct):D(tt,Ct,_))){for(P=I;--P;){var Rt=k[P];if(!(Rt?is(Rt,Ct):D(o[P],Ct,_)))continue t}pt&&pt.push(Ct),tt.push(yt)}}return tt}function Rb(o,u,_,D){return nn(o,function(C,I,P){u(D,_(C),I,P)}),D}function hs(o,u,_){u=Un(u,o),o=Q0(o,u);var D=o==null?o:o[on(Pr(u))];return D==null?e:br(D,o,_)}function d0(o){return Me(o)&&sr(o)==bt}function Pb(o){return Me(o)&&sr(o)==st}function zb(o){return Me(o)&&sr(o)==It}function ds(o,u,_,D,C){return o===u?!0:o==null||u==null||!Me(o)&&!Me(u)?o!==o&&u!==u:kb(o,u,_,D,ds,C)}function kb(o,u,_,D,C,I){var P=Tt(o),k=Tt(u),V=P?Ot:rr(o),tt=k?Ot:rr(u);V=V==bt?ze:V,tt=tt==bt?ze:tt;var et=V==ze,ot=tt==ze,pt=V==tt;if(pt&&jn(o)){if(!jn(u))return!1;P=!0,et=!1}if(pt&&!et)return I||(I=new Kr),P||ji(o)?Y0(o,u,_,D,C,I):dx(o,u,V,_,D,C,I);if(!(_&y)){var yt=et&&ue.call(o,"__wrapped__"),Ct=ot&&ue.call(u,"__wrapped__");if(yt||Ct){var Rt=yt?o.value():o,Ft=Ct?u.value():u;return I||(I=new Kr),C(Rt,Ft,_,D,I)}}return pt?(I||(I=new Kr),px(o,u,_,D,C,I)):!1}function qb(o){return Me(o)&&rr(o)==Jt}function ku(o,u,_,D){var C=_.length,I=C,P=!D;if(o==null)return!I;for(o=de(o);C--;){var k=_[C];if(P&&k[2]?k[1]!==o[k[0]]:!(k[0]in o))return!1}for(;++C<I;){k=_[C];var V=k[0],tt=o[V],et=k[1];if(P&&k[2]){if(tt===e&&!(V in o))return!1}else{var ot=new Kr;if(D)var pt=D(tt,et,V,o,u,ot);if(!(pt===e?ds(et,tt,y|m,D,ot):pt))return!1}}return!0}function p0(o){if(!Ce(o)||xx(o))return!1;var u=Dn(o)?qD:lu;return u.test(li(o))}function Ub(o){return Me(o)&&sr(o)==pn}function Wb(o){return Me(o)&&rr(o)==yr}function jb(o){return Me(o)&&sa(o.length)&&!!ye[sr(o)]}function _0(o){return typeof o=="function"?o:o==null?pr:typeof o=="object"?Tt(o)?v0(o[0],o[1]):g0(o):Rd(o)}function qu(o){if(!ms(o))return ZD(o);var u=[];for(var _ in de(o))ue.call(o,_)&&_!="constructor"&&u.push(_);return u}function Vb(o){if(!Ce(o))return Fx(o);var u=ms(o),_=[];for(var D in o)D=="constructor"&&(u||!ue.call(o,D))||_.push(D);return _}function Uu(o,u){return o<u}function m0(o,u){var _=-1,D=hr(o)?H(o.length):[];return kn(o,function(C,I,P){D[++_]=u(C,I,P)}),D}function g0(o){var u=nl(o);return u.length==1&&u[0][2]?J0(u[0][0],u[0][1]):function(_){return _===o||ku(_,o,u)}}function v0(o,u){return sl(o)&&H0(u)?J0(on(o),u):function(_){var D=_l(_,o);return D===e&&D===u?ml(_,o):ds(u,D,y|m)}}function Wo(o,u,_,D,C){o!==u&&Lu(u,function(I,P){if(C||(C=new Kr),Ce(I))Yb(o,u,P,_,Wo,D,C);else{var k=D?D(al(o,P),I,P+"",o,u,C):e;k===e&&(k=I),Tu(o,P,k)}},dr)}function Yb(o,u,_,D,C,I,P){var k=al(o,_),V=al(u,_),tt=P.get(V);if(tt){Tu(o,_,tt);return}var et=I?I(k,V,_+"",o,u,P):e,ot=et===e;if(ot){var pt=Tt(V),yt=!pt&&jn(V),Ct=!pt&&!yt&&ji(V);et=V,pt||yt||Ct?Tt(k)?et=k:Oe(k)?et=fr(k):yt?(ot=!1,et=S0(V,!0)):Ct?(ot=!1,et=O0(V,!0)):et=[]:vs(V)||ci(V)?(et=k,ci(k)?et=Fd(k):(!Ce(k)||Dn(k))&&(et=G0(V))):ot=!1}ot&&(P.set(V,et),C(et,V,D,I,P),P.delete(V)),Tu(o,_,et)}function y0(o,u){var _=o.length;if(_)return u+=u<0?_:0,wn(u,_)?o[u]:e}function w0(o,u,_){u.length?u=xe(u,function(I){return Tt(I)?function(P){return ai(P,I.length===1?I[0]:I)}:I}):u=[pr];var D=-1;u=xe(u,xr(At()));var C=m0(o,function(I,P,k){var V=xe(u,function(tt){return tt(I)});return{criteria:V,index:++D,value:I}});return yD(C,function(I,P){return sx(I,P,_)})}function Zb(o,u){return D0(o,u,function(_,D){return ml(o,D)})}function D0(o,u,_){for(var D=-1,C=u.length,I={};++D<C;){var P=u[D],k=ai(o,P);_(k,P)&&ps(I,Un(P,o),k)}return I}function Kb(o){return function(u){return ai(u,o)}}function Wu(o,u,_,D){var C=D?vD:Ii,I=-1,P=u.length,k=o;for(o===u&&(u=fr(u)),_&&(k=xe(o,xr(_)));++I<P;)for(var V=0,tt=u[I],et=_?_(tt):tt;(V=C(k,et,V,D))>-1;)k!==o&&Io.call(k,V,1),Io.call(o,V,1);return o}function b0(o,u){for(var _=o?u.length:0,D=_-1;_--;){var C=u[_];if(_==D||C!==I){var I=C;wn(C)?Io.call(o,C,1):Zu(o,C)}}return o}function ju(o,u){return o+Lo(r0()*(u-o+1))}function Gb(o,u,_,D){for(var C=-1,I=Ue($o((u-o)/(_||1)),0),P=H(I);I--;)P[D?I:++C]=o,o+=_;return P}function Vu(o,u){var _="";if(!o||u<1||u>Z)return _;do u%2&&(_+=o),u=Lo(u/2),u&&(o+=o);while(u);return _}function Pt(o,u){return ul(X0(o,u,pr),o+"")}function Hb(o){return s0(Vi(o))}function Jb(o,u){var _=Vi(o);return Qo(_,oi(u,0,_.length))}function ps(o,u,_,D){if(!Ce(o))return o;u=Un(u,o);for(var C=-1,I=u.length,P=I-1,k=o;k!=null&&++C<I;){var V=on(u[C]),tt=_;if(V==="__proto__"||V==="constructor"||V==="prototype")return o;if(C!=P){var et=k[V];tt=D?D(et,V,k):e,tt===e&&(tt=Ce(et)?et:wn(u[C+1])?[]:{})}cs(k,V,tt),k=k[V]}return o}var x0=Ro?function(o,u){return Ro.set(o,u),o}:pr,Xb=To?function(o,u){return To(o,"toString",{configurable:!0,enumerable:!1,value:vl(u),writable:!0})}:pr;function Qb(o){return Qo(Vi(o))}function Rr(o,u,_){var D=-1,C=o.length;u<0&&(u=-u>C?0:C+u),_=_>C?C:_,_<0&&(_+=C),C=u>_?0:_-u>>>0,u>>>=0;for(var I=H(C);++D<C;)I[D]=o[D+u];return I}function tx(o,u){var _;return kn(o,function(D,C,I){return _=u(D,C,I),!_}),!!_}function jo(o,u,_){var D=0,C=o==null?D:o.length;if(typeof u=="number"&&u===u&&C<=lt){for(;D<C;){var I=D+C>>>1,P=o[I];P!==null&&!Ar(P)&&(_?P<=u:P<u)?D=I+1:C=I}return C}return Yu(o,u,pr,_)}function Yu(o,u,_,D){var C=0,I=o==null?0:o.length;if(I===0)return 0;u=_(u);for(var P=u!==u,k=u===null,V=Ar(u),tt=u===e;C<I;){var et=Lo((C+I)/2),ot=_(o[et]),pt=ot!==e,yt=ot===null,Ct=ot===ot,Rt=Ar(ot);if(P)var Ft=D||Ct;else tt?Ft=Ct&&(D||pt):k?Ft=Ct&&pt&&(D||!yt):V?Ft=Ct&&pt&&!yt&&(D||!Rt):yt||Rt?Ft=!1:Ft=D?ot<=u:ot<u;Ft?C=et+1:I=et}return er(I,vt)}function E0(o,u){for(var _=-1,D=o.length,C=0,I=[];++_<D;){var P=o[_],k=u?u(P):P;if(!_||!Gr(k,V)){var V=k;I[C++]=P===0?0:P}}return I}function A0(o){return typeof o=="number"?o:Ar(o)?Q:+o}function Er(o){if(typeof o=="string")return o;if(Tt(o))return xe(o,Er)+"";if(Ar(o))return n0?n0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function qn(o,u,_){var D=-1,C=xo,I=o.length,P=!0,k=[],V=k;if(_)P=!1,C=Du;else if(I>=n){var tt=u?null:fx(o);if(tt)return Ao(tt);P=!1,C=is,V=new si}else V=u?[]:k;t:for(;++D<I;){var et=o[D],ot=u?u(et):et;if(et=_||et!==0?et:0,P&&ot===ot){for(var pt=V.length;pt--;)if(V[pt]===ot)continue t;u&&V.push(ot),k.push(et)}else C(V,ot,_)||(V!==k&&V.push(ot),k.push(et))}return k}function Zu(o,u){return u=Un(u,o),o=Q0(o,u),o==null||delete o[on(Pr(u))]}function C0(o,u,_,D){return ps(o,u,_(ai(o,u)),D)}function Vo(o,u,_,D){for(var C=o.length,I=D?C:-1;(D?I--:++I<C)&&u(o[I],I,o););return _?Rr(o,D?0:I,D?I+1:C):Rr(o,D?I+1:0,D?C:I)}function F0(o,u){var _=o;return _ instanceof jt&&(_=_.value()),bu(u,function(D,C){return C.func.apply(C.thisArg,Rn([D],C.args))},_)}function Ku(o,u,_){var D=o.length;if(D<2)return D?qn(o[0]):[];for(var C=-1,I=H(D);++C<D;)for(var P=o[C],k=-1;++k<D;)k!=C&&(I[C]=fs(I[C]||P,o[k],u,_));return qn(Je(I,1),u,_)}function M0(o,u,_){for(var D=-1,C=o.length,I=u.length,P={};++D<C;){var k=D<I?u[D]:e;_(P,o[D],k)}return P}function Gu(o){return Oe(o)?o:[]}function Hu(o){return typeof o=="function"?o:pr}function Un(o,u){return Tt(o)?o:sl(o,u)?[o]:nd(ie(o))}var ex=Pt;function Wn(o,u,_){var D=o.length;return _=_===e?D:_,!u&&_>=D?o:Rr(o,u,_)}var N0=UD||function(o){return He.clearTimeout(o)};function S0(o,u){if(u)return o.slice();var _=o.length,D=Jh?Jh(_):new o.constructor(_);return o.copy(D),D}function Ju(o){var u=new o.constructor(o.byteLength);return new Oo(u).set(new Oo(o)),u}function rx(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.byteLength)}function nx(o){var u=new o.constructor(o.source,wo.exec(o));return u.lastIndex=o.lastIndex,u}function ix(o){return ls?de(ls.call(o)):{}}function O0(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.length)}function B0(o,u){if(o!==u){var _=o!==e,D=o===null,C=o===o,I=Ar(o),P=u!==e,k=u===null,V=u===u,tt=Ar(u);if(!k&&!tt&&!I&&o>u||I&&P&&V&&!k&&!tt||D&&P&&V||!_&&V||!C)return 1;if(!D&&!I&&!tt&&o<u||tt&&_&&C&&!D&&!I||k&&_&&C||!P&&C||!V)return-1}return 0}function sx(o,u,_){for(var D=-1,C=o.criteria,I=u.criteria,P=C.length,k=_.length;++D<P;){var V=B0(C[D],I[D]);if(V){if(D>=k)return V;var tt=_[D];return V*(tt=="desc"?-1:1)}}return o.index-u.index}function I0(o,u,_,D){for(var C=-1,I=o.length,P=_.length,k=-1,V=u.length,tt=Ue(I-P,0),et=H(V+tt),ot=!D;++k<V;)et[k]=u[k];for(;++C<P;)(ot||C<I)&&(et[_[C]]=o[C]);for(;tt--;)et[k++]=o[C++];return et}function T0(o,u,_,D){for(var C=-1,I=o.length,P=-1,k=_.length,V=-1,tt=u.length,et=Ue(I-k,0),ot=H(et+tt),pt=!D;++C<et;)ot[C]=o[C];for(var yt=C;++V<tt;)ot[yt+V]=u[V];for(;++P<k;)(pt||C<I)&&(ot[yt+_[P]]=o[C++]);return ot}function fr(o,u){var _=-1,D=o.length;for(u||(u=H(D));++_<D;)u[_]=o[_];return u}function sn(o,u,_,D){var C=!_;_||(_={});for(var I=-1,P=u.length;++I<P;){var k=u[I],V=D?D(_[k],o[k],k,_,o):e;V===e&&(V=o[k]),C?gn(_,k,V):cs(_,k,V)}return _}function ox(o,u){return sn(o,il(o),u)}function ax(o,u){return sn(o,Z0(o),u)}function Yo(o,u){return function(_,D){var C=Tt(_)?hD:Nb,I=u?u():{};return C(_,o,At(D,2),I)}}function qi(o){return Pt(function(u,_){var D=-1,C=_.length,I=C>1?_[C-1]:e,P=C>2?_[2]:e;for(I=o.length>3&&typeof I=="function"?(C--,I):e,P&&or(_[0],_[1],P)&&(I=C<3?e:I,C=1),u=de(u);++D<C;){var k=_[D];k&&o(u,k,D,I)}return u})}function $0(o,u){return function(_,D){if(_==null)return _;if(!hr(_))return o(_,D);for(var C=_.length,I=u?C:-1,P=de(_);(u?I--:++I<C)&&D(P[I],I,P)!==!1;);return _}}function L0(o){return function(u,_,D){for(var C=-1,I=de(u),P=D(u),k=P.length;k--;){var V=P[o?k:++C];if(_(I[V],V,I)===!1)break}return u}}function ux(o,u,_){var D=u&w,C=_s(o);function I(){var P=this&&this!==He&&this instanceof I?C:o;return P.apply(D?_:this,arguments)}return I}function R0(o){return function(u){u=ie(u);var _=Ti(u)?Zr(u):e,D=_?_[0]:u.charAt(0),C=_?Wn(_,1).join(""):u.slice(1);return D[o]()+C}}function Ui(o){return function(u){return bu($d(Td(u).replace(Xw,"")),o,"")}}function _s(o){return function(){var u=arguments;switch(u.length){case 0:return new o;case 1:return new o(u[0]);case 2:return new o(u[0],u[1]);case 3:return new o(u[0],u[1],u[2]);case 4:return new o(u[0],u[1],u[2],u[3]);case 5:return new o(u[0],u[1],u[2],u[3],u[4]);case 6:return new o(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new o(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var _=ki(o.prototype),D=o.apply(_,u);return Ce(D)?D:_}}function lx(o,u,_){var D=_s(o);function C(){for(var I=arguments.length,P=H(I),k=I,V=Wi(C);k--;)P[k]=arguments[k];var tt=I<3&&P[0]!==V&&P[I-1]!==V?[]:Pn(P,V);if(I-=tt.length,I<_)return U0(o,u,Zo,C.placeholder,e,P,tt,e,e,_-I);var et=this&&this!==He&&this instanceof C?D:o;return br(et,this,P)}return C}function P0(o){return function(u,_,D){var C=de(u);if(!hr(u)){var I=At(_,3);u=Ve(u),_=function(k){return I(C[k],k,C)}}var P=o(u,_,D);return P>-1?C[I?u[P]:P]:e}}function z0(o){return yn(function(u){var _=u.length,D=_,C=$r.prototype.thru;for(o&&u.reverse();D--;){var I=u[D];if(typeof I!="function")throw new Tr(a);if(C&&!P&&Jo(I)=="wrapper")var P=new $r([],!0)}for(D=P?D:_;++D<_;){I=u[D];var k=Jo(I),V=k=="wrapper"?rl(I):e;V&&ol(V[0])&&V[1]==(M|b|E|S)&&!V[4].length&&V[9]==1?P=P[Jo(V[0])].apply(P,V[3]):P=I.length==1&&ol(I)?P[k]():P.thru(I)}return function(){var tt=arguments,et=tt[0];if(P&&tt.length==1&&Tt(et))return P.plant(et).value();for(var ot=0,pt=_?u[ot].apply(this,tt):et;++ot<_;)pt=u[ot].call(this,pt);return pt}})}function Zo(o,u,_,D,C,I,P,k,V,tt){var et=u&M,ot=u&w,pt=u&v,yt=u&(b|N),Ct=u&T,Rt=pt?e:_s(o);function Ft(){for(var Ut=arguments.length,Vt=H(Ut),Cr=Ut;Cr--;)Vt[Cr]=arguments[Cr];if(yt)var ar=Wi(Ft),Fr=DD(Vt,ar);if(D&&(Vt=I0(Vt,D,C,yt)),I&&(Vt=T0(Vt,I,P,yt)),Ut-=Fr,yt&&Ut<tt){var Be=Pn(Vt,ar);return U0(o,u,Zo,Ft.placeholder,_,Vt,Be,k,V,tt-Ut)}var Hr=ot?_:this,xn=pt?Hr[o]:o;return Ut=Vt.length,k?Vt=Nx(Vt,k):Ct&&Ut>1&&Vt.reverse(),et&&V<Ut&&(Vt.length=V),this&&this!==He&&this instanceof Ft&&(xn=Rt||_s(xn)),xn.apply(Hr,Vt)}return Ft}function k0(o,u){return function(_,D){return Rb(_,o,u(D),{})}}function Ko(o,u){return function(_,D){var C;if(_===e&&D===e)return u;if(_!==e&&(C=_),D!==e){if(C===e)return D;typeof _=="string"||typeof D=="string"?(_=Er(_),D=Er(D)):(_=A0(_),D=A0(D)),C=o(_,D)}return C}}function Xu(o){return yn(function(u){return u=xe(u,xr(At())),Pt(function(_){var D=this;return o(u,function(C){return br(C,D,_)})})})}function Go(o,u){u=u===e?" ":Er(u);var _=u.length;if(_<2)return _?Vu(u,o):u;var D=Vu(u,$o(o/$i(u)));return Ti(u)?Wn(Zr(D),0,o).join(""):D.slice(0,o)}function cx(o,u,_,D){var C=u&w,I=_s(o);function P(){for(var k=-1,V=arguments.length,tt=-1,et=D.length,ot=H(et+V),pt=this&&this!==He&&this instanceof P?I:o;++tt<et;)ot[tt]=D[tt];for(;V--;)ot[tt++]=arguments[++k];return br(pt,C?_:this,ot)}return P}function q0(o){return function(u,_,D){return D&&typeof D!="number"&&or(u,_,D)&&(_=D=e),u=bn(u),_===e?(_=u,u=0):_=bn(_),D=D===e?u<_?1:-1:bn(D),Gb(u,_,D,o)}}function Ho(o){return function(u,_){return typeof u=="string"&&typeof _=="string"||(u=zr(u),_=zr(_)),o(u,_)}}function U0(o,u,_,D,C,I,P,k,V,tt){var et=u&b,ot=et?P:e,pt=et?e:P,yt=et?I:e,Ct=et?e:I;u|=et?E:A,u&=~(et?A:E),u&x||(u&=~(w|v));var Rt=[o,u,C,yt,ot,Ct,pt,k,V,tt],Ft=_.apply(e,Rt);return ol(o)&&td(Ft,Rt),Ft.placeholder=D,ed(Ft,o,u)}function Qu(o){var u=qe[o];return function(_,D){if(_=zr(_),D=D==null?0:er(Lt(D),292),D&&e0(_)){var C=(ie(_)+"e").split("e"),I=u(C[0]+"e"+(+C[1]+D));return C=(ie(I)+"e").split("e"),+(C[0]+"e"+(+C[1]-D))}return u(_)}}var fx=Pi&&1/Ao(new Pi([,-0]))[1]==K?function(o){return new Pi(o)}:Dl;function W0(o){return function(u){var _=rr(u);return _==Jt?Nu(u):_==yr?MD(u):wD(u,o(u))}}function vn(o,u,_,D,C,I,P,k){var V=u&v;if(!V&&typeof o!="function")throw new Tr(a);var tt=D?D.length:0;if(tt||(u&=~(E|A),D=C=e),P=P===e?P:Ue(Lt(P),0),k=k===e?k:Lt(k),tt-=C?C.length:0,u&A){var et=D,ot=C;D=C=e}var pt=V?e:rl(o),yt=[o,u,_,D,C,et,ot,I,P,k];if(pt&&Cx(yt,pt),o=yt[0],u=yt[1],_=yt[2],D=yt[3],C=yt[4],k=yt[9]=yt[9]===e?V?0:o.length:Ue(yt[9]-tt,0),!k&&u&(b|N)&&(u&=~(b|N)),!u||u==w)var Ct=ux(o,u,_);else u==b||u==N?Ct=lx(o,u,k):(u==E||u==(w|E))&&!C.length?Ct=cx(o,u,_,D):Ct=Zo.apply(e,yt);var Rt=pt?x0:td;return ed(Rt(Ct,yt),o,u)}function j0(o,u,_,D){return o===e||Gr(o,Ri[_])&&!ue.call(D,_)?u:o}function V0(o,u,_,D,C,I){return Ce(o)&&Ce(u)&&(I.set(u,o),Wo(o,u,e,V0,I),I.delete(u)),o}function hx(o){return vs(o)?e:o}function Y0(o,u,_,D,C,I){var P=_&y,k=o.length,V=u.length;if(k!=V&&!(P&&V>k))return!1;var tt=I.get(o),et=I.get(u);if(tt&&et)return tt==u&&et==o;var ot=-1,pt=!0,yt=_&m?new si:e;for(I.set(o,u),I.set(u,o);++ot<k;){var Ct=o[ot],Rt=u[ot];if(D)var Ft=P?D(Rt,Ct,ot,u,o,I):D(Ct,Rt,ot,o,u,I);if(Ft!==e){if(Ft)continue;pt=!1;break}if(yt){if(!xu(u,function(Ut,Vt){if(!is(yt,Vt)&&(Ct===Ut||C(Ct,Ut,_,D,I)))return yt.push(Vt)})){pt=!1;break}}else if(!(Ct===Rt||C(Ct,Rt,_,D,I))){pt=!1;break}}return I.delete(o),I.delete(u),pt}function dx(o,u,_,D,C,I,P){switch(_){case rt:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case st:return!(o.byteLength!=u.byteLength||!I(new Oo(o),new Oo(u)));case ae:case It:case $e:return Gr(+o,+u);case ce:return o.name==u.name&&o.message==u.message;case pn:case In:return o==u+"";case Jt:var k=Nu;case yr:var V=D&y;if(k||(k=Ao),o.size!=u.size&&!V)return!1;var tt=P.get(o);if(tt)return tt==u;D|=m,P.set(o,u);var et=Y0(k(o),k(u),D,C,I,P);return P.delete(o),et;case L:if(ls)return ls.call(o)==ls.call(u)}return!1}function px(o,u,_,D,C,I){var P=_&y,k=tl(o),V=k.length,tt=tl(u),et=tt.length;if(V!=et&&!P)return!1;for(var ot=V;ot--;){var pt=k[ot];if(!(P?pt in u:ue.call(u,pt)))return!1}var yt=I.get(o),Ct=I.get(u);if(yt&&Ct)return yt==u&&Ct==o;var Rt=!0;I.set(o,u),I.set(u,o);for(var Ft=P;++ot<V;){pt=k[ot];var Ut=o[pt],Vt=u[pt];if(D)var Cr=P?D(Vt,Ut,pt,u,o,I):D(Ut,Vt,pt,o,u,I);if(!(Cr===e?Ut===Vt||C(Ut,Vt,_,D,I):Cr)){Rt=!1;break}Ft||(Ft=pt=="constructor")}if(Rt&&!Ft){var ar=o.constructor,Fr=u.constructor;ar!=Fr&&"constructor"in o&&"constructor"in u&&!(typeof ar=="function"&&ar instanceof ar&&typeof Fr=="function"&&Fr instanceof Fr)&&(Rt=!1)}return I.delete(o),I.delete(u),Rt}function yn(o){return ul(X0(o,e,ad),o+"")}function tl(o){return h0(o,Ve,il)}function el(o){return h0(o,dr,Z0)}var rl=Ro?function(o){return Ro.get(o)}:Dl;function Jo(o){for(var u=o.name+"",_=zi[u],D=ue.call(zi,u)?_.length:0;D--;){var C=_[D],I=C.func;if(I==null||I==o)return C.name}return u}function Wi(o){var u=ue.call(O,"placeholder")?O:o;return u.placeholder}function At(){var o=O.iteratee||yl;return o=o===yl?_0:o,arguments.length?o(arguments[0],arguments[1]):o}function Xo(o,u){var _=o.__data__;return bx(u)?_[typeof u=="string"?"string":"hash"]:_.map}function nl(o){for(var u=Ve(o),_=u.length;_--;){var D=u[_],C=o[D];u[_]=[D,C,H0(C)]}return u}function ui(o,u){var _=AD(o,u);return p0(_)?_:e}function _x(o){var u=ue.call(o,ni),_=o[ni];try{o[ni]=e;var D=!0}catch{}var C=No.call(o);return D&&(u?o[ni]=_:delete o[ni]),C}var il=Ou?function(o){return o==null?[]:(o=de(o),Ln(Ou(o),function(u){return Qh.call(o,u)}))}:bl,Z0=Ou?function(o){for(var u=[];o;)Rn(u,il(o)),o=Bo(o);return u}:bl,rr=sr;(Bu&&rr(new Bu(new ArrayBuffer(1)))!=rt||os&&rr(new os)!=Jt||Iu&&rr(Iu.resolve())!=dn||Pi&&rr(new Pi)!=yr||as&&rr(new as)!=G)&&(rr=function(o){var u=sr(o),_=u==ze?o.constructor:e,D=_?li(_):"";if(D)switch(D){case JD:return rt;case XD:return Jt;case QD:return dn;case tb:return yr;case eb:return G}return u});function mx(o,u,_){for(var D=-1,C=_.length;++D<C;){var I=_[D],P=I.size;switch(I.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=er(u,o+P);break;case"takeRight":o=Ue(o,u-P);break}}return{start:o,end:u}}function gx(o){var u=o.match(eu);return u?u[1].split(ru):[]}function K0(o,u,_){u=Un(u,o);for(var D=-1,C=u.length,I=!1;++D<C;){var P=on(u[D]);if(!(I=o!=null&&_(o,P)))break;o=o[P]}return I||++D!=C?I:(C=o==null?0:o.length,!!C&&sa(C)&&wn(P,C)&&(Tt(o)||ci(o)))}function vx(o){var u=o.length,_=new o.constructor(u);return u&&typeof o[0]=="string"&&ue.call(o,"index")&&(_.index=o.index,_.input=o.input),_}function G0(o){return typeof o.constructor=="function"&&!ms(o)?ki(Bo(o)):{}}function yx(o,u,_){var D=o.constructor;switch(u){case st:return Ju(o);case ae:case It:return new D(+o);case rt:return rx(o,_);case ft:case ut:case ht:case at:case Xt:case ne:case be:case je:case ke:return O0(o,_);case Jt:return new D;case $e:case In:return new D(o);case pn:return nx(o);case yr:return new D;case L:return ix(o)}}function wx(o,u){var _=u.length;if(!_)return o;var D=_-1;return u[D]=(_>1?"& ":"")+u[D],u=u.join(_>2?", ":" "),o.replace(tu,`{
|
9
|
+
/* [wrapped with `+u+`] */
|
10
|
+
`)}function Dx(o){return Tt(o)||ci(o)||!!(t0&&o&&o[t0])}function wn(o,u){var _=typeof o;return u=u??Z,!!u&&(_=="number"||_!="symbol"&&fu.test(o))&&o>-1&&o%1==0&&o<u}function or(o,u,_){if(!Ce(_))return!1;var D=typeof u;return(D=="number"?hr(_)&&wn(u,_.length):D=="string"&&u in _)?Gr(_[u],o):!1}function sl(o,u){if(Tt(o))return!1;var _=typeof o;return _=="number"||_=="symbol"||_=="boolean"||o==null||Ar(o)?!0:Ha.test(o)||!Ga.test(o)||u!=null&&o in de(u)}function bx(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function ol(o){var u=Jo(o),_=O[u];if(typeof _!="function"||!(u in jt.prototype))return!1;if(o===_)return!0;var D=rl(_);return!!D&&o===D[0]}function xx(o){return!!Hh&&Hh in o}var Ex=Fo?Dn:xl;function ms(o){var u=o&&o.constructor,_=typeof u=="function"&&u.prototype||Ri;return o===_}function H0(o){return o===o&&!Ce(o)}function J0(o,u){return function(_){return _==null?!1:_[o]===u&&(u!==e||o in de(_))}}function Ax(o){var u=na(o,function(D){return _.size===h&&_.clear(),D}),_=u.cache;return u}function Cx(o,u){var _=o[1],D=u[1],C=_|D,I=C<(w|v|M),P=D==M&&_==b||D==M&&_==S&&o[7].length<=u[8]||D==(M|S)&&u[7].length<=u[8]&&_==b;if(!(I||P))return o;D&w&&(o[2]=u[2],C|=_&w?0:x);var k=u[3];if(k){var V=o[3];o[3]=V?I0(V,k,u[4]):k,o[4]=V?Pn(o[3],d):u[4]}return k=u[5],k&&(V=o[5],o[5]=V?T0(V,k,u[6]):k,o[6]=V?Pn(o[5],d):u[6]),k=u[7],k&&(o[7]=k),D&M&&(o[8]=o[8]==null?u[8]:er(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=C,o}function Fx(o){var u=[];if(o!=null)for(var _ in de(o))u.push(_);return u}function Mx(o){return No.call(o)}function X0(o,u,_){return u=Ue(u===e?o.length-1:u,0),function(){for(var D=arguments,C=-1,I=Ue(D.length-u,0),P=H(I);++C<I;)P[C]=D[u+C];C=-1;for(var k=H(u+1);++C<u;)k[C]=D[C];return k[u]=_(P),br(o,this,k)}}function Q0(o,u){return u.length<2?o:ai(o,Rr(u,0,-1))}function Nx(o,u){for(var _=o.length,D=er(u.length,_),C=fr(o);D--;){var I=u[D];o[D]=wn(I,_)?C[I]:e}return o}function al(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var td=rd(x0),gs=jD||function(o,u){return He.setTimeout(o,u)},ul=rd(Xb);function ed(o,u,_){var D=u+"";return ul(o,wx(D,Sx(gx(D),_)))}function rd(o){var u=0,_=0;return function(){var D=KD(),C=U-(D-_);if(_=D,C>0){if(++u>=R)return arguments[0]}else u=0;return o.apply(e,arguments)}}function Qo(o,u){var _=-1,D=o.length,C=D-1;for(u=u===e?D:u;++_<u;){var I=ju(_,C),P=o[I];o[I]=o[_],o[_]=P}return o.length=u,o}var nd=Ax(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(Ja,function(_,D,C,I){u.push(C?I.replace(su,"$1"):D||_)}),u});function on(o){if(typeof o=="string"||Ar(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function li(o){if(o!=null){try{return Mo.call(o)}catch{}try{return o+""}catch{}}return""}function Sx(o,u){return Ir(wt,function(_){var D="_."+_[0];u&_[1]&&!xo(o,D)&&o.push(D)}),o.sort()}function id(o){if(o instanceof jt)return o.clone();var u=new $r(o.__wrapped__,o.__chain__);return u.__actions__=fr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function Ox(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Ue(Lt(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var C=0,I=0,P=H($o(D/u));C<D;)P[I++]=Rr(o,C,C+=u);return P}function Bx(o){for(var u=-1,_=o==null?0:o.length,D=0,C=[];++u<_;){var I=o[u];I&&(C[D++]=I)}return C}function Ix(){var o=arguments.length;if(!o)return[];for(var u=H(o-1),_=arguments[0],D=o;D--;)u[D-1]=arguments[D];return Rn(Tt(_)?fr(_):[_],Je(u,1))}var Tx=Pt(function(o,u){return Oe(o)?fs(o,Je(u,1,Oe,!0)):[]}),$x=Pt(function(o,u){var _=Pr(u);return Oe(_)&&(_=e),Oe(o)?fs(o,Je(u,1,Oe,!0),At(_,2)):[]}),Lx=Pt(function(o,u){var _=Pr(u);return Oe(_)&&(_=e),Oe(o)?fs(o,Je(u,1,Oe,!0),e,_):[]});function Rx(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),Rr(o,u<0?0:u,D)):[]}function Px(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,0,u<0?0:u)):[]}function zx(o,u){return o&&o.length?Vo(o,At(u,3),!0,!0):[]}function kx(o,u){return o&&o.length?Vo(o,At(u,3),!0):[]}function qx(o,u,_,D){var C=o==null?0:o.length;return C?(_&&typeof _!="number"&&or(o,u,_)&&(_=0,D=C),Ib(o,u,_,D)):[]}function sd(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=Ue(D+C,0)),Eo(o,At(u,3),C)}function od(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D-1;return _!==e&&(C=Lt(_),C=_<0?Ue(D+C,0):er(C,D-1)),Eo(o,At(u,3),C,!0)}function ad(o){var u=o==null?0:o.length;return u?Je(o,1):[]}function Ux(o){var u=o==null?0:o.length;return u?Je(o,K):[]}function Wx(o,u){var _=o==null?0:o.length;return _?(u=u===e?1:Lt(u),Je(o,u)):[]}function jx(o){for(var u=-1,_=o==null?0:o.length,D={};++u<_;){var C=o[u];D[C[0]]=C[1]}return D}function ud(o){return o&&o.length?o[0]:e}function Vx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=Ue(D+C,0)),Ii(o,u,C)}function Yx(o){var u=o==null?0:o.length;return u?Rr(o,0,-1):[]}var Zx=Pt(function(o){var u=xe(o,Gu);return u.length&&u[0]===o[0]?zu(u):[]}),Kx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u===Pr(_)?u=e:_.pop(),_.length&&_[0]===o[0]?zu(_,At(u,2)):[]}),Gx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u=typeof u=="function"?u:e,u&&_.pop(),_.length&&_[0]===o[0]?zu(_,e,u):[]});function Hx(o,u){return o==null?"":YD.call(o,u)}function Pr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function Jx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D;return _!==e&&(C=Lt(_),C=C<0?Ue(D+C,0):er(C,D-1)),u===u?SD(o,u,C):Eo(o,Uh,C,!0)}function Xx(o,u){return o&&o.length?y0(o,Lt(u)):e}var Qx=Pt(ld);function ld(o,u){return o&&o.length&&u&&u.length?Wu(o,u):o}function tE(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,At(_,2)):o}function eE(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,e,_):o}var rE=yn(function(o,u){var _=o==null?0:o.length,D=$u(o,u);return b0(o,xe(u,function(C){return wn(C,_)?+C:C}).sort(B0)),D});function nE(o,u){var _=[];if(!(o&&o.length))return _;var D=-1,C=[],I=o.length;for(u=At(u,3);++D<I;){var P=o[D];u(P,D,o)&&(_.push(P),C.push(D))}return b0(o,C),_}function ll(o){return o==null?o:HD.call(o)}function iE(o,u,_){var D=o==null?0:o.length;return D?(_&&typeof _!="number"&&or(o,u,_)?(u=0,_=D):(u=u==null?0:Lt(u),_=_===e?D:Lt(_)),Rr(o,u,_)):[]}function sE(o,u){return jo(o,u)}function oE(o,u,_){return Yu(o,u,At(_,2))}function aE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u);if(D<_&&Gr(o[D],u))return D}return-1}function uE(o,u){return jo(o,u,!0)}function lE(o,u,_){return Yu(o,u,At(_,2),!0)}function cE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u,!0)-1;if(Gr(o[D],u))return D}return-1}function fE(o){return o&&o.length?E0(o):[]}function hE(o,u){return o&&o.length?E0(o,At(u,2)):[]}function dE(o){var u=o==null?0:o.length;return u?Rr(o,1,u):[]}function pE(o,u,_){return o&&o.length?(u=_||u===e?1:Lt(u),Rr(o,0,u<0?0:u)):[]}function _E(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,u<0?0:u,D)):[]}function mE(o,u){return o&&o.length?Vo(o,At(u,3),!1,!0):[]}function gE(o,u){return o&&o.length?Vo(o,At(u,3)):[]}var vE=Pt(function(o){return qn(Je(o,1,Oe,!0))}),yE=Pt(function(o){var u=Pr(o);return Oe(u)&&(u=e),qn(Je(o,1,Oe,!0),At(u,2))}),wE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,qn(Je(o,1,Oe,!0),e,u)});function DE(o){return o&&o.length?qn(o):[]}function bE(o,u){return o&&o.length?qn(o,At(u,2)):[]}function xE(o,u){return u=typeof u=="function"?u:e,o&&o.length?qn(o,e,u):[]}function cl(o){if(!(o&&o.length))return[];var u=0;return o=Ln(o,function(_){if(Oe(_))return u=Ue(_.length,u),!0}),Fu(u,function(_){return xe(o,Eu(_))})}function cd(o,u){if(!(o&&o.length))return[];var _=cl(o);return u==null?_:xe(_,function(D){return br(u,e,D)})}var EE=Pt(function(o,u){return Oe(o)?fs(o,u):[]}),AE=Pt(function(o){return Ku(Ln(o,Oe))}),CE=Pt(function(o){var u=Pr(o);return Oe(u)&&(u=e),Ku(Ln(o,Oe),At(u,2))}),FE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,Ku(Ln(o,Oe),e,u)}),ME=Pt(cl);function NE(o,u){return M0(o||[],u||[],cs)}function SE(o,u){return M0(o||[],u||[],ps)}var OE=Pt(function(o){var u=o.length,_=u>1?o[u-1]:e;return _=typeof _=="function"?(o.pop(),_):e,cd(o,_)});function fd(o){var u=O(o);return u.__chain__=!0,u}function BE(o,u){return u(o),o}function ta(o,u){return u(o)}var IE=yn(function(o){var u=o.length,_=u?o[0]:0,D=this.__wrapped__,C=function(I){return $u(I,o)};return u>1||this.__actions__.length||!(D instanceof jt)||!wn(_)?this.thru(C):(D=D.slice(_,+_+(u?1:0)),D.__actions__.push({func:ta,args:[C],thisArg:e}),new $r(D,this.__chain__).thru(function(I){return u&&!I.length&&I.push(e),I}))});function TE(){return fd(this)}function $E(){return new $r(this.value(),this.__chain__)}function LE(){this.__values__===e&&(this.__values__=Ad(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function RE(){return this}function PE(o){for(var u,_=this;_ instanceof zo;){var D=id(_);D.__index__=0,D.__values__=e,u?C.__wrapped__=D:u=D;var C=D;_=_.__wrapped__}return C.__wrapped__=o,u}function zE(){var o=this.__wrapped__;if(o instanceof jt){var u=o;return this.__actions__.length&&(u=new jt(this)),u=u.reverse(),u.__actions__.push({func:ta,args:[ll],thisArg:e}),new $r(u,this.__chain__)}return this.thru(ll)}function kE(){return F0(this.__wrapped__,this.__actions__)}var qE=Yo(function(o,u,_){ue.call(o,_)?++o[_]:gn(o,_,1)});function UE(o,u,_){var D=Tt(o)?kh:Bb;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}function WE(o,u){var _=Tt(o)?Ln:c0;return _(o,At(u,3))}var jE=P0(sd),VE=P0(od);function YE(o,u){return Je(ea(o,u),1)}function ZE(o,u){return Je(ea(o,u),K)}function KE(o,u,_){return _=_===e?1:Lt(_),Je(ea(o,u),_)}function hd(o,u){var _=Tt(o)?Ir:kn;return _(o,At(u,3))}function dd(o,u){var _=Tt(o)?dD:l0;return _(o,At(u,3))}var GE=Yo(function(o,u,_){ue.call(o,_)?o[_].push(u):gn(o,_,[u])});function HE(o,u,_,D){o=hr(o)?o:Vi(o),_=_&&!D?Lt(_):0;var C=o.length;return _<0&&(_=Ue(C+_,0)),oa(o)?_<=C&&o.indexOf(u,_)>-1:!!C&&Ii(o,u,_)>-1}var JE=Pt(function(o,u,_){var D=-1,C=typeof u=="function",I=hr(o)?H(o.length):[];return kn(o,function(P){I[++D]=C?br(u,P,_):hs(P,u,_)}),I}),XE=Yo(function(o,u,_){gn(o,_,u)});function ea(o,u){var _=Tt(o)?xe:m0;return _(o,At(u,3))}function QE(o,u,_,D){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),_=D?e:_,Tt(_)||(_=_==null?[]:[_]),w0(o,u,_))}var tA=Yo(function(o,u,_){o[_?0:1].push(u)},function(){return[[],[]]});function eA(o,u,_){var D=Tt(o)?bu:jh,C=arguments.length<3;return D(o,At(u,4),_,C,kn)}function rA(o,u,_){var D=Tt(o)?pD:jh,C=arguments.length<3;return D(o,At(u,4),_,C,l0)}function nA(o,u){var _=Tt(o)?Ln:c0;return _(o,ia(At(u,3)))}function iA(o){var u=Tt(o)?s0:Hb;return u(o)}function sA(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Lt(u);var D=Tt(o)?Fb:Jb;return D(o,u)}function oA(o){var u=Tt(o)?Mb:Qb;return u(o)}function aA(o){if(o==null)return 0;if(hr(o))return oa(o)?$i(o):o.length;var u=rr(o);return u==Jt||u==yr?o.size:qu(o).length}function uA(o,u,_){var D=Tt(o)?xu:tx;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}var lA=Pt(function(o,u){if(o==null)return[];var _=u.length;return _>1&&or(o,u[0],u[1])?u=[]:_>2&&or(u[0],u[1],u[2])&&(u=[u[0]]),w0(o,Je(u,1),[])}),ra=WD||function(){return He.Date.now()};function cA(o,u){if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){if(--o<1)return u.apply(this,arguments)}}function pd(o,u,_){return u=_?e:u,u=o&&u==null?o.length:u,vn(o,M,e,e,e,e,u)}function _d(o,u){var _;if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){return--o>0&&(_=u.apply(this,arguments)),o<=1&&(u=e),_}}var fl=Pt(function(o,u,_){var D=w;if(_.length){var C=Pn(_,Wi(fl));D|=E}return vn(o,D,u,_,C)}),md=Pt(function(o,u,_){var D=w|v;if(_.length){var C=Pn(_,Wi(md));D|=E}return vn(u,D,o,_,C)});function gd(o,u,_){u=_?e:u;var D=vn(o,b,e,e,e,e,e,u);return D.placeholder=gd.placeholder,D}function vd(o,u,_){u=_?e:u;var D=vn(o,N,e,e,e,e,e,u);return D.placeholder=vd.placeholder,D}function yd(o,u,_){var D,C,I,P,k,V,tt=0,et=!1,ot=!1,pt=!0;if(typeof o!="function")throw new Tr(a);u=zr(u)||0,Ce(_)&&(et=!!_.leading,ot="maxWait"in _,I=ot?Ue(zr(_.maxWait)||0,u):I,pt="trailing"in _?!!_.trailing:pt);function yt(Be){var Hr=D,xn=C;return D=C=e,tt=Be,P=o.apply(xn,Hr),P}function Ct(Be){return tt=Be,k=gs(Ut,u),et?yt(Be):P}function Rt(Be){var Hr=Be-V,xn=Be-tt,Pd=u-Hr;return ot?er(Pd,I-xn):Pd}function Ft(Be){var Hr=Be-V,xn=Be-tt;return V===e||Hr>=u||Hr<0||ot&&xn>=I}function Ut(){var Be=ra();if(Ft(Be))return Vt(Be);k=gs(Ut,Rt(Be))}function Vt(Be){return k=e,pt&&D?yt(Be):(D=C=e,P)}function Cr(){k!==e&&N0(k),tt=0,D=V=C=k=e}function ar(){return k===e?P:Vt(ra())}function Fr(){var Be=ra(),Hr=Ft(Be);if(D=arguments,C=this,V=Be,Hr){if(k===e)return Ct(V);if(ot)return N0(k),k=gs(Ut,u),yt(V)}return k===e&&(k=gs(Ut,u)),P}return Fr.cancel=Cr,Fr.flush=ar,Fr}var fA=Pt(function(o,u){return u0(o,1,u)}),hA=Pt(function(o,u,_){return u0(o,zr(u)||0,_)});function dA(o){return vn(o,T)}function na(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new Tr(a);var _=function(){var D=arguments,C=u?u.apply(this,D):D[0],I=_.cache;if(I.has(C))return I.get(C);var P=o.apply(this,D);return _.cache=I.set(C,P)||I,P};return _.cache=new(na.Cache||mn),_}na.Cache=mn;function ia(o){if(typeof o!="function")throw new Tr(a);return function(){var u=arguments;switch(u.length){case 0:return!o.call(this);case 1:return!o.call(this,u[0]);case 2:return!o.call(this,u[0],u[1]);case 3:return!o.call(this,u[0],u[1],u[2])}return!o.apply(this,u)}}function pA(o){return _d(2,o)}var _A=ex(function(o,u){u=u.length==1&&Tt(u[0])?xe(u[0],xr(At())):xe(Je(u,1),xr(At()));var _=u.length;return Pt(function(D){for(var C=-1,I=er(D.length,_);++C<I;)D[C]=u[C].call(this,D[C]);return br(o,this,D)})}),hl=Pt(function(o,u){var _=Pn(u,Wi(hl));return vn(o,E,e,u,_)}),wd=Pt(function(o,u){var _=Pn(u,Wi(wd));return vn(o,A,e,u,_)}),mA=yn(function(o,u){return vn(o,S,e,e,e,u)});function gA(o,u){if(typeof o!="function")throw new Tr(a);return u=u===e?u:Lt(u),Pt(o,u)}function vA(o,u){if(typeof o!="function")throw new Tr(a);return u=u==null?0:Ue(Lt(u),0),Pt(function(_){var D=_[u],C=Wn(_,0,u);return D&&Rn(C,D),br(o,this,C)})}function yA(o,u,_){var D=!0,C=!0;if(typeof o!="function")throw new Tr(a);return Ce(_)&&(D="leading"in _?!!_.leading:D,C="trailing"in _?!!_.trailing:C),yd(o,u,{leading:D,maxWait:u,trailing:C})}function wA(o){return pd(o,1)}function DA(o,u){return hl(Hu(u),o)}function bA(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function xA(o){return Lr(o,g)}function EA(o,u){return u=typeof u=="function"?u:e,Lr(o,g,u)}function AA(o){return Lr(o,f|g)}function CA(o,u){return u=typeof u=="function"?u:e,Lr(o,f|g,u)}function FA(o,u){return u==null||a0(o,u,Ve(u))}function Gr(o,u){return o===u||o!==o&&u!==u}var MA=Ho(Pu),NA=Ho(function(o,u){return o>=u}),ci=d0(function(){return arguments}())?d0:function(o){return Me(o)&&ue.call(o,"callee")&&!Qh.call(o,"callee")},Tt=H.isArray,SA=Th?xr(Th):Pb;function hr(o){return o!=null&&sa(o.length)&&!Dn(o)}function Oe(o){return Me(o)&&hr(o)}function OA(o){return o===!0||o===!1||Me(o)&&sr(o)==ae}var jn=VD||xl,BA=$h?xr($h):zb;function IA(o){return Me(o)&&o.nodeType===1&&!vs(o)}function TA(o){if(o==null)return!0;if(hr(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||jn(o)||ji(o)||ci(o)))return!o.length;var u=rr(o);if(u==Jt||u==yr)return!o.size;if(ms(o))return!qu(o).length;for(var _ in o)if(ue.call(o,_))return!1;return!0}function $A(o,u){return ds(o,u)}function LA(o,u,_){_=typeof _=="function"?_:e;var D=_?_(o,u):e;return D===e?ds(o,u,e,_):!!D}function dl(o){if(!Me(o))return!1;var u=sr(o);return u==ce||u==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!vs(o)}function RA(o){return typeof o=="number"&&e0(o)}function Dn(o){if(!Ce(o))return!1;var u=sr(o);return u==re||u==qt||u==xt||u==Bn}function Dd(o){return typeof o=="number"&&o==Lt(o)}function sa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Ce(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Me(o){return o!=null&&typeof o=="object"}var bd=Lh?xr(Lh):qb;function PA(o,u){return o===u||ku(o,u,nl(u))}function zA(o,u,_){return _=typeof _=="function"?_:e,ku(o,u,nl(u),_)}function kA(o){return xd(o)&&o!=+o}function qA(o){if(Ex(o))throw new Bt(i);return p0(o)}function UA(o){return o===null}function WA(o){return o==null}function xd(o){return typeof o=="number"||Me(o)&&sr(o)==$e}function vs(o){if(!Me(o)||sr(o)!=ze)return!1;var u=Bo(o);if(u===null)return!0;var _=ue.call(u,"constructor")&&u.constructor;return typeof _=="function"&&_ instanceof _&&Mo.call(_)==zD}var pl=Rh?xr(Rh):Ub;function jA(o){return Dd(o)&&o>=-Z&&o<=Z}var Ed=Ph?xr(Ph):Wb;function oa(o){return typeof o=="string"||!Tt(o)&&Me(o)&&sr(o)==In}function Ar(o){return typeof o=="symbol"||Me(o)&&sr(o)==L}var ji=zh?xr(zh):jb;function VA(o){return o===e}function YA(o){return Me(o)&&rr(o)==G}function ZA(o){return Me(o)&&sr(o)==nt}var KA=Ho(Uu),GA=Ho(function(o,u){return o<=u});function Ad(o){if(!o)return[];if(hr(o))return oa(o)?Zr(o):fr(o);if(ss&&o[ss])return FD(o[ss]());var u=rr(o),_=u==Jt?Nu:u==yr?Ao:Vi;return _(o)}function bn(o){if(!o)return o===0?o:0;if(o=zr(o),o===K||o===-K){var u=o<0?-1:1;return u*X}return o===o?o:0}function Lt(o){var u=bn(o),_=u%1;return u===u?_?u-_:u:0}function Cd(o){return o?oi(Lt(o),0,ct):0}function zr(o){if(typeof o=="number")return o;if(Ar(o))return Q;if(Ce(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Ce(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=Vh(o);var _=uu.test(o);return _||cu.test(o)?cD(o.slice(2),_?2:8):au.test(o)?Q:+o}function Fd(o){return sn(o,dr(o))}function HA(o){return o?oi(Lt(o),-Z,Z):o===0?o:0}function ie(o){return o==null?"":Er(o)}var JA=qi(function(o,u){if(ms(u)||hr(u)){sn(u,Ve(u),o);return}for(var _ in u)ue.call(u,_)&&cs(o,_,u[_])}),Md=qi(function(o,u){sn(u,dr(u),o)}),aa=qi(function(o,u,_,D){sn(u,dr(u),o,D)}),XA=qi(function(o,u,_,D){sn(u,Ve(u),o,D)}),QA=yn($u);function tC(o,u){var _=ki(o);return u==null?_:o0(_,u)}var eC=Pt(function(o,u){o=de(o);var _=-1,D=u.length,C=D>2?u[2]:e;for(C&&or(u[0],u[1],C)&&(D=1);++_<D;)for(var I=u[_],P=dr(I),k=-1,V=P.length;++k<V;){var tt=P[k],et=o[tt];(et===e||Gr(et,Ri[tt])&&!ue.call(o,tt))&&(o[tt]=I[tt])}return o}),rC=Pt(function(o){return o.push(e,V0),br(Nd,e,o)});function nC(o,u){return qh(o,At(u,3),nn)}function iC(o,u){return qh(o,At(u,3),Ru)}function sC(o,u){return o==null?o:Lu(o,At(u,3),dr)}function oC(o,u){return o==null?o:f0(o,At(u,3),dr)}function aC(o,u){return o&&nn(o,At(u,3))}function uC(o,u){return o&&Ru(o,At(u,3))}function lC(o){return o==null?[]:Uo(o,Ve(o))}function cC(o){return o==null?[]:Uo(o,dr(o))}function _l(o,u,_){var D=o==null?e:ai(o,u);return D===e?_:D}function fC(o,u){return o!=null&&K0(o,u,Tb)}function ml(o,u){return o!=null&&K0(o,u,$b)}var hC=k0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),o[u]=_},vl(pr)),dC=k0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),ue.call(o,u)?o[u].push(_):o[u]=[_]},At),pC=Pt(hs);function Ve(o){return hr(o)?i0(o):qu(o)}function dr(o){return hr(o)?i0(o,!0):Vb(o)}function _C(o,u){var _={};return u=At(u,3),nn(o,function(D,C,I){gn(_,u(D,C,I),D)}),_}function mC(o,u){var _={};return u=At(u,3),nn(o,function(D,C,I){gn(_,C,u(D,C,I))}),_}var gC=qi(function(o,u,_){Wo(o,u,_)}),Nd=qi(function(o,u,_,D){Wo(o,u,_,D)}),vC=yn(function(o,u){var _={};if(o==null)return _;var D=!1;u=xe(u,function(I){return I=Un(I,o),D||(D=I.length>1),I}),sn(o,el(o),_),D&&(_=Lr(_,f|p|g,hx));for(var C=u.length;C--;)Zu(_,u[C]);return _});function yC(o,u){return Sd(o,ia(At(u)))}var wC=yn(function(o,u){return o==null?{}:Zb(o,u)});function Sd(o,u){if(o==null)return{};var _=xe(el(o),function(D){return[D]});return u=At(u),D0(o,_,function(D,C){return u(D,C[0])})}function DC(o,u,_){u=Un(u,o);var D=-1,C=u.length;for(C||(C=1,o=e);++D<C;){var I=o==null?e:o[on(u[D])];I===e&&(D=C,I=_),o=Dn(I)?I.call(o):I}return o}function bC(o,u,_){return o==null?o:ps(o,u,_)}function xC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:ps(o,u,_,D)}var Od=W0(Ve),Bd=W0(dr);function EC(o,u,_){var D=Tt(o),C=D||jn(o)||ji(o);if(u=At(u,4),_==null){var I=o&&o.constructor;C?_=D?new I:[]:Ce(o)?_=Dn(I)?ki(Bo(o)):{}:_={}}return(C?Ir:nn)(o,function(P,k,V){return u(_,P,k,V)}),_}function AC(o,u){return o==null?!0:Zu(o,u)}function CC(o,u,_){return o==null?o:C0(o,u,Hu(_))}function FC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:C0(o,u,Hu(_),D)}function Vi(o){return o==null?[]:Mu(o,Ve(o))}function MC(o){return o==null?[]:Mu(o,dr(o))}function NC(o,u,_){return _===e&&(_=u,u=e),_!==e&&(_=zr(_),_=_===_?_:0),u!==e&&(u=zr(u),u=u===u?u:0),oi(zr(o),u,_)}function SC(o,u,_){return u=bn(u),_===e?(_=u,u=0):_=bn(_),o=zr(o),Lb(o,u,_)}function OC(o,u,_){if(_&&typeof _!="boolean"&&or(o,u,_)&&(u=_=e),_===e&&(typeof u=="boolean"?(_=u,u=e):typeof o=="boolean"&&(_=o,o=e)),o===e&&u===e?(o=0,u=1):(o=bn(o),u===e?(u=o,o=0):u=bn(u)),o>u){var D=o;o=u,u=D}if(_||o%1||u%1){var C=r0();return er(o+C*(u-o+lD("1e-"+((C+"").length-1))),u)}return ju(o,u)}var BC=Ui(function(o,u,_){return u=u.toLowerCase(),o+(_?Id(u):u)});function Id(o){return gl(ie(o).toLowerCase())}function Td(o){return o=ie(o),o&&o.replace(hu,bD).replace(Qw,"")}function IC(o,u,_){o=ie(o),u=Er(u);var D=o.length;_=_===e?D:oi(Lt(_),0,D);var C=_;return _-=u.length,_>=0&&o.slice(_,C)==u}function TC(o){return o=ie(o),o&&Ya.test(o)?o.replace(vo,xD):o}function $C(o){return o=ie(o),o&&Xa.test(o)?o.replace(rs,"\\$&"):o}var LC=Ui(function(o,u,_){return o+(_?"-":"")+u.toLowerCase()}),RC=Ui(function(o,u,_){return o+(_?" ":"")+u.toLowerCase()}),PC=R0("toLowerCase");function zC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;if(!u||D>=u)return o;var C=(u-D)/2;return Go(Lo(C),_)+o+Go($o(C),_)}function kC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?o+Go(u-D,_):o}function qC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?Go(u-D,_)+o:o}function UC(o,u,_){return _||u==null?u=0:u&&(u=+u),GD(ie(o).replace(ns,""),u||0)}function WC(o,u,_){return(_?or(o,u,_):u===e)?u=1:u=Lt(u),Vu(ie(o),u)}function jC(){var o=arguments,u=ie(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var VC=Ui(function(o,u,_){return o+(_?"_":"")+u.toLowerCase()});function YC(o,u,_){return _&&typeof _!="number"&&or(o,u,_)&&(u=_=e),_=_===e?ct:_>>>0,_?(o=ie(o),o&&(typeof u=="string"||u!=null&&!pl(u))&&(u=Er(u),!u&&Ti(o))?Wn(Zr(o),0,_):o.split(u,_)):[]}var ZC=Ui(function(o,u,_){return o+(_?" ":"")+gl(u)});function KC(o,u,_){return o=ie(o),_=_==null?0:oi(Lt(_),0,o.length),u=Er(u),o.slice(_,_+u.length)==u}function GC(o,u,_){var D=O.templateSettings;_&&or(o,u,_)&&(u=e),o=ie(o),u=aa({},u,D,j0);var C=aa({},u.imports,D.imports,j0),I=Ve(C),P=Mu(C,I),k,V,tt=0,et=u.interpolate||Si,ot="__p += '",pt=Su((u.escape||Si).source+"|"+et.source+"|"+(et===yo?ou:Si).source+"|"+(u.evaluate||Si).source+"|$","g"),yt="//# sourceURL="+(ue.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++iD+"]")+`
|
11
|
+
`;o.replace(pt,function(Ft,Ut,Vt,Cr,ar,Fr){return Vt||(Vt=Cr),ot+=o.slice(tt,Fr).replace(ei,ED),Ut&&(k=!0,ot+=`' +
|
12
|
+
__e(`+Ut+`) +
|
13
|
+
'`),ar&&(V=!0,ot+=`';
|
14
|
+
`+ar+`;
|
15
|
+
__p += '`),Vt&&(ot+=`' +
|
16
|
+
((__t = (`+Vt+`)) == null ? '' : __t) +
|
17
|
+
'`),tt=Fr+Ft.length,Ft}),ot+=`';
|
18
|
+
`;var Ct=ue.call(u,"variable")&&u.variable;if(!Ct)ot=`with (obj) {
|
19
|
+
`+ot+`
|
20
|
+
}
|
21
|
+
`;else if(iu.test(Ct))throw new Bt(l);ot=(V?ot.replace(wr,""):ot).replace(Dr,"$1").replace(Tn,"$1;"),ot="function("+(Ct||"obj")+`) {
|
22
|
+
`+(Ct?"":`obj || (obj = {});
|
23
|
+
`)+"var __t, __p = ''"+(k?", __e = _.escape":"")+(V?`, __j = Array.prototype.join;
|
24
|
+
function print() { __p += __j.call(arguments, '') }
|
25
|
+
`:`;
|
26
|
+
`)+ot+`return __p
|
27
|
+
}`;var Rt=Ld(function(){return te(I,yt+"return "+ot).apply(e,P)});if(Rt.source=ot,dl(Rt))throw Rt;return Rt}function HC(o){return ie(o).toLowerCase()}function JC(o){return ie(o).toUpperCase()}function XC(o,u,_){if(o=ie(o),o&&(_||u===e))return Vh(o);if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Zr(u),I=Yh(D,C),P=Zh(D,C)+1;return Wn(D,I,P).join("")}function QC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.slice(0,Gh(o)+1);if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Zh(D,Zr(u))+1;return Wn(D,0,C).join("")}function tF(o,u,_){if(o=ie(o),o&&(_||u===e))return o.replace(ns,"");if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Yh(D,Zr(u));return Wn(D,C).join("")}function eF(o,u){var _=F,D=B;if(Ce(u)){var C="separator"in u?u.separator:C;_="length"in u?Lt(u.length):_,D="omission"in u?Er(u.omission):D}o=ie(o);var I=o.length;if(Ti(o)){var P=Zr(o);I=P.length}if(_>=I)return o;var k=_-$i(D);if(k<1)return D;var V=P?Wn(P,0,k).join(""):o.slice(0,k);if(C===e)return V+D;if(P&&(k+=V.length-k),pl(C)){if(o.slice(k).search(C)){var tt,et=V;for(C.global||(C=Su(C.source,ie(wo.exec(C))+"g")),C.lastIndex=0;tt=C.exec(et);)var ot=tt.index;V=V.slice(0,ot===e?k:ot)}}else if(o.indexOf(Er(C),k)!=k){var pt=V.lastIndexOf(C);pt>-1&&(V=V.slice(0,pt))}return V+D}function rF(o){return o=ie(o),o&&Va.test(o)?o.replace(ti,OD):o}var nF=Ui(function(o,u,_){return o+(_?" ":"")+u.toUpperCase()}),gl=R0("toUpperCase");function $d(o,u,_){return o=ie(o),u=_?e:u,u===e?CD(o)?TD(o):gD(o):o.match(u)||[]}var Ld=Pt(function(o,u){try{return br(o,e,u)}catch(_){return dl(_)?_:new Bt(_)}}),iF=yn(function(o,u){return Ir(u,function(_){_=on(_),gn(o,_,fl(o[_],o))}),o});function sF(o){var u=o==null?0:o.length,_=At();return o=u?xe(o,function(D){if(typeof D[1]!="function")throw new Tr(a);return[_(D[0]),D[1]]}):[],Pt(function(D){for(var C=-1;++C<u;){var I=o[C];if(br(I[0],this,D))return br(I[1],this,D)}})}function oF(o){return Ob(Lr(o,f))}function vl(o){return function(){return o}}function aF(o,u){return o==null||o!==o?u:o}var uF=z0(),lF=z0(!0);function pr(o){return o}function yl(o){return _0(typeof o=="function"?o:Lr(o,f))}function cF(o){return g0(Lr(o,f))}function fF(o,u){return v0(o,Lr(u,f))}var hF=Pt(function(o,u){return function(_){return hs(_,o,u)}}),dF=Pt(function(o,u){return function(_){return hs(o,_,u)}});function wl(o,u,_){var D=Ve(u),C=Uo(u,D);_==null&&!(Ce(u)&&(C.length||!D.length))&&(_=u,u=o,o=this,C=Uo(u,Ve(u)));var I=!(Ce(_)&&"chain"in _)||!!_.chain,P=Dn(o);return Ir(C,function(k){var V=u[k];o[k]=V,P&&(o.prototype[k]=function(){var tt=this.__chain__;if(I||tt){var et=o(this.__wrapped__),ot=et.__actions__=fr(this.__actions__);return ot.push({func:V,args:arguments,thisArg:o}),et.__chain__=tt,et}return V.apply(o,Rn([this.value()],arguments))})}),o}function pF(){return He._===this&&(He._=kD),this}function Dl(){}function _F(o){return o=Lt(o),Pt(function(u){return y0(u,o)})}var mF=Xu(xe),gF=Xu(kh),vF=Xu(xu);function Rd(o){return sl(o)?Eu(on(o)):Kb(o)}function yF(o){return function(u){return o==null?e:ai(o,u)}}var wF=q0(),DF=q0(!0);function bl(){return[]}function xl(){return!1}function bF(){return{}}function xF(){return""}function EF(){return!0}function AF(o,u){if(o=Lt(o),o<1||o>Z)return[];var _=ct,D=er(o,ct);u=At(u),o-=ct;for(var C=Fu(D,u);++_<o;)u(_);return C}function CF(o){return Tt(o)?xe(o,on):Ar(o)?[o]:fr(nd(ie(o)))}function FF(o){var u=++PD;return ie(o)+u}var MF=Ko(function(o,u){return o+u},0),NF=Qu("ceil"),SF=Ko(function(o,u){return o/u},1),OF=Qu("floor");function BF(o){return o&&o.length?qo(o,pr,Pu):e}function IF(o,u){return o&&o.length?qo(o,At(u,2),Pu):e}function TF(o){return Wh(o,pr)}function $F(o,u){return Wh(o,At(u,2))}function LF(o){return o&&o.length?qo(o,pr,Uu):e}function RF(o,u){return o&&o.length?qo(o,At(u,2),Uu):e}var PF=Ko(function(o,u){return o*u},1),zF=Qu("round"),kF=Ko(function(o,u){return o-u},0);function qF(o){return o&&o.length?Cu(o,pr):0}function UF(o,u){return o&&o.length?Cu(o,At(u,2)):0}return O.after=cA,O.ary=pd,O.assign=JA,O.assignIn=Md,O.assignInWith=aa,O.assignWith=XA,O.at=QA,O.before=_d,O.bind=fl,O.bindAll=iF,O.bindKey=md,O.castArray=bA,O.chain=fd,O.chunk=Ox,O.compact=Bx,O.concat=Ix,O.cond=sF,O.conforms=oF,O.constant=vl,O.countBy=qE,O.create=tC,O.curry=gd,O.curryRight=vd,O.debounce=yd,O.defaults=eC,O.defaultsDeep=rC,O.defer=fA,O.delay=hA,O.difference=Tx,O.differenceBy=$x,O.differenceWith=Lx,O.drop=Rx,O.dropRight=Px,O.dropRightWhile=zx,O.dropWhile=kx,O.fill=qx,O.filter=WE,O.flatMap=YE,O.flatMapDeep=ZE,O.flatMapDepth=KE,O.flatten=ad,O.flattenDeep=Ux,O.flattenDepth=Wx,O.flip=dA,O.flow=uF,O.flowRight=lF,O.fromPairs=jx,O.functions=lC,O.functionsIn=cC,O.groupBy=GE,O.initial=Yx,O.intersection=Zx,O.intersectionBy=Kx,O.intersectionWith=Gx,O.invert=hC,O.invertBy=dC,O.invokeMap=JE,O.iteratee=yl,O.keyBy=XE,O.keys=Ve,O.keysIn=dr,O.map=ea,O.mapKeys=_C,O.mapValues=mC,O.matches=cF,O.matchesProperty=fF,O.memoize=na,O.merge=gC,O.mergeWith=Nd,O.method=hF,O.methodOf=dF,O.mixin=wl,O.negate=ia,O.nthArg=_F,O.omit=vC,O.omitBy=yC,O.once=pA,O.orderBy=QE,O.over=mF,O.overArgs=_A,O.overEvery=gF,O.overSome=vF,O.partial=hl,O.partialRight=wd,O.partition=tA,O.pick=wC,O.pickBy=Sd,O.property=Rd,O.propertyOf=yF,O.pull=Qx,O.pullAll=ld,O.pullAllBy=tE,O.pullAllWith=eE,O.pullAt=rE,O.range=wF,O.rangeRight=DF,O.rearg=mA,O.reject=nA,O.remove=nE,O.rest=gA,O.reverse=ll,O.sampleSize=sA,O.set=bC,O.setWith=xC,O.shuffle=oA,O.slice=iE,O.sortBy=lA,O.sortedUniq=fE,O.sortedUniqBy=hE,O.split=YC,O.spread=vA,O.tail=dE,O.take=pE,O.takeRight=_E,O.takeRightWhile=mE,O.takeWhile=gE,O.tap=BE,O.throttle=yA,O.thru=ta,O.toArray=Ad,O.toPairs=Od,O.toPairsIn=Bd,O.toPath=CF,O.toPlainObject=Fd,O.transform=EC,O.unary=wA,O.union=vE,O.unionBy=yE,O.unionWith=wE,O.uniq=DE,O.uniqBy=bE,O.uniqWith=xE,O.unset=AC,O.unzip=cl,O.unzipWith=cd,O.update=CC,O.updateWith=FC,O.values=Vi,O.valuesIn=MC,O.without=EE,O.words=$d,O.wrap=DA,O.xor=AE,O.xorBy=CE,O.xorWith=FE,O.zip=ME,O.zipObject=NE,O.zipObjectDeep=SE,O.zipWith=OE,O.entries=Od,O.entriesIn=Bd,O.extend=Md,O.extendWith=aa,wl(O,O),O.add=MF,O.attempt=Ld,O.camelCase=BC,O.capitalize=Id,O.ceil=NF,O.clamp=NC,O.clone=xA,O.cloneDeep=AA,O.cloneDeepWith=CA,O.cloneWith=EA,O.conformsTo=FA,O.deburr=Td,O.defaultTo=aF,O.divide=SF,O.endsWith=IC,O.eq=Gr,O.escape=TC,O.escapeRegExp=$C,O.every=UE,O.find=jE,O.findIndex=sd,O.findKey=nC,O.findLast=VE,O.findLastIndex=od,O.findLastKey=iC,O.floor=OF,O.forEach=hd,O.forEachRight=dd,O.forIn=sC,O.forInRight=oC,O.forOwn=aC,O.forOwnRight=uC,O.get=_l,O.gt=MA,O.gte=NA,O.has=fC,O.hasIn=ml,O.head=ud,O.identity=pr,O.includes=HE,O.indexOf=Vx,O.inRange=SC,O.invoke=pC,O.isArguments=ci,O.isArray=Tt,O.isArrayBuffer=SA,O.isArrayLike=hr,O.isArrayLikeObject=Oe,O.isBoolean=OA,O.isBuffer=jn,O.isDate=BA,O.isElement=IA,O.isEmpty=TA,O.isEqual=$A,O.isEqualWith=LA,O.isError=dl,O.isFinite=RA,O.isFunction=Dn,O.isInteger=Dd,O.isLength=sa,O.isMap=bd,O.isMatch=PA,O.isMatchWith=zA,O.isNaN=kA,O.isNative=qA,O.isNil=WA,O.isNull=UA,O.isNumber=xd,O.isObject=Ce,O.isObjectLike=Me,O.isPlainObject=vs,O.isRegExp=pl,O.isSafeInteger=jA,O.isSet=Ed,O.isString=oa,O.isSymbol=Ar,O.isTypedArray=ji,O.isUndefined=VA,O.isWeakMap=YA,O.isWeakSet=ZA,O.join=Hx,O.kebabCase=LC,O.last=Pr,O.lastIndexOf=Jx,O.lowerCase=RC,O.lowerFirst=PC,O.lt=KA,O.lte=GA,O.max=BF,O.maxBy=IF,O.mean=TF,O.meanBy=$F,O.min=LF,O.minBy=RF,O.stubArray=bl,O.stubFalse=xl,O.stubObject=bF,O.stubString=xF,O.stubTrue=EF,O.multiply=PF,O.nth=Xx,O.noConflict=pF,O.noop=Dl,O.now=ra,O.pad=zC,O.padEnd=kC,O.padStart=qC,O.parseInt=UC,O.random=OC,O.reduce=eA,O.reduceRight=rA,O.repeat=WC,O.replace=jC,O.result=DC,O.round=zF,O.runInContext=j,O.sample=iA,O.size=aA,O.snakeCase=VC,O.some=uA,O.sortedIndex=sE,O.sortedIndexBy=oE,O.sortedIndexOf=aE,O.sortedLastIndex=uE,O.sortedLastIndexBy=lE,O.sortedLastIndexOf=cE,O.startCase=ZC,O.startsWith=KC,O.subtract=kF,O.sum=qF,O.sumBy=UF,O.template=GC,O.times=AF,O.toFinite=bn,O.toInteger=Lt,O.toLength=Cd,O.toLower=HC,O.toNumber=zr,O.toSafeInteger=HA,O.toString=ie,O.toUpper=JC,O.trim=XC,O.trimEnd=QC,O.trimStart=tF,O.truncate=eF,O.unescape=rF,O.uniqueId=FF,O.upperCase=nF,O.upperFirst=gl,O.each=hd,O.eachRight=dd,O.first=ud,wl(O,function(){var o={};return nn(O,function(u,_){ue.call(O.prototype,_)||(o[_]=u)}),o}(),{chain:!1}),O.VERSION=r,Ir(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){O[o].placeholder=O}),Ir(["drop","take"],function(o,u){jt.prototype[o]=function(_){_=_===e?1:Ue(Lt(_),0);var D=this.__filtered__&&!u?new jt(this):this.clone();return D.__filtered__?D.__takeCount__=er(_,D.__takeCount__):D.__views__.push({size:er(_,ct),type:o+(D.__dir__<0?"Right":"")}),D},jt.prototype[o+"Right"]=function(_){return this.reverse()[o](_).reverse()}}),Ir(["filter","map","takeWhile"],function(o,u){var _=u+1,D=_==q||_==z;jt.prototype[o]=function(C){var I=this.clone();return I.__iteratees__.push({iteratee:At(C,3),type:_}),I.__filtered__=I.__filtered__||D,I}}),Ir(["head","last"],function(o,u){var _="take"+(u?"Right":"");jt.prototype[o]=function(){return this[_](1).value()[0]}}),Ir(["initial","tail"],function(o,u){var _="drop"+(u?"":"Right");jt.prototype[o]=function(){return this.__filtered__?new jt(this):this[_](1)}}),jt.prototype.compact=function(){return this.filter(pr)},jt.prototype.find=function(o){return this.filter(o).head()},jt.prototype.findLast=function(o){return this.reverse().find(o)},jt.prototype.invokeMap=Pt(function(o,u){return typeof o=="function"?new jt(this):this.map(function(_){return hs(_,o,u)})}),jt.prototype.reject=function(o){return this.filter(ia(At(o)))},jt.prototype.slice=function(o,u){o=Lt(o);var _=this;return _.__filtered__&&(o>0||u<0)?new jt(_):(o<0?_=_.takeRight(-o):o&&(_=_.drop(o)),u!==e&&(u=Lt(u),_=u<0?_.dropRight(-u):_.take(u-o)),_)},jt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},jt.prototype.toArray=function(){return this.take(ct)},nn(jt.prototype,function(o,u){var _=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),C=O[D?"take"+(u=="last"?"Right":""):u],I=D||/^find/.test(u);C&&(O.prototype[u]=function(){var P=this.__wrapped__,k=D?[1]:arguments,V=P instanceof jt,tt=k[0],et=V||Tt(P),ot=function(Ut){var Vt=C.apply(O,Rn([Ut],k));return D&&pt?Vt[0]:Vt};et&&_&&typeof tt=="function"&&tt.length!=1&&(V=et=!1);var pt=this.__chain__,yt=!!this.__actions__.length,Ct=I&&!pt,Rt=V&&!yt;if(!I&&et){P=Rt?P:new jt(this);var Ft=o.apply(P,k);return Ft.__actions__.push({func:ta,args:[ot],thisArg:e}),new $r(Ft,pt)}return Ct&&Rt?o.apply(this,k):(Ft=this.thru(ot),Ct?D?Ft.value()[0]:Ft.value():Ft)})}),Ir(["pop","push","shift","sort","splice","unshift"],function(o){var u=Co[o],_=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);O.prototype[o]=function(){var C=arguments;if(D&&!this.__chain__){var I=this.value();return u.apply(Tt(I)?I:[],C)}return this[_](function(P){return u.apply(Tt(P)?P:[],C)})}}),nn(jt.prototype,function(o,u){var _=O[u];if(_){var D=_.name+"";ue.call(zi,D)||(zi[D]=[]),zi[D].push({name:u,func:_})}}),zi[Zo(e,v).name]=[{name:"wrapper",func:e}],jt.prototype.clone=rb,jt.prototype.reverse=nb,jt.prototype.value=ib,O.prototype.at=IE,O.prototype.chain=TE,O.prototype.commit=$E,O.prototype.next=LE,O.prototype.plant=PE,O.prototype.reverse=zE,O.prototype.toJSON=O.prototype.valueOf=O.prototype.value=kE,O.prototype.first=O.prototype.head,ss&&(O.prototype[ss]=RE),O},Li=$D();ri?((ri.exports=Li)._=Li,yu._=Li):He._=Li}).call(Yt)}(Vn,Vn.exports);var Xr=Vn.exports;class zd{constructor(t,e){$(this,"_defaultParams");$(this,"_UserTypeFileds");$(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Xr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Xr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){$(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Xr.cloneDeep(this)}}}}var Ml={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e=1e3,r=6e4,n=36e5,i="millisecond",a="second",l="minute",c="hour",h="day",d="week",f="month",p="quarter",g="year",y="date",m="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,x={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(q){var W=["th","st","nd","rd"],z=q%100;return"["+q+(W[(z-20)%10]||W[z]||W[0])+"]"}},b=function(q,W,z){var K=String(q);return!K||K.length>=W?q:""+Array(W+1-K.length).join(z)+q},N={s:b,z:function(q){var W=-q.utcOffset(),z=Math.abs(W),K=Math.floor(z/60),Z=z%60;return(W<=0?"+":"-")+b(K,2,"0")+":"+b(Z,2,"0")},m:function q(W,z){if(W.date()<z.date())return-q(z,W);var K=12*(z.year()-W.year())+(z.month()-W.month()),Z=W.clone().add(K,f),X=z-Z<0,Q=W.clone().add(K+(X?-1:1),f);return+(-(K+(z-Z)/(X?Z-Q:Q-Z))||0)},a:function(q){return q<0?Math.ceil(q)||0:Math.floor(q)},p:function(q){return{M:f,y:g,w:d,d:h,D:y,h:c,m:l,s:a,ms:i,Q:p}[q]||String(q||"").toLowerCase().replace(/s$/,"")},u:function(q){return q===void 0}},E="en",A={};A[E]=x;var M="$isDayjsObject",S=function(q){return q instanceof R||!(!q||!q[M])},T=function q(W,z,K){var Z;if(!W)return E;if(typeof W=="string"){var X=W.toLowerCase();A[X]&&(Z=X),z&&(A[X]=z,Z=X);var Q=W.split("-");if(!Z&&Q.length>1)return q(Q[0])}else{var ct=W.name;A[ct]=W,Z=ct}return!K&&Z&&(E=Z),Z||!K&&E},F=function(q,W){if(S(q))return q.clone();var z=typeof W=="object"?W:{};return z.date=q,z.args=arguments,new R(z)},B=N;B.l=T,B.i=S,B.w=function(q,W){return F(q,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var R=function(){function q(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[M]=!0}var W=q.prototype;return W.parse=function(z){this.$d=function(K){var Z=K.date,X=K.utc;if(Z===null)return new Date(NaN);if(B.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var Q=Z.match(w);if(Q){var ct=Q[2]-1||0,vt=(Q[7]||"0").substring(0,3);return X?new Date(Date.UTC(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)):new Date(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)}}return new Date(Z)}(z),this.init()},W.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},W.$utils=function(){return B},W.isValid=function(){return this.$d.toString()!==m},W.isSame=function(z,K){var Z=F(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},W.isAfter=function(z,K){return F(z)<this.startOf(K)},W.isBefore=function(z,K){return this.endOf(K)<F(z)},W.$g=function(z,K,Z){return B.u(z)?this[K]:this.set(Z,z)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(z,K){var Z=this,X=!!B.u(K)||K,Q=B.p(z),ct=function(It,Nt){var ce=B.w(Z.$u?Date.UTC(Z.$y,Nt,It):new Date(Z.$y,Nt,It),Z);return X?ce:ce.endOf(h)},vt=function(It,Nt){return B.w(Z.toDate()[It].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Z)},lt=this.$W,wt=this.$M,bt=this.$D,Ot="set"+(this.$u?"UTC":"");switch(Q){case g:return X?ct(1,0):ct(31,11);case f:return X?ct(1,wt):ct(0,wt+1);case d:var xt=this.$locale().weekStart||0,ae=(lt<xt?lt+7:lt)-xt;return ct(X?bt-ae:bt+(6-ae),wt);case h:case y:return vt(Ot+"Hours",0);case c:return vt(Ot+"Minutes",1);case l:return vt(Ot+"Seconds",2);case a:return vt(Ot+"Milliseconds",3);default:return this.clone()}},W.endOf=function(z){return this.startOf(z,!1)},W.$set=function(z,K){var Z,X=B.p(z),Q="set"+(this.$u?"UTC":""),ct=(Z={},Z[h]=Q+"Date",Z[y]=Q+"Date",Z[f]=Q+"Month",Z[g]=Q+"FullYear",Z[c]=Q+"Hours",Z[l]=Q+"Minutes",Z[a]=Q+"Seconds",Z[i]=Q+"Milliseconds",Z)[X],vt=X===h?this.$D+(K-this.$W):K;if(X===f||X===g){var lt=this.clone().set(y,1);lt.$d[ct](vt),lt.init(),this.$d=lt.set(y,Math.min(this.$D,lt.daysInMonth())).$d}else ct&&this.$d[ct](vt);return this.init(),this},W.set=function(z,K){return this.clone().$set(z,K)},W.get=function(z){return this[B.p(z)]()},W.add=function(z,K){var Z,X=this;z=Number(z);var Q=B.p(K),ct=function(wt){var bt=F(X);return B.w(bt.date(bt.date()+Math.round(wt*z)),X)};if(Q===f)return this.set(f,this.$M+z);if(Q===g)return this.set(g,this.$y+z);if(Q===h)return ct(1);if(Q===d)return ct(7);var vt=(Z={},Z[l]=r,Z[c]=n,Z[a]=e,Z)[Q]||1,lt=this.$d.getTime()+z*vt;return B.w(lt,this)},W.subtract=function(z,K){return this.add(-1*z,K)},W.format=function(z){var K=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||m;var X=z||"YYYY-MM-DDTHH:mm:ssZ",Q=B.z(this),ct=this.$H,vt=this.$m,lt=this.$M,wt=Z.weekdays,bt=Z.months,Ot=Z.meridiem,xt=function(Nt,ce,re,qt){return Nt&&(Nt[ce]||Nt(K,X))||re[ce].slice(0,qt)},ae=function(Nt){return B.s(ct%12||12,Nt,"0")},It=Ot||function(Nt,ce,re){var qt=Nt<12?"AM":"PM";return re?qt.toLowerCase():qt};return X.replace(v,function(Nt,ce){return ce||function(re){switch(re){case"YY":return String(K.$y).slice(-2);case"YYYY":return B.s(K.$y,4,"0");case"M":return lt+1;case"MM":return B.s(lt+1,2,"0");case"MMM":return xt(Z.monthsShort,lt,bt,3);case"MMMM":return xt(bt,lt);case"D":return K.$D;case"DD":return B.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return xt(Z.weekdaysMin,K.$W,wt,2);case"ddd":return xt(Z.weekdaysShort,K.$W,wt,3);case"dddd":return wt[K.$W];case"H":return String(ct);case"HH":return B.s(ct,2,"0");case"h":return ae(1);case"hh":return ae(2);case"a":return It(ct,vt,!0);case"A":return It(ct,vt,!1);case"m":return String(vt);case"mm":return B.s(vt,2,"0");case"s":return String(K.$s);case"ss":return B.s(K.$s,2,"0");case"SSS":return B.s(K.$ms,3,"0");case"Z":return Q}return null}(Nt)||Q.replace(":","")})},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(z,K,Z){var X,Q=this,ct=B.p(K),vt=F(z),lt=(vt.utcOffset()-this.utcOffset())*r,wt=this-vt,bt=function(){return B.m(Q,vt)};switch(ct){case g:X=bt()/12;break;case f:X=bt();break;case p:X=bt()/3;break;case d:X=(wt-lt)/6048e5;break;case h:X=(wt-lt)/864e5;break;case c:X=wt/n;break;case l:X=wt/r;break;case a:X=wt/e;break;default:X=wt}return Z?X:B.a(X)},W.daysInMonth=function(){return this.endOf(f).$D},W.$locale=function(){return A[this.$L]},W.locale=function(z,K){if(!z)return this.$L;var Z=this.clone(),X=T(z,K,!0);return X&&(Z.$L=X),Z},W.clone=function(){return B.w(this.$d,this)},W.toDate=function(){return new Date(this.valueOf())},W.toJSON=function(){return this.isValid()?this.toISOString():null},W.toISOString=function(){return this.$d.toISOString()},W.toString=function(){return this.$d.toUTCString()},q}(),U=R.prototype;return F.prototype=U,[["$ms",i],["$s",a],["$m",l],["$H",c],["$W",h],["$M",f],["$y",g],["$D",y]].forEach(function(q){U[q[1]]=function(W){return this.$g(W,q[0],q[1])}}),F.extend=function(q,W){return q.$i||(q(W,R,F),q.$i=!0),F},F.locale=T,F.isDayjs=S,F.unix=function(q){return F(1e3*q)},F.en=A[E],F.Ls=A,F.p={},F})})(Ml);var kd=Ml.exports,ee=Gt(kd),Nl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,a,l){var c=a.prototype;l.utc=function(m){var w={date:m,utc:!0,args:arguments};return new a(w)},c.utc=function(m){var w=l(this.toDate(),{locale:this.$L,utc:!0});return m?w.add(this.utcOffset(),e):w},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var h=c.parse;c.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),h.call(this,m)};var d=c.init;c.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else d.call(this)};var f=c.utcOffset;c.utcOffset=function(m,w){var v=this.$utils().u;if(v(m))return this.$u?0:v(this.$offset)?f.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var A=E.match(r);if(!A)return null;var M=(""+A[0]).match(n)||["-",0,0],S=M[0],T=60*+M[1]+ +M[2];return T===0?0:S==="+"?T:-T}(m),m===null))return this;var x=Math.abs(m)<=16?60*m:m,b=this;if(w)return b.$offset=x,b.$u=m===0,b;if(m!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+N,e)).$offset=x,b.$x.$localOffset=N}else b=this.utc();return b};var p=c.format;c.format=function(m){var w=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return p.call(this,w)},c.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var g=c.toDate;c.toDate=function(m){return m==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var y=c.diff;c.diff=function(m,w,v){if(m&&this.$u===m.$u)return y.call(this,m,w,v);var x=this.local(),b=l(m).local();return y.call(x,b,w,v)}}})})(Nl);var qd=Nl.exports,Sl=Gt(qd),Ol={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,i,a){var l,c=function(p,g,y){y===void 0&&(y={});var m=new Date(p),w=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",N=v+"|"+b,E=r[N];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[N]=E),E}(g,y);return w.formatToParts(m)},h=function(p,g){for(var y=c(p,g),m=[],w=0;w<y.length;w+=1){var v=y[w],x=v.type,b=v.value,N=e[x];N>=0&&(m[N]=parseInt(b,10))}var E=m[3],A=E===24?0:E,M=m[0]+"-"+m[1]+"-"+m[2]+" "+A+":"+m[4]+":"+m[5]+":000",S=+p;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},d=i.prototype;d.tz=function(p,g){p===void 0&&(p=l);var y=this.utcOffset(),m=this.toDate(),w=m.toLocaleString("en-US",{timeZone:p}),v=Math.round((m-new Date(w))/1e3/60),x=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(y-b,"minute")}return x.$x.$timezone=p,x},d.offsetName=function(p){var g=this.$x.$timezone||a.tz.guess(),y=c(this.valueOf(),g,{timeZoneName:p}).find(function(m){return m.type.toLowerCase()==="timezonename"});return y&&y.value};var f=d.startOf;d.startOf=function(p,g){if(!this.$x||!this.$x.$timezone)return f.call(this,p,g);var y=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return f.call(y,p,g).tz(this.$x.$timezone,!0)},a.tz=function(p,g,y){var m=y&&g,w=y||g||l,v=h(+a(),w);if(typeof p!="string")return a(p).tz(w);var x=function(A,M,S){var T=A-60*M*1e3,F=h(T,S);if(M===F)return[T,M];var B=h(T-=60*(F-M)*1e3,S);return F===B?[T,F]:[A-60*Math.min(F,B)*1e3,Math.max(F,B)]}(a.utc(p,m).valueOf(),v,w),b=x[0],N=x[1],E=a(b).utcOffset(N);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(p){l=p}}})})(Ol);var Ud=Ol.exports,Wd=Gt(Ud),Bl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e="week",r="year";return function(n,i,a){var l=i.prototype;l.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var h=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=a(this).startOf(r).add(1,r).date(h),f=a(this).endOf(e);if(d.isBefore(f))return 1}var p=a(this).startOf(r).date(h).startOf(e).subtract(1,"millisecond"),g=this.diff(p,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},l.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Bl);var jd=Bl.exports,Vd=Gt(jd);function Ye(s,t){return s.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function ys(s){const t=parseInt(s)||1;let e=s.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function Yd(s){const t=/([+-])(\d{1,2})(\d{0,2})/,e=s.replace(/GMT|UTC/,"").match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,i]=e,a=parseInt(n,10)*60||0,l=parseInt(i,10)||0;return(r==="+"?-1:1)*(a+l)}function kr(s,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ee(s).utcOffset(Yd(t)):ee(s).tz(t)}function Qr(s){const[t,e]=ys(s);let r=0;switch(e){case"m":r=60;break;case"s":r=1;break;case"M":r=31*24*60*60;break;case"d":r=24*60*60;break;case"w":r=7*24*60*60;break;default:r=60*60;break}return Math.round(Number(t)*r)}function _t(s){return typeof s!="number"||isNaN(s)}function me(s,t){for(const e of t)s!=null&&s.hasOwnProperty(e)&&s[e]===void 0&&(s[e]=null)}function Il(s){var t=atob(s),e=decodeURI(t);return e}function Tl(s,t){if(!String(s).includes("."))return s;const e=Math.pow(10,t);return Math.floor(s*e)/e}var Fe=(s=>(s.BOOL="bool",s.INT="int",s.FLOAT="float",s.ARRAY="array",s.BOX="box",s.CHART_POINT="chart.point",s.COLOR="color",s.CONST="const",s.LABEL="label",s.LINE="line",s.LINEFILL="linefill",s.MAP="map",s.MATRIX="matrix",s.POLYLINE="polyline",s.SERIES="series",s.SIMPLE="simple",s.STRING="string",s.TABLE="table",s.UNDETERMINED="undetermined type",s.INPUT="input",s.NA="na",s.VOID="void",s.ENUM="enum",s))(Fe||{}),ws=(s=>(s.dividends="dividends",s.none="none",s.splits="splits",s))(ws||{}),qr=(s=>(s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close",s))(qr||{}),Yi=(s=>(s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on",s))(Yi||{}),Ze=(s=>(s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line",s))(Ze||{}),Ur=(s=>(s.both="both",s.left="left",s.none="none",s.right="right",s))(Ur||{}),Kt=(s=>(s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume",s))(Kt||{}),Ds=(s=>(s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Ds||{}),ge=(s=>(s.styleArrowdown="style_arrowdown",s.styleArrowup="style_arrowup",s.styleCircle="style_circle",s.styleCross="style_cross",s.styleDiamond="style_diamond",s.styleFlag="style_flag",s.styleLabelCenter="style_label_center",s.styleLabelDown="style_label_down",s.styleLabelLeft="style_label_left",s.styleLabelLowerLeft="style_label_lower_left",s.styleLabelLowerRight="style_label_lower_right",s.styleLabelRight="style_label_right",s.styleLabelUp="style_label_up",s.styleLabelUpperLeft="style_label_upper_left",s.styleLabelUpperRight="style_label_upper_right",s.styleNone="style_none",s.styleSquare="style_square",s.styleTextOutline="style_text_outline",s.styleTriangledown="style_triangledown",s.styleTriangleup="style_triangleup",s.styleXcross="style_xcross",s))(ge||{}),Le=(s=>(s.styleArrowBoth="style_arrow_both",s.styleArrowLeft="style_arrow_left",s.styleArrowRight="style_arrow_right",s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Le||{}),an=(s=>(s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top",s))(an||{}),Yn=(s=>(s.ascending="ascending",s.descending="descending",s))(Yn||{}),Mr=(s=>(s.styleArea="Area",s.styleAreabr="Area With Breaks",s.styleCircles="Circles",s.styleColumns="Columns",s.styleCross="Cross",s.styleHistogram="Histogram",s.styleLine="Line",s.styleLinebr="Line With Breaks",s.styleStepline="Step Line",s.styleSteplineDiamond="Step Line With Diamonds",s.styleSteplinebr="Step line with Breaks",s))(Mr||{}),_r=(s=>(s.bottomCenter="bottom_center",s.bottomLeft="bottom_left",s.bottomRight="bottom_right",s.middleCenter="middle_center",s.middleLeft="middle_left",s.middleRight="middle_right",s.topCenter="top_center",s.topLeft="top_left",s.topRight="top_right",s))(_r||{}),bs=(s=>(s.left="left",s.none="none",s.right="right",s))(bs||{}),fi=(s=>(s.extended="extended",s.regular="regular",s))(fi||{}),ur=(s=>(s.arrowdown="arrowdown",s.arrowup="arrowup",s.circle="circle",s.cross="cross",s.diamond="diamond",s.flag="flag",s.labeldown="labeldown",s.labelup="labelup",s.square="square",s.triangledown="triangledown",s.triangleup="triangleup",s.xcross="xcross",s))(ur||{}),nr=(s=>(s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny",s))(nr||{}),Zn=(s=>(s.familyDefault="default",s.familyMonospace="monospace",s))(Zn||{}),Re=(s=>(s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity",s))(Re||{}),We=(s=>(s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent",s))(We||{}),se=(s=>(s.all="all",s.long="long",s.short="short",s))(se||{}),un=(s=>(s.cancel="cancel",s.none="none",s.reduce="reduce",s))(un||{}),Wt=(s=>(s.alignBottom="align_bottom",s.alignCenter="align_center",s.alignLeft="align_left",s.alignRight="align_right",s.alignTop="align_top",s.wrapAuto="wrap_auto",s.wrapNone="wrap_none",s))(Wt||{}),we=(s=>(s.bar_index="bar_index",s.bar_time="bar_time",s))(we||{}),Wr=(s=>(s.abovebar="abovebar",s.belowbar="belowbar",s.price="price",s))(Wr||{}),xs=(s=>(s.actual="actual",s.estimate="estimate",s.standardized="standardized",s))(xs||{}),Kn=(s=>(s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla",s))(Kn||{}),ir=(s=>(s.INT="int",s.BOOL="bool",s.TIME="time",s.COLOR="color",s.FLOAT="float",s.PRICE="price",s.SOURCE="source",s.STRING="string",s.SYMBOL="symbol",s.SESSION="session",s.TEXT_AREA="text_area",s.TIMEFRAME="timeframe",s.ENUM="enum",s))(ir||{}),$l=(s=>(s.library="library",s.indicator="indicator",s.strategy="strategy",s))($l||{}),zt=(s=>(s[s.Hint=1]="Hint",s[s.Info=2]="Info",s[s.Warning=4]="Warning",s[s.Error=8]="Error",s))(zt||{});const le={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeRepeatErr:"$keyword '$name' is already defined.",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",typeFieldErr:"In a type declaration, all fields without a default value must be explicitly typified.",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an na object. The object is 'na'.",buidinAssignErr:"Cannot assign a new value to the built-in variable '$name'.",buidinVarErr:"Cannot shadow the built-in variable `$name` because it has already been used as a built-in.",useNaErr:"Cannot use an `na` value of an unspecified type in the `$name` function.",libraryTitleErr:"Invalid argument 'title' in 'library' call. It cannot contain spaces, special characters or begin with a digit.",exportFuncArgErr:"All exported functions args should be typified",indiRunErr:"An indicator must contain at least one of the following: any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, `alertcondition()`, or any drawing (line, label, box, table, polyline).",libraryExportErr:"A library must contain at least one exported function, method, or type.",strategyRunErr:"A strategy must contain at least one of the following: any `strategy.*()` function that creates orders, any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, or any drawing (line, label, box, table, polyline).",exportUseErr:"Only libraries can contain exported $type.",funcRepeatErr:"The '$name' function has overloads with the same parameters. The type of parameters must be different in overloaded versions of functions.",importMultipleErr:"Cannot import a library more than once",importNotExitErr:"The user '$username' does not have a published library titled '$libraryName'",importNameRepeatErr:"More than one import uses the same alias: $name. Previous usage at line: $line",exportFuncHasInputErr:"The exported function '$func' depends on the '$name' input variable, which is not allowed.",libraryTitleIsKeywordErr:"Invalid argument 'title' in 'library' call. Token: '$name' can't be used as library title.",exportFuncUseGlobalVarErr:"Cannot use global variables in exported functions. Function: $func",loopRuntimeErr:"Loop takes too long to execute (> 500 ms)",paramsErr:"Invalid value '$value' for '$param' parameter of the '$func' function. Possible values: $targetVal",displayErr:"Invalid argument 'display' in '$func' call. Possible values: $values",exportFuncUseReqErr:"Cannot use `request.*()` call in exported function `$name()`",requestExprErr:"Type series $type cannot be used in $name 'expression' argument",argDefaultErr:"The default value assigned to a parameter must be either a literal value (e.g., `5`) or a built-in variable (e.g., `close`)",overloadFuncErr:"Cannot use global variables or any values qualified as 'input' in the local scopes of overloaded functions or methods. Remove any global variables or inputs from the scopes of all '$name()' overloads.",againAssignErr:"Unable to determine the object for the field assignment. Try putting the object into a separate variable before assigning values to its fields.",requestUserInLoopErr:"Cannot use `request.*()` call within loops or conditional structures.",enumVarNameErr:"Invalid enum name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumVarNameBuiltinErr:"Invalid object name: $name. Namespaces of built-ins cannot be used.",typeNameErr:"Invalid user-defined type name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumUseErr:"Cannot use the '$name' as a value. Use one of the enum's fields instead.",conditionalErr:"'$name' conditional expression must be of a bool type!",fortoErr:'The value of the "for" loop must be a number.',indicatorUseStrategyFuncErr:"You cannot use strategy $type ($name) in indicator script.",arrEmptyErr:"Array must not be empty",arrLengthDiffErr:"Arrays have different lengths",arrTypeErr:"数组类型错误,array.$name方法只能使用$type类型数组!",inputOptErr:"input's defval should be in options, but '$defval' is not in [$args]",mathRandomErr:"min must be less than max",matrixRehapeErr:"New matrix must be of same area as original matrix",strategyExitErr:"strategy.exit must have at least one of the following parameters: 'profit', 'limit', 'loss', 'stop' or one of the following pairs: 'trail_offset' and 'trail_price' / 'trail_points'. To close the position at market price, use 'strategy.close'",arrLenErr:"Invalid array length",mergeCellErr:"error: start_column > end_column or start_row > end_row"},Zd={repeatVar:"Shadowing variable '$name' which exists in parent scope. Did you want to use the ':=' operator instead of '=' ?",typeMismatch:"The `$index` parameter of the `$operator` function accepts a '$type' argument. To avoid potential unexpected results, pass a '$type' value or expression to this parameter.",moreSameArg:"More than one '$arg' arguments are supplied. Only the first one will be used.",localScopeGetHistory:"The variable '$name' is declared in local scope, which may not be executed at every update. So, obtaining its historical values may lead to unexpected results",localScopeWarning:"The function '$name' should be called on each calculation for consistency. It is recommended to extract the call from this scope",strategyCalcTickWarn:"Strategies without `calc_on_every_tick = true` only calculate on confirmed chart bars. In this case, `barstate.islast` may not initially return `true` on realtime bars, as the last bar is unconfirmed until it closes. If you need to check whether a bar is the latest before it closes, enable `calc_on_every_tick` in the `strategy()` function.",conditionWarning:"The `condition` parameter of the `$name` accepts a 'bool' argument. To avoid potential unexpected results, pass a 'bool' value or expression to this parameter.",lineWidthWarning:"Passing a value below 1 to `linewidth` will be replaced with 1 during compilation.",boolVarNumWarning:"The `$name` variable casts a numeric value to the 'bool' type. To avoid potential unexpected results, assign a 'bool' value to this variable."};Fe.SERIES,Fe.SIMPLE,Fe.INPUT,Fe.CONST,Fe.INT,Fe.FLOAT,Fe.BOOL,Fe.COLOR,Fe.STRING;const Kd=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Gd=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Hd=["linefill","polyline","matrix","series","simple","string","array","color","const","float","label","table","bool","line","box","int","map","continue","for","varip","var","in","export","import","method","switch","break","while","else","type","and","for","not","as","by","if","in","or","to"];class Jd{constructor(t){$(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}slice({id:t,index_from:e,index_to:r}){return t==null?void 0:t.slice({index_from:e,index_to:r})}size({id:t}){return t==null?void 0:t.size()}first({id:t}){return t==null?void 0:t.first()}abs({id:t},e){return t==null?void 0:t.abs(e)}avg({id:t},e){return t==null?void 0:t.avg(e)}binary_search({id:t,val:e},r){return t==null?void 0:t.binary_search({val:e},r)}binary_search_leftmost({id:t,val:e},r){return t==null?void 0:t.binary_search_leftmost({val:e},r)}binary_search_rightmost({id:t,val:e},r){return t==null?void 0:t.binary_search_rightmost({val:e},r)}clear({id:t}){t==null||t.clear()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}covariance({id1:t,id2:e,biased:r},n){return t==null?void 0:t.covariance({id2:e,biased:r},n)}every({id:t},e){return t==null?void 0:t.every(e)}from(t,e){const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}fill({id:t,value:e,index_from:r,index_to:n}){t==null||t.fill({value:e,index_from:r,index_to:n})}get({id:t,index:e}){return t==null?void 0:t.get({index:e})}includes({id:t,value:e}){return t==null?void 0:t.includes({value:e})}indexof({id:t,value:e}){return t==null?void 0:t.indexof({value:e})}insert({id:t,index:e,value:r}){t==null||t.insert({index:e,value:r})}join({id:t,separator:e},r){return t==null?void 0:t.join({separator:e},r)}last({id:t}){return t==null?void 0:t.last()}lastindexof({id:t,value:e}){return t==null?void 0:t.lastindexof({value:e})}max({id:t,nth:e},r){return t==null?void 0:t.max({nth:e},r)}median({id:t},e){return t==null?void 0:t.median(e)}min({id:t,nth:e},r){return t==null?void 0:t.min({nth:e},r)}mode({id:t},e){return t==null?void 0:t.mode(e)}percentile_linear_interpolation({id:t,percentage:e},r){return t==null?void 0:t.percentile_linear_interpolation({percentage:e},r)}percentile_nearest_rank({id:t,percentage:e},r){return t==null?void 0:t.percentile_nearest_rank({percentage:e},r)}percentrank({id:t,index:e},r){return t==null?void 0:t.percentrank({index:e},r)}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t},e){return t==null?void 0:t.range(e)}remove({id:t,index:e}){return t==null?void 0:t.remove({index:e})}reverse({id:t}){return t==null?void 0:t.reverse()}set({id:t,index:e,value:r}){t==null||t.set({index:e,value:r})}shift({id:t}){return t==null?void 0:t.shift()}some({id:t},e){return t==null?void 0:t.some(e)}sort({id:t,order:e},r){t==null||t.sort({order:e},r)}sort_indices({id:t,order:e},r){return t==null?void 0:t.sort_indices({order:e},r)}standardize({id:t},e){return t==null?void 0:t.standardize(e)}stdev({id:t,biased:e},r){return t==null?void 0:t.stdev({biased:e},r)}sum({id:t},e){return t==null?void 0:t.sum(e)}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e},r){return t==null?void 0:t.variance({biased:e},r)}}class Qt{constructor(t=0,e,r){$(this,"_arrInstance");$(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Xr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Xr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Qt(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Qt(0,void 0,this._errorListener);return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(t){const e=new Qt(0,void 0,this._errorListener);this._verifySimpleType("number","abs","int/float",t);const r=this._arrInstance.map(n=>Math.abs(n));return e._copyData(r),e}avg(t){return this._verifySimpleType("number","avg","int/float",t),Xr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),_t(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),_t(t)?this._arrInstance.length-1:this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t},e){return this._verifySimpleType("number","binary_search_rightmost","int/float",e),_t(t)?this._arrInstance.length:this._binarySearchRightMost(this._arrInstance,t)}clear(){this._arrInstance=[]}concat({id2:t}){return this._arrInstance=this._arrInstance.concat(t==null?void 0:t._value),this}covariance({id2:t,biased:e},r){return this._verifySimpleType("number","covariance","int/float",r),this._verifySimpleType("number","covariance","int/float",r,t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e,r)}every(t){return this._verifySimpleType("number|boolean","every","int/float/bool",t),this._arrInstance.every(e=>!!e)}fill({value:t,index_from:e=0,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index:t}){if(!_t(t))return this._arrInstance[t]}includes({value:t}){return this._arrInstance.includes(t)}indexof({value:t}){return this._arrInstance.indexOf(t)}insert({index:t,value:e}){_t(t)||this._arrInstance.splice(t,0,e)}join({separator:t}={},e){return this._verifySimpleType("number|string","join","int/float/string",e),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={},e){return this._verifySimpleType("number","max","int/float",e),this._maxNth([...this._arrInstance],t)}median(t){return this._verifySimpleType("number","median","int/float",t),this._median([...this._arrInstance])}min({nth:t}={},e){return this._verifySimpleType("number","min","int/float",e),this._minNth([...this._arrInstance],t)}mode(t){return this._verifySimpleType("number","mode","int/float",t),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t},e){return this._verifySimpleType("number","percentile_linear_interpolation","int/float",e),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t=0},e){var r;if(this._arrInstance.length===0||t<0||t>100||_t(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,zt.Error);return}return this._verifySimpleType("number","percentile_nearest_rank","int/float",e),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t},e){return this._verifySimpleType("number","percentrank","int/float",e),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(t){var i;if(this._arrInstance.length===0){(i=this._errorListener)==null||i.addError(le.arrEmptyErr,t,zt.Error);return}this._verifySimpleType("number","range","int/float",t);const e=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-e}remove({index:t}){if(!_t(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){_t(t)||(this._arrInstance[t]=e)}shift(){return this._arrInstance.shift()}some(t){return this._verifySimpleType("number|boolean","some","int/float/bool",t),this._arrInstance.some(e=>!!e)}sort({order:t}={},e){this._verifySimpleType("number","sort","int/float",e),this._arrInstance.sort((r,n)=>t!==Yn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((i,a)=>a);r.sort((i,a)=>t!==Yn.descending?this._arrInstance[i]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[i]);const n=new Qt(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new Qt(0,void 0,this._errorListener);return e._copyData(this._standardizeArray([...this._arrInstance])),e}stdev({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(le.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","stdev","int/float",e),this._calculateStandardDeviations([...this._arrInstance],t)}sum(t){return this._verifySimpleType("number","sum","int/float",t),this._arrInstance.reduce((r,n)=>r+(n||0),0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(le.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>a+((l||0)-r)**2,0),i=n/t.length;return e?i:t.length>1?n/(t.length-1):i}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>{const c=(l||0)-r;return a+c*c},0),i=Math.sqrt(n/t.length);return e?i:t.length>1?Math.sqrt(n/(t.length-1)):i}_standardizeArray(t){const e=t.reduce((i,a)=>i+(a||0),0)/t.length,r=Math.sqrt(t.reduce((i,a)=>i+Math.pow((a||0)-e,2),0)/t.length);return t.map(i=>((i||0)-e)/r)}_getPercentileRank(t,e=0){if(_t(e))return;const r=t[e];let n=0;for(let a=0;a<t.length;a++)(t[a]<r||t[a]===r&&a!=e)&&n++;return n/(t.length-1)*100}_getNearestRankPercentile(t,e=0){const r=t.slice().sort((a,l)=>a-l),n=e/100*r.length,i=Math.ceil(n)-1;return r[i>=r.length?r.length-1:i]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||_t(e))return;t.sort(function(i,a){return i-a});const r=t.length;e/=100;const n=1/(r*2);if(e<=n)return t[0];if(e>=1-1/(r*2))return t[r-1];for(const[i,a]of t.entries()){const l=t[i-1];if(e<(i+.5)/r)return l+(a-l)*(e-(i-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const i of t)e[i]=(e[i]||0)+1,r=Math.max(r,e[i]);for(const i in e)e[i]===r&&n.push(Number(i));return Math.min(...r===1?t:n)}_median(t){t.sort(function(r,n){return r-n});const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}_minNth(t,e=0){return t.sort(function(r,n){return r-n}),t[e]}_maxNth(t,e=0){return t.sort(function(r,n){return n-r}),t[e]}_setElements(t,e,r=0,n){n===void 0&&(n=t.length);for(let i=r;i<n;i++)t[i]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(le.arrLengthDiffErr,n,zt.Error);return}t=t.filter(h=>h!==void 0),e=e.filter(h=>h!==void 0);const i=t.reduce((h,d)=>h+d,0)/t.length,a=e.reduce((h,d)=>h+d,0)/e.length;let l=0;for(let h=0;h<t.length;h++)l+=(t[h]-i)*(e[h]-a);return r?l/t.length:l/(t.length-1)}_verifySimpleType(t,e,r,n,i=this._arrInstance){var l;i.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((l=this._errorListener)==null||l.addError(Ye(le.arrTypeErr,{name:e,type:r}),n,zt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const i=Math.floor((r+n)/2);if(t[i]===e)return i;t[i]<e?r=i+1:n=i-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<e?r=a+1:n=a-1}return i.length?Math.min(...i):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<=e?r=a+1:n=a-1}return i.length?Math.max(...i):r}}class Xd{constructor(t,e){$(this,"_randomNums");$(this,"_mintick");$(this,"_cacheData");$(this,"_barIndex");$(this,"_errorListener");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0,this._errorListener=e}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){if(!_t(t))return Math.abs(t)}acos({angle:t}){if(_t(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(_t(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(_t(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Xr.mean(e)}ceil({number:t}){if(!_t(t))return Math.ceil(t)}floor({number:t}){if(!_t(t))return Math.floor(t)}cos({angle:t}){if(_t(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(_t(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(_t(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!_t(t))return Math.exp(t)}log({number:t}){if(!_t(t))return Math.log(t)}log10({number:t}){if(!_t(t))return Math.log10(t)}max(t,e){return e=e.filter(r=>!_t(r)),Math.max(...e)}min(t,e){return e=e.filter(r=>!_t(r)),Math.min(...e)}pow({base:t,exponent:e}){if(!(_t(t)||_t(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(_t(t)&&(t=0),_t(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(le.mathRandomErr,n,zt.Error);return}let i;do i=Math.random()*(e-t)+t;while(i===t||i===e);return r&&(this._randomNums[r]=i),i}round({number:t,precision:e}){if(!_t(t))return _t(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!_t(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!_t(t))return t&&Math.sign(t)}sqrt({number:t}){if(!_t(t))return Math.sqrt(t)}sum({source:t,length:e=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=t,this._cacheData[`sum_${r}`]=n;const i=n.filter(a=>!_t(a));if(!(i.length<e))return Xr.sum(i.slice(-e))}todegrees({radians:t}){if(!_t(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!_t(t))return t*(Math.PI/180)}}function Es(){return Es=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=e[r])}return s},Es.apply(this,arguments)}var Ll={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function pe(s){return typeof s=="number"}function Se(s){return!s||typeof s!="object"||typeof s.constructor!="function"?!1:s.isBigNumber===!0&&typeof s.constructor.prototype=="object"&&s.constructor.prototype.isBigNumber===!0||typeof s.constructor.isDecimal=="function"&&s.constructor.isDecimal(s)===!0}function Rl(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isComplex===!0||!1}function Pl(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isFraction===!0||!1}function zl(s){return s&&s.constructor.prototype.isUnit===!0||!1}function tn(s){return typeof s=="string"}var Ee=Array.isArray;function ve(s){return s&&s.constructor.prototype.isMatrix===!0||!1}function Zi(s){return Array.isArray(s)||ve(s)}function Qd(s){return s&&s.isDenseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function tp(s){return s&&s.isSparseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function ep(s){return s&&s.constructor.prototype.isRange===!0||!1}function la(s){return s&&s.constructor.prototype.isIndex===!0||!1}function rp(s){return typeof s=="boolean"}function np(s){return s&&s.constructor.prototype.isResultSet===!0||!1}function ip(s){return s&&s.constructor.prototype.isHelp===!0||!1}function sp(s){return typeof s=="function"}function op(s){return s instanceof Date}function ap(s){return s instanceof RegExp}function ca(s){return!!(s&&typeof s=="object"&&s.constructor===Object&&!Rl(s)&&!Pl(s))}function up(s){return s===null}function lp(s){return s===void 0}function cp(s){return s&&s.isAccessorNode===!0&&s.constructor.prototype.isNode===!0||!1}function fp(s){return s&&s.isArrayNode===!0&&s.constructor.prototype.isNode===!0||!1}function hp(s){return s&&s.isAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function dp(s){return s&&s.isBlockNode===!0&&s.constructor.prototype.isNode===!0||!1}function pp(s){return s&&s.isConditionalNode===!0&&s.constructor.prototype.isNode===!0||!1}function _p(s){return s&&s.isConstantNode===!0&&s.constructor.prototype.isNode===!0||!1}function mp(s){return s&&s.isFunctionAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function gp(s){return s&&s.isFunctionNode===!0&&s.constructor.prototype.isNode===!0||!1}function vp(s){return s&&s.isIndexNode===!0&&s.constructor.prototype.isNode===!0||!1}function yp(s){return s&&s.isNode===!0&&s.constructor.prototype.isNode===!0||!1}function wp(s){return s&&s.isObjectNode===!0&&s.constructor.prototype.isNode===!0||!1}function Dp(s){return s&&s.isOperatorNode===!0&&s.constructor.prototype.isNode===!0||!1}function bp(s){return s&&s.isParenthesisNode===!0&&s.constructor.prototype.isNode===!0||!1}function xp(s){return s&&s.isRangeNode===!0&&s.constructor.prototype.isNode===!0||!1}function Ep(s){return s&&s.isRelationalNode===!0&&s.constructor.prototype.isNode===!0||!1}function Ap(s){return s&&s.isSymbolNode===!0&&s.constructor.prototype.isNode===!0||!1}function Cp(s){return s&&s.constructor.prototype.isChain===!0||!1}function En(s){var t=typeof s;return t==="object"?s===null?"null":Se(s)?"BigNumber":s.constructor&&s.constructor.name?s.constructor.name:"Object":t}function oe(s){var t=typeof s;if(t==="number"||t==="string"||t==="boolean"||s===null||s===void 0)return s;if(typeof s.clone=="function")return s.clone();if(Array.isArray(s))return s.map(function(e){return oe(e)});if(s instanceof Date)return new Date(s.valueOf());if(Se(s))return s;if(ca(s))return Fp(s,oe);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(s,")"))}function Fp(s,t){var e={};for(var r in s)Ki(s,r)&&(e[r]=t(s[r]));return e}function kl(s,t){for(var e in t)Ki(t,e)&&(s[e]=t[e]);return s}function hi(s,t){var e,r,n;if(Array.isArray(s)){if(!Array.isArray(t)||s.length!==t.length)return!1;for(r=0,n=s.length;r<n;r++)if(!hi(s[r],t[r]))return!1;return!0}else{if(typeof s=="function")return s===t;if(s instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in s)if(!(e in t)||!hi(s[e],t[e]))return!1;for(e in t)if(!(e in s))return!1;return!0}else return s===t}}function Ki(s,t){return s&&Object.hasOwnProperty.call(s,t)}function Mp(s,t){for(var e={},r=0;r<t.length;r++){var n=t[r],i=s[n];i!==void 0&&(e[n]=i)}return e}var Np=["Matrix","Array"],Sp=["number","BigNumber","Fraction"],mr=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(Ll)};Es(mr,Ll,{MATRIX_OPTIONS:Np,NUMBER_OPTIONS:Sp});function ql(){return!0}function Nr(){return!1}function di(){}const Ul="Argument is not a typed-function.";function Wl(){function s(L){return typeof L=="object"&&L!==null&&L.constructor===Object}const t=[{name:"number",test:function(L){return typeof L=="number"}},{name:"string",test:function(L){return typeof L=="string"}},{name:"boolean",test:function(L){return typeof L=="boolean"}},{name:"Function",test:function(L){return typeof L=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(L){return L instanceof Date}},{name:"RegExp",test:function(L){return L instanceof RegExp}},{name:"Object",test:s},{name:"null",test:function(L){return L===null}},{name:"undefined",test:function(L){return L===void 0}}],e={name:"any",test:ql,isAny:!0};let r,n,i=0,a={createCount:0};function l(L){const Y=r.get(L);if(Y)return Y;let G='Unknown type "'+L+'"';const nt=L.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){G+='. Did you mean "'+st+'" ?';break}throw new TypeError(G)}function c(L){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=Y?l(Y).index:n.length,nt=[];for(let rt=0;rt<L.length;++rt){if(!L[rt]||typeof L[rt].name!="string"||typeof L[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=L[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:L[rt].test,isAny:L[rt].isAny,index:G+rt,conversionsTo:[]})}const st=n.slice(G);n=n.slice(0,G).concat(nt).concat(st);for(let rt=G+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function h(){r=new Map,n=[],i=0,c([e],!1)}h(),c(t);function d(){let L;for(L of n)r.get(L).conversionsTo=[];i=0}function f(L){const Y=n.filter(G=>{const nt=r.get(G);return!nt.isAny&&nt.test(L)});return Y.length?Y:["any"]}function p(L){return L&&typeof L=="function"&&"_typedFunctionData"in L}function g(L,Y,G){if(!p(L))throw new TypeError(Ul);const nt=G&&G.exact,st=Array.isArray(Y)?Y.join(","):Y,rt=N(st),ft=w(rt);if(!nt||ft in L.signatures){const Xt=L._typedFunctionData.signatureMap.get(ft);if(Xt)return Xt}const ut=rt.length;let ht;if(nt){ht=[];let Xt;for(Xt in L.signatures)ht.push(L._typedFunctionData.signatureMap.get(Xt))}else ht=L._typedFunctionData.signatures;for(let Xt=0;Xt<ut;++Xt){const ne=rt[Xt],be=[];let je;for(je of ht){const ke=S(je.params,Xt);if(!(!ke||ne.restParam&&!ke.restParam)){if(!ke.hasAny){const wr=b(ke);if(ne.types.some(Dr=>!wr.has(Dr.name)))continue}be.push(je)}}if(ht=be,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+(L.name||"unnamed")+"("+w(rt,", ")+"))")}function y(L,Y,G){return g(L,Y,G).implementation}function m(L,Y){const G=l(Y);if(G.test(L))return L;const nt=G.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+Y+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test(L))return nt[st].convert(L);throw new Error("Cannot convert "+L+" to "+Y)}function w(L){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return L.map(G=>G.name).join(Y)}function v(L){const Y=L.indexOf("...")===0,nt=(Y?L.length>3?L.slice(3):"any":L).split("|").map(ut=>l(ut.trim()));let st=!1,rt=Y?"...":"";return{types:nt.map(function(ut){return st=ut.isAny||st,rt+=ut.name+"|",{name:ut.name,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:Y}}function x(L){const Y=L.types.map(ft=>ft.name),G=K(Y);let nt=L.hasAny,st=L.name;const rt=G.map(function(ft){const ut=l(ft.from);return nt=ut.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:ft,conversionIndex:ft.index}});return{types:L.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:L.restParam}}function b(L){return L.typeSet||(L.typeSet=new Set,L.types.forEach(Y=>L.typeSet.add(Y.name))),L.typeSet}function N(L){const Y=[];if(typeof L!="string")throw new TypeError("Signatures must be strings");const G=L.trim();if(G==="")return Y;const nt=G.split(",");for(let st=0;st<nt.length;++st){const rt=v(nt[st].trim());if(rt.restParam&&st!==nt.length-1)throw new SyntaxError('Unexpected rest parameter "'+nt[st]+'": only allowed for the last parameter');if(rt.types.length===0)return null;Y.push(rt)}return Y}function E(L){const Y=It(L);return Y?Y.restParam:!1}function A(L){if(!L||L.types.length===0)return ql;if(L.types.length===1)return l(L.types[0].name).test;if(L.types.length===2){const Y=l(L.types[0].name).test,G=l(L.types[1].name).test;return function(st){return Y(st)||G(st)}}else{const Y=L.types.map(function(G){return l(G.name).test});return function(nt){for(let st=0;st<Y.length;st++)if(Y[st](nt))return!0;return!1}}}function M(L){let Y,G,nt;if(E(L)){Y=ae(L).map(A);const st=Y.length,rt=A(It(L)),ft=function(ut){for(let ht=st;ht<ut.length;ht++)if(!rt(ut[ht]))return!1;return!0};return function(ht){for(let at=0;at<Y.length;at++)if(!Y[at](ht[at]))return!1;return ft(ht)&&ht.length>=st+1}}else return L.length===0?function(rt){return rt.length===0}:L.length===1?(G=A(L[0]),function(rt){return G(rt[0])&&rt.length===1}):L.length===2?(G=A(L[0]),nt=A(L[1]),function(rt){return G(rt[0])&&nt(rt[1])&&rt.length===2}):(Y=L.map(A),function(rt){for(let ft=0;ft<Y.length;ft++)if(!Y[ft](rt[ft]))return!1;return rt.length===Y.length})}function S(L,Y){return Y<L.length?L[Y]:E(L)?It(L):null}function T(L,Y){const G=S(L,Y);return G?b(G):new Set}function F(L){return L.conversion===null||L.conversion===void 0}function B(L,Y){const G=new Set;return L.forEach(nt=>{const st=T(nt.params,Y);let rt;for(rt of st)G.add(rt)}),G.has("any")?["any"]:Array.from(G)}function R(L,Y,G){let nt,st;const rt=L||"unnamed";let ft=G,ut;for(ut=0;ut<Y.length;ut++){const ne=[];if(ft.forEach(be=>{const je=S(be.params,ut),ke=A(je);(ut<be.params.length||E(be.params))&&ke(Y[ut])&&ne.push(be)}),ne.length===0){if(st=B(ft,ut),st.length>0){const be=f(Y[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+be.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:be,expected:st},nt}}else ft=ne}const ht=ft.map(function(ne){return E(ne.params)?1/0:ne.params.length});if(Y.length<Math.min.apply(null,ht))return st=B(ft,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+Y.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:Y.length,expected:st},nt;const at=Math.max.apply(null,ht);if(Y.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+Y.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:Y.length,expectedLength:at},nt;const Xt=[];for(let ne=0;ne<Y.length;++ne)Xt.push(f(Y[ne]).join("|"));return nt=new TypeError('Arguments of type "'+Xt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Xt},nt}function U(L){let Y=n.length+1;for(let G=0;G<L.types.length;G++)F(L.types[G])&&(Y=Math.min(Y,L.types[G].typeIndex));return Y}function q(L){let Y=i+1;for(let G=0;G<L.types.length;G++)F(L.types[G])||(Y=Math.min(Y,L.types[G].conversionIndex));return Y}function W(L,Y){if(L.hasAny){if(!Y.hasAny)return 1}else if(Y.hasAny)return-1;if(L.restParam){if(!Y.restParam)return 1}else if(Y.restParam)return-1;if(L.hasConversion){if(!Y.hasConversion)return 1}else if(Y.hasConversion)return-1;const G=U(L)-U(Y);if(G<0)return-1;if(G>0)return 1;const nt=q(L)-q(Y);return nt<0?-1:nt>0?1:0}function z(L,Y){const G=L.params,nt=Y.params,st=It(G),rt=It(nt),ft=E(G),ut=E(nt);if(ft&&st.hasAny){if(!ut||!rt.hasAny)return 1}else if(ut&&rt.hasAny)return-1;let ht=0,at=0,Xt;for(Xt of G)Xt.hasAny&&++ht,Xt.hasConversion&&++at;let ne=0,be=0;for(Xt of nt)Xt.hasAny&&++ne,Xt.hasConversion&&++be;if(ht!==ne)return ht-ne;if(ft&&st.hasConversion){if(!ut||!rt.hasConversion)return 1}else if(ut&&rt.hasConversion)return-1;if(at!==be)return at-be;if(ft){if(!ut)return 1}else if(ut)return-1;const je=(G.length-nt.length)*(ft?-1:1);if(je!==0)return je;const ke=[];let wr=0;for(let Tn=0;Tn<G.length;++Tn){const ti=W(G[Tn],nt[Tn]);ke.push(ti),wr+=ti}if(wr!==0)return wr;let Dr;for(Dr of ke)if(Dr!==0)return Dr;return 0}function K(L){if(L.length===0)return[];const Y=L.map(l);L.length>1&&Y.sort((st,rt)=>st.index-rt.index);let G=Y[0].conversionsTo;if(L.length===1)return G;G=G.concat([]);const nt=new Set(L);for(let st=1;st<Y.length;++st){let rt;for(rt of Y[st].conversionsTo)nt.has(rt.from)||(G.push(rt),nt.add(rt.from))}return G}function Z(L,Y){let G=Y;if(L.some(st=>st.hasConversion)){const st=E(L),rt=L.map(X);G=function(){const ut=[],ht=st?arguments.length-1:arguments.length;for(let at=0;at<ht;at++)ut[at]=rt[at](arguments[at]);return st&&(ut[ht]=arguments[ht].map(rt[ht])),Y.apply(this,ut)}}let nt=G;if(E(L)){const st=L.length-1;nt=function(){return G.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function X(L){let Y,G,nt,st;const rt=[],ft=[];switch(L.types.forEach(function(ut){ut.conversion&&(rt.push(l(ut.conversion.from).test),ft.push(ut.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return Y=rt[0],nt=ft[0],function(ht){return Y(ht)?nt(ht):ht};case 2:return Y=rt[0],G=rt[1],nt=ft[0],st=ft[1],function(ht){return Y(ht)?nt(ht):G(ht)?st(ht):ht};default:return function(ht){for(let at=0;at<ft.length;at++)if(rt[at](ht))return ft[at](ht);return ht}}}function Q(L){function Y(G,nt,st){if(nt<G.length){const rt=G[nt];let ft=[];if(rt.restParam){const ut=rt.types.filter(F);ut.length<rt.types.length&&ft.push({types:ut,name:"..."+ut.map(ht=>ht.name).join("|"),hasAny:ut.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ut){return{types:[ut],name:ut.name,hasAny:ut.isAny,hasConversion:ut.conversion,restParam:!1}});return re(ft,function(ut){return Y(G,nt+1,st.concat([ut]))})}else return[st]}return Y(L,0,[])}function ct(L,Y){const G=Math.max(L.length,Y.length);for(let ut=0;ut<G;ut++){const ht=T(L,ut),at=T(Y,ut);let Xt=!1,ne;for(ne of at)if(ht.has(ne)){Xt=!0;break}if(!Xt)return!1}const nt=L.length,st=Y.length,rt=E(L),ft=E(Y);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function vt(L){return L.map(Y=>ze(Y)?$e(Y.referToSelf.callback):vr(Y)?Jt(Y.referTo.references,Y.referTo.callback):Y)}function lt(L,Y,G){const nt=[];let st;for(st of L){let rt=G[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=Y[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function wt(L,Y,G){const nt=vt(L),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ut=0;ut<nt.length;++ut){if(st[ut])continue;const ht=nt[ut];if(ze(ht))nt[ut]=ht.referToSelf.callback(G),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ft=!1;else if(vr(ht)){const at=lt(ht.referTo.references,nt,Y);at?(nt[ut]=ht.referTo.callback.apply(this,at),nt[ut].referTo=ht.referTo,st[ut]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function bt(L){const Y=/\bthis(\(|\.signatures\b)/;Object.keys(L).forEach(G=>{const nt=L[G];if(Y.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 Ot(L,Y){if(a.createCount++,Object.keys(Y).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&bt(Y);const G=[],nt=[],st={},rt=[];let ft;for(ft in Y){if(!Object.prototype.hasOwnProperty.call(Y,ft))continue;const Zt=N(ft);if(!Zt)continue;G.forEach(function($n){if(ct($n,Zt))throw new TypeError('Conflicting signatures "'+w($n)+'" and "'+w(Zt)+'".')}),G.push(Zt);const tr=nt.length;nt.push(Y[ft]);const du=Zt.map(x);let Oi;for(Oi of Q(du)){const $n=w(Oi);rt.push({params:Oi,name:$n,fn:tr}),Oi.every(Do=>!Do.hasConversion)&&(st[$n]=tr)}}rt.sort(z);const ut=wt(nt,st,ei);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ut[st[ht]]);const at=[],Xt=new Map;for(ht of rt)Xt.has(ht.name)||(ht.fn=ut[ht.fn],at.push(ht),Xt.set(ht.name,ht));const ne=at[0]&&at[0].params.length<=2&&!E(at[0].params),be=at[1]&&at[1].params.length<=2&&!E(at[1].params),je=at[2]&&at[2].params.length<=2&&!E(at[2].params),ke=at[3]&&at[3].params.length<=2&&!E(at[3].params),wr=at[4]&&at[4].params.length<=2&&!E(at[4].params),Dr=at[5]&&at[5].params.length<=2&&!E(at[5].params),Tn=ne&&be&&je&&ke&&wr&&Dr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].test=M(at[Zt].params);const ti=ne?A(at[0].params[0]):Nr,vo=be?A(at[1].params[0]):Nr,Va=je?A(at[2].params[0]):Nr,Ya=ke?A(at[3].params[0]):Nr,Za=wr?A(at[4].params[0]):Nr,Ka=Dr?A(at[5].params[0]):Nr,yo=ne?A(at[0].params[1]):Nr,Ga=be?A(at[1].params[1]):Nr,Ha=je?A(at[2].params[1]):Nr,Ja=ke?A(at[3].params[1]):Nr,rs=wr?A(at[4].params[1]):Nr,Xa=Dr?A(at[5].params[1]):Nr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].implementation=Z(at[Zt].params,at[Zt].fn);const ns=ne?at[0].implementation:di,Qa=be?at[1].implementation:di,tu=je?at[2].implementation:di,eu=ke?at[3].implementation:di,ru=wr?at[4].implementation:di,nu=Dr?at[5].implementation:di,iu=ne?at[0].params.length:-1,su=be?at[1].params.length:-1,ou=je?at[2].params.length:-1,wo=ke?at[3].params.length:-1,au=wr?at[4].params.length:-1,uu=Dr?at[5].params.length:-1,lu=Tn?6:0,cu=at.length,fu=at.map(Zt=>Zt.test),hu=at.map(Zt=>Zt.implementation),Si=function(){for(let tr=lu;tr<cu;tr++)if(fu[tr](arguments))return hu[tr].apply(this,arguments);return a.onMismatch(L,arguments,at)};function ei(Zt,tr){return arguments.length===iu&&ti(Zt)&&yo(tr)?ns.apply(this,arguments):arguments.length===su&&vo(Zt)&&Ga(tr)?Qa.apply(this,arguments):arguments.length===ou&&Va(Zt)&&Ha(tr)?tu.apply(this,arguments):arguments.length===wo&&Ya(Zt)&&Ja(tr)?eu.apply(this,arguments):arguments.length===au&&Za(Zt)&&rs(tr)?ru.apply(this,arguments):arguments.length===uu&&Ka(Zt)&&Xa(tr)?nu.apply(this,arguments):Si.apply(this,arguments)}try{Object.defineProperty(ei,"name",{value:L})}catch{}return ei.signatures=st,ei._typedFunctionData={signatures:at,signatureMap:Xt},ei}function xt(L,Y,G){throw R(L,Y,G)}function ae(L){return Nt(L,0,L.length-1)}function It(L){return L[L.length-1]}function Nt(L,Y,G){return Array.prototype.slice.call(L,Y,G)}function ce(L,Y){for(let G=0;G<L.length;G++)if(Y(L[G]))return L[G]}function re(L,Y){return Array.prototype.concat.apply([],L.map(Y))}function qt(){const L=ae(arguments).map(G=>w(N(G))),Y=It(arguments);if(typeof Y!="function")throw new TypeError("Callback function expected as last argument");return Jt(L,Y)}function Jt(L,Y){return{referTo:{references:L,callback:Y}}}function $e(L){if(typeof L!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:L}}}function vr(L){return L&&typeof L.referTo=="object"&&Array.isArray(L.referTo.references)&&typeof L.referTo.callback=="function"}function ze(L){return L&&typeof L.referToSelf=="object"&&typeof L.referToSelf.callback=="function"}function dn(L,Y){if(!L)return Y;if(Y&&Y!==L){const G=new Error("Function names do not match (expected: "+L+", actual: "+Y+")");throw G.data={actual:Y,expected:L},G}return L}function Bn(L){let Y;for(const G in L)Object.prototype.hasOwnProperty.call(L,G)&&(p(L[G])||typeof L[G].signature=="string")&&(Y=dn(Y,L[G].name));return Y}function pn(L,Y){let G;for(G in Y)if(Object.prototype.hasOwnProperty.call(Y,G)){if(G in L&&Y[G]!==L[G]){const nt=new Error('Signature "'+G+'" is defined twice');throw nt.data={signature:G,sourceFunction:Y[G],destFunction:L[G]},nt}L[G]=Y[G]}}const yr=a;a=function(L){const Y=typeof L=="string",G=Y?1:0;let nt=Y?L:"";const st={};for(let rt=G;rt<arguments.length;++rt){const ft=arguments[rt];let ut={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ut[ft.signature]=ft:p(ft)&&(ut=ft.signatures)):s(ft)&&(ut=ft,Y||(ht=Bn(ft))),Object.keys(ut).length===0){const at=new TypeError("Argument to 'typed' at index "+rt+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw at.data={index:rt,argument:ft},at}Y||(nt=dn(nt,ht)),pn(st,ut)}return Ot(nt||"",st)},a.create=Wl,a.createCount=yr.createCount,a.onMismatch=xt,a.throwMismatchError=xt,a.createError=R,a.clear=h,a.clearConversions=d,a.addTypes=c,a._findType=l,a.referTo=qt,a.referToSelf=$e,a.convert=m,a.findSignature=g,a.find=y,a.isTypedFunction=p,a.warnAgainstDeprecatedThis=!0,a.addType=function(L,Y){let G="any";Y!==!1&&r.has("Object")&&(G="Object"),a.addTypes([L],G)};function In(L){if(!L||typeof L.from!="string"||typeof L.to!="string"||typeof L.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(L.to===L.from)throw new SyntaxError('Illegal to define conversion from "'+L.from+'" to itself.')}return a.addConversion=function(L){In(L);const Y=l(L.to);if(Y.conversionsTo.every(function(G){return G.from!==L.from}))Y.conversionsTo.push({from:L.from,convert:L.convert,index:i++});else throw new Error('There is already a conversion from "'+L.from+'" to "'+Y.name+'"')},a.addConversions=function(L){L.forEach(a.addConversion)},a.removeConversion=function(L){In(L);const Y=l(L.to),G=ce(Y.conversionsTo,st=>st.from===L.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+L.from+" to "+L.to);if(G.convert!==L.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=Y.conversionsTo.indexOf(G);Y.conversionsTo.splice(nt,1)},a.resolve=function(L,Y){if(!p(L))throw new TypeError(Ul);const G=L._typedFunctionData.signatures;for(let nt=0;nt<G.length;++nt)if(G[nt].test(Y))return G[nt];return null},a}var jl=Wl();function De(s){return typeof s=="boolean"?!0:isFinite(s)?s===Math.round(s):!1}function fa(s,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s>2**(e-1)-1||s<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!De(s))throw new Error("Value must be an integer");s<0&&(s=s+2**e),i="i".concat(e)}var a="";return s<0&&(s=-s,a="-"),"".concat(a).concat(n).concat(s.toString(t)).concat(i)}function ha(s,t){if(typeof t=="function")return t(s);if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if(isNaN(s))return"NaN";var{notation:e,precision:r,wordSize:n}=Vl(t);switch(e){case"fixed":return Bp(s,r);case"exponential":return Yl(s,r);case"engineering":return Op(s,r);case"bin":return fa(s,2,n);case"oct":return fa(s,8,n);case"hex":return fa(s,16,n);case"auto":return Ip(s,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],a=arguments[4];return i!=="."?i+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Vl(s){var t="auto",e,r;if(s!==void 0)if(pe(s))e=s;else if(Se(s))e=s.toNumber();else if(ca(s))s.precision!==void 0&&(e=Zl(s.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),s.wordSize!==void 0&&(r=Zl(s.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),s.notation&&(t=s.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function As(s){var t=String(s).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+s);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),i=r.indexOf(".");n+=i!==-1?i-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(l){return n-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function Op(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=Cs(e,t),n=r.exponent,i=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(pe(t))for(;t>i.length||n-a+1>i.length;)i.push(0);else for(var l=Math.abs(n-a)-(i.length-1),c=0;c<l;c++)i.push(0);for(var h=Math.abs(n-a),d=1;h>0;)d++,h--;var f=i.slice(d).join(""),p=pe(t)&&f.length||f.match(/[1-9]/)?"."+f:"",g=i.slice(0,d).join("")+p+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Bp(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=typeof t=="number"?Cs(e,e.exponent+1+t):e,n=r.coefficients,i=r.exponent+1,a=i+(t||0);return n.length<a&&(n=n.concat(pi(a-n.length))),i<0&&(n=pi(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),r.sign+n.join("")}function Yl(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=t?Cs(e,t):e,n=r.coefficients,i=r.exponent;n.length<t&&(n=n.concat(pi(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function Ip(s,t,e){if(isNaN(s)||!isFinite(s))return String(s);var r=Kl(e==null?void 0:e.lowerExp,-3),n=Kl(e==null?void 0:e.upperExp,5),i=As(s),a=t?Cs(i,t):i;if(a.exponent<r||a.exponent>=n)return Yl(s,t);var l=a.coefficients,c=a.exponent;l.length<t&&(l=l.concat(pi(t-l.length))),l=l.concat(pi(c-l.length+1+(l.length<t?t-l.length:0))),l=pi(-c).concat(l);var h=c>0?c:0;return h<l.length-1&&l.splice(h+1,0,"."),a.sign+l.join("")}function Cs(s,t){for(var e={sign:s.sign,coefficients:s.coefficients,exponent:s.exponent},r=e.coefficients;t<=0;)r.unshift(0),e.exponent++,t++;if(r.length>t){var n=r.splice(t,r.length-t);if(n[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),e.exponent++,i++),i--,r[i]++}}return e}function pi(s){for(var t=[],e=0;e<s;e++)t.push(0);return t}function Tp(s){return s.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var $p=Number.EPSILON||2220446049250313e-31;function Gn(s,t,e){if(e==null)return s===t;if(s===t)return!0;if(isNaN(s)||isNaN(t))return!1;if(isFinite(s)&&isFinite(t)){var r=Math.abs(s-t);return r<=$p?!0:r<=Math.max(Math.abs(s),Math.abs(t))*e}return!1}function Zl(s,t){if(pe(s))return s;if(Se(s))return s.toNumber();t()}function Kl(s,t){return pe(s)?s:Se(s)?s.toNumber():t}function da(s,t,e){var r=s.constructor,n=new r(2),i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s.greaterThan(n.pow(e-1).sub(1))||s.lessThan(n.pow(e-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!s.isInteger())throw new Error("Value must be an integer");s.lessThan(0)&&(s=s.add(n.pow(e))),i="i".concat(e)}switch(t){case 2:return"".concat(s.toBinary()).concat(i);case 8:return"".concat(s.toOctal()).concat(i);case 16:return"".concat(s.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(t," not supported "))}}function Lp(s,t){if(typeof t=="function")return t(s);if(!s.isFinite())return s.isNaN()?"NaN":s.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=Vl(t);switch(e){case"fixed":return Pp(s,r);case"exponential":return Gl(s,r);case"engineering":return Rp(s,r);case"bin":return da(s,2,n);case"oct":return da(s,8,n);case"hex":return da(s,16,n);case"auto":{var i=Hl(t==null?void 0:t.lowerExp,-3),a=Hl(t==null?void 0:t.upperExp,5);if(s.isZero())return"0";var l,c=s.toSignificantDigits(r),h=c.e;return h>=i&&h<a?l=c.toFixed():l=Gl(s,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var d=arguments[2],f=arguments[4];return d!=="."?d+f:f})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Rp(s,t){var e=s.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=s.mul(Math.pow(10,-r)),i=n.toPrecision(t);if(i.indexOf("e")!==-1){var a=s.constructor;i=new a(i).toFixed()}return i+"e"+(e>=0?"+":"")+r.toString()}function Gl(s,t){return t!==void 0?s.toExponential(t-1):s.toExponential()}function Pp(s,t){return s.toFixed(t)}function Hl(s,t){return pe(s)?s:Se(s)?s.toNumber():t}function fe(s,t){var e=zp(s,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function zp(s,t){if(typeof s=="number")return ha(s,t);if(Se(s))return Lp(s,t);if(kp(s))return!t||t.fraction!=="decimal"?s.s*s.n+"/"+s.d:s.toString();if(Array.isArray(s))return Ql(s,t);if(tn(s))return Jl(s);if(typeof s=="function")return s.syntax?String(s.syntax):"function";if(s&&typeof s=="object"){if(typeof s.format=="function")return s.format(t);if(s&&s.toString(t)!=={}.toString())return s.toString(t);var e=Object.keys(s).map(r=>Jl(r)+": "+fe(s[r],t));return"{"+e.join(", ")+"}"}return String(s)}function Jl(s){for(var t=String(s),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Xl?Xl[n]:n,r++}return'"'+e+'"'}var Xl={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Ql(s,t){if(Array.isArray(s)){for(var e="[",r=s.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=Ql(s[n],t);return e+="]",e}else return fe(s,t)}function kp(s){return s&&typeof s=="object"&&typeof s.s=="number"&&typeof s.n=="number"&&typeof s.d=="number"||!1}function Ht(s,t,e){if(!(this instanceof Ht))throw new SyntaxError("Constructor must be called with the new operator");this.actual=s,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(s)?"["+s.join(", ")+"]":s)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Ht.prototype=new RangeError,Ht.prototype.constructor=RangeError,Ht.prototype.name="DimensionError",Ht.prototype.isDimensionError=!0;function An(s,t,e){if(!(this instanceof An))throw new SyntaxError("Constructor must be called with the new operator");this.index=s,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}An.prototype=new RangeError,An.prototype.constructor=RangeError,An.prototype.name="IndexError",An.prototype.isIndexError=!0;function Ie(s){for(var t=[];Array.isArray(s);)t.push(s.length),s=s[0];return t}function tc(s,t,e){var r,n=s.length;if(n!==t[e])throw new Ht(n,t[e]);if(e<t.length-1){var i=e+1;for(r=0;r<n;r++){var a=s[r];if(!Array.isArray(a))throw new Ht(t.length-1,t.length,"<");tc(s[r],t,i)}}else for(r=0;r<n;r++)if(Array.isArray(s[r]))throw new Ht(t.length+1,t.length,">")}function ec(s,t){var e=t.length===0;if(e){if(Array.isArray(s))throw new Ht(s.length,0)}else tc(s,t,0)}function Ae(s,t){if(s!==void 0){if(!pe(s)||!De(s))throw new TypeError("Index must be an integer (value: "+s+")");if(s<0||typeof t=="number"&&s>=t)throw new An(s,t)}}function pa(s,t,e){if(!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(n){if(!pe(n)||!De(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(t)+")")}),(pe(s)||Se(s))&&(s=[s]);var r=e!==void 0?e:0;return _a(s,t,0,r),s}function _a(s,t,e,r){var n,i,a=s.length,l=t[e],c=Math.min(a,l);if(s.length=l,e<t.length-1){var h=e+1;for(n=0;n<c;n++)i=s[n],Array.isArray(i)||(i=[i],s[n]=i),_a(i,t,h,r);for(n=c;n<l;n++)i=[],s[n]=i,_a(i,t,h,r)}else{for(n=0;n<c;n++)for(;Array.isArray(s[n]);)s[n]=s[n][0];for(n=c;n<l;n++)s[n]=r}}function ma(s,t){var e=va(s),r=e.length;if(!Array.isArray(s)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Ht(0,r,"!=");t=ga(t,r);var n=rc(t);if(r!==n)throw new Ht(n,r,"!=");try{return qp(e,t)}catch(i){throw i instanceof Ht?new Ht(n,r,"!="):i}}function ga(s,t){var e=rc(s),r=s.slice(),n=-1,i=s.indexOf(n),a=s.indexOf(n,i+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=i>=0,c=t%e===0;if(l)if(c)r[i]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function rc(s){return s.reduce((t,e)=>t*e,1)}function qp(s,t){for(var e=s,r,n=t.length-1;n>0;n--){var i=t[n];r=[];for(var a=e.length/i,l=0;l<a;l++)r.push(e.slice(l*i,(l+1)*i));e=r}return e}function nc(s,t,e,r){var n=r||Ie(s);if(e)for(var i=0;i<e;i++)s=[s],n.unshift(1);for(s=ic(s,t,0);n.length<t;)n.push(1);return s}function ic(s,t,e){var r,n;if(Array.isArray(s)){var i=e+1;for(r=0,n=s.length;r<n;r++)s[r]=ic(s[r],t,i)}else for(var a=e;a<t;a++)s=[s];return s}function va(s){if(!Array.isArray(s))return s;var t=[];return s.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Fs(s,t){for(var e,r=0,n=0;n<s.length;n++){var i=s[n],a=Array.isArray(i);if(n===0&&a&&(r=i.length),a&&i.length!==r)return;var l=a?Fs(i,t):t(i);if(e===void 0)e=l;else if(e!==l)return"mixed"}return e}function sc(s,t,e,r){if(r<e){if(s.length!==t.length)throw new Ht(s.length,t.length);for(var n=[],i=0;i<s.length;i++)n[i]=sc(s[i],t[i],e,r+1);return n}else return s.concat(t)}function oc(){var s=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(s.length===1)return s[0];if(s.length>1)return s.slice(1).reduce(function(e,r){return sc(e,r,t,0)},s[0]);throw new Error("Wrong number of arguments in function concat")}function Up(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];for(var r=t.map(p=>p.length),n=Math.max(...r),i=new Array(n).fill(null),a=0;a<t.length;a++)for(var l=t[a],c=r[a],h=0;h<c;h++){var d=n-c+h;l[h]>i[d]&&(i[d]=l[h])}for(var f=0;f<t.length;f++)Ms(t[f],i);return i}function Ms(s,t){for(var e=t.length,r=s.length,n=0;n<r;n++){var i=e-r+n;if(s[n]<t[i]&&s[n]>1||s[n]>t[i])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(s,") not possible to broadcast dimension ").concat(r," with size ").concat(s[n]," to size ").concat(t[i]))}}function ac(s,t){var e=Ie(s);if(hi(e,t))return s;Ms(e,t);var r=Up(e,t),n=r.length,i=[...Array(n-e.length).fill(1),...e],a=jp(s);e.length<n&&(a=ma(a,i),e=Ie(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=Wp(a,r[l],l),e=Ie(a));return a}function Wp(s,t,e){return oc(...Array(t).fill(s),e)}function jp(s){return Es([],s)}function mt(s,t,e,r){function n(i){var a=Mp(i,t.map(Zp));return Vp(s,t,i),e(a)}return n.isFactory=!0,n.fn=s,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Vp(s,t,e){var r=t.filter(i=>!Yp(i)).every(i=>e[i]!==void 0);if(!r){var n=t.filter(i=>e[i]===void 0);throw new Error('Cannot create function "'.concat(s,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function Yp(s){return s&&s[0]==="?"}function Zp(s){return s&&s[0]==="?"?s.slice(1):s}function Kp(s,t){if(lc(s)&&uc(s,t))return s[t];throw typeof s[t]=="function"&&Jp(s,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Gp(s,t,e){if(lc(s)&&uc(s,t))return s[t]=e,e;throw new Error('No access to property "'+t+'"')}function Hp(s,t){return t in s}function uc(s,t){return!s||typeof s!="object"?!1:Ki(Xp,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Jp(s,t){return s==null||typeof s[t]!="function"||Ki(s,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(s)?!1:Ki(Qp,t)?!0:!(t in Object.prototype||t in Function.prototype)}function lc(s){return typeof s=="object"&&s&&s.constructor===Object}var Xp={length:!0,name:!0},Qp={toString:!0,valueOf:!0,toLocaleString:!0};class t_{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Kp(this.wrappedObject,t)}set(t,e){return Gp(this.wrappedObject,t,e),this}has(t){return Hp(this.wrappedObject,t)}entries(){return e_(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 e_(s,t){return{next:()=>{var e=s.next();return e.done?e:{value:t(e.value),done:!1}}}}function r_(s){return s?s instanceof Map||s instanceof t_||typeof s.set=="function"&&typeof s.get=="function"&&typeof s.keys=="function"&&typeof s.has=="function":!1}var cc=function(){return cc=jl.create,jl},n_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],i_=mt("typed",n_,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:i}=t,a=cc();return a.clear(),a.addTypes([{name:"number",test:pe},{name:"Complex",test:Rl},{name:"BigNumber",test:Se},{name:"Fraction",test:Pl},{name:"Unit",test:zl},{name:"identifier",test:l=>tn&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(l)},{name:"string",test:tn},{name:"Chain",test:Cp},{name:"Array",test:Ee},{name:"Matrix",test:ve},{name:"DenseMatrix",test:Qd},{name:"SparseMatrix",test:tp},{name:"Range",test:ep},{name:"Index",test:la},{name:"boolean",test:rp},{name:"ResultSet",test:np},{name:"Help",test:ip},{name:"function",test:sp},{name:"Date",test:op},{name:"RegExp",test:ap},{name:"null",test:up},{name:"undefined",test:lp},{name:"AccessorNode",test:cp},{name:"ArrayNode",test:fp},{name:"AssignmentNode",test:hp},{name:"BlockNode",test:dp},{name:"ConditionalNode",test:pp},{name:"ConstantNode",test:_p},{name:"FunctionNode",test:gp},{name:"FunctionAssignmentNode",test:mp},{name:"IndexNode",test:vp},{name:"Node",test:yp},{name:"ObjectNode",test:wp},{name:"OperatorNode",test:Dp},{name:"ParenthesisNode",test:bp},{name:"RangeNode",test:xp},{name:"RelationalNode",test:Ep},{name:"SymbolNode",test:Ap},{name:"Map",test:r_},{name:"Object",test:ca}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||ya(c),Tp(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new e(c)}},{from:"number",to:"Complex",convert:function(c){return r||Ns(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ns(c),new r(c.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(c){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(c){return r||Ns(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){i||wa(c);var h=new i(c);if(h.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return h}},{from:"string",to:"number",convert:function(c){var h=Number(c);if(isNaN(h))throw new Error('Cannot convert "'+c+'" to a number');return h}},{from:"string",to:"BigNumber",convert:function(c){e||ya(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){i||wa(c);try{return new i(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ns(c);try{return new r(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return e||ya(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return i||wa(c),new i(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||s_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,h)=>{var d=a.createError(l,c,h);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&Zi(c[0])&&h.some(p=>!p.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=d.data,f}throw d},a.onMismatch=(l,c,h)=>{var d=a.createError(l,c,h);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&Zi(c[0])&&h.some(p=>!p.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=d.data,f}throw d},a});function ya(s){throw new Error("Cannot convert value ".concat(s," into a BigNumber: no class 'BigNumber' provided"))}function Ns(s){throw new Error("Cannot convert value ".concat(s," into a Complex number: no class 'Complex' provided"))}function s_(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function wa(s){throw new Error("Cannot convert value ".concat(s," into a Fraction, no class 'Fraction' provided."))}/*!
|
35
|
+
* 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 _i=9e15,Cn=1e9,Da="0123456789abcdef",Ss="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Os="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ba={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-_i,maxE:_i,crypto:!1},fc,ln,St=!0,Bs="[DecimalError] ",Fn=Bs+"Invalid argument: ",hc=Bs+"Precision limit exceeded",dc=Bs+"crypto unavailable",pc="[object Decimal]",Xe=Math.floor,Pe=Math.pow,o_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,a_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,u_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,_c=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,Et=7,l_=9007199254740991,c_=Ss.length-1,xa=Os.length-1,it={toStringTag:pc};it.absoluteValue=it.abs=function(){var s=new this.constructor(this);return s.s<0&&(s.s=1),Dt(s)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(s,t){var e,r=this,n=r.constructor;if(s=new n(s),t=new n(t),!s.s||!t.s)return new n(NaN);if(s.gt(t))throw Error(Fn+t);return e=r.cmp(s),e<0?s:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(s){var t,e,r,n,i=this,a=i.d,l=(s=new i.constructor(s)).d,c=i.s,h=s.s;if(!a||!l)return!c||!h?NaN:c!==h?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-h:0;if(c!==h)return c;if(i.e!==s.e)return i.e>s.e^c<0?1:-1;for(r=a.length,n=l.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==l[t])return a[t]>l[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var s,t,e=this,r=e.constructor;return e.d?e.d[0]?(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=f_(r,Dc(r,e)),r.precision=s,r.rounding=t,Dt(ln==2||ln==3?e.neg():e,s,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var s,t,e,r,n,i,a,l,c,h,d=this,f=d.constructor;if(!d.isFinite()||d.isZero())return new f(d);for(St=!1,i=d.s*Pe(d.s*d,1/3),!i||Math.abs(i)==1/0?(e=Ke(d.d),s=d.e,(i=(s-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=Pe(e,1/3),s=Xe((s+1)/3)-(s%3==(s<0?-1:2)),i==1/0?e="5e"+s:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+s),r=new f(e),r.s=d.s):r=new f(i.toString()),a=(s=f.precision)+3;;)if(l=r,c=l.times(l).times(l),h=c.plus(d),r=he(h.plus(d).times(l),h.plus(c),a+2,1),Ke(l.d).slice(0,a)===(e=Ke(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(l,s+1,0),l.times(l).times(l).eq(d))){r=l;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,s+1,1),t=!r.times(r).times(r).eq(d));break}return St=!0,Dt(r,s,f.rounding,t)},it.decimalPlaces=it.dp=function(){var s,t=this.d,e=NaN;if(t){if(s=t.length-1,e=(s-Xe(this.e/Et))*Et,s=t[s],s)for(;s%10==0;s/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(s){return he(this,new this.constructor(s))},it.dividedToIntegerBy=it.divToInt=function(s){var t=this,e=t.constructor;return Dt(he(t,new e(s),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(s){return this.cmp(s)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(s){return this.cmp(s)>0},it.greaterThanOrEqualTo=it.gte=function(s){var t=this.cmp(s);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var s,t,e,r,n,i=this,a=i.constructor,l=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return l;e=a.precision,r=a.rounding,a.precision=e+Math.max(i.e,i.sd())+4,a.rounding=1,n=i.d.length,n<32?(s=Math.ceil(n/3),t=(1/Ls(4,s)).toString()):(s=16,t="2.3283064365386962890625e-10"),i=mi(a,1,i.times(t),new a(1),!0);for(var c,h=s,d=new a(8);h--;)c=i.times(i),i=l.minus(c.times(d.minus(c.times(d))));return Dt(i,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var s,t,e,r,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+4,i.rounding=1,r=n.d.length,r<3)n=mi(i,2,n,n,!0);else{s=1.4*Math.sqrt(r),s=s>16?16:s|0,n=n.times(1/Ls(5,s)),n=mi(i,2,n,n,!0);for(var a,l=new i(5),c=new i(16),h=new i(20);s--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(h))))}return i.precision=t,i.rounding=e,Dt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+7,r.rounding=1,he(e.sinh(),e.cosh(),r.precision=s,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var s,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return r!==-1?r===0?t.isNeg()?Vr(e,n,i):new e(0):new e(NaN):t.isZero()?Vr(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),s=Vr(e,n+4,i).times(.5),e.precision=n,e.rounding=i,s.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var s,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(s=r.precision,t=r.rounding,r.precision=s+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,St=!1,e=e.times(e).minus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var s,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,St=!1,e=e.times(e).plus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var s,t,e,r,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(s=i.precision,t=i.rounding,r=n.sd(),Math.max(r,s)<2*-n.e-1?Dt(new i(n),s,t,!0):(i.precision=e=r-n.e,n=he(n.plus(1),new i(1).minus(n),e+s,1),i.precision=s+4,i.rounding=1,n=n.ln(),i.precision=s,i.rounding=t,n.times(.5))):new i(NaN)},it.inverseSine=it.asin=function(){var s,t,e,r,n=this,i=n.constructor;return n.isZero()?new i(n):(t=n.abs().cmp(1),e=i.precision,r=i.rounding,t!==-1?t===0?(s=Vr(i,e+4,r).times(.5),s.s=n.s,s):new i(NaN):(i.precision=e+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var s,t,e,r,n,i,a,l,c,h=this,d=h.constructor,f=d.precision,p=d.rounding;if(h.isFinite()){if(h.isZero())return new d(h);if(h.abs().eq(1)&&f+4<=xa)return a=Vr(d,f+4,p).times(.25),a.s=h.s,a}else{if(!h.s)return new d(NaN);if(f+4<=xa)return a=Vr(d,f+4,p).times(.5),a.s=h.s,a}for(d.precision=l=f+10,d.rounding=1,e=Math.min(28,l/Et+2|0),s=e;s;--s)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(l/Et),r=1,c=h.times(h),a=new d(h),n=h;s!==-1;)if(n=n.times(c),i=a.minus(n.div(r+=2)),n=n.times(c),a=i.plus(n.div(r+=2)),a.d[t]!==void 0)for(s=t;a.d[s]===i.d[s]&&s--;);return e&&(a=a.times(2<<e-1)),St=!0,Dt(a,d.precision=f,d.rounding=p,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Xe(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(s){return this.cmp(s)<0},it.lessThanOrEqualTo=it.lte=function(s){return this.cmp(s)<1},it.logarithm=it.log=function(s){var t,e,r,n,i,a,l,c,h=this,d=h.constructor,f=d.precision,p=d.rounding,g=5;if(s==null)s=new d(10),t=!0;else{if(s=new d(s),e=s.d,s.s<0||!e||!e[0]||s.eq(1))return new d(NaN);t=s.eq(10)}if(e=h.d,h.s<0||!e||!e[0]||h.eq(1))return new d(e&&!e[0]?-1/0:h.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)i=!0;else{for(n=e[0];n%10===0;)n/=10;i=n!==1}if(St=!1,l=f+g,a=Nn(h,l),r=t?$s(d,l+10):Nn(s,l),c=he(a,r,l,1),Gi(c.d,n=f,p))do if(l+=10,a=Nn(h,l),r=t?$s(d,l+10):Nn(s,l),c=he(a,r,l,1),!i){+Ke(c.d).slice(n+1,n+15)+1==1e14&&(c=Dt(c,f+1,0));break}while(Gi(c.d,n+=10,p));return St=!0,Dt(c,f,p)},it.minus=it.sub=function(s){var t,e,r,n,i,a,l,c,h,d,f,p,g=this,y=g.constructor;if(s=new y(s),!g.d||!s.d)return!g.s||!s.s?s=new y(NaN):g.d?s.s=-s.s:s=new y(s.d||g.s!==s.s?g:NaN),s;if(g.s!=s.s)return s.s=-s.s,g.plus(s);if(h=g.d,p=s.d,l=y.precision,c=y.rounding,!h[0]||!p[0]){if(p[0])s.s=-s.s;else if(h[0])s=new y(g);else return new y(c===3?-0:0);return St?Dt(s,l,c):s}if(e=Xe(s.e/Et),d=Xe(g.e/Et),h=h.slice(),i=d-e,i){for(f=i<0,f?(t=h,i=-i,a=p.length):(t=p,e=d,a=h.length),r=Math.max(Math.ceil(l/Et),a)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=h.length,a=p.length,f=r<a,f&&(a=r),r=0;r<a;r++)if(h[r]!=p[r]){f=h[r]<p[r];break}i=0}for(f&&(t=h,h=p,p=t,s.s=-s.s),a=h.length,r=p.length-a;r>0;--r)h[a++]=0;for(r=p.length;r>i;){if(h[--r]<p[r]){for(n=r;n&&h[--n]===0;)h[n]=jr-1;--h[n],h[r]+=jr}h[r]-=p[r]}for(;h[--a]===0;)h.pop();for(;h[0]===0;h.shift())--e;return h[0]?(s.d=h,s.e=Ts(h,e),St?Dt(s,l,c):s):new y(c===3?-0:0)},it.modulo=it.mod=function(s){var t,e=this,r=e.constructor;return s=new r(s),!e.d||!s.s||s.d&&!s.d[0]?new r(NaN):!s.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(St=!1,r.modulo==9?(t=he(e,s.abs(),0,3,1),t.s*=s.s):t=he(e,s,0,r.modulo,1),t=t.times(s),St=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return Ea(this)},it.naturalLogarithm=it.ln=function(){return Nn(this)},it.negated=it.neg=function(){var s=new this.constructor(this);return s.s=-s.s,Dt(s)},it.plus=it.add=function(s){var t,e,r,n,i,a,l,c,h,d,f=this,p=f.constructor;if(s=new p(s),!f.d||!s.d)return!f.s||!s.s?s=new p(NaN):f.d||(s=new p(s.d||f.s===s.s?f:NaN)),s;if(f.s!=s.s)return s.s=-s.s,f.minus(s);if(h=f.d,d=s.d,l=p.precision,c=p.rounding,!h[0]||!d[0])return d[0]||(s=new p(f)),St?Dt(s,l,c):s;if(i=Xe(f.e/Et),r=Xe(s.e/Et),h=h.slice(),n=i-r,n){for(n<0?(e=h,n=-n,a=d.length):(e=d,r=i,a=h.length),i=Math.ceil(l/Et),a=i>a?i+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=h.length,n=d.length,a-n<0&&(n=a,e=d,d=h,h=e),t=0;n;)t=(h[--n]=h[n]+d[n]+t)/jr|0,h[n]%=jr;for(t&&(h.unshift(t),++r),a=h.length;h[--a]==0;)h.pop();return s.d=h,s.e=Ts(h,r),St?Dt(s,l,c):s},it.precision=it.sd=function(s){var t,e=this;if(s!==void 0&&s!==!!s&&s!==1&&s!==0)throw Error(Fn+s);return e.d?(t=mc(e.d),s&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var s=this,t=s.constructor;return Dt(new t(s),s.e+1,t.rounding)},it.sine=it.sin=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=d_(r,Dc(r,e)),r.precision=s,r.rounding=t,Dt(ln>2?e.neg():e,s,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var s,t,e,r,n,i,a=this,l=a.d,c=a.e,h=a.s,d=a.constructor;if(h!==1||!l||!l[0])return new d(!h||h<0&&(!l||l[0])?NaN:l?a:1/0);for(St=!1,h=Math.sqrt(+a),h==0||h==1/0?(t=Ke(l),(t.length+c)%2==0&&(t+="0"),h=Math.sqrt(t),c=Xe((c+1)/2)-(c<0||c%2),h==1/0?t="5e"+c:(t=h.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new d(t)):r=new d(h.toString()),e=(c=d.precision)+3;;)if(i=r,r=i.plus(he(a,i,e+2,1)).times(.5),Ke(i.d).slice(0,e)===(t=Ke(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(i,c+1,0),i.times(i).eq(a))){r=i;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,c+1,1),s=!r.times(r).eq(a));break}return St=!0,Dt(r,c,d.rounding,s)},it.tangent=it.tan=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+10,r.rounding=1,e=e.sin(),e.s=1,e=he(e,new r(1).minus(e.times(e)).sqrt(),s+10,0),r.precision=s,r.rounding=t,Dt(ln==2||ln==4?e.neg():e,s,t,!0)):new r(NaN)},it.times=it.mul=function(s){var t,e,r,n,i,a,l,c,h,d=this,f=d.constructor,p=d.d,g=(s=new f(s)).d;if(s.s*=d.s,!p||!p[0]||!g||!g[0])return new f(!s.s||p&&!p[0]&&!g||g&&!g[0]&&!p?NaN:!p||!g?s.s/0:s.s*0);for(e=Xe(d.e/Et)+Xe(s.e/Et),c=p.length,h=g.length,c<h&&(i=p,p=g,g=i,a=c,c=h,h=a),i=[],a=c+h,r=a;r--;)i.push(0);for(r=h;--r>=0;){for(t=0,n=c+r;n>r;)l=i[n]+g[r]*p[n-r-1]+t,i[n--]=l%jr|0,t=l/jr|0;i[n]=(i[n]+t)%jr|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),s.d=i,s.e=Ts(i,e),St?Dt(s,f.precision,f.rounding):s},it.toBinary=function(s,t){return Ca(this,2,s,t)},it.toDecimalPlaces=it.toDP=function(s,t){var e=this,r=e.constructor;return e=new r(e),s===void 0?e:(lr(s,0,Cn),t===void 0?t=r.rounding:lr(t,0,8),Dt(e,s+e.e+1,t))},it.toExponential=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,!0):(lr(s,0,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s+1,t),e=en(r,!0,s+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(s,t){var e,r,n=this,i=n.constructor;return s===void 0?e=en(n):(lr(s,0,Cn),t===void 0?t=i.rounding:lr(t,0,8),r=Dt(new i(n),s+n.e+1,t),e=en(r,!1,s+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(s){var t,e,r,n,i,a,l,c,h,d,f,p,g=this,y=g.d,m=g.constructor;if(!y)return new m(g);if(h=e=new m(1),r=c=new m(0),t=new m(r),i=t.e=mc(y)-g.e-1,a=i%Et,t.d[0]=Pe(10,a<0?Et+a:a),s==null)s=i>0?t:h;else{if(l=new m(s),!l.isInt()||l.lt(h))throw Error(Fn+l);s=l.gt(t)?i>0?t:h:l}for(St=!1,l=new m(Ke(y)),d=m.precision,m.precision=i=y.length*Et*2;f=he(l,t,0,1,1),n=e.plus(f.times(r)),n.cmp(s)!=1;)e=r,r=n,n=h,h=c.plus(f.times(n)),c=n,n=t,t=l.minus(f.times(n)),l=n;return n=he(s.minus(e),r,0,1,1),c=c.plus(n.times(h)),e=e.plus(n.times(r)),c.s=h.s=g.s,p=he(h,r,i,1).minus(g).abs().cmp(he(c,e,i,1).minus(g).abs())<1?[h,r]:[c,e],m.precision=d,St=!0,p},it.toHexadecimal=it.toHex=function(s,t){return Ca(this,16,s,t)},it.toNearest=function(s,t){var e=this,r=e.constructor;if(e=new r(e),s==null){if(!e.d)return e;s=new r(1),t=r.rounding}else{if(s=new r(s),t===void 0?t=r.rounding:lr(t,0,8),!e.d)return s.s?e:s;if(!s.d)return s.s&&(s.s=e.s),s}return s.d[0]?(St=!1,e=he(e,s,0,t,1).times(s),St=!0,Dt(e)):(s.s=e.s,e=s),e},it.toNumber=function(){return+this},it.toOctal=function(s,t){return Ca(this,8,s,t)},it.toPower=it.pow=function(s){var t,e,r,n,i,a,l=this,c=l.constructor,h=+(s=new c(s));if(!l.d||!s.d||!l.d[0]||!s.d[0])return new c(Pe(+l,h));if(l=new c(l),l.eq(1))return l;if(r=c.precision,i=c.rounding,s.eq(1))return Dt(l,r,i);if(t=Xe(s.e/Et),t>=s.d.length-1&&(e=h<0?-h:h)<=l_)return n=gc(c,l,e,r),s.s<0?new c(1).div(n):Dt(n,r,i);if(a=l.s,a<0){if(t<s.d.length-1)return new c(NaN);if(s.d[t]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return e=Pe(+l,h),t=e==0||!isFinite(e)?Xe(h*(Math.log("0."+Ke(l.d))/Math.LN10+l.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(St=!1,c.rounding=l.s=1,e=Math.min(12,(t+"").length),n=Ea(s.times(Nn(l,r+e)),r),n.d&&(n=Dt(n,r+5,1),Gi(n.d,r,i)&&(t=r+10,n=Dt(Ea(s.times(Nn(l,t+e)),t),t+5,1),+Ke(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,St=!0,c.rounding=i,Dt(n,r,i))},it.toPrecision=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(lr(s,1,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s,t),e=en(r,s<=r.e||r.e<=n.toExpNeg,s)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(s,t){var e=this,r=e.constructor;return s===void 0?(s=r.precision,t=r.rounding):(lr(s,1,Cn),t===void 0?t=r.rounding:lr(t,0,8)),Dt(new r(e),s,t)},it.toString=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()&&!s.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()?"-"+e:e};function Ke(s){var t,e,r,n=s.length-1,i="",a=s[0];if(n>0){for(i+=a,t=1;t<n;t++)r=s[t]+"",e=Et-r.length,e&&(i+=Mn(e)),i+=r;a=s[t],r=a+"",e=Et-r.length,e&&(i+=Mn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function lr(s,t,e){if(s!==~~s||s<t||s>e)throw Error(Fn+s)}function Gi(s,t,e,r){var n,i,a,l;for(i=s[0];i>=10;i/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),i=Pe(10,Et-t),l=s[n]%i|0,r==null?t<3?(t==0?l=l/100|0:t==1&&(l=l/10|0),a=e<4&&l==99999||e>3&&l==49999||l==5e4||l==0):a=(e<4&&l+1==i||e>3&&l+1==i/2)&&(s[n+1]/i/100|0)==Pe(10,t-2)-1||(l==i/2||l==0)&&(s[n+1]/i/100|0)==0:t<4?(t==0?l=l/1e3|0:t==1?l=l/100|0:t==2&&(l=l/10|0),a=(r||e<4)&&l==9999||!r&&e>3&&l==4999):a=((r||e<4)&&l+1==i||!r&&e>3&&l+1==i/2)&&(s[n+1]/i/1e3|0)==Pe(10,t-3)-1,a}function Is(s,t,e){for(var r,n=[0],i,a=0,l=s.length;a<l;){for(i=n.length;i--;)n[i]*=t;for(n[0]+=Da.indexOf(s.charAt(a++)),r=0;r<n.length;r++)n[r]>e-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/e|0,n[r]%=e)}return n.reverse()}function f_(s,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ls(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),s.precision+=e,t=mi(s,1,t.times(n),new s(1));for(var i=e;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return s.precision-=e,t}var he=function(){function s(r,n,i){var a,l=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+l,r[c]=a%i|0,l=a/i|0;return l&&r.unshift(l),r}function t(r,n,i,a){var l,c;if(i!=a)c=i>a?1:-1;else for(l=c=0;l<i;l++)if(r[l]!=n[l]){c=r[l]>n[l]?1:-1;break}return c}function e(r,n,i,a){for(var l=0;i--;)r[i]-=l,l=r[i]<n[i]?1:0,r[i]=l*a+r[i]-n[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,i,a,l,c){var h,d,f,p,g,y,m,w,v,x,b,N,E,A,M,S,T,F,B,R,U=r.constructor,q=r.s==n.s?1:-1,W=r.d,z=n.d;if(!W||!W[0]||!z||!z[0])return new U(!r.s||!n.s||(W?z&&W[0]==z[0]:!z)?NaN:W&&W[0]==0||!z?q*0:q/0);for(c?(g=1,d=r.e-n.e):(c=jr,g=Et,d=Xe(r.e/g)-Xe(n.e/g)),B=z.length,T=W.length,v=new U(q),x=v.d=[],f=0;z[f]==(W[f]||0);f++);if(z[f]>(W[f]||0)&&d--,i==null?(A=i=U.precision,a=U.rounding):l?A=i+(r.e-n.e)+1:A=i,A<0)x.push(1),y=!0;else{if(A=A/g+2|0,f=0,B==1){for(p=0,z=z[0],A++;(f<T||p)&&A--;f++)M=p*c+(W[f]||0),x[f]=M/z|0,p=M%z|0;y=p||f<T}else{for(p=c/(z[0]+1)|0,p>1&&(z=s(z,p,c),W=s(W,p,c),B=z.length,T=W.length),S=B,b=W.slice(0,B),N=b.length;N<B;)b[N++]=0;R=z.slice(),R.unshift(0),F=z[0],z[1]>=c/2&&++F;do p=0,h=t(z,b,B,N),h<0?(E=b[0],B!=N&&(E=E*c+(b[1]||0)),p=E/F|0,p>1?(p>=c&&(p=c-1),m=s(z,p,c),w=m.length,N=b.length,h=t(m,b,w,N),h==1&&(p--,e(m,B<w?R:z,w,c))):(p==0&&(h=p=1),m=z.slice()),w=m.length,w<N&&m.unshift(0),e(b,m,N,c),h==-1&&(N=b.length,h=t(z,b,B,N),h<1&&(p++,e(b,B<N?R:z,N,c))),N=b.length):h===0&&(p++,b=[0]),x[f++]=p,h&&b[0]?b[N++]=W[S]||0:(b=[W[S]],N=1);while((S++<T||b[0]!==void 0)&&A--);y=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=d,fc=y;else{for(f=1,p=x[0];p>=10;p/=10)f++;v.e=f+d*g-1,Dt(v,l?i+v.e+1:i,a,y)}return v}}();function Dt(s,t,e,r){var n,i,a,l,c,h,d,f,p,g=s.constructor;t:if(t!=null){if(f=s.d,!f)return s;for(n=1,l=f[0];l>=10;l/=10)n++;if(i=t-n,i<0)i+=Et,a=t,d=f[p=0],c=d/Pe(10,n-a-1)%10|0;else if(p=Math.ceil((i+1)/Et),l=f.length,p>=l)if(r){for(;l++<=p;)f.push(0);d=c=0,n=1,i%=Et,a=i-Et+1}else break t;else{for(d=l=f[p],n=1;l>=10;l/=10)n++;i%=Et,a=i-Et+n,c=a<0?0:d/Pe(10,n-a-1)%10|0}if(r=r||t<0||f[p+1]!==void 0||(a<0?d:d%Pe(10,n-a-1)),h=e<4?(c||r)&&(e==0||e==(s.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(i>0?a>0?d/Pe(10,n-a):0:f[p-1])%10&1||e==(s.s<0?8:7)),t<1||!f[0])return f.length=0,h?(t-=s.e+1,f[0]=Pe(10,(Et-t%Et)%Et),s.e=-t||0):f[0]=s.e=0,s;if(i==0?(f.length=p,l=1,p--):(f.length=p+1,l=Pe(10,Et-i),f[p]=a>0?(d/Pe(10,n-a)%Pe(10,a)|0)*l:0),h)for(;;)if(p==0){for(i=1,a=f[0];a>=10;a/=10)i++;for(a=f[0]+=l,l=1;a>=10;a/=10)l++;i!=l&&(s.e++,f[0]==jr&&(f[0]=1));break}else{if(f[p]+=l,f[p]!=jr)break;f[p--]=0,l=1}for(i=f.length;f[--i]===0;)f.pop()}return St&&(s.e>g.maxE?(s.d=null,s.e=NaN):s.e<g.minE&&(s.e=0,s.d=[0])),s}function en(s,t,e){if(!s.isFinite())return wc(s);var r,n=s.e,i=Ke(s.d),a=i.length;return t?(e&&(r=e-a)>0?i=i.charAt(0)+"."+i.slice(1)+Mn(r):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s.e<0?"e":"e+")+s.e):n<0?(i="0."+Mn(-n-1)+i,e&&(r=e-a)>0&&(i+=Mn(r))):n>=a?(i+=Mn(n+1-a),e&&(r=e-n-1)>0&&(i=i+"."+Mn(r))):((r=n+1)<a&&(i=i.slice(0,r)+"."+i.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(i+="."),i+=Mn(r))),i}function Ts(s,t){var e=s[0];for(t*=Et;e>=10;e/=10)t++;return t}function $s(s,t,e){if(t>c_)throw St=!0,e&&(s.precision=e),Error(hc);return Dt(new s(Ss),t,1,!0)}function Vr(s,t,e){if(t>xa)throw Error(hc);return Dt(new s(Os),t,e,!0)}function mc(s){var t=s.length-1,e=t*Et+1;if(t=s[t],t){for(;t%10==0;t/=10)e--;for(t=s[0];t>=10;t/=10)e++}return e}function Mn(s){for(var t="";s--;)t+="0";return t}function gc(s,t,e,r){var n,i=new s(1),a=Math.ceil(r/Et+4);for(St=!1;;){if(e%2&&(i=i.times(t),bc(i.d,a)&&(n=!0)),e=Xe(e/2),e===0){e=i.d.length-1,n&&i.d[e]===0&&++i.d[e];break}t=t.times(t),bc(t.d,a)}return St=!0,i}function vc(s){return s.d[s.d.length-1]&1}function yc(s,t,e){for(var r,n=new s(t[0]),i=0;++i<t.length;)if(r=new s(t[i]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function Ea(s,t){var e,r,n,i,a,l,c,h=0,d=0,f=0,p=s.constructor,g=p.rounding,y=p.precision;if(!s.d||!s.d[0]||s.e>17)return new p(s.d?s.d[0]?s.s<0?0:1/0:1:s.s?s.s<0?0:s:NaN);for(t==null?(St=!1,c=y):c=t,l=new p(.03125);s.e>-2;)s=s.times(l),f+=5;for(r=Math.log(Pe(2,f))/Math.LN10*2+5|0,c+=r,e=i=a=new p(1),p.precision=c;;){if(i=Dt(i.times(s),c,1),e=e.times(++d),l=a.plus(he(i,e,c,1)),Ke(l.d).slice(0,c)===Ke(a.d).slice(0,c)){for(n=f;n--;)a=Dt(a.times(a),c,1);if(t==null)if(h<3&&Gi(a.d,c-r,g,h))p.precision=c+=10,e=i=l=new p(1),d=0,h++;else return Dt(a,p.precision=y,g,St=!0);else return p.precision=y,a}a=l}}function Nn(s,t){var e,r,n,i,a,l,c,h,d,f,p,g=1,y=10,m=s,w=m.d,v=m.constructor,x=v.rounding,b=v.precision;if(m.s<0||!w||!w[0]||!m.e&&w[0]==1&&w.length==1)return new v(w&&!w[0]?-1/0:m.s!=1?NaN:w?0:m);if(t==null?(St=!1,d=b):d=t,v.precision=d+=y,e=Ke(w),r=e.charAt(0),Math.abs(i=m.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)m=m.times(s),e=Ke(m.d),r=e.charAt(0),g++;i=m.e,r>1?(m=new v("0."+e),i++):m=new v(r+"."+e.slice(1))}else return h=$s(v,d+2,b).times(i+""),m=Nn(new v(r+"."+e.slice(1)),d-y).plus(h),v.precision=b,t==null?Dt(m,b,x,St=!0):m;for(f=m,c=a=m=he(m.minus(1),m.plus(1),d,1),p=Dt(m.times(m),d,1),n=3;;){if(a=Dt(a.times(p),d,1),h=c.plus(he(a,new v(n),d,1)),Ke(h.d).slice(0,d)===Ke(c.d).slice(0,d))if(c=c.times(2),i!==0&&(c=c.plus($s(v,d+2,b).times(i+""))),c=he(c,new v(g),d,1),t==null)if(Gi(c.d,d-y,x,l))v.precision=d+=y,h=a=m=he(f.minus(1),f.plus(1),d,1),p=Dt(m.times(m),d,1),n=l=1;else return Dt(c,v.precision=b,x,St=!0);else return v.precision=b,c;c=h,n+=2}}function wc(s){return String(s.s*s.s/0)}function Aa(s,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,s.e=e=e-r-1,s.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&s.d.push(+t.slice(0,r)),n-=Et;r<n;)s.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";s.d.push(+t),St&&(s.e>s.constructor.maxE?(s.d=null,s.e=NaN):s.e<s.constructor.minE&&(s.e=0,s.d=[0]))}else s.e=0,s.d=[0];return s}function h_(s,t){var e,r,n,i,a,l,c,h,d;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),_c.test(t))return Aa(s,t)}else if(t==="Infinity"||t==="NaN")return+t||(s.s=NaN),s.e=NaN,s.d=null,s;if(a_.test(t))e=16,t=t.toLowerCase();else if(o_.test(t))e=2;else if(u_.test(t))e=8;else throw Error(Fn+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),a=i>=0,r=s.constructor,a&&(t=t.replace(".",""),l=t.length,i=l-i,n=gc(r,new r(e),i,i*2)),h=Is(t,e,jr),d=h.length-1,i=d;h[i]===0;--i)h.pop();return i<0?new r(s.s*0):(s.e=Ts(h,d),s.d=h,St=!1,a&&(s=he(s,n,l*4)),c&&(s=s.times(Math.abs(c)<54?Pe(2,c):gi.pow(2,c))),St=!0,s)}function d_(s,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:mi(s,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ls(5,e)),t=mi(s,2,t,t);for(var n,i=new s(5),a=new s(16),l=new s(20);e--;)n=t.times(t),t=t.times(i.plus(n.times(a.times(n).minus(l))));return t}function mi(s,t,e,r,n){var i,a,l,c,h=s.precision,d=Math.ceil(h/Et);for(St=!1,c=e.times(e),l=new s(r);;){if(a=he(l.times(c),new s(t++*t++),h,1),l=n?r.plus(a):r.minus(a),r=he(a.times(c),new s(t++*t++),h,1),a=l.plus(r),a.d[d]!==void 0){for(i=d;a.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=r,r=a,a=i}return St=!0,a.d.length=d+1,a}function Ls(s,t){for(var e=s;--t;)e*=s;return e}function Dc(s,t){var e,r=t.s<0,n=Vr(s,s.precision,1),i=n.times(.5);if(t=t.abs(),t.lte(i))return ln=r?4:1,t;if(e=t.divToInt(n),e.isZero())ln=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(i))return ln=vc(e)?r?2:3:r?4:1,t;ln=vc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Ca(s,t,e,r){var n,i,a,l,c,h,d,f,p,g=s.constructor,y=e!==void 0;if(y?(lr(e,1,Cn),r===void 0?r=g.rounding:lr(r,0,8)):(e=g.precision,r=g.rounding),!s.isFinite())d=wc(s);else{for(d=en(s),a=d.indexOf("."),y?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(d=d.replace(".",""),p=new g(1),p.e=d.length-a,p.d=Is(en(p),10,n),p.e=p.d.length),f=Is(d,10,n),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])d=y?"0p+0":"0";else{if(a<0?i--:(s=new g(s),s.d=f,s.e=i,s=he(s,p,e,r,0,n),f=s.d,i=s.e,h=fc),a=f[e],l=n/2,h=h||f[e+1]!==void 0,h=r<4?(a!==void 0||h)&&(r===0||r===(s.s<0?3:2)):a>l||a===l&&(r===4||h||r===6&&f[e-1]&1||r===(s.s<0?8:7)),f.length=e,h)for(;++f[--e]>n-1;)f[e]=0,e||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(a=0,d="";a<c;a++)d+=Da.charAt(f[a]);if(y){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)d+="0";for(f=Is(d,n,t),c=f.length;!f[c-1];--c);for(a=1,d="1.";a<c;a++)d+=Da.charAt(f[a])}else d=d.charAt(0)+"."+d.slice(1);d=d+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)d="0"+d;d="0."+d}else if(++i>c)for(i-=c;i--;)d+="0";else i<c&&(d=d.slice(0,i)+"."+d.slice(i))}d=(t==16?"0x":t==2?"0b":t==8?"0o":"")+d}return s.s<0?"-"+d:d}function bc(s,t){if(s.length>t)return s.length=t,!0}function p_(s){return new this(s).abs()}function __(s){return new this(s).acos()}function m_(s){return new this(s).acosh()}function g_(s,t){return new this(s).plus(t)}function v_(s){return new this(s).asin()}function y_(s){return new this(s).asinh()}function w_(s){return new this(s).atan()}function D_(s){return new this(s).atanh()}function b_(s,t){s=new this(s),t=new this(t);var e,r=this.precision,n=this.rounding,i=r+4;return!s.s||!t.s?e=new this(NaN):!s.d&&!t.d?(e=Vr(this,i,1).times(t.s>0?.25:.75),e.s=s.s):!t.d||s.isZero()?(e=t.s<0?Vr(this,r,n):new this(0),e.s=s.s):!s.d||t.isZero()?(e=Vr(this,i,1).times(.5),e.s=s.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(he(s,t,i,1)),t=Vr(this,i,1),this.precision=r,this.rounding=n,e=s.s<0?e.minus(t):e.plus(t)):e=this.atan(he(s,t,i,1)),e}function x_(s){return new this(s).cbrt()}function E_(s){return Dt(s=new this(s),s.e+1,2)}function A_(s,t,e){return new this(s).clamp(t,e)}function C_(s){if(!s||typeof s!="object")throw Error(Bs+"Object expected");var t,e,r,n=s.defaults===!0,i=["precision",1,Cn,"rounding",0,8,"toExpNeg",-_i,0,"toExpPos",0,_i,"maxE",0,_i,"minE",-_i,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(e=i[t],n&&(this[e]=ba[e]),(r=s[e])!==void 0)if(Xe(r)===r&&r>=i[t+1]&&r<=i[t+2])this[e]=r;else throw Error(Fn+e+": "+r);if(e="crypto",n&&(this[e]=ba[e]),(r=s[e])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(dc);else this[e]=!1;else throw Error(Fn+e+": "+r);return this}function F_(s){return new this(s).cos()}function M_(s){return new this(s).cosh()}function xc(s){var t,e,r;function n(i){var a,l,c,h=this;if(!(h instanceof n))return new n(i);if(h.constructor=n,Ec(i)){h.s=i.s,St?!i.d||i.e>n.maxE?(h.e=NaN,h.d=null):i.e<n.minE?(h.e=0,h.d=[0]):(h.e=i.e,h.d=i.d.slice()):(h.e=i.e,h.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){h.s=1/i<0?-1:1,h.e=0,h.d=[0];return}if(i<0?(i=-i,h.s=-1):h.s=1,i===~~i&&i<1e7){for(a=0,l=i;l>=10;l/=10)a++;St?a>n.maxE?(h.e=NaN,h.d=null):a<n.minE?(h.e=0,h.d=[0]):(h.e=a,h.d=[i]):(h.e=a,h.d=[i]);return}else if(i*0!==0){i||(h.s=NaN),h.e=NaN,h.d=null;return}return Aa(h,i.toString())}else if(c!=="string")throw Error(Fn+i);return(l=i.charCodeAt(0))===45?(i=i.slice(1),h.s=-1):(l===43&&(i=i.slice(1)),h.s=1),_c.test(i)?Aa(h,i):h_(h,i)}if(n.prototype=it,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=C_,n.clone=xc,n.isDecimal=Ec,n.abs=p_,n.acos=__,n.acosh=m_,n.add=g_,n.asin=v_,n.asinh=y_,n.atan=w_,n.atanh=D_,n.atan2=b_,n.cbrt=x_,n.ceil=E_,n.clamp=A_,n.cos=F_,n.cosh=M_,n.div=N_,n.exp=S_,n.floor=O_,n.hypot=B_,n.ln=I_,n.log=T_,n.log10=L_,n.log2=$_,n.max=R_,n.min=P_,n.mod=z_,n.mul=k_,n.pow=q_,n.random=U_,n.round=W_,n.sign=j_,n.sin=V_,n.sinh=Y_,n.sqrt=Z_,n.sub=K_,n.sum=G_,n.tan=H_,n.tanh=J_,n.trunc=X_,s===void 0&&(s={}),s&&s.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)s.hasOwnProperty(e=r[t++])||(s[e]=this[e]);return n.config(s),n}function N_(s,t){return new this(s).div(t)}function S_(s){return new this(s).exp()}function O_(s){return Dt(s=new this(s),s.e+1,3)}function B_(){var s,t,e=new this(0);for(St=!1,s=0;s<arguments.length;)if(t=new this(arguments[s++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return St=!0,new this(1/0);e=t}return St=!0,e.sqrt()}function Ec(s){return s instanceof gi||s&&s.toStringTag===pc||!1}function I_(s){return new this(s).ln()}function T_(s,t){return new this(s).log(t)}function $_(s){return new this(s).log(2)}function L_(s){return new this(s).log(10)}function R_(){return yc(this,arguments,"lt")}function P_(){return yc(this,arguments,"gt")}function z_(s,t){return new this(s).mod(t)}function k_(s,t){return new this(s).mul(t)}function q_(s,t){return new this(s).pow(t)}function U_(s){var t,e,r,n,i=0,a=new this(1),l=[];if(s===void 0?s=this.precision:lr(s,1,Cn),r=Math.ceil(s/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)n=t[i],n>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)n=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,i):(l.push(n%1e7),i+=4);i=r/4}else throw Error(dc);else for(;i<r;)l[i++]=Math.random()*1e7|0;for(r=l[--i],s%=Et,r&&s&&(n=Pe(10,Et-s),l[i]=(r/n|0)*n);l[i]===0;i--)l.pop();if(i<0)e=0,l=[0];else{for(e=-1;l[0]===0;e-=Et)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=l,a}function W_(s){return Dt(s=new this(s),s.e+1,this.rounding)}function j_(s){return s=new this(s),s.d?s.d[0]?s.s:0*s.s:s.s||NaN}function V_(s){return new this(s).sin()}function Y_(s){return new this(s).sinh()}function Z_(s){return new this(s).sqrt()}function K_(s,t){return new this(s).sub(t)}function G_(){var s=0,t=arguments,e=new this(t[s]);for(St=!1;e.s&&++s<t.length;)e=e.plus(t[s]);return St=!0,Dt(e,this.precision,this.rounding)}function H_(s){return new this(s).tan()}function J_(s){return new this(s).tanh()}function X_(s){return Dt(s=new this(s),s.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var gi=it.constructor=xc(ba);Ss=new gi(Ss),Os=new gi(Os);var Q_="BigNumber",tm=["?on","config"],em=mt(Q_,tm,s=>{var{on:t,config:e}=s,r=gi.clone({precision:e.precision,modulo:gi.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},t&&t("config",function(n,i){n.precision!==i.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),Ac={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(s,t){(function(e){var r=Math.cosh||function(f){return Math.abs(f)<1e-9?1-f:(Math.exp(f)+Math.exp(-f))*.5},n=Math.sinh||function(f){return Math.abs(f)<1e-9?f:(Math.exp(f)-Math.exp(-f))*.5},i=function(f){var p=Math.PI/4;if(-p>f||f>p)return Math.cos(f)-1;var g=f*f;return g*(g*(g*(g*(g*(g*(g*(g/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(f,p){var g=Math.abs(f),y=Math.abs(p);return g<3e3&&y<3e3?Math.sqrt(g*g+y*y):(g<y?(g=y,y=f/p):y=p/f,g*Math.sqrt(1+y*y))},l=function(){throw SyntaxError("Invalid Param")};function c(f,p){var g=Math.abs(f),y=Math.abs(p);return f===0?Math.log(y):p===0?Math.log(g):g<3e3&&y<3e3?Math.log(f*f+p*p)*.5:(f=f/2,p=p/2,.5*Math.log(f*f+p*p)+Math.LN2)}var h=function(f,p){var g={re:0,im:0};if(f==null)g.re=g.im=0;else if(p!==void 0)g.re=f,g.im=p;else switch(typeof f){case"object":if("im"in f&&"re"in f)g.re=f.re,g.im=f.im;else if("abs"in f&&"arg"in f){if(!Number.isFinite(f.abs)&&Number.isFinite(f.arg))return d.INFINITY;g.re=f.abs*Math.cos(f.arg),g.im=f.abs*Math.sin(f.arg)}else if("r"in f&&"phi"in f){if(!Number.isFinite(f.r)&&Number.isFinite(f.phi))return d.INFINITY;g.re=f.r*Math.cos(f.phi),g.im=f.r*Math.sin(f.phi)}else f.length===2?(g.re=f[0],g.im=f[1]):l();break;case"string":g.im=g.re=0;var y=f.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),m=1,w=0;y===null&&l();for(var v=0;v<y.length;v++){var x=y[v];x===" "||x===" "||x===`
|
46
|
+
`||(x==="+"?m++:x==="-"?w++:x==="i"||x==="I"?(m+w===0&&l(),y[v+1]!==" "&&!isNaN(y[v+1])?(g.im+=parseFloat((w%2?"-":"")+y[v+1]),v++):g.im+=parseFloat((w%2?"-":"")+"1"),m=w=0):((m+w===0||isNaN(x))&&l(),y[v+1]==="i"||y[v+1]==="I"?(g.im+=parseFloat((w%2?"-":"")+x),v++):g.re+=parseFloat((w%2?"-":"")+x),m=w=0))}m+w>0&&l();break;case"number":g.im=0,g.re=f;break;default:l()}return isNaN(g.re)||isNaN(g.im),g};function d(f,p){if(!(this instanceof d))return new d(f,p);var g=h(f,p);this.re=g.re,this.im=g.im}d.prototype={re:0,im:0,sign:function(){var f=this.abs();return new d(this.re/f,this.im/f)},add:function(f,p){var g=new d(f,p);return this.isInfinite()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:new d(this.re+g.re,this.im+g.im)},sub:function(f,p){var g=new d(f,p);return this.isInfinite()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:new d(this.re-g.re,this.im-g.im)},mul:function(f,p){var g=new d(f,p);return this.isInfinite()&&g.isZero()||this.isZero()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:g.im===0&&this.im===0?new d(this.re*g.re,0):new d(this.re*g.re-this.im*g.im,this.re*g.im+this.im*g.re)},div:function(f,p){var g=new d(f,p);if(this.isZero()&&g.isZero()||this.isInfinite()&&g.isInfinite())return d.NAN;if(this.isInfinite()||g.isZero())return d.INFINITY;if(this.isZero()||g.isInfinite())return d.ZERO;f=this.re,p=this.im;var y=g.re,m=g.im,w,v;return m===0?new d(f/y,p/y):Math.abs(y)<Math.abs(m)?(v=y/m,w=y*v+m,new d((f*v+p)/w,(p*v-f)/w)):(v=m/y,w=m*v+y,new d((f+p*v)/w,(p-f*v)/w))},pow:function(f,p){var g=new d(f,p);if(f=this.re,p=this.im,g.isZero())return d.ONE;if(g.im===0){if(p===0&&f>0)return new d(Math.pow(f,g.re),0);if(f===0)switch((g.re%4+4)%4){case 0:return new d(Math.pow(p,g.re),0);case 1:return new d(0,Math.pow(p,g.re));case 2:return new d(-Math.pow(p,g.re),0);case 3:return new d(0,-Math.pow(p,g.re))}}if(f===0&&p===0&&g.re>0&&g.im>=0)return d.ZERO;var y=Math.atan2(p,f),m=c(f,p);return f=Math.exp(g.re*m-g.im*y),p=g.im*m+g.re*y,new d(f*Math.cos(p),f*Math.sin(p))},sqrt:function(){var f=this.re,p=this.im,g=this.abs(),y,m;if(f>=0){if(p===0)return new d(Math.sqrt(f),0);y=.5*Math.sqrt(2*(g+f))}else y=Math.abs(p)/Math.sqrt(2*(g-f));return f<=0?m=.5*Math.sqrt(2*(g-f)):m=Math.abs(p)/Math.sqrt(2*(g+f)),new d(y,p<0?-m:m)},exp:function(){var f=Math.exp(this.re);return this.im,new d(f*Math.cos(this.im),f*Math.sin(this.im))},expm1:function(){var f=this.re,p=this.im;return new d(Math.expm1(f)*Math.cos(p)+i(p),Math.exp(f)*Math.sin(p))},log:function(){var f=this.re,p=this.im;return new d(c(f,p),Math.atan2(p,f))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var f=this.re,p=this.im;return new d(Math.sin(f)*r(p),Math.cos(f)*n(p))},cos:function(){var f=this.re,p=this.im;return new d(Math.cos(f)*r(p),-Math.sin(f)*n(p))},tan:function(){var f=2*this.re,p=2*this.im,g=Math.cos(f)+r(p);return new d(Math.sin(f)/g,n(p)/g)},cot:function(){var f=2*this.re,p=2*this.im,g=Math.cos(f)-r(p);return new d(-Math.sin(f)/g,n(p)/g)},sec:function(){var f=this.re,p=this.im,g=.5*r(2*p)+.5*Math.cos(2*f);return new d(Math.cos(f)*r(p)/g,Math.sin(f)*n(p)/g)},csc:function(){var f=this.re,p=this.im,g=.5*r(2*p)-.5*Math.cos(2*f);return new d(Math.sin(f)*r(p)/g,-Math.cos(f)*n(p)/g)},asin:function(){var f=this.re,p=this.im,g=new d(p*p-f*f+1,-2*f*p).sqrt(),y=new d(g.re-p,g.im+f).log();return new d(y.im,-y.re)},acos:function(){var f=this.re,p=this.im,g=new d(p*p-f*f+1,-2*f*p).sqrt(),y=new d(g.re-p,g.im+f).log();return new d(Math.PI/2-y.im,y.re)},atan:function(){var f=this.re,p=this.im;if(f===0){if(p===1)return new d(0,1/0);if(p===-1)return new d(0,-1/0)}var g=f*f+(1-p)*(1-p),y=new d((1-p*p-f*f)/g,-2*f/g).log();return new d(-.5*y.im,.5*y.re)},acot:function(){var f=this.re,p=this.im;if(p===0)return new d(Math.atan2(1,f),0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).atan():new d(f!==0?f/0:0,p!==0?-p/0:0).atan()},asec:function(){var f=this.re,p=this.im;if(f===0&&p===0)return new d(0,1/0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).acos():new d(f!==0?f/0:0,p!==0?-p/0:0).acos()},acsc:function(){var f=this.re,p=this.im;if(f===0&&p===0)return new d(Math.PI/2,1/0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).asin():new d(f!==0?f/0:0,p!==0?-p/0:0).asin()},sinh:function(){var f=this.re,p=this.im;return new d(n(f)*Math.cos(p),r(f)*Math.sin(p))},cosh:function(){var f=this.re,p=this.im;return new d(r(f)*Math.cos(p),n(f)*Math.sin(p))},tanh:function(){var f=2*this.re,p=2*this.im,g=r(f)+Math.cos(p);return new d(n(f)/g,Math.sin(p)/g)},coth:function(){var f=2*this.re,p=2*this.im,g=r(f)-Math.cos(p);return new d(n(f)/g,-Math.sin(p)/g)},csch:function(){var f=this.re,p=this.im,g=Math.cos(2*p)-r(2*f);return new d(-2*n(f)*Math.cos(p)/g,2*r(f)*Math.sin(p)/g)},sech:function(){var f=this.re,p=this.im,g=Math.cos(2*p)+r(2*f);return new d(2*r(f)*Math.cos(p)/g,-2*n(f)*Math.sin(p)/g)},asinh:function(){var f=this.im;this.im=-this.re,this.re=f;var p=this.asin();return this.re=-this.im,this.im=f,f=p.re,p.re=-p.im,p.im=f,p},acosh:function(){var f=this.acos();if(f.im<=0){var p=f.re;f.re=-f.im,f.im=p}else{var p=f.im;f.im=-f.re,f.re=p}return f},atanh:function(){var f=this.re,p=this.im,g=f>1&&p===0,y=1-f,m=1+f,w=y*y+p*p,v=w!==0?new d((m*y-p*p)/w,(p*y+m*p)/w):new d(f!==-1?f/0:0,p!==0?p/0:0),x=v.re;return v.re=c(v.re,v.im)/2,v.im=Math.atan2(v.im,x)/2,g&&(v.im=-v.im),v},acoth:function(){var f=this.re,p=this.im;if(f===0&&p===0)return new d(0,Math.PI/2);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).atanh():new d(f!==0?f/0:0,p!==0?-p/0:0).atanh()},acsch:function(){var f=this.re,p=this.im;if(p===0)return new d(f!==0?Math.log(f+Math.sqrt(f*f+1)):1/0,0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).asinh():new d(f!==0?f/0:0,p!==0?-p/0:0).asinh()},asech:function(){var f=this.re,p=this.im;if(this.isZero())return d.INFINITY;var g=f*f+p*p;return g!==0?new d(f/g,-p/g).acosh():new d(f!==0?f/0:0,p!==0?-p/0:0).acosh()},inverse:function(){if(this.isZero())return d.INFINITY;if(this.isInfinite())return d.ZERO;var f=this.re,p=this.im,g=f*f+p*p;return new d(f/g,-p/g)},conjugate:function(){return new d(this.re,-this.im)},neg:function(){return new d(-this.re,-this.im)},ceil:function(f){return f=Math.pow(10,f||0),new d(Math.ceil(this.re*f)/f,Math.ceil(this.im*f)/f)},floor:function(f){return f=Math.pow(10,f||0),new d(Math.floor(this.re*f)/f,Math.floor(this.im*f)/f)},round:function(f){return f=Math.pow(10,f||0),new d(Math.round(this.re*f)/f,Math.round(this.im*f)/f)},equals:function(f,p){var g=new d(f,p);return Math.abs(g.re-this.re)<=d.EPSILON&&Math.abs(g.im-this.im)<=d.EPSILON},clone:function(){return new d(this.re,this.im)},toString:function(){var f=this.re,p=this.im,g="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(f)<d.EPSILON&&(f=0),Math.abs(p)<d.EPSILON&&(p=0),p===0?g+f:(f!==0?(g+=f,g+=" ",p<0?(p=-p,g+="-"):g+="+",g+=" "):p<0&&(p=-p,g+="-"),p!==1&&(g+=p),g+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},d.ZERO=new d(0,0),d.ONE=new d(1,0),d.I=new d(0,1),d.PI=new d(Math.PI,0),d.E=new d(Math.E,0),d.INFINITY=new d(1/0,1/0),d.NAN=new d(NaN,NaN),d.EPSILON=1e-15,Object.defineProperty(d,"__esModule",{value:!0}),d.default=d,d.Complex=d,s.exports=d})()})(Ac);var rm=Ac.exports,Ge=Gt(rm),nm="Complex",im=[],sm=mt(nm,im,()=>(Object.defineProperty(Ge,"name",{value:"Complex"}),Ge.prototype.constructor=Ge,Ge.prototype.type="Complex",Ge.prototype.isComplex=!0,Ge.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Ge.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Ge.prototype.format=function(s){var t="",e=this.im,r=this.re,n=ha(this.re,s),i=ha(this.im,s),a=pe(s)?s:s?s.precision:null;if(a!==null){var l=Math.pow(10,-a);Math.abs(r/e)<l&&(r=0),Math.abs(e/r)<l&&(e=0)}return e===0?t=n:r===0?e===1?t="i":e===-1?t="-i":t=i+"i":e<0?e===-1?t=n+" - i":t=n+" - "+i.substring(1)+"i":e===1?t=n+" + i":t=n+" + "+i+"i",t},Ge.fromPolar=function(s){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return Ge(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(pe(e)){if(zl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),pe(r))return new Ge({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")}},Ge.prototype.valueOf=Ge.prototype.toString,Ge.fromJSON=function(s){return new Ge(s)},Ge.compare=function(s,t){return s.re>t.re?1:s.re<t.re?-1:s.im>t.im?1:s.im<t.im?-1:0},Ge),{isClass:!0}),Cc={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(s,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function i(v,x){if(isNaN(v=parseInt(v,10)))throw m();return v*x}function a(v,x){if(x===0)throw y();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var N=p(v,x);return b.n=v/N,b.d=x/N,b}function l(v){for(var x={},b=v,N=2,E=4;E<=b;){for(;b%N===0;)b/=N,x[N]=(x[N]||0)+1;E+=1+2*N++}return b!==v?b>1&&(x[b]=(x[b]||0)+1):x[v]=(x[v]||0)+1,x}var c=function(v,x){var b=0,N=1,E=1,A=0,M=0,S=0,T=1,F=1,B=0,R=1,U=1,q=1,W=1e7,z;if(v!=null)if(x!==void 0){if(b=v,N=x,E=b*N,b%1!==0||N%1!==0)throw w()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw m();E=b*N;break}case"number":{if(v<0&&(E=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(F=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=F);R<=W&&q<=W;)if(z=(B+U)/(R+q),v===z){R+q<=W?(b=B+U,N=R+q):q>R?(b=U,N=q):(b=B,N=R);break}else v>z?(B+=U,R+=q):(U+=B,q+=R),R>W?(b=U,N=q):(b=B,N=R);b*=F}else(isNaN(v)||isNaN(x))&&(N=b=NaN);break}case"string":{if(R=v.match(/\d+|./g),R===null)throw m();if(R[B]==="-"?(E=-1,B++):R[B]==="+"&&B++,R.length===B+1?M=i(R[B++],E):R[B+1]==="."||R[B]==="."?(R[B]!=="."&&(A=i(R[B++],E)),B++,(B+1===R.length||R[B+1]==="("&&R[B+3]===")"||R[B+1]==="'"&&R[B+3]==="'")&&(M=i(R[B],E),T=Math.pow(10,R[B].length),B++),(R[B]==="("&&R[B+2]===")"||R[B]==="'"&&R[B+2]==="'")&&(S=i(R[B+1],E),F=Math.pow(10,R[B+1].length)-1,B+=3)):R[B+1]==="/"||R[B+1]===":"?(M=i(R[B],E),T=i(R[B+2],1),B+=3):R[B+3]==="/"&&R[B+1]===" "&&(A=i(R[B],E),M=i(R[B+2],E),T=i(R[B+4],1),B+=5),R.length<=B){N=T*F,E=b=S+N*A+F*M;break}}default:throw m()}if(N===0)throw y();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function h(v,x,b){for(var N=1;x>0;v=v*v%b,x>>=1)x&1&&(N=N*v%b);return N}function d(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,N=1;b!==1;N++)if(b=b*10%x,N>r)return 0;return N}function f(v,x,b){for(var N=1,E=h(10,b,x),A=0;A<300;A++){if(N===E)return A;N=N*10%x,E=E*10%x}return 0}function p(v,x){if(!v)return x;if(!x)return v;for(;;){if(v%=x,!v)return x;if(x%=v,!x)return v}}function g(v,x){if(c(v,x),this instanceof g)v=p(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var y=function(){return new Error("Division by Zero")},m=function(){return new Error("Invalid argument")},w=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,x){return c(v,x),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,x){return c(v,x),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,x){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,x),n.n===0&&this.d===0)throw y();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,x){return c(v,x),a(p(n.n,this.n)*p(n.d,this.d),n.d*this.d)},lcm:function(v,x){return c(v,x),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,p(n.n,this.n)*p(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,x){if(c(v,x),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=l(this.n),N=l(this.d),E=1,A=1;for(var M in b)if(M!=="1"){if(M==="0"){E=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;E*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;A*=Math.pow(M,N[M])}return n.s<0?a(A,E):a(E,A)},equals:function(v,x){return c(v,x),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,x){c(v,x);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var x=this.abs(),b=x.toContinued(),N=1;N<b.length;N++){for(var E=a(b[N-1],1),A=N-2;A>=0;A--)E=E.inverse().add(b[A]);if(Math.abs(E.sub(x).valueOf())<v)return E.mul(this.s)}return this},divisible:function(v,x){return c(v,x),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var x,b="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,b+=" ",N%=E),b+=N,b+="/",b+=E),b},toLatex:function(v){var x,b="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,N%=E),b+="\\frac{",b+=N,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,N=[];if(isNaN(x)||isNaN(b))return N;do N.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return N},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var N=d(x,b),E=f(x,b,N),A=this.s<0?"-":"";if(A+=x/b|0,x%=b,x*=10,x&&(A+="."),N){for(var M=E;M--;)A+=x/b|0,x%=b,x*=10;A+="(";for(var M=N;M--;)A+=x/b|0,x%=b,x*=10;A+=")"}else for(var M=v;x&&M--;)A+=x/b|0,x%=b,x*=10;return A}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,s.exports=g})()})(Cc);var om=Cc.exports,cn=Gt(om),am="Fraction",um=[],lm=mt(am,um,()=>(Object.defineProperty(cn,"name",{value:"Fraction"}),cn.prototype.constructor=cn,cn.prototype.type="Fraction",cn.prototype.isFraction=!0,cn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},cn.fromJSON=function(s){return new cn(s)},cn),{isClass:!0}),cm="Matrix",fm=[],hm=mt(cm,fm,()=>{function s(){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator")}return s.prototype.type="Matrix",s.prototype.isMatrix=!0,s.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},s.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},s.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},s.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},s.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},s.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},s.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},s.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},s.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},s.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},s.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},s.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},s.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},s.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},s.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},s.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},s.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},s},{isClass:!0});function Fc(s){return Object.keys(s.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var dm="DenseMatrix",pm=["Matrix"],_m=mt(dm,pm,s=>{var{Matrix:t}=s;function e(d,f){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!tn(f))throw new Error("Invalid datatype: "+f);if(ve(d))d.type==="DenseMatrix"?(this._data=oe(d._data),this._size=oe(d._size),this._datatype=f||d._datatype):(this._data=d.toArray(),this._size=d.size(),this._datatype=f||d._datatype);else if(d&&Ee(d.data)&&Ee(d.size))this._data=d.data,this._size=d.size,ec(this._data,this._size),this._datatype=f||d.datatype;else if(Ee(d))this._data=h(d),this._size=Ie(this._data),ec(this._data,this._size),this._datatype=f;else{if(d)throw new TypeError("Unsupported type of data ("+En(d)+")");this._data=[],this._size=[0],this._datatype=f}}e.prototype=new t,e.prototype.createDenseMatrix=function(d,f){return new e(d,f)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Fs(this._data,En)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(d,f){return new e(d,f)},e.prototype.subset=function(d,f,p){switch(arguments.length){case 1:return r(this,d);case 2:case 3:return i(this,d,f,p);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(d){if(!Ee(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new Ht(d.length,this._size.length);for(var f=0;f<d.length;f++)Ae(d[f],this._size[f]);for(var p=this._data,g=0,y=d.length;g<y;g++){var m=d[g];Ae(m,p.length),p=p[m]}return p},e.prototype.set=function(d,f,p){if(!Ee(d))throw new TypeError("Array expected");if(d.length<this._size.length)throw new Ht(d.length,this._size.length,"<");var g,y,m,w=d.map(function(x){return x+1});c(this,w,p);var v=this._data;for(g=0,y=d.length-1;g<y;g++)m=d[g],Ae(m,v.length),v=v[m];return m=d[d.length-1],Ae(m,v.length),v[m]=f,this};function r(d,f){if(!la(f))throw new TypeError("Invalid index");var p=f.isScalar();if(p)return d.get(f.min());var g=f.size();if(g.length!==d._size.length)throw new Ht(g.length,d._size.length);for(var y=f.min(),m=f.max(),w=0,v=d._size.length;w<v;w++)Ae(y[w],d._size[w]),Ae(m[w],d._size[w]);return new e(n(d._data,f,g.length,0),d._datatype)}function n(d,f,p,g){var y=g===p-1,m=f.dimension(g);return y?m.map(function(w){return Ae(w,d.length),d[w]}).valueOf():m.map(function(w){Ae(w,d.length);var v=d[w];return n(v,f,p,g+1)}).valueOf()}function i(d,f,p,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var y=f.size(),m=f.isScalar(),w;if(ve(p)?(w=p.size(),p=p.valueOf()):w=Ie(p),m){if(w.length!==0)throw new TypeError("Scalar expected");d.set(f.min(),p,g)}else{if(!hi(w,y))try{w.length===0?p=ac([p],y):p=ac(p,y),w=Ie(p)}catch{}if(y.length<d._size.length)throw new Ht(y.length,d._size.length,"<");if(w.length<y.length){for(var v=0,x=0;y[v]===1&&w[v]===1;)v++;for(;y[v]===1;)x++,v++;p=nc(p,y.length,x,w)}if(!hi(y,w))throw new Ht(y,w,">");var b=f.max().map(function(A){return A+1});c(d,b,g);var N=y.length,E=0;a(d._data,f,p,N,E)}return d}function a(d,f,p,g,y){var m=y===g-1,w=f.dimension(y);m?w.forEach(function(v,x){Ae(v),d[v]=p[x[0]]}):w.forEach(function(v,x){Ae(v),a(d[v],f,p[x[0]],g,y+1)})}e.prototype.resize=function(d,f,p){if(!Zi(d))throw new TypeError("Array or Matrix expected");var g=d.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),y=p?this.clone():this;return l(y,g,f)};function l(d,f,p){if(f.length===0){for(var g=d._data;Ee(g);)g=g[0];return g}return d._size=f.slice(0),d._data=pa(d._data,d._size,p),d}e.prototype.reshape=function(d,f){var p=f?this.clone():this;p._data=ma(p._data,d);var g=p._size.reduce((y,m)=>y*m);return p._size=ga(d,g),p};function c(d,f,p){for(var g=d._size.slice(0),y=!1;g.length<f.length;)g.push(0),y=!0;for(var m=0,w=f.length;m<w;m++)f[m]>g[m]&&(g[m]=f[m],y=!0);y&&l(d,g,p)}e.prototype.clone=function(){var d=new e({data:oe(this._data),size:oe(this._size),datatype:this._datatype});return d},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(d){var f=this,p=Fc(d),g=function w(v,x){return Ee(v)?v.map(function(b,N){return w(b,x.concat(N))}):p===1?d(v):p===2?d(v,x):d(v,x,f)},y=g(this._data,[]),m=this._datatype!==void 0?Fs(y,En):void 0;return new e(y,m)},e.prototype.forEach=function(d){var f=this,p=function g(y,m){Ee(y)?y.forEach(function(w,v){g(w,m.concat(v))}):d(y,m,f)};p(this._data,[])},e.prototype[Symbol.iterator]=function*(){var d=function*f(p,g){if(Ee(p))for(var y=0;y<p.length;y++)yield*f(p[y],g.concat(y));else yield{value:p,index:g}};yield*d(this._data,[])},e.prototype.rows=function(){var d=[],f=this.size();if(f.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var p=this._data;for(var g of p)d.push(new e([g],this._datatype));return d},e.prototype.columns=function(){var d=this,f=[],p=this.size();if(p.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,y=function(v){var x=g.map(b=>[b[v]]);f.push(new e(x,d._datatype))},m=0;m<p[1];m++)y(m);return f},e.prototype.toArray=function(){return oe(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(d){return fe(this._data,d)},e.prototype.toString=function(){return fe(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(d){if(d){if(Se(d)&&(d=d.toNumber()),!pe(d)||!De(d))throw new TypeError("The parameter k must be an integer number")}else d=0;for(var f=d>0?d:0,p=d<0?-d:0,g=this._size[0],y=this._size[1],m=Math.min(g-p,y-f),w=[],v=0;v<m;v++)w[v]=this._data[v+p][v+f];return new e({data:w,size:[m],datatype:this._datatype})},e.diagonal=function(d,f,p,g){if(!Ee(d))throw new TypeError("Array expected, size parameter");if(d.length!==2)throw new Error("Only two dimensions matrix are supported");if(d=d.map(function(M){if(Se(M)&&(M=M.toNumber()),!pe(M)||!De(M)||M<1)throw new Error("Size values must be positive integers");return M}),p){if(Se(p)&&(p=p.toNumber()),!pe(p)||!De(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var y=p>0?p:0,m=p<0?-p:0,w=d[0],v=d[1],x=Math.min(w-m,v-y),b;if(Ee(f)){if(f.length!==x)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(ve(f)){var N=f.size();if(N.length!==1||N[0]!==x)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=Se(b(0))?b(0).mul(0):0);var E=[];if(d.length>0){E=pa(E,d,g);for(var A=0;A<x;A++)E[A+m][A+y]=b(A)}return new e({data:E,size:[w,v]})},e.fromJSON=function(d){return new e(d)},e.prototype.swapRows=function(d,f){if(!pe(d)||!De(d)||!pe(f)||!De(f))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ae(d,this._size[0]),Ae(f,this._size[0]),e._swapRows(d,f,this._data),this},e._swapRows=function(d,f,p){var g=p[d];p[d]=p[f],p[f]=g};function h(d){return ve(d)?h(d.valueOf()):Ee(d)?d.map(h):d}return e},{isClass:!0});function mm(s){var t=s.length,e=s[0].length,r,n,i=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(s[r][n]);i.push(a)}return i}function Rs(s){for(var t=0;t<s.length;t++)if(Zi(s[t]))return!0;return!1}function Hi(s,t){ve(s)&&(s=s.valueOf());for(var e=0,r=s.length;e<r;e++){var n=s[e];Array.isArray(n)?Hi(n,t):t(n)}}function Yr(s,t,e){return s&&typeof s.map=="function"?s.map(function(r){return Yr(r,t)}):t(s)}function Fa(s,t,e){var r=Array.isArray(s)?Ie(s):s.size();if(t<0||t>=r.length)throw new An(t,r.length);return ve(s)?s.create(Ps(s.valueOf(),t,e)):Ps(s,t,e)}function Ps(s,t,e){var r,n,i,a;if(t<=0)if(Array.isArray(s[0])){for(a=mm(s),n=[],r=0;r<a.length;r++)n[r]=Ps(a[r],t-1,e);return n}else{for(i=s[0],r=1;r<s.length;r++)i=e(i,s[r]);return i}else{for(n=[],r=0;r<s.length;r++)n[r]=Ps(s[r],t-1,e);return n}}var Mc="isInteger",gm=["typed"],vm=mt(Mc,gm,s=>{var{typed:t}=s;return t(Mc,{number:De,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),Nc="number",zs="number, number";function Sc(s){return Math.abs(s)}Sc.signature=Nc;function Oc(s,t){return s+t}Oc.signature=zs;function Bc(s,t){return s-t}Bc.signature=zs;function Ic(s,t){return s*t}Ic.signature=zs;function Tc(s){return-s}Tc.signature=Nc;function $c(s,t){return s*s<1&&t===1/0||s*s>1&&t===-1/0?0:Math.pow(s,t)}$c.signature=zs;var Lc="number";function Rc(s){return s===0}Rc.signature=Lc;function Pc(s){return Number.isNaN(s)}Pc.signature=Lc;var zc="isNumeric",ym=["typed"],wm=mt(zc,ym,s=>{var{typed:t}=s;return t(zc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),kc="isZero",Dm=["typed"],bm=mt(kc,Dm,s=>{var{typed:t}=s;return t(kc,{number:Rc,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=>Yr(r,e))})}),qc="isNaN",xm=["typed"],Em=mt(qc,xm,s=>{var{typed:t}=s;return t(qc,{number:Pc,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 Yr(r,Number.isNaN)}})});function ks(s,t,e){if(e==null)return s.eq(t);if(s.eq(t))return!0;if(s.isNaN()||t.isNaN())return!1;if(s.isFinite()&&t.isFinite()){var r=s.minus(t).abs();if(r.isZero())return!0;var n=s.constructor.max(s.abs(),t.abs());return r.lte(n.times(e))}return!1}function Am(s,t,e){return Gn(s.re,t.re,e)&&Gn(s.im,t.im,e)}var qs=mt("compareUnits",["typed"],s=>{var{typed:t}=s;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Us="equalScalar",Cm=["typed","config"],Fm=mt(Us,Cm,s=>{var{typed:t,config:e}=s,r=qs({typed:t});return t(Us,{"boolean, boolean":function(i,a){return i===a},"number, number":function(i,a){return Gn(i,a,e.epsilon)},"BigNumber, BigNumber":function(i,a){return i.eq(a)||ks(i,a,e.epsilon)},"Fraction, Fraction":function(i,a){return i.equals(a)},"Complex, Complex":function(i,a){return Am(i,a,e.epsilon)}},r)});mt(Us,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Us,{"number, number":function(n,i){return Gn(n,i,e.epsilon)}})});var Mm="SparseMatrix",Nm=["typed","equalScalar","Matrix"],Sm=mt(Mm,Nm,s=>{var{typed:t,equalScalar:e,Matrix:r}=s;function n(m,w){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(w&&!tn(w))throw new Error("Invalid datatype: "+w);if(ve(m))i(this,m,w);else if(m&&Ee(m.index)&&Ee(m.ptr)&&Ee(m.size))this._values=m.values,this._index=m.index,this._ptr=m.ptr,this._size=m.size,this._datatype=w||m.datatype;else if(Ee(m))a(this,m,w);else{if(m)throw new TypeError("Unsupported type of data ("+En(m)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=w}}function i(m,w,v){w.type==="SparseMatrix"?(m._values=w._values?oe(w._values):void 0,m._index=oe(w._index),m._ptr=oe(w._ptr),m._size=oe(w._size),m._datatype=v||w._datatype):a(m,w.valueOf(),v||w._datatype)}function a(m,w,v){m._values=[],m._index=[],m._ptr=[],m._datatype=v;var x=w.length,b=0,N=e,E=0;if(tn(v)&&(N=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var A=0;do{m._ptr.push(m._index.length);for(var M=0;M<x;M++){var S=w[M];if(Ee(S)){if(A===0&&b<S.length&&(b=S.length),A<S.length){var T=S[A];N(T,E)||(m._values.push(T),m._index.push(M))}}else A===0&&b<1&&(b=1),N(S,E)||(m._values.push(S),m._index.push(M))}A++}while(A<b)}m._ptr.push(m._index.length),m._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(m,w){return new n(m,w)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Fs(this._values,En)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(m,w){return new n(m,w)},n.prototype.density=function(){var m=this._size[0],w=this._size[1];return m!==0&&w!==0?this._index.length/(m*w):0},n.prototype.subset=function(m,w,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,m);case 2:case 3:return c(this,m,w,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(m,w){if(!la(w))throw new TypeError("Invalid index");var v=w.isScalar();if(v)return m.get(w.min());var x=w.size();if(x.length!==m._size.length)throw new Ht(x.length,m._size.length);var b,N,E,A,M=w.min(),S=w.max();for(b=0,N=m._size.length;b<N;b++)Ae(M[b],m._size[b]),Ae(S[b],m._size[b]);var T=m._values,F=m._index,B=m._ptr,R=w.dimension(0),U=w.dimension(1),q=[],W=[];R.forEach(function(X,Q){W[X]=Q[0],q[X]=!0});var z=T?[]:void 0,K=[],Z=[];return U.forEach(function(X){for(Z.push(K.length),E=B[X],A=B[X+1];E<A;E++)b=F[E],q[b]===!0&&(K.push(W[b]),z&&z.push(T[E]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:x,datatype:m._datatype})}function c(m,w,v,x){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),N=w.isScalar(),E;if(ve(v)?(E=v.size(),v=v.toArray()):E=Ie(v),N){if(E.length!==0)throw new TypeError("Scalar expected");m.set(w.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Ht(b.length,m._size.length,"<");if(E.length<b.length){for(var A=0,M=0;b[A]===1&&E[A]===1;)A++;for(;b[A]===1;)M++,A++;v=nc(v,b.length,M,E)}if(!hi(b,E))throw new Ht(b,E,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(B,R){Ae(B),m.set([B,0],v[R[0]],x)})}else{var T=w.dimension(0),F=w.dimension(1);T.forEach(function(B,R){Ae(B),F.forEach(function(U,q){Ae(U),m.set([B,U],v[R[0]][q[0]],x)})})}}return m}n.prototype.get=function(m){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var w=m[0],v=m[1];Ae(w,this._size[0]),Ae(v,this._size[1]);var x=h(w,this._ptr[v],this._ptr[v+1],this._index);return x<this._ptr[v+1]&&this._index[x]===w?this._values[x]:0},n.prototype.set=function(m,w,v){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=m[0],b=m[1],N=this._size[0],E=this._size[1],A=e,M=0;tn(this._datatype)&&(A=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(x>N-1||b>E-1)&&(p(this,Math.max(x+1,N),Math.max(b+1,E),v),N=this._size[0],E=this._size[1]),Ae(x,N),Ae(b,E);var S=h(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?A(w,M)?d(S,b,this._values,this._index,this._ptr):this._values[S]=w:A(w,M)||f(S,x,b,w,this._values,this._index,this._ptr),this};function h(m,w,v,x){if(v-w===0)return v;for(var b=w;b<v;b++)if(x[b]===m)return b;return w}function d(m,w,v,x,b){v.splice(m,1),x.splice(m,1);for(var N=w+1;N<b.length;N++)b[N]--}function f(m,w,v,x,b,N,E){b.splice(m,0,x),N.splice(m,0,w);for(var A=v+1;A<E.length;A++)E[A]++}n.prototype.resize=function(m,w,v){if(!Zi(m))throw new TypeError("Array or Matrix expected");var x=m.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(N){if(!pe(N)||!De(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(x)+")")});var b=v?this.clone():this;return p(b,x[0],x[1],w)};function p(m,w,v,x){var b=x||0,N=e,E=0;tn(m._datatype)&&(N=t.find(e,[m._datatype,m._datatype])||e,E=t.convert(0,m._datatype),b=t.convert(b,m._datatype));var A=!N(b,E),M=m._size[0],S=m._size[1],T,F,B;if(v>S){for(F=S;F<v;F++)if(m._ptr[F]=m._values.length,A)for(T=0;T<M;T++)m._values.push(b),m._index.push(T);m._ptr[v]=m._values.length}else v<S&&(m._ptr.splice(v+1,S-v),m._values.splice(m._ptr[v],m._values.length),m._index.splice(m._ptr[v],m._index.length));if(S=v,w>M){if(A){var R=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]+R,B=m._ptr[F+1]+R;var U=0;for(T=M;T<w;T++,U++)m._values.splice(B+U,0,b),m._index.splice(B+U,0,T),R++}m._ptr[S]=m._values.length}}else if(w<M){var q=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]-q;var W=m._ptr[F],z=m._ptr[F+1]-q;for(B=W;B<z;B++)T=m._index[B],T>w-1&&(m._values.splice(B,1),m._index.splice(B,1),q++)}m._ptr[F]=m._values.length}return m._size[0]=w,m._size[1]=v,m}n.prototype.reshape=function(m,w){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");m.forEach(function(X){if(!pe(X)||!De(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+fe(m)+")")});var v=this._size[0]*this._size[1];m=ga(m,v);var x=m[0]*m[1];if(v!==x)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=w?this.clone():this;if(this._size[0]===m[0]&&this._size[1]===m[1])return b;for(var N=[],E=0;E<b._ptr.length;E++)for(var A=0;A<b._ptr[E+1]-b._ptr[E];A++)N.push(E);for(var M=b._values.slice(),S=b._index.slice(),T=0;T<b._index.length;T++){var F=S[T],B=N[T],R=F*b._size[1]+B;N[T]=R%m[1],S[T]=Math.floor(R/m[1])}b._values.length=0,b._index.length=0,b._ptr.length=m[1]+1,b._size=m.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var q=0;q<M.length;q++){var W=S[q],z=N[q],K=M[q],Z=h(W,b._ptr[z],b._ptr[z+1],b._index);f(Z,W,z,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var m=new n({values:this._values?oe(this._values):void 0,index:oe(this._index),ptr:oe(this._ptr),size:oe(this._size),datatype:this._datatype});return m},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(m,w){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,x=this._size[0],b=this._size[1],N=Fc(m),E=function(M,S,T){return N===1?m(M):N===2?m(M,[S,T]):m(M,[S,T],v)};return g(this,0,x-1,0,b-1,E,w)};function g(m,w,v,x,b,N,E){var A=[],M=[],S=[],T=e,F=0;tn(m._datatype)&&(T=t.find(e,[m._datatype,m._datatype])||e,F=t.convert(0,m._datatype));for(var B=function(lt,wt,bt){lt=N(lt,wt,bt),T(lt,F)||(A.push(lt),M.push(wt))},R=x;R<=b;R++){S.push(A.length);var U=m._ptr[R],q=m._ptr[R+1];if(E)for(var W=U;W<q;W++){var z=m._index[W];z>=w&&z<=v&&B(m._values[W],z-w,R-x)}else{for(var K={},Z=U;Z<q;Z++){var X=m._index[Z];K[X]=m._values[Z]}for(var Q=w;Q<=v;Q++){var ct=Q in K?K[Q]:0;B(ct,Q-w,R-x)}}}return S.push(A.length),new n({values:A,index:M,ptr:S,size:[v-w+1,b-x+1]})}n.prototype.forEach=function(m,w){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,x=this._size[0],b=this._size[1],N=0;N<b;N++){var E=this._ptr[N],A=this._ptr[N+1];if(w)for(var M=E;M<A;M++){var S=this._index[M];m(this._values[M],[S,N],v)}else{for(var T={},F=E;F<A;F++){var B=this._index[F];T[B]=this._values[F]}for(var R=0;R<x;R++){var U=R in T?T[R]:0;m(U,[R,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var m=this._size[1],w=0;w<m;w++)for(var v=this._ptr[w],x=this._ptr[w+1],b=v;b<x;b++){var N=this._index[b];yield{value:this._values[b],index:[N,w]}}},n.prototype.toArray=function(){return y(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return y(this._values,this._index,this._ptr,this._size,!1)};function y(m,w,v,x,b){var N=x[0],E=x[1],A=[],M,S;for(M=0;M<N;M++)for(A[M]=[],S=0;S<E;S++)A[M][S]=0;for(S=0;S<E;S++)for(var T=v[S],F=v[S+1],B=T;B<F;B++)M=w[B],A[M][S]=m?b?oe(m[B]):m[B]:1;return A}return n.prototype.format=function(m){for(var w=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+fe(w,m)+" x "+fe(v,m)+"] density: "+fe(x,m)+`
|
53
|
+
`,N=0;N<v;N++)for(var E=this._ptr[N],A=this._ptr[N+1],M=E;M<A;M++){var S=this._index[M];b+=`
|
54
|
+
(`+fe(S,m)+", "+fe(N,m)+") ==> "+(this._values?fe(this._values[M],m):"X")}return b},n.prototype.toString=function(){return fe(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(m){if(m){if(Se(m)&&(m=m.toNumber()),!pe(m)||!De(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var w=m>0?m:0,v=m<0?-m:0,x=this._size[0],b=this._size[1],N=Math.min(x-v,b-w),E=[],A=[],M=[];M[0]=0;for(var S=w;S<b&&E.length<N;S++)for(var T=this._ptr[S],F=this._ptr[S+1],B=T;B<F;B++){var R=this._index[B];if(R===S-w+v){E.push(this._values[B]),A[E.length-1]=R-v;break}}return M.push(E.length),new n({values:E,index:A,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,w,v,x,b){if(!Ee(m))throw new TypeError("Array expected, size parameter");if(m.length!==2)throw new Error("Only two dimensions matrix are supported");if(m=m.map(function(X){if(Se(X)&&(X=X.toNumber()),!pe(X)||!De(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Se(v)&&(v=v.toNumber()),!pe(v)||!De(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,E=0;tn(b)&&(N=t.find(e,[b,b])||e,E=t.convert(0,b));var A=v>0?v:0,M=v<0?-v:0,S=m[0],T=m[1],F=Math.min(S-M,T-A),B;if(Ee(w)){if(w.length!==F)throw new Error("Invalid value array length");B=function(Q){return w[Q]}}else if(ve(w)){var R=w.size();if(R.length!==1||R[0]!==F)throw new Error("Invalid matrix length");B=function(Q){return w.get([Q])}}else B=function(){return w};for(var U=[],q=[],W=[],z=0;z<T;z++){W.push(U.length);var K=z-A;if(K>=0&&K<F){var Z=B(K);N(Z,E)||(q.push(K+M),U.push(Z))}}return W.push(U.length),new n({values:U,index:q,ptr:W,size:[S,T]})},n.prototype.swapRows=function(m,w){if(!pe(m)||!De(m)||!pe(w)||!De(w))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ae(m,this._size[0]),Ae(w,this._size[0]),n._swapRows(m,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,w,v,x,b){for(var N=x[m],E=x[m+1],A=N;A<E;A++)b(v[A],w[A])},n._swapRows=function(m,w,v,x,b,N){for(var E=0;E<v;E++){var A=N[E],M=N[E+1],S=h(m,A,M,b),T=h(w,A,M,b);if(S<M&&T<M&&b[S]===m&&b[T]===w){if(x){var F=x[S];x[S]=x[T],x[T]=F}continue}if(S<M&&b[S]===m&&(T>=M||b[T]!==w)){var B=x?x[S]:void 0;b.splice(T,0,w),x&&x.splice(T,0,B),b.splice(T<=S?S+1:S,1),x&&x.splice(T<=S?S+1:S,1);continue}if(T<M&&b[T]===w&&(S>=M||b[S]!==m)){var R=x?x[T]:void 0;b.splice(S,0,m),x&&x.splice(S,0,R),b.splice(S<=T?T+1:T,1),x&&x.splice(S<=T?T+1:T,1)}}},n},{isClass:!0}),Om="number",Bm=["typed"];function Im(s){var t=s.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:s,radix:e,integerPart:r,fractionalPart:n}}else return null}function Tm(s){for(var t=parseInt(s.integerPart,s.radix),e=0,r=0;r<s.fractionalPart.length;r++){var n=parseInt(s.fractionalPart[r],s.radix);e+=n/Math.pow(s.radix,r+1)}var i=t+e;if(isNaN(i))throw new SyntaxError('String "'+s.input+'" is not a valid number');return i}var $m=mt(Om,Bm,s=>{var{typed:t}=s,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Im(n);if(i)return Tm(i);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":t.referToSelf(r=>n=>Yr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Lm="bignumber",Rm=["typed","BigNumber"],Pm=mt(Lm,Rm,s=>{var{typed:t,BigNumber:e}=s;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var a=i[2],l=e(i[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var h=new e(2).pow(Number(a)-1);return l.gte(h)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Yr(n,r))})}),zm="fraction",km=["typed","Fraction"],qm=mt(zm,km,s=>{var{typed:t,Fraction:e}=s;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,i){return new e(n,i)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Yr(n,r))})}),Uc="matrix",Um=["typed","Matrix","DenseMatrix","SparseMatrix"],Wm=mt(Uc,Um,s=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=s;return t(Uc,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,c){return i([],l,c)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(a,l,c){if(l==="dense"||l==="default"||l===void 0)return new r(a,c);if(l==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Wc="unaryMinus",jm=["typed"],Vm=mt(Wc,jm,s=>{var{typed:t}=s;return t(Wc,{number:Tc,"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=>Yr(r,e))})}),jc="abs",Ym=["typed"],Zm=mt(jc,Ym,s=>{var{typed:t}=s;return t(jc,{number:Sc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),Vc="addScalar",Km=["typed"],Gm=mt(Vc,Km,s=>{var{typed:t}=s;return t(Vc,{"number, number":Oc,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Yc="subtractScalar",Hm=["typed"],Jm=mt(Yc,Hm,s=>{var{typed:t}=s;return t(Yc,{"number, number":Bc,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Xm="matAlgo11xS0s",Qm=["typed","equalScalar"],Ma=mt(Xm,Qm,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,d=n._ptr,f=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=e,v=0,x=a;typeof p=="string"&&(m=p,w=t.find(e,[m,m]),v=t.convert(0,m),i=t.convert(i,m),x=t.find(a,[m,m]));for(var b=[],N=[],E=[],A=0;A<y;A++){E[A]=N.length;for(var M=d[A],S=d[A+1],T=M;T<S;T++){var F=h[T],B=l?x(i,c[T]):x(c[T],i);w(B,v)||(N.push(F),b.push(B))}}return E[y]=N.length,n.createSparseMatrix({values:b,index:N,ptr:E,size:[g,y],datatype:m})}}),tg="matAlgo12xSfs",eg=["typed","DenseMatrix"],vi=mt(tg,eg,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,d=n._ptr,f=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof p=="string"&&(m=p,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,A=d[N],M=d[N+1],S=A;S<M;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=l?w(i,0):w(0,i)}return new e({data:v,size:[g,y],datatype:m})}}),rg="matAlgo14xDs",ng=["typed"],Na=mt(rg,ng,s=>{var{typed:t}=s;return function(n,i,a,l){var c=n._data,h=n._size,d=n._datatype,f,p=a;typeof d=="string"&&(f=d,i=t.convert(i,f),p=t.find(a,[f,f]));var g=h.length>0?e(p,0,h,h[0],c,i,l):[];return n.createDenseMatrix({data:g,size:oe(h),datatype:f})};function e(r,n,i,a,l,c,h){var d=[];if(n===i.length-1)for(var f=0;f<a;f++)d[f]=h?r(c,l[f]):r(l[f],c);else for(var p=0;p<a;p++)d[p]=e(r,n+1,i,i[n+1],l[p],c,h);return d}}),ig="matAlgo02xDS0",sg=["typed","equalScalar"],og=mt(ig,sg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._data,h=n._size,d=n._datatype||n.getDataType(),f=i._values,p=i._index,g=i._ptr,y=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==y.length)throw new Ht(h.length,y.length);if(h[0]!==y[0]||h[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+y+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=h[0],v=h[1],x,b=e,N=0,E=a;typeof d=="string"&&d===m&&d!=="mixed"&&(x=d,b=t.find(e,[x,x]),N=t.convert(0,x),E=t.find(a,[x,x]));for(var A=[],M=[],S=[],T=0;T<v;T++){S[T]=M.length;for(var F=g[T],B=g[T+1],R=F;R<B;R++){var U=p[R],q=l?E(f[R],c[U][T]):E(c[U][T],f[R]);b(q,N)||(M.push(U),A.push(q))}}return S[v]=M.length,i.createSparseMatrix({values:A,index:M,ptr:S,size:[w,v],datatype:d===n._datatype&&m===i._datatype?x:void 0})}}),ag="matAlgo03xDSf",ug=["typed"],yi=mt(ag,ug,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),d=n._values,f=n._index,p=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v,x=0,b=i;typeof h=="string"&&h===y&&h!=="mixed"&&(v=h,x=t.convert(0,v),b=t.find(i,[v,v]));for(var N=[],E=0;E<m;E++)N[E]=[];for(var A=[],M=[],S=0;S<w;S++){for(var T=S+1,F=p[S],B=p[S+1],R=F;R<B;R++){var U=f[R];A[U]=a?b(d[R],l[U][S]):b(l[U][S],d[R]),M[U]=T}for(var q=0;q<m;q++)M[q]===T?N[q][S]=A[q]:N[q][S]=a?b(x,l[q][S]):b(l[q][S],x)}return r.createDenseMatrix({data:N,size:[m,w],datatype:h===r._datatype&&y===n._datatype?v:void 0})}}),lg="matAlgo05xSfSf",cg=["typed","equalScalar"],Zc=mt(lg,cg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,h=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(d.length!==m.length)throw new Ht(d.length,m.length);if(d[0]!==m[0]||d[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+m+")");var v=d[0],x=d[1],b,N=e,E=0,A=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var M=l&&p?[]:void 0,S=[],T=[],F=M?[]:void 0,B=M?[]:void 0,R=[],U=[],q,W,z,K;for(W=0;W<x;W++){T[W]=S.length;var Z=W+1;for(z=h[W],K=h[W+1];z<K;z++)q=c[z],S.push(q),R[q]=Z,F&&(F[q]=l[z]);for(z=y[W],K=y[W+1];z<K;z++)q=g[z],R[q]!==Z&&S.push(q),U[q]=Z,B&&(B[q]=p[z]);if(M)for(z=T[W];z<S.length;){q=S[z];var X=R[q],Q=U[q];if(X===Z||Q===Z){var ct=X===Z?F[q]:E,vt=Q===Z?B[q]:E,lt=A(ct,vt);N(lt,E)?S.splice(z,1):(M.push(lt),z++)}}}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),fg="matAlgo13xDD",hg=["typed"],dg=mt(fg,hg,s=>{var{typed:t}=s;return function(n,i,a){var l=n._data,c=n._size,h=n._datatype,d=i._data,f=i._size,p=i._datatype,g=[];if(c.length!==f.length)throw new Ht(c.length,f.length);for(var y=0;y<c.length;y++){if(c[y]!==f[y])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[y]=c[y]}var m,w=a;typeof h=="string"&&h===p&&(m=h,w=t.find(a,[m,m]));var v=g.length>0?e(w,0,g,g[0],l,d):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,i,a,l,c){var h=[];if(n===i.length-1)for(var d=0;d<a;d++)h[d]=r(l[d],c[d]);else for(var f=0;f<a;f++)h[f]=e(r,n+1,i,i[n+1],l[f],c[f]);return h}}),pg="broadcast",_g=["concat"],mg=mt(pg,_g,s=>{var{concat:t}=s;return function(n,i){var a=Math.max(n._size.length,i._size.length);if(n._size.length===i._size.length&&n._size.every((y,m)=>y===i._size[m]))return[n,i];for(var l=e(n._size,a,0),c=e(i._size,a,0),h=[],d=0;d<a;d++)h[d]=Math.max(l[d],c[d]);Ms(l,h),Ms(c,h);var f=n.clone(),p=i.clone();f._size.length<a?f.reshape(e(f._size,a,1)):p._size.length<a&&p.reshape(e(p._size,a,1));for(var g=0;g<a;g++)f._size[g]<h[g]&&(f=r(f,h[g],g)),p._size[g]<h[g]&&(p=r(p,h[g],g));return[f,p]};function e(n,i,a){return[...Array(i-n.length).fill(a),...n]}function r(n,i,a){return t(...Array(i).fill(n),a)}}),gg="matrixAlgorithmSuite",vg=["typed","matrix","concat"],Hn=mt(gg,vg,s=>{var{typed:t,matrix:e,concat:r}=s,n=dg({typed:t}),i=Na({typed:t}),a=mg({concat:r});return function(c){var h=c.elop,d=c.SD||c.DS,f;h?(f={"DenseMatrix, DenseMatrix":(m,w)=>n(...a(m,w),h),"Array, Array":(m,w)=>n(...a(e(m),e(w)),h).valueOf(),"Array, DenseMatrix":(m,w)=>n(...a(e(m),w),h),"DenseMatrix, Array":(m,w)=>n(...a(m,e(w)),h)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,w)=>c.SS(...a(m,w),h,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,w)=>c.DS(...a(m,w),h,!1),f["Array, SparseMatrix"]=(m,w)=>c.DS(...a(e(m),w),h,!1)),d&&(f["SparseMatrix, DenseMatrix"]=(m,w)=>d(...a(w,m),h,!0),f["SparseMatrix, Array"]=(m,w)=>d(...a(e(w),m),h,!0))):(f={"DenseMatrix, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(w,v),m)),"Array, Array":t.referToSelf(m=>(w,v)=>n(...a(e(w),e(v)),m).valueOf()),"Array, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(e(w),v),m)),"DenseMatrix, Array":t.referToSelf(m=>(w,v)=>n(...a(w,e(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.SS(...a(w,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(w,v),m,!1)),f["Array, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(e(w),v),m,!1))),d&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(w,v)=>d(...a(v,w),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(w,v)=>d(...a(e(v),w),m,!0))));var p=c.scalar||"any",g=c.Ds||c.Ss;g&&(h?(f["DenseMatrix,"+p]=(m,w)=>i(m,w,h,!1),f[p+", DenseMatrix"]=(m,w)=>i(w,m,h,!0),f["Array,"+p]=(m,w)=>i(e(m),w,h,!1).valueOf(),f[p+", Array"]=(m,w)=>i(e(w),m,h,!0).valueOf()):(f["DenseMatrix,"+p]=t.referToSelf(m=>(w,v)=>i(w,v,m,!1)),f[p+", DenseMatrix"]=t.referToSelf(m=>(w,v)=>i(v,w,m,!0)),f["Array,"+p]=t.referToSelf(m=>(w,v)=>i(e(w),v,m,!1).valueOf()),f[p+", Array"]=t.referToSelf(m=>(w,v)=>i(e(v),w,m,!0).valueOf())));var y=c.sS!==void 0?c.sS:c.Ss;return h?(c.Ss&&(f["SparseMatrix,"+p]=(m,w)=>c.Ss(m,w,h,!1)),y&&(f[p+", SparseMatrix"]=(m,w)=>y(w,m,h,!0))):(c.Ss&&(f["SparseMatrix,"+p]=t.referToSelf(m=>(w,v)=>c.Ss(w,v,m,!1))),y&&(f[p+", SparseMatrix"]=t.referToSelf(m=>(w,v)=>y(v,w,m,!0)))),h&&h.signatures&&kl(f,h.signatures),f}}),yg="matAlgo01xDSid",wg=["typed"],Kc=mt(yg,wg,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),d=n._values,f=n._index,p=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v=typeof h=="string"&&h!=="mixed"&&h===y?h:void 0,x=v?t.find(i,[v,v]):i,b,N,E=[];for(b=0;b<m;b++)E[b]=[];var A=[],M=[];for(N=0;N<w;N++){for(var S=N+1,T=p[N],F=p[N+1],B=T;B<F;B++)b=f[B],A[b]=a?x(d[B],l[b][N]):x(l[b][N],d[B]),M[b]=S;for(b=0;b<m;b++)M[b]===S?E[b][N]=A[b]:E[b][N]=l[b][N]}return r.createDenseMatrix({data:E,size:[m,w],datatype:h===r._datatype&&y===n._datatype?v:void 0})}}),Dg="matAlgo04xSidSid",bg=["typed","equalScalar"],xg=mt(Dg,bg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,h=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(d.length!==m.length)throw new Ht(d.length,m.length);if(d[0]!==m[0]||d[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+m+")");var v=d[0],x=d[1],b,N=e,E=0,A=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var M=l&&p?[]:void 0,S=[],T=[],F=l&&p?[]:void 0,B=l&&p?[]:void 0,R=[],U=[],q,W,z,K,Z;for(W=0;W<x;W++){T[W]=S.length;var X=W+1;for(K=h[W],Z=h[W+1],z=K;z<Z;z++)q=c[z],S.push(q),R[q]=X,F&&(F[q]=l[z]);for(K=y[W],Z=y[W+1],z=K;z<Z;z++)if(q=g[z],R[q]===X){if(F){var Q=A(F[q],p[z]);N(Q,E)?R[q]=null:F[q]=Q}}else S.push(q),U[q]=X,B&&(B[q]=p[z]);if(F&&B)for(z=T[W];z<S.length;)q=S[z],R[q]===X?(M[z]=F[q],z++):U[q]===X?(M[z]=B[q],z++):S.splice(z,1)}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),Eg="matAlgo10xSids",Ag=["typed","DenseMatrix"],Gc=mt(Eg,Ag,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,d=n._ptr,f=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof p=="string"&&(m=p,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,A=d[N],M=d[N+1],S=A;S<M;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=i}return new e({data:v,size:[g,y],datatype:m})}}),Cg="multiplyScalar",Fg=["typed"],Mg=mt(Cg,Fg,s=>{var{typed:t}=s;return t("multiplyScalar",{"number, number":Ic,"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)})}),Hc="multiply",Ng=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Sg=mt(Hc,Ng,s=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:i,dot:a}=s,l=Ma({typed:t,equalScalar:i}),c=Na({typed:t});function h(E,A){switch(E.length){case 1:switch(A.length){case 1:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+E[0]+") must match Matrix rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;case 2:switch(A.length){case 1:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+E[1]+") must match Vector length ("+A[0]+")");break;case 2:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+E[1]+") must match Matrix B rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+E.length+" dimensions)")}}function d(E,A,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(E,A)}function f(E,A){if(A.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return p(E,A)}function p(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,B=A._size,R=A._datatype||A.getDataType(),U=S[0],q=B[1],W,z=r,K=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&(W=T,z=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var Z=[],X=0;X<q;X++){for(var Q=K(M[0],F[0][X]),ct=1;ct<U;ct++)Q=z(Q,K(M[ct],F[ct][X]));Z[X]=Q}return E.createDenseMatrix({data:Z,size:[q],datatype:T===E._datatype&&R===A._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":x}),y=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,B=A._datatype||A.getDataType(),R=S[0],U=S[1],q,W=r,z=n;T&&B&&T===B&&typeof T=="string"&&T!=="mixed"&&(q=T,W=t.find(r,[q,q]),z=t.find(n,[q,q]));for(var K=[],Z=0;Z<R;Z++){for(var X=M[Z],Q=z(X[0],F[0]),ct=1;ct<U;ct++)Q=W(Q,z(X[ct],F[ct]));K[Z]=Q}return E.createDenseMatrix({data:K,size:[R],datatype:T===E._datatype&&B===A._datatype?q:void 0})}function w(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,B=A._size,R=A._datatype||A.getDataType(),U=S[0],q=S[1],W=B[1],z,K=r,Z=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&T!=="mixed"&&(z=T,K=t.find(r,[z,z]),Z=t.find(n,[z,z]));for(var X=[],Q=0;Q<U;Q++){var ct=M[Q];X[Q]=[];for(var vt=0;vt<W;vt++){for(var lt=Z(ct[0],F[0][vt]),wt=1;wt<q;wt++)lt=K(lt,Z(ct[wt],F[wt][vt]));X[Q][vt]=lt}}return E.createDenseMatrix({data:X,size:[U,W],datatype:T===E._datatype&&R===A._datatype?z:void 0})}function v(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._values,B=A._index,R=A._ptr,U=A._size,q=A._datatype||A._data===void 0?A._datatype:A.getDataType();if(!F)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],z=U[1],K,Z=r,X=n,Q=i,ct=0;T&&q&&T===q&&typeof T=="string"&&T!=="mixed"&&(K=T,Z=t.find(r,[K,K]),X=t.find(n,[K,K]),Q=t.find(i,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],wt=[],bt=A.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[W,z],datatype:T===E._datatype&&q===A._datatype?K:void 0}),Ot=0;Ot<z;Ot++){wt[Ot]=lt.length;var xt=R[Ot],ae=R[Ot+1];if(ae>xt)for(var It=0,Nt=0;Nt<W;Nt++){for(var ce=Nt+1,re=void 0,qt=xt;qt<ae;qt++){var Jt=B[qt];It!==ce?(re=X(M[Nt][Jt],F[qt]),It=ce):re=Z(re,X(M[Nt][Jt],F[qt]))}It===ce&&!Q(re,ct)&&(lt.push(Nt),vt.push(re))}}return wt[z]=lt.length,bt}function x(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=A._data,R=A._datatype||A.getDataType(),U=E._size[0],q=A._size[0],W=[],z=[],K=[],Z,X=r,Q=n,ct=i,vt=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]),ct=t.find(i,[Z,Z]),vt=t.convert(0,Z));var lt=[],wt=[];K[0]=0;for(var bt=0;bt<q;bt++){var Ot=B[bt];if(!ct(Ot,vt))for(var xt=T[bt],ae=T[bt+1],It=xt;It<ae;It++){var Nt=S[It];wt[Nt]?lt[Nt]=X(lt[Nt],Q(Ot,M[It])):(wt[Nt]=!0,z.push(Nt),lt[Nt]=Q(Ot,M[It]))}}for(var ce=z.length,re=0;re<ce;re++){var qt=z[re];W[re]=lt[qt]}return K[1]=z.length,E.createSparseMatrix({values:W,index:z,ptr:K,size:[U,1],datatype:F===E._datatype&&R===A._datatype?Z:void 0})}function b(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=A._data,R=A._datatype||A.getDataType(),U=E._size[0],q=A._size[0],W=A._size[1],z,K=r,Z=n,X=i,Q=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(z=F,K=t.find(r,[z,z]),Z=t.find(n,[z,z]),X=t.find(i,[z,z]),Q=t.convert(0,z));for(var ct=[],vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,W],datatype:F===E._datatype&&R===A._datatype?z:void 0}),bt=[],Ot=[],xt=0;xt<W;xt++){lt[xt]=vt.length;for(var ae=xt+1,It=0;It<q;It++){var Nt=B[It][xt];if(!X(Nt,Q))for(var ce=T[It],re=T[It+1],qt=ce;qt<re;qt++){var Jt=S[qt];Ot[Jt]!==ae?(Ot[Jt]=ae,vt.push(Jt),bt[Jt]=Z(Nt,M[qt])):bt[Jt]=K(bt[Jt],Z(Nt,M[qt]))}}for(var $e=lt[xt],vr=vt.length,ze=$e;ze<vr;ze++){var dn=vt[ze];ct[ze]=bt[dn]}}return lt[W]=vt.length,wt}function N(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType(),B=A._values,R=A._index,U=A._ptr,q=A._datatype||A._data===void 0?A._datatype:A.getDataType(),W=E._size[0],z=A._size[1],K=M&&B,Z,X=r,Q=n;F&&q&&F===q&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]));for(var ct=K?[]:void 0,vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,z],datatype:F===E._datatype&&q===A._datatype?Z:void 0}),bt=K?[]:void 0,Ot=[],xt,ae,It,Nt,ce,re,qt,Jt,$e=0;$e<z;$e++){lt[$e]=vt.length;var vr=$e+1;for(ce=U[$e],re=U[$e+1],Nt=ce;Nt<re;Nt++)if(Jt=R[Nt],K)for(ae=T[Jt],It=T[Jt+1],xt=ae;xt<It;xt++)qt=S[xt],Ot[qt]!==vr?(Ot[qt]=vr,vt.push(qt),bt[qt]=Q(B[Nt],M[xt])):bt[qt]=X(bt[qt],Q(B[Nt],M[xt]));else for(ae=T[Jt],It=T[Jt+1],xt=ae;xt<It;xt++)qt=S[xt],Ot[qt]!==vr&&(Ot[qt]=vr,vt.push(qt));if(K)for(var ze=lt[$e],dn=vt.length,Bn=ze;Bn<dn;Bn++){var pn=vt[Bn];ct[Bn]=bt[pn]}}return lt[z]=vt.length,wt}return t(Hc,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(A,M)=>{h(Ie(A),Ie(M));var S=E(e(A),e(M));return ve(S)?S.valueOf():S}),"Matrix, Matrix":function(A,M){var S=A.size(),T=M.size();return h(S,T),S.length===1?T.length===1?d(A,M,S[0]):f(A,M):T.length===1?g(A,M):y(A,M)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(A,M)=>E(A,e(M))),"Array, Matrix":t.referToSelf(E=>(A,M)=>E(e(A,M.storage()),M)),"SparseMatrix, any":function(A,M){return l(A,M,n,!1)},"DenseMatrix, any":function(A,M){return c(A,M,n,!1)},"any, SparseMatrix":function(A,M){return l(M,A,n,!0)},"any, DenseMatrix":function(A,M){return c(M,A,n,!0)},"Array, any":function(A,M){return c(e(A),M,n,!1).valueOf()},"any, Array":function(A,M){return c(e(M),A,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(A,M,S)=>{for(var T=E(A,M),F=0;F<S.length;F++)T=E(T,S[F]);return T})})}),Jc="subtract",Og=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Bg=mt(Jc,Og,s=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:l}=s,c=Kc({typed:t}),h=yi({typed:t}),d=Zc({typed:t,equalScalar:r}),f=Gc({typed:t,DenseMatrix:a}),p=vi({typed:t,DenseMatrix:a}),g=Hn({typed:t,matrix:e,concat:l});return t(Jc,{"any, any":n},g({elop:n,SS:d,DS:c,SD:h,Ss:p,sS:f}))}),Ig="matAlgo07xSSf",Tg=["typed","DenseMatrix"],Ws=mt(Ig,Tg,s=>{var{typed:t,DenseMatrix:e}=s;return function(i,a,l){var c=i._size,h=i._datatype||i._data===void 0?i._datatype:i.getDataType(),d=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==d.length)throw new Ht(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var p=c[0],g=c[1],y,m=0,w=l;typeof h=="string"&&h===f&&h!=="mixed"&&(y=h,m=t.convert(0,y),w=t.find(l,[y,y]));var v,x,b=[];for(v=0;v<p;v++)b[v]=[];var N=[],E=[],A=[],M=[];for(x=0;x<g;x++){var S=x+1;for(r(i,x,A,N,S),r(a,x,M,E,S),v=0;v<p;v++){var T=A[v]===S?N[v]:m,F=M[v]===S?E[v]:m;b[v][x]=w(T,F)}}return new e({data:b,size:[p,g],datatype:h===i._datatype&&f===a._datatype?y:void 0})};function r(n,i,a,l,c){for(var h=n._values,d=n._index,f=n._ptr,p=f[i],g=f[i+1];p<g;p++){var y=d[p];a[y]=c,l[y]=h[p]}}}),Xc="conj",$g=["typed"],Lg=mt(Xc,$g,s=>{var{typed:t}=s;return t(Xc,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),Qc="concat",Rg=["typed","matrix","isInteger"],Pg=mt(Qc,Rg,s=>{var{typed:t,matrix:e,isInteger:r}=s;return t(Qc,{"...Array | Matrix | number | BigNumber":function(i){var a,l=i.length,c=-1,h,d=!1,f=[];for(a=0;a<l;a++){var p=i[a];if(ve(p)&&(d=!0),pe(p)||Se(p)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(h=c,c=p.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>h)throw new An(c,h+1)}else{var g=oe(p).valueOf(),y=Ie(g);if(f[a]=g,h=c,c=y.length-1,a>0&&c!==h)throw new Ht(h+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=oc(m,f.shift(),c);return d?e(m):m},"...string":function(i){return i.join("")}})}),tf="count",zg=["typed","size","prod"],kg=mt(tf,zg,s=>{var{typed:t,size:e,prod:r}=s;return t(tf,{string:function(i){return i.length},"Matrix | Array":function(i){return r(e(i))}})}),ef="identity",qg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Ug=mt(ef,qg,s=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:i,SparseMatrix:a}=s;return t(ef,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(d){return r(d)},"number | BigNumber":function(d){return c(d,d,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(d,f){return c(d,d,f)},"number | BigNumber, number | BigNumber":function(d,f){return c(d,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(d,f,p){return c(d,f,p)},Array:function(d){return l(d)},"Array, string":function(d,f){return l(d,f)},Matrix:function(d){return l(d.valueOf(),d.storage())},"Matrix, string":function(d,f){return l(d.valueOf(),f)}});function l(h,d){switch(h.length){case 0:return d?r(d):[];case 1:return c(h[0],h[0],d);case 2:return c(h[0],h[1],d);default:throw new Error("Vector containing two values expected")}}function c(h,d,f){var p=Se(h)||Se(d)?n:null;if(Se(h)&&(h=h.toNumber()),Se(d)&&(d=d.toNumber()),!De(h)||h<1)throw new Error("Parameters in function identity must be positive integers");if(!De(d)||d<1)throw new Error("Parameters in function identity must be positive integers");var g=p?new n(1):1,y=p?new p(0):0,m=[h,d];if(f){if(f==="sparse")return a.diagonal(m,g,0,y);if(f==="dense")return i.diagonal(m,g,0,y);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var w=pa([],m,y),v=h<d?h:d,x=0;x<v;x++)w[x][x]=g;return w}}),rf="kron",Wg=["typed","matrix","multiplyScalar"],jg=mt(rf,Wg,s=>{var{typed:t,matrix:e,multiplyScalar:r}=s;return t(rf,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(i,a){if(Ie(i).length===1&&(i=[i]),Ie(a).length===1&&(a=[a]),Ie(i).length>2||Ie(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return i.map(function(h){return a.map(function(d){return c=[],l.push(c),h.map(function(f){return d.map(function(p){return c.push(r(f,p))})})})})&&l}});function Vg(){throw new Error('No "bignumber" implementation available')}function Yg(){throw new Error('No "fraction" implementation available')}function Zg(){throw new Error('No "matrix" implementation available')}var nf="reshape",Kg=["typed","isInteger","matrix"],Gg=mt(nf,Kg,s=>{var{typed:t,isInteger:e}=s;return t(nf,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),ma(n,i)}})}),sf="size",Hg=["typed","config","?matrix"],Jg=mt(sf,Hg,s=>{var{typed:t,config:e,matrix:r}=s;return t(sf,{Matrix:function(i){return i.create(i.size())},Array:Ie,string:function(i){return e.matrix==="Array"?[i.length]:r([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return e.matrix==="Array"?[]:r?r([]):Zg()}})}),of="transpose",Xg=["typed","matrix"],Qg=mt(of,Xg,s=>{var{typed:t,matrix:e}=s;return t(of,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:oe});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var h=l[0],d=l[1];if(d===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+fe(l)+")");switch(a.storage()){case"dense":c=n(a,h,d);break;case"sparse":c=i(a,h,d);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+fe(l)+")")}return c}function n(a,l,c){for(var h=a._data,d=[],f,p=0;p<c;p++){f=d[p]=[];for(var g=0;g<l;g++)f[g]=oe(h[g][p])}return a.createDenseMatrix({data:d,size:[c,l],datatype:a._datatype})}function i(a,l,c){for(var h=a._values,d=a._index,f=a._ptr,p=h?[]:void 0,g=[],y=[],m=[],w=0;w<l;w++)m[w]=0;var v,x,b;for(v=0,x=d.length;v<x;v++)m[d[v]]++;for(var N=0,E=0;E<l;E++)y.push(N),N+=m[E],m[E]=y[E];for(y.push(N),b=0;b<c;b++)for(var A=f[b],M=f[b+1],S=A;S<M;S++){var T=m[d[S]]++;g[T]=b,h&&(p[T]=oe(h[S]))}return a.createSparseMatrix({values:p,index:g,ptr:y,size:[c,l],datatype:a._datatype})}}),af="ctranspose",tv=["typed","transpose","conj"],ev=mt(af,tv,s=>{var{typed:t,transpose:e,conj:r}=s;return t(af,{any:function(i){return r(e(i))}})}),uf="mode",rv=["typed","isNaN","isNumeric"],nv=mt(uf,rv,s=>{var{typed:t,isNaN:e,isNumeric:r}=s;return t(uf,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(i){i=va(i.valueOf());var a=i.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],h=0,d=0;d<i.length;d++){var f=i[d];if(r(f)&&e(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===h?c.push(f):l[f]>h&&(h=l[f],c=[f])}return c}});function Sn(s,t,e){var r;return String(s).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":" (type: "+s.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(s).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):s}var lf="prod",iv=["typed","config","multiplyScalar","numeric"],sv=mt(lf,iv,s=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=s;return t(lf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(a){var l;if(Hi(a,function(c){try{l=l===void 0?c:r(l,c)}catch(h){throw Sn(h,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),ov="numeric",av=["number","?bignumber","?fraction"],uv=mt(ov,av,s=>{var{number:t,bignumber:e,fraction:r}=s,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:a=>t(a),BigNumber:e?a=>e(a):Vg,Fraction:r?a=>r(a):Yg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",h=arguments.length>2?arguments[2]:void 0;if(h!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var d=En(l);if(!(d in n))throw new TypeError("Cannot convert "+l+' of type "'+d+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in i))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(i).join(", "));return c===d?l:i[c](l)}}),cf="divideScalar",lv=["typed","numeric"],cv=mt(cf,lv,s=>{var{typed:t,numeric:e}=s;return t(cf,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),ff="pow",fv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],hv=mt(ff,fv,s=>{var{typed:t,config:e,identity:r,multiply:n,matrix:i,inv:a,number:l,fraction:c,Complex:h}=s;return t(ff,{"number, number":d,"Complex, Complex":function(y,m){return y.pow(m)},"BigNumber, BigNumber":function(y,m){return m.isInteger()||y>=0||e.predictable?y.pow(m):new h(y.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(y,m){var w=y.pow(m);if(w!=null)return w;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return d(y.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(y,m){return f(y,m.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(y,m){return p(y,m.toNumber())},"Unit, number | BigNumber":function(y,m){return y.pow(m)}});function d(g,y){if(e.predictable&&!De(y)&&g<0)try{var m=c(y),w=l(m);if((y===w||Math.abs((y-w)/y)<1e-14)&&m.d%2===1)return(m.n%2===0?1:-1)*Math.pow(-g,y)}catch{}return e.predictable&&(g<-1&&y===1/0||g>-1&&g<0&&y===-1/0)?NaN:De(y)||g>=0||e.predictable?$c(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new h(g,0).pow(y,0)}function f(g,y){if(!De(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var m=Ie(g);if(m.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+m.length+" dimensions)");if(m[0]!==m[1])throw new Error("For A^b, A must be square (size is "+m[0]+"x"+m[1]+")");if(y<0)try{return f(a(g),-y)}catch(x){throw x.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+y+")"):x}for(var w=r(m[0]).valueOf(),v=g;y>=1;)(y&1)===1&&(w=n(v,w)),y>>=1,v=n(v,v);return w}function p(g,y){return i(f(g.valueOf(),y))}}),hf="dotDivide",dv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],pv=mt(hf,dv,s=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,l=og({typed:t,equalScalar:r}),c=yi({typed:t}),h=Ws({typed:t,DenseMatrix:i}),d=Ma({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:i}),p=Hn({typed:t,matrix:e,concat:a});return t(hf,p({elop:n,SS:h,DS:c,SD:l,Ss:d,sS:f}))}),js="compare",_v=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],mv=mt(js,_v,s=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:l,concat:c}=s,h=yi({typed:t}),d=Zc({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:l}),p=Hn({typed:t,matrix:n,concat:c}),g=qs({typed:t});return t(js,gv({typed:t,config:e}),{"boolean, boolean":function(m,w){return m===w?0:m>w?1:-1},"BigNumber, BigNumber":function(m,w){return ks(m,w,e.epsilon)?new i(0):new i(m.cmp(w))},"Fraction, Fraction":function(m,w){return new a(m.compare(w))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,p({SS:d,DS:h,Ss:f}))}),gv=mt(js,["typed","config"],s=>{var{typed:t,config:e}=s;return t(js,{"number, number":function(n,i){return Gn(n,i,e.epsilon)?0:n>i?1:-1}})}),Vs="equal",vv=["typed","matrix","equalScalar","DenseMatrix","concat"],yv=mt(Vs,vv,s=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:e,concat:i});return t(Vs,wv({typed:t,equalScalar:r}),h({elop:r,SS:l,DS:a,Ss:c}))}),wv=mt(Vs,["typed","equalScalar"],s=>{var{typed:t,equalScalar:e}=s;return t(Vs,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:e(n,i)}})}),Ys="smaller",Dv=["typed","config","matrix","DenseMatrix","concat"],bv=mt(Ys,Dv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:r,concat:i}),d=qs({typed:t});return t(Ys,xv({typed:t,config:e}),{"boolean, boolean":(f,p)=>f<p,"BigNumber, BigNumber":function(p,g){return p.lt(g)&&!ks(p,g,e.epsilon)},"Fraction, Fraction":(f,p)=>f.compare(p)===-1,"Complex, Complex":function(p,g){throw new TypeError("No ordering relation is defined for complex numbers")}},d,h({SS:l,DS:a,Ss:c}))}),xv=mt(Ys,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Ys,{"number, number":function(n,i){return n<i&&!Gn(n,i,e.epsilon)}})}),Zs="larger",Ev=["typed","config","matrix","DenseMatrix","concat"],Av=mt(Zs,Ev,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:r,concat:i}),d=qs({typed:t});return t(Zs,Cv({typed:t,config:e}),{"boolean, boolean":(f,p)=>f>p,"BigNumber, BigNumber":function(p,g){return p.gt(g)&&!ks(p,g,e.epsilon)},"Fraction, Fraction":(f,p)=>f.compare(p)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,h({SS:l,DS:a,Ss:c}))}),Cv=mt(Zs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Zs,{"number, number":function(n,i){return n>i&&!Gn(n,i,e.epsilon)}})}),df="deepEqual",Fv=["typed","equal"],Mv=mt(df,Fv,s=>{var{typed:t,equal:e}=s;return t(df,{"any, any":function(i,a){return r(i.valueOf(),a.valueOf())}});function r(n,i){if(Array.isArray(n))if(Array.isArray(i)){var a=n.length;if(a!==i.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:e(n,i)}}),pf="partitionSelect",Nv=["typed","isNumeric","isNaN","compare"],Sv=mt(pf,Nv,s=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=s,i=n,a=(h,d)=>-n(h,d);return t(pf,{"Array | Matrix, number":function(d,f){return l(d,f,i)},"Array | Matrix, number, string":function(d,f,p){if(p==="asc")return l(d,f,i);if(p==="desc")return l(d,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(h,d,f){if(!De(d)||d<0)throw new Error("k must be a non-negative integer");if(ve(h)){var p=h.size();if(p.length>1)throw new Error("Only one dimensional matrices supported");return c(h.valueOf(),d,f)}if(Array.isArray(h))return c(h,d,f)}function c(h,d,f){if(d>=h.length)throw new Error("k out of bounds");for(var p=0;p<h.length;p++)if(e(h[p])&&r(h[p]))return h[p];for(var g=0,y=h.length-1;g<y;){for(var m=g,w=y,v=h[Math.floor(Math.random()*(y-g+1))+g];m<w;)if(f(h[m],v)>=0){var x=h[w];h[w]=h[m],h[m]=x,--w}else++m;f(h[m],v)>0&&--m,d<=m?y=m:g=m+1}return h[d]}}),_f="max",Ov=["typed","config","numeric","larger"],Bv=mt(_f,Ov,s=>{var{typed:t,config:e,numeric:r,larger:n}=s;return t(_f,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Fa(c,h.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(h){throw Sn(h,"max",c)}}function a(l){var c;if(Hi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(d){throw Sn(d,"max",h)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),mf="min",Iv=["typed","config","numeric","smaller"],Tv=mt(mf,Iv,s=>{var{typed:t,config:e,numeric:r,smaller:n}=s;return t(mf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Fa(c,h.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(h){throw Sn(h,"min",c)}}function a(l){var c;if(Hi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(d){throw Sn(d,"min",h)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),gf="add",$v=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Lv=mt(gf,$v,s=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:l}=s,c=Kc({typed:t}),h=xg({typed:t,equalScalar:n}),d=Gc({typed:t,DenseMatrix:i}),f=Hn({typed:t,matrix:e,concat:l});return t(gf,{"any, any":r,"any, any, ...any":t.referToSelf(p=>(g,y,m)=>{for(var w=p(g,y),v=0;v<m.length;v++)w=p(w,m[v]);return w})},f({elop:r,DS:c,SS:h,Ss:d}))}),vf="dot",Rv=["typed","addScalar","multiplyScalar","conj","size"],Pv=mt(vf,Rv,s=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:i}=s;return t(vf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(d,f){var p=h(d),g=h(f),y,m;if(p.length===1)y=p[0];else if(p.length===2&&p[1]===1)y=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(g.length===1)m=g[0];else if(g.length===2&&g[1]===1)m=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(y!==m)throw new RangeError("Vectors must have equal length ("+y+" != "+m+")");if(y===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return y}function l(d,f){var p=a(d,f),g=ve(d)?d._data:d,y=ve(d)?d._datatype||d.getDataType():void 0,m=ve(f)?f._data:f,w=ve(f)?f._datatype||f.getDataType():void 0,v=h(d).length===2,x=h(f).length===2,b=e,N=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var E=y;b=t.find(e,[E,E]),N=t.find(r,[E,E])}if(!v&&!x){for(var A=N(n(g[0]),m[0]),M=1;M<p;M++)A=b(A,N(n(g[M]),m[M]));return A}if(!v&&x){for(var S=N(n(g[0]),m[0][0]),T=1;T<p;T++)S=b(S,N(n(g[T]),m[T][0]));return S}if(v&&!x){for(var F=N(n(g[0][0]),m[0]),B=1;B<p;B++)F=b(F,N(n(g[B][0]),m[B]));return F}if(v&&x){for(var R=N(n(g[0][0]),m[0][0]),U=1;U<p;U++)R=b(R,N(n(g[U][0]),m[U][0]));return R}}function c(d,f){a(d,f);for(var p=d._index,g=d._values,y=f._index,m=f._values,w=0,v=e,x=r,b=0,N=0;b<p.length&&N<y.length;){var E=p[b],A=y[N];if(E<A){b++;continue}if(E>A){N++;continue}E===A&&(w=v(w,x(g[b],m[N])),b++,N++)}return w}function h(d){return ve(d)?d.size():i(d)}}),zv="trace",kv=["typed","matrix","add"],qv=mt(zv,kv,s=>{var{typed:t,matrix:e,add:r}=s;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:i,DenseMatrix:n,any:oe});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return oe(c[0]);throw new RangeError("Matrix must be square (size: "+fe(l)+")");case 2:{var h=l[0],d=l[1];if(h===d){for(var f=0,p=0;p<h;p++)f=r(f,c[p][p]);return f}else throw new RangeError("Matrix must be square (size: "+fe(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(l)+")")}}function i(a){var l=a._values,c=a._index,h=a._ptr,d=a._size,f=d[0],p=d[1];if(f===p){var g=0;if(l.length>0)for(var y=0;y<p;y++)for(var m=h[y],w=h[y+1],v=m;v<w;v++){var x=c[v];if(x===y){g=r(g,l[v]);break}if(x>y)break}return g}throw new RangeError("Matrix must be square (size: "+fe(d)+")")}}),yf="det",Uv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Wv=mt(yf,Uv,s=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:i,isZero:a,unaryMinus:l}=s;return t(yf,{any:function(d){return oe(d)},"Array | Matrix":function(d){var f;switch(ve(d)?f=d.size():Array.isArray(d)?(d=e(d),f=d.size()):f=[],f.length){case 0:return oe(d);case 1:if(f[0]===1)return oe(d.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")");case 2:{var p=f[0],g=f[1];if(p===g)return c(d.clone().valueOf(),p);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(f)+")")}}});function c(h,d,f){if(d===1)return oe(h[0][0]);if(d===2)return r(n(h[0][0],h[1][1]),n(h[1][0],h[0][1]));for(var p=!1,g=new Array(d).fill(0).map((M,S)=>S),y=0;y<d;y++){var m=g[y];if(a(h[m][y])){var w=void 0;for(w=y+1;w<d;w++)if(!a(h[g[w]][y])){m=g[w],g[w]=g[y],g[y]=m,p=!p;break}if(w===d)return h[m][y]}for(var v=h[m][y],x=y===0?1:h[g[y-1]][y-1],b=y+1;b<d;b++)for(var N=g[b],E=y+1;E<d;E++)h[N][E]=i(r(n(h[N][E],v),n(h[N][y],h[m][E])),x)}var A=h[g[d-1]][d-1];return p?l(A):A}}),wf="inv",jv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Vv=mt(wf,jv,s=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:l,identity:c,abs:h}=s;return t(wf,{"Array | Matrix":function(p){var g=ve(p)?p.size():Ie(p);switch(g.length){case 1:if(g[0]===1)return ve(p)?e([r(1,p.valueOf()[0])]):[r(1,p[0])];throw new RangeError("Matrix must be square (size: "+fe(g)+")");case 2:{var y=g[0],m=g[1];if(y===m)return ve(p)?e(d(p.valueOf(),y,m),p.storage()):d(p,y,m);throw new RangeError("Matrix must be square (size: "+fe(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(g)+")")}},any:function(p){return r(1,p)}});function d(f,p,g){var y,m,w,v,x;if(p===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(p===2){var b=l(f);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(f[1][1],b),r(a(f[0][1]),b)],[r(a(f[1][0]),b),r(f[0][0],b)]]}else{var N=f.concat();for(y=0;y<p;y++)N[y]=N[y].concat();for(var E=c(p).valueOf(),A=0;A<g;A++){var M=h(N[A][A]),S=A;for(y=A+1;y<p;)h(N[y][A])>M&&(M=h(N[y][A]),S=y),y++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==A&&(x=N[A],N[A]=N[y],N[y]=x,x=E[A],E[A]=E[y],E[y]=x);var T=N[A],F=E[A];for(y=0;y<p;y++){var B=N[y],R=E[y];if(y!==A){if(B[A]!==0){for(w=r(a(B[A]),T[A]),m=A;m<g;m++)B[m]=n(B[m],i(w,T[m]));for(m=0;m<g;m++)R[m]=n(R[m],i(w,F[m]))}}else{for(w=T[A],m=A;m<g;m++)B[m]=r(B[m],w);for(m=0;m<g;m++)R[m]=r(R[m],w)}}}return E}}}),Df="pinv",Yv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Zv=mt(Df,Yv,s=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:l,ctranspose:c,divideScalar:h,multiply:d,add:f,Complex:p}=s;return t(Df,{"Array | Matrix":function(b){var N=ve(b)?b.size():Ie(b);switch(N.length){case 1:return v(b)?c(b):N[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var E=N[0],A=N[1];if(E===A)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return ve(b)?e(g(b.valueOf(),E,A),b.storage()):g(b,E,A)}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(N)+")")}},any:function(b){return i(b,0)?oe(b):h(1,b)}});function g(x,b,N){var{C:E,F:A}=m(x,b,N),M=d(r(d(c(E),E)),c(E)),S=d(c(A),r(d(A,c(A))));return d(S,M)}function y(x,b,N){for(var E=oe(x),A=0,M=0;M<b;M++){if(N<=A)return E;for(var S=M;w(E[S][A]);)if(S++,b===S&&(S=M,A++,N===A))return E;[E[S],E[M]]=[E[M],E[S]];for(var T=E[M][A],F=0;F<N;F++)E[M][F]=a(E[M][F],T);for(var B=0;B<b;B++)if(B!==M){T=E[B][A];for(var R=0;R<N;R++)E[B][R]=f(E[B][R],d(-1,d(T,E[M][R])))}A++}return E}function m(x,b,N){var E=y(x,b,N),A=x.map((S,T)=>S.filter((F,B)=>B<b&&!w(l(E[B],E[B])))),M=E.filter((S,T)=>!w(l(E[T],E[T])));return{C:A,F:M}}function w(x){return i(f(x,p(1,1)),f(0,p(1,1)))}function v(x){return n(f(x,p(1,1)),f(d(x,0),p(1,1)))}}),Kv="divide",Gv=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Hv=mt(Kv,Gv,s=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:i,inv:a}=s,l=Ma({typed:t,equalScalar:n}),c=Na({typed:t});return t("divide",kl({"Array | Matrix, Array | Matrix":function(d,f){return r(d,a(f))},"DenseMatrix, any":function(d,f){return c(d,f,i,!1)},"SparseMatrix, any":function(d,f){return l(d,f,i,!1)},"Array, any":function(d,f){return c(e(d),f,i,!1).valueOf()},"any, Array | Matrix":function(d,f){return r(d,a(f))}},i.signatures))}),bf="sum",Jv=["typed","config","add","numeric"],Xv=mt(bf,Jv,s=>{var{typed:t,config:e,add:r,numeric:n}=s;return t(bf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function sum");return i(c)}});function i(l){var c;return Hi(l,function(h){try{c=c===void 0?h:r(c,h)}catch(d){throw Sn(d,"sum",h)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var h=Fa(l,c,r);return h}catch(d){throw Sn(d,"sum")}}}),xf="median",Qv=["typed","add","divide","compare","partitionSelect"],t1=mt(xf,Qv,s=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:i}=s;function a(h){try{h=va(h.valueOf());var d=h.length;if(d===0)throw new Error("Cannot calculate median of an empty array");if(d%2===0){for(var f=d/2-1,p=i(h,f+1),g=h[f],y=0;y<f;++y)n(h[y],g)>0&&(g=h[y]);return c(g,p)}else{var m=i(h,(d-1)/2);return l(m)}}catch(w){throw Sn(w,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(d){return d}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(d,f){return r(e(d,f),2)}});return t(xf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(d,f){throw new Error("median(A, dim) is not yet supported")},"...":function(d){if(Rs(d))throw new TypeError("Scalar values expected in function median");return a(d)}})}),Ks=em({config:mr}),Sa=sm({}),Oa=lm({}),Ba=hm({}),rn=_m({Matrix:Ba}),Mt=i_({BigNumber:Ks,Complex:Sa,DenseMatrix:rn,Fraction:Oa}),e1=Zm({typed:Mt}),Gs=Gm({typed:Mt}),r1=Pm({BigNumber:Ks,typed:Mt}),Ef=Lg({typed:Mt}),On=Fm({config:mr,typed:Mt}),Hs=vm({typed:Mt}),n1=bm({typed:Mt}),Js=Mg({typed:Mt}),Af=$m({typed:Mt}),Ia=Sm({Matrix:Ba,equalScalar:On,typed:Mt}),Cf=Jm({typed:Mt}),Ff=Em({typed:Mt}),Ta=Vm({typed:Mt}),Mf=qm({Fraction:Oa,typed:Mt}),Nf=wm({typed:Mt}),Te=Wm({DenseMatrix:rn,Matrix:Ba,SparseMatrix:Ia,typed:Mt}),Sf=nv({isNaN:Ff,isNumeric:Nf,typed:Mt}),Ji=uv({bignumber:r1,fraction:Mf,number:Af}),i1=sv({config:mr,multiplyScalar:Js,numeric:Ji,typed:Mt}),s1=Gg({isInteger:Hs,matrix:Te,typed:Mt}),Of=Jg({matrix:Te,config:mr,typed:Mt}),Bf=Qg({matrix:Te,typed:Mt}),Jn=Pg({isInteger:Hs,matrix:Te,typed:Mt}),o1=kg({prod:i1,size:Of,typed:Mt}),a1=ev({conj:Ef,transpose:Bf,typed:Mt}),Xi=cv({numeric:Ji,typed:Mt}),u1=pv({DenseMatrix:rn,concat:Jn,divideScalar:Xi,equalScalar:On,matrix:Te,typed:Mt}),If=yv({DenseMatrix:rn,concat:Jn,equalScalar:On,matrix:Te,typed:Mt}),Tf=Ug({BigNumber:Ks,DenseMatrix:rn,SparseMatrix:Ia,config:mr,matrix:Te,typed:Mt}),l1=jg({matrix:Te,multiplyScalar:Js,typed:Mt}),c1=bv({DenseMatrix:rn,concat:Jn,config:mr,matrix:Te,typed:Mt}),f1=Bg({DenseMatrix:rn,concat:Jn,equalScalar:On,matrix:Te,subtractScalar:Cf,typed:Mt,unaryMinus:Ta}),Qi=Lv({DenseMatrix:rn,SparseMatrix:Ia,addScalar:Gs,concat:Jn,equalScalar:On,matrix:Te,typed:Mt}),$f=mv({BigNumber:Ks,DenseMatrix:rn,Fraction:Oa,concat:Jn,config:mr,equalScalar:On,matrix:Te,typed:Mt}),h1=Mv({equal:If,typed:Mt}),Lf=Pv({addScalar:Gs,conj:Ef,multiplyScalar:Js,size:Of,typed:Mt}),d1=Av({DenseMatrix:rn,concat:Jn,config:mr,matrix:Te,typed:Mt}),$a=Tv({config:mr,numeric:Ji,smaller:c1,typed:Mt}),wi=Sg({addScalar:Gs,dot:Lf,equalScalar:On,matrix:Te,multiplyScalar:Js,typed:Mt}),p1=Sv({compare:$f,isNaN:Ff,isNumeric:Nf,typed:Mt}),_1=Xv({add:Qi,config:mr,numeric:Ji,typed:Mt}),m1=qv({add:Qi,matrix:Te,typed:Mt}),Rf=Wv({divideScalar:Xi,isZero:n1,matrix:Te,multiply:wi,subtractScalar:Cf,typed:Mt,unaryMinus:Ta}),g1=Bv({config:mr,larger:d1,numeric:Ji,typed:Mt}),Xs=Vv({abs:e1,addScalar:Gs,det:Rf,divideScalar:Xi,identity:Tf,matrix:Te,multiply:wi,typed:Mt,unaryMinus:Ta}),v1=Zv({Complex:Sa,add:Qi,ctranspose:a1,deepEqual:h1,divideScalar:Xi,dot:Lf,dotDivide:u1,equal:If,inv:Xs,matrix:Te,multiply:wi,typed:Mt}),y1=hv({Complex:Sa,config:mr,fraction:Mf,identity:Tf,inv:Xs,matrix:Te,multiply:wi,number:Af,typed:Mt}),w1=Hv({divideScalar:Xi,equalScalar:On,inv:Xs,matrix:Te,multiply:wi,typed:Mt}),Pf=t1({add:Qi,compare:$f,divide:w1,partitionSelect:p1,typed:Mt});class D1{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_math");$(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:i},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);i&&(c=Math.floor(c));const h=e/n;let d=0,f=0;for(let p=0;p<=e-1;p++){const g=Math.exp(-1*Math.pow(p-c,2)/(2*Math.pow(h,2)));d+=g,f+=l[l.length-1-(e-p-1)]*g}return f/d}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const i=this._cacheDataList(t,e,`sma_${r}`);if(i===void 0)return;const a=i.slice(-e);return n=_1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;this._cacheDataList(t,e,`sma_${r}`);const{sum:n}=this._cacheData[`rma_${r}`]||{},i=1/e,a=n===void 0?this.sma({source:t,length:e},r):i*t+(1-i)*(n||0);return this._cacheDataHandle(`rma_${r}`,{sum:a}),a}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:i,close:a,low:l}=this._variables,c=r===void 0?i-l:Math.max(Math.max(i-l,Math.abs(i-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:i,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const i=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(i===void 0)return;let l=0;for(let c=0;c<e;c++){const h=this._sum(i[i.length-1-c],-(a||0));l+=h*h}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return[];const l=r*a;return[i,i+l,i-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return;const l=r*a;return(i+l-(i-l))/i}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),i=this.dev({source:t,length:e},r);if(!(n===void 0||i===void 0))return(t-n)/(.015*i)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const i=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return i===void 0?i:typeof t=="boolean"?i!==t:t-i}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const i=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(i===void 0||a===void 0))return 100*(i-a)/(i+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),i=this._math.sum({source:t,length:e},r);if(i===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/i}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const i=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||i===void 0)return;let c=0,h=0,d=0;for(let p=0;p<r;p++){const[g,y]=i[i.length-1-p],m=g-a,w=y-l;c+=m*w,h+=m*m,d+=w*w}return isNaN(h)||isNaN(c)||isNaN(d)?void 0:c/Math.sqrt(h*d)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e||n<=i&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n<=i&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let i=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];i+=Math.abs(c-n)}return i/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:i,high:a,close:l,PDMS:c,NDMS:h,TRS:d,ADX:f,count:p=0}=this._cacheData[n]||{},{low:g,high:y,close:m}=this._variables;if(i===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:y,close:m,PDMS:c,NDMS:h,TRS:y-g,count:1},[void 0,void 0,void 0];let w=y-a,v=i-g;w=w>v&&w>0?w:0,v=v>w&&v>0?v:0,w===v&&(w=v=0);const x=Math.max(y-g,Math.abs(y-l),Math.abs(g-l));if(p<t)return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:(c||0)+w,NDMS:(h||0)+v,TRS:(d||0)+x,count:p+1}),[void 0,void 0,void 0];{const b=c-c/t+w,N=h-h/t+v,E=d-d/t+x,A=b/E*100,M=N/E*100,S=Math.abs((A-M)/(A+M))*100;let T=S,F=[A,M,void 0];if(p+1-t<e){const B=p+1-t;T=((f||0)*(B-1)+S)/B}else T=(f*(e-1)+S)/e,F=[A,M,T];return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:b,NDMS:N,TRS:E,ADX:T,count:p+1}),F}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:i=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(i>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return i+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:i}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:i=[]}=this._cacheData[`falling_${r}`]||{};i.push(n>t);const a=i.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:i=[]}=this._cacheData[`rising_${r}`]||{};i.push(n<t);const a=i.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(i)return Math.max(...i.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return i?i.slice(-e).reduce((l,c,h,d)=>c>=d[l]?h:l,0)-e+1:void 0}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let i=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;i+=c,a+=n[n.length-1-l]*c}return a/i}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),i=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||i===void 0?void 0:this.wma({source:2*i-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},i),{ta:l,high:c,low:h}=this._variables,d=n?l.tr:c-h,f=this.ema({source:d,length:e},`range_${i}`);return[a,a+f*r,a-f*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},i),{ta:l,high:c,low:h}=this._variables,d=n?l.tr:c-h,f=this.ema({source:d,length:e},`range_${i}`);return(a+f*r-(a-f*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const i=this._cacheDataList(t,e,`dev_${n}`);if(!i)return;const a=i.slice(-e).filter(g=>g!==void 0);let l=0,c=0,h=0,d=0;for(const[g,y]of a.entries())l+=g,c+=y,h+=g*y,d+=g*g;const f=(e*h-l*c)/(e*d-l*l);return(c-f*l)/e+f*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(i)return Math.min(...i.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return i?i.slice(-e).reduce((l,c,h,d)=>c<=d[l]?h:l,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${i}`),l=this.ema({source:t,length:r},`ema2_${i}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,h=this.ema({source:c,length:n},`macd_${i}`);if(h===void 0)return[c,h,void 0];const d=c-h;return[c,h,d]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Pf(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,i=this.change({source:t},r),a=this._math.sum({source:n*(i>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(i<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return $a(Sf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,i=this._cacheData[n]||[];if(i[this._variables.bar_index]=t,this._cacheData[n]=i,i.length<=e||t===void 0||isNaN(t))return;let a=i.length-e-1,l;for(;l===void 0&&a>=0;)l=i[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!i)return;const a=this._sort(i.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[h,d]of a.entries()){const f=a[h-1];if(r<(h+.5)/l)return f===void 0||d===void 0?void 0:f+(d-f)*(r-(h-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!i)return;const a=this._sort(i.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const i=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<i.length;c++)i[c]!==void 0&&(i[c]<a||i[c]===a&&c<e)&&l++;return l/(i.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const i=new Qt;let{close:a,open:l,low:c,high:h}=this._variables;const d=`pivot_point_levels_${n}`,{close:f,low:p,high:g,open:y,result:m}=this._cacheData[d]||{};if(!e&&(g&&p&&(h=Math.max(g,h),c=Math.min(p,c)),this._cacheDataHandle(d,{close:a,open:l,low:c,high:h,result:m}),!r))return i._value=m||[],i;const w={close:a,open:l,low:c,high:h};e===!0&&!r&&(a=f,l=y,c=p,h=g);const v=this._getPivotPointLevels(h,c,a,l,r,t);return this._cacheDataHandle(d,{...w,result:v}),i._value=v,i}_getPivotPointLevels(t,e,r,n,i,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Kn.traditional:return this._traditional(t,e,r);case Kn.fibonacci:return this._fibonacci(t,e,r);case Kn.woodie:return i?[]:this._woodie(t,e);case Kn.classic:return this._classic(t,e,r);case Kn.dm:return this._DM(t,e,r,n);case Kn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,i=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),h=n*4+(t-4*e),d=n*2-t,f=n-(t-e),p=n*2-(2*t-e),g=n*3-(3*t-e),y=n*4-(4*t-e);return[n,i,d,a,f,l,p,c,g,h,y]}_fibonacci(t,e,r){const n=(t+e+r)/3,i=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),h=n+(t-e),d=n-(t-e);return[n,i,a,l,c,h,d]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=t+2*(n-e),d=e-2*(t-n),f=h+(t-e),p=d-(t-e);return[n,i,a,l,c,h,d,f,p]}_classic(t,e,r){const n=(t+e+r)/3,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=n+2*(t-e),d=n-2*(t-e),f=n+3*(t-e),p=n-3*(t-e);return[n,i,a,l,c,h,d,f,p]}_DM(t,e,r,n){let i;n===r?i=t+e+2*r:r>n?i=2*t+e+r:i=2*e+t+r;const a=i/4,l=i/2-e,c=i/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,i=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,h=r+1.1*(t-e)/4,d=r-1.1*(t-e)/4,f=r+1.1*(t-e)/2,p=r-1.1*(t-e)/2,g=t/e*r,y=r-(g-r);return[n,i,a,l,c,h,d,f,p,g,y]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const i=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const i=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const i=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...i),l=Math.min(...i);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),i=this.change({source:t,length:e},r);if(n)return 100*i/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},i=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:i,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:i,low:a,high:l,preLow:c,preHigh:h,data:d={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:p,acceleration:g,isBelow:y}=d,m=!1;const{close:w,low:v,high:x,bar_index:b}=this._variables;return b===1&&(w>i?(y=!0,p=x,f=a):(y=!1,p=v,f=l),m=!0,g=t),f=f+g*(p-f),y?f>v&&(m=!0,y=!1,f=Math.max(x,p||0),p=v,g=t):f<x&&(m=!0,y=!0,f=Math.min(v,p||0),p=x,g=t),m||(y?x>(p||0)&&(p=x,g=Math.min((g||0)+e,r)):v<(p||0)&&(p=v,g=Math.min((g||0)+e,r))),y?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,h))),this._cacheDataHandle(`sar_${n}`,{high:x,close:w,low:v,preLow:a,preHigh:l,data:Object.assign(d,{result:f,maxMin:p,acceleration:g,isBelow:y})}),f}stoch({source:t,high:e,low:r,length:n},i){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},i),l=this.highest({source:e,length:n},i);if(!(a===void 0||l===void 0))return 100*(this._variables.close-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:i}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:h,atr:d,close:f}=this._cacheData[a]||{},p=this.atr({length:e},r);if(p===void 0)return this._cacheDataHandle(a,{close:i}),[void 0,void 0];let g=n+t*p,y=n-t*p;const m=l||0,w=c||0;y=y>w||f<w?y:w,g=g<m||f>m?g:m;let v;d===void 0?v=1:h===m?v=i>g?-1:1:v=i<y?1:-1;const x=v===-1?y:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:y,superTrend:x,atr:p,close:i}),[x,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:i}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?i-n:void 0:Math.max(i-n,Math.abs(i-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.change({source:t},n);if(i===void 0)return;const a=this.ema({source:Math.abs(i),length:e},`absema1_${n}`),l=this.ema({source:i,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),h=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/h}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:i}=this._cacheData[`valuewhen_${n}`]||{};return i||(i=[]),t&&i.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:i}),i[i.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const i=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`mode_${n}`,!0);if(!a||i===void 0)return;const l=a.filter(h=>h!==void 0&&!isNaN(h)).slice(-e);if(l.length<e)return;const c=l.reduce((h,d)=>h+Math.pow(d-i,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:i}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:h,sumS:d=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=d=0,h=!0),!h)return r!==void 0?[]:void 0;const f=t*i+a,p=i+l,g=f/p;return c++,r!==void 0?(d=i*Math.pow(t,2)+d,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:p,count:c,isReset:h,sumS:d}),this._computeBands(d,p,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:p,count:c,isReset:h}),g)}_computeBands(t,e,r,n){let i=t/e-Math.pow(n,2);i=i<0?0:i;const a=Math.sqrt(i),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,i=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(i===void 0||a===void 0))return i/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:i}=this._variables;if(!(r===void 0||n===void 0))return(r-i)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let i=0;i<e-r;i++){const{currentVal:a,currentIndex:l}=n,c=t[i];if(c!==void 0){if(a!==void 0&&c<a){t.splice(i,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:i,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const i=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(i.barIndex<=a&&(i.barIndex===a?i.list[i.list.length-1]=t:i.list.push(t),i.barIndex=a,i.list.length>e+5&&!n&&i.list.shift(),this._cacheData[r]=i),!(i.list.length<e))return i.list}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&!this._variables._isRealTimeBar&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}class b1{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_errorListener");$(this,"_historyInputs");$(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){if(!(t!=null&&t.length)){self.workerStorage.delete(this._name),this._cacheData={};return}for(const e of t){const r=e.id,n=this._historyInputs[r];(!(e!=null&&e.sourceTypeName)&&(n==null?void 0:n.defval)!==e.defval||n!=null&&n.sourceTypeName&&e.sourceTypeName!==(n==null?void 0:n.sourceTypeName))&&(this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}))}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,ir.INT)}bool(t,e){return this._cacheHandle(t,e,ir.BOOL)}color(t,e){return this._cacheHandle(t,e,ir.COLOR)}time(t,e){return this._cacheHandle(t,e,ir.TIME)}float(t,e){return this._cacheHandle(t,e,ir.FLOAT)}price(t,e){return this._cacheHandle(t,e,ir.PRICE)}source(t,e){return this._cacheHandle(t,e,ir.SOURCE)}string(t,e){return this._cacheHandle(t,e,ir.STRING)}symbol(t,e){return this._cacheHandle(t,e,ir.SYMBOL)}session(t,e){return this._cacheHandle(t,e,ir.SESSION)}text_area(t,e){return this._cacheHandle(t,e,ir.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,ir.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,ir.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,i=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(le.inputDefvalErr,e,zt.Error),self.workerStorage.setValue(this._name,n,{...t}),i)if(!i.isModify)Object.assign(this._cacheData[n],t);else{const a=this._historyInputs[n];!(t.sourceTypeName||a!=null&&a.sourceTypeName)&&t.defval===(a==null?void 0:a.defval)||t.sourceTypeName&&(a==null?void 0:a.sourceTypeName)===t.sourceTypeName?i.sourceTypeName&&(this._cacheData[n].defval=this._variables[i.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:l}=t;this._displayVerify(e,l),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===ir.SOURCE?this._cacheData[n].options=Kd:t.options&&!t.options.includes(a)&&this._errorListener.addError(Ye(le.inputOptErr,{defval:String(a),args:t.options.toString()}),e,zt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ze.dataWindow)||e.includes(Ze.statusLine)||this._errorListener.addError(Ye(le.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,zt.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e.sort((r,n)=>(r.index||0)-(n.index||0))}}class x1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const r=(100-e)/100,{r:n,g:i,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(i)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:i}){if(_t(t)||_t(e)||_t(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:h,b:d,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:p,g,b:y,a:m}=this._parseColor(i||"rgba(0,0,0,0)"),w=c+l*(p-c),v=h+l*(g-h),x=d+l*(y-d),b=f+l*(m-f);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,i;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var kt={};const E1=Object.prototype.toString;function ts(s){const t=E1.call(s);return t.endsWith("Array]")&&!t.includes("Big")}var A1=Object.freeze({__proto__:null,isAnyArray:ts}),C1=Ne(A1);function F1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]>a&&(a=s[l]);return a}function M1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]<a&&(a=s[l]);return a}function N1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ts(s)){if(s.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!ts(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(s.length);var r=M1(s),n=F1(s);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=t.min,a=i===void 0?t.autoMinMax?r:0:i,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var h=(c-a)/(n-r),d=0;d<s.length;d++)e[d]=(s[d]-r)*h+a;return e}var S1=Object.freeze({__proto__:null,default:N1}),O1=Ne(S1);Object.defineProperty(kt,"__esModule",{value:!0});var cr=C1,zf=O1;const Qs=" ".repeat(2),kf=" ".repeat(4);function B1(){return qf(this)}function qf(s,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=t;return`${s.constructor.name} {
|
55
|
+
${Qs}[
|
56
|
+
${kf}${I1(s,e,r,n,i)}
|
57
|
+
${Qs}]
|
58
|
+
${Qs}rows: ${s.rows}
|
59
|
+
${Qs}columns: ${s.columns}
|
60
|
+
}`}function I1(s,t,e,r,n){const{rows:i,columns:a}=s,l=Math.min(i,t),c=Math.min(a,e),h=[];if(n==="auto"){n=!1;t:for(let d=0;d<l;d++)for(let f=0;f<c;f++)if(s.get(d,f)<0){n=!0;break t}}for(let d=0;d<l;d++){let f=[];for(let p=0;p<c;p++)f.push(T1(s.get(d,p),r,n));h.push(`${f.join(" ")}`)}return c!==a&&(h[h.length-1]+=` ... ${a-e} more columns`),l!==i&&h.push(`... ${i-t} more rows`),h.join(`
|
61
|
+
${kf}`)}function T1(s,t,e){return(s>=0&&e?` ${Uf(s,t-1)}`:Uf(s,t)).padEnd(t)}function Uf(s,t){let e=s.toString();if(e.length<=t)return e;let r=s.toFixed(t);if(r.length>t&&(r=s.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=s.toExponential(t);return n.length>t&&(n=s.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function $1(s,t){s.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},s.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r);return this},s.prototype.addM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r.get(n,i));return this},s.add=function(r,n){return new t(r).add(n)},s.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},s.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r);return this},s.prototype.subM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r.get(n,i));return this},s.sub=function(r,n){return new t(r).sub(n)},s.prototype.subtract=s.prototype.sub,s.prototype.subtractS=s.prototype.subS,s.prototype.subtractM=s.prototype.subM,s.subtract=s.sub,s.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},s.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r);return this},s.prototype.mulM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r.get(n,i));return this},s.mul=function(r,n){return new t(r).mul(n)},s.prototype.multiply=s.prototype.mul,s.prototype.multiplyS=s.prototype.mulS,s.prototype.multiplyM=s.prototype.mulM,s.multiply=s.mul,s.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},s.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r);return this},s.prototype.divM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r.get(n,i));return this},s.div=function(r,n){return new t(r).div(n)},s.prototype.divide=s.prototype.div,s.prototype.divideS=s.prototype.divS,s.prototype.divideM=s.prototype.divM,s.divide=s.div,s.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},s.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r);return this},s.prototype.modM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r.get(n,i));return this},s.mod=function(r,n){return new t(r).mod(n)},s.prototype.modulus=s.prototype.mod,s.prototype.modulusS=s.prototype.modS,s.prototype.modulusM=s.prototype.modM,s.modulus=s.mod,s.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},s.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r);return this},s.prototype.andM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r.get(n,i));return this},s.and=function(r,n){return new t(r).and(n)},s.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},s.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r);return this},s.prototype.orM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r.get(n,i));return this},s.or=function(r,n){return new t(r).or(n)},s.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},s.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r);return this},s.prototype.xorM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r.get(n,i));return this},s.xor=function(r,n){return new t(r).xor(n)},s.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},s.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r);return this},s.prototype.leftShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r.get(n,i));return this},s.leftShift=function(r,n){return new t(r).leftShift(n)},s.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},s.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r);return this},s.prototype.signPropagatingRightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r.get(n,i));return this},s.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},s.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},s.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r);return this},s.prototype.rightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r.get(n,i));return this},s.rightShift=function(r,n){return new t(r).rightShift(n)},s.prototype.zeroFillRightShift=s.prototype.rightShift,s.prototype.zeroFillRightShiftS=s.prototype.rightShiftS,s.prototype.zeroFillRightShiftM=s.prototype.rightShiftM,s.zeroFillRightShift=s.rightShift,s.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},s.not=function(r){return new t(r).not()},s.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},s.abs=function(r){return new t(r).abs()},s.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},s.acos=function(r){return new t(r).acos()},s.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},s.acosh=function(r){return new t(r).acosh()},s.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},s.asin=function(r){return new t(r).asin()},s.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},s.asinh=function(r){return new t(r).asinh()},s.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},s.atan=function(r){return new t(r).atan()},s.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},s.atanh=function(r){return new t(r).atanh()},s.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},s.cbrt=function(r){return new t(r).cbrt()},s.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},s.ceil=function(r){return new t(r).ceil()},s.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},s.clz32=function(r){return new t(r).clz32()},s.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},s.cos=function(r){return new t(r).cos()},s.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},s.cosh=function(r){return new t(r).cosh()},s.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},s.exp=function(r){return new t(r).exp()},s.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},s.expm1=function(r){return new t(r).expm1()},s.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},s.floor=function(r){return new t(r).floor()},s.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},s.fround=function(r){return new t(r).fround()},s.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},s.log=function(r){return new t(r).log()},s.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},s.log1p=function(r){return new t(r).log1p()},s.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},s.log10=function(r){return new t(r).log10()},s.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},s.log2=function(r){return new t(r).log2()},s.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},s.round=function(r){return new t(r).round()},s.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},s.sign=function(r){return new t(r).sign()},s.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},s.sin=function(r){return new t(r).sin()},s.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},s.sinh=function(r){return new t(r).sinh()},s.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},s.sqrt=function(r){return new t(r).sqrt()},s.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},s.tan=function(r){return new t(r).tan()},s.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},s.tanh=function(r){return new t(r).tanh()},s.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},s.trunc=function(r){return new t(r).trunc()},s.pow=function(r,n){return new t(r).pow(n)},s.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},s.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r));return this},s.prototype.powM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r.get(n,i)));return this}}function Sr(s,t,e){let r=e?s.rows:s.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Or(s,t,e){let r=e?s.columns:s.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Di(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function bi(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function La(s,t){if(!cr.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=s.rows)throw new RangeError("row indices are out of range")}function Ra(s,t){if(!cr.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=s.columns)throw new RangeError("column indices are out of range")}function Pa(s,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(eo("startRow",t),eo("endRow",e),eo("startColumn",r),eo("endColumn",n),t>e||r>n||t<0||t>=s.rows||e<0||e>=s.rows||r<0||r>=s.columns||n<0||n>=s.columns)throw new RangeError("Submatrix indices are out of range")}function to(s,t=0){let e=[];for(let r=0;r<s;r++)e.push(t);return e}function eo(s,t){if(typeof t!="number")throw new TypeError(`${s} must be a number`)}function xi(s){if(s.isEmpty())throw new Error("Empty matrix has no elements to index")}function L1(s){let t=to(s.rows);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]+=s.get(e,r);return t}function R1(s){let t=to(s.columns);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]+=s.get(e,r);return t}function P1(s){let t=0;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t+=s.get(e,r);return t}function z1(s){let t=to(s.rows,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]*=s.get(e,r);return t}function k1(s){let t=to(s.columns,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]*=s.get(e,r);return t}function q1(s){let t=1;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t*=s.get(e,r);return t}function U1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<r;a++){let l=0,c=0,h=0;for(let d=0;d<n;d++)h=s.get(a,d)-e[a],l+=h,c+=h*h;t?i.push((c-l*l/n)/(n-1)):i.push((c-l*l/n)/n)}return i}function W1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<n;a++){let l=0,c=0,h=0;for(let d=0;d<r;d++)h=s.get(d,a)-e[a],l+=h,c+=h*h;t?i.push((c-l*l/r)/(r-1)):i.push((c-l*l/r)/r)}return i}function j1(s,t,e){const r=s.rows,n=s.columns,i=r*n;let a=0,l=0,c=0;for(let h=0;h<r;h++)for(let d=0;d<n;d++)c=s.get(h,d)-e,a+=c,l+=c*c;return t?(l-a*a/i)/(i-1):(l-a*a/i)/i}function V1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[e])}function Y1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[r])}function Z1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t)}function K1(s){const t=[];for(let e=0;e<s.rows;e++){let r=0;for(let n=0;n<s.columns;n++)r+=Math.pow(s.get(e,n),2)/(s.columns-1);t.push(Math.sqrt(r))}return t}function G1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[e])}function H1(s){const t=[];for(let e=0;e<s.columns;e++){let r=0;for(let n=0;n<s.rows;n++)r+=Math.pow(s.get(n,e),2)/(s.rows-1);t.push(Math.sqrt(r))}return t}function J1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[r])}function X1(s){const t=s.size-1;let e=0;for(let r=0;r<s.columns;r++)for(let n=0;n<s.rows;n++)e+=Math.pow(s.get(n,r),2)/t;return Math.sqrt(e)}function Q1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t)}class $t{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let i=new dt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,r[a*e+l]);return i}static rowVector(t){let e=new dt(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new dt(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new dt(t,e)}static ones(t,e){return new dt(t,e).fill(1)}static rand(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let i=new dt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,n());return i}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let l=i-n,c=new dt(t,e);for(let h=0;h<t;h++)for(let d=0;d<e;d++){let f=n+Math.round(a()*l);c.set(h,d,f)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),i=this.zeros(t,e);for(let a=0;a<n;a++)i.set(a,a,r);return i}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let i=Math.min(n,e,r),a=this.zeros(e,r);for(let l=0;l<i;l++)a.set(l,l,t[l]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new dt(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.min(t.get(a,l),e.get(a,l)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.max(t.get(a,l),e.get(a,l)));return i}static checkMatrix(t){return $t.isMatrix(t)?t:new dt(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(this.get(t,t)!==0)return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!0);for(let a=e+1;a<this.rows;a++)this.get(t,a)!==0&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let i=e;i<t.rows;i++)t.get(i,r)>t.get(n,r)&&(n=i);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let i=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/i);for(let a=e+1;a<t.rows;a++){let l=t.get(a,r)/t.get(e,r);t.set(a,r,0);for(let c=r+1;c<t.columns;c++)t.set(a,c,t.get(a,c)-t.get(e,c)*l)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(t.maxRow(n)===0)n--;else{let i=0,a=!1;for(;i<r&&a===!1;)t.get(n,i)===1?a=!0:i++;for(let l=0;l<n;l++){let c=t.get(l,i);for(let h=i;h<e;h++){let d=t.get(l,h)-c*t.get(n,h);t.set(l,h,d)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new dt(this.rows*e,this.columns*r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*i,this.columns*a);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Sr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return dt.rowVector(this.getRow(t))}setRow(t,e){Sr(this,t),e=Di(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Sr(this,t),Sr(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Or(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return dt.columnVector(this.getColumn(t))}setColumn(t,e){Or(this,t),e=bi(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Or(this,t),Or(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Sr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Or(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){xi(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}minIndex(){xi(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Sr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Sr(this,t),xi(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Sr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Sr(this,t),xi(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Or(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){Or(this,t),xi(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Or(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){Or(this,t),xi(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){$t.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,i=new dt(e,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let c=0;c<r;c++)a[c]=t.get(c,l);for(let c=0;c<e;c++){let h=0;for(let d=0;d<r;d++)h+=this.get(c,d)*a[d];i.set(c,l,h)}}return i}strassen2x2(t){t=dt.checkMatrix(t);let e=new dt(2,2);const r=this.get(0,0),n=t.get(0,0),i=this.get(0,1),a=t.get(0,1),l=this.get(1,0),c=t.get(1,0),h=this.get(1,1),d=t.get(1,1),f=(r+h)*(n+d),p=(l+h)*n,g=r*(a-d),y=h*(c-n),m=(r+i)*d,w=(l-r)*(n+a),v=(i-h)*(c+d),x=f+y-m+v,b=g+m,N=p+y,E=f-p+g+w;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,N),e.set(1,1,E),e}strassen3x3(t){t=dt.checkMatrix(t);let e=new dt(3,3);const r=this.get(0,0),n=this.get(0,1),i=this.get(0,2),a=this.get(1,0),l=this.get(1,1),c=this.get(1,2),h=this.get(2,0),d=this.get(2,1),f=this.get(2,2),p=t.get(0,0),g=t.get(0,1),y=t.get(0,2),m=t.get(1,0),w=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),N=t.get(2,2),E=(r+n+i-a-l-d-f)*w,A=(r-a)*(-g+w),M=l*(-p+g+m-w-v-x+N),S=(-r+a+l)*(p-g+w),T=(a+l)*(-p+g),F=r*p,B=(-r+h+d)*(p-y+v),R=(-r+h)*(y-v),U=(h+d)*(-p+y),q=(r+n+i-l-c-h-d)*v,W=d*(-p+y+m-w-v-x+b),z=(-i+d+f)*(w+x-b),K=(i-f)*(w-b),Z=i*x,X=(d+f)*(-x+b),Q=(-i+l+c)*(v+x-N),ct=(i-c)*(v-N),vt=(l+c)*(-x+N),lt=n*m,wt=c*b,bt=a*y,Ot=h*g,xt=f*N,ae=F+Z+lt,It=E+S+T+F+z+Z+X,Nt=F+B+U+q+Z+Q+vt,ce=A+M+S+F+Z+Q+ct,re=A+S+T+F+wt,qt=Z+Q+ct+vt+bt,Jt=F+B+R+W+z+K+Z,$e=z+K+Z+X+Ot,vr=F+B+R+U+xt;return e.set(0,0,ae),e.set(0,1,It),e.set(0,2,Nt),e.set(1,0,ce),e.set(1,1,re),e.set(1,2,qt),e.set(2,0,Jt),e.set(2,1,$e),e.set(2,2,vr),e}mmulStrassen(t){t=dt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,i=t.rows,a=t.columns;n!==i&&console.warn(`Multiplying ${r} x ${n} and ${i} x ${a} matrix: dimensions do not match.`);function l(f,p,g){let y=f.rows,m=f.columns;if(y===p&&m===g)return f;{let w=$t.zeros(p,g);return w=w.setSubMatrix(f,0,0),w}}let c=Math.max(r,i),h=Math.max(n,a);e=l(e,c,h),t=l(t,c,h);function d(f,p,g,y){if(g<=512||y<=512)return f.mmul(p);g%2===1&&y%2===1?(f=l(f,g+1,y+1),p=l(p,g+1,y+1)):g%2===1?(f=l(f,g+1,y),p=l(p,g+1,y)):y%2===1&&(f=l(f,g,y+1),p=l(p,g,y+1));let m=parseInt(f.rows/2,10),w=parseInt(f.columns/2,10),v=f.subMatrix(0,m-1,0,w-1),x=p.subMatrix(0,m-1,0,w-1),b=f.subMatrix(0,m-1,w,f.columns-1),N=p.subMatrix(0,m-1,w,p.columns-1),E=f.subMatrix(m,f.rows-1,0,w-1),A=p.subMatrix(m,p.rows-1,0,w-1),M=f.subMatrix(m,f.rows-1,w,f.columns-1),S=p.subMatrix(m,p.rows-1,w,p.columns-1),T=d($t.add(v,M),$t.add(x,S),m,w),F=d($t.add(E,M),x,m,w),B=d(v,$t.sub(N,S),m,w),R=d(M,$t.sub(A,x),m,w),U=d($t.add(v,b),S,m,w),q=d($t.sub(E,v),$t.add(x,N),m,w),W=d($t.sub(b,M),$t.add(A,S),m,w),z=$t.add(T,R);z.sub(U),z.add(W);let K=$t.add(B,U),Z=$t.add(F,R),X=$t.sub(T,F);X.add(B),X.add(q);let Q=$t.zeros(2*z.rows,2*z.columns);return Q=Q.setSubMatrix(z,0,0),Q=Q.setSubMatrix(K,z.rows,0),Q=Q.setSubMatrix(Z,0,z.columns),Q=Q.setSubMatrix(X,z.rows,z.columns),Q.subMatrix(0,g-1,0,y-1)}return d(e,t,c,h)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let i=0;i<this.rows;i++){const a=this.getRow(i);a.length>0&&zf(a,{min:e,max:r,output:a}),n.setRow(i,a)}return n}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let i=0;i<this.columns;i++){const a=this.getColumn(i);a.length&&zf(a,{min:e,max:r,output:a}),n.setColumn(i,a)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let n=this.get(e,r),i=this.get(e,this.columns-1-r);this.set(e,r,i),this.set(e,this.columns-1-r,n)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let n=this.get(r,e),i=this.get(this.rows-1-r,e);this.set(r,e,i),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,i=t.columns,a=new dt(e*n,r*i);for(let l=0;l<e;l++)for(let c=0;c<r;c++)for(let h=0;h<n;h++)for(let d=0;d<i;d++)a.set(n*l+h,i*c+d,this.get(l,c)*t.get(h,d));return a}kroneckerSum(t){if(t=dt.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(dt.eye(r,r)),i=dt.eye(e,e).kroneckerProduct(t);return n.add(i)}transpose(){let t=new dt(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=Wf){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Wf){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Pa(this,t,e,r,n);let i=new dt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let l=r;l<=n;l++)i.set(a-t,l-r,this.get(a,l));return i}subMatrixRow(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new dt(t.length,r-e+1);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,a-e,this.get(t[i],a))}return n}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new dt(r-e+1,t.length);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(a-e,i,this.get(a,t[i]))}return n}setSubMatrix(t,e,r){if(t=dt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,i=r+t.columns-1;Pa(this,e,n,r,i);for(let a=0;a<t.rows;a++)for(let l=0;l<t.columns;l++)this.set(e+a,r+l,t.get(a,l));return this}selection(t,e){La(this,t),Ra(this,e);let r=new dt(t.length,e.length);for(let n=0;n<t.length;n++){let i=t[n];for(let a=0;a<e.length;a++){let l=e[a];r.set(n,a,this.get(i,l))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new dt(this.rows,this.columns))}static copy(t,e){for(const[r,n,i]of t.entries())e.set(r,n,i);return e}sum(t){switch(t){case"row":return L1(this);case"column":return R1(this);case void 0:return P1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return z1(this);case"column":return k1(this);case void 0:return q1(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":{for(let r=0;r<this.rows;r++)e[r]/=this.columns;return e}case"column":{for(let r=0;r<this.columns;r++)e[r]/=this.rows;return e}case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return U1(this,r,n)}case"column":{if(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return W1(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return j1(this,r,n)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){typeof t=="object"&&(e=t,t=void 0);const r=this.variance(t,e);if(t===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":{if(!cr.isAnyArray(r))throw new TypeError("center must be an array");return V1(this,r),this}case"column":{if(!cr.isAnyArray(r))throw new TypeError("center must be an array");return Y1(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return Z1(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=K1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return G1(this,r),this}case"column":{if(r===void 0)r=H1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return J1(this,r),this}case void 0:{if(r===void 0)r=X1(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return Q1(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return qf(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")]=B1);function Wf(s,t){return s-t}function ty(s){return s.every(t=>typeof t=="number")}$t.random=$t.rand,$t.randomInt=$t.randInt,$t.diagonal=$t.diag,$t.prototype.diagonal=$t.prototype.diag,$t.identity=$t.eye,$t.prototype.negate=$t.prototype.neg,$t.prototype.tensorProduct=$t.prototype.kroneckerProduct;let dt=(Ni=class extends $t{constructor(e,r){super();Al(this,es);$(this,"data");if(Ni.isMatrix(e))Cl(this,es,Fl).call(this,e.rows,e.columns),Ni.copy(e,this);else if(Number.isInteger(e)&&e>=0)Cl(this,es,Fl).call(this,e,r);else if(cr.isAnyArray(e)){const n=e;if(e=n.length,r=e?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<e;i++){if(n[i].length!==r)throw new RangeError("Inconsistent array dimensions");if(!ty(n[i]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}this.rows=e,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(e,r,n){return this.data[e][r]=n,this}get(e,r){return this.data[e][r]}removeRow(e){return Sr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Sr(this,e,!0),r=Float64Array.from(Di(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Or(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let i=0;i<e;i++)n[i]=this.data[r][i];for(let i=e+1;i<this.columns;i++)n[i-1]=this.data[r][i];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Or(this,e,!0),r=bi(this,r);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)i[a]=this.data[n][a];for(i[a++]=r[n];a<this.columns+1;a++)i[a]=this.data[n][a-1];this.data[n]=i}return this.columns+=1,this}},es=new WeakSet,Fl=function(e,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=e,this.columns=r},Ni);$1($t,dt);const go=class go extends $t{constructor(e){super();Al(this,Qe,void 0);if(dt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ua(this,Qe,dt.copy(e,new dt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ua(this,Qe,new dt(e,e));else if(ua(this,Qe,new dt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Jr(this,Qe).size}get rows(){return Jr(this,Qe).rows}get columns(){return Jr(this,Qe).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return dt.isMatrix(e)&&e.klassType==="SymmetricMatrix"}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){const e=new go(this.diagonalSize);for(const[r,n,i]of this.upperRightEntries())e.set(r,n,i);return e}toMatrix(){return new dt(this)}get(e,r){return Jr(this,Qe).get(e,r)}set(e,r,n){return Jr(this,Qe).set(e,r,n),Jr(this,Qe).set(r,e,n),this}removeCross(e){return Jr(this,Qe).removeRow(e),Jr(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),Jr(this,Qe).addRow(e,n),Jr(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,i]of e.entries())i||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let n=0,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=e&&(n=++i);return r}static fromCompact(e){const r=e.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(e)}`);const i=new go(n);for(let a=0,l=0,c=0;c<r;c++)i.set(a,l,e[c]),++a>=n&&(a=++l);return i}*upperRightEntries(){for(let e=0,r=0;e<this.diagonalSize;void 0){const n=this.get(e,r);yield[e,r,n],++r>=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e<this.diagonalSize;void 0)yield this.get(e,r),++r>=this.diagonalSize&&(r=++e)}};Qe=new WeakMap;let Xn=go;Xn.prototype.klassType="SymmetricMatrix";class ro extends Xn{static isDistanceMatrix(t){return Xn.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new Xn(this)}clone(){const t=new ro(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let n=1,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=t&&(n=++i+1);return r}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let i=1,a=0,l=0;l<e;l++)n.set(i,a,t[l]),++i>=r&&(i=++a+1);return n}}ro.prototype.klassSubType="DistanceMatrix";class fn extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class ey extends fn{constructor(t,e){Or(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 ry extends fn{constructor(t,e){Ra(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class ny extends fn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class iy extends fn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class sy extends fn{constructor(t,e){Sr(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class oy extends fn{constructor(t,e){La(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class no extends fn{constructor(t,e,r){La(t,e),Ra(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class ay extends fn{constructor(t,e,r,n,i){Pa(t,e,r,n,i),super(t,r-e+1,i-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class uy extends fn{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class jf extends $t{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class gr extends $t{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function ly(s,t){if(cr.isAnyArray(s))return s[0]&&cr.isAnyArray(s[0])?new gr(s):new jf(s,t);throw new Error("the argument is not an array")}class io{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,i=new Float64Array(r),a=1,l,c,h,d,f,p,g,y,m;for(l=0;l<r;l++)i[l]=l;for(y=new Float64Array(r),c=0;c<n;c++){for(l=0;l<r;l++)y[l]=e.get(l,c);for(l=0;l<r;l++){for(m=Math.min(l,c),f=0,h=0;h<m;h++)f+=e.get(l,h)*y[h];y[l]-=f,e.set(l,c,y[l])}for(d=c,l=c+1;l<r;l++)Math.abs(y[l])>Math.abs(y[d])&&(d=l);if(d!==c){for(h=0;h<n;h++)p=e.get(d,h),e.set(d,h,e.get(c,h)),e.set(c,h,p);g=i[d],i[d]=i[c],i[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(l=c+1;l<r;l++)e.set(l,c,e.get(l,c)/e.get(c,c))}this.LU=e,this.pivotVector=i,this.pivotSign=a}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(t.get(r,r)===0)return!0;return!1}solve(t){t=dt.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=t.columns,i=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,l,c,h;for(h=0;h<a;h++)for(l=h+1;l<a;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h));for(h=a-1;h>=0;h--){for(c=0;c<n;c++)i.set(h,c,i.get(h,c)/e.get(h,h));for(l=0;l<h;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h))}return i}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i>a?n.set(i,a,t.get(i,a)):i===a?n.set(i,a,1):n.set(i,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i<=a?n.set(i,a,t.get(i,a)):n.set(i,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hn(s,t){let e=0;return Math.abs(s)>Math.abs(t)?(e=t/s,Math.abs(s)*Math.sqrt(1+e*e)):t!==0?(e=s/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class za{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,i=new Float64Array(n),a,l,c,h;for(c=0;c<n;c++){let d=0;for(a=c;a<r;a++)d=hn(d,e.get(a,c));if(d!==0){for(e.get(c,c)<0&&(d=-d),a=c;a<r;a++)e.set(a,c,e.get(a,c)/d);for(e.set(c,c,e.get(c,c)+1),l=c+1;l<n;l++){for(h=0,a=c;a<r;a++)h+=e.get(a,c)*e.get(a,l);for(h=-h/e.get(c,c),a=c;a<r;a++)e.set(a,l,e.get(a,l)+h*e.get(a,c))}}i[c]=-d}this.QR=e,this.Rdiag=i}solve(t){t=dt.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=t.columns,i=t.clone(),a=e.columns,l,c,h,d;for(h=0;h<a;h++)for(c=0;c<n;c++){for(d=0,l=h;l<r;l++)d+=e.get(l,h)*i.get(l,c);for(d=-d/e.get(h,h),l=h;l<r;l++)i.set(l,c,i.get(l,c)+d*e.get(l,h))}for(h=a-1;h>=0;h--){for(c=0;c<n;c++)i.set(h,c,i.get(h,c)/this.Rdiag[h]);for(l=0;l<h;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h))}return i.subMatrix(0,a-1,0,n-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,r=new dt(e,e),n,i;for(n=0;n<e;n++)for(i=0;i<e;i++)n<i?r.set(n,i,t.get(n,i)):n===i?r.set(n,i,this.Rdiag[n]):r.set(n,i,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new dt(e,r),i,a,l,c;for(l=r-1;l>=0;l--){for(i=0;i<e;i++)n.set(i,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(t.get(l,l)!==0){for(c=0,i=l;i<e;i++)c+=t.get(i,l)*n.get(i,a);for(c=-c/t.get(l,l),i=l;i<e;i++)n.set(i,a,n.get(i,a)+c*t.get(i,l))}}return n}}class Ei{constructor(t,e={}){if(t=gr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=e;let c=!!i,h=!!a,d=!1,f;if(r<n)if(!l)f=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{f=t.transpose(),r=f.rows,n=f.columns,d=!0;let F=c;c=h,h=F}else f=t.clone();let p=Math.min(r,n),g=Math.min(r+1,n),y=new Float64Array(g),m=new dt(r,p),w=new dt(n,n),v=new Float64Array(n),x=new Float64Array(r),b=new Float64Array(g);for(let F=0;F<g;F++)b[F]=F;let N=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),A=Math.max(N,E);for(let F=0;F<A;F++){if(F<N){y[F]=0;for(let B=F;B<r;B++)y[F]=hn(y[F],f.get(B,F));if(y[F]!==0){f.get(F,F)<0&&(y[F]=-y[F]);for(let B=F;B<r;B++)f.set(B,F,f.get(B,F)/y[F]);f.set(F,F,f.get(F,F)+1)}y[F]=-y[F]}for(let B=F+1;B<n;B++){if(F<N&&y[F]!==0){let R=0;for(let U=F;U<r;U++)R+=f.get(U,F)*f.get(U,B);R=-R/f.get(F,F);for(let U=F;U<r;U++)f.set(U,B,f.get(U,B)+R*f.get(U,F))}v[B]=f.get(F,B)}if(c&&F<N)for(let B=F;B<r;B++)m.set(B,F,f.get(B,F));if(F<E){v[F]=0;for(let B=F+1;B<n;B++)v[F]=hn(v[F],v[B]);if(v[F]!==0){v[F+1]<0&&(v[F]=0-v[F]);for(let B=F+1;B<n;B++)v[B]/=v[F];v[F+1]+=1}if(v[F]=-v[F],F+1<r&&v[F]!==0){for(let B=F+1;B<r;B++)x[B]=0;for(let B=F+1;B<r;B++)for(let R=F+1;R<n;R++)x[B]+=v[R]*f.get(B,R);for(let B=F+1;B<n;B++){let R=-v[B]/v[F+1];for(let U=F+1;U<r;U++)f.set(U,B,f.get(U,B)+R*x[U])}}if(h)for(let B=F+1;B<n;B++)w.set(B,F,v[B])}}let M=Math.min(n,r+1);if(N<n&&(y[N]=f.get(N,N)),r<M&&(y[M-1]=0),E+1<M&&(v[E]=f.get(E,M-1)),v[M-1]=0,c){for(let F=N;F<p;F++){for(let B=0;B<r;B++)m.set(B,F,0);m.set(F,F,1)}for(let F=N-1;F>=0;F--)if(y[F]!==0){for(let B=F+1;B<p;B++){let R=0;for(let U=F;U<r;U++)R+=m.get(U,F)*m.get(U,B);R=-R/m.get(F,F);for(let U=F;U<r;U++)m.set(U,B,m.get(U,B)+R*m.get(U,F))}for(let B=F;B<r;B++)m.set(B,F,-m.get(B,F));m.set(F,F,1+m.get(F,F));for(let B=0;B<F-1;B++)m.set(B,F,0)}else{for(let B=0;B<r;B++)m.set(B,F,0);m.set(F,F,1)}}if(h)for(let F=n-1;F>=0;F--){if(F<E&&v[F]!==0)for(let B=F+1;B<n;B++){let R=0;for(let U=F+1;U<n;U++)R+=w.get(U,F)*w.get(U,B);R=-R/w.get(F+1,F);for(let U=F+1;U<n;U++)w.set(U,B,w.get(U,B)+R*w.get(U,F))}for(let B=0;B<n;B++)w.set(B,F,0);w.set(F,F,1)}let S=M-1,T=Number.EPSILON;for(;M>0;){let F,B;for(F=M-2;F>=-1&&F!==-1;F--){const R=Number.MIN_VALUE+T*Math.abs(y[F]+Math.abs(y[F+1]));if(Math.abs(v[F])<=R||Number.isNaN(v[F])){v[F]=0;break}}if(F===M-2)B=4;else{let R;for(R=M-1;R>=F&&R!==F;R--){let U=(R!==M?Math.abs(v[R]):0)+(R!==F+1?Math.abs(v[R-1]):0);if(Math.abs(y[R])<=T*U){y[R]=0;break}}R===F?B=3:R===M-1?B=1:(B=2,F=R)}switch(F++,B){case 1:{let R=v[M-2];v[M-2]=0;for(let U=M-2;U>=F;U--){let q=hn(y[U],R),W=y[U]/q,z=R/q;if(y[U]=q,U!==F&&(R=-z*v[U-1],v[U-1]=W*v[U-1]),h)for(let K=0;K<n;K++)q=W*w.get(K,U)+z*w.get(K,M-1),w.set(K,M-1,-z*w.get(K,U)+W*w.get(K,M-1)),w.set(K,U,q)}break}case 2:{let R=v[F-1];v[F-1]=0;for(let U=F;U<M;U++){let q=hn(y[U],R),W=y[U]/q,z=R/q;if(y[U]=q,R=-z*v[U],v[U]=W*v[U],c)for(let K=0;K<r;K++)q=W*m.get(K,U)+z*m.get(K,F-1),m.set(K,F-1,-z*m.get(K,U)+W*m.get(K,F-1)),m.set(K,U,q)}break}case 3:{const R=Math.max(Math.abs(y[M-1]),Math.abs(y[M-2]),Math.abs(v[M-2]),Math.abs(y[F]),Math.abs(v[F])),U=y[M-1]/R,q=y[M-2]/R,W=v[M-2]/R,z=y[F]/R,K=v[F]/R,Z=((q+U)*(q-U)+W*W)/2,X=U*W*(U*W);let Q=0;(Z!==0||X!==0)&&(Z<0?Q=0-Math.sqrt(Z*Z+X):Q=Math.sqrt(Z*Z+X),Q=X/(Z+Q));let ct=(z+U)*(z-U)+Q,vt=z*K;for(let lt=F;lt<M-1;lt++){let wt=hn(ct,vt);wt===0&&(wt=Number.MIN_VALUE);let bt=ct/wt,Ot=vt/wt;if(lt!==F&&(v[lt-1]=wt),ct=bt*y[lt]+Ot*v[lt],v[lt]=bt*v[lt]-Ot*y[lt],vt=Ot*y[lt+1],y[lt+1]=bt*y[lt+1],h)for(let xt=0;xt<n;xt++)wt=bt*w.get(xt,lt)+Ot*w.get(xt,lt+1),w.set(xt,lt+1,-Ot*w.get(xt,lt)+bt*w.get(xt,lt+1)),w.set(xt,lt,wt);if(wt=hn(ct,vt),wt===0&&(wt=Number.MIN_VALUE),bt=ct/wt,Ot=vt/wt,y[lt]=wt,ct=bt*v[lt]+Ot*y[lt+1],y[lt+1]=-Ot*v[lt]+bt*y[lt+1],vt=Ot*v[lt+1],v[lt+1]=bt*v[lt+1],c&<<r-1)for(let xt=0;xt<r;xt++)wt=bt*m.get(xt,lt)+Ot*m.get(xt,lt+1),m.set(xt,lt+1,-Ot*m.get(xt,lt)+bt*m.get(xt,lt+1)),m.set(xt,lt,wt)}v[M-2]=ct;break}case 4:{if(y[F]<=0&&(y[F]=y[F]<0?-y[F]:0,h))for(let R=0;R<=S;R++)w.set(R,F,-w.get(R,F));for(;F<S&&!(y[F]>=y[F+1]);){let R=y[F];if(y[F]=y[F+1],y[F+1]=R,h&&F<n-1)for(let U=0;U<n;U++)R=w.get(U,F+1),w.set(U,F+1,w.get(U,F)),w.set(U,F,R);if(c&&F<r-1)for(let U=0;U<r;U++)R=m.get(U,F+1),m.set(U,F+1,m.get(U,F)),m.set(U,F,R);F++}M--;break}}}if(d){let F=w;w=m,m=F}this.m=r,this.n=n,this.s=y,this.U=m,this.V=w}solve(t){let e=t,r=this.threshold,n=this.s.length,i=dt.zeros(n,n);for(let p=0;p<n;p++)Math.abs(this.s[p])<=r?i.set(p,p,0):i.set(p,p,1/this.s[p]);let a=this.U,l=this.rightSingularVectors,c=l.mmul(i),h=l.rows,d=a.rows,f=dt.zeros(h,d);for(let p=0;p<h;p++)for(let g=0;g<d;g++){let y=0;for(let m=0;m<n;m++)y+=c.get(p,m)*a.get(g,m);f.set(p,g,y)}return f.mmul(e)}solveForDiagonal(t){return this.solve(dt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,i=new dt(r,this.s.length);for(let d=0;d<r;d++)for(let f=0;f<n;f++)Math.abs(this.s[f])>e&&i.set(d,f,t.get(d,f)/this.s[f]);let a=this.U,l=a.rows,c=a.columns,h=new dt(r,l);for(let d=0;d<r;d++)for(let f=0;f<l;f++){let p=0;for(let g=0;g<c;g++)p+=i.get(d,g)*a.get(f,g);h.set(d,f,p)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,i=r.length;n<i;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return dt.diag(this.s)}}function cy(s,t=!1){return s=gr.checkMatrix(s),t?new Ei(s).inverse():Vf(s,dt.eye(s.rows))}function Vf(s,t,e=!1){return s=gr.checkMatrix(s),t=gr.checkMatrix(t),e?new Ei(s).solve(t):s.isSquare()?new io(s).solve(t):new za(s).solve(t)}function so(s){if(s=dt.checkMatrix(s),s.isSquare()){if(s.columns===0)return 1;let t,e,r,n;if(s.columns===2)return t=s.get(0,0),e=s.get(0,1),r=s.get(1,0),n=s.get(1,1),t*n-e*r;if(s.columns===3){let i,a,l;return i=new no(s,[1,2],[1,2]),a=new no(s,[1,2],[0,2]),l=new no(s,[1,2],[0,1]),t=s.get(0,0),e=s.get(0,1),r=s.get(0,2),t*so(i)-e*so(a)+r*so(l)}else return new io(s).determinant}else throw Error("determinant can only be calculated for a square matrix")}function fy(s,t){let e=[];for(let r=0;r<s;r++)r!==t&&e.push(r);return e}function hy(s,t,e,r=1e-9,n=1e-9){if(s>n)return new Array(t.rows+1).fill(0);{let i=t.addRow(e,[0]);for(let a=0;a<i.rows;a++)Math.abs(i.get(a,0))<r&&i.set(a,0,0);return i.to1DArray()}}function dy(s,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;s=dt.checkMatrix(s);let n=s.rows,i=new dt(n,n);for(let a=0;a<n;a++){let l=dt.columnVector(s.getRow(a)),c=s.subMatrixRow(fy(n,a)).transpose(),d=new Ei(c).solve(l),f=dt.sub(l,c.mmul(d)).abs().max();i.setRow(a,hy(f,d,a,e,r))}return i}function py(s,t=Number.EPSILON){if(s=dt.checkMatrix(s),s.isEmpty())return s.transpose();let e=new Ei(s,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,i=e.diagonal;for(let a=0;a<i.length;a++)Math.abs(i[a])>t?i[a]=1/i[a]:i[a]=0;return n.mmul(dt.diag(i).mmul(r.transpose()))}function _y(s,t=s,e={}){s=new dt(s);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new dt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(s=s.center("column"),r||(t=t.center("column")));const i=s.transpose().mmul(t);for(let a=0;a<i.rows;a++)for(let l=0;l<i.columns;l++)i.set(a,l,i.get(a,l)*(1/(s.rows-1)));return i}function my(s,t=s,e={}){s=new dt(s);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new dt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:i=!0}=e;n&&(s.center("column"),r||t.center("column")),i&&(s.scale("column"),r||t.scale("column"));const a=s.standardDeviation("column",{unbiased:!0}),l=r?a:t.standardDeviation("column",{unbiased:!0}),c=s.transpose().mmul(t);for(let h=0;h<c.rows;h++)for(let d=0;d<c.columns;d++)c.set(h,d,c.get(h,d)*(1/(a[h]*l[d]))*(1/(s.rows-1)));return c}let Yf=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=gr.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n=t.columns,i=new dt(n,n),a=new Float64Array(n),l=new Float64Array(n),c=t,h,d,f=!1;if(r?f=!0:f=t.isSymmetric(),f){for(h=0;h<n;h++)for(d=0;d<n;d++)i.set(h,d,c.get(h,d));gy(n,l,a,i),vy(n,l,a,i)}else{let p=new dt(n,n),g=new Float64Array(n);for(d=0;d<n;d++)for(h=0;h<n;h++)p.set(h,d,c.get(h,d));yy(n,p,g,i),wy(n,l,a,i,p)}this.n=n,this.e=l,this.d=a,this.V=i}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,r=this.d,n=new dt(t,t),i,a;for(i=0;i<t;i++){for(a=0;a<t;a++)n.set(i,a,0);n.set(i,i,r[i]),e[i]>0?n.set(i,i+1,e[i]):e[i]<0&&n.set(i,i-1,e[i])}return n}};function gy(s,t,e,r){let n,i,a,l,c,h,d,f;for(c=0;c<s;c++)e[c]=r.get(s-1,c);for(l=s-1;l>0;l--){for(f=0,a=0,h=0;h<l;h++)f=f+Math.abs(e[h]);if(f===0)for(t[l]=e[l-1],c=0;c<l;c++)e[c]=r.get(l-1,c),r.set(l,c,0),r.set(c,l,0);else{for(h=0;h<l;h++)e[h]/=f,a+=e[h]*e[h];for(n=e[l-1],i=Math.sqrt(a),n>0&&(i=-i),t[l]=f*i,a=a-n*i,e[l-1]=n-i,c=0;c<l;c++)t[c]=0;for(c=0;c<l;c++){for(n=e[c],r.set(c,l,n),i=t[c]+r.get(c,c)*n,h=c+1;h<=l-1;h++)i+=r.get(h,c)*e[h],t[h]+=r.get(h,c)*n;t[c]=i}for(n=0,c=0;c<l;c++)t[c]/=a,n+=t[c]*e[c];for(d=n/(a+a),c=0;c<l;c++)t[c]-=d*e[c];for(c=0;c<l;c++){for(n=e[c],i=t[c],h=c;h<=l-1;h++)r.set(h,c,r.get(h,c)-(n*t[h]+i*e[h]));e[c]=r.get(l-1,c),r.set(l,c,0)}}e[l]=a}for(l=0;l<s-1;l++){if(r.set(s-1,l,r.get(l,l)),r.set(l,l,1),a=e[l+1],a!==0){for(h=0;h<=l;h++)e[h]=r.get(h,l+1)/a;for(c=0;c<=l;c++){for(i=0,h=0;h<=l;h++)i+=r.get(h,l+1)*r.get(h,c);for(h=0;h<=l;h++)r.set(h,c,r.get(h,c)-i*e[h])}}for(h=0;h<=l;h++)r.set(h,l+1,0)}for(c=0;c<s;c++)e[c]=r.get(s-1,c),r.set(s-1,c,0);r.set(s-1,s-1,1),t[0]=0}function vy(s,t,e,r){let n,i,a,l,c,h,d,f,p,g,y,m,w,v,x,b;for(a=1;a<s;a++)t[a-1]=t[a];t[s-1]=0;let N=0,E=0,A=Number.EPSILON;for(h=0;h<s;h++){for(E=Math.max(E,Math.abs(e[h])+Math.abs(t[h])),d=h;d<s&&!(Math.abs(t[d])<=A*E);)d++;if(d>h)do{for(n=e[h],f=(e[h+1]-n)/(2*t[h]),p=hn(f,1),f<0&&(p=-p),e[h]=t[h]/(f+p),e[h+1]=t[h]*(f+p),g=e[h+1],i=n-e[h],a=h+2;a<s;a++)e[a]-=i;for(N=N+i,f=e[d],y=1,m=y,w=y,v=t[h+1],x=0,b=0,a=d-1;a>=h;a--)for(w=m,m=y,b=x,n=y*t[a],i=y*f,p=hn(f,t[a]),t[a+1]=x*p,x=t[a]/p,y=f/p,f=y*e[a]-x*n,e[a+1]=i+x*(y*n+x*e[a]),c=0;c<s;c++)i=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+y*i),r.set(c,a,y*r.get(c,a)-x*i);f=-x*b*w*v*t[h]/g,t[h]=x*f,e[h]=y*f}while(Math.abs(t[h])>A*E);e[h]=e[h]+N,t[h]=0}for(a=0;a<s-1;a++){for(c=a,f=e[a],l=a+1;l<s;l++)e[l]<f&&(c=l,f=e[l]);if(c!==a)for(e[c]=e[a],e[a]=f,l=0;l<s;l++)f=r.get(l,a),r.set(l,a,r.get(l,c)),r.set(l,c,f)}}function yy(s,t,e,r){let n=0,i=s-1,a,l,c,h,d,f,p;for(f=n+1;f<=i-1;f++){for(p=0,h=f;h<=i;h++)p=p+Math.abs(t.get(h,f-1));if(p!==0){for(c=0,h=i;h>=f;h--)e[h]=t.get(h,f-1)/p,c+=e[h]*e[h];for(l=Math.sqrt(c),e[f]>0&&(l=-l),c=c-e[f]*l,e[f]=e[f]-l,d=f;d<s;d++){for(a=0,h=i;h>=f;h--)a+=e[h]*t.get(h,d);for(a=a/c,h=f;h<=i;h++)t.set(h,d,t.get(h,d)-a*e[h])}for(h=0;h<=i;h++){for(a=0,d=i;d>=f;d--)a+=e[d]*t.get(h,d);for(a=a/c,d=f;d<=i;d++)t.set(h,d,t.get(h,d)-a*e[d])}e[f]=p*e[f],t.set(f,f-1,p*l)}}for(h=0;h<s;h++)for(d=0;d<s;d++)r.set(h,d,h===d?1:0);for(f=i-1;f>=n+1;f--)if(t.get(f,f-1)!==0){for(h=f+1;h<=i;h++)e[h]=t.get(h,f-1);for(d=f;d<=i;d++){for(l=0,h=f;h<=i;h++)l+=e[h]*r.get(h,d);for(l=l/e[f]/t.get(f,f-1),h=f;h<=i;h++)r.set(h,d,r.get(h,d)+l*e[h])}}}function wy(s,t,e,r,n){let i=s-1,a=0,l=s-1,c=Number.EPSILON,h=0,d=0,f=0,p=0,g=0,y=0,m=0,w=0,v,x,b,N,E,A,M,S,T,F,B,R,U,q,W;for(v=0;v<s;v++)for((v<a||v>l)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<s;x++)d=d+Math.abs(n.get(v,x));for(;i>=a;){for(N=i;N>a&&(y=Math.abs(n.get(N-1,N-1))+Math.abs(n.get(N,N)),y===0&&(y=d),!(Math.abs(n.get(N,N-1))<c*y));)N--;if(N===i)n.set(i,i,n.get(i,i)+h),e[i]=n.get(i,i),t[i]=0,i--,w=0;else if(N===i-1){if(M=n.get(i,i-1)*n.get(i-1,i),f=(n.get(i-1,i-1)-n.get(i,i))/2,p=f*f+M,m=Math.sqrt(Math.abs(p)),n.set(i,i,n.get(i,i)+h),n.set(i-1,i-1,n.get(i-1,i-1)+h),S=n.get(i,i),p>=0){for(m=f>=0?f+m:f-m,e[i-1]=S+m,e[i]=e[i-1],m!==0&&(e[i]=S-M/m),t[i-1]=0,t[i]=0,S=n.get(i,i-1),y=Math.abs(S)+Math.abs(m),f=S/y,p=m/y,g=Math.sqrt(f*f+p*p),f=f/g,p=p/g,x=i-1;x<s;x++)m=n.get(i-1,x),n.set(i-1,x,p*m+f*n.get(i,x)),n.set(i,x,p*n.get(i,x)-f*m);for(v=0;v<=i;v++)m=n.get(v,i-1),n.set(v,i-1,p*m+f*n.get(v,i)),n.set(v,i,p*n.get(v,i)-f*m);for(v=a;v<=l;v++)m=r.get(v,i-1),r.set(v,i-1,p*m+f*r.get(v,i)),r.set(v,i,p*r.get(v,i)-f*m)}else e[i-1]=S+f,e[i]=S+f,t[i-1]=m,t[i]=-m;i=i-2,w=0}else{if(S=n.get(i,i),T=0,M=0,N<i&&(T=n.get(i-1,i-1),M=n.get(i,i-1)*n.get(i-1,i)),w===10){for(h+=S,v=a;v<=i;v++)n.set(v,v,n.get(v,v)-S);y=Math.abs(n.get(i,i-1))+Math.abs(n.get(i-1,i-2)),S=T=.75*y,M=-.4375*y*y}if(w===30&&(y=(T-S)/2,y=y*y+M,y>0)){for(y=Math.sqrt(y),T<S&&(y=-y),y=S-M/((T-S)/2+y),v=a;v<=i;v++)n.set(v,v,n.get(v,v)-y);h+=y,S=T=M=.964}for(w=w+1,E=i-2;E>=N&&(m=n.get(E,E),g=S-m,y=T-m,f=(g*y-M)/n.get(E+1,E)+n.get(E,E+1),p=n.get(E+1,E+1)-m-g-y,g=n.get(E+2,E+1),y=Math.abs(f)+Math.abs(p)+Math.abs(g),f=f/y,p=p/y,g=g/y,!(E===N||Math.abs(n.get(E,E-1))*(Math.abs(p)+Math.abs(g))<c*(Math.abs(f)*(Math.abs(n.get(E-1,E-1))+Math.abs(m)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=i;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=i-1&&(q=b!==i-1,b!==E&&(f=n.get(b,b-1),p=n.get(b+1,b-1),g=q?n.get(b+2,b-1):0,S=Math.abs(f)+Math.abs(p)+Math.abs(g),S!==0&&(f=f/S,p=p/S,g=g/S)),S!==0);b++)if(y=Math.sqrt(f*f+p*p+g*g),f<0&&(y=-y),y!==0){for(b!==E?n.set(b,b-1,-y*S):N!==E&&n.set(b,b-1,-n.get(b,b-1)),f=f+y,S=f/y,T=p/y,m=g/y,p=p/f,g=g/f,x=b;x<s;x++)f=n.get(b,x)+p*n.get(b+1,x),q&&(f=f+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-f*m)),n.set(b,x,n.get(b,x)-f*S),n.set(b+1,x,n.get(b+1,x)-f*T);for(v=0;v<=Math.min(i,b+3);v++)f=S*n.get(v,b)+T*n.get(v,b+1),q&&(f=f+m*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-f*g)),n.set(v,b,n.get(v,b)-f),n.set(v,b+1,n.get(v,b+1)-f*p);for(v=a;v<=l;v++)f=S*r.get(v,b)+T*r.get(v,b+1),q&&(f=f+m*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-f*g)),r.set(v,b,r.get(v,b)-f),r.set(v,b+1,r.get(v,b+1)-f*p)}}}if(d!==0){for(i=s-1;i>=0;i--)if(f=e[i],p=t[i],p===0)for(N=i,n.set(i,i,1),v=i-1;v>=0;v--){for(M=n.get(v,v)-f,g=0,x=N;x<=i;x++)g=g+n.get(v,x)*n.get(x,i);if(t[v]<0)m=M,y=g;else if(N=v,t[v]===0?n.set(v,i,M!==0?-g/M:-g/(c*d)):(S=n.get(v,v+1),T=n.get(v+1,v),p=(e[v]-f)*(e[v]-f)+t[v]*t[v],A=(S*y-m*g)/p,n.set(v,i,A),n.set(v+1,i,Math.abs(S)>Math.abs(m)?(-g-M*A)/S:(-y-T*A)/m)),A=Math.abs(n.get(v,i)),c*A*A>1)for(x=v;x<=i;x++)n.set(x,i,n.get(x,i)/A)}else if(p<0)for(N=i-1,Math.abs(n.get(i,i-1))>Math.abs(n.get(i-1,i))?(n.set(i-1,i-1,p/n.get(i,i-1)),n.set(i-1,i,-(n.get(i,i)-f)/n.get(i,i-1))):(W=oo(0,-n.get(i-1,i),n.get(i-1,i-1)-f,p),n.set(i-1,i-1,W[0]),n.set(i-1,i,W[1])),n.set(i,i-1,0),n.set(i,i,1),v=i-2;v>=0;v--){for(F=0,B=0,x=N;x<=i;x++)F=F+n.get(v,x)*n.get(x,i-1),B=B+n.get(v,x)*n.get(x,i);if(M=n.get(v,v)-f,t[v]<0)m=M,g=F,y=B;else if(N=v,t[v]===0?(W=oo(-F,-B,M,p),n.set(v,i-1,W[0]),n.set(v,i,W[1])):(S=n.get(v,v+1),T=n.get(v+1,v),R=(e[v]-f)*(e[v]-f)+t[v]*t[v]-p*p,U=(e[v]-f)*2*p,R===0&&U===0&&(R=c*d*(Math.abs(M)+Math.abs(p)+Math.abs(S)+Math.abs(T)+Math.abs(m))),W=oo(S*g-m*F+p*B,S*y-m*B-p*F,R,U),n.set(v,i-1,W[0]),n.set(v,i,W[1]),Math.abs(S)>Math.abs(m)+Math.abs(p)?(n.set(v+1,i-1,(-F-M*n.get(v,i-1)+p*n.get(v,i))/S),n.set(v+1,i,(-B-M*n.get(v,i)-p*n.get(v,i-1))/S)):(W=oo(-g-T*n.get(v,i-1),-y-T*n.get(v,i),m,p),n.set(v+1,i-1,W[0]),n.set(v+1,i,W[1]))),A=Math.max(Math.abs(n.get(v,i-1)),Math.abs(n.get(v,i))),c*A*A>1)for(x=v;x<=i;x++)n.set(x,i-1,n.get(x,i-1)/A),n.set(x,i,n.get(x,i)/A)}for(v=0;v<s;v++)if(v<a||v>l)for(x=v;x<s;x++)r.set(v,x,n.get(v,x));for(x=s-1;x>=a;x--)for(v=a;v<=l;v++){for(m=0,b=a;b<=Math.min(x,l);b++)m=m+r.get(v,b)*n.get(b,x);r.set(v,x,m)}}}function oo(s,t,e,r){let n,i;return Math.abs(e)>Math.abs(r)?(n=r/e,i=e+n*r,[(s+n*t)/i,(t-n*s)/i]):(n=e/r,i=r+n*e,[(n*s+t)/i,(n*t-s)/i])}class Zf{constructor(t){if(t=gr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new dt(r,r),i=!0,a,l,c;for(l=0;l<r;l++){let h=0;for(c=0;c<l;c++){let d=0;for(a=0;a<c;a++)d+=n.get(c,a)*n.get(l,a);d=(e.get(l,c)-d)/n.get(c,c),n.set(l,c,d),h=h+d*d}for(h=e.get(l,l)-h,i&=h>0,n.set(l,l,Math.sqrt(Math.max(h,0))),c=l+1;c<r;c++)n.set(l,c,0)}this.L=n,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=gr.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=t.columns,i=t.clone(),a,l,c;for(c=0;c<r;c++)for(l=0;l<n;l++){for(a=0;a<c;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(c,a));i.set(c,l,i.get(c,l)/e.get(c,c))}for(c=r-1;c>=0;c--)for(l=0;l<n;l++){for(a=c+1;a<r;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(a,c));i.set(c,l,i.get(c,l)/e.get(c,c))}return i}get lowerTriangularMatrix(){return this.L}}class Kf{constructor(t,e={}){t=gr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:i=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(cr.isAnyArray(r)&&typeof r[0]=="number"?r=dt.columnVector(r):r=gr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");l=r.getColumnVector(0)}else l=t.getColumnVector(0);let c=1,h,d,f,p;for(let g=0;g<i&&c>a;g++)f=t.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),f=f.div(f.norm()),h=t.mmul(f).div(f.transpose().mmul(f).get(0,0)),g>0&&(c=h.clone().sub(p).pow(2).sum()),p=h.clone(),r?(d=r.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),d=d.div(d.norm()),l=r.mmul(d).div(d.transpose().mmul(d).get(0,0))):l=h;if(r){let g=t.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0));g=g.div(g.norm());let y=t.clone().sub(h.clone().mmul(g.transpose())),m=l.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),w=r.clone().sub(h.clone().mulS(m.get(0,0)).mmul(d.transpose()));this.t=h,this.p=g.transpose(),this.w=f.transpose(),this.q=d,this.u=l,this.s=h.transpose().mmul(h),this.xResidual=y,this.yResidual=w,this.betas=m}else this.w=f.transpose(),this.s=h.transpose().mmul(h).sqrt(),n?this.t=h.clone().div(this.s.get(0,0)):this.t=h,this.xResidual=t.sub(h.mmul(f.transpose()))}}kt.AbstractMatrix=$t,kt.CHO=Zf,kt.CholeskyDecomposition=Zf,kt.DistanceMatrix=ro,kt.EVD=Yf;var Dy=kt.EigenvalueDecomposition=Yf;kt.LU=io,kt.LuDecomposition=io;var Gf=kt.Matrix=dt;kt.MatrixColumnSelectionView=ry,kt.MatrixColumnView=ey,kt.MatrixFlipColumnView=ny,kt.MatrixFlipRowView=iy,kt.MatrixRowSelectionView=oy,kt.MatrixRowView=sy,kt.MatrixSelectionView=no,kt.MatrixSubView=ay,kt.MatrixTransposeView=uy,kt.NIPALS=Kf,kt.Nipals=Kf,kt.QR=za,kt.QrDecomposition=za,kt.SVD=Ei,kt.SingularValueDecomposition=Ei,kt.SymmetricMatrix=Xn,kt.WrapperMatrix1D=jf,kt.WrapperMatrix2D=gr,kt.correlation=my,kt.covariance=_y;var Hf=kt.default=dt;kt.determinant=so,kt.inverse=cy,kt.linearDependencies=dy,kt.pseudoInverse=py,kt.solve=Vf,kt.wrap=ly;const Jf=Dy,Xf=Gf;Hf.Matrix&&Hf.Matrix;class by{constructor(t){$(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new ka(t,e,r,this._errorListener)}avg({id:t}){return t==null?void 0:t.avg()}col({id:t,column:e}){return t==null?void 0:t.col({column:e})}det({id:t}){return t==null?void 0:t.det()}get({id:t,row:e,column:r}){return t==null?void 0:t.get({row:e,column:r})}inv({id:t}){return t==null?void 0:t.inv()}max({id:t}){return t==null?void 0:t.max()}min({id:t}){return t==null?void 0:t.min()}pow({id:t,power:e}){return t==null?void 0:t.pow({power:e})}row({id:t,row:e}){return t==null?void 0:t.row({row:e})}set({id:t,row:e,column:r,value:n}){t==null||t.set({row:e,column:r,value:n})}sum({id1:t,id2:e}){return t==null?void 0:t.sum({id2:e})}copy({id:t}){return t==null?void 0:t.copy()}diff({id1:t,id2:e}){return t==null?void 0:t.diff({id2:e})}rows({id:t}){return t==null?void 0:t.rows()}columns({id:t}){return t==null?void 0:t.columns()}fill({id:t,value:e,from_row:r,to_row:n,from_column:i,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:i,to_column:a})}kron({id1:t,id2:e}){return t==null?void 0:t.kron({id2:e})}mode({id:t}){return t==null?void 0:t.mode()}mult({id1:t,id2:e}){return t==null?void 0:t.mult({id2:e})}pinv({id:t}){return t==null?void 0:t.pinv()}rank({id:t}){return t==null?void 0:t.rank()}sort({id:t,column:e,order:r}){t==null||t.sort({column:e,order:r})}trace({id:t}){return t==null?void 0:t.trace()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}median({id:t}){return t==null?void 0:t.median()}add_col({id:t,column:e,array_id:r}){t==null||t.add_col({column:e,array_id:r})}add_row({id:t,row:e,array_id:r}){t==null||t.add_row({row:e,array_id:r})}is_zero({id:t}){return t==null?void 0:t.is_zero()}reshape({id:t,rows:e,columns:r},n){return t==null?void 0:t.reshape({rows:e,columns:r},n)}reverse({id:t}){t==null||t.reverse()}is_binary({id:t}){return t==null?void 0:t.is_binary()}is_square({id:t}){return t==null?void 0:t.is_square()}submatrix({id:t,from_row:e,to_row:r,from_column:n,to_column:i}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:i})}swap_rows({id:t,row1:e,row2:r}){t==null||t.swap_rows({row1:e,row2:r})}transpose({id:t}){return t==null?void 0:t.transpose()}remove_col({id:t,column:e}){return t==null?void 0:t.remove_col({column:e})}remove_row({id:t,row:e}){return t==null?void 0:t.remove_row({row:e})}eigenvalues({id:t}){return t==null?void 0:t.eigenvalues()}is_diagonal({id:t}){return t==null?void 0:t.is_diagonal()}is_identity({id:t}){return t==null?void 0:t.is_identity()}eigenvectors({id:t}){return t==null?void 0:t.eigenvectors()}is_symmetric({id:t}){return t==null?void 0:t.is_symmetric()}swap_columns({id:t,column1:e,column2:r}){t==null||t.swap_columns({column1:e,column2:r})}is_stochastic({id:t}){return t==null?void 0:t.is_stochastic()}is_triangular({id:t}){return t==null?void 0:t.is_triangular()}elements_count({id:t}){return t==null?void 0:t.elements_count()}is_antidiagonal({id:t}){return t==null?void 0:t.is_antidiagonal()}is_antisymmetric({id:t}){return t==null?void 0:t.is_antisymmetric()}}class ka{constructor(t=0,e=0,r=void 0,n){$(this,"_matrixInstance");$(this,"_errorListener");this._matrixInstance=this._createMatrix(t,e,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(t=>[...t._value])}get _value(){return this._matrixInstance}set _value(t){this._matrixInstance=t}get isMatrix(){return!0}_createMatrix(t,e,r){return Array.from(new Array(t),()=>new Qt(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const i of n._value)t+=_t(i)?0:i,e+=1;return t/e}col({column:t}){const e=[],r=new Qt(0,void 0,this._errorListener);if(_t(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return Rf(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(_t(t)||_t(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=Xs(this._matrixArray);return this._newMatrix(t)}max(){return g1(this._matrixArray)}min(){return $a(this._matrixArray)}pow({power:t}){const e=_t(t)?this._matrixArray:y1(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return _t(t)?new Qt(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){_t(t)||_t(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=Qi(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=f1(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:t,from_row:e,to_row:r,from_column:n,to_column:i}={}){_t(e)&&(e=0),_t(r)&&(r=this.rows()),_t(n)&&(n=0),_t(i)&&(i=this.columns());for(const[a,l]of this._matrixInstance.entries())for(const[c]of l._value.entries())a<r&&a>=e&&c>=n&&c<i&&l.set({index:c,value:t})}kron({id2:t}){const e=l1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return $a(Sf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=wi(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=v1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Yn.ascending}={}){_t(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const i=r._value[t],a=n._value[t];return e!==Yn.descending?i-a:a-i})}trace(){return m1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Pf(this._matrixArray)}add_col({column:t,array_id:e}={}){_t(t)&&(t=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:t,value:e?e._value[r]:void 0})}add_row({row:t,array_id:e}){_t(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new Qt(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t=0,columns:e=0},r){if(t*e!==this.columns()*this.rows()){this._errorListener.addError(le.matrixRehapeErr,r,zt.Error);return}const n=s1(this._matrixArray,[t,e]);this._matrixInstance=n.map(i=>{const a=new Qt(0,void 0,this._errorListener);return a._value=[...i],a})}reverse(){this._matrixInstance.reverse();for(const t of this._matrixInstance)t.reverse()}is_binary(){return this._matrixArray.every(t=>t.every(e=>e===0||e===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:t,to_row:e,from_column:r,to_column:n}={}){_t(t)&&(t=0),_t(e)&&(e=this.rows()),_t(r)&&(r=0),_t(n)&&(n=this.columns());const i=this._matrixArray.splice(t,e),a=[];for(const l of i)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(_t(t)||_t(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=Bf(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){_t(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const i=n._value.splice(t,1);e.push(i[0])}const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return _t(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new Jf(new Xf(this._matrixArray)),e=new Qt(0,void 0,this._errorListener);return e._value=t.realEigenvalues,e}is_diagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<e;i++)if(n!==i&&r[n][i]!==0)return!1;return!0}is_identity(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<e;i++)if(n!==i&&r[n][i]!==0||n===i&&r[n][i]!==1)return!1;return!0}eigenvectors(){const t=new Jf(new Xf(this._matrixArray));return this._newMatrix(t.eigenvectorMatrix.to2DArray())}is_symmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=n+1;i<e;i++)if(r[n][i]!==r[i][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(_t(t)||_t(e)))for(const r of this._matrixInstance){const n=r._value[t],i=r._value[e];r.set({index:t,value:i}),r.set({index:e,value:n})}}is_stochastic(){const t=this._matrixArray;for(let e=0;e<t.length;e++){let r=0;for(let n=0;n<t[e].length;n++){if(t[e][n]<0)return!1;r+=t[e][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const t=this.rows(),e=this.columns();return t!==e?!1:this._isUpperTriangular(t)||this._isLowerTriangular(t)}elements_count(){return o1(this._matrixArray)}is_antidiagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<t;i++)if(n+i!==t-1&&r[n][i]!==0)return!1;return!0}is_antisymmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<t;i++)if(n!==i&&r[n][i]!==-r[i][n])return!1;return!0}_isUpperTriangular(t){const e=this._matrixArray;for(let r=1;r<t;r++)for(let n=0;n<r;n++)if(e[r][n]!==0)return!1;return!0}_isLowerTriangular(t){const e=this._matrixArray;for(let r=0;r<t-1;r++)for(let n=r+1;n<t;n++)if(e[r][n]!==0)return!1;return!0}_newMatrix(t){const e=new ka(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new Qt(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,i=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&i[l][a]===0;)l++;if(l===r)continue;if(l!==a){const h=i[l];i[l]=i[a],i[a]=h}const c=i[a][a];for(let h=0;h<n;h++)i[a][h]/=c;for(let h=a+1;h<r;h++){const d=i[h][a];i[h]=i[h].map((f,p)=>f-d*i[a][p]),i[h][a]=0}}for(let a=0;a<r;a++)i[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class xy{constructor(t){$(this,"_variables");$(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const r=Qr(t),n=Qr(this._variables.timeframe.period);if(r<n)return!0;const i=`change_${e}`,a=this._cacheData[i],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else{const c=this._calcTimeOffset(l,t);return this._cacheData[i]={currentTime:l,offset:c},!1}return!1}in_seconds({timeframe:t}={}){return Qr(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=ee.duration(e);if(r.years())return"12M";const i=r.asMonths();if(Hs(i))return`${i}M`;const a=r.asWeeks();if(Hs(a))return`${a}M`;const l=r.asDays();if(l>=1)return`${Math.ceil(l)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const h=r.asSeconds();return h<=1?"1S":h<=5?"5S":h<=10?"10S":h<=15?"15S":h<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const l=ee(t).day();e="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(e.includes("M")){const l=ee(t).date();e="1D";const c=ee(t).daysInMonth();l!==1&&(r=(c-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),i=Qr(e)*1e3,a=t-n-Math.floor((t-n)/i)*i;return r?r-a:a}}class Ey{constructor(t,e){$(this,"_errorListener");$(this,"_intlNumberFormatter");$(this,"_precision");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}pos({source:t="",str:e=""}){return t==null?void 0:t.indexOf(e)}trim({source:t=""}){return t==null?void 0:t.trim()}lower({source:t=""}){return t==null?void 0:t.toLocaleLowerCase()}match({source:t="",regex:e=""}){const r=t==null?void 0:t.match(new RegExp(e));return r?r[0]:""}split({string:t="",separator:e=""}){const r=t==null?void 0:t.split(e),n=new Qt;return n._value=r||[],n}upper({source:t=""}){return t==null?void 0:t.toLocaleUpperCase()}format({formatString:t=""},e){return this._strFormat(t,e)}length({string:t=""}){return t==null?void 0:t.length}repeat({source:t="",repeat:e,separator:r=""},n){if(_t(e)){this._errorListener.addError(le.arrLenErr,n,zt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){_t(n)&&(n=0);let i=-1;for(let a=0;a<n+1&&(i=t.indexOf(e,i+1),i!==-1);a++);return i!==-1?t.substring(0,i)+r+t.substring(i+e.length):t}contains({source:t="",str:e=""}){return t==null?void 0:t.includes(e)}endswith({source:t="",str:e=""}){return t==null?void 0:t.endsWith(e)}tonumber({string:t=""}){if(/[^\d.]/.test(t))return;const e=parseFloat(t);return isNaN(e)?void 0:e}tostring({value:t,format:e}){if(t===void 0)return"NaN";if(typeof t=="object"){if(t.isArray)return this._arrToStr(t._value,e);if(t.isMatrix){const r=[];for(const n of t._matrixArray)r.push(this._arrToStr(n,e));return r.join(`
|
62
|
+
`)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return String(this._toStringFormat(t,e==null?void 0:e.replace(/0/g,"#")))}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._toStringFormat(n,e):n).toString()}]`}substring({source:t="",begin_pos:e=0,end_pos:r}){return _t(e)&&(e=0),_t(r)&&(r=void 0),t==null?void 0:t.substring(e,r)}startswith({source:t="",str:e=""}){return t==null?void 0:t.startsWith(e)}format_time({time:t,format:e="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return _t(t)&&(t=0),kr(t,r).format(e)}replace_all({source:t="",target:e="",replacement:r=""}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_toStringFormat(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case Kt.mintick:return t.toFixed(this._precision);case Kt.percent:return`${t}%`;case Kt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var l;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[i,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),h=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;h&&(i=i.replace(new RegExp(`\\B(?=(\\d{${h}})+(?!\\d))`,"g"),",")),r=c.join("")}i=r.replace(/#/,i).replace(/#/g,"")}else i=`${r}${i}`;if(n&&n.includes("#")){const c=n.split("#").length-1,h=+`${i}.${a}`;if(!isNaN(h))return`${h.toFixed(c)}${n.replace(/#/g,"")}`;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}_formatNumber(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:return this._formatOthers(t,e)}}_strFormat(t,e){let r=t;for(const[n,i]of e.entries()){if(i===void 0||typeof i=="number"&&isNaN(i)){r="NaN";continue}if(typeof i=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(i,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(i))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),i)}return r}}class Ay{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new qa(this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}get({id:t,key:e}){return t==null?void 0:t.get({key:e})}put({id:t,key:e,value:r}){return t==null?void 0:t.put({key:e,value:r})}keys({id:t}){return t==null?void 0:t.keys()}size({id:t}){return t==null?void 0:t.size()}clear({id:t}){t==null||t.clear()}remove({id:t,key:e}){return t==null?void 0:t.remove({key:e})}values({id:t}){return t==null?void 0:t.values()}put_all({id:t,id2:e}){t==null||t.put_all({id2:e})}contains({id:t,key:e}){return t==null?void 0:t.contains({key:e})}}class qa{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new qa(this._errorListener);return e._mapInstance=new Map(t.entries()),e}copy(){return this._copyMap(this._mapInstance)}get({key:t}){return this._mapInstance.get(t)}put({key:t,value:e}){return this._mapInstance.set(t,e)}keys(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.keys()],t}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:t}){const e=this._mapInstance.get(t);return this._mapInstance.delete(t),e||void 0}values(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.values()],t}put_all({id2:t}){this._mapInstance=new Map([...this._mapInstance,...t._mapInstance])}contains({key:t}){return this._mapInstance.has(t)}}class Cy{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Ai(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Ai(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Ai(t,e)}from_time({price:t,time:e}){return new Ai(t,void 0,e)}}class Ai{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ai(this._price,this._index,this._time)}}class Fy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:we.bar_index,yloc:Wr.price,size:nr.normal,style:ge.styleLabelDown,textalign:Wt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:i,bar_index:a}=this._variables,l=`label_${e}_${a}`;me(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:l,time:r,high:n,low:i,bar_index:a};t.point&&(c.x=c.xloc===we.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Wr.abovebar?c.y=n:c.yloc===Wr.belowbar&&(c.y=i),this._verfiyArgs(t,e);const h=new ao(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,h),h}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:i,size:a,textalign:l,text_font_family:c}=t,h="label.new";this._paramVerfiy(i,e,h,Object.values(ge),"style"),this._paramVerfiy(r,e,h,Object.values(we),"xloc"),this._paramVerfiy(n,e,h,Object.values(Wr),"yloc"),this._paramVerfiy(a,e,h,Object.values(nr),"size"),this._paramVerfiy(l,e,h,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,h,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}label(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class ao{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get type(){return Fe.LABEL}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.label.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`label_${t}_${e}`,n=this._getLabel(t),i=new ao(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,i)}return i}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t),this._paramVerfiy(t,e,"label.set_size",Object.values(nr),"size")}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e,this._paramVerfiy(e,r,"label.set_xloc",Object.values(we),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:i}=this._variables;r&&(r.yloc=t,t===Wr.abovebar?r.y=n:t===Wr.belowbar&&(r.y=i),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Wr),"yloc"))}set_color(t,e){const r=this._getLabel(e);me(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t),this._paramVerfiy(t,e,"label.set_style",Object.values(ge),"style")}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t),this._paramVerfiy(t,e,"label.set_textalign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);me(t,["textcolor"]),r&&(r.textcolor=t.textcolor)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t),this._paramVerfiy(t,e,"label.set_text_font_family",Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const My={freq_all:qr.freqAll,freq_once_per_bar:qr.freqOncePerBar,freq_once_per_bar_close:qr.freqOncePerBarClose},Ny={gaps_off:Yi.gapsOff,gaps_on:Yi.gapsOn,lookahead_off:Yi.lookaheadOff,lookahead_on:Yi.lookaheadOn},Ci={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#FF5252",silver:"#B2B5BE",teal:"#00897B",white:"#FFFFFF",yellow:"#FFEB3B"},Qf={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"},Sy={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},th={all:[Ze.dataWindow,Ze.pane,Ze.priceScale,Ze.statusLine],data_window:[Ze.dataWindow],none:[],pane:[Ze.pane],price_scale:[Ze.priceScale],status_line:[Ze.statusLine]},Oy={both:Ur.both,left:Ur.left,none:Ur.none,right:Ur.right},By={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},Iy={style_solid:Ds.styleSolid,style_dashed:Ds.styleDashed,style_dotted:Ds.styleDotted},Ty={style_arrowdown:ge.styleArrowdown,style_arrowup:ge.styleArrowup,style_circle:ge.styleCircle,style_cross:ge.styleCross,style_diamond:ge.styleDiamond,style_flag:ge.styleFlag,style_label_center:ge.styleLabelCenter,style_label_down:ge.styleLabelDown,style_label_left:ge.styleLabelLeft,style_label_lower_left:ge.styleLabelLowerLeft,style_label_lower_right:ge.styleLabelLowerRight,style_label_right:ge.styleLabelRight,style_label_up:ge.styleLabelUp,style_label_upper_left:ge.styleLabelUpperLeft,style_label_upper_right:ge.styleLabelUpperRight,style_none:ge.styleNone,style_square:ge.styleSquare,style_text_outline:ge.styleTextOutline,style_triangledown:ge.styleTriangledown,style_triangleup:ge.styleTriangleup,style_xcross:ge.styleXcross},$y={style_arrow_both:Le.styleArrowBoth,style_arrow_left:Le.styleArrowLeft,style_arrow_right:Le.styleArrowRight,style_dashed:Le.styleDashed,style_dotted:Le.styleDotted,style_solid:Le.styleSolid},Ly={abovebar:an.abovebar,absolute:an.absolute,belowbar:an.belowbar,bottom:an.bottom,top:an.top},Ry={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Py={style_area:Mr.styleArea,style_areabr:Mr.styleAreabr,style_circles:Mr.styleCircles,style_columns:Mr.styleColumns,style_cross:Mr.styleCross,style_histogram:Mr.styleHistogram,style_line:Mr.styleLine,style_linebr:Mr.styleLinebr,style_stepline:Mr.styleStepline,style_stepline_diamond:Mr.styleSteplineDiamond,style_steplinebr:Mr.styleSteplinebr},zy={bottom_center:_r.bottomCenter,bottom_left:_r.bottomLeft,bottom_right:_r.bottomRight,middle_center:_r.middleCenter,middle_left:_r.middleLeft,middle_right:_r.middleRight,top_center:_r.topCenter,top_left:_r.topLeft,top_right:_r.topRight},ky={left:bs.left,none:bs.none,right:bs.right},qy={arrowdown:ur.arrowdown,arrowup:ur.arrowup,circle:ur.circle,cross:ur.cross,diamond:ur.diamond,flag:ur.flag,labeldown:ur.labeldown,labelup:ur.labelup,square:ur.square,triangledown:ur.triangledown,triangleup:ur.triangleup,xcross:ur.xcross},Uy={auto:nr.auto,huge:nr.huge,large:nr.large,normal:nr.normal,small:nr.small,tiny:nr.tiny},Wy={cash:Re.cash,fixed:Re.fixed,percent_of_equity:Re.percentOfEquity,commission:{cash_per_contract:We.cashPerContract,cash_per_order:We.cashPerOrder,percent:We.percent},direction:{all:se.all,long:se.long,short:se.short},oca:{cancel:un.cancel,none:un.none,reduce:un.reduce}},jy={align_bottom:Wt.alignBottom,align_center:Wt.alignCenter,align_left:Wt.alignLeft,align_right:Wt.alignRight,align_top:Wt.alignTop,wrap_auto:Wt.wrapAuto,wrap_none:Wt.wrapNone},Vy={bar_index:we.bar_index,bar_time:we.bar_time},Yy={abovebar:Wr.abovebar,belowbar:Wr.belowbar,price:Wr.price},Zy={actual:xs.actual,estimate:xs.estimate,standardized:xs.standardized};class eh{constructor(){$(this,"adjustment",{dividends:ws.dividends,none:ws.none,splits:ws.splits});$(this,"alert",My);$(this,"barmerge",Ny);$(this,"color",Ci);$(this,"currency",Qf);$(this,"dayofweek",Sy);$(this,"earnings",Zy);$(this,"display",th);$(this,"extend",Oy);$(this,"font",{family_default:Zn.familyDefault,family_monospace:Zn.familyMonospace});$(this,"format",By);$(this,"hline",Iy);$(this,"label",Ty);$(this,"line",$y);$(this,"location",Ly);$(this,"math",Ry);$(this,"order",{ascending:Yn.ascending,descending:Yn.descending});$(this,"plot",Py);$(this,"position",zy);$(this,"scale",ky);$(this,"session",{extended:fi.extended,regular:fi.regular});$(this,"shape",qy);$(this,"size",Uy);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",Wy);$(this,"text",jy);$(this,"xloc",Vy);$(this,"yloc",Yy)}updateData(){}}class Ky{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:we.bar_index,line_color:Ci.blue,line_style:Le.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var l;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,i=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(l=t.points)==null?void 0:l._value.map(c=>({time:c.time,index:c.index,price:c.price}))});me(i,["line_color","fill_color"]);const a=new rh(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,i,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,i="polyline.new";this._paramVerfiy(r,e,i,Object.values(Le),"line_style"),this._paramVerfiy(n,e,i,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}delete({id:t}){t&&t.delete()}}class rh{constructor(t,e){$(this,"_id");$(this,"_variables");this._variables=e,this._id=t}get type(){return Fe.POLYLINE}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id)}}class Gy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:we.bar_index,extend:Ur.none,style:Le.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:i}=this._variables,a=`line_${n}_${i}`;me(r,["color"]);const l={...this._defaultLine,...r,id:a,bar_index:i};if(t&&e){const h=l.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,d=l.xloc===we.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(l,{x1:h,y1:t==null?void 0:t.price,x2:d,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new uo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,l,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:i}=t,a="line.new";this._paramVerfiy(i,e,a,Object.values(Le),"style"),this._paramVerfiy(r,e,a,Object.values(Ur),"extend"),this._paramVerfiy(n,e,a,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}line(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class uo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get type(){return Fe.LINE}get data(){return this._variables.line.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`line_${t}_${e}`,n=this._getLine(t),i=new uo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===we.bar_index){const{x1:n,y1:i,x2:a,y2:l}=r;return n===void 0||a===void 0||i===void 0||l===void 0?void 0:(l-i)/(a-n)*(t-n)+i}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const i=this._getLine(n);i&&(i.xloc=t,i.x1=e,i.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(we),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(me(t,["color"]),r.color=t.color)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values(Le),"style"))}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t,this._paramVerfiy(t,e,"line.set_extend",Object.values(Ur),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class Hy{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:i}=this._variables,a=`linefill_${e}_${i}`,l=r==null?void 0:r.data,c=n==null?void 0:n.data;l&&(l.linefills=l.linefills||[],l.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),me(t,["color"]);const h=new lo(this._variables,a,r,n);return e.startsWith("export")||(l||c)&&this._variables.linefill.add(a,{line1:l,line2:c,color:t.color,id:a,bar_index:i},h),h}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class lo{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return Fe.LINEFILL}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new lo(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:i}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),i&&(i.linefills=(r=i.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(me(t,["color"]),e.color=t.color)}}class Jy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Ci.blue,border_width:1,bgcolor:Ci.blue,xloc:we.bar_index,extend:Ur.none,style:Le.styleSolid,text:"",text_size:nr.auto,text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_wrap:Wt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:i}=this._variables,a=`box_${n}_${i}`,l={...this._defaultBox,...r,id:a,bar_index:i};if(me(l,["border_color","bgcolor","text_color"]),t){const{price:h,time:d,index:f}=t;l.top=h,l.left=l.xloc===we.bar_index?f:d}if(e){const{price:h,time:d,index:f}=e;l.bottom=h,l.right=l.xloc===we.bar_index?f:d}this._verfiyArgs(r,n);const c=new co(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,l,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:l,text_valign:c,text_wrap:h,text_font_family:d}=t,f="box.new";this._paramVerfiy(r,e,f,[Le.styleDashed,Le.styleDotted,Le.styleSolid],"border_style"),this._paramVerfiy(n,e,f,Object.values(Ur),"extend"),this._paramVerfiy(i,e,f,Object.values(we),"xloc"),this._paramVerfiy(a,e,f,Object.values(nr),"text_size"),this._paramVerfiy(l,e,f,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"),this._paramVerfiy(c,e,f,[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"),this._paramVerfiy(h,e,f,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(d,e,f,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e},r){t==null||t.set_border_style(e,r)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e},r){t==null||t.set_text_size(e,r)}set_text_wrap({id:t,...e},r){t==null||t.set_text_wrap(e,r)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e},r){t==null||t.set_text_halign(e,r)}set_text_valign({id:t,...e},r){t==null||t.set_text_valign(e,r)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class co{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.BOX}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.box.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`box_${t}_${e}`,n=this._getBox(),i=new co(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.box.delete(this._id)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t},e){const r=this._getBox();r&&(r.extend=t,this._paramVerfiy(t,e,"box.set_extend",Object.values(Ur),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t},e){const r=this._getBox();r&&(r.text_size=t,this._paramVerfiy(t,e,"box.set_text_size",Object.values(nr),"text_size"))}set_text_wrap({text_wrap:t},e){const r=this._getBox();r&&(r.text_wrap=t,this._paramVerfiy(t,e,"box.set_text_wrap",[Wt.wrapAuto,Wt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,me(e,["text_color"]))}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t},e){const r=this._getBox();r&&(r.text_halign=t,this._paramVerfiy(t,e,"box.set_text_halign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"))}set_text_valign({text_valign:t},e){const r=this._getBox();r&&(r.text_valign=t,this._paramVerfiy(t,e,"box.set_text_valign",[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.top=n,e.left=e.xloc===we.bar_index?r:i}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,me(e,["border_color"]))}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[Le.styleDashed,Le.styleDotted,Le.styleSolid],"style"))}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.bottom=n,e.right=e.xloc===we.bar_index?r:i}}set_text_font_family({text_font_family:t},e){const r=this._getBox();r&&(r.text_font_family=t,this._paramVerfiy(t,e,"box.set_text_font_family",Object.values(Zn),"text_font_family"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Xy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:_r.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t}){return t}new(t,e){const{bar_index:r}=this._variables,n=`table_${e}_${r}`,{rows:i}=t;me(t,["text_color","bgcolor","border_color"]);const a=Array.from(Array(i),()=>[]),l=e.split("_"),c=l.pop(),h=l.pop(),d={...this._defaultTable,...t,cell:a,id:n,bar_index:r,line:h,col:c},f=new nh(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(_r),"position"),e.startsWith("export")||this._variables.table.add(n,d,f),f}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e},r){t==null||t.set_position(e,r)}}class nh{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:nr.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.TABLE}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.table.get(this._id)}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],l=a[n]||[];l[r]=e,a[n]=l,i.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r,me(n,["text_color"]))}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0}){const i=this._variables.table.get(this._id);if(i){const a=i.cell;if(a)for(let l=e;l<=n;l++)for(let c=t;c<=r;c++){const h=a[l];h&&(h[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},i){if(t>r||e>n){this._errorListener.addError(le.mergeCellErr,i,zt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,me(e,["border_color"]))}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t},e){const r=this._variables.table.get(this._id);r&&(r.position=t,this._paramVerfiy(t,e,"table.set_position",Object.values(_r),"position"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class Qy{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){return this._verifyTradeNum(t)&&this._strategy.historyOrders[t].commission||0}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.historyOrders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_time}exit_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_index}exit_comment({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_comment:""}exit_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_id:""}exit_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_price}exit_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{out_qty:e=0,direction:r}=this._strategy.historyOrders[t];return r===se.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class tw{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,original_qty:r=0,commission:n=0}=this._strategy.orders[t];return n*e/r}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.orders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,direction:r}=this._strategy.orders[t];return r===se.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class ew{constructor(t,e){$(this,"_strategy");$(this,"_errorListener");this._strategy=t,this._errorListener=e}allow_entry_in({value:t},e){this._paramVerfiy(t,e,"strategy.risk.allow_entry_in",Object.values(se),"value"),this._strategy.updateRisk({allow_entry_in:t})}max_cons_loss_days({count:t}){this._strategy.updateRisk({max_cons_loss_days:t})}max_drawdown({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_drawdown",[Re.percentOfEquity,Re.cash],"type"),e===Re.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_drawdown:t,max_drawdown_type:e})}max_intraday_filled_orders({count:t}){this._strategy.updateRisk({max_intraday_filled_orders:t})}max_intraday_loss({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_intraday_loss",[Re.percentOfEquity,Re.cash],"type"),e===Re.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_intraday_loss:t,max_intraday_loss_type:e})}max_position_size({contracts:t}){this._strategy.updateRisk({max_position_size:t})}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}}let rw=class{constructor(t,e,r,n,i){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");$(this,"_maxDrawdownVerifyIndex",0);$(this,"calcOnOrderFillsData",{index:-1});this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Re.fixed,default_qty_value:1,initial_capital:1e6,currency:Qf.NONE,slippage:0,commission_type:We.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=e,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new tw(this),this._closedtrades=new Qy(this),this._riskNamespace=new ew(this,n),this._id=`strategy_${i}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;return this._orders.reduce((e,r)=>e+t*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}get isCalcOnEveryTick(){return this._options.calc_on_every_tick}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),this._maxDrawdownVerify();const{open:t,close:e,high:r,low:n}=this.calcOnOrderFillsData.data||this._variables;this._variables.strategy.update({open:t,close:e,high:r,low:n}),!this._options.process_orders_on_close&&this._calcLiquidate(),this._calcProfitAndLoss()}calcCurrentOrder(){this._calcProfitAndLoss()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:t,max_intraday_loss_type:e,isDisabledOpen:r}=this._risk;if(t===void 0||!e||r)return;const{time_tradingday:n,time:i,strategy:{netprofit:a,initial_capital:l}}=this._variables,{high:c,low:h}=this.calcOnOrderFillsData.data||this._variables;let{preNetprofit:d=0}=this._risk;i===n&&(d=a,this._risk.preNetprofit=a,this._risk.isTemporaryBan=!1);let f=d-a;f+=this._orders.reduce((y,m)=>{const{in_price:w,direction:v,qty:x=0,commission:b=0,original_qty:N=0}=m,E=v===se.long?1:-1,A=(c-w)*x,M=(h-w)*x,S=E===1?M:-A;return y+S+x/N*b},0);let p=!1;switch(e){case Re.cash:p=t<f;break;case Re.percentOfEquity:const y=f/(l+a)*100;p=t<y;break}if(p){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===se.long?h:c,"Close Position (Max intraday Loss)",void 0,"close"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:t,intradayOrders:e=0,isDisabledOpen:r}=this._risk;if(t===void 0||r)return;const{time:n,time_tradingday:i}=this._variables,{open:a}=this.calcOnOrderFillsData.data||this._variables;n===i&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),t<=e&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)",void 0,"close"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:t,lossDays:e=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(t===void 0||r)return;const{time:i,time_tradingday:a,strategy:l}=this._variables,{open:c}=this.calcOnOrderFillsData.data||this._variables;let h=e;if(i===a){const d=l.netprofit+l.openprofit;d<n?h=0:h++,Object.assign(this._risk,{lossDays:h,totalProfit:d})}t<=h&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(r)return;const{bar_index:n}=this._variables,{open:i}=this.calcOnOrderFillsData.data||this._variables;if(t!==void 0&&e&&this._maxDrawdownVerifyIndex===n){const{initial_capital:a}=this._options,c=this._orders.reduce((d,f)=>{const{in_price:p,commission:g=0,qty:y=0,original_qty:m=0,direction:w}=f,v=w===se.long?1:-1,x=(i-p)*v*y;return d+x+g*y/m},0)+this._totalChangeCapital;let h=!1;switch(e){case Re.percentOfEquity:h=c/a*100<=-t;break;case Re.cash:h=c<=-t;break}h&&this._riskTouchOff(i,"Close Position (Max Drawdown)")}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._orders.length&&this._closeOrders(this._orders,t,e,"close"),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Kt.inherit,Kt.price,Kt.percent,Kt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Re),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(We),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={...this._updateOptions};if(r)for(const i of Object.keys({...r,...t}))t[i]!==r[i]&&delete n[i];self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,userSetStrategyConfig:n,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(un),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(un),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.filter(r=>!this._options.process_orders_on_close||r.in_index!==this._variables.bar_index).length)return;const{immediately:e}=t;if(e||this._options.process_orders_on_close){const r=this._pendingCloseOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingCloseOrders.push({...t,place_order_type:"close"})}else{const r=this._pendingOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingOrders.push({...t,place_order_type:"close"})}}close_all(t){if(typeof t=="string"&&(t={}),!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close_all"}):this._pendingOrders.push({...t,place_order_type:"close_all"})}cancel({id:t}){this._pendingOrders=this._pendingOrders.filter(e=>!(e.id===t&&e.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(t=>t.place_order_type==="close_all")}exit(t,e){this._exit(t,e)}convert_to_account({value:t}){return t}convert_to_symbol({value:t}){return t}default_entry_qty({fill_price:t}){return t?this._calcDefaultQty(t):0}_calcDefaultQty(t){const{default_qty_type:e=Re.fixed,default_qty_value:r=1,initial_capital:n,commission_value:i}=this._options;let a=r;switch(e){case Re.cash:a=r/t;break;case Re.percentOfEquity:const l=this._getOrderProfit(t),c=n+l+this._totalChangeCapital;i?a=this._getCommQty(c,t):a=c*r/100/t;break}return Tl(a,this._getLen(t))}_getCommQty(t,e){const{commission_type:r,commission_value:n=0,default_qty_value:i=0}=this._options;let a=0;switch(r){case We.percent:a=t*i/(100*e+n*e*i/100);break;case We.cashPerContract:a=t*i/(100*e+n*i);break;case We.cashPerOrder:a=(t-n)*i/100/e}return a}_getLen(t){const e=String(Math.floor(t)).length-2;return e<0?0:e}_getCapital(t,e){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&t===1?e=e*100/r:n<=100&&n>0&&t===-1&&(e=e*100/n),e}_calcProfitAndLoss(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:i}=e,a=i===se.long?1:-1,l=(t-r)*a*n,[c,h]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,l,c,h)}}_calcProfitAndLossHandle(t,e,r){const{high:n,low:i}=this.calcOnOrderFillsData.data||this._variables,a=(n-t)*e,l=(i-t)*e;let c=r===1?a:-l,h=r===1?l:-a;return[c,h]}_calcOrderPercent(t,e,r,n){const{commission_value:i}=this._options,{close:a}=this.calcOnOrderFillsData.data||this._variables,{original_qty:l=0,qty:c=0,in_price:h,max_profit:d=0,trading_loss:f=0}=t;let{commission:p=0}=t,g=h*c;if(i){const y=this._getCommission(a,c);p=p*c/l,r-=p,n-=p,g+=p,e=e-y-p}r=Math.max(r,d,0),n=Math.min(n,f,0),Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/(this._options.initial_capital+this._totalChangeCapital)*100,max_profit:r,trading_loss:n,profit_percent:e/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{time:t}=this._variables,{high:e,low:r}=this.calcOnOrderFillsData.data||this._variables,{initial_capital:n,margin_long:i=0,margin_short:a=0}=this._options,l=this._orders[0].direction===se.long?1:-1;let c=l===1?r:e;if(l===1&&i===100)return;const h=(l===1?i:a)/100;if(h<=0)return;let d=!1;const[f,p]=this._orders.reduce((w,v)=>{let[x,b]=w;const{in_price:N,qty:E=0,in_time:A}=v;A===t&&(d=!0);const M=N*E,S=c*E;return x+=M,b+=S,[x,b]},[0,0]);let g=0,y=0;const m=n+this._totalChangeCapital;if(d&&(g=m-f*h,g<0&&(c=this._orders[0].in_price,y=Math.abs(Math.trunc(g/h/c)*4),y=Math.max(y,1))),g>=0){const w=l*(p-f);if(g=m+w-p*h,g>=0)return;y=Math.abs(Math.trunc(g/h/c)*4)}y<=0||this._marginCallOrders(c,y,"Margin Call")}_marginCallOrders(t,e,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,t,e*this._orders.length,r,r,!0);return}for(const i of this.orders)i.position_close_type=i.place_order_type,this._processOrder(i,t,e,r,r,!0);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:i,quantities:a,close:l,price:c,activePrice:h}=this._orderArgsParse(t),d=t.direction===se.long?1:-1;if(a<=0)return;let f=a;if(i&&e){if(n.length){const b=this._processOrders(n,l,f,t.id,t.comment,!1,"order");if(b<=0)return;f=b}const g=l+d*r*this._mintick;if(!this._judgeCapitalEnough(f,g,d))return;this._ocaGroupVerify(f,t.oca_name,t.oca_type);const{bar_index:m,time:w}=this._variables,{high:v,low:x}=this.calcOnOrderFillsData.data||this._variables;this._calcCurrentOrder({...t,in_price:g,in_high:v,in_low:x,in_index:m,in_time:w,qty:f,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,d)&&this._addPendingOrders(t,c,f,i,h)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(d=>(d.direction===se.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:i=0,margin_short:a=0}=this._options;if(i===0&&r===1||a===0&&r===-1)return!0;const l=this._getOrderProfit(e),h=this._getCapital(r,this._options.initial_capital+l+this._totalChangeCapital)-n;return t*e<=h}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:i=0,direction:a}=r,l=a===se.long?1:-1;return e+(t-n)*i*l},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===un.none)return!1;let n=!1;switch(r){case un.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===e)i.isCancel=!0,n=!0;else return!0});break;case un.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:l}=i;if(e===l){const c=a-t;return n=!0,c<=0?(i.isCancel=!0,!1):(i.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,i,a=!1,l,c){let h=r;for(const d of t)if(d.position_close_type=l||d.place_order_type,d.immediately=c,h=this._processOrder(d,e,h,n,i,a),h<=0)break;return this._orders=this._orders.filter(d=>!d.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),h}_addPendingOrders(t,e,r,n,i){const a=this._pendingOrders.find(l=>l.id===t.id&&!l.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let i=t.limit||0;const{close:a}=this.calcOnOrderFillsData.data||this._variables;let l=a,c=!1,h;const d=e===se.long?1:-1,f=n&&(n-a)*d>0,{backtest_fill_limits_assumption:p=0}=this._options;p>0&&i&&(i-=p*this._mintick*d);const g=i&&(i-a)*d<0;f&&g?(h=n,l=i):f?l=n:g?l=i:c=!0;const y=r!==void 0?Tl(r,this._getLen(l)):this._calcDefaultQty(l);return{orders:this._orders.filter(w=>w.direction!==e),isMarketPrice:c,activePrice:h,quantities:y,close:a,price:l}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:l,activePrice:c}=this._orderArgsParse(t);if(i<=0)return;if(r.length&&n&&e){this._entryOrder(r,a,i,t);return}this._judgeCapitalEnough(i,a,t.direction===se.long?1:-1)&&this._addPendingEntry(t,l,i,n,c)}_entryOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{high:l,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:h=0}=this._options,{oca_name:d,oca_type:f,direction:p,comment:g,isMarketPrice:y,id:m}=n,w=p===se.long?1:-1;if(r=this._getAvailablePositionSize(r,p),r<=0||(e=e+h*this._mintick*w,!this._judgeCapitalEnough(r,e,w)))return;this._closeOrders(t,e,m,g,"entry");const x={...n,in_price:e,qty:r,in_index:a,in_high:l,in_low:c,in_time:i,place_order_type:"entry"};if(y){this._calcCurrentOrder(x);return}const{pendingOrders:b,orders:N}=this._getEntryOrders(p),E=b.length+N.length;E&&E>=(this._options.pyramiding||1)||(this._ocaGroupVerify(r,d,f),this._calcCurrentOrder(x))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==se.all&&n!==e)return 0;if(r===void 0)return t;const i=this._orders.reduce((a,l)=>a+(l.qty||0),0);return i?i+t>r?0:t:t>r?t-r:0}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===t),r=this._orders.filter(n=>n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,i){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),c=a.length+l.length,h=a.find(d=>d.id===t.id&&d.place_order_type==="entry");if(h)Object.assign(h,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else if(!c||c<(this._options.pyramiding||1)){const d={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(d)}}_closeAllOrders(t,e){const{comment:r,immediately:n}=t,{bar_index:i}=this._variables,a=this._orders.filter(l=>l.in_index!==i);a.length&&(this._closeOrders(a,e,"Close position order",r,"close",n),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n,i,a){for(const l of t)l.position_close_type=i,l.immediately=a,this._closeOrder(l,e,r,n);this._orders=this._orders.filter(l=>!l.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{high:l,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:h=0}=this._options,{in_price:d,qty:f=0,direction:p}=t,g=p===se.long?1:-1;e=e-g*h*this._mintick,t.isDeal=!0;const y=(e-d)*g*f,m={...t,out_price:e,out_id:r,out_index:a,out_high:l,out_low:c,out_time:i,out_comment:n,out_qty:f,profit:y};this._calcPercent(m)}_ordersHandle(){const t=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!t.length)return;const{open:e,low:r,high:n,close:i}=this.calcOnOrderFillsData.data||this._variables;for(const a of t){const{stop:l,limit:c,trail_stop_price:h,isMarketPriceLimit:d,isMarketPriceStop:f,direction:p,id:g,out_comment:y,active_price:m,trail_offset:w=0,out_qty:v,comment_loss:x,comment_profit:b,comment_trailing:N}=a;let E=h;const A=p===se.long?1:-1;let M,S=y;if(d||f?M=e:(c&&r<=c&&n>=c&&(S=b||y,M=c),l&&r<=l&&n>=l&&(M=E?(l-E)*A>0?l:E:l,S=(E===M?N:x)||y)),M)this._processExitOnClose(a,M,{from_entry:g,comment:S,qty:v});else{let T=!1;if(m&&m<=n&&m>=r&&(E=m-w*A*this._mintick,(E-i)*A>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(M=E)),T=!0,a.trail_stop_price=E),E)if((E-e)*A>=0&&!T)M=E;else{const F=(A===1?n:r)-w*A*this._mintick;A===1?E<e&&E>=r&&F>E&&F<i?M=E:F>E?(E=F,F>=i&&(M=F)):E<=n&&r<=E&&(M=E):E>e&&E<=n&&F<E&&F>i?M=E:F<E?(E=F,F<=i&&(M=F)):E<=n&&r<=E&&(M=E),a.trail_stop_price=E}M&&this._processExitOnClose(a,M,{from_entry:g,comment:N||y,qty:v})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&t.push(l)}for(const n of r)switch(n.place_order_type){case"close":const i=this._closeOrderHandle(n);i&&t.push(i);break;case"close_all":const{open:a}=this.calcOnOrderFillsData.data||this._variables;this._closeAllOrders(n,a);break}for(const n of e){const i=this._exitOrderHandle(n);i&&t.push(i)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),e=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this.calcOnOrderFillsData.data||this._variables;this._pendingCloseOrders=[];for(const n of e)switch(n.place_order_type){case"close":const i=this._closeOrderHandle(n,!0);i&&this._pendingCloseOrders.push(i);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of t){const{from_entry:i}=n,a=this._orders.filter(l=>!i||l.id===i&&(l.isMarketPriceLimit||l.isMarketPriceStop));for(const l of a)this._processExitOnClose(l,l.limit||l.stop||l.trail_stop_price||r,n)}}_entryOrderHandle(t){const{open:e,low:r,high:n}=this.calcOnOrderFillsData.data||this._variables,{isMarketPrice:i,qty:a=0,in_price:l,direction:c,active_price:h}=t;if(h&&n>=h&&r<=h)return delete t.active_price,t;let d=l;if(i&&(d=e),d<=n&&d>=r){const f=this._orders.filter(p=>p.direction!==c);this._entryOrder(f,d,a,t)}else return t}_orderOrderHandle(t){const{time:e,bar_index:r}=this._variables,{open:n,low:i,high:a}=this.calcOnOrderFillsData.data||this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:h=0,in_price:d,direction:f,comment:p,oca_name:g,oca_type:y,active_price:m,id:w}=t;if(m&&a>=m&&i<=m)return delete t.active_price,t;let v=d,x=h;if(c&&(v=n),v<=a&&v>=i){const b=this._orders.filter(E=>E.direction!==f);if(b.length&&(x=this._processOrders(b,v,h,w,p,!1,"order"),x<=0))return;const N=f===se.long?1:-1;this._ocaGroupVerify(x,g,y),this._calcCurrentOrder({...t,in_price:v+N*l*this._mintick,in_index:r,in_time:e,in_high:a,in_low:i,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:i=100,comment:a,immediately:l}=t,{close_entries_rule:c="FIFO"}=this._options;let h=[];if(c==="FIFO"?h=this._orders.filter(g=>g.id===r):h=this._orders.filter(g=>g.id===r&&!g.close_qty),!h.length)return t;let d=0;if(n?d=n:(d=h.reduce((g,y)=>g+(y.qty||0),d),d=i/100*d),d<=0)return;const{open:f,close:p}=this.calcOnOrderFillsData.data||this._variables;if(c==="FIFO")this._processOrders(h,e?p:f,d,`Close entry(s) order ${r}`,a,!1,"close",l);else if(this._processCloseOrders(h,e?p:f,d,`Close entry(s) order ${r}`,a,l))return t}_processCloseOrders(t,e,r,n,i,a){let l=!1;for(const c of t)c.close_qty=r,(c.qty||0)>r&&(l=!0),c.immediately=a,c.position_close_type="close",this._processOrder(c,e,r,n,i);return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_exitOrderHandle(t){const{from_entry:e}=t,r=this._orders.filter(n=>(!e||e===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,t)))return t}_exit(t,e){if(!t.hasOwnProperty("profit")&&!t.hasOwnProperty("loss")&&!t.hasOwnProperty("stop")&&!t.hasOwnProperty("limit")&&(!t.hasOwnProperty("trail_offset")||!t.hasOwnProperty("trail_price")&&!t.hasOwnProperty("trail_points"))){this._errorListener.addError(le.strategyExitErr,e,zt.Error);return}const{profit:r,loss:n,stop:i,limit:a,trail_offset:l,trail_price:c,trail_points:h,from_entry:d="",id:f}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(h)&&this._isNaN(c)))return;const p={...t,place_order_type:"exit"},g=this._orders.filter(w=>(!d||d===w.id)&&!w.hasExit),y=this._pendingOrders.filter(w=>!d||d===w.id);if(g.length){if(!this._ordersToExit(g,p))return}else if(!y.length)return;const m=this._pendingOrders.find(w=>w.id===f&&w.place_order_type==="exit");m?Object.assign(m,{...t}):this._pendingOrders.push(p)}_ordersToExit(t,e){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:l,comment_profit:c,comment_trailing:h}=e;let d=r,f=!1;e.comment=a||i;for(const p of t){const{qty:g=0}=p,y=p.direction===se.long?1:-1;d=r?r>=g?g:r:n/100*g,p.out_qty=d,d<g&&(f=!0),Object.assign(p,{out_comment:a||i,comment_loss:l,comment_profit:c,comment_trailing:h}),!(this._stopProfit(p,y,{...e,qty:d})||this._stopLoss(p,y,{...e,qty:d})||this._trailStopLoss(p,y,{...e,qty:d}))&&(p.place_order_type="exit")}return f}_addExitPendingCloseOrders(t){t.place_order_type="exit";const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r){const{limit:n,profit:i,comment_profit:a,comment:l}=r;let c=n;const{close:h}=this.calcOnOrderFillsData.data||this._variables,{in_price:d}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=d+e*i*this._mintick),t.limit=c,c!==void 0&&(c-h)*e<=0&&(t.isMarketPriceLimit=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=h,t.limit=c,f))return this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r){const{stop:n,loss:i,comment_loss:a,comment:l}=r;let c=n;const{close:h}=this.calcOnOrderFillsData.data||this._variables,{in_price:d}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=d-e*i*this._mintick),t.stop=c,c!==void 0&&(c-h)*e>=0&&(t.isMarketPriceStop=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=h,t.stop=c,f))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:l,comment:c}=r;if(!this._isNaN(n)){const{close:h}=this.calcOnOrderFillsData.data||this._variables,{in_price:d}=t,{process_orders_on_close:f}=this._options;let p;if(this._isNaN(i)?this._isNaN(a)||(p=d+a*e*this._mintick):p=i,t.trail_offset=n,p!==void 0&&(p-h)*e<=0){const g=h-n*e*this._mintick;if((g-h)*e>=0&&(t.trail_stop_price=h,t.isMarketPriceStop=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment}),f))return this._addExitPendingCloseOrders(r),!0;t.trail_stop_price=g}t.active_price=p}}_processExitOnClose(t,e,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const c=this._processExitOrders(this._orders,e,n,a,i);c&&!c.hasExit?(c.hasExit=!0,Object.assign(t,{trail_stop_price:c.trail_stop_price,stop:c.stop,limit:c.limit,trail_offset:c.trail_offset,active_price:c.active_price})):c&&(t.hasExit=!0)}else t.hasExit=!0,this._processOrders([t],e,n,a,i,!1,"exit")}_processExitOrders(t,e,r,n,i){let a=r,l;for(const c of t)if(l=c,c.position_close_type="exit",a=this._processOrder(c,e,a,n,i),a<=0||!c.hasExit)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_processOrder(t,e,r,n,i,a=!1){const{time:l,bar_index:c}=this._variables,{low:h,high:d}=this.calcOnOrderFillsData.data||this._variables,{slippage:f=0}=this._options,{in_price:p,qty:g=0,max_profit:y,trading_loss:m,direction:w,commission:v=0,original_qty:x=0}=t,b=w===se.long?1:-1;if(e=e-b*f*this._mintick,r<g){const N=g-r,E=(e-p)*b*r,A=y!==void 0?y/g*r:void 0,M=m!==void 0?m/g*r:void 0,S=v*N/x;this._calcPercent({...t,out_price:e,last_commission:S,out_id:n,out_index:c,out_high:d,out_low:h,out_time:l,out_comment:i,profit:E,out_qty:r,max_profit:A,trading_loss:M});const T=(e-p)*b*N-S;Object.assign(t,{qty:N,profit:T,max_profit:y!==void 0?y-(A||0):void 0,trading_loss:m!==void 0?m-(M||0):void 0,total_profit:this._totalChangeCapital+T}),r=0}else{t.isDeal=!0;const N=(e-p)*b*g;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_high:d,out_low:h,out_time:l,out_comment:i,out_qty:g,profit:N}),r-=g}return a&&(b===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t){const{commission_value:e,process_orders_on_close:r}=this._options,{in_price:n,out_qty:i=0,out_price:a=0,original_qty:l=0,direction:c,last_commission:h=0,immediately:d}=t;let{profit:f=0,max_profit:p,trading_loss:g,commission:y=0}=t,m=n*i,w=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=f,e){const v=this._getCommission(a,i);this._totalChangeCapital-=v;let x=y*i/l;m+=x,x+=v,f=f-x,Object.assign(t,{commission:x,profit:f});const b=this._orders.reduce((N,E)=>{const{qty:A=0,original_qty:M=0,commission:S=0}=E;return N+S*A/M},0);w+=b-h}if(p===void 0||g===void 0){const v=c===se.long?1:-1,x=this._calcProfitAndLossHandle(n,i,v);if(p=x[0],g=x[1],e){const b=y*i/l;p-=b,g-=b}p=Math.max(0,p),g=Math.min(0,g)}Object.assign(t,{max_profit:p,trading_loss:g,total_profit:this._totalChangeCapital,total_profit_percent:f/w*100,profit_percent:f/m*100,max_profit_percent:p/m*100,trading_loss_percent:g/m*100}),this._maxDrawdownVerifyIndex=this._variables.bar_index+(r?1:0),this._risk.intradayOrders+=1,this._historyOrder.push(t),this._calcOrderFillsHandle(n,c,d)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case We.percent:a=i*r/100;break;case We.cashPerContract:a=e*r;break;case We.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0,direction:l,immediately:c}=t;let{profit:h=0}=t,d=r*n;const f=this._totalChangeCapital+this._options.initial_capital;if(e){const p=this._getCommission(r,n);this._totalChangeCapital-=p,h=h-p,d+=p,Object.assign(t,{commission:p,profit:h,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:h/f*100,profit_percent:h/d*100,max_profit_percent:i/d*100,trading_loss_percent:a/d*100}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder),this._calcOrderFillsHandle(r,l,c)}_calcOrderFillsHandle(t,e,r=!1){const{calc_on_order_fills:n,process_orders_on_close:i,slippage:a=0}=this._options;if(n){const{open:l,high:c,low:h,close:d}=this._variables,f=e===se.long?1:-1,p=d-f*a*this._mintick;if((r||i)&&t===p)return;const g=l-f*a*this._mintick;let y={open:l,high:c,low:h,close:d},m=this.calcOnOrderFillsData.index;const w=Math.abs(c-l)<=Math.abs(h-l);switch(m){case-1:t===g?m=0:t>g?w?(m=1,y={open:c,high:c,low:h,close:d}):(m=2,y={open:c,high:c,low:d,close:d}):w?(m=2,y={open:h,high:d,low:h,close:d}):(m=1,y={open:h,high:c,low:h,close:d});break;case 0:t===g?(m=1,w?y={open:c,high:c,low:h,close:d}:y={open:h,high:c,low:h,close:d}):t>g?w?(m=1,y={open:c,high:c,low:h,close:d}):(m=2,y={open:c,high:c,low:d,close:d}):w?(m=2,y={open:h,high:d,low:h,close:d}):(m=1,y={open:h,high:c,low:h,close:d});break;case 1:m=2,w?y={open:h,high:d,low:h,close:d}:y={open:c,high:c,low:d,close:d};break;case 2:m=-1,y=void 0;break}this.calcOnOrderFillsData={tradeData:y,index:m}}}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}};var ih={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){return function(e,r,n){r.prototype.isBetween=function(i,a,l,c){var h=n(i),d=n(a),f=(c=c||"()")[0]==="(",p=c[1]===")";return(f?this.isAfter(h,l):!this.isBefore(h,l))&&(p?this.isBefore(d,l):!this.isAfter(d,l))||(f?this.isBefore(h,l):!this.isAfter(h,l))&&(p?this.isAfter(d,l):!this.isBefore(d,l))}}})})(ih);var nw=ih.exports,iw=Gt(nw),sh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){return function(e,r,n){var i=r.prototype,a=function(p){var g,y=p.date,m=p.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||i.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=m?n.utc():n();Object.keys(y).forEach(function(T){var F,B;w[F=T,B=i.$utils().p(F),B==="date"?"day":B]=y[T]});var x=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),N=w.month>=0?w.month:w.year||w.day?0:v.month(),E=w.hour||0,A=w.minute||0,M=w.second||0,S=w.millisecond||0;return m?new Date(Date.UTC(b,N,x,E,A,M,S)):new Date(b,N,x,E,A,M,S)}return y},l=i.parse;i.parse=function(p){p.date=a.bind(this)(p),l.bind(this)(p)};var c=i.set,h=i.add,d=i.subtract,f=function(p,g,y,m){m===void 0&&(m=1);var w=Object.keys(g),v=this;return w.forEach(function(x){v=p.bind(v)(g[x]*m,x)}),v};i.set=function(p,g){return g=g===void 0?p:g,p.constructor.name==="Object"?f.bind(this)(function(y,m){return c.bind(this)(m,y)},g,p):c.bind(this)(p,g)},i.add=function(p,g){return p.constructor.name==="Object"?f.bind(this)(h,p,g):h.bind(this)(p,g)},i.subtract=function(p,g){return p.constructor.name==="Object"?f.bind(this)(h,p,g,-1):d.bind(this)(p,g)}}})})(sh);var sw=sh.exports,ow=Gt(sw),oh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e,r,n=1e3,i=6e4,a=36e5,l=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,h=31536e6,d=2628e6,f=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,p={years:h,months:d,days:l,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},g=function(A){return A instanceof N},y=function(A,M,S){return new N(A,S,M.$l)},m=function(A){return r.p(A)+"s"},w=function(A){return A<0},v=function(A){return w(A)?Math.ceil(A):Math.floor(A)},x=function(A){return Math.abs(A)},b=function(A,M){return A?w(A)?{negative:!0,format:""+x(A)+M}:{negative:!1,format:""+A+M}:{negative:!1,format:""}},N=function(){function A(S,T,F){var B=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),T)return y(S*p[m(T)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(q){B.$d[m(q)]=S[q]}),this.calMilliseconds(),this;if(typeof S=="string"){var R=S.match(f);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=A.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(T,F){return T+(S.$d[F]||0)*p[F]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/h),S%=h,this.$d.months=v(S/d),S%=d,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/i),S%=i,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),T=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var B=b(F,"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 W=b(q,"S"),z=S.negative||T.negative||B.negative||R.negative||U.negative||W.negative,K=R.format||U.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+T.format+B.format+K+R.format+U.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},M.toJSON=function(){return this.toISOString()},M.format=function(S){var T=S||"YYYY-MM-DDTHH:mm:ss",F={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return T.replace(c,function(B,R){return R||String(F[B])})},M.as=function(S){return this.$ms/p[m(S)]},M.get=function(S){var T=this.$ms,F=m(S);return F==="milliseconds"?T%=1e3:T=F==="weeks"?v(T/p[F]):this.$d[F],T||0},M.add=function(S,T,F){var B;return B=T?S*p[m(T)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+B*(F?-1:1),this)},M.subtract=function(S,T){return this.add(S,T,!0)},M.locale=function(S){var T=this.clone();return T.$l=S,T},M.clone=function(){return y(this.$ms,this)},M.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},M.valueOf=function(){return this.asMilliseconds()},M.milliseconds=function(){return this.get("milliseconds")},M.asMilliseconds=function(){return this.as("milliseconds")},M.seconds=function(){return this.get("seconds")},M.asSeconds=function(){return this.as("seconds")},M.minutes=function(){return this.get("minutes")},M.asMinutes=function(){return this.as("minutes")},M.hours=function(){return this.get("hours")},M.asHours=function(){return this.as("hours")},M.days=function(){return this.get("days")},M.asDays=function(){return this.as("days")},M.weeks=function(){return this.get("weeks")},M.asWeeks=function(){return this.as("weeks")},M.months=function(){return this.get("months")},M.asMonths=function(){return this.as("months")},M.years=function(){return this.get("years")},M.asYears=function(){return this.as("years")},A}(),E=function(A,M,S){return A.add(M.years()*S,"y").add(M.months()*S,"M").add(M.days()*S,"d").add(M.hours()*S,"h").add(M.minutes()*S,"m").add(M.seconds()*S,"s").add(M.milliseconds()*S,"ms")};return function(A,M,S){e=S,r=S().$utils(),S.duration=function(B,R){var U=S.locale();return y(B,{$l:U},R)},S.isDuration=g;var T=M.prototype.add,F=M.prototype.subtract;M.prototype.add=function(B,R){return g(B)?E(this,B,1):T.bind(this)(B,R)},M.prototype.subtract=function(B,R){return g(B)?E(this,B,-1):F.bind(this)(B,R)}}})})(oh);var aw=oh.exports,uw=Gt(aw);ee.extend(Sl),ee.extend(iw),ee.extend(ow),ee.extend(uw);class ah{constructor(t,e,r){$(this,"array");$(this,"color");$(this,"math");$(this,"str");$(this,"map");$(this,"matrix");$(this,"timeframe");$(this,"ta");$(this,"input");$(this,"_variables");$(this,"_cacheData");$(this,"_options");$(this,"_errorListener");$(this,"_plots");$(this,"_plotshapes");$(this,"_plotbars");$(this,"_plotchars");$(this,"_plotarrows");$(this,"_plotcandles");$(this,"_alerts");$(this,"_bgColors");$(this,"_hlines");$(this,"_fills");$(this,"chart");$(this,"line");$(this,"label");$(this,"polyline");$(this,"box");$(this,"table");$(this,"linefill");$(this,"log");$(this,"runtime");$(this,"strategy");$(this,"request");$(this,"syminfo");$(this,"_count",0);var i;const n=((i=t.toString().split(".")[1])==null?void 0:i.length)||5;this._variables=e,this._errorListener=new dw,this.array=new Jd(this._errorListener),this.math=new Xd(n,this._errorListener),this.color=new x1,this.str=new Ey(this._errorListener,n),this.map=new Ay(this._errorListener),this.timeframe=new xy(e),this.matrix=new by(this._errorListener),this.ta=new D1(e,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new b1(e,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new Cy(e)},this.line=new Gy(e,this._errorListener),this.label=new Fy(e,this._errorListener),this.polyline=new Ky(e,this._errorListener),this.box=new Jy(e,this._errorListener),this.table=new Xy(e,this._errorListener),this.linefill=new Hy(e),this.log=new fw(e),this.runtime=new hw(this._errorListener),this.strategy=new rw(this._variables,this._options,t,this._errorListener,r),this.request=new lw(this._variables,r),this.syminfo=new cw}get errors(){return this._errorListener.errors}options(t){if(t.length)return this._getDataOfBarindex(t);const e=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let i;if(n.length){i={};for(const v of n)i[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=this._fills.size?[...this._fills.values()]:void 0,c=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders,strategySummary:this._variables.strategy.summaryData});const h=this._plots.size>0?[...this._plots.values()]:void 0,d=this._plotbars.size>0?[...this._plotbars.values()]:void 0,f=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,p=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,y=this._plotchars.size>0?[...this._plotchars.values()]:void 0,m=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:h,draws:m,alerts:r,colors:i,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:p,plotcandles:g,plotchars:y,plotbars:d,isUseBgColor:w})}_getDataOfBarindex(t){const e=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const p of r)n[p]=[...this._bgColors[p].values()].map(g=>{const y=[];for(const m of t){const w=g.colors[m];w&&y.push(w)}return g.colors=y,g})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,l=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._getDataFromBarindex(t,[...this._plots.values()]),h=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,d=this._getDrawsFromBarindex(t),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:d,alerts:e,colors:n,hlines:i,fills:a,logs:l,plotshapes:h,isUseBgColor:f})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const i of t){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:i,label:a}=this._variables,l={};return t.data.length&&(l.lines=t.data),e.data.length&&(l.linefills=e.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),i.data.length&&(l.polylines=i.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:i,polyline:a,label:l}=this._variables,c={};return e.data.length&&(c.lines=e.getValOfBarIndex(t)),r.data.length&&(c.linefills=r.getValOfBarIndex(t)),n.data.length&&(c.tables=n.getValOfBarIndex(t)),i.data.length&&(c.boxes=i.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),l.data.length&&(c.labels=l.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}updateOptions(t){const{inputs:e,strategy:r}=t;this.input.update(e),r&&this.strategy.updateOptions(r)}update(t){const{barIndex:e}=t;this.strategy.update(),this.math.update(e)}endExecution(){this.strategy.endExecution()}library(t,e){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=t;r.test(n)?(Hd.includes(n)||Gd.includes(n))&&this._errorListener.addError(Ye(le.libraryTitleIsKeywordErr,{name:n}),e,zt.Error):this._errorListener.addError(le.libraryTitleErr,e,zt.Error),this._options.scriptType="library",this._options.library=t}}indicator(t,e){if(!this._variables.bar_index){const{format:r}=t;this._paramVerfiy(r,e,"indicator",[Kt.inherit,Kt.percent,Kt.price,Kt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,i="format"){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(Zd.lineWidthWarning,e,zt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];me(t,r);const{series:n,color:i,...a}=t,{bar_index:l,time:c}=this._variables,h=`plot_${e}`,d=this._plots.get(h),f=(d==null?void 0:d.data)||[],p=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,p],itemStyle:{color:i}},this._seriesColorHandle(t,r,d),!d){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Kt.percent,Kt.price,Kt.volume]);const g=i?[i]:void 0;this._plots.set(h,{editable:!0,...a,colors:g,data:f,id:h,zIndex:this._count})}return{type:"plot",key:h}}plotbar(t,e){const r=["color"];me(t,r);const{open:n,close:i,low:a,high:l,color:c,...h}=t,{bar_index:d,time:f}=this._variables,p=`plotbar_${e}`,g=this._plotbars.get(p),y=(g==null?void 0:g.data)||[],m=i!==void 0&&isNaN(i)?void 0:i,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=l!==void 0&&isNaN(l)?void 0:l,b=[f,w,m,v,x];if(y[d]={value:b,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Kt.percent,Kt.price,Kt.volume]);const N=c?[c]:void 0;this._plotbars.set(p,{editable:!0,...h,colors:N,data:y,id:p,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:i,location:a,style:l}=t;this._paramVerfiy(l,r,e,Object.values(ur),"style"),this._paramVerfiy(a,r,e,Object.values(an),"location"),this._paramVerfiy(n,r,e,Object.values(nr),"size"),this._paramVerfiy(i,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:h,time:d,high:f,low:p}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),m=(y==null?void 0:y.data)||[],w={value:[d,n],itemStyle:{color:i,textcolor:a},low:p,high:f};m[h]=w,this._seriesColorHandle(t,r,y),y||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:l,data:m,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];me(t,r);const{series:n,colorup:i,colordown:a,...l}=t,{bar_index:c,time:h}=this._variables,d=`plotarrow_${e}`,f=this._plotarrows.get(d),p=(f==null?void 0:f.data)||[];p[c]={value:[h,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(t,r,f),f||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Kt.percent,Kt.price,Kt.volume]),this._plotarrows.set(d,{editable:!0,...l,data:p,id:d,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:h,time:d,low:f,high:p}=this._variables,g=`plotshape_${e}`,y=this._plotshapes.get(g),m=(y==null?void 0:y.data)||[],w={value:n,color:i,textcolor:a,time:d,low:f,high:p};if(m[h]=w,this._seriesColorHandle(t,r,y),!y){this._count++;const v=i?[i]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:m,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];me(t,r);const{wickcolor:n,bordercolor:i,color:a,close:l,open:c,low:h,high:d,...f}=t,{bar_index:p,time:g}=this._variables,y=`plotcandle_${e}`,m=this._plotcandles.get(y),w=(m==null?void 0:m.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,x=c!==void 0&&isNaN(c)?void 0:c,b=h!==void 0&&isNaN(h)?void 0:h,N=d!==void 0&&isNaN(d)?void 0:d,E=[g,x,v,b,N];w[p]={value:E,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(t,r,m),m||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Kt.percent,Kt.price,Kt.volume]),this._plotcandles.set(y,{editable:!0,...f,data:w,id:y,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;me(t,["color"]),this._verifyDisplay(t.display,"hline",e);const i=t.display&&!t.display.length?Ze.none:Ze.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,T,F,B,R,U,q,W,z,K;const r=["color","top_color","bottom_color"];me(t,r);const{color:n,top_color:i,bottom_color:a,seriesColors:l,hline1:c,hline2:h,plot1:d,plot2:f,top_value:p,bottom_value:g,...y}=t,{bar_index:m,time:w}=this._variables,v=`fill_${e}`,x=this._fills.get(v),b=(x==null?void 0:x.data)||[];this._verifyDisplay(t.display,"fill",e);const N=t.display&&!t.display.length?Ze.none:Ze.all;let E,A,M="plot";if(c&&h)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,A=(T=this._hlines.get(h==null?void 0:h.key))==null?void 0:T.price,M="hline";else{const Z=((F=this._plots.get(d==null?void 0:d.key))==null?void 0:F.data)||[],X=((B=this._plots.get(f==null?void 0:f.key))==null?void 0:B.data)||[];E=(U=(R=Z[m])==null?void 0:R.value)==null?void 0:U[1],A=(W=(q=X[m])==null?void 0:q.value)==null?void 0:W[1]}if(b[m]={time:w,color:n,top_color:i,bottom_color:a,plot1:E,plot2:A,top_value:p,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=i?[i]:void 0,ct=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ct,display:N,data:b,type:M,editable:!0,fillgaps:!1,hline1:c,hline2:h,plot1:d,plot2:f,...y,zIndex:Z?this._count:void 0})}}alert({message:t,freq:e=qr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},h=c.barIndex;if(this._paramVerfiy(e,r,"alert",[qr.freqAll,qr.freqOncePerBar,qr.freqOncePerBarClose]),e===qr.freqOncePerBar&&n===h){this._alerts.delete(l);return}this._cacheData[l]=c;const d={message:t,freq:e,id:l,type:"alert"};if(i){e!==qr.freqOncePerBarClose&&this._alerts.set(l,d),c.barIndex=n;return}if(!i&&e===qr.freqOncePerBarClose&&n===h&&a===n-1){this._alerts.set(l,d),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t,e){this._setColors(t,"barcolor",e)}bgcolor(t,e){this._setColors(t,"bgcolor",e)}_verifyDisplay(t=th.all,e,r){t.length&&t.length<4&&this._errorListener.addError(Ye(le.displayErr,{func:e,values:"[display.none, display.all]"}),r,zt.Error)}_setColors(t,e,r){me(t,["color"]);const{color:i,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?Ze.none:Ze.all,{bar_index:c,time:h}=this._variables,d=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const f=this._bgColors[e].get(d),p=(f==null?void 0:f.colors)||[],g=(f==null?void 0:f.setColors)||[];i&&!g.includes(i)&&g.push(i),p[c]={color:i,time:h},f||this._bgColors[e].set(d,{...a,display:l,colors:p,setColors:g,id:d})}max_bars_back({var:t,num:e,var_name:r}){console.log(t,e,r)}float({x:t}){return t}bool({x:t}){return t||!1}string({x:t}){return t}int({x:t}){return t&&Math.trunc(t)}na({x:t}){return!!(t===void 0||typeof t=="number"&&isNaN(t))}fixnan({source:t},e){return t===void 0||typeof t=="number"&&isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!(typeof t=="number"&&isNaN(t))?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._timeHandle(this._variables.time,i,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,t,e,r,n)}timestamp(t){const{dateString:e,timezone:r,year:n,month:i,day:a,hour:l=0,minute:c=0,second:h=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let d=i-1,f=n;if(d<0){const g=Math.ceil(Math.abs(d/12));d=12*g+d,f=n-g}let p=ee({year:f,month:d,day:a,hour:l,minute:c,second:h});return r&&(p=kr(p.utc(!0).valueOf(),r)),p.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return kr(t,e).week()}year({time:t,timezone:e}){return kr(t,e).year()}second({time:t,timezone:e}){return kr(t,e).second()}month({time:t,timezone:e}){return kr(t,e).month()+1}minute({time:t,timezone:e}){return kr(t,e).minute()}hour({time:t,timezone:e}){return kr(t,e).hour()}dayofweek({time:t,timezone:e}){return kr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return kr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Qr(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,i,a=0){const l=r||this._variables.timeframe.period,c=Qr(l),h=Qr(this._variables.timeframe.period);let d;if(c<=h)d=t;else{const f=`time_${e}`,p=this._cacheData[f];if(p)p.currentTime+c*1e3-p.offset<=t?(d=t,this._cacheData[f]={currentTime:t,offset:0}):d=p;else{const g=this._calcTimeOffset(t,l);this._cacheData[f]={currentTime:t,offset:g},d=t}}if(n){const{timePeriods:f,weeks:p}=this._parserSession(n,e),g=ee(t).format("YYYY-MM-DD"),y=d;d=void 0;for(const w of f){const[v,x]=w;if(ee(t).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")){ee(y).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")?d=y:d=ee(`${g} ${v}`).valueOf();break}}const m=this._variables.dayofweek;d&&!p.includes(m)&&(d=void 0)}return i&&(d=d&&kr(d,i).valueOf()),d&&d-a*h*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const i of e){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=t[i];if(!a)continue;const l=r[`${i}s`]||[];l.includes(a)||(l.push(a),r[`${i}s`]=l,l.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const h=parseInt(c,10);if(h<1||h>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,zt.Error);return}return h});return{timePeriods:n.split(",").map(c=>{c===""||c===fi.regular?c="0930-1500":c===fi.extended&&(c="1500-1830");const h=c.split("-");return h.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,zt.Error),[]):[this._processTime(h[0],e),this._processTime(h[1],e)]}),weeks:a}}_processTime(t,e){const r=parseInt(t.slice(0,2),10),n=parseInt(t.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",e,zt.Error);return}return`${r}:${n}`}}class lw{constructor(t,e){$(this,"_variables");$(this,"_scriptId");$(this,"_cacheData");this._variables=t,this._scriptId=e,this._cacheData=new Map}security(t,e){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=t,i=this._getRequestData(t,e);if(r!=null&&r.has(e)){const c=r.get(e);return this._runScripts(c,e,!1,n,i)}const a=this._parseExprCode(t),l=this._runScripts(a,e,!0,n,i);return r==null||r.set(e,a),l}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],i=1;e=Il(e);const a=JSON.parse(e),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},h=(l==null?void 0:l.depends)||[];if(!h.length)return`return ${l==null?void 0:l.code}`;let d=[],f=[];const p=[];if(this._getDependCodes(h,a,n,d,f,p),n.push(...p),f.length){const m=r.length;let w=[];for(let v=m-1;v>=0;v--){const x=r[v];let b=JSON.parse(Il(x));const N=[];i!==0&&f.length&&(w.unshift("{"),i++),b=b.map(S=>{const{scope:T,code:F,varNames:B,dependSelf:R}=S;return T===2&&!N.includes(B)&&!R&&(S.code=`let ${F}`),B&&N.push(...B.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],A=[];let M=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(M,b,A,d,f,E),w.unshift(...A,...E),n=w.concat(n),w=[]}}for(n.push(`return ${l==null?void 0:l.code}`);i>1;)n.push("}"),i--;n=d.concat(n);let g=n.join(`
|
63
|
+
`);const y=[];for(const m of Object.keys(c))g.includes(`$_var.getCacheData("${m}"`)&&y.push(c[m]);return y.length&&(g=`${y.join(`
|
64
|
+
`)}
|
65
|
+
${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:i}=t;const{__period:a,syminfo:{ticker:l,tickerid:c},mintick:h}=this._variables;if((n===a||n==="")&&(r===l||r===c)){const{close:g,open:y,high:m,low:w,bar_index:v,last_bar_index:x,last_bar_time:b,_isRealTimeBar:N,volume:E,time:A,time_tradingday:M}=this._variables;return{barIndex:v,c:g,o:y,h:m,l:w,volume:E,lastBarIndex:x,lastBarTime:b/1e3,isrealtime:N,time_tradingday:M,time:A/1e3,interval:a,mintick:h}}const d=`${r}--${n||a}`,f=self.workerStorage.get(`request_${this._scriptId}_data`),p=self.workerStorage.get(`request_${this._scriptId}_list`);if(f!=null&&f.has(d)){p==null||p.delete(d);const{index:g=0,periodStamp:y=Qr(this._variables.__period)*1e3}=this._cacheData.get(e)||{},m=(f.get(d)||[]).slice(g),w=this._variables.time,v=y+w,x=m.length-1,b={lastBarIndex:m[x].barindex||x,lastBarTime:m[x].time,interval:a,mintick:h};for(const[N,E]of m.entries()){let{time:A,barindex:M}=E;if(A=A*1e3,A>=v){this._cacheData.set(e,{index:N,periodStamp:y});return}if(A>=w)return this._cacheData.set(e,{index:N+1,periodStamp:y}),{...E,barIndex:M||N,...b}}this._cacheData.set(e,{index:m.length,periodStamp:y})}else(p==null?void 0:p.get(d))||p==null||p.set(d,{id:d,calc_bars_count:i,symbol:r,timeframe:n||a})}_getDependCodes(t,e,r,n,i,a){for(const l of t){if(!l.isArg){const c=e.filter(d=>{var f;return(f=d==null?void 0:d.depends)==null?void 0:f.some(p=>p.name===l.name&&p.scope===l.scope&&p.isAgainAssign)});for(const d of c){const{code:f,depends:p}=d;if(!r.includes(f)&&(r.unshift(f),p!=null&&p.length)){for(const g of p)g.memberCode&&a.push(g.memberCode);this._getDependCodes(p,e,r,n,i,a)}}const h=e.find(d=>{var f;return((f=d.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&d.methodName===l.functionName)||d.funcName===l.name});if(h){const{code:d,depends:f}=h,p=r.findIndex(g=>g===d);if(p!==-1&&r.splice(p,1),r.unshift(d),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,e,r,n,i,a)}continue}}i.some(c=>c.name===l.name)||i.push(l)}}_runScripts(t,e,r,n,i){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:d}=self.workerStorage.get(a)||{};const{interval:f,mintick:p,...g}=i||{};r&&(l=new uh(a),c=new eh,h=new ah(this._variables.mintick||1e-5,l,this._scriptId),d=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),l.updateOptions({interval:f,mintick:p||1e-5}),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:d})),l.updateData(g),h.update({barIndex:(g==null?void 0:g.barindex)||0});const y=d(l,c,h,n||[],e);return h.endExecution(),y}}let cw=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class fw{constructor(t){$(this,"_logs");$(this,"_variables");$(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:i,formatString:a}=t,{time:l,bar_index:c}=this._variables;let h=i;a&&Array.isArray(e)&&e.length&&(h=a.replace(/{(\d+)}/g,(d,f)=>{let p=e[f];return typeof p=="number"&&(p=this._intlFormat.format(parseFloat(p.toFixed(3)))),typeof p=="object"&&(p.isArray?p=JSON.stringify(p._value):p=p.toString()),p!==void 0?p:d})),h&&this._logs.push({message:`[${ee(l).format()}]: ${h}`,time:l,barIndex:c,type:r})}}class hw{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class dw{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Xr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[i,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(i),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(i),type:r};l?l.push(c):this._errors.set(e,[c])}}class pw{constructor(){$(this,"_isMarketOpen");$(this,"_currentBarIndex");$(this,"_totalBarIndex");$(this,"_isRealTimeBar");$(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class _w{constructor(t){$(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class mw{constructor(t){$(this,"_orders");$(this,"_historyOrders");$(this,"_options");$(this,"_max_contracts_held_all",0);$(this,"_max_contracts_held_long",0);$(this,"_max_contracts_held_short",0);$(this,"_max_drawdown",0);$(this,"_max_runup",0);$(this,"_max_runup_percent",0);$(this,"_max_drawdown_percent",0);$(this,"_variables");$(this,"_netprofit",0);$(this,"_eventrades",0);$(this,"_avg_trade_percent");$(this,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossloss_percent",0);$(this,"_grossprofit",0);$(this,"_grossprofit_percent",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"_preMaxNetValue",0);$(this,"_preMinNetValue",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(t){this._calcMaxDrawdownAndMaxRunup(t)}_calcMaxDrawdownAndMaxRunup(t){if(!this._orders.length&&!this._historyOrders.length)return;let e=0,r=0;const{high:n,low:i,close:a}=t;let l=0;for(const d of this._orders){const{in_price:f,qty:p=0,direction:g}=d,y=g===se.long?1:-1,m=(n-f)*p,w=(i-f)*p,v=y===1?m:-w,x=y===1?-w:m;l+=(a-f)*y*p,e+=x,r+=v}this._openprofit=l;const c=this.initial_capital,h=c+this._netprofit;this._preMinNetValue=this._preMinNetValue||c,this._preMaxNetValue=this._preMaxNetValue||c,e=this._preMaxNetValue-h+Math.max(e,0),r=h-this._preMinNetValue+r,this._max_drawdown<e&&(this._max_drawdown=e,this._max_drawdown_percent=e/c*100),r>this._max_runup&&(this._max_runup=r,this._max_runup_percent=r/(h+r)*100)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,i,a,l,c]=this._orders.reduce(([h,d,f,p,g,y,m],w)=>{const{direction:v,qty:x=0,in_price:b,commission:N=0}=w;return v===se.long?(h+=x,d+=x,y+=x):(h+=x,f+=x,y-=x),p+=x*b,g+=b,m+=N,[h,d,f,p,g,y,m]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=i,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,i,a]=this._historyOrders.reduce((h,d)=>{let[f,p,g,y]=h;const{profit:m=0,profit_percent:w=0}=d;return f+=m,p+=w,m<0?g+=m:y+=m,[f,p,g,y]},[0,0,0,0]),l=this._orders.reduce((h,d)=>{const{commission:f=0,qty:p=0,original_qty:g=0}=d,y=f*p/g;return h+y},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-l;const c=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,c),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,c),this._grossloss=i-l,this._grossprofit=a,this._eventrades=this._historyOrders.filter(h=>h.profit===0).length,this._losstrades=this._historyOrders.filter(h=>(h.profit||0)<0).length,this._wintrades=this._historyOrders.filter(h=>(h.profit||0)>0).length}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:i=0}=this._options,a=this._orders[0].direction===se.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[h,d]=this._orders.reduce((f,p)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=p,x=m*w;if(g+=x,i){let b=0;switch(n){case We.percent:b=(x+w*c)*i/100;break;case We.cashPerContract:b=w*i*2;break;case We.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(h-(t+this._netprofit-d))*a/this._position_size/(1-a*l)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case We.percent:a=i*r/100;break;case We.cashPerContract:a=e*r;break;case We.cashPerOrder:a=r;break}return a}}class gw{constructor(t){$(this,"_preAccdist");$(this,"_preNvi");$(this,"_prePvi");$(this,"_preObv");$(this,"_prePvt");$(this,"_preWad");$(this,"_preVwap");$(this,"_preValue");$(this,"_currentData");$(this,"_preData");$(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const i=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=i),this._preValue.accdist=i,i}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,i=(2*t-r-e)/((r-e)*n);return this._preValue.iii=i,i}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:i}=this._currentData,a=(t-i)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const i=Math.max(e,n),a=Math.min(r,n),l=t-n,h=(l>0?t-a:l<0?t-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=h),this._preValue.wad=h,h}get vwap(){var d,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:i}=this._preVwap;if(((f=(d=self.workerStorage)==null?void 0:d.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(i=!0,r=n=0),!i)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:i});const h=l/c;return this._preValue.vwap=h,h}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i<r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class vw{constructor(){$(this,"_period");$(this,"_multiplier");$(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=ys(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class yw{constructor(t){$(this,"_variables");$(this,"_bgColor");$(this,"_fgColor");$(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,i;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class ww{constructor(t){$(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return fi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){return""}get tickerid(){return""}get timezone(){}get type(){}get volumetype(){return"n/a"}}class Dw{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class bw{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(Vd),ee.extend(Sl),ee.extend(Wd);class uh{constructor(t){$(this,"_cacheData");$(this,"_barIndex");$(this,"_isRealTimeBar");$(this,"_barstate");$(this,"_priceVariables");$(this,"_lastBarIndex");$(this,"_currentBarTime");$(this,"_lastBarTime");$(this,"_period");$(this,"_offsetTime");$(this,"_timeframe");$(this,"_ta");$(this,"_polyline");$(this,"_label");$(this,"_line");$(this,"_linefill");$(this,"_box");$(this,"_table");$(this,"_strategy");$(this,"_session");$(this,"syminfo");$(this,"chart");$(this,"earnings");$(this,"dividends");$(this,"_timeTradingday");$(this,"_mintick");$(this,"_cacheSpace");this._cacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new pw,this._timeframe=new vw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new gw(t),this._polyline=new Fi,this._label=new Fi,this._line=new Fi,this._linefill=new Fi,this._box=new Fi,this._table=new Fi,this._strategy=new mw(this),this._session=new _w(this),this.syminfo=new ww(this),this.chart=new yw(this),this.earnings=new bw(this),this.dividends=new Dw(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=ys(this._period);return this._isRealTimeBar?void 0:ee(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:i}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),i&&this._polyline.setMaxLen(i)}getTimeTradingday(t,e){const[r,n]=ys(e),i=ee(t);return["M","w","y","d"].includes(n)?i.valueOf():(i.subtract(this._offsetTime,"h"),i.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){const{interval:e="1D",offsetTime:r=5,mintick:n,chart:i}=t;this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(i)}updateData(t){const{barIndex:e,c:r,o:n,h:i,l:a,volume:l,time:c,lastBarIndex:h,lastBarTime:d,isrealtime:f,time_tradingday:p}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(i),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varNewData={}),this._timeTradingday=p,this._currentBarTime=c*1e3,this._lastBarIndex=h,this._barIndex=e,this._lastBarTime=d*1e3,this._barstate.update(e,h,f,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new zd(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`;return r==="var"?this._isRealTimeBar&&this._cacheData.varNewData.hasOwnProperty(n)?this._cacheData.varNewData[n]:this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const i=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[i]||this._cacheData.varipData[i]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[i]=r,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=r[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Fe.BOX:this._setChartDraw(e,this._box);break;case Fe.LINE:this._setChartDraw(e,this._line);break;case Fe.POLYLINE:this._setChartDraw(e,this._polyline);break;case Fe.LABEL:this._setChartDraw(e,this._label);break;case Fe.LINEFILL:this._setChartDraw(e,this._linefill);break;case Fe.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t),i=(r==null?void 0:r.updateId())||t;e.delete(t),e.set(i,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Xr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case ao.name:case rh.name:case co.name:case nh.name:case uo.name:case lo.name:t==null||t.delete();break}}}class Fi{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[i,a]of this._all){const{isVar:l,id:c,bar_index:h}=a;if(h===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const i=r.filter(a=>a.endsWith(`_${n}`));for(const a of i){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}/**
|
66
|
+
* @license
|
67
|
+
* Copyright 2019 Google LLC
|
68
|
+
* SPDX-License-Identifier: Apache-2.0
|
69
|
+
*/const lh=Symbol("Comlink.proxy"),xw=Symbol("Comlink.endpoint"),Ew=Symbol("Comlink.releaseProxy"),Ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),ch=s=>typeof s=="object"&&s!==null||typeof s=="function",Aw={canHandle:s=>ch(s)&&s[lh],serialize(s){const{port1:t,port2:e}=new MessageChannel;return Wa(s,t),[e,[e]]},deserialize(s){return s.start(),Nw(s)}},Cw={canHandle:s=>ch(s)&&fo in s,serialize({value:s}){let t;return s instanceof Error?t={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:t={isError:!1,value:s},[t,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},fh=new Map([["proxy",Aw],["throw",Cw]]);function Fw(s,t){for(const e of s)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Wa(s,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Fw(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Qn);let h;try{const d=l.slice(0,-1).reduce((p,g)=>p[g],s),f=l.reduce((p,g)=>p[g],s);switch(a){case"GET":h=f;break;case"SET":d[l.slice(-1)[0]]=Qn(n.data.value),h=!0;break;case"APPLY":h=f.apply(d,c);break;case"CONSTRUCT":{const p=new f(...c);h=Tw(p)}break;case"ENDPOINT":{const{port1:p,port2:g}=new MessageChannel;Wa(s,g),h=Iw(p,[p])}break;case"RELEASE":h=void 0;break;default:return}}catch(d){h={value:d,[fo]:0}}Promise.resolve(h).catch(d=>({value:d,[fo]:0})).then(d=>{const[f,p]=mo(d);t.postMessage(Object.assign(Object.assign({},f),{id:i}),p),a==="RELEASE"&&(t.removeEventListener("message",r),hh(t),Ua in s&&typeof s[Ua]=="function"&&s[Ua]())}).catch(d=>{const[f,p]=mo({value:new TypeError("Unserializable return value"),[fo]:0});t.postMessage(Object.assign(Object.assign({},f),{id:i}),p)})}),t.start&&t.start()}function Mw(s){return s.constructor.name==="MessagePort"}function hh(s){Mw(s)&&s.close()}function Nw(s,t){return ja(s,[],t)}function ho(s){if(s)throw new Error("Proxy has been released and is not useable")}function dh(s){return Mi(s,{type:"RELEASE"}).then(()=>{hh(s)})}const po=new WeakMap,_o="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const t=(po.get(s)||0)-1;po.set(s,t),t===0&&dh(s)});function Sw(s,t){const e=(po.get(t)||0)+1;po.set(t,e),_o&&_o.register(s,t,s)}function Ow(s){_o&&_o.unregister(s)}function ja(s,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(i,a){if(ho(r),a===Ew)return()=>{Ow(n),dh(s),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=Mi(s,{type:"GET",path:t.map(c=>c.toString())}).then(Qn);return l.then.bind(l)}return ja(s,[...t,a])},set(i,a,l){ho(r);const[c,h]=mo(l);return Mi(s,{type:"SET",path:[...t,a].map(d=>d.toString()),value:c},h).then(Qn)},apply(i,a,l){ho(r);const c=t[t.length-1];if(c===xw)return Mi(s,{type:"ENDPOINT"}).then(Qn);if(c==="bind")return ja(s,t.slice(0,-1));const[h,d]=ph(l);return Mi(s,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:h},d).then(Qn)},construct(i,a){ho(r);const[l,c]=ph(a);return Mi(s,{type:"CONSTRUCT",path:t.map(h=>h.toString()),argumentList:l},c).then(Qn)}});return Sw(n,s),n}function Bw(s){return Array.prototype.concat.apply([],s)}function ph(s){const t=s.map(mo);return[t.map(e=>e[0]),Bw(t.map(e=>e[1]))]}const _h=new WeakMap;function Iw(s,t){return _h.set(s,t),s}function Tw(s){return Object.assign(s,{[lh]:!0})}function mo(s){for(const[t,e]of fh)if(e.canHandle(s)){const[r,n]=e.serialize(s);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:s},_h.get(s)||[]]}function Qn(s){switch(s.type){case"HANDLER":return fh.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Mi(s,t,e){return new Promise(r=>{const n=$w();s.addEventListener("message",function i(a){!a.data||!a.data.id||a.data.id!==n||(s.removeEventListener("message",i),r(a.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:n},t),e)})}function $w(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class Lw{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function Rw(s,t,e){var b;const{data:r,isPreParser:n,id:i="default",syminfo:a,interval:l,inputs:c,chart:h,strategy:d,scriptType:f}=t;self.workerStorage||(self.workerStorage=new Lw);let{builtInGather:p,buildinConstants:g,buildInFunctions:y,tradingvueFunc:m}=self.workerStorage.get(i)||{},w=[];e&&(p=new uh(i),g=new eh,y=new ah((a==null?void 0:a.mintick)||1e-5,p,i),m=new Function("$_var","$_const","$_func",s),self.workerStorage.set(i,{builtInGather:p,buildinConstants:g,buildInFunctions:y,tradingvueFunc:m}),self.workerStorage.set(`request_${i}`,new Map),self.workerStorage.set(`request_${i}_data`,new Map),self.workerStorage.set(`request_${i}_list`,new Map));let v=[];if(n)m(p,g,y);else if(r&&r.length){const N=r.length-1;p.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:h}),y.updateOptions({inputs:c,strategy:d});try{for(const[E,A]of r.entries()){const{barindex:M,isrealtime:S}=A;if(!e&&(M||M===0)&&w.push(M),S&&f===$l.strategy&&!y.strategy.isCalcOnEveryTick){y.strategy.calcCurrentOrder();continue}if(p.updateData(Object.assign(A,{barIndex:M||E,lastBarIndex:r[N].barindex||N,lastBarTime:r[N].time})),y.update({barIndex:M||E}),m(p,g,y),y.endExecution(),y.strategy.calcOnOrderFillsData.tradeData){for(;y.strategy.calcOnOrderFillsData.tradeData;)y.strategy.calcOnOrderFillsData.data=y.strategy.calcOnOrderFillsData.tradeData,y.strategy.calcOnOrderFillsData.tradeData=void 0,p.updateData(Object.assign(A,{barIndex:M||E,lastBarIndex:r[N].barindex||N,lastBarTime:r[N].time})),y.update({barIndex:M||E}),m(p,g,y),y.endExecution();y.strategy.calcOnOrderFillsData={index:-1}}const T=y.errors;if(T.length&&T.some(F=>F.type===zt.Error))return{status:1,errors:T}}v=[...((b=self.workerStorage.get(`request_${i}_list`))==null?void 0:b.values())||[]],v.length&&self.workerStorage.delete(`request_${i}_list`)}catch(E){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:E==null?void 0:E.message,type:zt.Error}]}}}const x=y.errors;return x.length&&x.some(N=>N.type===zt.Error)?{status:1,errors:x}:{status:0,requestList:v,errors:x,options:{...y.options(w),id:i}}}function Pw(s){self==null||self.workerStorage.deleteStartwidthKey(s),self==null||self.workerStorage.delete(`inputs_${s}`),self==null||self.workerStorage.delete(`strategy_${s}`),self==null||self.workerStorage.delete(`request_${s}`),self==null||self.workerStorage.delete(`request_${s}_data`),self==null||self.workerStorage.delete(`request_${s}_list`)}Wa({runScript:Rw,removeScript:Pw})})();
|