@tachybase/plugin-evaluator-mathjs 1.3.20 → 1.3.22

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.
@@ -1,52 +1,52 @@
1
- (function(ur,pr){typeof exports=="object"&&typeof module!="undefined"?pr(exports,require("@tachybase/client"),require("@tachybase/evaluators/client"),require("@tachybase/evaluators")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/evaluators/client","@tachybase/evaluators"],pr):(ur=typeof globalThis!="undefined"?globalThis:ur||self,pr(ur["@tachybase/plugin-evaluator-mathjs"]={},ur["@tachybase/client"],ur["@tachybase/evaluators"],ur["@tachybase/evaluators"]))})(this,function(ur,pr,nt,ht){"use strict";var io=(ur,pr)=>(pr=Symbol[ur])?pr:Symbol.for("Symbol."+ur),f$=ur=>{throw TypeError(ur)},en=Math.pow;var Mp=(ur,pr,nt)=>new Promise((ht,rr)=>{var qr=vr=>{try{Ie(nt.next(vr))}catch(at){rr(at)}},$e=vr=>{try{Ie(nt.throw(vr))}catch(at){rr(at)}},Ie=vr=>vr.done?ht(vr.value):Promise.resolve(vr.value).then(qr,$e);Ie((nt=nt.apply(ur,pr)).next())}),l$=function(ur,pr){this[0]=ur,this[1]=pr};var oo=ur=>{var pr=ur[io("asyncIterator")],nt=!1,ht,rr={};return pr==null?(pr=ur[io("iterator")](),ht=qr=>rr[qr]=$e=>pr[qr]($e)):(pr=pr.call(ur),ht=qr=>rr[qr]=$e=>{if(nt){if(nt=!1,qr==="throw")throw $e;return $e}return nt=!0,{done:!1,value:new l$(new Promise(Ie=>{var vr=pr[qr]($e);vr instanceof Object||f$("Object expected"),Ie(vr)}),1)}}),rr[io("iterator")]=()=>rr,ht("next"),"throw"in pr?ht("throw"):rr.throw=qr=>{throw qr},"return"in pr&&ht("return"),rr};function rr(){return rr=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var t in a)({}).hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e},rr.apply(null,arguments)}var qr={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function $e(e){return typeof e=="number"}function Ie(e){return!e||typeof e!="object"||typeof e.constructor!="function"?!1:e.isBigNumber===!0&&typeof e.constructor.prototype=="object"&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal=="function"&&e.constructor.isDecimal(e)===!0}function vr(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function at(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function En(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Br(e){return typeof e=="string"}var Xe=Array.isArray;function Oe(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function rn(e){return Array.isArray(e)||Oe(e)}function Kn(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Ut(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function jn(e){return e&&e.constructor.prototype.isRange===!0||!1}function Cn(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Ap(e){return typeof e=="boolean"}function so(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function Ja(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Sp(e){return typeof e=="function"}function Ep(e){return e instanceof Date}function Cp(e){return e instanceof RegExp}function Qa(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!vr(e)&&!at(e))}function Op(e){return e===null}function Dp(e){return e===void 0}function Lt(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function kr(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function Tp(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Bp(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function _p(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ye(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function On(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function kt(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function tn(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ve(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function ea(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function _r(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Dn(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function $p(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function xr(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ka(e){return e&&e.constructor.prototype.isChain===!0||!1}function Ke(e){var n=typeof e;return n==="object"?e===null?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":Ie(e)?"BigNumber":vr(e)?"Complex":at(e)?"Fraction":Oe(e)?"Matrix":En(e)?"Unit":Cn(e)?"Index":jn(e)?"Range":so(e)?"ResultSet":Ve(e)?e.type:Ka(e)?"Chain":Ja(e)?"Help":"Object":n==="function"?"Function":n}function Ce(e){var n=typeof e;if(n==="number"||n==="string"||n==="boolean"||e===null||e===void 0)return e;if(typeof e.clone=="function")return e.clone();if(Array.isArray(e))return e.map(function(a){return Ce(a)});if(e instanceof Date)return new Date(e.valueOf());if(Ie(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return Ip(e,Ce)}function Ip(e,n){var a={};for(var t in e)Me(e,t)&&(a[t]=n(e[t]));return a}function ja(e,n){for(var a in n)Me(n,a)&&(e[a]=n[a]);return e}function Tn(e,n){var a,t,r;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(t=0,r=e.length;t<r;t++)if(!Tn(e[t],n[t]))return!1;return!0}else{if(typeof e=="function")return e===n;if(e instanceof Object){if(Array.isArray(n)||!(n instanceof Object))return!1;for(a in e)if(!(a in n)||!Tn(e[a],n[a]))return!1;for(a in n)if(!(a in e))return!1;return!0}else return e===n}}function qp(e,n,a){var t=!0,r;Object.defineProperty(e,n,{get:function(){return t&&(r=a(),t=!1),r},set:function(l){r=l,t=!1},configurable:!0,enumerable:!0})}function Me(e,n){return e&&Object.hasOwnProperty.call(e,n)}function Rp(e,n){for(var a={},t=0;t<n.length;t++){var r=n[t],i=e[r];i!==void 0&&(a[r]=i)}return a}var Fp=["Matrix","Array"],zp=["number","BigNumber","Fraction"],oe=function(n){if(n)throw new Error(`The global config is readonly.
1
+ (function(fr,pr){typeof exports=="object"&&typeof module!="undefined"?pr(exports,require("@tachybase/client"),require("@tego/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client"],pr):(fr=typeof globalThis!="undefined"?globalThis:fr||self,pr(fr["@tachybase/plugin-evaluator-mathjs"]={},fr["@tachybase/client"],fr["@tego/client"]))})(this,function(fr,pr,Qr){"use strict";var ao=(fr,pr)=>(pr=Symbol[fr])?pr:Symbol.for("Symbol."+fr),c$=fr=>{throw TypeError(fr)},en=Math.pow;var Np=(fr,pr,Qr)=>new Promise((ar,kr)=>{var Be=yr=>{try{Or(Qr.next(yr))}catch(ht){kr(ht)}},_e=yr=>{try{Or(Qr.throw(yr))}catch(ht){kr(ht)}},Or=yr=>yr.done?ar(yr.value):Promise.resolve(yr.value).then(Be,_e);Or((Qr=Qr.apply(fr,pr)).next())}),f$=function(fr,pr){this[0]=fr,this[1]=pr};var io=fr=>{var pr=fr[ao("asyncIterator")],Qr=!1,ar,kr={};return pr==null?(pr=fr[ao("iterator")](),ar=Be=>kr[Be]=_e=>pr[Be](_e)):(pr=pr.call(fr),ar=Be=>kr[Be]=_e=>{if(Qr){if(Qr=!1,Be==="throw")throw _e;return _e}return Qr=!0,{done:!1,value:new f$(new Promise(Or=>{var yr=pr[Be](_e);yr instanceof Object||c$("Object expected"),Or(yr)}),1)}}),kr[ao("iterator")]=()=>kr,ar("next"),"throw"in pr?ar("throw"):kr.throw=Be=>{throw Be},"return"in pr&&ar("return"),kr};function ar(){return ar=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var t in a)({}).hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e},ar.apply(null,arguments)}var kr={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function Be(e){return typeof e=="number"}function _e(e){return!e||typeof e!="object"||typeof e.constructor!="function"?!1:e.isBigNumber===!0&&typeof e.constructor.prototype=="object"&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal=="function"&&e.constructor.isDecimal(e)===!0}function Or(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function yr(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function ht(e){return e&&e.constructor.prototype.isUnit===!0||!1}function _r(e){return typeof e=="string"}var Xe=Array.isArray;function Oe(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function rn(e){return Array.isArray(e)||Oe(e)}function Qn(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Ut(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Kn(e){return e&&e.constructor.prototype.isRange===!0||!1}function En(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Mp(e){return typeof e=="boolean"}function oo(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function Wa(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Ap(e){return typeof e=="function"}function Sp(e){return e instanceof Date}function Ep(e){return e instanceof RegExp}function Ja(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!Or(e)&&!yr(e))}function Cp(e){return e===null}function Op(e){return e===void 0}function Lt(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Hr(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function Dp(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Tp(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function Bp(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ye(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function Cn(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function kt(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function tn(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ve(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function jn(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function $r(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function On(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function _p(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function xr(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function Qa(e){return e&&e.constructor.prototype.isChain===!0||!1}function Ke(e){var n=typeof e;return n==="object"?e===null?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":_e(e)?"BigNumber":Or(e)?"Complex":yr(e)?"Fraction":Oe(e)?"Matrix":ht(e)?"Unit":En(e)?"Index":Kn(e)?"Range":oo(e)?"ResultSet":Ve(e)?e.type:Qa(e)?"Chain":Wa(e)?"Help":"Object":n==="function"?"Function":n}function Ce(e){var n=typeof e;if(n==="number"||n==="string"||n==="boolean"||e===null||e===void 0)return e;if(typeof e.clone=="function")return e.clone();if(Array.isArray(e))return e.map(function(a){return Ce(a)});if(e instanceof Date)return new Date(e.valueOf());if(_e(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return $p(e,Ce)}function $p(e,n){var a={};for(var t in e)Me(e,t)&&(a[t]=n(e[t]));return a}function Ka(e,n){for(var a in n)Me(n,a)&&(e[a]=n[a]);return e}function Dn(e,n){var a,t,r;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(t=0,r=e.length;t<r;t++)if(!Dn(e[t],n[t]))return!1;return!0}else{if(typeof e=="function")return e===n;if(e instanceof Object){if(Array.isArray(n)||!(n instanceof Object))return!1;for(a in e)if(!(a in n)||!Dn(e[a],n[a]))return!1;for(a in n)if(!(a in e))return!1;return!0}else return e===n}}function Ip(e,n,a){var t=!0,r;Object.defineProperty(e,n,{get:function(){return t&&(r=a(),t=!1),r},set:function(l){r=l,t=!1},configurable:!0,enumerable:!0})}function Me(e,n){return e&&Object.hasOwnProperty.call(e,n)}function qp(e,n){for(var a={},t=0;t<n.length;t++){var r=n[t],i=e[r];i!==void 0&&(a[r]=i)}return a}var Rp=["Matrix","Array"],Fp=["number","BigNumber","Fraction"],oe=function(n){if(n)throw new Error(`The global config is readonly.
2
2
  Please create a mathjs instance if you want to change the default configuration.
3
3
  Example:
4
4
 
5
5
  import { create, all } from 'mathjs';
6
6
  const mathjs = create(all);
7
7
  mathjs.config({ number: 'BigNumber' });
8
- `);return Object.freeze(qr)};rr(oe,qr,{MATRIX_OPTIONS:Fp,NUMBER_OPTIONS:zp});function Bn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Pp(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var n=e.default;if(typeof n=="function"){var a=function t(){var r=!1;try{r=this instanceof t}catch(i){}return r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};a.prototype=n.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),a}var ra={exports:{}},Up=ra.exports,uo;function Lp(){return uo||(uo=1,function(e,n){(function(a,t){e.exports=t()})(Up,function(){function a(){return!0}function t(){return!1}function r(){}function i(){var l=[{name:"number",test:function(q){return typeof q=="number"}},{name:"string",test:function(q){return typeof q=="string"}},{name:"boolean",test:function(q){return typeof q=="boolean"}},{name:"Function",test:function(q){return typeof q=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(q){return q instanceof Date}},{name:"RegExp",test:function(q){return q instanceof RegExp}},{name:"Object",test:function(q){return typeof q=="object"&&q!==null&&q.constructor===Object}},{name:"null",test:function(q){return q===null}},{name:"undefined",test:function(q){return q===void 0}}],m={name:"any",test:a},f=[],c=[],s={types:l,conversions:c,ignore:f};function o(q){var P=F(s.types,function(L){return L.name===q});if(P)return P;if(q==="any")return m;var Q=F(s.types,function(L){return L.name.toLowerCase()===q.toLowerCase()});throw new TypeError('Unknown type "'+q+'"'+(Q?'. Did you mean "'+Q.name+'"?':""))}function u(q){return q===m?999:s.types.indexOf(q)}function p(q){var P=F(s.types,function(Q){return Q.test(q)});if(P)return P.name;throw new TypeError("Value has unknown type. Value: "+q)}function v(q,P){if(!q.signatures)throw new TypeError("Function is no typed-function");var Q;if(typeof P=="string"){Q=P.split(",");for(var L=0;L<Q.length;L++)Q[L]=Q[L].trim()}else if(Array.isArray(P))Q=P;else throw new TypeError("String array or a comma separated string expected");var se=Q.join(","),fe=q.signatures[se];if(fe)return fe;throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+Q.join(", ")+"))")}function h(q,P){var Q=p(q);if(P===Q)return q;for(var L=0;L<s.conversions.length;L++){var se=s.conversions[L];if(se.from===Q&&se.to===P)return se.convert(q)}throw new Error("Cannot convert from "+Q+" to "+P)}function b(q){return q.map(function(P){var Q=P.types.map(O);return(P.restParam?"...":"")+Q.join("|")}).join(",")}function w(q,P){var Q=q.indexOf("...")===0,L=Q?q.length>3?q.slice(3):"any":q,se=L.split("|").map(re).filter(ie).filter(te),fe=B(P,se),ge=se.map(function(ve){var Ne=o(ve);return{name:ve,typeIndex:u(Ne),test:Ne.test,conversion:null,conversionIndex:-1}}),pe=fe.map(function(ve){var Ne=o(ve.from);return{name:ve.from,typeIndex:u(Ne),test:Ne.test,conversion:ve,conversionIndex:P.indexOf(ve)}});return{types:ge.concat(pe),restParam:Q}}function N(q,P,Q){var L=[];return q.trim()!==""&&(L=q.split(",").map(re).map(function(se,fe,ge){var pe=w(se,Q);if(pe.restParam&&fe!==ge.length-1)throw new SyntaxError('Unexpected rest parameter "'+se+'": only allowed for the last parameter');return pe})),L.some(ue)?null:{params:L,fn:P}}function g(q){var P=ye(q);return P?P.restParam:!1}function y(q){return q.types.some(function(P){return P.conversion!=null})}function x(q){if(!q||q.types.length===0)return a;if(q.types.length===1)return o(q.types[0].name).test;if(q.types.length===2){var P=o(q.types[0].name).test,Q=o(q.types[1].name).test;return function(fe){return P(fe)||Q(fe)}}else{var L=q.types.map(function(se){return o(se.name).test});return function(fe){for(var ge=0;ge<L.length;ge++)if(L[ge](fe))return!0;return!1}}}function d(q){var P,Q,L;if(g(q)){P=ee(q).map(x);var se=P.length,fe=x(ye(q)),ge=function(pe){for(var ve=se;ve<pe.length;ve++)if(!fe(pe[ve]))return!1;return!0};return function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ge(ve)&&ve.length>=se+1}}else return q.length===0?function(ve){return ve.length===0}:q.length===1?(Q=x(q[0]),function(ve){return Q(ve[0])&&ve.length===1}):q.length===2?(Q=x(q[0]),L=x(q[1]),function(ve){return Q(ve[0])&&L(ve[1])&&ve.length===2}):(P=q.map(x),function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ve.length===P.length})}function A(q,P){return P<q.params.length?q.params[P]:g(q.params)?ye(q.params):null}function S(q,P,Q){var L=A(q,P),se=L?Q?L.types.filter(M):L.types:[];return se.map(O)}function O(q){return q.name}function M(q){return q.conversion===null||q.conversion===void 0}function _(q,P){var Q=Y(k(q,function(L){return S(L,P,!1)}));return Q.indexOf("any")!==-1?["any"]:Q}function E(q,P,Q){var L,se,fe=q||"unnamed",ge=Q,pe;for(pe=0;pe<P.length;pe++){var ve=ge.filter(function(nr){var Wr=x(A(nr,pe));return(pe<nr.params.length||g(nr.params))&&Wr(P[pe])});if(ve.length===0){if(se=_(ge,pe),se.length>0){var Ne=p(P[pe]);return L=new TypeError("Unexpected type of argument in function "+fe+" (expected: "+se.join(" or ")+", actual: "+Ne+", index: "+pe+")"),L.data={category:"wrongType",fn:fe,index:pe,actual:Ne,expected:se},L}}else ge=ve}var Qe=ge.map(function(nr){return g(nr.params)?1/0:nr.params.length});if(P.length<Math.min.apply(null,Qe))return se=_(ge,pe),L=new TypeError("Too few arguments in function "+fe+" (expected: "+se.join(" or ")+", index: "+P.length+")"),L.data={category:"tooFewArgs",fn:fe,index:P.length,expected:se},L;var fr=Math.max.apply(null,Qe);return P.length>fr?(L=new TypeError("Too many arguments in function "+fe+" (expected: "+fr+", actual: "+P.length+")"),L.data={category:"tooManyArgs",fn:fe,index:P.length,expectedLength:fr},L):(L=new TypeError('Arguments of type "'+P.join(", ")+'" do not match any of the defined signatures of function '+fe+"."),L.data={category:"mismatch",actual:P.map(p)},L)}function $(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])&&(P=Math.min(P,q.types[Q].typeIndex));return P}function z(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])||(P=Math.min(P,q.types[Q].conversionIndex));return P}function I(q,P){var Q;return Q=q.restParam-P.restParam,Q!==0||(Q=y(q)-y(P),Q!==0)||(Q=$(q)-$(P),Q!==0)?Q:z(q)-z(P)}function T(q,P){var Q=Math.min(q.params.length,P.params.length),L,se;if(se=q.params.some(y)-P.params.some(y),se!==0)return se;for(L=0;L<Q;L++)if(se=y(q.params[L])-y(P.params[L]),se!==0)return se;for(L=0;L<Q;L++)if(se=I(q.params[L],P.params[L]),se!==0)return se;return q.params.length-P.params.length}function B(q,P){var Q={};return q.forEach(function(L){P.indexOf(L.from)===-1&&P.indexOf(L.to)!==-1&&!Q[L.from]&&(Q[L.from]=L)}),Object.keys(Q).map(function(L){return Q[L]})}function G(q,P){var Q=P;if(q.some(y)){var L=g(q),se=q.map(D);Q=function(){for(var ve=[],Ne=L?arguments.length-1:arguments.length,Qe=0;Qe<Ne;Qe++)ve[Qe]=se[Qe](arguments[Qe]);return L&&(ve[Ne]=arguments[Ne].map(se[Ne])),P.apply(this,ve)}}var fe=Q;if(g(q)){var ge=q.length-1;fe=function(){return Q.apply(this,we(arguments,0,ge).concat([we(arguments,ge)]))}}return fe}function D(q){var P,Q,L,se,fe=[],ge=[];switch(q.types.forEach(function(pe){pe.conversion&&(fe.push(o(pe.conversion.from).test),ge.push(pe.conversion.convert))}),ge.length){case 0:return function(ve){return ve};case 1:return P=fe[0],L=ge[0],function(ve){return P(ve)?L(ve):ve};case 2:return P=fe[0],Q=fe[1],L=ge[0],se=ge[1],function(ve){return P(ve)?L(ve):Q(ve)?se(ve):ve};default:return function(ve){for(var Ne=0;Ne<ge.length;Ne++)if(fe[Ne](ve))return ge[Ne](ve);return ve}}}function H(q){var P={};return q.forEach(function(Q){Q.params.some(y)||W(Q.params,!0).forEach(function(L){P[b(L)]=Q.fn})}),P}function W(q,P){function Q(L,se,fe){if(se<L.length){var ge=L[se],pe=P?ge.types.filter(M):ge.types,ve;if(ge.restParam){var Ne=pe.filter(M);ve=Ne.length<pe.length?[Ne,pe]:[pe]}else ve=pe.map(function(fr){return[fr]});return k(ve,function(fr){return Q(L,se+1,fe.concat([fr]))})}else{var Qe=fe.map(function(fr,nr){return{types:fr,restParam:nr===L.length-1&&g(L)}});return[Qe]}}return Q(q,0,[])}function j(q,P){for(var Q=Math.max(q.params.length,P.params.length),L=0;L<Q;L++){var se=S(q,L,!0),fe=S(P,L,!0);if(!xe(se,fe))return!1}var ge=q.params.length,pe=P.params.length,ve=g(q.params),Ne=g(P.params);return ve?Ne?ge===pe:pe>=ge:Ne?ge>=pe:ge===pe}function V(q,P){if(Object.keys(P).length===0)throw new SyntaxError("No signatures provided");var Q=[];Object.keys(P).map(function(ar){return N(ar,P[ar],s.conversions)}).filter(ne).forEach(function(ar){var Cr=F(Q,function(vt){return j(vt,ar)});if(Cr)throw new TypeError('Conflicting signatures "'+b(Cr.params)+'" and "'+b(ar.params)+'".');Q.push(ar)});var L=k(Q,function(ar){var Cr=ar?W(ar.params,!1):[];return Cr.map(function(vt){return{params:vt,fn:ar.fn}})}).filter(ne);L.sort(T);var se=L[0]&&L[0].params.length<=2&&!g(L[0].params),fe=L[1]&&L[1].params.length<=2&&!g(L[1].params),ge=L[2]&&L[2].params.length<=2&&!g(L[2].params),pe=L[3]&&L[3].params.length<=2&&!g(L[3].params),ve=L[4]&&L[4].params.length<=2&&!g(L[4].params),Ne=L[5]&&L[5].params.length<=2&&!g(L[5].params),Qe=se&&fe&&ge&&pe&&ve&&Ne,fr=L.map(function(ar){return d(ar.params)}),nr=se?x(L[0].params[0]):t,Wr=fe?x(L[1].params[0]):t,Lr=ge?x(L[2].params[0]):t,Ot=pe?x(L[3].params[0]):t,Ze=ve?x(L[4].params[0]):t,Pt=Ne?x(L[5].params[0]):t,C=se?x(L[0].params[1]):t,X=fe?x(L[1].params[1]):t,ae=ge?x(L[2].params[1]):t,he=pe?x(L[3].params[1]):t,qe=ve?x(L[4].params[1]):t,Ue=Ne?x(L[5].params[1]):t,gr=L.map(function(ar){return G(ar.params,ar.fn)}),no=se?gr[0]:r,J_=fe?gr[1]:r,Q_=ge?gr[2]:r,K_=pe?gr[3]:r,j_=ve?gr[4]:r,e$=Ne?gr[5]:r,r$=se?L[0].params.length:-1,t$=fe?L[1].params.length:-1,n$=ge?L[2].params.length:-1,a$=pe?L[3].params.length:-1,i$=ve?L[4].params.length:-1,o$=Ne?L[5].params.length:-1,s$=Qe?6:0,u$=L.length,c$=function(){for(var Cr=s$;Cr<u$;Cr++)if(fr[Cr](arguments))return gr[Cr].apply(this,arguments);return s.onMismatch(q,arguments,L)},ao=function ar(Cr,vt){return arguments.length===r$&&nr(Cr)&&C(vt)?no.apply(ar,arguments):arguments.length===t$&&Wr(Cr)&&X(vt)?J_.apply(ar,arguments):arguments.length===n$&&Lr(Cr)&&ae(vt)?Q_.apply(ar,arguments):arguments.length===a$&&Ot(Cr)&&he(vt)?K_.apply(ar,arguments):arguments.length===i$&&Ze(Cr)&&qe(vt)?j_.apply(ar,arguments):arguments.length===o$&&Pt(Cr)&&Ue(vt)?e$.apply(ar,arguments):c$.apply(ar,arguments)};try{Object.defineProperty(ao,"name",{value:q})}catch(ar){}return ao.signatures=H(L),ao}function K(q,P,Q){throw E(q,P,Q)}function te(q){return s.ignore.indexOf(q)===-1}function re(q){return q.trim()}function ie(q){return!!q}function ne(q){return q!==null}function ue(q){return q.types.length===0}function ee(q){return q.slice(0,q.length-1)}function ye(q){return q[q.length-1]}function we(q,P,Q){return Array.prototype.slice.call(q,P,Q)}function me(q,P){return q.indexOf(P)!==-1}function xe(q,P){for(var Q=0;Q<q.length;Q++)if(me(P,q[Q]))return!0;return!1}function F(q,P){for(var Q=0;Q<q.length;Q++)if(P(q[Q]))return q[Q]}function Y(q){for(var P={},Q=0;Q<q.length;Q++)P[q[Q]]=!0;return Object.keys(P)}function k(q,P){return Array.prototype.concat.apply([],q.map(P))}function U(q){for(var P="",Q=0;Q<q.length;Q++){var L=q[Q];if((typeof L.signatures=="object"||typeof L.signature=="string")&&L.name!==""){if(P==="")P=L.name;else if(P!==L.name){var se=new Error("Function names do not match (expected: "+P+", actual: "+L.name+")");throw se.data={actual:L.name,expected:P},se}}}return P}function J(q){var P,Q={};function L(pe,ve){if(Q.hasOwnProperty(pe)&&ve!==Q[pe])throw P=new Error('Signature "'+pe+'" is defined twice'),P.data={signature:pe},P}for(var se=0;se<q.length;se++){var fe=q[se];if(typeof fe.signatures=="object")for(var ge in fe.signatures)fe.signatures.hasOwnProperty(ge)&&(L(ge,fe.signatures[ge]),Q[ge]=fe.signatures[ge]);else if(typeof fe.signature=="string")L(fe.signature,fe),Q[fe.signature]=fe;else throw P=new TypeError("Function is no typed-function (index: "+se+")"),P.data={index:se},P}return Q}return s=V("typed",{"string, Object":V,Object:function(q){var P=[];for(var Q in q)q.hasOwnProperty(Q)&&P.push(q[Q]);var L=U(P);return V(L,q)},"...Function":function(q){return V(U(q),J(q))},"string, ...Function":function(q,P){return V(q,J(P))}}),s.create=i,s.types=l,s.conversions=c,s.ignore=f,s.onMismatch=K,s.throwMismatchError=K,s.createError=E,s.convert=h,s.find=v,s.addType=function(q,P){if(!q||typeof q.name!="string"||typeof q.test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");if(P!==!1){for(var Q=0;Q<s.types.length;Q++)if(s.types[Q].name==="Object"){s.types.splice(Q,0,q);return}}s.types.push(q)},s.addConversion=function(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");s.conversions.push(q)},s}return i()})}(ra)),ra.exports}var kp=Lp();const co=Bn(kp);function Ae(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Dt=Math.sign||function(e){return e>0?1:e<0?-1:0},Hp=Math.log2||function(n){return Math.log(n)/Math.LN2},Gp=Math.log10||function(n){return Math.log(n)/Math.LN10},Vp=Math.log1p||function(e){return Math.log(e+1)},Zp=Math.cbrt||function(n){if(n===0)return n;var a=n<0,t;return a&&(n=-n),isFinite(n)?(t=Math.exp(Math.log(n)/3),t=(n/(t*t)+2*t)/3):t=n,a?-t:t},Xp=Math.expm1||function(n){return n>=2e-4||n<=-2e-4?Math.exp(n)-1:n+n*n/2+n*n*n/6};function ei(e,n,a){var t={2:"0b",8:"0o",16:"0x"},r=t[n],i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e>en(2,a-1)-1||e<-en(2,a-1))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!Ae(e))throw new Error("Value must be an integer");e<0&&(e=e+en(2,a)),i="i".concat(a)}var l="";return e<0&&(e=-e,l="-"),"".concat(l).concat(r).concat(e.toString(n)).concat(i)}function Ht(e,n){if(typeof n=="function")return n(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var a="auto",t,r;if(n&&(n.notation&&(a=n.notation),$e(n)?t=n:$e(n.precision)&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return fo(e,t);case"exponential":return lo(e,t);case"engineering":return Yp(e,t);case"bin":return ei(e,2,r);case"oct":return ei(e,8,r);case"hex":return ei(e,16,r);case"auto":return Wp(e,t,n&&n).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],l=arguments[4];return i!=="."?i+l:l});default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ta(e){var n=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!n)throw new SyntaxError("Invalid number "+e);var a=n[1],t=n[2],r=parseFloat(n[4]||"0"),i=t.indexOf(".");r+=i!==-1?i-1:t.length-1;var l=t.replace(".","").replace(/^0*/,function(m){return r-=m.length,""}).replace(/0*$/,"").split("").map(function(m){return parseInt(m)});return l.length===0&&(l.push(0),r++),{sign:a,coefficients:l,exponent:r}}function Yp(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ta(e),t=na(a,n),r=t.exponent,i=t.coefficients,l=r%3===0?r:r<0?r-3-r%3:r-r%3;if($e(n))for(;n>i.length||r-l+1>i.length;)i.push(0);else for(var m=Math.abs(r-l)-(i.length-1),f=0;f<m;f++)i.push(0);for(var c=Math.abs(r-l),s=1;c>0;)s++,c--;var o=i.slice(s).join(""),u=$e(n)&&o.length||o.match(/[1-9]/)?"."+o:"",p=i.slice(0,s).join("")+u+"e"+(r>=0?"+":"")+l.toString();return t.sign+p}function fo(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ta(e),t=typeof n=="number"?na(a,a.exponent+1+n):a,r=t.coefficients,i=t.exponent+1,l=i+(n||0);return r.length<l&&(r=r.concat(nn(l-r.length))),i<0&&(r=nn(-i+1).concat(r),i=1),i<r.length&&r.splice(i,0,i===0?"0.":"."),t.sign+r.join("")}function lo(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ta(e),t=n?na(a,n):a,r=t.coefficients,i=t.exponent;r.length<n&&(r=r.concat(nn(n-r.length)));var l=r.shift();return t.sign+l+(r.length>0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i}function Wp(e,n,a){if(isNaN(e)||!isFinite(e))return String(e);var t=a&&a.lowerExp!==void 0?a.lowerExp:-3,r=a&&a.upperExp!==void 0?a.upperExp:5,i=ta(e),l=n?na(i,n):i;if(l.exponent<t||l.exponent>=r)return lo(e,n);var m=l.coefficients,f=l.exponent;m.length<n&&(m=m.concat(nn(n-m.length))),m=m.concat(nn(f-m.length+1+(m.length<n?n-m.length:0))),m=nn(-f).concat(m);var c=f>0?f:0;return c<m.length-1&&m.splice(c+1,0,"."),l.sign+m.join("")}function na(e,n){for(var a={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},t=a.coefficients;n<=0;)t.unshift(0),a.exponent++,n++;if(t.length>n){var r=t.splice(n,t.length-n);if(r[0]>=5){var i=n-1;for(t[i]++;t[i]===10;)t.pop(),i===0&&(t.unshift(0),a.exponent++,i++),i--,t[i]++}}return a}function nn(e){for(var n=[],a=0;a<e;a++)n.push(0);return n}function Jp(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Qp=Number.EPSILON||2220446049250313e-31;function Rr(e,n,a){if(a==null)return e===n;if(e===n)return!0;if(isNaN(e)||isNaN(n))return!1;if(isFinite(e)&&isFinite(n)){var t=Math.abs(e-n);return t<Qp?!0:t<=Math.max(Math.abs(e),Math.abs(n))*a}return!1}var Kp=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},jp=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},ev=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},rv=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},tv=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},nv=Math.tanh||function(e){var n=Math.exp(2*e);return(n-1)/(n+1)};function av(e,n){var a=!0,t=n>0?!0:n<0?!1:1/n===1/0;return a^t?-e:e}function ri(e,n,a){var t=e.constructor,r=new t(2),i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e.greaterThan(r.pow(a-1).sub(1))||e.lessThan(r.pow(a-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(a))),i="i".concat(a)}switch(n){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(n," not supported "))}}function iv(e,n){if(typeof n=="function")return n(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var a="auto",t,r;if(n!==void 0&&(n.notation&&(a=n.notation),typeof n=="number"?t=n:n.precision&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return sv(e,t);case"exponential":return mo(e,t);case"engineering":return ov(e,t);case"bin":return ri(e,2,r);case"oct":return ri(e,8,r);case"hex":return ri(e,16,r);case"auto":{var i=n&&n.lowerExp!==void 0?n.lowerExp:-3,l=n&&n.upperExp!==void 0?n.upperExp:5;if(e.isZero())return"0";var m,f=e.toSignificantDigits(t),c=f.e;return c>=i&&c<l?m=f.toFixed():m=mo(e,t),m.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],o=arguments[4];return s!=="."?s+o:o})}default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ov(e,n){var a=e.e,t=a%3===0?a:a<0?a-3-a%3:a-a%3,r=e.mul(Math.pow(10,-t)),i=r.toPrecision(n);return i.indexOf("e")!==-1&&(i=r.toString()),i+"e"+(a>=0?"+":"")+t.toString()}function mo(e,n){return n!==void 0?e.toExponential(n-1):e.toExponential()}function sv(e,n){return e.toFixed(n)}function uv(e,n){var a=e.length-n.length,t=e.length;return e.substring(a,t)===n}function Re(e,n){var a=cv(e,n);return n&&typeof n=="object"&&"truncate"in n&&a.length>n.truncate?a.substring(0,n.truncate-3)+"...":a}function cv(e,n){if(typeof e=="number")return Ht(e,n);if(Ie(e))return iv(e,n);if(fv(e))return!n||n.fraction!=="decimal"?e.s*e.n+"/"+e.d:e.toString();if(Array.isArray(e))return po(e,n);if(Br(e))return'"'+e+'"';if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(n);if(e&&e.toString(n)!=={}.toString())return e.toString(n);var a=Object.keys(e).map(t=>'"'+t+'": '+Re(e[t],n));return"{"+a.join(", ")+"}"}return String(e)}function aa(e){for(var n=String(e),a="",t=0;t<n.length;){var r=n.charAt(t);r==="\\"?(a+=r,t++,r=n.charAt(t),(r===""||'"\\/bfnrtu'.indexOf(r)===-1)&&(a+="\\"),a+=r):r==='"'?a+='\\"':a+=r,t++}return'"'+a+'"'}function Hr(e){var n=String(e);return n=n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n}function po(e,n){if(Array.isArray(e)){for(var a="[",t=e.length,r=0;r<t;r++)r!==0&&(a+=", "),a+=po(e[r],n);return a+="]",a}else return Re(e,n)}function fv(e){return e&&typeof e=="object"&&typeof e.s=="number"&&typeof e.n=="number"&&typeof e.d=="number"||!1}function an(e,n){if(!Br(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(e)+", index: 0)");if(!Br(n))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(n)+", index: 1)");return e===n?0:e>n?1:-1}function Fe(e,n,a){if(!(this instanceof Fe))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=n,this.relation=a,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(n)?"["+n.join(", ")+"]":n)+")",this.stack=new Error().stack}Fe.prototype=new RangeError,Fe.prototype.constructor=RangeError,Fe.prototype.name="DimensionError",Fe.prototype.isDimensionError=!0;function Jr(e,n,a){if(!(this instanceof Jr))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=n):(this.min=n,this.max=a),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}Jr.prototype=new RangeError,Jr.prototype.constructor=RangeError,Jr.prototype.name="IndexError",Jr.prototype.isIndexError=!0;function Pe(e){for(var n=[];Array.isArray(e);)n.push(e.length),e=e[0];return n}function vo(e,n,a){var t,r=e.length;if(r!==n[a])throw new Fe(r,n[a]);if(a<n.length-1){var i=a+1;for(t=0;t<r;t++){var l=e[t];if(!Array.isArray(l))throw new Fe(n.length-1,n.length,"<");vo(e[t],n,i)}}else for(t=0;t<r;t++)if(Array.isArray(e[t]))throw new Fe(n.length+1,n.length,">")}function ho(e,n){var a=n.length===0;if(a){if(Array.isArray(e))throw new Fe(e.length,0)}else vo(e,n,0)}function We(e,n){if(!$e(e)||!Ae(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof n=="number"&&e>=n)throw new Jr(e,n)}function on(e,n,a){if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Error("Resizing to scalar is not supported");n.forEach(function(r){if(!$e(r)||!Ae(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(n)+")")});var t=a!==void 0?a:0;return ti(e,n,0,t),e}function ti(e,n,a,t){var r,i,l=e.length,m=n[a],f=Math.min(l,m);if(e.length=m,a<n.length-1){var c=a+1;for(r=0;r<f;r++)i=e[r],Array.isArray(i)||(i=[i],e[r]=i),ti(i,n,c,t);for(r=f;r<m;r++)i=[],e[r]=i,ti(i,n,c,t)}else{for(r=0;r<f;r++)for(;Array.isArray(e[r]);)e[r]=e[r][0];for(r=f;r<m;r++)e[r]=t}}function go(e,n){var a=Le(e),t=a.length;if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Fe(0,t,"!=");n=ni(n,t);var r=yo(n);if(t!==r)throw new Fe(r,t,"!=");try{return lv(a,n)}catch(i){throw i instanceof Fe?new Fe(r,t,"!="):i}}function ni(e,n){var a=yo(e),t=e.slice(),r=-1,i=e.indexOf(r),l=e.indexOf(r,i+1)>=0;if(l)throw new Error("More than one wildcard in sizes");var m=i>=0,f=n%a===0;if(m)if(f)t[i]=-n/a;else throw new Error("Could not replace wildcard, since "+n+" is no multiple of "+-a);return t}function yo(e){return e.reduce((n,a)=>n*a,1)}function lv(e,n){for(var a=e,t,r=n.length-1;r>0;r--){var i=n[r];t=[];for(var l=a.length/i,m=0;m<l;m++)t.push(a.slice(m*i,(m+1)*i));a=t}return a}function ia(e,n){for(var a=Pe(e);Array.isArray(e)&&e.length===1;)e=e[0],a.shift();for(var t=a.length;a[t-1]===1;)t--;return t<a.length&&(e=xo(e,t,0),a.length=t),e}function xo(e,n,a){var t,r;if(a<n){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=xo(e[t],n,i)}else for(;Array.isArray(e);)e=e[0];return e}function bo(e,n,a,t){var r=t||Pe(e);if(a)for(var i=0;i<a;i++)e=[e],r.unshift(1);for(e=wo(e,n,0);r.length<n;)r.push(1);return e}function wo(e,n,a){var t,r;if(Array.isArray(e)){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=wo(e[t],n,i)}else for(var l=a;l<n;l++)e=[e];return e}function Le(e){if(!Array.isArray(e))return e;var n=[];return e.forEach(function a(t){Array.isArray(t)?t.forEach(a):n.push(t)}),n}function dt(e,n){return Array.prototype.map.call(e,n)}function oa(e,n){Array.prototype.forEach.call(e,n)}function No(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,n)}function sa(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,a=>n.test(a))}function Mo(e,n){return Array.prototype.join.call(e,n)}function sn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;var n=[],a=0;n[0]={value:e[0],identifier:0};for(var t=1;t<e.length;t++)e[t]===e[t-1]?a++:a=0,n.push({value:e[t],identifier:a});return n}function ua(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;for(var n=[],a=0;a<e.length;a++)n.push(e[a].value);return n}function _n(e,n){for(var a,t=0,r=0;r<e.length;r++){var i=e[r],l=Array.isArray(i);if(r===0&&l&&(t=i.length),l&&i.length!==t)return;var m=l?_n(i,n):n(i);if(a===void 0)a=m;else if(a!==m)return"mixed"}return a}function R(e,n,a,t){function r(i){var l=Rp(i,n.map(vv));return mv(e,n,i),a(l)}return r.isFactory=!0,r.fn=e,r.dependencies=n.slice().sort(),t&&(r.meta=t),r}function mv(e,n,a){var t=n.filter(i=>!pv(i)).every(i=>a[i]!==void 0);if(!t){var r=n.filter(i=>a[i]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function pv(e){return e&&e[0]==="?"}function vv(e){return e&&e[0]==="?"?e.slice(1):e}function Gr(e,n){if(Ao(e)&&ai(e,n))return e[n];throw typeof e[n]=="function"&&ii(e,n)?new Error('Cannot access method "'+n+'" as a property'):new Error('No access to property "'+n+'"')}function un(e,n,a){if(Ao(e)&&ai(e,n))return e[n]=a,a;throw new Error('No access to property "'+n+'"')}function hv(e,n){return n in e}function ai(e,n){return!e||typeof e!="object"?!1:Me(gv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function dv(e,n){if(!ii(e,n))throw new Error('No access to method "'+n+'"')}function ii(e,n){return e==null||typeof e[n]!="function"||Me(e,n)&&Object.getPrototypeOf&&n in Object.getPrototypeOf(e)?!1:Me(yv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function Ao(e){return typeof e=="object"&&e&&e.constructor===Object}var gv={length:!0,name:!0},yv={toString:!0,valueOf:!0,toLocaleString:!0};class oi{constructor(n){this.wrappedObject=n}keys(){return Object.keys(this.wrappedObject)}get(n){return Gr(this.wrappedObject,n)}set(n,a){return un(this.wrappedObject,n,a),this}has(n){return hv(this.wrappedObject,n)}}function gt(){return new Map}function si(e){if(!e)return gt();if(ca(e))return e;if(Qa(e))return new oi(e);throw new Error("createMap can create maps from objects or Maps")}function xv(e){if(e instanceof oi)return e.wrappedObject;var n={};for(var a of e.keys()){var t=e.get(a);un(n,a,t)}return n}function ca(e){return e?e instanceof Map||e instanceof oi||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function So(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];for(var r of a)if(r){if(ca(r))for(var i of r.keys())e.set(i,r.get(i));else if(Qa(r))for(var l of Object.keys(r))e.set(l,r[l])}return e}var Eo=function(){return Eo=co.create,co},bv=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],wv=R("typed",bv,function(n){var{BigNumber:a,Complex:t,DenseMatrix:r,Fraction:i}=n,l=Eo();return l.types=[{name:"number",test:$e},{name:"Complex",test:vr},{name:"BigNumber",test:Ie},{name:"Fraction",test:at},{name:"Unit",test:En},{name:"string",test:Br},{name:"Chain",test:Ka},{name:"Array",test:Xe},{name:"Matrix",test:Oe},{name:"DenseMatrix",test:Kn},{name:"SparseMatrix",test:Ut},{name:"Range",test:jn},{name:"Index",test:Cn},{name:"boolean",test:Ap},{name:"ResultSet",test:so},{name:"Help",test:Ja},{name:"function",test:Sp},{name:"Date",test:Ep},{name:"RegExp",test:Cp},{name:"null",test:Op},{name:"undefined",test:Dp},{name:"AccessorNode",test:Lt},{name:"ArrayNode",test:kr},{name:"AssignmentNode",test:Tp},{name:"BlockNode",test:Bp},{name:"ConditionalNode",test:_p},{name:"ConstantNode",test:Ye},{name:"FunctionNode",test:kt},{name:"FunctionAssignmentNode",test:On},{name:"IndexNode",test:tn},{name:"Node",test:Ve},{name:"ObjectNode",test:ea},{name:"OperatorNode",test:_r},{name:"ParenthesisNode",test:Dn},{name:"RangeNode",test:$p},{name:"SymbolNode",test:xr},{name:"Map",test:ca},{name:"Object",test:Qa}],l.conversions=[{from:"number",to:"BigNumber",convert:function(f){if(a||ui(f),Jp(f)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+f+"). Use function bignumber(x) to convert to BigNumber.");return new a(f)}},{from:"number",to:"Complex",convert:function(f){return t||fa(f),new t(f,0)}},{from:"number",to:"string",convert:function(f){return f+""}},{from:"BigNumber",to:"Complex",convert:function(f){return t||fa(f),new t(f.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(f){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(f){return t||fa(f),new t(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){i||ci(f);var c=new i(f);if(c.valueOf()!==f)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+f+"). Use function fraction(x) to convert to Fraction.");return c}},{from:"string",to:"number",convert:function(f){var c=Number(f);if(isNaN(c))throw new Error('Cannot convert "'+f+'" to a number');return c}},{from:"string",to:"BigNumber",convert:function(f){a||ui(f);try{return new a(f)}catch(c){throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){i||ci(f);try{return new i(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){t||fa(f);try{return new t(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Complex')}}},{from:"boolean",to:"number",convert:function(f){return+f}},{from:"boolean",to:"BigNumber",convert:function(f){return a||ui(f),new a(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return i||ci(f),new i(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return r||Nv(),new r(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}],l});function ui(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function fa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Nv(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function ci(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Mv="ResultSet",Av=[],Sv=R(Mv,Av,()=>{function e(n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=n||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(n){return new e(n.entries)},e},{isClass:!0});/*!
8
+ `);return Object.freeze(kr)};ar(oe,kr,{MATRIX_OPTIONS:Rp,NUMBER_OPTIONS:Fp});function Tn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function zp(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var n=e.default;if(typeof n=="function"){var a=function t(){var r=!1;try{r=this instanceof t}catch(i){}return r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};a.prototype=n.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),a}var ea={exports:{}},Pp=ea.exports,so;function Up(){return so||(so=1,function(e,n){(function(a,t){e.exports=t()})(Pp,function(){function a(){return!0}function t(){return!1}function r(){}function i(){var l=[{name:"number",test:function(q){return typeof q=="number"}},{name:"string",test:function(q){return typeof q=="string"}},{name:"boolean",test:function(q){return typeof q=="boolean"}},{name:"Function",test:function(q){return typeof q=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(q){return q instanceof Date}},{name:"RegExp",test:function(q){return q instanceof RegExp}},{name:"Object",test:function(q){return typeof q=="object"&&q!==null&&q.constructor===Object}},{name:"null",test:function(q){return q===null}},{name:"undefined",test:function(q){return q===void 0}}],m={name:"any",test:a},f=[],c=[],s={types:l,conversions:c,ignore:f};function o(q){var P=F(s.types,function(L){return L.name===q});if(P)return P;if(q==="any")return m;var Q=F(s.types,function(L){return L.name.toLowerCase()===q.toLowerCase()});throw new TypeError('Unknown type "'+q+'"'+(Q?'. Did you mean "'+Q.name+'"?':""))}function u(q){return q===m?999:s.types.indexOf(q)}function p(q){var P=F(s.types,function(Q){return Q.test(q)});if(P)return P.name;throw new TypeError("Value has unknown type. Value: "+q)}function v(q,P){if(!q.signatures)throw new TypeError("Function is no typed-function");var Q;if(typeof P=="string"){Q=P.split(",");for(var L=0;L<Q.length;L++)Q[L]=Q[L].trim()}else if(Array.isArray(P))Q=P;else throw new TypeError("String array or a comma separated string expected");var se=Q.join(","),fe=q.signatures[se];if(fe)return fe;throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+Q.join(", ")+"))")}function h(q,P){var Q=p(q);if(P===Q)return q;for(var L=0;L<s.conversions.length;L++){var se=s.conversions[L];if(se.from===Q&&se.to===P)return se.convert(q)}throw new Error("Cannot convert from "+Q+" to "+P)}function b(q){return q.map(function(P){var Q=P.types.map(O);return(P.restParam?"...":"")+Q.join("|")}).join(",")}function w(q,P){var Q=q.indexOf("...")===0,L=Q?q.length>3?q.slice(3):"any":q,se=L.split("|").map(re).filter(ie).filter(te),fe=B(P,se),ge=se.map(function(ve){var Ne=o(ve);return{name:ve,typeIndex:u(Ne),test:Ne.test,conversion:null,conversionIndex:-1}}),pe=fe.map(function(ve){var Ne=o(ve.from);return{name:ve.from,typeIndex:u(Ne),test:Ne.test,conversion:ve,conversionIndex:P.indexOf(ve)}});return{types:ge.concat(pe),restParam:Q}}function N(q,P,Q){var L=[];return q.trim()!==""&&(L=q.split(",").map(re).map(function(se,fe,ge){var pe=w(se,Q);if(pe.restParam&&fe!==ge.length-1)throw new SyntaxError('Unexpected rest parameter "'+se+'": only allowed for the last parameter');return pe})),L.some(ue)?null:{params:L,fn:P}}function g(q){var P=ye(q);return P?P.restParam:!1}function y(q){return q.types.some(function(P){return P.conversion!=null})}function x(q){if(!q||q.types.length===0)return a;if(q.types.length===1)return o(q.types[0].name).test;if(q.types.length===2){var P=o(q.types[0].name).test,Q=o(q.types[1].name).test;return function(fe){return P(fe)||Q(fe)}}else{var L=q.types.map(function(se){return o(se.name).test});return function(fe){for(var ge=0;ge<L.length;ge++)if(L[ge](fe))return!0;return!1}}}function d(q){var P,Q,L;if(g(q)){P=ee(q).map(x);var se=P.length,fe=x(ye(q)),ge=function(pe){for(var ve=se;ve<pe.length;ve++)if(!fe(pe[ve]))return!1;return!0};return function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ge(ve)&&ve.length>=se+1}}else return q.length===0?function(ve){return ve.length===0}:q.length===1?(Q=x(q[0]),function(ve){return Q(ve[0])&&ve.length===1}):q.length===2?(Q=x(q[0]),L=x(q[1]),function(ve){return Q(ve[0])&&L(ve[1])&&ve.length===2}):(P=q.map(x),function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ve.length===P.length})}function A(q,P){return P<q.params.length?q.params[P]:g(q.params)?ye(q.params):null}function S(q,P,Q){var L=A(q,P),se=L?Q?L.types.filter(M):L.types:[];return se.map(O)}function O(q){return q.name}function M(q){return q.conversion===null||q.conversion===void 0}function _(q,P){var Q=Y(k(q,function(L){return S(L,P,!1)}));return Q.indexOf("any")!==-1?["any"]:Q}function E(q,P,Q){var L,se,fe=q||"unnamed",ge=Q,pe;for(pe=0;pe<P.length;pe++){var ve=ge.filter(function(tr){var Jr=x(A(tr,pe));return(pe<tr.params.length||g(tr.params))&&Jr(P[pe])});if(ve.length===0){if(se=_(ge,pe),se.length>0){var Ne=p(P[pe]);return L=new TypeError("Unexpected type of argument in function "+fe+" (expected: "+se.join(" or ")+", actual: "+Ne+", index: "+pe+")"),L.data={category:"wrongType",fn:fe,index:pe,actual:Ne,expected:se},L}}else ge=ve}var Qe=ge.map(function(tr){return g(tr.params)?1/0:tr.params.length});if(P.length<Math.min.apply(null,Qe))return se=_(ge,pe),L=new TypeError("Too few arguments in function "+fe+" (expected: "+se.join(" or ")+", index: "+P.length+")"),L.data={category:"tooFewArgs",fn:fe,index:P.length,expected:se},L;var cr=Math.max.apply(null,Qe);return P.length>cr?(L=new TypeError("Too many arguments in function "+fe+" (expected: "+cr+", actual: "+P.length+")"),L.data={category:"tooManyArgs",fn:fe,index:P.length,expectedLength:cr},L):(L=new TypeError('Arguments of type "'+P.join(", ")+'" do not match any of the defined signatures of function '+fe+"."),L.data={category:"mismatch",actual:P.map(p)},L)}function $(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])&&(P=Math.min(P,q.types[Q].typeIndex));return P}function z(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])||(P=Math.min(P,q.types[Q].conversionIndex));return P}function I(q,P){var Q;return Q=q.restParam-P.restParam,Q!==0||(Q=y(q)-y(P),Q!==0)||(Q=$(q)-$(P),Q!==0)?Q:z(q)-z(P)}function T(q,P){var Q=Math.min(q.params.length,P.params.length),L,se;if(se=q.params.some(y)-P.params.some(y),se!==0)return se;for(L=0;L<Q;L++)if(se=y(q.params[L])-y(P.params[L]),se!==0)return se;for(L=0;L<Q;L++)if(se=I(q.params[L],P.params[L]),se!==0)return se;return q.params.length-P.params.length}function B(q,P){var Q={};return q.forEach(function(L){P.indexOf(L.from)===-1&&P.indexOf(L.to)!==-1&&!Q[L.from]&&(Q[L.from]=L)}),Object.keys(Q).map(function(L){return Q[L]})}function G(q,P){var Q=P;if(q.some(y)){var L=g(q),se=q.map(D);Q=function(){for(var ve=[],Ne=L?arguments.length-1:arguments.length,Qe=0;Qe<Ne;Qe++)ve[Qe]=se[Qe](arguments[Qe]);return L&&(ve[Ne]=arguments[Ne].map(se[Ne])),P.apply(this,ve)}}var fe=Q;if(g(q)){var ge=q.length-1;fe=function(){return Q.apply(this,we(arguments,0,ge).concat([we(arguments,ge)]))}}return fe}function D(q){var P,Q,L,se,fe=[],ge=[];switch(q.types.forEach(function(pe){pe.conversion&&(fe.push(o(pe.conversion.from).test),ge.push(pe.conversion.convert))}),ge.length){case 0:return function(ve){return ve};case 1:return P=fe[0],L=ge[0],function(ve){return P(ve)?L(ve):ve};case 2:return P=fe[0],Q=fe[1],L=ge[0],se=ge[1],function(ve){return P(ve)?L(ve):Q(ve)?se(ve):ve};default:return function(ve){for(var Ne=0;Ne<ge.length;Ne++)if(fe[Ne](ve))return ge[Ne](ve);return ve}}}function H(q){var P={};return q.forEach(function(Q){Q.params.some(y)||W(Q.params,!0).forEach(function(L){P[b(L)]=Q.fn})}),P}function W(q,P){function Q(L,se,fe){if(se<L.length){var ge=L[se],pe=P?ge.types.filter(M):ge.types,ve;if(ge.restParam){var Ne=pe.filter(M);ve=Ne.length<pe.length?[Ne,pe]:[pe]}else ve=pe.map(function(cr){return[cr]});return k(ve,function(cr){return Q(L,se+1,fe.concat([cr]))})}else{var Qe=fe.map(function(cr,tr){return{types:cr,restParam:tr===L.length-1&&g(L)}});return[Qe]}}return Q(q,0,[])}function j(q,P){for(var Q=Math.max(q.params.length,P.params.length),L=0;L<Q;L++){var se=S(q,L,!0),fe=S(P,L,!0);if(!xe(se,fe))return!1}var ge=q.params.length,pe=P.params.length,ve=g(q.params),Ne=g(P.params);return ve?Ne?ge===pe:pe>=ge:Ne?ge>=pe:ge===pe}function V(q,P){if(Object.keys(P).length===0)throw new SyntaxError("No signatures provided");var Q=[];Object.keys(P).map(function(nr){return N(nr,P[nr],s.conversions)}).filter(ne).forEach(function(nr){var Cr=F(Q,function(vt){return j(vt,nr)});if(Cr)throw new TypeError('Conflicting signatures "'+b(Cr.params)+'" and "'+b(nr.params)+'".');Q.push(nr)});var L=k(Q,function(nr){var Cr=nr?W(nr.params,!1):[];return Cr.map(function(vt){return{params:vt,fn:nr.fn}})}).filter(ne);L.sort(T);var se=L[0]&&L[0].params.length<=2&&!g(L[0].params),fe=L[1]&&L[1].params.length<=2&&!g(L[1].params),ge=L[2]&&L[2].params.length<=2&&!g(L[2].params),pe=L[3]&&L[3].params.length<=2&&!g(L[3].params),ve=L[4]&&L[4].params.length<=2&&!g(L[4].params),Ne=L[5]&&L[5].params.length<=2&&!g(L[5].params),Qe=se&&fe&&ge&&pe&&ve&&Ne,cr=L.map(function(nr){return d(nr.params)}),tr=se?x(L[0].params[0]):t,Jr=fe?x(L[1].params[0]):t,Lr=ge?x(L[2].params[0]):t,Ot=pe?x(L[3].params[0]):t,Ze=ve?x(L[4].params[0]):t,Pt=Ne?x(L[5].params[0]):t,C=se?x(L[0].params[1]):t,X=fe?x(L[1].params[1]):t,ae=ge?x(L[2].params[1]):t,he=pe?x(L[3].params[1]):t,qe=ve?x(L[4].params[1]):t,Ue=Ne?x(L[5].params[1]):t,dr=L.map(function(nr){return G(nr.params,nr.fn)}),to=se?dr[0]:r,W_=fe?dr[1]:r,J_=ge?dr[2]:r,Q_=pe?dr[3]:r,K_=ve?dr[4]:r,j_=Ne?dr[5]:r,e$=se?L[0].params.length:-1,r$=fe?L[1].params.length:-1,t$=ge?L[2].params.length:-1,n$=pe?L[3].params.length:-1,a$=ve?L[4].params.length:-1,i$=Ne?L[5].params.length:-1,o$=Qe?6:0,s$=L.length,u$=function(){for(var Cr=o$;Cr<s$;Cr++)if(cr[Cr](arguments))return dr[Cr].apply(this,arguments);return s.onMismatch(q,arguments,L)},no=function nr(Cr,vt){return arguments.length===e$&&tr(Cr)&&C(vt)?to.apply(nr,arguments):arguments.length===r$&&Jr(Cr)&&X(vt)?W_.apply(nr,arguments):arguments.length===t$&&Lr(Cr)&&ae(vt)?J_.apply(nr,arguments):arguments.length===n$&&Ot(Cr)&&he(vt)?Q_.apply(nr,arguments):arguments.length===a$&&Ze(Cr)&&qe(vt)?K_.apply(nr,arguments):arguments.length===i$&&Pt(Cr)&&Ue(vt)?j_.apply(nr,arguments):u$.apply(nr,arguments)};try{Object.defineProperty(no,"name",{value:q})}catch(nr){}return no.signatures=H(L),no}function K(q,P,Q){throw E(q,P,Q)}function te(q){return s.ignore.indexOf(q)===-1}function re(q){return q.trim()}function ie(q){return!!q}function ne(q){return q!==null}function ue(q){return q.types.length===0}function ee(q){return q.slice(0,q.length-1)}function ye(q){return q[q.length-1]}function we(q,P,Q){return Array.prototype.slice.call(q,P,Q)}function me(q,P){return q.indexOf(P)!==-1}function xe(q,P){for(var Q=0;Q<q.length;Q++)if(me(P,q[Q]))return!0;return!1}function F(q,P){for(var Q=0;Q<q.length;Q++)if(P(q[Q]))return q[Q]}function Y(q){for(var P={},Q=0;Q<q.length;Q++)P[q[Q]]=!0;return Object.keys(P)}function k(q,P){return Array.prototype.concat.apply([],q.map(P))}function U(q){for(var P="",Q=0;Q<q.length;Q++){var L=q[Q];if((typeof L.signatures=="object"||typeof L.signature=="string")&&L.name!==""){if(P==="")P=L.name;else if(P!==L.name){var se=new Error("Function names do not match (expected: "+P+", actual: "+L.name+")");throw se.data={actual:L.name,expected:P},se}}}return P}function J(q){var P,Q={};function L(pe,ve){if(Q.hasOwnProperty(pe)&&ve!==Q[pe])throw P=new Error('Signature "'+pe+'" is defined twice'),P.data={signature:pe},P}for(var se=0;se<q.length;se++){var fe=q[se];if(typeof fe.signatures=="object")for(var ge in fe.signatures)fe.signatures.hasOwnProperty(ge)&&(L(ge,fe.signatures[ge]),Q[ge]=fe.signatures[ge]);else if(typeof fe.signature=="string")L(fe.signature,fe),Q[fe.signature]=fe;else throw P=new TypeError("Function is no typed-function (index: "+se+")"),P.data={index:se},P}return Q}return s=V("typed",{"string, Object":V,Object:function(q){var P=[];for(var Q in q)q.hasOwnProperty(Q)&&P.push(q[Q]);var L=U(P);return V(L,q)},"...Function":function(q){return V(U(q),J(q))},"string, ...Function":function(q,P){return V(q,J(P))}}),s.create=i,s.types=l,s.conversions=c,s.ignore=f,s.onMismatch=K,s.throwMismatchError=K,s.createError=E,s.convert=h,s.find=v,s.addType=function(q,P){if(!q||typeof q.name!="string"||typeof q.test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");if(P!==!1){for(var Q=0;Q<s.types.length;Q++)if(s.types[Q].name==="Object"){s.types.splice(Q,0,q);return}}s.types.push(q)},s.addConversion=function(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");s.conversions.push(q)},s}return i()})}(ea)),ea.exports}var Lp=Up();const uo=Tn(Lp);function Ae(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Dt=Math.sign||function(e){return e>0?1:e<0?-1:0},kp=Math.log2||function(n){return Math.log(n)/Math.LN2},Hp=Math.log10||function(n){return Math.log(n)/Math.LN10},Gp=Math.log1p||function(e){return Math.log(e+1)},Vp=Math.cbrt||function(n){if(n===0)return n;var a=n<0,t;return a&&(n=-n),isFinite(n)?(t=Math.exp(Math.log(n)/3),t=(n/(t*t)+2*t)/3):t=n,a?-t:t},Zp=Math.expm1||function(n){return n>=2e-4||n<=-2e-4?Math.exp(n)-1:n+n*n/2+n*n*n/6};function ja(e,n,a){var t={2:"0b",8:"0o",16:"0x"},r=t[n],i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e>en(2,a-1)-1||e<-en(2,a-1))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!Ae(e))throw new Error("Value must be an integer");e<0&&(e=e+en(2,a)),i="i".concat(a)}var l="";return e<0&&(e=-e,l="-"),"".concat(l).concat(r).concat(e.toString(n)).concat(i)}function Ht(e,n){if(typeof n=="function")return n(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var a="auto",t,r;if(n&&(n.notation&&(a=n.notation),Be(n)?t=n:Be(n.precision)&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return co(e,t);case"exponential":return fo(e,t);case"engineering":return Xp(e,t);case"bin":return ja(e,2,r);case"oct":return ja(e,8,r);case"hex":return ja(e,16,r);case"auto":return Yp(e,t,n&&n).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],l=arguments[4];return i!=="."?i+l:l});default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ra(e){var n=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!n)throw new SyntaxError("Invalid number "+e);var a=n[1],t=n[2],r=parseFloat(n[4]||"0"),i=t.indexOf(".");r+=i!==-1?i-1:t.length-1;var l=t.replace(".","").replace(/^0*/,function(m){return r-=m.length,""}).replace(/0*$/,"").split("").map(function(m){return parseInt(m)});return l.length===0&&(l.push(0),r++),{sign:a,coefficients:l,exponent:r}}function Xp(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=ta(a,n),r=t.exponent,i=t.coefficients,l=r%3===0?r:r<0?r-3-r%3:r-r%3;if(Be(n))for(;n>i.length||r-l+1>i.length;)i.push(0);else for(var m=Math.abs(r-l)-(i.length-1),f=0;f<m;f++)i.push(0);for(var c=Math.abs(r-l),s=1;c>0;)s++,c--;var o=i.slice(s).join(""),u=Be(n)&&o.length||o.match(/[1-9]/)?"."+o:"",p=i.slice(0,s).join("")+u+"e"+(r>=0?"+":"")+l.toString();return t.sign+p}function co(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=typeof n=="number"?ta(a,a.exponent+1+n):a,r=t.coefficients,i=t.exponent+1,l=i+(n||0);return r.length<l&&(r=r.concat(nn(l-r.length))),i<0&&(r=nn(-i+1).concat(r),i=1),i<r.length&&r.splice(i,0,i===0?"0.":"."),t.sign+r.join("")}function fo(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=n?ta(a,n):a,r=t.coefficients,i=t.exponent;r.length<n&&(r=r.concat(nn(n-r.length)));var l=r.shift();return t.sign+l+(r.length>0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i}function Yp(e,n,a){if(isNaN(e)||!isFinite(e))return String(e);var t=a&&a.lowerExp!==void 0?a.lowerExp:-3,r=a&&a.upperExp!==void 0?a.upperExp:5,i=ra(e),l=n?ta(i,n):i;if(l.exponent<t||l.exponent>=r)return fo(e,n);var m=l.coefficients,f=l.exponent;m.length<n&&(m=m.concat(nn(n-m.length))),m=m.concat(nn(f-m.length+1+(m.length<n?n-m.length:0))),m=nn(-f).concat(m);var c=f>0?f:0;return c<m.length-1&&m.splice(c+1,0,"."),l.sign+m.join("")}function ta(e,n){for(var a={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},t=a.coefficients;n<=0;)t.unshift(0),a.exponent++,n++;if(t.length>n){var r=t.splice(n,t.length-n);if(r[0]>=5){var i=n-1;for(t[i]++;t[i]===10;)t.pop(),i===0&&(t.unshift(0),a.exponent++,i++),i--,t[i]++}}return a}function nn(e){for(var n=[],a=0;a<e;a++)n.push(0);return n}function Wp(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Jp=Number.EPSILON||2220446049250313e-31;function Rr(e,n,a){if(a==null)return e===n;if(e===n)return!0;if(isNaN(e)||isNaN(n))return!1;if(isFinite(e)&&isFinite(n)){var t=Math.abs(e-n);return t<Jp?!0:t<=Math.max(Math.abs(e),Math.abs(n))*a}return!1}var Qp=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Kp=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},jp=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},ev=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},rv=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},tv=Math.tanh||function(e){var n=Math.exp(2*e);return(n-1)/(n+1)};function nv(e,n){var a=!0,t=n>0?!0:n<0?!1:1/n===1/0;return a^t?-e:e}function ei(e,n,a){var t=e.constructor,r=new t(2),i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e.greaterThan(r.pow(a-1).sub(1))||e.lessThan(r.pow(a-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(a))),i="i".concat(a)}switch(n){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(n," not supported "))}}function av(e,n){if(typeof n=="function")return n(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var a="auto",t,r;if(n!==void 0&&(n.notation&&(a=n.notation),typeof n=="number"?t=n:n.precision&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return ov(e,t);case"exponential":return lo(e,t);case"engineering":return iv(e,t);case"bin":return ei(e,2,r);case"oct":return ei(e,8,r);case"hex":return ei(e,16,r);case"auto":{var i=n&&n.lowerExp!==void 0?n.lowerExp:-3,l=n&&n.upperExp!==void 0?n.upperExp:5;if(e.isZero())return"0";var m,f=e.toSignificantDigits(t),c=f.e;return c>=i&&c<l?m=f.toFixed():m=lo(e,t),m.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],o=arguments[4];return s!=="."?s+o:o})}default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function iv(e,n){var a=e.e,t=a%3===0?a:a<0?a-3-a%3:a-a%3,r=e.mul(Math.pow(10,-t)),i=r.toPrecision(n);return i.indexOf("e")!==-1&&(i=r.toString()),i+"e"+(a>=0?"+":"")+t.toString()}function lo(e,n){return n!==void 0?e.toExponential(n-1):e.toExponential()}function ov(e,n){return e.toFixed(n)}function sv(e,n){var a=e.length-n.length,t=e.length;return e.substring(a,t)===n}function Re(e,n){var a=uv(e,n);return n&&typeof n=="object"&&"truncate"in n&&a.length>n.truncate?a.substring(0,n.truncate-3)+"...":a}function uv(e,n){if(typeof e=="number")return Ht(e,n);if(_e(e))return av(e,n);if(cv(e))return!n||n.fraction!=="decimal"?e.s*e.n+"/"+e.d:e.toString();if(Array.isArray(e))return mo(e,n);if(_r(e))return'"'+e+'"';if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(n);if(e&&e.toString(n)!=={}.toString())return e.toString(n);var a=Object.keys(e).map(t=>'"'+t+'": '+Re(e[t],n));return"{"+a.join(", ")+"}"}return String(e)}function na(e){for(var n=String(e),a="",t=0;t<n.length;){var r=n.charAt(t);r==="\\"?(a+=r,t++,r=n.charAt(t),(r===""||'"\\/bfnrtu'.indexOf(r)===-1)&&(a+="\\"),a+=r):r==='"'?a+='\\"':a+=r,t++}return'"'+a+'"'}function Gr(e){var n=String(e);return n=n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n}function mo(e,n){if(Array.isArray(e)){for(var a="[",t=e.length,r=0;r<t;r++)r!==0&&(a+=", "),a+=mo(e[r],n);return a+="]",a}else return Re(e,n)}function cv(e){return e&&typeof e=="object"&&typeof e.s=="number"&&typeof e.n=="number"&&typeof e.d=="number"||!1}function an(e,n){if(!_r(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(e)+", index: 0)");if(!_r(n))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(n)+", index: 1)");return e===n?0:e>n?1:-1}function Fe(e,n,a){if(!(this instanceof Fe))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=n,this.relation=a,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(n)?"["+n.join(", ")+"]":n)+")",this.stack=new Error().stack}Fe.prototype=new RangeError,Fe.prototype.constructor=RangeError,Fe.prototype.name="DimensionError",Fe.prototype.isDimensionError=!0;function Kr(e,n,a){if(!(this instanceof Kr))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=n):(this.min=n,this.max=a),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}Kr.prototype=new RangeError,Kr.prototype.constructor=RangeError,Kr.prototype.name="IndexError",Kr.prototype.isIndexError=!0;function Pe(e){for(var n=[];Array.isArray(e);)n.push(e.length),e=e[0];return n}function po(e,n,a){var t,r=e.length;if(r!==n[a])throw new Fe(r,n[a]);if(a<n.length-1){var i=a+1;for(t=0;t<r;t++){var l=e[t];if(!Array.isArray(l))throw new Fe(n.length-1,n.length,"<");po(e[t],n,i)}}else for(t=0;t<r;t++)if(Array.isArray(e[t]))throw new Fe(n.length+1,n.length,">")}function vo(e,n){var a=n.length===0;if(a){if(Array.isArray(e))throw new Fe(e.length,0)}else po(e,n,0)}function We(e,n){if(!Be(e)||!Ae(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof n=="number"&&e>=n)throw new Kr(e,n)}function on(e,n,a){if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Error("Resizing to scalar is not supported");n.forEach(function(r){if(!Be(r)||!Ae(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(n)+")")});var t=a!==void 0?a:0;return ri(e,n,0,t),e}function ri(e,n,a,t){var r,i,l=e.length,m=n[a],f=Math.min(l,m);if(e.length=m,a<n.length-1){var c=a+1;for(r=0;r<f;r++)i=e[r],Array.isArray(i)||(i=[i],e[r]=i),ri(i,n,c,t);for(r=f;r<m;r++)i=[],e[r]=i,ri(i,n,c,t)}else{for(r=0;r<f;r++)for(;Array.isArray(e[r]);)e[r]=e[r][0];for(r=f;r<m;r++)e[r]=t}}function ho(e,n){var a=Le(e),t=a.length;if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Fe(0,t,"!=");n=ti(n,t);var r=go(n);if(t!==r)throw new Fe(r,t,"!=");try{return fv(a,n)}catch(i){throw i instanceof Fe?new Fe(r,t,"!="):i}}function ti(e,n){var a=go(e),t=e.slice(),r=-1,i=e.indexOf(r),l=e.indexOf(r,i+1)>=0;if(l)throw new Error("More than one wildcard in sizes");var m=i>=0,f=n%a===0;if(m)if(f)t[i]=-n/a;else throw new Error("Could not replace wildcard, since "+n+" is no multiple of "+-a);return t}function go(e){return e.reduce((n,a)=>n*a,1)}function fv(e,n){for(var a=e,t,r=n.length-1;r>0;r--){var i=n[r];t=[];for(var l=a.length/i,m=0;m<l;m++)t.push(a.slice(m*i,(m+1)*i));a=t}return a}function aa(e,n){for(var a=Pe(e);Array.isArray(e)&&e.length===1;)e=e[0],a.shift();for(var t=a.length;a[t-1]===1;)t--;return t<a.length&&(e=yo(e,t,0),a.length=t),e}function yo(e,n,a){var t,r;if(a<n){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=yo(e[t],n,i)}else for(;Array.isArray(e);)e=e[0];return e}function xo(e,n,a,t){var r=t||Pe(e);if(a)for(var i=0;i<a;i++)e=[e],r.unshift(1);for(e=bo(e,n,0);r.length<n;)r.push(1);return e}function bo(e,n,a){var t,r;if(Array.isArray(e)){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=bo(e[t],n,i)}else for(var l=a;l<n;l++)e=[e];return e}function Le(e){if(!Array.isArray(e))return e;var n=[];return e.forEach(function a(t){Array.isArray(t)?t.forEach(a):n.push(t)}),n}function dt(e,n){return Array.prototype.map.call(e,n)}function ia(e,n){Array.prototype.forEach.call(e,n)}function wo(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,n)}function oa(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,a=>n.test(a))}function No(e,n){return Array.prototype.join.call(e,n)}function sn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;var n=[],a=0;n[0]={value:e[0],identifier:0};for(var t=1;t<e.length;t++)e[t]===e[t-1]?a++:a=0,n.push({value:e[t],identifier:a});return n}function sa(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;for(var n=[],a=0;a<e.length;a++)n.push(e[a].value);return n}function Bn(e,n){for(var a,t=0,r=0;r<e.length;r++){var i=e[r],l=Array.isArray(i);if(r===0&&l&&(t=i.length),l&&i.length!==t)return;var m=l?Bn(i,n):n(i);if(a===void 0)a=m;else if(a!==m)return"mixed"}return a}function R(e,n,a,t){function r(i){var l=qp(i,n.map(pv));return lv(e,n,i),a(l)}return r.isFactory=!0,r.fn=e,r.dependencies=n.slice().sort(),t&&(r.meta=t),r}function lv(e,n,a){var t=n.filter(i=>!mv(i)).every(i=>a[i]!==void 0);if(!t){var r=n.filter(i=>a[i]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function mv(e){return e&&e[0]==="?"}function pv(e){return e&&e[0]==="?"?e.slice(1):e}function Vr(e,n){if(Mo(e)&&ni(e,n))return e[n];throw typeof e[n]=="function"&&ai(e,n)?new Error('Cannot access method "'+n+'" as a property'):new Error('No access to property "'+n+'"')}function un(e,n,a){if(Mo(e)&&ni(e,n))return e[n]=a,a;throw new Error('No access to property "'+n+'"')}function vv(e,n){return n in e}function ni(e,n){return!e||typeof e!="object"?!1:Me(dv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function hv(e,n){if(!ai(e,n))throw new Error('No access to method "'+n+'"')}function ai(e,n){return e==null||typeof e[n]!="function"||Me(e,n)&&Object.getPrototypeOf&&n in Object.getPrototypeOf(e)?!1:Me(gv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function Mo(e){return typeof e=="object"&&e&&e.constructor===Object}var dv={length:!0,name:!0},gv={toString:!0,valueOf:!0,toLocaleString:!0};class ii{constructor(n){this.wrappedObject=n}keys(){return Object.keys(this.wrappedObject)}get(n){return Vr(this.wrappedObject,n)}set(n,a){return un(this.wrappedObject,n,a),this}has(n){return vv(this.wrappedObject,n)}}function gt(){return new Map}function oi(e){if(!e)return gt();if(ua(e))return e;if(Ja(e))return new ii(e);throw new Error("createMap can create maps from objects or Maps")}function yv(e){if(e instanceof ii)return e.wrappedObject;var n={};for(var a of e.keys()){var t=e.get(a);un(n,a,t)}return n}function ua(e){return e?e instanceof Map||e instanceof ii||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function Ao(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];for(var r of a)if(r){if(ua(r))for(var i of r.keys())e.set(i,r.get(i));else if(Ja(r))for(var l of Object.keys(r))e.set(l,r[l])}return e}var So=function(){return So=uo.create,uo},xv=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],bv=R("typed",xv,function(n){var{BigNumber:a,Complex:t,DenseMatrix:r,Fraction:i}=n,l=So();return l.types=[{name:"number",test:Be},{name:"Complex",test:Or},{name:"BigNumber",test:_e},{name:"Fraction",test:yr},{name:"Unit",test:ht},{name:"string",test:_r},{name:"Chain",test:Qa},{name:"Array",test:Xe},{name:"Matrix",test:Oe},{name:"DenseMatrix",test:Qn},{name:"SparseMatrix",test:Ut},{name:"Range",test:Kn},{name:"Index",test:En},{name:"boolean",test:Mp},{name:"ResultSet",test:oo},{name:"Help",test:Wa},{name:"function",test:Ap},{name:"Date",test:Sp},{name:"RegExp",test:Ep},{name:"null",test:Cp},{name:"undefined",test:Op},{name:"AccessorNode",test:Lt},{name:"ArrayNode",test:Hr},{name:"AssignmentNode",test:Dp},{name:"BlockNode",test:Tp},{name:"ConditionalNode",test:Bp},{name:"ConstantNode",test:Ye},{name:"FunctionNode",test:kt},{name:"FunctionAssignmentNode",test:Cn},{name:"IndexNode",test:tn},{name:"Node",test:Ve},{name:"ObjectNode",test:jn},{name:"OperatorNode",test:$r},{name:"ParenthesisNode",test:On},{name:"RangeNode",test:_p},{name:"SymbolNode",test:xr},{name:"Map",test:ua},{name:"Object",test:Ja}],l.conversions=[{from:"number",to:"BigNumber",convert:function(f){if(a||si(f),Wp(f)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+f+"). Use function bignumber(x) to convert to BigNumber.");return new a(f)}},{from:"number",to:"Complex",convert:function(f){return t||ca(f),new t(f,0)}},{from:"number",to:"string",convert:function(f){return f+""}},{from:"BigNumber",to:"Complex",convert:function(f){return t||ca(f),new t(f.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(f){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(f){return t||ca(f),new t(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){i||ui(f);var c=new i(f);if(c.valueOf()!==f)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+f+"). Use function fraction(x) to convert to Fraction.");return c}},{from:"string",to:"number",convert:function(f){var c=Number(f);if(isNaN(c))throw new Error('Cannot convert "'+f+'" to a number');return c}},{from:"string",to:"BigNumber",convert:function(f){a||si(f);try{return new a(f)}catch(c){throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){i||ui(f);try{return new i(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){t||ca(f);try{return new t(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Complex')}}},{from:"boolean",to:"number",convert:function(f){return+f}},{from:"boolean",to:"BigNumber",convert:function(f){return a||si(f),new a(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return i||ui(f),new i(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return r||wv(),new r(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}],l});function si(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function ca(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function wv(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function ui(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Nv="ResultSet",Mv=[],Av=R(Nv,Mv,()=>{function e(n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=n||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(n){return new e(n.entries)},e},{isClass:!0});/*!
9
9
  * decimal.js v10.6.0
10
10
  * An arbitrary-precision Decimal type for JavaScript.
11
11
  * https://github.com/MikeMcl/decimal.js
12
12
  * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
13
13
  * MIT Licence
14
- */var cn=9e15,Tt=1e9,fi="0123456789abcdef",la="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ma="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",li={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-cn,maxE:cn,crypto:!1},Co,yt,Be=!0,pa="[DecimalError] ",Bt=pa+"Invalid argument: ",Oo=pa+"Precision limit exceeded",Do=pa+"crypto unavailable",To="[object Decimal]",Nr=Math.floor,dr=Math.pow,Ev=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Cv=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ov=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Bo=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Qr=1e7,De=7,Dv=9007199254740991,Tv=la.length-1,mi=ma.length-1,ce={toStringTag:To};ce.absoluteValue=ce.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Ee(e)},ce.ceil=function(){return Ee(new this.constructor(this),this.e+1,2)},ce.clampedTo=ce.clamp=function(e,n){var a,t=this,r=t.constructor;if(e=new r(e),n=new r(n),!e.s||!n.s)return new r(NaN);if(e.gt(n))throw Error(Bt+n);return a=t.cmp(e),a<0?e:t.cmp(n)>0?n:new r(t)},ce.comparedTo=ce.cmp=function(e){var n,a,t,r,i=this,l=i.d,m=(e=new i.constructor(e)).d,f=i.s,c=e.s;if(!l||!m)return!f||!c?NaN:f!==c?f:l===m?0:!l^f<0?1:-1;if(!l[0]||!m[0])return l[0]?f:m[0]?-c:0;if(f!==c)return f;if(i.e!==e.e)return i.e>e.e^f<0?1:-1;for(t=l.length,r=m.length,n=0,a=t<r?t:r;n<a;++n)if(l[n]!==m[n])return l[n]>m[n]^f<0?1:-1;return t===r?0:t>r^f<0?1:-1},ce.cosine=ce.cos=function(){var e,n,a=this,t=a.constructor;return a.d?a.d[0]?(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=Bv(t,Fo(t,a)),t.precision=e,t.rounding=n,Ee(yt==2||yt==3?a.neg():a,e,n,!0)):new t(1):new t(NaN)},ce.cubeRoot=ce.cbrt=function(){var e,n,a,t,r,i,l,m,f,c,s=this,o=s.constructor;if(!s.isFinite()||s.isZero())return new o(s);for(Be=!1,i=s.s*dr(s.s*s,1/3),!i||Math.abs(i)==1/0?(a=br(s.d),e=s.e,(i=(e-a.length+1)%3)&&(a+=i==1||i==-2?"0":"00"),i=dr(a,1/3),e=Nr((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?a="5e"+e:(a=i.toExponential(),a=a.slice(0,a.indexOf("e")+1)+e),t=new o(a),t.s=s.s):t=new o(i.toString()),l=(e=o.precision)+3;;)if(m=t,f=m.times(m).times(m),c=f.plus(s),t=er(c.plus(s).times(m),c.plus(f),l+2,1),br(m.d).slice(0,l)===(a=br(t.d)).slice(0,l))if(a=a.slice(l-3,l+1),a=="9999"||!r&&a=="4999"){if(!r&&(Ee(m,e+1,0),m.times(m).times(m).eq(s))){t=m;break}l+=4,r=1}else{(!+a||!+a.slice(1)&&a.charAt(0)=="5")&&(Ee(t,e+1,1),n=!t.times(t).times(t).eq(s));break}return Be=!0,Ee(t,e,o.rounding,n)},ce.decimalPlaces=ce.dp=function(){var e,n=this.d,a=NaN;if(n){if(e=n.length-1,a=(e-Nr(this.e/De))*De,e=n[e],e)for(;e%10==0;e/=10)a--;a<0&&(a=0)}return a},ce.dividedBy=ce.div=function(e){return er(this,new this.constructor(e))},ce.dividedToIntegerBy=ce.divToInt=function(e){var n=this,a=n.constructor;return Ee(er(n,new a(e),0,1,1),a.precision,a.rounding)},ce.equals=ce.eq=function(e){return this.cmp(e)===0},ce.floor=function(){return Ee(new this.constructor(this),this.e+1,3)},ce.greaterThan=ce.gt=function(e){return this.cmp(e)>0},ce.greaterThanOrEqualTo=ce.gte=function(e){var n=this.cmp(e);return n==1||n===0},ce.hyperbolicCosine=ce.cosh=function(){var e,n,a,t,r,i=this,l=i.constructor,m=new l(1);if(!i.isFinite())return new l(i.s?1/0:NaN);if(i.isZero())return m;a=l.precision,t=l.rounding,l.precision=a+Math.max(i.e,i.sd())+4,l.rounding=1,r=i.d.length,r<32?(e=Math.ceil(r/3),n=(1/ya(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i=fn(l,1,i.times(n),new l(1),!0);for(var f,c=e,s=new l(8);c--;)f=i.times(i),i=m.minus(f.times(s.minus(f.times(s))));return Ee(i,l.precision=a,l.rounding=t,!0)},ce.hyperbolicSine=ce.sinh=function(){var e,n,a,t,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(n=i.precision,a=i.rounding,i.precision=n+Math.max(r.e,r.sd())+4,i.rounding=1,t=r.d.length,t<3)r=fn(i,2,r,r,!0);else{e=1.4*Math.sqrt(t),e=e>16?16:e|0,r=r.times(1/ya(5,e)),r=fn(i,2,r,r,!0);for(var l,m=new i(5),f=new i(16),c=new i(20);e--;)l=r.times(r),r=r.times(m.plus(l.times(f.times(l).plus(c))))}return i.precision=n,i.rounding=a,Ee(r,n,a,!0)},ce.hyperbolicTangent=ce.tanh=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+7,t.rounding=1,er(a.sinh(),a.cosh(),t.precision=e,t.rounding=n)):new t(a.s)},ce.inverseCosine=ce.acos=function(){var e=this,n=e.constructor,a=e.abs().cmp(1),t=n.precision,r=n.rounding;return a!==-1?a===0?e.isNeg()?ot(n,t,r):new n(0):new n(NaN):e.isZero()?ot(n,t+4,r).times(.5):(n.precision=t+6,n.rounding=1,e=new n(1).minus(e).div(e.plus(1)).sqrt().atan(),n.precision=t,n.rounding=r,e.times(2))},ce.inverseHyperbolicCosine=ce.acosh=function(){var e,n,a=this,t=a.constructor;return a.lte(1)?new t(a.eq(1)?0:NaN):a.isFinite()?(e=t.precision,n=t.rounding,t.precision=e+Math.max(Math.abs(a.e),a.sd())+4,t.rounding=1,Be=!1,a=a.times(a).minus(1).sqrt().plus(a),Be=!0,t.precision=e,t.rounding=n,a.ln()):new t(a)},ce.inverseHyperbolicSine=ce.asinh=function(){var e,n,a=this,t=a.constructor;return!a.isFinite()||a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+2*Math.max(Math.abs(a.e),a.sd())+6,t.rounding=1,Be=!1,a=a.times(a).plus(1).sqrt().plus(a),Be=!0,t.precision=e,t.rounding=n,a.ln())},ce.inverseHyperbolicTangent=ce.atanh=function(){var e,n,a,t,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=i.precision,n=i.rounding,t=r.sd(),Math.max(t,e)<2*-r.e-1?Ee(new i(r),e,n,!0):(i.precision=a=t-r.e,r=er(r.plus(1),new i(1).minus(r),a+e,1),i.precision=e+4,i.rounding=1,r=r.ln(),i.precision=e,i.rounding=n,r.times(.5))):new i(NaN)},ce.inverseSine=ce.asin=function(){var e,n,a,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),a=i.precision,t=i.rounding,n!==-1?n===0?(e=ot(i,a+4,t).times(.5),e.s=r.s,e):new i(NaN):(i.precision=a+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=a,i.rounding=t,r.times(2)))},ce.inverseTangent=ce.atan=function(){var e,n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding;if(c.isFinite()){if(c.isZero())return new s(c);if(c.abs().eq(1)&&o+4<=mi)return l=ot(s,o+4,u).times(.25),l.s=c.s,l}else{if(!c.s)return new s(NaN);if(o+4<=mi)return l=ot(s,o+4,u).times(.5),l.s=c.s,l}for(s.precision=m=o+10,s.rounding=1,a=Math.min(28,m/De+2|0),e=a;e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(Be=!1,n=Math.ceil(m/De),t=1,f=c.times(c),l=new s(c),r=c;e!==-1;)if(r=r.times(f),i=l.minus(r.div(t+=2)),r=r.times(f),l=i.plus(r.div(t+=2)),l.d[n]!==void 0)for(e=n;l.d[e]===i.d[e]&&e--;);return a&&(l=l.times(2<<a-1)),Be=!0,Ee(l,s.precision=o,s.rounding=u,!0)},ce.isFinite=function(){return!!this.d},ce.isInteger=ce.isInt=function(){return!!this.d&&Nr(this.e/De)>this.d.length-2},ce.isNaN=function(){return!this.s},ce.isNegative=ce.isNeg=function(){return this.s<0},ce.isPositive=ce.isPos=function(){return this.s>0},ce.isZero=function(){return!!this.d&&this.d[0]===0},ce.lessThan=ce.lt=function(e){return this.cmp(e)<0},ce.lessThanOrEqualTo=ce.lte=function(e){return this.cmp(e)<1},ce.logarithm=ce.log=function(e){var n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding,p=5;if(e==null)e=new s(10),n=!0;else{if(e=new s(e),a=e.d,e.s<0||!a||!a[0]||e.eq(1))return new s(NaN);n=e.eq(10)}if(a=c.d,c.s<0||!a||!a[0]||c.eq(1))return new s(a&&!a[0]?-1/0:c.s!=1?NaN:a?0:1/0);if(n)if(a.length>1)i=!0;else{for(r=a[0];r%10===0;)r/=10;i=r!==1}if(Be=!1,m=o+p,l=$t(c,m),t=n?da(s,m+10):$t(e,m),f=er(l,t,m,1),$n(f.d,r=o,u))do if(m+=10,l=$t(c,m),t=n?da(s,m+10):$t(e,m),f=er(l,t,m,1),!i){+br(f.d).slice(r+1,r+15)+1==1e14&&(f=Ee(f,o+1,0));break}while($n(f.d,r+=10,u));return Be=!0,Ee(f,o,u)},ce.minus=ce.sub=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.constructor;if(e=new v(e),!p.d||!e.d)return!p.s||!e.s?e=new v(NaN):p.d?e.s=-e.s:e=new v(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,u=e.d,m=v.precision,f=v.rounding,!c[0]||!u[0]){if(u[0])e.s=-e.s;else if(c[0])e=new v(p);else return new v(f===3?-0:0);return Be?Ee(e,m,f):e}if(a=Nr(e.e/De),s=Nr(p.e/De),c=c.slice(),i=s-a,i){for(o=i<0,o?(n=c,i=-i,l=u.length):(n=u,a=s,l=c.length),t=Math.max(Math.ceil(m/De),l)+2,i>t&&(i=t,n.length=1),n.reverse(),t=i;t--;)n.push(0);n.reverse()}else{for(t=c.length,l=u.length,o=t<l,o&&(l=t),t=0;t<l;t++)if(c[t]!=u[t]){o=c[t]<u[t];break}i=0}for(o&&(n=c,c=u,u=n,e.s=-e.s),l=c.length,t=u.length-l;t>0;--t)c[l++]=0;for(t=u.length;t>i;){if(c[--t]<u[t]){for(r=t;r&&c[--r]===0;)c[r]=Qr-1;--c[r],c[t]+=Qr}c[t]-=u[t]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--a;return c[0]?(e.d=c,e.e=ha(c,a),Be?Ee(e,m,f):e):new v(f===3?-0:0)},ce.modulo=ce.mod=function(e){var n,a=this,t=a.constructor;return e=new t(e),!a.d||!e.s||e.d&&!e.d[0]?new t(NaN):!e.d||a.d&&!a.d[0]?Ee(new t(a),t.precision,t.rounding):(Be=!1,t.modulo==9?(n=er(a,e.abs(),0,3,1),n.s*=e.s):n=er(a,e,0,t.modulo,1),n=n.times(e),Be=!0,a.minus(n))},ce.naturalExponential=ce.exp=function(){return pi(this)},ce.naturalLogarithm=ce.ln=function(){return $t(this)},ce.negated=ce.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Ee(e)},ce.plus=ce.add=function(e){var n,a,t,r,i,l,m,f,c,s,o=this,u=o.constructor;if(e=new u(e),!o.d||!e.d)return!o.s||!e.s?e=new u(NaN):o.d||(e=new u(e.d||o.s===e.s?o:NaN)),e;if(o.s!=e.s)return e.s=-e.s,o.minus(e);if(c=o.d,s=e.d,m=u.precision,f=u.rounding,!c[0]||!s[0])return s[0]||(e=new u(o)),Be?Ee(e,m,f):e;if(i=Nr(o.e/De),t=Nr(e.e/De),c=c.slice(),r=i-t,r){for(r<0?(a=c,r=-r,l=s.length):(a=s,t=i,l=c.length),i=Math.ceil(m/De),l=i>l?i+1:l+1,r>l&&(r=l,a.length=1),a.reverse();r--;)a.push(0);a.reverse()}for(l=c.length,r=s.length,l-r<0&&(r=l,a=s,s=c,c=a),n=0;r;)n=(c[--r]=c[r]+s[r]+n)/Qr|0,c[r]%=Qr;for(n&&(c.unshift(n),++t),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=ha(c,t),Be?Ee(e,m,f):e},ce.precision=ce.sd=function(e){var n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Bt+e);return a.d?(n=_o(a.d),e&&a.e+1>n&&(n=a.e+1)):n=NaN,n},ce.round=function(){var e=this,n=e.constructor;return Ee(new n(e),e.e+1,n.rounding)},ce.sine=ce.sin=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=$v(t,Fo(t,a)),t.precision=e,t.rounding=n,Ee(yt>2?a.neg():a,e,n,!0)):new t(NaN)},ce.squareRoot=ce.sqrt=function(){var e,n,a,t,r,i,l=this,m=l.d,f=l.e,c=l.s,s=l.constructor;if(c!==1||!m||!m[0])return new s(!c||c<0&&(!m||m[0])?NaN:m?l:1/0);for(Be=!1,c=Math.sqrt(+l),c==0||c==1/0?(n=br(m),(n.length+f)%2==0&&(n+="0"),c=Math.sqrt(n),f=Nr((f+1)/2)-(f<0||f%2),c==1/0?n="5e"+f:(n=c.toExponential(),n=n.slice(0,n.indexOf("e")+1)+f),t=new s(n)):t=new s(c.toString()),a=(f=s.precision)+3;;)if(i=t,t=i.plus(er(l,i,a+2,1)).times(.5),br(i.d).slice(0,a)===(n=br(t.d)).slice(0,a))if(n=n.slice(a-3,a+1),n=="9999"||!r&&n=="4999"){if(!r&&(Ee(i,f+1,0),i.times(i).eq(l))){t=i;break}a+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(Ee(t,f+1,1),e=!t.times(t).eq(l));break}return Be=!0,Ee(t,f,s.rounding,e)},ce.tangent=ce.tan=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+10,t.rounding=1,a=a.sin(),a.s=1,a=er(a,new t(1).minus(a.times(a)).sqrt(),e+10,0),t.precision=e,t.rounding=n,Ee(yt==2||yt==4?a.neg():a,e,n,!0)):new t(NaN)},ce.times=ce.mul=function(e){var n,a,t,r,i,l,m,f,c,s=this,o=s.constructor,u=s.d,p=(e=new o(e)).d;if(e.s*=s.s,!u||!u[0]||!p||!p[0])return new o(!e.s||u&&!u[0]&&!p||p&&!p[0]&&!u?NaN:!u||!p?e.s/0:e.s*0);for(a=Nr(s.e/De)+Nr(e.e/De),f=u.length,c=p.length,f<c&&(i=u,u=p,p=i,l=f,f=c,c=l),i=[],l=f+c,t=l;t--;)i.push(0);for(t=c;--t>=0;){for(n=0,r=f+t;r>t;)m=i[r]+p[t]*u[r-t-1]+n,i[r--]=m%Qr|0,n=m/Qr|0;i[r]=(i[r]+n)%Qr|0}for(;!i[--l];)i.pop();return n?++a:i.shift(),e.d=i,e.e=ha(i,a),Be?Ee(e,o.precision,o.rounding):e},ce.toBinary=function(e,n){return vi(this,2,e,n)},ce.toDecimalPlaces=ce.toDP=function(e,n){var a=this,t=a.constructor;return a=new t(a),e===void 0?a:($r(e,0,Tt),n===void 0?n=t.rounding:$r(n,0,8),Ee(a,e+a.e+1,n))},ce.toExponential=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,!0):($r(e,0,Tt),n===void 0?n=r.rounding:$r(n,0,8),t=Ee(new r(t),e+1,n),a=it(t,!0,e+1)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toFixed=function(e,n){var a,t,r=this,i=r.constructor;return e===void 0?a=it(r):($r(e,0,Tt),n===void 0?n=i.rounding:$r(n,0,8),t=Ee(new i(r),e+r.e+1,n),a=it(t,!1,e+t.e+1)),r.isNeg()&&!r.isZero()?"-"+a:a},ce.toFraction=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.d,h=p.constructor;if(!v)return new h(p);if(c=a=new h(1),t=f=new h(0),n=new h(t),i=n.e=_o(v)-p.e-1,l=i%De,n.d[0]=dr(10,l<0?De+l:l),e==null)e=i>0?n:c;else{if(m=new h(e),!m.isInt()||m.lt(c))throw Error(Bt+m);e=m.gt(n)?i>0?n:c:m}for(Be=!1,m=new h(br(v)),s=h.precision,h.precision=i=v.length*De*2;o=er(m,n,0,1,1),r=a.plus(o.times(t)),r.cmp(e)!=1;)a=t,t=r,r=c,c=f.plus(o.times(r)),f=r,r=n,n=m.minus(o.times(r)),m=r;return r=er(e.minus(a),t,0,1,1),f=f.plus(r.times(c)),a=a.plus(r.times(t)),f.s=c.s=p.s,u=er(c,t,i,1).minus(p).abs().cmp(er(f,a,i,1).minus(p).abs())<1?[c,t]:[f,a],h.precision=s,Be=!0,u},ce.toHexadecimal=ce.toHex=function(e,n){return vi(this,16,e,n)},ce.toNearest=function(e,n){var a=this,t=a.constructor;if(a=new t(a),e==null){if(!a.d)return a;e=new t(1),n=t.rounding}else{if(e=new t(e),n===void 0?n=t.rounding:$r(n,0,8),!a.d)return e.s?a:e;if(!e.d)return e.s&&(e.s=a.s),e}return e.d[0]?(Be=!1,a=er(a,e,0,n,1).times(e),Be=!0,Ee(a)):(e.s=a.s,a=e),a},ce.toNumber=function(){return+this},ce.toOctal=function(e,n){return vi(this,8,e,n)},ce.toPower=ce.pow=function(e){var n,a,t,r,i,l,m=this,f=m.constructor,c=+(e=new f(e));if(!m.d||!e.d||!m.d[0]||!e.d[0])return new f(dr(+m,c));if(m=new f(m),m.eq(1))return m;if(t=f.precision,i=f.rounding,e.eq(1))return Ee(m,t,i);if(n=Nr(e.e/De),n>=e.d.length-1&&(a=c<0?-c:c)<=Dv)return r=$o(f,m,a,t),e.s<0?new f(1).div(r):Ee(r,t,i);if(l=m.s,l<0){if(n<e.d.length-1)return new f(NaN);if((e.d[n]&1)==0&&(l=1),m.e==0&&m.d[0]==1&&m.d.length==1)return m.s=l,m}return a=dr(+m,c),n=a==0||!isFinite(a)?Nr(c*(Math.log("0."+br(m.d))/Math.LN10+m.e+1)):new f(a+"").e,n>f.maxE+1||n<f.minE-1?new f(n>0?l/0:0):(Be=!1,f.rounding=m.s=1,a=Math.min(12,(n+"").length),r=pi(e.times($t(m,t+a)),t),r.d&&(r=Ee(r,t+5,1),$n(r.d,t,i)&&(n=t+10,r=Ee(pi(e.times($t(m,n+a)),n),n+5,1),+br(r.d).slice(t+1,t+15)+1==1e14&&(r=Ee(r,t+1,0)))),r.s=l,Be=!0,f.rounding=i,Ee(r,t,i))},ce.toPrecision=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):($r(e,1,Tt),n===void 0?n=r.rounding:$r(n,0,8),t=Ee(new r(t),e,n),a=it(t,e<=t.e||t.e<=r.toExpNeg,e)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toSignificantDigits=ce.toSD=function(e,n){var a=this,t=a.constructor;return e===void 0?(e=t.precision,n=t.rounding):($r(e,1,Tt),n===void 0?n=t.rounding:$r(n,0,8)),Ee(new t(a),e,n)},ce.toString=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+a:a},ce.truncated=ce.trunc=function(){return Ee(new this.constructor(this),this.e+1,1)},ce.valueOf=ce.toJSON=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+a:a};function br(e){var n,a,t,r=e.length-1,i="",l=e[0];if(r>0){for(i+=l,n=1;n<r;n++)t=e[n]+"",a=De-t.length,a&&(i+=_t(a)),i+=t;l=e[n],t=l+"",a=De-t.length,a&&(i+=_t(a))}else if(l===0)return"0";for(;l%10===0;)l/=10;return i+l}function $r(e,n,a){if(e!==~~e||e<n||e>a)throw Error(Bt+e)}function $n(e,n,a,t){var r,i,l,m;for(i=e[0];i>=10;i/=10)--n;return--n<0?(n+=De,r=0):(r=Math.ceil((n+1)/De),n%=De),i=dr(10,De-n),m=e[r]%i|0,t==null?n<3?(n==0?m=m/100|0:n==1&&(m=m/10|0),l=a<4&&m==99999||a>3&&m==49999||m==5e4||m==0):l=(a<4&&m+1==i||a>3&&m+1==i/2)&&(e[r+1]/i/100|0)==dr(10,n-2)-1||(m==i/2||m==0)&&(e[r+1]/i/100|0)==0:n<4?(n==0?m=m/1e3|0:n==1?m=m/100|0:n==2&&(m=m/10|0),l=(t||a<4)&&m==9999||!t&&a>3&&m==4999):l=((t||a<4)&&m+1==i||!t&&a>3&&m+1==i/2)&&(e[r+1]/i/1e3|0)==dr(10,n-3)-1,l}function va(e,n,a){for(var t,r=[0],i,l=0,m=e.length;l<m;){for(i=r.length;i--;)r[i]*=n;for(r[0]+=fi.indexOf(e.charAt(l++)),t=0;t<r.length;t++)r[t]>a-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/a|0,r[t]%=a)}return r.reverse()}function Bv(e,n){var a,t,r;if(n.isZero())return n;t=n.d.length,t<32?(a=Math.ceil(t/3),r=(1/ya(4,a)).toString()):(a=16,r="2.3283064365386962890625e-10"),e.precision+=a,n=fn(e,1,n.times(r),new e(1));for(var i=a;i--;){var l=n.times(n);n=l.times(l).minus(l).times(8).plus(1)}return e.precision-=a,n}var er=function(){function e(t,r,i){var l,m=0,f=t.length;for(t=t.slice();f--;)l=t[f]*r+m,t[f]=l%i|0,m=l/i|0;return m&&t.unshift(m),t}function n(t,r,i,l){var m,f;if(i!=l)f=i>l?1:-1;else for(m=f=0;m<i;m++)if(t[m]!=r[m]){f=t[m]>r[m]?1:-1;break}return f}function a(t,r,i,l){for(var m=0;i--;)t[i]-=m,m=t[i]<r[i]?1:0,t[i]=m*l+t[i]-r[i];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,i,l,m,f){var c,s,o,u,p,v,h,b,w,N,g,y,x,d,A,S,O,M,_,E,$=t.constructor,z=t.s==r.s?1:-1,I=t.d,T=r.d;if(!I||!I[0]||!T||!T[0])return new $(!t.s||!r.s||(I?T&&I[0]==T[0]:!T)?NaN:I&&I[0]==0||!T?z*0:z/0);for(f?(p=1,s=t.e-r.e):(f=Qr,p=De,s=Nr(t.e/p)-Nr(r.e/p)),_=T.length,O=I.length,w=new $(z),N=w.d=[],o=0;T[o]==(I[o]||0);o++);if(T[o]>(I[o]||0)&&s--,i==null?(d=i=$.precision,l=$.rounding):m?d=i+(t.e-r.e)+1:d=i,d<0)N.push(1),v=!0;else{if(d=d/p+2|0,o=0,_==1){for(u=0,T=T[0],d++;(o<O||u)&&d--;o++)A=u*f+(I[o]||0),N[o]=A/T|0,u=A%T|0;v=u||o<O}else{for(u=f/(T[0]+1)|0,u>1&&(T=e(T,u,f),I=e(I,u,f),_=T.length,O=I.length),S=_,g=I.slice(0,_),y=g.length;y<_;)g[y++]=0;E=T.slice(),E.unshift(0),M=T[0],T[1]>=f/2&&++M;do u=0,c=n(T,g,_,y),c<0?(x=g[0],_!=y&&(x=x*f+(g[1]||0)),u=x/M|0,u>1?(u>=f&&(u=f-1),h=e(T,u,f),b=h.length,y=g.length,c=n(h,g,b,y),c==1&&(u--,a(h,_<b?E:T,b,f))):(u==0&&(c=u=1),h=T.slice()),b=h.length,b<y&&h.unshift(0),a(g,h,y,f),c==-1&&(y=g.length,c=n(T,g,_,y),c<1&&(u++,a(g,_<y?E:T,y,f))),y=g.length):c===0&&(u++,g=[0]),N[o++]=u,c&&g[0]?g[y++]=I[S]||0:(g=[I[S]],y=1);while((S++<O||g[0]!==void 0)&&d--);v=g[0]!==void 0}N[0]||N.shift()}if(p==1)w.e=s,Co=v;else{for(o=1,u=N[0];u>=10;u/=10)o++;w.e=o+s*p-1,Ee(w,m?i+w.e+1:i,l,v)}return w}}();function Ee(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor;e:if(n!=null){if(o=e.d,!o)return e;for(r=1,m=o[0];m>=10;m/=10)r++;if(i=n-r,i<0)i+=De,l=n,s=o[u=0],f=s/dr(10,r-l-1)%10|0;else if(u=Math.ceil((i+1)/De),m=o.length,u>=m)if(t){for(;m++<=u;)o.push(0);s=f=0,r=1,i%=De,l=i-De+1}else break e;else{for(s=m=o[u],r=1;m>=10;m/=10)r++;i%=De,l=i-De+r,f=l<0?0:s/dr(10,r-l-1)%10|0}if(t=t||n<0||o[u+1]!==void 0||(l<0?s:s%dr(10,r-l-1)),c=a<4?(f||t)&&(a==0||a==(e.s<0?3:2)):f>5||f==5&&(a==4||t||a==6&&(i>0?l>0?s/dr(10,r-l):0:o[u-1])%10&1||a==(e.s<0?8:7)),n<1||!o[0])return o.length=0,c?(n-=e.e+1,o[0]=dr(10,(De-n%De)%De),e.e=-n||0):o[0]=e.e=0,e;if(i==0?(o.length=u,m=1,u--):(o.length=u+1,m=dr(10,De-i),o[u]=l>0?(s/dr(10,r-l)%dr(10,l)|0)*m:0),c)for(;;)if(u==0){for(i=1,l=o[0];l>=10;l/=10)i++;for(l=o[0]+=m,m=1;l>=10;l/=10)m++;i!=m&&(e.e++,o[0]==Qr&&(o[0]=1));break}else{if(o[u]+=m,o[u]!=Qr)break;o[u--]=0,m=1}for(i=o.length;o[--i]===0;)o.pop()}return Be&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function it(e,n,a){if(!e.isFinite())return Ro(e);var t,r=e.e,i=br(e.d),l=i.length;return n?(a&&(t=a-l)>0?i=i.charAt(0)+"."+i.slice(1)+_t(t):l>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):r<0?(i="0."+_t(-r-1)+i,a&&(t=a-l)>0&&(i+=_t(t))):r>=l?(i+=_t(r+1-l),a&&(t=a-r-1)>0&&(i=i+"."+_t(t))):((t=r+1)<l&&(i=i.slice(0,t)+"."+i.slice(t)),a&&(t=a-l)>0&&(r+1===l&&(i+="."),i+=_t(t))),i}function ha(e,n){var a=e[0];for(n*=De;a>=10;a/=10)n++;return n}function da(e,n,a){if(n>Tv)throw Be=!0,a&&(e.precision=a),Error(Oo);return Ee(new e(la),n,1,!0)}function ot(e,n,a){if(n>mi)throw Error(Oo);return Ee(new e(ma),n,a,!0)}function _o(e){var n=e.length-1,a=n*De+1;if(n=e[n],n){for(;n%10==0;n/=10)a--;for(n=e[0];n>=10;n/=10)a++}return a}function _t(e){for(var n="";e--;)n+="0";return n}function $o(e,n,a,t){var r,i=new e(1),l=Math.ceil(t/De+4);for(Be=!1;;){if(a%2&&(i=i.times(n),zo(i.d,l)&&(r=!0)),a=Nr(a/2),a===0){a=i.d.length-1,r&&i.d[a]===0&&++i.d[a];break}n=n.times(n),zo(n.d,l)}return Be=!0,i}function Io(e){return e.d[e.d.length-1]&1}function qo(e,n,a){for(var t,r,i=new e(n[0]),l=0;++l<n.length;){if(r=new e(n[l]),!r.s){i=r;break}t=i.cmp(r),(t===a||t===0&&i.s===a)&&(i=r)}return i}function pi(e,n){var a,t,r,i,l,m,f,c=0,s=0,o=0,u=e.constructor,p=u.rounding,v=u.precision;if(!e.d||!e.d[0]||e.e>17)return new u(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(n==null?(Be=!1,f=v):f=n,m=new u(.03125);e.e>-2;)e=e.times(m),o+=5;for(t=Math.log(dr(2,o))/Math.LN10*2+5|0,f+=t,a=i=l=new u(1),u.precision=f;;){if(i=Ee(i.times(e),f,1),a=a.times(++s),m=l.plus(er(i,a,f,1)),br(m.d).slice(0,f)===br(l.d).slice(0,f)){for(r=o;r--;)l=Ee(l.times(l),f,1);if(n==null)if(c<3&&$n(l.d,f-t,p,c))u.precision=f+=10,a=i=m=new u(1),s=0,c++;else return Ee(l,u.precision=v,p,Be=!0);else return u.precision=v,l}l=m}}function $t(e,n){var a,t,r,i,l,m,f,c,s,o,u,p=1,v=10,h=e,b=h.d,w=h.constructor,N=w.rounding,g=w.precision;if(h.s<0||!b||!b[0]||!h.e&&b[0]==1&&b.length==1)return new w(b&&!b[0]?-1/0:h.s!=1?NaN:b?0:h);if(n==null?(Be=!1,s=g):s=n,w.precision=s+=v,a=br(b),t=a.charAt(0),Math.abs(i=h.e)<15e14){for(;t<7&&t!=1||t==1&&a.charAt(1)>3;)h=h.times(e),a=br(h.d),t=a.charAt(0),p++;i=h.e,t>1?(h=new w("0."+a),i++):h=new w(t+"."+a.slice(1))}else return c=da(w,s+2,g).times(i+""),h=$t(new w(t+"."+a.slice(1)),s-v).plus(c),w.precision=g,n==null?Ee(h,g,N,Be=!0):h;for(o=h,f=l=h=er(h.minus(1),h.plus(1),s,1),u=Ee(h.times(h),s,1),r=3;;){if(l=Ee(l.times(u),s,1),c=f.plus(er(l,new w(r),s,1)),br(c.d).slice(0,s)===br(f.d).slice(0,s))if(f=f.times(2),i!==0&&(f=f.plus(da(w,s+2,g).times(i+""))),f=er(f,new w(p),s,1),n==null)if($n(f.d,s-v,N,m))w.precision=s+=v,c=l=h=er(o.minus(1),o.plus(1),s,1),u=Ee(h.times(h),s,1),r=m=1;else return Ee(f,w.precision=g,N,Be=!0);else return w.precision=g,f;f=c,r+=2}}function Ro(e){return String(e.s*e.s/0)}function ga(e,n){var a,t,r;for((a=n.indexOf("."))>-1&&(n=n.replace(".","")),(t=n.search(/e/i))>0?(a<0&&(a=t),a+=+n.slice(t+1),n=n.substring(0,t)):a<0&&(a=n.length),t=0;n.charCodeAt(t)===48;t++);for(r=n.length;n.charCodeAt(r-1)===48;--r);if(n=n.slice(t,r),n){if(r-=t,e.e=a=a-t-1,e.d=[],t=(a+1)%De,a<0&&(t+=De),t<r){for(t&&e.d.push(+n.slice(0,t)),r-=De;t<r;)e.d.push(+n.slice(t,t+=De));n=n.slice(t),t=De-n.length}else t-=r;for(;t--;)n+="0";e.d.push(+n),Be&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function _v(e,n){var a,t,r,i,l,m,f,c,s;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),Bo.test(n))return ga(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(Cv.test(n))a=16,n=n.toLowerCase();else if(Ev.test(n))a=2;else if(Ov.test(n))a=8;else throw Error(Bt+n);for(i=n.search(/p/i),i>0?(f=+n.slice(i+1),n=n.substring(2,i)):n=n.slice(2),i=n.indexOf("."),l=i>=0,t=e.constructor,l&&(n=n.replace(".",""),m=n.length,i=m-i,r=$o(t,new t(a),i,i*2)),c=va(n,a,Qr),s=c.length-1,i=s;c[i]===0;--i)c.pop();return i<0?new t(e.s*0):(e.e=ha(c,s),e.d=c,Be=!1,l&&(e=er(e,r,m*4)),f&&(e=e.times(Math.abs(f)<54?dr(2,f):It.pow(2,f))),Be=!0,e)}function $v(e,n){var a,t=n.d.length;if(t<3)return n.isZero()?n:fn(e,2,n,n);a=1.4*Math.sqrt(t),a=a>16?16:a|0,n=n.times(1/ya(5,a)),n=fn(e,2,n,n);for(var r,i=new e(5),l=new e(16),m=new e(20);a--;)r=n.times(n),n=n.times(i.plus(r.times(l.times(r).minus(m))));return n}function fn(e,n,a,t,r){var i,l,m,f,c=e.precision,s=Math.ceil(c/De);for(Be=!1,f=a.times(a),m=new e(t);;){if(l=er(m.times(f),new e(n++*n++),c,1),m=r?t.plus(l):t.minus(l),t=er(l.times(f),new e(n++*n++),c,1),l=m.plus(t),l.d[s]!==void 0){for(i=s;l.d[i]===m.d[i]&&i--;);if(i==-1)break}i=m,m=t,t=l,l=i}return Be=!0,l.d.length=s+1,l}function ya(e,n){for(var a=e;--n;)a*=e;return a}function Fo(e,n){var a,t=n.s<0,r=ot(e,e.precision,1),i=r.times(.5);if(n=n.abs(),n.lte(i))return yt=t?4:1,n;if(a=n.divToInt(r),a.isZero())yt=t?3:2;else{if(n=n.minus(a.times(r)),n.lte(i))return yt=Io(a)?t?2:3:t?4:1,n;yt=Io(a)?t?1:4:t?3:2}return n.minus(r).abs()}function vi(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor,v=a!==void 0;if(v?($r(a,1,Tt),t===void 0?t=p.rounding:$r(t,0,8)):(a=p.precision,t=p.rounding),!e.isFinite())s=Ro(e);else{for(s=it(e),l=s.indexOf("."),v?(r=2,n==16?a=a*4-3:n==8&&(a=a*3-2)):r=n,l>=0&&(s=s.replace(".",""),u=new p(1),u.e=s.length-l,u.d=va(it(u),10,r),u.e=u.d.length),o=va(s,10,r),i=f=o.length;o[--f]==0;)o.pop();if(!o[0])s=v?"0p+0":"0";else{if(l<0?i--:(e=new p(e),e.d=o,e.e=i,e=er(e,u,a,t,0,r),o=e.d,i=e.e,c=Co),l=o[a],m=r/2,c=c||o[a+1]!==void 0,c=t<4?(l!==void 0||c)&&(t===0||t===(e.s<0?3:2)):l>m||l===m&&(t===4||c||t===6&&o[a-1]&1||t===(e.s<0?8:7)),o.length=a,c)for(;++o[--a]>r-1;)o[a]=0,a||(++i,o.unshift(1));for(f=o.length;!o[f-1];--f);for(l=0,s="";l<f;l++)s+=fi.charAt(o[l]);if(v){if(f>1)if(n==16||n==8){for(l=n==16?4:3,--f;f%l;f++)s+="0";for(o=va(s,r,n),f=o.length;!o[f-1];--f);for(l=1,s="1.";l<f;l++)s+=fi.charAt(o[l])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>f)for(i-=f;i--;)s+="0";else i<f&&(s=s.slice(0,i)+"."+s.slice(i))}s=(n==16?"0x":n==2?"0b":n==8?"0o":"")+s}return e.s<0?"-"+s:s}function zo(e,n){if(e.length>n)return e.length=n,!0}function Iv(e){return new this(e).abs()}function qv(e){return new this(e).acos()}function Rv(e){return new this(e).acosh()}function Fv(e,n){return new this(e).plus(n)}function zv(e){return new this(e).asin()}function Pv(e){return new this(e).asinh()}function Uv(e){return new this(e).atan()}function Lv(e){return new this(e).atanh()}function kv(e,n){e=new this(e),n=new this(n);var a,t=this.precision,r=this.rounding,i=t+4;return!e.s||!n.s?a=new this(NaN):!e.d&&!n.d?(a=ot(this,i,1).times(n.s>0?.25:.75),a.s=e.s):!n.d||e.isZero()?(a=n.s<0?ot(this,t,r):new this(0),a.s=e.s):!e.d||n.isZero()?(a=ot(this,i,1).times(.5),a.s=e.s):n.s<0?(this.precision=i,this.rounding=1,a=this.atan(er(e,n,i,1)),n=ot(this,i,1),this.precision=t,this.rounding=r,a=e.s<0?a.minus(n):a.plus(n)):a=this.atan(er(e,n,i,1)),a}function Hv(e){return new this(e).cbrt()}function Gv(e){return Ee(e=new this(e),e.e+1,2)}function Vv(e,n,a){return new this(e).clamp(n,a)}function Zv(e){if(!e||typeof e!="object")throw Error(pa+"Object expected");var n,a,t,r=e.defaults===!0,i=["precision",1,Tt,"rounding",0,8,"toExpNeg",-cn,0,"toExpPos",0,cn,"maxE",0,cn,"minE",-cn,0,"modulo",0,9];for(n=0;n<i.length;n+=3)if(a=i[n],r&&(this[a]=li[a]),(t=e[a])!==void 0)if(Nr(t)===t&&t>=i[n+1]&&t<=i[n+2])this[a]=t;else throw Error(Bt+a+": "+t);if(a="crypto",r&&(this[a]=li[a]),(t=e[a])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[a]=!0;else throw Error(Do);else this[a]=!1;else throw Error(Bt+a+": "+t);return this}function Xv(e){return new this(e).cos()}function Yv(e){return new this(e).cosh()}function Po(e){var n,a,t;function r(i){var l,m,f,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Uo(i)){c.s=i.s,Be?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(f=typeof i,f==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(l=0,m=i;m>=10;m/=10)l++;Be?l>r.maxE?(c.e=NaN,c.d=null):l<r.minE?(c.e=0,c.d=[0]):(c.e=l,c.d=[i]):(c.e=l,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return ga(c,i.toString())}if(f==="string")return(m=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(m===43&&(i=i.slice(1)),c.s=1),Bo.test(i)?ga(c,i):_v(c,i);if(f==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,ga(c,i.toString());throw Error(Bt+i)}if(r.prototype=ce,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Zv,r.clone=Po,r.isDecimal=Uo,r.abs=Iv,r.acos=qv,r.acosh=Rv,r.add=Fv,r.asin=zv,r.asinh=Pv,r.atan=Uv,r.atanh=Lv,r.atan2=kv,r.cbrt=Hv,r.ceil=Gv,r.clamp=Vv,r.cos=Xv,r.cosh=Yv,r.div=Wv,r.exp=Jv,r.floor=Qv,r.hypot=Kv,r.ln=jv,r.log=eh,r.log10=th,r.log2=rh,r.max=nh,r.min=ah,r.mod=ih,r.mul=oh,r.pow=sh,r.random=uh,r.round=ch,r.sign=fh,r.sin=lh,r.sinh=mh,r.sqrt=ph,r.sub=vh,r.sum=hh,r.tan=dh,r.tanh=gh,r.trunc=yh,e===void 0&&(e={}),e&&e.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<t.length;)e.hasOwnProperty(a=t[n++])||(e[a]=this[a]);return r.config(e),r}function Wv(e,n){return new this(e).div(n)}function Jv(e){return new this(e).exp()}function Qv(e){return Ee(e=new this(e),e.e+1,3)}function Kv(){var e,n,a=new this(0);for(Be=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)a.d&&(a=a.plus(n.times(n)));else{if(n.s)return Be=!0,new this(1/0);a=n}return Be=!0,a.sqrt()}function Uo(e){return e instanceof It||e&&e.toStringTag===To||!1}function jv(e){return new this(e).ln()}function eh(e,n){return new this(e).log(n)}function rh(e){return new this(e).log(2)}function th(e){return new this(e).log(10)}function nh(){return qo(this,arguments,-1)}function ah(){return qo(this,arguments,1)}function ih(e,n){return new this(e).mod(n)}function oh(e,n){return new this(e).mul(n)}function sh(e,n){return new this(e).pow(n)}function uh(e){var n,a,t,r,i=0,l=new this(1),m=[];if(e===void 0?e=this.precision:$r(e,1,Tt),t=Math.ceil(e/De),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(t));i<t;)r=n[i],r>=429e7?n[i]=crypto.getRandomValues(new Uint32Array(1))[0]:m[i++]=r%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(t*=4);i<t;)r=n[i]+(n[i+1]<<8)+(n[i+2]<<16)+((n[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(n,i):(m.push(r%1e7),i+=4);i=t/4}else throw Error(Do);else for(;i<t;)m[i++]=Math.random()*1e7|0;for(t=m[--i],e%=De,t&&e&&(r=dr(10,De-e),m[i]=(t/r|0)*r);m[i]===0;i--)m.pop();if(i<0)a=0,m=[0];else{for(a=-1;m[0]===0;a-=De)m.shift();for(t=1,r=m[0];r>=10;r/=10)t++;t<De&&(a-=De-t)}return l.e=a,l.d=m,l}function ch(e){return Ee(e=new this(e),e.e+1,this.rounding)}function fh(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function lh(e){return new this(e).sin()}function mh(e){return new this(e).sinh()}function ph(e){return new this(e).sqrt()}function vh(e,n){return new this(e).sub(n)}function hh(){var e=0,n=arguments,a=new this(n[e]);for(Be=!1;a.s&&++e<n.length;)a=a.plus(n[e]);return Be=!0,Ee(a,this.precision,this.rounding)}function dh(e){return new this(e).tan()}function gh(e){return new this(e).tanh()}function yh(e){return Ee(e=new this(e),e.e+1,1)}ce[Symbol.for("nodejs.util.inspect.custom")]=ce.toString,ce[Symbol.toStringTag]="Decimal";var It=ce.constructor=Po(li);la=new It(la),ma=new It(ma);var xh="BigNumber",bh=["?on","config"],wh=R(xh,bh,e=>{var{on:n,config:a}=e,t=It.clone({precision:a.precision,modulo:It.EUCLID});return t.prototype=Object.create(t.prototype),t.prototype.type="BigNumber",t.prototype.isBigNumber=!0,t.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},t.fromJSON=function(r){return new t(r.value)},n&&n("config",function(r,i){r.precision!==i.precision&&t.config({precision:r.precision})}),t},{isClass:!0}),hi={exports:{}};/**
14
+ */var cn=9e15,Tt=1e9,ci="0123456789abcdef",fa="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",la="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",fi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-cn,maxE:cn,crypto:!1},Eo,yt,$e=!0,ma="[DecimalError] ",Bt=ma+"Invalid argument: ",Co=ma+"Precision limit exceeded",Oo=ma+"crypto unavailable",Do="[object Decimal]",Nr=Math.floor,hr=Math.pow,Sv=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ev=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Cv=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,To=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,De=7,Ov=9007199254740991,Dv=fa.length-1,li=la.length-1,ce={toStringTag:Do};ce.absoluteValue=ce.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Ee(e)},ce.ceil=function(){return Ee(new this.constructor(this),this.e+1,2)},ce.clampedTo=ce.clamp=function(e,n){var a,t=this,r=t.constructor;if(e=new r(e),n=new r(n),!e.s||!n.s)return new r(NaN);if(e.gt(n))throw Error(Bt+n);return a=t.cmp(e),a<0?e:t.cmp(n)>0?n:new r(t)},ce.comparedTo=ce.cmp=function(e){var n,a,t,r,i=this,l=i.d,m=(e=new i.constructor(e)).d,f=i.s,c=e.s;if(!l||!m)return!f||!c?NaN:f!==c?f:l===m?0:!l^f<0?1:-1;if(!l[0]||!m[0])return l[0]?f:m[0]?-c:0;if(f!==c)return f;if(i.e!==e.e)return i.e>e.e^f<0?1:-1;for(t=l.length,r=m.length,n=0,a=t<r?t:r;n<a;++n)if(l[n]!==m[n])return l[n]>m[n]^f<0?1:-1;return t===r?0:t>r^f<0?1:-1},ce.cosine=ce.cos=function(){var e,n,a=this,t=a.constructor;return a.d?a.d[0]?(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=Tv(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt==2||yt==3?a.neg():a,e,n,!0)):new t(1):new t(NaN)},ce.cubeRoot=ce.cbrt=function(){var e,n,a,t,r,i,l,m,f,c,s=this,o=s.constructor;if(!s.isFinite()||s.isZero())return new o(s);for($e=!1,i=s.s*hr(s.s*s,1/3),!i||Math.abs(i)==1/0?(a=br(s.d),e=s.e,(i=(e-a.length+1)%3)&&(a+=i==1||i==-2?"0":"00"),i=hr(a,1/3),e=Nr((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?a="5e"+e:(a=i.toExponential(),a=a.slice(0,a.indexOf("e")+1)+e),t=new o(a),t.s=s.s):t=new o(i.toString()),l=(e=o.precision)+3;;)if(m=t,f=m.times(m).times(m),c=f.plus(s),t=er(c.plus(s).times(m),c.plus(f),l+2,1),br(m.d).slice(0,l)===(a=br(t.d)).slice(0,l))if(a=a.slice(l-3,l+1),a=="9999"||!r&&a=="4999"){if(!r&&(Ee(m,e+1,0),m.times(m).times(m).eq(s))){t=m;break}l+=4,r=1}else{(!+a||!+a.slice(1)&&a.charAt(0)=="5")&&(Ee(t,e+1,1),n=!t.times(t).times(t).eq(s));break}return $e=!0,Ee(t,e,o.rounding,n)},ce.decimalPlaces=ce.dp=function(){var e,n=this.d,a=NaN;if(n){if(e=n.length-1,a=(e-Nr(this.e/De))*De,e=n[e],e)for(;e%10==0;e/=10)a--;a<0&&(a=0)}return a},ce.dividedBy=ce.div=function(e){return er(this,new this.constructor(e))},ce.dividedToIntegerBy=ce.divToInt=function(e){var n=this,a=n.constructor;return Ee(er(n,new a(e),0,1,1),a.precision,a.rounding)},ce.equals=ce.eq=function(e){return this.cmp(e)===0},ce.floor=function(){return Ee(new this.constructor(this),this.e+1,3)},ce.greaterThan=ce.gt=function(e){return this.cmp(e)>0},ce.greaterThanOrEqualTo=ce.gte=function(e){var n=this.cmp(e);return n==1||n===0},ce.hyperbolicCosine=ce.cosh=function(){var e,n,a,t,r,i=this,l=i.constructor,m=new l(1);if(!i.isFinite())return new l(i.s?1/0:NaN);if(i.isZero())return m;a=l.precision,t=l.rounding,l.precision=a+Math.max(i.e,i.sd())+4,l.rounding=1,r=i.d.length,r<32?(e=Math.ceil(r/3),n=(1/ga(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i=fn(l,1,i.times(n),new l(1),!0);for(var f,c=e,s=new l(8);c--;)f=i.times(i),i=m.minus(f.times(s.minus(f.times(s))));return Ee(i,l.precision=a,l.rounding=t,!0)},ce.hyperbolicSine=ce.sinh=function(){var e,n,a,t,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(n=i.precision,a=i.rounding,i.precision=n+Math.max(r.e,r.sd())+4,i.rounding=1,t=r.d.length,t<3)r=fn(i,2,r,r,!0);else{e=1.4*Math.sqrt(t),e=e>16?16:e|0,r=r.times(1/ga(5,e)),r=fn(i,2,r,r,!0);for(var l,m=new i(5),f=new i(16),c=new i(20);e--;)l=r.times(r),r=r.times(m.plus(l.times(f.times(l).plus(c))))}return i.precision=n,i.rounding=a,Ee(r,n,a,!0)},ce.hyperbolicTangent=ce.tanh=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+7,t.rounding=1,er(a.sinh(),a.cosh(),t.precision=e,t.rounding=n)):new t(a.s)},ce.inverseCosine=ce.acos=function(){var e=this,n=e.constructor,a=e.abs().cmp(1),t=n.precision,r=n.rounding;return a!==-1?a===0?e.isNeg()?ot(n,t,r):new n(0):new n(NaN):e.isZero()?ot(n,t+4,r).times(.5):(n.precision=t+6,n.rounding=1,e=new n(1).minus(e).div(e.plus(1)).sqrt().atan(),n.precision=t,n.rounding=r,e.times(2))},ce.inverseHyperbolicCosine=ce.acosh=function(){var e,n,a=this,t=a.constructor;return a.lte(1)?new t(a.eq(1)?0:NaN):a.isFinite()?(e=t.precision,n=t.rounding,t.precision=e+Math.max(Math.abs(a.e),a.sd())+4,t.rounding=1,$e=!1,a=a.times(a).minus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln()):new t(a)},ce.inverseHyperbolicSine=ce.asinh=function(){var e,n,a=this,t=a.constructor;return!a.isFinite()||a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+2*Math.max(Math.abs(a.e),a.sd())+6,t.rounding=1,$e=!1,a=a.times(a).plus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln())},ce.inverseHyperbolicTangent=ce.atanh=function(){var e,n,a,t,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=i.precision,n=i.rounding,t=r.sd(),Math.max(t,e)<2*-r.e-1?Ee(new i(r),e,n,!0):(i.precision=a=t-r.e,r=er(r.plus(1),new i(1).minus(r),a+e,1),i.precision=e+4,i.rounding=1,r=r.ln(),i.precision=e,i.rounding=n,r.times(.5))):new i(NaN)},ce.inverseSine=ce.asin=function(){var e,n,a,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),a=i.precision,t=i.rounding,n!==-1?n===0?(e=ot(i,a+4,t).times(.5),e.s=r.s,e):new i(NaN):(i.precision=a+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=a,i.rounding=t,r.times(2)))},ce.inverseTangent=ce.atan=function(){var e,n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding;if(c.isFinite()){if(c.isZero())return new s(c);if(c.abs().eq(1)&&o+4<=li)return l=ot(s,o+4,u).times(.25),l.s=c.s,l}else{if(!c.s)return new s(NaN);if(o+4<=li)return l=ot(s,o+4,u).times(.5),l.s=c.s,l}for(s.precision=m=o+10,s.rounding=1,a=Math.min(28,m/De+2|0),e=a;e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for($e=!1,n=Math.ceil(m/De),t=1,f=c.times(c),l=new s(c),r=c;e!==-1;)if(r=r.times(f),i=l.minus(r.div(t+=2)),r=r.times(f),l=i.plus(r.div(t+=2)),l.d[n]!==void 0)for(e=n;l.d[e]===i.d[e]&&e--;);return a&&(l=l.times(2<<a-1)),$e=!0,Ee(l,s.precision=o,s.rounding=u,!0)},ce.isFinite=function(){return!!this.d},ce.isInteger=ce.isInt=function(){return!!this.d&&Nr(this.e/De)>this.d.length-2},ce.isNaN=function(){return!this.s},ce.isNegative=ce.isNeg=function(){return this.s<0},ce.isPositive=ce.isPos=function(){return this.s>0},ce.isZero=function(){return!!this.d&&this.d[0]===0},ce.lessThan=ce.lt=function(e){return this.cmp(e)<0},ce.lessThanOrEqualTo=ce.lte=function(e){return this.cmp(e)<1},ce.logarithm=ce.log=function(e){var n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding,p=5;if(e==null)e=new s(10),n=!0;else{if(e=new s(e),a=e.d,e.s<0||!a||!a[0]||e.eq(1))return new s(NaN);n=e.eq(10)}if(a=c.d,c.s<0||!a||!a[0]||c.eq(1))return new s(a&&!a[0]?-1/0:c.s!=1?NaN:a?0:1/0);if(n)if(a.length>1)i=!0;else{for(r=a[0];r%10===0;)r/=10;i=r!==1}if($e=!1,m=o+p,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),_n(f.d,r=o,u))do if(m+=10,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),!i){+br(f.d).slice(r+1,r+15)+1==1e14&&(f=Ee(f,o+1,0));break}while(_n(f.d,r+=10,u));return $e=!0,Ee(f,o,u)},ce.minus=ce.sub=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.constructor;if(e=new v(e),!p.d||!e.d)return!p.s||!e.s?e=new v(NaN):p.d?e.s=-e.s:e=new v(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,u=e.d,m=v.precision,f=v.rounding,!c[0]||!u[0]){if(u[0])e.s=-e.s;else if(c[0])e=new v(p);else return new v(f===3?-0:0);return $e?Ee(e,m,f):e}if(a=Nr(e.e/De),s=Nr(p.e/De),c=c.slice(),i=s-a,i){for(o=i<0,o?(n=c,i=-i,l=u.length):(n=u,a=s,l=c.length),t=Math.max(Math.ceil(m/De),l)+2,i>t&&(i=t,n.length=1),n.reverse(),t=i;t--;)n.push(0);n.reverse()}else{for(t=c.length,l=u.length,o=t<l,o&&(l=t),t=0;t<l;t++)if(c[t]!=u[t]){o=c[t]<u[t];break}i=0}for(o&&(n=c,c=u,u=n,e.s=-e.s),l=c.length,t=u.length-l;t>0;--t)c[l++]=0;for(t=u.length;t>i;){if(c[--t]<u[t]){for(r=t;r&&c[--r]===0;)c[r]=jr-1;--c[r],c[t]+=jr}c[t]-=u[t]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--a;return c[0]?(e.d=c,e.e=va(c,a),$e?Ee(e,m,f):e):new v(f===3?-0:0)},ce.modulo=ce.mod=function(e){var n,a=this,t=a.constructor;return e=new t(e),!a.d||!e.s||e.d&&!e.d[0]?new t(NaN):!e.d||a.d&&!a.d[0]?Ee(new t(a),t.precision,t.rounding):($e=!1,t.modulo==9?(n=er(a,e.abs(),0,3,1),n.s*=e.s):n=er(a,e,0,t.modulo,1),n=n.times(e),$e=!0,a.minus(n))},ce.naturalExponential=ce.exp=function(){return mi(this)},ce.naturalLogarithm=ce.ln=function(){return $t(this)},ce.negated=ce.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Ee(e)},ce.plus=ce.add=function(e){var n,a,t,r,i,l,m,f,c,s,o=this,u=o.constructor;if(e=new u(e),!o.d||!e.d)return!o.s||!e.s?e=new u(NaN):o.d||(e=new u(e.d||o.s===e.s?o:NaN)),e;if(o.s!=e.s)return e.s=-e.s,o.minus(e);if(c=o.d,s=e.d,m=u.precision,f=u.rounding,!c[0]||!s[0])return s[0]||(e=new u(o)),$e?Ee(e,m,f):e;if(i=Nr(o.e/De),t=Nr(e.e/De),c=c.slice(),r=i-t,r){for(r<0?(a=c,r=-r,l=s.length):(a=s,t=i,l=c.length),i=Math.ceil(m/De),l=i>l?i+1:l+1,r>l&&(r=l,a.length=1),a.reverse();r--;)a.push(0);a.reverse()}for(l=c.length,r=s.length,l-r<0&&(r=l,a=s,s=c,c=a),n=0;r;)n=(c[--r]=c[r]+s[r]+n)/jr|0,c[r]%=jr;for(n&&(c.unshift(n),++t),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=va(c,t),$e?Ee(e,m,f):e},ce.precision=ce.sd=function(e){var n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Bt+e);return a.d?(n=Bo(a.d),e&&a.e+1>n&&(n=a.e+1)):n=NaN,n},ce.round=function(){var e=this,n=e.constructor;return Ee(new n(e),e.e+1,n.rounding)},ce.sine=ce.sin=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=_v(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt>2?a.neg():a,e,n,!0)):new t(NaN)},ce.squareRoot=ce.sqrt=function(){var e,n,a,t,r,i,l=this,m=l.d,f=l.e,c=l.s,s=l.constructor;if(c!==1||!m||!m[0])return new s(!c||c<0&&(!m||m[0])?NaN:m?l:1/0);for($e=!1,c=Math.sqrt(+l),c==0||c==1/0?(n=br(m),(n.length+f)%2==0&&(n+="0"),c=Math.sqrt(n),f=Nr((f+1)/2)-(f<0||f%2),c==1/0?n="5e"+f:(n=c.toExponential(),n=n.slice(0,n.indexOf("e")+1)+f),t=new s(n)):t=new s(c.toString()),a=(f=s.precision)+3;;)if(i=t,t=i.plus(er(l,i,a+2,1)).times(.5),br(i.d).slice(0,a)===(n=br(t.d)).slice(0,a))if(n=n.slice(a-3,a+1),n=="9999"||!r&&n=="4999"){if(!r&&(Ee(i,f+1,0),i.times(i).eq(l))){t=i;break}a+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(Ee(t,f+1,1),e=!t.times(t).eq(l));break}return $e=!0,Ee(t,f,s.rounding,e)},ce.tangent=ce.tan=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+10,t.rounding=1,a=a.sin(),a.s=1,a=er(a,new t(1).minus(a.times(a)).sqrt(),e+10,0),t.precision=e,t.rounding=n,Ee(yt==2||yt==4?a.neg():a,e,n,!0)):new t(NaN)},ce.times=ce.mul=function(e){var n,a,t,r,i,l,m,f,c,s=this,o=s.constructor,u=s.d,p=(e=new o(e)).d;if(e.s*=s.s,!u||!u[0]||!p||!p[0])return new o(!e.s||u&&!u[0]&&!p||p&&!p[0]&&!u?NaN:!u||!p?e.s/0:e.s*0);for(a=Nr(s.e/De)+Nr(e.e/De),f=u.length,c=p.length,f<c&&(i=u,u=p,p=i,l=f,f=c,c=l),i=[],l=f+c,t=l;t--;)i.push(0);for(t=c;--t>=0;){for(n=0,r=f+t;r>t;)m=i[r]+p[t]*u[r-t-1]+n,i[r--]=m%jr|0,n=m/jr|0;i[r]=(i[r]+n)%jr|0}for(;!i[--l];)i.pop();return n?++a:i.shift(),e.d=i,e.e=va(i,a),$e?Ee(e,o.precision,o.rounding):e},ce.toBinary=function(e,n){return pi(this,2,e,n)},ce.toDecimalPlaces=ce.toDP=function(e,n){var a=this,t=a.constructor;return a=new t(a),e===void 0?a:(Ir(e,0,Tt),n===void 0?n=t.rounding:Ir(n,0,8),Ee(a,e+a.e+1,n))},ce.toExponential=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,!0):(Ir(e,0,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e+1,n),a=it(t,!0,e+1)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toFixed=function(e,n){var a,t,r=this,i=r.constructor;return e===void 0?a=it(r):(Ir(e,0,Tt),n===void 0?n=i.rounding:Ir(n,0,8),t=Ee(new i(r),e+r.e+1,n),a=it(t,!1,e+t.e+1)),r.isNeg()&&!r.isZero()?"-"+a:a},ce.toFraction=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.d,h=p.constructor;if(!v)return new h(p);if(c=a=new h(1),t=f=new h(0),n=new h(t),i=n.e=Bo(v)-p.e-1,l=i%De,n.d[0]=hr(10,l<0?De+l:l),e==null)e=i>0?n:c;else{if(m=new h(e),!m.isInt()||m.lt(c))throw Error(Bt+m);e=m.gt(n)?i>0?n:c:m}for($e=!1,m=new h(br(v)),s=h.precision,h.precision=i=v.length*De*2;o=er(m,n,0,1,1),r=a.plus(o.times(t)),r.cmp(e)!=1;)a=t,t=r,r=c,c=f.plus(o.times(r)),f=r,r=n,n=m.minus(o.times(r)),m=r;return r=er(e.minus(a),t,0,1,1),f=f.plus(r.times(c)),a=a.plus(r.times(t)),f.s=c.s=p.s,u=er(c,t,i,1).minus(p).abs().cmp(er(f,a,i,1).minus(p).abs())<1?[c,t]:[f,a],h.precision=s,$e=!0,u},ce.toHexadecimal=ce.toHex=function(e,n){return pi(this,16,e,n)},ce.toNearest=function(e,n){var a=this,t=a.constructor;if(a=new t(a),e==null){if(!a.d)return a;e=new t(1),n=t.rounding}else{if(e=new t(e),n===void 0?n=t.rounding:Ir(n,0,8),!a.d)return e.s?a:e;if(!e.d)return e.s&&(e.s=a.s),e}return e.d[0]?($e=!1,a=er(a,e,0,n,1).times(e),$e=!0,Ee(a)):(e.s=a.s,a=e),a},ce.toNumber=function(){return+this},ce.toOctal=function(e,n){return pi(this,8,e,n)},ce.toPower=ce.pow=function(e){var n,a,t,r,i,l,m=this,f=m.constructor,c=+(e=new f(e));if(!m.d||!e.d||!m.d[0]||!e.d[0])return new f(hr(+m,c));if(m=new f(m),m.eq(1))return m;if(t=f.precision,i=f.rounding,e.eq(1))return Ee(m,t,i);if(n=Nr(e.e/De),n>=e.d.length-1&&(a=c<0?-c:c)<=Ov)return r=_o(f,m,a,t),e.s<0?new f(1).div(r):Ee(r,t,i);if(l=m.s,l<0){if(n<e.d.length-1)return new f(NaN);if((e.d[n]&1)==0&&(l=1),m.e==0&&m.d[0]==1&&m.d.length==1)return m.s=l,m}return a=hr(+m,c),n=a==0||!isFinite(a)?Nr(c*(Math.log("0."+br(m.d))/Math.LN10+m.e+1)):new f(a+"").e,n>f.maxE+1||n<f.minE-1?new f(n>0?l/0:0):($e=!1,f.rounding=m.s=1,a=Math.min(12,(n+"").length),r=mi(e.times($t(m,t+a)),t),r.d&&(r=Ee(r,t+5,1),_n(r.d,t,i)&&(n=t+10,r=Ee(mi(e.times($t(m,n+a)),n),n+5,1),+br(r.d).slice(t+1,t+15)+1==1e14&&(r=Ee(r,t+1,0)))),r.s=l,$e=!0,f.rounding=i,Ee(r,t,i))},ce.toPrecision=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(Ir(e,1,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e,n),a=it(t,e<=t.e||t.e<=r.toExpNeg,e)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toSignificantDigits=ce.toSD=function(e,n){var a=this,t=a.constructor;return e===void 0?(e=t.precision,n=t.rounding):(Ir(e,1,Tt),n===void 0?n=t.rounding:Ir(n,0,8)),Ee(new t(a),e,n)},ce.toString=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+a:a},ce.truncated=ce.trunc=function(){return Ee(new this.constructor(this),this.e+1,1)},ce.valueOf=ce.toJSON=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+a:a};function br(e){var n,a,t,r=e.length-1,i="",l=e[0];if(r>0){for(i+=l,n=1;n<r;n++)t=e[n]+"",a=De-t.length,a&&(i+=_t(a)),i+=t;l=e[n],t=l+"",a=De-t.length,a&&(i+=_t(a))}else if(l===0)return"0";for(;l%10===0;)l/=10;return i+l}function Ir(e,n,a){if(e!==~~e||e<n||e>a)throw Error(Bt+e)}function _n(e,n,a,t){var r,i,l,m;for(i=e[0];i>=10;i/=10)--n;return--n<0?(n+=De,r=0):(r=Math.ceil((n+1)/De),n%=De),i=hr(10,De-n),m=e[r]%i|0,t==null?n<3?(n==0?m=m/100|0:n==1&&(m=m/10|0),l=a<4&&m==99999||a>3&&m==49999||m==5e4||m==0):l=(a<4&&m+1==i||a>3&&m+1==i/2)&&(e[r+1]/i/100|0)==hr(10,n-2)-1||(m==i/2||m==0)&&(e[r+1]/i/100|0)==0:n<4?(n==0?m=m/1e3|0:n==1?m=m/100|0:n==2&&(m=m/10|0),l=(t||a<4)&&m==9999||!t&&a>3&&m==4999):l=((t||a<4)&&m+1==i||!t&&a>3&&m+1==i/2)&&(e[r+1]/i/1e3|0)==hr(10,n-3)-1,l}function pa(e,n,a){for(var t,r=[0],i,l=0,m=e.length;l<m;){for(i=r.length;i--;)r[i]*=n;for(r[0]+=ci.indexOf(e.charAt(l++)),t=0;t<r.length;t++)r[t]>a-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/a|0,r[t]%=a)}return r.reverse()}function Tv(e,n){var a,t,r;if(n.isZero())return n;t=n.d.length,t<32?(a=Math.ceil(t/3),r=(1/ga(4,a)).toString()):(a=16,r="2.3283064365386962890625e-10"),e.precision+=a,n=fn(e,1,n.times(r),new e(1));for(var i=a;i--;){var l=n.times(n);n=l.times(l).minus(l).times(8).plus(1)}return e.precision-=a,n}var er=function(){function e(t,r,i){var l,m=0,f=t.length;for(t=t.slice();f--;)l=t[f]*r+m,t[f]=l%i|0,m=l/i|0;return m&&t.unshift(m),t}function n(t,r,i,l){var m,f;if(i!=l)f=i>l?1:-1;else for(m=f=0;m<i;m++)if(t[m]!=r[m]){f=t[m]>r[m]?1:-1;break}return f}function a(t,r,i,l){for(var m=0;i--;)t[i]-=m,m=t[i]<r[i]?1:0,t[i]=m*l+t[i]-r[i];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,i,l,m,f){var c,s,o,u,p,v,h,b,w,N,g,y,x,d,A,S,O,M,_,E,$=t.constructor,z=t.s==r.s?1:-1,I=t.d,T=r.d;if(!I||!I[0]||!T||!T[0])return new $(!t.s||!r.s||(I?T&&I[0]==T[0]:!T)?NaN:I&&I[0]==0||!T?z*0:z/0);for(f?(p=1,s=t.e-r.e):(f=jr,p=De,s=Nr(t.e/p)-Nr(r.e/p)),_=T.length,O=I.length,w=new $(z),N=w.d=[],o=0;T[o]==(I[o]||0);o++);if(T[o]>(I[o]||0)&&s--,i==null?(d=i=$.precision,l=$.rounding):m?d=i+(t.e-r.e)+1:d=i,d<0)N.push(1),v=!0;else{if(d=d/p+2|0,o=0,_==1){for(u=0,T=T[0],d++;(o<O||u)&&d--;o++)A=u*f+(I[o]||0),N[o]=A/T|0,u=A%T|0;v=u||o<O}else{for(u=f/(T[0]+1)|0,u>1&&(T=e(T,u,f),I=e(I,u,f),_=T.length,O=I.length),S=_,g=I.slice(0,_),y=g.length;y<_;)g[y++]=0;E=T.slice(),E.unshift(0),M=T[0],T[1]>=f/2&&++M;do u=0,c=n(T,g,_,y),c<0?(x=g[0],_!=y&&(x=x*f+(g[1]||0)),u=x/M|0,u>1?(u>=f&&(u=f-1),h=e(T,u,f),b=h.length,y=g.length,c=n(h,g,b,y),c==1&&(u--,a(h,_<b?E:T,b,f))):(u==0&&(c=u=1),h=T.slice()),b=h.length,b<y&&h.unshift(0),a(g,h,y,f),c==-1&&(y=g.length,c=n(T,g,_,y),c<1&&(u++,a(g,_<y?E:T,y,f))),y=g.length):c===0&&(u++,g=[0]),N[o++]=u,c&&g[0]?g[y++]=I[S]||0:(g=[I[S]],y=1);while((S++<O||g[0]!==void 0)&&d--);v=g[0]!==void 0}N[0]||N.shift()}if(p==1)w.e=s,Eo=v;else{for(o=1,u=N[0];u>=10;u/=10)o++;w.e=o+s*p-1,Ee(w,m?i+w.e+1:i,l,v)}return w}}();function Ee(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor;e:if(n!=null){if(o=e.d,!o)return e;for(r=1,m=o[0];m>=10;m/=10)r++;if(i=n-r,i<0)i+=De,l=n,s=o[u=0],f=s/hr(10,r-l-1)%10|0;else if(u=Math.ceil((i+1)/De),m=o.length,u>=m)if(t){for(;m++<=u;)o.push(0);s=f=0,r=1,i%=De,l=i-De+1}else break e;else{for(s=m=o[u],r=1;m>=10;m/=10)r++;i%=De,l=i-De+r,f=l<0?0:s/hr(10,r-l-1)%10|0}if(t=t||n<0||o[u+1]!==void 0||(l<0?s:s%hr(10,r-l-1)),c=a<4?(f||t)&&(a==0||a==(e.s<0?3:2)):f>5||f==5&&(a==4||t||a==6&&(i>0?l>0?s/hr(10,r-l):0:o[u-1])%10&1||a==(e.s<0?8:7)),n<1||!o[0])return o.length=0,c?(n-=e.e+1,o[0]=hr(10,(De-n%De)%De),e.e=-n||0):o[0]=e.e=0,e;if(i==0?(o.length=u,m=1,u--):(o.length=u+1,m=hr(10,De-i),o[u]=l>0?(s/hr(10,r-l)%hr(10,l)|0)*m:0),c)for(;;)if(u==0){for(i=1,l=o[0];l>=10;l/=10)i++;for(l=o[0]+=m,m=1;l>=10;l/=10)m++;i!=m&&(e.e++,o[0]==jr&&(o[0]=1));break}else{if(o[u]+=m,o[u]!=jr)break;o[u--]=0,m=1}for(i=o.length;o[--i]===0;)o.pop()}return $e&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function it(e,n,a){if(!e.isFinite())return qo(e);var t,r=e.e,i=br(e.d),l=i.length;return n?(a&&(t=a-l)>0?i=i.charAt(0)+"."+i.slice(1)+_t(t):l>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):r<0?(i="0."+_t(-r-1)+i,a&&(t=a-l)>0&&(i+=_t(t))):r>=l?(i+=_t(r+1-l),a&&(t=a-r-1)>0&&(i=i+"."+_t(t))):((t=r+1)<l&&(i=i.slice(0,t)+"."+i.slice(t)),a&&(t=a-l)>0&&(r+1===l&&(i+="."),i+=_t(t))),i}function va(e,n){var a=e[0];for(n*=De;a>=10;a/=10)n++;return n}function ha(e,n,a){if(n>Dv)throw $e=!0,a&&(e.precision=a),Error(Co);return Ee(new e(fa),n,1,!0)}function ot(e,n,a){if(n>li)throw Error(Co);return Ee(new e(la),n,a,!0)}function Bo(e){var n=e.length-1,a=n*De+1;if(n=e[n],n){for(;n%10==0;n/=10)a--;for(n=e[0];n>=10;n/=10)a++}return a}function _t(e){for(var n="";e--;)n+="0";return n}function _o(e,n,a,t){var r,i=new e(1),l=Math.ceil(t/De+4);for($e=!1;;){if(a%2&&(i=i.times(n),Fo(i.d,l)&&(r=!0)),a=Nr(a/2),a===0){a=i.d.length-1,r&&i.d[a]===0&&++i.d[a];break}n=n.times(n),Fo(n.d,l)}return $e=!0,i}function $o(e){return e.d[e.d.length-1]&1}function Io(e,n,a){for(var t,r,i=new e(n[0]),l=0;++l<n.length;){if(r=new e(n[l]),!r.s){i=r;break}t=i.cmp(r),(t===a||t===0&&i.s===a)&&(i=r)}return i}function mi(e,n){var a,t,r,i,l,m,f,c=0,s=0,o=0,u=e.constructor,p=u.rounding,v=u.precision;if(!e.d||!e.d[0]||e.e>17)return new u(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(n==null?($e=!1,f=v):f=n,m=new u(.03125);e.e>-2;)e=e.times(m),o+=5;for(t=Math.log(hr(2,o))/Math.LN10*2+5|0,f+=t,a=i=l=new u(1),u.precision=f;;){if(i=Ee(i.times(e),f,1),a=a.times(++s),m=l.plus(er(i,a,f,1)),br(m.d).slice(0,f)===br(l.d).slice(0,f)){for(r=o;r--;)l=Ee(l.times(l),f,1);if(n==null)if(c<3&&_n(l.d,f-t,p,c))u.precision=f+=10,a=i=m=new u(1),s=0,c++;else return Ee(l,u.precision=v,p,$e=!0);else return u.precision=v,l}l=m}}function $t(e,n){var a,t,r,i,l,m,f,c,s,o,u,p=1,v=10,h=e,b=h.d,w=h.constructor,N=w.rounding,g=w.precision;if(h.s<0||!b||!b[0]||!h.e&&b[0]==1&&b.length==1)return new w(b&&!b[0]?-1/0:h.s!=1?NaN:b?0:h);if(n==null?($e=!1,s=g):s=n,w.precision=s+=v,a=br(b),t=a.charAt(0),Math.abs(i=h.e)<15e14){for(;t<7&&t!=1||t==1&&a.charAt(1)>3;)h=h.times(e),a=br(h.d),t=a.charAt(0),p++;i=h.e,t>1?(h=new w("0."+a),i++):h=new w(t+"."+a.slice(1))}else return c=ha(w,s+2,g).times(i+""),h=$t(new w(t+"."+a.slice(1)),s-v).plus(c),w.precision=g,n==null?Ee(h,g,N,$e=!0):h;for(o=h,f=l=h=er(h.minus(1),h.plus(1),s,1),u=Ee(h.times(h),s,1),r=3;;){if(l=Ee(l.times(u),s,1),c=f.plus(er(l,new w(r),s,1)),br(c.d).slice(0,s)===br(f.d).slice(0,s))if(f=f.times(2),i!==0&&(f=f.plus(ha(w,s+2,g).times(i+""))),f=er(f,new w(p),s,1),n==null)if(_n(f.d,s-v,N,m))w.precision=s+=v,c=l=h=er(o.minus(1),o.plus(1),s,1),u=Ee(h.times(h),s,1),r=m=1;else return Ee(f,w.precision=g,N,$e=!0);else return w.precision=g,f;f=c,r+=2}}function qo(e){return String(e.s*e.s/0)}function da(e,n){var a,t,r;for((a=n.indexOf("."))>-1&&(n=n.replace(".","")),(t=n.search(/e/i))>0?(a<0&&(a=t),a+=+n.slice(t+1),n=n.substring(0,t)):a<0&&(a=n.length),t=0;n.charCodeAt(t)===48;t++);for(r=n.length;n.charCodeAt(r-1)===48;--r);if(n=n.slice(t,r),n){if(r-=t,e.e=a=a-t-1,e.d=[],t=(a+1)%De,a<0&&(t+=De),t<r){for(t&&e.d.push(+n.slice(0,t)),r-=De;t<r;)e.d.push(+n.slice(t,t+=De));n=n.slice(t),t=De-n.length}else t-=r;for(;t--;)n+="0";e.d.push(+n),$e&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Bv(e,n){var a,t,r,i,l,m,f,c,s;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),To.test(n))return da(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ev.test(n))a=16,n=n.toLowerCase();else if(Sv.test(n))a=2;else if(Cv.test(n))a=8;else throw Error(Bt+n);for(i=n.search(/p/i),i>0?(f=+n.slice(i+1),n=n.substring(2,i)):n=n.slice(2),i=n.indexOf("."),l=i>=0,t=e.constructor,l&&(n=n.replace(".",""),m=n.length,i=m-i,r=_o(t,new t(a),i,i*2)),c=pa(n,a,jr),s=c.length-1,i=s;c[i]===0;--i)c.pop();return i<0?new t(e.s*0):(e.e=va(c,s),e.d=c,$e=!1,l&&(e=er(e,r,m*4)),f&&(e=e.times(Math.abs(f)<54?hr(2,f):It.pow(2,f))),$e=!0,e)}function _v(e,n){var a,t=n.d.length;if(t<3)return n.isZero()?n:fn(e,2,n,n);a=1.4*Math.sqrt(t),a=a>16?16:a|0,n=n.times(1/ga(5,a)),n=fn(e,2,n,n);for(var r,i=new e(5),l=new e(16),m=new e(20);a--;)r=n.times(n),n=n.times(i.plus(r.times(l.times(r).minus(m))));return n}function fn(e,n,a,t,r){var i,l,m,f,c=e.precision,s=Math.ceil(c/De);for($e=!1,f=a.times(a),m=new e(t);;){if(l=er(m.times(f),new e(n++*n++),c,1),m=r?t.plus(l):t.minus(l),t=er(l.times(f),new e(n++*n++),c,1),l=m.plus(t),l.d[s]!==void 0){for(i=s;l.d[i]===m.d[i]&&i--;);if(i==-1)break}i=m,m=t,t=l,l=i}return $e=!0,l.d.length=s+1,l}function ga(e,n){for(var a=e;--n;)a*=e;return a}function Ro(e,n){var a,t=n.s<0,r=ot(e,e.precision,1),i=r.times(.5);if(n=n.abs(),n.lte(i))return yt=t?4:1,n;if(a=n.divToInt(r),a.isZero())yt=t?3:2;else{if(n=n.minus(a.times(r)),n.lte(i))return yt=$o(a)?t?2:3:t?4:1,n;yt=$o(a)?t?1:4:t?3:2}return n.minus(r).abs()}function pi(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor,v=a!==void 0;if(v?(Ir(a,1,Tt),t===void 0?t=p.rounding:Ir(t,0,8)):(a=p.precision,t=p.rounding),!e.isFinite())s=qo(e);else{for(s=it(e),l=s.indexOf("."),v?(r=2,n==16?a=a*4-3:n==8&&(a=a*3-2)):r=n,l>=0&&(s=s.replace(".",""),u=new p(1),u.e=s.length-l,u.d=pa(it(u),10,r),u.e=u.d.length),o=pa(s,10,r),i=f=o.length;o[--f]==0;)o.pop();if(!o[0])s=v?"0p+0":"0";else{if(l<0?i--:(e=new p(e),e.d=o,e.e=i,e=er(e,u,a,t,0,r),o=e.d,i=e.e,c=Eo),l=o[a],m=r/2,c=c||o[a+1]!==void 0,c=t<4?(l!==void 0||c)&&(t===0||t===(e.s<0?3:2)):l>m||l===m&&(t===4||c||t===6&&o[a-1]&1||t===(e.s<0?8:7)),o.length=a,c)for(;++o[--a]>r-1;)o[a]=0,a||(++i,o.unshift(1));for(f=o.length;!o[f-1];--f);for(l=0,s="";l<f;l++)s+=ci.charAt(o[l]);if(v){if(f>1)if(n==16||n==8){for(l=n==16?4:3,--f;f%l;f++)s+="0";for(o=pa(s,r,n),f=o.length;!o[f-1];--f);for(l=1,s="1.";l<f;l++)s+=ci.charAt(o[l])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>f)for(i-=f;i--;)s+="0";else i<f&&(s=s.slice(0,i)+"."+s.slice(i))}s=(n==16?"0x":n==2?"0b":n==8?"0o":"")+s}return e.s<0?"-"+s:s}function Fo(e,n){if(e.length>n)return e.length=n,!0}function $v(e){return new this(e).abs()}function Iv(e){return new this(e).acos()}function qv(e){return new this(e).acosh()}function Rv(e,n){return new this(e).plus(n)}function Fv(e){return new this(e).asin()}function zv(e){return new this(e).asinh()}function Pv(e){return new this(e).atan()}function Uv(e){return new this(e).atanh()}function Lv(e,n){e=new this(e),n=new this(n);var a,t=this.precision,r=this.rounding,i=t+4;return!e.s||!n.s?a=new this(NaN):!e.d&&!n.d?(a=ot(this,i,1).times(n.s>0?.25:.75),a.s=e.s):!n.d||e.isZero()?(a=n.s<0?ot(this,t,r):new this(0),a.s=e.s):!e.d||n.isZero()?(a=ot(this,i,1).times(.5),a.s=e.s):n.s<0?(this.precision=i,this.rounding=1,a=this.atan(er(e,n,i,1)),n=ot(this,i,1),this.precision=t,this.rounding=r,a=e.s<0?a.minus(n):a.plus(n)):a=this.atan(er(e,n,i,1)),a}function kv(e){return new this(e).cbrt()}function Hv(e){return Ee(e=new this(e),e.e+1,2)}function Gv(e,n,a){return new this(e).clamp(n,a)}function Vv(e){if(!e||typeof e!="object")throw Error(ma+"Object expected");var n,a,t,r=e.defaults===!0,i=["precision",1,Tt,"rounding",0,8,"toExpNeg",-cn,0,"toExpPos",0,cn,"maxE",0,cn,"minE",-cn,0,"modulo",0,9];for(n=0;n<i.length;n+=3)if(a=i[n],r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(Nr(t)===t&&t>=i[n+1]&&t<=i[n+2])this[a]=t;else throw Error(Bt+a+": "+t);if(a="crypto",r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[a]=!0;else throw Error(Oo);else this[a]=!1;else throw Error(Bt+a+": "+t);return this}function Zv(e){return new this(e).cos()}function Xv(e){return new this(e).cosh()}function zo(e){var n,a,t;function r(i){var l,m,f,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Po(i)){c.s=i.s,$e?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(f=typeof i,f==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(l=0,m=i;m>=10;m/=10)l++;$e?l>r.maxE?(c.e=NaN,c.d=null):l<r.minE?(c.e=0,c.d=[0]):(c.e=l,c.d=[i]):(c.e=l,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return da(c,i.toString())}if(f==="string")return(m=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(m===43&&(i=i.slice(1)),c.s=1),To.test(i)?da(c,i):Bv(c,i);if(f==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,da(c,i.toString());throw Error(Bt+i)}if(r.prototype=ce,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Vv,r.clone=zo,r.isDecimal=Po,r.abs=$v,r.acos=Iv,r.acosh=qv,r.add=Rv,r.asin=Fv,r.asinh=zv,r.atan=Pv,r.atanh=Uv,r.atan2=Lv,r.cbrt=kv,r.ceil=Hv,r.clamp=Gv,r.cos=Zv,r.cosh=Xv,r.div=Yv,r.exp=Wv,r.floor=Jv,r.hypot=Qv,r.ln=Kv,r.log=jv,r.log10=rh,r.log2=eh,r.max=th,r.min=nh,r.mod=ah,r.mul=ih,r.pow=oh,r.random=sh,r.round=uh,r.sign=ch,r.sin=fh,r.sinh=lh,r.sqrt=mh,r.sub=ph,r.sum=vh,r.tan=hh,r.tanh=dh,r.trunc=gh,e===void 0&&(e={}),e&&e.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<t.length;)e.hasOwnProperty(a=t[n++])||(e[a]=this[a]);return r.config(e),r}function Yv(e,n){return new this(e).div(n)}function Wv(e){return new this(e).exp()}function Jv(e){return Ee(e=new this(e),e.e+1,3)}function Qv(){var e,n,a=new this(0);for($e=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)a.d&&(a=a.plus(n.times(n)));else{if(n.s)return $e=!0,new this(1/0);a=n}return $e=!0,a.sqrt()}function Po(e){return e instanceof It||e&&e.toStringTag===Do||!1}function Kv(e){return new this(e).ln()}function jv(e,n){return new this(e).log(n)}function eh(e){return new this(e).log(2)}function rh(e){return new this(e).log(10)}function th(){return Io(this,arguments,-1)}function nh(){return Io(this,arguments,1)}function ah(e,n){return new this(e).mod(n)}function ih(e,n){return new this(e).mul(n)}function oh(e,n){return new this(e).pow(n)}function sh(e){var n,a,t,r,i=0,l=new this(1),m=[];if(e===void 0?e=this.precision:Ir(e,1,Tt),t=Math.ceil(e/De),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(t));i<t;)r=n[i],r>=429e7?n[i]=crypto.getRandomValues(new Uint32Array(1))[0]:m[i++]=r%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(t*=4);i<t;)r=n[i]+(n[i+1]<<8)+(n[i+2]<<16)+((n[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(n,i):(m.push(r%1e7),i+=4);i=t/4}else throw Error(Oo);else for(;i<t;)m[i++]=Math.random()*1e7|0;for(t=m[--i],e%=De,t&&e&&(r=hr(10,De-e),m[i]=(t/r|0)*r);m[i]===0;i--)m.pop();if(i<0)a=0,m=[0];else{for(a=-1;m[0]===0;a-=De)m.shift();for(t=1,r=m[0];r>=10;r/=10)t++;t<De&&(a-=De-t)}return l.e=a,l.d=m,l}function uh(e){return Ee(e=new this(e),e.e+1,this.rounding)}function ch(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function fh(e){return new this(e).sin()}function lh(e){return new this(e).sinh()}function mh(e){return new this(e).sqrt()}function ph(e,n){return new this(e).sub(n)}function vh(){var e=0,n=arguments,a=new this(n[e]);for($e=!1;a.s&&++e<n.length;)a=a.plus(n[e]);return $e=!0,Ee(a,this.precision,this.rounding)}function hh(e){return new this(e).tan()}function dh(e){return new this(e).tanh()}function gh(e){return Ee(e=new this(e),e.e+1,1)}ce[Symbol.for("nodejs.util.inspect.custom")]=ce.toString,ce[Symbol.toStringTag]="Decimal";var It=ce.constructor=zo(fi);fa=new It(fa),la=new It(la);var yh="BigNumber",xh=["?on","config"],bh=R(yh,xh,e=>{var{on:n,config:a}=e,t=It.clone({precision:a.precision,modulo:It.EUCLID});return t.prototype=Object.create(t.prototype),t.prototype.type="BigNumber",t.prototype.isBigNumber=!0,t.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},t.fromJSON=function(r){return new t(r.value)},n&&n("config",function(r,i){r.precision!==i.precision&&t.config({precision:r.precision})}),t},{isClass:!0}),vi={exports:{}};/**
15
15
  * @license Complex.js v2.1.1 12/05/2020
16
16
  *
17
17
  * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
18
18
  * Dual licensed under the MIT or GPL Version 2 licenses.
19
- **/var Lo;function Nh(){return Lo||(Lo=1,function(e,n){(function(a){var t=Math.cosh||function(o){return Math.abs(o)<1e-9?1-o:(Math.exp(o)+Math.exp(-o))*.5},r=Math.sinh||function(o){return Math.abs(o)<1e-9?o:(Math.exp(o)-Math.exp(-o))*.5},i=function(o){var u=Math.PI/4;if(-u>o||o>u)return Math.cos(o)-1;var p=o*o;return p*(p*(p*(p*(p*(p*(p*(p/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},l=function(o,u){var p=Math.abs(o),v=Math.abs(u);return p<3e3&&v<3e3?Math.sqrt(p*p+v*v):(p<v?(p=v,v=o/u):v=u/o,p*Math.sqrt(1+v*v))},m=function(){throw SyntaxError("Invalid Param")};function f(o,u){var p=Math.abs(o),v=Math.abs(u);return o===0?Math.log(v):u===0?Math.log(p):p<3e3&&v<3e3?Math.log(o*o+u*u)*.5:(o=o/2,u=u/2,.5*Math.log(o*o+u*u)+Math.LN2)}var c=function(o,u){var p={re:0,im:0};if(o==null)p.re=p.im=0;else if(u!==void 0)p.re=o,p.im=u;else switch(typeof o){case"object":if("im"in o&&"re"in o)p.re=o.re,p.im=o.im;else if("abs"in o&&"arg"in o){if(!Number.isFinite(o.abs)&&Number.isFinite(o.arg))return s.INFINITY;p.re=o.abs*Math.cos(o.arg),p.im=o.abs*Math.sin(o.arg)}else if("r"in o&&"phi"in o){if(!Number.isFinite(o.r)&&Number.isFinite(o.phi))return s.INFINITY;p.re=o.r*Math.cos(o.phi),p.im=o.r*Math.sin(o.phi)}else o.length===2?(p.re=o[0],p.im=o[1]):m();break;case"string":p.im=p.re=0;var v=o.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),h=1,b=0;v===null&&m();for(var w=0;w<v.length;w++){var N=v[w];N===" "||N===" "||N===`
20
- `||(N==="+"?h++:N==="-"?b++:N==="i"||N==="I"?(h+b===0&&m(),v[w+1]!==" "&&!isNaN(v[w+1])?(p.im+=parseFloat((b%2?"-":"")+v[w+1]),w++):p.im+=parseFloat((b%2?"-":"")+"1"),h=b=0):((h+b===0||isNaN(N))&&m(),v[w+1]==="i"||v[w+1]==="I"?(p.im+=parseFloat((b%2?"-":"")+N),w++):p.re+=parseFloat((b%2?"-":"")+N),h=b=0))}h+b>0&&m();break;case"number":p.im=0,p.re=o;break;default:m()}return isNaN(p.re)||isNaN(p.im),p};function s(o,u){if(!(this instanceof s))return new s(o,u);var p=c(o,u);this.re=p.re,this.im=p.im}s.prototype={re:0,im:0,sign:function(){var o=this.abs();return new s(this.re/o,this.im/o)},add:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re+p.re,this.im+p.im)},sub:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re-p.re,this.im-p.im)},mul:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isZero()||this.isZero()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:p.im===0&&this.im===0?new s(this.re*p.re,0):new s(this.re*p.re-this.im*p.im,this.re*p.im+this.im*p.re)},div:function(o,u){var p=new s(o,u);if(this.isZero()&&p.isZero()||this.isInfinite()&&p.isInfinite())return s.NAN;if(this.isInfinite()||p.isZero())return s.INFINITY;if(this.isZero()||p.isInfinite())return s.ZERO;o=this.re,u=this.im;var v=p.re,h=p.im,b,w;return h===0?new s(o/v,u/v):Math.abs(v)<Math.abs(h)?(w=v/h,b=v*w+h,new s((o*w+u)/b,(u*w-o)/b)):(w=h/v,b=h*w+v,new s((o+u*w)/b,(u-o*w)/b))},pow:function(o,u){var p=new s(o,u);if(o=this.re,u=this.im,p.isZero())return s.ONE;if(p.im===0){if(u===0&&o>0)return new s(Math.pow(o,p.re),0);if(o===0)switch((p.re%4+4)%4){case 0:return new s(Math.pow(u,p.re),0);case 1:return new s(0,Math.pow(u,p.re));case 2:return new s(-Math.pow(u,p.re),0);case 3:return new s(0,-Math.pow(u,p.re))}}if(o===0&&u===0&&p.re>0&&p.im>=0)return s.ZERO;var v=Math.atan2(u,o),h=f(o,u);return o=Math.exp(p.re*h-p.im*v),u=p.im*h+p.re*v,new s(o*Math.cos(u),o*Math.sin(u))},sqrt:function(){var o=this.re,u=this.im,p=this.abs(),v,h;if(o>=0){if(u===0)return new s(Math.sqrt(o),0);v=.5*Math.sqrt(2*(p+o))}else v=Math.abs(u)/Math.sqrt(2*(p-o));return o<=0?h=.5*Math.sqrt(2*(p-o)):h=Math.abs(u)/Math.sqrt(2*(p+o)),new s(v,u<0?-h:h)},exp:function(){var o=Math.exp(this.re);return this.im,new s(o*Math.cos(this.im),o*Math.sin(this.im))},expm1:function(){var o=this.re,u=this.im;return new s(Math.expm1(o)*Math.cos(u)+i(u),Math.exp(o)*Math.sin(u))},log:function(){var o=this.re,u=this.im;return new s(f(o,u),Math.atan2(u,o))},abs:function(){return l(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var o=this.re,u=this.im;return new s(Math.sin(o)*t(u),Math.cos(o)*r(u))},cos:function(){var o=this.re,u=this.im;return new s(Math.cos(o)*t(u),-Math.sin(o)*r(u))},tan:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)+t(u);return new s(Math.sin(o)/p,r(u)/p)},cot:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)-t(u);return new s(-Math.sin(o)/p,r(u)/p)},sec:function(){var o=this.re,u=this.im,p=.5*t(2*u)+.5*Math.cos(2*o);return new s(Math.cos(o)*t(u)/p,Math.sin(o)*r(u)/p)},csc:function(){var o=this.re,u=this.im,p=.5*t(2*u)-.5*Math.cos(2*o);return new s(Math.sin(o)*t(u)/p,-Math.cos(o)*r(u)/p)},asin:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(v.im,-v.re)},acos:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(Math.PI/2-v.im,v.re)},atan:function(){var o=this.re,u=this.im;if(o===0){if(u===1)return new s(0,1/0);if(u===-1)return new s(0,-1/0)}var p=o*o+(1-u)*(1-u),v=new s((1-u*u-o*o)/p,-2*o/p).log();return new s(-.5*v.im,.5*v.re)},acot:function(){var o=this.re,u=this.im;if(u===0)return new s(Math.atan2(1,o),0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atan():new s(o!==0?o/0:0,u!==0?-u/0:0).atan()},asec:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acos():new s(o!==0?o/0:0,u!==0?-u/0:0).acos()},acsc:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(Math.PI/2,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asin():new s(o!==0?o/0:0,u!==0?-u/0:0).asin()},sinh:function(){var o=this.re,u=this.im;return new s(r(o)*Math.cos(u),t(o)*Math.sin(u))},cosh:function(){var o=this.re,u=this.im;return new s(t(o)*Math.cos(u),r(o)*Math.sin(u))},tanh:function(){var o=2*this.re,u=2*this.im,p=t(o)+Math.cos(u);return new s(r(o)/p,Math.sin(u)/p)},coth:function(){var o=2*this.re,u=2*this.im,p=t(o)-Math.cos(u);return new s(r(o)/p,-Math.sin(u)/p)},csch:function(){var o=this.re,u=this.im,p=Math.cos(2*u)-t(2*o);return new s(-2*r(o)*Math.cos(u)/p,2*t(o)*Math.sin(u)/p)},sech:function(){var o=this.re,u=this.im,p=Math.cos(2*u)+t(2*o);return new s(2*t(o)*Math.cos(u)/p,-2*r(o)*Math.sin(u)/p)},asinh:function(){var o=this.im;this.im=-this.re,this.re=o;var u=this.asin();return this.re=-this.im,this.im=o,o=u.re,u.re=-u.im,u.im=o,u},acosh:function(){var o=this.acos();if(o.im<=0){var u=o.re;o.re=-o.im,o.im=u}else{var u=o.im;o.im=-o.re,o.re=u}return o},atanh:function(){var o=this.re,u=this.im,p=o>1&&u===0,v=1-o,h=1+o,b=v*v+u*u,w=b!==0?new s((h*v-u*u)/b,(u*v+h*u)/b):new s(o!==-1?o/0:0,u!==0?u/0:0),N=w.re;return w.re=f(w.re,w.im)/2,w.im=Math.atan2(w.im,N)/2,p&&(w.im=-w.im),w},acoth:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,Math.PI/2);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atanh():new s(o!==0?o/0:0,u!==0?-u/0:0).atanh()},acsch:function(){var o=this.re,u=this.im;if(u===0)return new s(o!==0?Math.log(o+Math.sqrt(o*o+1)):1/0,0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asinh():new s(o!==0?o/0:0,u!==0?-u/0:0).asinh()},asech:function(){var o=this.re,u=this.im;if(this.isZero())return s.INFINITY;var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acosh():new s(o!==0?o/0:0,u!==0?-u/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var o=this.re,u=this.im,p=o*o+u*u;return new s(o/p,-u/p)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(o){return o=Math.pow(10,o||0),new s(Math.ceil(this.re*o)/o,Math.ceil(this.im*o)/o)},floor:function(o){return o=Math.pow(10,o||0),new s(Math.floor(this.re*o)/o,Math.floor(this.im*o)/o)},round:function(o){return o=Math.pow(10,o||0),new s(Math.round(this.re*o)/o,Math.round(this.im*o)/o)},equals:function(o,u){var p=new s(o,u);return Math.abs(p.re-this.re)<=s.EPSILON&&Math.abs(p.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var o=this.re,u=this.im,p="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(o)<s.EPSILON&&(o=0),Math.abs(u)<s.EPSILON&&(u=0),u===0?p+o:(o!==0?(p+=o,p+=" ",u<0?(u=-u,p+="-"):p+="+",p+=" "):u<0&&(u=-u,p+="-"),u!==1&&(p+=u),p+"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())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,e.exports=s})()}(hi)),hi.exports}var Mh=Nh();const Ir=Bn(Mh);var Ah="Complex",Sh=[],Eh=R(Ah,Sh,()=>(Ir.prototype.type="Complex",Ir.prototype.isComplex=!0,Ir.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Ir.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Ir.prototype.format=function(e){var n="",a=this.im,t=this.re,r=Ht(this.re,e),i=Ht(this.im,e),l=$e(e)?e:e?e.precision:null;if(l!==null){var m=Math.pow(10,-l);Math.abs(t/a)<m&&(t=0),Math.abs(a/t)<m&&(a=0)}return a===0?n=r:t===0?a===1?n="i":a===-1?n="-i":n=i+"i":a<0?a===-1?n=r+" - i":n=r+" - "+i.substring(1)+"i":a===1?n=r+" + i":n=r+" + "+i+"i",n},Ir.fromPolar=function(e){switch(arguments.length){case 1:{var n=arguments[0];if(typeof n=="object")return Ir(n);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var a=arguments[0],t=arguments[1];if($e(a)){if(En(t)&&t.hasBase("ANGLE")&&(t=t.toNumber("rad")),$e(t))return new Ir({r:a,phi:t});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")}},Ir.prototype.valueOf=Ir.prototype.toString,Ir.fromJSON=function(e){return new Ir(e)},Ir.compare=function(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0},Ir),{isClass:!0});/**
19
+ **/var Uo;function wh(){return Uo||(Uo=1,function(e,n){(function(a){var t=Math.cosh||function(o){return Math.abs(o)<1e-9?1-o:(Math.exp(o)+Math.exp(-o))*.5},r=Math.sinh||function(o){return Math.abs(o)<1e-9?o:(Math.exp(o)-Math.exp(-o))*.5},i=function(o){var u=Math.PI/4;if(-u>o||o>u)return Math.cos(o)-1;var p=o*o;return p*(p*(p*(p*(p*(p*(p*(p/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},l=function(o,u){var p=Math.abs(o),v=Math.abs(u);return p<3e3&&v<3e3?Math.sqrt(p*p+v*v):(p<v?(p=v,v=o/u):v=u/o,p*Math.sqrt(1+v*v))},m=function(){throw SyntaxError("Invalid Param")};function f(o,u){var p=Math.abs(o),v=Math.abs(u);return o===0?Math.log(v):u===0?Math.log(p):p<3e3&&v<3e3?Math.log(o*o+u*u)*.5:(o=o/2,u=u/2,.5*Math.log(o*o+u*u)+Math.LN2)}var c=function(o,u){var p={re:0,im:0};if(o==null)p.re=p.im=0;else if(u!==void 0)p.re=o,p.im=u;else switch(typeof o){case"object":if("im"in o&&"re"in o)p.re=o.re,p.im=o.im;else if("abs"in o&&"arg"in o){if(!Number.isFinite(o.abs)&&Number.isFinite(o.arg))return s.INFINITY;p.re=o.abs*Math.cos(o.arg),p.im=o.abs*Math.sin(o.arg)}else if("r"in o&&"phi"in o){if(!Number.isFinite(o.r)&&Number.isFinite(o.phi))return s.INFINITY;p.re=o.r*Math.cos(o.phi),p.im=o.r*Math.sin(o.phi)}else o.length===2?(p.re=o[0],p.im=o[1]):m();break;case"string":p.im=p.re=0;var v=o.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),h=1,b=0;v===null&&m();for(var w=0;w<v.length;w++){var N=v[w];N===" "||N===" "||N===`
20
+ `||(N==="+"?h++:N==="-"?b++:N==="i"||N==="I"?(h+b===0&&m(),v[w+1]!==" "&&!isNaN(v[w+1])?(p.im+=parseFloat((b%2?"-":"")+v[w+1]),w++):p.im+=parseFloat((b%2?"-":"")+"1"),h=b=0):((h+b===0||isNaN(N))&&m(),v[w+1]==="i"||v[w+1]==="I"?(p.im+=parseFloat((b%2?"-":"")+N),w++):p.re+=parseFloat((b%2?"-":"")+N),h=b=0))}h+b>0&&m();break;case"number":p.im=0,p.re=o;break;default:m()}return isNaN(p.re)||isNaN(p.im),p};function s(o,u){if(!(this instanceof s))return new s(o,u);var p=c(o,u);this.re=p.re,this.im=p.im}s.prototype={re:0,im:0,sign:function(){var o=this.abs();return new s(this.re/o,this.im/o)},add:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re+p.re,this.im+p.im)},sub:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re-p.re,this.im-p.im)},mul:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isZero()||this.isZero()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:p.im===0&&this.im===0?new s(this.re*p.re,0):new s(this.re*p.re-this.im*p.im,this.re*p.im+this.im*p.re)},div:function(o,u){var p=new s(o,u);if(this.isZero()&&p.isZero()||this.isInfinite()&&p.isInfinite())return s.NAN;if(this.isInfinite()||p.isZero())return s.INFINITY;if(this.isZero()||p.isInfinite())return s.ZERO;o=this.re,u=this.im;var v=p.re,h=p.im,b,w;return h===0?new s(o/v,u/v):Math.abs(v)<Math.abs(h)?(w=v/h,b=v*w+h,new s((o*w+u)/b,(u*w-o)/b)):(w=h/v,b=h*w+v,new s((o+u*w)/b,(u-o*w)/b))},pow:function(o,u){var p=new s(o,u);if(o=this.re,u=this.im,p.isZero())return s.ONE;if(p.im===0){if(u===0&&o>0)return new s(Math.pow(o,p.re),0);if(o===0)switch((p.re%4+4)%4){case 0:return new s(Math.pow(u,p.re),0);case 1:return new s(0,Math.pow(u,p.re));case 2:return new s(-Math.pow(u,p.re),0);case 3:return new s(0,-Math.pow(u,p.re))}}if(o===0&&u===0&&p.re>0&&p.im>=0)return s.ZERO;var v=Math.atan2(u,o),h=f(o,u);return o=Math.exp(p.re*h-p.im*v),u=p.im*h+p.re*v,new s(o*Math.cos(u),o*Math.sin(u))},sqrt:function(){var o=this.re,u=this.im,p=this.abs(),v,h;if(o>=0){if(u===0)return new s(Math.sqrt(o),0);v=.5*Math.sqrt(2*(p+o))}else v=Math.abs(u)/Math.sqrt(2*(p-o));return o<=0?h=.5*Math.sqrt(2*(p-o)):h=Math.abs(u)/Math.sqrt(2*(p+o)),new s(v,u<0?-h:h)},exp:function(){var o=Math.exp(this.re);return this.im,new s(o*Math.cos(this.im),o*Math.sin(this.im))},expm1:function(){var o=this.re,u=this.im;return new s(Math.expm1(o)*Math.cos(u)+i(u),Math.exp(o)*Math.sin(u))},log:function(){var o=this.re,u=this.im;return new s(f(o,u),Math.atan2(u,o))},abs:function(){return l(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var o=this.re,u=this.im;return new s(Math.sin(o)*t(u),Math.cos(o)*r(u))},cos:function(){var o=this.re,u=this.im;return new s(Math.cos(o)*t(u),-Math.sin(o)*r(u))},tan:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)+t(u);return new s(Math.sin(o)/p,r(u)/p)},cot:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)-t(u);return new s(-Math.sin(o)/p,r(u)/p)},sec:function(){var o=this.re,u=this.im,p=.5*t(2*u)+.5*Math.cos(2*o);return new s(Math.cos(o)*t(u)/p,Math.sin(o)*r(u)/p)},csc:function(){var o=this.re,u=this.im,p=.5*t(2*u)-.5*Math.cos(2*o);return new s(Math.sin(o)*t(u)/p,-Math.cos(o)*r(u)/p)},asin:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(v.im,-v.re)},acos:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(Math.PI/2-v.im,v.re)},atan:function(){var o=this.re,u=this.im;if(o===0){if(u===1)return new s(0,1/0);if(u===-1)return new s(0,-1/0)}var p=o*o+(1-u)*(1-u),v=new s((1-u*u-o*o)/p,-2*o/p).log();return new s(-.5*v.im,.5*v.re)},acot:function(){var o=this.re,u=this.im;if(u===0)return new s(Math.atan2(1,o),0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atan():new s(o!==0?o/0:0,u!==0?-u/0:0).atan()},asec:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acos():new s(o!==0?o/0:0,u!==0?-u/0:0).acos()},acsc:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(Math.PI/2,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asin():new s(o!==0?o/0:0,u!==0?-u/0:0).asin()},sinh:function(){var o=this.re,u=this.im;return new s(r(o)*Math.cos(u),t(o)*Math.sin(u))},cosh:function(){var o=this.re,u=this.im;return new s(t(o)*Math.cos(u),r(o)*Math.sin(u))},tanh:function(){var o=2*this.re,u=2*this.im,p=t(o)+Math.cos(u);return new s(r(o)/p,Math.sin(u)/p)},coth:function(){var o=2*this.re,u=2*this.im,p=t(o)-Math.cos(u);return new s(r(o)/p,-Math.sin(u)/p)},csch:function(){var o=this.re,u=this.im,p=Math.cos(2*u)-t(2*o);return new s(-2*r(o)*Math.cos(u)/p,2*t(o)*Math.sin(u)/p)},sech:function(){var o=this.re,u=this.im,p=Math.cos(2*u)+t(2*o);return new s(2*t(o)*Math.cos(u)/p,-2*r(o)*Math.sin(u)/p)},asinh:function(){var o=this.im;this.im=-this.re,this.re=o;var u=this.asin();return this.re=-this.im,this.im=o,o=u.re,u.re=-u.im,u.im=o,u},acosh:function(){var o=this.acos();if(o.im<=0){var u=o.re;o.re=-o.im,o.im=u}else{var u=o.im;o.im=-o.re,o.re=u}return o},atanh:function(){var o=this.re,u=this.im,p=o>1&&u===0,v=1-o,h=1+o,b=v*v+u*u,w=b!==0?new s((h*v-u*u)/b,(u*v+h*u)/b):new s(o!==-1?o/0:0,u!==0?u/0:0),N=w.re;return w.re=f(w.re,w.im)/2,w.im=Math.atan2(w.im,N)/2,p&&(w.im=-w.im),w},acoth:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,Math.PI/2);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atanh():new s(o!==0?o/0:0,u!==0?-u/0:0).atanh()},acsch:function(){var o=this.re,u=this.im;if(u===0)return new s(o!==0?Math.log(o+Math.sqrt(o*o+1)):1/0,0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asinh():new s(o!==0?o/0:0,u!==0?-u/0:0).asinh()},asech:function(){var o=this.re,u=this.im;if(this.isZero())return s.INFINITY;var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acosh():new s(o!==0?o/0:0,u!==0?-u/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var o=this.re,u=this.im,p=o*o+u*u;return new s(o/p,-u/p)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(o){return o=Math.pow(10,o||0),new s(Math.ceil(this.re*o)/o,Math.ceil(this.im*o)/o)},floor:function(o){return o=Math.pow(10,o||0),new s(Math.floor(this.re*o)/o,Math.floor(this.im*o)/o)},round:function(o){return o=Math.pow(10,o||0),new s(Math.round(this.re*o)/o,Math.round(this.im*o)/o)},equals:function(o,u){var p=new s(o,u);return Math.abs(p.re-this.re)<=s.EPSILON&&Math.abs(p.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var o=this.re,u=this.im,p="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(o)<s.EPSILON&&(o=0),Math.abs(u)<s.EPSILON&&(u=0),u===0?p+o:(o!==0?(p+=o,p+=" ",u<0?(u=-u,p+="-"):p+="+",p+=" "):u<0&&(u=-u,p+="-"),u!==1&&(p+=u),p+"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())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,e.exports=s})()}(vi)),vi.exports}var Nh=wh();const qr=Tn(Nh);var Mh="Complex",Ah=[],Sh=R(Mh,Ah,()=>(qr.prototype.type="Complex",qr.prototype.isComplex=!0,qr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},qr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},qr.prototype.format=function(e){var n="",a=this.im,t=this.re,r=Ht(this.re,e),i=Ht(this.im,e),l=Be(e)?e:e?e.precision:null;if(l!==null){var m=Math.pow(10,-l);Math.abs(t/a)<m&&(t=0),Math.abs(a/t)<m&&(a=0)}return a===0?n=r:t===0?a===1?n="i":a===-1?n="-i":n=i+"i":a<0?a===-1?n=r+" - i":n=r+" - "+i.substring(1)+"i":a===1?n=r+" + i":n=r+" + "+i+"i",n},qr.fromPolar=function(e){switch(arguments.length){case 1:{var n=arguments[0];if(typeof n=="object")return qr(n);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var a=arguments[0],t=arguments[1];if(Be(a)){if(ht(t)&&t.hasBase("ANGLE")&&(t=t.toNumber("rad")),Be(t))return new qr({r:a,phi:t});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")}},qr.prototype.valueOf=qr.prototype.toString,qr.fromJSON=function(e){return new qr(e)},qr.compare=function(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0},qr),{isClass:!0});/**
21
21
  * @license Fraction.js v4.3.7 31/08/2023
22
22
  * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
23
23
  *
24
24
  * Copyright (c) 2023, Robert Eisele (robert@raw.org)
25
25
  * Dual licensed under the MIT or GPL Version 2 licenses.
26
- **/var Ch=2e3,Se={s:1,n:0,d:1};function xt(e,n){if(isNaN(e=parseInt(e,10)))throw xa();return e*n}function cr(e,n){if(n===0)throw di();var a=Object.create(zr.prototype);a.s=e<0?-1:1,e=e<0?-e:e;var t=ln(e,n);return a.n=e/t,a.d=n/t,a}function ko(e){for(var n={},a=e,t=2,r=4;r<=a;){for(;a%t===0;)a/=t,n[t]=(n[t]||0)+1;r+=1+2*t++}return a!==e?a>1&&(n[a]=(n[a]||0)+1):n[e]=(n[e]||0)+1,n}var Fr=function(e,n){var a=0,t=1,r=1,i=0,l=0,m=0,f=1,c=1,s=0,o=1,u=1,p=1,v=1e7,h;if(e!=null)if(n!==void 0){if(a=e,t=n,r=a*t,a%1!==0||t%1!==0)throw Bh()}else switch(typeof e){case"object":{if("d"in e&&"n"in e)a=e.n,t=e.d,"s"in e&&(a*=e.s);else if(0 in e)a=e[0],1 in e&&(t=e[1]);else throw xa();r=a*t;break}case"number":{if(e<0&&(r=e,e=-e),e%1===0)a=e;else if(e>0){for(e>=1&&(c=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=c);o<=v&&p<=v;)if(h=(s+u)/(o+p),e===h){o+p<=v?(a=s+u,t=o+p):p>o?(a=u,t=p):(a=s,t=o);break}else e>h?(s+=u,o+=p):(u+=s,p+=o),o>v?(a=u,t=p):(a=s,t=o);a*=c}else(isNaN(e)||isNaN(n))&&(t=a=NaN);break}case"string":{if(o=e.match(/\d+|./g),o===null)throw xa();if(o[s]==="-"?(r=-1,s++):o[s]==="+"&&s++,o.length===s+1?l=xt(o[s++],r):o[s+1]==="."||o[s]==="."?(o[s]!=="."&&(i=xt(o[s++],r)),s++,(s+1===o.length||o[s+1]==="("&&o[s+3]===")"||o[s+1]==="'"&&o[s+3]==="'")&&(l=xt(o[s],r),f=Math.pow(10,o[s].length),s++),(o[s]==="("&&o[s+2]===")"||o[s]==="'"&&o[s+2]==="'")&&(m=xt(o[s+1],r),c=Math.pow(10,o[s+1].length)-1,s+=3)):o[s+1]==="/"||o[s+1]===":"?(l=xt(o[s],r),f=xt(o[s+2],1),s+=3):o[s+3]==="/"&&o[s+1]===" "&&(i=xt(o[s],r),l=xt(o[s+2],r),f=xt(o[s+4],1),s+=5),o.length<=s){t=f*c,r=a=m+t*i+c*l;break}}default:throw xa()}if(t===0)throw di();Se.s=r<0?-1:1,Se.n=Math.abs(a),Se.d=Math.abs(t)};function Oh(e,n,a){for(var t=1;n>0;e=e*e%a,n>>=1)n&1&&(t=t*e%a);return t}function Dh(e,n){for(;n%2===0;n/=2);for(;n%5===0;n/=5);if(n===1)return 0;for(var a=10%n,t=1;a!==1;t++)if(a=a*10%n,t>Ch)return 0;return t}function Th(e,n,a){for(var t=1,r=Oh(10,a,n),i=0;i<300;i++){if(t===r)return i;t=t*10%n,r=r*10%n}return 0}function ln(e,n){if(!e)return n;if(!n)return e;for(;;){if(e%=n,!e)return n;if(n%=e,!n)return e}}function zr(e,n){if(Fr(e,n),this instanceof zr)e=ln(Se.d,Se.n),this.s=Se.s,this.n=Se.n/e,this.d=Se.d/e;else return cr(Se.s*Se.n,Se.d)}var di=function(){return new Error("Division by Zero")},xa=function(){return new Error("Invalid argument")},Bh=function(){return new Error("Parameters must be integer")};zr.prototype={s:1,n:0,d:1,abs:function(){return cr(this.n,this.d)},neg:function(){return cr(-this.s*this.n,this.d)},add:function(e,n){return Fr(e,n),cr(this.s*this.n*Se.d+Se.s*this.d*Se.n,this.d*Se.d)},sub:function(e,n){return Fr(e,n),cr(this.s*this.n*Se.d-Se.s*this.d*Se.n,this.d*Se.d)},mul:function(e,n){return Fr(e,n),cr(this.s*Se.s*this.n*Se.n,this.d*Se.d)},div:function(e,n){return Fr(e,n),cr(this.s*Se.s*this.n*Se.d,this.d*Se.n)},clone:function(){return cr(this.s*this.n,this.d)},mod:function(e,n){if(isNaN(this.n)||isNaN(this.d))return new zr(NaN);if(e===void 0)return cr(this.s*this.n%this.d,1);if(Fr(e,n),Se.n===0&&this.d===0)throw di();return cr(this.s*(Se.d*this.n)%(Se.n*this.d),Se.d*this.d)},gcd:function(e,n){return Fr(e,n),cr(ln(Se.n,this.n)*ln(Se.d,this.d),Se.d*this.d)},lcm:function(e,n){return Fr(e,n),Se.n===0&&this.n===0?cr(0,1):cr(Se.n*this.n,ln(Se.n,this.n)*ln(Se.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):cr(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):cr(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):cr(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,n){return Fr(e,n),cr(this.s*Math.round(this.n*Se.d/(this.d*Se.n))*Se.n,Se.d)},inverse:function(){return cr(this.s*this.d,this.n)},pow:function(e,n){if(Fr(e,n),Se.d===1)return Se.s<0?cr(Math.pow(this.s*this.d,Se.n),Math.pow(this.n,Se.n)):cr(Math.pow(this.s*this.n,Se.n),Math.pow(this.d,Se.n));if(this.s<0)return null;var a=ko(this.n),t=ko(this.d),r=1,i=1;for(var l in a)if(l!=="1"){if(l==="0"){r=0;break}if(a[l]*=Se.n,a[l]%Se.d===0)a[l]/=Se.d;else return null;r*=Math.pow(l,a[l])}for(var l in t)if(l!=="1"){if(t[l]*=Se.n,t[l]%Se.d===0)t[l]/=Se.d;else return null;i*=Math.pow(l,t[l])}return Se.s<0?cr(i,r):cr(r,i)},equals:function(e,n){return Fr(e,n),this.s*this.n*Se.d===Se.s*Se.n*this.d},compare:function(e,n){Fr(e,n);var a=this.s*this.n*Se.d-Se.s*Se.n*this.d;return(0<a)-(a<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var n=this.abs(),a=n.toContinued(),t=1;t<a.length;t++){for(var r=cr(a[t-1],1),i=t-2;i>=0;i--)r=r.inverse().add(a[i]);if(Math.abs(r.sub(n).valueOf())<e)return r.mul(this.s)}return this},divisible:function(e,n){return Fr(e,n),!(!(Se.n*this.d)||this.n*Se.d%(Se.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,a+=" ",t%=r),a+=t,a+="/",a+=r),a},toLatex:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,t%=r),a+="\\frac{",a+=t,a+="}{",a+=r,a+="}"),a},toContinued:function(){var e,n=this.n,a=this.d,t=[];if(isNaN(n)||isNaN(a))return t;do t.push(Math.floor(n/a)),e=n%a,n=a,a=e;while(n!==1);return t},toString:function(e){var n=this.n,a=this.d;if(isNaN(n)||isNaN(a))return"NaN";e=e||15;var t=Dh(n,a),r=Th(n,a,t),i=this.s<0?"-":"";if(i+=n/a|0,n%=a,n*=10,n&&(i+="."),t){for(var l=r;l--;)i+=n/a|0,n%=a,n*=10;i+="(";for(var l=t;l--;)i+=n/a|0,n%=a,n*=10;i+=")"}else for(var l=e;n&&l--;)i+=n/a|0,n%=a,n*=10;return i}};var _h="Fraction",$h=[],Ih=R(_h,$h,()=>(zr.prototype.type="Fraction",zr.prototype.isFraction=!0,zr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},zr.fromJSON=function(e){return new zr(e)},zr),{isClass:!0}),qh="Range",Rh=[],Fh=R(qh,Rh,()=>{function e(n,a,t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var r=n!=null,i=a!=null,l=t!=null;if(r){if(Ie(n))n=n.toNumber();else if(typeof n!="number")throw new TypeError("Parameter start must be a number")}if(i){if(Ie(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter end must be a number")}if(l){if(Ie(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter step must be a number")}this.start=r?parseFloat(n):0,this.end=i?parseFloat(a):0,this.step=l?parseFloat(t):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(n){if(typeof n!="string")return null;var a=n.split(":"),t=a.map(function(i){return parseFloat(i)}),r=t.some(function(i){return isNaN(i)});if(r)return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var n=0,a=this.start,t=this.step,r=this.end,i=r-a;return Dt(t)===Dt(i)?n=Math.ceil(i/t):i===0&&(n=0),isNaN(n)&&(n=0),[n]},e.prototype.min=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start:this.start+(n-1)*this.step},e.prototype.max=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start+(n-1)*this.step:this.start},e.prototype.forEach=function(n){var a=this.start,t=this.step,r=this.end,i=0;if(t>0)for(;a<r;)n(a,[i],this),a+=t,i++;else if(t<0)for(;a>r;)n(a,[i],this),a+=t,i++},e.prototype.map=function(n){var a=[];return this.forEach(function(t,r,i){a[r[0]]=n(t,r,i)}),a},e.prototype.toArray=function(){var n=[];return this.forEach(function(a,t){n[t[0]]=a}),n},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(n){var a=Ht(this.start,n);return this.step!==1&&(a+=":"+Ht(this.step,n)),a+=":"+Ht(this.end,n),a},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(n){return new e(n.start,n.end,n.step)},e},{isClass:!0}),zh="Matrix",Ph=[],Uh=R(zh,Ph,()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(n,a){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(n,a,t){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(n){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(n,a,t){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(n,a){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(n,a){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(n,a){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(n){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(n){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0}),Lh="DenseMatrix",kh=["Matrix"],Hh=R(Lh,kh,e=>{var{Matrix:n}=e;function a(s,o){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(o&&!Br(o))throw new Error("Invalid datatype: "+o);if(Oe(s))s.type==="DenseMatrix"?(this._data=Ce(s._data),this._size=Ce(s._size),this._datatype=o||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=o||s._datatype);else if(s&&Xe(s.data)&&Xe(s.size))this._data=s.data,this._size=s.size,ho(this._data,this._size),this._datatype=o||s.datatype;else if(Xe(s))this._data=c(s),this._size=Pe(this._data),ho(this._data,this._size),this._datatype=o;else{if(s)throw new TypeError("Unsupported type of data ("+Ke(s)+")");this._data=[],this._size=[0],this._datatype=o}}a.prototype=new n,a.prototype.createDenseMatrix=function(s,o){return new a(s,o)},a.prototype.type="DenseMatrix",a.prototype.isDenseMatrix=!0,a.prototype.getDataType=function(){return _n(this._data,Ke)},a.prototype.storage=function(){return"dense"},a.prototype.datatype=function(){return this._datatype},a.prototype.create=function(s,o){return new a(s,o)},a.prototype.subset=function(s,o,u){switch(arguments.length){case 1:return t(this,s);case 2:case 3:return i(this,s,o,u);default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.get=function(s){if(!Xe(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Fe(s.length,this._size.length);for(var o=0;o<s.length;o++)We(s[o],this._size[o]);for(var u=this._data,p=0,v=s.length;p<v;p++){var h=s[p];We(h,u.length),u=u[h]}return u},a.prototype.set=function(s,o,u){if(!Xe(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Fe(s.length,this._size.length,"<");var p,v,h,b=s.map(function(N){return N+1});f(this,b,u);var w=this._data;for(p=0,v=s.length-1;p<v;p++)h=s[p],We(h,w.length),w=w[h];return h=s[s.length-1],We(h,w.length),w[h]=o,this};function t(s,o){if(!Cn(o))throw new TypeError("Invalid index");var u=o.isScalar();if(u)return s.get(o.min());var p=o.size();if(p.length!==s._size.length)throw new Fe(p.length,s._size.length);for(var v=o.min(),h=o.max(),b=0,w=s._size.length;b<w;b++)We(v[b],s._size[b]),We(h[b],s._size[b]);return new a(r(s._data,o,p.length,0),s._datatype)}function r(s,o,u,p){var v=p===u-1,h=o.dimension(p);return v?h.map(function(b){return We(b,s.length),s[b]}).valueOf():h.map(function(b){We(b,s.length);var w=s[b];return r(w,o,u,p+1)}).valueOf()}function i(s,o,u,p){if(!o||o.isIndex!==!0)throw new TypeError("Invalid index");var v=o.size(),h=o.isScalar(),b;if(Oe(u)?(b=u.size(),u=u.valueOf()):b=Pe(u),h){if(b.length!==0)throw new TypeError("Scalar expected");s.set(o.min(),u,p)}else{if(v.length<s._size.length)throw new Fe(v.length,s._size.length,"<");if(b.length<v.length){for(var w=0,N=0;v[w]===1&&b[w]===1;)w++;for(;v[w]===1;)N++,w++;u=bo(u,v.length,N,b)}if(!Tn(v,b))throw new Fe(v,b,">");var g=o.max().map(function(d){return d+1});f(s,g,p);var y=v.length,x=0;l(s._data,o,u,y,x)}return s}function l(s,o,u,p,v){var h=v===p-1,b=o.dimension(v);h?b.forEach(function(w,N){We(w),s[w]=u[N[0]]}):b.forEach(function(w,N){We(w),l(s[w],o,u[N[0]],p,v+1)})}a.prototype.resize=function(s,o,u){if(!rn(s))throw new TypeError("Array or Matrix expected");var p=s.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),v=u?this.clone():this;return m(v,p,o)};function m(s,o,u){if(o.length===0){for(var p=s._data;Xe(p);)p=p[0];return p}return s._size=o.slice(0),s._data=on(s._data,s._size,u),s}a.prototype.reshape=function(s,o){var u=o?this.clone():this;u._data=go(u._data,s);var p=u._size.reduce((v,h)=>v*h);return u._size=ni(s,p),u};function f(s,o,u){for(var p=s._size.slice(0),v=!1;p.length<o.length;)p.push(0),v=!0;for(var h=0,b=o.length;h<b;h++)o[h]>p[h]&&(p[h]=o[h],v=!0);v&&m(s,p,u)}a.prototype.clone=function(){var s=new a({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype});return s},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(s){var o=this,u=function h(b,w){return Xe(b)?b.map(function(N,g){return h(N,w.concat(g))}):s(b,w,o)},p=u(this._data,[]),v=this._datatype!==void 0?_n(p,Ke):void 0;return new a(p,v)},a.prototype.forEach=function(s){var o=this,u=function p(v,h){Xe(v)?v.forEach(function(b,w){p(b,h.concat(w))}):s(v,h,o)};u(this._data,[])},a.prototype[Symbol.iterator]=function*(){var s=function*o(u,p){if(Xe(u))for(var v=0;v<u.length;v++)yield*oo(o(u[v],p.concat(v)));else yield{value:u,index:p}};yield*oo(s(this._data,[]))},a.prototype.rows=function(){var s=[],o=this.size();if(o.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var u=this._data;for(var p of u)s.push(new a([p],this._datatype));return s},a.prototype.columns=function(){var s=this,o=[],u=this.size();if(u.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,v=function(w){var N=p.map(g=>[g[w]]);o.push(new a(N,s._datatype))},h=0;h<u[1];h++)v(h);return o},a.prototype.toArray=function(){return Ce(this._data)},a.prototype.valueOf=function(){return this._data},a.prototype.format=function(s){return Re(this._data,s)},a.prototype.toString=function(){return Re(this._data)},a.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(s){if(s){if(Ie(s)&&(s=s.toNumber()),!$e(s)||!Ae(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var o=s>0?s:0,u=s<0?-s:0,p=this._size[0],v=this._size[1],h=Math.min(p-u,v-o),b=[],w=0;w<h;w++)b[w]=this._data[w+u][w+o];return new a({data:b,size:[h],datatype:this._datatype})},a.diagonal=function(s,o,u,p){if(!Xe(s))throw new TypeError("Array expected, size parameter");if(s.length!==2)throw new Error("Only two dimensions matrix are supported");if(s=s.map(function(A){if(Ie(A)&&(A=A.toNumber()),!$e(A)||!Ae(A)||A<1)throw new Error("Size values must be positive integers");return A}),u){if(Ie(u)&&(u=u.toNumber()),!$e(u)||!Ae(u))throw new TypeError("The parameter k must be an integer number")}else u=0;var v=u>0?u:0,h=u<0?-u:0,b=s[0],w=s[1],N=Math.min(b-h,w-v),g;if(Xe(o)){if(o.length!==N)throw new Error("Invalid value array length");g=function(S){return o[S]}}else if(Oe(o)){var y=o.size();if(y.length!==1||y[0]!==N)throw new Error("Invalid matrix length");g=function(S){return o.get([S])}}else g=function(){return o};p||(p=Ie(g(0))?g(0).mul(0):0);var x=[];if(s.length>0){x=on(x,s,p);for(var d=0;d<N;d++)x[d+h][d+v]=g(d)}return new a({data:x,size:[b,w]})},a.fromJSON=function(s){return new a(s)},a.prototype.swapRows=function(s,o){if(!$e(s)||!Ae(s)||!$e(o)||!Ae(o))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(s,this._size[0]),We(o,this._size[0]),a._swapRows(s,o,this._data),this},a._swapRows=function(s,o,u){var p=u[s];u[s]=u[o],u[o]=p};function c(s){for(var o=0,u=s.length;o<u;o++){var p=s[o];Xe(p)?s[o]=c(p):p&&p.isMatrix===!0&&(s[o]=c(p.valueOf()))}return s}return a},{isClass:!0}),Ho="clone",Gh=["typed"],Vh=R(Ho,Gh,e=>{var{typed:n}=e;return n(Ho,{any:Ce})});function Go(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}function mn(e){for(var n=0;n<e.length;n++)if(rn(e[n]))return!0;return!1}function bt(e,n){Oe(e)&&(e=e.valueOf());for(var a=0,t=e.length;a<t;a++){var r=e[a];Array.isArray(r)?bt(r,n):n(r)}}function be(e,n,a){return e&&typeof e.map=="function"?e.map(function(t){return be(t,n)}):n(e)}function ba(e,n,a){var t=Array.isArray(e)?Pe(e):e.size();if(n<0||n>=t.length)throw new Jr(n,t.length);return Oe(e)?e.create(wa(e.valueOf(),n,a)):wa(e,n,a)}function wa(e,n,a){var t,r,i,l;if(n<=0)if(Array.isArray(e[0])){for(l=Go(e),r=[],t=0;t<l.length;t++)r[t]=wa(l[t],n-1,a);return r}else{for(i=e[0],t=1;t<e.length;t++)i=a(i,e[t]);return i}else{for(r=[],t=0;t<e.length;t++)r[t]=wa(e[t],n-1,a);return r}}function Vo(e,n,a,t,r,i,l,m,f,c,s){var o=e._values,u=e._index,p=e._ptr,v,h,b,w;if(t)for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w),t[w]=o[v]):(t[w]=m(t[w],o[v]),r[w]=i);else for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w)):r[w]=i}var Zo="isInteger",Zh=["typed"],Xh=R(Zo,Zh,e=>{var{typed:n}=e;return n(Zo,{number:Ae,BigNumber:function(t){return t.isInt()},Fraction:function(t){return t.d===1&&isFinite(t.n)},"Array | Matrix":function(t){return be(t,this)}})}),Kr="number",Gt="number, number";function Xo(e){return Math.abs(e)}Xo.signature=Kr;function Yo(e,n){return e+n}Yo.signature=Gt;function Wo(e,n){return e*n}Wo.signature=Gt;function Jo(e){return-e}Jo.signature=Kr;function Qo(e){return e}Qo.signature=Kr;function In(e){return Zp(e)}In.signature=Kr;function Ko(e){return e*e*e}Ko.signature=Kr;function jo(e){return Math.exp(e)}jo.signature=Kr;function es(e){return Xp(e)}es.signature=Kr;function rs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function gcd must be integer numbers");for(var a;n!==0;)a=e%n,e=n,n=a;return e<0?-e:e}rs.signature=Gt;function ts(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function lcm must be integer numbers");if(e===0||n===0)return 0;for(var a,t=e*n;n!==0;)a=n,n=e%a,e=a;return Math.abs(t/e)}ts.signature=Gt;function Yh(e,n){return Math.log(e)}function ns(e){return Gp(e)}ns.signature=Kr;function as(e){return Hp(e)}as.signature=Kr;function is(e,n){if(n>0)return e-n*Math.floor(e/n);if(n===0)return e;throw new Error("Cannot calculate mod for a negative divisor")}is.signature=Gt;function os(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,a=n<0;if(a&&(n=-n),n===0)throw new Error("Root must be non-zero");if(e<0&&Math.abs(n)%2!==1)throw new Error("Root must be odd when a is negative.");if(e===0)return a?1/0:0;if(!isFinite(e))return a?0:e;var t=Math.pow(Math.abs(e),1/n);return t=e<0?-t:t,a?1/t:t}function gi(e){return Dt(e)}gi.signature=Kr;function ss(e){return e*e}ss.signature=Kr;function us(e,n){var a,t,r,i=0,l=1,m=1,f=0;if(!Ae(e)||!Ae(n))throw new Error("Parameters in function xgcd must be integer numbers");for(;n;)t=Math.floor(e/n),r=e-t*n,a=i,i=l-t*i,l=a,a=m,m=f-t*m,f=a,e=n,n=r;var c;return e<0?c=[-e,-l,-f]:c=[e,e?l:0,f],c}us.signature=Gt;function cs(e,n){return e*e<1&&n===1/0||e*e>1&&n===-1/0?0:Math.pow(e,n)}cs.signature=Gt;function fs(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Ae(n)||n<0||n>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(fo(e,n))}var Wh="number",pn="number, number";function ls(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitAnd");return e&n}ls.signature=pn;function ms(e){if(!Ae(e))throw new Error("Integer expected in function bitNot");return~e}ms.signature=Wh;function ps(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitOr");return e|n}ps.signature=pn;function vs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitXor");return e^n}vs.signature=pn;function hs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function leftShift");return e<<n}hs.signature=pn;function ds(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightArithShift");return e>>n}ds.signature=pn;function gs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightLogShift");return e>>>n}gs.signature=pn;function wt(e,n){if(n<e)return 1;if(n===e)return n;var a=n+e>>1;return wt(e,a)*wt(a+1,n)}function ys(e,n){if(!Ae(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Ae(n)||n<0)throw new TypeError("Positive integer value expected in function combinations");if(n>e)throw new TypeError("k must be less than or equal to n");for(var a=e-n,t=1,r=n<a?a+1:n+1,i=2,l=n<a?n:a,m=r;m<=e;++m)for(t*=m;i<=l&&t%i===0;)t/=i,++i;return i<=l&&(t/=wt(i,l)),t}ys.signature="number, number";var Jh=Math.PI,Qh=2*Math.PI,Kh=Math.E,jh=1.618033988749895,ed="number",yi="number, number";function xs(e){return!e}xs.signature=ed;function bs(e,n){return!!(e||n)}bs.signature=yi;function ws(e,n){return!!e!=!!n}ws.signature=yi;function Ns(e,n){return!!(e&&n)}Ns.signature=yi;function xi(e){var n;if(Ae(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:wt(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*xi(1-e));if(e>=171.35)return 1/0;if(e>85){var a=e*e,t=a*e,r=t*e,i=r*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*a)-139/(51840*t)-571/(2488320*r)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,n=vn[0];for(var l=1;l<vn.length;++l)n+=vn[l]/(e+l);var m=e+Ms+.5;return Math.sqrt(2*Math.PI)*Math.pow(m,e+.5)*Math.exp(-m)*n}xi.signature="number";var Ms=4.7421875,vn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],As=.9189385332046728,rd=5,td=7,Ss=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Na(e){if(e<0)return NaN;if(e===0)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-Na(1-e);e=e-1;for(var n=e+rd+.5,a=Ss[0],t=td-1;t>=1;t--)a+=Ss[t]/(e+t);return As+(e+.5)*Math.log(n)-n+Math.log(a)}Na.signature="number";var Mr="number";function Es(e){return Kp(e)}Es.signature=Mr;function Cs(e){return Math.atan(1/e)}Cs.signature=Mr;function Os(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}Os.signature=Mr;function Ds(e){return Math.asin(1/e)}Ds.signature=Mr;function Ts(e){var n=1/e;return Math.log(n+Math.sqrt(n*n+1))}Ts.signature=Mr;function Bs(e){return Math.acos(1/e)}Bs.signature=Mr;function _s(e){var n=1/e,a=Math.sqrt(n*n-1);return Math.log(a+n)}_s.signature=Mr;function $s(e){return jp(e)}$s.signature=Mr;function Is(e){return ev(e)}Is.signature=Mr;function qs(e){return 1/Math.tan(e)}qs.signature=Mr;function Rs(e){var n=Math.exp(2*e);return(n+1)/(n-1)}Rs.signature=Mr;function Fs(e){return 1/Math.sin(e)}Fs.signature=Mr;function zs(e){return e===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Dt(e)}zs.signature=Mr;function Ps(e){return 1/Math.cos(e)}Ps.signature=Mr;function Us(e){return 2/(Math.exp(e)+Math.exp(-e))}Us.signature=Mr;function Ls(e){return tv(e)}Ls.signature=Mr;var Ma="number";function ks(e){return e<0}ks.signature=Ma;function Hs(e){return e>0}Hs.signature=Ma;function Gs(e){return e===0}Gs.signature=Ma;function Vs(e){return Number.isNaN(e)}Vs.signature=Ma;var Zs="isNegative",nd=["typed"],ad=R(Zs,nd,e=>{var{typed:n}=e;return n(Zs,{number:ks,BigNumber:function(t){return t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s<0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Xs="isNumeric",id=["typed"],od=R(Xs,id,e=>{var{typed:n}=e;return n(Xs,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(t){return be(t,this)}})}),Ys="hasNumericValue",sd=["typed","isNumeric"],ud=R(Ys,sd,e=>{var{typed:n,isNumeric:a}=e;return n(Ys,{string:function(r){return r.trim().length>0&&!isNaN(Number(r))},any:function(r){return a(r)}})}),Ws="isPositive",cd=["typed"],fd=R(Ws,cd,e=>{var{typed:n}=e;return n(Ws,{number:Hs,BigNumber:function(t){return!t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s>0&&t.n>0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Js="isZero",ld=["typed"],md=R(Js,ld,e=>{var{typed:n}=e;return n(Js,{number:Gs,BigNumber:function(t){return t.isZero()},Complex:function(t){return t.re===0&&t.im===0},Fraction:function(t){return t.d===1&&t.n===0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Qs="isNaN",pd=["typed"],vd=R(Qs,pd,e=>{var{typed:n}=e;return n(Qs,{number:Vs,BigNumber:function(t){return t.isNaN()},Fraction:function(t){return!1},Complex:function(t){return t.isNaN()},Unit:function(t){return Number.isNaN(t.value)},"Array | Matrix":function(t){return be(t,Number.isNaN)}})}),Ks="typeOf",hd=["typed"],dd=R(Ks,hd,e=>{var{typed:n}=e;return n(Ks,{any:Ke})});function st(e,n,a){if(a==null)return e.eq(n);if(e.eq(n))return!0;if(e.isNaN()||n.isNaN())return!1;if(e.isFinite()&&n.isFinite()){var t=e.minus(n).abs();if(t.isZero())return!0;var r=e.constructor.max(e.abs(),n.abs());return t.lte(r.times(a))}return!1}function gd(e,n,a){return Rr(e.re,n.re,a)&&Rr(e.im,n.im,a)}var Aa="equalScalar",yd=["typed","config"],xd=R(Aa,yd,e=>{var{typed:n,config:a}=e;return n(Aa,{"boolean, boolean":function(r,i){return r===i},"number, number":function(r,i){return Rr(r,i,a.epsilon)},"BigNumber, BigNumber":function(r,i){return r.eq(i)||st(r,i,a.epsilon)},"Fraction, Fraction":function(r,i){return r.equals(i)},"Complex, Complex":function(r,i){return gd(r,i,a.epsilon)},"Unit, Unit":function(r,i){if(!r.equalBase(i))throw new Error("Cannot compare units with different base");return this(r.value,i.value)}})});R(Aa,["typed","config"],e=>{var{typed:n,config:a}=e;return n(Aa,{"number, number":function(r,i){return Rr(r,i,a.epsilon)}})});var bd="SparseMatrix",wd=["typed","equalScalar","Matrix"],Nd=R(bd,wd,e=>{var{typed:n,equalScalar:a,Matrix:t}=e;function r(h,b){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!Br(b))throw new Error("Invalid datatype: "+b);if(Oe(h))i(this,h,b);else if(h&&Xe(h.index)&&Xe(h.ptr)&&Xe(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=b||h.datatype;else if(Xe(h))l(this,h,b);else{if(h)throw new TypeError("Unsupported type of data ("+Ke(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=b}}function i(h,b,w){b.type==="SparseMatrix"?(h._values=b._values?Ce(b._values):void 0,h._index=Ce(b._index),h._ptr=Ce(b._ptr),h._size=Ce(b._size),h._datatype=w||b._datatype):l(h,b.valueOf(),w||b._datatype)}function l(h,b,w){h._values=[],h._index=[],h._ptr=[],h._datatype=w;var N=b.length,g=0,y=a,x=0;if(Br(w)&&(y=n.find(a,[w,w])||a,x=n.convert(0,w)),N>0){var d=0;do{h._ptr.push(h._index.length);for(var A=0;A<N;A++){var S=b[A];if(Xe(S)){if(d===0&&g<S.length&&(g=S.length),d<S.length){var O=S[d];y(O,x)||(h._values.push(O),h._index.push(A))}}else d===0&&g<1&&(g=1),y(S,x)||(h._values.push(S),h._index.push(A))}d++}while(d<g)}h._ptr.push(h._index.length),h._size=[N,g]}r.prototype=new t,r.prototype.createSparseMatrix=function(h,b){return new r(h,b)},r.prototype.type="SparseMatrix",r.prototype.isSparseMatrix=!0,r.prototype.getDataType=function(){return _n(this._values,Ke)},r.prototype.storage=function(){return"sparse"},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(h,b){return new r(h,b)},r.prototype.density=function(){var h=this._size[0],b=this._size[1];return h!==0&&b!==0?this._index.length/(h*b):0},r.prototype.subset=function(h,b,w){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return m(this,h);case 2:case 3:return f(this,h,b,w);default:throw new SyntaxError("Wrong number of arguments")}};function m(h,b){if(!Cn(b))throw new TypeError("Invalid index");var w=b.isScalar();if(w)return h.get(b.min());var N=b.size();if(N.length!==h._size.length)throw new Fe(N.length,h._size.length);var g,y,x,d,A=b.min(),S=b.max();for(g=0,y=h._size.length;g<y;g++)We(A[g],h._size[g]),We(S[g],h._size[g]);var O=h._values,M=h._index,_=h._ptr,E=b.dimension(0),$=b.dimension(1),z=[],I=[];E.forEach(function(D,H){I[D]=H[0],z[D]=!0});var T=O?[]:void 0,B=[],G=[];return $.forEach(function(D){for(G.push(B.length),x=_[D],d=_[D+1];x<d;x++)g=M[x],z[g]===!0&&(B.push(I[g]),T&&T.push(O[x]))}),G.push(B.length),new r({values:T,index:B,ptr:G,size:N,datatype:h._datatype})}function f(h,b,w,N){if(!b||b.isIndex!==!0)throw new TypeError("Invalid index");var g=b.size(),y=b.isScalar(),x;if(Oe(w)?(x=w.size(),w=w.toArray()):x=Pe(w),y){if(x.length!==0)throw new TypeError("Scalar expected");h.set(b.min(),w,N)}else{if(g.length!==1&&g.length!==2)throw new Fe(g.length,h._size.length,"<");if(x.length<g.length){for(var d=0,A=0;g[d]===1&&x[d]===1;)d++;for(;g[d]===1;)A++,d++;w=bo(w,g.length,A,x)}if(!Tn(g,x))throw new Fe(g,x,">");if(g.length===1){var S=b.dimension(0);S.forEach(function(_,E){We(_),h.set([_,0],w[E[0]],N)})}else{var O=b.dimension(0),M=b.dimension(1);O.forEach(function(_,E){We(_),M.forEach(function($,z){We($),h.set([_,$],w[E[0]][z[0]],N)})})}}return h}r.prototype.get=function(h){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var b=h[0],w=h[1];We(b,this._size[0]),We(w,this._size[1]);var N=c(b,this._ptr[w],this._ptr[w+1],this._index);return N<this._ptr[w+1]&&this._index[N]===b?this._values[N]:0},r.prototype.set=function(h,b,w){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=h[0],g=h[1],y=this._size[0],x=this._size[1],d=a,A=0;Br(this._datatype)&&(d=n.find(a,[this._datatype,this._datatype])||a,A=n.convert(0,this._datatype)),(N>y-1||g>x-1)&&(u(this,Math.max(N+1,y),Math.max(g+1,x),w),y=this._size[0],x=this._size[1]),We(N,y),We(g,x);var S=c(N,this._ptr[g],this._ptr[g+1],this._index);return S<this._ptr[g+1]&&this._index[S]===N?d(b,A)?s(S,g,this._values,this._index,this._ptr):this._values[S]=b:o(S,N,g,b,this._values,this._index,this._ptr),this};function c(h,b,w,N){if(w-b===0)return w;for(var g=b;g<w;g++)if(N[g]===h)return g;return b}function s(h,b,w,N,g){w.splice(h,1),N.splice(h,1);for(var y=b+1;y<g.length;y++)g[y]--}function o(h,b,w,N,g,y,x){g.splice(h,0,N),y.splice(h,0,b);for(var d=w+1;d<x.length;d++)x[d]++}r.prototype.resize=function(h,b,w){if(!rn(h))throw new TypeError("Array or Matrix expected");var N=h.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(y){if(!$e(y)||!Ae(y)||y<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(N)+")")});var g=w?this.clone():this;return u(g,N[0],N[1],b)};function u(h,b,w,N){var g=N||0,y=a,x=0;Br(h._datatype)&&(y=n.find(a,[h._datatype,h._datatype])||a,x=n.convert(0,h._datatype),g=n.convert(g,h._datatype));var d=!y(g,x),A=h._size[0],S=h._size[1],O,M,_;if(w>S){for(M=S;M<w;M++)if(h._ptr[M]=h._values.length,d)for(O=0;O<A;O++)h._values.push(g),h._index.push(O);h._ptr[w]=h._values.length}else w<S&&(h._ptr.splice(w+1,S-w),h._values.splice(h._ptr[w],h._values.length),h._index.splice(h._ptr[w],h._index.length));if(S=w,b>A){if(d){var E=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]+E,_=h._ptr[M+1]+E;var $=0;for(O=A;O<b;O++,$++)h._values.splice(_+$,0,g),h._index.splice(_+$,0,O),E++}h._ptr[S]=h._values.length}}else if(b<A){var z=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]-z;var I=h._ptr[M],T=h._ptr[M+1]-z;for(_=I;_<T;_++)O=h._index[_],O>b-1&&(h._values.splice(_,1),h._index.splice(_,1),z++)}h._ptr[M]=h._values.length}return h._size[0]=b,h._size[1]=w,h}r.prototype.reshape=function(h,b){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");h.forEach(function(D){if(!$e(D)||!Ae(D)||D<=-2||D===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Re(h)+")")});var w=this._size[0]*this._size[1];h=ni(h,w);var N=h[0]*h[1];if(w!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=b?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return g;for(var y=[],x=0;x<g._ptr.length;x++)for(var d=0;d<g._ptr[x+1]-g._ptr[x];d++)y.push(x);for(var A=g._values.slice(),S=g._index.slice(),O=0;O<g._index.length;O++){var M=S[O],_=y[O],E=M*g._size[1]+_;y[O]=E%h[1],S[O]=Math.floor(E/h[1])}g._values.length=0,g._index.length=0,g._ptr.length=h[1]+1,g._size=h.slice();for(var $=0;$<g._ptr.length;$++)g._ptr[$]=0;for(var z=0;z<A.length;z++){var I=S[z],T=y[z],B=A[z],G=c(I,g._ptr[T],g._ptr[T+1],g._index);o(G,I,T,B,g._values,g._index,g._ptr)}return g},r.prototype.clone=function(){var h=new r({values:this._values?Ce(this._values):void 0,index:Ce(this._index),ptr:Ce(this._ptr),size:Ce(this._size),datatype:this._datatype});return h},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(h,b){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var w=this,N=this._size[0],g=this._size[1],y=function(d,A,S){return h(d,[A,S],w)};return p(this,0,N-1,0,g-1,y,b)};function p(h,b,w,N,g,y,x){var d=[],A=[],S=[],O=a,M=0;Br(h._datatype)&&(O=n.find(a,[h._datatype,h._datatype])||a,M=n.convert(0,h._datatype));for(var _=function(V,K,te){V=y(V,K,te),O(V,M)||(d.push(V),A.push(K))},E=N;E<=g;E++){S.push(d.length);var $=h._ptr[E],z=h._ptr[E+1];if(x)for(var I=$;I<z;I++){var T=h._index[I];T>=b&&T<=w&&_(h._values[I],T-b,E-N)}else{for(var B={},G=$;G<z;G++){var D=h._index[G];B[D]=h._values[G]}for(var H=b;H<=w;H++){var W=H in B?B[H]:0;_(W,H-b,E-N)}}}return S.push(d.length),new r({values:d,index:A,ptr:S,size:[w-b+1,g-N+1]})}r.prototype.forEach=function(h,b){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var w=this,N=this._size[0],g=this._size[1],y=0;y<g;y++){var x=this._ptr[y],d=this._ptr[y+1];if(b)for(var A=x;A<d;A++){var S=this._index[A];h(this._values[A],[S,y],w)}else{for(var O={},M=x;M<d;M++){var _=this._index[M];O[_]=this._values[M]}for(var E=0;E<N;E++){var $=E in O?O[E]:0;h($,[E,y],w)}}}},r.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],b=0;b<h;b++)for(var w=this._ptr[b],N=this._ptr[b+1],g=w;g<N;g++){var y=this._index[g];yield{value:this._values[g],index:[y,b]}}},r.prototype.toArray=function(){return v(this._values,this._index,this._ptr,this._size,!0)},r.prototype.valueOf=function(){return v(this._values,this._index,this._ptr,this._size,!1)};function v(h,b,w,N,g){var y=N[0],x=N[1],d=[],A,S;for(A=0;A<y;A++)for(d[A]=[],S=0;S<x;S++)d[A][S]=0;for(S=0;S<x;S++)for(var O=w[S],M=w[S+1],_=O;_<M;_++)A=b[_],d[A][S]=h?g?Ce(h[_]):h[_]:1;return d}return r.prototype.format=function(h){for(var b=this._size[0],w=this._size[1],N=this.density(),g="Sparse Matrix ["+Re(b,h)+" x "+Re(w,h)+"] density: "+Re(N,h)+`
26
+ **/var Eh=2e3,Se={s:1,n:0,d:1};function xt(e,n){if(isNaN(e=parseInt(e,10)))throw ya();return e*n}function ur(e,n){if(n===0)throw hi();var a=Object.create(zr.prototype);a.s=e<0?-1:1,e=e<0?-e:e;var t=ln(e,n);return a.n=e/t,a.d=n/t,a}function Lo(e){for(var n={},a=e,t=2,r=4;r<=a;){for(;a%t===0;)a/=t,n[t]=(n[t]||0)+1;r+=1+2*t++}return a!==e?a>1&&(n[a]=(n[a]||0)+1):n[e]=(n[e]||0)+1,n}var Fr=function(e,n){var a=0,t=1,r=1,i=0,l=0,m=0,f=1,c=1,s=0,o=1,u=1,p=1,v=1e7,h;if(e!=null)if(n!==void 0){if(a=e,t=n,r=a*t,a%1!==0||t%1!==0)throw Th()}else switch(typeof e){case"object":{if("d"in e&&"n"in e)a=e.n,t=e.d,"s"in e&&(a*=e.s);else if(0 in e)a=e[0],1 in e&&(t=e[1]);else throw ya();r=a*t;break}case"number":{if(e<0&&(r=e,e=-e),e%1===0)a=e;else if(e>0){for(e>=1&&(c=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=c);o<=v&&p<=v;)if(h=(s+u)/(o+p),e===h){o+p<=v?(a=s+u,t=o+p):p>o?(a=u,t=p):(a=s,t=o);break}else e>h?(s+=u,o+=p):(u+=s,p+=o),o>v?(a=u,t=p):(a=s,t=o);a*=c}else(isNaN(e)||isNaN(n))&&(t=a=NaN);break}case"string":{if(o=e.match(/\d+|./g),o===null)throw ya();if(o[s]==="-"?(r=-1,s++):o[s]==="+"&&s++,o.length===s+1?l=xt(o[s++],r):o[s+1]==="."||o[s]==="."?(o[s]!=="."&&(i=xt(o[s++],r)),s++,(s+1===o.length||o[s+1]==="("&&o[s+3]===")"||o[s+1]==="'"&&o[s+3]==="'")&&(l=xt(o[s],r),f=Math.pow(10,o[s].length),s++),(o[s]==="("&&o[s+2]===")"||o[s]==="'"&&o[s+2]==="'")&&(m=xt(o[s+1],r),c=Math.pow(10,o[s+1].length)-1,s+=3)):o[s+1]==="/"||o[s+1]===":"?(l=xt(o[s],r),f=xt(o[s+2],1),s+=3):o[s+3]==="/"&&o[s+1]===" "&&(i=xt(o[s],r),l=xt(o[s+2],r),f=xt(o[s+4],1),s+=5),o.length<=s){t=f*c,r=a=m+t*i+c*l;break}}default:throw ya()}if(t===0)throw hi();Se.s=r<0?-1:1,Se.n=Math.abs(a),Se.d=Math.abs(t)};function Ch(e,n,a){for(var t=1;n>0;e=e*e%a,n>>=1)n&1&&(t=t*e%a);return t}function Oh(e,n){for(;n%2===0;n/=2);for(;n%5===0;n/=5);if(n===1)return 0;for(var a=10%n,t=1;a!==1;t++)if(a=a*10%n,t>Eh)return 0;return t}function Dh(e,n,a){for(var t=1,r=Ch(10,a,n),i=0;i<300;i++){if(t===r)return i;t=t*10%n,r=r*10%n}return 0}function ln(e,n){if(!e)return n;if(!n)return e;for(;;){if(e%=n,!e)return n;if(n%=e,!n)return e}}function zr(e,n){if(Fr(e,n),this instanceof zr)e=ln(Se.d,Se.n),this.s=Se.s,this.n=Se.n/e,this.d=Se.d/e;else return ur(Se.s*Se.n,Se.d)}var hi=function(){return new Error("Division by Zero")},ya=function(){return new Error("Invalid argument")},Th=function(){return new Error("Parameters must be integer")};zr.prototype={s:1,n:0,d:1,abs:function(){return ur(this.n,this.d)},neg:function(){return ur(-this.s*this.n,this.d)},add:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d+Se.s*this.d*Se.n,this.d*Se.d)},sub:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d-Se.s*this.d*Se.n,this.d*Se.d)},mul:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.n,this.d*Se.d)},div:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.d,this.d*Se.n)},clone:function(){return ur(this.s*this.n,this.d)},mod:function(e,n){if(isNaN(this.n)||isNaN(this.d))return new zr(NaN);if(e===void 0)return ur(this.s*this.n%this.d,1);if(Fr(e,n),Se.n===0&&this.d===0)throw hi();return ur(this.s*(Se.d*this.n)%(Se.n*this.d),Se.d*this.d)},gcd:function(e,n){return Fr(e,n),ur(ln(Se.n,this.n)*ln(Se.d,this.d),Se.d*this.d)},lcm:function(e,n){return Fr(e,n),Se.n===0&&this.n===0?ur(0,1):ur(Se.n*this.n,ln(Se.n,this.n)*ln(Se.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,n){return Fr(e,n),ur(this.s*Math.round(this.n*Se.d/(this.d*Se.n))*Se.n,Se.d)},inverse:function(){return ur(this.s*this.d,this.n)},pow:function(e,n){if(Fr(e,n),Se.d===1)return Se.s<0?ur(Math.pow(this.s*this.d,Se.n),Math.pow(this.n,Se.n)):ur(Math.pow(this.s*this.n,Se.n),Math.pow(this.d,Se.n));if(this.s<0)return null;var a=Lo(this.n),t=Lo(this.d),r=1,i=1;for(var l in a)if(l!=="1"){if(l==="0"){r=0;break}if(a[l]*=Se.n,a[l]%Se.d===0)a[l]/=Se.d;else return null;r*=Math.pow(l,a[l])}for(var l in t)if(l!=="1"){if(t[l]*=Se.n,t[l]%Se.d===0)t[l]/=Se.d;else return null;i*=Math.pow(l,t[l])}return Se.s<0?ur(i,r):ur(r,i)},equals:function(e,n){return Fr(e,n),this.s*this.n*Se.d===Se.s*Se.n*this.d},compare:function(e,n){Fr(e,n);var a=this.s*this.n*Se.d-Se.s*Se.n*this.d;return(0<a)-(a<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var n=this.abs(),a=n.toContinued(),t=1;t<a.length;t++){for(var r=ur(a[t-1],1),i=t-2;i>=0;i--)r=r.inverse().add(a[i]);if(Math.abs(r.sub(n).valueOf())<e)return r.mul(this.s)}return this},divisible:function(e,n){return Fr(e,n),!(!(Se.n*this.d)||this.n*Se.d%(Se.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,a+=" ",t%=r),a+=t,a+="/",a+=r),a},toLatex:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,t%=r),a+="\\frac{",a+=t,a+="}{",a+=r,a+="}"),a},toContinued:function(){var e,n=this.n,a=this.d,t=[];if(isNaN(n)||isNaN(a))return t;do t.push(Math.floor(n/a)),e=n%a,n=a,a=e;while(n!==1);return t},toString:function(e){var n=this.n,a=this.d;if(isNaN(n)||isNaN(a))return"NaN";e=e||15;var t=Oh(n,a),r=Dh(n,a,t),i=this.s<0?"-":"";if(i+=n/a|0,n%=a,n*=10,n&&(i+="."),t){for(var l=r;l--;)i+=n/a|0,n%=a,n*=10;i+="(";for(var l=t;l--;)i+=n/a|0,n%=a,n*=10;i+=")"}else for(var l=e;n&&l--;)i+=n/a|0,n%=a,n*=10;return i}};var Bh="Fraction",_h=[],$h=R(Bh,_h,()=>(zr.prototype.type="Fraction",zr.prototype.isFraction=!0,zr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},zr.fromJSON=function(e){return new zr(e)},zr),{isClass:!0}),Ih="Range",qh=[],Rh=R(Ih,qh,()=>{function e(n,a,t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var r=n!=null,i=a!=null,l=t!=null;if(r){if(_e(n))n=n.toNumber();else if(typeof n!="number")throw new TypeError("Parameter start must be a number")}if(i){if(_e(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter end must be a number")}if(l){if(_e(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter step must be a number")}this.start=r?parseFloat(n):0,this.end=i?parseFloat(a):0,this.step=l?parseFloat(t):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(n){if(typeof n!="string")return null;var a=n.split(":"),t=a.map(function(i){return parseFloat(i)}),r=t.some(function(i){return isNaN(i)});if(r)return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var n=0,a=this.start,t=this.step,r=this.end,i=r-a;return Dt(t)===Dt(i)?n=Math.ceil(i/t):i===0&&(n=0),isNaN(n)&&(n=0),[n]},e.prototype.min=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start:this.start+(n-1)*this.step},e.prototype.max=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start+(n-1)*this.step:this.start},e.prototype.forEach=function(n){var a=this.start,t=this.step,r=this.end,i=0;if(t>0)for(;a<r;)n(a,[i],this),a+=t,i++;else if(t<0)for(;a>r;)n(a,[i],this),a+=t,i++},e.prototype.map=function(n){var a=[];return this.forEach(function(t,r,i){a[r[0]]=n(t,r,i)}),a},e.prototype.toArray=function(){var n=[];return this.forEach(function(a,t){n[t[0]]=a}),n},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(n){var a=Ht(this.start,n);return this.step!==1&&(a+=":"+Ht(this.step,n)),a+=":"+Ht(this.end,n),a},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(n){return new e(n.start,n.end,n.step)},e},{isClass:!0}),Fh="Matrix",zh=[],Ph=R(Fh,zh,()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(n,a){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(n,a,t){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(n){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(n,a,t){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(n,a){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(n,a){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(n,a){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(n){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(n){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0}),Uh="DenseMatrix",Lh=["Matrix"],kh=R(Uh,Lh,e=>{var{Matrix:n}=e;function a(s,o){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(o&&!_r(o))throw new Error("Invalid datatype: "+o);if(Oe(s))s.type==="DenseMatrix"?(this._data=Ce(s._data),this._size=Ce(s._size),this._datatype=o||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=o||s._datatype);else if(s&&Xe(s.data)&&Xe(s.size))this._data=s.data,this._size=s.size,vo(this._data,this._size),this._datatype=o||s.datatype;else if(Xe(s))this._data=c(s),this._size=Pe(this._data),vo(this._data,this._size),this._datatype=o;else{if(s)throw new TypeError("Unsupported type of data ("+Ke(s)+")");this._data=[],this._size=[0],this._datatype=o}}a.prototype=new n,a.prototype.createDenseMatrix=function(s,o){return new a(s,o)},a.prototype.type="DenseMatrix",a.prototype.isDenseMatrix=!0,a.prototype.getDataType=function(){return Bn(this._data,Ke)},a.prototype.storage=function(){return"dense"},a.prototype.datatype=function(){return this._datatype},a.prototype.create=function(s,o){return new a(s,o)},a.prototype.subset=function(s,o,u){switch(arguments.length){case 1:return t(this,s);case 2:case 3:return i(this,s,o,u);default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.get=function(s){if(!Xe(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Fe(s.length,this._size.length);for(var o=0;o<s.length;o++)We(s[o],this._size[o]);for(var u=this._data,p=0,v=s.length;p<v;p++){var h=s[p];We(h,u.length),u=u[h]}return u},a.prototype.set=function(s,o,u){if(!Xe(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Fe(s.length,this._size.length,"<");var p,v,h,b=s.map(function(N){return N+1});f(this,b,u);var w=this._data;for(p=0,v=s.length-1;p<v;p++)h=s[p],We(h,w.length),w=w[h];return h=s[s.length-1],We(h,w.length),w[h]=o,this};function t(s,o){if(!En(o))throw new TypeError("Invalid index");var u=o.isScalar();if(u)return s.get(o.min());var p=o.size();if(p.length!==s._size.length)throw new Fe(p.length,s._size.length);for(var v=o.min(),h=o.max(),b=0,w=s._size.length;b<w;b++)We(v[b],s._size[b]),We(h[b],s._size[b]);return new a(r(s._data,o,p.length,0),s._datatype)}function r(s,o,u,p){var v=p===u-1,h=o.dimension(p);return v?h.map(function(b){return We(b,s.length),s[b]}).valueOf():h.map(function(b){We(b,s.length);var w=s[b];return r(w,o,u,p+1)}).valueOf()}function i(s,o,u,p){if(!o||o.isIndex!==!0)throw new TypeError("Invalid index");var v=o.size(),h=o.isScalar(),b;if(Oe(u)?(b=u.size(),u=u.valueOf()):b=Pe(u),h){if(b.length!==0)throw new TypeError("Scalar expected");s.set(o.min(),u,p)}else{if(v.length<s._size.length)throw new Fe(v.length,s._size.length,"<");if(b.length<v.length){for(var w=0,N=0;v[w]===1&&b[w]===1;)w++;for(;v[w]===1;)N++,w++;u=xo(u,v.length,N,b)}if(!Dn(v,b))throw new Fe(v,b,">");var g=o.max().map(function(d){return d+1});f(s,g,p);var y=v.length,x=0;l(s._data,o,u,y,x)}return s}function l(s,o,u,p,v){var h=v===p-1,b=o.dimension(v);h?b.forEach(function(w,N){We(w),s[w]=u[N[0]]}):b.forEach(function(w,N){We(w),l(s[w],o,u[N[0]],p,v+1)})}a.prototype.resize=function(s,o,u){if(!rn(s))throw new TypeError("Array or Matrix expected");var p=s.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),v=u?this.clone():this;return m(v,p,o)};function m(s,o,u){if(o.length===0){for(var p=s._data;Xe(p);)p=p[0];return p}return s._size=o.slice(0),s._data=on(s._data,s._size,u),s}a.prototype.reshape=function(s,o){var u=o?this.clone():this;u._data=ho(u._data,s);var p=u._size.reduce((v,h)=>v*h);return u._size=ti(s,p),u};function f(s,o,u){for(var p=s._size.slice(0),v=!1;p.length<o.length;)p.push(0),v=!0;for(var h=0,b=o.length;h<b;h++)o[h]>p[h]&&(p[h]=o[h],v=!0);v&&m(s,p,u)}a.prototype.clone=function(){var s=new a({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype});return s},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(s){var o=this,u=function h(b,w){return Xe(b)?b.map(function(N,g){return h(N,w.concat(g))}):s(b,w,o)},p=u(this._data,[]),v=this._datatype!==void 0?Bn(p,Ke):void 0;return new a(p,v)},a.prototype.forEach=function(s){var o=this,u=function p(v,h){Xe(v)?v.forEach(function(b,w){p(b,h.concat(w))}):s(v,h,o)};u(this._data,[])},a.prototype[Symbol.iterator]=function*(){var s=function*o(u,p){if(Xe(u))for(var v=0;v<u.length;v++)yield*io(o(u[v],p.concat(v)));else yield{value:u,index:p}};yield*io(s(this._data,[]))},a.prototype.rows=function(){var s=[],o=this.size();if(o.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var u=this._data;for(var p of u)s.push(new a([p],this._datatype));return s},a.prototype.columns=function(){var s=this,o=[],u=this.size();if(u.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,v=function(w){var N=p.map(g=>[g[w]]);o.push(new a(N,s._datatype))},h=0;h<u[1];h++)v(h);return o},a.prototype.toArray=function(){return Ce(this._data)},a.prototype.valueOf=function(){return this._data},a.prototype.format=function(s){return Re(this._data,s)},a.prototype.toString=function(){return Re(this._data)},a.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(s){if(s){if(_e(s)&&(s=s.toNumber()),!Be(s)||!Ae(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var o=s>0?s:0,u=s<0?-s:0,p=this._size[0],v=this._size[1],h=Math.min(p-u,v-o),b=[],w=0;w<h;w++)b[w]=this._data[w+u][w+o];return new a({data:b,size:[h],datatype:this._datatype})},a.diagonal=function(s,o,u,p){if(!Xe(s))throw new TypeError("Array expected, size parameter");if(s.length!==2)throw new Error("Only two dimensions matrix are supported");if(s=s.map(function(A){if(_e(A)&&(A=A.toNumber()),!Be(A)||!Ae(A)||A<1)throw new Error("Size values must be positive integers");return A}),u){if(_e(u)&&(u=u.toNumber()),!Be(u)||!Ae(u))throw new TypeError("The parameter k must be an integer number")}else u=0;var v=u>0?u:0,h=u<0?-u:0,b=s[0],w=s[1],N=Math.min(b-h,w-v),g;if(Xe(o)){if(o.length!==N)throw new Error("Invalid value array length");g=function(S){return o[S]}}else if(Oe(o)){var y=o.size();if(y.length!==1||y[0]!==N)throw new Error("Invalid matrix length");g=function(S){return o.get([S])}}else g=function(){return o};p||(p=_e(g(0))?g(0).mul(0):0);var x=[];if(s.length>0){x=on(x,s,p);for(var d=0;d<N;d++)x[d+h][d+v]=g(d)}return new a({data:x,size:[b,w]})},a.fromJSON=function(s){return new a(s)},a.prototype.swapRows=function(s,o){if(!Be(s)||!Ae(s)||!Be(o)||!Ae(o))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(s,this._size[0]),We(o,this._size[0]),a._swapRows(s,o,this._data),this},a._swapRows=function(s,o,u){var p=u[s];u[s]=u[o],u[o]=p};function c(s){for(var o=0,u=s.length;o<u;o++){var p=s[o];Xe(p)?s[o]=c(p):p&&p.isMatrix===!0&&(s[o]=c(p.valueOf()))}return s}return a},{isClass:!0}),ko="clone",Hh=["typed"],Gh=R(ko,Hh,e=>{var{typed:n}=e;return n(ko,{any:Ce})});function Ho(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}function mn(e){for(var n=0;n<e.length;n++)if(rn(e[n]))return!0;return!1}function bt(e,n){Oe(e)&&(e=e.valueOf());for(var a=0,t=e.length;a<t;a++){var r=e[a];Array.isArray(r)?bt(r,n):n(r)}}function be(e,n,a){return e&&typeof e.map=="function"?e.map(function(t){return be(t,n)}):n(e)}function xa(e,n,a){var t=Array.isArray(e)?Pe(e):e.size();if(n<0||n>=t.length)throw new Kr(n,t.length);return Oe(e)?e.create(ba(e.valueOf(),n,a)):ba(e,n,a)}function ba(e,n,a){var t,r,i,l;if(n<=0)if(Array.isArray(e[0])){for(l=Ho(e),r=[],t=0;t<l.length;t++)r[t]=ba(l[t],n-1,a);return r}else{for(i=e[0],t=1;t<e.length;t++)i=a(i,e[t]);return i}else{for(r=[],t=0;t<e.length;t++)r[t]=ba(e[t],n-1,a);return r}}function Go(e,n,a,t,r,i,l,m,f,c,s){var o=e._values,u=e._index,p=e._ptr,v,h,b,w;if(t)for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w),t[w]=o[v]):(t[w]=m(t[w],o[v]),r[w]=i);else for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w)):r[w]=i}var Vo="isInteger",Vh=["typed"],Zh=R(Vo,Vh,e=>{var{typed:n}=e;return n(Vo,{number:Ae,BigNumber:function(t){return t.isInt()},Fraction:function(t){return t.d===1&&isFinite(t.n)},"Array | Matrix":function(t){return be(t,this)}})}),et="number",Gt="number, number";function Zo(e){return Math.abs(e)}Zo.signature=et;function Xo(e,n){return e+n}Xo.signature=Gt;function Yo(e,n){return e*n}Yo.signature=Gt;function Wo(e){return-e}Wo.signature=et;function Jo(e){return e}Jo.signature=et;function $n(e){return Vp(e)}$n.signature=et;function Qo(e){return e*e*e}Qo.signature=et;function Ko(e){return Math.exp(e)}Ko.signature=et;function jo(e){return Zp(e)}jo.signature=et;function es(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function gcd must be integer numbers");for(var a;n!==0;)a=e%n,e=n,n=a;return e<0?-e:e}es.signature=Gt;function rs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function lcm must be integer numbers");if(e===0||n===0)return 0;for(var a,t=e*n;n!==0;)a=n,n=e%a,e=a;return Math.abs(t/e)}rs.signature=Gt;function Xh(e,n){return Math.log(e)}function ts(e){return Hp(e)}ts.signature=et;function ns(e){return kp(e)}ns.signature=et;function as(e,n){if(n>0)return e-n*Math.floor(e/n);if(n===0)return e;throw new Error("Cannot calculate mod for a negative divisor")}as.signature=Gt;function is(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,a=n<0;if(a&&(n=-n),n===0)throw new Error("Root must be non-zero");if(e<0&&Math.abs(n)%2!==1)throw new Error("Root must be odd when a is negative.");if(e===0)return a?1/0:0;if(!isFinite(e))return a?0:e;var t=Math.pow(Math.abs(e),1/n);return t=e<0?-t:t,a?1/t:t}function di(e){return Dt(e)}di.signature=et;function os(e){return e*e}os.signature=et;function ss(e,n){var a,t,r,i=0,l=1,m=1,f=0;if(!Ae(e)||!Ae(n))throw new Error("Parameters in function xgcd must be integer numbers");for(;n;)t=Math.floor(e/n),r=e-t*n,a=i,i=l-t*i,l=a,a=m,m=f-t*m,f=a,e=n,n=r;var c;return e<0?c=[-e,-l,-f]:c=[e,e?l:0,f],c}ss.signature=Gt;function us(e,n){return e*e<1&&n===1/0||e*e>1&&n===-1/0?0:Math.pow(e,n)}us.signature=Gt;function cs(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Ae(n)||n<0||n>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(co(e,n))}var Yh="number",pn="number, number";function fs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitAnd");return e&n}fs.signature=pn;function ls(e){if(!Ae(e))throw new Error("Integer expected in function bitNot");return~e}ls.signature=Yh;function ms(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitOr");return e|n}ms.signature=pn;function ps(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitXor");return e^n}ps.signature=pn;function vs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function leftShift");return e<<n}vs.signature=pn;function hs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightArithShift");return e>>n}hs.signature=pn;function ds(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightLogShift");return e>>>n}ds.signature=pn;function wt(e,n){if(n<e)return 1;if(n===e)return n;var a=n+e>>1;return wt(e,a)*wt(a+1,n)}function gs(e,n){if(!Ae(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Ae(n)||n<0)throw new TypeError("Positive integer value expected in function combinations");if(n>e)throw new TypeError("k must be less than or equal to n");for(var a=e-n,t=1,r=n<a?a+1:n+1,i=2,l=n<a?n:a,m=r;m<=e;++m)for(t*=m;i<=l&&t%i===0;)t/=i,++i;return i<=l&&(t/=wt(i,l)),t}gs.signature="number, number";var Wh=Math.PI,Jh=2*Math.PI,Qh=Math.E,Kh=1.618033988749895,jh="number",gi="number, number";function ys(e){return!e}ys.signature=jh;function xs(e,n){return!!(e||n)}xs.signature=gi;function bs(e,n){return!!e!=!!n}bs.signature=gi;function ws(e,n){return!!(e&&n)}ws.signature=gi;function yi(e){var n;if(Ae(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:wt(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*yi(1-e));if(e>=171.35)return 1/0;if(e>85){var a=e*e,t=a*e,r=t*e,i=r*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*a)-139/(51840*t)-571/(2488320*r)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,n=vn[0];for(var l=1;l<vn.length;++l)n+=vn[l]/(e+l);var m=e+Ns+.5;return Math.sqrt(2*Math.PI)*Math.pow(m,e+.5)*Math.exp(-m)*n}yi.signature="number";var Ns=4.7421875,vn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Ms=.9189385332046728,ed=5,rd=7,As=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function wa(e){if(e<0)return NaN;if(e===0)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-wa(1-e);e=e-1;for(var n=e+ed+.5,a=As[0],t=rd-1;t>=1;t--)a+=As[t]/(e+t);return Ms+(e+.5)*Math.log(n)-n+Math.log(a)}wa.signature="number";var Mr="number";function Ss(e){return Qp(e)}Ss.signature=Mr;function Es(e){return Math.atan(1/e)}Es.signature=Mr;function Cs(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}Cs.signature=Mr;function Os(e){return Math.asin(1/e)}Os.signature=Mr;function Ds(e){var n=1/e;return Math.log(n+Math.sqrt(n*n+1))}Ds.signature=Mr;function Ts(e){return Math.acos(1/e)}Ts.signature=Mr;function Bs(e){var n=1/e,a=Math.sqrt(n*n-1);return Math.log(a+n)}Bs.signature=Mr;function _s(e){return Kp(e)}_s.signature=Mr;function $s(e){return jp(e)}$s.signature=Mr;function Is(e){return 1/Math.tan(e)}Is.signature=Mr;function qs(e){var n=Math.exp(2*e);return(n+1)/(n-1)}qs.signature=Mr;function Rs(e){return 1/Math.sin(e)}Rs.signature=Mr;function Fs(e){return e===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Dt(e)}Fs.signature=Mr;function zs(e){return 1/Math.cos(e)}zs.signature=Mr;function Ps(e){return 2/(Math.exp(e)+Math.exp(-e))}Ps.signature=Mr;function Us(e){return rv(e)}Us.signature=Mr;var Na="number";function Ls(e){return e<0}Ls.signature=Na;function ks(e){return e>0}ks.signature=Na;function Hs(e){return e===0}Hs.signature=Na;function Gs(e){return Number.isNaN(e)}Gs.signature=Na;var Vs="isNegative",td=["typed"],nd=R(Vs,td,e=>{var{typed:n}=e;return n(Vs,{number:Ls,BigNumber:function(t){return t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s<0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Zs="isNumeric",ad=["typed"],id=R(Zs,ad,e=>{var{typed:n}=e;return n(Zs,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(t){return be(t,this)}})}),Xs="hasNumericValue",od=["typed","isNumeric"],sd=R(Xs,od,e=>{var{typed:n,isNumeric:a}=e;return n(Xs,{string:function(r){return r.trim().length>0&&!isNaN(Number(r))},any:function(r){return a(r)}})}),Ys="isPositive",ud=["typed"],cd=R(Ys,ud,e=>{var{typed:n}=e;return n(Ys,{number:ks,BigNumber:function(t){return!t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s>0&&t.n>0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ws="isZero",fd=["typed"],ld=R(Ws,fd,e=>{var{typed:n}=e;return n(Ws,{number:Hs,BigNumber:function(t){return t.isZero()},Complex:function(t){return t.re===0&&t.im===0},Fraction:function(t){return t.d===1&&t.n===0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Js="isNaN",md=["typed"],pd=R(Js,md,e=>{var{typed:n}=e;return n(Js,{number:Gs,BigNumber:function(t){return t.isNaN()},Fraction:function(t){return!1},Complex:function(t){return t.isNaN()},Unit:function(t){return Number.isNaN(t.value)},"Array | Matrix":function(t){return be(t,Number.isNaN)}})}),Qs="typeOf",vd=["typed"],hd=R(Qs,vd,e=>{var{typed:n}=e;return n(Qs,{any:Ke})});function st(e,n,a){if(a==null)return e.eq(n);if(e.eq(n))return!0;if(e.isNaN()||n.isNaN())return!1;if(e.isFinite()&&n.isFinite()){var t=e.minus(n).abs();if(t.isZero())return!0;var r=e.constructor.max(e.abs(),n.abs());return t.lte(r.times(a))}return!1}function dd(e,n,a){return Rr(e.re,n.re,a)&&Rr(e.im,n.im,a)}var Ma="equalScalar",gd=["typed","config"],yd=R(Ma,gd,e=>{var{typed:n,config:a}=e;return n(Ma,{"boolean, boolean":function(r,i){return r===i},"number, number":function(r,i){return Rr(r,i,a.epsilon)},"BigNumber, BigNumber":function(r,i){return r.eq(i)||st(r,i,a.epsilon)},"Fraction, Fraction":function(r,i){return r.equals(i)},"Complex, Complex":function(r,i){return dd(r,i,a.epsilon)},"Unit, Unit":function(r,i){if(!r.equalBase(i))throw new Error("Cannot compare units with different base");return this(r.value,i.value)}})});R(Ma,["typed","config"],e=>{var{typed:n,config:a}=e;return n(Ma,{"number, number":function(r,i){return Rr(r,i,a.epsilon)}})});var xd="SparseMatrix",bd=["typed","equalScalar","Matrix"],wd=R(xd,bd,e=>{var{typed:n,equalScalar:a,Matrix:t}=e;function r(h,b){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!_r(b))throw new Error("Invalid datatype: "+b);if(Oe(h))i(this,h,b);else if(h&&Xe(h.index)&&Xe(h.ptr)&&Xe(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=b||h.datatype;else if(Xe(h))l(this,h,b);else{if(h)throw new TypeError("Unsupported type of data ("+Ke(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=b}}function i(h,b,w){b.type==="SparseMatrix"?(h._values=b._values?Ce(b._values):void 0,h._index=Ce(b._index),h._ptr=Ce(b._ptr),h._size=Ce(b._size),h._datatype=w||b._datatype):l(h,b.valueOf(),w||b._datatype)}function l(h,b,w){h._values=[],h._index=[],h._ptr=[],h._datatype=w;var N=b.length,g=0,y=a,x=0;if(_r(w)&&(y=n.find(a,[w,w])||a,x=n.convert(0,w)),N>0){var d=0;do{h._ptr.push(h._index.length);for(var A=0;A<N;A++){var S=b[A];if(Xe(S)){if(d===0&&g<S.length&&(g=S.length),d<S.length){var O=S[d];y(O,x)||(h._values.push(O),h._index.push(A))}}else d===0&&g<1&&(g=1),y(S,x)||(h._values.push(S),h._index.push(A))}d++}while(d<g)}h._ptr.push(h._index.length),h._size=[N,g]}r.prototype=new t,r.prototype.createSparseMatrix=function(h,b){return new r(h,b)},r.prototype.type="SparseMatrix",r.prototype.isSparseMatrix=!0,r.prototype.getDataType=function(){return Bn(this._values,Ke)},r.prototype.storage=function(){return"sparse"},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(h,b){return new r(h,b)},r.prototype.density=function(){var h=this._size[0],b=this._size[1];return h!==0&&b!==0?this._index.length/(h*b):0},r.prototype.subset=function(h,b,w){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return m(this,h);case 2:case 3:return f(this,h,b,w);default:throw new SyntaxError("Wrong number of arguments")}};function m(h,b){if(!En(b))throw new TypeError("Invalid index");var w=b.isScalar();if(w)return h.get(b.min());var N=b.size();if(N.length!==h._size.length)throw new Fe(N.length,h._size.length);var g,y,x,d,A=b.min(),S=b.max();for(g=0,y=h._size.length;g<y;g++)We(A[g],h._size[g]),We(S[g],h._size[g]);var O=h._values,M=h._index,_=h._ptr,E=b.dimension(0),$=b.dimension(1),z=[],I=[];E.forEach(function(D,H){I[D]=H[0],z[D]=!0});var T=O?[]:void 0,B=[],G=[];return $.forEach(function(D){for(G.push(B.length),x=_[D],d=_[D+1];x<d;x++)g=M[x],z[g]===!0&&(B.push(I[g]),T&&T.push(O[x]))}),G.push(B.length),new r({values:T,index:B,ptr:G,size:N,datatype:h._datatype})}function f(h,b,w,N){if(!b||b.isIndex!==!0)throw new TypeError("Invalid index");var g=b.size(),y=b.isScalar(),x;if(Oe(w)?(x=w.size(),w=w.toArray()):x=Pe(w),y){if(x.length!==0)throw new TypeError("Scalar expected");h.set(b.min(),w,N)}else{if(g.length!==1&&g.length!==2)throw new Fe(g.length,h._size.length,"<");if(x.length<g.length){for(var d=0,A=0;g[d]===1&&x[d]===1;)d++;for(;g[d]===1;)A++,d++;w=xo(w,g.length,A,x)}if(!Dn(g,x))throw new Fe(g,x,">");if(g.length===1){var S=b.dimension(0);S.forEach(function(_,E){We(_),h.set([_,0],w[E[0]],N)})}else{var O=b.dimension(0),M=b.dimension(1);O.forEach(function(_,E){We(_),M.forEach(function($,z){We($),h.set([_,$],w[E[0]][z[0]],N)})})}}return h}r.prototype.get=function(h){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var b=h[0],w=h[1];We(b,this._size[0]),We(w,this._size[1]);var N=c(b,this._ptr[w],this._ptr[w+1],this._index);return N<this._ptr[w+1]&&this._index[N]===b?this._values[N]:0},r.prototype.set=function(h,b,w){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=h[0],g=h[1],y=this._size[0],x=this._size[1],d=a,A=0;_r(this._datatype)&&(d=n.find(a,[this._datatype,this._datatype])||a,A=n.convert(0,this._datatype)),(N>y-1||g>x-1)&&(u(this,Math.max(N+1,y),Math.max(g+1,x),w),y=this._size[0],x=this._size[1]),We(N,y),We(g,x);var S=c(N,this._ptr[g],this._ptr[g+1],this._index);return S<this._ptr[g+1]&&this._index[S]===N?d(b,A)?s(S,g,this._values,this._index,this._ptr):this._values[S]=b:o(S,N,g,b,this._values,this._index,this._ptr),this};function c(h,b,w,N){if(w-b===0)return w;for(var g=b;g<w;g++)if(N[g]===h)return g;return b}function s(h,b,w,N,g){w.splice(h,1),N.splice(h,1);for(var y=b+1;y<g.length;y++)g[y]--}function o(h,b,w,N,g,y,x){g.splice(h,0,N),y.splice(h,0,b);for(var d=w+1;d<x.length;d++)x[d]++}r.prototype.resize=function(h,b,w){if(!rn(h))throw new TypeError("Array or Matrix expected");var N=h.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(y){if(!Be(y)||!Ae(y)||y<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(N)+")")});var g=w?this.clone():this;return u(g,N[0],N[1],b)};function u(h,b,w,N){var g=N||0,y=a,x=0;_r(h._datatype)&&(y=n.find(a,[h._datatype,h._datatype])||a,x=n.convert(0,h._datatype),g=n.convert(g,h._datatype));var d=!y(g,x),A=h._size[0],S=h._size[1],O,M,_;if(w>S){for(M=S;M<w;M++)if(h._ptr[M]=h._values.length,d)for(O=0;O<A;O++)h._values.push(g),h._index.push(O);h._ptr[w]=h._values.length}else w<S&&(h._ptr.splice(w+1,S-w),h._values.splice(h._ptr[w],h._values.length),h._index.splice(h._ptr[w],h._index.length));if(S=w,b>A){if(d){var E=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]+E,_=h._ptr[M+1]+E;var $=0;for(O=A;O<b;O++,$++)h._values.splice(_+$,0,g),h._index.splice(_+$,0,O),E++}h._ptr[S]=h._values.length}}else if(b<A){var z=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]-z;var I=h._ptr[M],T=h._ptr[M+1]-z;for(_=I;_<T;_++)O=h._index[_],O>b-1&&(h._values.splice(_,1),h._index.splice(_,1),z++)}h._ptr[M]=h._values.length}return h._size[0]=b,h._size[1]=w,h}r.prototype.reshape=function(h,b){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");h.forEach(function(D){if(!Be(D)||!Ae(D)||D<=-2||D===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Re(h)+")")});var w=this._size[0]*this._size[1];h=ti(h,w);var N=h[0]*h[1];if(w!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=b?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return g;for(var y=[],x=0;x<g._ptr.length;x++)for(var d=0;d<g._ptr[x+1]-g._ptr[x];d++)y.push(x);for(var A=g._values.slice(),S=g._index.slice(),O=0;O<g._index.length;O++){var M=S[O],_=y[O],E=M*g._size[1]+_;y[O]=E%h[1],S[O]=Math.floor(E/h[1])}g._values.length=0,g._index.length=0,g._ptr.length=h[1]+1,g._size=h.slice();for(var $=0;$<g._ptr.length;$++)g._ptr[$]=0;for(var z=0;z<A.length;z++){var I=S[z],T=y[z],B=A[z],G=c(I,g._ptr[T],g._ptr[T+1],g._index);o(G,I,T,B,g._values,g._index,g._ptr)}return g},r.prototype.clone=function(){var h=new r({values:this._values?Ce(this._values):void 0,index:Ce(this._index),ptr:Ce(this._ptr),size:Ce(this._size),datatype:this._datatype});return h},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(h,b){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var w=this,N=this._size[0],g=this._size[1],y=function(d,A,S){return h(d,[A,S],w)};return p(this,0,N-1,0,g-1,y,b)};function p(h,b,w,N,g,y,x){var d=[],A=[],S=[],O=a,M=0;_r(h._datatype)&&(O=n.find(a,[h._datatype,h._datatype])||a,M=n.convert(0,h._datatype));for(var _=function(V,K,te){V=y(V,K,te),O(V,M)||(d.push(V),A.push(K))},E=N;E<=g;E++){S.push(d.length);var $=h._ptr[E],z=h._ptr[E+1];if(x)for(var I=$;I<z;I++){var T=h._index[I];T>=b&&T<=w&&_(h._values[I],T-b,E-N)}else{for(var B={},G=$;G<z;G++){var D=h._index[G];B[D]=h._values[G]}for(var H=b;H<=w;H++){var W=H in B?B[H]:0;_(W,H-b,E-N)}}}return S.push(d.length),new r({values:d,index:A,ptr:S,size:[w-b+1,g-N+1]})}r.prototype.forEach=function(h,b){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var w=this,N=this._size[0],g=this._size[1],y=0;y<g;y++){var x=this._ptr[y],d=this._ptr[y+1];if(b)for(var A=x;A<d;A++){var S=this._index[A];h(this._values[A],[S,y],w)}else{for(var O={},M=x;M<d;M++){var _=this._index[M];O[_]=this._values[M]}for(var E=0;E<N;E++){var $=E in O?O[E]:0;h($,[E,y],w)}}}},r.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],b=0;b<h;b++)for(var w=this._ptr[b],N=this._ptr[b+1],g=w;g<N;g++){var y=this._index[g];yield{value:this._values[g],index:[y,b]}}},r.prototype.toArray=function(){return v(this._values,this._index,this._ptr,this._size,!0)},r.prototype.valueOf=function(){return v(this._values,this._index,this._ptr,this._size,!1)};function v(h,b,w,N,g){var y=N[0],x=N[1],d=[],A,S;for(A=0;A<y;A++)for(d[A]=[],S=0;S<x;S++)d[A][S]=0;for(S=0;S<x;S++)for(var O=w[S],M=w[S+1],_=O;_<M;_++)A=b[_],d[A][S]=h?g?Ce(h[_]):h[_]:1;return d}return r.prototype.format=function(h){for(var b=this._size[0],w=this._size[1],N=this.density(),g="Sparse Matrix ["+Re(b,h)+" x "+Re(w,h)+"] density: "+Re(N,h)+`
27
27
  `,y=0;y<w;y++)for(var x=this._ptr[y],d=this._ptr[y+1],A=x;A<d;A++){var S=this._index[A];g+=`
28
- (`+Re(S,h)+", "+Re(y,h)+") ==> "+(this._values?Re(this._values[A],h):"X")}return g},r.prototype.toString=function(){return Re(this.toArray())},r.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(h){if(h){if(Ie(h)&&(h=h.toNumber()),!$e(h)||!Ae(h))throw new TypeError("The parameter k must be an integer number")}else h=0;var b=h>0?h:0,w=h<0?-h:0,N=this._size[0],g=this._size[1],y=Math.min(N-w,g-b),x=[],d=[],A=[];A[0]=0;for(var S=b;S<g&&x.length<y;S++)for(var O=this._ptr[S],M=this._ptr[S+1],_=O;_<M;_++){var E=this._index[_];if(E===S-b+w){x.push(this._values[_]),d[x.length-1]=E-w;break}}return A.push(x.length),new r({values:x,index:d,ptr:A,size:[y,1]})},r.fromJSON=function(h){return new r(h)},r.diagonal=function(h,b,w,N,g){if(!Xe(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(D){if(Ie(D)&&(D=D.toNumber()),!$e(D)||!Ae(D)||D<1)throw new Error("Size values must be positive integers");return D}),w){if(Ie(w)&&(w=w.toNumber()),!$e(w)||!Ae(w))throw new TypeError("The parameter k must be an integer number")}else w=0;var y=a,x=0;Br(g)&&(y=n.find(a,[g,g])||a,x=n.convert(0,g));var d=w>0?w:0,A=w<0?-w:0,S=h[0],O=h[1],M=Math.min(S-A,O-d),_;if(Xe(b)){if(b.length!==M)throw new Error("Invalid value array length");_=function(H){return b[H]}}else if(Oe(b)){var E=b.size();if(E.length!==1||E[0]!==M)throw new Error("Invalid matrix length");_=function(H){return b.get([H])}}else _=function(){return b};for(var $=[],z=[],I=[],T=0;T<O;T++){I.push($.length);var B=T-d;if(B>=0&&B<M){var G=_(B);y(G,x)||(z.push(B+A),$.push(G))}}return I.push($.length),new r({values:$,index:z,ptr:I,size:[S,O]})},r.prototype.swapRows=function(h,b){if(!$e(h)||!Ae(h)||!$e(b)||!Ae(b))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(h,this._size[0]),We(b,this._size[0]),r._swapRows(h,b,this._size[1],this._values,this._index,this._ptr),this},r._forEachRow=function(h,b,w,N,g){for(var y=N[h],x=N[h+1],d=y;d<x;d++)g(w[d],b[d])},r._swapRows=function(h,b,w,N,g,y){for(var x=0;x<w;x++){var d=y[x],A=y[x+1],S=c(h,d,A,g),O=c(b,d,A,g);if(S<A&&O<A&&g[S]===h&&g[O]===b){if(N){var M=N[S];N[S]=N[O],N[O]=M}continue}if(S<A&&g[S]===h&&(O>=A||g[O]!==b)){var _=N?N[S]:void 0;g.splice(O,0,b),N&&N.splice(O,0,_),g.splice(O<=S?S+1:S,1),N&&N.splice(O<=S?S+1:S,1);continue}if(O<A&&g[O]===b&&(S>=A||g[S]!==h)){var E=N?N[O]:void 0;g.splice(S,0,h),N&&N.splice(S,0,E),g.splice(S<=O?O+1:O,1),N&&N.splice(S<=O?O+1:O,1)}}},r},{isClass:!0}),Md="number",Ad=["typed"];function Sd(e){var n=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(n){var a={"0b":2,"0o":8,"0x":16}[n[1]],t=n[2],r=n[3];return{input:e,radix:a,integerPart:t,fractionalPart:r}}else return null}function Ed(e){for(var n=parseInt(e.integerPart,e.radix),a=0,t=0;t<e.fractionalPart.length;t++){var r=parseInt(e.fractionalPart[t],e.radix);a+=r/Math.pow(e.radix,t+1)}var i=n+a;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is no valid number');return i}var Cd=R(Md,Ad,e=>{var{typed:n}=e,a=n("number",{"":function(){return 0},number:function(r){return r},string:function(r){if(r==="NaN")return NaN;var i=Sd(r);if(i)return Ed(i);var l=0,m=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);m&&(l=Number(m[2]),r=m[1]);var f=Number(r);if(isNaN(f))throw new SyntaxError('String "'+r+'" is no valid number');if(m){if(f>en(2,l)-1)throw new SyntaxError('String "'.concat(r,'" is out of range'));f>=en(2,l-1)&&(f=f-en(2,l))}return f},BigNumber:function(r){return r.toNumber()},Fraction:function(r){return r.valueOf()},Unit:function(r){throw new Error("Second argument with valueless unit expected")},null:function(r){return 0},"Unit, string | Unit":function(r,i){return r.toNumber(i)},"Array | Matrix":function(r){return be(r,this)}});return a.fromJSON=function(t){return parseFloat(t.value)},a}),js="string",Od=["typed"],Dd=R(js,Od,e=>{var{typed:n}=e;return n(js,{"":function(){return""},number:Ht,null:function(t){return"null"},boolean:function(t){return t+""},string:function(t){return t},"Array | Matrix":function(t){return be(t,this)},any:function(t){return String(t)}})}),eu="boolean",Td=["typed"],Bd=R(eu,Td,e=>{var{typed:n}=e;return n(eu,{"":function(){return!1},boolean:function(t){return t},number:function(t){return!!t},null:function(t){return!1},BigNumber:function(t){return!t.isZero()},string:function(t){var r=t.toLowerCase();if(r==="true")return!0;if(r==="false")return!1;var i=Number(t);if(t!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+t+'" to a boolean')},"Array | Matrix":function(t){return be(t,this)}})}),_d="bignumber",$d=["typed","BigNumber"],Id=R(_d,$d,e=>{var{typed:n,BigNumber:a}=e;return n("bignumber",{"":function(){return new a(0)},number:function(r){return new a(r+"")},string:function(r){var i=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var l=i[2],m=a(i[1]),f=new a(2).pow(Number(l));if(m.gt(f.sub(1)))throw new SyntaxError('String "'.concat(r,'" is out of range'));var c=new a(2).pow(Number(l)-1);return m.gte(c)?m.sub(f):m}return new a(r)},BigNumber:function(r){return r},Fraction:function(r){return new a(r.n).div(r.d).times(r.s)},null:function(r){return new a(0)},"Array | Matrix":function(r){return be(r,this)}})}),qd="complex",Rd=["typed","Complex"],Fd=R(qd,Rd,e=>{var{typed:n,Complex:a}=e;return n("complex",{"":function(){return a.ZERO},number:function(r){return new a(r,0)},"number, number":function(r,i){return new a(r,i)},"BigNumber, BigNumber":function(r,i){return new a(r.toNumber(),i.toNumber())},Fraction:function(r){return new a(r.valueOf(),0)},Complex:function(r){return r.clone()},string:function(r){return a(r)},null:function(r){return a(0)},Object:function(r){if("re"in r&&"im"in r)return new a(r.re,r.im);if("r"in r&&"phi"in r||"abs"in r&&"arg"in r)return new a(r);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(r){return be(r,this)}})}),zd="fraction",Pd=["typed","Fraction"],Ud=R(zd,Pd,e=>{var{typed:n,Fraction:a}=e;return n("fraction",{number:function(r){if(!isFinite(r)||isNaN(r))throw new Error(r+" cannot be represented as a fraction");return new a(r)},string:function(r){return new a(r)},"number, number":function(r,i){return new a(r,i)},null:function(r){return new a(0)},BigNumber:function(r){return new a(r.toString())},Fraction:function(r){return r},Object:function(r){return new a(r)},"Array | Matrix":function(r){return be(r,this)}})}),ru="matrix",Ld=["typed","Matrix","DenseMatrix","SparseMatrix"],kd=R(ru,Ld,e=>{var{typed:n,Matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(ru,{"":function(){return i([])},string:function(m){return i([],m)},"string, string":function(m,f){return i([],m,f)},Array:function(m){return i(m)},Matrix:function(m){return i(m,m.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(l,m,f){if(m==="dense"||m==="default"||m===void 0)return new t(l,f);if(m==="sparse")return new r(l,f);throw new TypeError("Unknown matrix type "+JSON.stringify(m)+".")}}),tu="matrixFromFunction",Hd=["typed","matrix","isZero"],Gd=R(tu,Hd,e=>{var{typed:n,matrix:a,isZero:t}=e;return n(tu,{"Array | Matrix, function, string, string":function(l,m,f,c){return r(l,m,f,c)},"Array | Matrix, function, string":function(l,m,f){return r(l,m,f)},"Matrix, function":function(l,m){return r(l,m,"dense")},"Array, function":function(l,m){return r(l,m,"dense").toArray()},"Array | Matrix, string, function":function(l,m,f){return r(l,f,m)},"Array | Matrix, string, string, function":function(l,m,f,c){return r(l,c,m,f)}});function r(i,l,m,f){var c;return f!==void 0?c=a(m,f):c=a(m),c.resize(i),c.forEach(function(s,o){var u=l(o);t(u)||c.set(o,u)}),c}}),nu="matrixFromRows",Vd=["typed","matrix","flatten","size"],Zd=R(nu,Vd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(nu,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var f=l(m[0]),c=[];for(var s of m){var o=l(s);if(o!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(o|0));c.push(t(s))}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),au="matrixFromColumns",Xd=["typed","matrix","flatten","size"],Yd=R(au,Xd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(au,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var f=l(m[0]),c=[],s=0;s<f;s++)c[s]=[];for(var o of m){var u=l(o);if(u!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(u|0));for(var p=t(o),v=0;v<f;v++)c[v].push(p[v])}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),iu="splitUnit",Wd=["typed"],Jd=R(iu,Wd,e=>{var{typed:n}=e;return n(iu,{"Unit, Array":function(t,r){return t.splitUnit(r)}})}),ou="unaryMinus",Qd=["typed"],Kd=R(ou,Qd,e=>{var{typed:n}=e;return n(ou,{number:Jo,Complex:function(t){return t.neg()},BigNumber:function(t){return t.neg()},Fraction:function(t){return t.neg()},Unit:function(t){var r=t.clone();return r.value=this(t.value),r},"Array | Matrix":function(t){return be(t,this)}})}),su="unaryPlus",jd=["typed","config","BigNumber"],eg=R(su,jd,e=>{var{typed:n,config:a,BigNumber:t}=e;return n(su,{number:Qo,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":function(i){return be(i,this)},"boolean | string":function(i){return a.number==="BigNumber"?new t(+i):+i}})}),uu="abs",rg=["typed"],tg=R(uu,rg,e=>{var{typed:n}=e;return n(uu,{number:Xo,Complex:function(t){return t.abs()},BigNumber:function(t){return t.abs()},Fraction:function(t){return t.abs()},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.abs()}})}),cu="apply",ng=["typed","isInteger"],fu=R(cu,ng,e=>{var{typed:n,isInteger:a}=e;return n(cu,{"Array | Matrix, number | BigNumber, function":function(r,i,l){if(!a(i))throw new TypeError("Integer number expected for dimension");var m=Array.isArray(r)?Pe(r):r.size();if(i<0||i>=m.length)throw new Jr(i,m.length);return Oe(r)?r.create(Sa(r.valueOf(),i,l)):Sa(r,i,l)}})});function Sa(e,n,a){var t,r,i;if(n<=0)if(Array.isArray(e[0])){for(i=ag(e),r=[],t=0;t<i.length;t++)r[t]=Sa(i[t],n-1,a);return r}else return a(e);else{for(r=[],t=0;t<e.length;t++)r[t]=Sa(e[t],n-1,a);return r}}function ag(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}var lu="addScalar",ig=["typed"],og=R(lu,ig,e=>{var{typed:n}=e;return n(lu,{"number, number":Yo,"Complex, Complex":function(t,r){return t.add(r)},"BigNumber, BigNumber":function(t,r){return t.plus(r)},"Fraction, Fraction":function(t,r){return t.add(r)},"Unit, Unit":function(t,r){if(t.value===null||t.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(r.value===null||r.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!t.equalBase(r))throw new Error("Units do not match");var i=t.clone();return i.value=this(i.value,r.value),i.fixPrefix=!1,i}})}),mu="cbrt",sg=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],ug=R(mu,sg,e=>{var{config:n,typed:a,isNegative:t,unaryMinus:r,matrix:i,Complex:l,BigNumber:m,Fraction:f}=e;return a(mu,{number:In,Complex:c,"Complex, boolean":c,BigNumber:function(u){return u.cbrt()},Unit:s,"Array | Matrix":function(u){return be(u,this)}});function c(o,u){var p=o.arg()/3,v=o.abs(),h=new l(In(v),0).mul(new l(0,p).exp());if(u){var b=[h,new l(In(v),0).mul(new l(0,p+Math.PI*2/3).exp()),new l(In(v),0).mul(new l(0,p-Math.PI*2/3).exp())];return n.matrix==="Array"?b:i(b)}else return h}function s(o){if(o.value&&vr(o.value)){var u=o.clone();return u.value=1,u=u.pow(1/3),u.value=c(o.value),u}else{var p=t(o.value);p&&(o.value=r(o.value));var v;Ie(o.value)?v=new m(1).div(3):at(o.value)?v=new f(1,3):v=1/3;var h=o.pow(v);return p&&(h.value=r(h.value)),h}}}),cg="algorithm11",fg=["typed","equalScalar"],wr=R(cg,fg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=a,w=0,N=l;typeof u=="string"&&(h=u,b=n.find(a,[h,h]),w=n.convert(0,h),i=n.convert(i,h),N=n.find(l,[h,h]));for(var g=[],y=[],x=[],d=0;d<v;d++){x[d]=y.length;for(var A=s[d],S=s[d+1],O=A;O<S;O++){var M=c[O],_=m?N(i,f[O]):N(f[O],i);b(_,w)||(y.push(M),g.push(_))}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),lg="algorithm12",mg=["typed","DenseMatrix"],yr=R(lg,mg,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=m?b(i,0):b(0,i)}return new a({data:w,size:[p,v],datatype:h})}}),pg="algorithm14",vg=["typed"],Ge=R(pg,vg,e=>{var{typed:n}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o,u=l;typeof s=="string"&&(o=s,i=n.convert(i,o),u=n.find(l,[o,o]));var p=c.length>0?a(u,0,c,c[0],f,i,m):[];return r.createDenseMatrix({data:p,size:Ce(c),datatype:o})};function a(t,r,i,l,m,f,c){var s=[];if(r===i.length-1)for(var o=0;o<l;o++)s[o]=c?t(f,m[o]):t(m[o],f);else for(var u=0;u<l;u++)s[u]=a(t,r+1,i,i[r+1],m[u],f,c);return s}}),bi="ceil",hg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],dg=R(bi,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(bi,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.ceil(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.ceil(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),gg=R(bi,hg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=yr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=dg({typed:n,config:a,round:t});return n("ceil",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.ceil()},"Complex, number":function(p,v){return p.ceil(v)},"Complex, BigNumber":function(p,v){return p.ceil(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.ceil()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_CEIL)},Fraction:function(p){return p.ceil()},"Fraction, number":function(p,v){return p.ceil(v)},"Fraction, BigNumber":function(p,v){return p.ceil(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),pu="cube",yg=["typed"],xg=R(pu,yg,e=>{var{typed:n}=e;return n(pu,{number:Ko,Complex:function(t){return t.mul(t).mul(t)},BigNumber:function(t){return t.times(t).times(t)},Fraction:function(t){return t.pow(3)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(3)}})}),vu="exp",bg=["typed"],wg=R(vu,bg,e=>{var{typed:n}=e;return n(vu,{number:jo,Complex:function(t){return t.exp()},BigNumber:function(t){return t.exp()},"Array | Matrix":function(t){return be(t,this)}})}),hu="expm1",Ng=["typed","Complex"],Mg=R(hu,Ng,e=>{var{typed:n,Complex:a}=e;return n(hu,{number:es,Complex:function(r){var i=Math.exp(r.re);return new a(i*Math.cos(r.im)-1,i*Math.sin(r.im))},BigNumber:function(r){return r.exp().minus(1)},"Array | Matrix":function(r){return be(r,this)}})}),wi="fix",Ag=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Sg=R(wi,["typed","ceil","floor"],e=>{var{typed:n,ceil:a,floor:t}=e;return n(wi,{number:function(i){return i>0?t(i):a(i)},"number, number":function(i,l){return i>0?t(i,l):a(i,l)}})}),Eg=R(wi,Ag,e=>{var{typed:n,Complex:a,matrix:t,ceil:r,floor:i,equalScalar:l,zeros:m,DenseMatrix:f}=e,c=yr({typed:n,DenseMatrix:f}),s=Ge({typed:n}),o=Sg({typed:n,ceil:r,floor:i});return n("fix",{number:o.signatures.number,"number, number | BigNumber":o.signatures["number,number"],Complex:function(p){return new a(p.re>0?Math.floor(p.re):Math.ceil(p.re),p.im>0?Math.floor(p.im):Math.ceil(p.im))},"Complex, number":function(p,v){return new a(p.re>0?i(p.re,v):r(p.re,v),p.im>0?i(p.im,v):r(p.im,v))},"Complex, BigNumber":function(p,v){var h=v.toNumber();return new a(p.re>0?i(p.re,h):r(p.re,h),p.im>0?i(p.im,h):r(p.im,h))},BigNumber:function(p){return p.isNegative()?r(p):i(p)},"BigNumber, number | BigNumber":function(p,v){return p.isNegative()?r(p,v):i(p,v)},Fraction:function(p){return p.s<0?p.ceil():p.floor()},"Fraction, number | BigNumber":function(p,v){return p.s<0?r(p,v):i(p,v)},"Array | Matrix":function(p){return be(p,this)},"Array | Matrix, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(t(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return l(p,0)?m(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),Ni="floor",Cg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Og=R(Ni,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(Ni,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.floor(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.floor(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),Dg=R(Ni,Cg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=yr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=Og({typed:n,config:a,round:t});return n("floor",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.floor()},"Complex, number":function(p,v){return p.floor(v)},"Complex, BigNumber":function(p,v){return p.floor(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.floor()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_FLOOR)},Fraction:function(p){return p.floor()},"Fraction, number":function(p,v){return p.floor(v)},"Fraction, BigNumber":function(p,v){return p.floor(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),Tg="algorithm01",Bg=["typed"],qt=R(Tg,Bg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w=typeof c=="string"&&c===v?c:void 0,N=w?n.find(i,[w,w]):i,g,y,x=[];for(g=0;g<h;g++)x[g]=[];var d=[],A=[];for(y=0;y<b;y++){for(var S=y+1,O=u[y],M=u[y+1],_=O;_<M;_++)g=o[_],d[g]=l?N(s[_],m[g][y]):N(m[g][y],s[_]),A[g]=S;for(g=0;g<h;g++)A[g]===S?x[g][y]=d[g]:x[g][y]=m[g][y]}return t.createDenseMatrix({data:x,size:[h,b],datatype:w})}}),_g="algorithm04",$g=["typed","equalScalar"],Mi=R(_g,$g,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=m&&u?[]:void 0,_=m&&u?[]:void 0,E=[],$=[],z,I,T,B,G;for(I=0;I<N;I++){O[I]=S.length;var D=I+1;for(B=c[I],G=c[I+1],T=B;T<G;T++)z=f[T],S.push(z),E[z]=D,M&&(M[z]=m[T]);for(B=v[I],G=v[I+1],T=B;T<G;T++)if(z=p[T],E[z]===D){if(M){var H=d(M[z],u[T]);y(H,x)?E[z]=null:M[z]=H}}else S.push(z),$[z]=D,_&&(_[z]=u[T]);if(M&&_)for(T=O[I];T<S.length;)z=S[T],E[z]===D?(A[T]=M[z],T++):$[z]===D?(A[T]=_[z],T++):S.splice(T,1)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Ig="algorithm10",qg=["typed","DenseMatrix"],Vt=R(Ig,qg,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=i}return new a({data:w,size:[p,v],datatype:h})}}),Rg="algorithm13",Fg=["typed"],je=R(Rg,Fg,e=>{var{typed:n}=e;return function(r,i,l){var m=r._data,f=r._size,c=r._datatype,s=i._data,o=i._size,u=i._datatype,p=[];if(f.length!==o.length)throw new Fe(f.length,o.length);for(var v=0;v<f.length;v++){if(f[v]!==o[v])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");p[v]=f[v]}var h,b=l;typeof c=="string"&&c===u&&(h=c,b=n.find(l,[h,h]));var w=p.length>0?a(b,0,p,p[0],m,s):[];return r.createDenseMatrix({data:w,size:p,datatype:h})};function a(t,r,i,l,m,f){var c=[];if(r===i.length-1)for(var s=0;s<l;s++)c[s]=t(m[s],f[s]);else for(var o=0;o<l;o++)c[o]=a(t,r+1,i,i[r+1],m[o],f[o]);return c}}),du="gcd",zg=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],Pg=R(du,zg,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=qt({typed:n}),m=Mi({typed:n,equalScalar:t}),f=Vt({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n(du,{"number, number":rs,"BigNumber, BigNumber":o,"Fraction, Fraction":function(p,v){return p.gcd(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | BigNumber, SparseMatrix":function(p,v){return f(v,p,this,!0)},"number | BigNumber, DenseMatrix":function(p,v){return s(v,p,this,!0)},"Array, number | BigNumber":function(p,v){return s(a(p),v,this,!1).valueOf()},"number | BigNumber, Array":function(p,v){return s(a(v),p,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}});function o(u,p){if(!u.isInt()||!p.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var v=new r(0);!p.isZero();){var h=u.mod(p);u=p,p=h}return u.lt(v)?u.neg():u}}),Ug="algorithm02",Lg=["typed","equalScalar"],jr=R(Ug,Lg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o=i._values,u=i._index,p=i._ptr,v=i._size,h=i._datatype;if(c.length!==v.length)throw new Fe(c.length,v.length);if(c[0]!==v[0]||c[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+v+")");if(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var b=c[0],w=c[1],N,g=a,y=0,x=l;typeof s=="string"&&s===h&&(N=s,g=n.find(a,[N,N]),y=n.convert(0,N),x=n.find(l,[N,N]));for(var d=[],A=[],S=[],O=0;O<w;O++){S[O]=A.length;for(var M=p[O],_=p[O+1],E=M;E<_;E++){var $=u[E],z=m?x(o[E],f[$][O]):x(f[$][O],o[E]);g(z,y)||(A.push($),d.push(z))}}return S[w]=A.length,i.createSparseMatrix({values:d,index:A,ptr:S,size:[b,w],datatype:N})}}),kg="algorithm06",Hg=["typed","equalScalar"],Ea=R(kg,Hg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._size,c=r._datatype,s=i._values,o=i._size,u=i._datatype;if(f.length!==o.length)throw new Fe(f.length,o.length);if(f[0]!==o[0]||f[1]!==o[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");var p=f[0],v=f[1],h,b=a,w=0,N=l;typeof c=="string"&&c===u&&(h=c,b=n.find(a,[h,h]),w=n.convert(0,h),N=n.find(l,[h,h]));for(var g=m&&s?[]:void 0,y=[],x=[],d=g?[]:void 0,A=[],S=[],O=0;O<v;O++){x[O]=y.length;var M=O+1;if(Vo(r,O,A,d,S,M,y,N),Vo(i,O,A,d,S,M,y,N),d)for(var _=x[O];_<y.length;){var E=y[_];if(S[E]===M){var $=d[E];b($,w)?y.splice(_,1):(g.push($),_++)}else y.splice(_,1)}else for(var z=x[O];z<y.length;){var I=y[z];S[I]!==M?y.splice(z,1):z++}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),gu="lcm",Gg=["typed","matrix","equalScalar"],Vg=R(gu,Gg,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=jr({typed:n,equalScalar:t}),i=Ea({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(gu,{"number, number":ts,"BigNumber, BigNumber":c,"Fraction, Fraction":function(o,u){return o.lcm(u)},"SparseMatrix, SparseMatrix":function(o,u){return i(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return r(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return r(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return m(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, number | BigNumber":function(o,u){return l(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return f(o,u,this,!1)},"number | BigNumber, SparseMatrix":function(o,u){return l(u,o,this,!0)},"number | BigNumber, DenseMatrix":function(o,u){return f(u,o,this,!0)},"Array, number | BigNumber":function(o,u){return f(a(o),u,this,!1).valueOf()},"number | BigNumber, Array":function(o,u){return f(a(u),o,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(o,u,p){for(var v=this(o,u),h=0;h<p.length;h++)v=this(v,p[h]);return v}});function c(s,o){if(!s.isInt()||!o.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(s.isZero())return s;if(o.isZero())return o;for(var u=s.times(o);!o.isZero();){var p=o;o=s.mod(p),s=p}return u.div(s).abs()}}),yu="log10",Zg=["typed","config","Complex"],Xg=R(yu,Zg,e=>{var{typed:n,config:a,Complex:t}=e;return n(yu,{number:function(i){return i>=0||a.predictable?ns(i):new t(i,0).log().div(Math.LN10)},Complex:function(i){return new t(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||a.predictable?i.log():new t(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(i){return be(i,this)}})}),xu="log2",Yg=["typed","config","Complex"],Wg=R(xu,Yg,e=>{var{typed:n,config:a,Complex:t}=e;return n(xu,{number:function(l){return l>=0||a.predictable?as(l):r(new t(l,0))},Complex:r,BigNumber:function(l){return!l.isNegative()||a.predictable?l.log(2):r(new t(l.toNumber(),0))},"Array | Matrix":function(l){return be(l,this)}});function r(i){var l=Math.sqrt(i.re*i.re+i.im*i.im);return new t(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),Jg="algorithm03",Qg=["typed"],Or=R(Jg,Qg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w,N=0,g=i;typeof c=="string"&&c===v&&(w=c,N=n.convert(0,w),g=n.find(i,[w,w]));for(var y=[],x=0;x<h;x++)y[x]=[];for(var d=[],A=[],S=0;S<b;S++){for(var O=S+1,M=u[S],_=u[S+1],E=M;E<_;E++){var $=o[E];d[$]=l?g(s[E],m[$][S]):g(m[$][S],s[E]),A[$]=O}for(var z=0;z<h;z++)A[z]===O?y[z][S]=d[z]:y[z][S]=l?g(N,m[z][S]):g(m[z][S],N)}return t.createDenseMatrix({data:y,size:[h,b],datatype:w})}}),Kg="algorithm05",jg=["typed","equalScalar"],Ca=R(Kg,jg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=A?[]:void 0,E=[],$=[],z,I,T,B;for(I=0;I<N;I++){O[I]=S.length;var G=I+1;for(T=c[I],B=c[I+1];T<B;T++)z=f[T],S.push(z),E[z]=G,M&&(M[z]=m[T]);for(T=v[I],B=v[I+1];T<B;T++)z=p[T],E[z]!==G&&S.push(z),$[z]=G,_&&(_[z]=u[T]);if(A)for(T=O[I];T<S.length;){z=S[T];var D=E[z],H=$[z];if(D===G||H===G){var W=D===G?M[z]:x,j=H===G?_[z]:x,V=d(W,j);y(V,x)?S.splice(T,1):(A.push(V),T++)}}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),bu="mod",ey=["typed","matrix","equalScalar","DenseMatrix"],ry=R(bu,ey,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=jr({typed:n,equalScalar:t}),l=Or({typed:n}),m=Ca({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=yr({typed:n,DenseMatrix:r}),s=je({typed:n}),o=Ge({typed:n});return n(bu,{"number, number":is,"BigNumber, BigNumber":function(p,v){if(v.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return v.isZero()?p:p.mod(v)},"Fraction, Fraction":function(p,v){if(v.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return p.compare(0)>=0?p.mod(v):p.mod(v).add(v).mod(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this,!1)},"SparseMatrix, DenseMatrix":function(p,v){return i(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(a(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,this,!0).valueOf()}})}),ty="multiplyScalar",ny=["typed"],ay=R(ty,ny,e=>{var{typed:n}=e;return n("multiplyScalar",{"number, number":Wo,"Complex, Complex":function(t,r){return t.mul(r)},"BigNumber, BigNumber":function(t,r){return t.times(r)},"Fraction, Fraction":function(t,r){return t.mul(r)},"number | Fraction | BigNumber | Complex, Unit":function(t,r){var i=r.clone();return i.value=i.value===null?i._normalize(t):this(i.value,t),i},"Unit, number | Fraction | BigNumber | Complex":function(t,r){var i=t.clone();return i.value=i.value===null?i._normalize(r):this(i.value,r),i},"Unit, Unit":function(t,r){return t.multiply(r)}})}),wu="multiply",iy=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],oy=R(wu,iy,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,equalScalar:i,dot:l}=e,m=wr({typed:n,equalScalar:i}),f=Ge({typed:n});function c(x,d){switch(x.length){case 1:switch(d.length){case 1:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;case 2:switch(d.length){case 1:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+d[0]+")");break;case 2:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function s(x,d,A){if(A===0)throw new Error("Cannot multiply two empty vectors");return l(x,d)}function o(x,d){if(d.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return u(x,d)}function u(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=_[1],I,T=t,B=r;O&&E&&O===E&&typeof O=="string"&&(I=O,T=n.find(t,[I,I]),B=n.find(r,[I,I]));for(var G=[],D=0;D<z;D++){for(var H=B(A[0],M[0][D]),W=1;W<$;W++)H=T(H,B(A[W],M[W][D]));G[D]=H}return x.createDenseMatrix({data:G,size:[z],datatype:I})}var p=n("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":N}),v=n("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":b,"DenseMatrix, SparseMatrix":w,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":y});function h(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._datatype,E=S[0],$=S[1],z,I=t,T=r;O&&_&&O===_&&typeof O=="string"&&(z=O,I=n.find(t,[z,z]),T=n.find(r,[z,z]));for(var B=[],G=0;G<E;G++){for(var D=A[G],H=T(D[0],M[0]),W=1;W<$;W++)H=I(H,T(D[W],M[W]));B[G]=H}return x.createDenseMatrix({data:B,size:[E],datatype:z})}function b(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=S[1],I=_[1],T,B=t,G=r;O&&E&&O===E&&typeof O=="string"&&(T=O,B=n.find(t,[T,T]),G=n.find(r,[T,T]));for(var D=[],H=0;H<$;H++){var W=A[H];D[H]=[];for(var j=0;j<I;j++){for(var V=G(W[0],M[0][j]),K=1;K<z;K++)V=B(V,G(W[K],M[K][j]));D[H][j]=V}}return x.createDenseMatrix({data:D,size:[$,I],datatype:T})}function w(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._values,_=d._index,E=d._ptr,$=d._size,z=d._datatype;if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var I=S[0],T=$[1],B,G=t,D=r,H=i,W=0;O&&z&&O===z&&typeof O=="string"&&(B=O,G=n.find(t,[B,B]),D=n.find(r,[B,B]),H=n.find(i,[B,B]),W=n.convert(0,B));for(var j=[],V=[],K=[],te=d.createSparseMatrix({values:j,index:V,ptr:K,size:[I,T],datatype:B}),re=0;re<T;re++){K[re]=V.length;var ie=E[re],ne=E[re+1];if(ne>ie)for(var ue=0,ee=0;ee<I;ee++){for(var ye=ee+1,we=void 0,me=ie;me<ne;me++){var xe=_[me];ue!==ye?(we=D(A[ee][xe],M[me]),ue=ye):we=G(we,D(A[ee][xe],M[me]))}ue===ye&&!H(we,W)&&(V.push(ee),j.push(we))}}return K[T]=V.length,te}function N(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=[],T=[],B=[],G,D=t,H=r,W=i,j=0;M&&E&&M===E&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]),W=n.find(i,[G,G]),j=n.convert(0,G));var V=[],K=[];B[0]=0;for(var te=0;te<z;te++){var re=_[te];if(!W(re,j))for(var ie=O[te],ne=O[te+1],ue=ie;ue<ne;ue++){var ee=S[ue];K[ee]?V[ee]=D(V[ee],H(re,A[ue])):(K[ee]=!0,T.push(ee),V[ee]=H(re,A[ue]))}}for(var ye=T.length,we=0;we<ye;we++){var me=T[we];I[we]=V[me]}return B[1]=T.length,x.createSparseMatrix({values:I,index:T,ptr:B,size:[$,1],datatype:G})}function g(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=d._size[1],T,B=t,G=r,D=i,H=0;M&&E&&M===E&&typeof M=="string"&&(T=M,B=n.find(t,[T,T]),G=n.find(r,[T,T]),D=n.find(i,[T,T]),H=n.convert(0,T));for(var W=[],j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[$,I],datatype:T}),te=[],re=[],ie=0;ie<I;ie++){V[ie]=j.length;for(var ne=ie+1,ue=0;ue<z;ue++){var ee=_[ue][ie];if(!D(ee,H))for(var ye=O[ue],we=O[ue+1],me=ye;me<we;me++){var xe=S[me];re[xe]!==ne?(re[xe]=ne,j.push(xe),te[xe]=G(ee,A[me])):te[xe]=B(te[xe],G(ee,A[me]))}}for(var F=V[ie],Y=j.length,k=F;k<Y;k++){var U=j[k];W[k]=te[U]}}return V[I]=j.length,K}function y(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype,_=d._values,E=d._index,$=d._ptr,z=d._datatype,I=x._size[0],T=d._size[1],B=A&&_,G,D=t,H=r;M&&z&&M===z&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]));for(var W=B?[]:void 0,j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[I,T],datatype:G}),te=B?[]:void 0,re=[],ie,ne,ue,ee,ye,we,me,xe,F=0;F<T;F++){V[F]=j.length;var Y=F+1;for(ye=$[F],we=$[F+1],ee=ye;ee<we;ee++)if(xe=E[ee],B)for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y?(re[me]=Y,j.push(me),te[me]=H(_[ee],A[ie])):te[me]=D(te[me],H(_[ee],A[ie]));else for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y&&(re[me]=Y,j.push(me));if(B)for(var k=V[F],U=j.length,J=k;J<U;J++){var q=j[J];W[J]=te[q]}}return V[T]=j.length,K}return n(wu,ja({"Array, Array":function(d,A){c(Pe(d),Pe(A));var S=this(a(d),a(A));return Oe(S)?S.valueOf():S},"Matrix, Matrix":function(d,A){var S=d.size(),O=A.size();return c(S,O),S.length===1?O.length===1?s(d,A,S[0]):o(d,A):O.length===1?p(d,A):v(d,A)},"Matrix, Array":function(d,A){return this(d,a(A))},"Array, Matrix":function(d,A){return this(a(d,A.storage()),A)},"SparseMatrix, any":function(d,A){return m(d,A,r,!1)},"DenseMatrix, any":function(d,A){return f(d,A,r,!1)},"any, SparseMatrix":function(d,A){return m(A,d,r,!0)},"any, DenseMatrix":function(d,A){return f(A,d,r,!0)},"Array, any":function(d,A){return f(a(d),A,r,!1).valueOf()},"any, Array":function(d,A){return f(a(A),d,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(d,A,S){for(var O=this(d,A),M=0;M<S.length;M++)O=this(O,S[M]);return O}},r.signatures))}),Nu="nthRoot",sy=["typed","matrix","equalScalar","BigNumber"],uy=R(Nu,sy,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r}=e,i=qt({typed:n}),l=jr({typed:n,equalScalar:t}),m=Ea({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n}),o="Complex number not supported in function nthRoot. Use nthRoots instead.";return n(Nu,{number:os,"number, number":os,BigNumber:function(v){return u(v,new r(2))},Complex:function(v){throw new Error(o)},"Complex, number":function(v,h){throw new Error(o)},"BigNumber, BigNumber":u,"Array | Matrix":function(v){return this(v,2)},"SparseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return m(v,h,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return i(v,h,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(v,h){return c(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return f(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return s(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){if(h.density()===1)return f(h,v,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(v,h){return s(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}});function u(p,v){var h=r.precision,b=r.clone({precision:h+2}),w=new r(0),N=new b(1),g=v.isNegative();if(g&&(v=v.neg()),v.isZero())throw new Error("Root must be non-zero");if(p.isNegative()&&!v.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(p.isZero())return g?new b(1/0):0;if(!p.isFinite())return g?w:p;var y=p.abs().pow(N.div(v));return y=p.isNeg()?y.neg():y,new r((g?N.div(y):y).toPrecision(h))}}),Mu="sign",cy=["typed","BigNumber","Fraction","complex"],fy=R(Mu,cy,e=>{var{typed:n,BigNumber:a,complex:t,Fraction:r}=e;return n(Mu,{number:gi,Complex:function(l){return l.im===0?t(gi(l.re)):l.sign()},BigNumber:function(l){return new a(l.cmp(0))},Fraction:function(l){return new r(l.s,1)},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){if(!l._isDerived()&&l.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return this(l.value)}})}),ly="sqrt",my=["config","typed","Complex"],py=R(ly,my,e=>{var{config:n,typed:a,Complex:t}=e;return a("sqrt",{number:r,Complex:function(l){return l.sqrt()},BigNumber:function(l){return!l.isNegative()||n.predictable?l.sqrt():r(l.toNumber())},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){return l.pow(.5)}});function r(i){return isNaN(i)?NaN:i>=0||n.predictable?Math.sqrt(i):new t(i,0).sqrt()}}),Au="square",vy=["typed"],hy=R(Au,vy,e=>{var{typed:n}=e;return n(Au,{number:ss,Complex:function(t){return t.mul(t)},BigNumber:function(t){return t.times(t)},Fraction:function(t){return t.mul(t)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(2)}})}),Su="subtract",dy=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],gy=R(Su,dy,e=>{var{typed:n,matrix:a,equalScalar:t,addScalar:r,unaryMinus:i,DenseMatrix:l}=e,m=qt({typed:n}),f=Or({typed:n}),c=Ca({typed:n,equalScalar:t}),s=Vt({typed:n,DenseMatrix:l}),o=je({typed:n}),u=Ge({typed:n});return n(Su,{"number, number":function(v,h){return v-h},"Complex, Complex":function(v,h){return v.sub(h)},"BigNumber, BigNumber":function(v,h){return v.minus(h)},"Fraction, Fraction":function(v,h){return v.sub(h)},"Unit, Unit":function(v,h){if(v.value===null)throw new Error("Parameter x contains a unit with undefined value");if(h.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!v.equalBase(h))throw new Error("Units do not match");var b=v.clone();return b.value=this(b.value,h.value),b.fixPrefix=!1,b},"SparseMatrix, SparseMatrix":function(v,h){return Oa(v,h),c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return Oa(v,h),f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return Oa(v,h),m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return Oa(v,h),o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return s(v,i(h),r)},"DenseMatrix, any":function(v,h){return u(v,h,this)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(a(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})});function Oa(e,n){var a=e.size(),t=n.size();if(a.length!==t.length)throw new Fe(a.length,t.length)}var Eu="xgcd",yy=["typed","config","matrix","BigNumber"],xy=R(Eu,yy,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(Eu,{"number, number":function(m,f){var c=us(m,f);return a.matrix==="Array"?c:t(c)},"BigNumber, BigNumber":i});function i(l,m){var f,c,s,o=new r(0),u=new r(1),p=o,v=u,h=u,b=o;if(!l.isInt()||!m.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!m.isZero();)c=l.div(m).floor(),s=l.mod(m),f=p,p=v.minus(c.times(p)),v=f,f=h,h=b.minus(c.times(h)),b=f,l=m,m=s;var w;return l.lt(o)?w=[l.neg(),v.neg(),b.neg()]:w=[l,l.isZero()?0:v,b],a.matrix==="Array"?w:t(w)}}),Cu="invmod",by=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],wy=R(Cu,by,e=>{var{typed:n,config:a,BigNumber:t,xgcd:r,equal:i,smaller:l,mod:m,add:f,isInteger:c}=e;return n(Cu,{"number, number":s,"BigNumber, BigNumber":s});function s(o,u){if(!c(o)||!c(u))throw new Error("Parameters in function invmod must be integer numbers");if(o=m(o,u),i(u,0))throw new Error("Divisor must be non zero");var p=r(o,u);p=p.valueOf();var[v,h]=p;return i(v,t(1))?(h=m(h,u),l(h,t(0))&&(h=f(h,u)),h):NaN}}),Ny="algorithm09",My=["typed","equalScalar"],Ou=R(Ny,My,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=[],E,$,z,I,T;for($=0;$<N;$++){O[$]=S.length;var B=$+1;if(M)for(I=v[$],T=v[$+1],z=I;z<T;z++)E=p[z],_[E]=B,M[E]=u[z];for(I=c[$],T=c[$+1],z=I;z<T;z++)if(E=f[z],M){var G=_[E]===B?M[E]:x,D=d(m[z],G);y(D,x)||(S.push(E),A.push(D))}else S.push(E)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Du="dotMultiply",Ay=["typed","matrix","equalScalar","multiplyScalar"],Sy=R(Du,Ay,e=>{var{typed:n,matrix:a,equalScalar:t,multiplyScalar:r}=e,i=jr({typed:n,equalScalar:t}),l=Ou({typed:n,equalScalar:t}),m=wr({typed:n,equalScalar:t}),f=je({typed:n}),c=Ge({typed:n});return n(Du,{"any, any":r,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,r,!1)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,r,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,r,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,r)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,r,!1)},"DenseMatrix, any":function(o,u){return c(o,u,r,!1)},"any, SparseMatrix":function(o,u){return m(u,o,r,!0)},"any, DenseMatrix":function(o,u){return c(u,o,r,!0)},"Array, any":function(o,u){return c(a(o),u,r,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,r,!0).valueOf()}})});function Ey(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitAnd");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero()||n.eq(-1)||e.eq(n))return e;if(n.isZero()||e.eq(-1))return n;if(!e.isFinite()||!n.isFinite()){if(!e.isFinite()&&!n.isFinite())return e.isNegative()===n.isNegative()?e:new a(0);if(!e.isFinite())return n.isNegative()?e:e.isNegative()?new a(0):n;if(!n.isFinite())return e.isNegative()?n:n.isNegative()?new a(0):e}return Ai(e,n,function(t,r){return t&r})}function qn(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var n=e.constructor,a=n.precision;n.config({precision:1e9});var t=e.plus(new n(1));return t.s=-t.s||null,n.config({precision:a}),t}function Cy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitOr");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);var t=new a(-1);return e.isZero()||n.eq(t)||e.eq(n)?n:n.isZero()||e.eq(t)?e:!e.isFinite()||!n.isFinite()?!e.isFinite()&&!e.isNegative()&&n.isNegative()||e.isNegative()&&!n.isNegative()&&!n.isFinite()?t:e.isNegative()&&n.isNegative()?e.isFinite()?e:n:e.isFinite()?n:e:Ai(e,n,function(r,i){return r|i})}function Ai(e,n,a){var t=e.constructor,r,i,l=+(e.s<0),m=+(n.s<0);if(l){r=Da(qn(e));for(var f=0;f<r.length;++f)r[f]^=1}else r=Da(e);if(m){i=Da(qn(n));for(var c=0;c<i.length;++c)i[c]^=1}else i=Da(n);var s,o,u;r.length<=i.length?(s=r,o=i,u=l):(s=i,o=r,u=m);var p=s.length,v=o.length,h=a(l,m)^1,b=new t(h^1),w=new t(1),N=new t(2),g=t.precision;for(t.config({precision:1e9});p>0;)a(s[--p],o[--v])===h&&(b=b.plus(w)),w=w.times(N);for(;v>0;)a(u,o[--v])===h&&(b=b.plus(w)),w=w.times(N);return t.config({precision:g}),h===0&&(b.s=-b.s),b}function Da(e){for(var n=e.d,a=n[0]+"",t=1;t<n.length;++t){for(var r=n[t]+"",i=7-r.length;i--;)r="0"+r;a+=r}for(var l=a.length;a.charAt(l)==="0";)l--;var m=e.e,f=a.slice(0,l+1||1),c=f.length;if(m>0)if(++m>c)for(m-=c;m--;)f+="0";else m<c&&(f=f.slice(0,m)+"."+f.slice(m));for(var s=[0],o=0;o<f.length;){for(var u=s.length;u--;)s[u]*=10;s[0]+=parseInt(f.charAt(o++));for(var p=0;p<s.length;++p)s[p]>1&&((s[p+1]===null||s[p+1]===void 0)&&(s[p+1]=0),s[p+1]+=s[p]>>1,s[p]&=1)}return s.reverse()}function Oy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitXor");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero())return n;if(n.isZero())return e;if(e.eq(n))return new a(0);var t=new a(-1);return e.eq(t)?qn(n):n.eq(t)?qn(e):!e.isFinite()||!n.isFinite()?!e.isFinite()&&!n.isFinite()?t:new a(e.isNegative()===n.isNegative()?1/0:-1/0):Ai(e,n,function(r,i){return r^i})}function Dy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function leftShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:!e.isFinite()&&!n.isFinite()?new a(NaN):n.lt(55)?e.times(Math.pow(2,n.toNumber())+""):e.times(new a(2).pow(n))}function Ty(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function rightArithShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:n.isFinite()?n.lt(55)?e.div(Math.pow(2,n.toNumber())+"").floor():e.div(new a(2).pow(n)).floor():e.isNegative()?new a(-1):e.isFinite()?new a(0):new a(NaN)}var Tu="bitAnd",By=["typed","matrix","equalScalar"],_y=R(Tu,By,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=jr({typed:n,equalScalar:t}),i=Ea({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(Tu,{"number, number":ls,"BigNumber, BigNumber":Ey,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this,!1)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Bu="bitNot",$y=["typed"],Iy=R(Bu,$y,e=>{var{typed:n}=e;return n(Bu,{number:ms,BigNumber:qn,"Array | Matrix":function(t){return be(t,this)}})}),_u="bitOr",qy=["typed","matrix","equalScalar","DenseMatrix"],Ry=R(_u,qy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=qt({typed:n}),l=Mi({typed:n,equalScalar:t}),m=Vt({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(_u,{"number, number":ps,"BigNumber, BigNumber":Cy,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Fy="algorithm07",zy=["typed","DenseMatrix"],ut=R(Fy,zy,e=>{var{typed:n,DenseMatrix:a}=e;return function(i,l,m){var f=i._size,c=i._datatype,s=l._size,o=l._datatype;if(f.length!==s.length)throw new Fe(f.length,s.length);if(f[0]!==s[0]||f[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+s+")");var u=f[0],p=f[1],v,h=0,b=m;typeof c=="string"&&c===o&&(v=c,h=n.convert(0,v),b=n.find(m,[v,v]));var w,N,g=[];for(w=0;w<u;w++)g[w]=[];var y=[],x=[],d=[],A=[];for(N=0;N<p;N++){var S=N+1;for(t(i,N,d,y,S),t(l,N,A,x,S),w=0;w<u;w++){var O=d[w]===S?y[w]:h,M=A[w]===S?x[w]:h;g[w][N]=b(O,M)}}return new a({data:g,size:[u,p],datatype:v})};function t(r,i,l,m,f){for(var c=r._values,s=r._index,o=r._ptr,u=o[i],p=o[i+1];u<p;u++){var v=s[u];l[v]=f,m[v]=c[u]}}}),$u="bitXor",Py=["typed","matrix","DenseMatrix"],Uy=R($u,Py,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Or({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=yr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n($u,{"number, number":vs,"BigNumber, BigNumber":Oy,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Iu="arg",Ly=["typed"],ky=R(Iu,Ly,e=>{var{typed:n}=e;return n(Iu,{number:function(t){return Math.atan2(0,t)},BigNumber:function(t){return t.constructor.atan2(0,t)},Complex:function(t){return t.arg()},"Array | Matrix":function(t){return be(t,this)}})}),qu="conj",Hy=["typed"],Gy=R(qu,Hy,e=>{var{typed:n}=e;return n(qu,{number:function(t){return t},BigNumber:function(t){return t},Complex:function(t){return t.conjugate()},"Array | Matrix":function(t){return be(t,this)}})}),Ru="im",Vy=["typed"],Zy=R(Ru,Vy,e=>{var{typed:n}=e;return n(Ru,{number:function(t){return 0},BigNumber:function(t){return t.mul(0)},Fraction:function(t){return t.mul(0)},Complex:function(t){return t.im},"Array | Matrix":function(t){return be(t,this)}})}),Fu="re",Xy=["typed"],Yy=R(Fu,Xy,e=>{var{typed:n}=e;return n(Fu,{number:function(t){return t},BigNumber:function(t){return t},Fraction:function(t){return t},Complex:function(t){return t.re},"Array | Matrix":function(t){return be(t,this)}})}),zu="not",Wy=["typed"],Jy=R(zu,Wy,e=>{var{typed:n}=e;return n(zu,{number:xs,Complex:function(t){return t.re===0&&t.im===0},BigNumber:function(t){return t.isZero()||t.isNaN()},Unit:function(t){return t.value!==null?this(t.value):!0},"Array | Matrix":function(t){return be(t,this)}})}),Pu="or",Qy=["typed","matrix","equalScalar","DenseMatrix"],Ky=R(Pu,Qy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Or({typed:n}),l=Ca({typed:n,equalScalar:t}),m=yr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Pu,{"number, number":bs,"Complex, Complex":function(o,u){return o.re!==0||o.im!==0||u.re!==0||u.im!==0},"BigNumber, BigNumber":function(o,u){return!o.isZero()&&!o.isNaN()||!u.isZero()&&!u.isNaN()},"Unit, Unit":function(o,u){return this(o.value||0,u.value||0)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Uu="xor",jy=["typed","matrix","DenseMatrix"],e0=R(Uu,jy,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Or({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=yr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n(Uu,{"number, number":ws,"Complex, Complex":function(s,o){return(s.re!==0||s.im!==0)!=(o.re!==0||o.im!==0)},"BigNumber, BigNumber":function(s,o){return(!s.isZero()&&!s.isNaN())!=(!o.isZero()&&!o.isNaN())},"Unit, Unit":function(s,o){return this(s.value||0,o.value||0)},"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Lu="concat",r0=["typed","matrix","isInteger"],ku=R(Lu,r0,e=>{var{typed:n,matrix:a,isInteger:t}=e;return n(Lu,{"...Array | Matrix | number | BigNumber":function(i){var l,m=i.length,f=-1,c,s=!1,o=[];for(l=0;l<m;l++){var u=i[l];if(Oe(u)&&(s=!0),$e(u)||Ie(u)){if(l!==m-1)throw new Error("Dimension must be specified as last argument");if(c=f,f=u.valueOf(),!t(f))throw new TypeError("Integer number expected for dimension");if(f<0||l>0&&f>c)throw new Jr(f,c+1)}else{var p=Ce(u).valueOf(),v=Pe(p);if(o[l]=p,c=f,f=v.length-1,l>0&&f!==c)throw new Fe(c+1,f+1)}}if(o.length===0)throw new SyntaxError("At least one matrix expected");for(var h=o.shift();o.length;)h=Hu(h,o.shift(),f,0);return s?a(h):h},"...string":function(i){return i.join("")}})});function Hu(e,n,a,t){if(t<a){if(e.length!==n.length)throw new Fe(e.length,n.length);for(var r=[],i=0;i<e.length;i++)r[i]=Hu(e[i],n[i],a,t+1);return r}else return e.concat(n)}var Gu="column",t0=["typed","Index","matrix","range"],Vu=R(Gu,t0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(Gu,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[1]);var f=r(0,l.size()[0]),c=new a(f,m);return l.subset(c)}}),Zu="count",n0=["typed","size","prod"],a0=R(Zu,n0,e=>{var{typed:n,size:a,prod:t}=e;return n(Zu,{string:function(i){return i.length},"Matrix | Array":function(i){return t(a(i))}})}),Xu="cross",i0=["typed","matrix","subtract","multiply"],o0=R(Xu,i0,e=>{var{typed:n,matrix:a,subtract:t,multiply:r}=e;return n(Xu,{"Matrix, Matrix":function(m,f){return a(i(m.toArray(),f.toArray()))},"Matrix, Array":function(m,f){return a(i(m.toArray(),f))},"Array, Matrix":function(m,f){return a(i(m,f.toArray()))},"Array, Array":i});function i(l,m){var f=Math.max(Pe(l).length,Pe(m).length);l=ia(l),m=ia(m);var c=Pe(l),s=Pe(m);if(c.length!==1||s.length!==1||c[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+c.join(", ")+"], B = ["+s.join(", ")+"])");var o=[t(r(l[1],m[2]),r(l[2],m[1])),t(r(l[2],m[0]),r(l[0],m[2])),t(r(l[0],m[1]),r(l[1],m[0]))];return f>1?[o]:o}}),Yu="diag",s0=["typed","matrix","DenseMatrix","SparseMatrix"],u0=R(Yu,s0,e=>{var{typed:n,matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(Yu,{Array:function(c){return i(c,0,Pe(c),null)},"Array, number":function(c,s){return i(c,s,Pe(c),null)},"Array, BigNumber":function(c,s){return i(c,s.toNumber(),Pe(c),null)},"Array, string":function(c,s){return i(c,0,Pe(c),s)},"Array, number, string":function(c,s,o){return i(c,s,Pe(c),o)},"Array, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),Pe(c),o)},Matrix:function(c){return i(c,0,c.size(),c.storage())},"Matrix, number":function(c,s){return i(c,s,c.size(),c.storage())},"Matrix, BigNumber":function(c,s){return i(c,s.toNumber(),c.size(),c.storage())},"Matrix, string":function(c,s){return i(c,0,c.size(),s)},"Matrix, number, string":function(c,s,o){return i(c,s,c.size(),o)},"Matrix, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),c.size(),o)}});function i(f,c,s,o){if(!Ae(c))throw new TypeError("Second parameter in function diag must be an integer");var u=c>0?c:0,p=c<0?-c:0;switch(s.length){case 1:return l(f,c,o,s[0],p,u);case 2:return m(f,c,o,s,p,u)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function l(f,c,s,o,u,p){var v=[o+u,o+p];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var h=s==="sparse"?r.diagonal(v,f,c):t.diagonal(v,f,c);return s!==null?h:h.valueOf()}function m(f,c,s,o,u,p){if(Oe(f)){var v=f.diagonal(c);return s!==null?s!==v.storage()?a(v,s):v:v.valueOf()}for(var h=Math.min(o[0]-u,o[1]-p),b=[],w=0;w<h;w++)b[w]=f[w+u][w+p];return s!==null?a(b):b}});function c0(e){var n=0,a=1,t=Object.create(null),r=Object.create(null),i=0,l=function(f){var c=r[f];if(c&&(delete t[c],delete r[f],--n,a===c)){if(!n){i=0,a=1;return}for(;!hasOwnProperty.call(t,++a););}};return e=Math.abs(e),{hit:function(f){var c=r[f],s=++i;if(t[s]=f,r[f]=s,!c)return++n,n<=e?void 0:(f=t[a],l(f),f);if(delete t[c],a===c)for(;!hasOwnProperty.call(t,++a););},delete:l,clear:function(){n=i=0,a=1,t=Object.create(null),r=Object.create(null)}}}function Rn(e){var{hasher:n,limit:a}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return a=a==null?Number.POSITIVE_INFINITY:a,n=n==null?JSON.stringify:n,function t(){typeof t.cache!="object"&&(t.cache={values:new Map,lru:c0(a||Number.POSITIVE_INFINITY)});for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var l=n(r);if(t.cache.values.has(l))return t.cache.lru.hit(l),t.cache.values.get(l);var m=e.apply(e,r);return t.cache.values.set(l,m),t.cache.values.delete(t.cache.lru.hit(l)),m}}function hn(e){return Object.keys(e.signatures||{}).reduce(function(n,a){var t=(a.match(/,/g)||[]).length+1;return Math.max(n,t)},-1)}var f0="filter",l0=["typed"],m0=R(f0,l0,e=>{var{typed:n}=e;return n("filter",{"Array, function":Wu,"Matrix, function":function(t,r){return t.create(Wu(t.toArray(),r))},"Array, RegExp":sa,"Matrix, RegExp":function(t,r){return t.create(sa(t.toArray(),r))}})});function Wu(e,n){var a=hn(n);return No(e,function(t,r,i){return a===1?n(t):a===2?n(t,[r]):n(t,[r],i)})}var Ju="flatten",p0=["typed","matrix"],v0=R(Ju,p0,e=>{var{typed:n,matrix:a}=e;return n(Ju,{Array:function(r){return Le(Ce(r))},Matrix:function(r){var i=Le(Ce(r.toArray()));return a(i)}})}),Qu="forEach",h0=["typed"],d0=R(Qu,h0,e=>{var{typed:n}=e;return n(Qu,{"Array, function":g0,"Matrix, function":function(t,r){return t.forEach(r)}})});function g0(e,n){var a=hn(n),t=function r(i,l){Array.isArray(i)?oa(i,function(m,f){r(m,l.concat(f))}):a===1?n(i):a===2?n(i,l):n(i,l,e)};t(e,[])}var Ku="getMatrixDataType",y0=["typed"],x0=R(Ku,y0,e=>{var{typed:n}=e;return n(Ku,{Array:function(t){return _n(t,Ke)},Matrix:function(t){return t.getDataType()}})}),ju="identity",b0=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],w0=R(ju,b0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r,DenseMatrix:i,SparseMatrix:l}=e;return n(ju,{"":function(){return a.matrix==="Matrix"?t([]):[]},string:function(s){return t(s)},"number | BigNumber":function(s){return f(s,s,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(s,o){return f(s,s,o)},"number | BigNumber, number | BigNumber":function(s,o){return f(s,o,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(s,o,u){return f(s,o,u)},Array:function(s){return m(s)},"Array, string":function(s,o){return m(s,o)},Matrix:function(s){return m(s.valueOf(),s.storage())},"Matrix, string":function(s,o){return m(s.valueOf(),o)}});function m(c,s){switch(c.length){case 0:return s?t(s):[];case 1:return f(c[0],c[0],s);case 2:return f(c[0],c[1],s);default:throw new Error("Vector containing two values expected")}}function f(c,s,o){var u=Ie(c)||Ie(s)?r:null;if(Ie(c)&&(c=c.toNumber()),Ie(s)&&(s=s.toNumber()),!Ae(c)||c<1)throw new Error("Parameters in function identity must be positive integers");if(!Ae(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var p=u?new r(1):1,v=u?new u(0):0,h=[c,s];if(o){if(o==="sparse")return l.diagonal(h,p,0,v);if(o==="dense")return i.diagonal(h,p,0,v);throw new TypeError('Unknown matrix type "'.concat(o,'"'))}for(var b=on([],h,v),w=c<s?c:s,N=0;N<w;N++)b[N][N]=p;return b}}),ec="kron",N0=["typed","matrix","multiplyScalar"],M0=R(ec,N0,e=>{var{typed:n,matrix:a,multiplyScalar:t}=e;return n(ec,{"Matrix, Matrix":function(l,m){return a(r(l.toArray(),m.toArray()))},"Matrix, Array":function(l,m){return a(r(l.toArray(),m))},"Array, Matrix":function(l,m){return a(r(l,m.toArray()))},"Array, Array":r});function r(i,l){if(Pe(i).length===1&&(i=[i]),Pe(l).length===1&&(l=[l]),Pe(i).length>2||Pe(l).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(l.length)+")");var m=[],f=[];return i.map(function(c){return l.map(function(s){return f=[],m.push(f),c.map(function(o){return s.map(function(u){return f.push(t(o,u))})})})})&&m}}),rc="map",A0=["typed"],S0=R(rc,A0,e=>{var{typed:n}=e;return n(rc,{"Array, function":E0,"Matrix, function":function(t,r){return t.map(r)}})});function E0(e,n){var a=hn(n),t=function r(i,l){if(Array.isArray(i))return i.map(function(c,s){return r(c,l.concat(s))});try{return a===1?n(i):a===2?n(i,l):n(i,l,e)}catch(c){if(c instanceof TypeError&&"data"in c&&c.data.category==="wrongType"){var m="map attempted to call '".concat(c.data.fn,"(").concat(i),f=JSON.stringify(l);throw a===2?m+=","+f:a!==1&&(m+=",".concat(f,",").concat(e)),m+=")' but argument ".concat(c.data.index+1," of type "),m+="".concat(c.data.actual," does not match expected type "),m+=c.data.expected.join(" or "),new TypeError(m)}throw c}};return t(e,[])}var tc="diff",C0=["typed","matrix","subtract","number"],nc=R(tc,C0,e=>{var{typed:n,matrix:a,subtract:t,number:r}=e;return n(tc,{"Array | Matrix":function(s){return Oe(s)?a(l(s.toArray())):l(s)},"Array | Matrix, number":function(s,o){if(!Ae(o))throw new RangeError("Dimension must be a whole number");return Oe(s)?a(i(s.toArray(),o)):i(s,o)},"Array | Matrix, BigNumber":function(s,o){return this(s,r(o))}});function i(c,s){if(Oe(c)&&(c=c.toArray()),!Array.isArray(c))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var o=[];return c.forEach(u=>{o.push(i(u,s-1))}),o}else{if(s===0)return l(c);throw RangeError("Cannot have negative dimension")}}function l(c){var s=[],o=c.length;if(o<2)return c;for(var u=1;u<o;u++)s.push(m(c[u-1],c[u]));return s}function m(c,s){Oe(c)&&(c=c.toArray()),Oe(s)&&(s=s.toArray());var o=Array.isArray(c),u=Array.isArray(s);if(o&&u)return f(c,s);if(!o&&!u)return t(s,c);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function f(c,s){if(c.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var o=[],u=c.length,p=0;p<u;p++)o.push(m(c[p],s[p]));return o}}),O0="ones",D0=["typed","config","matrix","BigNumber"],T0=R(O0,D0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n("ones",{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(1):1;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){Ie(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function ones must be positive integers")})}});function Si(){throw new Error('No "bignumber" implementation available')}function ac(){throw new Error('No "fraction" implementation available')}function ic(){throw new Error('No "matrix" implementation available')}var oc="range",B0=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],sc=R(oc,B0,e=>{var{typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f}=e;return n(oc,{string:s,"string, boolean":s,"number, number":function(w,N){return c(o(w,N,1))},"number, number, number":function(w,N,g){return c(o(w,N,g))},"number, number, boolean":function(w,N,g){return c(g?u(w,N,1):o(w,N,1))},"number, number, number, boolean":function(w,N,g,y){return c(y?u(w,N,g):o(w,N,g))},"BigNumber, BigNumber":function(w,N){var g=w.constructor;return c(p(w,N,new g(1)))},"BigNumber, BigNumber, BigNumber":function(w,N,g){return c(p(w,N,g))},"BigNumber, BigNumber, boolean":function(w,N,g){var y=w.constructor;return c(g?v(w,N,new y(1)):p(w,N,new y(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(w,N,g,y){return c(y?v(w,N,g):p(w,N,g))}});function c(b){return a.matrix==="Matrix"?t?t(b):ic():b}function s(b,w){var N=h(b);if(!N)throw new SyntaxError('String "'+b+'" is no valid range');var g;return a.number==="BigNumber"?(r===void 0&&Si(),g=w?v:p,c(g(r(N.start),r(N.end),r(N.step)))):(g=w?u:o,c(g(N.start,N.end,N.step)))}function o(b,w,N){var g=[],y=b;if(N>0)for(;i(y,w);)g.push(y),y+=N;else if(N<0)for(;m(y,w);)g.push(y),y+=N;return g}function u(b,w,N){var g=[],y=b;if(N>0)for(;l(y,w);)g.push(y),y+=N;else if(N<0)for(;f(y,w);)g.push(y),y+=N;return g}function p(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;i(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;m(x,w);)y.push(x),x=x.plus(N);return y}function v(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;l(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;f(x,w);)y.push(x),x=x.plus(N);return y}function h(b){var w=b.split(":"),N=w.map(function(y){return Number(y)}),g=N.some(function(y){return isNaN(y)});if(g)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),uc="reshape",_0=["typed","isInteger","matrix"],$0=R(uc,_0,e=>{var{typed:n,isInteger:a}=e;return n(uc,{"Matrix, Array":function(r,i){return r.reshape(i)},"Array, Array":function(r,i){return i.forEach(function(l){if(!a(l))throw new TypeError("Invalid size for dimension: "+l)}),go(r,i)}})});function dn(e,n,a,t){if(!(this instanceof dn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=n,this.min=a,this.max=t,this.message="Wrong number of arguments in function "+e+" ("+n+" provided, "+a+(t!=null?"-"+t:"")+" expected)",this.stack=new Error().stack}dn.prototype=new Error,dn.prototype.constructor=Error,dn.prototype.name="ArgumentsError",dn.prototype.isArgumentsError=!0;var I0="resize",q0=["config","matrix"],R0=R(I0,q0,e=>{var{config:n,matrix:a}=e;return function(i,l,m){if(arguments.length!==2&&arguments.length!==3)throw new dn("resize",arguments.length,2,3);if(Oe(l)&&(l=l.valueOf()),Ie(l[0])&&(l=l.map(function(s){return Ie(s)?s.toNumber():s})),Oe(i))return i.resize(l,m,!0);if(typeof i=="string")return t(i,l,m);var f=Array.isArray(i)?!1:n.matrix!=="Array";if(l.length===0){for(;Array.isArray(i);)i=i[0];return Ce(i)}else{Array.isArray(i)||(i=[i]),i=Ce(i);var c=on(i,l,m);return f?a(c):c}};function t(r,i,l){if(l!==void 0){if(typeof l!="string"||l.length!==1)throw new TypeError("Single character expected as defaultValue")}else l=" ";if(i.length!==1)throw new Fe(i.length,1);var m=i[0];if(typeof m!="number"||!Ae(m))throw new TypeError("Invalid size, must contain positive integers (size: "+Re(i)+")");if(r.length>m)return r.substring(0,m);if(r.length<m){for(var f=r,c=0,s=m-r.length;c<s;c++)f+=l;return f}else return r}}),cc="rotate",F0=["typed","multiply","rotationMatrix"],z0=R(cc,F0,e=>{var{typed:n,multiply:a,rotationMatrix:t}=e;return n(cc,{"Array , number | BigNumber | Complex | Unit":function(l,m){r(l,2);var f=a(t(m),l);return f.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(l,m){return r(l,2),a(t(m),l)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){r(l,3);var c=a(t(m,f),l);return c},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){return r(l,3),a(t(m,f),l)}});function r(i,l){var m=Array.isArray(i)?Pe(i):i.size();if(m.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m.length===2&&m[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m[0]!==l)throw new RangeError("Vector must be of dimensions 1x".concat(l))}}),fc="rotationMatrix",P0=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],U0=R(fc,P0,e=>{var{typed:n,config:a,multiplyScalar:t,addScalar:r,unaryMinus:i,norm:l,BigNumber:m,matrix:f,DenseMatrix:c,SparseMatrix:s,cos:o,sin:u}=e;return n(fc,{"":function(){return a.matrix==="Matrix"?f([]):[]},string:function(g){return f(g)},"number | BigNumber | Complex | Unit":function(g){return p(g,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(g,y){return p(g,y)},"number | BigNumber | Complex | Unit, Array":function(g,y){var x=f(y);return v(x),w(g,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(g,y){v(y);var x=y.storage()||(a.matrix==="Matrix"?"dense":void 0);return w(g,y,x)},"number | BigNumber | Complex | Unit, Array, string":function(g,y,x){var d=f(y);return v(d),w(g,d,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(g,y,x){return v(y),w(g,y,x)}});function p(N,g){var y=Ie(N),x=y?new m(-1):-1,d=o(N),A=u(N),S=[[d,t(x,A)],[A,d]];return b(S,g)}function v(N){var g=N.size();if(g.length<1||g[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(N){return N.reduce((g,y)=>t(g,y))}function b(N,g){if(g){if(g==="sparse")return new s(N);if(g==="dense")return new c(N);throw new TypeError('Unknown matrix type "'.concat(g,'"'))}return N}function w(N,g,y){var x=l(g);if(x===0)throw new RangeError("Rotation around zero vector");var d=Ie(N)?m:null,A=d?new d(1):1,S=d?new d(-1):-1,O=d?new d(g.get([0])/x):g.get([0])/x,M=d?new d(g.get([1])/x):g.get([1])/x,_=d?new d(g.get([2])/x):g.get([2])/x,E=o(N),$=r(A,i(E)),z=u(N),I=r(E,h([O,O,$])),T=r(h([O,M,$]),h([S,_,z])),B=r(h([O,_,$]),h([M,z])),G=r(h([O,M,$]),h([_,z])),D=r(E,h([M,M,$])),H=r(h([M,_,$]),h([S,O,z])),W=r(h([O,_,$]),h([S,M,z])),j=r(h([M,_,$]),h([O,z])),V=r(E,h([_,_,$])),K=[[I,T,B],[G,D,H],[W,j,V]];return b(K,y)}}),lc="row",L0=["typed","Index","matrix","range"],mc=R(lc,L0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(lc,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[0]);var f=r(0,l.size()[1]),c=new a(m,f);return l.subset(c)}}),pc="size",k0=["typed","config","?matrix"],H0=R(pc,k0,e=>{var{typed:n,config:a,matrix:t}=e;return n(pc,{Matrix:function(i){return i.create(i.size())},Array:Pe,string:function(i){return a.matrix==="Array"?[i.length]:t([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return a.matrix==="Array"?[]:t?t([]):ic()}})}),vc="squeeze",G0=["typed","matrix"],V0=R(vc,G0,e=>{var{typed:n,matrix:a}=e;return n(vc,{Array:function(r){return ia(Ce(r))},Matrix:function(r){var i=ia(r.toArray());return Array.isArray(i)?a(i):i},any:function(r){return Ce(r)}})}),hc="subset",Z0=["typed","matrix"],dc=R(hc,Z0,e=>{var{typed:n,matrix:a}=e;return n(hc,{"Array, Index":function(r,i){var l=a(r),m=l.subset(i);return i.isScalar()?m:m.valueOf()},"Matrix, Index":function(r,i){return r.subset(i)},"Object, Index":Y0,"string, Index":X0,"Array, Index, any":function(r,i,l){return a(Ce(r)).subset(i,l,void 0).valueOf()},"Array, Index, any, any":function(r,i,l,m){return a(Ce(r)).subset(i,l,m).valueOf()},"Matrix, Index, any":function(r,i,l){return r.clone().subset(i,l)},"Matrix, Index, any, any":function(r,i,l,m){return r.clone().subset(i,l,m)},"string, Index, string":gc,"string, Index, string, string":gc,"Object, Index, any":W0})});function X0(e,n){if(!Cn(n))throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);var a=e.length;We(n.min()[0],a),We(n.max()[0],a);var t=n.dimension(0),r="";return t.forEach(function(i){r+=e.charAt(i)}),r}function gc(e,n,a,t){if(!n||n.isIndex!==!0)throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);if(t!==void 0){if(typeof t!="string"||t.length!==1)throw new TypeError("Single character expected as defaultValue")}else t=" ";var r=n.dimension(0),i=r.size()[0];if(i!==a.length)throw new Fe(r.size()[0],a.length);var l=e.length;We(n.min()[0]),We(n.max()[0]);for(var m=[],f=0;f<l;f++)m[f]=e.charAt(f);if(r.forEach(function(o,u){m[o]=a.charAt(u[0])}),m.length>l)for(var c=l-1,s=m.length;c<s;c++)m[c]||(m[c]=t);return m.join("")}function Y0(e,n){if(n.size().length!==1)throw new Fe(n.size(),1);var a=n.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");return Gr(e,a)}function W0(e,n,a){if(n.size().length!==1)throw new Fe(n.size(),1);var t=n.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");var r=Ce(e);return un(r,t,a),r}var J0="transpose",Q0=["typed","matrix"],K0=R(J0,Q0,e=>{var{typed:n,matrix:a}=e;return n("transpose",{Array:function(l){return this(a(l)).valueOf()},Matrix:function(l){var m=l.size(),f;switch(m.length){case 1:f=l.clone();break;case 2:{var c=m[0],s=m[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Re(m)+")");switch(l.storage()){case"dense":f=t(l,c,s);break;case"sparse":f=r(l,c,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Re(this._size)+")")}return f},any:function(l){return Ce(l)}});function t(i,l,m){for(var f=i._data,c=[],s,o=0;o<m;o++){s=c[o]=[];for(var u=0;u<l;u++)s[u]=Ce(f[u][o])}return i.createDenseMatrix({data:c,size:[m,l],datatype:i._datatype})}function r(i,l,m){for(var f=i._values,c=i._index,s=i._ptr,o=f?[]:void 0,u=[],p=[],v=[],h=0;h<l;h++)v[h]=0;var b,w,N;for(b=0,w=c.length;b<w;b++)v[c[b]]++;for(var g=0,y=0;y<l;y++)p.push(g),g+=v[y],v[y]=p[y];for(p.push(g),N=0;N<m;N++)for(var x=s[N],d=s[N+1],A=x;A<d;A++){var S=v[c[A]]++;u[S]=N,f&&(o[S]=Ce(f[A]))}return i.createSparseMatrix({values:o,index:u,ptr:p,size:[m,l],datatype:i._datatype})}}),yc="ctranspose",j0=["typed","transpose","conj"],e1=R(yc,j0,e=>{var{typed:n,transpose:a,conj:t}=e;return n(yc,{any:function(i){return t(a(i))}})}),xc="zeros",r1=["typed","config","matrix","BigNumber"],t1=R(xc,r1,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(xc,{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(0):0;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){Ie(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function zeros must be positive integers")})}}),bc="fft",n1=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],a1=R(bc,n1,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,divideScalar:i,exp:l,tau:m,i:f}=e;return n(bc,{Array:c,Matrix:function(p){return p.create(c(p.toArray()))}});function c(u){var p=Pe(u);return p.length===1?o(u,p[0]):s(u.map(v=>c(v,p.slice(1))),0)}function s(u,p){var v=Pe(u);if(p!==0)return new Array(v[0]).fill(0).map((b,w)=>s(u[w],p-1));if(v.length===1)return o(u);function h(b){var w=Pe(b);return new Array(w[1]).fill(0).map((N,g)=>new Array(w[0]).fill(0).map((y,x)=>b[x][g]))}return h(s(h(u),1))}function o(u){var p=u.length;if(p===1)return[u[0]];if(p%2===0){for(var v=[...o(u.filter((N,g)=>g%2===0)),...o(u.filter((N,g)=>g%2===1))],h=0;h<p/2;h++){var b=v[h],w=r(v[h+p/2],l(r(r(m,f),i(-h,p))));v[h]=t(b,w),v[h+p/2]=t(b,r(-1,w))}return v}throw new Error("Can only calculate FFT of power-of-two size")}}),wc="ifft",i1=["typed","fft","dotDivide","conj"],o1=R(wc,i1,e=>{var{typed:n,fft:a,dotDivide:t,conj:r}=e;return n(wc,{"Array | Matrix":function(l){var m=Oe(l)?l.size():Pe(l);return t(r(a(r(l))),m.reduce((f,c)=>f*c,1))}})}),s1="erf",u1=["typed"],c1=R(s1,u1,e=>{var{typed:n}=e;return n("name",{number:function(l){var m=Math.abs(l);return m>=m1?Dt(l):m<=f1?Dt(l)*a(m):m<=4?Dt(l)*(1-t(m)):Dt(l)*(1-r(m))},"Array | Matrix":function(l){return be(l,this)}});function a(i){var l=i*i,m=Nt[0][4]*l,f=l,c;for(c=0;c<3;c+=1)m=(m+Nt[0][c])*l,f=(f+gn[0][c])*l;return i*(m+Nt[0][3])/(f+gn[0][3])}function t(i){var l=Nt[1][8]*i,m=i,f;for(f=0;f<7;f+=1)l=(l+Nt[1][f])*i,m=(m+gn[1][f])*i;var c=(l+Nt[1][7])/(m+gn[1][7]),s=parseInt(i*16)/16,o=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-o)*c}function r(i){var l=1/(i*i),m=Nt[2][5]*l,f=l,c;for(c=0;c<4;c+=1)m=(m+Nt[2][c])*l,f=(f+gn[2][c])*l;var s=l*(m+Nt[2][4])/(f+gn[2][4]);s=(l1-s)/i,l=parseInt(i*16)/16;var o=(i-l)*(i+l);return Math.exp(-l*l)*Math.exp(-o)*s}}),f1=.46875,l1=.5641895835477563,Nt=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],gn=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],m1=Math.pow(2,53),Nc="mode",p1=["typed","isNaN","isNumeric"],v1=R(Nc,p1,e=>{var{typed:n,isNaN:a,isNumeric:t}=e;return n(Nc,{"Array | Matrix":r,"...":function(l){return r(l)}});function r(i){i=Le(i.valueOf());var l=i.length;if(l===0)throw new Error("Cannot calculate mode of an empty array");for(var m={},f=[],c=0,s=0;s<i.length;s++){var o=i[s];if(t(o)&&a(o))throw new Error("Cannot calculate mode of an array containing NaN values");o in m||(m[o]=0),m[o]++,m[o]===c?f.push(o):m[o]>c&&(c=m[o],f=[o])}return f}});function Dr(e,n,a){var t;return String(e).indexOf("Unexpected type")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+n+", unexpected type of argument"+t)):String(e).indexOf("complex numbers")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":"",new TypeError("Cannot calculate "+n+", no ordering relation is defined for complex numbers"+t)):e}var Mc="prod",h1=["typed","config","multiplyScalar","numeric"],d1=R(Mc,h1,e=>{var{typed:n,config:a,multiplyScalar:t,numeric:r}=e;return n(Mc,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(m,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(m){return i(m)}});function i(l){var m;if(bt(l,function(f){try{m=m===void 0?f:t(m,f)}catch(c){throw Dr(c,"prod",f)}}),typeof m=="string"&&(m=r(m,a.number)),m===void 0)throw new Error("Cannot calculate prod of an empty array");return m}}),Ac="format",g1=["typed"],y1=R(Ac,g1,e=>{var{typed:n}=e;return n(Ac,{any:Re,"any, Object | function | number":Re})}),Sc="bin",x1=["typed","format"],b1=R(Sc,x1,e=>{var{typed:n,format:a}=e;return n(Sc,{"number | BigNumber":function(r){return a(r,{notation:"bin"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"bin",wordSize:i})}})}),Ec="oct",w1=["typed","format"],N1=R(Ec,w1,e=>{var{typed:n,format:a}=e;return n(Ec,{"number | BigNumber":function(r){return a(r,{notation:"oct"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"oct",wordSize:i})}})}),Cc="hex",M1=["typed","format"],A1=R(Cc,M1,e=>{var{typed:n,format:a}=e;return n(Cc,{"number | BigNumber":function(r){return a(r,{notation:"hex"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"hex",wordSize:i})}})}),Oc="print",S1=["typed"],E1=R(Oc,S1,e=>{var{typed:n}=e;return n(Oc,{"string, Object | Array":Dc,"string, Object | Array, number | Object":Dc})});function Dc(e,n,a){return e.replace(/\$([\w.]+)/g,function(t,r){for(var i=r.split("."),l=n[i.shift()];i.length&&l!==void 0;){var m=i.shift();l=m?l[m]:l+"."}return l!==void 0?Br(l)?l:Re(l,a):t})}var Tc="to",C1=["typed","matrix"],O1=R(Tc,C1,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Tc,{"Unit, Unit | string":function(l,m){return l.to(m)},"Matrix, Matrix":function(l,m){return t(l,m,this)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"Matrix, any":function(l,m){return r(l,m,this,!1)},"any, Matrix":function(l,m){return r(m,l,this,!0)},"Array, any":function(l,m){return r(a(l),m,this,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,this,!0).valueOf()}})}),Bc="isPrime",D1=["typed"],T1=R(Bc,D1,e=>{var{typed:n}=e;return n(Bc,{number:function(t){if(t*0!==0)return!1;if(t<=3)return t>1;if(t%2===0||t%3===0)return!1;for(var r=5;r*r<=t;r+=6)if(t%r===0||t%(r+2)===0)return!1;return!0},BigNumber:function(t){if(t.toNumber()*0!==0)return!1;if(t.lte(3))return t.gt(1);if(t.mod(2).eq(0)||t.mod(3).eq(0))return!1;if(t.lt(Math.pow(2,32))){for(var r=t.toNumber(),i=5;i*i<=r;i+=6)if(r%i===0||r%(i+2)===0)return!1;return!0}function l(N,g,y){for(var x=1;!g.eq(0);)g.mod(2).eq(0)?(g=g.div(2),N=N.mul(N).mod(y)):(g=g.sub(1),x=N.mul(x).mod(y));return x}var m=t.constructor.clone({precision:t.toFixed(0).length*2});t=new m(t);for(var f=0,c=t.sub(1);c.mod(2).eq(0);)c=c.div(2),f+=1;var s=null;if(t.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<t);else{var o=Math.min(t.toNumber()-2,Math.floor(2*Math.pow(t.toFixed(0).length*Math.log(10),2)));s=[];for(var u=2;u<=o;u+=1)s.push(o)}for(var p=0;p<s.length;p+=1){var v=s[p],h=l(t.sub(t).add(v),c,t);if(!h.eq(1)){for(var b=0,w=h;!w.eq(t.sub(1));b+=1,w=w.mul(w).mod(t))if(b===f-1)return!1}}return!0},"Array | Matrix":function(t){return be(t,this)}})}),B1="numeric",_1=["number","?bignumber","?fraction"],$1=R(B1,_1,e=>{var{number:n,bignumber:a,fraction:t}=e,r={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:l=>n(l),BigNumber:a?l=>a(l):Si,Fraction:t?l=>t(l):ac};return function(m,f){var c=Ke(m);if(!(c in r))throw new TypeError("Cannot convert "+m+' of type "'+c+'"; valid input types are '+Object.keys(r).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+m+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===c?m:i[f](m)}}),_c="divideScalar",I1=["typed","numeric"],q1=R(_c,I1,e=>{var{typed:n,numeric:a}=e;return n(_c,{"number, number":function(r,i){return r/i},"Complex, Complex":function(r,i){return r.div(i)},"BigNumber, BigNumber":function(r,i){return r.div(i)},"Fraction, Fraction":function(r,i){return r.div(i)},"Unit, number | Fraction | BigNumber":function(r,i){var l=r.clone(),m=a(1,Ke(i));return l.value=this(l.value===null?l._normalize(m):l.value,i),l},"number | Fraction | BigNumber, Unit":function(r,i){var l=i.clone();l=l.pow(-1);var m=a(1,Ke(r));return l.value=this(r,i.value===null?i._normalize(m):i.value),l},"Unit, Unit":function(r,i){return r.divide(i)}})}),$c="pow",R1=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],F1=R($c,R1,e=>{var{typed:n,config:a,identity:t,multiply:r,matrix:i,inv:l,number:m,fraction:f,Complex:c}=e;return n($c,{"number, number":s,"Complex, Complex":function(v,h){return v.pow(h)},"BigNumber, BigNumber":function(v,h){return h.isInteger()||v>=0||a.predictable?v.pow(h):new c(v.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(v,h){var b=v.pow(h);if(b!=null)return b;if(a.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return s(v.valueOf(),h.valueOf())},"Array, number":o,"Array, BigNumber":function(v,h){return o(v,h.toNumber())},"Matrix, number":u,"Matrix, BigNumber":function(v,h){return u(v,h.toNumber())},"Unit, number | BigNumber":function(v,h){return v.pow(h)}});function s(p,v){if(a.predictable&&!Ae(v)&&p<0)try{var h=f(v),b=m(h);if((v===b||Math.abs((v-b)/v)<1e-14)&&h.d%2===1)return(h.n%2===0?1:-1)*Math.pow(-p,v)}catch(w){}return a.predictable&&(p<-1&&v===1/0||p>-1&&p<0&&v===-1/0)?NaN:Ae(v)||p>=0||a.predictable?cs(p,v):p*p<1&&v===1/0||p*p>1&&v===-1/0?0:new c(p,0).pow(v,0)}function o(p,v){if(!Ae(v))throw new TypeError("For A^b, b must be an integer (value is "+v+")");var h=Pe(p);if(h.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+h.length+" dimensions)");if(h[0]!==h[1])throw new Error("For A^b, A must be square (size is "+h[0]+"x"+h[1]+")");if(v<0)try{return o(l(p),-v)}catch(N){throw N.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 "+v+")"):N}for(var b=t(h[0]).valueOf(),w=p;v>=1;)(v&1)===1&&(b=r(w,b)),v>>=1,w=r(w,w);return b}function u(p,v){return i(o(p.valueOf(),v))}}),yn="Number of decimals in function round must be an integer",Ic="round",z1=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],P1=R(Ic,z1,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,BigNumber:i,DenseMatrix:l}=e,m=wr({typed:n,equalScalar:t}),f=yr({typed:n,DenseMatrix:l}),c=Ge({typed:n});return n(Ic,{number:fs,"number, number":fs,"number, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return new i(o).toDecimalPlaces(u.toNumber())},Complex:function(o){return o.round()},"Complex, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Complex, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);var p=u.toNumber();return o.round(p)},BigNumber:function(o){return o.toDecimalPlaces(0)},"BigNumber, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.toDecimalPlaces(u.toNumber())},Fraction:function(o){return o.round()},"Fraction, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Fraction, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.round(u.toNumber())},"Array | Matrix":function(o){return be(o,this)},"SparseMatrix, number | BigNumber":function(o,u){return m(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return c(o,u,this,!1)},"Array, number | BigNumber":function(o,u){return c(a(o),u,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):f(u,o,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):c(u,o,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),qc="log",U1=["config","typed","divideScalar","Complex"],L1=R(qc,U1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e;return n(qc,{number:function(l){return l>=0||a.predictable?Yh(l):new r(l,0).log()},Complex:function(l){return l.log()},BigNumber:function(l){return!l.isNegative()||a.predictable?l.ln():new r(l.toNumber(),0).log()},"Array | Matrix":function(l){return be(l,this)},"any, any":function(l,m){return t(this(l),this(m))}})}),Rc="log1p",k1=["typed","config","divideScalar","log","Complex"],H1=R(Rc,k1,e=>{var{typed:n,config:a,divideScalar:t,log:r,Complex:i}=e;return n(Rc,{number:function(f){return f>=-1||a.predictable?Vp(f):l(new i(f,0))},Complex:l,BigNumber:function(f){var c=f.plus(1);return!c.isNegative()||a.predictable?c.ln():l(new i(f.toNumber(),0))},"Array | Matrix":function(f){return be(f,this)},"any, any":function(f,c){return t(this(f),r(c))}});function l(m){var f=m.re+1;return new i(Math.log(Math.sqrt(f*f+m.im*m.im)),Math.atan2(m.im,f))}}),Fc="nthRoots",G1=["config","typed","divideScalar","Complex"],V1=R(Fc,G1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e,i=[function(f){return new r(f,0)},function(f){return new r(0,f)},function(f){return new r(-f,0)},function(f){return new r(0,-f)}];function l(m,f){if(f<0)throw new Error("Root must be greater than zero");if(f===0)throw new Error("Root must be non-zero");if(f%1!==0)throw new Error("Root must be an integer");if(m===0||m.abs()===0)return[new r(0,0)];var c=typeof m=="number",s;(c||m.re===0||m.im===0)&&(c?s=2*+(m<0):m.im===0?s=2*+(m.re<0):s=2*+(m.im<0)+1);for(var o=m.arg(),u=m.abs(),p=[],v=Math.pow(u,1/f),h=0;h<f;h++){var b=(s+4*h)/f;if(b===Math.round(b)){p.push(i[b%4](v));continue}p.push(new r({r:v,phi:(o+2*Math.PI*h)/f}))}return p}return n(Fc,{Complex:function(f){return l(f,2)},"Complex, number":l})}),zc="dotPow",Z1=["typed","equalScalar","matrix","pow","DenseMatrix"],X1=R(zc,Z1,e=>{var{typed:n,equalScalar:a,matrix:t,pow:r,DenseMatrix:i}=e,l=Or({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=wr({typed:n,equalScalar:a}),c=yr({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(zc,{"any, any":r,"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,r,!1)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,r,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,r,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,r)},"Array, Array":function(p,v){return this(t(p),t(v)).valueOf()},"Array, Matrix":function(p,v){return this(t(p),v)},"Matrix, Array":function(p,v){return this(p,t(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(t(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(t(v),p,this,!0).valueOf()}})}),Pc="dotDivide",Y1=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],W1=R(Pc,Y1,e=>{var{typed:n,matrix:a,equalScalar:t,divideScalar:r,DenseMatrix:i}=e,l=jr({typed:n,equalScalar:t}),m=Or({typed:n}),f=ut({typed:n,DenseMatrix:i}),c=wr({typed:n,equalScalar:t}),s=yr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(Pc,{"any, any":r,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,r,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,r,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,r,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,r)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return c(v,h,r,!1)},"DenseMatrix, any":function(v,h){return u(v,h,r,!1)},"any, SparseMatrix":function(v,h){return s(h,v,r,!0)},"any, DenseMatrix":function(v,h){return u(h,v,r,!0)},"Array, any":function(v,h){return u(a(v),h,r,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,r,!0).valueOf()}})});function Fn(e){var{DenseMatrix:n}=e;return function(t,r,i){var l=t.size();if(l.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Re(l)+")");var m=l[0],f=l[1];if(m!==f)throw new RangeError("Matrix must be square (size: "+Re(l)+")");var c=[];if(Oe(r)){var s=r.size(),o=r._data;if(s.length===1){if(s[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var u=0;u<m;u++)c[u]=[o[u]];return new n({data:c,size:[m,1],datatype:r._datatype})}if(s.length===2){if(s[0]!==m||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(Kn(r)){if(i){c=[];for(var p=0;p<m;p++)c[p]=[o[p][0]];return new n({data:c,size:[m,1],datatype:r._datatype})}return r}if(Ut(r)){for(var v=0;v<m;v++)c[v]=[0];for(var h=r._values,b=r._index,w=r._ptr,N=w[1],g=w[0];g<N;g++){var y=b[g];c[y][0]=h[g]}return new n({data:c,size:[m,1],datatype:r._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(Xe(r)){var x=Pe(r);if(x.length===1){if(x[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var d=0;d<m;d++)c[d]=[r[d]];return new n({data:c,size:[m,1]})}if(x.length===2){if(x[0]!==m||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var A=0;A<m;A++)c[A]=[r[A][0]];return new n({data:c,size:[m,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Uc="lsolve",J1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],Q1=R(Uc,J1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Fn({DenseMatrix:m});return n(Uc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=0;N<h;N++){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N+1;d<v;d++)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=0;y<h;y++){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=O;_<M;_++){var E=w[_];E===y?d=b[_]:E>y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0]||0,r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),Lc="usolve",K1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],j1=R(Lc,K1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Fn({DenseMatrix:m});return n(Lc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=h-1;N>=0;N--){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N-1;d>=0;d--)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=h-1;y>=0;y--){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=M-1;_>=O;_--){var E=w[_];E===y?d=b[_]:E<y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0],r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),kc="lsolveAll",ex=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],rx=R(kc,ex,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Fn({DenseMatrix:m});return n(kc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=0;w<b;w++)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w+1;A<b;A++)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w+1;x<b;x++)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=0;g<h;g++)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=O;E<M;E++){var $=w[E];$===g?_=b[E]:$>g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),Hc="usolveAll",tx=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],nx=R(Hc,tx,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Fn({DenseMatrix:m});return n(Hc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=b-1;w>=0;w--)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w-1;A>=0;A--)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w-1;x>=0;x--)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=h-1;g>=0;g--)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=M-1;E>=O;E--){var $=w[E];$===g?_=b[E]:$<g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),ax="algorithm08",ix=["typed","equalScalar"],Ei=R(ax,ix,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");if(!m||!u)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));for(var A=[],S=[],O=[],M=[],_=[],E,$,z,I,T=0;T<N;T++){O[T]=S.length;var B=T+1;for($=c[T],z=c[T+1],E=$;E<z;E++)I=f[E],_[I]=B,M[I]=m[E],S.push(I);for($=v[T],z=v[T+1],E=$;E<z;E++)I=p[E],_[I]===B&&(M[I]=d(M[I],u[E]));for(E=O[T];E<S.length;){I=S[E];var G=M[I];y(G,x)?S.splice(E,1):(A.push(G),E++)}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Gc="leftShift",ox=["typed","matrix","equalScalar","zeros","DenseMatrix"],sx=R(Gc,ox,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=jr({typed:n,equalScalar:t}),f=Ei({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Gc,{"number, number":hs,"BigNumber, BigNumber":Dy,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Vc="rightArithShift",ux=["typed","matrix","equalScalar","zeros","DenseMatrix"],cx=R(Vc,ux,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=jr({typed:n,equalScalar:t}),f=Ei({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Vc,{"number, number":ds,"BigNumber, BigNumber":Ty,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Zc="rightLogShift",fx=["typed","matrix","equalScalar","zeros","DenseMatrix"],lx=R(Zc,fx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=jr({typed:n,equalScalar:t}),f=Ei({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Zc,{"number, number":gs,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Xc="and",mx=["typed","matrix","equalScalar","zeros","not"],px=R(Xc,mx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,not:i}=e,l=jr({typed:n,equalScalar:t}),m=Ea({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n});return n(Xc,{"number, number":Ns,"Complex, Complex":function(u,p){return(u.re!==0||u.im!==0)&&(p.re!==0||p.im!==0)},"BigNumber, BigNumber":function(u,p){return!u.isZero()&&!p.isZero()&&!u.isNaN()&&!p.isNaN()},"Unit, Unit":function(u,p){return this(u.value||0,p.value||0)},"SparseMatrix, SparseMatrix":function(u,p){return m(u,p,this,!1)},"SparseMatrix, DenseMatrix":function(u,p){return l(p,u,this,!0)},"DenseMatrix, SparseMatrix":function(u,p){return l(u,p,this,!1)},"DenseMatrix, DenseMatrix":function(u,p){return c(u,p,this)},"Array, Array":function(u,p){return this(a(u),a(p)).valueOf()},"Array, Matrix":function(u,p){return this(a(u),p)},"Matrix, Array":function(u,p){return this(u,a(p))},"SparseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):f(u,p,this,!1)},"DenseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):s(u,p,this,!1)},"any, SparseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):f(p,u,this,!0)},"any, DenseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):s(p,u,this,!0)},"Array, any":function(u,p){return this(a(u),p).valueOf()},"any, Array":function(u,p){return this(u,a(p)).valueOf()}})}),Yc="compare",vx=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],hx=R(Yc,vx,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,BigNumber:i,Fraction:l,DenseMatrix:m}=e,f=Or({typed:n}),c=Ca({typed:n,equalScalar:t}),s=yr({typed:n,DenseMatrix:m}),o=je({typed:n}),u=Ge({typed:n});return n(Yc,{"boolean, boolean":function(v,h){return v===h?0:v>h?1:-1},"number, number":function(v,h){return Rr(v,h,a.epsilon)?0:v>h?1:-1},"BigNumber, BigNumber":function(v,h){return st(v,h,a.epsilon)?new i(0):new i(v.cmp(h))},"Fraction, Fraction":function(v,h){return new l(v.compare(h))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(v,h){if(!v.equalBase(h))throw new Error("Cannot compare units with different base");return this(v.value,h.value)},"SparseMatrix, SparseMatrix":function(v,h){return c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(r(v),r(h)).valueOf()},"Array, Matrix":function(v,h){return this(r(v),h)},"Matrix, Array":function(v,h){return this(v,r(h))},"SparseMatrix, any":function(v,h){return s(v,h,this,!1)},"DenseMatrix, any":function(v,h){return u(v,h,this,!1)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(r(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(r(h),v,this,!0).valueOf()}})}),Ci,Wc;function dx(){return Wc||(Wc=1,Ci=function e(n,a){var t=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,r=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,m=/^0/,f=function(g){return e.insensitive&&(""+g).toLowerCase()||""+g},c=f(n).replace(r,"")||"",s=f(a).replace(r,"")||"",o=c.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),u=s.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=parseInt(c.match(l),16)||o.length!==1&&c.match(i)&&Date.parse(c),v=parseInt(s.match(l),16)||p&&s.match(i)&&Date.parse(s)||null,h,b;if(v){if(p<v)return-1;if(p>v)return 1}for(var w=0,N=Math.max(o.length,u.length);w<N;w++){if(h=!(o[w]||"").match(m)&&parseFloat(o[w])||o[w]||0,b=!(u[w]||"").match(m)&&parseFloat(u[w])||u[w]||0,isNaN(h)!==isNaN(b))return isNaN(h)?1:-1;if(typeof h!=typeof b&&(h+="",b+=""),h<b)return-1;if(h>b)return 1}return 0}),Ci}var gx=dx();const xn=Bn(gx);var Jc="compareNatural",yx=["typed","compare"],xx=R(Jc,yx,e=>{var{typed:n,compare:a}=e,t=a.signatures["boolean,boolean"];return n(Jc,{"any, any":function(f,c){var s=Ke(f),o=Ke(c),u;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(o==="number"||o==="BigNumber"||o==="Fraction"))return u=a(f,c),u.toString()!=="0"?u>0?1:-1:xn(s,o);if(s==="Array"||s==="Matrix"||o==="Array"||o==="Matrix")return u=r(this,f,c),u!==0?u:xn(s,o);if(s!==o)return xn(s,o);if(s==="Complex")return bx(f,c);if(s==="Unit")return f.equalBase(c)?this(f.value,c.value):i(this,f.formatUnits(),c.formatUnits());if(s==="boolean")return t(f,c);if(s==="string")return xn(f,c);if(s==="Object")return l(this,f,c);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}});function r(m,f,c){return Ut(f)&&Ut(c)?i(m,f.toJSON().values,c.toJSON().values):Ut(f)?r(m,f.toArray(),c):Ut(c)?r(m,f,c.toArray()):Kn(f)?r(m,f.toJSON().data,c):Kn(c)?r(m,f,c.toJSON().data):Array.isArray(f)?Array.isArray(c)?i(m,f,c):r(m,f,[c]):r(m,[f],c)}function i(m,f,c){for(var s=0,o=Math.min(f.length,c.length);s<o;s++){var u=m(f[s],c[s]);if(u!==0)return u}return f.length>c.length?1:f.length<c.length?-1:0}function l(m,f,c){var s=Object.keys(f),o=Object.keys(c);s.sort(xn),o.sort(xn);var u=i(m,s,o);if(u!==0)return u;for(var p=0;p<s.length;p++){var v=m(f[s[p]],c[o[p]]);if(v!==0)return v}return 0}});function bx(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0}var Qc="compareText",wx=["typed","matrix"],Nx=R(Qc,wx,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Qc,{"any, any":an,"DenseMatrix, DenseMatrix":function(l,m){return t(l,m,an)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"DenseMatrix, any":function(l,m){return r(l,m,an,!1)},"any, DenseMatrix":function(l,m){return r(m,l,an,!0)},"Array, any":function(l,m){return r(a(l),m,an,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,an,!0).valueOf()}})}),Ta="equal",Mx=["typed","matrix","equalScalar","DenseMatrix"],Ax=R(Ta,Mx,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Or({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=yr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Ta,{"any, any":function(o,u){return o===null?u===null:u===null?o===null:o===void 0?u===void 0:u===void 0?o===void 0:t(o,u)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,t)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,t,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,t,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,t)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,t,!1)},"DenseMatrix, any":function(o,u){return c(o,u,t,!1)},"any, SparseMatrix":function(o,u){return m(u,o,t,!0)},"any, DenseMatrix":function(o,u){return c(u,o,t,!0)},"Array, any":function(o,u){return c(a(o),u,t,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,t,!0).valueOf()}})});R(Ta,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Ta,{"any, any":function(r,i){return r===null?i===null:i===null?r===null:r===void 0?i===void 0:i===void 0?r===void 0:a(r,i)}})});var Kc="equalText",Sx=["typed","compareText","isZero"],Ex=R(Kc,Sx,e=>{var{typed:n,compareText:a,isZero:t}=e;return n(Kc,{"any, any":function(i,l){return t(a(i,l))}})}),jc="smaller",Cx=["typed","config","matrix","DenseMatrix"],Ox=R(jc,Cx,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Or({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=yr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(jc,{"boolean, boolean":function(o,u){return o<u},"number, number":function(o,u){return o<u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===-1},"Complex, Complex":function(o,u){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),ef="smallerEq",Dx=["typed","config","matrix","DenseMatrix"],Tx=R(ef,Dx,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Or({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=yr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(ef,{"boolean, boolean":function(o,u){return o<=u},"number, number":function(o,u){return o<=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),rf="larger",Bx=["typed","config","matrix","DenseMatrix"],_x=R(rf,Bx,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Or({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=yr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(rf,{"boolean, boolean":function(o,u){return o>u},"number, number":function(o,u){return o>u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),tf="largerEq",$x=["typed","config","matrix","DenseMatrix"],Ix=R(tf,$x,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Or({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=yr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(tf,{"boolean, boolean":function(o,u){return o>=u},"number, number":function(o,u){return o>=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==-1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),nf="deepEqual",qx=["typed","equal"],Rx=R(nf,qx,e=>{var{typed:n,equal:a}=e;return n(nf,{"any, any":function(i,l){return t(i.valueOf(),l.valueOf())}});function t(r,i){if(Array.isArray(r))if(Array.isArray(i)){var l=r.length;if(l!==i.length)return!1;for(var m=0;m<l;m++)if(!t(r[m],i[m]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:a(r,i)}}),Oi="unequal",Fx=["typed","config","equalScalar","matrix","DenseMatrix"],zx=R(Oi,Fx,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,DenseMatrix:i}=e,l=Or({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=yr({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n("unequal",{"any, any":function(p,v){return p===null?v!==null:v===null?p!==null:p===void 0?v!==void 0:v===void 0?p!==void 0:o(p,v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,o)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,o,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,o,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,o)},"Array, Array":function(p,v){return this(r(p),r(v)).valueOf()},"Array, Matrix":function(p,v){return this(r(p),v)},"Matrix, Array":function(p,v){return this(p,r(v))},"SparseMatrix, any":function(p,v){return f(p,v,o,!1)},"DenseMatrix, any":function(p,v){return s(p,v,o,!1)},"any, SparseMatrix":function(p,v){return f(v,p,o,!0)},"any, DenseMatrix":function(p,v){return s(v,p,o,!0)},"Array, any":function(p,v){return s(r(p),v,o,!1).valueOf()},"any, Array":function(p,v){return s(r(v),p,o,!0).valueOf()}});function o(u,p){return!t(u,p)}});R(Oi,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Oi,{"any, any":function(r,i){return r===null?i!==null:i===null?r!==null:r===void 0?i!==void 0:i===void 0?r!==void 0:!a(r,i)}})});var af="partitionSelect",Px=["typed","isNumeric","isNaN","compare"],Ux=R(af,Px,e=>{var{typed:n,isNumeric:a,isNaN:t,compare:r}=e,i=r,l=(c,s)=>-r(c,s);return n(af,{"Array | Matrix, number":function(s,o){return m(s,o,i)},"Array | Matrix, number, string":function(s,o,u){if(u==="asc")return m(s,o,i);if(u==="desc")return m(s,o,l);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":m});function m(c,s,o){if(!Ae(s)||s<0)throw new Error("k must be a non-negative integer");if(Oe(c)){var u=c.size();if(u.length>1)throw new Error("Only one dimensional matrices supported");return f(c.valueOf(),s,o)}if(Array.isArray(c))return f(c,s,o)}function f(c,s,o){if(s>=c.length)throw new Error("k out of bounds");for(var u=0;u<c.length;u++)if(a(c[u])&&t(c[u]))return c[u];for(var p=0,v=c.length-1;p<v;){for(var h=p,b=v,w=c[Math.floor(Math.random()*(v-p+1))+p];h<b;)if(o(c[h],w)>=0){var N=c[b];c[b]=c[h],c[h]=N,--b}else++h;o(c[h],w)>0&&--h,s<=h?v=h:p=h+1}return c[s]}}),of="sort",Lx=["typed","matrix","compare","compareNatural"],kx=R(of,Lx,e=>{var{typed:n,matrix:a,compare:t,compareNatural:r}=e,i=t,l=(s,o)=>-t(s,o);return n(of,{Array:function(o){return f(o),o.sort(i)},Matrix:function(o){return c(o),a(o.toArray().sort(i),o.storage())},"Array, function":function(o,u){return f(o),o.sort(u)},"Matrix, function":function(o,u){return c(o),a(o.toArray().sort(u),o.storage())},"Array, string":function(o,u){return f(o),o.sort(m(u))},"Matrix, string":function(o,u){return c(o),a(o.toArray().sort(m(u)),o.storage())}});function m(s){if(s==="asc")return i;if(s==="desc")return l;if(s==="natural")return r;throw new Error('String "asc", "desc", or "natural" expected')}function f(s){if(Pe(s).length!==1)throw new Error("One dimensional array expected")}function c(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),sf="max",Hx=["typed","config","numeric","larger"],uf=R(sf,Hx,e=>{var{typed:n,config:a,numeric:t,larger:r}=e;return n(sf,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return ba(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function max");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Dr(c,"max",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Dr(s,"max",c)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),cf="min",Gx=["typed","config","numeric","smaller"],ff=R(cf,Gx,e=>{var{typed:n,config:a,numeric:t,smaller:r}=e;return n(cf,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return ba(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function min");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Dr(c,"min",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Dr(s,"min",c)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),Vx="ImmutableDenseMatrix",Zx=["smaller","DenseMatrix"],Xx=R(Vx,Zx,e=>{var{smaller:n,DenseMatrix:a}=e;function t(r,i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!Br(i))throw new Error("Invalid datatype: "+i);if(Oe(r)||Xe(r)){var l=new a(r,i);this._data=l._data,this._size=l._size,this._datatype=l._datatype,this._min=null,this._max=null}else if(r&&Xe(r.data)&&Xe(r.size))this._data=r.data,this._size=r.size,this._datatype=r.datatype,this._min=typeof r.min!="undefined"?r.min:null,this._max=typeof r.max!="undefined"?r.max:null;else{if(r)throw new TypeError("Unsupported type of data ("+Ke(r)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return t.prototype=new a,t.prototype.type="ImmutableDenseMatrix",t.prototype.isImmutableDenseMatrix=!0,t.prototype.subset=function(r){switch(arguments.length){case 1:{var i=a.prototype.subset.call(this,r);return Oe(i)?new t({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},t.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},t.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},t.prototype.clone=function(){return new t({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype})},t.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.fromJSON=function(r){return new t(r)},t.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},t.prototype.min=function(){if(this._min===null){var r=null;this.forEach(function(i){(r===null||n(i,r))&&(r=i)}),this._min=r!==null?r:void 0}return this._min},t.prototype.max=function(){if(this._max===null){var r=null;this.forEach(function(i){(r===null||n(r,i))&&(r=i)}),this._max=r!==null?r:void 0}return this._max},t},{isClass:!0}),Yx="Index",Wx=["ImmutableDenseMatrix"],Jx=R(Yx,Wx,e=>{var{ImmutableDenseMatrix:n}=e;function a(r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,l=arguments.length;i<l;i++){var m=arguments[i];if(jn(m))this._dimensions.push(m),this._isScalar=!1;else if(Array.isArray(m)||Oe(m)){var f=t(m.valueOf());this._dimensions.push(f);var c=f.size();(c.length!==1||c[0]!==1)&&(this._isScalar=!1)}else if(typeof m=="number")this._dimensions.push(t([m]));else if(typeof m=="string")this._dimensions.push(m);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}a.prototype.type="Index",a.prototype.isIndex=!0;function t(r){for(var i=0,l=r.length;i<l;i++)if(typeof r[i]!="number"||!Ae(r[i]))throw new TypeError("Index parameters must be positive integer numbers");return new n(r)}return a.prototype.clone=function(){var r=new a;return r._dimensions=Ce(this._dimensions),r._isScalar=this._isScalar,r},a.create=function(r){var i=new a;return a.apply(i,r),i},a.prototype.size=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?1:m.size()[0]}return r},a.prototype.max=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.max()}return r},a.prototype.min=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.min()}return r},a.prototype.forEach=function(r){for(var i=0,l=this._dimensions.length;i<l;i++)r(this._dimensions[i],i,this)},a.prototype.dimension=function(r){return this._dimensions[r]||null},a.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},a.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},a.prototype.isScalar=function(){return this._isScalar},a.prototype.toArray=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r.push(typeof m=="string"?m:m.toArray())}return r},a.prototype.valueOf=a.prototype.toArray,a.prototype.toString=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];typeof m=="string"?r.push(JSON.stringify(m)):r.push(m.toString())}return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},a.fromJSON=function(r){return a.create(r.dimensions)},a},{isClass:!0}),Qx="FibonacciHeap",Kx=["smaller","larger"],jx=R(Qx,Kx,e=>{var{smaller:n,larger:a}=e,t=1/Math.log((1+Math.sqrt(5))/2);function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}r.prototype.type="FibonacciHeap",r.prototype.isFibonacciHeap=!0,r.prototype.insert=function(s,o){var u={key:s,value:o,degree:0};if(this._minimum){var p=this._minimum;u.left=p,u.right=p.right,p.right=u,u.right.left=u,n(s,p.key)&&(this._minimum=u)}else u.left=u,u.right=u,this._minimum=u;return this._size++,u},r.prototype.size=function(){return this._size},r.prototype.clear=function(){this._minimum=null,this._size=0},r.prototype.isEmpty=function(){return this._size===0},r.prototype.extractMinimum=function(){var s=this._minimum;if(s===null)return s;for(var o=this._minimum,u=s.degree,p=s.child;u>0;){var v=p.right;p.left.right=p.right,p.right.left=p.left,p.left=o,p.right=o.right,o.right=p,p.right.left=p,p.parent=null,p=v,u--}return s.left.right=s.right,s.right.left=s.left,s===s.right?o=null:(o=s.right,o=c(o,this._size)),this._size--,this._minimum=o,s},r.prototype.remove=function(s){this._minimum=i(this._minimum,s,-1),this.extractMinimum()};function i(s,o,u){o.key=u;var p=o.parent;return p&&n(o.key,p.key)&&(l(s,o,p),m(s,p)),n(o.key,s.key)&&(s=o),s}function l(s,o,u){o.left.right=o.right,o.right.left=o.left,u.degree--,u.child===o&&(u.child=o.right),u.degree===0&&(u.child=null),o.left=s,o.right=s.right,s.right=o,o.right.left=o,o.parent=null,o.mark=!1}function m(s,o){var u=o.parent;u&&(o.mark?(l(s,o,u),m(u)):o.mark=!0)}var f=function(o,u){o.left.right=o.right,o.right.left=o.left,o.parent=u,u.child?(o.left=u.child,o.right=u.child.right,u.child.right=o,o.right.left=o):(u.child=o,o.right=o,o.left=o),u.degree++,o.mark=!1};function c(s,o){var u=Math.floor(Math.log(o)*t)+1,p=new Array(u),v=0,h=s;if(h)for(v++,h=h.right;h!==s;)v++,h=h.right;for(var b;v>0;){for(var w=h.degree,N=h.right;b=p[w],!!b;){if(a(h.key,b.key)){var g=b;b=h,h=g}f(b,h),p[w]=null,w++}p[w]=h,h=N,v--}s=null;for(var y=0;y<u;y++)b=p[y],b&&(s?(b.left.right=b.right,b.right.left=b.left,b.left=s,b.right=s.right,s.right=b,b.right.left=b,n(b.key,s.key)&&(s=b)):s=b);return s}return r},{isClass:!0}),eb="Spa",rb=["addScalar","equalScalar","FibonacciHeap"],tb=R(eb,rb,e=>{var{addScalar:n,equalScalar:a,FibonacciHeap:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new t}return r.prototype.type="Spa",r.prototype.isSpa=!0,r.prototype.set=function(i,l){if(this._values[i])this._values[i].value=l;else{var m=this._heap.insert(i,l);this._values[i]=m}},r.prototype.get=function(i){var l=this._values[i];return l?l.value:0},r.prototype.accumulate=function(i,l){var m=this._values[i];m?m.value=n(m.value,l):(m=this._heap.insert(i,l),this._values[i]=m)},r.prototype.forEach=function(i,l,m){var f=this._heap,c=this._values,s=[],o=f.extractMinimum();for(o&&s.push(o);o&&o.key<=l;)o.key>=i&&(a(o.value,0)||m(o.key,o.value,this)),o=f.extractMinimum(),o&&s.push(o);for(var u=0;u<s.length;u++){var p=s[u];o=f.insert(p.key,p.value),c[o.key]=o}},r.prototype.swap=function(i,l){var m=this._values[i],f=this._values[l];if(!m&&f)m=this._heap.insert(i,f.value),this._heap.remove(f),this._values[i]=m,this._values[l]=void 0;else if(m&&!f)f=this._heap.insert(l,m.value),this._heap.remove(m),this._values[l]=f,this._values[i]=void 0;else if(m&&f){var c=m.value;m.value=f.value,f.value=c}},r},{isClass:!0});function zn(e){"@babel/helpers - typeof";return zn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},zn(e)}function nb(e,n){if(zn(e)!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var t=a.call(e,n);if(zn(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function ab(e){var n=nb(e,"string");return zn(n)=="symbol"?n:n+""}function lf(e,n,a){return(n=ab(n))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}var ib=Rn(function(e){return new e(1).exp()},{hasher:Ba}),ob=Rn(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Ba}),Di=Rn(function(e){return e.acos(-1)},{hasher:Ba}),sb=Rn(function(e){return Di(e).times(2)},{hasher:Ba});function Ba(e){return e[0].precision}function mf(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),a.push.apply(a,t)}return a}function Ti(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?mf(Object(a),!0).forEach(function(t){lf(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):mf(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var ub="Unit",cb=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],fb=R(ub,cb,e=>{var{on:n,config:a,addScalar:t,subtract:r,multiplyScalar:i,divideScalar:l,pow:m,abs:f,fix:c,round:s,equal:o,isNumeric:u,format:p,number:v,Complex:h,BigNumber:b,Fraction:w}=e,N=v;function g(F,Y){if(!(this instanceof g))throw new Error("Constructor must be called with the new operator");if(!(F==null||u(F)||vr(F)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(Y!==void 0&&(typeof Y!="string"||Y===""))throw new TypeError("Second parameter in Unit constructor must be a string");if(Y!==void 0){var k=g.parse(Y);this.units=k.units,this.dimensions=k.dimensions}else{this.units=[{unit:j,prefix:B.NONE,power:0}],this.dimensions=[];for(var U=0;U<G.length;U++)this.dimensions[U]=0}this.value=F!=null?this._normalize(F):null,this.fixPrefix=!1,this.skipAutomaticSimplification=!0}g.prototype.type="Unit",g.prototype.isUnit=!0;var y,x,d;function A(){for(;d===" "||d===" ";)M()}function S(F){return F>="0"&&F<="9"||F==="."}function O(F){return F>="0"&&F<="9"}function M(){x++,d=y.charAt(x)}function _(F){x=F,d=y.charAt(x)}function E(){var F="",Y=x;if(d==="+"?M():d==="-"&&(F+=d,M()),!S(d))return _(Y),null;if(d==="."){if(F+=d,M(),!O(d))return _(Y),null}else{for(;O(d);)F+=d,M();d==="."&&(F+=d,M())}for(;O(d);)F+=d,M();if(d==="E"||d==="e"){var k="",U=x;if(k+=d,M(),(d==="+"||d==="-")&&(k+=d,M()),!O(d))return _(U),F;for(F=F+k;O(d);)F+=d,M()}return F}function $(){for(var F="";O(d)||g.isValidAlpha(d);)F+=d,M();var Y=F.charAt(0);return g.isValidAlpha(Y)?F:null}function z(F){return d===F?(M(),F):null}g.parse=function(F,Y){if(Y=Y||{},y=F,x=-1,d="",typeof y!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var k=new g;k.units=[];var U=1,J=!1;M(),A();var q=E(),P=null;if(q){if(a.number==="BigNumber")P=new b(q);else if(a.number==="Fraction")try{P=new w(q)}catch(fr){P=parseFloat(q)}else P=parseFloat(q);A(),z("*")?(U=1,J=!0):z("/")&&(U=-1,J=!0)}for(var Q=[],L=1;;){for(A();d==="(";)Q.push(U),L*=U,U=1,M(),A();var se=void 0;if(d){var fe=d;if(se=$(),se===null)throw new SyntaxError('Unexpected "'+fe+'" in "'+y+'" at index '+x.toString())}else break;var ge=I(se);if(ge===null)throw new SyntaxError('Unit "'+se+'" not found.');var pe=U*L;if(A(),z("^")){A();var ve=E();if(ve===null)throw new SyntaxError('In "'+F+'", "^" must be followed by a floating-point number');pe*=ve}k.units.push({unit:ge.unit,prefix:ge.prefix,power:pe});for(var Ne=0;Ne<G.length;Ne++)k.dimensions[Ne]+=(ge.unit.dimensions[Ne]||0)*pe;for(A();d===")";){if(Q.length===0)throw new SyntaxError('Unmatched ")" in "'+y+'" at index '+x.toString());L/=Q.pop(),M(),A()}if(J=!1,z("*")?(U=1,J=!0):z("/")?(U=-1,J=!0):U=1,ge.unit.base){var Qe=ge.unit.base.key;re.auto[Qe]={unit:ge.unit,prefix:ge.prefix}}}if(A(),d)throw new SyntaxError('Could not parse: "'+F+'"');if(J)throw new SyntaxError('Trailing characters: "'+F+'"');if(Q.length!==0)throw new SyntaxError('Unmatched "(" in "'+y+'"');if(k.units.length===0&&!Y.allowNoUnits)throw new SyntaxError('"'+F+'" contains no units');return k.value=P!==void 0?k._normalize(P):null,k},g.prototype.clone=function(){var F=new g;F.fixPrefix=this.fixPrefix,F.skipAutomaticSimplification=this.skipAutomaticSimplification,F.value=Ce(this.value),F.dimensions=this.dimensions.slice(0),F.units=[];for(var Y=0;Y<this.units.length;Y++){F.units[Y]={};for(var k in this.units[Y])Me(this.units[Y],k)&&(F.units[Y][k]=this.units[Y][k])}return F},g.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},g.prototype._normalize=function(F){if(F==null||this.units.length===0)return F;for(var Y=F,k=g._getNumberConverter(Ke(F)),U=0;U<this.units.length;U++){var J=k(this.units[U].unit.value),q=k(this.units[U].prefix.value),P=k(this.units[U].power);Y=i(Y,m(i(J,q),P))}return Y},g.prototype._denormalize=function(F,Y){if(F==null||this.units.length===0)return F;for(var k=F,U=g._getNumberConverter(Ke(F)),J=0;J<this.units.length;J++){var q=U(this.units[J].unit.value),P=U(this.units[J].prefix.value),Q=U(this.units[J].power);k=l(k,m(i(q,P),Q))}return k};var I=Rn(F=>{if(Me(V,F)){var Y=V[F],k=Y.prefixes[""];return{unit:Y,prefix:k}}for(var U in V)if(Me(V,U)&&uv(F,U)){var J=V[U],q=F.length-U.length,P=F.substring(0,q),Q=Me(J.prefixes,P)?J.prefixes[P]:void 0;if(Q!==void 0)return{unit:J,prefix:Q}}return null},{hasher:F=>F[0],limit:100});g.isValuelessUnit=function(F){return I(F)!==null},g.prototype.hasBase=function(F){if(typeof F=="string"&&(F=D[F]),!F)return!1;for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equalBase=function(F){for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equals=function(F){return this.equalBase(F)&&o(this.value,F.value)},g.prototype.multiply=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)+(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Ti({},F.units[U]);Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=i(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.divide=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)-(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Ti(Ti({},F.units[U]),{},{power:-F.units[U].power});Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=l(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.pow=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)*F;for(var U=0;U<Y.units.length;U++)Y.units[U].power*=F;return Y.value!==null?Y.value=m(Y.value,F):Y.value=null,Y.skipAutomaticSimplification=!1,T(Y)};function T(F){return F.equalBase(D.NONE)&&F.value!==null&&!a.predictable?F.value:F}g.prototype.abs=function(){var F=this.clone();if(F.value!==null)if(F._isDerived()||F.units[0].unit.offset===0)F.value=f(F.value);else{var Y=g._getNumberConverter(Ke(F.value)),k=Y(F.units[0].unit.value),U=Y(F.units[0].unit.offset),J=i(k,U);F.value=r(f(t(F.value,J)),J)}for(var q in F.units)(F.units[q].unit.name==="VA"||F.units[q].unit.name==="VAR")&&(F.units[q].unit=V.W);return F},g.prototype.to=function(F){var Y=this.value===null?this._normalize(1):this.value,k;if(typeof F=="string")k=g.parse(F);else if(En(F))k=F.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(k))throw new Error("Units do not match ('".concat(k.toString(),"' != '").concat(this.toString(),"')"));if(k.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===k.units[0].unit.offset)k.value=Ce(Y);else{var U=g._getNumberConverter(Ke(Y)),J=U(this.units[0].unit.value),q=U(this.units[0].unit.offset),P=i(J,q),Q=U(k.units[0].unit.value),L=U(k.units[0].unit.offset),se=i(Q,L);k.value=r(t(Y,P),se)}return k.fixPrefix=!0,k.skipAutomaticSimplification=!0,k},g.prototype.toNumber=function(F){return N(this.toNumeric(F))},g.prototype.toNumeric=function(F){var Y;return F?Y=this.to(F):Y=this.clone(),Y._isDerived()||Y.units.length===0?Y._denormalize(Y.value):Y._denormalize(Y.value,Y.units[0].prefix.value)},g.prototype.toString=function(){return this.format()},g.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},g.fromJSON=function(F){var Y=new g(F.value,F.unit);return Y.fixPrefix=F.fixPrefix||!1,Y},g.prototype.valueOf=g.prototype.toString,g.prototype.simplify=function(){var F=this.clone(),Y=[],k;for(var U in ie)if(Me(ie,U)&&F.hasBase(D[U])){k=U;break}if(k==="NONE")F.units=[];else{var J;if(k&&Me(ie,k)&&(J=ie[k]),J)F.units=[{unit:J.unit,prefix:J.prefix,power:1}];else{for(var q=!1,P=0;P<G.length;P++){var Q=G[P];Math.abs(F.dimensions[P]||0)>1e-12&&(Me(ie,Q)?Y.push({unit:ie[Q].unit,prefix:ie[Q].prefix,power:F.dimensions[P]||0}):q=!0)}Y.length<F.units.length&&!q&&(F.units=Y)}}return F},g.prototype.toSI=function(){for(var F=this.clone(),Y=[],k=0;k<G.length;k++){var U=G[k];if(Math.abs(F.dimensions[k]||0)>1e-12)if(Me(re.si,U))Y.push({unit:re.si[U].unit,prefix:re.si[U].prefix,power:F.dimensions[k]||0});else throw new Error("Cannot express custom unit "+U+" in SI units")}return F.units=Y,F.fixPrefix=!0,F.skipAutomaticSimplification=!0,F},g.prototype.formatUnits=function(){for(var F="",Y="",k=0,U=0,J=0;J<this.units.length;J++)this.units[J].power>0?(k++,F+=" "+this.units[J].prefix.name+this.units[J].unit.name,Math.abs(this.units[J].power-1)>1e-15&&(F+="^"+this.units[J].power)):this.units[J].power<0&&U++;if(U>0)for(var q=0;q<this.units.length;q++)this.units[q].power<0&&(k>0?(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Math.abs(this.units[q].power+1)>1e-15&&(Y+="^"+-this.units[q].power)):(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Y+="^"+this.units[q].power));F=F.substr(1),Y=Y.substr(1),k>1&&U>0&&(F="("+F+")"),U>1&&k>0&&(Y="("+Y+")");var P=F;return k>0&&U>0&&(P+=" / "),P+=Y,P},g.prototype.format=function(F){var Y=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),k=!1;typeof Y.value!="undefined"&&Y.value!==null&&vr(Y.value)&&(k=Math.abs(Y.value.re)<1e-14);for(var U in Y.units)Me(Y.units,U)&&Y.units[U].unit&&(Y.units[U].unit.name==="VA"&&k?Y.units[U].unit=V.VAR:Y.units[U].unit.name==="VAR"&&!k&&(Y.units[U].unit=V.VA));Y.units.length===1&&!Y.fixPrefix&&Math.abs(Y.units[0].power-Math.round(Y.units[0].power))<1e-14&&(Y.units[0].prefix=Y._bestPrefix());var J=Y._denormalize(Y.value),q=Y.value!==null?p(J,F||{}):"",P=Y.formatUnits();return Y.value&&vr(Y.value)&&(q="("+q+")"),P.length>0&&q.length>0&&(q+=" "),q+=P,q},g.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var F=this.value!==null?f(this.value):0,Y=f(this.units[0].unit.value),k=this.units[0].prefix;if(F===0)return k;var U=this.units[0].power,J=Math.log(F/Math.pow(k.value*Y,U))/Math.LN10-1.2;if(J>-2.200001&&J<1.800001)return k;J=Math.abs(J);var q=this.units[0].unit.prefixes;for(var P in q)if(Me(q,P)){var Q=q[P];if(Q.scientific){var L=Math.abs(Math.log(F/Math.pow(Q.value*Y,U))/Math.LN10-1.2);(L<J||L===J&&Q.name.length<k.name.length)&&(k=Q,J=L)}}return k},g.prototype.splitUnit=function(F){for(var Y=this.clone(),k=[],U=0;U<F.length&&(Y=Y.to(F[U]),U!==F.length-1);U++){var J=Y.toNumeric(),q=s(J),P=void 0,Q=o(q,J);Q?P=q:P=c(Y.toNumeric());var L=new g(P,F[U].toString());k.push(L),Y=r(Y,L)}for(var se=0,fe=0;fe<k.length;fe++)se=t(se,k[fe].value);return o(se,this.value)&&(Y.value=0),k.push(Y),k};var B={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};B.SHORTLONG=rr({},B.SHORT,B.LONG),B.BINARY_SHORT=rr({},B.BINARY_SHORT_SI,B.BINARY_SHORT_IEC),B.BINARY_LONG=rr({},B.BINARY_LONG_SI,B.BINARY_LONG_IEC);var G=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],D={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var H in D)Me(D,H)&&(D[H].key=H);var W={},j={name:"",base:W,value:1,offset:0,dimensions:G.map(F=>0)},V={meter:{name:"meter",base:D.LENGTH,prefixes:B.LONG,value:1,offset:0},inch:{name:"inch",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},foot:{name:"foot",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yard:{name:"yard",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mile:{name:"mile",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},link:{name:"link",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rod:{name:"rod",base:D.LENGTH,prefixes:B.NONE,value:5.0292,offset:0},chain:{name:"chain",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:D.LENGTH,prefixes:B.NONE,value:1e-10,offset:0},m:{name:"m",base:D.LENGTH,prefixes:B.SHORT,value:1,offset:0},in:{name:"in",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},ft:{name:"ft",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yd:{name:"yd",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mi:{name:"mi",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},li:{name:"li",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rd:{name:"rd",base:D.LENGTH,prefixes:B.NONE,value:5.02921,offset:0},ch:{name:"ch",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},mil:{name:"mil",base:D.LENGTH,prefixes:B.NONE,value:254e-7,offset:0},m2:{name:"m2",base:D.SURFACE,prefixes:B.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:D.SURFACE,prefixes:B.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:D.SURFACE,prefixes:B.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:D.SURFACE,prefixes:B.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:D.SURFACE,prefixes:B.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:D.SURFACE,prefixes:B.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:D.SURFACE,prefixes:B.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:D.SURFACE,prefixes:B.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:D.SURFACE,prefixes:B.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:D.SURFACE,prefixes:B.NONE,value:1e4,offset:0},m3:{name:"m3",base:D.VOLUME,prefixes:B.CUBIC,value:1,offset:0},L:{name:"L",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},l:{name:"l",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},litre:{name:"litre",base:D.VOLUME,prefixes:B.LONG,value:.001,offset:0},cuin:{name:"cuin",base:D.VOLUME,prefixes:B.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:D.VOLUME,prefixes:B.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:D.VOLUME,prefixes:B.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:D.VOLUME,prefixes:B.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:D.VOLUME,prefixes:B.NONE,value:15e-6,offset:0},drop:{name:"drop",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},minim:{name:"minim",base:D.VOLUME,prefixes:B.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:D.VOLUME,prefixes:B.NONE,value:1e-6,offset:0},cup:{name:"cup",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:D.VOLUME,prefixes:B.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},obl:{name:"obl",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},g:{name:"g",base:D.MASS,prefixes:B.SHORT,value:.001,offset:0},gram:{name:"gram",base:D.MASS,prefixes:B.LONG,value:.001,offset:0},ton:{name:"ton",base:D.MASS,prefixes:B.SHORT,value:907.18474,offset:0},t:{name:"t",base:D.MASS,prefixes:B.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:D.MASS,prefixes:B.LONG,value:1e3,offset:0},grain:{name:"grain",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},stick:{name:"stick",base:D.MASS,prefixes:B.NONE,value:.115,offset:0},stone:{name:"stone",base:D.MASS,prefixes:B.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},s:{name:"s",base:D.TIME,prefixes:B.SHORT,value:1,offset:0},min:{name:"min",base:D.TIME,prefixes:B.NONE,value:60,offset:0},h:{name:"h",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},second:{name:"second",base:D.TIME,prefixes:B.LONG,value:1,offset:0},sec:{name:"sec",base:D.TIME,prefixes:B.LONG,value:1,offset:0},minute:{name:"minute",base:D.TIME,prefixes:B.NONE,value:60,offset:0},hour:{name:"hour",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},day:{name:"day",base:D.TIME,prefixes:B.NONE,value:86400,offset:0},week:{name:"week",base:D.TIME,prefixes:B.NONE,value:7*86400,offset:0},month:{name:"month",base:D.TIME,prefixes:B.NONE,value:2629800,offset:0},year:{name:"year",base:D.TIME,prefixes:B.NONE,value:31557600,offset:0},decade:{name:"decade",base:D.TIME,prefixes:B.NONE,value:315576e3,offset:0},century:{name:"century",base:D.TIME,prefixes:B.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:D.TIME,prefixes:B.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:D.FREQUENCY,prefixes:B.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:D.FREQUENCY,prefixes:B.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:D.ANGLE,prefixes:B.SHORT,value:1,offset:0},radian:{name:"radian",base:D.ANGLE,prefixes:B.LONG,value:1,offset:0},deg:{name:"deg",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},degree:{name:"degree",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},grad:{name:"grad",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},gradian:{name:"gradian",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},cycle:{name:"cycle",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},A:{name:"A",base:D.CURRENT,prefixes:B.SHORT,value:1,offset:0},ampere:{name:"ampere",base:D.CURRENT,prefixes:B.LONG,value:1,offset:0},K:{name:"K",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},degC:{name:"degC",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},degF:{name:"degF",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},celsius:{name:"celsius",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.SHORT,value:1,offset:0},mole:{name:"mole",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.LONG,value:1,offset:0},cd:{name:"cd",base:D.LUMINOUS_INTENSITY,prefixes:B.SHORT,value:1,offset:0},candela:{name:"candela",base:D.LUMINOUS_INTENSITY,prefixes:B.LONG,value:1,offset:0},N:{name:"N",base:D.FORCE,prefixes:B.SHORT,value:1,offset:0},newton:{name:"newton",base:D.FORCE,prefixes:B.LONG,value:1,offset:0},dyn:{name:"dyn",base:D.FORCE,prefixes:B.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:D.FORCE,prefixes:B.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:D.FORCE,prefixes:B.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:D.FORCE,prefixes:B.NONE,value:9.80665,offset:0},J:{name:"J",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},joule:{name:"joule",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},erg:{name:"erg",base:D.ENERGY,prefixes:B.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:D.ENERGY,prefixes:B.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:D.ENERGY,prefixes:B.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:D.ENERGY,prefixes:B.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:D.ENERGY,prefixes:B.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},watt:{name:"watt",base:D.POWER,prefixes:B.LONG,value:1,offset:0},hp:{name:"hp",base:D.POWER,prefixes:B.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:D.POWER,prefixes:B.SHORT,value:h.I,offset:0},VA:{name:"VA",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},Pa:{name:"Pa",base:D.PRESSURE,prefixes:B.SHORT,value:1,offset:0},psi:{name:"psi",base:D.PRESSURE,prefixes:B.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:D.PRESSURE,prefixes:B.NONE,value:101325,offset:0},bar:{name:"bar",base:D.PRESSURE,prefixes:B.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:D.PRESSURE,prefixes:B.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:D.PRESSURE,prefixes:B.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:D.ELECTRIC_CHARGE,prefixes:B.LONG,value:1,offset:0},C:{name:"C",base:D.ELECTRIC_CHARGE,prefixes:B.SHORT,value:1,offset:0},farad:{name:"farad",base:D.ELECTRIC_CAPACITANCE,prefixes:B.LONG,value:1,offset:0},F:{name:"F",base:D.ELECTRIC_CAPACITANCE,prefixes:B.SHORT,value:1,offset:0},volt:{name:"volt",base:D.ELECTRIC_POTENTIAL,prefixes:B.LONG,value:1,offset:0},V:{name:"V",base:D.ELECTRIC_POTENTIAL,prefixes:B.SHORT,value:1,offset:0},ohm:{name:"ohm",base:D.ELECTRIC_RESISTANCE,prefixes:B.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:D.ELECTRIC_INDUCTANCE,prefixes:B.LONG,value:1,offset:0},H:{name:"H",base:D.ELECTRIC_INDUCTANCE,prefixes:B.SHORT,value:1,offset:0},siemens:{name:"siemens",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.LONG,value:1,offset:0},S:{name:"S",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.SHORT,value:1,offset:0},weber:{name:"weber",base:D.MAGNETIC_FLUX,prefixes:B.LONG,value:1,offset:0},Wb:{name:"Wb",base:D.MAGNETIC_FLUX,prefixes:B.SHORT,value:1,offset:0},tesla:{name:"tesla",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.LONG,value:1,offset:0},T:{name:"T",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.SHORT,value:1,offset:0},b:{name:"b",base:D.BIT,prefixes:B.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:D.BIT,prefixes:B.BINARY_LONG,value:1,offset:0},B:{name:"B",base:D.BIT,prefixes:B.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:D.BIT,prefixes:B.BINARY_LONG,value:8,offset:0}},K={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function te(F){if(F.number==="BigNumber"){var Y=Di(b);V.rad.value=new b(1),V.deg.value=Y.div(180),V.grad.value=Y.div(200),V.cycle.value=Y.times(2),V.arcsec.value=Y.div(648e3),V.arcmin.value=Y.div(10800)}else V.rad.value=1,V.deg.value=Math.PI/180,V.grad.value=Math.PI/200,V.cycle.value=Math.PI*2,V.arcsec.value=Math.PI/648e3,V.arcmin.value=Math.PI/10800;V.radian.value=V.rad.value,V.degree.value=V.deg.value,V.gradian.value=V.grad.value}te(a),n&&n("config",function(F,Y){F.number!==Y.number&&te(F)});var re={si:{NONE:{unit:j,prefix:B.NONE[""]},LENGTH:{unit:V.m,prefix:B.SHORT[""]},MASS:{unit:V.g,prefix:B.SHORT.k},TIME:{unit:V.s,prefix:B.SHORT[""]},CURRENT:{unit:V.A,prefix:B.SHORT[""]},TEMPERATURE:{unit:V.K,prefix:B.SHORT[""]},LUMINOUS_INTENSITY:{unit:V.cd,prefix:B.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:V.mol,prefix:B.SHORT[""]},ANGLE:{unit:V.rad,prefix:B.SHORT[""]},BIT:{unit:V.bits,prefix:B.SHORT[""]},FORCE:{unit:V.N,prefix:B.SHORT[""]},ENERGY:{unit:V.J,prefix:B.SHORT[""]},POWER:{unit:V.W,prefix:B.SHORT[""]},PRESSURE:{unit:V.Pa,prefix:B.SHORT[""]},ELECTRIC_CHARGE:{unit:V.C,prefix:B.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:V.F,prefix:B.SHORT[""]},ELECTRIC_POTENTIAL:{unit:V.V,prefix:B.SHORT[""]},ELECTRIC_RESISTANCE:{unit:V.ohm,prefix:B.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:V.H,prefix:B.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:V.S,prefix:B.SHORT[""]},MAGNETIC_FLUX:{unit:V.Wb,prefix:B.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:V.T,prefix:B.SHORT[""]},FREQUENCY:{unit:V.Hz,prefix:B.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:V.m,prefix:B.SHORT.c},re.cgs.MASS={unit:V.g,prefix:B.SHORT[""]},re.cgs.FORCE={unit:V.dyn,prefix:B.SHORT[""]},re.cgs.ENERGY={unit:V.erg,prefix:B.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:V.ft,prefix:B.NONE[""]},re.us.MASS={unit:V.lbm,prefix:B.NONE[""]},re.us.TEMPERATURE={unit:V.degF,prefix:B.NONE[""]},re.us.FORCE={unit:V.lbf,prefix:B.NONE[""]},re.us.ENERGY={unit:V.BTU,prefix:B.BTU[""]},re.us.POWER={unit:V.hp,prefix:B.NONE[""]},re.us.PRESSURE={unit:V.psi,prefix:B.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var ie=re.auto;g.setUnitSystem=function(F){if(Me(re,F))ie=re[F];else throw new Error("Unit system "+F+" does not exist. Choices are: "+Object.keys(re).join(", "))},g.getUnitSystem=function(){for(var F in re)if(Me(re,F)&&re[F]===ie)return F},g.typeConverters={BigNumber:function(Y){return new b(Y+"")},Fraction:function(Y){return new w(Y)},Complex:function(Y){return Y},number:function(Y){return Y}},g._getNumberConverter=function(F){if(!g.typeConverters[F])throw new TypeError('Unsupported type "'+F+'"');return g.typeConverters[F]};for(var ne in V)if(Me(V,ne)){var ue=V[ne];ue.dimensions=ue.base.dimensions}for(var ee in K)if(Me(K,ee)){var ye=V[K[ee]],we={};for(var me in ye)Me(ye,me)&&(we[me]=ye[me]);we.name=ee,V[ee]=we}g.isValidAlpha=function(Y){return/^[a-zA-Z]$/.test(Y)};function xe(F){for(var Y=0;Y<F.length;Y++){if(d=F.charAt(Y),Y===0&&!g.isValidAlpha(d))throw new Error('Invalid unit name (must begin with alpha character): "'+F+'"');if(Y>0&&!(g.isValidAlpha(d)||O(d)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+F+'"')}}return g.createUnit=function(F,Y){if(typeof F!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Y&&Y.override){for(var k in F)if(Me(F,k)&&g.deleteUnit(k),F[k].aliases)for(var U=0;U<F[k].aliases.length;U++)g.deleteUnit(F[k].aliases[U])}var J;for(var q in F)Me(F,q)&&(J=g.createUnitSingle(q,F[q]));return J},g.createUnitSingle=function(F,Y,k){if((typeof Y=="undefined"||Y===null)&&(Y={}),typeof F!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Me(V,F))throw new Error('Cannot create unit "'+F+'": a unit with that name already exists');xe(F);var U=null,J=[],q=0,P,Q,L;if(Y&&Y.type==="Unit")U=Y.clone();else if(typeof Y=="string")Y!==""&&(P=Y);else if(typeof Y=="object")P=Y.definition,Q=Y.prefixes,q=Y.offset,L=Y.baseName,Y.aliases&&(J=Y.aliases.valueOf());else throw new TypeError('Cannot create unit "'+F+'" from "'+Y.toString()+'": expecting "string" or "Unit" or "Object"');if(J){for(var se=0;se<J.length;se++)if(Me(V,J[se]))throw new Error('Cannot create alias "'+J[se]+'": a unit with that name already exists')}if(P&&typeof P=="string"&&!U)try{U=g.parse(P,{allowNoUnits:!0})}catch(C){throw C.message='Could not create unit "'+F+'" from "'+P+'": '+C.message,C}else P&&P.type==="Unit"&&(U=P.clone());J=J||[],q=q||0,Q&&Q.toUpperCase?Q=B[Q.toUpperCase()]||B.NONE:Q=B.NONE;var fe={};if(U){fe={name:F,value:U.value,dimensions:U.dimensions.slice(0),prefixes:Q,offset:q};var Ne=!1;for(var Qe in D)if(Me(D,Qe)){for(var fr=!0,nr=0;nr<G.length;nr++)if(Math.abs((fe.dimensions[nr]||0)-(D[Qe].dimensions[nr]||0))>1e-12){fr=!1;break}if(fr){Ne=!0,fe.base=D[Qe];break}}if(!Ne){L=L||F+"_STUFF";var Wr={dimensions:U.dimensions.slice(0)};Wr.key=L,D[L]=Wr,ie[L]={unit:fe,prefix:B.NONE[""]},fe.base=D[L]}}else{if(L=L||F+"_STUFF",G.indexOf(L)>=0)throw new Error('Cannot create new base unit "'+F+'": a base unit with that name already exists (and cannot be overridden)');G.push(L);for(var ge in D)Me(D,ge)&&(D[ge].dimensions[G.length-1]=0);for(var pe={dimensions:[]},ve=0;ve<G.length;ve++)pe.dimensions[ve]=0;pe.dimensions[G.length-1]=1,pe.key=L,D[L]=pe,fe={name:F,value:1,dimensions:D[L].dimensions.slice(0),prefixes:Q,offset:q,base:D[L]},ie[L]={unit:fe,prefix:B.NONE[""]}}g.UNITS[F]=fe;for(var Lr=0;Lr<J.length;Lr++){var Ot=J[Lr],Ze={};for(var Pt in fe)Me(fe,Pt)&&(Ze[Pt]=fe[Pt]);Ze.name=Ot,g.UNITS[Ot]=Ze}return delete I.cache,new g(null,F)},g.deleteUnit=function(F){delete g.UNITS[F]},g.PREFIXES=B,g.BASE_DIMENSIONS=G,g.BASE_UNITS=D,g.UNIT_SYSTEMS=re,g.UNITS=V,g},{isClass:!0}),pf="unit",lb=["typed","Unit"],mb=R(pf,lb,e=>{var{typed:n,Unit:a}=e;return n(pf,{Unit:function(r){return r.clone()},string:function(r){return a.isValuelessUnit(r)?new a(null,r):a.parse(r,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(r,i){return new a(r,i)},"Array | Matrix":function(r){return be(r,this)}})}),vf="sparse",pb=["typed","SparseMatrix"],vb=R(vf,pb,e=>{var{typed:n,SparseMatrix:a}=e;return n(vf,{"":function(){return new a([])},string:function(r){return new a([],r)},"Array | Matrix":function(r){return new a(r)},"Array | Matrix, string":function(r,i){return new a(r,i)}})}),hf="createUnit",hb=["typed","Unit"],db=R(hf,hb,e=>{var{typed:n,Unit:a}=e;return n(hf,{"Object, Object":function(r,i){return a.createUnit(r,i)},Object:function(r){return a.createUnit(r,{})},"string, Unit | string | Object, Object":function(r,i,l){var m={};return m[r]=i,a.createUnit(m,l)},"string, Unit | string | Object":function(r,i){var l={};return l[r]=i,a.createUnit(l,{})},string:function(r){var i={};return i[r]={},a.createUnit(i,{})}})}),df="acos",gb=["typed","config","Complex"],yb=R(df,gb,e=>{var{typed:n,config:a,Complex:t}=e;return n(df,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.acos(i):new t(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()},"Array | Matrix":function(i){return be(i,this)}})}),gf="acosh",xb=["typed","config","Complex"],bb=R(gf,xb,e=>{var{typed:n,config:a,Complex:t}=e;return n(gf,{number:function(i){return i>=1||a.predictable?Es(i):i<=-1?new t(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new t(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()},"Array | Matrix":function(i){return be(i,this)}})}),yf="acot",wb=["typed","BigNumber"],Nb=R(yf,wb,e=>{var{typed:n,BigNumber:a}=e;return n(yf,{number:Cs,Complex:function(r){return r.acot()},BigNumber:function(r){return new a(1).div(r).atan()},"Array | Matrix":function(r){return be(r,this)}})}),xf="acoth",Mb=["typed","config","Complex","BigNumber"],Ab=R(xf,Mb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(xf,{number:function(l){return l>=1||l<=-1||a.predictable?Os(l):new t(l,0).acoth()},Complex:function(l){return l.acoth()},BigNumber:function(l){return new r(1).div(l).atanh()},"Array | Matrix":function(l){return be(l,this)}})}),bf="acsc",Sb=["typed","config","Complex","BigNumber"],Eb=R(bf,Sb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(bf,{number:function(l){return l<=-1||l>=1||a.predictable?Ds(l):new t(l,0).acsc()},Complex:function(l){return l.acsc()},BigNumber:function(l){return new r(1).div(l).asin()},"Array | Matrix":function(l){return be(l,this)}})}),wf="acsch",Cb=["typed","BigNumber"],Ob=R(wf,Cb,e=>{var{typed:n,BigNumber:a}=e;return n(wf,{number:Ts,Complex:function(r){return r.acsch()},BigNumber:function(r){return new a(1).div(r).asinh()},"Array | Matrix":function(r){return be(r,this)}})}),Nf="asec",Db=["typed","config","Complex","BigNumber"],Tb=R(Nf,Db,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(Nf,{number:function(l){return l<=-1||l>=1||a.predictable?Bs(l):new t(l,0).asec()},Complex:function(l){return l.asec()},BigNumber:function(l){return new r(1).div(l).acos()},"Array | Matrix":function(l){return be(l,this)}})}),Mf="asech",Bb=["typed","config","Complex","BigNumber"],_b=R(Mf,Bb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(Mf,{number:function(l){if(l<=1&&l>=-1||a.predictable){var m=1/l;if(m>0||a.predictable)return _s(l);var f=Math.sqrt(m*m-1);return new t(Math.log(f-m),Math.PI)}return new t(l,0).asech()},Complex:function(l){return l.asech()},BigNumber:function(l){return new r(1).div(l).acosh()},"Array | Matrix":function(l){return be(l,this)}})}),Af="asin",$b=["typed","config","Complex"],Ib=R(Af,$b,e=>{var{typed:n,config:a,Complex:t}=e;return n(Af,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.asin(i):new t(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()},"Array | Matrix":function(i){return be(i,this)}})}),qb="asinh",Rb=["typed"],Fb=R(qb,Rb,e=>{var{typed:n}=e;return n("asinh",{number:$s,Complex:function(t){return t.asinh()},BigNumber:function(t){return t.asinh()},"Array | Matrix":function(t){return be(t,this)}})}),zb="atan",Pb=["typed"],Ub=R(zb,Pb,e=>{var{typed:n}=e;return n("atan",{number:function(t){return Math.atan(t)},Complex:function(t){return t.atan()},BigNumber:function(t){return t.atan()},"Array | Matrix":function(t){return be(t,this)}})}),Sf="atan2",Lb=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],kb=R(Sf,Lb,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=jr({typed:n,equalScalar:t}),m=Or({typed:n}),f=Ou({typed:n,equalScalar:t}),c=wr({typed:n,equalScalar:t}),s=yr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(Sf,{"number, number":Math.atan2,"BigNumber, BigNumber":function(v,h){return r.atan2(v,h)},"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return c(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return s(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return u(a(v),h,this,!1).valueOf()},"number | BigNumber, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})}),Ef="atanh",Hb=["typed","config","Complex"],Gb=R(Ef,Hb,e=>{var{typed:n,config:a,Complex:t}=e;return n(Ef,{number:function(i){return i<=1&&i>=-1||a.predictable?Is(i):new t(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()},"Array | Matrix":function(i){return be(i,this)}})}),Cf="cos",Vb=["typed"],Zb=R(Cf,Vb,e=>{var{typed:n}=e;return n(Cf,{number:Math.cos,Complex:function(t){return t.cos()},BigNumber:function(t){return t.cos()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Of="cosh",Xb=["typed"],Yb=R(Of,Xb,e=>{var{typed:n}=e;return n(Of,{number:rv,Complex:function(t){return t.cosh()},BigNumber:function(t){return t.cosh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Df="cot",Wb=["typed","BigNumber"],Jb=R(Df,Wb,e=>{var{typed:n,BigNumber:a}=e;return n(Df,{number:qs,Complex:function(r){return r.cot()},BigNumber:function(r){return new a(1).div(r.tan())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Tf="coth",Qb=["typed","BigNumber"],Kb=R(Tf,Qb,e=>{var{typed:n,BigNumber:a}=e;return n(Tf,{number:Rs,Complex:function(r){return r.coth()},BigNumber:function(r){return new a(1).div(r.tanh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Bf="csc",jb=["typed","BigNumber"],ew=R(Bf,jb,e=>{var{typed:n,BigNumber:a}=e;return n(Bf,{number:Fs,Complex:function(r){return r.csc()},BigNumber:function(r){return new a(1).div(r.sin())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),_f="csch",rw=["typed","BigNumber"],tw=R(_f,rw,e=>{var{typed:n,BigNumber:a}=e;return n(_f,{number:zs,Complex:function(r){return r.csch()},BigNumber:function(r){return new a(1).div(r.sinh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),$f="sec",nw=["typed","BigNumber"],aw=R($f,nw,e=>{var{typed:n,BigNumber:a}=e;return n($f,{number:Ps,Complex:function(r){return r.sec()},BigNumber:function(r){return new a(1).div(r.cos())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),If="sech",iw=["typed","BigNumber"],ow=R(If,iw,e=>{var{typed:n,BigNumber:a}=e;return n(If,{number:Us,Complex:function(r){return r.sech()},BigNumber:function(r){return new a(1).div(r.cosh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),qf="sin",sw=["typed"],uw=R(qf,sw,e=>{var{typed:n}=e;return n(qf,{number:Math.sin,Complex:function(t){return t.sin()},BigNumber:function(t){return t.sin()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Rf="sinh",cw=["typed"],fw=R(Rf,cw,e=>{var{typed:n}=e;return n(Rf,{number:Ls,Complex:function(t){return t.sinh()},BigNumber:function(t){return t.sinh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ff="tan",lw=["typed"],mw=R(Ff,lw,e=>{var{typed:n}=e;return n(Ff,{number:Math.tan,Complex:function(t){return t.tan()},BigNumber:function(t){return t.tan()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),pw="tanh",vw=["typed"],hw=R(pw,vw,e=>{var{typed:n}=e;return n("tanh",{number:nv,Complex:function(t){return t.tanh()},BigNumber:function(t){return t.tanh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),zf="setCartesian",dw=["typed","size","subset","compareNatural","Index","DenseMatrix"],gw=R(zf,dw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(zf,{"Array | Matrix, Array | Matrix":function(f,c){var s=[];if(t(a(f),new i(0))!==0&&t(a(c),new i(0))!==0){var o=Le(Array.isArray(f)?f:f.toArray()).sort(r),u=Le(Array.isArray(c)?c:c.toArray()).sort(r);s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)s.push([o[p],u[v]])}return Array.isArray(f)&&Array.isArray(c)?s:new l(s)}})}),Pf="setDifference",yw=["typed","size","subset","compareNatural","Index","DenseMatrix"],xw=R(Pf,yw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Pf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0)s=[];else{if(t(a(c),new i(0))===0)return Le(f.toArray());var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p,v=0;v<o.length;v++){p=!1;for(var h=0;h<u.length;h++)if(r(o[v].value,u[h].value)===0&&o[v].identifier===u[h].identifier){p=!0;break}p||s.push(o[v])}}return Array.isArray(f)&&Array.isArray(c)?ua(s):new l(ua(s))}})}),Uf="setDistinct",bw=["typed","size","subset","compareNatural","Index","DenseMatrix"],ww=R(Uf,bw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Uf,{"Array | Matrix":function(f){var c;if(t(a(f),new i(0))===0)c=[];else{var s=Le(Array.isArray(f)?f:f.toArray()).sort(r);c=[],c.push(s[0]);for(var o=1;o<s.length;o++)r(s[o],s[o-1])!==0&&c.push(s[o])}return Array.isArray(f)?c:new l(c)}})}),Lf="setIntersect",Nw=["typed","size","subset","compareNatural","Index","DenseMatrix"],Mw=R(Lf,Nw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Lf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0||t(a(c),new i(0))===0)s=[];else{var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)if(r(o[p].value,u[v].value)===0&&o[p].identifier===u[v].identifier){s.push(o[p]);break}}return Array.isArray(f)&&Array.isArray(c)?ua(s):new l(ua(s))}})}),kf="setIsSubset",Aw=["typed","size","subset","compareNatural","Index"],Sw=R(kf,Aw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(kf,{"Array | Matrix, Array | Matrix":function(m,f){if(t(a(m),new i(0))===0)return!0;if(t(a(f),new i(0))===0)return!1;for(var c=sn(Le(Array.isArray(m)?m:m.toArray()).sort(r)),s=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),o,u=0;u<c.length;u++){o=!1;for(var p=0;p<s.length;p++)if(r(c[u].value,s[p].value)===0&&c[u].identifier===s[p].identifier){o=!0;break}if(o===!1)return!1}return!0}})}),Hf="setMultiplicity",Ew=["typed","size","subset","compareNatural","Index"],Cw=R(Hf,Ew,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Hf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(m,f){if(t(a(f),new i(0))===0)return 0;for(var c=Le(Array.isArray(f)?f:f.toArray()),s=0,o=0;o<c.length;o++)r(c[o],m)===0&&s++;return s}})}),Gf="setPowerset",Ow=["typed","size","subset","compareNatural","Index"],Dw=R(Gf,Ow,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Gf,{"Array | Matrix":function(c){if(t(a(c),new i(0))===0)return[];for(var s=Le(Array.isArray(c)?c:c.toArray()).sort(r),o=[],u=0;u.toString(2).length<=s.length;)o.push(l(s,u.toString(2).split("").reverse())),u++;return m(o)}});function l(f,c){for(var s=[],o=0;o<c.length;o++)c[o]==="1"&&s.push(f[o]);return s}function m(f){for(var c=[],s=f.length-1;s>0;s--)for(var o=0;o<s;o++)f[o].length>f[o+1].length&&(c=f[o],f[o]=f[o+1],f[o+1]=c);return f}}),Vf="setSize",Tw=["typed","compareNatural"],Bw=R(Vf,Tw,e=>{var{typed:n,compareNatural:a}=e;return n(Vf,{"Array | Matrix":function(r){return Array.isArray(r)?Le(r).length:Le(r.toArray()).length},"Array | Matrix, boolean":function(r,i){if(i===!1||r.length===0)return Array.isArray(r)?Le(r).length:Le(r.toArray()).length;for(var l=Le(Array.isArray(r)?r:r.toArray()).sort(a),m=1,f=1;f<l.length;f++)a(l[f],l[f-1])!==0&&m++;return m}})}),Zf="setSymDifference",_w=["typed","size","concat","subset","setDifference","Index"],$w=R(Zf,_w,e=>{var{typed:n,size:a,concat:t,subset:r,setDifference:i,Index:l}=e;return n(Zf,{"Array | Matrix, Array | Matrix":function(f,c){if(r(a(f),new l(0))===0)return Le(c);if(r(a(c),new l(0))===0)return Le(f);var s=Le(f),o=Le(c);return t(i(s,o),i(o,s))}})}),Xf="setUnion",Iw=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],qw=R(Xf,Iw,e=>{var{typed:n,size:a,concat:t,subset:r,setIntersect:i,setSymDifference:l,Index:m}=e;return n(Xf,{"Array | Matrix, Array | Matrix":function(c,s){if(r(a(c),new m(0))===0)return Le(s);if(r(a(s),new m(0))===0)return Le(c);var o=Le(c),u=Le(s);return t(l(o,u),i(o,u))}})}),Yf="add",Rw=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],Fw=R(Yf,Rw,e=>{var{typed:n,matrix:a,addScalar:t,equalScalar:r,DenseMatrix:i,SparseMatrix:l}=e,m=qt({typed:n}),f=Mi({typed:n,equalScalar:r}),c=Vt({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(Yf,ja({"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,t)},"DenseMatrix, SparseMatrix":function(p,v){return m(p,v,t,!1)},"SparseMatrix, DenseMatrix":function(p,v){return m(v,p,t,!0)},"SparseMatrix, SparseMatrix":function(p,v){return f(p,v,t)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"DenseMatrix, any":function(p,v){return o(p,v,t,!1)},"SparseMatrix, any":function(p,v){return c(p,v,t,!1)},"any, DenseMatrix":function(p,v){return o(v,p,t,!0)},"any, SparseMatrix":function(p,v){return c(v,p,t,!0)},"Array, any":function(p,v){return o(a(p),v,t,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,t,!0).valueOf()},"any, any":t,"any, any, ...any":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}},t.signatures))}),Wf="hypot",zw=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],Pw=R(Wf,zw,e=>{var{typed:n,abs:a,addScalar:t,divideScalar:r,multiplyScalar:i,sqrt:l,smaller:m,isPositive:f}=e;return n(Wf,{"... number | BigNumber":c,Array:function(o){return this.apply(this,Le(o))},Matrix:function(o){return this.apply(this,Le(o.toArray()))}});function c(s){for(var o=0,u=0,p=0;p<s.length;p++){var v=a(s[p]);m(u,v)?(o=i(o,i(r(u,v),r(u,v))),o=t(o,1),u=v):o=t(o,f(v)?i(r(v,u),r(v,u)):v)}return i(u,l(o))}}),Jf="norm",Uw=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Lw=R(Jf,Uw,e=>{var{typed:n,abs:a,add:t,pow:r,conj:i,sqrt:l,multiply:m,equalScalar:f,larger:c,smaller:s,matrix:o,ctranspose:u,eigs:p}=e;return n(Jf,{number:Math.abs,Complex:function(S){return S.abs()},BigNumber:function(S){return S.abs()},boolean:function(S){return Math.abs(S)},Array:function(S){return d(o(S),2)},Matrix:function(S){return d(S,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(S){return this(S)},"Array, number | BigNumber | string":function(S,O){return d(o(S),O)},"Matrix, number | BigNumber | string":function(S,O){return d(S,O)}});function v(A){var S=0;return A.forEach(function(O){var M=a(O);c(M,S)&&(S=M)},!0),S}function h(A){var S;return A.forEach(function(O){var M=a(O);(!S||s(M,S))&&(S=M)},!0),S||0}function b(A,S){if(S===Number.POSITIVE_INFINITY||S==="inf")return v(A);if(S===Number.NEGATIVE_INFINITY||S==="-inf")return h(A);if(S==="fro")return d(A,2);if(typeof S=="number"&&!isNaN(S)){if(!f(S,0)){var O=0;return A.forEach(function(M){O=t(r(a(M),S),O)},!0),r(O,1/S)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function w(A){var S=0;return A.forEach(function(O,M){S=t(S,m(O,i(O)))}),a(l(S))}function N(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[1],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function g(A){var S=A.size();if(S[0]!==S[1])throw new RangeError("Invalid matrix dimensions");var O=u(A),M=m(O,A),_=p(M).values.toArray(),E=_[_.length-1];return a(l(E))}function y(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[0],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function x(A,S){if(S===1)return N(A);if(S===Number.POSITIVE_INFINITY||S==="inf")return y(A);if(S==="fro")return w(A);if(S===2)return g(A);throw new Error("Unsupported parameter value "+S)}function d(A,S){var O=A.size();if(O.length===1)return b(A,S);if(O.length===2){if(O[0]&&O[1])return x(A,S);throw new RangeError("Invalid matrix dimensions")}}}),Qf="dot",kw=["typed","addScalar","multiplyScalar","conj","size"],Hw=R(Qf,kw,e=>{var{typed:n,addScalar:a,multiplyScalar:t,conj:r,size:i}=e;return n(Qf,{"Array | DenseMatrix, Array | DenseMatrix":m,"SparseMatrix, SparseMatrix":f});function l(s,o){var u=c(s),p=c(o),v,h;if(u.length===1)v=u[0];else if(u.length===2&&u[1]===1)v=u[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+u.join(", ")+")");if(p.length===1)h=p[0];else if(p.length===2&&p[1]===1)h=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(v!==h)throw new RangeError("Vectors must have equal length ("+v+" != "+h+")");if(v===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return v}function m(s,o){var u=l(s,o),p=Oe(s)?s._data:s,v=Oe(s)?s._datatype:void 0,h=Oe(o)?o._data:o,b=Oe(o)?o._datatype:void 0,w=c(s).length===2,N=c(o).length===2,g=a,y=t;if(v&&b&&v===b&&typeof v=="string"){var x=v;g=n.find(a,[x,x]),y=n.find(t,[x,x])}if(!w&&!N){for(var d=y(r(p[0]),h[0]),A=1;A<u;A++)d=g(d,y(r(p[A]),h[A]));return d}if(!w&&N){for(var S=y(r(p[0]),h[0][0]),O=1;O<u;O++)S=g(S,y(r(p[O]),h[O][0]));return S}if(w&&!N){for(var M=y(r(p[0][0]),h[0]),_=1;_<u;_++)M=g(M,y(r(p[_][0]),h[_]));return M}if(w&&N){for(var E=y(r(p[0][0]),h[0][0]),$=1;$<u;$++)E=g(E,y(r(p[$][0]),h[$][0]));return E}}function f(s,o){l(s,o);for(var u=s._index,p=s._values,v=o._index,h=o._values,b=0,w=a,N=t,g=0,y=0;g<u.length&&y<v.length;){var x=u[g],d=v[y];if(x<d){g++;continue}if(x>d){y++;continue}x===d&&(b=w(b,N(p[g],h[y])),g++,y++)}return b}function c(s){return Oe(s)?s.size():i(s)}}),Gw="trace",Vw=["typed","matrix","add"],Zw=R(Gw,Vw,e=>{var{typed:n,matrix:a,add:t}=e;return n("trace",{Array:function(m){return r(a(m))},SparseMatrix:i,DenseMatrix:r,any:Ce});function r(l){var m=l._size,f=l._data;switch(m.length){case 1:if(m[0]===1)return Ce(f[0]);throw new RangeError("Matrix must be square (size: "+Re(m)+")");case 2:{var c=m[0],s=m[1];if(c===s){for(var o=0,u=0;u<c;u++)o=t(o,f[u][u]);return o}else throw new RangeError("Matrix must be square (size: "+Re(m)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(m)+")")}}function i(l){var m=l._values,f=l._index,c=l._ptr,s=l._size,o=s[0],u=s[1];if(o===u){var p=0;if(m.length>0)for(var v=0;v<u;v++)for(var h=c[v],b=c[v+1],w=h;w<b;w++){var N=f[w];if(N===v){p=t(p,m[w]);break}if(N>v)break}return p}throw new RangeError("Matrix must be square (size: "+Re(s)+")")}}),Kf="index",Xw=["typed","Index"],Yw=R(Kf,Xw,e=>{var{typed:n,Index:a}=e;return n(Kf,{"...number | string | BigNumber | Range | Array | Matrix":function(r){var i=r.map(function(m){return Ie(m)?m.toNumber():Array.isArray(m)||Oe(m)?m.map(function(f){return Ie(f)?f.toNumber():f}):m}),l=new a;return a.apply(l,i),l}})}),jf=new Set(["end"]),Ww="Node",Jw=["mathWithTransform"],Qw=R(Ww,Jw,e=>{var{mathWithTransform:n}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator")}a.prototype.evaluate=function(r){return this.compile().evaluate(r)},a.prototype.type="Node",a.prototype.isNode=!0,a.prototype.comment="",a.prototype.compile=function(){var r=this._compile(n,{}),i={},l=null;function m(f){var c=si(f);return t(c),r(c,i,l)}return{evaluate:m}},a.prototype._compile=function(r,i){throw new Error("Method _compile should be implemented by type "+this.type)},a.prototype.forEach=function(r){throw new Error("Cannot run forEach on a Node interface")},a.prototype.map=function(r){throw new Error("Cannot run map on a Node interface")},a.prototype._ifNode=function(r){if(!Ve(r))throw new TypeError("Callback function must return a Node");return r},a.prototype.traverse=function(r){r(this,null,null);function i(l,m){l.forEach(function(f,c,s){m(f,c,s),i(f,m)})}i(this,r)},a.prototype.transform=function(r){function i(l,m,f){var c=r(l,m,f);return c!==l?c:l.map(i)}return i(this,null,null)},a.prototype.filter=function(r){var i=[];return this.traverse(function(l,m,f){r(l,m,f)&&i.push(l)}),i},a.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},a.prototype.cloneDeep=function(){return this.map(function(r){return r.cloneDeep()})},a.prototype.equals=function(r){return r?Tn(this,r):!1},a.prototype.toString=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toString(r)},a.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},a.prototype.toHTML=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this.toHTML(r)},a.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},a.prototype.toTex=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toTex(r)},a.prototype._toTex=function(r){throw new Error("_toTex not implemented for "+this.type)},a.prototype._getCustomString=function(r){if(r&&typeof r=="object")switch(typeof r.handler){case"object":case"undefined":return;case"function":return r.handler(this,r);default:throw new TypeError("Object or function expected as callback")}},a.prototype.getIdentifier=function(){return this.type},a.prototype.getContent=function(){return this};function t(r){for(var i of[...jf])if(r.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}return a},{isClass:!0,isNode:!0});function Tr(e){return e&&e.isIndexError?new Jr(e.index+1,e.min+1,e.max!==void 0?e.max+1:void 0):e}function el(e){var{subset:n}=e;return function(t,r){try{if(Array.isArray(t))return n(t,r);if(t&&typeof t.subset=="function")return t.subset(r);if(typeof t=="string")return n(t,r);if(typeof t=="object"){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Gr(t,r.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Tr(i)}}}var Kw="AccessorNode",jw=["subset","Node"],eN=R(Kw,jw,e=>{var{subset:n,Node:a}=e,t=el({subset:n});function r(l,m){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(l))throw new TypeError('Node expected for parameter "object"');if(!tn(m))throw new TypeError('IndexNode expected for parameter "index"');this.object=l||null,this.index=m,Object.defineProperty(this,"name",{get:(function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}r.prototype=new a,r.prototype.type="AccessorNode",r.prototype.isAccessorNode=!0,r.prototype._compile=function(l,m){var f=this.object._compile(l,m),c=this.index._compile(l,m);if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(u,p,v){return Gr(f(u,p,v),s)}}else return function(u,p,v){var h=f(u,p,v),b=c(u,p,h);return t(h,b)}},r.prototype.forEach=function(l){l(this.object,"object",this),l(this.index,"index",this)},r.prototype.map=function(l){return new r(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)))},r.prototype.clone=function(){return new r(this.object,this.index)},r.prototype._toString=function(l){var m=this.object.toString(l);return i(this.object)&&(m="("+m+")"),m+this.index.toString(l)},r.prototype.toHTML=function(l){var m=this.object.toHTML(l);return i(this.object)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+this.index.toHTML(l)},r.prototype._toTex=function(l){var m=this.object.toTex(l);return i(this.object)&&(m="\\left(' + object + '\\right)"),m+this.index.toTex(l)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(l){return new r(l.object,l.index)};function i(l){return!(Lt(l)||kr(l)||Ye(l)||kt(l)||ea(l)||Dn(l)||xr(l))}return r},{isClass:!0,isNode:!0}),rN="ArrayNode",tN=["Node"],nN=R(rN,tN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=t||[],!Array.isArray(this.items)||!this.items.every(Ve))throw new TypeError("Array containing Nodes expected")}return a.prototype=new n,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(t,r){var i=dt(this.items,function(f){return f._compile(t,r)}),l=t.config.matrix!=="Array";if(l){var m=t.matrix;return function(c,s,o){return m(dt(i,function(u){return u(c,s,o)}))}}else return function(c,s,o){return dt(i,function(u){return u(c,s,o)})}},a.prototype.forEach=function(t){for(var r=0;r<this.items.length;r++){var i=this.items[r];t(i,"items["+r+"]",this)}},a.prototype.map=function(t){for(var r=[],i=0;i<this.items.length;i++)r[i]=this._ifNode(t(this.items[i],"items["+i+"]",this));return new a(r)},a.prototype.clone=function(){return new a(this.items.slice(0))},a.prototype._toString=function(t){var r=this.items.map(function(i){return i.toString(t)});return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"ArrayNode",items:this.items}},a.fromJSON=function(t){return new a(t.items)},a.prototype.toHTML=function(t){var r=this.items.map(function(i){return i.toHTML(t)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},a.prototype._toTex=function(t){function r(i,l){var m=i.some(kr)&&!i.every(kr),f=l||m,c=f?"&":"\\\\",s=i.map(function(o){return o.items?r(o.items,!l):o.toTex(t)}).join(c);return m||!f||f&&!l?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}return r(this.items,!1)},a},{isClass:!0,isNode:!0});function aN(e){var{subset:n,matrix:a}=e;return function(r,i,l){try{if(Array.isArray(r))return a(r).subset(i,l).valueOf();if(r&&typeof r.subset=="function")return r.subset(i,l);if(typeof r=="string")return n(r,i,l);if(typeof r=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return un(r,i.getObjectProperty(),l),r}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(m){throw Tr(m)}}}var ct=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Je(e,n){var a=e;n!=="keep"&&(a=e.getContent());for(var t=a.getIdentifier(),r=0;r<ct.length;r++)if(t in ct[r])return r;return null}function Pn(e,n){var a=e;n!=="keep"&&(a=e.getContent());var t=a.getIdentifier(),r=Je(a,n);if(r===null)return null;var i=ct[r][t];if(Me(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+t+"' has the invalid associativity '"+i.associativity+"'.")}return null}function Bi(e,n,a){var t=a!=="keep"?e.getContent():e,r=a!=="keep"?e.getContent():n,i=t.getIdentifier(),l=r.getIdentifier(),m=Je(t,a);if(m===null)return null;var f=ct[m][i];if(Me(f,"associativeWith")&&f.associativeWith instanceof Array){for(var c=0;c<f.associativeWith.length;c++)if(f.associativeWith[c]===l)return!0;return!1}return null}var iN="AssignmentNode",oN=["subset","?matrix","Node"],sN=R(iN,oN,e=>{var{subset:n,matrix:a,Node:t}=e,r=el({subset:n}),i=aN({subset:n,matrix:a});function l(f,c,s){if(!(this instanceof l))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=f,this.index=s?c:null,this.value=s||c,!xr(f)&&!Lt(f))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(xr(f)&&f.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!tn(this.index))throw new TypeError('IndexNode expected as "index"');if(!Ve(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:(function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}l.prototype=new t,l.prototype.type="AssignmentNode",l.prototype.isAssignmentNode=!0,l.prototype._compile=function(f,c){var s=this.object._compile(f,c),o=this.index?this.index._compile(f,c):null,u=this.value._compile(f,c),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(g,y,x){var d=s(g,y,x),A=u(g,y,x);return un(d,v,A),A}}else{if(xr(this.object))return function(g,y,x){var d=s(g,y,x),A=u(g,y,x),S=o(g,y,d);return g.set(p,i(d,S,A)),A};var h=this.object.object._compile(f,c);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(g,y,x){var d=h(g,y,x),A=Gr(d,b),S=o(g,y,A),O=u(g,y,x);return un(d,b,i(A,S,O)),O}}else{var w=this.object.index._compile(f,c);return function(g,y,x){var d=h(g,y,x),A=w(g,y,d),S=r(d,A),O=o(g,y,S),M=u(g,y,x);return i(d,A,i(S,O,M)),M}}}else{if(!xr(this.object))throw new TypeError("SymbolNode expected as object");return function(g,y,x){var d=u(g,y,x);return g.set(p,d),d}}},l.prototype.forEach=function(f){f(this.object,"object",this),this.index&&f(this.index,"index",this),f(this.value,"value",this)},l.prototype.map=function(f){var c=this._ifNode(f(this.object,"object",this)),s=this.index?this._ifNode(f(this.index,"index",this)):null,o=this._ifNode(f(this.value,"value",this));return new l(c,s,o)},l.prototype.clone=function(){return new l(this.object,this.index,this.value)};function m(f,c){c||(c="keep");var s=Je(f,c),o=Je(f.value,c);return c==="all"||o!==null&&o<=s}return l.prototype._toString=function(f){var c=this.object.toString(f),s=this.index?this.index.toString(f):"",o=this.value.toString(f);return m(this,f&&f.parenthesis)&&(o="("+o+")"),c+s+" = "+o},l.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},l.fromJSON=function(f){return new l(f.object,f.index,f.value)},l.prototype.toHTML=function(f){var c=this.object.toHTML(f),s=this.index?this.index.toHTML(f):"",o=this.value.toHTML(f);return m(this,f&&f.parenthesis)&&(o='<span class="math-paranthesis math-round-parenthesis">(</span>'+o+'<span class="math-paranthesis math-round-parenthesis">)</span>'),c+s+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+o},l.prototype._toTex=function(f){var c=this.object.toTex(f),s=this.index?this.index.toTex(f):"",o=this.value.toTex(f);return m(this,f&&f.parenthesis)&&(o="\\left(".concat(o,"\\right)")),c+s+":="+o},l},{isClass:!0,isNode:!0}),uN="BlockNode",cN=["ResultSet","Node"],fN=R(uN,cN,e=>{var{ResultSet:n,Node:a}=e;function t(r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(r))throw new Error("Array expected");this.blocks=r.map(function(i){var l=i&&i.node,m=i&&i.visible!==void 0?i.visible:!0;if(!Ve(l))throw new TypeError('Property "node" must be a Node');if(typeof m!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:l,visible:m}})}return t.prototype=new a,t.prototype.type="BlockNode",t.prototype.isBlockNode=!0,t.prototype._compile=function(r,i){var l=dt(this.blocks,function(m){return{evaluate:m.node._compile(r,i),visible:m.visible}});return function(f,c,s){var o=[];return oa(l,function(p){var v=p.evaluate(f,c,s);p.visible&&o.push(v)}),new n(o)}},t.prototype.forEach=function(r){for(var i=0;i<this.blocks.length;i++)r(this.blocks[i].node,"blocks["+i+"].node",this)},t.prototype.map=function(r){for(var i=[],l=0;l<this.blocks.length;l++){var m=this.blocks[l],f=this._ifNode(r(m.node,"blocks["+l+"].node",this));i[l]={node:f,visible:m.visible}}return new t(i)},t.prototype.clone=function(){var r=this.blocks.map(function(i){return{node:i.node,visible:i.visible}});return new t(r)},t.prototype._toString=function(r){return this.blocks.map(function(i){return i.node.toString(r)+(i.visible?"":";")}).join(`
28
+ (`+Re(S,h)+", "+Re(y,h)+") ==> "+(this._values?Re(this._values[A],h):"X")}return g},r.prototype.toString=function(){return Re(this.toArray())},r.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(h){if(h){if(_e(h)&&(h=h.toNumber()),!Be(h)||!Ae(h))throw new TypeError("The parameter k must be an integer number")}else h=0;var b=h>0?h:0,w=h<0?-h:0,N=this._size[0],g=this._size[1],y=Math.min(N-w,g-b),x=[],d=[],A=[];A[0]=0;for(var S=b;S<g&&x.length<y;S++)for(var O=this._ptr[S],M=this._ptr[S+1],_=O;_<M;_++){var E=this._index[_];if(E===S-b+w){x.push(this._values[_]),d[x.length-1]=E-w;break}}return A.push(x.length),new r({values:x,index:d,ptr:A,size:[y,1]})},r.fromJSON=function(h){return new r(h)},r.diagonal=function(h,b,w,N,g){if(!Xe(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(D){if(_e(D)&&(D=D.toNumber()),!Be(D)||!Ae(D)||D<1)throw new Error("Size values must be positive integers");return D}),w){if(_e(w)&&(w=w.toNumber()),!Be(w)||!Ae(w))throw new TypeError("The parameter k must be an integer number")}else w=0;var y=a,x=0;_r(g)&&(y=n.find(a,[g,g])||a,x=n.convert(0,g));var d=w>0?w:0,A=w<0?-w:0,S=h[0],O=h[1],M=Math.min(S-A,O-d),_;if(Xe(b)){if(b.length!==M)throw new Error("Invalid value array length");_=function(H){return b[H]}}else if(Oe(b)){var E=b.size();if(E.length!==1||E[0]!==M)throw new Error("Invalid matrix length");_=function(H){return b.get([H])}}else _=function(){return b};for(var $=[],z=[],I=[],T=0;T<O;T++){I.push($.length);var B=T-d;if(B>=0&&B<M){var G=_(B);y(G,x)||(z.push(B+A),$.push(G))}}return I.push($.length),new r({values:$,index:z,ptr:I,size:[S,O]})},r.prototype.swapRows=function(h,b){if(!Be(h)||!Ae(h)||!Be(b)||!Ae(b))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(h,this._size[0]),We(b,this._size[0]),r._swapRows(h,b,this._size[1],this._values,this._index,this._ptr),this},r._forEachRow=function(h,b,w,N,g){for(var y=N[h],x=N[h+1],d=y;d<x;d++)g(w[d],b[d])},r._swapRows=function(h,b,w,N,g,y){for(var x=0;x<w;x++){var d=y[x],A=y[x+1],S=c(h,d,A,g),O=c(b,d,A,g);if(S<A&&O<A&&g[S]===h&&g[O]===b){if(N){var M=N[S];N[S]=N[O],N[O]=M}continue}if(S<A&&g[S]===h&&(O>=A||g[O]!==b)){var _=N?N[S]:void 0;g.splice(O,0,b),N&&N.splice(O,0,_),g.splice(O<=S?S+1:S,1),N&&N.splice(O<=S?S+1:S,1);continue}if(O<A&&g[O]===b&&(S>=A||g[S]!==h)){var E=N?N[O]:void 0;g.splice(S,0,h),N&&N.splice(S,0,E),g.splice(S<=O?O+1:O,1),N&&N.splice(S<=O?O+1:O,1)}}},r},{isClass:!0}),Nd="number",Md=["typed"];function Ad(e){var n=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(n){var a={"0b":2,"0o":8,"0x":16}[n[1]],t=n[2],r=n[3];return{input:e,radix:a,integerPart:t,fractionalPart:r}}else return null}function Sd(e){for(var n=parseInt(e.integerPart,e.radix),a=0,t=0;t<e.fractionalPart.length;t++){var r=parseInt(e.fractionalPart[t],e.radix);a+=r/Math.pow(e.radix,t+1)}var i=n+a;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is no valid number');return i}var Ed=R(Nd,Md,e=>{var{typed:n}=e,a=n("number",{"":function(){return 0},number:function(r){return r},string:function(r){if(r==="NaN")return NaN;var i=Ad(r);if(i)return Sd(i);var l=0,m=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);m&&(l=Number(m[2]),r=m[1]);var f=Number(r);if(isNaN(f))throw new SyntaxError('String "'+r+'" is no valid number');if(m){if(f>en(2,l)-1)throw new SyntaxError('String "'.concat(r,'" is out of range'));f>=en(2,l-1)&&(f=f-en(2,l))}return f},BigNumber:function(r){return r.toNumber()},Fraction:function(r){return r.valueOf()},Unit:function(r){throw new Error("Second argument with valueless unit expected")},null:function(r){return 0},"Unit, string | Unit":function(r,i){return r.toNumber(i)},"Array | Matrix":function(r){return be(r,this)}});return a.fromJSON=function(t){return parseFloat(t.value)},a}),Ks="string",Cd=["typed"],Od=R(Ks,Cd,e=>{var{typed:n}=e;return n(Ks,{"":function(){return""},number:Ht,null:function(t){return"null"},boolean:function(t){return t+""},string:function(t){return t},"Array | Matrix":function(t){return be(t,this)},any:function(t){return String(t)}})}),js="boolean",Dd=["typed"],Td=R(js,Dd,e=>{var{typed:n}=e;return n(js,{"":function(){return!1},boolean:function(t){return t},number:function(t){return!!t},null:function(t){return!1},BigNumber:function(t){return!t.isZero()},string:function(t){var r=t.toLowerCase();if(r==="true")return!0;if(r==="false")return!1;var i=Number(t);if(t!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+t+'" to a boolean')},"Array | Matrix":function(t){return be(t,this)}})}),Bd="bignumber",_d=["typed","BigNumber"],$d=R(Bd,_d,e=>{var{typed:n,BigNumber:a}=e;return n("bignumber",{"":function(){return new a(0)},number:function(r){return new a(r+"")},string:function(r){var i=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var l=i[2],m=a(i[1]),f=new a(2).pow(Number(l));if(m.gt(f.sub(1)))throw new SyntaxError('String "'.concat(r,'" is out of range'));var c=new a(2).pow(Number(l)-1);return m.gte(c)?m.sub(f):m}return new a(r)},BigNumber:function(r){return r},Fraction:function(r){return new a(r.n).div(r.d).times(r.s)},null:function(r){return new a(0)},"Array | Matrix":function(r){return be(r,this)}})}),Id="complex",qd=["typed","Complex"],Rd=R(Id,qd,e=>{var{typed:n,Complex:a}=e;return n("complex",{"":function(){return a.ZERO},number:function(r){return new a(r,0)},"number, number":function(r,i){return new a(r,i)},"BigNumber, BigNumber":function(r,i){return new a(r.toNumber(),i.toNumber())},Fraction:function(r){return new a(r.valueOf(),0)},Complex:function(r){return r.clone()},string:function(r){return a(r)},null:function(r){return a(0)},Object:function(r){if("re"in r&&"im"in r)return new a(r.re,r.im);if("r"in r&&"phi"in r||"abs"in r&&"arg"in r)return new a(r);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(r){return be(r,this)}})}),Fd="fraction",zd=["typed","Fraction"],Pd=R(Fd,zd,e=>{var{typed:n,Fraction:a}=e;return n("fraction",{number:function(r){if(!isFinite(r)||isNaN(r))throw new Error(r+" cannot be represented as a fraction");return new a(r)},string:function(r){return new a(r)},"number, number":function(r,i){return new a(r,i)},null:function(r){return new a(0)},BigNumber:function(r){return new a(r.toString())},Fraction:function(r){return r},Object:function(r){return new a(r)},"Array | Matrix":function(r){return be(r,this)}})}),eu="matrix",Ud=["typed","Matrix","DenseMatrix","SparseMatrix"],Ld=R(eu,Ud,e=>{var{typed:n,Matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(eu,{"":function(){return i([])},string:function(m){return i([],m)},"string, string":function(m,f){return i([],m,f)},Array:function(m){return i(m)},Matrix:function(m){return i(m,m.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(l,m,f){if(m==="dense"||m==="default"||m===void 0)return new t(l,f);if(m==="sparse")return new r(l,f);throw new TypeError("Unknown matrix type "+JSON.stringify(m)+".")}}),ru="matrixFromFunction",kd=["typed","matrix","isZero"],Hd=R(ru,kd,e=>{var{typed:n,matrix:a,isZero:t}=e;return n(ru,{"Array | Matrix, function, string, string":function(l,m,f,c){return r(l,m,f,c)},"Array | Matrix, function, string":function(l,m,f){return r(l,m,f)},"Matrix, function":function(l,m){return r(l,m,"dense")},"Array, function":function(l,m){return r(l,m,"dense").toArray()},"Array | Matrix, string, function":function(l,m,f){return r(l,f,m)},"Array | Matrix, string, string, function":function(l,m,f,c){return r(l,c,m,f)}});function r(i,l,m,f){var c;return f!==void 0?c=a(m,f):c=a(m),c.resize(i),c.forEach(function(s,o){var u=l(o);t(u)||c.set(o,u)}),c}}),tu="matrixFromRows",Gd=["typed","matrix","flatten","size"],Vd=R(tu,Gd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(tu,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var f=l(m[0]),c=[];for(var s of m){var o=l(s);if(o!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(o|0));c.push(t(s))}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),nu="matrixFromColumns",Zd=["typed","matrix","flatten","size"],Xd=R(nu,Zd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(nu,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var f=l(m[0]),c=[],s=0;s<f;s++)c[s]=[];for(var o of m){var u=l(o);if(u!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(u|0));for(var p=t(o),v=0;v<f;v++)c[v].push(p[v])}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),au="splitUnit",Yd=["typed"],Wd=R(au,Yd,e=>{var{typed:n}=e;return n(au,{"Unit, Array":function(t,r){return t.splitUnit(r)}})}),iu="unaryMinus",Jd=["typed"],Qd=R(iu,Jd,e=>{var{typed:n}=e;return n(iu,{number:Wo,Complex:function(t){return t.neg()},BigNumber:function(t){return t.neg()},Fraction:function(t){return t.neg()},Unit:function(t){var r=t.clone();return r.value=this(t.value),r},"Array | Matrix":function(t){return be(t,this)}})}),ou="unaryPlus",Kd=["typed","config","BigNumber"],jd=R(ou,Kd,e=>{var{typed:n,config:a,BigNumber:t}=e;return n(ou,{number:Jo,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":function(i){return be(i,this)},"boolean | string":function(i){return a.number==="BigNumber"?new t(+i):+i}})}),su="abs",eg=["typed"],rg=R(su,eg,e=>{var{typed:n}=e;return n(su,{number:Zo,Complex:function(t){return t.abs()},BigNumber:function(t){return t.abs()},Fraction:function(t){return t.abs()},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.abs()}})}),uu="apply",tg=["typed","isInteger"],cu=R(uu,tg,e=>{var{typed:n,isInteger:a}=e;return n(uu,{"Array | Matrix, number | BigNumber, function":function(r,i,l){if(!a(i))throw new TypeError("Integer number expected for dimension");var m=Array.isArray(r)?Pe(r):r.size();if(i<0||i>=m.length)throw new Kr(i,m.length);return Oe(r)?r.create(Aa(r.valueOf(),i,l)):Aa(r,i,l)}})});function Aa(e,n,a){var t,r,i;if(n<=0)if(Array.isArray(e[0])){for(i=ng(e),r=[],t=0;t<i.length;t++)r[t]=Aa(i[t],n-1,a);return r}else return a(e);else{for(r=[],t=0;t<e.length;t++)r[t]=Aa(e[t],n-1,a);return r}}function ng(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}var fu="addScalar",ag=["typed"],ig=R(fu,ag,e=>{var{typed:n}=e;return n(fu,{"number, number":Xo,"Complex, Complex":function(t,r){return t.add(r)},"BigNumber, BigNumber":function(t,r){return t.plus(r)},"Fraction, Fraction":function(t,r){return t.add(r)},"Unit, Unit":function(t,r){if(t.value===null||t.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(r.value===null||r.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!t.equalBase(r))throw new Error("Units do not match");var i=t.clone();return i.value=this(i.value,r.value),i.fixPrefix=!1,i}})}),lu="cbrt",og=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],sg=R(lu,og,e=>{var{config:n,typed:a,isNegative:t,unaryMinus:r,matrix:i,Complex:l,BigNumber:m,Fraction:f}=e;return a(lu,{number:$n,Complex:c,"Complex, boolean":c,BigNumber:function(u){return u.cbrt()},Unit:s,"Array | Matrix":function(u){return be(u,this)}});function c(o,u){var p=o.arg()/3,v=o.abs(),h=new l($n(v),0).mul(new l(0,p).exp());if(u){var b=[h,new l($n(v),0).mul(new l(0,p+Math.PI*2/3).exp()),new l($n(v),0).mul(new l(0,p-Math.PI*2/3).exp())];return n.matrix==="Array"?b:i(b)}else return h}function s(o){if(o.value&&Or(o.value)){var u=o.clone();return u.value=1,u=u.pow(1/3),u.value=c(o.value),u}else{var p=t(o.value);p&&(o.value=r(o.value));var v;_e(o.value)?v=new m(1).div(3):yr(o.value)?v=new f(1,3):v=1/3;var h=o.pow(v);return p&&(h.value=r(h.value)),h}}}),ug="algorithm11",cg=["typed","equalScalar"],wr=R(ug,cg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=a,w=0,N=l;typeof u=="string"&&(h=u,b=n.find(a,[h,h]),w=n.convert(0,h),i=n.convert(i,h),N=n.find(l,[h,h]));for(var g=[],y=[],x=[],d=0;d<v;d++){x[d]=y.length;for(var A=s[d],S=s[d+1],O=A;O<S;O++){var M=c[O],_=m?N(i,f[O]):N(f[O],i);b(_,w)||(y.push(M),g.push(_))}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),fg="algorithm12",lg=["typed","DenseMatrix"],gr=R(fg,lg,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=m?b(i,0):b(0,i)}return new a({data:w,size:[p,v],datatype:h})}}),mg="algorithm14",pg=["typed"],Ge=R(mg,pg,e=>{var{typed:n}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o,u=l;typeof s=="string"&&(o=s,i=n.convert(i,o),u=n.find(l,[o,o]));var p=c.length>0?a(u,0,c,c[0],f,i,m):[];return r.createDenseMatrix({data:p,size:Ce(c),datatype:o})};function a(t,r,i,l,m,f,c){var s=[];if(r===i.length-1)for(var o=0;o<l;o++)s[o]=c?t(f,m[o]):t(m[o],f);else for(var u=0;u<l;u++)s[u]=a(t,r+1,i,i[r+1],m[u],f,c);return s}}),xi="ceil",vg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],hg=R(xi,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(xi,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.ceil(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.ceil(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),dg=R(xi,vg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=gr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=hg({typed:n,config:a,round:t});return n("ceil",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.ceil()},"Complex, number":function(p,v){return p.ceil(v)},"Complex, BigNumber":function(p,v){return p.ceil(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.ceil()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_CEIL)},Fraction:function(p){return p.ceil()},"Fraction, number":function(p,v){return p.ceil(v)},"Fraction, BigNumber":function(p,v){return p.ceil(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),mu="cube",gg=["typed"],yg=R(mu,gg,e=>{var{typed:n}=e;return n(mu,{number:Qo,Complex:function(t){return t.mul(t).mul(t)},BigNumber:function(t){return t.times(t).times(t)},Fraction:function(t){return t.pow(3)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(3)}})}),pu="exp",xg=["typed"],bg=R(pu,xg,e=>{var{typed:n}=e;return n(pu,{number:Ko,Complex:function(t){return t.exp()},BigNumber:function(t){return t.exp()},"Array | Matrix":function(t){return be(t,this)}})}),vu="expm1",wg=["typed","Complex"],Ng=R(vu,wg,e=>{var{typed:n,Complex:a}=e;return n(vu,{number:jo,Complex:function(r){var i=Math.exp(r.re);return new a(i*Math.cos(r.im)-1,i*Math.sin(r.im))},BigNumber:function(r){return r.exp().minus(1)},"Array | Matrix":function(r){return be(r,this)}})}),bi="fix",Mg=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Ag=R(bi,["typed","ceil","floor"],e=>{var{typed:n,ceil:a,floor:t}=e;return n(bi,{number:function(i){return i>0?t(i):a(i)},"number, number":function(i,l){return i>0?t(i,l):a(i,l)}})}),Sg=R(bi,Mg,e=>{var{typed:n,Complex:a,matrix:t,ceil:r,floor:i,equalScalar:l,zeros:m,DenseMatrix:f}=e,c=gr({typed:n,DenseMatrix:f}),s=Ge({typed:n}),o=Ag({typed:n,ceil:r,floor:i});return n("fix",{number:o.signatures.number,"number, number | BigNumber":o.signatures["number,number"],Complex:function(p){return new a(p.re>0?Math.floor(p.re):Math.ceil(p.re),p.im>0?Math.floor(p.im):Math.ceil(p.im))},"Complex, number":function(p,v){return new a(p.re>0?i(p.re,v):r(p.re,v),p.im>0?i(p.im,v):r(p.im,v))},"Complex, BigNumber":function(p,v){var h=v.toNumber();return new a(p.re>0?i(p.re,h):r(p.re,h),p.im>0?i(p.im,h):r(p.im,h))},BigNumber:function(p){return p.isNegative()?r(p):i(p)},"BigNumber, number | BigNumber":function(p,v){return p.isNegative()?r(p,v):i(p,v)},Fraction:function(p){return p.s<0?p.ceil():p.floor()},"Fraction, number | BigNumber":function(p,v){return p.s<0?r(p,v):i(p,v)},"Array | Matrix":function(p){return be(p,this)},"Array | Matrix, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(t(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return l(p,0)?m(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),wi="floor",Eg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Cg=R(wi,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(wi,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.floor(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.floor(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),Og=R(wi,Eg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=gr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=Cg({typed:n,config:a,round:t});return n("floor",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.floor()},"Complex, number":function(p,v){return p.floor(v)},"Complex, BigNumber":function(p,v){return p.floor(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.floor()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_FLOOR)},Fraction:function(p){return p.floor()},"Fraction, number":function(p,v){return p.floor(v)},"Fraction, BigNumber":function(p,v){return p.floor(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),Dg="algorithm01",Tg=["typed"],qt=R(Dg,Tg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w=typeof c=="string"&&c===v?c:void 0,N=w?n.find(i,[w,w]):i,g,y,x=[];for(g=0;g<h;g++)x[g]=[];var d=[],A=[];for(y=0;y<b;y++){for(var S=y+1,O=u[y],M=u[y+1],_=O;_<M;_++)g=o[_],d[g]=l?N(s[_],m[g][y]):N(m[g][y],s[_]),A[g]=S;for(g=0;g<h;g++)A[g]===S?x[g][y]=d[g]:x[g][y]=m[g][y]}return t.createDenseMatrix({data:x,size:[h,b],datatype:w})}}),Bg="algorithm04",_g=["typed","equalScalar"],Ni=R(Bg,_g,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=m&&u?[]:void 0,_=m&&u?[]:void 0,E=[],$=[],z,I,T,B,G;for(I=0;I<N;I++){O[I]=S.length;var D=I+1;for(B=c[I],G=c[I+1],T=B;T<G;T++)z=f[T],S.push(z),E[z]=D,M&&(M[z]=m[T]);for(B=v[I],G=v[I+1],T=B;T<G;T++)if(z=p[T],E[z]===D){if(M){var H=d(M[z],u[T]);y(H,x)?E[z]=null:M[z]=H}}else S.push(z),$[z]=D,_&&(_[z]=u[T]);if(M&&_)for(T=O[I];T<S.length;)z=S[T],E[z]===D?(A[T]=M[z],T++):$[z]===D?(A[T]=_[z],T++):S.splice(T,1)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),$g="algorithm10",Ig=["typed","DenseMatrix"],Vt=R($g,Ig,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=i}return new a({data:w,size:[p,v],datatype:h})}}),qg="algorithm13",Rg=["typed"],je=R(qg,Rg,e=>{var{typed:n}=e;return function(r,i,l){var m=r._data,f=r._size,c=r._datatype,s=i._data,o=i._size,u=i._datatype,p=[];if(f.length!==o.length)throw new Fe(f.length,o.length);for(var v=0;v<f.length;v++){if(f[v]!==o[v])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");p[v]=f[v]}var h,b=l;typeof c=="string"&&c===u&&(h=c,b=n.find(l,[h,h]));var w=p.length>0?a(b,0,p,p[0],m,s):[];return r.createDenseMatrix({data:w,size:p,datatype:h})};function a(t,r,i,l,m,f){var c=[];if(r===i.length-1)for(var s=0;s<l;s++)c[s]=t(m[s],f[s]);else for(var o=0;o<l;o++)c[o]=a(t,r+1,i,i[r+1],m[o],f[o]);return c}}),hu="gcd",Fg=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],zg=R(hu,Fg,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=qt({typed:n}),m=Ni({typed:n,equalScalar:t}),f=Vt({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n(hu,{"number, number":es,"BigNumber, BigNumber":o,"Fraction, Fraction":function(p,v){return p.gcd(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | BigNumber, SparseMatrix":function(p,v){return f(v,p,this,!0)},"number | BigNumber, DenseMatrix":function(p,v){return s(v,p,this,!0)},"Array, number | BigNumber":function(p,v){return s(a(p),v,this,!1).valueOf()},"number | BigNumber, Array":function(p,v){return s(a(v),p,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}});function o(u,p){if(!u.isInt()||!p.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var v=new r(0);!p.isZero();){var h=u.mod(p);u=p,p=h}return u.lt(v)?u.neg():u}}),Pg="algorithm02",Ug=["typed","equalScalar"],rt=R(Pg,Ug,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o=i._values,u=i._index,p=i._ptr,v=i._size,h=i._datatype;if(c.length!==v.length)throw new Fe(c.length,v.length);if(c[0]!==v[0]||c[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+v+")");if(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var b=c[0],w=c[1],N,g=a,y=0,x=l;typeof s=="string"&&s===h&&(N=s,g=n.find(a,[N,N]),y=n.convert(0,N),x=n.find(l,[N,N]));for(var d=[],A=[],S=[],O=0;O<w;O++){S[O]=A.length;for(var M=p[O],_=p[O+1],E=M;E<_;E++){var $=u[E],z=m?x(o[E],f[$][O]):x(f[$][O],o[E]);g(z,y)||(A.push($),d.push(z))}}return S[w]=A.length,i.createSparseMatrix({values:d,index:A,ptr:S,size:[b,w],datatype:N})}}),Lg="algorithm06",kg=["typed","equalScalar"],Sa=R(Lg,kg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._size,c=r._datatype,s=i._values,o=i._size,u=i._datatype;if(f.length!==o.length)throw new Fe(f.length,o.length);if(f[0]!==o[0]||f[1]!==o[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");var p=f[0],v=f[1],h,b=a,w=0,N=l;typeof c=="string"&&c===u&&(h=c,b=n.find(a,[h,h]),w=n.convert(0,h),N=n.find(l,[h,h]));for(var g=m&&s?[]:void 0,y=[],x=[],d=g?[]:void 0,A=[],S=[],O=0;O<v;O++){x[O]=y.length;var M=O+1;if(Go(r,O,A,d,S,M,y,N),Go(i,O,A,d,S,M,y,N),d)for(var _=x[O];_<y.length;){var E=y[_];if(S[E]===M){var $=d[E];b($,w)?y.splice(_,1):(g.push($),_++)}else y.splice(_,1)}else for(var z=x[O];z<y.length;){var I=y[z];S[I]!==M?y.splice(z,1):z++}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),du="lcm",Hg=["typed","matrix","equalScalar"],Gg=R(du,Hg,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=rt({typed:n,equalScalar:t}),i=Sa({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(du,{"number, number":rs,"BigNumber, BigNumber":c,"Fraction, Fraction":function(o,u){return o.lcm(u)},"SparseMatrix, SparseMatrix":function(o,u){return i(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return r(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return r(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return m(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, number | BigNumber":function(o,u){return l(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return f(o,u,this,!1)},"number | BigNumber, SparseMatrix":function(o,u){return l(u,o,this,!0)},"number | BigNumber, DenseMatrix":function(o,u){return f(u,o,this,!0)},"Array, number | BigNumber":function(o,u){return f(a(o),u,this,!1).valueOf()},"number | BigNumber, Array":function(o,u){return f(a(u),o,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(o,u,p){for(var v=this(o,u),h=0;h<p.length;h++)v=this(v,p[h]);return v}});function c(s,o){if(!s.isInt()||!o.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(s.isZero())return s;if(o.isZero())return o;for(var u=s.times(o);!o.isZero();){var p=o;o=s.mod(p),s=p}return u.div(s).abs()}}),gu="log10",Vg=["typed","config","Complex"],Zg=R(gu,Vg,e=>{var{typed:n,config:a,Complex:t}=e;return n(gu,{number:function(i){return i>=0||a.predictable?ts(i):new t(i,0).log().div(Math.LN10)},Complex:function(i){return new t(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||a.predictable?i.log():new t(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(i){return be(i,this)}})}),yu="log2",Xg=["typed","config","Complex"],Yg=R(yu,Xg,e=>{var{typed:n,config:a,Complex:t}=e;return n(yu,{number:function(l){return l>=0||a.predictable?ns(l):r(new t(l,0))},Complex:r,BigNumber:function(l){return!l.isNegative()||a.predictable?l.log(2):r(new t(l.toNumber(),0))},"Array | Matrix":function(l){return be(l,this)}});function r(i){var l=Math.sqrt(i.re*i.re+i.im*i.im);return new t(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),Wg="algorithm03",Jg=["typed"],Dr=R(Wg,Jg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w,N=0,g=i;typeof c=="string"&&c===v&&(w=c,N=n.convert(0,w),g=n.find(i,[w,w]));for(var y=[],x=0;x<h;x++)y[x]=[];for(var d=[],A=[],S=0;S<b;S++){for(var O=S+1,M=u[S],_=u[S+1],E=M;E<_;E++){var $=o[E];d[$]=l?g(s[E],m[$][S]):g(m[$][S],s[E]),A[$]=O}for(var z=0;z<h;z++)A[z]===O?y[z][S]=d[z]:y[z][S]=l?g(N,m[z][S]):g(m[z][S],N)}return t.createDenseMatrix({data:y,size:[h,b],datatype:w})}}),Qg="algorithm05",Kg=["typed","equalScalar"],Ea=R(Qg,Kg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=A?[]:void 0,E=[],$=[],z,I,T,B;for(I=0;I<N;I++){O[I]=S.length;var G=I+1;for(T=c[I],B=c[I+1];T<B;T++)z=f[T],S.push(z),E[z]=G,M&&(M[z]=m[T]);for(T=v[I],B=v[I+1];T<B;T++)z=p[T],E[z]!==G&&S.push(z),$[z]=G,_&&(_[z]=u[T]);if(A)for(T=O[I];T<S.length;){z=S[T];var D=E[z],H=$[z];if(D===G||H===G){var W=D===G?M[z]:x,j=H===G?_[z]:x,V=d(W,j);y(V,x)?S.splice(T,1):(A.push(V),T++)}}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),xu="mod",jg=["typed","matrix","equalScalar","DenseMatrix"],ey=R(xu,jg,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=rt({typed:n,equalScalar:t}),l=Dr({typed:n}),m=Ea({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=gr({typed:n,DenseMatrix:r}),s=je({typed:n}),o=Ge({typed:n});return n(xu,{"number, number":as,"BigNumber, BigNumber":function(p,v){if(v.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return v.isZero()?p:p.mod(v)},"Fraction, Fraction":function(p,v){if(v.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return p.compare(0)>=0?p.mod(v):p.mod(v).add(v).mod(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this,!1)},"SparseMatrix, DenseMatrix":function(p,v){return i(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(a(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,this,!0).valueOf()}})}),ry="multiplyScalar",ty=["typed"],ny=R(ry,ty,e=>{var{typed:n}=e;return n("multiplyScalar",{"number, number":Yo,"Complex, Complex":function(t,r){return t.mul(r)},"BigNumber, BigNumber":function(t,r){return t.times(r)},"Fraction, Fraction":function(t,r){return t.mul(r)},"number | Fraction | BigNumber | Complex, Unit":function(t,r){var i=r.clone();return i.value=i.value===null?i._normalize(t):this(i.value,t),i},"Unit, number | Fraction | BigNumber | Complex":function(t,r){var i=t.clone();return i.value=i.value===null?i._normalize(r):this(i.value,r),i},"Unit, Unit":function(t,r){return t.multiply(r)}})}),bu="multiply",ay=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],iy=R(bu,ay,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,equalScalar:i,dot:l}=e,m=wr({typed:n,equalScalar:i}),f=Ge({typed:n});function c(x,d){switch(x.length){case 1:switch(d.length){case 1:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;case 2:switch(d.length){case 1:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+d[0]+")");break;case 2:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function s(x,d,A){if(A===0)throw new Error("Cannot multiply two empty vectors");return l(x,d)}function o(x,d){if(d.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return u(x,d)}function u(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=_[1],I,T=t,B=r;O&&E&&O===E&&typeof O=="string"&&(I=O,T=n.find(t,[I,I]),B=n.find(r,[I,I]));for(var G=[],D=0;D<z;D++){for(var H=B(A[0],M[0][D]),W=1;W<$;W++)H=T(H,B(A[W],M[W][D]));G[D]=H}return x.createDenseMatrix({data:G,size:[z],datatype:I})}var p=n("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":N}),v=n("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":b,"DenseMatrix, SparseMatrix":w,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":y});function h(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._datatype,E=S[0],$=S[1],z,I=t,T=r;O&&_&&O===_&&typeof O=="string"&&(z=O,I=n.find(t,[z,z]),T=n.find(r,[z,z]));for(var B=[],G=0;G<E;G++){for(var D=A[G],H=T(D[0],M[0]),W=1;W<$;W++)H=I(H,T(D[W],M[W]));B[G]=H}return x.createDenseMatrix({data:B,size:[E],datatype:z})}function b(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=S[1],I=_[1],T,B=t,G=r;O&&E&&O===E&&typeof O=="string"&&(T=O,B=n.find(t,[T,T]),G=n.find(r,[T,T]));for(var D=[],H=0;H<$;H++){var W=A[H];D[H]=[];for(var j=0;j<I;j++){for(var V=G(W[0],M[0][j]),K=1;K<z;K++)V=B(V,G(W[K],M[K][j]));D[H][j]=V}}return x.createDenseMatrix({data:D,size:[$,I],datatype:T})}function w(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._values,_=d._index,E=d._ptr,$=d._size,z=d._datatype;if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var I=S[0],T=$[1],B,G=t,D=r,H=i,W=0;O&&z&&O===z&&typeof O=="string"&&(B=O,G=n.find(t,[B,B]),D=n.find(r,[B,B]),H=n.find(i,[B,B]),W=n.convert(0,B));for(var j=[],V=[],K=[],te=d.createSparseMatrix({values:j,index:V,ptr:K,size:[I,T],datatype:B}),re=0;re<T;re++){K[re]=V.length;var ie=E[re],ne=E[re+1];if(ne>ie)for(var ue=0,ee=0;ee<I;ee++){for(var ye=ee+1,we=void 0,me=ie;me<ne;me++){var xe=_[me];ue!==ye?(we=D(A[ee][xe],M[me]),ue=ye):we=G(we,D(A[ee][xe],M[me]))}ue===ye&&!H(we,W)&&(V.push(ee),j.push(we))}}return K[T]=V.length,te}function N(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=[],T=[],B=[],G,D=t,H=r,W=i,j=0;M&&E&&M===E&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]),W=n.find(i,[G,G]),j=n.convert(0,G));var V=[],K=[];B[0]=0;for(var te=0;te<z;te++){var re=_[te];if(!W(re,j))for(var ie=O[te],ne=O[te+1],ue=ie;ue<ne;ue++){var ee=S[ue];K[ee]?V[ee]=D(V[ee],H(re,A[ue])):(K[ee]=!0,T.push(ee),V[ee]=H(re,A[ue]))}}for(var ye=T.length,we=0;we<ye;we++){var me=T[we];I[we]=V[me]}return B[1]=T.length,x.createSparseMatrix({values:I,index:T,ptr:B,size:[$,1],datatype:G})}function g(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=d._size[1],T,B=t,G=r,D=i,H=0;M&&E&&M===E&&typeof M=="string"&&(T=M,B=n.find(t,[T,T]),G=n.find(r,[T,T]),D=n.find(i,[T,T]),H=n.convert(0,T));for(var W=[],j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[$,I],datatype:T}),te=[],re=[],ie=0;ie<I;ie++){V[ie]=j.length;for(var ne=ie+1,ue=0;ue<z;ue++){var ee=_[ue][ie];if(!D(ee,H))for(var ye=O[ue],we=O[ue+1],me=ye;me<we;me++){var xe=S[me];re[xe]!==ne?(re[xe]=ne,j.push(xe),te[xe]=G(ee,A[me])):te[xe]=B(te[xe],G(ee,A[me]))}}for(var F=V[ie],Y=j.length,k=F;k<Y;k++){var U=j[k];W[k]=te[U]}}return V[I]=j.length,K}function y(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype,_=d._values,E=d._index,$=d._ptr,z=d._datatype,I=x._size[0],T=d._size[1],B=A&&_,G,D=t,H=r;M&&z&&M===z&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]));for(var W=B?[]:void 0,j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[I,T],datatype:G}),te=B?[]:void 0,re=[],ie,ne,ue,ee,ye,we,me,xe,F=0;F<T;F++){V[F]=j.length;var Y=F+1;for(ye=$[F],we=$[F+1],ee=ye;ee<we;ee++)if(xe=E[ee],B)for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y?(re[me]=Y,j.push(me),te[me]=H(_[ee],A[ie])):te[me]=D(te[me],H(_[ee],A[ie]));else for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y&&(re[me]=Y,j.push(me));if(B)for(var k=V[F],U=j.length,J=k;J<U;J++){var q=j[J];W[J]=te[q]}}return V[T]=j.length,K}return n(bu,Ka({"Array, Array":function(d,A){c(Pe(d),Pe(A));var S=this(a(d),a(A));return Oe(S)?S.valueOf():S},"Matrix, Matrix":function(d,A){var S=d.size(),O=A.size();return c(S,O),S.length===1?O.length===1?s(d,A,S[0]):o(d,A):O.length===1?p(d,A):v(d,A)},"Matrix, Array":function(d,A){return this(d,a(A))},"Array, Matrix":function(d,A){return this(a(d,A.storage()),A)},"SparseMatrix, any":function(d,A){return m(d,A,r,!1)},"DenseMatrix, any":function(d,A){return f(d,A,r,!1)},"any, SparseMatrix":function(d,A){return m(A,d,r,!0)},"any, DenseMatrix":function(d,A){return f(A,d,r,!0)},"Array, any":function(d,A){return f(a(d),A,r,!1).valueOf()},"any, Array":function(d,A){return f(a(A),d,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(d,A,S){for(var O=this(d,A),M=0;M<S.length;M++)O=this(O,S[M]);return O}},r.signatures))}),wu="nthRoot",oy=["typed","matrix","equalScalar","BigNumber"],sy=R(wu,oy,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r}=e,i=qt({typed:n}),l=rt({typed:n,equalScalar:t}),m=Sa({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n}),o="Complex number not supported in function nthRoot. Use nthRoots instead.";return n(wu,{number:is,"number, number":is,BigNumber:function(v){return u(v,new r(2))},Complex:function(v){throw new Error(o)},"Complex, number":function(v,h){throw new Error(o)},"BigNumber, BigNumber":u,"Array | Matrix":function(v){return this(v,2)},"SparseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return m(v,h,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return i(v,h,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(v,h){return c(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return f(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return s(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){if(h.density()===1)return f(h,v,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(v,h){return s(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}});function u(p,v){var h=r.precision,b=r.clone({precision:h+2}),w=new r(0),N=new b(1),g=v.isNegative();if(g&&(v=v.neg()),v.isZero())throw new Error("Root must be non-zero");if(p.isNegative()&&!v.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(p.isZero())return g?new b(1/0):0;if(!p.isFinite())return g?w:p;var y=p.abs().pow(N.div(v));return y=p.isNeg()?y.neg():y,new r((g?N.div(y):y).toPrecision(h))}}),Nu="sign",uy=["typed","BigNumber","Fraction","complex"],cy=R(Nu,uy,e=>{var{typed:n,BigNumber:a,complex:t,Fraction:r}=e;return n(Nu,{number:di,Complex:function(l){return l.im===0?t(di(l.re)):l.sign()},BigNumber:function(l){return new a(l.cmp(0))},Fraction:function(l){return new r(l.s,1)},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){if(!l._isDerived()&&l.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return this(l.value)}})}),fy="sqrt",ly=["config","typed","Complex"],my=R(fy,ly,e=>{var{config:n,typed:a,Complex:t}=e;return a("sqrt",{number:r,Complex:function(l){return l.sqrt()},BigNumber:function(l){return!l.isNegative()||n.predictable?l.sqrt():r(l.toNumber())},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){return l.pow(.5)}});function r(i){return isNaN(i)?NaN:i>=0||n.predictable?Math.sqrt(i):new t(i,0).sqrt()}}),Mu="square",py=["typed"],vy=R(Mu,py,e=>{var{typed:n}=e;return n(Mu,{number:os,Complex:function(t){return t.mul(t)},BigNumber:function(t){return t.times(t)},Fraction:function(t){return t.mul(t)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(2)}})}),Au="subtract",hy=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],dy=R(Au,hy,e=>{var{typed:n,matrix:a,equalScalar:t,addScalar:r,unaryMinus:i,DenseMatrix:l}=e,m=qt({typed:n}),f=Dr({typed:n}),c=Ea({typed:n,equalScalar:t}),s=Vt({typed:n,DenseMatrix:l}),o=je({typed:n}),u=Ge({typed:n});return n(Au,{"number, number":function(v,h){return v-h},"Complex, Complex":function(v,h){return v.sub(h)},"BigNumber, BigNumber":function(v,h){return v.minus(h)},"Fraction, Fraction":function(v,h){return v.sub(h)},"Unit, Unit":function(v,h){if(v.value===null)throw new Error("Parameter x contains a unit with undefined value");if(h.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!v.equalBase(h))throw new Error("Units do not match");var b=v.clone();return b.value=this(b.value,h.value),b.fixPrefix=!1,b},"SparseMatrix, SparseMatrix":function(v,h){return Ca(v,h),c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return Ca(v,h),f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return Ca(v,h),m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return Ca(v,h),o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return s(v,i(h),r)},"DenseMatrix, any":function(v,h){return u(v,h,this)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(a(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})});function Ca(e,n){var a=e.size(),t=n.size();if(a.length!==t.length)throw new Fe(a.length,t.length)}var Su="xgcd",gy=["typed","config","matrix","BigNumber"],yy=R(Su,gy,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(Su,{"number, number":function(m,f){var c=ss(m,f);return a.matrix==="Array"?c:t(c)},"BigNumber, BigNumber":i});function i(l,m){var f,c,s,o=new r(0),u=new r(1),p=o,v=u,h=u,b=o;if(!l.isInt()||!m.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!m.isZero();)c=l.div(m).floor(),s=l.mod(m),f=p,p=v.minus(c.times(p)),v=f,f=h,h=b.minus(c.times(h)),b=f,l=m,m=s;var w;return l.lt(o)?w=[l.neg(),v.neg(),b.neg()]:w=[l,l.isZero()?0:v,b],a.matrix==="Array"?w:t(w)}}),Eu="invmod",xy=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],by=R(Eu,xy,e=>{var{typed:n,config:a,BigNumber:t,xgcd:r,equal:i,smaller:l,mod:m,add:f,isInteger:c}=e;return n(Eu,{"number, number":s,"BigNumber, BigNumber":s});function s(o,u){if(!c(o)||!c(u))throw new Error("Parameters in function invmod must be integer numbers");if(o=m(o,u),i(u,0))throw new Error("Divisor must be non zero");var p=r(o,u);p=p.valueOf();var[v,h]=p;return i(v,t(1))?(h=m(h,u),l(h,t(0))&&(h=f(h,u)),h):NaN}}),wy="algorithm09",Ny=["typed","equalScalar"],Cu=R(wy,Ny,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=[],E,$,z,I,T;for($=0;$<N;$++){O[$]=S.length;var B=$+1;if(M)for(I=v[$],T=v[$+1],z=I;z<T;z++)E=p[z],_[E]=B,M[E]=u[z];for(I=c[$],T=c[$+1],z=I;z<T;z++)if(E=f[z],M){var G=_[E]===B?M[E]:x,D=d(m[z],G);y(D,x)||(S.push(E),A.push(D))}else S.push(E)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Ou="dotMultiply",My=["typed","matrix","equalScalar","multiplyScalar"],Ay=R(Ou,My,e=>{var{typed:n,matrix:a,equalScalar:t,multiplyScalar:r}=e,i=rt({typed:n,equalScalar:t}),l=Cu({typed:n,equalScalar:t}),m=wr({typed:n,equalScalar:t}),f=je({typed:n}),c=Ge({typed:n});return n(Ou,{"any, any":r,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,r,!1)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,r,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,r,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,r)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,r,!1)},"DenseMatrix, any":function(o,u){return c(o,u,r,!1)},"any, SparseMatrix":function(o,u){return m(u,o,r,!0)},"any, DenseMatrix":function(o,u){return c(u,o,r,!0)},"Array, any":function(o,u){return c(a(o),u,r,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,r,!0).valueOf()}})});function Sy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitAnd");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero()||n.eq(-1)||e.eq(n))return e;if(n.isZero()||e.eq(-1))return n;if(!e.isFinite()||!n.isFinite()){if(!e.isFinite()&&!n.isFinite())return e.isNegative()===n.isNegative()?e:new a(0);if(!e.isFinite())return n.isNegative()?e:e.isNegative()?new a(0):n;if(!n.isFinite())return e.isNegative()?n:n.isNegative()?new a(0):e}return Mi(e,n,function(t,r){return t&r})}function In(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var n=e.constructor,a=n.precision;n.config({precision:1e9});var t=e.plus(new n(1));return t.s=-t.s||null,n.config({precision:a}),t}function Ey(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitOr");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);var t=new a(-1);return e.isZero()||n.eq(t)||e.eq(n)?n:n.isZero()||e.eq(t)?e:!e.isFinite()||!n.isFinite()?!e.isFinite()&&!e.isNegative()&&n.isNegative()||e.isNegative()&&!n.isNegative()&&!n.isFinite()?t:e.isNegative()&&n.isNegative()?e.isFinite()?e:n:e.isFinite()?n:e:Mi(e,n,function(r,i){return r|i})}function Mi(e,n,a){var t=e.constructor,r,i,l=+(e.s<0),m=+(n.s<0);if(l){r=Oa(In(e));for(var f=0;f<r.length;++f)r[f]^=1}else r=Oa(e);if(m){i=Oa(In(n));for(var c=0;c<i.length;++c)i[c]^=1}else i=Oa(n);var s,o,u;r.length<=i.length?(s=r,o=i,u=l):(s=i,o=r,u=m);var p=s.length,v=o.length,h=a(l,m)^1,b=new t(h^1),w=new t(1),N=new t(2),g=t.precision;for(t.config({precision:1e9});p>0;)a(s[--p],o[--v])===h&&(b=b.plus(w)),w=w.times(N);for(;v>0;)a(u,o[--v])===h&&(b=b.plus(w)),w=w.times(N);return t.config({precision:g}),h===0&&(b.s=-b.s),b}function Oa(e){for(var n=e.d,a=n[0]+"",t=1;t<n.length;++t){for(var r=n[t]+"",i=7-r.length;i--;)r="0"+r;a+=r}for(var l=a.length;a.charAt(l)==="0";)l--;var m=e.e,f=a.slice(0,l+1||1),c=f.length;if(m>0)if(++m>c)for(m-=c;m--;)f+="0";else m<c&&(f=f.slice(0,m)+"."+f.slice(m));for(var s=[0],o=0;o<f.length;){for(var u=s.length;u--;)s[u]*=10;s[0]+=parseInt(f.charAt(o++));for(var p=0;p<s.length;++p)s[p]>1&&((s[p+1]===null||s[p+1]===void 0)&&(s[p+1]=0),s[p+1]+=s[p]>>1,s[p]&=1)}return s.reverse()}function Cy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitXor");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero())return n;if(n.isZero())return e;if(e.eq(n))return new a(0);var t=new a(-1);return e.eq(t)?In(n):n.eq(t)?In(e):!e.isFinite()||!n.isFinite()?!e.isFinite()&&!n.isFinite()?t:new a(e.isNegative()===n.isNegative()?1/0:-1/0):Mi(e,n,function(r,i){return r^i})}function Oy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function leftShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:!e.isFinite()&&!n.isFinite()?new a(NaN):n.lt(55)?e.times(Math.pow(2,n.toNumber())+""):e.times(new a(2).pow(n))}function Dy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function rightArithShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:n.isFinite()?n.lt(55)?e.div(Math.pow(2,n.toNumber())+"").floor():e.div(new a(2).pow(n)).floor():e.isNegative()?new a(-1):e.isFinite()?new a(0):new a(NaN)}var Du="bitAnd",Ty=["typed","matrix","equalScalar"],By=R(Du,Ty,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=rt({typed:n,equalScalar:t}),i=Sa({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(Du,{"number, number":fs,"BigNumber, BigNumber":Sy,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this,!1)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Tu="bitNot",_y=["typed"],$y=R(Tu,_y,e=>{var{typed:n}=e;return n(Tu,{number:ls,BigNumber:In,"Array | Matrix":function(t){return be(t,this)}})}),Bu="bitOr",Iy=["typed","matrix","equalScalar","DenseMatrix"],qy=R(Bu,Iy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=qt({typed:n}),l=Ni({typed:n,equalScalar:t}),m=Vt({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Bu,{"number, number":ms,"BigNumber, BigNumber":Ey,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Ry="algorithm07",Fy=["typed","DenseMatrix"],ut=R(Ry,Fy,e=>{var{typed:n,DenseMatrix:a}=e;return function(i,l,m){var f=i._size,c=i._datatype,s=l._size,o=l._datatype;if(f.length!==s.length)throw new Fe(f.length,s.length);if(f[0]!==s[0]||f[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+s+")");var u=f[0],p=f[1],v,h=0,b=m;typeof c=="string"&&c===o&&(v=c,h=n.convert(0,v),b=n.find(m,[v,v]));var w,N,g=[];for(w=0;w<u;w++)g[w]=[];var y=[],x=[],d=[],A=[];for(N=0;N<p;N++){var S=N+1;for(t(i,N,d,y,S),t(l,N,A,x,S),w=0;w<u;w++){var O=d[w]===S?y[w]:h,M=A[w]===S?x[w]:h;g[w][N]=b(O,M)}}return new a({data:g,size:[u,p],datatype:v})};function t(r,i,l,m,f){for(var c=r._values,s=r._index,o=r._ptr,u=o[i],p=o[i+1];u<p;u++){var v=s[u];l[v]=f,m[v]=c[u]}}}),_u="bitXor",zy=["typed","matrix","DenseMatrix"],Py=R(_u,zy,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Dr({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=gr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n(_u,{"number, number":ps,"BigNumber, BigNumber":Cy,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),$u="arg",Uy=["typed"],Ly=R($u,Uy,e=>{var{typed:n}=e;return n($u,{number:function(t){return Math.atan2(0,t)},BigNumber:function(t){return t.constructor.atan2(0,t)},Complex:function(t){return t.arg()},"Array | Matrix":function(t){return be(t,this)}})}),Iu="conj",ky=["typed"],Hy=R(Iu,ky,e=>{var{typed:n}=e;return n(Iu,{number:function(t){return t},BigNumber:function(t){return t},Complex:function(t){return t.conjugate()},"Array | Matrix":function(t){return be(t,this)}})}),qu="im",Gy=["typed"],Vy=R(qu,Gy,e=>{var{typed:n}=e;return n(qu,{number:function(t){return 0},BigNumber:function(t){return t.mul(0)},Fraction:function(t){return t.mul(0)},Complex:function(t){return t.im},"Array | Matrix":function(t){return be(t,this)}})}),Ru="re",Zy=["typed"],Xy=R(Ru,Zy,e=>{var{typed:n}=e;return n(Ru,{number:function(t){return t},BigNumber:function(t){return t},Fraction:function(t){return t},Complex:function(t){return t.re},"Array | Matrix":function(t){return be(t,this)}})}),Fu="not",Yy=["typed"],Wy=R(Fu,Yy,e=>{var{typed:n}=e;return n(Fu,{number:ys,Complex:function(t){return t.re===0&&t.im===0},BigNumber:function(t){return t.isZero()||t.isNaN()},Unit:function(t){return t.value!==null?this(t.value):!0},"Array | Matrix":function(t){return be(t,this)}})}),zu="or",Jy=["typed","matrix","equalScalar","DenseMatrix"],Qy=R(zu,Jy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=Ea({typed:n,equalScalar:t}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(zu,{"number, number":xs,"Complex, Complex":function(o,u){return o.re!==0||o.im!==0||u.re!==0||u.im!==0},"BigNumber, BigNumber":function(o,u){return!o.isZero()&&!o.isNaN()||!u.isZero()&&!u.isNaN()},"Unit, Unit":function(o,u){return this(o.value||0,u.value||0)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Pu="xor",Ky=["typed","matrix","DenseMatrix"],jy=R(Pu,Ky,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Dr({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=gr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n(Pu,{"number, number":bs,"Complex, Complex":function(s,o){return(s.re!==0||s.im!==0)!=(o.re!==0||o.im!==0)},"BigNumber, BigNumber":function(s,o){return(!s.isZero()&&!s.isNaN())!=(!o.isZero()&&!o.isNaN())},"Unit, Unit":function(s,o){return this(s.value||0,o.value||0)},"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Uu="concat",e0=["typed","matrix","isInteger"],Lu=R(Uu,e0,e=>{var{typed:n,matrix:a,isInteger:t}=e;return n(Uu,{"...Array | Matrix | number | BigNumber":function(i){var l,m=i.length,f=-1,c,s=!1,o=[];for(l=0;l<m;l++){var u=i[l];if(Oe(u)&&(s=!0),Be(u)||_e(u)){if(l!==m-1)throw new Error("Dimension must be specified as last argument");if(c=f,f=u.valueOf(),!t(f))throw new TypeError("Integer number expected for dimension");if(f<0||l>0&&f>c)throw new Kr(f,c+1)}else{var p=Ce(u).valueOf(),v=Pe(p);if(o[l]=p,c=f,f=v.length-1,l>0&&f!==c)throw new Fe(c+1,f+1)}}if(o.length===0)throw new SyntaxError("At least one matrix expected");for(var h=o.shift();o.length;)h=ku(h,o.shift(),f,0);return s?a(h):h},"...string":function(i){return i.join("")}})});function ku(e,n,a,t){if(t<a){if(e.length!==n.length)throw new Fe(e.length,n.length);for(var r=[],i=0;i<e.length;i++)r[i]=ku(e[i],n[i],a,t+1);return r}else return e.concat(n)}var Hu="column",r0=["typed","Index","matrix","range"],Gu=R(Hu,r0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(Hu,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[1]);var f=r(0,l.size()[0]),c=new a(f,m);return l.subset(c)}}),Vu="count",t0=["typed","size","prod"],n0=R(Vu,t0,e=>{var{typed:n,size:a,prod:t}=e;return n(Vu,{string:function(i){return i.length},"Matrix | Array":function(i){return t(a(i))}})}),Zu="cross",a0=["typed","matrix","subtract","multiply"],i0=R(Zu,a0,e=>{var{typed:n,matrix:a,subtract:t,multiply:r}=e;return n(Zu,{"Matrix, Matrix":function(m,f){return a(i(m.toArray(),f.toArray()))},"Matrix, Array":function(m,f){return a(i(m.toArray(),f))},"Array, Matrix":function(m,f){return a(i(m,f.toArray()))},"Array, Array":i});function i(l,m){var f=Math.max(Pe(l).length,Pe(m).length);l=aa(l),m=aa(m);var c=Pe(l),s=Pe(m);if(c.length!==1||s.length!==1||c[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+c.join(", ")+"], B = ["+s.join(", ")+"])");var o=[t(r(l[1],m[2]),r(l[2],m[1])),t(r(l[2],m[0]),r(l[0],m[2])),t(r(l[0],m[1]),r(l[1],m[0]))];return f>1?[o]:o}}),Xu="diag",o0=["typed","matrix","DenseMatrix","SparseMatrix"],s0=R(Xu,o0,e=>{var{typed:n,matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(Xu,{Array:function(c){return i(c,0,Pe(c),null)},"Array, number":function(c,s){return i(c,s,Pe(c),null)},"Array, BigNumber":function(c,s){return i(c,s.toNumber(),Pe(c),null)},"Array, string":function(c,s){return i(c,0,Pe(c),s)},"Array, number, string":function(c,s,o){return i(c,s,Pe(c),o)},"Array, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),Pe(c),o)},Matrix:function(c){return i(c,0,c.size(),c.storage())},"Matrix, number":function(c,s){return i(c,s,c.size(),c.storage())},"Matrix, BigNumber":function(c,s){return i(c,s.toNumber(),c.size(),c.storage())},"Matrix, string":function(c,s){return i(c,0,c.size(),s)},"Matrix, number, string":function(c,s,o){return i(c,s,c.size(),o)},"Matrix, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),c.size(),o)}});function i(f,c,s,o){if(!Ae(c))throw new TypeError("Second parameter in function diag must be an integer");var u=c>0?c:0,p=c<0?-c:0;switch(s.length){case 1:return l(f,c,o,s[0],p,u);case 2:return m(f,c,o,s,p,u)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function l(f,c,s,o,u,p){var v=[o+u,o+p];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var h=s==="sparse"?r.diagonal(v,f,c):t.diagonal(v,f,c);return s!==null?h:h.valueOf()}function m(f,c,s,o,u,p){if(Oe(f)){var v=f.diagonal(c);return s!==null?s!==v.storage()?a(v,s):v:v.valueOf()}for(var h=Math.min(o[0]-u,o[1]-p),b=[],w=0;w<h;w++)b[w]=f[w+u][w+p];return s!==null?a(b):b}});function u0(e){var n=0,a=1,t=Object.create(null),r=Object.create(null),i=0,l=function(f){var c=r[f];if(c&&(delete t[c],delete r[f],--n,a===c)){if(!n){i=0,a=1;return}for(;!hasOwnProperty.call(t,++a););}};return e=Math.abs(e),{hit:function(f){var c=r[f],s=++i;if(t[s]=f,r[f]=s,!c)return++n,n<=e?void 0:(f=t[a],l(f),f);if(delete t[c],a===c)for(;!hasOwnProperty.call(t,++a););},delete:l,clear:function(){n=i=0,a=1,t=Object.create(null),r=Object.create(null)}}}function qn(e){var{hasher:n,limit:a}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return a=a==null?Number.POSITIVE_INFINITY:a,n=n==null?JSON.stringify:n,function t(){typeof t.cache!="object"&&(t.cache={values:new Map,lru:u0(a||Number.POSITIVE_INFINITY)});for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var l=n(r);if(t.cache.values.has(l))return t.cache.lru.hit(l),t.cache.values.get(l);var m=e.apply(e,r);return t.cache.values.set(l,m),t.cache.values.delete(t.cache.lru.hit(l)),m}}function hn(e){return Object.keys(e.signatures||{}).reduce(function(n,a){var t=(a.match(/,/g)||[]).length+1;return Math.max(n,t)},-1)}var c0="filter",f0=["typed"],l0=R(c0,f0,e=>{var{typed:n}=e;return n("filter",{"Array, function":Yu,"Matrix, function":function(t,r){return t.create(Yu(t.toArray(),r))},"Array, RegExp":oa,"Matrix, RegExp":function(t,r){return t.create(oa(t.toArray(),r))}})});function Yu(e,n){var a=hn(n);return wo(e,function(t,r,i){return a===1?n(t):a===2?n(t,[r]):n(t,[r],i)})}var Wu="flatten",m0=["typed","matrix"],p0=R(Wu,m0,e=>{var{typed:n,matrix:a}=e;return n(Wu,{Array:function(r){return Le(Ce(r))},Matrix:function(r){var i=Le(Ce(r.toArray()));return a(i)}})}),Ju="forEach",v0=["typed"],h0=R(Ju,v0,e=>{var{typed:n}=e;return n(Ju,{"Array, function":d0,"Matrix, function":function(t,r){return t.forEach(r)}})});function d0(e,n){var a=hn(n),t=function r(i,l){Array.isArray(i)?ia(i,function(m,f){r(m,l.concat(f))}):a===1?n(i):a===2?n(i,l):n(i,l,e)};t(e,[])}var Qu="getMatrixDataType",g0=["typed"],y0=R(Qu,g0,e=>{var{typed:n}=e;return n(Qu,{Array:function(t){return Bn(t,Ke)},Matrix:function(t){return t.getDataType()}})}),Ku="identity",x0=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],b0=R(Ku,x0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r,DenseMatrix:i,SparseMatrix:l}=e;return n(Ku,{"":function(){return a.matrix==="Matrix"?t([]):[]},string:function(s){return t(s)},"number | BigNumber":function(s){return f(s,s,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(s,o){return f(s,s,o)},"number | BigNumber, number | BigNumber":function(s,o){return f(s,o,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(s,o,u){return f(s,o,u)},Array:function(s){return m(s)},"Array, string":function(s,o){return m(s,o)},Matrix:function(s){return m(s.valueOf(),s.storage())},"Matrix, string":function(s,o){return m(s.valueOf(),o)}});function m(c,s){switch(c.length){case 0:return s?t(s):[];case 1:return f(c[0],c[0],s);case 2:return f(c[0],c[1],s);default:throw new Error("Vector containing two values expected")}}function f(c,s,o){var u=_e(c)||_e(s)?r:null;if(_e(c)&&(c=c.toNumber()),_e(s)&&(s=s.toNumber()),!Ae(c)||c<1)throw new Error("Parameters in function identity must be positive integers");if(!Ae(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var p=u?new r(1):1,v=u?new u(0):0,h=[c,s];if(o){if(o==="sparse")return l.diagonal(h,p,0,v);if(o==="dense")return i.diagonal(h,p,0,v);throw new TypeError('Unknown matrix type "'.concat(o,'"'))}for(var b=on([],h,v),w=c<s?c:s,N=0;N<w;N++)b[N][N]=p;return b}}),ju="kron",w0=["typed","matrix","multiplyScalar"],N0=R(ju,w0,e=>{var{typed:n,matrix:a,multiplyScalar:t}=e;return n(ju,{"Matrix, Matrix":function(l,m){return a(r(l.toArray(),m.toArray()))},"Matrix, Array":function(l,m){return a(r(l.toArray(),m))},"Array, Matrix":function(l,m){return a(r(l,m.toArray()))},"Array, Array":r});function r(i,l){if(Pe(i).length===1&&(i=[i]),Pe(l).length===1&&(l=[l]),Pe(i).length>2||Pe(l).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(l.length)+")");var m=[],f=[];return i.map(function(c){return l.map(function(s){return f=[],m.push(f),c.map(function(o){return s.map(function(u){return f.push(t(o,u))})})})})&&m}}),ec="map",M0=["typed"],A0=R(ec,M0,e=>{var{typed:n}=e;return n(ec,{"Array, function":S0,"Matrix, function":function(t,r){return t.map(r)}})});function S0(e,n){var a=hn(n),t=function r(i,l){if(Array.isArray(i))return i.map(function(c,s){return r(c,l.concat(s))});try{return a===1?n(i):a===2?n(i,l):n(i,l,e)}catch(c){if(c instanceof TypeError&&"data"in c&&c.data.category==="wrongType"){var m="map attempted to call '".concat(c.data.fn,"(").concat(i),f=JSON.stringify(l);throw a===2?m+=","+f:a!==1&&(m+=",".concat(f,",").concat(e)),m+=")' but argument ".concat(c.data.index+1," of type "),m+="".concat(c.data.actual," does not match expected type "),m+=c.data.expected.join(" or "),new TypeError(m)}throw c}};return t(e,[])}var rc="diff",E0=["typed","matrix","subtract","number"],tc=R(rc,E0,e=>{var{typed:n,matrix:a,subtract:t,number:r}=e;return n(rc,{"Array | Matrix":function(s){return Oe(s)?a(l(s.toArray())):l(s)},"Array | Matrix, number":function(s,o){if(!Ae(o))throw new RangeError("Dimension must be a whole number");return Oe(s)?a(i(s.toArray(),o)):i(s,o)},"Array | Matrix, BigNumber":function(s,o){return this(s,r(o))}});function i(c,s){if(Oe(c)&&(c=c.toArray()),!Array.isArray(c))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var o=[];return c.forEach(u=>{o.push(i(u,s-1))}),o}else{if(s===0)return l(c);throw RangeError("Cannot have negative dimension")}}function l(c){var s=[],o=c.length;if(o<2)return c;for(var u=1;u<o;u++)s.push(m(c[u-1],c[u]));return s}function m(c,s){Oe(c)&&(c=c.toArray()),Oe(s)&&(s=s.toArray());var o=Array.isArray(c),u=Array.isArray(s);if(o&&u)return f(c,s);if(!o&&!u)return t(s,c);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function f(c,s){if(c.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var o=[],u=c.length,p=0;p<u;p++)o.push(m(c[p],s[p]));return o}}),C0="ones",O0=["typed","config","matrix","BigNumber"],D0=R(C0,O0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n("ones",{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(1):1;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){_e(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function ones must be positive integers")})}});function Ai(){throw new Error('No "bignumber" implementation available')}function nc(){throw new Error('No "fraction" implementation available')}function ac(){throw new Error('No "matrix" implementation available')}var ic="range",T0=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],oc=R(ic,T0,e=>{var{typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f}=e;return n(ic,{string:s,"string, boolean":s,"number, number":function(w,N){return c(o(w,N,1))},"number, number, number":function(w,N,g){return c(o(w,N,g))},"number, number, boolean":function(w,N,g){return c(g?u(w,N,1):o(w,N,1))},"number, number, number, boolean":function(w,N,g,y){return c(y?u(w,N,g):o(w,N,g))},"BigNumber, BigNumber":function(w,N){var g=w.constructor;return c(p(w,N,new g(1)))},"BigNumber, BigNumber, BigNumber":function(w,N,g){return c(p(w,N,g))},"BigNumber, BigNumber, boolean":function(w,N,g){var y=w.constructor;return c(g?v(w,N,new y(1)):p(w,N,new y(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(w,N,g,y){return c(y?v(w,N,g):p(w,N,g))}});function c(b){return a.matrix==="Matrix"?t?t(b):ac():b}function s(b,w){var N=h(b);if(!N)throw new SyntaxError('String "'+b+'" is no valid range');var g;return a.number==="BigNumber"?(r===void 0&&Ai(),g=w?v:p,c(g(r(N.start),r(N.end),r(N.step)))):(g=w?u:o,c(g(N.start,N.end,N.step)))}function o(b,w,N){var g=[],y=b;if(N>0)for(;i(y,w);)g.push(y),y+=N;else if(N<0)for(;m(y,w);)g.push(y),y+=N;return g}function u(b,w,N){var g=[],y=b;if(N>0)for(;l(y,w);)g.push(y),y+=N;else if(N<0)for(;f(y,w);)g.push(y),y+=N;return g}function p(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;i(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;m(x,w);)y.push(x),x=x.plus(N);return y}function v(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;l(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;f(x,w);)y.push(x),x=x.plus(N);return y}function h(b){var w=b.split(":"),N=w.map(function(y){return Number(y)}),g=N.some(function(y){return isNaN(y)});if(g)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),sc="reshape",B0=["typed","isInteger","matrix"],_0=R(sc,B0,e=>{var{typed:n,isInteger:a}=e;return n(sc,{"Matrix, Array":function(r,i){return r.reshape(i)},"Array, Array":function(r,i){return i.forEach(function(l){if(!a(l))throw new TypeError("Invalid size for dimension: "+l)}),ho(r,i)}})});function dn(e,n,a,t){if(!(this instanceof dn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=n,this.min=a,this.max=t,this.message="Wrong number of arguments in function "+e+" ("+n+" provided, "+a+(t!=null?"-"+t:"")+" expected)",this.stack=new Error().stack}dn.prototype=new Error,dn.prototype.constructor=Error,dn.prototype.name="ArgumentsError",dn.prototype.isArgumentsError=!0;var $0="resize",I0=["config","matrix"],q0=R($0,I0,e=>{var{config:n,matrix:a}=e;return function(i,l,m){if(arguments.length!==2&&arguments.length!==3)throw new dn("resize",arguments.length,2,3);if(Oe(l)&&(l=l.valueOf()),_e(l[0])&&(l=l.map(function(s){return _e(s)?s.toNumber():s})),Oe(i))return i.resize(l,m,!0);if(typeof i=="string")return t(i,l,m);var f=Array.isArray(i)?!1:n.matrix!=="Array";if(l.length===0){for(;Array.isArray(i);)i=i[0];return Ce(i)}else{Array.isArray(i)||(i=[i]),i=Ce(i);var c=on(i,l,m);return f?a(c):c}};function t(r,i,l){if(l!==void 0){if(typeof l!="string"||l.length!==1)throw new TypeError("Single character expected as defaultValue")}else l=" ";if(i.length!==1)throw new Fe(i.length,1);var m=i[0];if(typeof m!="number"||!Ae(m))throw new TypeError("Invalid size, must contain positive integers (size: "+Re(i)+")");if(r.length>m)return r.substring(0,m);if(r.length<m){for(var f=r,c=0,s=m-r.length;c<s;c++)f+=l;return f}else return r}}),uc="rotate",R0=["typed","multiply","rotationMatrix"],F0=R(uc,R0,e=>{var{typed:n,multiply:a,rotationMatrix:t}=e;return n(uc,{"Array , number | BigNumber | Complex | Unit":function(l,m){r(l,2);var f=a(t(m),l);return f.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(l,m){return r(l,2),a(t(m),l)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){r(l,3);var c=a(t(m,f),l);return c},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){return r(l,3),a(t(m,f),l)}});function r(i,l){var m=Array.isArray(i)?Pe(i):i.size();if(m.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m.length===2&&m[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m[0]!==l)throw new RangeError("Vector must be of dimensions 1x".concat(l))}}),cc="rotationMatrix",z0=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],P0=R(cc,z0,e=>{var{typed:n,config:a,multiplyScalar:t,addScalar:r,unaryMinus:i,norm:l,BigNumber:m,matrix:f,DenseMatrix:c,SparseMatrix:s,cos:o,sin:u}=e;return n(cc,{"":function(){return a.matrix==="Matrix"?f([]):[]},string:function(g){return f(g)},"number | BigNumber | Complex | Unit":function(g){return p(g,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(g,y){return p(g,y)},"number | BigNumber | Complex | Unit, Array":function(g,y){var x=f(y);return v(x),w(g,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(g,y){v(y);var x=y.storage()||(a.matrix==="Matrix"?"dense":void 0);return w(g,y,x)},"number | BigNumber | Complex | Unit, Array, string":function(g,y,x){var d=f(y);return v(d),w(g,d,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(g,y,x){return v(y),w(g,y,x)}});function p(N,g){var y=_e(N),x=y?new m(-1):-1,d=o(N),A=u(N),S=[[d,t(x,A)],[A,d]];return b(S,g)}function v(N){var g=N.size();if(g.length<1||g[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(N){return N.reduce((g,y)=>t(g,y))}function b(N,g){if(g){if(g==="sparse")return new s(N);if(g==="dense")return new c(N);throw new TypeError('Unknown matrix type "'.concat(g,'"'))}return N}function w(N,g,y){var x=l(g);if(x===0)throw new RangeError("Rotation around zero vector");var d=_e(N)?m:null,A=d?new d(1):1,S=d?new d(-1):-1,O=d?new d(g.get([0])/x):g.get([0])/x,M=d?new d(g.get([1])/x):g.get([1])/x,_=d?new d(g.get([2])/x):g.get([2])/x,E=o(N),$=r(A,i(E)),z=u(N),I=r(E,h([O,O,$])),T=r(h([O,M,$]),h([S,_,z])),B=r(h([O,_,$]),h([M,z])),G=r(h([O,M,$]),h([_,z])),D=r(E,h([M,M,$])),H=r(h([M,_,$]),h([S,O,z])),W=r(h([O,_,$]),h([S,M,z])),j=r(h([M,_,$]),h([O,z])),V=r(E,h([_,_,$])),K=[[I,T,B],[G,D,H],[W,j,V]];return b(K,y)}}),fc="row",U0=["typed","Index","matrix","range"],lc=R(fc,U0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(fc,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[0]);var f=r(0,l.size()[1]),c=new a(m,f);return l.subset(c)}}),mc="size",L0=["typed","config","?matrix"],k0=R(mc,L0,e=>{var{typed:n,config:a,matrix:t}=e;return n(mc,{Matrix:function(i){return i.create(i.size())},Array:Pe,string:function(i){return a.matrix==="Array"?[i.length]:t([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return a.matrix==="Array"?[]:t?t([]):ac()}})}),pc="squeeze",H0=["typed","matrix"],G0=R(pc,H0,e=>{var{typed:n,matrix:a}=e;return n(pc,{Array:function(r){return aa(Ce(r))},Matrix:function(r){var i=aa(r.toArray());return Array.isArray(i)?a(i):i},any:function(r){return Ce(r)}})}),vc="subset",V0=["typed","matrix"],hc=R(vc,V0,e=>{var{typed:n,matrix:a}=e;return n(vc,{"Array, Index":function(r,i){var l=a(r),m=l.subset(i);return i.isScalar()?m:m.valueOf()},"Matrix, Index":function(r,i){return r.subset(i)},"Object, Index":X0,"string, Index":Z0,"Array, Index, any":function(r,i,l){return a(Ce(r)).subset(i,l,void 0).valueOf()},"Array, Index, any, any":function(r,i,l,m){return a(Ce(r)).subset(i,l,m).valueOf()},"Matrix, Index, any":function(r,i,l){return r.clone().subset(i,l)},"Matrix, Index, any, any":function(r,i,l,m){return r.clone().subset(i,l,m)},"string, Index, string":dc,"string, Index, string, string":dc,"Object, Index, any":Y0})});function Z0(e,n){if(!En(n))throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);var a=e.length;We(n.min()[0],a),We(n.max()[0],a);var t=n.dimension(0),r="";return t.forEach(function(i){r+=e.charAt(i)}),r}function dc(e,n,a,t){if(!n||n.isIndex!==!0)throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);if(t!==void 0){if(typeof t!="string"||t.length!==1)throw new TypeError("Single character expected as defaultValue")}else t=" ";var r=n.dimension(0),i=r.size()[0];if(i!==a.length)throw new Fe(r.size()[0],a.length);var l=e.length;We(n.min()[0]),We(n.max()[0]);for(var m=[],f=0;f<l;f++)m[f]=e.charAt(f);if(r.forEach(function(o,u){m[o]=a.charAt(u[0])}),m.length>l)for(var c=l-1,s=m.length;c<s;c++)m[c]||(m[c]=t);return m.join("")}function X0(e,n){if(n.size().length!==1)throw new Fe(n.size(),1);var a=n.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");return Vr(e,a)}function Y0(e,n,a){if(n.size().length!==1)throw new Fe(n.size(),1);var t=n.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");var r=Ce(e);return un(r,t,a),r}var W0="transpose",J0=["typed","matrix"],Q0=R(W0,J0,e=>{var{typed:n,matrix:a}=e;return n("transpose",{Array:function(l){return this(a(l)).valueOf()},Matrix:function(l){var m=l.size(),f;switch(m.length){case 1:f=l.clone();break;case 2:{var c=m[0],s=m[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Re(m)+")");switch(l.storage()){case"dense":f=t(l,c,s);break;case"sparse":f=r(l,c,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Re(this._size)+")")}return f},any:function(l){return Ce(l)}});function t(i,l,m){for(var f=i._data,c=[],s,o=0;o<m;o++){s=c[o]=[];for(var u=0;u<l;u++)s[u]=Ce(f[u][o])}return i.createDenseMatrix({data:c,size:[m,l],datatype:i._datatype})}function r(i,l,m){for(var f=i._values,c=i._index,s=i._ptr,o=f?[]:void 0,u=[],p=[],v=[],h=0;h<l;h++)v[h]=0;var b,w,N;for(b=0,w=c.length;b<w;b++)v[c[b]]++;for(var g=0,y=0;y<l;y++)p.push(g),g+=v[y],v[y]=p[y];for(p.push(g),N=0;N<m;N++)for(var x=s[N],d=s[N+1],A=x;A<d;A++){var S=v[c[A]]++;u[S]=N,f&&(o[S]=Ce(f[A]))}return i.createSparseMatrix({values:o,index:u,ptr:p,size:[m,l],datatype:i._datatype})}}),gc="ctranspose",K0=["typed","transpose","conj"],j0=R(gc,K0,e=>{var{typed:n,transpose:a,conj:t}=e;return n(gc,{any:function(i){return t(a(i))}})}),yc="zeros",e1=["typed","config","matrix","BigNumber"],r1=R(yc,e1,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(yc,{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(0):0;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){_e(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function zeros must be positive integers")})}}),xc="fft",t1=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],n1=R(xc,t1,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,divideScalar:i,exp:l,tau:m,i:f}=e;return n(xc,{Array:c,Matrix:function(p){return p.create(c(p.toArray()))}});function c(u){var p=Pe(u);return p.length===1?o(u,p[0]):s(u.map(v=>c(v,p.slice(1))),0)}function s(u,p){var v=Pe(u);if(p!==0)return new Array(v[0]).fill(0).map((b,w)=>s(u[w],p-1));if(v.length===1)return o(u);function h(b){var w=Pe(b);return new Array(w[1]).fill(0).map((N,g)=>new Array(w[0]).fill(0).map((y,x)=>b[x][g]))}return h(s(h(u),1))}function o(u){var p=u.length;if(p===1)return[u[0]];if(p%2===0){for(var v=[...o(u.filter((N,g)=>g%2===0)),...o(u.filter((N,g)=>g%2===1))],h=0;h<p/2;h++){var b=v[h],w=r(v[h+p/2],l(r(r(m,f),i(-h,p))));v[h]=t(b,w),v[h+p/2]=t(b,r(-1,w))}return v}throw new Error("Can only calculate FFT of power-of-two size")}}),bc="ifft",a1=["typed","fft","dotDivide","conj"],i1=R(bc,a1,e=>{var{typed:n,fft:a,dotDivide:t,conj:r}=e;return n(bc,{"Array | Matrix":function(l){var m=Oe(l)?l.size():Pe(l);return t(r(a(r(l))),m.reduce((f,c)=>f*c,1))}})}),o1="erf",s1=["typed"],u1=R(o1,s1,e=>{var{typed:n}=e;return n("name",{number:function(l){var m=Math.abs(l);return m>=l1?Dt(l):m<=c1?Dt(l)*a(m):m<=4?Dt(l)*(1-t(m)):Dt(l)*(1-r(m))},"Array | Matrix":function(l){return be(l,this)}});function a(i){var l=i*i,m=Nt[0][4]*l,f=l,c;for(c=0;c<3;c+=1)m=(m+Nt[0][c])*l,f=(f+gn[0][c])*l;return i*(m+Nt[0][3])/(f+gn[0][3])}function t(i){var l=Nt[1][8]*i,m=i,f;for(f=0;f<7;f+=1)l=(l+Nt[1][f])*i,m=(m+gn[1][f])*i;var c=(l+Nt[1][7])/(m+gn[1][7]),s=parseInt(i*16)/16,o=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-o)*c}function r(i){var l=1/(i*i),m=Nt[2][5]*l,f=l,c;for(c=0;c<4;c+=1)m=(m+Nt[2][c])*l,f=(f+gn[2][c])*l;var s=l*(m+Nt[2][4])/(f+gn[2][4]);s=(f1-s)/i,l=parseInt(i*16)/16;var o=(i-l)*(i+l);return Math.exp(-l*l)*Math.exp(-o)*s}}),c1=.46875,f1=.5641895835477563,Nt=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],gn=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],l1=Math.pow(2,53),wc="mode",m1=["typed","isNaN","isNumeric"],p1=R(wc,m1,e=>{var{typed:n,isNaN:a,isNumeric:t}=e;return n(wc,{"Array | Matrix":r,"...":function(l){return r(l)}});function r(i){i=Le(i.valueOf());var l=i.length;if(l===0)throw new Error("Cannot calculate mode of an empty array");for(var m={},f=[],c=0,s=0;s<i.length;s++){var o=i[s];if(t(o)&&a(o))throw new Error("Cannot calculate mode of an array containing NaN values");o in m||(m[o]=0),m[o]++,m[o]===c?f.push(o):m[o]>c&&(c=m[o],f=[o])}return f}});function Tr(e,n,a){var t;return String(e).indexOf("Unexpected type")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+n+", unexpected type of argument"+t)):String(e).indexOf("complex numbers")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":"",new TypeError("Cannot calculate "+n+", no ordering relation is defined for complex numbers"+t)):e}var Nc="prod",v1=["typed","config","multiplyScalar","numeric"],h1=R(Nc,v1,e=>{var{typed:n,config:a,multiplyScalar:t,numeric:r}=e;return n(Nc,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(m,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(m){return i(m)}});function i(l){var m;if(bt(l,function(f){try{m=m===void 0?f:t(m,f)}catch(c){throw Tr(c,"prod",f)}}),typeof m=="string"&&(m=r(m,a.number)),m===void 0)throw new Error("Cannot calculate prod of an empty array");return m}}),Mc="format",d1=["typed"],g1=R(Mc,d1,e=>{var{typed:n}=e;return n(Mc,{any:Re,"any, Object | function | number":Re})}),Ac="bin",y1=["typed","format"],x1=R(Ac,y1,e=>{var{typed:n,format:a}=e;return n(Ac,{"number | BigNumber":function(r){return a(r,{notation:"bin"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"bin",wordSize:i})}})}),Sc="oct",b1=["typed","format"],w1=R(Sc,b1,e=>{var{typed:n,format:a}=e;return n(Sc,{"number | BigNumber":function(r){return a(r,{notation:"oct"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"oct",wordSize:i})}})}),Ec="hex",N1=["typed","format"],M1=R(Ec,N1,e=>{var{typed:n,format:a}=e;return n(Ec,{"number | BigNumber":function(r){return a(r,{notation:"hex"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"hex",wordSize:i})}})}),Cc="print",A1=["typed"],S1=R(Cc,A1,e=>{var{typed:n}=e;return n(Cc,{"string, Object | Array":Oc,"string, Object | Array, number | Object":Oc})});function Oc(e,n,a){return e.replace(/\$([\w.]+)/g,function(t,r){for(var i=r.split("."),l=n[i.shift()];i.length&&l!==void 0;){var m=i.shift();l=m?l[m]:l+"."}return l!==void 0?_r(l)?l:Re(l,a):t})}var Dc="to",E1=["typed","matrix"],C1=R(Dc,E1,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Dc,{"Unit, Unit | string":function(l,m){return l.to(m)},"Matrix, Matrix":function(l,m){return t(l,m,this)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"Matrix, any":function(l,m){return r(l,m,this,!1)},"any, Matrix":function(l,m){return r(m,l,this,!0)},"Array, any":function(l,m){return r(a(l),m,this,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,this,!0).valueOf()}})}),Tc="isPrime",O1=["typed"],D1=R(Tc,O1,e=>{var{typed:n}=e;return n(Tc,{number:function(t){if(t*0!==0)return!1;if(t<=3)return t>1;if(t%2===0||t%3===0)return!1;for(var r=5;r*r<=t;r+=6)if(t%r===0||t%(r+2)===0)return!1;return!0},BigNumber:function(t){if(t.toNumber()*0!==0)return!1;if(t.lte(3))return t.gt(1);if(t.mod(2).eq(0)||t.mod(3).eq(0))return!1;if(t.lt(Math.pow(2,32))){for(var r=t.toNumber(),i=5;i*i<=r;i+=6)if(r%i===0||r%(i+2)===0)return!1;return!0}function l(N,g,y){for(var x=1;!g.eq(0);)g.mod(2).eq(0)?(g=g.div(2),N=N.mul(N).mod(y)):(g=g.sub(1),x=N.mul(x).mod(y));return x}var m=t.constructor.clone({precision:t.toFixed(0).length*2});t=new m(t);for(var f=0,c=t.sub(1);c.mod(2).eq(0);)c=c.div(2),f+=1;var s=null;if(t.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<t);else{var o=Math.min(t.toNumber()-2,Math.floor(2*Math.pow(t.toFixed(0).length*Math.log(10),2)));s=[];for(var u=2;u<=o;u+=1)s.push(o)}for(var p=0;p<s.length;p+=1){var v=s[p],h=l(t.sub(t).add(v),c,t);if(!h.eq(1)){for(var b=0,w=h;!w.eq(t.sub(1));b+=1,w=w.mul(w).mod(t))if(b===f-1)return!1}}return!0},"Array | Matrix":function(t){return be(t,this)}})}),T1="numeric",B1=["number","?bignumber","?fraction"],_1=R(T1,B1,e=>{var{number:n,bignumber:a,fraction:t}=e,r={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:l=>n(l),BigNumber:a?l=>a(l):Ai,Fraction:t?l=>t(l):nc};return function(m,f){var c=Ke(m);if(!(c in r))throw new TypeError("Cannot convert "+m+' of type "'+c+'"; valid input types are '+Object.keys(r).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+m+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===c?m:i[f](m)}}),Bc="divideScalar",$1=["typed","numeric"],I1=R(Bc,$1,e=>{var{typed:n,numeric:a}=e;return n(Bc,{"number, number":function(r,i){return r/i},"Complex, Complex":function(r,i){return r.div(i)},"BigNumber, BigNumber":function(r,i){return r.div(i)},"Fraction, Fraction":function(r,i){return r.div(i)},"Unit, number | Fraction | BigNumber":function(r,i){var l=r.clone(),m=a(1,Ke(i));return l.value=this(l.value===null?l._normalize(m):l.value,i),l},"number | Fraction | BigNumber, Unit":function(r,i){var l=i.clone();l=l.pow(-1);var m=a(1,Ke(r));return l.value=this(r,i.value===null?i._normalize(m):i.value),l},"Unit, Unit":function(r,i){return r.divide(i)}})}),_c="pow",q1=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],R1=R(_c,q1,e=>{var{typed:n,config:a,identity:t,multiply:r,matrix:i,inv:l,number:m,fraction:f,Complex:c}=e;return n(_c,{"number, number":s,"Complex, Complex":function(v,h){return v.pow(h)},"BigNumber, BigNumber":function(v,h){return h.isInteger()||v>=0||a.predictable?v.pow(h):new c(v.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(v,h){var b=v.pow(h);if(b!=null)return b;if(a.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return s(v.valueOf(),h.valueOf())},"Array, number":o,"Array, BigNumber":function(v,h){return o(v,h.toNumber())},"Matrix, number":u,"Matrix, BigNumber":function(v,h){return u(v,h.toNumber())},"Unit, number | BigNumber":function(v,h){return v.pow(h)}});function s(p,v){if(a.predictable&&!Ae(v)&&p<0)try{var h=f(v),b=m(h);if((v===b||Math.abs((v-b)/v)<1e-14)&&h.d%2===1)return(h.n%2===0?1:-1)*Math.pow(-p,v)}catch(w){}return a.predictable&&(p<-1&&v===1/0||p>-1&&p<0&&v===-1/0)?NaN:Ae(v)||p>=0||a.predictable?us(p,v):p*p<1&&v===1/0||p*p>1&&v===-1/0?0:new c(p,0).pow(v,0)}function o(p,v){if(!Ae(v))throw new TypeError("For A^b, b must be an integer (value is "+v+")");var h=Pe(p);if(h.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+h.length+" dimensions)");if(h[0]!==h[1])throw new Error("For A^b, A must be square (size is "+h[0]+"x"+h[1]+")");if(v<0)try{return o(l(p),-v)}catch(N){throw N.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 "+v+")"):N}for(var b=t(h[0]).valueOf(),w=p;v>=1;)(v&1)===1&&(b=r(w,b)),v>>=1,w=r(w,w);return b}function u(p,v){return i(o(p.valueOf(),v))}}),yn="Number of decimals in function round must be an integer",$c="round",F1=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],z1=R($c,F1,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,BigNumber:i,DenseMatrix:l}=e,m=wr({typed:n,equalScalar:t}),f=gr({typed:n,DenseMatrix:l}),c=Ge({typed:n});return n($c,{number:cs,"number, number":cs,"number, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return new i(o).toDecimalPlaces(u.toNumber())},Complex:function(o){return o.round()},"Complex, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Complex, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);var p=u.toNumber();return o.round(p)},BigNumber:function(o){return o.toDecimalPlaces(0)},"BigNumber, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.toDecimalPlaces(u.toNumber())},Fraction:function(o){return o.round()},"Fraction, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Fraction, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.round(u.toNumber())},"Array | Matrix":function(o){return be(o,this)},"SparseMatrix, number | BigNumber":function(o,u){return m(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return c(o,u,this,!1)},"Array, number | BigNumber":function(o,u){return c(a(o),u,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):f(u,o,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):c(u,o,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Ic="log",P1=["config","typed","divideScalar","Complex"],U1=R(Ic,P1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e;return n(Ic,{number:function(l){return l>=0||a.predictable?Xh(l):new r(l,0).log()},Complex:function(l){return l.log()},BigNumber:function(l){return!l.isNegative()||a.predictable?l.ln():new r(l.toNumber(),0).log()},"Array | Matrix":function(l){return be(l,this)},"any, any":function(l,m){return t(this(l),this(m))}})}),qc="log1p",L1=["typed","config","divideScalar","log","Complex"],k1=R(qc,L1,e=>{var{typed:n,config:a,divideScalar:t,log:r,Complex:i}=e;return n(qc,{number:function(f){return f>=-1||a.predictable?Gp(f):l(new i(f,0))},Complex:l,BigNumber:function(f){var c=f.plus(1);return!c.isNegative()||a.predictable?c.ln():l(new i(f.toNumber(),0))},"Array | Matrix":function(f){return be(f,this)},"any, any":function(f,c){return t(this(f),r(c))}});function l(m){var f=m.re+1;return new i(Math.log(Math.sqrt(f*f+m.im*m.im)),Math.atan2(m.im,f))}}),Rc="nthRoots",H1=["config","typed","divideScalar","Complex"],G1=R(Rc,H1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e,i=[function(f){return new r(f,0)},function(f){return new r(0,f)},function(f){return new r(-f,0)},function(f){return new r(0,-f)}];function l(m,f){if(f<0)throw new Error("Root must be greater than zero");if(f===0)throw new Error("Root must be non-zero");if(f%1!==0)throw new Error("Root must be an integer");if(m===0||m.abs()===0)return[new r(0,0)];var c=typeof m=="number",s;(c||m.re===0||m.im===0)&&(c?s=2*+(m<0):m.im===0?s=2*+(m.re<0):s=2*+(m.im<0)+1);for(var o=m.arg(),u=m.abs(),p=[],v=Math.pow(u,1/f),h=0;h<f;h++){var b=(s+4*h)/f;if(b===Math.round(b)){p.push(i[b%4](v));continue}p.push(new r({r:v,phi:(o+2*Math.PI*h)/f}))}return p}return n(Rc,{Complex:function(f){return l(f,2)},"Complex, number":l})}),Fc="dotPow",V1=["typed","equalScalar","matrix","pow","DenseMatrix"],Z1=R(Fc,V1,e=>{var{typed:n,equalScalar:a,matrix:t,pow:r,DenseMatrix:i}=e,l=Dr({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=wr({typed:n,equalScalar:a}),c=gr({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(Fc,{"any, any":r,"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,r,!1)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,r,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,r,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,r)},"Array, Array":function(p,v){return this(t(p),t(v)).valueOf()},"Array, Matrix":function(p,v){return this(t(p),v)},"Matrix, Array":function(p,v){return this(p,t(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(t(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(t(v),p,this,!0).valueOf()}})}),zc="dotDivide",X1=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],Y1=R(zc,X1,e=>{var{typed:n,matrix:a,equalScalar:t,divideScalar:r,DenseMatrix:i}=e,l=rt({typed:n,equalScalar:t}),m=Dr({typed:n}),f=ut({typed:n,DenseMatrix:i}),c=wr({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(zc,{"any, any":r,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,r,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,r,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,r,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,r)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return c(v,h,r,!1)},"DenseMatrix, any":function(v,h){return u(v,h,r,!1)},"any, SparseMatrix":function(v,h){return s(h,v,r,!0)},"any, DenseMatrix":function(v,h){return u(h,v,r,!0)},"Array, any":function(v,h){return u(a(v),h,r,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,r,!0).valueOf()}})});function Rn(e){var{DenseMatrix:n}=e;return function(t,r,i){var l=t.size();if(l.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Re(l)+")");var m=l[0],f=l[1];if(m!==f)throw new RangeError("Matrix must be square (size: "+Re(l)+")");var c=[];if(Oe(r)){var s=r.size(),o=r._data;if(s.length===1){if(s[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var u=0;u<m;u++)c[u]=[o[u]];return new n({data:c,size:[m,1],datatype:r._datatype})}if(s.length===2){if(s[0]!==m||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(Qn(r)){if(i){c=[];for(var p=0;p<m;p++)c[p]=[o[p][0]];return new n({data:c,size:[m,1],datatype:r._datatype})}return r}if(Ut(r)){for(var v=0;v<m;v++)c[v]=[0];for(var h=r._values,b=r._index,w=r._ptr,N=w[1],g=w[0];g<N;g++){var y=b[g];c[y][0]=h[g]}return new n({data:c,size:[m,1],datatype:r._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(Xe(r)){var x=Pe(r);if(x.length===1){if(x[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var d=0;d<m;d++)c[d]=[r[d]];return new n({data:c,size:[m,1]})}if(x.length===2){if(x[0]!==m||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var A=0;A<m;A++)c[A]=[r[A][0]];return new n({data:c,size:[m,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Pc="lsolve",W1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],J1=R(Pc,W1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Pc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=0;N<h;N++){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N+1;d<v;d++)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=0;y<h;y++){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=O;_<M;_++){var E=w[_];E===y?d=b[_]:E>y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0]||0,r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),Uc="usolve",Q1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],K1=R(Uc,Q1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Uc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=h-1;N>=0;N--){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N-1;d>=0;d--)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=h-1;y>=0;y--){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=M-1;_>=O;_--){var E=w[_];E===y?d=b[_]:E<y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0],r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),Lc="lsolveAll",j1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ex=R(Lc,j1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Lc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=0;w<b;w++)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w+1;A<b;A++)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w+1;x<b;x++)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=0;g<h;g++)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=O;E<M;E++){var $=w[E];$===g?_=b[E]:$>g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),kc="usolveAll",rx=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],tx=R(kc,rx,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(kc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=b-1;w>=0;w--)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w-1;A>=0;A--)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w-1;x>=0;x--)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=h-1;g>=0;g--)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=M-1;E>=O;E--){var $=w[E];$===g?_=b[E]:$<g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),nx="algorithm08",ax=["typed","equalScalar"],Si=R(nx,ax,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");if(!m||!u)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));for(var A=[],S=[],O=[],M=[],_=[],E,$,z,I,T=0;T<N;T++){O[T]=S.length;var B=T+1;for($=c[T],z=c[T+1],E=$;E<z;E++)I=f[E],_[I]=B,M[I]=m[E],S.push(I);for($=v[T],z=v[T+1],E=$;E<z;E++)I=p[E],_[I]===B&&(M[I]=d(M[I],u[E]));for(E=O[T];E<S.length;){I=S[E];var G=M[I];y(G,x)?S.splice(E,1):(A.push(G),E++)}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Hc="leftShift",ix=["typed","matrix","equalScalar","zeros","DenseMatrix"],ox=R(Hc,ix,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Hc,{"number, number":vs,"BigNumber, BigNumber":Oy,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Gc="rightArithShift",sx=["typed","matrix","equalScalar","zeros","DenseMatrix"],ux=R(Gc,sx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Gc,{"number, number":hs,"BigNumber, BigNumber":Dy,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Vc="rightLogShift",cx=["typed","matrix","equalScalar","zeros","DenseMatrix"],fx=R(Vc,cx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Vc,{"number, number":ds,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Zc="and",lx=["typed","matrix","equalScalar","zeros","not"],mx=R(Zc,lx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,not:i}=e,l=rt({typed:n,equalScalar:t}),m=Sa({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n});return n(Zc,{"number, number":ws,"Complex, Complex":function(u,p){return(u.re!==0||u.im!==0)&&(p.re!==0||p.im!==0)},"BigNumber, BigNumber":function(u,p){return!u.isZero()&&!p.isZero()&&!u.isNaN()&&!p.isNaN()},"Unit, Unit":function(u,p){return this(u.value||0,p.value||0)},"SparseMatrix, SparseMatrix":function(u,p){return m(u,p,this,!1)},"SparseMatrix, DenseMatrix":function(u,p){return l(p,u,this,!0)},"DenseMatrix, SparseMatrix":function(u,p){return l(u,p,this,!1)},"DenseMatrix, DenseMatrix":function(u,p){return c(u,p,this)},"Array, Array":function(u,p){return this(a(u),a(p)).valueOf()},"Array, Matrix":function(u,p){return this(a(u),p)},"Matrix, Array":function(u,p){return this(u,a(p))},"SparseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):f(u,p,this,!1)},"DenseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):s(u,p,this,!1)},"any, SparseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):f(p,u,this,!0)},"any, DenseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):s(p,u,this,!0)},"Array, any":function(u,p){return this(a(u),p).valueOf()},"any, Array":function(u,p){return this(u,a(p)).valueOf()}})}),Xc="compare",px=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],vx=R(Xc,px,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,BigNumber:i,Fraction:l,DenseMatrix:m}=e,f=Dr({typed:n}),c=Ea({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:m}),o=je({typed:n}),u=Ge({typed:n});return n(Xc,{"boolean, boolean":function(v,h){return v===h?0:v>h?1:-1},"number, number":function(v,h){return Rr(v,h,a.epsilon)?0:v>h?1:-1},"BigNumber, BigNumber":function(v,h){return st(v,h,a.epsilon)?new i(0):new i(v.cmp(h))},"Fraction, Fraction":function(v,h){return new l(v.compare(h))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(v,h){if(!v.equalBase(h))throw new Error("Cannot compare units with different base");return this(v.value,h.value)},"SparseMatrix, SparseMatrix":function(v,h){return c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(r(v),r(h)).valueOf()},"Array, Matrix":function(v,h){return this(r(v),h)},"Matrix, Array":function(v,h){return this(v,r(h))},"SparseMatrix, any":function(v,h){return s(v,h,this,!1)},"DenseMatrix, any":function(v,h){return u(v,h,this,!1)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(r(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(r(h),v,this,!0).valueOf()}})}),Ei,Yc;function hx(){return Yc||(Yc=1,Ei=function e(n,a){var t=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,r=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,m=/^0/,f=function(g){return e.insensitive&&(""+g).toLowerCase()||""+g},c=f(n).replace(r,"")||"",s=f(a).replace(r,"")||"",o=c.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),u=s.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=parseInt(c.match(l),16)||o.length!==1&&c.match(i)&&Date.parse(c),v=parseInt(s.match(l),16)||p&&s.match(i)&&Date.parse(s)||null,h,b;if(v){if(p<v)return-1;if(p>v)return 1}for(var w=0,N=Math.max(o.length,u.length);w<N;w++){if(h=!(o[w]||"").match(m)&&parseFloat(o[w])||o[w]||0,b=!(u[w]||"").match(m)&&parseFloat(u[w])||u[w]||0,isNaN(h)!==isNaN(b))return isNaN(h)?1:-1;if(typeof h!=typeof b&&(h+="",b+=""),h<b)return-1;if(h>b)return 1}return 0}),Ei}var dx=hx();const xn=Tn(dx);var Wc="compareNatural",gx=["typed","compare"],yx=R(Wc,gx,e=>{var{typed:n,compare:a}=e,t=a.signatures["boolean,boolean"];return n(Wc,{"any, any":function(f,c){var s=Ke(f),o=Ke(c),u;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(o==="number"||o==="BigNumber"||o==="Fraction"))return u=a(f,c),u.toString()!=="0"?u>0?1:-1:xn(s,o);if(s==="Array"||s==="Matrix"||o==="Array"||o==="Matrix")return u=r(this,f,c),u!==0?u:xn(s,o);if(s!==o)return xn(s,o);if(s==="Complex")return xx(f,c);if(s==="Unit")return f.equalBase(c)?this(f.value,c.value):i(this,f.formatUnits(),c.formatUnits());if(s==="boolean")return t(f,c);if(s==="string")return xn(f,c);if(s==="Object")return l(this,f,c);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}});function r(m,f,c){return Ut(f)&&Ut(c)?i(m,f.toJSON().values,c.toJSON().values):Ut(f)?r(m,f.toArray(),c):Ut(c)?r(m,f,c.toArray()):Qn(f)?r(m,f.toJSON().data,c):Qn(c)?r(m,f,c.toJSON().data):Array.isArray(f)?Array.isArray(c)?i(m,f,c):r(m,f,[c]):r(m,[f],c)}function i(m,f,c){for(var s=0,o=Math.min(f.length,c.length);s<o;s++){var u=m(f[s],c[s]);if(u!==0)return u}return f.length>c.length?1:f.length<c.length?-1:0}function l(m,f,c){var s=Object.keys(f),o=Object.keys(c);s.sort(xn),o.sort(xn);var u=i(m,s,o);if(u!==0)return u;for(var p=0;p<s.length;p++){var v=m(f[s[p]],c[o[p]]);if(v!==0)return v}return 0}});function xx(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0}var Jc="compareText",bx=["typed","matrix"],wx=R(Jc,bx,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Jc,{"any, any":an,"DenseMatrix, DenseMatrix":function(l,m){return t(l,m,an)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"DenseMatrix, any":function(l,m){return r(l,m,an,!1)},"any, DenseMatrix":function(l,m){return r(m,l,an,!0)},"Array, any":function(l,m){return r(a(l),m,an,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,an,!0).valueOf()}})}),Da="equal",Nx=["typed","matrix","equalScalar","DenseMatrix"],Mx=R(Da,Nx,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Da,{"any, any":function(o,u){return o===null?u===null:u===null?o===null:o===void 0?u===void 0:u===void 0?o===void 0:t(o,u)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,t)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,t,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,t,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,t)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,t,!1)},"DenseMatrix, any":function(o,u){return c(o,u,t,!1)},"any, SparseMatrix":function(o,u){return m(u,o,t,!0)},"any, DenseMatrix":function(o,u){return c(u,o,t,!0)},"Array, any":function(o,u){return c(a(o),u,t,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,t,!0).valueOf()}})});R(Da,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Da,{"any, any":function(r,i){return r===null?i===null:i===null?r===null:r===void 0?i===void 0:i===void 0?r===void 0:a(r,i)}})});var Qc="equalText",Ax=["typed","compareText","isZero"],Sx=R(Qc,Ax,e=>{var{typed:n,compareText:a,isZero:t}=e;return n(Qc,{"any, any":function(i,l){return t(a(i,l))}})}),Kc="smaller",Ex=["typed","config","matrix","DenseMatrix"],Cx=R(Kc,Ex,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Kc,{"boolean, boolean":function(o,u){return o<u},"number, number":function(o,u){return o<u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===-1},"Complex, Complex":function(o,u){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),jc="smallerEq",Ox=["typed","config","matrix","DenseMatrix"],Dx=R(jc,Ox,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(jc,{"boolean, boolean":function(o,u){return o<=u},"number, number":function(o,u){return o<=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),ef="larger",Tx=["typed","config","matrix","DenseMatrix"],Bx=R(ef,Tx,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(ef,{"boolean, boolean":function(o,u){return o>u},"number, number":function(o,u){return o>u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),rf="largerEq",_x=["typed","config","matrix","DenseMatrix"],$x=R(rf,_x,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(rf,{"boolean, boolean":function(o,u){return o>=u},"number, number":function(o,u){return o>=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==-1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),tf="deepEqual",Ix=["typed","equal"],qx=R(tf,Ix,e=>{var{typed:n,equal:a}=e;return n(tf,{"any, any":function(i,l){return t(i.valueOf(),l.valueOf())}});function t(r,i){if(Array.isArray(r))if(Array.isArray(i)){var l=r.length;if(l!==i.length)return!1;for(var m=0;m<l;m++)if(!t(r[m],i[m]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:a(r,i)}}),Ci="unequal",Rx=["typed","config","equalScalar","matrix","DenseMatrix"],Fx=R(Ci,Rx,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,DenseMatrix:i}=e,l=Dr({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=gr({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n("unequal",{"any, any":function(p,v){return p===null?v!==null:v===null?p!==null:p===void 0?v!==void 0:v===void 0?p!==void 0:o(p,v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,o)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,o,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,o,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,o)},"Array, Array":function(p,v){return this(r(p),r(v)).valueOf()},"Array, Matrix":function(p,v){return this(r(p),v)},"Matrix, Array":function(p,v){return this(p,r(v))},"SparseMatrix, any":function(p,v){return f(p,v,o,!1)},"DenseMatrix, any":function(p,v){return s(p,v,o,!1)},"any, SparseMatrix":function(p,v){return f(v,p,o,!0)},"any, DenseMatrix":function(p,v){return s(v,p,o,!0)},"Array, any":function(p,v){return s(r(p),v,o,!1).valueOf()},"any, Array":function(p,v){return s(r(v),p,o,!0).valueOf()}});function o(u,p){return!t(u,p)}});R(Ci,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Ci,{"any, any":function(r,i){return r===null?i!==null:i===null?r!==null:r===void 0?i!==void 0:i===void 0?r!==void 0:!a(r,i)}})});var nf="partitionSelect",zx=["typed","isNumeric","isNaN","compare"],Px=R(nf,zx,e=>{var{typed:n,isNumeric:a,isNaN:t,compare:r}=e,i=r,l=(c,s)=>-r(c,s);return n(nf,{"Array | Matrix, number":function(s,o){return m(s,o,i)},"Array | Matrix, number, string":function(s,o,u){if(u==="asc")return m(s,o,i);if(u==="desc")return m(s,o,l);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":m});function m(c,s,o){if(!Ae(s)||s<0)throw new Error("k must be a non-negative integer");if(Oe(c)){var u=c.size();if(u.length>1)throw new Error("Only one dimensional matrices supported");return f(c.valueOf(),s,o)}if(Array.isArray(c))return f(c,s,o)}function f(c,s,o){if(s>=c.length)throw new Error("k out of bounds");for(var u=0;u<c.length;u++)if(a(c[u])&&t(c[u]))return c[u];for(var p=0,v=c.length-1;p<v;){for(var h=p,b=v,w=c[Math.floor(Math.random()*(v-p+1))+p];h<b;)if(o(c[h],w)>=0){var N=c[b];c[b]=c[h],c[h]=N,--b}else++h;o(c[h],w)>0&&--h,s<=h?v=h:p=h+1}return c[s]}}),af="sort",Ux=["typed","matrix","compare","compareNatural"],Lx=R(af,Ux,e=>{var{typed:n,matrix:a,compare:t,compareNatural:r}=e,i=t,l=(s,o)=>-t(s,o);return n(af,{Array:function(o){return f(o),o.sort(i)},Matrix:function(o){return c(o),a(o.toArray().sort(i),o.storage())},"Array, function":function(o,u){return f(o),o.sort(u)},"Matrix, function":function(o,u){return c(o),a(o.toArray().sort(u),o.storage())},"Array, string":function(o,u){return f(o),o.sort(m(u))},"Matrix, string":function(o,u){return c(o),a(o.toArray().sort(m(u)),o.storage())}});function m(s){if(s==="asc")return i;if(s==="desc")return l;if(s==="natural")return r;throw new Error('String "asc", "desc", or "natural" expected')}function f(s){if(Pe(s).length!==1)throw new Error("One dimensional array expected")}function c(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),of="max",kx=["typed","config","numeric","larger"],sf=R(of,kx,e=>{var{typed:n,config:a,numeric:t,larger:r}=e;return n(of,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return xa(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function max");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Tr(c,"max",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Tr(s,"max",c)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),uf="min",Hx=["typed","config","numeric","smaller"],cf=R(uf,Hx,e=>{var{typed:n,config:a,numeric:t,smaller:r}=e;return n(uf,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return xa(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function min");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Tr(c,"min",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Tr(s,"min",c)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),Gx="ImmutableDenseMatrix",Vx=["smaller","DenseMatrix"],Zx=R(Gx,Vx,e=>{var{smaller:n,DenseMatrix:a}=e;function t(r,i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!_r(i))throw new Error("Invalid datatype: "+i);if(Oe(r)||Xe(r)){var l=new a(r,i);this._data=l._data,this._size=l._size,this._datatype=l._datatype,this._min=null,this._max=null}else if(r&&Xe(r.data)&&Xe(r.size))this._data=r.data,this._size=r.size,this._datatype=r.datatype,this._min=typeof r.min!="undefined"?r.min:null,this._max=typeof r.max!="undefined"?r.max:null;else{if(r)throw new TypeError("Unsupported type of data ("+Ke(r)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return t.prototype=new a,t.prototype.type="ImmutableDenseMatrix",t.prototype.isImmutableDenseMatrix=!0,t.prototype.subset=function(r){switch(arguments.length){case 1:{var i=a.prototype.subset.call(this,r);return Oe(i)?new t({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},t.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},t.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},t.prototype.clone=function(){return new t({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype})},t.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.fromJSON=function(r){return new t(r)},t.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},t.prototype.min=function(){if(this._min===null){var r=null;this.forEach(function(i){(r===null||n(i,r))&&(r=i)}),this._min=r!==null?r:void 0}return this._min},t.prototype.max=function(){if(this._max===null){var r=null;this.forEach(function(i){(r===null||n(r,i))&&(r=i)}),this._max=r!==null?r:void 0}return this._max},t},{isClass:!0}),Xx="Index",Yx=["ImmutableDenseMatrix"],Wx=R(Xx,Yx,e=>{var{ImmutableDenseMatrix:n}=e;function a(r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,l=arguments.length;i<l;i++){var m=arguments[i];if(Kn(m))this._dimensions.push(m),this._isScalar=!1;else if(Array.isArray(m)||Oe(m)){var f=t(m.valueOf());this._dimensions.push(f);var c=f.size();(c.length!==1||c[0]!==1)&&(this._isScalar=!1)}else if(typeof m=="number")this._dimensions.push(t([m]));else if(typeof m=="string")this._dimensions.push(m);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}a.prototype.type="Index",a.prototype.isIndex=!0;function t(r){for(var i=0,l=r.length;i<l;i++)if(typeof r[i]!="number"||!Ae(r[i]))throw new TypeError("Index parameters must be positive integer numbers");return new n(r)}return a.prototype.clone=function(){var r=new a;return r._dimensions=Ce(this._dimensions),r._isScalar=this._isScalar,r},a.create=function(r){var i=new a;return a.apply(i,r),i},a.prototype.size=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?1:m.size()[0]}return r},a.prototype.max=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.max()}return r},a.prototype.min=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.min()}return r},a.prototype.forEach=function(r){for(var i=0,l=this._dimensions.length;i<l;i++)r(this._dimensions[i],i,this)},a.prototype.dimension=function(r){return this._dimensions[r]||null},a.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},a.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},a.prototype.isScalar=function(){return this._isScalar},a.prototype.toArray=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r.push(typeof m=="string"?m:m.toArray())}return r},a.prototype.valueOf=a.prototype.toArray,a.prototype.toString=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];typeof m=="string"?r.push(JSON.stringify(m)):r.push(m.toString())}return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},a.fromJSON=function(r){return a.create(r.dimensions)},a},{isClass:!0}),Jx="FibonacciHeap",Qx=["smaller","larger"],Kx=R(Jx,Qx,e=>{var{smaller:n,larger:a}=e,t=1/Math.log((1+Math.sqrt(5))/2);function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}r.prototype.type="FibonacciHeap",r.prototype.isFibonacciHeap=!0,r.prototype.insert=function(s,o){var u={key:s,value:o,degree:0};if(this._minimum){var p=this._minimum;u.left=p,u.right=p.right,p.right=u,u.right.left=u,n(s,p.key)&&(this._minimum=u)}else u.left=u,u.right=u,this._minimum=u;return this._size++,u},r.prototype.size=function(){return this._size},r.prototype.clear=function(){this._minimum=null,this._size=0},r.prototype.isEmpty=function(){return this._size===0},r.prototype.extractMinimum=function(){var s=this._minimum;if(s===null)return s;for(var o=this._minimum,u=s.degree,p=s.child;u>0;){var v=p.right;p.left.right=p.right,p.right.left=p.left,p.left=o,p.right=o.right,o.right=p,p.right.left=p,p.parent=null,p=v,u--}return s.left.right=s.right,s.right.left=s.left,s===s.right?o=null:(o=s.right,o=c(o,this._size)),this._size--,this._minimum=o,s},r.prototype.remove=function(s){this._minimum=i(this._minimum,s,-1),this.extractMinimum()};function i(s,o,u){o.key=u;var p=o.parent;return p&&n(o.key,p.key)&&(l(s,o,p),m(s,p)),n(o.key,s.key)&&(s=o),s}function l(s,o,u){o.left.right=o.right,o.right.left=o.left,u.degree--,u.child===o&&(u.child=o.right),u.degree===0&&(u.child=null),o.left=s,o.right=s.right,s.right=o,o.right.left=o,o.parent=null,o.mark=!1}function m(s,o){var u=o.parent;u&&(o.mark?(l(s,o,u),m(u)):o.mark=!0)}var f=function(o,u){o.left.right=o.right,o.right.left=o.left,o.parent=u,u.child?(o.left=u.child,o.right=u.child.right,u.child.right=o,o.right.left=o):(u.child=o,o.right=o,o.left=o),u.degree++,o.mark=!1};function c(s,o){var u=Math.floor(Math.log(o)*t)+1,p=new Array(u),v=0,h=s;if(h)for(v++,h=h.right;h!==s;)v++,h=h.right;for(var b;v>0;){for(var w=h.degree,N=h.right;b=p[w],!!b;){if(a(h.key,b.key)){var g=b;b=h,h=g}f(b,h),p[w]=null,w++}p[w]=h,h=N,v--}s=null;for(var y=0;y<u;y++)b=p[y],b&&(s?(b.left.right=b.right,b.right.left=b.left,b.left=s,b.right=s.right,s.right=b,b.right.left=b,n(b.key,s.key)&&(s=b)):s=b);return s}return r},{isClass:!0}),jx="Spa",eb=["addScalar","equalScalar","FibonacciHeap"],rb=R(jx,eb,e=>{var{addScalar:n,equalScalar:a,FibonacciHeap:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new t}return r.prototype.type="Spa",r.prototype.isSpa=!0,r.prototype.set=function(i,l){if(this._values[i])this._values[i].value=l;else{var m=this._heap.insert(i,l);this._values[i]=m}},r.prototype.get=function(i){var l=this._values[i];return l?l.value:0},r.prototype.accumulate=function(i,l){var m=this._values[i];m?m.value=n(m.value,l):(m=this._heap.insert(i,l),this._values[i]=m)},r.prototype.forEach=function(i,l,m){var f=this._heap,c=this._values,s=[],o=f.extractMinimum();for(o&&s.push(o);o&&o.key<=l;)o.key>=i&&(a(o.value,0)||m(o.key,o.value,this)),o=f.extractMinimum(),o&&s.push(o);for(var u=0;u<s.length;u++){var p=s[u];o=f.insert(p.key,p.value),c[o.key]=o}},r.prototype.swap=function(i,l){var m=this._values[i],f=this._values[l];if(!m&&f)m=this._heap.insert(i,f.value),this._heap.remove(f),this._values[i]=m,this._values[l]=void 0;else if(m&&!f)f=this._heap.insert(l,m.value),this._heap.remove(m),this._values[l]=f,this._values[i]=void 0;else if(m&&f){var c=m.value;m.value=f.value,f.value=c}},r},{isClass:!0});function Fn(e){"@babel/helpers - typeof";return Fn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Fn(e)}function tb(e,n){if(Fn(e)!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var t=a.call(e,n);if(Fn(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function nb(e){var n=tb(e,"string");return Fn(n)=="symbol"?n:n+""}function ff(e,n,a){return(n=nb(n))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}var ab=qn(function(e){return new e(1).exp()},{hasher:Ta}),ib=qn(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Ta}),Oi=qn(function(e){return e.acos(-1)},{hasher:Ta}),ob=qn(function(e){return Oi(e).times(2)},{hasher:Ta});function Ta(e){return e[0].precision}function lf(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),a.push.apply(a,t)}return a}function Di(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?lf(Object(a),!0).forEach(function(t){ff(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):lf(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var sb="Unit",ub=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],cb=R(sb,ub,e=>{var{on:n,config:a,addScalar:t,subtract:r,multiplyScalar:i,divideScalar:l,pow:m,abs:f,fix:c,round:s,equal:o,isNumeric:u,format:p,number:v,Complex:h,BigNumber:b,Fraction:w}=e,N=v;function g(F,Y){if(!(this instanceof g))throw new Error("Constructor must be called with the new operator");if(!(F==null||u(F)||Or(F)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(Y!==void 0&&(typeof Y!="string"||Y===""))throw new TypeError("Second parameter in Unit constructor must be a string");if(Y!==void 0){var k=g.parse(Y);this.units=k.units,this.dimensions=k.dimensions}else{this.units=[{unit:j,prefix:B.NONE,power:0}],this.dimensions=[];for(var U=0;U<G.length;U++)this.dimensions[U]=0}this.value=F!=null?this._normalize(F):null,this.fixPrefix=!1,this.skipAutomaticSimplification=!0}g.prototype.type="Unit",g.prototype.isUnit=!0;var y,x,d;function A(){for(;d===" "||d===" ";)M()}function S(F){return F>="0"&&F<="9"||F==="."}function O(F){return F>="0"&&F<="9"}function M(){x++,d=y.charAt(x)}function _(F){x=F,d=y.charAt(x)}function E(){var F="",Y=x;if(d==="+"?M():d==="-"&&(F+=d,M()),!S(d))return _(Y),null;if(d==="."){if(F+=d,M(),!O(d))return _(Y),null}else{for(;O(d);)F+=d,M();d==="."&&(F+=d,M())}for(;O(d);)F+=d,M();if(d==="E"||d==="e"){var k="",U=x;if(k+=d,M(),(d==="+"||d==="-")&&(k+=d,M()),!O(d))return _(U),F;for(F=F+k;O(d);)F+=d,M()}return F}function $(){for(var F="";O(d)||g.isValidAlpha(d);)F+=d,M();var Y=F.charAt(0);return g.isValidAlpha(Y)?F:null}function z(F){return d===F?(M(),F):null}g.parse=function(F,Y){if(Y=Y||{},y=F,x=-1,d="",typeof y!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var k=new g;k.units=[];var U=1,J=!1;M(),A();var q=E(),P=null;if(q){if(a.number==="BigNumber")P=new b(q);else if(a.number==="Fraction")try{P=new w(q)}catch(cr){P=parseFloat(q)}else P=parseFloat(q);A(),z("*")?(U=1,J=!0):z("/")&&(U=-1,J=!0)}for(var Q=[],L=1;;){for(A();d==="(";)Q.push(U),L*=U,U=1,M(),A();var se=void 0;if(d){var fe=d;if(se=$(),se===null)throw new SyntaxError('Unexpected "'+fe+'" in "'+y+'" at index '+x.toString())}else break;var ge=I(se);if(ge===null)throw new SyntaxError('Unit "'+se+'" not found.');var pe=U*L;if(A(),z("^")){A();var ve=E();if(ve===null)throw new SyntaxError('In "'+F+'", "^" must be followed by a floating-point number');pe*=ve}k.units.push({unit:ge.unit,prefix:ge.prefix,power:pe});for(var Ne=0;Ne<G.length;Ne++)k.dimensions[Ne]+=(ge.unit.dimensions[Ne]||0)*pe;for(A();d===")";){if(Q.length===0)throw new SyntaxError('Unmatched ")" in "'+y+'" at index '+x.toString());L/=Q.pop(),M(),A()}if(J=!1,z("*")?(U=1,J=!0):z("/")?(U=-1,J=!0):U=1,ge.unit.base){var Qe=ge.unit.base.key;re.auto[Qe]={unit:ge.unit,prefix:ge.prefix}}}if(A(),d)throw new SyntaxError('Could not parse: "'+F+'"');if(J)throw new SyntaxError('Trailing characters: "'+F+'"');if(Q.length!==0)throw new SyntaxError('Unmatched "(" in "'+y+'"');if(k.units.length===0&&!Y.allowNoUnits)throw new SyntaxError('"'+F+'" contains no units');return k.value=P!==void 0?k._normalize(P):null,k},g.prototype.clone=function(){var F=new g;F.fixPrefix=this.fixPrefix,F.skipAutomaticSimplification=this.skipAutomaticSimplification,F.value=Ce(this.value),F.dimensions=this.dimensions.slice(0),F.units=[];for(var Y=0;Y<this.units.length;Y++){F.units[Y]={};for(var k in this.units[Y])Me(this.units[Y],k)&&(F.units[Y][k]=this.units[Y][k])}return F},g.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},g.prototype._normalize=function(F){if(F==null||this.units.length===0)return F;for(var Y=F,k=g._getNumberConverter(Ke(F)),U=0;U<this.units.length;U++){var J=k(this.units[U].unit.value),q=k(this.units[U].prefix.value),P=k(this.units[U].power);Y=i(Y,m(i(J,q),P))}return Y},g.prototype._denormalize=function(F,Y){if(F==null||this.units.length===0)return F;for(var k=F,U=g._getNumberConverter(Ke(F)),J=0;J<this.units.length;J++){var q=U(this.units[J].unit.value),P=U(this.units[J].prefix.value),Q=U(this.units[J].power);k=l(k,m(i(q,P),Q))}return k};var I=qn(F=>{if(Me(V,F)){var Y=V[F],k=Y.prefixes[""];return{unit:Y,prefix:k}}for(var U in V)if(Me(V,U)&&sv(F,U)){var J=V[U],q=F.length-U.length,P=F.substring(0,q),Q=Me(J.prefixes,P)?J.prefixes[P]:void 0;if(Q!==void 0)return{unit:J,prefix:Q}}return null},{hasher:F=>F[0],limit:100});g.isValuelessUnit=function(F){return I(F)!==null},g.prototype.hasBase=function(F){if(typeof F=="string"&&(F=D[F]),!F)return!1;for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equalBase=function(F){for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equals=function(F){return this.equalBase(F)&&o(this.value,F.value)},g.prototype.multiply=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)+(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Di({},F.units[U]);Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=i(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.divide=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)-(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Di(Di({},F.units[U]),{},{power:-F.units[U].power});Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=l(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.pow=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)*F;for(var U=0;U<Y.units.length;U++)Y.units[U].power*=F;return Y.value!==null?Y.value=m(Y.value,F):Y.value=null,Y.skipAutomaticSimplification=!1,T(Y)};function T(F){return F.equalBase(D.NONE)&&F.value!==null&&!a.predictable?F.value:F}g.prototype.abs=function(){var F=this.clone();if(F.value!==null)if(F._isDerived()||F.units[0].unit.offset===0)F.value=f(F.value);else{var Y=g._getNumberConverter(Ke(F.value)),k=Y(F.units[0].unit.value),U=Y(F.units[0].unit.offset),J=i(k,U);F.value=r(f(t(F.value,J)),J)}for(var q in F.units)(F.units[q].unit.name==="VA"||F.units[q].unit.name==="VAR")&&(F.units[q].unit=V.W);return F},g.prototype.to=function(F){var Y=this.value===null?this._normalize(1):this.value,k;if(typeof F=="string")k=g.parse(F);else if(ht(F))k=F.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(k))throw new Error("Units do not match ('".concat(k.toString(),"' != '").concat(this.toString(),"')"));if(k.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===k.units[0].unit.offset)k.value=Ce(Y);else{var U=g._getNumberConverter(Ke(Y)),J=U(this.units[0].unit.value),q=U(this.units[0].unit.offset),P=i(J,q),Q=U(k.units[0].unit.value),L=U(k.units[0].unit.offset),se=i(Q,L);k.value=r(t(Y,P),se)}return k.fixPrefix=!0,k.skipAutomaticSimplification=!0,k},g.prototype.toNumber=function(F){return N(this.toNumeric(F))},g.prototype.toNumeric=function(F){var Y;return F?Y=this.to(F):Y=this.clone(),Y._isDerived()||Y.units.length===0?Y._denormalize(Y.value):Y._denormalize(Y.value,Y.units[0].prefix.value)},g.prototype.toString=function(){return this.format()},g.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},g.fromJSON=function(F){var Y=new g(F.value,F.unit);return Y.fixPrefix=F.fixPrefix||!1,Y},g.prototype.valueOf=g.prototype.toString,g.prototype.simplify=function(){var F=this.clone(),Y=[],k;for(var U in ie)if(Me(ie,U)&&F.hasBase(D[U])){k=U;break}if(k==="NONE")F.units=[];else{var J;if(k&&Me(ie,k)&&(J=ie[k]),J)F.units=[{unit:J.unit,prefix:J.prefix,power:1}];else{for(var q=!1,P=0;P<G.length;P++){var Q=G[P];Math.abs(F.dimensions[P]||0)>1e-12&&(Me(ie,Q)?Y.push({unit:ie[Q].unit,prefix:ie[Q].prefix,power:F.dimensions[P]||0}):q=!0)}Y.length<F.units.length&&!q&&(F.units=Y)}}return F},g.prototype.toSI=function(){for(var F=this.clone(),Y=[],k=0;k<G.length;k++){var U=G[k];if(Math.abs(F.dimensions[k]||0)>1e-12)if(Me(re.si,U))Y.push({unit:re.si[U].unit,prefix:re.si[U].prefix,power:F.dimensions[k]||0});else throw new Error("Cannot express custom unit "+U+" in SI units")}return F.units=Y,F.fixPrefix=!0,F.skipAutomaticSimplification=!0,F},g.prototype.formatUnits=function(){for(var F="",Y="",k=0,U=0,J=0;J<this.units.length;J++)this.units[J].power>0?(k++,F+=" "+this.units[J].prefix.name+this.units[J].unit.name,Math.abs(this.units[J].power-1)>1e-15&&(F+="^"+this.units[J].power)):this.units[J].power<0&&U++;if(U>0)for(var q=0;q<this.units.length;q++)this.units[q].power<0&&(k>0?(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Math.abs(this.units[q].power+1)>1e-15&&(Y+="^"+-this.units[q].power)):(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Y+="^"+this.units[q].power));F=F.substr(1),Y=Y.substr(1),k>1&&U>0&&(F="("+F+")"),U>1&&k>0&&(Y="("+Y+")");var P=F;return k>0&&U>0&&(P+=" / "),P+=Y,P},g.prototype.format=function(F){var Y=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),k=!1;typeof Y.value!="undefined"&&Y.value!==null&&Or(Y.value)&&(k=Math.abs(Y.value.re)<1e-14);for(var U in Y.units)Me(Y.units,U)&&Y.units[U].unit&&(Y.units[U].unit.name==="VA"&&k?Y.units[U].unit=V.VAR:Y.units[U].unit.name==="VAR"&&!k&&(Y.units[U].unit=V.VA));Y.units.length===1&&!Y.fixPrefix&&Math.abs(Y.units[0].power-Math.round(Y.units[0].power))<1e-14&&(Y.units[0].prefix=Y._bestPrefix());var J=Y._denormalize(Y.value),q=Y.value!==null?p(J,F||{}):"",P=Y.formatUnits();return Y.value&&Or(Y.value)&&(q="("+q+")"),P.length>0&&q.length>0&&(q+=" "),q+=P,q},g.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var F=this.value!==null?f(this.value):0,Y=f(this.units[0].unit.value),k=this.units[0].prefix;if(F===0)return k;var U=this.units[0].power,J=Math.log(F/Math.pow(k.value*Y,U))/Math.LN10-1.2;if(J>-2.200001&&J<1.800001)return k;J=Math.abs(J);var q=this.units[0].unit.prefixes;for(var P in q)if(Me(q,P)){var Q=q[P];if(Q.scientific){var L=Math.abs(Math.log(F/Math.pow(Q.value*Y,U))/Math.LN10-1.2);(L<J||L===J&&Q.name.length<k.name.length)&&(k=Q,J=L)}}return k},g.prototype.splitUnit=function(F){for(var Y=this.clone(),k=[],U=0;U<F.length&&(Y=Y.to(F[U]),U!==F.length-1);U++){var J=Y.toNumeric(),q=s(J),P=void 0,Q=o(q,J);Q?P=q:P=c(Y.toNumeric());var L=new g(P,F[U].toString());k.push(L),Y=r(Y,L)}for(var se=0,fe=0;fe<k.length;fe++)se=t(se,k[fe].value);return o(se,this.value)&&(Y.value=0),k.push(Y),k};var B={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};B.SHORTLONG=ar({},B.SHORT,B.LONG),B.BINARY_SHORT=ar({},B.BINARY_SHORT_SI,B.BINARY_SHORT_IEC),B.BINARY_LONG=ar({},B.BINARY_LONG_SI,B.BINARY_LONG_IEC);var G=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],D={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var H in D)Me(D,H)&&(D[H].key=H);var W={},j={name:"",base:W,value:1,offset:0,dimensions:G.map(F=>0)},V={meter:{name:"meter",base:D.LENGTH,prefixes:B.LONG,value:1,offset:0},inch:{name:"inch",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},foot:{name:"foot",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yard:{name:"yard",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mile:{name:"mile",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},link:{name:"link",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rod:{name:"rod",base:D.LENGTH,prefixes:B.NONE,value:5.0292,offset:0},chain:{name:"chain",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:D.LENGTH,prefixes:B.NONE,value:1e-10,offset:0},m:{name:"m",base:D.LENGTH,prefixes:B.SHORT,value:1,offset:0},in:{name:"in",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},ft:{name:"ft",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yd:{name:"yd",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mi:{name:"mi",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},li:{name:"li",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rd:{name:"rd",base:D.LENGTH,prefixes:B.NONE,value:5.02921,offset:0},ch:{name:"ch",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},mil:{name:"mil",base:D.LENGTH,prefixes:B.NONE,value:254e-7,offset:0},m2:{name:"m2",base:D.SURFACE,prefixes:B.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:D.SURFACE,prefixes:B.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:D.SURFACE,prefixes:B.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:D.SURFACE,prefixes:B.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:D.SURFACE,prefixes:B.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:D.SURFACE,prefixes:B.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:D.SURFACE,prefixes:B.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:D.SURFACE,prefixes:B.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:D.SURFACE,prefixes:B.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:D.SURFACE,prefixes:B.NONE,value:1e4,offset:0},m3:{name:"m3",base:D.VOLUME,prefixes:B.CUBIC,value:1,offset:0},L:{name:"L",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},l:{name:"l",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},litre:{name:"litre",base:D.VOLUME,prefixes:B.LONG,value:.001,offset:0},cuin:{name:"cuin",base:D.VOLUME,prefixes:B.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:D.VOLUME,prefixes:B.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:D.VOLUME,prefixes:B.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:D.VOLUME,prefixes:B.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:D.VOLUME,prefixes:B.NONE,value:15e-6,offset:0},drop:{name:"drop",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},minim:{name:"minim",base:D.VOLUME,prefixes:B.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:D.VOLUME,prefixes:B.NONE,value:1e-6,offset:0},cup:{name:"cup",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:D.VOLUME,prefixes:B.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},obl:{name:"obl",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},g:{name:"g",base:D.MASS,prefixes:B.SHORT,value:.001,offset:0},gram:{name:"gram",base:D.MASS,prefixes:B.LONG,value:.001,offset:0},ton:{name:"ton",base:D.MASS,prefixes:B.SHORT,value:907.18474,offset:0},t:{name:"t",base:D.MASS,prefixes:B.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:D.MASS,prefixes:B.LONG,value:1e3,offset:0},grain:{name:"grain",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},stick:{name:"stick",base:D.MASS,prefixes:B.NONE,value:.115,offset:0},stone:{name:"stone",base:D.MASS,prefixes:B.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},s:{name:"s",base:D.TIME,prefixes:B.SHORT,value:1,offset:0},min:{name:"min",base:D.TIME,prefixes:B.NONE,value:60,offset:0},h:{name:"h",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},second:{name:"second",base:D.TIME,prefixes:B.LONG,value:1,offset:0},sec:{name:"sec",base:D.TIME,prefixes:B.LONG,value:1,offset:0},minute:{name:"minute",base:D.TIME,prefixes:B.NONE,value:60,offset:0},hour:{name:"hour",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},day:{name:"day",base:D.TIME,prefixes:B.NONE,value:86400,offset:0},week:{name:"week",base:D.TIME,prefixes:B.NONE,value:7*86400,offset:0},month:{name:"month",base:D.TIME,prefixes:B.NONE,value:2629800,offset:0},year:{name:"year",base:D.TIME,prefixes:B.NONE,value:31557600,offset:0},decade:{name:"decade",base:D.TIME,prefixes:B.NONE,value:315576e3,offset:0},century:{name:"century",base:D.TIME,prefixes:B.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:D.TIME,prefixes:B.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:D.FREQUENCY,prefixes:B.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:D.FREQUENCY,prefixes:B.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:D.ANGLE,prefixes:B.SHORT,value:1,offset:0},radian:{name:"radian",base:D.ANGLE,prefixes:B.LONG,value:1,offset:0},deg:{name:"deg",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},degree:{name:"degree",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},grad:{name:"grad",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},gradian:{name:"gradian",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},cycle:{name:"cycle",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},A:{name:"A",base:D.CURRENT,prefixes:B.SHORT,value:1,offset:0},ampere:{name:"ampere",base:D.CURRENT,prefixes:B.LONG,value:1,offset:0},K:{name:"K",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},degC:{name:"degC",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},degF:{name:"degF",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},celsius:{name:"celsius",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.SHORT,value:1,offset:0},mole:{name:"mole",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.LONG,value:1,offset:0},cd:{name:"cd",base:D.LUMINOUS_INTENSITY,prefixes:B.SHORT,value:1,offset:0},candela:{name:"candela",base:D.LUMINOUS_INTENSITY,prefixes:B.LONG,value:1,offset:0},N:{name:"N",base:D.FORCE,prefixes:B.SHORT,value:1,offset:0},newton:{name:"newton",base:D.FORCE,prefixes:B.LONG,value:1,offset:0},dyn:{name:"dyn",base:D.FORCE,prefixes:B.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:D.FORCE,prefixes:B.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:D.FORCE,prefixes:B.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:D.FORCE,prefixes:B.NONE,value:9.80665,offset:0},J:{name:"J",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},joule:{name:"joule",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},erg:{name:"erg",base:D.ENERGY,prefixes:B.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:D.ENERGY,prefixes:B.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:D.ENERGY,prefixes:B.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:D.ENERGY,prefixes:B.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:D.ENERGY,prefixes:B.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},watt:{name:"watt",base:D.POWER,prefixes:B.LONG,value:1,offset:0},hp:{name:"hp",base:D.POWER,prefixes:B.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:D.POWER,prefixes:B.SHORT,value:h.I,offset:0},VA:{name:"VA",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},Pa:{name:"Pa",base:D.PRESSURE,prefixes:B.SHORT,value:1,offset:0},psi:{name:"psi",base:D.PRESSURE,prefixes:B.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:D.PRESSURE,prefixes:B.NONE,value:101325,offset:0},bar:{name:"bar",base:D.PRESSURE,prefixes:B.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:D.PRESSURE,prefixes:B.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:D.PRESSURE,prefixes:B.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:D.ELECTRIC_CHARGE,prefixes:B.LONG,value:1,offset:0},C:{name:"C",base:D.ELECTRIC_CHARGE,prefixes:B.SHORT,value:1,offset:0},farad:{name:"farad",base:D.ELECTRIC_CAPACITANCE,prefixes:B.LONG,value:1,offset:0},F:{name:"F",base:D.ELECTRIC_CAPACITANCE,prefixes:B.SHORT,value:1,offset:0},volt:{name:"volt",base:D.ELECTRIC_POTENTIAL,prefixes:B.LONG,value:1,offset:0},V:{name:"V",base:D.ELECTRIC_POTENTIAL,prefixes:B.SHORT,value:1,offset:0},ohm:{name:"ohm",base:D.ELECTRIC_RESISTANCE,prefixes:B.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:D.ELECTRIC_INDUCTANCE,prefixes:B.LONG,value:1,offset:0},H:{name:"H",base:D.ELECTRIC_INDUCTANCE,prefixes:B.SHORT,value:1,offset:0},siemens:{name:"siemens",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.LONG,value:1,offset:0},S:{name:"S",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.SHORT,value:1,offset:0},weber:{name:"weber",base:D.MAGNETIC_FLUX,prefixes:B.LONG,value:1,offset:0},Wb:{name:"Wb",base:D.MAGNETIC_FLUX,prefixes:B.SHORT,value:1,offset:0},tesla:{name:"tesla",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.LONG,value:1,offset:0},T:{name:"T",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.SHORT,value:1,offset:0},b:{name:"b",base:D.BIT,prefixes:B.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:D.BIT,prefixes:B.BINARY_LONG,value:1,offset:0},B:{name:"B",base:D.BIT,prefixes:B.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:D.BIT,prefixes:B.BINARY_LONG,value:8,offset:0}},K={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function te(F){if(F.number==="BigNumber"){var Y=Oi(b);V.rad.value=new b(1),V.deg.value=Y.div(180),V.grad.value=Y.div(200),V.cycle.value=Y.times(2),V.arcsec.value=Y.div(648e3),V.arcmin.value=Y.div(10800)}else V.rad.value=1,V.deg.value=Math.PI/180,V.grad.value=Math.PI/200,V.cycle.value=Math.PI*2,V.arcsec.value=Math.PI/648e3,V.arcmin.value=Math.PI/10800;V.radian.value=V.rad.value,V.degree.value=V.deg.value,V.gradian.value=V.grad.value}te(a),n&&n("config",function(F,Y){F.number!==Y.number&&te(F)});var re={si:{NONE:{unit:j,prefix:B.NONE[""]},LENGTH:{unit:V.m,prefix:B.SHORT[""]},MASS:{unit:V.g,prefix:B.SHORT.k},TIME:{unit:V.s,prefix:B.SHORT[""]},CURRENT:{unit:V.A,prefix:B.SHORT[""]},TEMPERATURE:{unit:V.K,prefix:B.SHORT[""]},LUMINOUS_INTENSITY:{unit:V.cd,prefix:B.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:V.mol,prefix:B.SHORT[""]},ANGLE:{unit:V.rad,prefix:B.SHORT[""]},BIT:{unit:V.bits,prefix:B.SHORT[""]},FORCE:{unit:V.N,prefix:B.SHORT[""]},ENERGY:{unit:V.J,prefix:B.SHORT[""]},POWER:{unit:V.W,prefix:B.SHORT[""]},PRESSURE:{unit:V.Pa,prefix:B.SHORT[""]},ELECTRIC_CHARGE:{unit:V.C,prefix:B.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:V.F,prefix:B.SHORT[""]},ELECTRIC_POTENTIAL:{unit:V.V,prefix:B.SHORT[""]},ELECTRIC_RESISTANCE:{unit:V.ohm,prefix:B.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:V.H,prefix:B.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:V.S,prefix:B.SHORT[""]},MAGNETIC_FLUX:{unit:V.Wb,prefix:B.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:V.T,prefix:B.SHORT[""]},FREQUENCY:{unit:V.Hz,prefix:B.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:V.m,prefix:B.SHORT.c},re.cgs.MASS={unit:V.g,prefix:B.SHORT[""]},re.cgs.FORCE={unit:V.dyn,prefix:B.SHORT[""]},re.cgs.ENERGY={unit:V.erg,prefix:B.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:V.ft,prefix:B.NONE[""]},re.us.MASS={unit:V.lbm,prefix:B.NONE[""]},re.us.TEMPERATURE={unit:V.degF,prefix:B.NONE[""]},re.us.FORCE={unit:V.lbf,prefix:B.NONE[""]},re.us.ENERGY={unit:V.BTU,prefix:B.BTU[""]},re.us.POWER={unit:V.hp,prefix:B.NONE[""]},re.us.PRESSURE={unit:V.psi,prefix:B.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var ie=re.auto;g.setUnitSystem=function(F){if(Me(re,F))ie=re[F];else throw new Error("Unit system "+F+" does not exist. Choices are: "+Object.keys(re).join(", "))},g.getUnitSystem=function(){for(var F in re)if(Me(re,F)&&re[F]===ie)return F},g.typeConverters={BigNumber:function(Y){return new b(Y+"")},Fraction:function(Y){return new w(Y)},Complex:function(Y){return Y},number:function(Y){return Y}},g._getNumberConverter=function(F){if(!g.typeConverters[F])throw new TypeError('Unsupported type "'+F+'"');return g.typeConverters[F]};for(var ne in V)if(Me(V,ne)){var ue=V[ne];ue.dimensions=ue.base.dimensions}for(var ee in K)if(Me(K,ee)){var ye=V[K[ee]],we={};for(var me in ye)Me(ye,me)&&(we[me]=ye[me]);we.name=ee,V[ee]=we}g.isValidAlpha=function(Y){return/^[a-zA-Z]$/.test(Y)};function xe(F){for(var Y=0;Y<F.length;Y++){if(d=F.charAt(Y),Y===0&&!g.isValidAlpha(d))throw new Error('Invalid unit name (must begin with alpha character): "'+F+'"');if(Y>0&&!(g.isValidAlpha(d)||O(d)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+F+'"')}}return g.createUnit=function(F,Y){if(typeof F!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Y&&Y.override){for(var k in F)if(Me(F,k)&&g.deleteUnit(k),F[k].aliases)for(var U=0;U<F[k].aliases.length;U++)g.deleteUnit(F[k].aliases[U])}var J;for(var q in F)Me(F,q)&&(J=g.createUnitSingle(q,F[q]));return J},g.createUnitSingle=function(F,Y,k){if((typeof Y=="undefined"||Y===null)&&(Y={}),typeof F!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Me(V,F))throw new Error('Cannot create unit "'+F+'": a unit with that name already exists');xe(F);var U=null,J=[],q=0,P,Q,L;if(Y&&Y.type==="Unit")U=Y.clone();else if(typeof Y=="string")Y!==""&&(P=Y);else if(typeof Y=="object")P=Y.definition,Q=Y.prefixes,q=Y.offset,L=Y.baseName,Y.aliases&&(J=Y.aliases.valueOf());else throw new TypeError('Cannot create unit "'+F+'" from "'+Y.toString()+'": expecting "string" or "Unit" or "Object"');if(J){for(var se=0;se<J.length;se++)if(Me(V,J[se]))throw new Error('Cannot create alias "'+J[se]+'": a unit with that name already exists')}if(P&&typeof P=="string"&&!U)try{U=g.parse(P,{allowNoUnits:!0})}catch(C){throw C.message='Could not create unit "'+F+'" from "'+P+'": '+C.message,C}else P&&P.type==="Unit"&&(U=P.clone());J=J||[],q=q||0,Q&&Q.toUpperCase?Q=B[Q.toUpperCase()]||B.NONE:Q=B.NONE;var fe={};if(U){fe={name:F,value:U.value,dimensions:U.dimensions.slice(0),prefixes:Q,offset:q};var Ne=!1;for(var Qe in D)if(Me(D,Qe)){for(var cr=!0,tr=0;tr<G.length;tr++)if(Math.abs((fe.dimensions[tr]||0)-(D[Qe].dimensions[tr]||0))>1e-12){cr=!1;break}if(cr){Ne=!0,fe.base=D[Qe];break}}if(!Ne){L=L||F+"_STUFF";var Jr={dimensions:U.dimensions.slice(0)};Jr.key=L,D[L]=Jr,ie[L]={unit:fe,prefix:B.NONE[""]},fe.base=D[L]}}else{if(L=L||F+"_STUFF",G.indexOf(L)>=0)throw new Error('Cannot create new base unit "'+F+'": a base unit with that name already exists (and cannot be overridden)');G.push(L);for(var ge in D)Me(D,ge)&&(D[ge].dimensions[G.length-1]=0);for(var pe={dimensions:[]},ve=0;ve<G.length;ve++)pe.dimensions[ve]=0;pe.dimensions[G.length-1]=1,pe.key=L,D[L]=pe,fe={name:F,value:1,dimensions:D[L].dimensions.slice(0),prefixes:Q,offset:q,base:D[L]},ie[L]={unit:fe,prefix:B.NONE[""]}}g.UNITS[F]=fe;for(var Lr=0;Lr<J.length;Lr++){var Ot=J[Lr],Ze={};for(var Pt in fe)Me(fe,Pt)&&(Ze[Pt]=fe[Pt]);Ze.name=Ot,g.UNITS[Ot]=Ze}return delete I.cache,new g(null,F)},g.deleteUnit=function(F){delete g.UNITS[F]},g.PREFIXES=B,g.BASE_DIMENSIONS=G,g.BASE_UNITS=D,g.UNIT_SYSTEMS=re,g.UNITS=V,g},{isClass:!0}),mf="unit",fb=["typed","Unit"],lb=R(mf,fb,e=>{var{typed:n,Unit:a}=e;return n(mf,{Unit:function(r){return r.clone()},string:function(r){return a.isValuelessUnit(r)?new a(null,r):a.parse(r,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(r,i){return new a(r,i)},"Array | Matrix":function(r){return be(r,this)}})}),pf="sparse",mb=["typed","SparseMatrix"],pb=R(pf,mb,e=>{var{typed:n,SparseMatrix:a}=e;return n(pf,{"":function(){return new a([])},string:function(r){return new a([],r)},"Array | Matrix":function(r){return new a(r)},"Array | Matrix, string":function(r,i){return new a(r,i)}})}),vf="createUnit",vb=["typed","Unit"],hb=R(vf,vb,e=>{var{typed:n,Unit:a}=e;return n(vf,{"Object, Object":function(r,i){return a.createUnit(r,i)},Object:function(r){return a.createUnit(r,{})},"string, Unit | string | Object, Object":function(r,i,l){var m={};return m[r]=i,a.createUnit(m,l)},"string, Unit | string | Object":function(r,i){var l={};return l[r]=i,a.createUnit(l,{})},string:function(r){var i={};return i[r]={},a.createUnit(i,{})}})}),hf="acos",db=["typed","config","Complex"],gb=R(hf,db,e=>{var{typed:n,config:a,Complex:t}=e;return n(hf,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.acos(i):new t(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()},"Array | Matrix":function(i){return be(i,this)}})}),df="acosh",yb=["typed","config","Complex"],xb=R(df,yb,e=>{var{typed:n,config:a,Complex:t}=e;return n(df,{number:function(i){return i>=1||a.predictable?Ss(i):i<=-1?new t(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new t(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()},"Array | Matrix":function(i){return be(i,this)}})}),gf="acot",bb=["typed","BigNumber"],wb=R(gf,bb,e=>{var{typed:n,BigNumber:a}=e;return n(gf,{number:Es,Complex:function(r){return r.acot()},BigNumber:function(r){return new a(1).div(r).atan()},"Array | Matrix":function(r){return be(r,this)}})}),yf="acoth",Nb=["typed","config","Complex","BigNumber"],Mb=R(yf,Nb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(yf,{number:function(l){return l>=1||l<=-1||a.predictable?Cs(l):new t(l,0).acoth()},Complex:function(l){return l.acoth()},BigNumber:function(l){return new r(1).div(l).atanh()},"Array | Matrix":function(l){return be(l,this)}})}),xf="acsc",Ab=["typed","config","Complex","BigNumber"],Sb=R(xf,Ab,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(xf,{number:function(l){return l<=-1||l>=1||a.predictable?Os(l):new t(l,0).acsc()},Complex:function(l){return l.acsc()},BigNumber:function(l){return new r(1).div(l).asin()},"Array | Matrix":function(l){return be(l,this)}})}),bf="acsch",Eb=["typed","BigNumber"],Cb=R(bf,Eb,e=>{var{typed:n,BigNumber:a}=e;return n(bf,{number:Ds,Complex:function(r){return r.acsch()},BigNumber:function(r){return new a(1).div(r).asinh()},"Array | Matrix":function(r){return be(r,this)}})}),wf="asec",Ob=["typed","config","Complex","BigNumber"],Db=R(wf,Ob,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(wf,{number:function(l){return l<=-1||l>=1||a.predictable?Ts(l):new t(l,0).asec()},Complex:function(l){return l.asec()},BigNumber:function(l){return new r(1).div(l).acos()},"Array | Matrix":function(l){return be(l,this)}})}),Nf="asech",Tb=["typed","config","Complex","BigNumber"],Bb=R(Nf,Tb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(Nf,{number:function(l){if(l<=1&&l>=-1||a.predictable){var m=1/l;if(m>0||a.predictable)return Bs(l);var f=Math.sqrt(m*m-1);return new t(Math.log(f-m),Math.PI)}return new t(l,0).asech()},Complex:function(l){return l.asech()},BigNumber:function(l){return new r(1).div(l).acosh()},"Array | Matrix":function(l){return be(l,this)}})}),Mf="asin",_b=["typed","config","Complex"],$b=R(Mf,_b,e=>{var{typed:n,config:a,Complex:t}=e;return n(Mf,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.asin(i):new t(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()},"Array | Matrix":function(i){return be(i,this)}})}),Ib="asinh",qb=["typed"],Rb=R(Ib,qb,e=>{var{typed:n}=e;return n("asinh",{number:_s,Complex:function(t){return t.asinh()},BigNumber:function(t){return t.asinh()},"Array | Matrix":function(t){return be(t,this)}})}),Fb="atan",zb=["typed"],Pb=R(Fb,zb,e=>{var{typed:n}=e;return n("atan",{number:function(t){return Math.atan(t)},Complex:function(t){return t.atan()},BigNumber:function(t){return t.atan()},"Array | Matrix":function(t){return be(t,this)}})}),Af="atan2",Ub=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],Lb=R(Af,Ub,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=rt({typed:n,equalScalar:t}),m=Dr({typed:n}),f=Cu({typed:n,equalScalar:t}),c=wr({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(Af,{"number, number":Math.atan2,"BigNumber, BigNumber":function(v,h){return r.atan2(v,h)},"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return c(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return s(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return u(a(v),h,this,!1).valueOf()},"number | BigNumber, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})}),Sf="atanh",kb=["typed","config","Complex"],Hb=R(Sf,kb,e=>{var{typed:n,config:a,Complex:t}=e;return n(Sf,{number:function(i){return i<=1&&i>=-1||a.predictable?$s(i):new t(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()},"Array | Matrix":function(i){return be(i,this)}})}),Ef="cos",Gb=["typed"],Vb=R(Ef,Gb,e=>{var{typed:n}=e;return n(Ef,{number:Math.cos,Complex:function(t){return t.cos()},BigNumber:function(t){return t.cos()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Cf="cosh",Zb=["typed"],Xb=R(Cf,Zb,e=>{var{typed:n}=e;return n(Cf,{number:ev,Complex:function(t){return t.cosh()},BigNumber:function(t){return t.cosh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Of="cot",Yb=["typed","BigNumber"],Wb=R(Of,Yb,e=>{var{typed:n,BigNumber:a}=e;return n(Of,{number:Is,Complex:function(r){return r.cot()},BigNumber:function(r){return new a(1).div(r.tan())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Df="coth",Jb=["typed","BigNumber"],Qb=R(Df,Jb,e=>{var{typed:n,BigNumber:a}=e;return n(Df,{number:qs,Complex:function(r){return r.coth()},BigNumber:function(r){return new a(1).div(r.tanh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Tf="csc",Kb=["typed","BigNumber"],jb=R(Tf,Kb,e=>{var{typed:n,BigNumber:a}=e;return n(Tf,{number:Rs,Complex:function(r){return r.csc()},BigNumber:function(r){return new a(1).div(r.sin())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Bf="csch",ew=["typed","BigNumber"],rw=R(Bf,ew,e=>{var{typed:n,BigNumber:a}=e;return n(Bf,{number:Fs,Complex:function(r){return r.csch()},BigNumber:function(r){return new a(1).div(r.sinh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),_f="sec",tw=["typed","BigNumber"],nw=R(_f,tw,e=>{var{typed:n,BigNumber:a}=e;return n(_f,{number:zs,Complex:function(r){return r.sec()},BigNumber:function(r){return new a(1).div(r.cos())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),$f="sech",aw=["typed","BigNumber"],iw=R($f,aw,e=>{var{typed:n,BigNumber:a}=e;return n($f,{number:Ps,Complex:function(r){return r.sech()},BigNumber:function(r){return new a(1).div(r.cosh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),If="sin",ow=["typed"],sw=R(If,ow,e=>{var{typed:n}=e;return n(If,{number:Math.sin,Complex:function(t){return t.sin()},BigNumber:function(t){return t.sin()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),qf="sinh",uw=["typed"],cw=R(qf,uw,e=>{var{typed:n}=e;return n(qf,{number:Us,Complex:function(t){return t.sinh()},BigNumber:function(t){return t.sinh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Rf="tan",fw=["typed"],lw=R(Rf,fw,e=>{var{typed:n}=e;return n(Rf,{number:Math.tan,Complex:function(t){return t.tan()},BigNumber:function(t){return t.tan()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),mw="tanh",pw=["typed"],vw=R(mw,pw,e=>{var{typed:n}=e;return n("tanh",{number:tv,Complex:function(t){return t.tanh()},BigNumber:function(t){return t.tanh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ff="setCartesian",hw=["typed","size","subset","compareNatural","Index","DenseMatrix"],dw=R(Ff,hw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Ff,{"Array | Matrix, Array | Matrix":function(f,c){var s=[];if(t(a(f),new i(0))!==0&&t(a(c),new i(0))!==0){var o=Le(Array.isArray(f)?f:f.toArray()).sort(r),u=Le(Array.isArray(c)?c:c.toArray()).sort(r);s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)s.push([o[p],u[v]])}return Array.isArray(f)&&Array.isArray(c)?s:new l(s)}})}),zf="setDifference",gw=["typed","size","subset","compareNatural","Index","DenseMatrix"],yw=R(zf,gw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(zf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0)s=[];else{if(t(a(c),new i(0))===0)return Le(f.toArray());var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p,v=0;v<o.length;v++){p=!1;for(var h=0;h<u.length;h++)if(r(o[v].value,u[h].value)===0&&o[v].identifier===u[h].identifier){p=!0;break}p||s.push(o[v])}}return Array.isArray(f)&&Array.isArray(c)?sa(s):new l(sa(s))}})}),Pf="setDistinct",xw=["typed","size","subset","compareNatural","Index","DenseMatrix"],bw=R(Pf,xw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Pf,{"Array | Matrix":function(f){var c;if(t(a(f),new i(0))===0)c=[];else{var s=Le(Array.isArray(f)?f:f.toArray()).sort(r);c=[],c.push(s[0]);for(var o=1;o<s.length;o++)r(s[o],s[o-1])!==0&&c.push(s[o])}return Array.isArray(f)?c:new l(c)}})}),Uf="setIntersect",ww=["typed","size","subset","compareNatural","Index","DenseMatrix"],Nw=R(Uf,ww,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Uf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0||t(a(c),new i(0))===0)s=[];else{var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)if(r(o[p].value,u[v].value)===0&&o[p].identifier===u[v].identifier){s.push(o[p]);break}}return Array.isArray(f)&&Array.isArray(c)?sa(s):new l(sa(s))}})}),Lf="setIsSubset",Mw=["typed","size","subset","compareNatural","Index"],Aw=R(Lf,Mw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Lf,{"Array | Matrix, Array | Matrix":function(m,f){if(t(a(m),new i(0))===0)return!0;if(t(a(f),new i(0))===0)return!1;for(var c=sn(Le(Array.isArray(m)?m:m.toArray()).sort(r)),s=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),o,u=0;u<c.length;u++){o=!1;for(var p=0;p<s.length;p++)if(r(c[u].value,s[p].value)===0&&c[u].identifier===s[p].identifier){o=!0;break}if(o===!1)return!1}return!0}})}),kf="setMultiplicity",Sw=["typed","size","subset","compareNatural","Index"],Ew=R(kf,Sw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(kf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(m,f){if(t(a(f),new i(0))===0)return 0;for(var c=Le(Array.isArray(f)?f:f.toArray()),s=0,o=0;o<c.length;o++)r(c[o],m)===0&&s++;return s}})}),Hf="setPowerset",Cw=["typed","size","subset","compareNatural","Index"],Ow=R(Hf,Cw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Hf,{"Array | Matrix":function(c){if(t(a(c),new i(0))===0)return[];for(var s=Le(Array.isArray(c)?c:c.toArray()).sort(r),o=[],u=0;u.toString(2).length<=s.length;)o.push(l(s,u.toString(2).split("").reverse())),u++;return m(o)}});function l(f,c){for(var s=[],o=0;o<c.length;o++)c[o]==="1"&&s.push(f[o]);return s}function m(f){for(var c=[],s=f.length-1;s>0;s--)for(var o=0;o<s;o++)f[o].length>f[o+1].length&&(c=f[o],f[o]=f[o+1],f[o+1]=c);return f}}),Gf="setSize",Dw=["typed","compareNatural"],Tw=R(Gf,Dw,e=>{var{typed:n,compareNatural:a}=e;return n(Gf,{"Array | Matrix":function(r){return Array.isArray(r)?Le(r).length:Le(r.toArray()).length},"Array | Matrix, boolean":function(r,i){if(i===!1||r.length===0)return Array.isArray(r)?Le(r).length:Le(r.toArray()).length;for(var l=Le(Array.isArray(r)?r:r.toArray()).sort(a),m=1,f=1;f<l.length;f++)a(l[f],l[f-1])!==0&&m++;return m}})}),Vf="setSymDifference",Bw=["typed","size","concat","subset","setDifference","Index"],_w=R(Vf,Bw,e=>{var{typed:n,size:a,concat:t,subset:r,setDifference:i,Index:l}=e;return n(Vf,{"Array | Matrix, Array | Matrix":function(f,c){if(r(a(f),new l(0))===0)return Le(c);if(r(a(c),new l(0))===0)return Le(f);var s=Le(f),o=Le(c);return t(i(s,o),i(o,s))}})}),Zf="setUnion",$w=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],Iw=R(Zf,$w,e=>{var{typed:n,size:a,concat:t,subset:r,setIntersect:i,setSymDifference:l,Index:m}=e;return n(Zf,{"Array | Matrix, Array | Matrix":function(c,s){if(r(a(c),new m(0))===0)return Le(s);if(r(a(s),new m(0))===0)return Le(c);var o=Le(c),u=Le(s);return t(l(o,u),i(o,u))}})}),Xf="add",qw=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],Rw=R(Xf,qw,e=>{var{typed:n,matrix:a,addScalar:t,equalScalar:r,DenseMatrix:i,SparseMatrix:l}=e,m=qt({typed:n}),f=Ni({typed:n,equalScalar:r}),c=Vt({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(Xf,Ka({"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,t)},"DenseMatrix, SparseMatrix":function(p,v){return m(p,v,t,!1)},"SparseMatrix, DenseMatrix":function(p,v){return m(v,p,t,!0)},"SparseMatrix, SparseMatrix":function(p,v){return f(p,v,t)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"DenseMatrix, any":function(p,v){return o(p,v,t,!1)},"SparseMatrix, any":function(p,v){return c(p,v,t,!1)},"any, DenseMatrix":function(p,v){return o(v,p,t,!0)},"any, SparseMatrix":function(p,v){return c(v,p,t,!0)},"Array, any":function(p,v){return o(a(p),v,t,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,t,!0).valueOf()},"any, any":t,"any, any, ...any":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}},t.signatures))}),Yf="hypot",Fw=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],zw=R(Yf,Fw,e=>{var{typed:n,abs:a,addScalar:t,divideScalar:r,multiplyScalar:i,sqrt:l,smaller:m,isPositive:f}=e;return n(Yf,{"... number | BigNumber":c,Array:function(o){return this.apply(this,Le(o))},Matrix:function(o){return this.apply(this,Le(o.toArray()))}});function c(s){for(var o=0,u=0,p=0;p<s.length;p++){var v=a(s[p]);m(u,v)?(o=i(o,i(r(u,v),r(u,v))),o=t(o,1),u=v):o=t(o,f(v)?i(r(v,u),r(v,u)):v)}return i(u,l(o))}}),Wf="norm",Pw=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Uw=R(Wf,Pw,e=>{var{typed:n,abs:a,add:t,pow:r,conj:i,sqrt:l,multiply:m,equalScalar:f,larger:c,smaller:s,matrix:o,ctranspose:u,eigs:p}=e;return n(Wf,{number:Math.abs,Complex:function(S){return S.abs()},BigNumber:function(S){return S.abs()},boolean:function(S){return Math.abs(S)},Array:function(S){return d(o(S),2)},Matrix:function(S){return d(S,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(S){return this(S)},"Array, number | BigNumber | string":function(S,O){return d(o(S),O)},"Matrix, number | BigNumber | string":function(S,O){return d(S,O)}});function v(A){var S=0;return A.forEach(function(O){var M=a(O);c(M,S)&&(S=M)},!0),S}function h(A){var S;return A.forEach(function(O){var M=a(O);(!S||s(M,S))&&(S=M)},!0),S||0}function b(A,S){if(S===Number.POSITIVE_INFINITY||S==="inf")return v(A);if(S===Number.NEGATIVE_INFINITY||S==="-inf")return h(A);if(S==="fro")return d(A,2);if(typeof S=="number"&&!isNaN(S)){if(!f(S,0)){var O=0;return A.forEach(function(M){O=t(r(a(M),S),O)},!0),r(O,1/S)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function w(A){var S=0;return A.forEach(function(O,M){S=t(S,m(O,i(O)))}),a(l(S))}function N(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[1],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function g(A){var S=A.size();if(S[0]!==S[1])throw new RangeError("Invalid matrix dimensions");var O=u(A),M=m(O,A),_=p(M).values.toArray(),E=_[_.length-1];return a(l(E))}function y(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[0],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function x(A,S){if(S===1)return N(A);if(S===Number.POSITIVE_INFINITY||S==="inf")return y(A);if(S==="fro")return w(A);if(S===2)return g(A);throw new Error("Unsupported parameter value "+S)}function d(A,S){var O=A.size();if(O.length===1)return b(A,S);if(O.length===2){if(O[0]&&O[1])return x(A,S);throw new RangeError("Invalid matrix dimensions")}}}),Jf="dot",Lw=["typed","addScalar","multiplyScalar","conj","size"],kw=R(Jf,Lw,e=>{var{typed:n,addScalar:a,multiplyScalar:t,conj:r,size:i}=e;return n(Jf,{"Array | DenseMatrix, Array | DenseMatrix":m,"SparseMatrix, SparseMatrix":f});function l(s,o){var u=c(s),p=c(o),v,h;if(u.length===1)v=u[0];else if(u.length===2&&u[1]===1)v=u[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+u.join(", ")+")");if(p.length===1)h=p[0];else if(p.length===2&&p[1]===1)h=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(v!==h)throw new RangeError("Vectors must have equal length ("+v+" != "+h+")");if(v===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return v}function m(s,o){var u=l(s,o),p=Oe(s)?s._data:s,v=Oe(s)?s._datatype:void 0,h=Oe(o)?o._data:o,b=Oe(o)?o._datatype:void 0,w=c(s).length===2,N=c(o).length===2,g=a,y=t;if(v&&b&&v===b&&typeof v=="string"){var x=v;g=n.find(a,[x,x]),y=n.find(t,[x,x])}if(!w&&!N){for(var d=y(r(p[0]),h[0]),A=1;A<u;A++)d=g(d,y(r(p[A]),h[A]));return d}if(!w&&N){for(var S=y(r(p[0]),h[0][0]),O=1;O<u;O++)S=g(S,y(r(p[O]),h[O][0]));return S}if(w&&!N){for(var M=y(r(p[0][0]),h[0]),_=1;_<u;_++)M=g(M,y(r(p[_][0]),h[_]));return M}if(w&&N){for(var E=y(r(p[0][0]),h[0][0]),$=1;$<u;$++)E=g(E,y(r(p[$][0]),h[$][0]));return E}}function f(s,o){l(s,o);for(var u=s._index,p=s._values,v=o._index,h=o._values,b=0,w=a,N=t,g=0,y=0;g<u.length&&y<v.length;){var x=u[g],d=v[y];if(x<d){g++;continue}if(x>d){y++;continue}x===d&&(b=w(b,N(p[g],h[y])),g++,y++)}return b}function c(s){return Oe(s)?s.size():i(s)}}),Hw="trace",Gw=["typed","matrix","add"],Vw=R(Hw,Gw,e=>{var{typed:n,matrix:a,add:t}=e;return n("trace",{Array:function(m){return r(a(m))},SparseMatrix:i,DenseMatrix:r,any:Ce});function r(l){var m=l._size,f=l._data;switch(m.length){case 1:if(m[0]===1)return Ce(f[0]);throw new RangeError("Matrix must be square (size: "+Re(m)+")");case 2:{var c=m[0],s=m[1];if(c===s){for(var o=0,u=0;u<c;u++)o=t(o,f[u][u]);return o}else throw new RangeError("Matrix must be square (size: "+Re(m)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(m)+")")}}function i(l){var m=l._values,f=l._index,c=l._ptr,s=l._size,o=s[0],u=s[1];if(o===u){var p=0;if(m.length>0)for(var v=0;v<u;v++)for(var h=c[v],b=c[v+1],w=h;w<b;w++){var N=f[w];if(N===v){p=t(p,m[w]);break}if(N>v)break}return p}throw new RangeError("Matrix must be square (size: "+Re(s)+")")}}),Qf="index",Zw=["typed","Index"],Xw=R(Qf,Zw,e=>{var{typed:n,Index:a}=e;return n(Qf,{"...number | string | BigNumber | Range | Array | Matrix":function(r){var i=r.map(function(m){return _e(m)?m.toNumber():Array.isArray(m)||Oe(m)?m.map(function(f){return _e(f)?f.toNumber():f}):m}),l=new a;return a.apply(l,i),l}})}),Kf=new Set(["end"]),Yw="Node",Ww=["mathWithTransform"],Jw=R(Yw,Ww,e=>{var{mathWithTransform:n}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator")}a.prototype.evaluate=function(r){return this.compile().evaluate(r)},a.prototype.type="Node",a.prototype.isNode=!0,a.prototype.comment="",a.prototype.compile=function(){var r=this._compile(n,{}),i={},l=null;function m(f){var c=oi(f);return t(c),r(c,i,l)}return{evaluate:m}},a.prototype._compile=function(r,i){throw new Error("Method _compile should be implemented by type "+this.type)},a.prototype.forEach=function(r){throw new Error("Cannot run forEach on a Node interface")},a.prototype.map=function(r){throw new Error("Cannot run map on a Node interface")},a.prototype._ifNode=function(r){if(!Ve(r))throw new TypeError("Callback function must return a Node");return r},a.prototype.traverse=function(r){r(this,null,null);function i(l,m){l.forEach(function(f,c,s){m(f,c,s),i(f,m)})}i(this,r)},a.prototype.transform=function(r){function i(l,m,f){var c=r(l,m,f);return c!==l?c:l.map(i)}return i(this,null,null)},a.prototype.filter=function(r){var i=[];return this.traverse(function(l,m,f){r(l,m,f)&&i.push(l)}),i},a.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},a.prototype.cloneDeep=function(){return this.map(function(r){return r.cloneDeep()})},a.prototype.equals=function(r){return r?Dn(this,r):!1},a.prototype.toString=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toString(r)},a.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},a.prototype.toHTML=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this.toHTML(r)},a.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},a.prototype.toTex=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toTex(r)},a.prototype._toTex=function(r){throw new Error("_toTex not implemented for "+this.type)},a.prototype._getCustomString=function(r){if(r&&typeof r=="object")switch(typeof r.handler){case"object":case"undefined":return;case"function":return r.handler(this,r);default:throw new TypeError("Object or function expected as callback")}},a.prototype.getIdentifier=function(){return this.type},a.prototype.getContent=function(){return this};function t(r){for(var i of[...Kf])if(r.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}return a},{isClass:!0,isNode:!0});function Br(e){return e&&e.isIndexError?new Kr(e.index+1,e.min+1,e.max!==void 0?e.max+1:void 0):e}function jf(e){var{subset:n}=e;return function(t,r){try{if(Array.isArray(t))return n(t,r);if(t&&typeof t.subset=="function")return t.subset(r);if(typeof t=="string")return n(t,r);if(typeof t=="object"){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Vr(t,r.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Br(i)}}}var Qw="AccessorNode",Kw=["subset","Node"],jw=R(Qw,Kw,e=>{var{subset:n,Node:a}=e,t=jf({subset:n});function r(l,m){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(l))throw new TypeError('Node expected for parameter "object"');if(!tn(m))throw new TypeError('IndexNode expected for parameter "index"');this.object=l||null,this.index=m,Object.defineProperty(this,"name",{get:(function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}r.prototype=new a,r.prototype.type="AccessorNode",r.prototype.isAccessorNode=!0,r.prototype._compile=function(l,m){var f=this.object._compile(l,m),c=this.index._compile(l,m);if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(u,p,v){return Vr(f(u,p,v),s)}}else return function(u,p,v){var h=f(u,p,v),b=c(u,p,h);return t(h,b)}},r.prototype.forEach=function(l){l(this.object,"object",this),l(this.index,"index",this)},r.prototype.map=function(l){return new r(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)))},r.prototype.clone=function(){return new r(this.object,this.index)},r.prototype._toString=function(l){var m=this.object.toString(l);return i(this.object)&&(m="("+m+")"),m+this.index.toString(l)},r.prototype.toHTML=function(l){var m=this.object.toHTML(l);return i(this.object)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+this.index.toHTML(l)},r.prototype._toTex=function(l){var m=this.object.toTex(l);return i(this.object)&&(m="\\left(' + object + '\\right)"),m+this.index.toTex(l)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(l){return new r(l.object,l.index)};function i(l){return!(Lt(l)||Hr(l)||Ye(l)||kt(l)||jn(l)||On(l)||xr(l))}return r},{isClass:!0,isNode:!0}),eN="ArrayNode",rN=["Node"],tN=R(eN,rN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=t||[],!Array.isArray(this.items)||!this.items.every(Ve))throw new TypeError("Array containing Nodes expected")}return a.prototype=new n,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(t,r){var i=dt(this.items,function(f){return f._compile(t,r)}),l=t.config.matrix!=="Array";if(l){var m=t.matrix;return function(c,s,o){return m(dt(i,function(u){return u(c,s,o)}))}}else return function(c,s,o){return dt(i,function(u){return u(c,s,o)})}},a.prototype.forEach=function(t){for(var r=0;r<this.items.length;r++){var i=this.items[r];t(i,"items["+r+"]",this)}},a.prototype.map=function(t){for(var r=[],i=0;i<this.items.length;i++)r[i]=this._ifNode(t(this.items[i],"items["+i+"]",this));return new a(r)},a.prototype.clone=function(){return new a(this.items.slice(0))},a.prototype._toString=function(t){var r=this.items.map(function(i){return i.toString(t)});return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"ArrayNode",items:this.items}},a.fromJSON=function(t){return new a(t.items)},a.prototype.toHTML=function(t){var r=this.items.map(function(i){return i.toHTML(t)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},a.prototype._toTex=function(t){function r(i,l){var m=i.some(Hr)&&!i.every(Hr),f=l||m,c=f?"&":"\\\\",s=i.map(function(o){return o.items?r(o.items,!l):o.toTex(t)}).join(c);return m||!f||f&&!l?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}return r(this.items,!1)},a},{isClass:!0,isNode:!0});function nN(e){var{subset:n,matrix:a}=e;return function(r,i,l){try{if(Array.isArray(r))return a(r).subset(i,l).valueOf();if(r&&typeof r.subset=="function")return r.subset(i,l);if(typeof r=="string")return n(r,i,l);if(typeof r=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return un(r,i.getObjectProperty(),l),r}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(m){throw Br(m)}}}var ct=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Je(e,n){var a=e;n!=="keep"&&(a=e.getContent());for(var t=a.getIdentifier(),r=0;r<ct.length;r++)if(t in ct[r])return r;return null}function zn(e,n){var a=e;n!=="keep"&&(a=e.getContent());var t=a.getIdentifier(),r=Je(a,n);if(r===null)return null;var i=ct[r][t];if(Me(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+t+"' has the invalid associativity '"+i.associativity+"'.")}return null}function Ti(e,n,a){var t=a!=="keep"?e.getContent():e,r=a!=="keep"?e.getContent():n,i=t.getIdentifier(),l=r.getIdentifier(),m=Je(t,a);if(m===null)return null;var f=ct[m][i];if(Me(f,"associativeWith")&&f.associativeWith instanceof Array){for(var c=0;c<f.associativeWith.length;c++)if(f.associativeWith[c]===l)return!0;return!1}return null}var aN="AssignmentNode",iN=["subset","?matrix","Node"],oN=R(aN,iN,e=>{var{subset:n,matrix:a,Node:t}=e,r=jf({subset:n}),i=nN({subset:n,matrix:a});function l(f,c,s){if(!(this instanceof l))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=f,this.index=s?c:null,this.value=s||c,!xr(f)&&!Lt(f))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(xr(f)&&f.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!tn(this.index))throw new TypeError('IndexNode expected as "index"');if(!Ve(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:(function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}l.prototype=new t,l.prototype.type="AssignmentNode",l.prototype.isAssignmentNode=!0,l.prototype._compile=function(f,c){var s=this.object._compile(f,c),o=this.index?this.index._compile(f,c):null,u=this.value._compile(f,c),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(g,y,x){var d=s(g,y,x),A=u(g,y,x);return un(d,v,A),A}}else{if(xr(this.object))return function(g,y,x){var d=s(g,y,x),A=u(g,y,x),S=o(g,y,d);return g.set(p,i(d,S,A)),A};var h=this.object.object._compile(f,c);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(g,y,x){var d=h(g,y,x),A=Vr(d,b),S=o(g,y,A),O=u(g,y,x);return un(d,b,i(A,S,O)),O}}else{var w=this.object.index._compile(f,c);return function(g,y,x){var d=h(g,y,x),A=w(g,y,d),S=r(d,A),O=o(g,y,S),M=u(g,y,x);return i(d,A,i(S,O,M)),M}}}else{if(!xr(this.object))throw new TypeError("SymbolNode expected as object");return function(g,y,x){var d=u(g,y,x);return g.set(p,d),d}}},l.prototype.forEach=function(f){f(this.object,"object",this),this.index&&f(this.index,"index",this),f(this.value,"value",this)},l.prototype.map=function(f){var c=this._ifNode(f(this.object,"object",this)),s=this.index?this._ifNode(f(this.index,"index",this)):null,o=this._ifNode(f(this.value,"value",this));return new l(c,s,o)},l.prototype.clone=function(){return new l(this.object,this.index,this.value)};function m(f,c){c||(c="keep");var s=Je(f,c),o=Je(f.value,c);return c==="all"||o!==null&&o<=s}return l.prototype._toString=function(f){var c=this.object.toString(f),s=this.index?this.index.toString(f):"",o=this.value.toString(f);return m(this,f&&f.parenthesis)&&(o="("+o+")"),c+s+" = "+o},l.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},l.fromJSON=function(f){return new l(f.object,f.index,f.value)},l.prototype.toHTML=function(f){var c=this.object.toHTML(f),s=this.index?this.index.toHTML(f):"",o=this.value.toHTML(f);return m(this,f&&f.parenthesis)&&(o='<span class="math-paranthesis math-round-parenthesis">(</span>'+o+'<span class="math-paranthesis math-round-parenthesis">)</span>'),c+s+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+o},l.prototype._toTex=function(f){var c=this.object.toTex(f),s=this.index?this.index.toTex(f):"",o=this.value.toTex(f);return m(this,f&&f.parenthesis)&&(o="\\left(".concat(o,"\\right)")),c+s+":="+o},l},{isClass:!0,isNode:!0}),sN="BlockNode",uN=["ResultSet","Node"],cN=R(sN,uN,e=>{var{ResultSet:n,Node:a}=e;function t(r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(r))throw new Error("Array expected");this.blocks=r.map(function(i){var l=i&&i.node,m=i&&i.visible!==void 0?i.visible:!0;if(!Ve(l))throw new TypeError('Property "node" must be a Node');if(typeof m!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:l,visible:m}})}return t.prototype=new a,t.prototype.type="BlockNode",t.prototype.isBlockNode=!0,t.prototype._compile=function(r,i){var l=dt(this.blocks,function(m){return{evaluate:m.node._compile(r,i),visible:m.visible}});return function(f,c,s){var o=[];return ia(l,function(p){var v=p.evaluate(f,c,s);p.visible&&o.push(v)}),new n(o)}},t.prototype.forEach=function(r){for(var i=0;i<this.blocks.length;i++)r(this.blocks[i].node,"blocks["+i+"].node",this)},t.prototype.map=function(r){for(var i=[],l=0;l<this.blocks.length;l++){var m=this.blocks[l],f=this._ifNode(r(m.node,"blocks["+l+"].node",this));i[l]={node:f,visible:m.visible}}return new t(i)},t.prototype.clone=function(){var r=this.blocks.map(function(i){return{node:i.node,visible:i.visible}});return new t(r)},t.prototype._toString=function(r){return this.blocks.map(function(i){return i.node.toString(r)+(i.visible?"":";")}).join(`
29
29
  `)},t.prototype.toJSON=function(){return{mathjs:"BlockNode",blocks:this.blocks}},t.fromJSON=function(r){return new t(r.blocks)},t.prototype.toHTML=function(r){return this.blocks.map(function(i){return i.node.toHTML(r)+(i.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')},t.prototype._toTex=function(r){return this.blocks.map(function(i){return i.node.toTex(r)+(i.visible?"":";")}).join(`\\;\\;
30
- `)},t},{isClass:!0,isNode:!0}),lN="ConditionalNode",mN=["Node"],pN=R(lN,mN,e=>{var{Node:n}=e;function a(r,i,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(r))throw new TypeError("Parameter condition must be a Node");if(!Ve(i))throw new TypeError("Parameter trueExpr must be a Node");if(!Ve(l))throw new TypeError("Parameter falseExpr must be a Node");this.condition=r,this.trueExpr=i,this.falseExpr=l}a.prototype=new n,a.prototype.type="ConditionalNode",a.prototype.isConditionalNode=!0,a.prototype._compile=function(r,i){var l=this.condition._compile(r,i),m=this.trueExpr._compile(r,i),f=this.falseExpr._compile(r,i);return function(s,o,u){return t(l(s,o,u))?m(s,o,u):f(s,o,u)}},a.prototype.forEach=function(r){r(this.condition,"condition",this),r(this.trueExpr,"trueExpr",this),r(this.falseExpr,"falseExpr",this)},a.prototype.map=function(r){return new a(this._ifNode(r(this.condition,"condition",this)),this._ifNode(r(this.trueExpr,"trueExpr",this)),this._ifNode(r(this.falseExpr,"falseExpr",this)))},a.prototype.clone=function(){return new a(this.condition,this.trueExpr,this.falseExpr)},a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=Je(this,i),m=this.condition.toString(r),f=Je(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=l)&&(m="("+m+")");var c=this.trueExpr.toString(r),s=Je(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=l)&&(c="("+c+")");var o=this.falseExpr.toString(r),u=Je(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=l)&&(o="("+o+")"),m+" ? "+c+" : "+o},a.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},a.fromJSON=function(r){return new a(r.condition,r.trueExpr,r.falseExpr)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=Je(this,i),m=this.condition.toHTML(r),f=Je(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=l)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>');var c=this.trueExpr.toHTML(r),s=Je(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>');var o=this.falseExpr.toHTML(r),u=Je(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=l)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+'<span class="math-operator math-conditional-operator">?</span>'+c+'<span class="math-operator math-conditional-operator">:</span>'+o},a.prototype._toTex=function(r){return"\\begin{cases} {"+this.trueExpr.toTex(r)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(r)+"}\\\\{"+this.falseExpr.toTex(r)+"}, &\\quad{\\text{otherwise}}\\end{cases}"};function t(r){if(typeof r=="number"||typeof r=="boolean"||typeof r=="string")return!!r;if(r){if(Ie(r))return!r.isZero();if(vr(r))return!!(r.re||r.im);if(En(r))return!!r.value}if(r==null)return!1;throw new TypeError('Unsupported type of condition "'+Ke(r)+'"')}return a},{isClass:!0,isNode:!0}),_i,rl;function vN(){if(rl)return _i;rl=1;var e=Object.assign||function(r){for(var i=1;i<arguments.length;i++){var l=arguments[i];for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&(r[m]=l[m])}return r},n={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},a={"–":"\\--","—":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},t=function(i,l){return e({},i,l)};return _i=function(r){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=i.preserveFormatting,m=l===void 0?!1:l,f=i.escapeMapFn,c=f===void 0?t:f,s=String(r),o="",u=c(e({},n),m?e({},a):{}),p=Object.keys(u),v=function(){var b=!1;p.forEach(function(w,N){b||s.length>=w.length&&s.slice(0,w.length)===w&&(o+=u[p[N]],s=s.slice(w.length,s.length),b=!0)}),b||(o+=s.slice(0,1),s=s.slice(1,s.length))};s;)v();return o},_i}var hN=vN();const dN=Bn(hN);var $i={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},He={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},tl={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(He.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(He.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(He.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(He.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(He.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(He.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(He.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(He.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(He.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(He.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(He.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(He.bitAnd,"${args[1]}\\right)")},bitNot:{1:He.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(He.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(He.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(He.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(He.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(He.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(He.and,"${args[1]}\\right)")},not:{1:He.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(He.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(He.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(He.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(He.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(He.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(He.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(He.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(He.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(He.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(He.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(He.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(He.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(He.to,"${args[1]}\\right)")},numeric:function(n,a){return n.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat($i.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},gN="\\mathrm{${name}}\\left(${args}\\right)",nl={deg:"^\\circ"};function Ii(e){return dN(e,{preserveFormatting:!0})}function al(e,n){return n=typeof n=="undefined"?!1:n,n?Me(nl,e)?nl[e]:"\\mathrm{"+Ii(e)+"}":Me($i,e)?$i[e]:Ii(e)}var yN="ConstantNode",xN=["Node"],bN=R(yN,xN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this.value=t}return a.prototype=new n,a.prototype.type="ConstantNode",a.prototype.isConstantNode=!0,a.prototype._compile=function(t,r){var i=this.value;return function(){return i}},a.prototype.forEach=function(t){},a.prototype.map=function(t){return this.clone()},a.prototype.clone=function(){return new a(this.value)},a.prototype._toString=function(t){return Re(this.value,t)},a.prototype.toHTML=function(t){var r=this._toString(t);switch(Ke(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+r+"</span>";case"string":return'<span class="math-string">'+r+"</span>";case"boolean":return'<span class="math-boolean">'+r+"</span>";case"null":return'<span class="math-null-symbol">'+r+"</span>";case"undefined":return'<span class="math-undefined">'+r+"</span>";default:return'<span class="math-symbol">'+r+"</span>"}},a.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},a.fromJSON=function(t){return new a(t.value)},a.prototype._toTex=function(t){var r=this._toString(t);switch(Ke(this.value)){case"string":return"\\mathtt{"+Ii(r)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var i=r.toLowerCase().indexOf("e");if(i!==-1)return r.substring(0,i)+"\\cdot10^{"+r.substring(i+1)+"}"}return r;case"Fraction":return this.value.toLatex();default:return r}},a},{isClass:!0,isNode:!0}),wN="FunctionAssignmentNode",NN=["typed","Node"],MN=R(wN,NN,e=>{var{typed:n,Node:a}=e;function t(i,l,m){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(typeof i!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(l))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Ve(m))throw new TypeError('Node expected for parameter "expr"');if(jf.has(i))throw new Error('Illegal function name, "'+i+'" is a reserved keyword');this.name=i,this.params=l.map(function(f){return f&&f.name||f}),this.types=l.map(function(f){return f&&f.type||"any"}),this.expr=m}t.prototype=new a,t.prototype.type="FunctionAssignmentNode",t.prototype.isFunctionAssignmentNode=!0,t.prototype._compile=function(i,l){var m=Object.create(l);oa(this.params,function(p){m[p]=!0});var f=this.expr._compile(i,m),c=this.name,s=this.params,o=Mo(this.types,","),u=c+"("+Mo(this.params,", ")+")";return function(v,h,b){var w={};w[o]=function(){for(var g=Object.create(h),y=0;y<s.length;y++)g[s[y]]=arguments[y];return f(v,g,b)};var N=n(c,w);return N.syntax=u,v.set(c,N),N}},t.prototype.forEach=function(i){i(this.expr,"expr",this)},t.prototype.map=function(i){var l=this._ifNode(i(this.expr,"expr",this));return new t(this.name,this.params.slice(0),l)},t.prototype.clone=function(){return new t(this.name,this.params.slice(0),this.expr)};function r(i,l){var m=Je(i,l),f=Je(i.expr,l);return l==="all"||f!==null&&f<=m}return t.prototype._toString=function(i){var l=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toString(i);return r(this,l)&&(m="("+m+")"),this.name+"("+this.params.join(", ")+") = "+m},t.prototype.toJSON=function(){var i=this.types;return{mathjs:"FunctionAssignmentNode",name:this.name,params:this.params.map(function(l,m){return{name:l,type:i[m]}}),expr:this.expr}},t.fromJSON=function(i){return new t(i.name,i.params,i.expr)},t.prototype.toHTML=function(i){for(var l=i&&i.parenthesis?i.parenthesis:"keep",m=[],f=0;f<this.params.length;f++)m.push('<span class="math-symbol math-parameter">'+Hr(this.params[f])+"</span>");var c=this.expr.toHTML(i);return r(this,l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Hr(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+m.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+c},t.prototype._toTex=function(i){var l=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toTex(i);return r(this,l)&&(m="\\left(".concat(m,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(al).join(",")+"\\right):="+m},t},{isClass:!0,isNode:!0}),AN="IndexNode",SN=["Node","size"],EN=R(AN,SN,e=>{var{Node:n,size:a}=e;function t(r,i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=r,this.dotNotation=i||!1,!Array.isArray(r)||!r.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}return t.prototype=new n,t.prototype.type="IndexNode",t.prototype.isIndexNode=!0,t.prototype._compile=function(r,i){var l=dt(this.dimensions,function(f,c){var s=f.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(s){var o=Object.create(i);o.end=!0;var u=f._compile(r,o);return function(v,h,b){if(!Oe(b)&&!Xe(b)&&!Br(b))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+Ke(b));var w=a(b).valueOf(),N=Object.create(h);return N.end=w[c],u(v,N,b)}}else return f._compile(r,i)}),m=Gr(r,"index");return function(c,s,o){var u=dt(l,function(p){return p(c,s,o)});return m(...u)}},t.prototype.forEach=function(r){for(var i=0;i<this.dimensions.length;i++)r(this.dimensions[i],"dimensions["+i+"]",this)},t.prototype.map=function(r){for(var i=[],l=0;l<this.dimensions.length;l++)i[l]=this._ifNode(r(this.dimensions[l],"dimensions["+l+"]",this));return new t(i,this.dotNotation)},t.prototype.clone=function(){return new t(this.dimensions.slice(0),this.dotNotation)},t.prototype.isObjectProperty=function(){return this.dimensions.length===1&&Ye(this.dimensions[0])&&typeof this.dimensions[0].value=="string"},t.prototype.getObjectProperty=function(){return this.isObjectProperty()?this.dimensions[0].value:null},t.prototype._toString=function(r){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"IndexNode",dimensions:this.dimensions,dotNotation:this.dotNotation}},t.fromJSON=function(r){return new t(r.dimensions,r.dotNotation)},t.prototype.toHTML=function(r){for(var i=[],l=0;l<this.dimensions.length;l++)i[l]=this.dimensions[l].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Hr(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},t.prototype._toTex=function(r){var i=this.dimensions.map(function(l){return l.toTex(r)});return this.dotNotation?"."+this.getObjectProperty():"_{"+i.join(",")+"}"},t},{isClass:!0,isNode:!0}),CN="ObjectNode",ON=["Node"],DN=R(CN,ON,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=t||{},t&&(typeof t!="object"||!Object.keys(t).every(function(r){return Ve(t[r])})))throw new TypeError("Object containing Nodes expected")}return a.prototype=new n,a.prototype.type="ObjectNode",a.prototype.isObjectNode=!0,a.prototype._compile=function(t,r){var i={};for(var l in this.properties)if(Me(this.properties,l)){var m=aa(l),f=JSON.parse(m);if(!ai(this.properties,f))throw new Error('No access to property "'+f+'"');i[f]=this.properties[l]._compile(t,r)}return function(s,o,u){var p={};for(var v in i)Me(i,v)&&(p[v]=i[v](s,o,u));return p}},a.prototype.forEach=function(t){for(var r in this.properties)Me(this.properties,r)&&t(this.properties[r],"properties["+aa(r)+"]",this)},a.prototype.map=function(t){var r={};for(var i in this.properties)Me(this.properties,i)&&(r[i]=this._ifNode(t(this.properties[i],"properties["+aa(i)+"]",this)));return new a(r)},a.prototype.clone=function(){var t={};for(var r in this.properties)Me(this.properties,r)&&(t[r]=this.properties[r]);return new a(t)},a.prototype._toString=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push(aa(i)+": "+this.properties[i].toString(t));return"{"+r.join(", ")+"}"},a.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},a.fromJSON=function(t){return new a(t.properties)},a.prototype.toHTML=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push('<span class="math-symbol math-property">'+Hr(i)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[i].toHTML(t));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'},a.prototype._toTex=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push("\\mathbf{"+i+":} & "+this.properties[i].toTex(t)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(r.join(`
31
- `),"\\end{array}\\right\\}")},a},{isClass:!0,isNode:!0}),TN="OperatorNode",BN=["Node"],_N=R(TN,BN,e=>{var{Node:n}=e;function a(r,i,l,m,f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(typeof r!="string")throw new TypeError('string expected for parameter "op"');if(typeof i!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(l)||!l.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=m===!0,this.isPercentage=f===!0,this.op=r,this.fn=i,this.args=l||[]}a.prototype=new n,a.prototype.type="OperatorNode",a.prototype.isOperatorNode=!0,a.prototype._compile=function(r,i){if(typeof this.fn!="string"||!ii(r,this.fn))throw r[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=Gr(r,this.fn),m=dt(this.args,function(o){return o._compile(r,i)});if(m.length===1){var f=m[0];return function(u,p,v){return l(f(u,p,v))}}else if(m.length===2){var c=m[0],s=m[1];return function(u,p,v){return l(c(u,p,v),s(u,p,v))}}else return function(u,p,v){return l.apply(null,dt(m,function(h){return h(u,p,v)}))}},a.prototype.forEach=function(r){for(var i=0;i<this.args.length;i++)r(this.args[i],"args["+i+"]",this)},a.prototype.map=function(r){for(var i=[],l=0;l<this.args.length;l++)i[l]=this._ifNode(r(this.args[l],"args["+l+"]",this));return new a(this.op,this.fn,i,this.implicit,this.isPercentage)},a.prototype.clone=function(){return new a(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)},a.prototype.isUnary=function(){return this.args.length===1},a.prototype.isBinary=function(){return this.args.length===2};function t(r,i,l,m,f){var c=Je(r,i),s=Pn(r,i);if(i==="all"||m.length>2&&r.getIdentifier()!=="OperatorNode:add"&&r.getIdentifier()!=="OperatorNode:multiply")return m.map(function(S){switch(S.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var o;switch(m.length){case 0:o=[];break;case 1:{var u=Je(m[0],i);if(f&&u!==null){var p,v;if(i==="keep"?(p=m[0].getIdentifier(),v=r.getIdentifier()):(p=m[0].getContent().getIdentifier(),v=r.getContent().getIdentifier()),ct[c][v].latexLeftParens===!1){o=[!1];break}if(ct[u][p].latexParens===!1){o=[!1];break}}if(u===null){o=[!1];break}if(u<=c){o=[!0];break}o=[!1]}break;case 2:{var h,b=Je(m[0],i),w=Bi(r,m[0],i);b===null?h=!1:b===c&&s==="right"&&!w||b<c?h=!0:h=!1;var N,g=Je(m[1],i),y=Bi(r,m[1],i);if(g===null?N=!1:g===c&&s==="left"&&!y||g<c?N=!0:N=!1,f){var x,d,A;i==="keep"?(x=r.getIdentifier(),d=r.args[0].getIdentifier(),A=r.args[1].getIdentifier()):(x=r.getContent().getIdentifier(),d=r.args[0].getContent().getIdentifier(),A=r.args[1].getContent().getIdentifier()),b!==null&&(ct[c][x].latexLeftParens===!1&&(h=!1),ct[b][d].latexParens===!1&&(h=!1)),g!==null&&(ct[c][x].latexRightParens===!1&&(N=!1),ct[g][A].latexParens===!1&&(N=!1))}o=[h,N]}break;default:(r.getIdentifier()==="OperatorNode:add"||r.getIdentifier()==="OperatorNode:multiply")&&(o=m.map(function(S){var O=Je(S,i),M=Bi(r,S,i),_=Pn(S,i);return O===null?!1:c===O&&s===_&&!M?!0:O<c}));break}return m.length>=2&&r.getIdentifier()==="OperatorNode:multiply"&&r.implicit&&i==="auto"&&l==="hide"&&(o=m.map(function(S,O){var M=S.getIdentifier()==="ParenthesisNode";return!!(o[O]||M)})),o}return a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!1);if(m.length===1){var c=Pn(this,i),s=m[0].toString(r);f[0]&&(s="("+s+")");var o=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(o?" ":"")+s:c==="left"?s+(o?" ":"")+this.op:s+this.op}else if(m.length===2){var u=m[0].toString(r),p=m[1].toString(r);return f[0]&&(u="("+u+")"),f[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?u+" "+p:u+" "+this.op+" "+p}else if(m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var v=m.map(function(h,b){return h=h.toString(r),f[b]&&(h="("+h+")"),h});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?v.join(" "):v.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"},a.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},a.fromJSON=function(r){return new a(r.op,r.fn,r.args,r.implicit,r.isPercentage)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!1);if(m.length===1){var c=Pn(this,i),s=m[0].toHTML(r);return f[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Hr(this.op)+"</span>"+s:s+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Hr(this.op)+"</span>"}else if(m.length===2){var o=m[0].toHTML(r),u=m[1].toHTML(r);return f[0]&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),f[1]&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?o+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+u:o+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Hr(this.op)+"</span>"+u}else{var p=m.map(function(v,h){return v=v.toHTML(r),f[h]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),v});return m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Hr(this.op)+"</span>"):'<span class="math-function">'+Hr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+p.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}},a.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!0),c=He[this.fn];if(c=typeof c=="undefined"?this.op:c,m.length===1){var s=Pn(this,i),o=m[0].toTex(r);return f[0]&&(o="\\left(".concat(o,"\\right)")),s==="right"?c+o:o+c}else if(m.length===2){var u=m[0],p=u.toTex(r);f[0]&&(p="\\left(".concat(p,"\\right)"));var v=m[1],h=v.toTex(r);f[1]&&(h="\\left(".concat(h,"\\right)"));var b;switch(i==="keep"?b=u.getIdentifier():b=u.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+p+"}{"+h+"}";case"OperatorNode:pow":switch(p="{"+p+"}",h="{"+h+"}",b){case"ConditionalNode":case"OperatorNode:divide":p="\\left(".concat(p,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return p+"~"+h}return p+c+h}else if(m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var w=m.map(function(N,g){return N=N.toTex(r),f[g]&&(N="\\left(".concat(N,"\\right)")),N});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit?w.join("~"):w.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+m.map(function(N){return N.toTex(r)}).join(",")+"\\right)"},a.prototype.getIdentifier=function(){return this.type+":"+this.fn},a},{isClass:!0,isNode:!0}),$N="ParenthesisNode",IN=["Node"],qN=R($N,IN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(t))throw new TypeError('Node expected for parameter "content"');this.content=t}return a.prototype=new n,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,a.prototype._compile=function(t,r){return this.content._compile(t,r)},a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(t){t(this.content,"content",this)},a.prototype.map=function(t){var r=t(this.content,"content",this);return new a(r)},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?"("+this.content.toString(t)+")":this.content.toString(t)},a.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},a.fromJSON=function(t){return new a(t.content)},a.prototype.toHTML=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(t)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(t)},a.prototype._toTex=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?"\\left(".concat(this.content.toTex(t),"\\right)"):this.content.toTex(t)},a},{isClass:!0,isNode:!0}),RN="RangeNode",FN=["Node"],zN=R(RN,FN,e=>{var{Node:n}=e;function a(r,i,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(r))throw new TypeError("Node expected");if(!Ve(i))throw new TypeError("Node expected");if(l&&!Ve(l))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=r,this.end=i,this.step=l||null}a.prototype=new n,a.prototype.type="RangeNode",a.prototype.isRangeNode=!0,a.prototype.needsEnd=function(){var r=this.filter(function(i){return xr(i)&&i.name==="end"});return r.length>0},a.prototype._compile=function(r,i){var l=r.range,m=this.start._compile(r,i),f=this.end._compile(r,i);if(this.step){var c=this.step._compile(r,i);return function(o,u,p){return l(m(o,u,p),f(o,u,p),c(o,u,p))}}else return function(o,u,p){return l(m(o,u,p),f(o,u,p))}},a.prototype.forEach=function(r){r(this.start,"start",this),r(this.end,"end",this),this.step&&r(this.step,"step",this)},a.prototype.map=function(r){return new a(this._ifNode(r(this.start,"start",this)),this._ifNode(r(this.end,"end",this)),this.step&&this._ifNode(r(this.step,"step",this)))},a.prototype.clone=function(){return new a(this.start,this.end,this.step&&this.step)};function t(r,i){var l=Je(r,i),m={},f=Je(r.start,i);if(m.start=f!==null&&f<=l||i==="all",r.step){var c=Je(r.step,i);m.step=c!==null&&c<=l||i==="all"}var s=Je(r.end,i);return m.end=s!==null&&s<=l||i==="all",m}return a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m,f=this.start.toString(r);if(l.start&&(f="("+f+")"),m=f,this.step){var c=this.step.toString(r);l.step&&(c="("+c+")"),m+=":"+c}var s=this.end.toString(r);return l.end&&(s="("+s+")"),m+=":"+s,m},a.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},a.fromJSON=function(r){return new a(r.start,r.end,r.step)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m,f=this.start.toHTML(r);if(l.start&&(f='<span class="math-parenthesis math-round-parenthesis">(</span>'+f+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m=f,this.step){var c=this.step.toHTML(r);l.step&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+='<span class="math-operator math-range-operator">:</span>'+c}var s=this.end.toHTML(r);return l.end&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+='<span class="math-operator math-range-operator">:</span>'+s,m},a.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m=this.start.toTex(r);if(l.start&&(m="\\left(".concat(m,"\\right)")),this.step){var f=this.step.toTex(r);l.step&&(f="\\left(".concat(f,"\\right)")),m+=":"+f}var c=this.end.toTex(r);return l.end&&(c="\\left(".concat(c,"\\right)")),m+=":"+c,m},a},{isClass:!0,isNode:!0}),PN="RelationalNode",UN=["Node"],LN=R(PN,UN,e=>{var{Node:n}=e;function a(t,r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(t))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(r))throw new TypeError("Parameter params must be an array");if(t.length!==r.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=t,this.params=r}return a.prototype=new n,a.prototype.type="RelationalNode",a.prototype.isRelationalNode=!0,a.prototype._compile=function(t,r){var i=this,l=this.params.map(m=>m._compile(t,r));return function(f,c,s){for(var o,u=l[0](f,c,s),p=0;p<i.conditionals.length;p++){o=u,u=l[p+1](f,c,s);var v=Gr(t,i.conditionals[p]);if(!v(o,u))return!1}return!0}},a.prototype.forEach=function(t){this.params.forEach((r,i)=>t(r,"params["+i+"]",this),this)},a.prototype.map=function(t){return new a(this.conditionals.slice(),this.params.map((r,i)=>this._ifNode(t(r,"params["+i+"]",this)),this))},a.prototype.clone=function(){return new a(this.conditionals,this.params)},a.prototype._toString=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(s,o){var u=Je(s,r);return r==="all"||u!==null&&u<=i?"("+s.toString(t)+")":s.toString(t)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=l[0],c=0;c<this.conditionals.length;c++)f+=" "+m[this.conditionals[c]]+" "+l[c+1];return f},a.prototype.toJSON=function(){return{mathjs:"RelationalNode",conditionals:this.conditionals,params:this.params}},a.fromJSON=function(t){return new a(t.conditionals,t.params)},a.prototype.toHTML=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(s,o){var u=Je(s,r);return r==="all"||u!==null&&u<=i?'<span class="math-parenthesis math-round-parenthesis">(</span>'+s.toHTML(t)+'<span class="math-parenthesis math-round-parenthesis">)</span>':s.toHTML(t)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=l[0],c=0;c<this.conditionals.length;c++)f+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Hr(m[this.conditionals[c]])+"</span>"+l[c+1];return f},a.prototype._toTex=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(c,s){var o=Je(c,r);return r==="all"||o!==null&&o<=i?"\\left("+c.toTex(t)+"\right)":c.toTex(t)}),m=l[0],f=0;f<this.conditionals.length;f++)m+=He[this.conditionals[f]]+l[f+1];return m},a},{isClass:!0,isNode:!0}),kN="SymbolNode",HN=["math","?Unit","Node"],GN=R(kN,HN,e=>{var{math:n,Unit:a,Node:t}=e;function r(l){return a?a.isValuelessUnit(l):!1}function i(l){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(typeof l!="string")throw new TypeError('String expected for parameter "name"');this.name=l}return i.prototype=new t,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(l,m){var f=this.name;if(m[f]===!0)return function(s,o,u){return o[f]};if(f in l)return function(s,o,u){return s.has(f)?s.get(f):Gr(l,f)};var c=r(f);return function(s,o,u){return s.has(f)?s.get(f):c?new a(null,f):i.onUndefinedSymbol(f)}},i.prototype.forEach=function(l){},i.prototype.map=function(l){return this.clone()},i.onUndefinedSymbol=function(l){throw new Error("Undefined symbol "+l)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(l){return this.name},i.prototype.toHTML=function(l){var m=Hr(this.name);return m==="true"||m==="false"?'<span class="math-symbol math-boolean">'+m+"</span>":m==="i"?'<span class="math-symbol math-imaginary-symbol">'+m+"</span>":m==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+m+"</span>":m==="NaN"?'<span class="math-symbol math-nan-symbol">'+m+"</span>":m==="null"?'<span class="math-symbol math-null-symbol">'+m+"</span>":m==="undefined"?'<span class="math-symbol math-undefined-symbol">'+m+"</span>":'<span class="math-symbol">'+m+"</span>"},i.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},i.fromJSON=function(l){return new i(l.name)},i.prototype._toTex=function(l){var m=!1;typeof n[this.name]=="undefined"&&r(this.name)&&(m=!0);var f=al(this.name,m);return f[0]==="\\"?f:" "+f},i},{isClass:!0,isNode:!0});function Un(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];return typeof e.createSubScope=="function"?So(e.createSubScope(),...a):So(gt(),e,...a)}var VN="FunctionNode",ZN=["math","Node","SymbolNode"],XN=R(VN,ZN,e=>{var{math:n,Node:a,SymbolNode:t}=e;function r(c,s){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(typeof c=="string"&&(c=new t(c)),!Ve(c))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(s)||!s.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=c,this.args=s||[],Object.defineProperty(this,"name",{get:(function(){return this.fn.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}r.prototype=new a,r.prototype.type="FunctionNode",r.prototype.isFunctionNode=!0;var i=c=>Re(c,{truncate:78});r.prototype._compile=function(c,s){if(!(this instanceof r))throw new TypeError("No valid FunctionNode");var o=this.args.map(S=>S._compile(c,s));if(xr(this.fn)){var u=this.fn.name;if(s[u]){var w=this.args;return function(O,M,_){var E=M[u];if(typeof E!="function")throw new TypeError("Argument '".concat(u,"' was not a function; received: ").concat(i(E)));if(E.rawArgs)return E(w,c,Un(O,M),O);var $=o.map(z=>z(O,M,_));return E.apply(E,$)}}else{var p=u in c?Gr(c,u):void 0,v=typeof p=="function"&&p.rawArgs===!0,h=S=>{var O;if(S.has(u))O=S.get(u);else if(u in c)O=Gr(c,u);else return r.onUndefinedFunction(u);if(typeof O=="function")return O;throw new TypeError("'".concat(u,`' is not a function; its value is:
32
- `).concat(i(O)))};if(v){var b=this.args;return function(O,M,_){var E=h(O);return E(b,c,Un(O,M),O)}}else switch(o.length){case 0:return function(O,M,_){var E=h(O);return E()};case 1:return function(O,M,_){var E=h(O),$=o[0];return E($(O,M,_))};case 2:return function(O,M,_){var E=h(O),$=o[0],z=o[1];return E($(O,M,_),z(O,M,_))};default:return function(O,M,_){var E=h(O),$=o.map(z=>z(O,M,_));return E(...$)}}}}else if(Lt(this.fn)&&tn(this.fn.index)&&this.fn.index.isObjectProperty()){var N=this.fn.object._compile(c,s),g=this.fn.index.getObjectProperty(),y=this.args;return function(O,M,_){var E=N(O,M,_);dv(E,g);var $=E[g]&&E[g].rawArgs;if($)return E[g](y,c,Un(O,M),O);var z=o.map(I=>I(O,M,_));return E[g].apply(E,z)}}else{var x=this.fn.toString(),d=this.fn._compile(c,s),A=this.args;return function(O,M,_){var E=d(O,M,_);if(typeof E!="function")throw new TypeError("Expression '".concat(x,"' did not evaluate to a function; value is:")+`
33
- `.concat(i(E)));if(E.rawArgs)return E(A,c,Un(O,M),O);var $=o.map(z=>z(O,M,_));return E.apply(E,$)}}},r.prototype.forEach=function(c){c(this.fn,"fn",this);for(var s=0;s<this.args.length;s++)c(this.args[s],"args["+s+"]",this)},r.prototype.map=function(c){for(var s=this._ifNode(c(this.fn,"fn",this)),o=[],u=0;u<this.args.length;u++)o[u]=this._ifNode(c(this.args[u],"args["+u+"]",this));return new r(s,o)},r.prototype.clone=function(){return new r(this.fn,this.args.slice(0))},r.onUndefinedFunction=function(c){throw new Error("Undefined function "+c)};var l=r.prototype.toString;r.prototype.toString=function(c){var s,o=this.fn.toString(c);return c&&typeof c.handler=="object"&&Me(c.handler,o)&&(s=c.handler[o](this,c)),typeof s!="undefined"?s:l.call(this,c)},r.prototype._toString=function(c){var s=this.args.map(function(u){return u.toString(c)}),o=On(this.fn)?"("+this.fn.toString(c)+")":this.fn.toString(c);return o+"("+s.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"FunctionNode",fn:this.fn,args:this.args}},r.fromJSON=function(c){return new r(c.fn,c.args)},r.prototype.toHTML=function(c){var s=this.args.map(function(o){return o.toHTML(c)});return'<span class="math-function">'+Hr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+s.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'};function m(c,s,o){for(var u="",p=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,v=0,h;(h=p.exec(c))!==null;)if(u+=c.substring(v,h.index),v=h.index,h[0]==="$$")u+="$",v++;else{v+=h[0].length;var b=s[h[1]];if(!b)throw new ReferenceError("Template: Property "+h[1]+" does not exist.");if(h[2]===void 0)switch(typeof b){case"string":u+=b;break;case"object":if(Ve(b))u+=b.toTex(o);else if(Array.isArray(b))u+=b.map(function(w,N){if(Ve(w))return w.toTex(o);throw new TypeError("Template: "+h[1]+"["+N+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes")}else if(Ve(b[h[2]]&&b[h[2]]))u+=b[h[2]].toTex(o);else throw new TypeError("Template: "+h[1]+"["+h[2]+"] is not a Node.")}return u+=c.slice(v),u}var f=r.prototype.toTex;return r.prototype.toTex=function(c){var s;return c&&typeof c.handler=="object"&&Me(c.handler,this.name)&&(s=c.handler[this.name](this,c)),typeof s!="undefined"?s:f.call(this,c)},r.prototype._toTex=function(c){var s=this.args.map(function(p){return p.toTex(c)}),o;tl[this.name]&&(o=tl[this.name]),n[this.name]&&(typeof n[this.name].toTex=="function"||typeof n[this.name].toTex=="object"||typeof n[this.name].toTex=="string")&&(o=n[this.name].toTex);var u;switch(typeof o){case"function":u=o(this,c);break;case"string":u=m(o,this,c);break;case"object":switch(typeof o[s.length]){case"function":u=o[s.length](this,c);break;case"string":u=m(o[s.length],this,c);break}}return typeof u!="undefined"?u:m(gN,this,c)},r.prototype.getIdentifier=function(){return this.type+":"+this.name},r},{isClass:!0,isNode:!0}),il="parse",YN=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],WN=R(il,YN,e=>{var{typed:n,numeric:a,config:t,AccessorNode:r,ArrayNode:i,AssignmentNode:l,BlockNode:m,ConditionalNode:f,ConstantNode:c,FunctionAssignmentNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,RangeNode:b,RelationalNode:w,SymbolNode:N}=e,g=n(il,{string:function(X){return H(X,{})},"Array | Matrix":function(X){return y(X,{})},"string, Object":function(X,ae){var he=ae.nodes!==void 0?ae.nodes:{};return H(X,he)},"Array | Matrix, Object":y});function y(C){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ae=X.nodes!==void 0?X.nodes:{};return be(C,function(he){if(typeof he!="string")throw new TypeError("String expected");return H(he,ae)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},d={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},A={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},O=["NaN","Infinity"];function M(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function _(C,X){return C.expression.substr(C.index,X)}function E(C){return _(C,1)}function $(C){C.index++}function z(C){return C.expression.charAt(C.index-1)}function I(C){return C.expression.charAt(C.index+1)}function T(C){for(C.tokenType=x.NULL,C.token="",C.comment="";;){if(E(C)==="#")for(;E(C)!==`
30
+ `)},t},{isClass:!0,isNode:!0}),fN="ConditionalNode",lN=["Node"],mN=R(fN,lN,e=>{var{Node:n}=e;function a(r,i,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(r))throw new TypeError("Parameter condition must be a Node");if(!Ve(i))throw new TypeError("Parameter trueExpr must be a Node");if(!Ve(l))throw new TypeError("Parameter falseExpr must be a Node");this.condition=r,this.trueExpr=i,this.falseExpr=l}a.prototype=new n,a.prototype.type="ConditionalNode",a.prototype.isConditionalNode=!0,a.prototype._compile=function(r,i){var l=this.condition._compile(r,i),m=this.trueExpr._compile(r,i),f=this.falseExpr._compile(r,i);return function(s,o,u){return t(l(s,o,u))?m(s,o,u):f(s,o,u)}},a.prototype.forEach=function(r){r(this.condition,"condition",this),r(this.trueExpr,"trueExpr",this),r(this.falseExpr,"falseExpr",this)},a.prototype.map=function(r){return new a(this._ifNode(r(this.condition,"condition",this)),this._ifNode(r(this.trueExpr,"trueExpr",this)),this._ifNode(r(this.falseExpr,"falseExpr",this)))},a.prototype.clone=function(){return new a(this.condition,this.trueExpr,this.falseExpr)},a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=Je(this,i),m=this.condition.toString(r),f=Je(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=l)&&(m="("+m+")");var c=this.trueExpr.toString(r),s=Je(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=l)&&(c="("+c+")");var o=this.falseExpr.toString(r),u=Je(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=l)&&(o="("+o+")"),m+" ? "+c+" : "+o},a.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},a.fromJSON=function(r){return new a(r.condition,r.trueExpr,r.falseExpr)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=Je(this,i),m=this.condition.toHTML(r),f=Je(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=l)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>');var c=this.trueExpr.toHTML(r),s=Je(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>');var o=this.falseExpr.toHTML(r),u=Je(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=l)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+'<span class="math-operator math-conditional-operator">?</span>'+c+'<span class="math-operator math-conditional-operator">:</span>'+o},a.prototype._toTex=function(r){return"\\begin{cases} {"+this.trueExpr.toTex(r)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(r)+"}\\\\{"+this.falseExpr.toTex(r)+"}, &\\quad{\\text{otherwise}}\\end{cases}"};function t(r){if(typeof r=="number"||typeof r=="boolean"||typeof r=="string")return!!r;if(r){if(_e(r))return!r.isZero();if(Or(r))return!!(r.re||r.im);if(ht(r))return!!r.value}if(r==null)return!1;throw new TypeError('Unsupported type of condition "'+Ke(r)+'"')}return a},{isClass:!0,isNode:!0}),Bi,el;function pN(){if(el)return Bi;el=1;var e=Object.assign||function(r){for(var i=1;i<arguments.length;i++){var l=arguments[i];for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&(r[m]=l[m])}return r},n={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},a={"–":"\\--","—":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},t=function(i,l){return e({},i,l)};return Bi=function(r){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=i.preserveFormatting,m=l===void 0?!1:l,f=i.escapeMapFn,c=f===void 0?t:f,s=String(r),o="",u=c(e({},n),m?e({},a):{}),p=Object.keys(u),v=function(){var b=!1;p.forEach(function(w,N){b||s.length>=w.length&&s.slice(0,w.length)===w&&(o+=u[p[N]],s=s.slice(w.length,s.length),b=!0)}),b||(o+=s.slice(0,1),s=s.slice(1,s.length))};s;)v();return o},Bi}var vN=pN();const hN=Tn(vN);var _i={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},He={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},rl={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(He.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(He.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(He.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(He.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(He.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(He.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(He.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(He.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(He.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(He.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(He.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(He.bitAnd,"${args[1]}\\right)")},bitNot:{1:He.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(He.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(He.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(He.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(He.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(He.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(He.and,"${args[1]}\\right)")},not:{1:He.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(He.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(He.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(He.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(He.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(He.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(He.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(He.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(He.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(He.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(He.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(He.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(He.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(He.to,"${args[1]}\\right)")},numeric:function(n,a){return n.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(_i.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dN="\\mathrm{${name}}\\left(${args}\\right)",tl={deg:"^\\circ"};function $i(e){return hN(e,{preserveFormatting:!0})}function nl(e,n){return n=typeof n=="undefined"?!1:n,n?Me(tl,e)?tl[e]:"\\mathrm{"+$i(e)+"}":Me(_i,e)?_i[e]:$i(e)}var gN="ConstantNode",yN=["Node"],xN=R(gN,yN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this.value=t}return a.prototype=new n,a.prototype.type="ConstantNode",a.prototype.isConstantNode=!0,a.prototype._compile=function(t,r){var i=this.value;return function(){return i}},a.prototype.forEach=function(t){},a.prototype.map=function(t){return this.clone()},a.prototype.clone=function(){return new a(this.value)},a.prototype._toString=function(t){return Re(this.value,t)},a.prototype.toHTML=function(t){var r=this._toString(t);switch(Ke(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+r+"</span>";case"string":return'<span class="math-string">'+r+"</span>";case"boolean":return'<span class="math-boolean">'+r+"</span>";case"null":return'<span class="math-null-symbol">'+r+"</span>";case"undefined":return'<span class="math-undefined">'+r+"</span>";default:return'<span class="math-symbol">'+r+"</span>"}},a.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},a.fromJSON=function(t){return new a(t.value)},a.prototype._toTex=function(t){var r=this._toString(t);switch(Ke(this.value)){case"string":return"\\mathtt{"+$i(r)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var i=r.toLowerCase().indexOf("e");if(i!==-1)return r.substring(0,i)+"\\cdot10^{"+r.substring(i+1)+"}"}return r;case"Fraction":return this.value.toLatex();default:return r}},a},{isClass:!0,isNode:!0}),bN="FunctionAssignmentNode",wN=["typed","Node"],NN=R(bN,wN,e=>{var{typed:n,Node:a}=e;function t(i,l,m){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(typeof i!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(l))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Ve(m))throw new TypeError('Node expected for parameter "expr"');if(Kf.has(i))throw new Error('Illegal function name, "'+i+'" is a reserved keyword');this.name=i,this.params=l.map(function(f){return f&&f.name||f}),this.types=l.map(function(f){return f&&f.type||"any"}),this.expr=m}t.prototype=new a,t.prototype.type="FunctionAssignmentNode",t.prototype.isFunctionAssignmentNode=!0,t.prototype._compile=function(i,l){var m=Object.create(l);ia(this.params,function(p){m[p]=!0});var f=this.expr._compile(i,m),c=this.name,s=this.params,o=No(this.types,","),u=c+"("+No(this.params,", ")+")";return function(v,h,b){var w={};w[o]=function(){for(var g=Object.create(h),y=0;y<s.length;y++)g[s[y]]=arguments[y];return f(v,g,b)};var N=n(c,w);return N.syntax=u,v.set(c,N),N}},t.prototype.forEach=function(i){i(this.expr,"expr",this)},t.prototype.map=function(i){var l=this._ifNode(i(this.expr,"expr",this));return new t(this.name,this.params.slice(0),l)},t.prototype.clone=function(){return new t(this.name,this.params.slice(0),this.expr)};function r(i,l){var m=Je(i,l),f=Je(i.expr,l);return l==="all"||f!==null&&f<=m}return t.prototype._toString=function(i){var l=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toString(i);return r(this,l)&&(m="("+m+")"),this.name+"("+this.params.join(", ")+") = "+m},t.prototype.toJSON=function(){var i=this.types;return{mathjs:"FunctionAssignmentNode",name:this.name,params:this.params.map(function(l,m){return{name:l,type:i[m]}}),expr:this.expr}},t.fromJSON=function(i){return new t(i.name,i.params,i.expr)},t.prototype.toHTML=function(i){for(var l=i&&i.parenthesis?i.parenthesis:"keep",m=[],f=0;f<this.params.length;f++)m.push('<span class="math-symbol math-parameter">'+Gr(this.params[f])+"</span>");var c=this.expr.toHTML(i);return r(this,l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Gr(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+m.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+c},t.prototype._toTex=function(i){var l=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toTex(i);return r(this,l)&&(m="\\left(".concat(m,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(nl).join(",")+"\\right):="+m},t},{isClass:!0,isNode:!0}),MN="IndexNode",AN=["Node","size"],SN=R(MN,AN,e=>{var{Node:n,size:a}=e;function t(r,i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=r,this.dotNotation=i||!1,!Array.isArray(r)||!r.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}return t.prototype=new n,t.prototype.type="IndexNode",t.prototype.isIndexNode=!0,t.prototype._compile=function(r,i){var l=dt(this.dimensions,function(f,c){var s=f.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(s){var o=Object.create(i);o.end=!0;var u=f._compile(r,o);return function(v,h,b){if(!Oe(b)&&!Xe(b)&&!_r(b))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+Ke(b));var w=a(b).valueOf(),N=Object.create(h);return N.end=w[c],u(v,N,b)}}else return f._compile(r,i)}),m=Vr(r,"index");return function(c,s,o){var u=dt(l,function(p){return p(c,s,o)});return m(...u)}},t.prototype.forEach=function(r){for(var i=0;i<this.dimensions.length;i++)r(this.dimensions[i],"dimensions["+i+"]",this)},t.prototype.map=function(r){for(var i=[],l=0;l<this.dimensions.length;l++)i[l]=this._ifNode(r(this.dimensions[l],"dimensions["+l+"]",this));return new t(i,this.dotNotation)},t.prototype.clone=function(){return new t(this.dimensions.slice(0),this.dotNotation)},t.prototype.isObjectProperty=function(){return this.dimensions.length===1&&Ye(this.dimensions[0])&&typeof this.dimensions[0].value=="string"},t.prototype.getObjectProperty=function(){return this.isObjectProperty()?this.dimensions[0].value:null},t.prototype._toString=function(r){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"IndexNode",dimensions:this.dimensions,dotNotation:this.dotNotation}},t.fromJSON=function(r){return new t(r.dimensions,r.dotNotation)},t.prototype.toHTML=function(r){for(var i=[],l=0;l<this.dimensions.length;l++)i[l]=this.dimensions[l].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Gr(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},t.prototype._toTex=function(r){var i=this.dimensions.map(function(l){return l.toTex(r)});return this.dotNotation?"."+this.getObjectProperty():"_{"+i.join(",")+"}"},t},{isClass:!0,isNode:!0}),EN="ObjectNode",CN=["Node"],ON=R(EN,CN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=t||{},t&&(typeof t!="object"||!Object.keys(t).every(function(r){return Ve(t[r])})))throw new TypeError("Object containing Nodes expected")}return a.prototype=new n,a.prototype.type="ObjectNode",a.prototype.isObjectNode=!0,a.prototype._compile=function(t,r){var i={};for(var l in this.properties)if(Me(this.properties,l)){var m=na(l),f=JSON.parse(m);if(!ni(this.properties,f))throw new Error('No access to property "'+f+'"');i[f]=this.properties[l]._compile(t,r)}return function(s,o,u){var p={};for(var v in i)Me(i,v)&&(p[v]=i[v](s,o,u));return p}},a.prototype.forEach=function(t){for(var r in this.properties)Me(this.properties,r)&&t(this.properties[r],"properties["+na(r)+"]",this)},a.prototype.map=function(t){var r={};for(var i in this.properties)Me(this.properties,i)&&(r[i]=this._ifNode(t(this.properties[i],"properties["+na(i)+"]",this)));return new a(r)},a.prototype.clone=function(){var t={};for(var r in this.properties)Me(this.properties,r)&&(t[r]=this.properties[r]);return new a(t)},a.prototype._toString=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push(na(i)+": "+this.properties[i].toString(t));return"{"+r.join(", ")+"}"},a.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},a.fromJSON=function(t){return new a(t.properties)},a.prototype.toHTML=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push('<span class="math-symbol math-property">'+Gr(i)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[i].toHTML(t));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'},a.prototype._toTex=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push("\\mathbf{"+i+":} & "+this.properties[i].toTex(t)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(r.join(`
31
+ `),"\\end{array}\\right\\}")},a},{isClass:!0,isNode:!0}),DN="OperatorNode",TN=["Node"],BN=R(DN,TN,e=>{var{Node:n}=e;function a(r,i,l,m,f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(typeof r!="string")throw new TypeError('string expected for parameter "op"');if(typeof i!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(l)||!l.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=m===!0,this.isPercentage=f===!0,this.op=r,this.fn=i,this.args=l||[]}a.prototype=new n,a.prototype.type="OperatorNode",a.prototype.isOperatorNode=!0,a.prototype._compile=function(r,i){if(typeof this.fn!="string"||!ai(r,this.fn))throw r[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=Vr(r,this.fn),m=dt(this.args,function(o){return o._compile(r,i)});if(m.length===1){var f=m[0];return function(u,p,v){return l(f(u,p,v))}}else if(m.length===2){var c=m[0],s=m[1];return function(u,p,v){return l(c(u,p,v),s(u,p,v))}}else return function(u,p,v){return l.apply(null,dt(m,function(h){return h(u,p,v)}))}},a.prototype.forEach=function(r){for(var i=0;i<this.args.length;i++)r(this.args[i],"args["+i+"]",this)},a.prototype.map=function(r){for(var i=[],l=0;l<this.args.length;l++)i[l]=this._ifNode(r(this.args[l],"args["+l+"]",this));return new a(this.op,this.fn,i,this.implicit,this.isPercentage)},a.prototype.clone=function(){return new a(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)},a.prototype.isUnary=function(){return this.args.length===1},a.prototype.isBinary=function(){return this.args.length===2};function t(r,i,l,m,f){var c=Je(r,i),s=zn(r,i);if(i==="all"||m.length>2&&r.getIdentifier()!=="OperatorNode:add"&&r.getIdentifier()!=="OperatorNode:multiply")return m.map(function(S){switch(S.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var o;switch(m.length){case 0:o=[];break;case 1:{var u=Je(m[0],i);if(f&&u!==null){var p,v;if(i==="keep"?(p=m[0].getIdentifier(),v=r.getIdentifier()):(p=m[0].getContent().getIdentifier(),v=r.getContent().getIdentifier()),ct[c][v].latexLeftParens===!1){o=[!1];break}if(ct[u][p].latexParens===!1){o=[!1];break}}if(u===null){o=[!1];break}if(u<=c){o=[!0];break}o=[!1]}break;case 2:{var h,b=Je(m[0],i),w=Ti(r,m[0],i);b===null?h=!1:b===c&&s==="right"&&!w||b<c?h=!0:h=!1;var N,g=Je(m[1],i),y=Ti(r,m[1],i);if(g===null?N=!1:g===c&&s==="left"&&!y||g<c?N=!0:N=!1,f){var x,d,A;i==="keep"?(x=r.getIdentifier(),d=r.args[0].getIdentifier(),A=r.args[1].getIdentifier()):(x=r.getContent().getIdentifier(),d=r.args[0].getContent().getIdentifier(),A=r.args[1].getContent().getIdentifier()),b!==null&&(ct[c][x].latexLeftParens===!1&&(h=!1),ct[b][d].latexParens===!1&&(h=!1)),g!==null&&(ct[c][x].latexRightParens===!1&&(N=!1),ct[g][A].latexParens===!1&&(N=!1))}o=[h,N]}break;default:(r.getIdentifier()==="OperatorNode:add"||r.getIdentifier()==="OperatorNode:multiply")&&(o=m.map(function(S){var O=Je(S,i),M=Ti(r,S,i),_=zn(S,i);return O===null?!1:c===O&&s===_&&!M?!0:O<c}));break}return m.length>=2&&r.getIdentifier()==="OperatorNode:multiply"&&r.implicit&&i==="auto"&&l==="hide"&&(o=m.map(function(S,O){var M=S.getIdentifier()==="ParenthesisNode";return!!(o[O]||M)})),o}return a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!1);if(m.length===1){var c=zn(this,i),s=m[0].toString(r);f[0]&&(s="("+s+")");var o=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(o?" ":"")+s:c==="left"?s+(o?" ":"")+this.op:s+this.op}else if(m.length===2){var u=m[0].toString(r),p=m[1].toString(r);return f[0]&&(u="("+u+")"),f[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?u+" "+p:u+" "+this.op+" "+p}else if(m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var v=m.map(function(h,b){return h=h.toString(r),f[b]&&(h="("+h+")"),h});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?v.join(" "):v.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"},a.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},a.fromJSON=function(r){return new a(r.op,r.fn,r.args,r.implicit,r.isPercentage)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!1);if(m.length===1){var c=zn(this,i),s=m[0].toHTML(r);return f[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Gr(this.op)+"</span>"+s:s+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Gr(this.op)+"</span>"}else if(m.length===2){var o=m[0].toHTML(r),u=m[1].toHTML(r);return f[0]&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),f[1]&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?o+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+u:o+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Gr(this.op)+"</span>"+u}else{var p=m.map(function(v,h){return v=v.toHTML(r),f[h]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),v});return m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Gr(this.op)+"</span>"):'<span class="math-function">'+Gr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+p.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}},a.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!0),c=He[this.fn];if(c=typeof c=="undefined"?this.op:c,m.length===1){var s=zn(this,i),o=m[0].toTex(r);return f[0]&&(o="\\left(".concat(o,"\\right)")),s==="right"?c+o:o+c}else if(m.length===2){var u=m[0],p=u.toTex(r);f[0]&&(p="\\left(".concat(p,"\\right)"));var v=m[1],h=v.toTex(r);f[1]&&(h="\\left(".concat(h,"\\right)"));var b;switch(i==="keep"?b=u.getIdentifier():b=u.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+p+"}{"+h+"}";case"OperatorNode:pow":switch(p="{"+p+"}",h="{"+h+"}",b){case"ConditionalNode":case"OperatorNode:divide":p="\\left(".concat(p,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return p+"~"+h}return p+c+h}else if(m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var w=m.map(function(N,g){return N=N.toTex(r),f[g]&&(N="\\left(".concat(N,"\\right)")),N});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit?w.join("~"):w.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+m.map(function(N){return N.toTex(r)}).join(",")+"\\right)"},a.prototype.getIdentifier=function(){return this.type+":"+this.fn},a},{isClass:!0,isNode:!0}),_N="ParenthesisNode",$N=["Node"],IN=R(_N,$N,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(t))throw new TypeError('Node expected for parameter "content"');this.content=t}return a.prototype=new n,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,a.prototype._compile=function(t,r){return this.content._compile(t,r)},a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(t){t(this.content,"content",this)},a.prototype.map=function(t){var r=t(this.content,"content",this);return new a(r)},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?"("+this.content.toString(t)+")":this.content.toString(t)},a.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},a.fromJSON=function(t){return new a(t.content)},a.prototype.toHTML=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(t)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(t)},a.prototype._toTex=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?"\\left(".concat(this.content.toTex(t),"\\right)"):this.content.toTex(t)},a},{isClass:!0,isNode:!0}),qN="RangeNode",RN=["Node"],FN=R(qN,RN,e=>{var{Node:n}=e;function a(r,i,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(r))throw new TypeError("Node expected");if(!Ve(i))throw new TypeError("Node expected");if(l&&!Ve(l))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=r,this.end=i,this.step=l||null}a.prototype=new n,a.prototype.type="RangeNode",a.prototype.isRangeNode=!0,a.prototype.needsEnd=function(){var r=this.filter(function(i){return xr(i)&&i.name==="end"});return r.length>0},a.prototype._compile=function(r,i){var l=r.range,m=this.start._compile(r,i),f=this.end._compile(r,i);if(this.step){var c=this.step._compile(r,i);return function(o,u,p){return l(m(o,u,p),f(o,u,p),c(o,u,p))}}else return function(o,u,p){return l(m(o,u,p),f(o,u,p))}},a.prototype.forEach=function(r){r(this.start,"start",this),r(this.end,"end",this),this.step&&r(this.step,"step",this)},a.prototype.map=function(r){return new a(this._ifNode(r(this.start,"start",this)),this._ifNode(r(this.end,"end",this)),this.step&&this._ifNode(r(this.step,"step",this)))},a.prototype.clone=function(){return new a(this.start,this.end,this.step&&this.step)};function t(r,i){var l=Je(r,i),m={},f=Je(r.start,i);if(m.start=f!==null&&f<=l||i==="all",r.step){var c=Je(r.step,i);m.step=c!==null&&c<=l||i==="all"}var s=Je(r.end,i);return m.end=s!==null&&s<=l||i==="all",m}return a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m,f=this.start.toString(r);if(l.start&&(f="("+f+")"),m=f,this.step){var c=this.step.toString(r);l.step&&(c="("+c+")"),m+=":"+c}var s=this.end.toString(r);return l.end&&(s="("+s+")"),m+=":"+s,m},a.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},a.fromJSON=function(r){return new a(r.start,r.end,r.step)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m,f=this.start.toHTML(r);if(l.start&&(f='<span class="math-parenthesis math-round-parenthesis">(</span>'+f+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m=f,this.step){var c=this.step.toHTML(r);l.step&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+='<span class="math-operator math-range-operator">:</span>'+c}var s=this.end.toHTML(r);return l.end&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+='<span class="math-operator math-range-operator">:</span>'+s,m},a.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m=this.start.toTex(r);if(l.start&&(m="\\left(".concat(m,"\\right)")),this.step){var f=this.step.toTex(r);l.step&&(f="\\left(".concat(f,"\\right)")),m+=":"+f}var c=this.end.toTex(r);return l.end&&(c="\\left(".concat(c,"\\right)")),m+=":"+c,m},a},{isClass:!0,isNode:!0}),zN="RelationalNode",PN=["Node"],UN=R(zN,PN,e=>{var{Node:n}=e;function a(t,r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(t))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(r))throw new TypeError("Parameter params must be an array");if(t.length!==r.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=t,this.params=r}return a.prototype=new n,a.prototype.type="RelationalNode",a.prototype.isRelationalNode=!0,a.prototype._compile=function(t,r){var i=this,l=this.params.map(m=>m._compile(t,r));return function(f,c,s){for(var o,u=l[0](f,c,s),p=0;p<i.conditionals.length;p++){o=u,u=l[p+1](f,c,s);var v=Vr(t,i.conditionals[p]);if(!v(o,u))return!1}return!0}},a.prototype.forEach=function(t){this.params.forEach((r,i)=>t(r,"params["+i+"]",this),this)},a.prototype.map=function(t){return new a(this.conditionals.slice(),this.params.map((r,i)=>this._ifNode(t(r,"params["+i+"]",this)),this))},a.prototype.clone=function(){return new a(this.conditionals,this.params)},a.prototype._toString=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(s,o){var u=Je(s,r);return r==="all"||u!==null&&u<=i?"("+s.toString(t)+")":s.toString(t)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=l[0],c=0;c<this.conditionals.length;c++)f+=" "+m[this.conditionals[c]]+" "+l[c+1];return f},a.prototype.toJSON=function(){return{mathjs:"RelationalNode",conditionals:this.conditionals,params:this.params}},a.fromJSON=function(t){return new a(t.conditionals,t.params)},a.prototype.toHTML=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(s,o){var u=Je(s,r);return r==="all"||u!==null&&u<=i?'<span class="math-parenthesis math-round-parenthesis">(</span>'+s.toHTML(t)+'<span class="math-parenthesis math-round-parenthesis">)</span>':s.toHTML(t)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=l[0],c=0;c<this.conditionals.length;c++)f+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Gr(m[this.conditionals[c]])+"</span>"+l[c+1];return f},a.prototype._toTex=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(c,s){var o=Je(c,r);return r==="all"||o!==null&&o<=i?"\\left("+c.toTex(t)+"\right)":c.toTex(t)}),m=l[0],f=0;f<this.conditionals.length;f++)m+=He[this.conditionals[f]]+l[f+1];return m},a},{isClass:!0,isNode:!0}),LN="SymbolNode",kN=["math","?Unit","Node"],HN=R(LN,kN,e=>{var{math:n,Unit:a,Node:t}=e;function r(l){return a?a.isValuelessUnit(l):!1}function i(l){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(typeof l!="string")throw new TypeError('String expected for parameter "name"');this.name=l}return i.prototype=new t,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(l,m){var f=this.name;if(m[f]===!0)return function(s,o,u){return o[f]};if(f in l)return function(s,o,u){return s.has(f)?s.get(f):Vr(l,f)};var c=r(f);return function(s,o,u){return s.has(f)?s.get(f):c?new a(null,f):i.onUndefinedSymbol(f)}},i.prototype.forEach=function(l){},i.prototype.map=function(l){return this.clone()},i.onUndefinedSymbol=function(l){throw new Error("Undefined symbol "+l)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(l){return this.name},i.prototype.toHTML=function(l){var m=Gr(this.name);return m==="true"||m==="false"?'<span class="math-symbol math-boolean">'+m+"</span>":m==="i"?'<span class="math-symbol math-imaginary-symbol">'+m+"</span>":m==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+m+"</span>":m==="NaN"?'<span class="math-symbol math-nan-symbol">'+m+"</span>":m==="null"?'<span class="math-symbol math-null-symbol">'+m+"</span>":m==="undefined"?'<span class="math-symbol math-undefined-symbol">'+m+"</span>":'<span class="math-symbol">'+m+"</span>"},i.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},i.fromJSON=function(l){return new i(l.name)},i.prototype._toTex=function(l){var m=!1;typeof n[this.name]=="undefined"&&r(this.name)&&(m=!0);var f=nl(this.name,m);return f[0]==="\\"?f:" "+f},i},{isClass:!0,isNode:!0});function Pn(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];return typeof e.createSubScope=="function"?Ao(e.createSubScope(),...a):Ao(gt(),e,...a)}var GN="FunctionNode",VN=["math","Node","SymbolNode"],ZN=R(GN,VN,e=>{var{math:n,Node:a,SymbolNode:t}=e;function r(c,s){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(typeof c=="string"&&(c=new t(c)),!Ve(c))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(s)||!s.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=c,this.args=s||[],Object.defineProperty(this,"name",{get:(function(){return this.fn.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}r.prototype=new a,r.prototype.type="FunctionNode",r.prototype.isFunctionNode=!0;var i=c=>Re(c,{truncate:78});r.prototype._compile=function(c,s){if(!(this instanceof r))throw new TypeError("No valid FunctionNode");var o=this.args.map(S=>S._compile(c,s));if(xr(this.fn)){var u=this.fn.name;if(s[u]){var w=this.args;return function(O,M,_){var E=M[u];if(typeof E!="function")throw new TypeError("Argument '".concat(u,"' was not a function; received: ").concat(i(E)));if(E.rawArgs)return E(w,c,Pn(O,M),O);var $=o.map(z=>z(O,M,_));return E.apply(E,$)}}else{var p=u in c?Vr(c,u):void 0,v=typeof p=="function"&&p.rawArgs===!0,h=S=>{var O;if(S.has(u))O=S.get(u);else if(u in c)O=Vr(c,u);else return r.onUndefinedFunction(u);if(typeof O=="function")return O;throw new TypeError("'".concat(u,`' is not a function; its value is:
32
+ `).concat(i(O)))};if(v){var b=this.args;return function(O,M,_){var E=h(O);return E(b,c,Pn(O,M),O)}}else switch(o.length){case 0:return function(O,M,_){var E=h(O);return E()};case 1:return function(O,M,_){var E=h(O),$=o[0];return E($(O,M,_))};case 2:return function(O,M,_){var E=h(O),$=o[0],z=o[1];return E($(O,M,_),z(O,M,_))};default:return function(O,M,_){var E=h(O),$=o.map(z=>z(O,M,_));return E(...$)}}}}else if(Lt(this.fn)&&tn(this.fn.index)&&this.fn.index.isObjectProperty()){var N=this.fn.object._compile(c,s),g=this.fn.index.getObjectProperty(),y=this.args;return function(O,M,_){var E=N(O,M,_);hv(E,g);var $=E[g]&&E[g].rawArgs;if($)return E[g](y,c,Pn(O,M),O);var z=o.map(I=>I(O,M,_));return E[g].apply(E,z)}}else{var x=this.fn.toString(),d=this.fn._compile(c,s),A=this.args;return function(O,M,_){var E=d(O,M,_);if(typeof E!="function")throw new TypeError("Expression '".concat(x,"' did not evaluate to a function; value is:")+`
33
+ `.concat(i(E)));if(E.rawArgs)return E(A,c,Pn(O,M),O);var $=o.map(z=>z(O,M,_));return E.apply(E,$)}}},r.prototype.forEach=function(c){c(this.fn,"fn",this);for(var s=0;s<this.args.length;s++)c(this.args[s],"args["+s+"]",this)},r.prototype.map=function(c){for(var s=this._ifNode(c(this.fn,"fn",this)),o=[],u=0;u<this.args.length;u++)o[u]=this._ifNode(c(this.args[u],"args["+u+"]",this));return new r(s,o)},r.prototype.clone=function(){return new r(this.fn,this.args.slice(0))},r.onUndefinedFunction=function(c){throw new Error("Undefined function "+c)};var l=r.prototype.toString;r.prototype.toString=function(c){var s,o=this.fn.toString(c);return c&&typeof c.handler=="object"&&Me(c.handler,o)&&(s=c.handler[o](this,c)),typeof s!="undefined"?s:l.call(this,c)},r.prototype._toString=function(c){var s=this.args.map(function(u){return u.toString(c)}),o=Cn(this.fn)?"("+this.fn.toString(c)+")":this.fn.toString(c);return o+"("+s.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"FunctionNode",fn:this.fn,args:this.args}},r.fromJSON=function(c){return new r(c.fn,c.args)},r.prototype.toHTML=function(c){var s=this.args.map(function(o){return o.toHTML(c)});return'<span class="math-function">'+Gr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+s.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'};function m(c,s,o){for(var u="",p=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,v=0,h;(h=p.exec(c))!==null;)if(u+=c.substring(v,h.index),v=h.index,h[0]==="$$")u+="$",v++;else{v+=h[0].length;var b=s[h[1]];if(!b)throw new ReferenceError("Template: Property "+h[1]+" does not exist.");if(h[2]===void 0)switch(typeof b){case"string":u+=b;break;case"object":if(Ve(b))u+=b.toTex(o);else if(Array.isArray(b))u+=b.map(function(w,N){if(Ve(w))return w.toTex(o);throw new TypeError("Template: "+h[1]+"["+N+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes")}else if(Ve(b[h[2]]&&b[h[2]]))u+=b[h[2]].toTex(o);else throw new TypeError("Template: "+h[1]+"["+h[2]+"] is not a Node.")}return u+=c.slice(v),u}var f=r.prototype.toTex;return r.prototype.toTex=function(c){var s;return c&&typeof c.handler=="object"&&Me(c.handler,this.name)&&(s=c.handler[this.name](this,c)),typeof s!="undefined"?s:f.call(this,c)},r.prototype._toTex=function(c){var s=this.args.map(function(p){return p.toTex(c)}),o;rl[this.name]&&(o=rl[this.name]),n[this.name]&&(typeof n[this.name].toTex=="function"||typeof n[this.name].toTex=="object"||typeof n[this.name].toTex=="string")&&(o=n[this.name].toTex);var u;switch(typeof o){case"function":u=o(this,c);break;case"string":u=m(o,this,c);break;case"object":switch(typeof o[s.length]){case"function":u=o[s.length](this,c);break;case"string":u=m(o[s.length],this,c);break}}return typeof u!="undefined"?u:m(dN,this,c)},r.prototype.getIdentifier=function(){return this.type+":"+this.name},r},{isClass:!0,isNode:!0}),al="parse",XN=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],YN=R(al,XN,e=>{var{typed:n,numeric:a,config:t,AccessorNode:r,ArrayNode:i,AssignmentNode:l,BlockNode:m,ConditionalNode:f,ConstantNode:c,FunctionAssignmentNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,RangeNode:b,RelationalNode:w,SymbolNode:N}=e,g=n(al,{string:function(X){return H(X,{})},"Array | Matrix":function(X){return y(X,{})},"string, Object":function(X,ae){var he=ae.nodes!==void 0?ae.nodes:{};return H(X,he)},"Array | Matrix, Object":y});function y(C){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ae=X.nodes!==void 0?X.nodes:{};return be(C,function(he){if(typeof he!="string")throw new TypeError("String expected");return H(he,ae)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},d={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},A={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},O=["NaN","Infinity"];function M(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function _(C,X){return C.expression.substr(C.index,X)}function E(C){return _(C,1)}function $(C){C.index++}function z(C){return C.expression.charAt(C.index-1)}function I(C){return C.expression.charAt(C.index+1)}function T(C){for(C.tokenType=x.NULL,C.token="",C.comment="";;){if(E(C)==="#")for(;E(C)!==`
34
34
  `&&E(C)!=="";)C.comment+=E(C),$(C);if(g.isWhitespace(E(C),C.nestingLevel))$(C);else break}if(E(C)===""){C.tokenType=x.DELIMITER;return}if(E(C)===`
35
35
  `&&!C.nestingLevel){C.tokenType=x.DELIMITER,C.token=E(C),$(C);return}var X=E(C),ae=_(C,2),he=_(C,3);if(he.length===3&&d[he]){C.tokenType=x.DELIMITER,C.token=he,$(C),$(C),$(C);return}if(ae.length===2&&d[ae]){C.tokenType=x.DELIMITER,C.token=ae,$(C),$(C);return}if(d[X]){C.tokenType=x.DELIMITER,C.token=X,$(C);return}if(g.isDigitDot(X)){C.tokenType=x.NUMBER;var qe=_(C,2);if(qe==="0b"||qe==="0o"||qe==="0x"){for(C.token+=E(C),$(C),C.token+=E(C),$(C);g.isHexDigit(E(C));)C.token+=E(C),$(C);if(E(C)===".")for(C.token+=".",$(C);g.isHexDigit(E(C));)C.token+=E(C),$(C);else if(E(C)==="i")for(C.token+="i",$(C);g.isDigit(E(C));)C.token+=E(C),$(C);return}if(E(C)==="."){if(C.token+=E(C),$(C),!g.isDigit(E(C))){C.tokenType=x.DELIMITER;return}}else{for(;g.isDigit(E(C));)C.token+=E(C),$(C);g.isDecimalMark(E(C),I(C))&&(C.token+=E(C),$(C))}for(;g.isDigit(E(C));)C.token+=E(C),$(C);if(E(C)==="E"||E(C)==="e"){if(g.isDigit(I(C))||I(C)==="-"||I(C)==="+"){if(C.token+=E(C),$(C),(E(C)==="+"||E(C)==="-")&&(C.token+=E(C),$(C)),!g.isDigit(E(C)))throw Ze(C,'Digit expected, got "'+E(C)+'"');for(;g.isDigit(E(C));)C.token+=E(C),$(C);if(g.isDecimalMark(E(C),I(C)))throw Ze(C,'Digit expected, got "'+E(C)+'"')}else if(I(C)===".")throw $(C),Ze(C,'Digit expected, got "'+E(C)+'"')}return}if(g.isAlpha(E(C),z(C),I(C))){for(;g.isAlpha(E(C),z(C),I(C))||g.isDigit(E(C));)C.token+=E(C),$(C);Me(A,C.token)?C.tokenType=x.DELIMITER:C.tokenType=x.SYMBOL;return}for(C.tokenType=x.UNKNOWN;E(C)!=="";)C.token+=E(C),$(C);throw Ze(C,'Syntax error in part "'+C.token+'"')}function B(C){do T(C);while(C.token===`
36
36
  `)}function G(C){C.nestingLevel++}function D(C){C.nestingLevel--}g.isAlpha=function(X,ae,he){return g.isValidLatinOrGreek(X)||g.isValidMathSymbol(X,he)||g.isValidMathSymbol(ae,X)},g.isValidLatinOrGreek=function(X){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(X)},g.isValidMathSymbol=function(X,ae){return/^[\uD835]$/.test(X)&&/^[\uDC00-\uDFFF]$/.test(ae)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(ae)},g.isWhitespace=function(X,ae){return X===" "||X===" "||X===`
37
- `&&ae>0},g.isDecimalMark=function(X,ae){return X==="."&&ae!=="/"&&ae!=="*"&&ae!=="^"},g.isDigitDot=function(X){return X>="0"&&X<="9"||X==="."},g.isDigit=function(X){return X>="0"&&X<="9"},g.isHexDigit=function(X){return X>="0"&&X<="9"||X>="a"&&X<="f"||X>="A"&&X<="F"};function H(C,X){var ae=M();rr(ae,{expression:C,extraNodes:X}),T(ae);var he=W(ae);if(ae.token!=="")throw ae.tokenType===x.DELIMITER?Pt(ae,"Unexpected operator "+ae.token):Ze(ae,'Unexpected part "'+ae.token+'"');return he}function W(C){var X,ae=[],he;for(C.token!==""&&C.token!==`
37
+ `&&ae>0},g.isDecimalMark=function(X,ae){return X==="."&&ae!=="/"&&ae!=="*"&&ae!=="^"},g.isDigitDot=function(X){return X>="0"&&X<="9"||X==="."},g.isDigit=function(X){return X>="0"&&X<="9"},g.isHexDigit=function(X){return X>="0"&&X<="9"||X>="a"&&X<="f"||X>="A"&&X<="F"};function H(C,X){var ae=M();ar(ae,{expression:C,extraNodes:X}),T(ae);var he=W(ae);if(ae.token!=="")throw ae.tokenType===x.DELIMITER?Pt(ae,"Unexpected operator "+ae.token):Ze(ae,'Unexpected part "'+ae.token+'"');return he}function W(C){var X,ae=[],he;for(C.token!==""&&C.token!==`
38
38
  `&&C.token!==";"&&(X=j(C),X.comment=C.comment);C.token===`
39
39
  `||C.token===";";)ae.length===0&&X&&(he=C.token!==";",ae.push({node:X,visible:he})),T(C),C.token!==`
40
- `&&C.token!==";"&&C.token!==""&&(X=j(C),X.comment=C.comment,he=C.token!==";",ae.push({node:X,visible:he}));return ae.length>0?new m(ae):(X||(X=new c(void 0),X.comment=C.comment),X)}function j(C){var X,ae,he,qe,Ue=V(C);if(C.token==="="){if(xr(Ue))return X=Ue.name,B(C),he=j(C),new l(new N(X),he);if(Lt(Ue))return B(C),he=j(C),new l(Ue.object,Ue.index,he);if(kt(Ue)&&xr(Ue.fn)&&(qe=!0,ae=[],X=Ue.name,Ue.args.forEach(function(gr,no){xr(gr)?ae[no]=gr.name:qe=!1}),qe))return B(C),he=j(C),new s(X,ae,he);throw Ze(C,"Invalid left hand side of assignment operator =")}return Ue}function V(C){for(var X=K(C);C.token==="?";){var ae=C.conditionalLevel;C.conditionalLevel=C.nestingLevel,B(C);var he=X,qe=j(C);if(C.token!==":")throw Ze(C,"False part of conditional expression expected");C.conditionalLevel=null,B(C);var Ue=j(C);X=new f(he,qe,Ue),C.conditionalLevel=ae}return X}function K(C){for(var X=te(C);C.token==="or";)B(C),X=new v("or","or",[X,te(C)]);return X}function te(C){for(var X=re(C);C.token==="xor";)B(C),X=new v("xor","xor",[X,re(C)]);return X}function re(C){for(var X=ie(C);C.token==="and";)B(C),X=new v("and","and",[X,ie(C)]);return X}function ie(C){for(var X=ne(C);C.token==="|";)B(C),X=new v("|","bitOr",[X,ne(C)]);return X}function ne(C){for(var X=ue(C);C.token==="^|";)B(C),X=new v("^|","bitXor",[X,ue(C)]);return X}function ue(C){for(var X=ee(C);C.token==="&";)B(C),X=new v("&","bitAnd",[X,ee(C)]);return X}function ee(C){for(var X=[ye(C)],ae=[],he={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Me(he,C.token);){var qe={name:C.token,fn:he[C.token]};ae.push(qe),B(C),X.push(ye(C))}return X.length===1?X[0]:X.length===2?new v(ae[0].name,ae[0].fn,X):new w(ae.map(Ue=>Ue.fn),X)}function ye(C){var X,ae,he,qe;X=we(C);for(var Ue={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),qe=[X,we(C)],X=new v(ae,he,qe);return X}function we(C){var X,ae,he,qe;X=me(C);for(var Ue={to:"to",in:"to"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),ae==="in"&&C.token===""?X=new v("*","multiply",[X,new N("in")],!0):(qe=[X,me(C)],X=new v(ae,he,qe));return X}function me(C){var X,ae=[];if(C.token===":"?X=new c(1):X=xe(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(ae.push(X);C.token===":"&&ae.length<3;)B(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?ae.push(new N("end")):ae.push(xe(C));ae.length===3?X=new b(ae[0],ae[2],ae[1]):X=new b(ae[0],ae[1])}return X}function xe(C){var X,ae,he,qe;X=F(C);for(var Ue={"+":"add","-":"subtract"};Me(Ue,C.token);){ae=C.token,he=Ue[ae],B(C);var gr=F(C);gr.isPercentage?qe=[X,new v("*","multiply",[X,gr])]:qe=[X,gr],X=new v(ae,he,qe)}return X}function F(C){var X,ae,he,qe;X=Y(C),ae=X;for(var Ue={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Me(Ue,C.token);)he=C.token,qe=Ue[he],B(C),ae=Y(C),X=new v(he,qe,[X,ae]);return X}function Y(C){var X,ae;for(X=k(C),ae=X;C.tokenType===x.SYMBOL||C.token==="in"&&Ye(X)||C.tokenType===x.NUMBER&&!Ye(ae)&&(!_r(ae)||ae.op==="!")||C.token==="(";)ae=k(C),X=new v("*","multiply",[X,ae],!0);return X}function k(C){for(var X=U(C),ae=X,he=[];C.token==="/"&&Ye(ae);)if(he.push(rr({},C)),B(C),C.tokenType===x.NUMBER)if(he.push(rr({},C)),B(C),C.tokenType===x.SYMBOL||C.token==="(")rr(C,he.pop()),he.pop(),ae=U(C),X=new v("/","divide",[X,ae]);else{he.pop(),rr(C,he.pop());break}else{rr(C,he.pop());break}return X}function U(C){var X,ae,he,qe;X=J(C);for(var Ue={"%":"mod",mod:"mod"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),ae==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?X=new v("/","divide",[X,new c(100)],!1,!0):(qe=[X,J(C)],X=new v(ae,he,qe));return X}function J(C){var X,ae,he,qe={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Me(qe,C.token)?(he=qe[C.token],X=C.token,B(C),ae=[J(C)],new v(X,he,ae)):q(C)}function q(C){var X,ae,he,qe;return X=P(C),(C.token==="^"||C.token===".^")&&(ae=C.token,he=ae==="^"?"pow":"dotPow",B(C),qe=[X,J(C)],X=new v(ae,he,qe)),X}function P(C){var X,ae,he,qe;X=Q(C);for(var Ue={"!":"factorial","'":"ctranspose"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],T(C),qe=[X],X=new v(ae,he,qe),X=se(C,X);return X}function Q(C){var X=[];if(C.tokenType===x.SYMBOL&&Me(C.extraNodes,C.token)){var ae=C.extraNodes[C.token];if(T(C),C.token==="("){if(X=[],G(C),T(C),C.token!==")")for(X.push(j(C));C.token===",";)T(C),X.push(j(C));if(C.token!==")")throw Ze(C,"Parenthesis ) expected");D(C),T(C)}return new ae(X)}return L(C)}function L(C){var X,ae;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A?(ae=C.token,T(C),Me(S,ae)?X=new c(S[ae]):O.indexOf(ae)!==-1?X=new c(a(ae,"number")):X=new N(ae),X=se(C,X),X):fe(C)}function se(C,X,ae){for(var he;C.token==="("||C.token==="["||C.token===".";)if(he=[],C.token==="(")if(xr(X)||Lt(X)){if(G(C),T(C),C.token!==")")for(he.push(j(C));C.token===",";)T(C),he.push(j(C));if(C.token!==")")throw Ze(C,"Parenthesis ) expected");D(C),T(C),X=new o(X,he)}else return X;else if(C.token==="["){if(G(C),T(C),C.token!=="]")for(he.push(j(C));C.token===",";)T(C),he.push(j(C));if(C.token!=="]")throw Ze(C,"Parenthesis ] expected");D(C),T(C),X=new r(X,new u(he))}else{if(T(C),C.tokenType!==x.SYMBOL)throw Ze(C,"Property name expected after dot");he.push(new c(C.token)),T(C);var qe=!0;X=new r(X,new u(he,qe))}return X}function fe(C){var X,ae;return C.token==='"'?(ae=ge(C),X=new c(ae),X=se(C,X),X):pe(C)}function ge(C){for(var X="";E(C)!==""&&E(C)!=='"';)E(C)==="\\"&&(X+=E(C),$(C)),X+=E(C),$(C);if(T(C),C.token!=='"')throw Ze(C,'End of string " expected');return T(C),JSON.parse('"'+X+'"')}function pe(C){var X,ae;return C.token==="'"?(ae=ve(C),X=new c(ae),X=se(C,X),X):Ne(C)}function ve(C){for(var X="";E(C)!==""&&E(C)!=="'";)E(C)==="\\"&&(X+=E(C),$(C)),X+=E(C),$(C);if(T(C),C.token!=="'")throw Ze(C,"End of string ' expected");return T(C),JSON.parse('"'+X+'"')}function Ne(C){var X,ae,he,qe;if(C.token==="["){if(G(C),T(C),C.token!=="]"){var Ue=Qe(C);if(C.token===";"){for(he=1,ae=[Ue];C.token===";";)T(C),ae[he]=Qe(C),he++;if(C.token!=="]")throw Ze(C,"End of matrix ] expected");D(C),T(C),qe=ae[0].items.length;for(var gr=1;gr<he;gr++)if(ae[gr].items.length!==qe)throw Pt(C,"Column dimensions mismatch ("+ae[gr].items.length+" !== "+qe+")");X=new i(ae)}else{if(C.token!=="]")throw Ze(C,"End of matrix ] expected");D(C),T(C),X=Ue}}else D(C),T(C),X=new i([]);return se(C,X)}return fr(C)}function Qe(C){for(var X=[j(C)],ae=1;C.token===",";)T(C),X[ae]=j(C),ae++;return new i(X)}function fr(C){if(C.token==="{"){G(C);var X,ae={};do if(T(C),C.token!=="}"){if(C.token==='"')X=ge(C);else if(C.token==="'")X=ve(C);else if(C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A)X=C.token,T(C);else throw Ze(C,"Symbol or string expected as object key");if(C.token!==":")throw Ze(C,"Colon : expected after object key");T(C),ae[X]=j(C)}while(C.token===",");if(C.token!=="}")throw Ze(C,"Comma , or bracket } expected after object value");D(C),T(C);var he=new p(ae);return he=se(C,he),he}return nr(C)}function nr(C){var X;return C.tokenType===x.NUMBER?(X=C.token,T(C),new c(a(X,t.number))):Wr(C)}function Wr(C){var X;if(C.token==="("){if(G(C),T(C),X=j(C),C.token!==")")throw Ze(C,"Parenthesis ) expected");return D(C),T(C),X=new h(X),X=se(C,X),X}return Lr(C)}function Lr(C){throw C.token===""?Ze(C,"Unexpected end of expression"):Ze(C,"Value expected")}function Ot(C){return C.index-C.token.length+1}function Ze(C,X){var ae=Ot(C),he=new SyntaxError(X+" (char "+ae+")");return he.char=ae,he}function Pt(C,X){var ae=Ot(C),he=new SyntaxError(X+" (char "+ae+")");return he.char=ae,he}return g}),ol="compile",JN=["typed","parse"],QN=R(ol,JN,e=>{var{typed:n,parse:a}=e;return n(ol,{string:function(r){return a(r).compile()},"Array | Matrix":function(r){return be(r,function(i){return a(i).compile()})}})}),sl="evaluate",KN=["typed","parse"],jN=R(sl,KN,e=>{var{typed:n,parse:a}=e;return n(sl,{string:function(r){var i=gt();return a(r).compile().evaluate(i)},"string, Map | Object":function(r,i){return a(r).compile().evaluate(i)},"Array | Matrix":function(r){var i=gt();return be(r,function(l){return a(l).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(r,i){return be(r,function(l){return a(l).compile().evaluate(i)})}})}),eM="Parser",rM=["evaluate"],tM=R(eM,rM,e=>{var{evaluate:n}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:gt(),writable:!1})}return a.prototype.type="Parser",a.prototype.isParser=!0,a.prototype.evaluate=function(t){return n(t,this.scope)},a.prototype.get=function(t){if(this.scope.has(t))return this.scope.get(t)},a.prototype.getAll=function(){return xv(this.scope)},a.prototype.getAllAsMap=function(){return this.scope},a.prototype.set=function(t,r){return this.scope.set(t,r),r},a.prototype.remove=function(t){this.scope.delete(t)},a.prototype.clear=function(){this.scope.clear()},a},{isClass:!0}),ul="parser",nM=["typed","Parser"],aM=R(ul,nM,e=>{var{typed:n,Parser:a}=e;return n(ul,{"":function(){return new a}})}),cl="lup",iM=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],oM=R(cl,iM,e=>{var{typed:n,matrix:a,abs:t,addScalar:r,divideScalar:i,multiplyScalar:l,subtract:m,larger:f,equalScalar:c,unaryMinus:s,DenseMatrix:o,SparseMatrix:u,Spa:p}=e;return n(cl,{DenseMatrix:function(w){return v(w)},SparseMatrix:function(w){return h(w)},Array:function(w){var N=a(w),g=v(N);return{L:g.L.valueOf(),U:g.U.valueOf(),p:g.p}}});function v(b){var w=b._size[0],N=b._size[1],g=Math.min(w,N),y=Ce(b._data),x=[],d=[w,g],A=[],S=[g,N],O,M,_,E=[];for(O=0;O<w;O++)E[O]=O;for(M=0;M<N;M++){if(M>0)for(O=0;O<w;O++){var $=Math.min(O,M),z=0;for(_=0;_<$;_++)z=r(z,l(y[O][_],y[_][M]));y[O][M]=m(y[O][M],z)}var I=M,T=0,B=0;for(O=M;O<w;O++){var G=y[O][M],D=t(G);f(D,T)&&(I=O,T=D,B=G)}if(M!==I&&(E[M]=[E[I],E[I]=E[M]][0],o._swapRows(M,I,y)),M<w)for(O=M+1;O<w;O++){var H=y[O][M];c(H,0)||(y[O][M]=i(y[O][M],B))}}for(M=0;M<N;M++)for(O=0;O<w;O++){if(M===0&&(O<N&&(A[O]=[]),x[O]=[]),O<M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=0);continue}if(O===M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=1);continue}O<N&&(A[O][M]=0),M<w&&(x[O][M]=y[O][M])}var W=new o({data:x,size:d}),j=new o({data:A,size:S}),V=[];for(O=0,g=E.length;O<g;O++)V[E[O]]=O;return{L:W,U:j,p:V,toString:function(){return"L: "+this.L.toString()+`
40
+ `&&C.token!==";"&&C.token!==""&&(X=j(C),X.comment=C.comment,he=C.token!==";",ae.push({node:X,visible:he}));return ae.length>0?new m(ae):(X||(X=new c(void 0),X.comment=C.comment),X)}function j(C){var X,ae,he,qe,Ue=V(C);if(C.token==="="){if(xr(Ue))return X=Ue.name,B(C),he=j(C),new l(new N(X),he);if(Lt(Ue))return B(C),he=j(C),new l(Ue.object,Ue.index,he);if(kt(Ue)&&xr(Ue.fn)&&(qe=!0,ae=[],X=Ue.name,Ue.args.forEach(function(dr,to){xr(dr)?ae[to]=dr.name:qe=!1}),qe))return B(C),he=j(C),new s(X,ae,he);throw Ze(C,"Invalid left hand side of assignment operator =")}return Ue}function V(C){for(var X=K(C);C.token==="?";){var ae=C.conditionalLevel;C.conditionalLevel=C.nestingLevel,B(C);var he=X,qe=j(C);if(C.token!==":")throw Ze(C,"False part of conditional expression expected");C.conditionalLevel=null,B(C);var Ue=j(C);X=new f(he,qe,Ue),C.conditionalLevel=ae}return X}function K(C){for(var X=te(C);C.token==="or";)B(C),X=new v("or","or",[X,te(C)]);return X}function te(C){for(var X=re(C);C.token==="xor";)B(C),X=new v("xor","xor",[X,re(C)]);return X}function re(C){for(var X=ie(C);C.token==="and";)B(C),X=new v("and","and",[X,ie(C)]);return X}function ie(C){for(var X=ne(C);C.token==="|";)B(C),X=new v("|","bitOr",[X,ne(C)]);return X}function ne(C){for(var X=ue(C);C.token==="^|";)B(C),X=new v("^|","bitXor",[X,ue(C)]);return X}function ue(C){for(var X=ee(C);C.token==="&";)B(C),X=new v("&","bitAnd",[X,ee(C)]);return X}function ee(C){for(var X=[ye(C)],ae=[],he={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Me(he,C.token);){var qe={name:C.token,fn:he[C.token]};ae.push(qe),B(C),X.push(ye(C))}return X.length===1?X[0]:X.length===2?new v(ae[0].name,ae[0].fn,X):new w(ae.map(Ue=>Ue.fn),X)}function ye(C){var X,ae,he,qe;X=we(C);for(var Ue={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),qe=[X,we(C)],X=new v(ae,he,qe);return X}function we(C){var X,ae,he,qe;X=me(C);for(var Ue={to:"to",in:"to"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),ae==="in"&&C.token===""?X=new v("*","multiply",[X,new N("in")],!0):(qe=[X,me(C)],X=new v(ae,he,qe));return X}function me(C){var X,ae=[];if(C.token===":"?X=new c(1):X=xe(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(ae.push(X);C.token===":"&&ae.length<3;)B(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?ae.push(new N("end")):ae.push(xe(C));ae.length===3?X=new b(ae[0],ae[2],ae[1]):X=new b(ae[0],ae[1])}return X}function xe(C){var X,ae,he,qe;X=F(C);for(var Ue={"+":"add","-":"subtract"};Me(Ue,C.token);){ae=C.token,he=Ue[ae],B(C);var dr=F(C);dr.isPercentage?qe=[X,new v("*","multiply",[X,dr])]:qe=[X,dr],X=new v(ae,he,qe)}return X}function F(C){var X,ae,he,qe;X=Y(C),ae=X;for(var Ue={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Me(Ue,C.token);)he=C.token,qe=Ue[he],B(C),ae=Y(C),X=new v(he,qe,[X,ae]);return X}function Y(C){var X,ae;for(X=k(C),ae=X;C.tokenType===x.SYMBOL||C.token==="in"&&Ye(X)||C.tokenType===x.NUMBER&&!Ye(ae)&&(!$r(ae)||ae.op==="!")||C.token==="(";)ae=k(C),X=new v("*","multiply",[X,ae],!0);return X}function k(C){for(var X=U(C),ae=X,he=[];C.token==="/"&&Ye(ae);)if(he.push(ar({},C)),B(C),C.tokenType===x.NUMBER)if(he.push(ar({},C)),B(C),C.tokenType===x.SYMBOL||C.token==="(")ar(C,he.pop()),he.pop(),ae=U(C),X=new v("/","divide",[X,ae]);else{he.pop(),ar(C,he.pop());break}else{ar(C,he.pop());break}return X}function U(C){var X,ae,he,qe;X=J(C);for(var Ue={"%":"mod",mod:"mod"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),ae==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?X=new v("/","divide",[X,new c(100)],!1,!0):(qe=[X,J(C)],X=new v(ae,he,qe));return X}function J(C){var X,ae,he,qe={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Me(qe,C.token)?(he=qe[C.token],X=C.token,B(C),ae=[J(C)],new v(X,he,ae)):q(C)}function q(C){var X,ae,he,qe;return X=P(C),(C.token==="^"||C.token===".^")&&(ae=C.token,he=ae==="^"?"pow":"dotPow",B(C),qe=[X,J(C)],X=new v(ae,he,qe)),X}function P(C){var X,ae,he,qe;X=Q(C);for(var Ue={"!":"factorial","'":"ctranspose"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],T(C),qe=[X],X=new v(ae,he,qe),X=se(C,X);return X}function Q(C){var X=[];if(C.tokenType===x.SYMBOL&&Me(C.extraNodes,C.token)){var ae=C.extraNodes[C.token];if(T(C),C.token==="("){if(X=[],G(C),T(C),C.token!==")")for(X.push(j(C));C.token===",";)T(C),X.push(j(C));if(C.token!==")")throw Ze(C,"Parenthesis ) expected");D(C),T(C)}return new ae(X)}return L(C)}function L(C){var X,ae;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A?(ae=C.token,T(C),Me(S,ae)?X=new c(S[ae]):O.indexOf(ae)!==-1?X=new c(a(ae,"number")):X=new N(ae),X=se(C,X),X):fe(C)}function se(C,X,ae){for(var he;C.token==="("||C.token==="["||C.token===".";)if(he=[],C.token==="(")if(xr(X)||Lt(X)){if(G(C),T(C),C.token!==")")for(he.push(j(C));C.token===",";)T(C),he.push(j(C));if(C.token!==")")throw Ze(C,"Parenthesis ) expected");D(C),T(C),X=new o(X,he)}else return X;else if(C.token==="["){if(G(C),T(C),C.token!=="]")for(he.push(j(C));C.token===",";)T(C),he.push(j(C));if(C.token!=="]")throw Ze(C,"Parenthesis ] expected");D(C),T(C),X=new r(X,new u(he))}else{if(T(C),C.tokenType!==x.SYMBOL)throw Ze(C,"Property name expected after dot");he.push(new c(C.token)),T(C);var qe=!0;X=new r(X,new u(he,qe))}return X}function fe(C){var X,ae;return C.token==='"'?(ae=ge(C),X=new c(ae),X=se(C,X),X):pe(C)}function ge(C){for(var X="";E(C)!==""&&E(C)!=='"';)E(C)==="\\"&&(X+=E(C),$(C)),X+=E(C),$(C);if(T(C),C.token!=='"')throw Ze(C,'End of string " expected');return T(C),JSON.parse('"'+X+'"')}function pe(C){var X,ae;return C.token==="'"?(ae=ve(C),X=new c(ae),X=se(C,X),X):Ne(C)}function ve(C){for(var X="";E(C)!==""&&E(C)!=="'";)E(C)==="\\"&&(X+=E(C),$(C)),X+=E(C),$(C);if(T(C),C.token!=="'")throw Ze(C,"End of string ' expected");return T(C),JSON.parse('"'+X+'"')}function Ne(C){var X,ae,he,qe;if(C.token==="["){if(G(C),T(C),C.token!=="]"){var Ue=Qe(C);if(C.token===";"){for(he=1,ae=[Ue];C.token===";";)T(C),ae[he]=Qe(C),he++;if(C.token!=="]")throw Ze(C,"End of matrix ] expected");D(C),T(C),qe=ae[0].items.length;for(var dr=1;dr<he;dr++)if(ae[dr].items.length!==qe)throw Pt(C,"Column dimensions mismatch ("+ae[dr].items.length+" !== "+qe+")");X=new i(ae)}else{if(C.token!=="]")throw Ze(C,"End of matrix ] expected");D(C),T(C),X=Ue}}else D(C),T(C),X=new i([]);return se(C,X)}return cr(C)}function Qe(C){for(var X=[j(C)],ae=1;C.token===",";)T(C),X[ae]=j(C),ae++;return new i(X)}function cr(C){if(C.token==="{"){G(C);var X,ae={};do if(T(C),C.token!=="}"){if(C.token==='"')X=ge(C);else if(C.token==="'")X=ve(C);else if(C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A)X=C.token,T(C);else throw Ze(C,"Symbol or string expected as object key");if(C.token!==":")throw Ze(C,"Colon : expected after object key");T(C),ae[X]=j(C)}while(C.token===",");if(C.token!=="}")throw Ze(C,"Comma , or bracket } expected after object value");D(C),T(C);var he=new p(ae);return he=se(C,he),he}return tr(C)}function tr(C){var X;return C.tokenType===x.NUMBER?(X=C.token,T(C),new c(a(X,t.number))):Jr(C)}function Jr(C){var X;if(C.token==="("){if(G(C),T(C),X=j(C),C.token!==")")throw Ze(C,"Parenthesis ) expected");return D(C),T(C),X=new h(X),X=se(C,X),X}return Lr(C)}function Lr(C){throw C.token===""?Ze(C,"Unexpected end of expression"):Ze(C,"Value expected")}function Ot(C){return C.index-C.token.length+1}function Ze(C,X){var ae=Ot(C),he=new SyntaxError(X+" (char "+ae+")");return he.char=ae,he}function Pt(C,X){var ae=Ot(C),he=new SyntaxError(X+" (char "+ae+")");return he.char=ae,he}return g}),il="compile",WN=["typed","parse"],JN=R(il,WN,e=>{var{typed:n,parse:a}=e;return n(il,{string:function(r){return a(r).compile()},"Array | Matrix":function(r){return be(r,function(i){return a(i).compile()})}})}),ol="evaluate",QN=["typed","parse"],KN=R(ol,QN,e=>{var{typed:n,parse:a}=e;return n(ol,{string:function(r){var i=gt();return a(r).compile().evaluate(i)},"string, Map | Object":function(r,i){return a(r).compile().evaluate(i)},"Array | Matrix":function(r){var i=gt();return be(r,function(l){return a(l).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(r,i){return be(r,function(l){return a(l).compile().evaluate(i)})}})}),jN="Parser",eM=["evaluate"],rM=R(jN,eM,e=>{var{evaluate:n}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:gt(),writable:!1})}return a.prototype.type="Parser",a.prototype.isParser=!0,a.prototype.evaluate=function(t){return n(t,this.scope)},a.prototype.get=function(t){if(this.scope.has(t))return this.scope.get(t)},a.prototype.getAll=function(){return yv(this.scope)},a.prototype.getAllAsMap=function(){return this.scope},a.prototype.set=function(t,r){return this.scope.set(t,r),r},a.prototype.remove=function(t){this.scope.delete(t)},a.prototype.clear=function(){this.scope.clear()},a},{isClass:!0}),sl="parser",tM=["typed","Parser"],nM=R(sl,tM,e=>{var{typed:n,Parser:a}=e;return n(sl,{"":function(){return new a}})}),ul="lup",aM=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],iM=R(ul,aM,e=>{var{typed:n,matrix:a,abs:t,addScalar:r,divideScalar:i,multiplyScalar:l,subtract:m,larger:f,equalScalar:c,unaryMinus:s,DenseMatrix:o,SparseMatrix:u,Spa:p}=e;return n(ul,{DenseMatrix:function(w){return v(w)},SparseMatrix:function(w){return h(w)},Array:function(w){var N=a(w),g=v(N);return{L:g.L.valueOf(),U:g.U.valueOf(),p:g.p}}});function v(b){var w=b._size[0],N=b._size[1],g=Math.min(w,N),y=Ce(b._data),x=[],d=[w,g],A=[],S=[g,N],O,M,_,E=[];for(O=0;O<w;O++)E[O]=O;for(M=0;M<N;M++){if(M>0)for(O=0;O<w;O++){var $=Math.min(O,M),z=0;for(_=0;_<$;_++)z=r(z,l(y[O][_],y[_][M]));y[O][M]=m(y[O][M],z)}var I=M,T=0,B=0;for(O=M;O<w;O++){var G=y[O][M],D=t(G);f(D,T)&&(I=O,T=D,B=G)}if(M!==I&&(E[M]=[E[I],E[I]=E[M]][0],o._swapRows(M,I,y)),M<w)for(O=M+1;O<w;O++){var H=y[O][M];c(H,0)||(y[O][M]=i(y[O][M],B))}}for(M=0;M<N;M++)for(O=0;O<w;O++){if(M===0&&(O<N&&(A[O]=[]),x[O]=[]),O<M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=0);continue}if(O===M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=1);continue}O<N&&(A[O][M]=0),M<w&&(x[O][M]=y[O][M])}var W=new o({data:x,size:d}),j=new o({data:A,size:S}),V=[];for(O=0,g=E.length;O<g;O++)V[E[O]]=O;return{L:W,U:j,p:V,toString:function(){return"L: "+this.L.toString()+`
41
41
  U: `+this.U.toString()+`
42
42
  P: `+this.p}}}function h(b){var w=b._size[0],N=b._size[1],g=Math.min(w,N),y=b._values,x=b._index,d=b._ptr,A=[],S=[],O=[],M=[w,g],_=[],E=[],$=[],z=[g,N],I,T,B,G=[],D=[];for(I=0;I<w;I++)G[I]=I,D[I]=I;var H=function(V,K){var te=D[V],re=D[K];G[te]=K,G[re]=V,D[V]=re,D[K]=te},W=function(){var V=new p;T<w&&(O.push(A.length),A.push(1),S.push(T)),$.push(_.length);var K=d[T],te=d[T+1];for(B=K;B<te;B++)I=x[B],V.set(G[I],y[B]);T>0&&V.forEach(0,T-1,function(ue,ee){u._forEachRow(ue,A,S,O,function(ye,we){ye>ue&&V.accumulate(ye,s(l(we,ee)))})});var re=T,ie=V.get(T),ne=t(ie);V.forEach(T+1,w-1,function(ue,ee){var ye=t(ee);f(ye,ne)&&(re=ue,ne=ye,ie=ee)}),T!==re&&(u._swapRows(T,re,M[1],A,S,O),u._swapRows(T,re,z[1],_,E,$),V.swap(T,re),H(T,re)),V.forEach(0,w-1,function(ue,ee){ue<=T?(_.push(ee),E.push(ue)):(ee=i(ee,ie),c(ee,0)||(A.push(ee),S.push(ue)))})};for(T=0;T<N;T++)W();return $.push(_.length),O.push(A.length),{L:new u({values:A,index:S,ptr:O,size:M}),U:new u({values:_,index:E,ptr:$,size:z}),p:G,toString:function(){return"L: "+this.L.toString()+`
43
43
  U: `+this.U.toString()+`
44
- P: `+this.p}}}}),fl="qr",sM=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],uM=R(fl,sM,e=>{var{typed:n,matrix:a,zeros:t,identity:r,isZero:i,equal:l,sign:m,sqrt:f,conj:c,unaryMinus:s,addScalar:o,divideScalar:u,multiplyScalar:p,subtract:v,complex:h}=e;return rr(n(fl,{DenseMatrix:function(y){return w(y)},SparseMatrix:function(y){return N()},Array:function(y){var x=a(y),d=w(x);return{Q:d.Q.valueOf(),R:d.R.valueOf()}}}),{_denseQRimpl:b});function b(g){var y=g._size[0],x=g._size[1],d=r([y],"dense"),A=d._data,S=g.clone(),O=S._data,M,_,E,$=t([y],"");for(E=0;E<Math.min(x,y);++E){var z=O[E][E],I=s(l(z,0)?1:m(z)),T=c(I),B=0;for(M=E;M<y;M++)B=o(B,p(O[M][E],c(O[M][E])));var G=p(I,f(B));if(!i(G)){var D=v(z,G);for($[E]=1,M=E+1;M<y;M++)$[M]=u(O[M][E],D);var H=s(c(u(D,G))),W=void 0;for(_=E;_<x;_++){for(W=0,M=E;M<y;M++)W=o(W,p(c($[M]),O[M][_]));for(W=p(W,H),M=E;M<y;M++)O[M][_]=p(v(O[M][_],p($[M],W)),T)}for(M=0;M<y;M++){for(W=0,_=E;_<y;_++)W=o(W,p(A[M][_],$[_]));for(W=p(W,H),_=E;_<y;++_)A[M][_]=u(v(A[M][_],p(W,c($[_]))),T)}}}return{Q:d,R:S,toString:function(){return"Q: "+this.Q.toString()+`
45
- R: `+this.R.toString()}}}function w(g){var y=b(g),x=y.R._data;if(g._data.length>0)for(var d=x[0][0].type==="Complex"?h(0):0,A=0;A<x.length;++A)for(var S=0;S<A&&S<(x[0]||[]).length;++S)x[A][S]=d;return y}function N(g){throw new Error("qr not implemented for sparse matrices yet")}});function cM(e,n,a,t){e._values;for(var r=e._index,i=e._ptr,l=e._size,m=e._datatype,f=l[0],c=l[1],s=null,o=[],u=[],p=0,v=0;v<c;v++){u[v]=p;for(var h=a?a[v]:v,b=i[h],w=i[h+1],N=b;N<w;N++){var g=r[N];o[p]=g,p++}}return u[c]=p,e.createSparseMatrix({values:s,index:o,ptr:u,size:[f,c],datatype:m})}function ll(e,n,a,t,r,i,l){var m=0;for(a[l]=e;m>=0;){var f=a[l+m],c=a[t+f];c===-1?(m--,i[n++]=f):(a[t+f]=a[r+c],++m,a[l+m]=c)}return n}function fM(e,n){if(!e)return null;var a=0,t,r=[],i=[],l=0,m=n,f=2*n;for(t=0;t<n;t++)i[l+t]=-1;for(t=n-1;t>=0;t--)e[t]!==-1&&(i[m+t]=i[l+e[t]],i[l+e[t]]=t);for(t=0;t<n;t++)e[t]===-1&&(a=ll(t,a,i,l,m,r,f));return r}function lM(e,n){if(!e)return null;var a=e._index,t=e._ptr,r=e._size,i=r[0],l=r[1],m=[],f=[],c=0,s=l,o,u;for(o=0;o<i;o++)f[s+o]=-1;for(var p=0;p<l;p++){m[p]=-1,f[c+p]=-1;for(var v=t[p],h=t[p+1],b=v;b<h;b++){var w=a[b];for(o=f[s+w];o!==-1&&o<p;o=u)u=f[c+o],f[c+o]=p,u===-1&&(m[o]=p);f[s+w]=p}}return m}function mM(e,n,a){for(var t=e._values,r=e._index,i=e._ptr,l=e._size,m=l[1],f=0,c=0;c<m;c++){var s=i[c];for(i[c]=f;s<i[c+1];s++)n(r[s],c,t?t[s]:1,a)&&(r[f]=r[s],t&&(t[f]=t[s]),f++)}return i[m]=f,r.splice(f,r.length-f),t&&t.splice(f,t.length-f),f}function Rt(e){return-e-2}var pM="csAmd",vM=["add","multiply","transpose"],hM=R(pM,vM,e=>{var{add:n,multiply:a,transpose:t}=e;return function(s,o){if(!o||s<=0||s>3)return null;var u=o._size,p=u[0],v=u[1],h=0,b=Math.max(16,10*Math.sqrt(v));b=Math.min(v-2,b);var w=r(s,o,p,v,b);mM(w,f,null);for(var N=w._index,g=w._ptr,y=g[v],x=[],d=[],A=0,S=v+1,O=2*(v+1),M=3*(v+1),_=4*(v+1),E=5*(v+1),$=6*(v+1),z=7*(v+1),I=x,T=i(v,g,d,A,M,I,O,z,S,$,_,E),B=l(v,g,d,E,_,$,b,S,M,I,O),G=0,D,H,W,j,V,K,te,re,ie,ne,ue,ee,ye,we,me,xe;B<v;){for(W=-1;G<v&&(W=d[M+G])===-1;G++);d[O+W]!==-1&&(I[d[O+W]]=-1),d[M+G]=d[O+W];var F=d[_+W],Y=d[S+W];B+=Y;var k=0;d[S+W]=-Y;var U=g[W],J=F===0?U:y,q=J;for(j=1;j<=F+1;j++){for(j>F?(K=W,te=U,re=d[A+W]-F):(K=N[U++],te=g[K],re=d[A+K]),V=1;V<=re;V++)D=N[te++],!((ie=d[S+D])<=0)&&(k+=ie,d[S+D]=-ie,N[q++]=D,d[O+D]!==-1&&(I[d[O+D]]=I[D]),I[D]!==-1?d[O+I[D]]=d[O+D]:d[M+d[E+D]]=d[O+D]);K!==W&&(g[K]=Rt(W),d[$+K]=0)}for(F!==0&&(y=q),d[E+W]=k,g[W]=J,d[A+W]=q-J,d[_+W]=-2,T=m(T,h,d,$,v),ne=J;ne<q;ne++)if(D=N[ne],!((ue=d[_+D])<=0)){ie=-d[S+D];var P=T-ie;for(U=g[D],ee=g[D]+ue-1;U<=ee;U++)K=N[U],d[$+K]>=T?d[$+K]-=ie:d[$+K]!==0&&(d[$+K]=d[E+K]+P)}for(ne=J;ne<q;ne++){for(D=N[ne],ee=g[D],ye=ee+d[_+D]-1,we=ee,me=0,xe=0,U=ee;U<=ye;U++)if(K=N[U],d[$+K]!==0){var Q=d[$+K]-T;Q>0?(xe+=Q,N[we++]=K,me+=K):(g[K]=Rt(W),d[$+K]=0)}d[_+D]=we-ee+1;var L=we,se=ee+d[A+D];for(U=ye+1;U<se;U++){H=N[U];var fe=d[S+H];fe<=0||(xe+=fe,N[we++]=H,me+=H)}xe===0?(g[D]=Rt(W),ie=-d[S+D],k-=ie,Y+=ie,B+=ie,d[S+D]=0,d[_+D]=-1):(d[E+D]=Math.min(d[E+D],xe),N[we]=N[L],N[L]=N[ee],N[ee]=W,d[A+D]=we-ee+1,me=(me<0?-me:me)%v,d[O+D]=d[z+me],d[z+me]=D,I[D]=me)}for(d[E+W]=k,h=Math.max(h,k),T=m(T+h,h,d,$,v),ne=J;ne<q;ne++)if(D=N[ne],!(d[S+D]>=0))for(me=I[D],D=d[z+me],d[z+me]=-1;D!==-1&&d[O+D]!==-1;D=d[O+D],T++){for(re=d[A+D],ue=d[_+D],U=g[D]+1;U<=g[D]+re-1;U++)d[$+N[U]]=T;var ge=D;for(H=d[O+D];H!==-1;){var pe=d[A+H]===re&&d[_+H]===ue;for(U=g[H]+1;pe&&U<=g[H]+re-1;U++)d[$+N[U]]!==T&&(pe=0);pe?(g[H]=Rt(D),d[S+D]+=d[S+H],d[S+H]=0,d[_+H]=-1,H=d[O+H],d[O+ge]=H):(ge=H,H=d[O+H])}}for(U=J,ne=J;ne<q;ne++)D=N[ne],!((ie=-d[S+D])<=0)&&(d[S+D]=ie,xe=d[E+D]+k-ie,xe=Math.min(xe,v-B-ie),d[M+xe]!==-1&&(I[d[M+xe]]=D),d[O+D]=d[M+xe],I[D]=-1,d[M+xe]=D,G=Math.min(G,xe),d[E+D]=xe,N[U++]=D);d[S+W]=Y,(d[A+W]=U-J)===0&&(g[W]=-1,d[$+W]=0),F!==0&&(y=U)}for(D=0;D<v;D++)g[D]=Rt(g[D]);for(H=0;H<=v;H++)d[M+H]=-1;for(H=v;H>=0;H--)d[S+H]>0||(d[O+H]=d[M+g[H]],d[M+g[H]]=H);for(K=v;K>=0;K--)d[S+K]<=0||g[K]!==-1&&(d[O+K]=d[M+g[K]],d[M+g[K]]=K);for(W=0,D=0;D<=v;D++)g[D]===-1&&(W=ll(D,W,d,M,O,x,$));return x.splice(x.length-1,1),x};function r(c,s,o,u,p){var v=t(s);if(c===1&&u===o)return n(s,v);if(c===2){for(var h=v._index,b=v._ptr,w=0,N=0;N<o;N++){var g=b[N];if(b[N]=w,!(b[N+1]-g>p))for(var y=b[N+1];g<y;g++)h[w++]=h[g]}return b[o]=w,s=t(v),a(v,s)}return a(v,s)}function i(c,s,o,u,p,v,h,b,w,N,g,y){for(var x=0;x<c;x++)o[u+x]=s[x+1]-s[x];o[u+c]=0;for(var d=0;d<=c;d++)o[p+d]=-1,v[d]=-1,o[h+d]=-1,o[b+d]=-1,o[w+d]=1,o[N+d]=1,o[g+d]=0,o[y+d]=o[u+d];var A=m(0,0,o,N,c);return o[g+c]=-2,s[c]=-1,o[N+c]=0,A}function l(c,s,o,u,p,v,h,b,w,N,g){for(var y=0,x=0;x<c;x++){var d=o[u+x];if(d===0)o[p+x]=-2,y++,s[x]=-1,o[v+x]=0;else if(d>h)o[b+x]=0,o[p+x]=-1,y++,s[x]=Rt(c),o[b+c]++;else{var A=o[w+d];A!==-1&&(N[A]=x),o[g+x]=o[w+d],o[w+d]=x}}return y}function m(c,s,o,u,p){if(c<2||c+s<0){for(var v=0;v<p;v++)o[u+v]!==0&&(o[u+v]=1);c=2}return c}function f(c,s){return c!==s}});function dM(e,n,a,t,r,i,l){var m,f,c=0,s;if(e<=n||a[t+n]<=a[r+e])return-1;a[r+e]=a[t+n];var o=a[i+e];if(a[i+e]=n,o===-1)c=1,s=e;else{for(c=2,s=o;s!==a[l+s];s=a[l+s]);for(m=o;m!==s;m=f)f=a[l+m],a[l+m]=s}return{jleaf:c,q:s}}var gM="csCounts",yM=["transpose"],xM=R(gM,yM,e=>{var{transpose:n}=e;return function(a,t,r,i){if(!a||!t||!r)return null;var l=a._size,m=l[0],f=l[1],c,s,o,u,p,v,h,b=4*f+(i?f+m+1:0),w=[],N=0,g=f,y=2*f,x=3*f,d=4*f,A=5*f+1;for(o=0;o<b;o++)w[o]=-1;var S=[],O=n(a),M=O._index,_=O._ptr;for(o=0;o<f;o++)for(s=r[o],S[s]=w[x+s]===-1?1:0;s!==-1&&w[x+s]===-1;s=t[s])w[x+s]=o;if(i){for(o=0;o<f;o++)w[r[o]]=o;for(c=0;c<m;c++){for(o=f,v=_[c],h=_[c+1],p=v;p<h;p++)o=Math.min(o,w[M[p]]);w[A+c]=w[d+o],w[d+o]=c}}for(c=0;c<f;c++)w[N+c]=c;for(o=0;o<f;o++){for(s=r[o],t[s]!==-1&&S[t[s]]--,u=i?w[d+o]:s;u!==-1;u=i?w[A+u]:-1)for(p=_[u];p<_[u+1];p++){c=M[p];var E=dM(c,s,w,x,g,y,N);E.jleaf>=1&&S[s]++,E.jleaf===2&&S[E.q]--}t[s]!==-1&&(w[N+s]=t[s])}for(s=0;s<f;s++)t[s]!==-1&&(S[t[s]]+=S[s]);return S}}),bM="csSqr",wM=["add","multiply","transpose"],NM=R(bM,wM,e=>{var{add:n,multiply:a,transpose:t}=e,r=hM({add:n,multiply:a,transpose:t}),i=xM({transpose:t});return function(f,c,s){var o=c._ptr,u=c._size,p=u[1],v,h={};if(h.q=r(f,c),f&&!h.q)return null;if(s){var b=f?cM(c,null,h.q):c;h.parent=lM(b);var w=fM(h.parent,p);if(h.cp=i(b,h.parent,w,1),b&&h.parent&&h.cp&&l(b,h))for(h.unz=0,v=0;v<p;v++)h.unz+=h.cp[v]}else h.unz=4*o[p]+p,h.lnz=h.unz;return h};function l(m,f){var c=m._ptr,s=m._index,o=m._size,u=o[0],p=o[1];f.pinv=[],f.leftmost=[];var v=f.parent,h=f.pinv,b=f.leftmost,w=[],N=0,g=u,y=u+p,x=u+2*p,d,A,S,O,M;for(A=0;A<p;A++)w[g+A]=-1,w[y+A]=-1,w[x+A]=0;for(d=0;d<u;d++)b[d]=-1;for(A=p-1;A>=0;A--)for(O=c[A],M=c[A+1],S=O;S<M;S++)b[s[S]]=A;for(d=u-1;d>=0;d--)h[d]=-1,A=b[d],A!==-1&&(w[x+A]++===0&&(w[y+A]=d),w[N+d]=w[g+A],w[g+A]=d);for(f.lnz=0,f.m2=u,A=0;A<p;A++)if(d=w[g+A],f.lnz++,d<0&&(d=f.m2++),h[d]=A,!(--x[A]<=0)){f.lnz+=w[x+A];var _=v[A];_!==-1&&(w[x+_]===0&&(w[y+_]=w[y+A]),w[N+w[y+A]]=w[g+_],w[g+_]=w[N+d],w[x+_]+=w[x+A])}for(d=0;d<u;d++)h[d]<0&&(h[d]=A++);return!0}});function qi(e,n){return e[n]<0}function ml(e,n){e[n]=Rt(e[n])}function pl(e){return e<0?Rt(e):e}function MM(e,n,a,t,r){var i=n._index,l=n._ptr,m=n._size,f=m[1],c,s,o,u=0;for(t[0]=e;u>=0;){e=t[u];var p=r?r[e]:e;qi(l,e)||(ml(l,e),t[f+u]=p<0?0:pl(l[p]));var v=1;for(s=t[f+u],o=p<0?0:pl(l[p+1]);s<o;s++)if(c=i[s],!qi(l,c)){t[f+u]=s,t[++u]=c,v=0;break}v&&(u--,t[--a]=e)}return a}function AM(e,n,a,t,r){var i=e._ptr,l=e._size,m=n._index,f=n._ptr,c=l[1],s,o,u,p=c;for(o=f[a],u=f[a+1],s=o;s<u;s++){var v=m[s];qi(i,v)||(p=MM(v,e,p,t,r))}for(s=p;s<c;s++)ml(i,t[s]);return p}var SM="csSpsolve",EM=["divideScalar","multiply","subtract"],CM=R(SM,EM,e=>{var{divideScalar:n,multiply:a,subtract:t}=e;return function(i,l,m,f,c,s,o){var u=i._values,p=i._index,v=i._ptr,h=i._size,b=h[1],w=l._values,N=l._index,g=l._ptr,y,x,d,A,S=AM(i,l,m,f,s);for(y=S;y<b;y++)c[f[y]]=0;for(x=g[m],d=g[m+1],y=x;y<d;y++)c[N[y]]=w[y];for(var O=S;O<b;O++){var M=f[O],_=s?s[M]:M;if(!(_<0))for(x=v[_],d=v[_+1],c[M]=n(c[M],u[o?x:d-1]),y=o?x+1:x,A=o?d:d-1;y<A;y++){var E=p[y];c[E]=t(c[E],a(u[y],c[M]))}}return S}}),OM="csLu",DM=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],TM=R(OM,DM,e=>{var{abs:n,divideScalar:a,multiply:t,subtract:r,larger:i,largerEq:l,SparseMatrix:m}=e,f=CM({divideScalar:a,multiply:t,subtract:r});return function(s,o,u){if(!s)return null;var p=s._size,v=p[1],h,b=100,w=100;o&&(h=o.q,b=o.lnz||b,w=o.unz||w);var N=[],g=[],y=[],x=new m({values:N,index:g,ptr:y,size:[v,v]}),d=[],A=[],S=[],O=new m({values:d,index:A,ptr:S,size:[v,v]}),M=[],_,E,$=[],z=[];for(_=0;_<v;_++)$[_]=0,M[_]=-1,y[_+1]=0;b=0,w=0;for(var I=0;I<v;I++){y[I]=b,S[I]=w;var T=h?h[I]:I,B=f(x,s,T,z,$,M,1),G=-1,D=-1;for(E=B;E<v;E++)if(_=z[E],M[_]<0){var H=n($[_]);i(H,D)&&(D=H,G=_)}else A[w]=M[_],d[w++]=$[_];if(G===-1||D<=0)return null;M[T]<0&&l(n($[T]),t(D,u))&&(G=T);var W=$[G];for(A[w]=I,d[w++]=W,M[G]=I,g[b]=G,N[b++]=1,E=B;E<v;E++)_=z[E],M[_]<0&&(g[b]=_,N[b++]=a($[_],W)),$[_]=0}for(y[v]=b,S[v]=w,E=0;E<b;E++)g[E]=M[g[E]];return N.splice(b,N.length-b),g.splice(b,g.length-b),d.splice(w,d.length-w),A.splice(w,A.length-w),{L:x,U:O,pinv:M}}}),vl="slu",BM=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],_M=R(vl,BM,e=>{var{typed:n,abs:a,add:t,multiply:r,transpose:i,divideScalar:l,subtract:m,larger:f,largerEq:c,SparseMatrix:s}=e,o=NM({add:t,multiply:r,transpose:i}),u=TM({abs:a,divideScalar:l,multiply:r,subtract:m,larger:f,largerEq:c,SparseMatrix:s});return n(vl,{"SparseMatrix, number, number":function(v,h,b){if(!Ae(h)||h<0||h>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(b<0||b>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var w=o(h,v,!1),N=u(v,w,b);return{L:N.L,U:N.U,p:N.pinv,q:w.q,toString:function(){return"L: "+this.L.toString()+`
44
+ P: `+this.p}}}}),cl="qr",oM=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],sM=R(cl,oM,e=>{var{typed:n,matrix:a,zeros:t,identity:r,isZero:i,equal:l,sign:m,sqrt:f,conj:c,unaryMinus:s,addScalar:o,divideScalar:u,multiplyScalar:p,subtract:v,complex:h}=e;return ar(n(cl,{DenseMatrix:function(y){return w(y)},SparseMatrix:function(y){return N()},Array:function(y){var x=a(y),d=w(x);return{Q:d.Q.valueOf(),R:d.R.valueOf()}}}),{_denseQRimpl:b});function b(g){var y=g._size[0],x=g._size[1],d=r([y],"dense"),A=d._data,S=g.clone(),O=S._data,M,_,E,$=t([y],"");for(E=0;E<Math.min(x,y);++E){var z=O[E][E],I=s(l(z,0)?1:m(z)),T=c(I),B=0;for(M=E;M<y;M++)B=o(B,p(O[M][E],c(O[M][E])));var G=p(I,f(B));if(!i(G)){var D=v(z,G);for($[E]=1,M=E+1;M<y;M++)$[M]=u(O[M][E],D);var H=s(c(u(D,G))),W=void 0;for(_=E;_<x;_++){for(W=0,M=E;M<y;M++)W=o(W,p(c($[M]),O[M][_]));for(W=p(W,H),M=E;M<y;M++)O[M][_]=p(v(O[M][_],p($[M],W)),T)}for(M=0;M<y;M++){for(W=0,_=E;_<y;_++)W=o(W,p(A[M][_],$[_]));for(W=p(W,H),_=E;_<y;++_)A[M][_]=u(v(A[M][_],p(W,c($[_]))),T)}}}return{Q:d,R:S,toString:function(){return"Q: "+this.Q.toString()+`
45
+ R: `+this.R.toString()}}}function w(g){var y=b(g),x=y.R._data;if(g._data.length>0)for(var d=x[0][0].type==="Complex"?h(0):0,A=0;A<x.length;++A)for(var S=0;S<A&&S<(x[0]||[]).length;++S)x[A][S]=d;return y}function N(g){throw new Error("qr not implemented for sparse matrices yet")}});function uM(e,n,a,t){e._values;for(var r=e._index,i=e._ptr,l=e._size,m=e._datatype,f=l[0],c=l[1],s=null,o=[],u=[],p=0,v=0;v<c;v++){u[v]=p;for(var h=a?a[v]:v,b=i[h],w=i[h+1],N=b;N<w;N++){var g=r[N];o[p]=g,p++}}return u[c]=p,e.createSparseMatrix({values:s,index:o,ptr:u,size:[f,c],datatype:m})}function fl(e,n,a,t,r,i,l){var m=0;for(a[l]=e;m>=0;){var f=a[l+m],c=a[t+f];c===-1?(m--,i[n++]=f):(a[t+f]=a[r+c],++m,a[l+m]=c)}return n}function cM(e,n){if(!e)return null;var a=0,t,r=[],i=[],l=0,m=n,f=2*n;for(t=0;t<n;t++)i[l+t]=-1;for(t=n-1;t>=0;t--)e[t]!==-1&&(i[m+t]=i[l+e[t]],i[l+e[t]]=t);for(t=0;t<n;t++)e[t]===-1&&(a=fl(t,a,i,l,m,r,f));return r}function fM(e,n){if(!e)return null;var a=e._index,t=e._ptr,r=e._size,i=r[0],l=r[1],m=[],f=[],c=0,s=l,o,u;for(o=0;o<i;o++)f[s+o]=-1;for(var p=0;p<l;p++){m[p]=-1,f[c+p]=-1;for(var v=t[p],h=t[p+1],b=v;b<h;b++){var w=a[b];for(o=f[s+w];o!==-1&&o<p;o=u)u=f[c+o],f[c+o]=p,u===-1&&(m[o]=p);f[s+w]=p}}return m}function lM(e,n,a){for(var t=e._values,r=e._index,i=e._ptr,l=e._size,m=l[1],f=0,c=0;c<m;c++){var s=i[c];for(i[c]=f;s<i[c+1];s++)n(r[s],c,t?t[s]:1,a)&&(r[f]=r[s],t&&(t[f]=t[s]),f++)}return i[m]=f,r.splice(f,r.length-f),t&&t.splice(f,t.length-f),f}function Rt(e){return-e-2}var mM="csAmd",pM=["add","multiply","transpose"],vM=R(mM,pM,e=>{var{add:n,multiply:a,transpose:t}=e;return function(s,o){if(!o||s<=0||s>3)return null;var u=o._size,p=u[0],v=u[1],h=0,b=Math.max(16,10*Math.sqrt(v));b=Math.min(v-2,b);var w=r(s,o,p,v,b);lM(w,f,null);for(var N=w._index,g=w._ptr,y=g[v],x=[],d=[],A=0,S=v+1,O=2*(v+1),M=3*(v+1),_=4*(v+1),E=5*(v+1),$=6*(v+1),z=7*(v+1),I=x,T=i(v,g,d,A,M,I,O,z,S,$,_,E),B=l(v,g,d,E,_,$,b,S,M,I,O),G=0,D,H,W,j,V,K,te,re,ie,ne,ue,ee,ye,we,me,xe;B<v;){for(W=-1;G<v&&(W=d[M+G])===-1;G++);d[O+W]!==-1&&(I[d[O+W]]=-1),d[M+G]=d[O+W];var F=d[_+W],Y=d[S+W];B+=Y;var k=0;d[S+W]=-Y;var U=g[W],J=F===0?U:y,q=J;for(j=1;j<=F+1;j++){for(j>F?(K=W,te=U,re=d[A+W]-F):(K=N[U++],te=g[K],re=d[A+K]),V=1;V<=re;V++)D=N[te++],!((ie=d[S+D])<=0)&&(k+=ie,d[S+D]=-ie,N[q++]=D,d[O+D]!==-1&&(I[d[O+D]]=I[D]),I[D]!==-1?d[O+I[D]]=d[O+D]:d[M+d[E+D]]=d[O+D]);K!==W&&(g[K]=Rt(W),d[$+K]=0)}for(F!==0&&(y=q),d[E+W]=k,g[W]=J,d[A+W]=q-J,d[_+W]=-2,T=m(T,h,d,$,v),ne=J;ne<q;ne++)if(D=N[ne],!((ue=d[_+D])<=0)){ie=-d[S+D];var P=T-ie;for(U=g[D],ee=g[D]+ue-1;U<=ee;U++)K=N[U],d[$+K]>=T?d[$+K]-=ie:d[$+K]!==0&&(d[$+K]=d[E+K]+P)}for(ne=J;ne<q;ne++){for(D=N[ne],ee=g[D],ye=ee+d[_+D]-1,we=ee,me=0,xe=0,U=ee;U<=ye;U++)if(K=N[U],d[$+K]!==0){var Q=d[$+K]-T;Q>0?(xe+=Q,N[we++]=K,me+=K):(g[K]=Rt(W),d[$+K]=0)}d[_+D]=we-ee+1;var L=we,se=ee+d[A+D];for(U=ye+1;U<se;U++){H=N[U];var fe=d[S+H];fe<=0||(xe+=fe,N[we++]=H,me+=H)}xe===0?(g[D]=Rt(W),ie=-d[S+D],k-=ie,Y+=ie,B+=ie,d[S+D]=0,d[_+D]=-1):(d[E+D]=Math.min(d[E+D],xe),N[we]=N[L],N[L]=N[ee],N[ee]=W,d[A+D]=we-ee+1,me=(me<0?-me:me)%v,d[O+D]=d[z+me],d[z+me]=D,I[D]=me)}for(d[E+W]=k,h=Math.max(h,k),T=m(T+h,h,d,$,v),ne=J;ne<q;ne++)if(D=N[ne],!(d[S+D]>=0))for(me=I[D],D=d[z+me],d[z+me]=-1;D!==-1&&d[O+D]!==-1;D=d[O+D],T++){for(re=d[A+D],ue=d[_+D],U=g[D]+1;U<=g[D]+re-1;U++)d[$+N[U]]=T;var ge=D;for(H=d[O+D];H!==-1;){var pe=d[A+H]===re&&d[_+H]===ue;for(U=g[H]+1;pe&&U<=g[H]+re-1;U++)d[$+N[U]]!==T&&(pe=0);pe?(g[H]=Rt(D),d[S+D]+=d[S+H],d[S+H]=0,d[_+H]=-1,H=d[O+H],d[O+ge]=H):(ge=H,H=d[O+H])}}for(U=J,ne=J;ne<q;ne++)D=N[ne],!((ie=-d[S+D])<=0)&&(d[S+D]=ie,xe=d[E+D]+k-ie,xe=Math.min(xe,v-B-ie),d[M+xe]!==-1&&(I[d[M+xe]]=D),d[O+D]=d[M+xe],I[D]=-1,d[M+xe]=D,G=Math.min(G,xe),d[E+D]=xe,N[U++]=D);d[S+W]=Y,(d[A+W]=U-J)===0&&(g[W]=-1,d[$+W]=0),F!==0&&(y=U)}for(D=0;D<v;D++)g[D]=Rt(g[D]);for(H=0;H<=v;H++)d[M+H]=-1;for(H=v;H>=0;H--)d[S+H]>0||(d[O+H]=d[M+g[H]],d[M+g[H]]=H);for(K=v;K>=0;K--)d[S+K]<=0||g[K]!==-1&&(d[O+K]=d[M+g[K]],d[M+g[K]]=K);for(W=0,D=0;D<=v;D++)g[D]===-1&&(W=fl(D,W,d,M,O,x,$));return x.splice(x.length-1,1),x};function r(c,s,o,u,p){var v=t(s);if(c===1&&u===o)return n(s,v);if(c===2){for(var h=v._index,b=v._ptr,w=0,N=0;N<o;N++){var g=b[N];if(b[N]=w,!(b[N+1]-g>p))for(var y=b[N+1];g<y;g++)h[w++]=h[g]}return b[o]=w,s=t(v),a(v,s)}return a(v,s)}function i(c,s,o,u,p,v,h,b,w,N,g,y){for(var x=0;x<c;x++)o[u+x]=s[x+1]-s[x];o[u+c]=0;for(var d=0;d<=c;d++)o[p+d]=-1,v[d]=-1,o[h+d]=-1,o[b+d]=-1,o[w+d]=1,o[N+d]=1,o[g+d]=0,o[y+d]=o[u+d];var A=m(0,0,o,N,c);return o[g+c]=-2,s[c]=-1,o[N+c]=0,A}function l(c,s,o,u,p,v,h,b,w,N,g){for(var y=0,x=0;x<c;x++){var d=o[u+x];if(d===0)o[p+x]=-2,y++,s[x]=-1,o[v+x]=0;else if(d>h)o[b+x]=0,o[p+x]=-1,y++,s[x]=Rt(c),o[b+c]++;else{var A=o[w+d];A!==-1&&(N[A]=x),o[g+x]=o[w+d],o[w+d]=x}}return y}function m(c,s,o,u,p){if(c<2||c+s<0){for(var v=0;v<p;v++)o[u+v]!==0&&(o[u+v]=1);c=2}return c}function f(c,s){return c!==s}});function hM(e,n,a,t,r,i,l){var m,f,c=0,s;if(e<=n||a[t+n]<=a[r+e])return-1;a[r+e]=a[t+n];var o=a[i+e];if(a[i+e]=n,o===-1)c=1,s=e;else{for(c=2,s=o;s!==a[l+s];s=a[l+s]);for(m=o;m!==s;m=f)f=a[l+m],a[l+m]=s}return{jleaf:c,q:s}}var dM="csCounts",gM=["transpose"],yM=R(dM,gM,e=>{var{transpose:n}=e;return function(a,t,r,i){if(!a||!t||!r)return null;var l=a._size,m=l[0],f=l[1],c,s,o,u,p,v,h,b=4*f+(i?f+m+1:0),w=[],N=0,g=f,y=2*f,x=3*f,d=4*f,A=5*f+1;for(o=0;o<b;o++)w[o]=-1;var S=[],O=n(a),M=O._index,_=O._ptr;for(o=0;o<f;o++)for(s=r[o],S[s]=w[x+s]===-1?1:0;s!==-1&&w[x+s]===-1;s=t[s])w[x+s]=o;if(i){for(o=0;o<f;o++)w[r[o]]=o;for(c=0;c<m;c++){for(o=f,v=_[c],h=_[c+1],p=v;p<h;p++)o=Math.min(o,w[M[p]]);w[A+c]=w[d+o],w[d+o]=c}}for(c=0;c<f;c++)w[N+c]=c;for(o=0;o<f;o++){for(s=r[o],t[s]!==-1&&S[t[s]]--,u=i?w[d+o]:s;u!==-1;u=i?w[A+u]:-1)for(p=_[u];p<_[u+1];p++){c=M[p];var E=hM(c,s,w,x,g,y,N);E.jleaf>=1&&S[s]++,E.jleaf===2&&S[E.q]--}t[s]!==-1&&(w[N+s]=t[s])}for(s=0;s<f;s++)t[s]!==-1&&(S[t[s]]+=S[s]);return S}}),xM="csSqr",bM=["add","multiply","transpose"],wM=R(xM,bM,e=>{var{add:n,multiply:a,transpose:t}=e,r=vM({add:n,multiply:a,transpose:t}),i=yM({transpose:t});return function(f,c,s){var o=c._ptr,u=c._size,p=u[1],v,h={};if(h.q=r(f,c),f&&!h.q)return null;if(s){var b=f?uM(c,null,h.q):c;h.parent=fM(b);var w=cM(h.parent,p);if(h.cp=i(b,h.parent,w,1),b&&h.parent&&h.cp&&l(b,h))for(h.unz=0,v=0;v<p;v++)h.unz+=h.cp[v]}else h.unz=4*o[p]+p,h.lnz=h.unz;return h};function l(m,f){var c=m._ptr,s=m._index,o=m._size,u=o[0],p=o[1];f.pinv=[],f.leftmost=[];var v=f.parent,h=f.pinv,b=f.leftmost,w=[],N=0,g=u,y=u+p,x=u+2*p,d,A,S,O,M;for(A=0;A<p;A++)w[g+A]=-1,w[y+A]=-1,w[x+A]=0;for(d=0;d<u;d++)b[d]=-1;for(A=p-1;A>=0;A--)for(O=c[A],M=c[A+1],S=O;S<M;S++)b[s[S]]=A;for(d=u-1;d>=0;d--)h[d]=-1,A=b[d],A!==-1&&(w[x+A]++===0&&(w[y+A]=d),w[N+d]=w[g+A],w[g+A]=d);for(f.lnz=0,f.m2=u,A=0;A<p;A++)if(d=w[g+A],f.lnz++,d<0&&(d=f.m2++),h[d]=A,!(--x[A]<=0)){f.lnz+=w[x+A];var _=v[A];_!==-1&&(w[x+_]===0&&(w[y+_]=w[y+A]),w[N+w[y+A]]=w[g+_],w[g+_]=w[N+d],w[x+_]+=w[x+A])}for(d=0;d<u;d++)h[d]<0&&(h[d]=A++);return!0}});function Ii(e,n){return e[n]<0}function ll(e,n){e[n]=Rt(e[n])}function ml(e){return e<0?Rt(e):e}function NM(e,n,a,t,r){var i=n._index,l=n._ptr,m=n._size,f=m[1],c,s,o,u=0;for(t[0]=e;u>=0;){e=t[u];var p=r?r[e]:e;Ii(l,e)||(ll(l,e),t[f+u]=p<0?0:ml(l[p]));var v=1;for(s=t[f+u],o=p<0?0:ml(l[p+1]);s<o;s++)if(c=i[s],!Ii(l,c)){t[f+u]=s,t[++u]=c,v=0;break}v&&(u--,t[--a]=e)}return a}function MM(e,n,a,t,r){var i=e._ptr,l=e._size,m=n._index,f=n._ptr,c=l[1],s,o,u,p=c;for(o=f[a],u=f[a+1],s=o;s<u;s++){var v=m[s];Ii(i,v)||(p=NM(v,e,p,t,r))}for(s=p;s<c;s++)ll(i,t[s]);return p}var AM="csSpsolve",SM=["divideScalar","multiply","subtract"],EM=R(AM,SM,e=>{var{divideScalar:n,multiply:a,subtract:t}=e;return function(i,l,m,f,c,s,o){var u=i._values,p=i._index,v=i._ptr,h=i._size,b=h[1],w=l._values,N=l._index,g=l._ptr,y,x,d,A,S=MM(i,l,m,f,s);for(y=S;y<b;y++)c[f[y]]=0;for(x=g[m],d=g[m+1],y=x;y<d;y++)c[N[y]]=w[y];for(var O=S;O<b;O++){var M=f[O],_=s?s[M]:M;if(!(_<0))for(x=v[_],d=v[_+1],c[M]=n(c[M],u[o?x:d-1]),y=o?x+1:x,A=o?d:d-1;y<A;y++){var E=p[y];c[E]=t(c[E],a(u[y],c[M]))}}return S}}),CM="csLu",OM=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],DM=R(CM,OM,e=>{var{abs:n,divideScalar:a,multiply:t,subtract:r,larger:i,largerEq:l,SparseMatrix:m}=e,f=EM({divideScalar:a,multiply:t,subtract:r});return function(s,o,u){if(!s)return null;var p=s._size,v=p[1],h,b=100,w=100;o&&(h=o.q,b=o.lnz||b,w=o.unz||w);var N=[],g=[],y=[],x=new m({values:N,index:g,ptr:y,size:[v,v]}),d=[],A=[],S=[],O=new m({values:d,index:A,ptr:S,size:[v,v]}),M=[],_,E,$=[],z=[];for(_=0;_<v;_++)$[_]=0,M[_]=-1,y[_+1]=0;b=0,w=0;for(var I=0;I<v;I++){y[I]=b,S[I]=w;var T=h?h[I]:I,B=f(x,s,T,z,$,M,1),G=-1,D=-1;for(E=B;E<v;E++)if(_=z[E],M[_]<0){var H=n($[_]);i(H,D)&&(D=H,G=_)}else A[w]=M[_],d[w++]=$[_];if(G===-1||D<=0)return null;M[T]<0&&l(n($[T]),t(D,u))&&(G=T);var W=$[G];for(A[w]=I,d[w++]=W,M[G]=I,g[b]=G,N[b++]=1,E=B;E<v;E++)_=z[E],M[_]<0&&(g[b]=_,N[b++]=a($[_],W)),$[_]=0}for(y[v]=b,S[v]=w,E=0;E<b;E++)g[E]=M[g[E]];return N.splice(b,N.length-b),g.splice(b,g.length-b),d.splice(w,d.length-w),A.splice(w,A.length-w),{L:x,U:O,pinv:M}}}),pl="slu",TM=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],BM=R(pl,TM,e=>{var{typed:n,abs:a,add:t,multiply:r,transpose:i,divideScalar:l,subtract:m,larger:f,largerEq:c,SparseMatrix:s}=e,o=wM({add:t,multiply:r,transpose:i}),u=DM({abs:a,divideScalar:l,multiply:r,subtract:m,larger:f,largerEq:c,SparseMatrix:s});return n(pl,{"SparseMatrix, number, number":function(v,h,b){if(!Ae(h)||h<0||h>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(b<0||b>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var w=o(h,v,!1),N=u(v,w,b);return{L:N.L,U:N.U,p:N.pinv,q:w.q,toString:function(){return"L: "+this.L.toString()+`
46
46
  U: `+this.U.toString()+`
47
47
  p: `+this.p.toString()+(this.q?`
48
48
  q: `+this.q.toString():"")+`
49
- `}}}})});function hl(e,n){var a,t=n.length,r=[];if(e)for(a=0;a<t;a++)r[e[a]]=n[a];else for(a=0;a<t;a++)r[a]=n[a];return r}var dl="lusolve",$M=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],IM=R(dl,$M,e=>{var{typed:n,matrix:a,lup:t,slu:r,usolve:i,lsolve:l,DenseMatrix:m}=e,f=Fn({DenseMatrix:m});return n(dl,{"Array, Array | Matrix":function(u,p){u=a(u);var v=t(u),h=s(v.L,v.U,v.p,null,p);return h.valueOf()},"DenseMatrix, Array | Matrix":function(u,p){var v=t(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix":function(u,p){var v=t(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix, number, number":function(u,p,v,h){var b=r(u,v,h);return s(b.L,b.U,b.p,b.q,p)},"Object, Array | Matrix":function(u,p){return s(u.L,u.U,u.p,u.q,p)}});function c(o){if(Oe(o))return o;if(Xe(o))return a(o);throw new TypeError("Invalid Matrix LU decomposition")}function s(o,u,p,v,h){o=c(o),u=c(u),p&&(h=f(o,h,!0),h._data=hl(p,h._data));var b=l(o,h),w=i(u,b);return v&&(w._data=hl(v,w._data)),w}}),qM="Help",RM=["parse"],FM=R(qM,RM,e=>{var{parse:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!t)throw new Error('Argument "doc" missing');this.doc=t}return a.prototype.type="Help",a.prototype.isHelp=!0,a.prototype.toString=function(){var t=this.doc||{},r=`
49
+ `}}}})});function vl(e,n){var a,t=n.length,r=[];if(e)for(a=0;a<t;a++)r[e[a]]=n[a];else for(a=0;a<t;a++)r[a]=n[a];return r}var hl="lusolve",_M=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],$M=R(hl,_M,e=>{var{typed:n,matrix:a,lup:t,slu:r,usolve:i,lsolve:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(hl,{"Array, Array | Matrix":function(u,p){u=a(u);var v=t(u),h=s(v.L,v.U,v.p,null,p);return h.valueOf()},"DenseMatrix, Array | Matrix":function(u,p){var v=t(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix":function(u,p){var v=t(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix, number, number":function(u,p,v,h){var b=r(u,v,h);return s(b.L,b.U,b.p,b.q,p)},"Object, Array | Matrix":function(u,p){return s(u.L,u.U,u.p,u.q,p)}});function c(o){if(Oe(o))return o;if(Xe(o))return a(o);throw new TypeError("Invalid Matrix LU decomposition")}function s(o,u,p,v,h){o=c(o),u=c(u),p&&(h=f(o,h,!0),h._data=vl(p,h._data));var b=l(o,h),w=i(u,b);return v&&(w._data=vl(v,w._data)),w}}),IM="Help",qM=["parse"],RM=R(IM,qM,e=>{var{parse:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!t)throw new Error('Argument "doc" missing');this.doc=t}return a.prototype.type="Help",a.prototype.isHelp=!0,a.prototype.toString=function(){var t=this.doc||{},r=`
50
50
  `;if(t.name&&(r+="Name: "+t.name+`
51
51
 
52
52
  `),t.category&&(r+="Category: "+t.category+`
@@ -60,11 +60,11 @@ q: `+this.q.toString():"")+`
60
60
 
61
61
  `),t.examples){r+=`Examples:
62
62
  `;for(var i={},l=0;l<t.examples.length;l++){var m=t.examples[l];r+=" "+m+`
63
- `;var f=void 0;try{f=n(m).compile().evaluate(i)}catch(c){f=c}f!==void 0&&!Ja(f)&&(r+=" "+Re(f,{precision:14})+`
63
+ `;var f=void 0;try{f=n(m).compile().evaluate(i)}catch(c){f=c}f!==void 0&&!Wa(f)&&(r+=" "+Re(f,{precision:14})+`
64
64
  `)}r+=`
65
65
  `}return t.mayThrow&&t.mayThrow.length&&(r+="Throws: "+t.mayThrow.join(", ")+`
66
66
 
67
67
  `),t.seealso&&t.seealso.length&&(r+="See also: "+t.seealso.join(", ")+`
68
- `),r},a.prototype.toJSON=function(){var t=Ce(this.doc);return t.mathjs="Help",t},a.fromJSON=function(t){var r={};return Object.keys(t).filter(i=>i!=="mathjs").forEach(i=>{r[i]=t[i]}),new a(r)},a.prototype.valueOf=a.prototype.toString,a},{isClass:!0}),zM="Chain",PM=["?on","math"],UM=R(zM,PM,e=>{var{on:n,math:a}=e;function t(f){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Ka(f)?this.value=f.value:this.value=f}t.prototype.type="Chain",t.prototype.isChain=!0,t.prototype.done=function(){return this.value},t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return Re(this.value)},t.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},t.fromJSON=function(f){return new t(f.value)};function r(f,c){typeof c=="function"&&(t.prototype[f]=l(c))}function i(f,c){qp(t.prototype,f,function(){var o=c();if(typeof o=="function")return l(o)})}function l(f){return function(){for(var c=[this.value],s=0;s<arguments.length;s++)c[s+1]=arguments[s];return new t(f.apply(f,c))}}t.createProxy=function(f,c){if(typeof f=="string")r(f,c);else{var s=function(p){Me(f,p)&&m[p]===void 0&&i(p,()=>f[p])};for(var o in f)s(o)}};var m={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return t.createProxy(a),n&&n("import",function(f,c,s){s||i(f,c)}),t},{isClass:!0}),gl={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},LM={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},kM={name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},HM={name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},GM={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},VM={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},ZM={name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},XM={name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},YM={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},WM={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},JM={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},yl={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},QM={name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},KM={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},jM={name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},e2={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},r2={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},t2={name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},n2={name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},a2={name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},i2={name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},o2={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},s2={name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},u2={name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},c2={name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},f2={name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},l2={name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},m2={name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},p2={name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},v2={name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},h2={name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},d2={name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},g2={name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},y2={name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},x2={name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},b2={name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},w2={name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},N2={name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},M2={name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},A2={name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},S2={name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},E2={name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},C2={name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","evaluate"]},O2={name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},D2={name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},T2={name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},B2={name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},_2={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},$2={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},I2={name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},q2={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},R2={name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},F2={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},z2={name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},P2={name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},U2={name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},L2={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},k2={name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},H2={name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},G2={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},V2={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},Z2={name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},X2={name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},Y2={name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},W2={name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},J2={name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},Q2={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},K2={name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},j2={name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},eA={name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},rA={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},tA={name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nA={name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},aA={name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},iA={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},oA={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sA={name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},uA={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},cA={name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},fA={name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},lA={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},mA={name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},pA={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},vA={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},hA={name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},dA={name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},gA={name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},yA={name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},xA={name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},bA={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},wA={name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},NA={name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},MA={name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},AA={name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},SA={name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},EA={name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},CA={name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},OA={name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},DA={name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},TA={name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},BA={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},_A={name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},$A={name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},IA={name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},qA={name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},RA={name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},FA={name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},zA={name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},PA={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},UA={name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},LA={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},kA={name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},HA={name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},GA={name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},VA={name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},ZA={name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},XA={name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},YA={name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},WA={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},JA={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},QA={name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},KA={name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},jA={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eS={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},rS={name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},tS={name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},nS={name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},aS={name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},iS={name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},oS={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},sS={name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},uS={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},cS={name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},fS={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},lS={name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},mS={name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},pS={name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},vS={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},hS={name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},dS={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},gS={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},yS={name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},xS={name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},bS={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},wS={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},NS={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},MS={name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},AS={name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},SS={name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},ES={name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},CS={name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},OS={name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},DS={name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},TS={name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},BS={name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},_S={name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},$S={name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},IS={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},qS={name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},RS={name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},FS={name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},zS={name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},PS={name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},US={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},LS={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},kS={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},HS={name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},GS={name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},VS={name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},ZS={name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},XS={name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},YS={name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},WS={name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},JS={name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},QS={name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},KS={name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},jS={name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},eE={name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},rE={name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},tE={name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},nE={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},aE={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},iE={name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},oE={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},sE={name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},uE={name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},cE={name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber.
68
+ `),r},a.prototype.toJSON=function(){var t=Ce(this.doc);return t.mathjs="Help",t},a.fromJSON=function(t){var r={};return Object.keys(t).filter(i=>i!=="mathjs").forEach(i=>{r[i]=t[i]}),new a(r)},a.prototype.valueOf=a.prototype.toString,a},{isClass:!0}),FM="Chain",zM=["?on","math"],PM=R(FM,zM,e=>{var{on:n,math:a}=e;function t(f){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Qa(f)?this.value=f.value:this.value=f}t.prototype.type="Chain",t.prototype.isChain=!0,t.prototype.done=function(){return this.value},t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return Re(this.value)},t.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},t.fromJSON=function(f){return new t(f.value)};function r(f,c){typeof c=="function"&&(t.prototype[f]=l(c))}function i(f,c){Ip(t.prototype,f,function(){var o=c();if(typeof o=="function")return l(o)})}function l(f){return function(){for(var c=[this.value],s=0;s<arguments.length;s++)c[s+1]=arguments[s];return new t(f.apply(f,c))}}t.createProxy=function(f,c){if(typeof f=="string")r(f,c);else{var s=function(p){Me(f,p)&&m[p]===void 0&&i(p,()=>f[p])};for(var o in f)s(o)}};var m={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return t.createProxy(a),n&&n("import",function(f,c,s){s||i(f,c)}),t},{isClass:!0}),dl={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},UM={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},LM={name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},kM={name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},HM={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},GM={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},VM={name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},ZM={name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},XM={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},YM={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},WM={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},gl={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},JM={name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},QM={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},KM={name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},jM={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},e2={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},r2={name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},t2={name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},n2={name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},a2={name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},i2={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},o2={name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},s2={name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},u2={name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},c2={name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},f2={name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},l2={name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},m2={name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},p2={name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},v2={name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},h2={name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},d2={name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},g2={name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},y2={name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},x2={name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},b2={name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},w2={name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},N2={name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},M2={name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},A2={name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},S2={name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},E2={name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","evaluate"]},C2={name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},O2={name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},D2={name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},T2={name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},B2={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},_2={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},$2={name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},I2={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},q2={name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},R2={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},F2={name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},z2={name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},P2={name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},U2={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},L2={name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},k2={name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},H2={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},G2={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},V2={name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},Z2={name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},X2={name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},Y2={name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},W2={name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},J2={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},Q2={name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},K2={name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},j2={name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},eA={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},rA={name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},tA={name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nA={name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},aA={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},iA={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},oA={name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sA={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},uA={name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},cA={name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},fA={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},lA={name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},mA={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},pA={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},vA={name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},hA={name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},dA={name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},gA={name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},yA={name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},xA={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},bA={name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},wA={name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},NA={name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},MA={name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},AA={name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},SA={name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},EA={name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},CA={name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},OA={name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},DA={name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},TA={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},BA={name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},_A={name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},$A={name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},IA={name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},qA={name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},RA={name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},FA={name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},zA={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},PA={name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},UA={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},LA={name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},kA={name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},HA={name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},GA={name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},VA={name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},ZA={name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},XA={name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},YA={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},WA={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},JA={name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},QA={name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},KA={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},jA={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eS={name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},rS={name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},tS={name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},nS={name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},aS={name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},iS={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},oS={name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},sS={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},uS={name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},cS={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},fS={name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},lS={name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},mS={name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},pS={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},vS={name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},hS={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},dS={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},gS={name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},yS={name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},xS={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},bS={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},wS={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},NS={name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},MS={name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},AS={name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},SS={name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},ES={name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},CS={name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},OS={name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},DS={name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},TS={name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},BS={name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},_S={name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},$S={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},IS={name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},qS={name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},RS={name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},FS={name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},zS={name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},PS={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},US={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},LS={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},kS={name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},HS={name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},GS={name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},VS={name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},ZS={name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},XS={name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},YS={name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},WS={name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},JS={name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},QS={name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},KS={name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},jS={name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},eE={name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},rE={name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},tE={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},nE={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},aE={name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},iE={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},oE={name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},sE={name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},uE={name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber.
69
69
 
70
- In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},fE={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},lE={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mE={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},pE={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},vE={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},hE={name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},dE={name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},gE={name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},yE={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},xE={name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},bE={name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},wE={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},NE={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},ME={name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},AE={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},SE={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},EE={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},CE={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},OE={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},DE={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},TE={name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},BE={name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},_E={name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},$E={name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},IE={name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},qE={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},RE={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},FE={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},zE={name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},PE={name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},UE={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},LE={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},kE={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},HE={name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},GE={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},VE={name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},ZE={name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},XE={name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},YE={name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},WE={name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},JE={name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},QE={name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},KE={name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]},jE={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},eC={name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},rC={name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},tC={bignumber:t2,boolean:n2,complex:a2,createUnit:i2,fraction:o2,index:s2,matrix:u2,number:c2,sparse:f2,splitUnit:l2,string:m2,unit:p2,e:gl,E:gl,false:LM,i:kM,Infinity:HM,LN2:VM,LN10:GM,LOG2E:XM,LOG10E:ZM,NaN:YM,null:WM,pi:yl,PI:yl,phi:JM,SQRT1_2:QM,SQRT2:KM,tau:jM,true:e2,version:r2,speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:g2,lsolve:x2,lsolveAll:b2,lup:w2,lusolve:N2,leafCount:y2,resolve:S2,simplify:E2,simplifyCore:C2,symbolicEqual:D2,rationalize:A2,slu:O2,usolve:T2,usolveAll:B2,qr:M2,abs:_2,add:$2,cbrt:I2,ceil:q2,cube:R2,divide:F2,dotDivide:z2,dotMultiply:P2,dotPow:U2,exp:L2,expm:k2,expm1:H2,fix:G2,floor:V2,gcd:Z2,hypot:X2,lcm:W2,log:J2,log2:j2,log1p:K2,log10:Q2,mod:eA,multiply:rA,norm:tA,nthRoot:nA,nthRoots:aA,pow:iA,round:oA,sign:sA,sqrt:uA,sqrtm:cA,square:fA,subtract:lA,unaryMinus:mA,unaryPlus:pA,xgcd:vA,invmod:Y2,bitAnd:hA,bitNot:dA,bitOr:gA,bitXor:yA,leftShift:xA,rightArithShift:bA,rightLogShift:wA,bellNumbers:NA,catalan:MA,composition:AA,stirlingS2:SA,config:v2,import:h2,typed:d2,arg:EA,conj:CA,re:DA,im:OA,evaluate:TA,help:BA,distance:_A,intersect:$A,and:IA,not:qA,or:RA,xor:FA,concat:PA,count:UA,cross:LA,column:zA,ctranspose:kA,det:HA,diag:GA,diff:VA,dot:ZA,getMatrixDataType:QA,identity:KA,filter:YA,flatten:WA,forEach:JA,inv:jA,pinv:eS,eigs:XA,kron:rS,matrixFromFunction:aS,matrixFromRows:iS,matrixFromColumns:nS,map:tS,ones:oS,partitionSelect:sS,range:uS,resize:fS,reshape:cS,rotate:lS,rotationMatrix:mS,row:pS,size:vS,sort:hS,squeeze:dS,subset:gS,trace:yS,transpose:xS,zeros:bS,fft:wS,ifft:NS,combinations:MS,combinationsWithRep:AS,factorial:SS,gamma:ES,kldivergence:OS,lgamma:CS,multinomial:DS,permutations:TS,pickRandom:BS,random:_S,randomInt:$S,compare:IS,compareNatural:qS,compareText:RS,deepEqual:FS,equal:zS,equalText:PS,larger:US,largerEq:LS,smaller:kS,smallerEq:HS,unequal:GS,setCartesian:VS,setDifference:ZS,setDistinct:XS,setIntersect:YS,setIsSubset:WS,setMultiplicity:JS,setPowerset:QS,setSize:KS,setSymDifference:jS,setUnion:eE,erf:rE,cumsum:lE,mad:tE,max:nE,mean:aE,median:iE,min:oE,mode:sE,prod:uE,quantileSeq:cE,std:fE,sum:mE,variance:pE,acos:vE,acosh:hE,acot:dE,acoth:gE,acsc:yE,acsch:xE,asec:bE,asech:wE,asin:NE,asinh:ME,atan:AE,atanh:EE,atan2:SE,cos:CE,cosh:OE,cot:DE,coth:TE,csc:BE,csch:_E,sec:$E,sech:IE,sin:qE,sinh:RE,tan:FE,tanh:zE,to:PE,clone:LE,format:kE,bin:UE,oct:jE,hex:GE,isNaN:ZE,isInteger:VE,isNegative:XE,isNumeric:YE,hasNumericValue:HE,isPositive:WE,isPrime:JE,isZero:QE,print:eC,typeOf:rC,numeric:KE},xl="help",nC=["typed","mathWithTransform","Help"],aC=R(xl,nC,e=>{var{typed:n,mathWithTransform:a,Help:t}=e;return n(xl,{any:function(i){var l,m=i;if(typeof i!="string"){for(l in a)if(Me(a,l)&&i===a[l]){m=l;break}}var f=Gr(tC,m);if(!f){var c=typeof m=="function"?m.name:m;throw new Error('No documentation found on "'+c+'"')}return new t(f)}})}),bl="chain",iC=["typed","Chain"],oC=R(bl,iC,e=>{var{typed:n,Chain:a}=e;return n(bl,{"":function(){return new a},any:function(r){return new a(r)}})}),wl="det",sC=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],uC=R(wl,sC,e=>{var{typed:n,matrix:a,subtract:t,multiply:r,divideScalar:i,isZero:l,unaryMinus:m}=e;return n(wl,{any:function(s){return Ce(s)},"Array | Matrix":function(s){var o;switch(Oe(s)?o=s.size():Array.isArray(s)?(s=a(s),o=s.size()):o=[],o.length){case 0:return Ce(s);case 1:if(o[0]===1)return Ce(s.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Re(o)+")");case 2:{var u=o[0],p=o[1];if(u===p)return f(s.clone().valueOf(),u);throw new RangeError("Matrix must be square (size: "+Re(o)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(o)+")")}}});function f(c,s,o){if(s===1)return Ce(c[0][0]);if(s===2)return t(r(c[0][0],c[1][1]),r(c[1][0],c[0][1]));for(var u=!1,p=new Array(s).fill(0).map((A,S)=>S),v=0;v<s;v++){var h=p[v];if(l(c[h][v])){var b=void 0;for(b=v+1;b<s;b++)if(!l(c[p[b]][v])){h=p[b],p[b]=p[v],p[v]=h,u=!u;break}if(b===s)return c[h][v]}for(var w=c[h][v],N=v===0?1:c[p[v-1]][v-1],g=v+1;g<s;g++)for(var y=p[g],x=v+1;x<s;x++)c[y][x]=i(t(r(c[y][x],w),r(c[y][v],c[h][x])),N)}var d=c[p[s-1]][s-1];return u?m(d):d}}),Nl="inv",cC=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],fC=R(Nl,cC,e=>{var{typed:n,matrix:a,divideScalar:t,addScalar:r,multiply:i,unaryMinus:l,det:m,identity:f,abs:c}=e;return n(Nl,{"Array | Matrix":function(u){var p=Oe(u)?u.size():Pe(u);switch(p.length){case 1:if(p[0]===1)return Oe(u)?a([t(1,u.valueOf()[0])]):[t(1,u[0])];throw new RangeError("Matrix must be square (size: "+Re(p)+")");case 2:{var v=p[0],h=p[1];if(v===h)return Oe(u)?a(s(u.valueOf(),v,h),u.storage()):s(u,v,h);throw new RangeError("Matrix must be square (size: "+Re(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(p)+")")}},any:function(u){return t(1,u)}});function s(o,u,p){var v,h,b,w,N;if(u===1){if(w=o[0][0],w===0)throw Error("Cannot calculate inverse, determinant is zero");return[[t(1,w)]]}else if(u===2){var g=m(o);if(g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[t(o[1][1],g),t(l(o[0][1]),g)],[t(l(o[1][0]),g),t(o[0][0],g)]]}else{var y=o.concat();for(v=0;v<u;v++)y[v]=y[v].concat();for(var x=f(u).valueOf(),d=0;d<p;d++){var A=c(y[d][d]),S=d;for(v=d+1;v<u;)c(y[v][d])>A&&(A=c(y[v][d]),S=v),v++;if(A===0)throw Error("Cannot calculate inverse, determinant is zero");v=S,v!==d&&(N=y[d],y[d]=y[v],y[v]=N,N=x[d],x[d]=x[v],x[v]=N);var O=y[d],M=x[d];for(v=0;v<u;v++){var _=y[v],E=x[v];if(v!==d){if(_[d]!==0){for(b=t(l(_[d]),O[d]),h=d;h<p;h++)_[h]=r(_[h],i(b,O[h]));for(h=0;h<p;h++)E[h]=r(E[h],i(b,M[h]))}}else{for(b=O[d],h=d;h<p;h++)_[h]=t(_[h],b);for(h=0;h<p;h++)E[h]=t(E[h],b)}}}return x}}}),Ml="pinv",lC=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],mC=R(Ml,lC,e=>{var{typed:n,matrix:a,inv:t,deepEqual:r,equal:i,dotDivide:l,dot:m,ctranspose:f,divideScalar:c,multiply:s,add:o,Complex:u}=e;return n(Ml,{"Array | Matrix":function(g){var y=Oe(g)?g.size():Pe(g);switch(y.length){case 1:return w(g)?f(g):y[0]===1?t(g):l(f(g),m(g,g));case 2:{if(w(g))return f(g);var x=y[0],d=y[1];if(x===d)try{return t(g)}catch(A){if(!(A instanceof Error&&A.message.match(/Cannot calculate inverse, determinant is zero/)))throw A}return Oe(g)?a(p(g.valueOf(),x,d),g.storage()):p(g,x,d)}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(y)+")")}},any:function(g){return i(g,0)?Ce(g):c(1,g)}});function p(N,g,y){var{C:x,F:d}=h(N,g,y),A=s(t(s(f(x),x)),f(x)),S=s(f(d),t(s(d,f(d))));return s(S,A)}function v(N,g,y){for(var x=Ce(N),d=0,A=0;A<g;A++){if(y<=d)return x;for(var S=A;b(x[S][d]);)if(S++,g===S&&(S=A,d++,y===d))return x;[x[S],x[A]]=[x[A],x[S]];for(var O=x[A][d],M=0;M<y;M++)x[A][M]=l(x[A][M],O);for(var _=0;_<g;_++)if(_!==A){O=x[_][d];for(var E=0;E<y;E++)x[_][E]=o(x[_][E],s(-1,s(O,x[A][E])))}d++}return x}function h(N,g,y){var x=v(N,g,y),d=N.map((S,O)=>S.filter((M,_)=>_<g&&!b(m(x[_],x[_])))),A=x.filter((S,O)=>!b(m(x[O],x[O])));return{C:d,F:A}}function b(N){return i(o(N,u(1,1)),o(0,u(1,1)))}function w(N){return r(o(N,u(1,1)),o(s(N,0),u(1,1)))}});function pC(e){var{addScalar:n,subtract:a,flatten:t,multiply:r,multiplyScalar:i,divideScalar:l,sqrt:m,abs:f,bignumber:c,diag:s,inv:o,qr:u,usolve:p,usolveAll:v,equal:h,complex:b,larger:w,smaller:N,matrixFromColumns:g,dot:y}=e;function x(H,W,j,V,K){K===void 0&&(K=!0);var te=d(H,W,j,V,K);A(H,W,j,V,K,te);var{values:re,C:ie}=S(H,W,j,V,K),ne;return K&&(ne=O(H,W,ie,te,re,j,V),ne=g(...ne)),{values:re,vectors:ne}}function d(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",ie=te?c(0):0,ne=te?c(1):re?b(1):1,ue=te?c(1):1,ee=te?c(10):2,ye=i(ee,ee),we;K&&(we=Array(W).fill(ne));for(var me=!1;!me;){me=!0;for(var xe=0;xe<W;xe++){for(var F=ie,Y=ie,k=0;k<W;k++)if(xe!==k){var U=f(H[xe][k]);F=n(F,U),Y=n(Y,U)}if(!h(F,0)&&!h(Y,0)){for(var J=ue,q=F,P=l(Y,ee),Q=i(Y,ee);N(q,P);)q=i(q,ye),J=i(J,ee);for(;w(q,Q);)q=l(q,ye),J=l(J,ee);var L=N(l(n(q,Y),J),i(n(F,Y),.95));if(L){me=!1;for(var se=l(1,J),fe=0;fe<W;fe++)xe!==fe&&(H[xe][fe]=i(H[xe][fe],J),H[fe][xe]=i(H[fe][xe],se));K&&(we[xe]=i(we[xe],J))}}}}return s(we)}function A(H,W,j,V,K,te){var re=V==="BigNumber",ie=V==="Complex",ne=re?c(0):ie?b(0):0;re&&(j=c(j));for(var ue=0;ue<W-2;ue++){for(var ee=0,ye=ne,we=ue+1;we<W;we++){var me=H[we][ue];N(f(ye),f(me))&&(ye=me,ee=we)}if(!N(f(ye),j)){if(ee!==ue+1){var xe=H[ee];H[ee]=H[ue+1],H[ue+1]=xe;for(var F=0;F<W;F++){var Y=H[F][ee];H[F][ee]=H[F][ue+1],H[F][ue+1]=Y}if(K){var k=te[ee];te[ee]=te[ue+1],te[ue+1]=k}}for(var U=ue+2;U<W;U++){var J=l(H[U][ue],ye);if(J!==0){for(var q=0;q<W;q++)H[U][q]=a(H[U][q],i(J,H[ue+1][q]));for(var P=0;P<W;P++)H[P][ue+1]=n(H[P][ue+1],i(J,H[P][U]));if(K)for(var Q=0;Q<W;Q++)te[U][Q]=a(te[U][Q],i(J,te[ue+1][Q]))}}}}return te}function S(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",ie=te?c(1):re?b(1):1;te&&(j=c(j));for(var ne=Ce(H),ue=[],ee=W,ye=[],we=K?s(Array(W).fill(ie)):void 0,me=K?s(Array(ee).fill(ie)):void 0,xe=0;xe<=100;){xe+=1;for(var F=0,Y=0;Y<ee;Y++)ne[Y][Y]=a(ne[Y][Y],F);var{Q:k,R:U}=u(ne);ne=r(U,k);for(var J=0;J<ee;J++)ne[J][J]=n(ne[J][J],F);if(K&&(me=r(me,k)),ee===1||N(f(ne[ee-1][ee-2]),j)){xe=0,ue.push(ne[ee-1][ee-1]),K&&(ye.unshift([[1]]),E(me,W),we=r(we,me),ee>1&&(me=s(Array(ee-1).fill(ie)))),ee-=1,ne.pop();for(var q=0;q<ee;q++)ne[q].pop()}else if(ee===2||N(f(ne[ee-2][ee-3]),j)){xe=0;var P=M(ne[ee-2][ee-2],ne[ee-2][ee-1],ne[ee-1][ee-2],ne[ee-1][ee-1]);ue.push(...P),K&&(ye.unshift(_(ne[ee-2][ee-2],ne[ee-2][ee-1],ne[ee-1][ee-2],ne[ee-1][ee-1],P[0],P[1],j,V)),E(me,W),we=r(we,me),ee>2&&(me=s(Array(ee-2).fill(ie)))),ee-=2,ne.pop(),ne.pop();for(var Q=0;Q<ee;Q++)ne[Q].pop(),ne[Q].pop()}if(ee===0)break}if(ue.sort((fe,ge)=>+a(f(fe),f(ge))),xe>100){var L=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ue.join(", "));throw L.values=ue,L.vectors=[],L}var se=K?r(we,$(ye,W)):void 0;return{values:ue,C:se}}function O(H,W,j,V,K,te,re){var ie=o(j),ne=r(ie,H,j),ue=re==="BigNumber",ee=re==="Complex",ye=ue?c(0):ee?b(0):0,we=ue?c(1):ee?b(1):1,me=[],xe=[];for(var F of K){var Y=z(me,F,h);Y===-1?(me.push(F),xe.push(1)):xe[Y]+=1}for(var k=[],U=me.length,J=Array(W).fill(ye),q=s(Array(W).fill(we)),P=[],Q=function(ge){var pe=me[ge],ve=a(ne,r(pe,q)),Ne=v(ve,J);for(Ne.shift();Ne.length<xe[ge];){var Qe=I(ve,W,Ne,te,re);if(Qe==null){P.push(pe);break}Ne.push(Qe)}var fr=r(o(V),j);Ne=Ne.map(nr=>r(fr,nr)),k.push(...Ne.map(nr=>t(nr)))},L=0;L<U;L++)Q(L);if(P.length!==0){var se=new Error("Failed to find eigenvectors for the following eigenvalues: "+P.join(", "));throw se.values=K,se.vectors=k,se}return k}function M(H,W,j,V){var K=n(H,V),te=a(i(H,V),i(W,j)),re=i(K,.5),ie=i(m(a(i(K,K),i(4,te))),.5);return[n(re,ie),a(re,ie)]}function _(H,W,j,V,K,te,re,ie){var ne=ie==="BigNumber",ue=ie==="Complex",ee=ne?c(0):ue?b(0):0,ye=ne?c(1):ue?b(1):1;if(N(f(j),re))return[[ye,ee],[ee,ye]];if(w(f(a(K,te)),re))return[[a(K,V),a(te,V)],[j,j]];var we=a(H,K),me=a(W,K),xe=a(j,K),F=a(V,K);return N(f(me),re)?[[we,ye],[xe,ee]]:[[me,ee],[F,ye]]}function E(H,W){for(var j=0;j<H.length;j++)H[j].push(...Array(W-H[j].length).fill(0));for(var V=H.length;V<W;V++)H.push(Array(W).fill(0)),H[V][V]=1;return H}function $(H,W){for(var j=[],V=0;V<W;V++)j[V]=Array(W).fill(0);var K=0;for(var te of H){for(var re=te.length,ie=0;ie<re;ie++)for(var ne=0;ne<re;ne++)j[K+ie][K+ne]=te[ie][ne];K+=re}return j}function z(H,W,j){for(var V=0;V<H.length;V++)if(j(H[V],W))return V;return-1}function I(H,W,j,V,K){for(var te=K==="BigNumber"?c(1e3):1e3,re,ie=0;re=T(W,j,K),re=p(H,re),!w(G(re),te);)if(++ie>=5)return null;for(ie=0;;){var ne=p(H,re);if(N(G(B(re,[ne])),V))break;if(++ie>=10)return null;re=D(ne)}return re}function T(H,W,j){var V=j==="BigNumber",K=j==="Complex",te=Array(H).fill(0).map(re=>2*Math.random()-1);return V&&(te=te.map(re=>c(re))),K&&(te=te.map(re=>b(re))),te=B(te,W),D(te,j)}function B(H,W){for(var j of W)H=a(H,r(l(y(j,H),y(j,j)),j));return H}function G(H){return f(m(y(H,H)))}function D(H,W){var j=W==="BigNumber",V=W==="Complex",K=j?c(1):V?b(1):1;return r(l(K,G(H)),H)}return x}function vC(e){var{config:n,addScalar:a,subtract:t,abs:r,atan:i,cos:l,sin:m,multiplyScalar:f,inv:c,bignumber:s,multiply:o,add:u}=e;function p(M,_){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:n.epsilon,$=arguments.length>3?arguments[3]:void 0;if($==="number")return v(M,E);if($==="BigNumber")return h(M,E);throw TypeError("Unsupported data type: "+$)}function v(M,_){for(var E=M.length,$=Math.abs(_/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=d(M);Math.abs(B[1])>=Math.abs($);){var G=B[0][0],D=B[0][1];z=b(M[G][G],M[D][D],M[G][D]),M=x(M,z,G,D),I=N(I,z,G,D),B=d(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Ce(H),Ce(I))}function h(M,_){for(var E=M.length,$=r(_/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=A(M);r(B[1])>=r($);){var G=B[0][0],D=B[0][1];z=w(M[G][G],M[D][D],M[G][D]),M=y(M,z,G,D),I=g(I,z,G,D),B=A(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Ce(H),Ce(I))}function b(M,_,E){var $=_-M;return Math.abs($)<=n.epsilon?Math.PI/4:.5*Math.atan(2*E/(_-M))}function w(M,_,E){var $=t(_,M);return r($)<=n.epsilon?s(-1).acos().div(4):f(.5,i(o(2,E,c($))))}function N(M,_,E,$){for(var z=M.length,I=Math.cos(_),T=Math.sin(_),B=O(z,0),G=O(z,0),D=0;D<z;D++)B[D]=I*M[D][E]-T*M[D][$],G[D]=T*M[D][E]+I*M[D][$];for(var H=0;H<z;H++)M[H][E]=B[H],M[H][$]=G[H];return M}function g(M,_,E,$){for(var z=M.length,I=l(_),T=m(_),B=O(z,s(0)),G=O(z,s(0)),D=0;D<z;D++)B[D]=t(f(I,M[D][E]),f(T,M[D][$])),G[D]=a(f(T,M[D][E]),f(I,M[D][$]));for(var H=0;H<z;H++)M[H][E]=B[H],M[H][$]=G[H];return M}function y(M,_,E,$){for(var z=M.length,I=s(l(_)),T=s(m(_)),B=f(I,I),G=f(T,T),D=O(z,s(0)),H=O(z,s(0)),W=o(s(2),I,T,M[E][$]),j=a(t(f(B,M[E][E]),W),f(G,M[$][$])),V=u(f(G,M[E][E]),W,f(B,M[$][$])),K=0;K<z;K++)D[K]=t(f(I,M[E][K]),f(T,M[$][K])),H[K]=a(f(T,M[E][K]),f(I,M[$][K]));M[E][E]=j,M[$][$]=V,M[E][$]=s(0),M[$][E]=s(0);for(var te=0;te<z;te++)te!==E&&te!==$&&(M[E][te]=D[te],M[te][E]=D[te],M[$][te]=H[te],M[te][$]=H[te]);return M}function x(M,_,E,$){for(var z=M.length,I=Math.cos(_),T=Math.sin(_),B=I*I,G=T*T,D=O(z,0),H=O(z,0),W=B*M[E][E]-2*I*T*M[E][$]+G*M[$][$],j=G*M[E][E]+2*I*T*M[E][$]+B*M[$][$],V=0;V<z;V++)D[V]=I*M[E][V]-T*M[$][V],H[V]=T*M[E][V]+I*M[$][V];M[E][E]=W,M[$][$]=j,M[E][$]=0,M[$][E]=0;for(var K=0;K<z;K++)K!==E&&K!==$&&(M[E][K]=D[K],M[K][E]=D[K],M[$][K]=H[K],M[K][$]=H[K]);return M}function d(M){for(var _=M.length,E=0,$=[0,1],z=0;z<_;z++)for(var I=z+1;I<_;I++)Math.abs(E)<Math.abs(M[z][I])&&(E=Math.abs(M[z][I]),$=[z,I]);return[$,E]}function A(M){for(var _=M.length,E=0,$=[0,1],z=0;z<_;z++)for(var I=z+1;I<_;I++)r(E)<r(M[z][I])&&(E=r(M[z][I]),$=[z,I]);return[$,E]}function S(M,_){for(var E=M.length,$=Array(E),z=Array(E),I=0;I<E;I++)z[I]=Array(E);for(var T=0;T<E;T++){for(var B=0,G=M[0],D=0;D<M.length;D++)r(M[D])<r(G)&&(B=D,G=M[B]);$[T]=M.splice(B,1)[0];for(var H=0;H<E;H++)z[H][T]=_[H][B],_[H].splice(B,1)}return{values:$,vectors:z}}function O(M,_){for(var E=new Array(M),$=0;$<M;$++)E[$]=_;return E}return p}var hC="eigs",dC=["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],gC=R(hC,dC,e=>{var{config:n,typed:a,matrix:t,addScalar:r,subtract:i,equal:l,abs:m,atan:f,cos:c,sin:s,multiplyScalar:o,divideScalar:u,inv:p,bignumber:v,multiply:h,add:b,larger:w,column:N,flatten:g,number:y,complex:x,sqrt:d,diag:A,qr:S,usolve:O,usolveAll:M,im:_,re:E,smaller:$,matrixFromColumns:z,dot:I}=e,T=vC({config:n,addScalar:r,subtract:i,abs:m,atan:f,cos:c,sin:s,multiplyScalar:o,inv:p,bignumber:v,multiply:h,add:b}),B=pC({addScalar:r,subtract:i,multiply:h,multiplyScalar:o,flatten:g,divideScalar:u,sqrt:d,abs:m,bignumber:v,diag:A,qr:S,inv:p,usolve:O,usolveAll:M,equal:l,complex:x,larger:w,smaller:$,matrixFromColumns:z,dot:I});return a("eigs",{Array:function(K){var te=t(K);return G(te)},"Array, number|BigNumber":function(K,te){var re=t(K);return G(re,te)},Matrix:function(K){var{values:te,vectors:re}=G(K);return{values:t(te),vectors:t(re)}},"Matrix, number|BigNumber":function(K,te){var{values:re,vectors:ie}=G(K,te);return{values:t(re),vectors:t(ie)}}});function G(V,K){K===void 0&&(K=n.epsilon);var te=V.size();if(te.length!==2||te[0]!==te[1])throw new RangeError("Matrix must be square (size: "+Re(te)+")");var re=V.toArray(),ie=te[0];if(H(re,ie,K)&&(W(re,ie),D(re,ie,K))){var ne=j(V,re,ie);return T(re,ie,K,ne)}var ue=j(V,re,ie);return B(re,ie,K,ue)}function D(V,K,te){for(var re=0;re<K;re++)for(var ie=re;ie<K;ie++)if(w(v(m(i(V[re][ie],V[ie][re]))),te))return!1;return!0}function H(V,K,te){for(var re=0;re<K;re++)for(var ie=0;ie<K;ie++)if(w(v(m(_(V[re][ie]))),te))return!1;return!0}function W(V,K){for(var te=0;te<K;te++)for(var re=0;re<K;re++)V[te][re]=E(V[te][re])}function j(V,K,te){var re=V.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var ie=!1,ne=!1,ue=!1,ee=0;ee<te;ee++)for(var ye=0;ye<te;ye++){var we=K[ee][ye];if($e(we)||at(we))ie=!0;else if(Ie(we))ne=!0;else if(vr(we))ue=!0;else throw TypeError("Unsupported type in Matrix: "+Ke(we))}if(ne&&ue&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ue){for(var me=0;me<te;me++)for(var xe=0;xe<te;xe++)K[me][xe]=x(K[me][xe]);return"Complex"}if(ne){for(var F=0;F<te;F++)for(var Y=0;Y<te;Y++)K[F][Y]=v(K[F][Y]);return"BigNumber"}if(ie){for(var k=0;k<te;k++)for(var U=0;U<te;U++)K[k][U]=y(K[k][U]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Al="expm",yC=["typed","abs","add","identity","inv","multiply"],xC=R(Al,yC,e=>{var{typed:n,abs:a,add:t,identity:r,inv:i,multiply:l}=e;return n(Al,{Matrix:function(o){var u=o.size();if(u.length!==2||u[0]!==u[1])throw new RangeError("Matrix must be square (size: "+Re(u)+")");for(var p=u[0],v=1e-15,h=m(o),b=f(h,v),w=b.q,N=b.j,g=l(o,Math.pow(2,-N)),y=r(p),x=r(p),d=1,A=g,S=-1,O=1;O<=w;O++)O>1&&(A=l(A,g),S=-S),d=d*(w-O+1)/((2*w-O+1)*O),y=t(y,l(d,A)),x=t(x,l(d*S,A));for(var M=l(i(x),y),_=0;_<N;_++)M=l(M,M);return Ut(o)?o.createSparseMatrix(M):M}});function m(s){for(var o=s.size()[0],u=0,p=0;p<o;p++){for(var v=0,h=0;h<o;h++)v+=a(s.get([p,h]));u=Math.max(v,u)}return u}function f(s,o){for(var u=30,p=0;p<u;p++)for(var v=0;v<=p;v++){var h=p-v;if(c(s,v,h)<o)return{q:v,j:h}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function c(s,o,u){for(var p=1,v=2;v<=o;v++)p*=v;for(var h=p,b=o+1;b<=2*o;b++)h*=b;var w=h*(2*o+1);return 8*Math.pow(s/Math.pow(2,u),2*o)*p*p/(h*w)}}),Sl="sqrtm",bC=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],wC=R(Sl,bC,e=>{var{typed:n,abs:a,add:t,multiply:r,sqrt:i,subtract:l,inv:m,size:f,max:c,identity:s}=e,o=1e3,u=1e-6;function p(v){var h,b=0,w=v,N=s(f(v));do{var g=w;if(w=r(.5,t(g,m(N))),N=r(.5,t(N,m(g))),h=c(a(l(w,g))),h>u&&++b>o)throw new Error("computing square root of matrix: iterative method could not converge")}while(h>u);return w}return n(Sl,{"Array | Matrix":function(h){var b=Oe(h)?h.size():Pe(h);switch(b.length){case 1:if(b[0]===1)return i(h);throw new RangeError("Matrix must be square (size: "+Re(b)+")");case 2:{var w=b[0],N=b[1];if(w===N)return p(h);throw new RangeError("Matrix must be square (size: "+Re(b)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Re(b)+")")}}})}),NC="divide",MC=["typed","matrix","multiply","equalScalar","divideScalar","inv"],AC=R(NC,MC,e=>{var{typed:n,matrix:a,multiply:t,equalScalar:r,divideScalar:i,inv:l}=e,m=wr({typed:n,equalScalar:r}),f=Ge({typed:n});return n("divide",ja({"Array | Matrix, Array | Matrix":function(s,o){return t(s,l(o))},"DenseMatrix, any":function(s,o){return f(s,o,i,!1)},"SparseMatrix, any":function(s,o){return m(s,o,i,!1)},"Array, any":function(s,o){return f(a(s),o,i,!1).valueOf()},"any, Array | Matrix":function(s,o){return t(s,l(o))}},i.signatures))}),El="distance",SC=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],EC=R(El,SC,e=>{var{typed:n,addScalar:a,subtract:t,multiplyScalar:r,divideScalar:i,unaryMinus:l,sqrt:m,abs:f}=e;return n(El,{"Array, Array, Array":function(x,d,A){if(x.length===2&&d.length===2&&A.length===2){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(d))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(A))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var S=i(t(A[1],A[0]),t(d[1],d[0])),O=r(r(S,S),d[0]),M=l(r(S,d[0])),_=x[1];return b(x[0],x[1],O,M,_)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,d,A){if(Object.keys(x).length===2&&Object.keys(d).length===2&&Object.keys(A).length===2){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(A))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in d&&"lineOnePtY"in d&&"lineTwoPtX"in A&&"lineTwoPtY"in A){var S=i(t(A.lineTwoPtY,A.lineTwoPtX),t(d.lineOnePtY,d.lineOnePtX)),O=r(r(S,S),d.lineOnePtX),M=l(r(S,d.lineOnePtX)),_=x.pointX;return b(x.pointX,x.pointY,O,M,_)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,d){if(x.length===2&&d.length===3){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!o(d))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return b(x[0],x[1],d[0],d[1],d[2])}else if(x.length===3&&d.length===6){if(!o(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!p(d))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return w(x[0],x[1],x[2],d[0],d[1],d[2],d[3],d[4],d[5])}else if(x.length===d.length&&x.length>0){if(!u(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!u(d))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,d)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,d){if(Object.keys(x).length===2&&Object.keys(d).length===3){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in d&&"yCoeffLine"in d&&"constant"in d)return b(x.pointX,x.pointY,d.xCoeffLine,d.yCoeffLine,d.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===6){if(!o(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!p(d))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"x0"in d&&"y0"in d&&"z0"in d&&"a"in d&&"b"in d&&"c"in d)return w(x.pointX,x.pointY,x.pointZ,d.x0,d.y0,d.z0,d.a,d.b,d.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(d).length===2){if(!s(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in d&&"pointTwoY"in d)return N([x.pointOneX,x.pointOneY],[d.pointTwoX,d.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===3){if(!o(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointOneZ"in x&&"pointTwoX"in d&&"pointTwoY"in d&&"pointTwoZ"in d)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[d.pointTwoX,d.pointTwoY,d.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!h(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return g(x)}});function c(y){return typeof y=="number"||Ie(y)}function s(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])}function o(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])}function u(y){return Array.isArray(y)||(y=v(y)),y.every(c)}function p(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])&&c(y[3])&&c(y[4])&&c(y[5])}function v(y){for(var x=Object.keys(y),d=[],A=0;A<x.length;A++)d.push(y[x[A]]);return d}function h(y){if(y[0].length===2&&c(y[0][0])&&c(y[0][1])){if(y.some(x=>x.length!==2||!c(x[0])||!c(x[1])))return!1}else if(y[0].length===3&&c(y[0][0])&&c(y[0][1])&&c(y[0][2])){if(y.some(x=>x.length!==3||!c(x[0])||!c(x[1])||!c(x[2])))return!1}else return!1;return!0}function b(y,x,d,A,S){var O=f(a(a(r(d,y),r(A,x)),S)),M=m(a(r(d,d),r(A,A)));return i(O,M)}function w(y,x,d,A,S,O,M,_,E){var $=[t(r(t(S,x),E),r(t(O,d),_)),t(r(t(O,d),M),r(t(A,y),E)),t(r(t(A,y),_),r(t(S,x),M))];$=m(a(a(r($[0],$[0]),r($[1],$[1])),r($[2],$[2])));var z=m(a(a(r(M,M),r(_,_)),r(E,E)));return i($,z)}function N(y,x){for(var d=y.length,A=0,S=0,O=0;O<d;O++)S=t(y[O],x[O]),A=a(r(S,S),A);return m(A)}function g(y){for(var x=[],d=[],A=[],S=0;S<y.length-1;S++)for(var O=S+1;O<y.length;O++)y[0].length===2?(d=[y[S][0],y[S][1]],A=[y[O][0],y[O][1]]):y[0].length===3&&(d=[y[S][0],y[S][1],y[S][2]],A=[y[O][0],y[O][1],y[O][2]]),x.push(N(d,A));return x}}),CC="intersect",OC=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],DC=R(CC,OC,e=>{var{typed:n,config:a,abs:t,add:r,addScalar:i,matrix:l,multiply:m,multiplyScalar:f,divideScalar:c,subtract:s,smaller:o,equalScalar:u,flatten:p,isZero:v,isNumeric:h}=e;return n("intersect",{"Array, Array, Array":b,"Array, Array, Array, Array":w,"Matrix, Matrix, Matrix":function(_,E,$){var z=b(_.valueOf(),E.valueOf(),$.valueOf());return z===null?null:l(z)},"Matrix, Matrix, Matrix, Matrix":function(_,E,$,z){var I=w(_.valueOf(),E.valueOf(),$.valueOf(),z.valueOf());return I===null?null:l(I)}});function b(M,_,E){if(M=N(M),_=N(_),E=N(E),!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(E))throw new TypeError("Array with 4 numbers expected as third argument");return O(M[0],M[1],M[2],_[0],_[1],_[2],E[0],E[1],E[2],E[3])}function w(M,_,E,$){if(M=N(M),_=N(_),E=N(E),$=N($),M.length===2){if(!g(M))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!g(_))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!g(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!g($))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return d(M,_,E,$)}else if(M.length===3){if(!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(E))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y($))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return S(M[0],M[1],M[2],_[0],_[1],_[2],E[0],E[1],E[2],$[0],$[1],$[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function N(M){return M.length===1?M[0]:M.length>1&&Array.isArray(M[0])&&M.every(_=>Array.isArray(_)&&_.length===1)?p(M):M}function g(M){return M.length===2&&h(M[0])&&h(M[1])}function y(M){return M.length===3&&h(M[0])&&h(M[1])&&h(M[2])}function x(M){return M.length===4&&h(M[0])&&h(M[1])&&h(M[2])&&h(M[3])}function d(M,_,E,$){var z=M,I=E,T=s(z,_),B=s(I,$),G=s(f(T[0],B[1]),f(B[0],T[1]));if(v(G)||o(t(G),a.epsilon))return null;var D=f(B[0],z[1]),H=f(B[1],z[0]),W=f(B[0],I[1]),j=f(B[1],I[0]),V=c(i(s(s(D,H),W),j),G);return r(m(T,V),z)}function A(M,_,E,$,z,I,T,B,G,D,H,W){var j=f(s(M,_),s(E,$)),V=f(s(z,I),s(T,B)),K=f(s(G,D),s(H,W));return i(i(j,V),K)}function S(M,_,E,$,z,I,T,B,G,D,H,W){var j=A(M,T,D,T,_,B,H,B,E,G,W,G),V=A(D,T,$,M,H,B,z,_,W,G,I,E),K=A(M,T,$,M,_,B,z,_,E,G,I,E),te=A(D,T,D,T,H,B,H,B,W,G,W,G),re=A($,M,$,M,z,_,z,_,I,E,I,E),ie=s(f(j,V),f(K,te)),ne=s(f(re,te),f(V,V));if(v(ne))return null;var ue=c(ie,ne),ee=c(i(j,f(ue,V)),te),ye=i(M,f(ue,s($,M))),we=i(_,f(ue,s(z,_))),me=i(E,f(ue,s(I,E))),xe=i(T,f(ee,s(D,T))),F=i(B,f(ee,s(H,B))),Y=i(G,f(ee,s(W,G)));return u(ye,xe)&&u(we,F)&&u(me,Y)?[ye,we,me]:null}function O(M,_,E,$,z,I,T,B,G,D){var H=f(M,T),W=f($,T),j=f(_,B),V=f(z,B),K=f(E,G),te=f(I,G),re=s(s(s(D,H),j),K),ie=s(s(s(i(i(W,V),te),H),j),K),ne=c(re,ie),ue=i(M,f(ne,s($,M))),ee=i(_,f(ne,s(z,_))),ye=i(E,f(ne,s(I,E)));return[ue,ee,ye]}}),Cl="sum",TC=["typed","config","add","numeric"],Ol=R(Cl,TC,e=>{var{typed:n,config:a,add:t,numeric:r}=e;return n(Cl,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":l,"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function sum");return i(f)}});function i(m){var f;return bt(m,function(c){try{f=f===void 0?c:t(f,c)}catch(s){throw Dr(s,"sum",c)}}),f===void 0&&(f=r(0,a.number)),typeof f=="string"&&(f=r(f,a.number)),f}function l(m,f){try{var c=ba(m,f,t);return c}catch(s){throw Dr(s,"sum")}}}),_a="cumsum",BC=["typed","add","unaryPlus"],Dl=R(_a,BC,e=>{var{typed:n,add:a,unaryPlus:t}=e;return n(_a,{Array:r,Matrix:function(c){return c.create(r(c.valueOf()))},"Array, number | BigNumber":l,"Matrix, number | BigNumber":function(c,s){return c.create(l(c.valueOf(),s))},"...":function(c){if(mn(c))throw new TypeError("All values expected to be scalar in function cumsum");return r(c)}});function r(f){try{return i(f)}catch(c){throw Dr(c,_a)}}function i(f){if(f.length===0)return[];for(var c=[t(f[0])],s=1;s<f.length;++s)c.push(a(c[s-1],f[s]));return c}function l(f,c){var s=Pe(f);if(c<0||c>=s.length)throw new Jr(c,s.length);try{return m(f,c)}catch(o){throw Dr(o,_a)}}function m(f,c){var s,o,u;if(c<=0){var p=f[0][0];if(Array.isArray(p)){for(u=Go(f),o=[],s=0;s<u.length;s++)o[s]=m(u[s],c-1);return o}else return i(f)}else{for(o=[],s=0;s<f.length;s++)o[s]=m(f[s],c-1);return o}}}),Tl="mean",_C=["typed","add","divide"],Bl=R(Tl,_C,e=>{var{typed:n,add:a,divide:t}=e;return n(Tl,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":r,"...":function(m){if(mn(m))throw new TypeError("Scalar values expected in function mean");return i(m)}});function r(l,m){try{var f=ba(l,m,a),c=Array.isArray(l)?Pe(l):l.size();return t(f,c[m])}catch(s){throw Dr(s,"mean")}}function i(l){var m,f=0;if(bt(l,function(c){try{m=m===void 0?c:a(m,c),f++}catch(s){throw Dr(s,"mean",c)}}),f===0)throw new Error("Cannot calculate the mean of an empty array");return t(m,f)}}),_l="median",$C=["typed","add","divide","compare","partitionSelect"],IC=R(_l,$C,e=>{var{typed:n,add:a,divide:t,compare:r,partitionSelect:i}=e;function l(c){try{c=Le(c.valueOf());var s=c.length;if(s===0)throw new Error("Cannot calculate median of an empty array");if(s%2===0){for(var o=s/2-1,u=i(c,o+1),p=c[o],v=0;v<o;++v)r(c[v],p)>0&&(p=c[v]);return f(p,u)}else{var h=i(c,(s-1)/2);return m(h)}}catch(b){throw Dr(b,"median")}}var m=n({"number | BigNumber | Complex | Unit":function(s){return s}}),f=n({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(s,o){return t(a(s,o),2)}});return n(_l,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(s,o){throw new Error("median(A, dim) is not yet supported")},"...":function(s){if(mn(s))throw new TypeError("Scalar values expected in function median");return l(s)}})}),$l="mad",qC=["typed","abs","map","median","subtract"],RC=R($l,qC,e=>{var{typed:n,abs:a,map:t,median:r,subtract:i}=e;return n($l,{"Array | Matrix":l,"...":function(f){return l(f)}});function l(m){if(m=Le(m.valueOf()),m.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var f=r(m);return r(t(m,function(c){return a(i(c,f))}))}catch(c){throw c instanceof TypeError&&c.message.indexOf("median")!==-1?new TypeError(c.message.replace("median","mad")):Dr(c,"mad")}}}),Ri="unbiased",Il="variance",FC=["typed","add","subtract","multiply","divide","apply","isNaN"],ql=R(Il,FC,e=>{var{typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m}=e;return n(Il,{"Array | Matrix":function(o){return f(o,Ri)},"Array | Matrix, string":f,"Array | Matrix, number | BigNumber":function(o,u){return c(o,u,Ri)},"Array | Matrix, number | BigNumber, string":c,"...":function(o){return f(o,Ri)}});function f(s,o){var u,p=0;if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(bt(s,function(b){try{u=u===void 0?b:a(u,b),p++}catch(w){throw Dr(w,"variance",b)}}),p===0)throw new Error("Cannot calculate variance of an empty array");var v=i(u,p);if(u=void 0,bt(s,function(b){var w=t(b,v);u=u===void 0?r(w,w):a(u,r(w,w))}),m(u))return u;switch(o){case"uncorrected":return i(u,p);case"biased":return i(u,p+1);case"unbiased":{var h=Ie(u)?u.mul(0):0;return p===1?h:i(u,p-1)}default:throw new Error('Unknown normalization "'+o+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(s,o,u){try{if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return l(s,o,p=>f(p,u))}catch(p){throw Dr(p,"variance")}}}),zC="quantileSeq",PC=["typed","add","multiply","partitionSelect","compare"],UC=R(zC,PC,e=>{var{typed:n,add:a,multiply:t,partitionSelect:r,compare:i}=e;function l(c,s,o){var u,p,v;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(rn(c)){if(o=o||!1,typeof o=="boolean"){if(p=c.valueOf(),$e(s)){if(s<0)throw new Error("N/prob must be non-negative");if(s<=1)return m(p,s,o);if(s>1){if(!Ae(s))throw new Error("N must be a positive integer");var h=s+1;u=new Array(s);for(var b=0;b<s;)u[b]=m(p,++b/h,o);return u}}if(Ie(s)){var w=s.constructor;if(s.isNegative())throw new Error("N/prob must be non-negative");if(v=new w(1),s.lte(v))return new w(m(p,s,o));if(s.gt(v)){if(!s.isInteger())throw new Error("N must be a positive integer");var N=s.toNumber();if(N>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var g=new w(N+1);u=new Array(N);for(var y=0;y<N;)u[y]=new w(m(p,new w(++y).div(g),o));return u}}if(Array.isArray(s)){u=new Array(s.length);for(var x=0;x<u.length;++x){var d=s[x];if($e(d)){if(d<0||d>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(Ie(d)){if(v=new d.constructor(1),d.isNegative()||d.gt(v))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");u[x]=m(p,d,o)}return u}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function m(c,s,o){var u=Le(c),p=u.length;if(p===0)throw new Error("Cannot calculate quantile of an empty sequence");if($e(s)){var v=s*(p-1),h=v%1;if(h===0){var b=o?u[v]:r(u,v);return f(b),b}var w=Math.floor(v),N,g;if(o)N=u[w],g=u[w+1];else{g=r(u,w+1),N=u[w];for(var y=0;y<w;++y)i(u[y],N)>0&&(N=u[y])}return f(N),f(g),a(t(N,1-h),t(g,h))}var x=s.times(p-1);if(x.isInteger()){x=x.toNumber();var d=o?u[x]:r(u,x);return f(d),d}var A=x.floor(),S=x.minus(A),O=A.toNumber(),M,_;if(o)M=u[O],_=u[O+1];else{_=r(u,O+1),M=u[O];for(var E=0;E<O;++E)i(u[E],M)>0&&(M=u[E])}f(M),f(_);var $=new S.constructor(1);return a(t(M,$.minus(S)),t(_,S))}var f=n({"number | BigNumber | Unit":function(s){return s}});return l}),Rl="std",LC=["typed","sqrt","variance"],Fl=R(Rl,LC,e=>{var{typed:n,sqrt:a,variance:t}=e;return n(Rl,{"Array | Matrix":r,"Array | Matrix, string":r,"Array | Matrix, number | BigNumber":r,"Array | Matrix, number | BigNumber, string":r,"...":function(l){return r(l)}});function r(i,l){if(i.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return a(t.apply(null,arguments))}catch(m){throw m instanceof TypeError&&m.message.indexOf(" variance")!==-1?new TypeError(m.message.replace(" variance"," std")):m}}}),zl="combinations",kC=["typed"],HC=R(zl,kC,e=>{var{typed:n}=e;return n(zl,{"number, number":ys,"BigNumber, BigNumber":function(t,r){var i=t.constructor,l,m,f=t.minus(r),c=new i(1);if(!Pl(t)||!Pl(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(t))throw new TypeError("k must be less than n in function combinations");if(l=c,r.lt(f))for(m=c;m.lte(f);m=m.plus(c))l=l.times(r.plus(m)).dividedBy(m);else for(m=c;m.lte(r);m=m.plus(c))l=l.times(f.plus(m)).dividedBy(m);return l}})});function Pl(e){return e.isInteger()&&e.gte(0)}var Ul="combinationsWithRep",GC=["typed"],VC=R(Ul,GC,e=>{var{typed:n}=e;return n(Ul,{"number, number":function(t,r){if(!Ae(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!Ae(r)||r<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(t<1)throw new TypeError("k must be less than or equal to n + k - 1");if(r<t-1){var i=wt(t,t+r-1);return i/wt(1,r)}var l=wt(r+1,t+r-1);return l/wt(1,t-1)},"BigNumber, BigNumber":function(t,r){var i=t.constructor,l,m,f=new i(1),c=t.minus(f);if(!Ll(t)||!Ll(r))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(t.lt(f))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(l=f,r.lt(c))for(m=f;m.lte(c);m=m.plus(f))l=l.times(r.plus(m)).dividedBy(m);else for(m=f;m.lte(r);m=m.plus(f))l=l.times(c.plus(m)).dividedBy(m);return l}})});function Ll(e){return e.isInteger()&&e.gte(0)}var kl="gamma",ZC=["typed","config","multiplyScalar","pow","BigNumber","Complex"],XC=R(kl,ZC,e=>{var{typed:n,config:a,multiplyScalar:t,pow:r,BigNumber:i,Complex:l}=e;return n(kl,{number:xi,Complex:function(c){if(c.im===0)return this(c.re);if(c.re<.5){var s=new l(1-c.re,-c.im),o=new l(Math.PI*c.re,Math.PI*c.im);return new l(Math.PI).div(o.sin()).div(this(s))}c=new l(c.re-1,c.im);for(var u=new l(vn[0],0),p=1;p<vn.length;++p){var v=new l(vn[p],0);u=u.add(v.div(c.add(p)))}var h=new l(c.re+Ms+.5,c.im),b=Math.sqrt(2*Math.PI),w=h.pow(c.add(.5)),N=h.neg().exp();return u.mul(b).mul(w).mul(N)},BigNumber:function(c){if(c.isInteger())return c.isNegative()||c.isZero()?new i(1/0):m(c.minus(1));if(!c.isFinite())return new i(c.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(c){return be(c,this)}});function m(f){if(f<8)return new i([1,1,2,6,24,120,720,5040][f]);var c=a.precision+(Math.log(f.toNumber())|0),s=i.clone({precision:c});if(f%2===1)return f.times(m(new i(f-1)));for(var o=f,u=new s(f),p=f.toNumber();o>2;)o-=2,p+=o,u=u.times(p);return new i(u.toPrecision(i.precision))}}),Hl="lgamma",YC=["Complex","typed"],WC=R(Hl,YC,e=>{var{Complex:n,typed:a}=e,t=7,r=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return a(Hl,{number:Na,Complex:function(c){var s=6.283185307179586,o=1.1447298858494002,u=.1;if(c.isNaN())return new n(NaN,NaN);if(c.im===0)return new n(Na(c.re),0);if(c.re>=t||Math.abs(c.im)>=r)return l(c);if(c.re<=u){var p=av(s,c.im)*Math.floor(.5*c.re+.25),v=c.mul(Math.PI).sin().log(),h=this(new n(1-c.re,-c.im));return new n(o,p).sub(v).sub(h)}else return c.im>=0?m(c):m(c.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function l(f){for(var c=f.sub(.5).mul(f.log()).sub(f).add(As),s=new n(1,0).div(f),o=s.div(f),u=i[0],p=i[1],v=2*o.re,h=o.re*o.re+o.im*o.im,b=2;b<8;b++){var w=p;p=-h*u+i[b],u=v*u+w}var N=s.mul(o.mul(u).add(p));return c.add(N)}function m(f){var c=0,s=0,o=f;for(f=f.add(1);f.re<=t;){o=o.mul(f);var u=o.im<0?1:0;u!==0&&s===0&&c++,s=u,f=f.add(1)}return l(f).sub(o.log()).sub(new n(0,c*2*Math.PI*1))}}),Gl="factorial",JC=["typed","gamma"],QC=R(Gl,JC,e=>{var{typed:n,gamma:a}=e;return n(Gl,{number:function(r){if(r<0)throw new Error("Value must be non-negative");return a(r+1)},BigNumber:function(r){if(r.isNegative())throw new Error("Value must be non-negative");return a(r.plus(1))},"Array | Matrix":function(r){return be(r,this)}})}),Vl="kldivergence",KC=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],jC=R(Vl,KC,e=>{var{typed:n,matrix:a,divide:t,sum:r,multiply:i,dotDivide:l,log:m,isNumeric:f}=e;return n(Vl,{"Array, Array":function(o,u){return c(a(o),a(u))},"Matrix, Array":function(o,u){return c(o,a(u))},"Array, Matrix":function(o,u){return c(a(o),u)},"Matrix, Matrix":function(o,u){return c(o,u)}});function c(s,o){var u=o.size().length,p=s.size().length;if(u>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(u!==p)throw new Error("Length of two vectors must be equal");var v=r(s);if(v===0)throw new Error("Sum of elements in first object must be non zero");var h=r(o);if(h===0)throw new Error("Sum of elements in second object must be non zero");var b=t(s,r(s)),w=t(o,r(o)),N=r(i(b,m(l(b,w))));return f(N)?N:Number.NaN}}),Zl="multinomial",e3=["typed","add","divide","multiply","factorial","isInteger","isPositive"],r3=R(Zl,e3,e=>{var{typed:n,add:a,divide:t,multiply:r,factorial:i,isInteger:l,isPositive:m}=e;return n(Zl,{"Array | Matrix":function(c){var s=0,o=1;return bt(c,function(u){if(!l(u)||!m(u))throw new TypeError("Positive integer value expected in function multinomial");s=a(s,u),o=r(o,i(u))}),t(i(s),o)}})}),Xl="permutations",t3=["typed","factorial"],n3=R(Xl,t3,e=>{var{typed:n,factorial:a}=e;return n(Xl,{"number | BigNumber":a,"number, number":function(r,i){if(!Ae(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(!Ae(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>r)throw new TypeError("second argument k must be less than or equal to first argument n");return wt(r-i+1,r)},"BigNumber, BigNumber":function(r,i){var l,m;if(!Yl(r)||!Yl(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(r))throw new TypeError("second argument k must be less than or equal to first argument n");var f=r.mul(0).add(1);for(l=f,m=r.minus(i).plus(1);m.lte(r);m=m.plus(1))l=l.times(m);return l}})});function Yl(e){return e.isInteger()&&e.gte(0)}var $a={exports:{}},a3=$a.exports,Wl;function i3(){return Wl||(Wl=1,function(e){(function(n,a,t){function r(f){var c=this,s=m();c.next=function(){var o=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=o-(c.c=o|0)},c.c=1,c.s0=s(" "),c.s1=s(" "),c.s2=s(" "),c.s0-=s(f),c.s0<0&&(c.s0+=1),c.s1-=s(f),c.s1<0&&(c.s1+=1),c.s2-=s(f),c.s2<0&&(c.s2+=1),s=null}function i(f,c){return c.c=f.c,c.s0=f.s0,c.s1=f.s1,c.s2=f.s2,c}function l(f,c){var s=new r(f),o=c&&c.state,u=s.next;return u.int32=function(){return s.next()*4294967296|0},u.double=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.quick=u,o&&(typeof o=="object"&&i(o,s),u.state=function(){return i(s,{})}),u}function m(){var f=4022871197,c=function(s){s=String(s);for(var o=0;o<s.length;o++){f+=s.charCodeAt(o);var u=.02519603282416938*f;f=u>>>0,u-=f,u*=f,f=u>>>0,u-=f,f+=u*4294967296}return(f>>>0)*23283064365386963e-26};return c}a&&a.exports?a.exports=l:this.alea=l})(a3,e)}($a)),$a.exports}var Ia={exports:{}},o3=Ia.exports,Jl;function s3(){return Jl||(Jl=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.x=0,f.y=0,f.z=0,f.w=0,f.next=function(){var o=f.x^f.x<<11;return f.x=f.y,f.y=f.z,f.z=f.w,f.w^=f.w>>>19^o^o>>>8},m===(m|0)?f.x=m:c+=m;for(var s=0;s<c.length+64;s++)f.x^=c.charCodeAt(s)|0,f.next()}function i(m,f){return f.x=m.x,f.y=m.y,f.z=m.z,f.w=m.w,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xor128=l})(o3,e)}(Ia)),Ia.exports}var qa={exports:{}},u3=qa.exports,Ql;function c3(){return Ql||(Ql=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.next=function(){var o=f.x^f.x>>>2;return f.x=f.y,f.y=f.z,f.z=f.w,f.w=f.v,(f.d=f.d+362437|0)+(f.v=f.v^f.v<<4^(o^o<<1))|0},f.x=0,f.y=0,f.z=0,f.w=0,f.v=0,m===(m|0)?f.x=m:c+=m;for(var s=0;s<c.length+64;s++)f.x^=c.charCodeAt(s)|0,s==c.length&&(f.d=f.x<<10^f.x>>>4),f.next()}function i(m,f){return f.x=m.x,f.y=m.y,f.z=m.z,f.w=m.w,f.v=m.v,f.d=m.d,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xorwow=l})(u3,e)}(qa)),qa.exports}var Ra={exports:{}},f3=Ra.exports,Kl;function l3(){return Kl||(Kl=1,function(e){(function(n,a,t){function r(m){var f=this;f.next=function(){var s=f.x,o=f.i,u,p;return u=s[o],u^=u>>>7,p=u^u<<24,u=s[o+1&7],p^=u^u>>>10,u=s[o+3&7],p^=u^u>>>3,u=s[o+4&7],p^=u^u<<7,u=s[o+7&7],u=u^u<<13,p^=u^u<<9,s[o]=p,f.i=o+1&7,p};function c(s,o){var u,p=[];if(o===(o|0))p[0]=o;else for(o=""+o,u=0;u<o.length;++u)p[u&7]=p[u&7]<<15^o.charCodeAt(u)+p[u+1&7]<<13;for(;p.length<8;)p.push(0);for(u=0;u<8&&p[u]===0;++u);for(u==8?p[7]=-1:p[u],s.x=p,s.i=0,u=256;u>0;--u)s.next()}c(f,m)}function i(m,f){return f.x=m.x.slice(),f.i=m.i,f}function l(m,f){m==null&&(m=+new Date);var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(s.x&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xorshift7=l})(f3,e)}(Ra)),Ra.exports}var Fa={exports:{}},m3=Fa.exports,jl;function p3(){return jl||(jl=1,function(e){(function(n,a,t){function r(m){var f=this;f.next=function(){var s=f.w,o=f.X,u=f.i,p,v;return f.w=s=s+1640531527|0,v=o[u+34&127],p=o[u=u+1&127],v^=v<<13,p^=p<<17,v^=v>>>15,p^=p>>>12,v=o[u]=v^p,f.i=u,v+(s^s>>>16)|0};function c(s,o){var u,p,v,h,b,w=[],N=128;for(o===(o|0)?(p=o,o=null):(o=o+"\0",p=0,N=Math.max(N,o.length)),v=0,h=-32;h<N;++h)o&&(p^=o.charCodeAt((h+32)%o.length)),h===0&&(b=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,h>=0&&(b=b+1640531527|0,u=w[h&127]^=p+b,v=u==0?v+1:0);for(v>=128&&(w[(o&&o.length||0)&127]=-1),v=127,h=4*128;h>0;--h)p=w[v+34&127],u=w[v=v+1&127],p^=p<<13,u^=u<<17,p^=p>>>15,u^=u>>>12,w[v]=p^u;s.w=b,s.X=w,s.i=v}c(f,m)}function i(m,f){return f.i=m.i,f.w=m.w,f.X=m.X.slice(),f}function l(m,f){m==null&&(m=+new Date);var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(s.X&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xor4096=l})(m3,e)}(Fa)),Fa.exports}var za={exports:{}},v3=za.exports,em;function h3(){return em||(em=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.next=function(){var o=f.b,u=f.c,p=f.d,v=f.a;return o=o<<25^o>>>7^u,u=u-p|0,p=p<<24^p>>>8^v,v=v-o|0,f.b=o=o<<20^o>>>12^u,f.c=u=u-p|0,f.d=p<<16^u>>>16^v,f.a=v-o|0},f.a=0,f.b=0,f.c=-1640531527,f.d=1367130551,m===Math.floor(m)?(f.a=m/4294967296|0,f.b=m|0):c+=m;for(var s=0;s<c.length+20;s++)f.b^=c.charCodeAt(s)|0,f.next()}function i(m,f){return f.a=m.a,f.b=m.b,f.c=m.c,f.d=m.d,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.tychei=l})(v3,e)}(za)),za.exports}var Pa={exports:{}};const d3=Pp(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var g3=Pa.exports,rm;function y3(){return rm||(rm=1,function(e){(function(n,a,t){var r=256,i=6,l=52,m="random",f=t.pow(r,i),c=t.pow(2,l),s=c*2,o=r-1,u;function p(y,x,d){var A=[];x=x==!0?{entropy:!0}:x||{};var S=w(b(x.entropy?[y,g(a)]:y==null?N():y,3),A),O=new v(A),M=function(){for(var _=O.g(i),E=f,$=0;_<c;)_=(_+$)*r,E*=r,$=O.g(1);for(;_>=s;)_/=2,E/=2,$>>>=1;return(_+$)/E};return M.int32=function(){return O.g(4)|0},M.quick=function(){return O.g(4)/4294967296},M.double=M,w(g(O.S),a),(x.pass||d||function(_,E,$,z){return z&&(z.S&&h(z,O),_.state=function(){return h(O,{})}),$?(t[m]=_,E):_})(M,S,"global"in x?x.global:this==t,x.state)}function v(y){var x,d=y.length,A=this,S=0,O=A.i=A.j=0,M=A.S=[];for(d||(y=[d++]);S<r;)M[S]=S++;for(S=0;S<r;S++)M[S]=M[O=o&O+y[S%d]+(x=M[S])],M[O]=x;(A.g=function(_){for(var E,$=0,z=A.i,I=A.j,T=A.S;_--;)E=T[z=o&z+1],$=$*r+T[o&(T[z]=T[I=o&I+E])+(T[I]=E)];return A.i=z,A.j=I,$})(r)}function h(y,x){return x.i=y.i,x.j=y.j,x.S=y.S.slice(),x}function b(y,x){var d=[],A=typeof y,S;if(x&&A=="object")for(S in y)try{d.push(b(y[S],x-1))}catch(O){}return d.length?d:A=="string"?y:y+"\0"}function w(y,x){for(var d=y+"",A,S=0;S<d.length;)x[o&S]=o&(A^=x[o&S]*19)+d.charCodeAt(S++);return g(x)}function N(){try{var y;return u&&(y=u.randomBytes)?y=y(r):(y=new Uint8Array(r),(n.crypto||n.msCrypto).getRandomValues(y)),g(y)}catch(A){var x=n.navigator,d=x&&x.plugins;return[+new Date,n,d,n.screen,g(a)]}}function g(y){return String.fromCharCode.apply(0,y)}if(w(t.random(),a),e.exports){e.exports=p;try{u=d3}catch(y){}}else t["seed"+m]=p})(typeof self!="undefined"?self:g3,[],Math)}(Pa)),Pa.exports}var Fi,tm;function x3(){if(tm)return Fi;tm=1;var e=i3(),n=s3(),a=c3(),t=l3(),r=p3(),i=h3(),l=y3();return l.alea=e,l.xor128=n,l.xorwow=a,l.xorshift7=t,l.xor4096=r,l.tychei=i,Fi=l,Fi}var b3=x3();const nm=Bn(b3);var w3=nm(Date.now());function bn(e){var n;function a(r){n=r===null?w3:nm(String(r))}a(e);function t(){return n()}return t}var am="pickRandom",N3=["typed","config","?on"],M3=R(am,N3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(l,m){l.randomSeed!==m.randomSeed&&(r=bn(l.randomSeed))}),n(am,{"Array | Matrix":function(m){return i(m,{})},"Array | Matrix, Object":function(m,f){return i(m,f)},"Array | Matrix, number":function(m,f){return i(m,{number:f})},"Array | Matrix, Array | Matrix":function(m,f){return i(m,{weights:f})},"Array | Matrix, Array | Matrix, number":function(m,f,c){return i(m,{number:c,weights:f})},"Array | Matrix, number, Array | Matrix":function(m,f,c){return i(m,{number:f,weights:c})}});function i(l,m){var{number:f,weights:c,elementWise:s=!0}=m,o=typeof f=="undefined";o&&(f=1);var u=Oe(l)?l.create:Oe(c)?c.create:null;l=l.valueOf(),c&&(c=c.valueOf()),s===!0&&(l=Le(l),c=Le(c));var p=0;if(typeof c!="undefined"){if(c.length!==l.length)throw new Error("Weights must have the same length as possibles");for(var v=0,h=c.length;v<h;v++){if(!$e(c[v])||c[v]<0)throw new Error("Weights must be an array of positive numbers");p+=c[v]}}for(var b=l.length,w=[],N;w.length<f;){if(typeof c=="undefined")N=l[Math.floor(r()*b)];else for(var g=r()*p,y=0,x=l.length;y<x;y++)if(g-=c[y],g<0){N=l[y];break}w.push(N)}return o?w[0]:u?u(w):w}});function zi(e,n){var a=[];if(e=e.slice(0),e.length>1)for(var t=0,r=e.shift();t<r;t++)a.push(zi(e,n));else for(var i=0,l=e.shift();i<l;i++)a.push(n());return a}var im="random",A3=["typed","config","?on"],S3=R(im,A3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(m,f){m.randomSeed!==f.randomSeed&&(r=bn(m.randomSeed))}),n(im,{"":()=>l(0,1),number:m=>l(0,m),"number, number":(m,f)=>l(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,c)=>i(m,f,c)});function i(m,f,c){var s=zi(m.valueOf(),()=>l(f,c));return Oe(m)?m.create(s):s}function l(m,f){return m+r()*(f-m)}}),om="randomInt",E3=["typed","config","?on"],C3=R(om,E3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(m,f){m.randomSeed!==f.randomSeed&&(r=bn(m.randomSeed))}),n(om,{"":()=>l(0,1),number:m=>l(0,m),"number, number":(m,f)=>l(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,c)=>i(m,f,c)});function i(m,f,c){var s=zi(m.valueOf(),()=>l(f,c));return Oe(m)?m.create(s):s}function l(m,f){return Math.floor(m+r()*(f-m))}}),sm="stirlingS2",O3=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],D3=R(sm,O3,e=>{var{typed:n,addScalar:a,subtract:t,multiplyScalar:r,divideScalar:i,pow:l,factorial:m,combinations:f,isNegative:c,isInteger:s,number:o,bignumber:u,larger:p}=e,v=[],h=[];return n(sm,{"number | BigNumber, number | BigNumber":function(w,N){if(!s(w)||c(w)||!s(N)||c(N))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(p(N,w))throw new TypeError("k must be less than or equal to n in function stirlingS2");var g=!($e(w)&&$e(N)),y=g?h:v,x=g?u:o,d=o(w),A=o(N);if(y[d]&&y[d].length>A)return y[d][A];for(var S=0;S<=d;++S)if(y[S]||(y[S]=[x(S===0?1:0)]),S!==0)for(var O=y[S],M=y[S-1],_=O.length;_<=S&&_<=A;++_)_===S?O[_]=1:O[_]=a(r(x(_),M[_]),M[_-1]);return y[d][A]}})}),um="bellNumbers",T3=["typed","addScalar","isNegative","isInteger","stirlingS2"],B3=R(um,T3,e=>{var{typed:n,addScalar:a,isNegative:t,isInteger:r,stirlingS2:i}=e;return n(um,{"number | BigNumber":function(m){if(!r(m)||t(m))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var f=0,c=0;c<=m;c++)f=a(f,i(m,c));return f}})}),cm="catalan",_3=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],$3=R(cm,_3,e=>{var{typed:n,addScalar:a,divideScalar:t,multiplyScalar:r,combinations:i,isNegative:l,isInteger:m}=e;return n(cm,{"number | BigNumber":function(c){if(!m(c)||l(c))throw new TypeError("Non-negative integer value expected in function catalan");return t(i(r(c,2),c),a(c,1))}})}),fm="composition",I3=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],q3=R(fm,I3,e=>{var{typed:n,addScalar:a,combinations:t,isPositive:r,isNegative:i,isInteger:l,larger:m}=e;return n(fm,{"number | BigNumber, number | BigNumber":function(c,s){if(!l(c)||!r(c)||!l(s)||!r(s))throw new TypeError("Positive integer value expected in function composition");if(m(s,c))throw new TypeError("k must be less than or equal to n in function composition");return t(a(c,-1),a(s,-1))}})}),lm="leafCount",R3=["parse","typed"],F3=R(lm,R3,e=>{var{parse:n,typed:a}=e;function t(r){var i=0;return r.forEach(l=>{i+=t(l)}),i||1}return a(lm,{string:function(i){return this(n(i))},Node:function(i){return t(i)}})});function mm(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),a.push.apply(a,t)}return a}function Pi(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?mm(Object(a),!0).forEach(function(t){lf(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):mm(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var z3="simplifyUtil",P3=["FunctionNode","OperatorNode","SymbolNode"],Ui=R(z3,P3,e=>{var{FunctionNode:n,OperatorNode:a,SymbolNode:t}=e,r=!0,i=!1,l="defaultF",m={add:{trivial:r,total:r,commutative:r,associative:r},unaryPlus:{trivial:r,total:r,commutative:r,associative:r},subtract:{trivial:i,total:r,commutative:i,associative:i},multiply:{trivial:r,total:r,commutative:r,associative:r},divide:{trivial:i,total:r,commutative:i,associative:i},paren:{trivial:r,total:r,commutative:r,associative:i},defaultF:{trivial:i,total:r,commutative:i,associative:i}},f={divide:{total:i},log:{total:i}},c={subtract:{total:i},abs:{trivial:r},log:{total:r}};function s(g,y){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:m,d=l;if(typeof g=="string"?d=g:_r(g)?d=g.fn.toString():kt(g)?d=g.name:Dn(g)&&(d="paren"),Me(x,d)){var A=x[d];if(Me(A,y))return A[y];if(Me(m,d))return m[d][y]}if(Me(x,l)){var S=x[l];return Me(S,y)?S[y]:m[l][y]}if(Me(m,d)){var O=m[d];if(Me(O,y))return O[y]}return m[l][y]}function o(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(g,"commutative",y)}function u(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(g,"associative",y)}function p(g,y){var x=Pi({},g);for(var d in y)Me(g,d)?x[d]=Pi(Pi({},y[d]),g[d]):x[d]=y[d];return x}function v(g,y){if(!g.args||g.args.length===0)return g;g.args=h(g,y);for(var x=0;x<g.args.length;x++)v(g.args[x],y)}function h(g,y){var x,d=[],A=function S(O){for(var M=0;M<O.args.length;M++){var _=O.args[M];_r(_)&&x===_.op?S(_):d.push(_)}};return u(g,y)?(x=g.op,A(g),d):g.args}function b(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)b(g.args[A],y);if(d>2&&u(g,y)){for(var S=g.args.pop();g.args.length>0;)S=x([g.args.pop(),S]);g.args=S.args}}}function w(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)w(g.args[A],y);if(d>2&&u(g,y)){for(var S=g.args.shift();g.args.length>0;)S=x([S,g.args.shift()]);g.args=S.args}}}function N(g){return _r(g)?function(y){try{return new a(g.op,g.fn,y,g.implicit)}catch(x){return console.error(x),[]}}:function(y){return new n(new t(g.name),y)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:o,isAssociative:u,mergeContext:p,flatten:v,allChildren:h,unflattenr:b,unflattenl:w,defaultContext:m,realContext:f,positiveContext:c}}),U3="simplifyConstant",L3=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],pm=R(U3,L3,e=>{var{typed:n,config:a,mathWithTransform:t,matrix:r,fraction:i,bignumber:l,AccessorNode:m,ArrayNode:f,ConstantNode:c,FunctionNode:s,IndexNode:o,ObjectNode:u,OperatorNode:p,SymbolNode:v}=e,{isCommutative:h,isAssociative:b,allChildren:w,createMakeNodeFunction:N}=Ui({FunctionNode:s,OperatorNode:p,SymbolNode:v});function g(I,T){return A(z(I,T))}function y(I){return at(I)?I.valueOf():I instanceof Array?I.map(y):Oe(I)?r(y(I.valueOf())):I}function x(I,T,B){try{return t[I].apply(null,T)}catch(G){return T=T.map(y),O(t[I].apply(null,T),B)}}var d=n({Fraction:_,number:function(T){return T<0?M(new c(-T)):new c(T)},BigNumber:function(T){return T<0?M(new c(-T)):new c(T)},Complex:function(T){throw new Error("Cannot convert Complex number to Node")},string:function(T){return new c(T)},Matrix:function(T){return new f(T.valueOf().map(B=>d(B)))}});function A(I){return Ve(I)?I:d(I)}function S(I,T){var B=T&&T.exactFractions!==!1;if(B&&isFinite(I)&&i){var G=i(I),D=T&&typeof T.fractionsLimit=="number"?T.fractionsLimit:1/0;if(G.valueOf()===I&&G.n<D&&G.d<D)return G}return I}var O=n({"string, Object":function(T,B){if(a.number==="BigNumber")return l===void 0&&Si(),l(T);if(a.number==="Fraction")return i===void 0&&ac(),i(T);var G=parseFloat(T);return S(G,B)},"Fraction, Object":function(T,B){return T},"BigNumber, Object":function(T,B){return T},"number, Object":function(T,B){return S(T,B)},"Complex, Object":function(T,B){return T.im!==0?T:S(T.re,B)},"Matrix, Object":function(T,B){return r(S(T.valueOf()))},"Array, Object":function(T,B){return T.map(S)}});function M(I){return new p("-","unaryMinus",[I])}function _(I){var T,B=I.s*I.n;return B<0?T=new p("-","unaryMinus",[new c(-B)]):T=new c(B),I.d===1?T:new p("/","divide",[T,new c(I.d)])}function E(I,T,B){if(!tn(T))return new m(A(I),A(T));if(kr(I)||Oe(I)){for(var G=Array.from(T.dimensions);G.length>0;)if(Ye(G[0])&&typeof G[0].value!="string"){var D=O(G.shift().value,B);kr(I)?I=I.items[D-1]:(I=I.valueOf()[D-1],I instanceof Array&&(I=r(I)))}else if(G.length>1&&Ye(G[1])&&typeof G[1].value!="string"){var H=O(G[1].value,B),W=[],j=kr(I)?I.items:I.valueOf();for(var V of j)if(kr(V))W.push(V.items[H-1]);else if(Oe(I))W.push(V[H-1]);else break;if(W.length===j.length)kr(I)?I=new f(W):I=r(W),G.splice(1,1);else break}else break;return G.length===T.dimensions.length?new m(A(I),T):G.length>0?(T=new o(G),new m(A(I),T)):I}if(ea(I)&&T.dimensions.length===1&&Ye(T.dimensions[0])){var K=T.dimensions[0].value;return K in I.properties?I.properties[K]:new c}return new m(A(I),T)}function $(I,T,B,G){return T.reduce(function(D,H){if(!Ve(D)&&!Ve(H)){try{return x(I,[D,H],G)}catch(W){}D=d(D),H=d(H)}else Ve(D)?Ve(H)||(H=d(H)):D=d(D);return B([D,H])})}function z(I,T){switch(I.type){case"SymbolNode":return I;case"ConstantNode":switch(typeof I.value){case"number":return O(I.value,T);case"string":return I.value;default:if(!isNaN(I.value))return O(I.value,T)}return I;case"FunctionNode":if(t[I.name]&&t[I.name].rawArgs)return I;{var B=["add","multiply"];if(B.indexOf(I.name)===-1){var G=I.args.map(ye=>z(ye,T));if(!G.some(Ve))try{return x(I.name,G,T)}catch(ye){}if(I.name==="size"&&G.length===1&&kr(G[0])){for(var D=[],H=G[0];kr(H);)D.push(H.items.length),H=H.items[0];return r(D)}return new s(I.name,G.map(A))}}case"OperatorNode":{var W=I.fn.toString(),j,V,K=N(I);if(_r(I)&&I.isUnary())j=[z(I.args[0],T)],Ve(j[0])?V=K(j):V=x(W,j,T);else if(b(I,T.context))if(j=w(I,T.context),j=j.map(ye=>z(ye,T)),h(W,T.context)){for(var te=[],re=[],ie=0;ie<j.length;ie++)Ve(j[ie])?re.push(j[ie]):te.push(j[ie]);te.length>1?(V=$(W,te,K,T),re.unshift(V),V=$(W,re,K,T)):V=$(W,j,K,T)}else V=$(W,j,K,T);else j=I.args.map(ye=>z(ye,T)),V=$(W,j,K,T);return V}case"ParenthesisNode":return z(I.content,T);case"AccessorNode":return E(z(I.object,T),z(I.index,T),T);case"ArrayNode":{var ne=I.items.map(ye=>z(ye,T));return ne.some(Ve)?new f(ne.map(A)):r(ne)}case"IndexNode":return new o(I.dimensions.map(ye=>g(ye,T)));case"ObjectNode":{var ue={};for(var ee in I.properties)ue[ee]=g(I.properties[ee],T);return new u(ue)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(I.type))}}return g}),k3="simplify",H3=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],G3=R(k3,H3,e=>{var{config:n,typed:a,parse:t,add:r,subtract:i,multiply:l,divide:m,pow:f,isZero:c,equal:s,resolve:o,simplifyCore:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,ParenthesisNode:S,SymbolNode:O}=e,M=pm({typed:a,config:n,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:O}),{hasProperty:_,isCommutative:E,isAssociative:$,mergeContext:z,flatten:I,unflattenr:T,unflattenl:B,createMakeNodeFunction:G,defaultContext:D,realContext:H,positiveContext:W}=Ui({FunctionNode:y,OperatorNode:A,SymbolNode:O}),j=a("simplify",{string:function(U){return this(t(U),this.rules,gt(),{})},"string, Map | Object":function(U,J){return this(t(U),this.rules,J,{})},"string, Map | Object, Object":function(U,J,q){return this(t(U),this.rules,J,q)},"string, Array":function(U,J){return this(t(U),J,gt(),{})},"string, Array, Map | Object":function(U,J,q){return this(t(U),J,q,{})},"string, Array, Map | Object, Object":function(U,J,q,P){return this(t(U),J,q,P)},"Node, Map | Object":function(U,J){return this(U,this.rules,J,{})},"Node, Map | Object, Object":function(U,J,q){return this(U,this.rules,J,q)},Node:function(U){return this(U,this.rules,gt(),{})},"Node, Array":function(U,J){return this(U,J,gt(),{})},"Node, Array, Map | Object":function(U,J,q){return this(U,J,q,{})},"Node, Array, Object, Object":function(U,J,q,P){return this(U,J,si(q),P)},"Node, Array, Map, Object":function(U,J,q,P){var Q=P.consoleDebug;J=re(J,P.context);var L=o(U,q);L=V(L);for(var se={},fe=L.toString({parenthesis:"all"});!se[fe];){se[fe]=!0,ie=0;var ge=fe;Q&&console.log("Working on: ",fe);for(var pe=0;pe<J.length;pe++){var ve="";if(typeof J[pe]=="function"?(L=J[pe](L,P),Q&&(ve=J[pe].name)):(I(L,P.context),L=ee(L,J[pe],P.context),Q&&(ve="".concat(J[pe].l.toString()," -> ").concat(J[pe].r.toString()))),Q){var Ne=L.toString({parenthesis:"all"});Ne!==ge&&(console.log("Applying",ve,"produced",Ne),ge=Ne)}B(L,P.context)}fe=L.toString({parenthesis:"all"})}return L}});j.defaultContext=D,j.realContext=H,j.positiveContext=W;function V(k){return k.transform(function(U,J,q){return Dn(U)?V(U.content):U})}var K={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};j.rules=[u,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},M,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},M,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];function te(k,U){var J={};if(k.s){var q=k.s.split("->");if(q.length===2)J.l=q[0],J.r=q[1];else throw SyntaxError("Could not parse rule: "+k.s)}else J.l=k.l,J.r=k.r;J.l=V(t(J.l)),J.r=V(t(J.r));for(var P of["imposeContext","repeat","assuming"])P in k&&(J[P]=k[P]);if(k.evaluate&&(J.evaluate=t(k.evaluate)),$(J.l,U)){var Q=G(J.l),L=ne();J.expanded={},J.expanded.l=Q([J.l.clone(),L]),I(J.expanded.l,U),T(J.expanded.l,U),J.expanded.r=Q([J.r,L])}return J}function re(k,U){for(var J=[],q=0;q<k.length;q++){var P=k[q],Q=void 0,L=typeof P;switch(L){case"string":P={s:P};case"object":Q=te(P,U);break;case"function":Q=P;break;default:throw TypeError("Unsupported type of rule: "+L)}J.push(Q)}return J}var ie=0;function ne(){return new O("_p"+ie++)}function ue(k,U,J){var q=k;if(k)for(var P=0;P<k.length;++P){var Q=ee(k[P],U,J);Q!==k[P]&&(q===k&&(q=k.slice()),q[P]=Q)}return q}function ee(k,U,J){if(U.assuming){for(var q in U.assuming)for(var P in U.assuming[q])if(_(q,P,J)!==U.assuming[q][P])return k}var Q=z(U.imposeContext,J),L=k;if(L instanceof A||L instanceof y){var se=ue(L.args,U,J);se!==L.args&&(L=L.clone(),L.args=se)}else if(L instanceof S){if(L.content){var fe=ee(L.content,U,J);fe!==L.content&&(L=new S(fe))}}else if(L instanceof N){var ge=ue(L.items,U,J);ge!==L.items&&(L=new N(ge))}else if(L instanceof w){var pe=L.object;L.object&&(pe=ee(L.object,U,J));var ve=L.index;L.index&&(ve=ee(L.index,U,J)),(pe!==L.object||ve!==L.index)&&(L=new w(pe,ve))}else if(L instanceof x){var Ne=ue(L.dimensions,U,J);Ne!==L.dimensions&&(L=new x(Ne))}else if(L instanceof d){var Qe=!1,fr={};for(var nr in L.properties)fr[nr]=ee(L.properties[nr],U,J),fr[nr]!==L.properties[nr]&&(Qe=!0);Qe&&(L=new d(fr))}var Wr=U.r,Lr=F(U.l,L,Q)[0];if(!Lr&&U.expanded&&(Wr=U.expanded.r,Lr=F(U.expanded.l,L,Q)[0]),Lr){var Ot=L.implicit;L=Wr.clone(),Ot&&"implicit"in Wr&&(L.implicit=!0),L=L.transform(function(Ze){return Ze.isSymbolNode&&Me(Lr.placeholders,Ze.name)?Lr.placeholders[Ze.name].clone():Ze})}return U.repeat&&L!==k&&(L=ee(L,U,J)),L}function ye(k,U){var J=[],q,P,Q=G(k);if(E(k,U))for(var L=0;L<k.args.length;L++)P=k.args.slice(0),P.splice(L,1),q=P.length===1?P[0]:Q(P),J.push(Q([k.args[L],q]));else for(var se=1;se<k.args.length;se++){var fe=k.args[0];se>1&&(fe=Q(k.args.slice(0,se))),P=k.args.slice(se),q=P.length===1?P[0]:Q(P),J.push(Q([fe,q]))}return J}function we(k,U){var J={placeholders:{}};if(!k.placeholders&&!U.placeholders)return J;if(k.placeholders){if(!U.placeholders)return k}else return U;for(var q in k.placeholders)if(Me(k.placeholders,q)&&(J.placeholders[q]=k.placeholders[q],Me(U.placeholders,q)&&!Y(k.placeholders[q],U.placeholders[q])))return null;for(var P in U.placeholders)Me(U.placeholders,P)&&(J.placeholders[P]=U.placeholders[P]);return J}function me(k,U){var J=[];if(k.length===0||U.length===0)return J;for(var q,P=0;P<k.length;P++)for(var Q=0;Q<U.length;Q++)q=we(k[P],U[Q]),q&&J.push(q);return J}function xe(k){if(k.length===0)return k;for(var U=k.reduce(me),J=[],q={},P=0;P<U.length;P++){var Q=JSON.stringify(U[P]);q[Q]||(q[Q]=!0,J.push(U[P]))}return J}function F(k,U,J,q){var P=[{placeholders:{}}];if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return[]}else if(k instanceof y&&k.name!==U.name)return[];if(U.args.length===1&&k.args.length===1||!$(U,J)&&U.args.length===k.args.length||q){for(var Q=[],L=0;L<k.args.length;L++){var se=F(k.args[L],U.args[L],J);if(se.length===0)break;Q.push(se)}if(Q.length!==k.args.length){if(!E(U,J)||k.args.length===1)return[];if(k.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var fe=F(k.args[0],U.args[1],J);if(fe.length===0)return[];var ge=F(k.args[1],U.args[0],J);if(ge.length===0)return[];Q=[fe,ge]}P=xe(Q)}else if(U.args.length>=2&&k.args.length===2){for(var pe=ye(U,J),ve=[],Ne=0;Ne<pe.length;Ne++){var Qe=F(k,pe[Ne],J,!0);ve=ve.concat(Qe)}return ve}else{if(k.args.length>2)throw Error("Unexpected non-binary associative function: "+k.toString());return[]}}else if(k instanceof O){if(k.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(K[k.name]){if(k.name!==U.name)return[]}else if(k.name[0]==="n"||k.name.substring(0,2)==="_p")P[0].placeholders[k.name]=U;else if(k.name[0]==="v")if(!Ye(U))P[0].placeholders[k.name]=U;else return[];else if(k.name[0]==="c")if(U instanceof g)P[0].placeholders[k.name]=U;else return[];else throw new Error("Invalid symbol in rule: "+k.name)}else if(k instanceof g){if(!s(k.value,U.value))return[]}else return[];return P}function Y(k,U){if(k instanceof g&&U instanceof g){if(!s(k.value,U.value))return!1}else if(k instanceof O&&U instanceof O){if(k.name!==U.name)return!1}else if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return!1}else if(k instanceof y&&k.name!==U.name)return!1;if(k.args.length!==U.args.length)return!1;for(var J=0;J<k.args.length;J++)if(!Y(k.args[J],U.args[J]))return!1}else return!1;return!0}return j}),V3="simplifyCore",Z3=["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],X3=R(V3,Z3,e=>{var{equal:n,isZero:a,add:t,subtract:r,multiply:i,divide:l,pow:m,AccessorNode:f,ArrayNode:c,ConstantNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,SymbolNode:b}=e,w=new s(0),N=new s(1),{hasProperty:g,isCommutative:y}=Ui({FunctionNode:o,OperatorNode:v,SymbolNode:b});function x(d,A){var S=A?A.context:void 0;if(g(d,"trivial",S)){if(kt(d)&&d.args.length===1)return x(d.args[0],A);var O=!1,M=0;if(d.forEach(D=>{++M,M===1&&(O=x(D,A))}),M===1)return O}if(_r(d)&&d.isUnary()){var _=x(d.args[0],A);if(d.op==="-"){if(_r(_)){if(_.isUnary()&&_.op==="-")return _.args[0];if(_.isBinary()&&_.fn==="subtract")return new v("-","subtract",[_.args[1],_.args[0]])}return new v(d.op,d.fn,[_])}}else if(_r(d)&&d.isBinary()){var E=x(d.args[0],A),$=x(d.args[1],A);if(d.op==="+"){if(Ye(E)){if(a(E.value))return $;if(Ye($))return new s(t(E.value,$.value))}return Ye($)&&a($.value)?E:_r($)&&$.isUnary()&&$.op==="-"?new v("-","subtract",[E,$.args[0]]):new v(d.op,d.fn,$?[E,$]:[E])}else if(d.op==="-"){if(Ye(E)&&$){if(Ye($))return new s(r(E.value,$.value));if(a(E.value))return new v("-","unaryMinus",[$])}if(d.fn==="subtract")return Ye($)&&a($.value)?E:_r($)&&$.isUnary()&&$.op==="-"?x(new v("+","add",[E,$.args[0]]),A):new v(d.op,d.fn,[E,$])}else if(d.op==="*"){if(Ye(E)){if(a(E.value))return w;if(n(E.value,1))return $;if(Ye($))return new s(i(E.value,$.value))}if(Ye($)){if(a($.value))return w;if(n($.value,1))return E;if(_r(E)&&E.isBinary()&&E.op===d.op&&y(d,S)){var z=E.args[0];if(Ye(z)){var I=new s(i(z.value,$.value));return new v(d.op,d.fn,[I,E.args[1]],d.implicit)}}return y(d,S)?new v(d.op,d.fn,[$,E],d.implicit):new v(d.op,d.fn,[E,$],d.implicit)}return new v(d.op,d.fn,[E,$],d.implicit)}else if(d.op==="/"){if(Ye(E)){if(a(E.value))return w;if(Ye($)&&(n($.value,1)||n($.value,2)||n($.value,4)))return new s(l(E.value,$.value))}return new v(d.op,d.fn,[E,$])}else if(d.op==="^"&&Ye($)){if(a($.value))return N;if(n($.value,1))return E;if(Ye(E))return new s(m(E.value,$.value));if(_r(E)&&E.isBinary()&&E.op==="^"){var T=E.args[1];if(Ye(T))return new v(d.op,d.fn,[E.args[0],new s(i(T.value,$.value))])}}return new v(d.op,d.fn,[E,$])}else{if(kt(d))return new o(x(d.fn),d.args.map(D=>x(D,A)));if(kr(d))return new c(d.items.map(D=>x(D,A)));if(Lt(d))return new f(x(d.object,A),x(d.index,A));if(tn(d))return new u(d.dimensions.map(D=>x(D,A)));if(ea(d)){var B={};for(var G in d.properties)B[G]=x(d.properties[G],A);return new p(B)}}return d}return x}),Y3="resolve",W3=["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],J3=R(Y3,W3,e=>{var{parse:n,ConstantNode:a,FunctionNode:t,OperatorNode:r,ParenthesisNode:i}=e;function l(m,f){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!f)return m;if(ca(f)||(f=si(f)),xr(m)){if(c.has(m.name)){var s=Array.from(c).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(s,"}"))}var o=f.get(m.name);if(Ve(o)){var u=new Set(c);return u.add(m.name),l(o,f,u)}else return typeof o=="number"?n(String(o)):o!==void 0?new a(o):m}else if(_r(m)){var p=m.args.map(function(h){return l(h,f,c)});return new r(m.op,m.fn,p,m.implicit)}else{if(Dn(m))return new i(l(m.content,f,c));if(kt(m)){var v=m.args.map(function(h){return l(h,f,c)});return new t(m.name,v)}}return m.map(h=>l(h,f,c))}return l}),vm="symbolicEqual",Q3=["parse","simplify","typed","OperatorNode"],K3=R(vm,Q3,e=>{var{parse:n,simplify:a,typed:t,OperatorNode:r}=e;return t(vm,{"string, string":function(l,m){return this(n(l),n(m),{})},"string, string, Object":function(l,m,f){return this(n(l),n(m),f)},"Node, string":function(l,m){return this(l,n(m),{})},"Node, string, Object":function(l,m,f){return this(l,n(m),f)},"string, Node":function(l,m){return this(n(l),m,{})},"string, Node, Object":function(l,m,f){return this(n(l),m,f)},"Node, Node":function(l,m){return this(l,m,{})},"Node, Node, Object":function(l,m,f){var c=new r("-","subtract",[l,m]),s=a(c,{},f);return Ye(s)&&!s.value}})}),j3="derivative",eO=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],rO=R(j3,eO,e=>{var{typed:n,config:a,parse:t,simplify:r,equal:i,isZero:l,numeric:m,ConstantNode:f,FunctionNode:c,OperatorNode:s,ParenthesisNode:o,SymbolNode:u}=e,p=n("derivative",{"Node, SymbolNode, Object":function(y,x,d){var A={};h(A,y,x.name);var S=b(y,A);return d.simplify?r(S):S},"Node, SymbolNode":function(y,x){return this(y,x,{simplify:!0})},"string, SymbolNode":function(y,x){return this(t(y),x)},"string, SymbolNode, Object":function(y,x,d){return this(t(y),x,d)},"string, string":function(y,x){return this(t(y),t(x))},"string, string, Object":function(y,x,d){return this(t(y),t(x),d)},"Node, string":function(y,x){return this(y,t(x))},"Node, string, Object":function(y,x,d){return this(y,t(x),d)}});p._simplify=!0,p.toTex=function(g){return v.apply(null,g.args)};var v=n("_derivTex",{"Node, SymbolNode":function(y,x){return Ye(y)&&Ke(y.value)==="string"?v(t(y.value).toString(),x.toString(),1):v(y.toTex(),x.toString(),1)},"Node, ConstantNode":function(y,x){if(Ke(x.value)==="string")return v(y,t(x.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(y,x,d){return v(y.toString(),x.name,d.value)},"string, string, number":function(y,x,d){var A;return d===1?A="{d\\over d"+x+"}":A="{d^{"+d+"}\\over d"+x+"^{"+d+"}}",A+"\\left[".concat(y,"\\right]")}}),h=n("constTag",{"Object, ConstantNode, string":function(y,x){return y[x]=!0,!0},"Object, SymbolNode, string":function(y,x,d){return x.name!==d?(y[x]=!0,!0):!1},"Object, ParenthesisNode, string":function(y,x,d){return h(y,x.content,d)},"Object, FunctionAssignmentNode, string":function(y,x,d){return x.params.indexOf(d)===-1?(y[x]=!0,!0):h(y,x.expr,d)},"Object, FunctionNode | OperatorNode, string":function(y,x,d){if(x.args.length>0){for(var A=h(y,x.args[0],d),S=1;S<x.args.length;++S)A=h(y,x.args[S],d)&&A;if(A)return y[x]=!0,!0}return!1}}),b=n("_derivative",{"ConstantNode, Object":function(y){return N(0)},"SymbolNode, Object":function(y,x){return x[y]!==void 0?N(0):N(1)},"ParenthesisNode, Object":function(y,x){return new o(b(y.content,x))},"FunctionAssignmentNode, Object":function(y,x){return x[y]!==void 0?N(0):b(y.expr,x)},"FunctionNode, Object":function(y,x){if(y.args.length!==1&&w(y),x[y]!==void 0)return N(0);var d=y.args[0],A,S=!1,O=!1,M;switch(y.name){case"cbrt":S=!0,M=new s("*","multiply",[N(3),new s("^","pow",[d,new s("/","divide",[N(2),N(3)])])]);break;case"sqrt":case"nthRoot":if(y.args.length===1)S=!0,M=new s("*","multiply",[N(2),new c("sqrt",[d])]);else if(y.args.length===2)return A=new s("/","divide",[N(1),y.args[1]]),x[A]=x[y.args[1]],b(new s("^","pow",[d,A]),x);break;case"log10":A=N(10);case"log":if(!A&&y.args.length===1)M=d.clone(),S=!0;else if(y.args.length===1&&A||y.args.length===2&&x[y.args[1]]!==void 0)M=new s("*","multiply",[d.clone(),new c("log",[A||y.args[1]])]),S=!0;else if(y.args.length===2)return b(new s("/","divide",[new c("log",[d]),new c("log",[y.args[1]])]),x);break;case"pow":return x[A]=x[y.args[1]],b(new s("^","pow",[d,y.args[1]]),x);case"exp":M=new c("exp",[d.clone()]);break;case"sin":M=new c("cos",[d.clone()]);break;case"cos":M=new s("-","unaryMinus",[new c("sin",[d.clone()])]);break;case"tan":M=new s("^","pow",[new c("sec",[d.clone()]),N(2)]);break;case"sec":M=new s("*","multiply",[y,new c("tan",[d.clone()])]);break;case"csc":O=!0,M=new s("*","multiply",[y,new c("cot",[d.clone()])]);break;case"cot":O=!0,M=new s("^","pow",[new c("csc",[d.clone()]),N(2)]);break;case"asin":S=!0,M=new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])]);break;case"acos":S=!0,O=!0,M=new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])]);break;case"atan":S=!0,M=new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)]);break;case"asec":S=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acsc":S=!0,O=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acot":S=!0,O=!0,M=new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)]);break;case"sinh":M=new c("cosh",[d.clone()]);break;case"cosh":M=new c("sinh",[d.clone()]);break;case"tanh":M=new s("^","pow",[new c("sech",[d.clone()]),N(2)]);break;case"sech":O=!0,M=new s("*","multiply",[y,new c("tanh",[d.clone()])]);break;case"csch":O=!0,M=new s("*","multiply",[y,new c("coth",[d.clone()])]);break;case"coth":O=!0,M=new s("^","pow",[new c("csch",[d.clone()]),N(2)]);break;case"asinh":S=!0,M=new c("sqrt",[new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"acosh":S=!0,M=new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"atanh":S=!0,M=new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])]);break;case"asech":S=!0,O=!0,M=new s("*","multiply",[d.clone(),new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])])]);break;case"acsch":S=!0,O=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acoth":S=!0,O=!0,M=new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])]);break;case"abs":M=new s("/","divide",[new c(new u("abs"),[d.clone()]),d.clone()]);break;case"gamma":default:throw new Error('Function "'+y.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var _,E;S?(_="/",E="divide"):(_="*",E="multiply");var $=b(d,x);return O&&($=new s("-","unaryMinus",[$])),new s(_,E,[$,M])},"OperatorNode, Object":function(y,x){if(x[y]!==void 0)return N(0);if(y.op==="+")return new s(y.op,y.fn,y.args.map(function(I){return b(I,x)}));if(y.op==="-"){if(y.isUnary())return new s(y.op,y.fn,[b(y.args[0],x)]);if(y.isBinary())return new s(y.op,y.fn,[b(y.args[0],x),b(y.args[1],x)])}if(y.op==="*"){var d=y.args.filter(function(I){return x[I]!==void 0});if(d.length>0){var A=y.args.filter(function(I){return x[I]===void 0}),S=A.length===1?A[0]:new s("*","multiply",A),O=d.concat(b(S,x));return new s("*","multiply",O)}return new s("+","add",y.args.map(function(I){return new s("*","multiply",y.args.map(function(T){return T===I?b(T,x):T.clone()}))}))}if(y.op==="/"&&y.isBinary()){var M=y.args[0],_=y.args[1];return x[_]!==void 0?new s("/","divide",[b(M,x),_]):x[M]!==void 0?new s("*","multiply",[new s("-","unaryMinus",[M]),new s("/","divide",[b(_,x),new s("^","pow",[_.clone(),N(2)])])]):new s("/","divide",[new s("-","subtract",[new s("*","multiply",[b(M,x),_.clone()]),new s("*","multiply",[M.clone(),b(_,x)])]),new s("^","pow",[_.clone(),N(2)])])}if(y.op==="^"&&y.isBinary()){var E=y.args[0],$=y.args[1];if(x[E]!==void 0)return Ye(E)&&(l(E.value)||i(E.value,1))?N(0):new s("*","multiply",[y,new s("*","multiply",[new c("log",[E.clone()]),b($.clone(),x)])]);if(x[$]!==void 0){if(Ye($)){if(l($.value))return N(0);if(i($.value,1))return b(E,x)}var z=new s("^","pow",[E.clone(),new s("-","subtract",[$,N(1)])]);return new s("*","multiply",[$.clone(),new s("*","multiply",[b(E,x),z])])}return new s("*","multiply",[new s("^","pow",[E.clone(),$.clone()]),new s("+","add",[new s("*","multiply",[b(E,x),new s("/","divide",[$.clone(),E.clone()])]),new s("*","multiply",[b($,x),new c("log",[E.clone()])])])])}throw new Error('Operator "'+y.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function w(g){if(!((g.name==="log"||g.name==="nthRoot"||g.name==="pow")&&g.args.length===2)){for(var y=0;y<g.args.length;++y)g.args[y]=N(0);throw g.compile().evaluate(),new Error("Expected TypeError, but none found")}}function N(g,y){return new f(m(g,a.number))}return p}),hm="rationalize",tO=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],nO=R(hm,tO,e=>{var{config:n,typed:a,equal:t,isZero:r,add:i,subtract:l,multiply:m,divide:f,pow:c,parse:s,simplifyCore:o,simplify:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S,ParenthesisNode:O}=e,M=pm({typed:a,config:n,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S});return a(hm,{string:function(T){return this(s(T),{},!1)},"string, boolean":function(T,B){return this(s(T),{},B)},"string, Object":function(T,B){return this(s(T),B,!1)},"string, Object, boolean":function(T,B,G){return this(s(T),B,G)},Node:function(T){return this(T,{},!1)},"Node, boolean":function(T,B){return this(T,{},B)},"Node, Object":function(T,B){return this(T,B,!1)},"Node, Object, boolean":function(T,B,G){var D=E(),H=_(T,B,!0,D.firstRules),W=H.variables.length,j={exactFractions:!1},V={exactFractions:!0};if(T=H.expression,W>=1){T=$(T);var K,te,re=!0,ie=!1;T=u(T,D.firstRules,{},j);for(var ne;te=re?D.distrDivRules:D.sucDivRules,T=u(T,te,{},V),re=!re,ne=T.toString(),ne!==K;)ie=!0,K=ne;ie&&(T=u(T,D.firstRulesAgain,{},j)),T=u(T,D.finalRules,{},j)}var ue=[],ee={};return T.type==="OperatorNode"&&T.isBinary()&&T.op==="/"?(W===1&&(T.args[0]=z(T.args[0],ue),T.args[1]=z(T.args[1])),G&&(ee.numerator=T.args[0],ee.denominator=T.args[1])):(W===1&&(T=z(T,ue)),G&&(ee.numerator=T,ee.denominator=null)),G?(ee.coefficients=ue,ee.variables=H.variables,ee.expression=T,ee):T}});function _(I,T,B,G){var D=[],H=u(I,G,T,{exactFractions:!1});B=!!B;var W="+-*"+(B?"/":"");V(H);var j={};return j.expression=H,j.variables=D,j;function V(K){var te=K.type;if(te==="FunctionNode")throw new Error("There is an unsolved function call");if(te==="OperatorNode")if(K.op==="^"){if(K.args[1].type!=="ConstantNode"||!Ae(parseFloat(K.args[1].value)))throw new Error("There is a non-integer exponent");V(K.args[0])}else{if(W.indexOf(K.op)===-1)throw new Error("Operator "+K.op+" invalid in polynomial expression");for(var re=0;re<K.args.length;re++)V(K.args[re])}else if(te==="SymbolNode"){var ie=K.name,ne=D.indexOf(ie);ne===-1&&D.push(ie)}else if(te==="ParenthesisNode")V(K.content);else if(te!=="ConstantNode")throw new Error("type "+te+" is not allowed in polynomial expression")}}function E(){var I=[o,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},M,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],T=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],B=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],G=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],D={};return D.firstRules=I.concat(T,G),D.distrDivRules=B,D.sucDivRules=G,D.firstRulesAgain=I.concat(T),D.finalRules=[o,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},M,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],D}function $(I,T,B){var G=I.type,D=arguments.length>1;if(G==="OperatorNode"&&I.isBinary()){var H=!1,W;if(I.op==="^"&&(I.args[0].type==="ParenthesisNode"||I.args[0].type==="OperatorNode")&&I.args[1].type==="ConstantNode"&&(W=parseFloat(I.args[1].value),H=W>=2&&Ae(W)),H){if(W>2){var j=I.args[0],V=new A("^","pow",[I.args[0].cloneDeep(),new g(W-1)]);I=new A("*","multiply",[j,V])}else I=new A("*","multiply",[I.args[0],I.args[0].cloneDeep()]);D&&(B==="content"?T.content=I:T.args[B]=I)}}if(G==="ParenthesisNode")$(I.content,I,"content");else if(G!=="ConstantNode"&&G!=="SymbolNode")for(var K=0;K<I.args.length;K++)$(I.args[K],I,K);if(!D)return I}function z(I,T){T===void 0&&(T=[]),T[0]=0;var B={};B.cte=1,B.oper="+",B.fire="";var G=0,D="";ie(I,null,B),G=T.length-1;for(var H=!0,W,j=G;j>=0;j--)if(T[j]!==0){var V=new g(H?T[j]:Math.abs(T[j])),K=T[j]<0?"-":"+";if(j>0){var te=new S(D);if(j>1){var re=new g(j);te=new A("^","pow",[te,re])}T[j]===-1&&H?V=new A("-","unaryMinus",[te]):Math.abs(T[j])===1?V=te:V=new A("*","multiply",[V,te])}H?W=V:K==="+"?W=new A("+","add",[W,V]):W=new A("-","subtract",[W,V]),H=!1}if(H)return new g(0);return W;function ie(ne,ue,ee){var ye=ne.type;if(ye==="FunctionNode")throw new Error("There is an unsolved function call");if(ye==="OperatorNode"){if("+-*^".indexOf(ne.op)===-1)throw new Error("Operator "+ne.op+" invalid");if(ue!==null){if((ne.fn==="unaryMinus"||ne.fn==="pow")&&ue.fn!=="add"&&ue.fn!=="subtract"&&ue.fn!=="multiply")throw new Error("Invalid "+ne.op+" placing");if((ne.fn==="subtract"||ne.fn==="add"||ne.fn==="multiply")&&ue.fn!=="add"&&ue.fn!=="subtract")throw new Error("Invalid "+ne.op+" placing");if((ne.fn==="subtract"||ne.fn==="add"||ne.fn==="unaryMinus")&&ee.noFil!==0)throw new Error("Invalid "+ne.op+" placing")}(ne.op==="^"||ne.op==="*")&&(ee.fire=ne.op);for(var we=0;we<ne.args.length;we++)ne.fn==="unaryMinus"&&(ee.oper="-"),(ne.op==="+"||ne.fn==="subtract")&&(ee.fire="",ee.cte=1,ee.oper=we===0?"+":ne.op),ee.noFil=we,ie(ne.args[we],ne,ee)}else if(ye==="SymbolNode"){if(ne.name!==D&&D!=="")throw new Error("There is more than one variable");if(D=ne.name,ue===null){T[1]=1;return}if(ue.op==="^"&&ee.noFil!==0)throw new Error("In power the variable should be the first parameter");if(ue.op==="*"&&ee.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(ee.fire===""||ee.fire==="*")&&(G<1&&(T[1]=0),T[1]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(1,G))}else if(ye==="ConstantNode"){var me=parseFloat(ne.value);if(ue===null){T[0]=me;return}if(ue.op==="^"){if(ee.noFil!==1)throw new Error("Constant cannot be powered");if(!Ae(me)||me<=0)throw new Error("Non-integer exponent is not allowed");for(var xe=G+1;xe<me;xe++)T[xe]=0;me>G&&(T[me]=0),T[me]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(me,G);return}ee.cte=me,ee.fire===""&&(T[0]+=ee.cte*(ee.oper==="+"?1:-1))}else throw new Error("Type "+ye+" is not allowed")}}}),aO="reviver",iO=["classes"],oO=R(aO,iO,e=>{var{classes:n}=e;return function(t,r){var i=n[r&&r.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(r):r}}),sO="replacer",uO=[],cO=R(sO,uO,()=>function(n,a){return typeof a=="number"&&(!isFinite(a)||isNaN(a))?{mathjs:"number",value:String(a)}:a}),fO="10.6.4",lO=R("true",[],()=>!0),mO=R("false",[],()=>!1),pO=R("null",[],()=>null),vO=Pr("Infinity",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1/0):1/0}),hO=Pr("NaN",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(NaN):NaN}),dO=Pr("pi",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?Di(a):Jh}),gO=Pr("tau",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?sb(a):Qh}),yO=Pr("e",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ib(a):Kh}),xO=Pr("phi",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ob(a):jh}),bO=Pr("LN2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(2).ln():Math.LN2}),wO=Pr("LN10",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(10).ln():Math.LN10}),NO=Pr("LOG2E",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1).div(new a(2).ln()):Math.LOG2E}),MO=Pr("LOG10E",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1).div(new a(10).ln()):Math.LOG10E}),AO=Pr("SQRT1_2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a("0.5").sqrt():Math.SQRT1_2}),SO=Pr("SQRT2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(2).sqrt():Math.SQRT2}),EO=Pr("i",["Complex"],e=>{var{Complex:n}=e;return n.I}),CO=R("version",[],()=>fO);function Pr(e,n,a){return R(e,n,a,{recreateOnConfigChange:!0})}var OO=_e("speedOfLight","299792458","m s^-1"),DO=_e("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),TO=_e("planckConstant","6.62607015e-34","J s"),BO=_e("reducedPlanckConstant","1.0545718176461565e-34","J s"),_O=_e("magneticConstant","1.25663706212e-6","N A^-2"),$O=_e("electricConstant","8.8541878128e-12","F m^-1"),IO=_e("vacuumImpedance","376.730313667","ohm"),qO=_e("coulomb","8.987551792261171e9","N m^2 C^-2"),RO=_e("elementaryCharge","1.602176634e-19","C"),FO=_e("bohrMagneton","9.2740100783e-24","J T^-1"),zO=_e("conductanceQuantum","7.748091729863649e-5","S"),PO=_e("inverseConductanceQuantum","12906.403729652257","ohm"),UO=_e("magneticFluxQuantum","2.0678338484619295e-15","Wb"),LO=_e("nuclearMagneton","5.0507837461e-27","J T^-1"),kO=_e("klitzing","25812.807459304513","ohm"),HO=_e("bohrRadius","5.29177210903e-11","m"),GO=_e("classicalElectronRadius","2.8179403262e-15","m"),VO=_e("electronMass","9.1093837015e-31","kg"),ZO=_e("fermiCoupling","1.1663787e-5","GeV^-2"),XO=Ua("fineStructure",.0072973525693),YO=_e("hartreeEnergy","4.3597447222071e-18","J"),WO=_e("protonMass","1.67262192369e-27","kg"),JO=_e("deuteronMass","3.3435830926e-27","kg"),QO=_e("neutronMass","1.6749271613e-27","kg"),KO=_e("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),jO=_e("rydberg","10973731.568160","m^-1"),eD=_e("thomsonCrossSection","6.6524587321e-29","m^2"),rD=Ua("weakMixingAngle",.2229),tD=Ua("efimovFactor",22.7),nD=_e("atomicMass","1.66053906660e-27","kg"),aD=_e("avogadro","6.02214076e23","mol^-1"),iD=_e("boltzmann","1.380649e-23","J K^-1"),oD=_e("faraday","96485.33212331001","C mol^-1"),sD=_e("firstRadiation","3.7417718521927573e-16","W m^2"),uD=_e("loschmidt","2.686780111798444e25","m^-3"),cD=_e("gasConstant","8.31446261815324","J K^-1 mol^-1"),fD=_e("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),lD=_e("molarVolume","0.022413969545014137","m^3 mol^-1"),mD=Ua("sackurTetrode",-1.16487052358),pD=_e("secondRadiation","0.014387768775039337","m K"),vD=_e("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),hD=_e("wienDisplacement","2.897771955e-3","m K"),dD=_e("molarMass","0.99999999965e-3","kg mol^-1"),gD=_e("molarMassC12","11.9999999958e-3","kg mol^-1"),yD=_e("gravity","9.80665","m s^-2"),xD=_e("planckLength","1.616255e-35","m"),bD=_e("planckMass","2.176435e-8","kg"),wD=_e("planckTime","5.391245e-44","s"),ND=_e("planckCharge","1.87554603778e-18","C"),MD=_e("planckTemperature","1.416785e+32","K");function _e(e,n,a){var t=["config","Unit","BigNumber"];return R(e,t,r=>{var{config:i,Unit:l,BigNumber:m}=r,f=i.number==="BigNumber"?new m(n):parseFloat(n),c=new l(f,a);return c.fixPrefix=!0,c})}function Ua(e,n){var a=["config","BigNumber"];return R(e,a,t=>{var{config:r,BigNumber:i}=t;return r.number==="BigNumber"?new i(n):n})}var AD="apply",SD=["typed","isInteger"],ED=R(AD,SD,e=>{var{typed:n,isInteger:a}=e,t=fu({typed:n,isInteger:a});return n("apply",{"...any":function(i){var l=i[1];$e(l)?i[1]=l-1:Ie(l)&&(i[1]=l.minus(1));try{return t.apply(null,i)}catch(m){throw Tr(m)}}})},{isTransformFunction:!0}),CD="column",OD=["typed","Index","matrix","range"],DD=R(CD,OD,e=>{var{typed:n,Index:a,matrix:t,range:r}=e,i=Vu({typed:n,Index:a,matrix:t,range:r});return n("column",{"...any":function(m){var f=m.length-1,c=m[f];$e(c)&&(m[f]=c-1);try{return i.apply(null,m)}catch(s){throw Tr(s)}}})},{isTransformFunction:!0});function Li(e,n,a){var t=e.filter(function(m){return xr(m)&&!(m.name in n)&&!a.has(m.name)})[0];if(!t)throw new Error('No undefined variable found in inline expression "'+e+'"');var r=t.name,i=Un(a),l=e.compile();return function(f){return i.set(r,f),l.evaluate(i)}}var TD="filter",BD=["typed"],_D=R(TD,BD,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||On(r[1])?f=r[1].compile().evaluate(l):f=Li(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("filter",{"Array, function":dm,"Matrix, function":function(i,l){return i.create(dm(i.toArray(),l))},"Array, RegExp":sa,"Matrix, RegExp":function(i,l){return i.create(sa(i.toArray(),l))}});return a},{isTransformFunction:!0});function dm(e,n){var a=hn(n);return No(e,function(t,r,i){return a===1?n(t):a===2?n(t,[r+1]):n(t,[r+1],i)})}var $D="forEach",ID=["typed"],qD=R($D,ID,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||On(r[1])?f=r[1].compile().evaluate(l):f=Li(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("forEach",{"Array | Matrix, function":function(i,l){var m=hn(l),f=function c(s,o){Array.isArray(s)?oa(s,function(u,p){c(u,o.concat(p+1))}):m===1?l(s):m===2?l(s,o):l(s,o,i)};f(i.valueOf(),[])}});return a},{isTransformFunction:!0}),RD="index",FD=["Index"],zD=R(RD,FD,e=>{var{Index:n}=e;return function(){for(var t=[],r=0,i=arguments.length;r<i;r++){var l=arguments[r];if(jn(l))l.start--,l.end-=l.step>0?0:2;else if(l&&l.isSet===!0)l=l.map(function(f){return f-1});else if(Xe(l)||Oe(l))l=l.map(function(f){return f-1});else if($e(l))l--;else if(Ie(l))l=l.toNumber()-1;else if(typeof l!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");t[r]=l}var m=new n;return n.apply(m,t),m}},{isTransformFunction:!0}),PD="map",UD=["typed"],LD=R(PD,UD,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||On(r[1])?f=r[1].compile().evaluate(l):f=Li(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("map",{"Array, function":function(i,l){return gm(i,l,i)},"Matrix, function":function(i,l){return i.create(gm(i.valueOf(),l,i))}});return a},{isTransformFunction:!0});function gm(e,n,a){var t=hn(n);function r(i,l){return Array.isArray(i)?dt(i,function(m,f){return r(m,l.concat(f+1))}):t===1?n(i):t===2?n(i,l):n(i,l,a)}return r(e,[])}function Zt(e){if(e.length===2&&rn(e[0])){e=e.slice();var n=e[1];$e(n)?e[1]=n-1:Ie(n)&&(e[1]=n.minus(1))}return e}var kD="max",HD=["typed","config","numeric","larger"],GD=R(kD,HD,e=>{var{typed:n,config:a,numeric:t,larger:r}=e,i=uf({typed:n,config:a,numeric:t,larger:r});return n("max",{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Tr(f)}}})},{isTransformFunction:!0}),VD="mean",ZD=["typed","add","divide"],XD=R(VD,ZD,e=>{var{typed:n,add:a,divide:t}=e,r=Bl({typed:n,add:a,divide:t});return n("mean",{"...any":function(l){l=Zt(l);try{return r.apply(null,l)}catch(m){throw Tr(m)}}})},{isTransformFunction:!0}),YD="min",WD=["typed","config","numeric","smaller"],JD=R(YD,WD,e=>{var{typed:n,config:a,numeric:t,smaller:r}=e,i=ff({typed:n,config:a,numeric:t,smaller:r});return n("min",{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Tr(f)}}})},{isTransformFunction:!0}),QD="range",KD=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],jD=R(QD,KD,e=>{var{typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f}=e,c=sc({typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f});return n("range",{"...any":function(o){var u=o.length-1,p=o[u];return typeof p!="boolean"&&o.push(!0),c.apply(null,o)}})},{isTransformFunction:!0}),eT="row",rT=["typed","Index","matrix","range"],tT=R(eT,rT,e=>{var{typed:n,Index:a,matrix:t,range:r}=e,i=mc({typed:n,Index:a,matrix:t,range:r});return n("row",{"...any":function(m){var f=m.length-1,c=m[f];$e(c)&&(m[f]=c-1);try{return i.apply(null,m)}catch(s){throw Tr(s)}}})},{isTransformFunction:!0}),nT="subset",aT=["typed","matrix"],iT=R(nT,aT,e=>{var{typed:n,matrix:a}=e,t=dc({typed:n,matrix:a});return n("subset",{"...any":function(i){try{return t.apply(null,i)}catch(l){throw Tr(l)}}})},{isTransformFunction:!0}),oT="concat",sT=["typed","matrix","isInteger"],uT=R(oT,sT,e=>{var{typed:n,matrix:a,isInteger:t}=e,r=ku({typed:n,matrix:a,isInteger:t});return n("concat",{"...any":function(l){var m=l.length-1,f=l[m];$e(f)?l[m]=f-1:Ie(f)&&(l[m]=f.minus(1));try{return r.apply(null,l)}catch(c){throw Tr(c)}}})},{isTransformFunction:!0}),ym="diff",cT=["typed","matrix","subtract","number","bignumber"],fT=R(ym,cT,e=>{var{typed:n,matrix:a,subtract:t,number:r,bignumber:i}=e,l=nc({typed:n,matrix:a,subtract:t,number:r,bignumber:i});return n(ym,{"...any":function(f){f=Zt(f);try{return l.apply(null,f)}catch(c){throw Tr(c)}}})},{isTransformFunction:!0}),lT="std",mT=["typed","sqrt","variance"],pT=R(lT,mT,e=>{var{typed:n,sqrt:a,variance:t}=e,r=Fl({typed:n,sqrt:a,variance:t});return n("std",{"...any":function(l){l=Zt(l);try{return r.apply(null,l)}catch(m){throw Tr(m)}}})},{isTransformFunction:!0}),xm="sum",vT=["typed","config","add","numeric"],hT=R(xm,vT,e=>{var{typed:n,config:a,add:t,numeric:r}=e,i=Ol({typed:n,config:a,add:t,numeric:r});return n(xm,{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Tr(f)}}})},{isTransformFunction:!0}),bm="cumsum",dT=["typed","add","unaryPlus"],gT=R(bm,dT,e=>{var{typed:n,add:a,unaryPlus:t}=e,r=Dl({typed:n,add:a,unaryPlus:t});return n(bm,{"...any":function(l){if(l.length===2&&rn(l[0])){var m=l[1];$e(m)?l[1]=m-1:Ie(m)&&(l[1]=m.minus(1))}try{return r.apply(null,l)}catch(f){throw Tr(f)}}})},{isTransformFunction:!0}),wm="variance",yT=["typed","add","subtract","multiply","divide","apply","isNaN"],xT=R(wm,yT,e=>{var{typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m}=e,f=ql({typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m});return n(wm,{"...any":function(s){s=Zt(s);try{return f.apply(null,s)}catch(o){throw Tr(o)}}})},{isTransformFunction:!0}),le=wh({config:oe}),tr=Eh({}),Nm=yO({BigNumber:le,config:oe}),bT=mO({}),wT=XO({BigNumber:le,config:oe}),Xt=Ih({}),Mm=EO({Complex:tr}),NT=vO({BigNumber:le,config:oe}),MT=wO({BigNumber:le,config:oe}),AT=MO({BigNumber:le,config:oe}),La=Uh({}),ST=hO({BigNumber:le,config:oe}),ET=pO({}),CT=xO({BigNumber:le,config:oe}),OT=Fh({}),Am=Sv({}),DT=AO({BigNumber:le,config:oe}),TT=mD({BigNumber:le,config:oe}),Sm=gO({BigNumber:le,config:oe}),BT=lO({}),_T=CO({}),ze=Hh({Matrix:La}),$T=tD({BigNumber:le,config:oe}),IT=bO({BigNumber:le,config:oe}),Em=dO({BigNumber:le,config:oe}),qT=cO({}),RT=SO({BigNumber:le,config:oe}),Z=wv({BigNumber:le,Complex:tr,DenseMatrix:ze,Fraction:Xt}),ki=eg({BigNumber:le,config:oe,typed:Z}),FT=rD({BigNumber:le,config:oe}),Ur=tg({typed:Z}),zT=yb({Complex:tr,config:oe,typed:Z}),PT=Nb({BigNumber:le,typed:Z}),UT=Eb({BigNumber:le,Complex:tr,config:oe,typed:Z}),hr=og({typed:Z}),LT=ky({typed:Z}),kT=_b({BigNumber:le,Complex:tr,config:oe,typed:Z}),HT=Fb({typed:Z}),Cm=Ub({typed:Z}),GT=Gb({Complex:tr,config:oe,typed:Z}),Mt=Id({BigNumber:le,typed:Z}),VT=Iy({typed:Z}),ZT=Bd({typed:Z}),XT=Vh({typed:Z}),ka=HC({typed:Z}),Ha=Fd({Complex:tr,typed:Z}),wn=Gy({typed:Z}),YT=Yb({typed:Z}),WT=Kb({BigNumber:le,typed:Z}),JT=ew({BigNumber:le,typed:Z}),QT=xg({typed:Z}),ke=xd({config:oe,typed:Z}),KT=c1({typed:Z}),Om=wg({typed:Z}),jT=Mg({Complex:tr,typed:Z}),eB=m0({typed:Z}),rB=d0({typed:Z}),Ln=y1({typed:Z}),tB=x0({typed:Z}),nB=A1({format:Ln,typed:Z}),Dm=Zy({typed:Z}),Vr=Xh({typed:Z}),Nn=ad({typed:Z}),Ga=fd({typed:Z}),ft=md({typed:Z}),aB=NO({BigNumber:le,config:oe}),iB=WC({Complex:tr,typed:Z}),oB=Xg({Complex:tr,config:oe,typed:Z}),sB=Wg({Complex:tr,config:oe,typed:Z}),Tm=S0({typed:Z}),lr=ay({typed:Z}),Bm=Jy({typed:Z}),Ft=Cd({typed:Z}),uB=N1({format:Ln,typed:Z}),cB=M3({config:oe,typed:Z}),fB=E1({typed:Z}),lB=S3({config:oe,typed:Z}),_m=Yy({typed:Z}),mB=aw({BigNumber:le,typed:Z}),$m=fy({BigNumber:le,Fraction:Xt,complex:Ha,typed:Z}),Hi=uw({typed:Z}),At=Nd({Matrix:La,equalScalar:ke,typed:Z}),pB=Jd({typed:Z}),vB=hy({typed:Z}),hB=Dd({typed:Z}),dB=mw({typed:Z}),gB=dd({typed:Z}),yB=bb({Complex:tr,config:oe,typed:Z}),xB=Ob({BigNumber:le,typed:Z}),Gi=fu({isInteger:Vr,typed:Z}),bB=Tb({BigNumber:le,Complex:tr,config:oe,typed:Z}),wB=b1({format:Ln,typed:Z}),NB=VC({typed:Z}),Vi=Zb({typed:Z}),MB=tw({BigNumber:le,typed:Z}),kn=vd({typed:Z}),AB=T1({typed:Z}),SB=C3({config:oe,typed:Z}),EB=ow({BigNumber:le,typed:Z}),CB=fw({typed:Z}),OB=vb({SparseMatrix:At,typed:Z}),St=py({Complex:tr,config:oe,typed:Z}),DB=hw({typed:Z}),Et=Kd({typed:Z}),TB=Ab({BigNumber:le,Complex:tr,config:oe,typed:Z}),BB=Jb({BigNumber:le,typed:Z}),Hn=Ud({Fraction:Xt,typed:Z}),Yt=od({typed:Z}),de=kd({DenseMatrix:ze,Matrix:La,SparseMatrix:At,typed:Z}),_B=Gd({isZero:ft,matrix:de,typed:Z}),Im=ry({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),$B=uy({BigNumber:le,equalScalar:ke,matrix:de,typed:Z}),et=$1({bignumber:Mt,fraction:Hn,number:Ft}),IB=Ky({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),qm=d1({config:oe,multiplyScalar:lr,numeric:et,typed:Z}),qB=$0({isInteger:Vr,matrix:de,typed:Z}),Ar=H0({matrix:de,config:oe,typed:Z}),Zr=Ox({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),RB=V0({matrix:de,typed:Z}),Xr=dc({matrix:de,typed:Z}),ir=gy({DenseMatrix:ze,addScalar:hr,equalScalar:ke,matrix:de,typed:Z,unaryMinus:Et}),FB=O1({matrix:de,typed:Z}),Zi=K0({matrix:de,typed:Z}),Rm=xy({BigNumber:le,config:oe,matrix:de,typed:Z}),lt=t1({BigNumber:le,config:oe,matrix:de,typed:Z}),zB=px({equalScalar:ke,matrix:de,not:Bm,typed:Z,zeros:lt}),PB=_y({equalScalar:ke,matrix:de,typed:Z}),UB=Uy({DenseMatrix:ze,matrix:de,typed:Z}),LB=ug({BigNumber:le,Complex:tr,Fraction:Xt,config:oe,isNegative:Nn,matrix:de,typed:Z,unaryMinus:Et}),Mn=hx({BigNumber:le,DenseMatrix:ze,Fraction:Xt,config:oe,equalScalar:ke,matrix:de,typed:Z}),Fm=Nx({matrix:de,typed:Z}),Xi=ku({isInteger:Vr,matrix:de,typed:Z}),kB=a0({prod:qm,size:Ar,typed:Z}),Yi=e1({conj:wn,transpose:Zi,typed:Z}),zm=u0({DenseMatrix:ze,SparseMatrix:At,matrix:de,typed:Z}),or=q1({numeric:et,typed:Z}),Va=W1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,typed:Z}),rt=Ax({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),Pm=a1({addScalar:hr,divideScalar:or,exp:Om,i:Mm,matrix:de,multiplyScalar:lr,tau:Sm,typed:Z}),Gn=v0({matrix:de,typed:Z}),HB=Pg({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),GB=ud({isNumeric:Yt,typed:Z}),VB=Pw({abs:Ur,addScalar:hr,divideScalar:or,isPositive:Ga,multiplyScalar:lr,smaller:Zr,sqrt:St,typed:Z}),ZB=o1({conj:wn,dotDivide:Va,fft:Pm,typed:Z}),XB=M0({matrix:de,multiplyScalar:lr,typed:Z}),Za=Ix({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),YB=sx({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Um=Q1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),Lm=Yd({flatten:Gn,matrix:de,size:Ar,typed:Z}),WB=ff({config:oe,numeric:et,smaller:Zr,typed:Z}),JB=v1({isNaN:kn,isNumeric:Yt,typed:Z}),QB=V1({Complex:tr,config:oe,divideScalar:or,typed:Z}),KB=T0({BigNumber:le,config:oe,matrix:de,typed:Z}),Wi=Ux({compare:Mn,isNaN:kn,isNumeric:Yt,typed:Z}),jB=R0({config:oe,matrix:de}),e4=cx({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Vn=P1({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Ji=Tx({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),r4=zx({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,typed:Z}),Qi=j1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),t4=e0({DenseMatrix:ze,matrix:de,typed:Z}),sr=Fw({DenseMatrix:ze,SparseMatrix:At,addScalar:hr,equalScalar:ke,matrix:de,typed:Z}),n4=kb({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),a4=Ry({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),i4=$3({addScalar:hr,combinations:ka,divideScalar:or,isInteger:Vr,isNegative:Nn,multiplyScalar:lr,typed:Z}),mt=xx({compare:Mn,typed:Z}),o4=Dl({add:sr,typed:Z,unaryPlus:ki}),km=Rx({equal:rt,typed:Z}),s4=nc({matrix:de,number:Ft,subtract:ir,typed:Z}),Xa=Hw({addScalar:hr,conj:wn,multiplyScalar:lr,size:Ar,typed:Z}),u4=Ex({compareText:Fm,isZero:ft,typed:Z}),Hm=Dg({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,round:Vn,typed:Z,zeros:lt}),An=w0({BigNumber:le,DenseMatrix:ze,SparseMatrix:At,config:oe,matrix:de,typed:Z}),c4=wy({BigNumber:le,add:sr,config:oe,equal:rt,isInteger:Vr,mod:Im,smaller:Zr,typed:Z,xgcd:Rm}),Yr=_x({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),Ki=L1({Complex:tr,config:oe,divideScalar:or,typed:Z}),f4=rx({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),l4=Zd({flatten:Gn,matrix:de,size:Ar,typed:Z}),mr=oy({addScalar:hr,dot:Xa,equalScalar:ke,matrix:de,multiplyScalar:lr,typed:Z}),Gm=uM({addScalar:hr,complex:Ha,conj:wn,divideScalar:or,equal:rt,identity:An,isZero:ft,matrix:de,multiplyScalar:lr,sign:$m,sqrt:St,subtract:ir,typed:Z,unaryMinus:Et,zeros:lt}),Zn=sc({bignumber:Mt,matrix:de,config:oe,larger:Yr,largerEq:Za,smaller:Zr,smallerEq:Ji,typed:Z}),m4=lx({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),p4=Bw({compareNatural:mt,typed:Z}),Vm=_M({SparseMatrix:At,abs:Ur,add:sr,divideScalar:or,larger:Yr,largerEq:Za,multiply:mr,subtract:ir,transpose:Zi,typed:Z}),Zm=Ol({add:sr,config:oe,numeric:et,typed:Z}),v4=Zw({add:sr,matrix:de,typed:Z}),Xm=nx({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),h4=Ib({Complex:tr,config:oe,typed:Z}),Ym=gg({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,round:Vn,typed:Z,zeros:lt}),d4=q3({addScalar:hr,combinations:ka,isInteger:Vr,isNegative:Nn,isPositive:Ga,larger:Yr,typed:Z}),g4=o0({matrix:de,multiply:mr,subtract:ir,typed:Z}),Wm=uC({divideScalar:or,isZero:ft,matrix:de,multiply:mr,subtract:ir,typed:Z,unaryMinus:Et}),y4=EC({abs:Ur,addScalar:hr,divideScalar:or,multiplyScalar:lr,sqrt:St,subtract:ir,typed:Z,unaryMinus:Et}),x4=Sy({equalScalar:ke,matrix:de,multiplyScalar:lr,typed:Z}),Jm=jx({larger:Yr,smaller:Zr}),Qm=Eg({Complex:tr,DenseMatrix:ze,ceil:Ym,equalScalar:ke,floor:Hm,matrix:de,typed:Z,zeros:lt}),Km=Xx({DenseMatrix:ze,smaller:Zr}),Sr=Jx({ImmutableDenseMatrix:Km}),b4=DC({abs:Ur,add:sr,addScalar:hr,config:oe,divideScalar:or,equalScalar:ke,flatten:Gn,isNumeric:Yt,isZero:ft,matrix:de,multiply:mr,multiplyScalar:lr,smaller:Zr,subtract:ir,typed:Z}),w4=Vg({equalScalar:ke,matrix:de,typed:Z}),N4=H1({Complex:tr,config:oe,divideScalar:or,log:Ki,typed:Z}),jm=uf({config:oe,larger:Yr,numeric:et,typed:Z}),M4=UC({add:sr,compare:Mn,multiply:mr,partitionSelect:Wi,typed:Z}),A4=mc({Index:Sr,matrix:de,range:Zn,typed:Z}),S4=gw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Xr,typed:Z}),E4=ww({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Xr,typed:Z}),C4=Sw({Index:Sr,compareNatural:mt,size:Ar,subset:Xr,typed:Z}),O4=Dw({Index:Sr,compareNatural:mt,size:Ar,subset:Xr,typed:Z}),D4=kx({compare:Mn,compareNatural:mt,matrix:de,typed:Z}),ep=Vu({Index:Sr,matrix:de,range:Zn,typed:Z}),T4=Yw({Index:Sr,typed:Z}),Wt=fC({abs:Ur,addScalar:hr,det:Wm,divideScalar:or,identity:An,matrix:de,multiply:mr,typed:Z,unaryMinus:Et}),B4=mC({Complex:tr,add:sr,ctranspose:Yi,deepEqual:km,divideScalar:or,dot:Xa,dotDivide:Va,equal:rt,inv:Wt,matrix:de,multiply:mr,typed:Z}),Ct=F1({Complex:tr,config:oe,fraction:Hn,identity:An,inv:Wt,matrix:de,multiply:mr,number:Ft,typed:Z}),rp=xw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Xr,typed:Z}),_4=Cw({Index:Sr,compareNatural:mt,size:Ar,subset:Xr,typed:Z}),tp=tb({FibonacciHeap:Jm,addScalar:hr,equalScalar:ke}),$4=wC({abs:Ur,add:sr,identity:An,inv:Wt,max:jm,multiply:mr,size:Ar,sqrt:St,subtract:ir,typed:Z}),Te=fb({BigNumber:le,Complex:tr,Fraction:Xt,abs:Ur,addScalar:hr,config:oe,divideScalar:or,equal:rt,fix:Qm,format:Ln,isNumeric:Yt,multiplyScalar:lr,number:Ft,pow:Ct,round:Vn,subtract:ir}),I4=IO({BigNumber:le,Unit:Te,config:oe}),q4=hD({BigNumber:le,Unit:Te,config:oe}),R4=nD({BigNumber:le,Unit:Te,config:oe}),F4=FO({BigNumber:le,Unit:Te,config:oe}),z4=iD({BigNumber:le,Unit:Te,config:oe}),P4=zO({BigNumber:le,Unit:Te,config:oe}),U4=db({Unit:Te,typed:Z}),L4=JO({BigNumber:le,Unit:Te,config:oe}),k4=X1({DenseMatrix:ze,equalScalar:ke,matrix:de,pow:Ct,typed:Z}),H4=$O({BigNumber:le,Unit:Te,config:oe}),G4=RO({BigNumber:le,Unit:Te,config:oe}),V4=xC({abs:Ur,add:sr,identity:An,inv:Wt,multiply:mr,typed:Z}),Z4=oD({BigNumber:le,Unit:Te,config:oe}),X4=sD({BigNumber:le,Unit:Te,config:oe}),np=XC({BigNumber:le,Complex:tr,config:oe,multiplyScalar:lr,pow:Ct,typed:Z}),Y4=DO({BigNumber:le,Unit:Te,config:oe}),W4=YO({BigNumber:le,Unit:Te,config:oe}),J4=kO({BigNumber:le,Unit:Te,config:oe}),Q4=uD({BigNumber:le,Unit:Te,config:oe}),K4=_O({BigNumber:le,Unit:Te,config:oe}),j4=dD({BigNumber:le,Unit:Te,config:oe}),e_=fD({BigNumber:le,Unit:Te,config:oe}),r_=QO({BigNumber:le,Unit:Te,config:oe}),t_=LO({BigNumber:le,Unit:Te,config:oe}),n_=ND({BigNumber:le,Unit:Te,config:oe}),a_=xD({BigNumber:le,Unit:Te,config:oe}),i_=MD({BigNumber:le,Unit:Te,config:oe}),o_=WO({BigNumber:le,Unit:Te,config:oe}),s_=BO({BigNumber:le,Unit:Te,config:oe}),u_=jO({BigNumber:le,Unit:Te,config:oe}),ap=Mw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Xr,typed:Z}),c_=OO({BigNumber:le,Unit:Te,config:oe}),f_=vD({BigNumber:le,Unit:Te,config:oe}),l_=eD({BigNumber:le,Unit:Te,config:oe}),m_=aD({BigNumber:le,Unit:Te,config:oe}),p_=HO({BigNumber:le,Unit:Te,config:oe}),v_=qO({BigNumber:le,Unit:Te,config:oe}),tt=AC({divideScalar:or,equalScalar:ke,inv:Wt,matrix:de,multiply:mr,typed:Z}),h_=VO({BigNumber:le,Unit:Te,config:oe}),Ya=QC({gamma:np,typed:Z}),d_=yD({BigNumber:le,Unit:Te,config:oe}),g_=PO({BigNumber:le,Unit:Te,config:oe}),ip=oM({DenseMatrix:ze,Spa:tp,SparseMatrix:At,abs:Ur,addScalar:hr,divideScalar:or,equalScalar:ke,larger:Yr,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z,unaryMinus:Et}),y_=UO({BigNumber:le,Unit:Te,config:oe}),x_=gD({BigNumber:le,Unit:Te,config:oe}),b_=r3({add:sr,divide:tt,factorial:Ya,isInteger:Vr,isPositive:Ga,multiply:mr,typed:Z}),w_=n3({factorial:Ya,typed:Z}),N_=bD({BigNumber:le,Unit:Te,config:oe}),M_=KO({BigNumber:le,Unit:Te,config:oe}),A_=pD({BigNumber:le,Unit:Te,config:oe}),op=D3({bignumber:Mt,addScalar:hr,combinations:ka,divideScalar:or,factorial:Ya,isInteger:Vr,isNegative:Nn,larger:Yr,multiplyScalar:lr,number:Ft,pow:Ct,subtract:ir,typed:Z}),S_=mb({Unit:Te,typed:Z}),E_=B3({addScalar:hr,isInteger:Vr,isNegative:Nn,stirlingS2:op,typed:Z}),sp=gC({abs:Ur,add:sr,addScalar:hr,atan:Cm,bignumber:Mt,column:ep,complex:Ha,config:oe,cos:Vi,diag:zm,divideScalar:or,dot:Xa,equal:rt,flatten:Gn,im:Dm,inv:Wt,larger:Yr,matrix:de,matrixFromColumns:Lm,multiply:mr,multiplyScalar:lr,number:Ft,qr:Gm,re:_m,sin:Hi,smaller:Zr,sqrt:St,subtract:ir,typed:Z,usolve:Qi,usolveAll:Xm}),C_=ZO({BigNumber:le,Unit:Te,config:oe}),O_=Bl({add:sr,divide:tt,typed:Z}),D_=lD({BigNumber:le,Unit:Te,config:oe}),T_=TO({BigNumber:le,Unit:Te,config:oe}),up=$w({Index:Sr,concat:Xi,setDifference:rp,size:Ar,subset:Xr,typed:Z}),B_=GO({BigNumber:le,Unit:Te,config:oe}),__=IM({DenseMatrix:ze,lsolve:Um,lup:ip,matrix:de,slu:Vm,typed:Z,usolve:Qi}),cp=IC({add:sr,compare:Mn,divide:tt,partitionSelect:Wi,typed:Z}),$_=qw({Index:Sr,concat:Xi,setIntersect:ap,setSymDifference:up,size:Ar,subset:Xr,typed:Z}),ji=ql({add:sr,apply:Gi,divide:tt,isNaN:kn,multiply:mr,subtract:ir,typed:Z}),I_=jC({divide:tt,dotDivide:Va,isNumeric:Yt,log:Ki,matrix:de,multiply:mr,sum:Zm,typed:Z}),fp=Lw({abs:Ur,add:sr,conj:wn,ctranspose:Yi,eigs:sp,equalScalar:ke,larger:Yr,matrix:de,multiply:mr,pow:Ct,smaller:Zr,sqrt:St,typed:Z}),q_=wD({BigNumber:le,Unit:Te,config:oe}),lp=U0({BigNumber:le,DenseMatrix:ze,SparseMatrix:At,addScalar:hr,config:oe,cos:Vi,matrix:de,multiplyScalar:lr,norm:fp,sin:Hi,typed:Z,unaryMinus:Et}),R_=cD({BigNumber:le,Unit:Te,config:oe}),F_=Fl({sqrt:St,typed:Z,variance:ji}),z_=RC({abs:Ur,map:Tm,median:cp,subtract:ir,typed:Z}),P_=z0({multiply:mr,rotationMatrix:lp,typed:Z}),Sn={},Xn={},mp={},eo=UM({math:Sn}),Er=Qw({mathWithTransform:Xn}),Yn=DN({Node:Er}),zt=_N({Node:Er}),Jt=qN({Node:Er}),pp=LN({Node:Er}),Wn=nN({Node:Er}),vp=fN({Node:Er,ResultSet:Am}),hp=pN({Node:Er}),Qt=bN({Node:Er}),dp=zN({Node:Er}),U_=oO({classes:mp}),L_=oC({Chain:eo,typed:Z}),gp=MN({Node:Er,typed:Z}),Jn=eN({Node:Er,subset:Xr}),yp=sN({matrix:de,Node:Er,subset:Xr}),Qn=EN({Node:Er,size:Ar}),Kt=GN({Unit:Te,Node:Er,math:Sn}),jt=XN({Node:Er,SymbolNode:Kt,math:Sn}),pt=WN({AccessorNode:Jn,ArrayNode:Wn,AssignmentNode:yp,BlockNode:vp,ConditionalNode:hp,ConstantNode:Qt,FunctionAssignmentNode:gp,FunctionNode:jt,IndexNode:Qn,ObjectNode:Yn,OperatorNode:zt,ParenthesisNode:Jt,RangeNode:dp,RelationalNode:pp,SymbolNode:Kt,config:oe,numeric:et,typed:Z}),xp=J3({ConstantNode:Qt,FunctionNode:jt,OperatorNode:zt,ParenthesisNode:Jt,parse:pt}),ro=X3({AccessorNode:Jn,ArrayNode:Wn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Qn,ObjectNode:Yn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,divide:tt,equal:rt,isZero:ft,multiply:mr,pow:Ct,subtract:ir}),k_=QN({parse:pt,typed:Z}),bp=FM({parse:pt}),H_=F3({parse:pt,typed:Z}),Wa=G3({bignumber:Mt,fraction:Hn,AccessorNode:Jn,ArrayNode:Wn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Qn,ObjectNode:Yn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,config:oe,divide:tt,equal:rt,isZero:ft,mathWithTransform:Xn,matrix:de,multiply:mr,parse:pt,pow:Ct,resolve:xp,simplifyCore:ro,subtract:ir,typed:Z}),G_=K3({OperatorNode:zt,parse:pt,simplify:Wa,typed:Z}),to=jN({parse:pt,typed:Z}),V_=aC({Help:bp,mathWithTransform:Xn,typed:Z}),wp=tM({evaluate:to}),Z_=nO({bignumber:Mt,fraction:Hn,AccessorNode:Jn,ArrayNode:Wn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Qn,ObjectNode:Yn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,config:oe,divide:tt,equal:rt,isZero:ft,mathWithTransform:Xn,matrix:de,multiply:mr,parse:pt,pow:Ct,simplify:Wa,simplifyCore:ro,subtract:ir,typed:Z}),X_=rO({ConstantNode:Qt,FunctionNode:jt,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,config:oe,equal:rt,isZero:ft,numeric:et,parse:pt,simplify:Wa,typed:Z}),Y_=aM({Parser:wp,typed:Z});rr(Sn,{e:Nm,false:bT,fineStructure:wT,i:Mm,Infinity:NT,LN10:MT,LOG10E:AT,NaN:ST,null:ET,phi:CT,SQRT1_2:DT,sackurTetrode:TT,tau:Sm,true:BT,E:Nm,version:_T,efimovFactor:$T,LN2:IT,pi:Em,replacer:qT,reviver:U_,SQRT2:RT,typed:Z,unaryPlus:ki,PI:Em,weakMixingAngle:FT,abs:Ur,acos:zT,acot:PT,acsc:UT,addScalar:hr,arg:LT,asech:kT,asinh:HT,atan:Cm,atanh:GT,bignumber:Mt,bitNot:VT,boolean:ZT,chain:L_,clone:XT,combinations:ka,complex:Ha,conj:wn,cosh:YT,coth:WT,csc:JT,cube:QT,equalScalar:ke,erf:KT,exp:Om,expm1:jT,filter:eB,forEach:rB,format:Ln,getMatrixDataType:tB,hex:nB,im:Dm,isInteger:Vr,isNegative:Nn,isPositive:Ga,isZero:ft,LOG2E:aB,lgamma:iB,log10:oB,log2:sB,map:Tm,multiplyScalar:lr,not:Bm,number:Ft,oct:uB,pickRandom:cB,print:fB,random:lB,re:_m,sec:mB,sign:$m,sin:Hi,splitUnit:pB,square:vB,string:hB,tan:dB,typeOf:gB,acosh:yB,acsch:xB,apply:Gi,asec:bB,bin:wB,combinationsWithRep:NB,cos:Vi,csch:MB,isNaN:kn,isPrime:AB,randomInt:SB,sech:EB,sinh:CB,sparse:OB,sqrt:St,tanh:DB,unaryMinus:Et,acoth:TB,cot:BB,fraction:Hn,isNumeric:Yt,matrix:de,matrixFromFunction:_B,mod:Im,nthRoot:$B,numeric:et,or:IB,prod:qm,reshape:qB,size:Ar,smaller:Zr,squeeze:RB,subset:Xr,subtract:ir,to:FB,transpose:Zi,xgcd:Rm,zeros:lt,and:zB,bitAnd:PB,bitXor:UB,cbrt:LB,compare:Mn,compareText:Fm,concat:Xi,count:kB,ctranspose:Yi,diag:zm,divideScalar:or,dotDivide:Va,equal:rt,fft:Pm,flatten:Gn,gcd:HB,hasNumericValue:GB,hypot:VB,ifft:ZB,kron:XB,largerEq:Za,leftShift:YB,lsolve:Um,matrixFromColumns:Lm,min:WB,mode:JB,nthRoots:QB,ones:KB,partitionSelect:Wi,resize:jB,rightArithShift:e4,round:Vn,smallerEq:Ji,unequal:r4,usolve:Qi,xor:t4,add:sr,atan2:n4,bitOr:a4,catalan:i4,compareNatural:mt,cumsum:o4,deepEqual:km,diff:s4,dot:Xa,equalText:u4,floor:Hm,identity:An,invmod:c4,larger:Yr,log:Ki,lsolveAll:f4,matrixFromRows:l4,multiply:mr,qr:Gm,range:Zn,rightLogShift:m4,setSize:p4,slu:Vm,sum:Zm,trace:v4,usolveAll:Xm,asin:h4,ceil:Ym,composition:d4,cross:g4,det:Wm,distance:y4,dotMultiply:x4,fix:Qm,intersect:b4,lcm:w4,log1p:N4,max:jm,quantileSeq:M4,row:A4,setCartesian:S4,setDistinct:E4,setIsSubset:C4,setPowerset:O4,sort:D4,column:ep,index:T4,inv:Wt,pinv:B4,pow:Ct,setDifference:rp,setMultiplicity:_4,sqrtm:$4,vacuumImpedance:I4,wienDisplacement:q4,atomicMass:R4,bohrMagneton:F4,boltzmann:z4,conductanceQuantum:P4,createUnit:U4,deuteronMass:L4,dotPow:k4,electricConstant:H4,elementaryCharge:G4,expm:V4,faraday:Z4,firstRadiation:X4,gamma:np,gravitationConstant:Y4,hartreeEnergy:W4,klitzing:J4,loschmidt:Q4,magneticConstant:K4,molarMass:j4,molarPlanckConstant:e_,neutronMass:r_,nuclearMagneton:t_,planckCharge:n_,planckLength:a_,planckTemperature:i_,protonMass:o_,reducedPlanckConstant:s_,rydberg:u_,setIntersect:ap,speedOfLight:c_,stefanBoltzmann:f_,thomsonCrossSection:l_,avogadro:m_,bohrRadius:p_,coulomb:v_,divide:tt,electronMass:h_,factorial:Ya,gravity:d_,inverseConductanceQuantum:g_,lup:ip,magneticFluxQuantum:y_,molarMassC12:x_,multinomial:b_,parse:pt,permutations:w_,planckMass:N_,quantumOfCirculation:M_,resolve:xp,secondRadiation:A_,simplifyCore:ro,stirlingS2:op,unit:S_,bellNumbers:E_,compile:k_,eigs:sp,fermiCoupling:C_,leafCount:H_,mean:O_,molarVolume:D_,planckConstant:T_,setSymDifference:up,simplify:Wa,symbolicEqual:G_,classicalElectronRadius:B_,evaluate:to,help:V_,lusolve:__,median:cp,rationalize:Z_,setUnion:$_,variance:ji,derivative:X_,kldivergence:I_,norm:fp,planckTime:q_,rotationMatrix:lp,gasConstant:R_,parser:Y_,std:F_,mad:z_,rotate:P_,config:oe}),rr(Xn,Sn,{filter:_D({typed:Z}),forEach:qD({typed:Z}),map:LD({typed:Z}),apply:ED({isInteger:Vr,typed:Z}),diff:fT({bignumber:Mt,matrix:de,number:Ft,subtract:ir,typed:Z}),subset:iT({matrix:de,typed:Z}),concat:uT({isInteger:Vr,matrix:de,typed:Z}),max:GD({config:oe,larger:Yr,numeric:et,typed:Z}),min:JD({config:oe,numeric:et,smaller:Zr,typed:Z}),range:jD({bignumber:Mt,matrix:de,config:oe,larger:Yr,largerEq:Za,smaller:Zr,smallerEq:Ji,typed:Z}),sum:hT({add:sr,config:oe,numeric:et,typed:Z}),cumsum:gT({add:sr,typed:Z,unaryPlus:ki}),row:tT({Index:Sr,matrix:de,range:Zn,typed:Z}),column:DD({Index:Sr,matrix:de,range:Zn,typed:Z}),index:zD({Index:Sr}),mean:XD({add:sr,divide:tt,typed:Z}),variance:xT({add:sr,apply:Gi,divide:tt,isNaN:kn,multiply:mr,subtract:ir,typed:Z}),std:pT({sqrt:St,typed:Z,variance:ji})}),rr(mp,{BigNumber:le,Chain:eo,Complex:tr,Fraction:Xt,Matrix:La,Node:Er,ObjectNode:Yn,OperatorNode:zt,ParenthesisNode:Jt,Range:OT,RelationalNode:pp,ResultSet:Am,ArrayNode:Wn,BlockNode:vp,ConditionalNode:hp,ConstantNode:Qt,DenseMatrix:ze,RangeNode:dp,FunctionAssignmentNode:gp,SparseMatrix:At,AccessorNode:Jn,AssignmentNode:yp,IndexNode:Qn,FibonacciHeap:Jm,ImmutableDenseMatrix:Km,Index:Sr,Spa:tp,Unit:Te,SymbolNode:Kt,FunctionNode:jt,Help:bp,Parser:wp}),eo.createProxy(Sn);const W_={label:"Math.js",tooltip:"{{t('Math.js comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types.')}}",link:"https://mathjs.org/",evaluate:ht.evaluate.bind(function(e,n={}){const a=to(e,n);return typeof a=="number"?Number.isNaN(a)||!Number.isFinite(a)?null:Vn(a,9):a},{replaceKey:!0})};class Np extends pr.Plugin{load(){return Mp(this,null,function*(){nt.register("math.js",W_)})}}ur.PluginMathjsEvaluatorClient=Np,ur.default=Np,Object.defineProperties(ur,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
70
+ In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},cE={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},fE={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},lE={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mE={name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},pE={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},vE={name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},hE={name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},dE={name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},gE={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},yE={name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},xE={name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},bE={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},wE={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},NE={name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},ME={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},AE={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},SE={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},EE={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},CE={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},OE={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},DE={name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},TE={name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},BE={name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},_E={name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},$E={name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},IE={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},qE={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},RE={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},FE={name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},zE={name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},PE={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},UE={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},LE={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},kE={name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},HE={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},GE={name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},VE={name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},ZE={name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},XE={name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},YE={name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},WE={name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},JE={name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},QE={name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]},KE={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},jE={name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},eC={name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},rC={bignumber:r2,boolean:t2,complex:n2,createUnit:a2,fraction:i2,index:o2,matrix:s2,number:u2,sparse:c2,splitUnit:f2,string:l2,unit:m2,e:dl,E:dl,false:UM,i:LM,Infinity:kM,LN2:GM,LN10:HM,LOG2E:ZM,LOG10E:VM,NaN:XM,null:YM,pi:gl,PI:gl,phi:WM,SQRT1_2:JM,SQRT2:QM,tau:KM,true:jM,version:e2,speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:d2,lsolve:y2,lsolveAll:x2,lup:b2,lusolve:w2,leafCount:g2,resolve:A2,simplify:S2,simplifyCore:E2,symbolicEqual:O2,rationalize:M2,slu:C2,usolve:D2,usolveAll:T2,qr:N2,abs:B2,add:_2,cbrt:$2,ceil:I2,cube:q2,divide:R2,dotDivide:F2,dotMultiply:z2,dotPow:P2,exp:U2,expm:L2,expm1:k2,fix:H2,floor:G2,gcd:V2,hypot:Z2,lcm:Y2,log:W2,log2:K2,log1p:Q2,log10:J2,mod:j2,multiply:eA,norm:rA,nthRoot:tA,nthRoots:nA,pow:aA,round:iA,sign:oA,sqrt:sA,sqrtm:uA,square:cA,subtract:fA,unaryMinus:lA,unaryPlus:mA,xgcd:pA,invmod:X2,bitAnd:vA,bitNot:hA,bitOr:dA,bitXor:gA,leftShift:yA,rightArithShift:xA,rightLogShift:bA,bellNumbers:wA,catalan:NA,composition:MA,stirlingS2:AA,config:p2,import:v2,typed:h2,arg:SA,conj:EA,re:OA,im:CA,evaluate:DA,help:TA,distance:BA,intersect:_A,and:$A,not:IA,or:qA,xor:RA,concat:zA,count:PA,cross:UA,column:FA,ctranspose:LA,det:kA,diag:HA,diff:GA,dot:VA,getMatrixDataType:JA,identity:QA,filter:XA,flatten:YA,forEach:WA,inv:KA,pinv:jA,eigs:ZA,kron:eS,matrixFromFunction:nS,matrixFromRows:aS,matrixFromColumns:tS,map:rS,ones:iS,partitionSelect:oS,range:sS,resize:cS,reshape:uS,rotate:fS,rotationMatrix:lS,row:mS,size:pS,sort:vS,squeeze:hS,subset:dS,trace:gS,transpose:yS,zeros:xS,fft:bS,ifft:wS,combinations:NS,combinationsWithRep:MS,factorial:AS,gamma:SS,kldivergence:CS,lgamma:ES,multinomial:OS,permutations:DS,pickRandom:TS,random:BS,randomInt:_S,compare:$S,compareNatural:IS,compareText:qS,deepEqual:RS,equal:FS,equalText:zS,larger:PS,largerEq:US,smaller:LS,smallerEq:kS,unequal:HS,setCartesian:GS,setDifference:VS,setDistinct:ZS,setIntersect:XS,setIsSubset:YS,setMultiplicity:WS,setPowerset:JS,setSize:QS,setSymDifference:KS,setUnion:jS,erf:eE,cumsum:fE,mad:rE,max:tE,mean:nE,median:aE,min:iE,mode:oE,prod:sE,quantileSeq:uE,std:cE,sum:lE,variance:mE,acos:pE,acosh:vE,acot:hE,acoth:dE,acsc:gE,acsch:yE,asec:xE,asech:bE,asin:wE,asinh:NE,atan:ME,atanh:SE,atan2:AE,cos:EE,cosh:CE,cot:OE,coth:DE,csc:TE,csch:BE,sec:_E,sech:$E,sin:IE,sinh:qE,tan:RE,tanh:FE,to:zE,clone:UE,format:LE,bin:PE,oct:KE,hex:HE,isNaN:VE,isInteger:GE,isNegative:ZE,isNumeric:XE,hasNumericValue:kE,isPositive:YE,isPrime:WE,isZero:JE,print:jE,typeOf:eC,numeric:QE},yl="help",tC=["typed","mathWithTransform","Help"],nC=R(yl,tC,e=>{var{typed:n,mathWithTransform:a,Help:t}=e;return n(yl,{any:function(i){var l,m=i;if(typeof i!="string"){for(l in a)if(Me(a,l)&&i===a[l]){m=l;break}}var f=Vr(rC,m);if(!f){var c=typeof m=="function"?m.name:m;throw new Error('No documentation found on "'+c+'"')}return new t(f)}})}),xl="chain",aC=["typed","Chain"],iC=R(xl,aC,e=>{var{typed:n,Chain:a}=e;return n(xl,{"":function(){return new a},any:function(r){return new a(r)}})}),bl="det",oC=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],sC=R(bl,oC,e=>{var{typed:n,matrix:a,subtract:t,multiply:r,divideScalar:i,isZero:l,unaryMinus:m}=e;return n(bl,{any:function(s){return Ce(s)},"Array | Matrix":function(s){var o;switch(Oe(s)?o=s.size():Array.isArray(s)?(s=a(s),o=s.size()):o=[],o.length){case 0:return Ce(s);case 1:if(o[0]===1)return Ce(s.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Re(o)+")");case 2:{var u=o[0],p=o[1];if(u===p)return f(s.clone().valueOf(),u);throw new RangeError("Matrix must be square (size: "+Re(o)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(o)+")")}}});function f(c,s,o){if(s===1)return Ce(c[0][0]);if(s===2)return t(r(c[0][0],c[1][1]),r(c[1][0],c[0][1]));for(var u=!1,p=new Array(s).fill(0).map((A,S)=>S),v=0;v<s;v++){var h=p[v];if(l(c[h][v])){var b=void 0;for(b=v+1;b<s;b++)if(!l(c[p[b]][v])){h=p[b],p[b]=p[v],p[v]=h,u=!u;break}if(b===s)return c[h][v]}for(var w=c[h][v],N=v===0?1:c[p[v-1]][v-1],g=v+1;g<s;g++)for(var y=p[g],x=v+1;x<s;x++)c[y][x]=i(t(r(c[y][x],w),r(c[y][v],c[h][x])),N)}var d=c[p[s-1]][s-1];return u?m(d):d}}),wl="inv",uC=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],cC=R(wl,uC,e=>{var{typed:n,matrix:a,divideScalar:t,addScalar:r,multiply:i,unaryMinus:l,det:m,identity:f,abs:c}=e;return n(wl,{"Array | Matrix":function(u){var p=Oe(u)?u.size():Pe(u);switch(p.length){case 1:if(p[0]===1)return Oe(u)?a([t(1,u.valueOf()[0])]):[t(1,u[0])];throw new RangeError("Matrix must be square (size: "+Re(p)+")");case 2:{var v=p[0],h=p[1];if(v===h)return Oe(u)?a(s(u.valueOf(),v,h),u.storage()):s(u,v,h);throw new RangeError("Matrix must be square (size: "+Re(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(p)+")")}},any:function(u){return t(1,u)}});function s(o,u,p){var v,h,b,w,N;if(u===1){if(w=o[0][0],w===0)throw Error("Cannot calculate inverse, determinant is zero");return[[t(1,w)]]}else if(u===2){var g=m(o);if(g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[t(o[1][1],g),t(l(o[0][1]),g)],[t(l(o[1][0]),g),t(o[0][0],g)]]}else{var y=o.concat();for(v=0;v<u;v++)y[v]=y[v].concat();for(var x=f(u).valueOf(),d=0;d<p;d++){var A=c(y[d][d]),S=d;for(v=d+1;v<u;)c(y[v][d])>A&&(A=c(y[v][d]),S=v),v++;if(A===0)throw Error("Cannot calculate inverse, determinant is zero");v=S,v!==d&&(N=y[d],y[d]=y[v],y[v]=N,N=x[d],x[d]=x[v],x[v]=N);var O=y[d],M=x[d];for(v=0;v<u;v++){var _=y[v],E=x[v];if(v!==d){if(_[d]!==0){for(b=t(l(_[d]),O[d]),h=d;h<p;h++)_[h]=r(_[h],i(b,O[h]));for(h=0;h<p;h++)E[h]=r(E[h],i(b,M[h]))}}else{for(b=O[d],h=d;h<p;h++)_[h]=t(_[h],b);for(h=0;h<p;h++)E[h]=t(E[h],b)}}}return x}}}),Nl="pinv",fC=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],lC=R(Nl,fC,e=>{var{typed:n,matrix:a,inv:t,deepEqual:r,equal:i,dotDivide:l,dot:m,ctranspose:f,divideScalar:c,multiply:s,add:o,Complex:u}=e;return n(Nl,{"Array | Matrix":function(g){var y=Oe(g)?g.size():Pe(g);switch(y.length){case 1:return w(g)?f(g):y[0]===1?t(g):l(f(g),m(g,g));case 2:{if(w(g))return f(g);var x=y[0],d=y[1];if(x===d)try{return t(g)}catch(A){if(!(A instanceof Error&&A.message.match(/Cannot calculate inverse, determinant is zero/)))throw A}return Oe(g)?a(p(g.valueOf(),x,d),g.storage()):p(g,x,d)}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(y)+")")}},any:function(g){return i(g,0)?Ce(g):c(1,g)}});function p(N,g,y){var{C:x,F:d}=h(N,g,y),A=s(t(s(f(x),x)),f(x)),S=s(f(d),t(s(d,f(d))));return s(S,A)}function v(N,g,y){for(var x=Ce(N),d=0,A=0;A<g;A++){if(y<=d)return x;for(var S=A;b(x[S][d]);)if(S++,g===S&&(S=A,d++,y===d))return x;[x[S],x[A]]=[x[A],x[S]];for(var O=x[A][d],M=0;M<y;M++)x[A][M]=l(x[A][M],O);for(var _=0;_<g;_++)if(_!==A){O=x[_][d];for(var E=0;E<y;E++)x[_][E]=o(x[_][E],s(-1,s(O,x[A][E])))}d++}return x}function h(N,g,y){var x=v(N,g,y),d=N.map((S,O)=>S.filter((M,_)=>_<g&&!b(m(x[_],x[_])))),A=x.filter((S,O)=>!b(m(x[O],x[O])));return{C:d,F:A}}function b(N){return i(o(N,u(1,1)),o(0,u(1,1)))}function w(N){return r(o(N,u(1,1)),o(s(N,0),u(1,1)))}});function mC(e){var{addScalar:n,subtract:a,flatten:t,multiply:r,multiplyScalar:i,divideScalar:l,sqrt:m,abs:f,bignumber:c,diag:s,inv:o,qr:u,usolve:p,usolveAll:v,equal:h,complex:b,larger:w,smaller:N,matrixFromColumns:g,dot:y}=e;function x(H,W,j,V,K){K===void 0&&(K=!0);var te=d(H,W,j,V,K);A(H,W,j,V,K,te);var{values:re,C:ie}=S(H,W,j,V,K),ne;return K&&(ne=O(H,W,ie,te,re,j,V),ne=g(...ne)),{values:re,vectors:ne}}function d(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",ie=te?c(0):0,ne=te?c(1):re?b(1):1,ue=te?c(1):1,ee=te?c(10):2,ye=i(ee,ee),we;K&&(we=Array(W).fill(ne));for(var me=!1;!me;){me=!0;for(var xe=0;xe<W;xe++){for(var F=ie,Y=ie,k=0;k<W;k++)if(xe!==k){var U=f(H[xe][k]);F=n(F,U),Y=n(Y,U)}if(!h(F,0)&&!h(Y,0)){for(var J=ue,q=F,P=l(Y,ee),Q=i(Y,ee);N(q,P);)q=i(q,ye),J=i(J,ee);for(;w(q,Q);)q=l(q,ye),J=l(J,ee);var L=N(l(n(q,Y),J),i(n(F,Y),.95));if(L){me=!1;for(var se=l(1,J),fe=0;fe<W;fe++)xe!==fe&&(H[xe][fe]=i(H[xe][fe],J),H[fe][xe]=i(H[fe][xe],se));K&&(we[xe]=i(we[xe],J))}}}}return s(we)}function A(H,W,j,V,K,te){var re=V==="BigNumber",ie=V==="Complex",ne=re?c(0):ie?b(0):0;re&&(j=c(j));for(var ue=0;ue<W-2;ue++){for(var ee=0,ye=ne,we=ue+1;we<W;we++){var me=H[we][ue];N(f(ye),f(me))&&(ye=me,ee=we)}if(!N(f(ye),j)){if(ee!==ue+1){var xe=H[ee];H[ee]=H[ue+1],H[ue+1]=xe;for(var F=0;F<W;F++){var Y=H[F][ee];H[F][ee]=H[F][ue+1],H[F][ue+1]=Y}if(K){var k=te[ee];te[ee]=te[ue+1],te[ue+1]=k}}for(var U=ue+2;U<W;U++){var J=l(H[U][ue],ye);if(J!==0){for(var q=0;q<W;q++)H[U][q]=a(H[U][q],i(J,H[ue+1][q]));for(var P=0;P<W;P++)H[P][ue+1]=n(H[P][ue+1],i(J,H[P][U]));if(K)for(var Q=0;Q<W;Q++)te[U][Q]=a(te[U][Q],i(J,te[ue+1][Q]))}}}}return te}function S(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",ie=te?c(1):re?b(1):1;te&&(j=c(j));for(var ne=Ce(H),ue=[],ee=W,ye=[],we=K?s(Array(W).fill(ie)):void 0,me=K?s(Array(ee).fill(ie)):void 0,xe=0;xe<=100;){xe+=1;for(var F=0,Y=0;Y<ee;Y++)ne[Y][Y]=a(ne[Y][Y],F);var{Q:k,R:U}=u(ne);ne=r(U,k);for(var J=0;J<ee;J++)ne[J][J]=n(ne[J][J],F);if(K&&(me=r(me,k)),ee===1||N(f(ne[ee-1][ee-2]),j)){xe=0,ue.push(ne[ee-1][ee-1]),K&&(ye.unshift([[1]]),E(me,W),we=r(we,me),ee>1&&(me=s(Array(ee-1).fill(ie)))),ee-=1,ne.pop();for(var q=0;q<ee;q++)ne[q].pop()}else if(ee===2||N(f(ne[ee-2][ee-3]),j)){xe=0;var P=M(ne[ee-2][ee-2],ne[ee-2][ee-1],ne[ee-1][ee-2],ne[ee-1][ee-1]);ue.push(...P),K&&(ye.unshift(_(ne[ee-2][ee-2],ne[ee-2][ee-1],ne[ee-1][ee-2],ne[ee-1][ee-1],P[0],P[1],j,V)),E(me,W),we=r(we,me),ee>2&&(me=s(Array(ee-2).fill(ie)))),ee-=2,ne.pop(),ne.pop();for(var Q=0;Q<ee;Q++)ne[Q].pop(),ne[Q].pop()}if(ee===0)break}if(ue.sort((fe,ge)=>+a(f(fe),f(ge))),xe>100){var L=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ue.join(", "));throw L.values=ue,L.vectors=[],L}var se=K?r(we,$(ye,W)):void 0;return{values:ue,C:se}}function O(H,W,j,V,K,te,re){var ie=o(j),ne=r(ie,H,j),ue=re==="BigNumber",ee=re==="Complex",ye=ue?c(0):ee?b(0):0,we=ue?c(1):ee?b(1):1,me=[],xe=[];for(var F of K){var Y=z(me,F,h);Y===-1?(me.push(F),xe.push(1)):xe[Y]+=1}for(var k=[],U=me.length,J=Array(W).fill(ye),q=s(Array(W).fill(we)),P=[],Q=function(ge){var pe=me[ge],ve=a(ne,r(pe,q)),Ne=v(ve,J);for(Ne.shift();Ne.length<xe[ge];){var Qe=I(ve,W,Ne,te,re);if(Qe==null){P.push(pe);break}Ne.push(Qe)}var cr=r(o(V),j);Ne=Ne.map(tr=>r(cr,tr)),k.push(...Ne.map(tr=>t(tr)))},L=0;L<U;L++)Q(L);if(P.length!==0){var se=new Error("Failed to find eigenvectors for the following eigenvalues: "+P.join(", "));throw se.values=K,se.vectors=k,se}return k}function M(H,W,j,V){var K=n(H,V),te=a(i(H,V),i(W,j)),re=i(K,.5),ie=i(m(a(i(K,K),i(4,te))),.5);return[n(re,ie),a(re,ie)]}function _(H,W,j,V,K,te,re,ie){var ne=ie==="BigNumber",ue=ie==="Complex",ee=ne?c(0):ue?b(0):0,ye=ne?c(1):ue?b(1):1;if(N(f(j),re))return[[ye,ee],[ee,ye]];if(w(f(a(K,te)),re))return[[a(K,V),a(te,V)],[j,j]];var we=a(H,K),me=a(W,K),xe=a(j,K),F=a(V,K);return N(f(me),re)?[[we,ye],[xe,ee]]:[[me,ee],[F,ye]]}function E(H,W){for(var j=0;j<H.length;j++)H[j].push(...Array(W-H[j].length).fill(0));for(var V=H.length;V<W;V++)H.push(Array(W).fill(0)),H[V][V]=1;return H}function $(H,W){for(var j=[],V=0;V<W;V++)j[V]=Array(W).fill(0);var K=0;for(var te of H){for(var re=te.length,ie=0;ie<re;ie++)for(var ne=0;ne<re;ne++)j[K+ie][K+ne]=te[ie][ne];K+=re}return j}function z(H,W,j){for(var V=0;V<H.length;V++)if(j(H[V],W))return V;return-1}function I(H,W,j,V,K){for(var te=K==="BigNumber"?c(1e3):1e3,re,ie=0;re=T(W,j,K),re=p(H,re),!w(G(re),te);)if(++ie>=5)return null;for(ie=0;;){var ne=p(H,re);if(N(G(B(re,[ne])),V))break;if(++ie>=10)return null;re=D(ne)}return re}function T(H,W,j){var V=j==="BigNumber",K=j==="Complex",te=Array(H).fill(0).map(re=>2*Math.random()-1);return V&&(te=te.map(re=>c(re))),K&&(te=te.map(re=>b(re))),te=B(te,W),D(te,j)}function B(H,W){for(var j of W)H=a(H,r(l(y(j,H),y(j,j)),j));return H}function G(H){return f(m(y(H,H)))}function D(H,W){var j=W==="BigNumber",V=W==="Complex",K=j?c(1):V?b(1):1;return r(l(K,G(H)),H)}return x}function pC(e){var{config:n,addScalar:a,subtract:t,abs:r,atan:i,cos:l,sin:m,multiplyScalar:f,inv:c,bignumber:s,multiply:o,add:u}=e;function p(M,_){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:n.epsilon,$=arguments.length>3?arguments[3]:void 0;if($==="number")return v(M,E);if($==="BigNumber")return h(M,E);throw TypeError("Unsupported data type: "+$)}function v(M,_){for(var E=M.length,$=Math.abs(_/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=d(M);Math.abs(B[1])>=Math.abs($);){var G=B[0][0],D=B[0][1];z=b(M[G][G],M[D][D],M[G][D]),M=x(M,z,G,D),I=N(I,z,G,D),B=d(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Ce(H),Ce(I))}function h(M,_){for(var E=M.length,$=r(_/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=A(M);r(B[1])>=r($);){var G=B[0][0],D=B[0][1];z=w(M[G][G],M[D][D],M[G][D]),M=y(M,z,G,D),I=g(I,z,G,D),B=A(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Ce(H),Ce(I))}function b(M,_,E){var $=_-M;return Math.abs($)<=n.epsilon?Math.PI/4:.5*Math.atan(2*E/(_-M))}function w(M,_,E){var $=t(_,M);return r($)<=n.epsilon?s(-1).acos().div(4):f(.5,i(o(2,E,c($))))}function N(M,_,E,$){for(var z=M.length,I=Math.cos(_),T=Math.sin(_),B=O(z,0),G=O(z,0),D=0;D<z;D++)B[D]=I*M[D][E]-T*M[D][$],G[D]=T*M[D][E]+I*M[D][$];for(var H=0;H<z;H++)M[H][E]=B[H],M[H][$]=G[H];return M}function g(M,_,E,$){for(var z=M.length,I=l(_),T=m(_),B=O(z,s(0)),G=O(z,s(0)),D=0;D<z;D++)B[D]=t(f(I,M[D][E]),f(T,M[D][$])),G[D]=a(f(T,M[D][E]),f(I,M[D][$]));for(var H=0;H<z;H++)M[H][E]=B[H],M[H][$]=G[H];return M}function y(M,_,E,$){for(var z=M.length,I=s(l(_)),T=s(m(_)),B=f(I,I),G=f(T,T),D=O(z,s(0)),H=O(z,s(0)),W=o(s(2),I,T,M[E][$]),j=a(t(f(B,M[E][E]),W),f(G,M[$][$])),V=u(f(G,M[E][E]),W,f(B,M[$][$])),K=0;K<z;K++)D[K]=t(f(I,M[E][K]),f(T,M[$][K])),H[K]=a(f(T,M[E][K]),f(I,M[$][K]));M[E][E]=j,M[$][$]=V,M[E][$]=s(0),M[$][E]=s(0);for(var te=0;te<z;te++)te!==E&&te!==$&&(M[E][te]=D[te],M[te][E]=D[te],M[$][te]=H[te],M[te][$]=H[te]);return M}function x(M,_,E,$){for(var z=M.length,I=Math.cos(_),T=Math.sin(_),B=I*I,G=T*T,D=O(z,0),H=O(z,0),W=B*M[E][E]-2*I*T*M[E][$]+G*M[$][$],j=G*M[E][E]+2*I*T*M[E][$]+B*M[$][$],V=0;V<z;V++)D[V]=I*M[E][V]-T*M[$][V],H[V]=T*M[E][V]+I*M[$][V];M[E][E]=W,M[$][$]=j,M[E][$]=0,M[$][E]=0;for(var K=0;K<z;K++)K!==E&&K!==$&&(M[E][K]=D[K],M[K][E]=D[K],M[$][K]=H[K],M[K][$]=H[K]);return M}function d(M){for(var _=M.length,E=0,$=[0,1],z=0;z<_;z++)for(var I=z+1;I<_;I++)Math.abs(E)<Math.abs(M[z][I])&&(E=Math.abs(M[z][I]),$=[z,I]);return[$,E]}function A(M){for(var _=M.length,E=0,$=[0,1],z=0;z<_;z++)for(var I=z+1;I<_;I++)r(E)<r(M[z][I])&&(E=r(M[z][I]),$=[z,I]);return[$,E]}function S(M,_){for(var E=M.length,$=Array(E),z=Array(E),I=0;I<E;I++)z[I]=Array(E);for(var T=0;T<E;T++){for(var B=0,G=M[0],D=0;D<M.length;D++)r(M[D])<r(G)&&(B=D,G=M[B]);$[T]=M.splice(B,1)[0];for(var H=0;H<E;H++)z[H][T]=_[H][B],_[H].splice(B,1)}return{values:$,vectors:z}}function O(M,_){for(var E=new Array(M),$=0;$<M;$++)E[$]=_;return E}return p}var vC="eigs",hC=["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],dC=R(vC,hC,e=>{var{config:n,typed:a,matrix:t,addScalar:r,subtract:i,equal:l,abs:m,atan:f,cos:c,sin:s,multiplyScalar:o,divideScalar:u,inv:p,bignumber:v,multiply:h,add:b,larger:w,column:N,flatten:g,number:y,complex:x,sqrt:d,diag:A,qr:S,usolve:O,usolveAll:M,im:_,re:E,smaller:$,matrixFromColumns:z,dot:I}=e,T=pC({config:n,addScalar:r,subtract:i,abs:m,atan:f,cos:c,sin:s,multiplyScalar:o,inv:p,bignumber:v,multiply:h,add:b}),B=mC({addScalar:r,subtract:i,multiply:h,multiplyScalar:o,flatten:g,divideScalar:u,sqrt:d,abs:m,bignumber:v,diag:A,qr:S,inv:p,usolve:O,usolveAll:M,equal:l,complex:x,larger:w,smaller:$,matrixFromColumns:z,dot:I});return a("eigs",{Array:function(K){var te=t(K);return G(te)},"Array, number|BigNumber":function(K,te){var re=t(K);return G(re,te)},Matrix:function(K){var{values:te,vectors:re}=G(K);return{values:t(te),vectors:t(re)}},"Matrix, number|BigNumber":function(K,te){var{values:re,vectors:ie}=G(K,te);return{values:t(re),vectors:t(ie)}}});function G(V,K){K===void 0&&(K=n.epsilon);var te=V.size();if(te.length!==2||te[0]!==te[1])throw new RangeError("Matrix must be square (size: "+Re(te)+")");var re=V.toArray(),ie=te[0];if(H(re,ie,K)&&(W(re,ie),D(re,ie,K))){var ne=j(V,re,ie);return T(re,ie,K,ne)}var ue=j(V,re,ie);return B(re,ie,K,ue)}function D(V,K,te){for(var re=0;re<K;re++)for(var ie=re;ie<K;ie++)if(w(v(m(i(V[re][ie],V[ie][re]))),te))return!1;return!0}function H(V,K,te){for(var re=0;re<K;re++)for(var ie=0;ie<K;ie++)if(w(v(m(_(V[re][ie]))),te))return!1;return!0}function W(V,K){for(var te=0;te<K;te++)for(var re=0;re<K;re++)V[te][re]=E(V[te][re])}function j(V,K,te){var re=V.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var ie=!1,ne=!1,ue=!1,ee=0;ee<te;ee++)for(var ye=0;ye<te;ye++){var we=K[ee][ye];if(Be(we)||yr(we))ie=!0;else if(_e(we))ne=!0;else if(Or(we))ue=!0;else throw TypeError("Unsupported type in Matrix: "+Ke(we))}if(ne&&ue&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ue){for(var me=0;me<te;me++)for(var xe=0;xe<te;xe++)K[me][xe]=x(K[me][xe]);return"Complex"}if(ne){for(var F=0;F<te;F++)for(var Y=0;Y<te;Y++)K[F][Y]=v(K[F][Y]);return"BigNumber"}if(ie){for(var k=0;k<te;k++)for(var U=0;U<te;U++)K[k][U]=y(K[k][U]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Ml="expm",gC=["typed","abs","add","identity","inv","multiply"],yC=R(Ml,gC,e=>{var{typed:n,abs:a,add:t,identity:r,inv:i,multiply:l}=e;return n(Ml,{Matrix:function(o){var u=o.size();if(u.length!==2||u[0]!==u[1])throw new RangeError("Matrix must be square (size: "+Re(u)+")");for(var p=u[0],v=1e-15,h=m(o),b=f(h,v),w=b.q,N=b.j,g=l(o,Math.pow(2,-N)),y=r(p),x=r(p),d=1,A=g,S=-1,O=1;O<=w;O++)O>1&&(A=l(A,g),S=-S),d=d*(w-O+1)/((2*w-O+1)*O),y=t(y,l(d,A)),x=t(x,l(d*S,A));for(var M=l(i(x),y),_=0;_<N;_++)M=l(M,M);return Ut(o)?o.createSparseMatrix(M):M}});function m(s){for(var o=s.size()[0],u=0,p=0;p<o;p++){for(var v=0,h=0;h<o;h++)v+=a(s.get([p,h]));u=Math.max(v,u)}return u}function f(s,o){for(var u=30,p=0;p<u;p++)for(var v=0;v<=p;v++){var h=p-v;if(c(s,v,h)<o)return{q:v,j:h}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function c(s,o,u){for(var p=1,v=2;v<=o;v++)p*=v;for(var h=p,b=o+1;b<=2*o;b++)h*=b;var w=h*(2*o+1);return 8*Math.pow(s/Math.pow(2,u),2*o)*p*p/(h*w)}}),Al="sqrtm",xC=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],bC=R(Al,xC,e=>{var{typed:n,abs:a,add:t,multiply:r,sqrt:i,subtract:l,inv:m,size:f,max:c,identity:s}=e,o=1e3,u=1e-6;function p(v){var h,b=0,w=v,N=s(f(v));do{var g=w;if(w=r(.5,t(g,m(N))),N=r(.5,t(N,m(g))),h=c(a(l(w,g))),h>u&&++b>o)throw new Error("computing square root of matrix: iterative method could not converge")}while(h>u);return w}return n(Al,{"Array | Matrix":function(h){var b=Oe(h)?h.size():Pe(h);switch(b.length){case 1:if(b[0]===1)return i(h);throw new RangeError("Matrix must be square (size: "+Re(b)+")");case 2:{var w=b[0],N=b[1];if(w===N)return p(h);throw new RangeError("Matrix must be square (size: "+Re(b)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Re(b)+")")}}})}),wC="divide",NC=["typed","matrix","multiply","equalScalar","divideScalar","inv"],MC=R(wC,NC,e=>{var{typed:n,matrix:a,multiply:t,equalScalar:r,divideScalar:i,inv:l}=e,m=wr({typed:n,equalScalar:r}),f=Ge({typed:n});return n("divide",Ka({"Array | Matrix, Array | Matrix":function(s,o){return t(s,l(o))},"DenseMatrix, any":function(s,o){return f(s,o,i,!1)},"SparseMatrix, any":function(s,o){return m(s,o,i,!1)},"Array, any":function(s,o){return f(a(s),o,i,!1).valueOf()},"any, Array | Matrix":function(s,o){return t(s,l(o))}},i.signatures))}),Sl="distance",AC=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],SC=R(Sl,AC,e=>{var{typed:n,addScalar:a,subtract:t,multiplyScalar:r,divideScalar:i,unaryMinus:l,sqrt:m,abs:f}=e;return n(Sl,{"Array, Array, Array":function(x,d,A){if(x.length===2&&d.length===2&&A.length===2){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(d))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(A))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var S=i(t(A[1],A[0]),t(d[1],d[0])),O=r(r(S,S),d[0]),M=l(r(S,d[0])),_=x[1];return b(x[0],x[1],O,M,_)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,d,A){if(Object.keys(x).length===2&&Object.keys(d).length===2&&Object.keys(A).length===2){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(A))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in d&&"lineOnePtY"in d&&"lineTwoPtX"in A&&"lineTwoPtY"in A){var S=i(t(A.lineTwoPtY,A.lineTwoPtX),t(d.lineOnePtY,d.lineOnePtX)),O=r(r(S,S),d.lineOnePtX),M=l(r(S,d.lineOnePtX)),_=x.pointX;return b(x.pointX,x.pointY,O,M,_)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,d){if(x.length===2&&d.length===3){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!o(d))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return b(x[0],x[1],d[0],d[1],d[2])}else if(x.length===3&&d.length===6){if(!o(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!p(d))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return w(x[0],x[1],x[2],d[0],d[1],d[2],d[3],d[4],d[5])}else if(x.length===d.length&&x.length>0){if(!u(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!u(d))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,d)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,d){if(Object.keys(x).length===2&&Object.keys(d).length===3){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in d&&"yCoeffLine"in d&&"constant"in d)return b(x.pointX,x.pointY,d.xCoeffLine,d.yCoeffLine,d.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===6){if(!o(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!p(d))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"x0"in d&&"y0"in d&&"z0"in d&&"a"in d&&"b"in d&&"c"in d)return w(x.pointX,x.pointY,x.pointZ,d.x0,d.y0,d.z0,d.a,d.b,d.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(d).length===2){if(!s(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in d&&"pointTwoY"in d)return N([x.pointOneX,x.pointOneY],[d.pointTwoX,d.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===3){if(!o(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointOneZ"in x&&"pointTwoX"in d&&"pointTwoY"in d&&"pointTwoZ"in d)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[d.pointTwoX,d.pointTwoY,d.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!h(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return g(x)}});function c(y){return typeof y=="number"||_e(y)}function s(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])}function o(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])}function u(y){return Array.isArray(y)||(y=v(y)),y.every(c)}function p(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])&&c(y[3])&&c(y[4])&&c(y[5])}function v(y){for(var x=Object.keys(y),d=[],A=0;A<x.length;A++)d.push(y[x[A]]);return d}function h(y){if(y[0].length===2&&c(y[0][0])&&c(y[0][1])){if(y.some(x=>x.length!==2||!c(x[0])||!c(x[1])))return!1}else if(y[0].length===3&&c(y[0][0])&&c(y[0][1])&&c(y[0][2])){if(y.some(x=>x.length!==3||!c(x[0])||!c(x[1])||!c(x[2])))return!1}else return!1;return!0}function b(y,x,d,A,S){var O=f(a(a(r(d,y),r(A,x)),S)),M=m(a(r(d,d),r(A,A)));return i(O,M)}function w(y,x,d,A,S,O,M,_,E){var $=[t(r(t(S,x),E),r(t(O,d),_)),t(r(t(O,d),M),r(t(A,y),E)),t(r(t(A,y),_),r(t(S,x),M))];$=m(a(a(r($[0],$[0]),r($[1],$[1])),r($[2],$[2])));var z=m(a(a(r(M,M),r(_,_)),r(E,E)));return i($,z)}function N(y,x){for(var d=y.length,A=0,S=0,O=0;O<d;O++)S=t(y[O],x[O]),A=a(r(S,S),A);return m(A)}function g(y){for(var x=[],d=[],A=[],S=0;S<y.length-1;S++)for(var O=S+1;O<y.length;O++)y[0].length===2?(d=[y[S][0],y[S][1]],A=[y[O][0],y[O][1]]):y[0].length===3&&(d=[y[S][0],y[S][1],y[S][2]],A=[y[O][0],y[O][1],y[O][2]]),x.push(N(d,A));return x}}),EC="intersect",CC=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],OC=R(EC,CC,e=>{var{typed:n,config:a,abs:t,add:r,addScalar:i,matrix:l,multiply:m,multiplyScalar:f,divideScalar:c,subtract:s,smaller:o,equalScalar:u,flatten:p,isZero:v,isNumeric:h}=e;return n("intersect",{"Array, Array, Array":b,"Array, Array, Array, Array":w,"Matrix, Matrix, Matrix":function(_,E,$){var z=b(_.valueOf(),E.valueOf(),$.valueOf());return z===null?null:l(z)},"Matrix, Matrix, Matrix, Matrix":function(_,E,$,z){var I=w(_.valueOf(),E.valueOf(),$.valueOf(),z.valueOf());return I===null?null:l(I)}});function b(M,_,E){if(M=N(M),_=N(_),E=N(E),!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(E))throw new TypeError("Array with 4 numbers expected as third argument");return O(M[0],M[1],M[2],_[0],_[1],_[2],E[0],E[1],E[2],E[3])}function w(M,_,E,$){if(M=N(M),_=N(_),E=N(E),$=N($),M.length===2){if(!g(M))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!g(_))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!g(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!g($))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return d(M,_,E,$)}else if(M.length===3){if(!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(E))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y($))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return S(M[0],M[1],M[2],_[0],_[1],_[2],E[0],E[1],E[2],$[0],$[1],$[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function N(M){return M.length===1?M[0]:M.length>1&&Array.isArray(M[0])&&M.every(_=>Array.isArray(_)&&_.length===1)?p(M):M}function g(M){return M.length===2&&h(M[0])&&h(M[1])}function y(M){return M.length===3&&h(M[0])&&h(M[1])&&h(M[2])}function x(M){return M.length===4&&h(M[0])&&h(M[1])&&h(M[2])&&h(M[3])}function d(M,_,E,$){var z=M,I=E,T=s(z,_),B=s(I,$),G=s(f(T[0],B[1]),f(B[0],T[1]));if(v(G)||o(t(G),a.epsilon))return null;var D=f(B[0],z[1]),H=f(B[1],z[0]),W=f(B[0],I[1]),j=f(B[1],I[0]),V=c(i(s(s(D,H),W),j),G);return r(m(T,V),z)}function A(M,_,E,$,z,I,T,B,G,D,H,W){var j=f(s(M,_),s(E,$)),V=f(s(z,I),s(T,B)),K=f(s(G,D),s(H,W));return i(i(j,V),K)}function S(M,_,E,$,z,I,T,B,G,D,H,W){var j=A(M,T,D,T,_,B,H,B,E,G,W,G),V=A(D,T,$,M,H,B,z,_,W,G,I,E),K=A(M,T,$,M,_,B,z,_,E,G,I,E),te=A(D,T,D,T,H,B,H,B,W,G,W,G),re=A($,M,$,M,z,_,z,_,I,E,I,E),ie=s(f(j,V),f(K,te)),ne=s(f(re,te),f(V,V));if(v(ne))return null;var ue=c(ie,ne),ee=c(i(j,f(ue,V)),te),ye=i(M,f(ue,s($,M))),we=i(_,f(ue,s(z,_))),me=i(E,f(ue,s(I,E))),xe=i(T,f(ee,s(D,T))),F=i(B,f(ee,s(H,B))),Y=i(G,f(ee,s(W,G)));return u(ye,xe)&&u(we,F)&&u(me,Y)?[ye,we,me]:null}function O(M,_,E,$,z,I,T,B,G,D){var H=f(M,T),W=f($,T),j=f(_,B),V=f(z,B),K=f(E,G),te=f(I,G),re=s(s(s(D,H),j),K),ie=s(s(s(i(i(W,V),te),H),j),K),ne=c(re,ie),ue=i(M,f(ne,s($,M))),ee=i(_,f(ne,s(z,_))),ye=i(E,f(ne,s(I,E)));return[ue,ee,ye]}}),El="sum",DC=["typed","config","add","numeric"],Cl=R(El,DC,e=>{var{typed:n,config:a,add:t,numeric:r}=e;return n(El,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":l,"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function sum");return i(f)}});function i(m){var f;return bt(m,function(c){try{f=f===void 0?c:t(f,c)}catch(s){throw Tr(s,"sum",c)}}),f===void 0&&(f=r(0,a.number)),typeof f=="string"&&(f=r(f,a.number)),f}function l(m,f){try{var c=xa(m,f,t);return c}catch(s){throw Tr(s,"sum")}}}),Ba="cumsum",TC=["typed","add","unaryPlus"],Ol=R(Ba,TC,e=>{var{typed:n,add:a,unaryPlus:t}=e;return n(Ba,{Array:r,Matrix:function(c){return c.create(r(c.valueOf()))},"Array, number | BigNumber":l,"Matrix, number | BigNumber":function(c,s){return c.create(l(c.valueOf(),s))},"...":function(c){if(mn(c))throw new TypeError("All values expected to be scalar in function cumsum");return r(c)}});function r(f){try{return i(f)}catch(c){throw Tr(c,Ba)}}function i(f){if(f.length===0)return[];for(var c=[t(f[0])],s=1;s<f.length;++s)c.push(a(c[s-1],f[s]));return c}function l(f,c){var s=Pe(f);if(c<0||c>=s.length)throw new Kr(c,s.length);try{return m(f,c)}catch(o){throw Tr(o,Ba)}}function m(f,c){var s,o,u;if(c<=0){var p=f[0][0];if(Array.isArray(p)){for(u=Ho(f),o=[],s=0;s<u.length;s++)o[s]=m(u[s],c-1);return o}else return i(f)}else{for(o=[],s=0;s<f.length;s++)o[s]=m(f[s],c-1);return o}}}),Dl="mean",BC=["typed","add","divide"],Tl=R(Dl,BC,e=>{var{typed:n,add:a,divide:t}=e;return n(Dl,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":r,"...":function(m){if(mn(m))throw new TypeError("Scalar values expected in function mean");return i(m)}});function r(l,m){try{var f=xa(l,m,a),c=Array.isArray(l)?Pe(l):l.size();return t(f,c[m])}catch(s){throw Tr(s,"mean")}}function i(l){var m,f=0;if(bt(l,function(c){try{m=m===void 0?c:a(m,c),f++}catch(s){throw Tr(s,"mean",c)}}),f===0)throw new Error("Cannot calculate the mean of an empty array");return t(m,f)}}),Bl="median",_C=["typed","add","divide","compare","partitionSelect"],$C=R(Bl,_C,e=>{var{typed:n,add:a,divide:t,compare:r,partitionSelect:i}=e;function l(c){try{c=Le(c.valueOf());var s=c.length;if(s===0)throw new Error("Cannot calculate median of an empty array");if(s%2===0){for(var o=s/2-1,u=i(c,o+1),p=c[o],v=0;v<o;++v)r(c[v],p)>0&&(p=c[v]);return f(p,u)}else{var h=i(c,(s-1)/2);return m(h)}}catch(b){throw Tr(b,"median")}}var m=n({"number | BigNumber | Complex | Unit":function(s){return s}}),f=n({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(s,o){return t(a(s,o),2)}});return n(Bl,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(s,o){throw new Error("median(A, dim) is not yet supported")},"...":function(s){if(mn(s))throw new TypeError("Scalar values expected in function median");return l(s)}})}),_l="mad",IC=["typed","abs","map","median","subtract"],qC=R(_l,IC,e=>{var{typed:n,abs:a,map:t,median:r,subtract:i}=e;return n(_l,{"Array | Matrix":l,"...":function(f){return l(f)}});function l(m){if(m=Le(m.valueOf()),m.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var f=r(m);return r(t(m,function(c){return a(i(c,f))}))}catch(c){throw c instanceof TypeError&&c.message.indexOf("median")!==-1?new TypeError(c.message.replace("median","mad")):Tr(c,"mad")}}}),qi="unbiased",$l="variance",RC=["typed","add","subtract","multiply","divide","apply","isNaN"],Il=R($l,RC,e=>{var{typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m}=e;return n($l,{"Array | Matrix":function(o){return f(o,qi)},"Array | Matrix, string":f,"Array | Matrix, number | BigNumber":function(o,u){return c(o,u,qi)},"Array | Matrix, number | BigNumber, string":c,"...":function(o){return f(o,qi)}});function f(s,o){var u,p=0;if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(bt(s,function(b){try{u=u===void 0?b:a(u,b),p++}catch(w){throw Tr(w,"variance",b)}}),p===0)throw new Error("Cannot calculate variance of an empty array");var v=i(u,p);if(u=void 0,bt(s,function(b){var w=t(b,v);u=u===void 0?r(w,w):a(u,r(w,w))}),m(u))return u;switch(o){case"uncorrected":return i(u,p);case"biased":return i(u,p+1);case"unbiased":{var h=_e(u)?u.mul(0):0;return p===1?h:i(u,p-1)}default:throw new Error('Unknown normalization "'+o+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(s,o,u){try{if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return l(s,o,p=>f(p,u))}catch(p){throw Tr(p,"variance")}}}),FC="quantileSeq",zC=["typed","add","multiply","partitionSelect","compare"],PC=R(FC,zC,e=>{var{typed:n,add:a,multiply:t,partitionSelect:r,compare:i}=e;function l(c,s,o){var u,p,v;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(rn(c)){if(o=o||!1,typeof o=="boolean"){if(p=c.valueOf(),Be(s)){if(s<0)throw new Error("N/prob must be non-negative");if(s<=1)return m(p,s,o);if(s>1){if(!Ae(s))throw new Error("N must be a positive integer");var h=s+1;u=new Array(s);for(var b=0;b<s;)u[b]=m(p,++b/h,o);return u}}if(_e(s)){var w=s.constructor;if(s.isNegative())throw new Error("N/prob must be non-negative");if(v=new w(1),s.lte(v))return new w(m(p,s,o));if(s.gt(v)){if(!s.isInteger())throw new Error("N must be a positive integer");var N=s.toNumber();if(N>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var g=new w(N+1);u=new Array(N);for(var y=0;y<N;)u[y]=new w(m(p,new w(++y).div(g),o));return u}}if(Array.isArray(s)){u=new Array(s.length);for(var x=0;x<u.length;++x){var d=s[x];if(Be(d)){if(d<0||d>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(_e(d)){if(v=new d.constructor(1),d.isNegative()||d.gt(v))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");u[x]=m(p,d,o)}return u}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function m(c,s,o){var u=Le(c),p=u.length;if(p===0)throw new Error("Cannot calculate quantile of an empty sequence");if(Be(s)){var v=s*(p-1),h=v%1;if(h===0){var b=o?u[v]:r(u,v);return f(b),b}var w=Math.floor(v),N,g;if(o)N=u[w],g=u[w+1];else{g=r(u,w+1),N=u[w];for(var y=0;y<w;++y)i(u[y],N)>0&&(N=u[y])}return f(N),f(g),a(t(N,1-h),t(g,h))}var x=s.times(p-1);if(x.isInteger()){x=x.toNumber();var d=o?u[x]:r(u,x);return f(d),d}var A=x.floor(),S=x.minus(A),O=A.toNumber(),M,_;if(o)M=u[O],_=u[O+1];else{_=r(u,O+1),M=u[O];for(var E=0;E<O;++E)i(u[E],M)>0&&(M=u[E])}f(M),f(_);var $=new S.constructor(1);return a(t(M,$.minus(S)),t(_,S))}var f=n({"number | BigNumber | Unit":function(s){return s}});return l}),ql="std",UC=["typed","sqrt","variance"],Rl=R(ql,UC,e=>{var{typed:n,sqrt:a,variance:t}=e;return n(ql,{"Array | Matrix":r,"Array | Matrix, string":r,"Array | Matrix, number | BigNumber":r,"Array | Matrix, number | BigNumber, string":r,"...":function(l){return r(l)}});function r(i,l){if(i.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return a(t.apply(null,arguments))}catch(m){throw m instanceof TypeError&&m.message.indexOf(" variance")!==-1?new TypeError(m.message.replace(" variance"," std")):m}}}),Fl="combinations",LC=["typed"],kC=R(Fl,LC,e=>{var{typed:n}=e;return n(Fl,{"number, number":gs,"BigNumber, BigNumber":function(t,r){var i=t.constructor,l,m,f=t.minus(r),c=new i(1);if(!zl(t)||!zl(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(t))throw new TypeError("k must be less than n in function combinations");if(l=c,r.lt(f))for(m=c;m.lte(f);m=m.plus(c))l=l.times(r.plus(m)).dividedBy(m);else for(m=c;m.lte(r);m=m.plus(c))l=l.times(f.plus(m)).dividedBy(m);return l}})});function zl(e){return e.isInteger()&&e.gte(0)}var Pl="combinationsWithRep",HC=["typed"],GC=R(Pl,HC,e=>{var{typed:n}=e;return n(Pl,{"number, number":function(t,r){if(!Ae(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!Ae(r)||r<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(t<1)throw new TypeError("k must be less than or equal to n + k - 1");if(r<t-1){var i=wt(t,t+r-1);return i/wt(1,r)}var l=wt(r+1,t+r-1);return l/wt(1,t-1)},"BigNumber, BigNumber":function(t,r){var i=t.constructor,l,m,f=new i(1),c=t.minus(f);if(!Ul(t)||!Ul(r))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(t.lt(f))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(l=f,r.lt(c))for(m=f;m.lte(c);m=m.plus(f))l=l.times(r.plus(m)).dividedBy(m);else for(m=f;m.lte(r);m=m.plus(f))l=l.times(c.plus(m)).dividedBy(m);return l}})});function Ul(e){return e.isInteger()&&e.gte(0)}var Ll="gamma",VC=["typed","config","multiplyScalar","pow","BigNumber","Complex"],ZC=R(Ll,VC,e=>{var{typed:n,config:a,multiplyScalar:t,pow:r,BigNumber:i,Complex:l}=e;return n(Ll,{number:yi,Complex:function(c){if(c.im===0)return this(c.re);if(c.re<.5){var s=new l(1-c.re,-c.im),o=new l(Math.PI*c.re,Math.PI*c.im);return new l(Math.PI).div(o.sin()).div(this(s))}c=new l(c.re-1,c.im);for(var u=new l(vn[0],0),p=1;p<vn.length;++p){var v=new l(vn[p],0);u=u.add(v.div(c.add(p)))}var h=new l(c.re+Ns+.5,c.im),b=Math.sqrt(2*Math.PI),w=h.pow(c.add(.5)),N=h.neg().exp();return u.mul(b).mul(w).mul(N)},BigNumber:function(c){if(c.isInteger())return c.isNegative()||c.isZero()?new i(1/0):m(c.minus(1));if(!c.isFinite())return new i(c.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(c){return be(c,this)}});function m(f){if(f<8)return new i([1,1,2,6,24,120,720,5040][f]);var c=a.precision+(Math.log(f.toNumber())|0),s=i.clone({precision:c});if(f%2===1)return f.times(m(new i(f-1)));for(var o=f,u=new s(f),p=f.toNumber();o>2;)o-=2,p+=o,u=u.times(p);return new i(u.toPrecision(i.precision))}}),kl="lgamma",XC=["Complex","typed"],YC=R(kl,XC,e=>{var{Complex:n,typed:a}=e,t=7,r=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return a(kl,{number:wa,Complex:function(c){var s=6.283185307179586,o=1.1447298858494002,u=.1;if(c.isNaN())return new n(NaN,NaN);if(c.im===0)return new n(wa(c.re),0);if(c.re>=t||Math.abs(c.im)>=r)return l(c);if(c.re<=u){var p=nv(s,c.im)*Math.floor(.5*c.re+.25),v=c.mul(Math.PI).sin().log(),h=this(new n(1-c.re,-c.im));return new n(o,p).sub(v).sub(h)}else return c.im>=0?m(c):m(c.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function l(f){for(var c=f.sub(.5).mul(f.log()).sub(f).add(Ms),s=new n(1,0).div(f),o=s.div(f),u=i[0],p=i[1],v=2*o.re,h=o.re*o.re+o.im*o.im,b=2;b<8;b++){var w=p;p=-h*u+i[b],u=v*u+w}var N=s.mul(o.mul(u).add(p));return c.add(N)}function m(f){var c=0,s=0,o=f;for(f=f.add(1);f.re<=t;){o=o.mul(f);var u=o.im<0?1:0;u!==0&&s===0&&c++,s=u,f=f.add(1)}return l(f).sub(o.log()).sub(new n(0,c*2*Math.PI*1))}}),Hl="factorial",WC=["typed","gamma"],JC=R(Hl,WC,e=>{var{typed:n,gamma:a}=e;return n(Hl,{number:function(r){if(r<0)throw new Error("Value must be non-negative");return a(r+1)},BigNumber:function(r){if(r.isNegative())throw new Error("Value must be non-negative");return a(r.plus(1))},"Array | Matrix":function(r){return be(r,this)}})}),Gl="kldivergence",QC=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],KC=R(Gl,QC,e=>{var{typed:n,matrix:a,divide:t,sum:r,multiply:i,dotDivide:l,log:m,isNumeric:f}=e;return n(Gl,{"Array, Array":function(o,u){return c(a(o),a(u))},"Matrix, Array":function(o,u){return c(o,a(u))},"Array, Matrix":function(o,u){return c(a(o),u)},"Matrix, Matrix":function(o,u){return c(o,u)}});function c(s,o){var u=o.size().length,p=s.size().length;if(u>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(u!==p)throw new Error("Length of two vectors must be equal");var v=r(s);if(v===0)throw new Error("Sum of elements in first object must be non zero");var h=r(o);if(h===0)throw new Error("Sum of elements in second object must be non zero");var b=t(s,r(s)),w=t(o,r(o)),N=r(i(b,m(l(b,w))));return f(N)?N:Number.NaN}}),Vl="multinomial",jC=["typed","add","divide","multiply","factorial","isInteger","isPositive"],e3=R(Vl,jC,e=>{var{typed:n,add:a,divide:t,multiply:r,factorial:i,isInteger:l,isPositive:m}=e;return n(Vl,{"Array | Matrix":function(c){var s=0,o=1;return bt(c,function(u){if(!l(u)||!m(u))throw new TypeError("Positive integer value expected in function multinomial");s=a(s,u),o=r(o,i(u))}),t(i(s),o)}})}),Zl="permutations",r3=["typed","factorial"],t3=R(Zl,r3,e=>{var{typed:n,factorial:a}=e;return n(Zl,{"number | BigNumber":a,"number, number":function(r,i){if(!Ae(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(!Ae(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>r)throw new TypeError("second argument k must be less than or equal to first argument n");return wt(r-i+1,r)},"BigNumber, BigNumber":function(r,i){var l,m;if(!Xl(r)||!Xl(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(r))throw new TypeError("second argument k must be less than or equal to first argument n");var f=r.mul(0).add(1);for(l=f,m=r.minus(i).plus(1);m.lte(r);m=m.plus(1))l=l.times(m);return l}})});function Xl(e){return e.isInteger()&&e.gte(0)}var _a={exports:{}},n3=_a.exports,Yl;function a3(){return Yl||(Yl=1,function(e){(function(n,a,t){function r(f){var c=this,s=m();c.next=function(){var o=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=o-(c.c=o|0)},c.c=1,c.s0=s(" "),c.s1=s(" "),c.s2=s(" "),c.s0-=s(f),c.s0<0&&(c.s0+=1),c.s1-=s(f),c.s1<0&&(c.s1+=1),c.s2-=s(f),c.s2<0&&(c.s2+=1),s=null}function i(f,c){return c.c=f.c,c.s0=f.s0,c.s1=f.s1,c.s2=f.s2,c}function l(f,c){var s=new r(f),o=c&&c.state,u=s.next;return u.int32=function(){return s.next()*4294967296|0},u.double=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.quick=u,o&&(typeof o=="object"&&i(o,s),u.state=function(){return i(s,{})}),u}function m(){var f=4022871197,c=function(s){s=String(s);for(var o=0;o<s.length;o++){f+=s.charCodeAt(o);var u=.02519603282416938*f;f=u>>>0,u-=f,u*=f,f=u>>>0,u-=f,f+=u*4294967296}return(f>>>0)*23283064365386963e-26};return c}a&&a.exports?a.exports=l:this.alea=l})(n3,e)}(_a)),_a.exports}var $a={exports:{}},i3=$a.exports,Wl;function o3(){return Wl||(Wl=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.x=0,f.y=0,f.z=0,f.w=0,f.next=function(){var o=f.x^f.x<<11;return f.x=f.y,f.y=f.z,f.z=f.w,f.w^=f.w>>>19^o^o>>>8},m===(m|0)?f.x=m:c+=m;for(var s=0;s<c.length+64;s++)f.x^=c.charCodeAt(s)|0,f.next()}function i(m,f){return f.x=m.x,f.y=m.y,f.z=m.z,f.w=m.w,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xor128=l})(i3,e)}($a)),$a.exports}var Ia={exports:{}},s3=Ia.exports,Jl;function u3(){return Jl||(Jl=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.next=function(){var o=f.x^f.x>>>2;return f.x=f.y,f.y=f.z,f.z=f.w,f.w=f.v,(f.d=f.d+362437|0)+(f.v=f.v^f.v<<4^(o^o<<1))|0},f.x=0,f.y=0,f.z=0,f.w=0,f.v=0,m===(m|0)?f.x=m:c+=m;for(var s=0;s<c.length+64;s++)f.x^=c.charCodeAt(s)|0,s==c.length&&(f.d=f.x<<10^f.x>>>4),f.next()}function i(m,f){return f.x=m.x,f.y=m.y,f.z=m.z,f.w=m.w,f.v=m.v,f.d=m.d,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xorwow=l})(s3,e)}(Ia)),Ia.exports}var qa={exports:{}},c3=qa.exports,Ql;function f3(){return Ql||(Ql=1,function(e){(function(n,a,t){function r(m){var f=this;f.next=function(){var s=f.x,o=f.i,u,p;return u=s[o],u^=u>>>7,p=u^u<<24,u=s[o+1&7],p^=u^u>>>10,u=s[o+3&7],p^=u^u>>>3,u=s[o+4&7],p^=u^u<<7,u=s[o+7&7],u=u^u<<13,p^=u^u<<9,s[o]=p,f.i=o+1&7,p};function c(s,o){var u,p=[];if(o===(o|0))p[0]=o;else for(o=""+o,u=0;u<o.length;++u)p[u&7]=p[u&7]<<15^o.charCodeAt(u)+p[u+1&7]<<13;for(;p.length<8;)p.push(0);for(u=0;u<8&&p[u]===0;++u);for(u==8?p[7]=-1:p[u],s.x=p,s.i=0,u=256;u>0;--u)s.next()}c(f,m)}function i(m,f){return f.x=m.x.slice(),f.i=m.i,f}function l(m,f){m==null&&(m=+new Date);var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(s.x&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xorshift7=l})(c3,e)}(qa)),qa.exports}var Ra={exports:{}},l3=Ra.exports,Kl;function m3(){return Kl||(Kl=1,function(e){(function(n,a,t){function r(m){var f=this;f.next=function(){var s=f.w,o=f.X,u=f.i,p,v;return f.w=s=s+1640531527|0,v=o[u+34&127],p=o[u=u+1&127],v^=v<<13,p^=p<<17,v^=v>>>15,p^=p>>>12,v=o[u]=v^p,f.i=u,v+(s^s>>>16)|0};function c(s,o){var u,p,v,h,b,w=[],N=128;for(o===(o|0)?(p=o,o=null):(o=o+"\0",p=0,N=Math.max(N,o.length)),v=0,h=-32;h<N;++h)o&&(p^=o.charCodeAt((h+32)%o.length)),h===0&&(b=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,h>=0&&(b=b+1640531527|0,u=w[h&127]^=p+b,v=u==0?v+1:0);for(v>=128&&(w[(o&&o.length||0)&127]=-1),v=127,h=4*128;h>0;--h)p=w[v+34&127],u=w[v=v+1&127],p^=p<<13,u^=u<<17,p^=p>>>15,u^=u>>>12,w[v]=p^u;s.w=b,s.X=w,s.i=v}c(f,m)}function i(m,f){return f.i=m.i,f.w=m.w,f.X=m.X.slice(),f}function l(m,f){m==null&&(m=+new Date);var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(s.X&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xor4096=l})(l3,e)}(Ra)),Ra.exports}var Fa={exports:{}},p3=Fa.exports,jl;function v3(){return jl||(jl=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.next=function(){var o=f.b,u=f.c,p=f.d,v=f.a;return o=o<<25^o>>>7^u,u=u-p|0,p=p<<24^p>>>8^v,v=v-o|0,f.b=o=o<<20^o>>>12^u,f.c=u=u-p|0,f.d=p<<16^u>>>16^v,f.a=v-o|0},f.a=0,f.b=0,f.c=-1640531527,f.d=1367130551,m===Math.floor(m)?(f.a=m/4294967296|0,f.b=m|0):c+=m;for(var s=0;s<c.length+20;s++)f.b^=c.charCodeAt(s)|0,f.next()}function i(m,f){return f.a=m.a,f.b=m.b,f.c=m.c,f.d=m.d,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.tychei=l})(p3,e)}(Fa)),Fa.exports}var za={exports:{}};const h3=zp(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var d3=za.exports,em;function g3(){return em||(em=1,function(e){(function(n,a,t){var r=256,i=6,l=52,m="random",f=t.pow(r,i),c=t.pow(2,l),s=c*2,o=r-1,u;function p(y,x,d){var A=[];x=x==!0?{entropy:!0}:x||{};var S=w(b(x.entropy?[y,g(a)]:y==null?N():y,3),A),O=new v(A),M=function(){for(var _=O.g(i),E=f,$=0;_<c;)_=(_+$)*r,E*=r,$=O.g(1);for(;_>=s;)_/=2,E/=2,$>>>=1;return(_+$)/E};return M.int32=function(){return O.g(4)|0},M.quick=function(){return O.g(4)/4294967296},M.double=M,w(g(O.S),a),(x.pass||d||function(_,E,$,z){return z&&(z.S&&h(z,O),_.state=function(){return h(O,{})}),$?(t[m]=_,E):_})(M,S,"global"in x?x.global:this==t,x.state)}function v(y){var x,d=y.length,A=this,S=0,O=A.i=A.j=0,M=A.S=[];for(d||(y=[d++]);S<r;)M[S]=S++;for(S=0;S<r;S++)M[S]=M[O=o&O+y[S%d]+(x=M[S])],M[O]=x;(A.g=function(_){for(var E,$=0,z=A.i,I=A.j,T=A.S;_--;)E=T[z=o&z+1],$=$*r+T[o&(T[z]=T[I=o&I+E])+(T[I]=E)];return A.i=z,A.j=I,$})(r)}function h(y,x){return x.i=y.i,x.j=y.j,x.S=y.S.slice(),x}function b(y,x){var d=[],A=typeof y,S;if(x&&A=="object")for(S in y)try{d.push(b(y[S],x-1))}catch(O){}return d.length?d:A=="string"?y:y+"\0"}function w(y,x){for(var d=y+"",A,S=0;S<d.length;)x[o&S]=o&(A^=x[o&S]*19)+d.charCodeAt(S++);return g(x)}function N(){try{var y;return u&&(y=u.randomBytes)?y=y(r):(y=new Uint8Array(r),(n.crypto||n.msCrypto).getRandomValues(y)),g(y)}catch(A){var x=n.navigator,d=x&&x.plugins;return[+new Date,n,d,n.screen,g(a)]}}function g(y){return String.fromCharCode.apply(0,y)}if(w(t.random(),a),e.exports){e.exports=p;try{u=h3}catch(y){}}else t["seed"+m]=p})(typeof self!="undefined"?self:d3,[],Math)}(za)),za.exports}var Ri,rm;function y3(){if(rm)return Ri;rm=1;var e=a3(),n=o3(),a=u3(),t=f3(),r=m3(),i=v3(),l=g3();return l.alea=e,l.xor128=n,l.xorwow=a,l.xorshift7=t,l.xor4096=r,l.tychei=i,Ri=l,Ri}var x3=y3();const tm=Tn(x3);var b3=tm(Date.now());function bn(e){var n;function a(r){n=r===null?b3:tm(String(r))}a(e);function t(){return n()}return t}var nm="pickRandom",w3=["typed","config","?on"],N3=R(nm,w3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(l,m){l.randomSeed!==m.randomSeed&&(r=bn(l.randomSeed))}),n(nm,{"Array | Matrix":function(m){return i(m,{})},"Array | Matrix, Object":function(m,f){return i(m,f)},"Array | Matrix, number":function(m,f){return i(m,{number:f})},"Array | Matrix, Array | Matrix":function(m,f){return i(m,{weights:f})},"Array | Matrix, Array | Matrix, number":function(m,f,c){return i(m,{number:c,weights:f})},"Array | Matrix, number, Array | Matrix":function(m,f,c){return i(m,{number:f,weights:c})}});function i(l,m){var{number:f,weights:c,elementWise:s=!0}=m,o=typeof f=="undefined";o&&(f=1);var u=Oe(l)?l.create:Oe(c)?c.create:null;l=l.valueOf(),c&&(c=c.valueOf()),s===!0&&(l=Le(l),c=Le(c));var p=0;if(typeof c!="undefined"){if(c.length!==l.length)throw new Error("Weights must have the same length as possibles");for(var v=0,h=c.length;v<h;v++){if(!Be(c[v])||c[v]<0)throw new Error("Weights must be an array of positive numbers");p+=c[v]}}for(var b=l.length,w=[],N;w.length<f;){if(typeof c=="undefined")N=l[Math.floor(r()*b)];else for(var g=r()*p,y=0,x=l.length;y<x;y++)if(g-=c[y],g<0){N=l[y];break}w.push(N)}return o?w[0]:u?u(w):w}});function Fi(e,n){var a=[];if(e=e.slice(0),e.length>1)for(var t=0,r=e.shift();t<r;t++)a.push(Fi(e,n));else for(var i=0,l=e.shift();i<l;i++)a.push(n());return a}var am="random",M3=["typed","config","?on"],A3=R(am,M3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(m,f){m.randomSeed!==f.randomSeed&&(r=bn(m.randomSeed))}),n(am,{"":()=>l(0,1),number:m=>l(0,m),"number, number":(m,f)=>l(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,c)=>i(m,f,c)});function i(m,f,c){var s=Fi(m.valueOf(),()=>l(f,c));return Oe(m)?m.create(s):s}function l(m,f){return m+r()*(f-m)}}),im="randomInt",S3=["typed","config","?on"],E3=R(im,S3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(m,f){m.randomSeed!==f.randomSeed&&(r=bn(m.randomSeed))}),n(im,{"":()=>l(0,1),number:m=>l(0,m),"number, number":(m,f)=>l(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,c)=>i(m,f,c)});function i(m,f,c){var s=Fi(m.valueOf(),()=>l(f,c));return Oe(m)?m.create(s):s}function l(m,f){return Math.floor(m+r()*(f-m))}}),om="stirlingS2",C3=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],O3=R(om,C3,e=>{var{typed:n,addScalar:a,subtract:t,multiplyScalar:r,divideScalar:i,pow:l,factorial:m,combinations:f,isNegative:c,isInteger:s,number:o,bignumber:u,larger:p}=e,v=[],h=[];return n(om,{"number | BigNumber, number | BigNumber":function(w,N){if(!s(w)||c(w)||!s(N)||c(N))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(p(N,w))throw new TypeError("k must be less than or equal to n in function stirlingS2");var g=!(Be(w)&&Be(N)),y=g?h:v,x=g?u:o,d=o(w),A=o(N);if(y[d]&&y[d].length>A)return y[d][A];for(var S=0;S<=d;++S)if(y[S]||(y[S]=[x(S===0?1:0)]),S!==0)for(var O=y[S],M=y[S-1],_=O.length;_<=S&&_<=A;++_)_===S?O[_]=1:O[_]=a(r(x(_),M[_]),M[_-1]);return y[d][A]}})}),sm="bellNumbers",D3=["typed","addScalar","isNegative","isInteger","stirlingS2"],T3=R(sm,D3,e=>{var{typed:n,addScalar:a,isNegative:t,isInteger:r,stirlingS2:i}=e;return n(sm,{"number | BigNumber":function(m){if(!r(m)||t(m))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var f=0,c=0;c<=m;c++)f=a(f,i(m,c));return f}})}),um="catalan",B3=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],_3=R(um,B3,e=>{var{typed:n,addScalar:a,divideScalar:t,multiplyScalar:r,combinations:i,isNegative:l,isInteger:m}=e;return n(um,{"number | BigNumber":function(c){if(!m(c)||l(c))throw new TypeError("Non-negative integer value expected in function catalan");return t(i(r(c,2),c),a(c,1))}})}),cm="composition",$3=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],I3=R(cm,$3,e=>{var{typed:n,addScalar:a,combinations:t,isPositive:r,isNegative:i,isInteger:l,larger:m}=e;return n(cm,{"number | BigNumber, number | BigNumber":function(c,s){if(!l(c)||!r(c)||!l(s)||!r(s))throw new TypeError("Positive integer value expected in function composition");if(m(s,c))throw new TypeError("k must be less than or equal to n in function composition");return t(a(c,-1),a(s,-1))}})}),fm="leafCount",q3=["parse","typed"],R3=R(fm,q3,e=>{var{parse:n,typed:a}=e;function t(r){var i=0;return r.forEach(l=>{i+=t(l)}),i||1}return a(fm,{string:function(i){return this(n(i))},Node:function(i){return t(i)}})});function lm(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),a.push.apply(a,t)}return a}function zi(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?lm(Object(a),!0).forEach(function(t){ff(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):lm(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var F3="simplifyUtil",z3=["FunctionNode","OperatorNode","SymbolNode"],Pi=R(F3,z3,e=>{var{FunctionNode:n,OperatorNode:a,SymbolNode:t}=e,r=!0,i=!1,l="defaultF",m={add:{trivial:r,total:r,commutative:r,associative:r},unaryPlus:{trivial:r,total:r,commutative:r,associative:r},subtract:{trivial:i,total:r,commutative:i,associative:i},multiply:{trivial:r,total:r,commutative:r,associative:r},divide:{trivial:i,total:r,commutative:i,associative:i},paren:{trivial:r,total:r,commutative:r,associative:i},defaultF:{trivial:i,total:r,commutative:i,associative:i}},f={divide:{total:i},log:{total:i}},c={subtract:{total:i},abs:{trivial:r},log:{total:r}};function s(g,y){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:m,d=l;if(typeof g=="string"?d=g:$r(g)?d=g.fn.toString():kt(g)?d=g.name:On(g)&&(d="paren"),Me(x,d)){var A=x[d];if(Me(A,y))return A[y];if(Me(m,d))return m[d][y]}if(Me(x,l)){var S=x[l];return Me(S,y)?S[y]:m[l][y]}if(Me(m,d)){var O=m[d];if(Me(O,y))return O[y]}return m[l][y]}function o(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(g,"commutative",y)}function u(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(g,"associative",y)}function p(g,y){var x=zi({},g);for(var d in y)Me(g,d)?x[d]=zi(zi({},y[d]),g[d]):x[d]=y[d];return x}function v(g,y){if(!g.args||g.args.length===0)return g;g.args=h(g,y);for(var x=0;x<g.args.length;x++)v(g.args[x],y)}function h(g,y){var x,d=[],A=function S(O){for(var M=0;M<O.args.length;M++){var _=O.args[M];$r(_)&&x===_.op?S(_):d.push(_)}};return u(g,y)?(x=g.op,A(g),d):g.args}function b(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)b(g.args[A],y);if(d>2&&u(g,y)){for(var S=g.args.pop();g.args.length>0;)S=x([g.args.pop(),S]);g.args=S.args}}}function w(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)w(g.args[A],y);if(d>2&&u(g,y)){for(var S=g.args.shift();g.args.length>0;)S=x([S,g.args.shift()]);g.args=S.args}}}function N(g){return $r(g)?function(y){try{return new a(g.op,g.fn,y,g.implicit)}catch(x){return console.error(x),[]}}:function(y){return new n(new t(g.name),y)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:o,isAssociative:u,mergeContext:p,flatten:v,allChildren:h,unflattenr:b,unflattenl:w,defaultContext:m,realContext:f,positiveContext:c}}),P3="simplifyConstant",U3=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],mm=R(P3,U3,e=>{var{typed:n,config:a,mathWithTransform:t,matrix:r,fraction:i,bignumber:l,AccessorNode:m,ArrayNode:f,ConstantNode:c,FunctionNode:s,IndexNode:o,ObjectNode:u,OperatorNode:p,SymbolNode:v}=e,{isCommutative:h,isAssociative:b,allChildren:w,createMakeNodeFunction:N}=Pi({FunctionNode:s,OperatorNode:p,SymbolNode:v});function g(I,T){return A(z(I,T))}function y(I){return yr(I)?I.valueOf():I instanceof Array?I.map(y):Oe(I)?r(y(I.valueOf())):I}function x(I,T,B){try{return t[I].apply(null,T)}catch(G){return T=T.map(y),O(t[I].apply(null,T),B)}}var d=n({Fraction:_,number:function(T){return T<0?M(new c(-T)):new c(T)},BigNumber:function(T){return T<0?M(new c(-T)):new c(T)},Complex:function(T){throw new Error("Cannot convert Complex number to Node")},string:function(T){return new c(T)},Matrix:function(T){return new f(T.valueOf().map(B=>d(B)))}});function A(I){return Ve(I)?I:d(I)}function S(I,T){var B=T&&T.exactFractions!==!1;if(B&&isFinite(I)&&i){var G=i(I),D=T&&typeof T.fractionsLimit=="number"?T.fractionsLimit:1/0;if(G.valueOf()===I&&G.n<D&&G.d<D)return G}return I}var O=n({"string, Object":function(T,B){if(a.number==="BigNumber")return l===void 0&&Ai(),l(T);if(a.number==="Fraction")return i===void 0&&nc(),i(T);var G=parseFloat(T);return S(G,B)},"Fraction, Object":function(T,B){return T},"BigNumber, Object":function(T,B){return T},"number, Object":function(T,B){return S(T,B)},"Complex, Object":function(T,B){return T.im!==0?T:S(T.re,B)},"Matrix, Object":function(T,B){return r(S(T.valueOf()))},"Array, Object":function(T,B){return T.map(S)}});function M(I){return new p("-","unaryMinus",[I])}function _(I){var T,B=I.s*I.n;return B<0?T=new p("-","unaryMinus",[new c(-B)]):T=new c(B),I.d===1?T:new p("/","divide",[T,new c(I.d)])}function E(I,T,B){if(!tn(T))return new m(A(I),A(T));if(Hr(I)||Oe(I)){for(var G=Array.from(T.dimensions);G.length>0;)if(Ye(G[0])&&typeof G[0].value!="string"){var D=O(G.shift().value,B);Hr(I)?I=I.items[D-1]:(I=I.valueOf()[D-1],I instanceof Array&&(I=r(I)))}else if(G.length>1&&Ye(G[1])&&typeof G[1].value!="string"){var H=O(G[1].value,B),W=[],j=Hr(I)?I.items:I.valueOf();for(var V of j)if(Hr(V))W.push(V.items[H-1]);else if(Oe(I))W.push(V[H-1]);else break;if(W.length===j.length)Hr(I)?I=new f(W):I=r(W),G.splice(1,1);else break}else break;return G.length===T.dimensions.length?new m(A(I),T):G.length>0?(T=new o(G),new m(A(I),T)):I}if(jn(I)&&T.dimensions.length===1&&Ye(T.dimensions[0])){var K=T.dimensions[0].value;return K in I.properties?I.properties[K]:new c}return new m(A(I),T)}function $(I,T,B,G){return T.reduce(function(D,H){if(!Ve(D)&&!Ve(H)){try{return x(I,[D,H],G)}catch(W){}D=d(D),H=d(H)}else Ve(D)?Ve(H)||(H=d(H)):D=d(D);return B([D,H])})}function z(I,T){switch(I.type){case"SymbolNode":return I;case"ConstantNode":switch(typeof I.value){case"number":return O(I.value,T);case"string":return I.value;default:if(!isNaN(I.value))return O(I.value,T)}return I;case"FunctionNode":if(t[I.name]&&t[I.name].rawArgs)return I;{var B=["add","multiply"];if(B.indexOf(I.name)===-1){var G=I.args.map(ye=>z(ye,T));if(!G.some(Ve))try{return x(I.name,G,T)}catch(ye){}if(I.name==="size"&&G.length===1&&Hr(G[0])){for(var D=[],H=G[0];Hr(H);)D.push(H.items.length),H=H.items[0];return r(D)}return new s(I.name,G.map(A))}}case"OperatorNode":{var W=I.fn.toString(),j,V,K=N(I);if($r(I)&&I.isUnary())j=[z(I.args[0],T)],Ve(j[0])?V=K(j):V=x(W,j,T);else if(b(I,T.context))if(j=w(I,T.context),j=j.map(ye=>z(ye,T)),h(W,T.context)){for(var te=[],re=[],ie=0;ie<j.length;ie++)Ve(j[ie])?re.push(j[ie]):te.push(j[ie]);te.length>1?(V=$(W,te,K,T),re.unshift(V),V=$(W,re,K,T)):V=$(W,j,K,T)}else V=$(W,j,K,T);else j=I.args.map(ye=>z(ye,T)),V=$(W,j,K,T);return V}case"ParenthesisNode":return z(I.content,T);case"AccessorNode":return E(z(I.object,T),z(I.index,T),T);case"ArrayNode":{var ne=I.items.map(ye=>z(ye,T));return ne.some(Ve)?new f(ne.map(A)):r(ne)}case"IndexNode":return new o(I.dimensions.map(ye=>g(ye,T)));case"ObjectNode":{var ue={};for(var ee in I.properties)ue[ee]=g(I.properties[ee],T);return new u(ue)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(I.type))}}return g}),L3="simplify",k3=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],H3=R(L3,k3,e=>{var{config:n,typed:a,parse:t,add:r,subtract:i,multiply:l,divide:m,pow:f,isZero:c,equal:s,resolve:o,simplifyCore:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,ParenthesisNode:S,SymbolNode:O}=e,M=mm({typed:a,config:n,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:O}),{hasProperty:_,isCommutative:E,isAssociative:$,mergeContext:z,flatten:I,unflattenr:T,unflattenl:B,createMakeNodeFunction:G,defaultContext:D,realContext:H,positiveContext:W}=Pi({FunctionNode:y,OperatorNode:A,SymbolNode:O}),j=a("simplify",{string:function(U){return this(t(U),this.rules,gt(),{})},"string, Map | Object":function(U,J){return this(t(U),this.rules,J,{})},"string, Map | Object, Object":function(U,J,q){return this(t(U),this.rules,J,q)},"string, Array":function(U,J){return this(t(U),J,gt(),{})},"string, Array, Map | Object":function(U,J,q){return this(t(U),J,q,{})},"string, Array, Map | Object, Object":function(U,J,q,P){return this(t(U),J,q,P)},"Node, Map | Object":function(U,J){return this(U,this.rules,J,{})},"Node, Map | Object, Object":function(U,J,q){return this(U,this.rules,J,q)},Node:function(U){return this(U,this.rules,gt(),{})},"Node, Array":function(U,J){return this(U,J,gt(),{})},"Node, Array, Map | Object":function(U,J,q){return this(U,J,q,{})},"Node, Array, Object, Object":function(U,J,q,P){return this(U,J,oi(q),P)},"Node, Array, Map, Object":function(U,J,q,P){var Q=P.consoleDebug;J=re(J,P.context);var L=o(U,q);L=V(L);for(var se={},fe=L.toString({parenthesis:"all"});!se[fe];){se[fe]=!0,ie=0;var ge=fe;Q&&console.log("Working on: ",fe);for(var pe=0;pe<J.length;pe++){var ve="";if(typeof J[pe]=="function"?(L=J[pe](L,P),Q&&(ve=J[pe].name)):(I(L,P.context),L=ee(L,J[pe],P.context),Q&&(ve="".concat(J[pe].l.toString()," -> ").concat(J[pe].r.toString()))),Q){var Ne=L.toString({parenthesis:"all"});Ne!==ge&&(console.log("Applying",ve,"produced",Ne),ge=Ne)}B(L,P.context)}fe=L.toString({parenthesis:"all"})}return L}});j.defaultContext=D,j.realContext=H,j.positiveContext=W;function V(k){return k.transform(function(U,J,q){return On(U)?V(U.content):U})}var K={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};j.rules=[u,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},M,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},M,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];function te(k,U){var J={};if(k.s){var q=k.s.split("->");if(q.length===2)J.l=q[0],J.r=q[1];else throw SyntaxError("Could not parse rule: "+k.s)}else J.l=k.l,J.r=k.r;J.l=V(t(J.l)),J.r=V(t(J.r));for(var P of["imposeContext","repeat","assuming"])P in k&&(J[P]=k[P]);if(k.evaluate&&(J.evaluate=t(k.evaluate)),$(J.l,U)){var Q=G(J.l),L=ne();J.expanded={},J.expanded.l=Q([J.l.clone(),L]),I(J.expanded.l,U),T(J.expanded.l,U),J.expanded.r=Q([J.r,L])}return J}function re(k,U){for(var J=[],q=0;q<k.length;q++){var P=k[q],Q=void 0,L=typeof P;switch(L){case"string":P={s:P};case"object":Q=te(P,U);break;case"function":Q=P;break;default:throw TypeError("Unsupported type of rule: "+L)}J.push(Q)}return J}var ie=0;function ne(){return new O("_p"+ie++)}function ue(k,U,J){var q=k;if(k)for(var P=0;P<k.length;++P){var Q=ee(k[P],U,J);Q!==k[P]&&(q===k&&(q=k.slice()),q[P]=Q)}return q}function ee(k,U,J){if(U.assuming){for(var q in U.assuming)for(var P in U.assuming[q])if(_(q,P,J)!==U.assuming[q][P])return k}var Q=z(U.imposeContext,J),L=k;if(L instanceof A||L instanceof y){var se=ue(L.args,U,J);se!==L.args&&(L=L.clone(),L.args=se)}else if(L instanceof S){if(L.content){var fe=ee(L.content,U,J);fe!==L.content&&(L=new S(fe))}}else if(L instanceof N){var ge=ue(L.items,U,J);ge!==L.items&&(L=new N(ge))}else if(L instanceof w){var pe=L.object;L.object&&(pe=ee(L.object,U,J));var ve=L.index;L.index&&(ve=ee(L.index,U,J)),(pe!==L.object||ve!==L.index)&&(L=new w(pe,ve))}else if(L instanceof x){var Ne=ue(L.dimensions,U,J);Ne!==L.dimensions&&(L=new x(Ne))}else if(L instanceof d){var Qe=!1,cr={};for(var tr in L.properties)cr[tr]=ee(L.properties[tr],U,J),cr[tr]!==L.properties[tr]&&(Qe=!0);Qe&&(L=new d(cr))}var Jr=U.r,Lr=F(U.l,L,Q)[0];if(!Lr&&U.expanded&&(Jr=U.expanded.r,Lr=F(U.expanded.l,L,Q)[0]),Lr){var Ot=L.implicit;L=Jr.clone(),Ot&&"implicit"in Jr&&(L.implicit=!0),L=L.transform(function(Ze){return Ze.isSymbolNode&&Me(Lr.placeholders,Ze.name)?Lr.placeholders[Ze.name].clone():Ze})}return U.repeat&&L!==k&&(L=ee(L,U,J)),L}function ye(k,U){var J=[],q,P,Q=G(k);if(E(k,U))for(var L=0;L<k.args.length;L++)P=k.args.slice(0),P.splice(L,1),q=P.length===1?P[0]:Q(P),J.push(Q([k.args[L],q]));else for(var se=1;se<k.args.length;se++){var fe=k.args[0];se>1&&(fe=Q(k.args.slice(0,se))),P=k.args.slice(se),q=P.length===1?P[0]:Q(P),J.push(Q([fe,q]))}return J}function we(k,U){var J={placeholders:{}};if(!k.placeholders&&!U.placeholders)return J;if(k.placeholders){if(!U.placeholders)return k}else return U;for(var q in k.placeholders)if(Me(k.placeholders,q)&&(J.placeholders[q]=k.placeholders[q],Me(U.placeholders,q)&&!Y(k.placeholders[q],U.placeholders[q])))return null;for(var P in U.placeholders)Me(U.placeholders,P)&&(J.placeholders[P]=U.placeholders[P]);return J}function me(k,U){var J=[];if(k.length===0||U.length===0)return J;for(var q,P=0;P<k.length;P++)for(var Q=0;Q<U.length;Q++)q=we(k[P],U[Q]),q&&J.push(q);return J}function xe(k){if(k.length===0)return k;for(var U=k.reduce(me),J=[],q={},P=0;P<U.length;P++){var Q=JSON.stringify(U[P]);q[Q]||(q[Q]=!0,J.push(U[P]))}return J}function F(k,U,J,q){var P=[{placeholders:{}}];if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return[]}else if(k instanceof y&&k.name!==U.name)return[];if(U.args.length===1&&k.args.length===1||!$(U,J)&&U.args.length===k.args.length||q){for(var Q=[],L=0;L<k.args.length;L++){var se=F(k.args[L],U.args[L],J);if(se.length===0)break;Q.push(se)}if(Q.length!==k.args.length){if(!E(U,J)||k.args.length===1)return[];if(k.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var fe=F(k.args[0],U.args[1],J);if(fe.length===0)return[];var ge=F(k.args[1],U.args[0],J);if(ge.length===0)return[];Q=[fe,ge]}P=xe(Q)}else if(U.args.length>=2&&k.args.length===2){for(var pe=ye(U,J),ve=[],Ne=0;Ne<pe.length;Ne++){var Qe=F(k,pe[Ne],J,!0);ve=ve.concat(Qe)}return ve}else{if(k.args.length>2)throw Error("Unexpected non-binary associative function: "+k.toString());return[]}}else if(k instanceof O){if(k.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(K[k.name]){if(k.name!==U.name)return[]}else if(k.name[0]==="n"||k.name.substring(0,2)==="_p")P[0].placeholders[k.name]=U;else if(k.name[0]==="v")if(!Ye(U))P[0].placeholders[k.name]=U;else return[];else if(k.name[0]==="c")if(U instanceof g)P[0].placeholders[k.name]=U;else return[];else throw new Error("Invalid symbol in rule: "+k.name)}else if(k instanceof g){if(!s(k.value,U.value))return[]}else return[];return P}function Y(k,U){if(k instanceof g&&U instanceof g){if(!s(k.value,U.value))return!1}else if(k instanceof O&&U instanceof O){if(k.name!==U.name)return!1}else if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return!1}else if(k instanceof y&&k.name!==U.name)return!1;if(k.args.length!==U.args.length)return!1;for(var J=0;J<k.args.length;J++)if(!Y(k.args[J],U.args[J]))return!1}else return!1;return!0}return j}),G3="simplifyCore",V3=["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],Z3=R(G3,V3,e=>{var{equal:n,isZero:a,add:t,subtract:r,multiply:i,divide:l,pow:m,AccessorNode:f,ArrayNode:c,ConstantNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,SymbolNode:b}=e,w=new s(0),N=new s(1),{hasProperty:g,isCommutative:y}=Pi({FunctionNode:o,OperatorNode:v,SymbolNode:b});function x(d,A){var S=A?A.context:void 0;if(g(d,"trivial",S)){if(kt(d)&&d.args.length===1)return x(d.args[0],A);var O=!1,M=0;if(d.forEach(D=>{++M,M===1&&(O=x(D,A))}),M===1)return O}if($r(d)&&d.isUnary()){var _=x(d.args[0],A);if(d.op==="-"){if($r(_)){if(_.isUnary()&&_.op==="-")return _.args[0];if(_.isBinary()&&_.fn==="subtract")return new v("-","subtract",[_.args[1],_.args[0]])}return new v(d.op,d.fn,[_])}}else if($r(d)&&d.isBinary()){var E=x(d.args[0],A),$=x(d.args[1],A);if(d.op==="+"){if(Ye(E)){if(a(E.value))return $;if(Ye($))return new s(t(E.value,$.value))}return Ye($)&&a($.value)?E:$r($)&&$.isUnary()&&$.op==="-"?new v("-","subtract",[E,$.args[0]]):new v(d.op,d.fn,$?[E,$]:[E])}else if(d.op==="-"){if(Ye(E)&&$){if(Ye($))return new s(r(E.value,$.value));if(a(E.value))return new v("-","unaryMinus",[$])}if(d.fn==="subtract")return Ye($)&&a($.value)?E:$r($)&&$.isUnary()&&$.op==="-"?x(new v("+","add",[E,$.args[0]]),A):new v(d.op,d.fn,[E,$])}else if(d.op==="*"){if(Ye(E)){if(a(E.value))return w;if(n(E.value,1))return $;if(Ye($))return new s(i(E.value,$.value))}if(Ye($)){if(a($.value))return w;if(n($.value,1))return E;if($r(E)&&E.isBinary()&&E.op===d.op&&y(d,S)){var z=E.args[0];if(Ye(z)){var I=new s(i(z.value,$.value));return new v(d.op,d.fn,[I,E.args[1]],d.implicit)}}return y(d,S)?new v(d.op,d.fn,[$,E],d.implicit):new v(d.op,d.fn,[E,$],d.implicit)}return new v(d.op,d.fn,[E,$],d.implicit)}else if(d.op==="/"){if(Ye(E)){if(a(E.value))return w;if(Ye($)&&(n($.value,1)||n($.value,2)||n($.value,4)))return new s(l(E.value,$.value))}return new v(d.op,d.fn,[E,$])}else if(d.op==="^"&&Ye($)){if(a($.value))return N;if(n($.value,1))return E;if(Ye(E))return new s(m(E.value,$.value));if($r(E)&&E.isBinary()&&E.op==="^"){var T=E.args[1];if(Ye(T))return new v(d.op,d.fn,[E.args[0],new s(i(T.value,$.value))])}}return new v(d.op,d.fn,[E,$])}else{if(kt(d))return new o(x(d.fn),d.args.map(D=>x(D,A)));if(Hr(d))return new c(d.items.map(D=>x(D,A)));if(Lt(d))return new f(x(d.object,A),x(d.index,A));if(tn(d))return new u(d.dimensions.map(D=>x(D,A)));if(jn(d)){var B={};for(var G in d.properties)B[G]=x(d.properties[G],A);return new p(B)}}return d}return x}),X3="resolve",Y3=["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],W3=R(X3,Y3,e=>{var{parse:n,ConstantNode:a,FunctionNode:t,OperatorNode:r,ParenthesisNode:i}=e;function l(m,f){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!f)return m;if(ua(f)||(f=oi(f)),xr(m)){if(c.has(m.name)){var s=Array.from(c).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(s,"}"))}var o=f.get(m.name);if(Ve(o)){var u=new Set(c);return u.add(m.name),l(o,f,u)}else return typeof o=="number"?n(String(o)):o!==void 0?new a(o):m}else if($r(m)){var p=m.args.map(function(h){return l(h,f,c)});return new r(m.op,m.fn,p,m.implicit)}else{if(On(m))return new i(l(m.content,f,c));if(kt(m)){var v=m.args.map(function(h){return l(h,f,c)});return new t(m.name,v)}}return m.map(h=>l(h,f,c))}return l}),pm="symbolicEqual",J3=["parse","simplify","typed","OperatorNode"],Q3=R(pm,J3,e=>{var{parse:n,simplify:a,typed:t,OperatorNode:r}=e;return t(pm,{"string, string":function(l,m){return this(n(l),n(m),{})},"string, string, Object":function(l,m,f){return this(n(l),n(m),f)},"Node, string":function(l,m){return this(l,n(m),{})},"Node, string, Object":function(l,m,f){return this(l,n(m),f)},"string, Node":function(l,m){return this(n(l),m,{})},"string, Node, Object":function(l,m,f){return this(n(l),m,f)},"Node, Node":function(l,m){return this(l,m,{})},"Node, Node, Object":function(l,m,f){var c=new r("-","subtract",[l,m]),s=a(c,{},f);return Ye(s)&&!s.value}})}),K3="derivative",j3=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],eO=R(K3,j3,e=>{var{typed:n,config:a,parse:t,simplify:r,equal:i,isZero:l,numeric:m,ConstantNode:f,FunctionNode:c,OperatorNode:s,ParenthesisNode:o,SymbolNode:u}=e,p=n("derivative",{"Node, SymbolNode, Object":function(y,x,d){var A={};h(A,y,x.name);var S=b(y,A);return d.simplify?r(S):S},"Node, SymbolNode":function(y,x){return this(y,x,{simplify:!0})},"string, SymbolNode":function(y,x){return this(t(y),x)},"string, SymbolNode, Object":function(y,x,d){return this(t(y),x,d)},"string, string":function(y,x){return this(t(y),t(x))},"string, string, Object":function(y,x,d){return this(t(y),t(x),d)},"Node, string":function(y,x){return this(y,t(x))},"Node, string, Object":function(y,x,d){return this(y,t(x),d)}});p._simplify=!0,p.toTex=function(g){return v.apply(null,g.args)};var v=n("_derivTex",{"Node, SymbolNode":function(y,x){return Ye(y)&&Ke(y.value)==="string"?v(t(y.value).toString(),x.toString(),1):v(y.toTex(),x.toString(),1)},"Node, ConstantNode":function(y,x){if(Ke(x.value)==="string")return v(y,t(x.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(y,x,d){return v(y.toString(),x.name,d.value)},"string, string, number":function(y,x,d){var A;return d===1?A="{d\\over d"+x+"}":A="{d^{"+d+"}\\over d"+x+"^{"+d+"}}",A+"\\left[".concat(y,"\\right]")}}),h=n("constTag",{"Object, ConstantNode, string":function(y,x){return y[x]=!0,!0},"Object, SymbolNode, string":function(y,x,d){return x.name!==d?(y[x]=!0,!0):!1},"Object, ParenthesisNode, string":function(y,x,d){return h(y,x.content,d)},"Object, FunctionAssignmentNode, string":function(y,x,d){return x.params.indexOf(d)===-1?(y[x]=!0,!0):h(y,x.expr,d)},"Object, FunctionNode | OperatorNode, string":function(y,x,d){if(x.args.length>0){for(var A=h(y,x.args[0],d),S=1;S<x.args.length;++S)A=h(y,x.args[S],d)&&A;if(A)return y[x]=!0,!0}return!1}}),b=n("_derivative",{"ConstantNode, Object":function(y){return N(0)},"SymbolNode, Object":function(y,x){return x[y]!==void 0?N(0):N(1)},"ParenthesisNode, Object":function(y,x){return new o(b(y.content,x))},"FunctionAssignmentNode, Object":function(y,x){return x[y]!==void 0?N(0):b(y.expr,x)},"FunctionNode, Object":function(y,x){if(y.args.length!==1&&w(y),x[y]!==void 0)return N(0);var d=y.args[0],A,S=!1,O=!1,M;switch(y.name){case"cbrt":S=!0,M=new s("*","multiply",[N(3),new s("^","pow",[d,new s("/","divide",[N(2),N(3)])])]);break;case"sqrt":case"nthRoot":if(y.args.length===1)S=!0,M=new s("*","multiply",[N(2),new c("sqrt",[d])]);else if(y.args.length===2)return A=new s("/","divide",[N(1),y.args[1]]),x[A]=x[y.args[1]],b(new s("^","pow",[d,A]),x);break;case"log10":A=N(10);case"log":if(!A&&y.args.length===1)M=d.clone(),S=!0;else if(y.args.length===1&&A||y.args.length===2&&x[y.args[1]]!==void 0)M=new s("*","multiply",[d.clone(),new c("log",[A||y.args[1]])]),S=!0;else if(y.args.length===2)return b(new s("/","divide",[new c("log",[d]),new c("log",[y.args[1]])]),x);break;case"pow":return x[A]=x[y.args[1]],b(new s("^","pow",[d,y.args[1]]),x);case"exp":M=new c("exp",[d.clone()]);break;case"sin":M=new c("cos",[d.clone()]);break;case"cos":M=new s("-","unaryMinus",[new c("sin",[d.clone()])]);break;case"tan":M=new s("^","pow",[new c("sec",[d.clone()]),N(2)]);break;case"sec":M=new s("*","multiply",[y,new c("tan",[d.clone()])]);break;case"csc":O=!0,M=new s("*","multiply",[y,new c("cot",[d.clone()])]);break;case"cot":O=!0,M=new s("^","pow",[new c("csc",[d.clone()]),N(2)]);break;case"asin":S=!0,M=new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])]);break;case"acos":S=!0,O=!0,M=new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])]);break;case"atan":S=!0,M=new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)]);break;case"asec":S=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acsc":S=!0,O=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acot":S=!0,O=!0,M=new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)]);break;case"sinh":M=new c("cosh",[d.clone()]);break;case"cosh":M=new c("sinh",[d.clone()]);break;case"tanh":M=new s("^","pow",[new c("sech",[d.clone()]),N(2)]);break;case"sech":O=!0,M=new s("*","multiply",[y,new c("tanh",[d.clone()])]);break;case"csch":O=!0,M=new s("*","multiply",[y,new c("coth",[d.clone()])]);break;case"coth":O=!0,M=new s("^","pow",[new c("csch",[d.clone()]),N(2)]);break;case"asinh":S=!0,M=new c("sqrt",[new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"acosh":S=!0,M=new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"atanh":S=!0,M=new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])]);break;case"asech":S=!0,O=!0,M=new s("*","multiply",[d.clone(),new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])])]);break;case"acsch":S=!0,O=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acoth":S=!0,O=!0,M=new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])]);break;case"abs":M=new s("/","divide",[new c(new u("abs"),[d.clone()]),d.clone()]);break;case"gamma":default:throw new Error('Function "'+y.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var _,E;S?(_="/",E="divide"):(_="*",E="multiply");var $=b(d,x);return O&&($=new s("-","unaryMinus",[$])),new s(_,E,[$,M])},"OperatorNode, Object":function(y,x){if(x[y]!==void 0)return N(0);if(y.op==="+")return new s(y.op,y.fn,y.args.map(function(I){return b(I,x)}));if(y.op==="-"){if(y.isUnary())return new s(y.op,y.fn,[b(y.args[0],x)]);if(y.isBinary())return new s(y.op,y.fn,[b(y.args[0],x),b(y.args[1],x)])}if(y.op==="*"){var d=y.args.filter(function(I){return x[I]!==void 0});if(d.length>0){var A=y.args.filter(function(I){return x[I]===void 0}),S=A.length===1?A[0]:new s("*","multiply",A),O=d.concat(b(S,x));return new s("*","multiply",O)}return new s("+","add",y.args.map(function(I){return new s("*","multiply",y.args.map(function(T){return T===I?b(T,x):T.clone()}))}))}if(y.op==="/"&&y.isBinary()){var M=y.args[0],_=y.args[1];return x[_]!==void 0?new s("/","divide",[b(M,x),_]):x[M]!==void 0?new s("*","multiply",[new s("-","unaryMinus",[M]),new s("/","divide",[b(_,x),new s("^","pow",[_.clone(),N(2)])])]):new s("/","divide",[new s("-","subtract",[new s("*","multiply",[b(M,x),_.clone()]),new s("*","multiply",[M.clone(),b(_,x)])]),new s("^","pow",[_.clone(),N(2)])])}if(y.op==="^"&&y.isBinary()){var E=y.args[0],$=y.args[1];if(x[E]!==void 0)return Ye(E)&&(l(E.value)||i(E.value,1))?N(0):new s("*","multiply",[y,new s("*","multiply",[new c("log",[E.clone()]),b($.clone(),x)])]);if(x[$]!==void 0){if(Ye($)){if(l($.value))return N(0);if(i($.value,1))return b(E,x)}var z=new s("^","pow",[E.clone(),new s("-","subtract",[$,N(1)])]);return new s("*","multiply",[$.clone(),new s("*","multiply",[b(E,x),z])])}return new s("*","multiply",[new s("^","pow",[E.clone(),$.clone()]),new s("+","add",[new s("*","multiply",[b(E,x),new s("/","divide",[$.clone(),E.clone()])]),new s("*","multiply",[b($,x),new c("log",[E.clone()])])])])}throw new Error('Operator "'+y.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function w(g){if(!((g.name==="log"||g.name==="nthRoot"||g.name==="pow")&&g.args.length===2)){for(var y=0;y<g.args.length;++y)g.args[y]=N(0);throw g.compile().evaluate(),new Error("Expected TypeError, but none found")}}function N(g,y){return new f(m(g,a.number))}return p}),vm="rationalize",rO=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],tO=R(vm,rO,e=>{var{config:n,typed:a,equal:t,isZero:r,add:i,subtract:l,multiply:m,divide:f,pow:c,parse:s,simplifyCore:o,simplify:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S,ParenthesisNode:O}=e,M=mm({typed:a,config:n,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S});return a(vm,{string:function(T){return this(s(T),{},!1)},"string, boolean":function(T,B){return this(s(T),{},B)},"string, Object":function(T,B){return this(s(T),B,!1)},"string, Object, boolean":function(T,B,G){return this(s(T),B,G)},Node:function(T){return this(T,{},!1)},"Node, boolean":function(T,B){return this(T,{},B)},"Node, Object":function(T,B){return this(T,B,!1)},"Node, Object, boolean":function(T,B,G){var D=E(),H=_(T,B,!0,D.firstRules),W=H.variables.length,j={exactFractions:!1},V={exactFractions:!0};if(T=H.expression,W>=1){T=$(T);var K,te,re=!0,ie=!1;T=u(T,D.firstRules,{},j);for(var ne;te=re?D.distrDivRules:D.sucDivRules,T=u(T,te,{},V),re=!re,ne=T.toString(),ne!==K;)ie=!0,K=ne;ie&&(T=u(T,D.firstRulesAgain,{},j)),T=u(T,D.finalRules,{},j)}var ue=[],ee={};return T.type==="OperatorNode"&&T.isBinary()&&T.op==="/"?(W===1&&(T.args[0]=z(T.args[0],ue),T.args[1]=z(T.args[1])),G&&(ee.numerator=T.args[0],ee.denominator=T.args[1])):(W===1&&(T=z(T,ue)),G&&(ee.numerator=T,ee.denominator=null)),G?(ee.coefficients=ue,ee.variables=H.variables,ee.expression=T,ee):T}});function _(I,T,B,G){var D=[],H=u(I,G,T,{exactFractions:!1});B=!!B;var W="+-*"+(B?"/":"");V(H);var j={};return j.expression=H,j.variables=D,j;function V(K){var te=K.type;if(te==="FunctionNode")throw new Error("There is an unsolved function call");if(te==="OperatorNode")if(K.op==="^"){if(K.args[1].type!=="ConstantNode"||!Ae(parseFloat(K.args[1].value)))throw new Error("There is a non-integer exponent");V(K.args[0])}else{if(W.indexOf(K.op)===-1)throw new Error("Operator "+K.op+" invalid in polynomial expression");for(var re=0;re<K.args.length;re++)V(K.args[re])}else if(te==="SymbolNode"){var ie=K.name,ne=D.indexOf(ie);ne===-1&&D.push(ie)}else if(te==="ParenthesisNode")V(K.content);else if(te!=="ConstantNode")throw new Error("type "+te+" is not allowed in polynomial expression")}}function E(){var I=[o,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},M,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],T=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],B=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],G=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],D={};return D.firstRules=I.concat(T,G),D.distrDivRules=B,D.sucDivRules=G,D.firstRulesAgain=I.concat(T),D.finalRules=[o,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},M,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],D}function $(I,T,B){var G=I.type,D=arguments.length>1;if(G==="OperatorNode"&&I.isBinary()){var H=!1,W;if(I.op==="^"&&(I.args[0].type==="ParenthesisNode"||I.args[0].type==="OperatorNode")&&I.args[1].type==="ConstantNode"&&(W=parseFloat(I.args[1].value),H=W>=2&&Ae(W)),H){if(W>2){var j=I.args[0],V=new A("^","pow",[I.args[0].cloneDeep(),new g(W-1)]);I=new A("*","multiply",[j,V])}else I=new A("*","multiply",[I.args[0],I.args[0].cloneDeep()]);D&&(B==="content"?T.content=I:T.args[B]=I)}}if(G==="ParenthesisNode")$(I.content,I,"content");else if(G!=="ConstantNode"&&G!=="SymbolNode")for(var K=0;K<I.args.length;K++)$(I.args[K],I,K);if(!D)return I}function z(I,T){T===void 0&&(T=[]),T[0]=0;var B={};B.cte=1,B.oper="+",B.fire="";var G=0,D="";ie(I,null,B),G=T.length-1;for(var H=!0,W,j=G;j>=0;j--)if(T[j]!==0){var V=new g(H?T[j]:Math.abs(T[j])),K=T[j]<0?"-":"+";if(j>0){var te=new S(D);if(j>1){var re=new g(j);te=new A("^","pow",[te,re])}T[j]===-1&&H?V=new A("-","unaryMinus",[te]):Math.abs(T[j])===1?V=te:V=new A("*","multiply",[V,te])}H?W=V:K==="+"?W=new A("+","add",[W,V]):W=new A("-","subtract",[W,V]),H=!1}if(H)return new g(0);return W;function ie(ne,ue,ee){var ye=ne.type;if(ye==="FunctionNode")throw new Error("There is an unsolved function call");if(ye==="OperatorNode"){if("+-*^".indexOf(ne.op)===-1)throw new Error("Operator "+ne.op+" invalid");if(ue!==null){if((ne.fn==="unaryMinus"||ne.fn==="pow")&&ue.fn!=="add"&&ue.fn!=="subtract"&&ue.fn!=="multiply")throw new Error("Invalid "+ne.op+" placing");if((ne.fn==="subtract"||ne.fn==="add"||ne.fn==="multiply")&&ue.fn!=="add"&&ue.fn!=="subtract")throw new Error("Invalid "+ne.op+" placing");if((ne.fn==="subtract"||ne.fn==="add"||ne.fn==="unaryMinus")&&ee.noFil!==0)throw new Error("Invalid "+ne.op+" placing")}(ne.op==="^"||ne.op==="*")&&(ee.fire=ne.op);for(var we=0;we<ne.args.length;we++)ne.fn==="unaryMinus"&&(ee.oper="-"),(ne.op==="+"||ne.fn==="subtract")&&(ee.fire="",ee.cte=1,ee.oper=we===0?"+":ne.op),ee.noFil=we,ie(ne.args[we],ne,ee)}else if(ye==="SymbolNode"){if(ne.name!==D&&D!=="")throw new Error("There is more than one variable");if(D=ne.name,ue===null){T[1]=1;return}if(ue.op==="^"&&ee.noFil!==0)throw new Error("In power the variable should be the first parameter");if(ue.op==="*"&&ee.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(ee.fire===""||ee.fire==="*")&&(G<1&&(T[1]=0),T[1]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(1,G))}else if(ye==="ConstantNode"){var me=parseFloat(ne.value);if(ue===null){T[0]=me;return}if(ue.op==="^"){if(ee.noFil!==1)throw new Error("Constant cannot be powered");if(!Ae(me)||me<=0)throw new Error("Non-integer exponent is not allowed");for(var xe=G+1;xe<me;xe++)T[xe]=0;me>G&&(T[me]=0),T[me]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(me,G);return}ee.cte=me,ee.fire===""&&(T[0]+=ee.cte*(ee.oper==="+"?1:-1))}else throw new Error("Type "+ye+" is not allowed")}}}),nO="reviver",aO=["classes"],iO=R(nO,aO,e=>{var{classes:n}=e;return function(t,r){var i=n[r&&r.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(r):r}}),oO="replacer",sO=[],uO=R(oO,sO,()=>function(n,a){return typeof a=="number"&&(!isFinite(a)||isNaN(a))?{mathjs:"number",value:String(a)}:a}),cO="10.6.4",fO=R("true",[],()=>!0),lO=R("false",[],()=>!1),mO=R("null",[],()=>null),pO=Pr("Infinity",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1/0):1/0}),vO=Pr("NaN",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(NaN):NaN}),hO=Pr("pi",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?Oi(a):Wh}),dO=Pr("tau",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ob(a):Jh}),gO=Pr("e",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ab(a):Qh}),yO=Pr("phi",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ib(a):Kh}),xO=Pr("LN2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(2).ln():Math.LN2}),bO=Pr("LN10",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(10).ln():Math.LN10}),wO=Pr("LOG2E",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1).div(new a(2).ln()):Math.LOG2E}),NO=Pr("LOG10E",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1).div(new a(10).ln()):Math.LOG10E}),MO=Pr("SQRT1_2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a("0.5").sqrt():Math.SQRT1_2}),AO=Pr("SQRT2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(2).sqrt():Math.SQRT2}),SO=Pr("i",["Complex"],e=>{var{Complex:n}=e;return n.I}),EO=R("version",[],()=>cO);function Pr(e,n,a){return R(e,n,a,{recreateOnConfigChange:!0})}var CO=Ie("speedOfLight","299792458","m s^-1"),OO=Ie("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),DO=Ie("planckConstant","6.62607015e-34","J s"),TO=Ie("reducedPlanckConstant","1.0545718176461565e-34","J s"),BO=Ie("magneticConstant","1.25663706212e-6","N A^-2"),_O=Ie("electricConstant","8.8541878128e-12","F m^-1"),$O=Ie("vacuumImpedance","376.730313667","ohm"),IO=Ie("coulomb","8.987551792261171e9","N m^2 C^-2"),qO=Ie("elementaryCharge","1.602176634e-19","C"),RO=Ie("bohrMagneton","9.2740100783e-24","J T^-1"),FO=Ie("conductanceQuantum","7.748091729863649e-5","S"),zO=Ie("inverseConductanceQuantum","12906.403729652257","ohm"),PO=Ie("magneticFluxQuantum","2.0678338484619295e-15","Wb"),UO=Ie("nuclearMagneton","5.0507837461e-27","J T^-1"),LO=Ie("klitzing","25812.807459304513","ohm"),kO=Ie("bohrRadius","5.29177210903e-11","m"),HO=Ie("classicalElectronRadius","2.8179403262e-15","m"),GO=Ie("electronMass","9.1093837015e-31","kg"),VO=Ie("fermiCoupling","1.1663787e-5","GeV^-2"),ZO=Pa("fineStructure",.0072973525693),XO=Ie("hartreeEnergy","4.3597447222071e-18","J"),YO=Ie("protonMass","1.67262192369e-27","kg"),WO=Ie("deuteronMass","3.3435830926e-27","kg"),JO=Ie("neutronMass","1.6749271613e-27","kg"),QO=Ie("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),KO=Ie("rydberg","10973731.568160","m^-1"),jO=Ie("thomsonCrossSection","6.6524587321e-29","m^2"),eD=Pa("weakMixingAngle",.2229),rD=Pa("efimovFactor",22.7),tD=Ie("atomicMass","1.66053906660e-27","kg"),nD=Ie("avogadro","6.02214076e23","mol^-1"),aD=Ie("boltzmann","1.380649e-23","J K^-1"),iD=Ie("faraday","96485.33212331001","C mol^-1"),oD=Ie("firstRadiation","3.7417718521927573e-16","W m^2"),sD=Ie("loschmidt","2.686780111798444e25","m^-3"),uD=Ie("gasConstant","8.31446261815324","J K^-1 mol^-1"),cD=Ie("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),fD=Ie("molarVolume","0.022413969545014137","m^3 mol^-1"),lD=Pa("sackurTetrode",-1.16487052358),mD=Ie("secondRadiation","0.014387768775039337","m K"),pD=Ie("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),vD=Ie("wienDisplacement","2.897771955e-3","m K"),hD=Ie("molarMass","0.99999999965e-3","kg mol^-1"),dD=Ie("molarMassC12","11.9999999958e-3","kg mol^-1"),gD=Ie("gravity","9.80665","m s^-2"),yD=Ie("planckLength","1.616255e-35","m"),xD=Ie("planckMass","2.176435e-8","kg"),bD=Ie("planckTime","5.391245e-44","s"),wD=Ie("planckCharge","1.87554603778e-18","C"),ND=Ie("planckTemperature","1.416785e+32","K");function Ie(e,n,a){var t=["config","Unit","BigNumber"];return R(e,t,r=>{var{config:i,Unit:l,BigNumber:m}=r,f=i.number==="BigNumber"?new m(n):parseFloat(n),c=new l(f,a);return c.fixPrefix=!0,c})}function Pa(e,n){var a=["config","BigNumber"];return R(e,a,t=>{var{config:r,BigNumber:i}=t;return r.number==="BigNumber"?new i(n):n})}var MD="apply",AD=["typed","isInteger"],SD=R(MD,AD,e=>{var{typed:n,isInteger:a}=e,t=cu({typed:n,isInteger:a});return n("apply",{"...any":function(i){var l=i[1];Be(l)?i[1]=l-1:_e(l)&&(i[1]=l.minus(1));try{return t.apply(null,i)}catch(m){throw Br(m)}}})},{isTransformFunction:!0}),ED="column",CD=["typed","Index","matrix","range"],OD=R(ED,CD,e=>{var{typed:n,Index:a,matrix:t,range:r}=e,i=Gu({typed:n,Index:a,matrix:t,range:r});return n("column",{"...any":function(m){var f=m.length-1,c=m[f];Be(c)&&(m[f]=c-1);try{return i.apply(null,m)}catch(s){throw Br(s)}}})},{isTransformFunction:!0});function Ui(e,n,a){var t=e.filter(function(m){return xr(m)&&!(m.name in n)&&!a.has(m.name)})[0];if(!t)throw new Error('No undefined variable found in inline expression "'+e+'"');var r=t.name,i=Pn(a),l=e.compile();return function(f){return i.set(r,f),l.evaluate(i)}}var DD="filter",TD=["typed"],BD=R(DD,TD,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||Cn(r[1])?f=r[1].compile().evaluate(l):f=Ui(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("filter",{"Array, function":hm,"Matrix, function":function(i,l){return i.create(hm(i.toArray(),l))},"Array, RegExp":oa,"Matrix, RegExp":function(i,l){return i.create(oa(i.toArray(),l))}});return a},{isTransformFunction:!0});function hm(e,n){var a=hn(n);return wo(e,function(t,r,i){return a===1?n(t):a===2?n(t,[r+1]):n(t,[r+1],i)})}var _D="forEach",$D=["typed"],ID=R(_D,$D,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||Cn(r[1])?f=r[1].compile().evaluate(l):f=Ui(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("forEach",{"Array | Matrix, function":function(i,l){var m=hn(l),f=function c(s,o){Array.isArray(s)?ia(s,function(u,p){c(u,o.concat(p+1))}):m===1?l(s):m===2?l(s,o):l(s,o,i)};f(i.valueOf(),[])}});return a},{isTransformFunction:!0}),qD="index",RD=["Index"],FD=R(qD,RD,e=>{var{Index:n}=e;return function(){for(var t=[],r=0,i=arguments.length;r<i;r++){var l=arguments[r];if(Kn(l))l.start--,l.end-=l.step>0?0:2;else if(l&&l.isSet===!0)l=l.map(function(f){return f-1});else if(Xe(l)||Oe(l))l=l.map(function(f){return f-1});else if(Be(l))l--;else if(_e(l))l=l.toNumber()-1;else if(typeof l!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");t[r]=l}var m=new n;return n.apply(m,t),m}},{isTransformFunction:!0}),zD="map",PD=["typed"],UD=R(zD,PD,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||Cn(r[1])?f=r[1].compile().evaluate(l):f=Ui(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("map",{"Array, function":function(i,l){return dm(i,l,i)},"Matrix, function":function(i,l){return i.create(dm(i.valueOf(),l,i))}});return a},{isTransformFunction:!0});function dm(e,n,a){var t=hn(n);function r(i,l){return Array.isArray(i)?dt(i,function(m,f){return r(m,l.concat(f+1))}):t===1?n(i):t===2?n(i,l):n(i,l,a)}return r(e,[])}function Zt(e){if(e.length===2&&rn(e[0])){e=e.slice();var n=e[1];Be(n)?e[1]=n-1:_e(n)&&(e[1]=n.minus(1))}return e}var LD="max",kD=["typed","config","numeric","larger"],HD=R(LD,kD,e=>{var{typed:n,config:a,numeric:t,larger:r}=e,i=sf({typed:n,config:a,numeric:t,larger:r});return n("max",{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),GD="mean",VD=["typed","add","divide"],ZD=R(GD,VD,e=>{var{typed:n,add:a,divide:t}=e,r=Tl({typed:n,add:a,divide:t});return n("mean",{"...any":function(l){l=Zt(l);try{return r.apply(null,l)}catch(m){throw Br(m)}}})},{isTransformFunction:!0}),XD="min",YD=["typed","config","numeric","smaller"],WD=R(XD,YD,e=>{var{typed:n,config:a,numeric:t,smaller:r}=e,i=cf({typed:n,config:a,numeric:t,smaller:r});return n("min",{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),JD="range",QD=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],KD=R(JD,QD,e=>{var{typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f}=e,c=oc({typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f});return n("range",{"...any":function(o){var u=o.length-1,p=o[u];return typeof p!="boolean"&&o.push(!0),c.apply(null,o)}})},{isTransformFunction:!0}),jD="row",eT=["typed","Index","matrix","range"],rT=R(jD,eT,e=>{var{typed:n,Index:a,matrix:t,range:r}=e,i=lc({typed:n,Index:a,matrix:t,range:r});return n("row",{"...any":function(m){var f=m.length-1,c=m[f];Be(c)&&(m[f]=c-1);try{return i.apply(null,m)}catch(s){throw Br(s)}}})},{isTransformFunction:!0}),tT="subset",nT=["typed","matrix"],aT=R(tT,nT,e=>{var{typed:n,matrix:a}=e,t=hc({typed:n,matrix:a});return n("subset",{"...any":function(i){try{return t.apply(null,i)}catch(l){throw Br(l)}}})},{isTransformFunction:!0}),iT="concat",oT=["typed","matrix","isInteger"],sT=R(iT,oT,e=>{var{typed:n,matrix:a,isInteger:t}=e,r=Lu({typed:n,matrix:a,isInteger:t});return n("concat",{"...any":function(l){var m=l.length-1,f=l[m];Be(f)?l[m]=f-1:_e(f)&&(l[m]=f.minus(1));try{return r.apply(null,l)}catch(c){throw Br(c)}}})},{isTransformFunction:!0}),gm="diff",uT=["typed","matrix","subtract","number","bignumber"],cT=R(gm,uT,e=>{var{typed:n,matrix:a,subtract:t,number:r,bignumber:i}=e,l=tc({typed:n,matrix:a,subtract:t,number:r,bignumber:i});return n(gm,{"...any":function(f){f=Zt(f);try{return l.apply(null,f)}catch(c){throw Br(c)}}})},{isTransformFunction:!0}),fT="std",lT=["typed","sqrt","variance"],mT=R(fT,lT,e=>{var{typed:n,sqrt:a,variance:t}=e,r=Rl({typed:n,sqrt:a,variance:t});return n("std",{"...any":function(l){l=Zt(l);try{return r.apply(null,l)}catch(m){throw Br(m)}}})},{isTransformFunction:!0}),ym="sum",pT=["typed","config","add","numeric"],vT=R(ym,pT,e=>{var{typed:n,config:a,add:t,numeric:r}=e,i=Cl({typed:n,config:a,add:t,numeric:r});return n(ym,{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),xm="cumsum",hT=["typed","add","unaryPlus"],dT=R(xm,hT,e=>{var{typed:n,add:a,unaryPlus:t}=e,r=Ol({typed:n,add:a,unaryPlus:t});return n(xm,{"...any":function(l){if(l.length===2&&rn(l[0])){var m=l[1];Be(m)?l[1]=m-1:_e(m)&&(l[1]=m.minus(1))}try{return r.apply(null,l)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),bm="variance",gT=["typed","add","subtract","multiply","divide","apply","isNaN"],yT=R(bm,gT,e=>{var{typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m}=e,f=Il({typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m});return n(bm,{"...any":function(s){s=Zt(s);try{return f.apply(null,s)}catch(o){throw Br(o)}}})},{isTransformFunction:!0}),le=bh({config:oe}),rr=Sh({}),wm=gO({BigNumber:le,config:oe}),xT=lO({}),bT=ZO({BigNumber:le,config:oe}),Xt=$h({}),Nm=SO({Complex:rr}),wT=pO({BigNumber:le,config:oe}),NT=bO({BigNumber:le,config:oe}),MT=NO({BigNumber:le,config:oe}),Ua=Ph({}),AT=vO({BigNumber:le,config:oe}),ST=mO({}),ET=yO({BigNumber:le,config:oe}),CT=Rh({}),Mm=Av({}),OT=MO({BigNumber:le,config:oe}),DT=lD({BigNumber:le,config:oe}),Am=dO({BigNumber:le,config:oe}),TT=fO({}),BT=EO({}),ze=kh({Matrix:Ua}),_T=rD({BigNumber:le,config:oe}),$T=xO({BigNumber:le,config:oe}),Sm=hO({BigNumber:le,config:oe}),IT=uO({}),qT=AO({BigNumber:le,config:oe}),Z=bv({BigNumber:le,Complex:rr,DenseMatrix:ze,Fraction:Xt}),Li=jd({BigNumber:le,config:oe,typed:Z}),RT=eD({BigNumber:le,config:oe}),Ur=rg({typed:Z}),FT=gb({Complex:rr,config:oe,typed:Z}),zT=wb({BigNumber:le,typed:Z}),PT=Sb({BigNumber:le,Complex:rr,config:oe,typed:Z}),vr=ig({typed:Z}),UT=Ly({typed:Z}),LT=Bb({BigNumber:le,Complex:rr,config:oe,typed:Z}),kT=Rb({typed:Z}),Em=Pb({typed:Z}),HT=Hb({Complex:rr,config:oe,typed:Z}),Mt=$d({BigNumber:le,typed:Z}),GT=$y({typed:Z}),VT=Td({typed:Z}),ZT=Gh({typed:Z}),La=kC({typed:Z}),ka=Rd({Complex:rr,typed:Z}),wn=Hy({typed:Z}),XT=Xb({typed:Z}),YT=Qb({BigNumber:le,typed:Z}),WT=jb({BigNumber:le,typed:Z}),JT=yg({typed:Z}),ke=yd({config:oe,typed:Z}),QT=u1({typed:Z}),Cm=bg({typed:Z}),KT=Ng({Complex:rr,typed:Z}),jT=l0({typed:Z}),eB=h0({typed:Z}),Un=g1({typed:Z}),rB=y0({typed:Z}),tB=M1({format:Un,typed:Z}),Om=Vy({typed:Z}),Zr=Zh({typed:Z}),Nn=nd({typed:Z}),Ha=cd({typed:Z}),ft=ld({typed:Z}),nB=wO({BigNumber:le,config:oe}),aB=YC({Complex:rr,typed:Z}),iB=Zg({Complex:rr,config:oe,typed:Z}),oB=Yg({Complex:rr,config:oe,typed:Z}),Dm=A0({typed:Z}),lr=ny({typed:Z}),Tm=Wy({typed:Z}),Ft=Ed({typed:Z}),sB=w1({format:Un,typed:Z}),uB=N3({config:oe,typed:Z}),cB=S1({typed:Z}),fB=A3({config:oe,typed:Z}),Bm=Xy({typed:Z}),lB=nw({BigNumber:le,typed:Z}),_m=cy({BigNumber:le,Fraction:Xt,complex:ka,typed:Z}),ki=sw({typed:Z}),At=wd({Matrix:Ua,equalScalar:ke,typed:Z}),mB=Wd({typed:Z}),pB=vy({typed:Z}),vB=Od({typed:Z}),hB=lw({typed:Z}),dB=hd({typed:Z}),gB=xb({Complex:rr,config:oe,typed:Z}),yB=Cb({BigNumber:le,typed:Z}),Hi=cu({isInteger:Zr,typed:Z}),xB=Db({BigNumber:le,Complex:rr,config:oe,typed:Z}),bB=x1({format:Un,typed:Z}),wB=GC({typed:Z}),Gi=Vb({typed:Z}),NB=rw({BigNumber:le,typed:Z}),Ln=pd({typed:Z}),MB=D1({typed:Z}),AB=E3({config:oe,typed:Z}),SB=iw({BigNumber:le,typed:Z}),EB=cw({typed:Z}),CB=pb({SparseMatrix:At,typed:Z}),St=my({Complex:rr,config:oe,typed:Z}),OB=vw({typed:Z}),Et=Qd({typed:Z}),DB=Mb({BigNumber:le,Complex:rr,config:oe,typed:Z}),TB=Wb({BigNumber:le,typed:Z}),kn=Pd({Fraction:Xt,typed:Z}),Yt=id({typed:Z}),de=Ld({DenseMatrix:ze,Matrix:Ua,SparseMatrix:At,typed:Z}),BB=Hd({isZero:ft,matrix:de,typed:Z}),$m=ey({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),_B=sy({BigNumber:le,equalScalar:ke,matrix:de,typed:Z}),tt=_1({bignumber:Mt,fraction:kn,number:Ft}),$B=Qy({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),Im=h1({config:oe,multiplyScalar:lr,numeric:tt,typed:Z}),IB=_0({isInteger:Zr,matrix:de,typed:Z}),Ar=k0({matrix:de,config:oe,typed:Z}),Xr=Cx({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),qB=G0({matrix:de,typed:Z}),Yr=hc({matrix:de,typed:Z}),ir=dy({DenseMatrix:ze,addScalar:vr,equalScalar:ke,matrix:de,typed:Z,unaryMinus:Et}),RB=C1({matrix:de,typed:Z}),Vi=Q0({matrix:de,typed:Z}),qm=yy({BigNumber:le,config:oe,matrix:de,typed:Z}),lt=r1({BigNumber:le,config:oe,matrix:de,typed:Z}),FB=mx({equalScalar:ke,matrix:de,not:Tm,typed:Z,zeros:lt}),zB=By({equalScalar:ke,matrix:de,typed:Z}),PB=Py({DenseMatrix:ze,matrix:de,typed:Z}),UB=sg({BigNumber:le,Complex:rr,Fraction:Xt,config:oe,isNegative:Nn,matrix:de,typed:Z,unaryMinus:Et}),Mn=vx({BigNumber:le,DenseMatrix:ze,Fraction:Xt,config:oe,equalScalar:ke,matrix:de,typed:Z}),Rm=wx({matrix:de,typed:Z}),Zi=Lu({isInteger:Zr,matrix:de,typed:Z}),LB=n0({prod:Im,size:Ar,typed:Z}),Xi=j0({conj:wn,transpose:Vi,typed:Z}),Fm=s0({DenseMatrix:ze,SparseMatrix:At,matrix:de,typed:Z}),or=I1({numeric:tt,typed:Z}),Ga=Y1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,typed:Z}),nt=Mx({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),zm=n1({addScalar:vr,divideScalar:or,exp:Cm,i:Nm,matrix:de,multiplyScalar:lr,tau:Am,typed:Z}),Hn=p0({matrix:de,typed:Z}),kB=zg({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),HB=sd({isNumeric:Yt,typed:Z}),GB=zw({abs:Ur,addScalar:vr,divideScalar:or,isPositive:Ha,multiplyScalar:lr,smaller:Xr,sqrt:St,typed:Z}),VB=i1({conj:wn,dotDivide:Ga,fft:zm,typed:Z}),ZB=N0({matrix:de,multiplyScalar:lr,typed:Z}),Va=$x({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),XB=ox({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Pm=J1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),Um=Xd({flatten:Hn,matrix:de,size:Ar,typed:Z}),YB=cf({config:oe,numeric:tt,smaller:Xr,typed:Z}),WB=p1({isNaN:Ln,isNumeric:Yt,typed:Z}),JB=G1({Complex:rr,config:oe,divideScalar:or,typed:Z}),QB=D0({BigNumber:le,config:oe,matrix:de,typed:Z}),Yi=Px({compare:Mn,isNaN:Ln,isNumeric:Yt,typed:Z}),KB=q0({config:oe,matrix:de}),jB=ux({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Gn=z1({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Wi=Dx({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),e4=Fx({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,typed:Z}),Ji=K1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),r4=jy({DenseMatrix:ze,matrix:de,typed:Z}),sr=Rw({DenseMatrix:ze,SparseMatrix:At,addScalar:vr,equalScalar:ke,matrix:de,typed:Z}),t4=Lb({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),n4=qy({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),a4=_3({addScalar:vr,combinations:La,divideScalar:or,isInteger:Zr,isNegative:Nn,multiplyScalar:lr,typed:Z}),mt=yx({compare:Mn,typed:Z}),i4=Ol({add:sr,typed:Z,unaryPlus:Li}),Lm=qx({equal:nt,typed:Z}),o4=tc({matrix:de,number:Ft,subtract:ir,typed:Z}),Za=kw({addScalar:vr,conj:wn,multiplyScalar:lr,size:Ar,typed:Z}),s4=Sx({compareText:Rm,isZero:ft,typed:Z}),km=Og({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,round:Gn,typed:Z,zeros:lt}),An=b0({BigNumber:le,DenseMatrix:ze,SparseMatrix:At,config:oe,matrix:de,typed:Z}),u4=by({BigNumber:le,add:sr,config:oe,equal:nt,isInteger:Zr,mod:$m,smaller:Xr,typed:Z,xgcd:qm}),Wr=Bx({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),Qi=U1({Complex:rr,config:oe,divideScalar:or,typed:Z}),c4=ex({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),f4=Vd({flatten:Hn,matrix:de,size:Ar,typed:Z}),mr=iy({addScalar:vr,dot:Za,equalScalar:ke,matrix:de,multiplyScalar:lr,typed:Z}),Hm=sM({addScalar:vr,complex:ka,conj:wn,divideScalar:or,equal:nt,identity:An,isZero:ft,matrix:de,multiplyScalar:lr,sign:_m,sqrt:St,subtract:ir,typed:Z,unaryMinus:Et,zeros:lt}),Vn=oc({bignumber:Mt,matrix:de,config:oe,larger:Wr,largerEq:Va,smaller:Xr,smallerEq:Wi,typed:Z}),l4=fx({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),m4=Tw({compareNatural:mt,typed:Z}),Gm=BM({SparseMatrix:At,abs:Ur,add:sr,divideScalar:or,larger:Wr,largerEq:Va,multiply:mr,subtract:ir,transpose:Vi,typed:Z}),Vm=Cl({add:sr,config:oe,numeric:tt,typed:Z}),p4=Vw({add:sr,matrix:de,typed:Z}),Zm=tx({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),v4=$b({Complex:rr,config:oe,typed:Z}),Xm=dg({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,round:Gn,typed:Z,zeros:lt}),h4=I3({addScalar:vr,combinations:La,isInteger:Zr,isNegative:Nn,isPositive:Ha,larger:Wr,typed:Z}),d4=i0({matrix:de,multiply:mr,subtract:ir,typed:Z}),Ym=sC({divideScalar:or,isZero:ft,matrix:de,multiply:mr,subtract:ir,typed:Z,unaryMinus:Et}),g4=SC({abs:Ur,addScalar:vr,divideScalar:or,multiplyScalar:lr,sqrt:St,subtract:ir,typed:Z,unaryMinus:Et}),y4=Ay({equalScalar:ke,matrix:de,multiplyScalar:lr,typed:Z}),Wm=Kx({larger:Wr,smaller:Xr}),Jm=Sg({Complex:rr,DenseMatrix:ze,ceil:Xm,equalScalar:ke,floor:km,matrix:de,typed:Z,zeros:lt}),Qm=Zx({DenseMatrix:ze,smaller:Xr}),Sr=Wx({ImmutableDenseMatrix:Qm}),x4=OC({abs:Ur,add:sr,addScalar:vr,config:oe,divideScalar:or,equalScalar:ke,flatten:Hn,isNumeric:Yt,isZero:ft,matrix:de,multiply:mr,multiplyScalar:lr,smaller:Xr,subtract:ir,typed:Z}),b4=Gg({equalScalar:ke,matrix:de,typed:Z}),w4=k1({Complex:rr,config:oe,divideScalar:or,log:Qi,typed:Z}),Km=sf({config:oe,larger:Wr,numeric:tt,typed:Z}),N4=PC({add:sr,compare:Mn,multiply:mr,partitionSelect:Yi,typed:Z}),M4=lc({Index:Sr,matrix:de,range:Vn,typed:Z}),A4=dw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),S4=bw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),E4=Aw({Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),C4=Ow({Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),O4=Lx({compare:Mn,compareNatural:mt,matrix:de,typed:Z}),jm=Gu({Index:Sr,matrix:de,range:Vn,typed:Z}),D4=Xw({Index:Sr,typed:Z}),Wt=cC({abs:Ur,addScalar:vr,det:Ym,divideScalar:or,identity:An,matrix:de,multiply:mr,typed:Z,unaryMinus:Et}),T4=lC({Complex:rr,add:sr,ctranspose:Xi,deepEqual:Lm,divideScalar:or,dot:Za,dotDivide:Ga,equal:nt,inv:Wt,matrix:de,multiply:mr,typed:Z}),Ct=R1({Complex:rr,config:oe,fraction:kn,identity:An,inv:Wt,matrix:de,multiply:mr,number:Ft,typed:Z}),ep=yw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),B4=Ew({Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),rp=rb({FibonacciHeap:Wm,addScalar:vr,equalScalar:ke}),_4=bC({abs:Ur,add:sr,identity:An,inv:Wt,max:Km,multiply:mr,size:Ar,sqrt:St,subtract:ir,typed:Z}),Te=cb({BigNumber:le,Complex:rr,Fraction:Xt,abs:Ur,addScalar:vr,config:oe,divideScalar:or,equal:nt,fix:Jm,format:Un,isNumeric:Yt,multiplyScalar:lr,number:Ft,pow:Ct,round:Gn,subtract:ir}),$4=$O({BigNumber:le,Unit:Te,config:oe}),I4=vD({BigNumber:le,Unit:Te,config:oe}),q4=tD({BigNumber:le,Unit:Te,config:oe}),R4=RO({BigNumber:le,Unit:Te,config:oe}),F4=aD({BigNumber:le,Unit:Te,config:oe}),z4=FO({BigNumber:le,Unit:Te,config:oe}),P4=hb({Unit:Te,typed:Z}),U4=WO({BigNumber:le,Unit:Te,config:oe}),L4=Z1({DenseMatrix:ze,equalScalar:ke,matrix:de,pow:Ct,typed:Z}),k4=_O({BigNumber:le,Unit:Te,config:oe}),H4=qO({BigNumber:le,Unit:Te,config:oe}),G4=yC({abs:Ur,add:sr,identity:An,inv:Wt,multiply:mr,typed:Z}),V4=iD({BigNumber:le,Unit:Te,config:oe}),Z4=oD({BigNumber:le,Unit:Te,config:oe}),tp=ZC({BigNumber:le,Complex:rr,config:oe,multiplyScalar:lr,pow:Ct,typed:Z}),X4=OO({BigNumber:le,Unit:Te,config:oe}),Y4=XO({BigNumber:le,Unit:Te,config:oe}),W4=LO({BigNumber:le,Unit:Te,config:oe}),J4=sD({BigNumber:le,Unit:Te,config:oe}),Q4=BO({BigNumber:le,Unit:Te,config:oe}),K4=hD({BigNumber:le,Unit:Te,config:oe}),j4=cD({BigNumber:le,Unit:Te,config:oe}),e_=JO({BigNumber:le,Unit:Te,config:oe}),r_=UO({BigNumber:le,Unit:Te,config:oe}),t_=wD({BigNumber:le,Unit:Te,config:oe}),n_=yD({BigNumber:le,Unit:Te,config:oe}),a_=ND({BigNumber:le,Unit:Te,config:oe}),i_=YO({BigNumber:le,Unit:Te,config:oe}),o_=TO({BigNumber:le,Unit:Te,config:oe}),s_=KO({BigNumber:le,Unit:Te,config:oe}),np=Nw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),u_=CO({BigNumber:le,Unit:Te,config:oe}),c_=pD({BigNumber:le,Unit:Te,config:oe}),f_=jO({BigNumber:le,Unit:Te,config:oe}),l_=nD({BigNumber:le,Unit:Te,config:oe}),m_=kO({BigNumber:le,Unit:Te,config:oe}),p_=IO({BigNumber:le,Unit:Te,config:oe}),at=MC({divideScalar:or,equalScalar:ke,inv:Wt,matrix:de,multiply:mr,typed:Z}),v_=GO({BigNumber:le,Unit:Te,config:oe}),Xa=JC({gamma:tp,typed:Z}),h_=gD({BigNumber:le,Unit:Te,config:oe}),d_=zO({BigNumber:le,Unit:Te,config:oe}),ap=iM({DenseMatrix:ze,Spa:rp,SparseMatrix:At,abs:Ur,addScalar:vr,divideScalar:or,equalScalar:ke,larger:Wr,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z,unaryMinus:Et}),g_=PO({BigNumber:le,Unit:Te,config:oe}),y_=dD({BigNumber:le,Unit:Te,config:oe}),x_=e3({add:sr,divide:at,factorial:Xa,isInteger:Zr,isPositive:Ha,multiply:mr,typed:Z}),b_=t3({factorial:Xa,typed:Z}),w_=xD({BigNumber:le,Unit:Te,config:oe}),N_=QO({BigNumber:le,Unit:Te,config:oe}),M_=mD({BigNumber:le,Unit:Te,config:oe}),ip=O3({bignumber:Mt,addScalar:vr,combinations:La,divideScalar:or,factorial:Xa,isInteger:Zr,isNegative:Nn,larger:Wr,multiplyScalar:lr,number:Ft,pow:Ct,subtract:ir,typed:Z}),A_=lb({Unit:Te,typed:Z}),S_=T3({addScalar:vr,isInteger:Zr,isNegative:Nn,stirlingS2:ip,typed:Z}),op=dC({abs:Ur,add:sr,addScalar:vr,atan:Em,bignumber:Mt,column:jm,complex:ka,config:oe,cos:Gi,diag:Fm,divideScalar:or,dot:Za,equal:nt,flatten:Hn,im:Om,inv:Wt,larger:Wr,matrix:de,matrixFromColumns:Um,multiply:mr,multiplyScalar:lr,number:Ft,qr:Hm,re:Bm,sin:ki,smaller:Xr,sqrt:St,subtract:ir,typed:Z,usolve:Ji,usolveAll:Zm}),E_=VO({BigNumber:le,Unit:Te,config:oe}),C_=Tl({add:sr,divide:at,typed:Z}),O_=fD({BigNumber:le,Unit:Te,config:oe}),D_=DO({BigNumber:le,Unit:Te,config:oe}),sp=_w({Index:Sr,concat:Zi,setDifference:ep,size:Ar,subset:Yr,typed:Z}),T_=HO({BigNumber:le,Unit:Te,config:oe}),B_=$M({DenseMatrix:ze,lsolve:Pm,lup:ap,matrix:de,slu:Gm,typed:Z,usolve:Ji}),up=$C({add:sr,compare:Mn,divide:at,partitionSelect:Yi,typed:Z}),__=Iw({Index:Sr,concat:Zi,setIntersect:np,setSymDifference:sp,size:Ar,subset:Yr,typed:Z}),Ki=Il({add:sr,apply:Hi,divide:at,isNaN:Ln,multiply:mr,subtract:ir,typed:Z}),$_=KC({divide:at,dotDivide:Ga,isNumeric:Yt,log:Qi,matrix:de,multiply:mr,sum:Vm,typed:Z}),cp=Uw({abs:Ur,add:sr,conj:wn,ctranspose:Xi,eigs:op,equalScalar:ke,larger:Wr,matrix:de,multiply:mr,pow:Ct,smaller:Xr,sqrt:St,typed:Z}),I_=bD({BigNumber:le,Unit:Te,config:oe}),fp=P0({BigNumber:le,DenseMatrix:ze,SparseMatrix:At,addScalar:vr,config:oe,cos:Gi,matrix:de,multiplyScalar:lr,norm:cp,sin:ki,typed:Z,unaryMinus:Et}),q_=uD({BigNumber:le,Unit:Te,config:oe}),R_=Rl({sqrt:St,typed:Z,variance:Ki}),F_=qC({abs:Ur,map:Dm,median:up,subtract:ir,typed:Z}),z_=F0({multiply:mr,rotationMatrix:fp,typed:Z}),Sn={},Zn={},lp={},ji=PM({math:Sn}),Er=Jw({mathWithTransform:Zn}),Xn=ON({Node:Er}),zt=BN({Node:Er}),Jt=IN({Node:Er}),mp=UN({Node:Er}),Yn=tN({Node:Er}),pp=cN({Node:Er,ResultSet:Mm}),vp=mN({Node:Er}),Qt=xN({Node:Er}),hp=FN({Node:Er}),P_=iO({classes:lp}),U_=iC({Chain:ji,typed:Z}),dp=NN({Node:Er,typed:Z}),Wn=jw({Node:Er,subset:Yr}),gp=oN({matrix:de,Node:Er,subset:Yr}),Jn=SN({Node:Er,size:Ar}),Kt=HN({Unit:Te,Node:Er,math:Sn}),jt=ZN({Node:Er,SymbolNode:Kt,math:Sn}),pt=YN({AccessorNode:Wn,ArrayNode:Yn,AssignmentNode:gp,BlockNode:pp,ConditionalNode:vp,ConstantNode:Qt,FunctionAssignmentNode:dp,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,RangeNode:hp,RelationalNode:mp,SymbolNode:Kt,config:oe,numeric:tt,typed:Z}),yp=W3({ConstantNode:Qt,FunctionNode:jt,OperatorNode:zt,ParenthesisNode:Jt,parse:pt}),eo=Z3({AccessorNode:Wn,ArrayNode:Yn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,divide:at,equal:nt,isZero:ft,multiply:mr,pow:Ct,subtract:ir}),L_=JN({parse:pt,typed:Z}),xp=RM({parse:pt}),k_=R3({parse:pt,typed:Z}),Ya=H3({bignumber:Mt,fraction:kn,AccessorNode:Wn,ArrayNode:Yn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,config:oe,divide:at,equal:nt,isZero:ft,mathWithTransform:Zn,matrix:de,multiply:mr,parse:pt,pow:Ct,resolve:yp,simplifyCore:eo,subtract:ir,typed:Z}),H_=Q3({OperatorNode:zt,parse:pt,simplify:Ya,typed:Z}),ro=KN({parse:pt,typed:Z}),G_=nC({Help:xp,mathWithTransform:Zn,typed:Z}),bp=rM({evaluate:ro}),V_=tO({bignumber:Mt,fraction:kn,AccessorNode:Wn,ArrayNode:Yn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,config:oe,divide:at,equal:nt,isZero:ft,mathWithTransform:Zn,matrix:de,multiply:mr,parse:pt,pow:Ct,simplify:Ya,simplifyCore:eo,subtract:ir,typed:Z}),Z_=eO({ConstantNode:Qt,FunctionNode:jt,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,config:oe,equal:nt,isZero:ft,numeric:tt,parse:pt,simplify:Ya,typed:Z}),X_=nM({Parser:bp,typed:Z});ar(Sn,{e:wm,false:xT,fineStructure:bT,i:Nm,Infinity:wT,LN10:NT,LOG10E:MT,NaN:AT,null:ST,phi:ET,SQRT1_2:OT,sackurTetrode:DT,tau:Am,true:TT,E:wm,version:BT,efimovFactor:_T,LN2:$T,pi:Sm,replacer:IT,reviver:P_,SQRT2:qT,typed:Z,unaryPlus:Li,PI:Sm,weakMixingAngle:RT,abs:Ur,acos:FT,acot:zT,acsc:PT,addScalar:vr,arg:UT,asech:LT,asinh:kT,atan:Em,atanh:HT,bignumber:Mt,bitNot:GT,boolean:VT,chain:U_,clone:ZT,combinations:La,complex:ka,conj:wn,cosh:XT,coth:YT,csc:WT,cube:JT,equalScalar:ke,erf:QT,exp:Cm,expm1:KT,filter:jT,forEach:eB,format:Un,getMatrixDataType:rB,hex:tB,im:Om,isInteger:Zr,isNegative:Nn,isPositive:Ha,isZero:ft,LOG2E:nB,lgamma:aB,log10:iB,log2:oB,map:Dm,multiplyScalar:lr,not:Tm,number:Ft,oct:sB,pickRandom:uB,print:cB,random:fB,re:Bm,sec:lB,sign:_m,sin:ki,splitUnit:mB,square:pB,string:vB,tan:hB,typeOf:dB,acosh:gB,acsch:yB,apply:Hi,asec:xB,bin:bB,combinationsWithRep:wB,cos:Gi,csch:NB,isNaN:Ln,isPrime:MB,randomInt:AB,sech:SB,sinh:EB,sparse:CB,sqrt:St,tanh:OB,unaryMinus:Et,acoth:DB,cot:TB,fraction:kn,isNumeric:Yt,matrix:de,matrixFromFunction:BB,mod:$m,nthRoot:_B,numeric:tt,or:$B,prod:Im,reshape:IB,size:Ar,smaller:Xr,squeeze:qB,subset:Yr,subtract:ir,to:RB,transpose:Vi,xgcd:qm,zeros:lt,and:FB,bitAnd:zB,bitXor:PB,cbrt:UB,compare:Mn,compareText:Rm,concat:Zi,count:LB,ctranspose:Xi,diag:Fm,divideScalar:or,dotDivide:Ga,equal:nt,fft:zm,flatten:Hn,gcd:kB,hasNumericValue:HB,hypot:GB,ifft:VB,kron:ZB,largerEq:Va,leftShift:XB,lsolve:Pm,matrixFromColumns:Um,min:YB,mode:WB,nthRoots:JB,ones:QB,partitionSelect:Yi,resize:KB,rightArithShift:jB,round:Gn,smallerEq:Wi,unequal:e4,usolve:Ji,xor:r4,add:sr,atan2:t4,bitOr:n4,catalan:a4,compareNatural:mt,cumsum:i4,deepEqual:Lm,diff:o4,dot:Za,equalText:s4,floor:km,identity:An,invmod:u4,larger:Wr,log:Qi,lsolveAll:c4,matrixFromRows:f4,multiply:mr,qr:Hm,range:Vn,rightLogShift:l4,setSize:m4,slu:Gm,sum:Vm,trace:p4,usolveAll:Zm,asin:v4,ceil:Xm,composition:h4,cross:d4,det:Ym,distance:g4,dotMultiply:y4,fix:Jm,intersect:x4,lcm:b4,log1p:w4,max:Km,quantileSeq:N4,row:M4,setCartesian:A4,setDistinct:S4,setIsSubset:E4,setPowerset:C4,sort:O4,column:jm,index:D4,inv:Wt,pinv:T4,pow:Ct,setDifference:ep,setMultiplicity:B4,sqrtm:_4,vacuumImpedance:$4,wienDisplacement:I4,atomicMass:q4,bohrMagneton:R4,boltzmann:F4,conductanceQuantum:z4,createUnit:P4,deuteronMass:U4,dotPow:L4,electricConstant:k4,elementaryCharge:H4,expm:G4,faraday:V4,firstRadiation:Z4,gamma:tp,gravitationConstant:X4,hartreeEnergy:Y4,klitzing:W4,loschmidt:J4,magneticConstant:Q4,molarMass:K4,molarPlanckConstant:j4,neutronMass:e_,nuclearMagneton:r_,planckCharge:t_,planckLength:n_,planckTemperature:a_,protonMass:i_,reducedPlanckConstant:o_,rydberg:s_,setIntersect:np,speedOfLight:u_,stefanBoltzmann:c_,thomsonCrossSection:f_,avogadro:l_,bohrRadius:m_,coulomb:p_,divide:at,electronMass:v_,factorial:Xa,gravity:h_,inverseConductanceQuantum:d_,lup:ap,magneticFluxQuantum:g_,molarMassC12:y_,multinomial:x_,parse:pt,permutations:b_,planckMass:w_,quantumOfCirculation:N_,resolve:yp,secondRadiation:M_,simplifyCore:eo,stirlingS2:ip,unit:A_,bellNumbers:S_,compile:L_,eigs:op,fermiCoupling:E_,leafCount:k_,mean:C_,molarVolume:O_,planckConstant:D_,setSymDifference:sp,simplify:Ya,symbolicEqual:H_,classicalElectronRadius:T_,evaluate:ro,help:G_,lusolve:B_,median:up,rationalize:V_,setUnion:__,variance:Ki,derivative:Z_,kldivergence:$_,norm:cp,planckTime:I_,rotationMatrix:fp,gasConstant:q_,parser:X_,std:R_,mad:F_,rotate:z_,config:oe}),ar(Zn,Sn,{filter:BD({typed:Z}),forEach:ID({typed:Z}),map:UD({typed:Z}),apply:SD({isInteger:Zr,typed:Z}),diff:cT({bignumber:Mt,matrix:de,number:Ft,subtract:ir,typed:Z}),subset:aT({matrix:de,typed:Z}),concat:sT({isInteger:Zr,matrix:de,typed:Z}),max:HD({config:oe,larger:Wr,numeric:tt,typed:Z}),min:WD({config:oe,numeric:tt,smaller:Xr,typed:Z}),range:KD({bignumber:Mt,matrix:de,config:oe,larger:Wr,largerEq:Va,smaller:Xr,smallerEq:Wi,typed:Z}),sum:vT({add:sr,config:oe,numeric:tt,typed:Z}),cumsum:dT({add:sr,typed:Z,unaryPlus:Li}),row:rT({Index:Sr,matrix:de,range:Vn,typed:Z}),column:OD({Index:Sr,matrix:de,range:Vn,typed:Z}),index:FD({Index:Sr}),mean:ZD({add:sr,divide:at,typed:Z}),variance:yT({add:sr,apply:Hi,divide:at,isNaN:Ln,multiply:mr,subtract:ir,typed:Z}),std:mT({sqrt:St,typed:Z,variance:Ki})}),ar(lp,{BigNumber:le,Chain:ji,Complex:rr,Fraction:Xt,Matrix:Ua,Node:Er,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,Range:CT,RelationalNode:mp,ResultSet:Mm,ArrayNode:Yn,BlockNode:pp,ConditionalNode:vp,ConstantNode:Qt,DenseMatrix:ze,RangeNode:hp,FunctionAssignmentNode:dp,SparseMatrix:At,AccessorNode:Wn,AssignmentNode:gp,IndexNode:Jn,FibonacciHeap:Wm,ImmutableDenseMatrix:Qm,Index:Sr,Spa:rp,Unit:Te,SymbolNode:Kt,FunctionNode:jt,Help:xp,Parser:bp}),ji.createProxy(Sn);const Y_={label:"Math.js",tooltip:"{{t('Math.js comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types.')}}",link:"https://mathjs.org/",evaluate:Qr.evaluate.bind(function(e,n={}){const a=ro(e,n);return typeof a=="number"?Number.isNaN(a)||!Number.isFinite(a)?null:Gn(a,9):a},{replaceKey:!0})};class wp extends pr.Plugin{load(){return Np(this,null,function*(){Qr.evaluators.register("math.js",Y_)})}}fr.PluginMathjsEvaluatorClient=wp,fr.default=wp,Object.defineProperties(fr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});