@dice-roller/vue 0.1.9 → 1.0.0

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.
@@ -0,0 +1,83 @@
1
+ (function(yt,he){typeof exports=="object"&&typeof module<"u"?he(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],he):(yt=typeof globalThis<"u"?globalThis:yt||self,he(yt.DiceRollerVue={},yt.Vue))})(this,function(yt,he){"use strict";function Rr(){return Rr=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},Rr.apply(this,arguments)}var Xs={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function Ye(r){return typeof r=="number"}function We(r){return!r||typeof r!="object"||typeof r.constructor!="function"?!1:r.isBigNumber===!0&&typeof r.constructor.prototype=="object"&&r.constructor.prototype.isBigNumber===!0||typeof r.constructor.isDecimal=="function"&&r.constructor.isDecimal(r)===!0}function Dt(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function En(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function la(r){return r&&r.constructor.prototype.isUnit===!0||!1}function Zr(r){return typeof r=="string"}var ar=Array.isArray;function Fe(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Cn(r){return Array.isArray(r)||Fe(r)}function Va(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function un(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Ga(r){return r&&r.constructor.prototype.isRange===!0||!1}function fa(r){return r&&r.constructor.prototype.isIndex===!0||!1}function id(r){return typeof r=="boolean"}function Ys(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function Wi(r){return r&&r.constructor.prototype.isHelp===!0||!1}function od(r){return typeof r=="function"}function sd(r){return r instanceof Date}function ud(r){return r instanceof RegExp}function Xi(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!Dt(r)&&!En(r))}function cd(r){return r===null}function ld(r){return r===void 0}function cn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function Kr(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function fd(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function md(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function pd(r){return r&&r.isConditionalNode===!0&&r.constructor.prototype.isNode===!0||!1}function ir(r){return r&&r.isConstantNode===!0&&r.constructor.prototype.isNode===!0||!1}function ma(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function ln(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function On(r){return r&&r.isIndexNode===!0&&r.constructor.prototype.isNode===!0||!1}function tr(r){return r&&r.isNode===!0&&r.constructor.prototype.isNode===!0||!1}function Ha(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function Jr(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function pa(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function vd(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function Dr(r){return r&&r.isSymbolNode===!0&&r.constructor.prototype.isNode===!0||!1}function Yi(r){return r&&r.constructor.prototype.isChain===!0||!1}function cr(r){var e=typeof r;return e==="object"?r===null?"null":Array.isArray(r)?"Array":r instanceof Date?"Date":r instanceof RegExp?"RegExp":We(r)?"BigNumber":Dt(r)?"Complex":En(r)?"Fraction":Fe(r)?"Matrix":la(r)?"Unit":fa(r)?"Index":Ga(r)?"Range":Ys(r)?"ResultSet":tr(r)?r.type:Yi(r)?"Chain":Wi(r)?"Help":"Object":e==="function"?"Function":e}function Re(r){var e=typeof r;if(e==="number"||e==="string"||e==="boolean"||r===null||r===void 0)return r;if(typeof r.clone=="function")return r.clone();if(Array.isArray(r))return r.map(function(t){return Re(t)});if(r instanceof Date)return new Date(r.valueOf());if(We(r))return r;if(r instanceof RegExp)throw new TypeError("Cannot clone "+r);return hd(r,Re)}function hd(r,e){var t={};for(var a in r)De(r,a)&&(t[a]=e(r[a]));return t}function Qi(r,e){for(var t in e)De(e,t)&&(r[t]=e[t]);return r}function va(r,e){var t,a,n;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(a=0,n=r.length;a<n;a++)if(!va(r[a],e[a]))return!1;return!0}else{if(typeof r=="function")return r===e;if(r instanceof Object){if(Array.isArray(e)||!(e instanceof Object))return!1;for(t in r)if(!(t in e)||!va(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function dd(r,e,t){var a=!0,n;Object.defineProperty(r,e,{get:function(){return a&&(n=t(),a=!1),n},set:function(c){n=c,a=!1},configurable:!0,enumerable:!0})}function De(r,e){return r&&Object.hasOwnProperty.call(r,e)}function gd(r,e){for(var t={},a=0;a<e.length;a++){var n=e[a],i=r[n];i!==void 0&&(t[n]=i)}return t}var yd=["Matrix","Array"],bd=["number","BigNumber","Fraction"],le=function(e){if(e)throw new Error(`The global config is readonly.
2
+ Please create a mathjs instance if you want to change the default configuration.
3
+ Example:
4
+
5
+ import { create, all } from 'mathjs';
6
+ const mathjs = create(all);
7
+ mathjs.config({ number: 'BigNumber' });
8
+ `);return Object.freeze(Xs)};Rr(le,Xs,{MATRIX_OPTIONS:yd,NUMBER_OPTIONS:bd});var Ht=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function xd(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(a){var n=Object.getOwnPropertyDescriptor(r,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return r[a]}})}),t}var js={exports:{}};(function(r,e){(function(t,a){r.exports=a()})(Ht,function(){function t(){return!0}function a(){return!1}function n(){}function i(){var c=[{name:"number",test:function(F){return typeof F=="number"}},{name:"string",test:function(F){return typeof F=="string"}},{name:"boolean",test:function(F){return typeof F=="boolean"}},{name:"Function",test:function(F){return typeof F=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(F){return F instanceof Date}},{name:"RegExp",test:function(F){return F instanceof RegExp}},{name:"Object",test:function(F){return typeof F=="object"&&F!==null&&F.constructor===Object}},{name:"null",test:function(F){return F===null}},{name:"undefined",test:function(F){return F===void 0}}],m={name:"any",test:t},f=[],l=[],s={types:c,conversions:l,ignore:f};function o(F){var U=z(s.types,function(k){return k.name===F});if(U)return U;if(F==="any")return m;var ee=z(s.types,function(k){return k.name.toLowerCase()===F.toLowerCase()});throw new TypeError('Unknown type "'+F+'"'+(ee?'. Did you mean "'+ee.name+'"?':""))}function u(F){return F===m?999:s.types.indexOf(F)}function p(F){var U=z(s.types,function(ee){return ee.test(F)});if(U)return U.name;throw new TypeError("Value has unknown type. Value: "+F)}function v(F,U){if(!F.signatures)throw new TypeError("Function is no typed-function");var ee;if(typeof U=="string"){ee=U.split(",");for(var k=0;k<ee.length;k++)ee[k]=ee[k].trim()}else if(Array.isArray(U))ee=U;else throw new TypeError("String array or a comma separated string expected");var fe=ee.join(","),ve=F.signatures[fe];if(ve)return ve;throw new TypeError("Signature not found (signature: "+(F.name||"unnamed")+"("+ee.join(", ")+"))")}function h(F,U){var ee=p(F);if(U===ee)return F;for(var k=0;k<s.conversions.length;k++){var fe=s.conversions[k];if(fe.from===ee&&fe.to===U)return fe.convert(F)}throw new Error("Cannot convert from "+ee+" to "+U)}function b(F){return F.map(function(U){var ee=U.types.map(E);return(U.restParam?"...":"")+ee.join("|")}).join(",")}function w(F,U){var ee=F.indexOf("...")===0,k=ee?F.length>3?F.slice(3):"any":F,fe=k.split("|").map(ae).filter(ce).filter(oe),ve=D(U,fe),Me=fe.map(function(xe){var Te=o(xe);return{name:xe,typeIndex:u(Te),test:Te.test,conversion:null,conversionIndex:-1}}),be=ve.map(function(xe){var Te=o(xe.from);return{name:xe.from,typeIndex:u(Te),test:Te.test,conversion:xe,conversionIndex:U.indexOf(xe)}});return{types:Me.concat(be),restParam:ee}}function N(F,U,ee){var k=[];return F.trim()!==""&&(k=F.split(",").map(ae).map(function(fe,ve,Me){var be=w(fe,ee);if(be.restParam&&ve!==Me.length-1)throw new SyntaxError('Unexpected rest parameter "'+fe+'": only allowed for the last parameter');return be})),k.some(me)?null:{params:k,fn:U}}function d(F){var U=Ae(F);return U?U.restParam:!1}function y(F){return F.types.some(function(U){return U.conversion!=null})}function x(F){if(!F||F.types.length===0)return t;if(F.types.length===1)return o(F.types[0].name).test;if(F.types.length===2){var U=o(F.types[0].name).test,ee=o(F.types[1].name).test;return function(ve){return U(ve)||ee(ve)}}else{var k=F.types.map(function(fe){return o(fe.name).test});return function(ve){for(var Me=0;Me<k.length;Me++)if(k[Me](ve))return!0;return!1}}}function g(F){var U,ee,k;if(d(F)){U=ne(F).map(x);var fe=U.length,ve=x(Ae(F)),Me=function(be){for(var xe=fe;xe<be.length;xe++)if(!ve(be[xe]))return!1;return!0};return function(xe){for(var Te=0;Te<U.length;Te++)if(!U[Te](xe[Te]))return!1;return Me(xe)&&xe.length>=fe+1}}else return F.length===0?function(xe){return xe.length===0}:F.length===1?(ee=x(F[0]),function(xe){return ee(xe[0])&&xe.length===1}):F.length===2?(ee=x(F[0]),k=x(F[1]),function(xe){return ee(xe[0])&&k(xe[1])&&xe.length===2}):(U=F.map(x),function(xe){for(var Te=0;Te<U.length;Te++)if(!U[Te](xe[Te]))return!1;return xe.length===U.length})}function S(F,U){return U<F.params.length?F.params[U]:d(F.params)?Ae(F.params):null}function A(F,U,ee){var k=S(F,U),fe=k?ee?k.types.filter(M):k.types:[];return fe.map(E)}function E(F){return F.name}function M(F){return F.conversion===null||F.conversion===void 0}function B(F,U){var ee=Y(V(F,function(k){return A(k,U,!1)}));return ee.indexOf("any")!==-1?["any"]:ee}function C(F,U,ee){var k,fe,ve=F||"unnamed",Me=ee,be;for(be=0;be<U.length;be++){var xe=Me.filter(function(fr){var Gr=x(S(fr,be));return(be<fr.params.length||d(fr.params))&&Gr(U[be])});if(xe.length===0){if(fe=B(Me,be),fe.length>0){var Te=p(U[be]);return k=new TypeError("Unexpected type of argument in function "+ve+" (expected: "+fe.join(" or ")+", actual: "+Te+", index: "+be+")"),k.data={category:"wrongType",fn:ve,index:be,actual:Te,expected:fe},k}}else Me=xe}var nr=Me.map(function(fr){return d(fr.params)?1/0:fr.params.length});if(U.length<Math.min.apply(null,nr))return fe=B(Me,be),k=new TypeError("Too few arguments in function "+ve+" (expected: "+fe.join(" or ")+", index: "+U.length+")"),k.data={category:"tooFewArgs",fn:ve,index:U.length,expected:fe},k;var dr=Math.max.apply(null,nr);return U.length>dr?(k=new TypeError("Too many arguments in function "+ve+" (expected: "+dr+", actual: "+U.length+")"),k.data={category:"tooManyArgs",fn:ve,index:U.length,expectedLength:dr},k):(k=new TypeError('Arguments of type "'+U.join(", ")+'" do not match any of the defined signatures of function '+ve+"."),k.data={category:"mismatch",actual:U.map(p)},k)}function _(F){for(var U=999,ee=0;ee<F.types.length;ee++)M(F.types[ee])&&(U=Math.min(U,F.types[ee].typeIndex));return U}function P(F){for(var U=999,ee=0;ee<F.types.length;ee++)M(F.types[ee])||(U=Math.min(U,F.types[ee].conversionIndex));return U}function I(F,U){var ee;return ee=F.restParam-U.restParam,ee!==0||(ee=y(F)-y(U),ee!==0)||(ee=_(F)-_(U),ee!==0)?ee:P(F)-P(U)}function T(F,U){var ee=Math.min(F.params.length,U.params.length),k,fe;if(fe=F.params.some(y)-U.params.some(y),fe!==0)return fe;for(k=0;k<ee;k++)if(fe=y(F.params[k])-y(U.params[k]),fe!==0)return fe;for(k=0;k<ee;k++)if(fe=I(F.params[k],U.params[k]),fe!==0)return fe;return F.params.length-U.params.length}function D(F,U){var ee={};return F.forEach(function(k){U.indexOf(k.from)===-1&&U.indexOf(k.to)!==-1&&!ee[k.from]&&(ee[k.from]=k)}),Object.keys(ee).map(function(k){return ee[k]})}function Z(F,U){var ee=U;if(F.some(y)){var k=d(F),fe=F.map($);ee=function(){for(var xe=[],Te=k?arguments.length-1:arguments.length,nr=0;nr<Te;nr++)xe[nr]=fe[nr](arguments[nr]);return k&&(xe[Te]=arguments[Te].map(fe[Te])),U.apply(this,xe)}}var ve=ee;if(d(F)){var Me=F.length-1;ve=function(){return ee.apply(this,Ce(arguments,0,Me).concat([Ce(arguments,Me)]))}}return ve}function $(F){var U,ee,k,fe,ve=[],Me=[];switch(F.types.forEach(function(be){be.conversion&&(ve.push(o(be.conversion.from).test),Me.push(be.conversion.convert))}),Me.length){case 0:return function(xe){return xe};case 1:return U=ve[0],k=Me[0],function(xe){return U(xe)?k(xe):xe};case 2:return U=ve[0],ee=ve[1],k=Me[0],fe=Me[1],function(xe){return U(xe)?k(xe):ee(xe)?fe(xe):xe};default:return function(xe){for(var Te=0;Te<Me.length;Te++)if(ve[Te](xe))return Me[Te](xe);return xe}}}function H(F){var U={};return F.forEach(function(ee){ee.params.some(y)||Q(ee.params,!0).forEach(function(k){U[b(k)]=ee.fn})}),U}function Q(F,U){function ee(k,fe,ve){if(fe<k.length){var Me=k[fe],be=U?Me.types.filter(M):Me.types,xe;if(Me.restParam){var Te=be.filter(M);xe=Te.length<be.length?[Te,be]:[be]}else xe=be.map(function(dr){return[dr]});return V(xe,function(dr){return ee(k,fe+1,ve.concat([dr]))})}else{var nr=ve.map(function(dr,fr){return{types:dr,restParam:fr===k.length-1&&d(k)}});return[nr]}}return ee(F,0,[])}function te(F,U){for(var ee=Math.max(F.params.length,U.params.length),k=0;k<ee;k++){var fe=A(F,k,!0),ve=A(U,k,!0);if(!Se(fe,ve))return!1}var Me=F.params.length,be=U.params.length,xe=d(F.params),Te=d(U.params);return xe?Te?Me===be:be>=Me:Te?Me>=be:Me===be}function J(F,U){if(Object.keys(U).length===0)throw new SyntaxError("No signatures provided");var ee=[];Object.keys(U).map(function(pr){return N(pr,U[pr],s.conversions)}).filter(se).forEach(function(pr){var Tr=z(ee,function(ut){return te(ut,pr)});if(Tr)throw new TypeError('Conflicting signatures "'+b(Tr.params)+'" and "'+b(pr.params)+'".');ee.push(pr)});var k=V(ee,function(pr){var Tr=pr?Q(pr.params,!1):[];return Tr.map(function(ut){return{params:ut,fn:pr.fn}})}).filter(se);k.sort(T);var fe=k[0]&&k[0].params.length<=2&&!d(k[0].params),ve=k[1]&&k[1].params.length<=2&&!d(k[1].params),Me=k[2]&&k[2].params.length<=2&&!d(k[2].params),be=k[3]&&k[3].params.length<=2&&!d(k[3].params),xe=k[4]&&k[4].params.length<=2&&!d(k[4].params),Te=k[5]&&k[5].params.length<=2&&!d(k[5].params),nr=fe&&ve&&Me&&be&&xe&&Te,dr=k.map(function(pr){return g(pr.params)}),fr=fe?x(k[0].params[0]):a,Gr=ve?x(k[1].params[0]):a,Hr=Me?x(k[2].params[0]):a,st=be?x(k[3].params[0]):a,er=xe?x(k[4].params[0]):a,$t=Te?x(k[5].params[0]):a,O=fe?x(k[0].params[1]):a,X=ve?x(k[1].params[1]):a,ue=Me?x(k[2].params[1]):a,we=be?x(k[3].params[1]):a,ke=xe?x(k[4].params[1]):a,Xe=Te?x(k[5].params[1]):a,Sr=k.map(function(pr){return Z(pr.params,pr.fn)}),La=fe?Sr[0]:n,_s=ve?Sr[1]:n,Is=Me?Sr[2]:n,Rs=be?Sr[3]:n,Fs=xe?Sr[4]:n,qs=Te?Sr[5]:n,ia=fe?k[0].params.length:-1,oa=ve?k[1].params.length:-1,zs=Me?k[2].params.length:-1,Ps=be?k[3].params.length:-1,Us=xe?k[4].params.length:-1,Ls=Te?k[5].params.length:-1,ks=nr?6:0,Vs=k.length,Gs=function(){for(var Tr=ks;Tr<Vs;Tr++)if(dr[Tr](arguments))return Sr[Tr].apply(this,arguments);return s.onMismatch(F,arguments,k)},ka=function pr(Tr,ut){return arguments.length===ia&&fr(Tr)&&O(ut)?La.apply(pr,arguments):arguments.length===oa&&Gr(Tr)&&X(ut)?_s.apply(pr,arguments):arguments.length===zs&&Hr(Tr)&&ue(ut)?Is.apply(pr,arguments):arguments.length===Ps&&st(Tr)&&we(ut)?Rs.apply(pr,arguments):arguments.length===Us&&er(Tr)&&ke(ut)?Fs.apply(pr,arguments):arguments.length===Ls&&$t(Tr)&&Xe(ut)?qs.apply(pr,arguments):Gs.apply(pr,arguments)};try{Object.defineProperty(ka,"name",{value:F})}catch{}return ka.signatures=H(k),ka}function re(F,U,ee){throw C(F,U,ee)}function oe(F){return s.ignore.indexOf(F)===-1}function ae(F){return F.trim()}function ce(F){return!!F}function se(F){return F!==null}function me(F){return F.types.length===0}function ne(F){return F.slice(0,F.length-1)}function Ae(F){return F[F.length-1]}function Ce(F,U,ee){return Array.prototype.slice.call(F,U,ee)}function ge(F,U){return F.indexOf(U)!==-1}function Se(F,U){for(var ee=0;ee<F.length;ee++)if(ge(U,F[ee]))return!0;return!1}function z(F,U){for(var ee=0;ee<F.length;ee++)if(U(F[ee]))return F[ee]}function Y(F){for(var U={},ee=0;ee<F.length;ee++)U[F[ee]]=!0;return Object.keys(U)}function V(F,U){return Array.prototype.concat.apply([],F.map(U))}function L(F){for(var U="",ee=0;ee<F.length;ee++){var k=F[ee];if((typeof k.signatures=="object"||typeof k.signature=="string")&&k.name!==""){if(U==="")U=k.name;else if(U!==k.name){var fe=new Error("Function names do not match (expected: "+U+", actual: "+k.name+")");throw fe.data={actual:k.name,expected:U},fe}}}return U}function j(F){var U,ee={};function k(be,xe){if(ee.hasOwnProperty(be)&&xe!==ee[be])throw U=new Error('Signature "'+be+'" is defined twice'),U.data={signature:be},U}for(var fe=0;fe<F.length;fe++){var ve=F[fe];if(typeof ve.signatures=="object")for(var Me in ve.signatures)ve.signatures.hasOwnProperty(Me)&&(k(Me,ve.signatures[Me]),ee[Me]=ve.signatures[Me]);else if(typeof ve.signature=="string")k(ve.signature,ve),ee[ve.signature]=ve;else throw U=new TypeError("Function is no typed-function (index: "+fe+")"),U.data={index:fe},U}return ee}return s=J("typed",{"string, Object":J,Object:function(F){var U=[];for(var ee in F)F.hasOwnProperty(ee)&&U.push(F[ee]);var k=L(U);return J(k,F)},"...Function":function(F){return J(L(F),j(F))},"string, ...Function":function(F,U){return J(F,j(U))}}),s.create=i,s.types=c,s.conversions=l,s.ignore=f,s.onMismatch=re,s.throwMismatchError=re,s.createError=C,s.convert=h,s.find=v,s.addType=function(F,U){if(!F||typeof F.name!="string"||typeof F.test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");if(U!==!1){for(var ee=0;ee<s.types.length;ee++)if(s.types[ee].name==="Object"){s.types.splice(ee,0,F);return}}s.types.push(F)},s.addConversion=function(F){if(!F||typeof F.from!="string"||typeof F.to!="string"||typeof F.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");s.conversions.push(F)},s}return i()})})(js);const Ks=js.exports;function Be(r){return typeof r=="boolean"?!0:isFinite(r)?r===Math.round(r):!1}var Zt=Math.sign||function(r){return r>0?1:r<0?-1:0},wd=Math.log2||function(e){return Math.log(e)/Math.LN2},Nd=Math.log10||function(e){return Math.log(e)/Math.LN10},Md=Math.log1p||function(r){return Math.log(r+1)},Ad=Math.cbrt||function(e){if(e===0)return e;var t=e<0,a;return t&&(e=-e),isFinite(e)?(a=Math.exp(Math.log(e)/3),a=(e/(a*a)+2*a)/3):a=e,t?-a:a},Sd=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function ji(r,e,t){var a={2:"0b",8:"0o",16:"0x"},n=a[e],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Be(t))throw new Error("size must be an integer");if(r>2**(t-1)-1||r<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!Be(r))throw new Error("Value must be an integer");r<0&&(r=r+2**t),i="i".concat(t)}var c="";return r<0&&(r=-r,c="-"),"".concat(c).concat(n).concat(r.toString(e)).concat(i)}function fn(r,e){if(typeof e=="function")return e(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var t="auto",a,n;if(e&&(e.notation&&(t=e.notation),Ye(e)?a=e:Ye(e.precision)&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return eu(r,a);case"exponential":return ru(r,a);case"engineering":return Ed(r,a);case"bin":return ji(r,2,n);case"oct":return ji(r,8,n);case"hex":return ji(r,16,n);case"auto":return Cd(r,a,e&&e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],c=arguments[4];return i!=="."?i+c:c});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Za(r){var e=String(r).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+r);var t=e[1],a=e[2],n=parseFloat(e[4]||"0"),i=a.indexOf(".");n+=i!==-1?i-1:a.length-1;var c=a.replace(".","").replace(/^0*/,function(m){return n-=m.length,""}).replace(/0*$/,"").split("").map(function(m){return parseInt(m)});return c.length===0&&(c.push(0),n++),{sign:t,coefficients:c,exponent:n}}function Ed(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=Za(r),a=Ja(t,e),n=a.exponent,i=a.coefficients,c=n%3===0?n:n<0?n-3-n%3:n-n%3;if(Ye(e))for(;e>i.length||n-c+1>i.length;)i.push(0);else for(var m=Math.abs(n-c)-(i.length-1),f=0;f<m;f++)i.push(0);for(var l=Math.abs(n-c),s=1;l>0;)s++,l--;var o=i.slice(s).join(""),u=Ye(e)&&o.length||o.match(/[1-9]/)?"."+o:"",p=i.slice(0,s).join("")+u+"e"+(n>=0?"+":"")+c.toString();return a.sign+p}function eu(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=Za(r),a=typeof e=="number"?Ja(t,t.exponent+1+e):t,n=a.coefficients,i=a.exponent+1,c=i+(e||0);return n.length<c&&(n=n.concat($n(c-n.length))),i<0&&(n=$n(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),a.sign+n.join("")}function ru(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=Za(r),a=e?Ja(t,e):t,n=a.coefficients,i=a.exponent;n.length<e&&(n=n.concat($n(e-n.length)));var c=n.shift();return a.sign+c+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function Cd(r,e,t){if(isNaN(r)||!isFinite(r))return String(r);var a=t&&t.lowerExp!==void 0?t.lowerExp:-3,n=t&&t.upperExp!==void 0?t.upperExp:5,i=Za(r),c=e?Ja(i,e):i;if(c.exponent<a||c.exponent>=n)return ru(r,e);var m=c.coefficients,f=c.exponent;m.length<e&&(m=m.concat($n(e-m.length))),m=m.concat($n(f-m.length+1+(m.length<e?e-m.length:0))),m=$n(-f).concat(m);var l=f>0?f:0;return l<m.length-1&&m.splice(l+1,0,"."),c.sign+m.join("")}function Ja(r,e){for(var t={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},a=t.coefficients;e<=0;)a.unshift(0),t.exponent++,e++;if(a.length>e){var n=a.splice(e,a.length-e);if(n[0]>=5){var i=e-1;for(a[i]++;a[i]===10;)a.pop(),i===0&&(a.unshift(0),t.exponent++,i++),i--,a[i]++}}return t}function $n(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function Od(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var $d=Number.EPSILON||2220446049250313e-31;function Yr(r,e,t){if(t==null)return r===e;if(r===e)return!0;if(isNaN(r)||isNaN(e))return!1;if(isFinite(r)&&isFinite(e)){var a=Math.abs(r-e);return a<$d?!0:a<=Math.max(Math.abs(r),Math.abs(e))*t}return!1}var Td=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},Dd=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},Bd=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},_d=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},Id=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},Rd=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function Fd(r,e){var t=r>0?!0:r<0?!1:1/r===1/0,a=e>0?!0:e<0?!1:1/e===1/0;return t^a?-r:r}function Ki(r,e,t){var a=r.constructor,n=new a(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Be(t))throw new Error("size must be an integer");if(r.greaterThan(n.pow(t-1).sub(1))||r.lessThan(n.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!r.isInteger())throw new Error("Value must be an integer");r.lessThan(0)&&(r=r.add(n.pow(t))),i="i".concat(t)}switch(e){case 2:return"".concat(r.toBinary()).concat(i);case 8:return"".concat(r.toOctal()).concat(i);case 16:return"".concat(r.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(e," not supported "))}}function qd(r,e){if(typeof e=="function")return e(r);if(!r.isFinite())return r.isNaN()?"NaN":r.gt(0)?"Infinity":"-Infinity";var t="auto",a,n;if(e!==void 0&&(e.notation&&(t=e.notation),typeof e=="number"?a=e:e.precision&&(a=e.precision),e.wordSize&&(n=e.wordSize,typeof n!="number")))throw new Error('Option "wordSize" must be a number');switch(t){case"fixed":return Pd(r,a);case"exponential":return tu(r,a);case"engineering":return zd(r,a);case"bin":return Ki(r,2,n);case"oct":return Ki(r,8,n);case"hex":return Ki(r,16,n);case"auto":{var i=e&&e.lowerExp!==void 0?e.lowerExp:-3,c=e&&e.upperExp!==void 0?e.upperExp:5;if(r.isZero())return"0";var m,f=r.toSignificantDigits(a),l=f.e;return l>=i&&l<c?m=f.toFixed():m=tu(r,a),m.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],o=arguments[4];return s!=="."?s+o:o})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function zd(r,e){var t=r.e,a=t%3===0?t:t<0?t-3-t%3:t-t%3,n=r.mul(Math.pow(10,-a)),i=n.toPrecision(e);return i.indexOf("e")!==-1&&(i=n.toString()),i+"e"+(t>=0?"+":"")+a.toString()}function tu(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function Pd(r,e){return r.toFixed(e)}function Ud(r,e){var t=r.length-e.length,a=r.length;return r.substring(t,a)===e}function Ge(r,e){var t=Ld(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function Ld(r,e){if(typeof r=="number")return fn(r,e);if(We(r))return qd(r,e);if(kd(r))return!e||e.fraction!=="decimal"?r.s*r.n+"/"+r.d:r.toString();if(Array.isArray(r))return nu(r,e);if(Zr(r))return'"'+r+'"';if(typeof r=="function")return r.syntax?String(r.syntax):"function";if(r&&typeof r=="object"){if(typeof r.format=="function")return r.format(e);if(r&&r.toString(e)!=={}.toString())return r.toString(e);var t=Object.keys(r).map(a=>'"'+a+'": '+Ge(r[a],e));return"{"+t.join(", ")+"}"}return String(r)}function Wa(r){for(var e=String(r),t="",a=0;a<e.length;){var n=e.charAt(a);n==="\\"?(t+=n,a++,n=e.charAt(a),(n===""||'"\\/bfnrtu'.indexOf(n)===-1)&&(t+="\\"),t+=n):n==='"'?t+='\\"':t+=n,a++}return'"'+t+'"'}function et(r){var e=String(r);return e=e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e}function nu(r,e){if(Array.isArray(r)){for(var t="[",a=r.length,n=0;n<a;n++)n!==0&&(t+=", "),t+=nu(r[n],e);return t+="]",t}else return Ge(r,e)}function kd(r){return r&&typeof r=="object"&&typeof r.s=="number"&&typeof r.n=="number"&&typeof r.d=="number"||!1}function Tn(r,e){if(!Zr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+cr(r)+", index: 0)");if(!Zr(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+cr(e)+", index: 1)");return r===e?0:r>e?1:-1}function He(r,e,t){if(!(this instanceof He))throw new SyntaxError("Constructor must be called with the new operator");this.actual=r,this.expected=e,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(r)?"["+r.join(", ")+"]":r)+" "+(this.relation||"!=")+" "+(Array.isArray(e)?"["+e.join(", ")+"]":e)+")",this.stack=new Error().stack}He.prototype=new RangeError,He.prototype.constructor=RangeError,He.prototype.name="DimensionError",He.prototype.isDimensionError=!0;function ct(r,e,t){if(!(this instanceof ct))throw new SyntaxError("Constructor must be called with the new operator");this.index=r,arguments.length<3?(this.min=0,this.max=e):(this.min=e,this.max=t),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}ct.prototype=new RangeError,ct.prototype.constructor=RangeError,ct.prototype.name="IndexError",ct.prototype.isIndexError=!0;function Je(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function au(r,e,t){var a,n=r.length;if(n!==e[t])throw new He(n,e[t]);if(t<e.length-1){var i=t+1;for(a=0;a<n;a++){var c=r[a];if(!Array.isArray(c))throw new He(e.length-1,e.length,"<");au(r[a],e,i)}}else for(a=0;a<n;a++)if(Array.isArray(r[a]))throw new He(e.length+1,e.length,">")}function iu(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new He(r.length,0)}else au(r,e,0)}function or(r,e){if(!Ye(r)||!Be(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||typeof e=="number"&&r>=e)throw new ct(r,e)}function Dn(r,e,t){if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Error("Resizing to scalar is not supported");e.forEach(function(n){if(!Ye(n)||!Be(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ge(e)+")")});var a=t!==void 0?t:0;return eo(r,e,0,a),r}function eo(r,e,t,a){var n,i,c=r.length,m=e[t],f=Math.min(c,m);if(r.length=m,t<e.length-1){var l=t+1;for(n=0;n<f;n++)i=r[n],Array.isArray(i)||(i=[i],r[n]=i),eo(i,e,l,a);for(n=f;n<m;n++)i=[],r[n]=i,eo(i,e,l,a)}else{for(n=0;n<f;n++)for(;Array.isArray(r[n]);)r[n]=r[n][0];for(n=f;n<m;n++)r[n]=a}}function ou(r,e){var t=Qe(r),a=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new He(0,a,"!=");e=ro(e,a);var n=su(e);if(a!==n)throw new He(n,a,"!=");try{return Vd(t,e)}catch(i){throw i instanceof He?new He(n,a,"!="):i}}function ro(r,e){var t=su(r),a=r.slice(),n=-1,i=r.indexOf(n),c=r.indexOf(n,i+1)>=0;if(c)throw new Error("More than one wildcard in sizes");var m=i>=0,f=e%t===0;if(m)if(f)a[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return a}function su(r){return r.reduce((e,t)=>e*t,1)}function Vd(r,e){for(var t=r,a,n=e.length-1;n>0;n--){var i=e[n];a=[];for(var c=t.length/i,m=0;m<c;m++)a.push(t.slice(m*i,(m+1)*i));t=a}return t}function Xa(r,e){for(var t=e||Je(r);Array.isArray(r)&&r.length===1;)r=r[0],t.shift();for(var a=t.length;t[a-1]===1;)a--;return a<t.length&&(r=uu(r,a,0),t.length=a),r}function uu(r,e,t){var a,n;if(t<e){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=uu(r[a],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function cu(r,e,t,a){var n=a||Je(r);if(t)for(var i=0;i<t;i++)r=[r],n.unshift(1);for(r=lu(r,e,0);n.length<e;)n.push(1);return r}function lu(r,e,t){var a,n;if(Array.isArray(r)){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=lu(r[a],e,i)}else for(var c=t;c<e;c++)r=[r];return r}function Qe(r){if(!Array.isArray(r))return r;var e=[];return r.forEach(function t(a){Array.isArray(a)?a.forEach(t):e.push(a)}),e}function Bt(r,e){return Array.prototype.map.call(r,e)}function Ya(r,e){Array.prototype.forEach.call(r,e)}function fu(r,e){if(Je(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function Qa(r,e){if(Je(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,t=>e.test(t))}function mu(r,e){return Array.prototype.join.call(r,e)}function Bn(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;var e=[],t=0;e[0]={value:r[0],identifier:0};for(var a=1;a<r.length;a++)r[a]===r[a-1]?t++:t=0,e.push({value:r[a],identifier:t});return e}function ja(r){if(!Array.isArray(r))throw new TypeError("Array input expected");if(r.length===0)return r;for(var e=[],t=0;t<r.length;t++)e.push(r[t].value);return e}function ha(r,e){for(var t,a=0,n=0;n<r.length;n++){var i=r[n],c=Array.isArray(i);if(n===0&&c&&(a=i.length),c&&i.length!==a)return;var m=c?ha(i,e):e(i);if(t===void 0)t=m;else if(t!==m)return"mixed"}return t}function q(r,e,t,a){function n(i){var c=gd(i,e.map(Zd));return Gd(r,e,i),t(c)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),a&&(n.meta=a),n}function Gd(r,e,t){var a=e.filter(i=>!Hd(i)).every(i=>t[i]!==void 0);if(!a){var n=e.filter(i=>t[i]===void 0);throw new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function Hd(r){return r&&r[0]==="?"}function Zd(r){return r&&r[0]==="?"?r.slice(1):r}function rt(r,e){if(pu(r)&&to(r,e))return r[e];throw typeof r[e]=="function"&&no(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function _n(r,e,t){if(pu(r)&&to(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function Jd(r,e){return e in r}function to(r,e){return!r||typeof r!="object"?!1:De(Xd,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Wd(r,e){if(!no(r,e))throw new Error('No access to method "'+e+'"')}function no(r,e){return r==null||typeof r[e]!="function"||De(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:De(Yd,e)?!0:!(e in Object.prototype||e in Function.prototype)}function pu(r){return typeof r=="object"&&r&&r.constructor===Object}var Xd={length:!0,name:!0},Yd={toString:!0,valueOf:!0,toLocaleString:!0};class ao{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return rt(this.wrappedObject,e)}set(e,t){return _n(this.wrappedObject,e,t),this}has(e){return Jd(this.wrappedObject,e)}}function _t(){return new Map}function io(r){if(!r)return _t();if(Ka(r))return r;if(Xi(r))return new ao(r);throw new Error("createMap can create maps from objects or Maps")}function Qd(r){if(r instanceof ao)return r.wrappedObject;var e={};for(var t of r.keys()){var a=r.get(t);_n(e,t,a)}return e}function Ka(r){return r?r instanceof Map||r instanceof ao||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function vu(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];for(var n of t)if(!!n){if(Ka(n))for(var i of n.keys())r.set(i,n.get(i));else if(Xi(n))for(var c of Object.keys(n))r.set(c,n[c])}return r}var hu=function(){return hu=Ks.create,Ks},jd=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Kd=q("typed",jd,function(e){var{BigNumber:t,Complex:a,DenseMatrix:n,Fraction:i}=e,c=hu();return c.types=[{name:"number",test:Ye},{name:"Complex",test:Dt},{name:"BigNumber",test:We},{name:"Fraction",test:En},{name:"Unit",test:la},{name:"string",test:Zr},{name:"Chain",test:Yi},{name:"Array",test:ar},{name:"Matrix",test:Fe},{name:"DenseMatrix",test:Va},{name:"SparseMatrix",test:un},{name:"Range",test:Ga},{name:"Index",test:fa},{name:"boolean",test:id},{name:"ResultSet",test:Ys},{name:"Help",test:Wi},{name:"function",test:od},{name:"Date",test:sd},{name:"RegExp",test:ud},{name:"null",test:cd},{name:"undefined",test:ld},{name:"AccessorNode",test:cn},{name:"ArrayNode",test:Kr},{name:"AssignmentNode",test:fd},{name:"BlockNode",test:md},{name:"ConditionalNode",test:pd},{name:"ConstantNode",test:ir},{name:"FunctionNode",test:ln},{name:"FunctionAssignmentNode",test:ma},{name:"IndexNode",test:On},{name:"Node",test:tr},{name:"ObjectNode",test:Ha},{name:"OperatorNode",test:Jr},{name:"ParenthesisNode",test:pa},{name:"RangeNode",test:vd},{name:"SymbolNode",test:Dr},{name:"Map",test:Ka},{name:"Object",test:Xi}],c.conversions=[{from:"number",to:"BigNumber",convert:function(f){if(t||oo(f),Od(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 t(f)}},{from:"number",to:"Complex",convert:function(f){return a||ei(f),new a(f,0)}},{from:"number",to:"string",convert:function(f){return f+""}},{from:"BigNumber",to:"Complex",convert:function(f){return a||ei(f),new a(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 a||ei(f),new a(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){i||so(f);var l=new i(f);if(l.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 l}},{from:"string",to:"number",convert:function(f){var l=Number(f);if(isNaN(l))throw new Error('Cannot convert "'+f+'" to a number');return l}},{from:"string",to:"BigNumber",convert:function(f){t||oo(f);try{return new t(f)}catch{throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){i||so(f);try{return new i(f)}catch{throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){a||ei(f);try{return new a(f)}catch{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 t||oo(f),new t(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return i||so(f),new i(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return n||eg(),new n(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}],c});function oo(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function ei(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function eg(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function so(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var rg="ResultSet",tg=[],ng=q(rg,tg,()=>{function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return r.prototype.type="ResultSet",r.prototype.isResultSet=!0,r.prototype.valueOf=function(){return this.entries},r.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},r.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},r.fromJSON=function(e){return new r(e.entries)},r},{isClass:!0});/*!
9
+ * decimal.js v10.4.0
10
+ * An arbitrary-precision Decimal type for JavaScript.
11
+ * https://github.com/MikeMcl/decimal.js
12
+ * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
13
+ * MIT Licence
14
+ */var In=9e15,Jt=1e9,uo="0123456789abcdef",ri="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ti="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",co={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-In,maxE:In,crypto:!1},du,It,Ue=!0,ni="[DecimalError] ",Wt=ni+"Invalid argument: ",gu=ni+"Precision limit exceeded",yu=ni+"crypto unavailable",bu="[object Decimal]",Fr=Math.floor,Cr=Math.pow,ag=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ig=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,og=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,xu=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,lt=1e7,qe=7,sg=9007199254740991,ug=ri.length-1,lo=ti.length-1,pe={toStringTag:bu};pe.absoluteValue=pe.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),_e(r)},pe.ceil=function(){return _e(new this.constructor(this),this.e+1,2)},pe.clampedTo=pe.clamp=function(r,e){var t,a=this,n=a.constructor;if(r=new n(r),e=new n(e),!r.s||!e.s)return new n(NaN);if(r.gt(e))throw Error(Wt+e);return t=a.cmp(r),t<0?r:a.cmp(e)>0?e:new n(a)},pe.comparedTo=pe.cmp=function(r){var e,t,a,n,i=this,c=i.d,m=(r=new i.constructor(r)).d,f=i.s,l=r.s;if(!c||!m)return!f||!l?NaN:f!==l?f:c===m?0:!c^f<0?1:-1;if(!c[0]||!m[0])return c[0]?f:m[0]?-l:0;if(f!==l)return f;if(i.e!==r.e)return i.e>r.e^f<0?1:-1;for(a=c.length,n=m.length,e=0,t=a<n?a:n;e<t;++e)if(c[e]!==m[e])return c[e]>m[e]^f<0?1:-1;return a===n?0:a>n^f<0?1:-1},pe.cosine=pe.cos=function(){var r,e,t=this,a=t.constructor;return t.d?t.d[0]?(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+qe,a.rounding=1,t=cg(a,Eu(a,t)),a.precision=r,a.rounding=e,_e(It==2||It==3?t.neg():t,r,e,!0)):new a(1):new a(NaN)},pe.cubeRoot=pe.cbrt=function(){var r,e,t,a,n,i,c,m,f,l,s=this,o=s.constructor;if(!s.isFinite()||s.isZero())return new o(s);for(Ue=!1,i=s.s*Cr(s.s*s,1/3),!i||Math.abs(i)==1/0?(t=Br(s.d),r=s.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Cr(t,1/3),r=Fr((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),a=new o(t),a.s=s.s):a=new o(i.toString()),c=(r=o.precision)+3;;)if(m=a,f=m.times(m).times(m),l=f.plus(s),a=mr(l.plus(s).times(m),l.plus(f),c+2,1),Br(m.d).slice(0,c)===(t=Br(a.d)).slice(0,c))if(t=t.slice(c-3,c+1),t=="9999"||!n&&t=="4999"){if(!n&&(_e(m,r+1,0),m.times(m).times(m).eq(s))){a=m;break}c+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(_e(a,r+1,1),e=!a.times(a).times(a).eq(s));break}return Ue=!0,_e(a,r,o.rounding,e)},pe.decimalPlaces=pe.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-Fr(this.e/qe))*qe,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},pe.dividedBy=pe.div=function(r){return mr(this,new this.constructor(r))},pe.dividedToIntegerBy=pe.divToInt=function(r){var e=this,t=e.constructor;return _e(mr(e,new t(r),0,1,1),t.precision,t.rounding)},pe.equals=pe.eq=function(r){return this.cmp(r)===0},pe.floor=function(){return _e(new this.constructor(this),this.e+1,3)},pe.greaterThan=pe.gt=function(r){return this.cmp(r)>0},pe.greaterThanOrEqualTo=pe.gte=function(r){var e=this.cmp(r);return e==1||e===0},pe.hyperbolicCosine=pe.cosh=function(){var r,e,t,a,n,i=this,c=i.constructor,m=new c(1);if(!i.isFinite())return new c(i.s?1/0:NaN);if(i.isZero())return m;t=c.precision,a=c.rounding,c.precision=t+Math.max(i.e,i.sd())+4,c.rounding=1,n=i.d.length,n<32?(r=Math.ceil(n/3),e=(1/si(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=Rn(c,1,i.times(e),new c(1),!0);for(var f,l=r,s=new c(8);l--;)f=i.times(i),i=m.minus(f.times(s.minus(f.times(s))));return _e(i,c.precision=t,c.rounding=a,!0)},pe.hyperbolicSine=pe.sinh=function(){var r,e,t,a,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+4,i.rounding=1,a=n.d.length,a<3)n=Rn(i,2,n,n,!0);else{r=1.4*Math.sqrt(a),r=r>16?16:r|0,n=n.times(1/si(5,r)),n=Rn(i,2,n,n,!0);for(var c,m=new i(5),f=new i(16),l=new i(20);r--;)c=n.times(n),n=n.times(m.plus(c.times(f.times(c).plus(l))))}return i.precision=e,i.rounding=t,_e(n,e,t,!0)},pe.hyperbolicTangent=pe.tanh=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+7,a.rounding=1,mr(t.sinh(),t.cosh(),a.precision=r,a.rounding=e)):new a(t.s)},pe.inverseCosine=pe.acos=function(){var r,e=this,t=e.constructor,a=e.abs().cmp(1),n=t.precision,i=t.rounding;return a!==-1?a===0?e.isNeg()?ft(t,n,i):new t(0):new t(NaN):e.isZero()?ft(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=ft(t,n+4,i).times(.5),t.precision=n,t.rounding=i,r.minus(e))},pe.inverseHyperbolicCosine=pe.acosh=function(){var r,e,t=this,a=t.constructor;return t.lte(1)?new a(t.eq(1)?0:NaN):t.isFinite()?(r=a.precision,e=a.rounding,a.precision=r+Math.max(Math.abs(t.e),t.sd())+4,a.rounding=1,Ue=!1,t=t.times(t).minus(1).sqrt().plus(t),Ue=!0,a.precision=r,a.rounding=e,t.ln()):new a(t)},pe.inverseHyperbolicSine=pe.asinh=function(){var r,e,t=this,a=t.constructor;return!t.isFinite()||t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,a.rounding=1,Ue=!1,t=t.times(t).plus(1).sqrt().plus(t),Ue=!0,a.precision=r,a.rounding=e,t.ln())},pe.inverseHyperbolicTangent=pe.atanh=function(){var r,e,t,a,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(r=i.precision,e=i.rounding,a=n.sd(),Math.max(a,r)<2*-n.e-1?_e(new i(n),r,e,!0):(i.precision=t=a-n.e,n=mr(n.plus(1),new i(1).minus(n),t+r,1),i.precision=r+4,i.rounding=1,n=n.ln(),i.precision=r,i.rounding=e,n.times(.5))):new i(NaN)},pe.inverseSine=pe.asin=function(){var r,e,t,a,n=this,i=n.constructor;return n.isZero()?new i(n):(e=n.abs().cmp(1),t=i.precision,a=i.rounding,e!==-1?e===0?(r=ft(i,t+4,a).times(.5),r.s=n.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=a,n.times(2)))},pe.inverseTangent=pe.atan=function(){var r,e,t,a,n,i,c,m,f,l=this,s=l.constructor,o=s.precision,u=s.rounding;if(l.isFinite()){if(l.isZero())return new s(l);if(l.abs().eq(1)&&o+4<=lo)return c=ft(s,o+4,u).times(.25),c.s=l.s,c}else{if(!l.s)return new s(NaN);if(o+4<=lo)return c=ft(s,o+4,u).times(.5),c.s=l.s,c}for(s.precision=m=o+10,s.rounding=1,t=Math.min(28,m/qe+2|0),r=t;r;--r)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(Ue=!1,e=Math.ceil(m/qe),a=1,f=l.times(l),c=new s(l),n=l;r!==-1;)if(n=n.times(f),i=c.minus(n.div(a+=2)),n=n.times(f),c=i.plus(n.div(a+=2)),c.d[e]!==void 0)for(r=e;c.d[r]===i.d[r]&&r--;);return t&&(c=c.times(2<<t-1)),Ue=!0,_e(c,s.precision=o,s.rounding=u,!0)},pe.isFinite=function(){return!!this.d},pe.isInteger=pe.isInt=function(){return!!this.d&&Fr(this.e/qe)>this.d.length-2},pe.isNaN=function(){return!this.s},pe.isNegative=pe.isNeg=function(){return this.s<0},pe.isPositive=pe.isPos=function(){return this.s>0},pe.isZero=function(){return!!this.d&&this.d[0]===0},pe.lessThan=pe.lt=function(r){return this.cmp(r)<0},pe.lessThanOrEqualTo=pe.lte=function(r){return this.cmp(r)<1},pe.logarithm=pe.log=function(r){var e,t,a,n,i,c,m,f,l=this,s=l.constructor,o=s.precision,u=s.rounding,p=5;if(r==null)r=new s(10),e=!0;else{if(r=new s(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new s(NaN);e=r.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new s(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(n=t[0];n%10===0;)n/=10;i=n!==1}if(Ue=!1,m=o+p,c=Yt(l,m),a=e?oi(s,m+10):Yt(r,m),f=mr(c,a,m,1),da(f.d,n=o,u))do if(m+=10,c=Yt(l,m),a=e?oi(s,m+10):Yt(r,m),f=mr(c,a,m,1),!i){+Br(f.d).slice(n+1,n+15)+1==1e14&&(f=_e(f,o+1,0));break}while(da(f.d,n+=10,u));return Ue=!0,_e(f,o,u)},pe.minus=pe.sub=function(r){var e,t,a,n,i,c,m,f,l,s,o,u,p=this,v=p.constructor;if(r=new v(r),!p.d||!r.d)return!p.s||!r.s?r=new v(NaN):p.d?r.s=-r.s:r=new v(r.d||p.s!==r.s?p:NaN),r;if(p.s!=r.s)return r.s=-r.s,p.plus(r);if(l=p.d,u=r.d,m=v.precision,f=v.rounding,!l[0]||!u[0]){if(u[0])r.s=-r.s;else if(l[0])r=new v(p);else return new v(f===3?-0:0);return Ue?_e(r,m,f):r}if(t=Fr(r.e/qe),s=Fr(p.e/qe),l=l.slice(),i=s-t,i){for(o=i<0,o?(e=l,i=-i,c=u.length):(e=u,t=s,c=l.length),a=Math.max(Math.ceil(m/qe),c)+2,i>a&&(i=a,e.length=1),e.reverse(),a=i;a--;)e.push(0);e.reverse()}else{for(a=l.length,c=u.length,o=a<c,o&&(c=a),a=0;a<c;a++)if(l[a]!=u[a]){o=l[a]<u[a];break}i=0}for(o&&(e=l,l=u,u=e,r.s=-r.s),c=l.length,a=u.length-c;a>0;--a)l[c++]=0;for(a=u.length;a>i;){if(l[--a]<u[a]){for(n=a;n&&l[--n]===0;)l[n]=lt-1;--l[n],l[a]+=lt}l[a]-=u[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(r.d=l,r.e=ii(l,t),Ue?_e(r,m,f):r):new v(f===3?-0:0)},pe.modulo=pe.mod=function(r){var e,t=this,a=t.constructor;return r=new a(r),!t.d||!r.s||r.d&&!r.d[0]?new a(NaN):!r.d||t.d&&!t.d[0]?_e(new a(t),a.precision,a.rounding):(Ue=!1,a.modulo==9?(e=mr(t,r.abs(),0,3,1),e.s*=r.s):e=mr(t,r,0,a.modulo,1),e=e.times(r),Ue=!0,t.minus(e))},pe.naturalExponential=pe.exp=function(){return fo(this)},pe.naturalLogarithm=pe.ln=function(){return Yt(this)},pe.negated=pe.neg=function(){var r=new this.constructor(this);return r.s=-r.s,_e(r)},pe.plus=pe.add=function(r){var e,t,a,n,i,c,m,f,l,s,o=this,u=o.constructor;if(r=new u(r),!o.d||!r.d)return!o.s||!r.s?r=new u(NaN):o.d||(r=new u(r.d||o.s===r.s?o:NaN)),r;if(o.s!=r.s)return r.s=-r.s,o.minus(r);if(l=o.d,s=r.d,m=u.precision,f=u.rounding,!l[0]||!s[0])return s[0]||(r=new u(o)),Ue?_e(r,m,f):r;if(i=Fr(o.e/qe),a=Fr(r.e/qe),l=l.slice(),n=i-a,n){for(n<0?(t=l,n=-n,c=s.length):(t=s,a=i,c=l.length),i=Math.ceil(m/qe),c=i>c?i+1:c+1,n>c&&(n=c,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for(c=l.length,n=s.length,c-n<0&&(n=c,t=s,s=l,l=t),e=0;n;)e=(l[--n]=l[n]+s[n]+e)/lt|0,l[n]%=lt;for(e&&(l.unshift(e),++a),c=l.length;l[--c]==0;)l.pop();return r.d=l,r.e=ii(l,a),Ue?_e(r,m,f):r},pe.precision=pe.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(Wt+r);return t.d?(e=wu(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},pe.round=function(){var r=this,e=r.constructor;return _e(new e(r),r.e+1,e.rounding)},pe.sine=pe.sin=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+Math.max(t.e,t.sd())+qe,a.rounding=1,t=fg(a,Eu(a,t)),a.precision=r,a.rounding=e,_e(It>2?t.neg():t,r,e,!0)):new a(NaN)},pe.squareRoot=pe.sqrt=function(){var r,e,t,a,n,i,c=this,m=c.d,f=c.e,l=c.s,s=c.constructor;if(l!==1||!m||!m[0])return new s(!l||l<0&&(!m||m[0])?NaN:m?c:1/0);for(Ue=!1,l=Math.sqrt(+c),l==0||l==1/0?(e=Br(m),(e.length+f)%2==0&&(e+="0"),l=Math.sqrt(e),f=Fr((f+1)/2)-(f<0||f%2),l==1/0?e="5e"+f:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+f),a=new s(e)):a=new s(l.toString()),t=(f=s.precision)+3;;)if(i=a,a=i.plus(mr(c,i,t+2,1)).times(.5),Br(i.d).slice(0,t)===(e=Br(a.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!n&&e=="4999"){if(!n&&(_e(i,f+1,0),i.times(i).eq(c))){a=i;break}t+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(_e(a,f+1,1),r=!a.times(a).eq(c));break}return Ue=!0,_e(a,f,s.rounding,r)},pe.tangent=pe.tan=function(){var r,e,t=this,a=t.constructor;return t.isFinite()?t.isZero()?new a(t):(r=a.precision,e=a.rounding,a.precision=r+10,a.rounding=1,t=t.sin(),t.s=1,t=mr(t,new a(1).minus(t.times(t)).sqrt(),r+10,0),a.precision=r,a.rounding=e,_e(It==2||It==4?t.neg():t,r,e,!0)):new a(NaN)},pe.times=pe.mul=function(r){var e,t,a,n,i,c,m,f,l,s=this,o=s.constructor,u=s.d,p=(r=new o(r)).d;if(r.s*=s.s,!u||!u[0]||!p||!p[0])return new o(!r.s||u&&!u[0]&&!p||p&&!p[0]&&!u?NaN:!u||!p?r.s/0:r.s*0);for(t=Fr(s.e/qe)+Fr(r.e/qe),f=u.length,l=p.length,f<l&&(i=u,u=p,p=i,c=f,f=l,l=c),i=[],c=f+l,a=c;a--;)i.push(0);for(a=l;--a>=0;){for(e=0,n=f+a;n>a;)m=i[n]+p[a]*u[n-a-1]+e,i[n--]=m%lt|0,e=m/lt|0;i[n]=(i[n]+e)%lt|0}for(;!i[--c];)i.pop();return e?++t:i.shift(),r.d=i,r.e=ii(i,t),Ue?_e(r,o.precision,o.rounding):r},pe.toBinary=function(r,e){return po(this,2,r,e)},pe.toDecimalPlaces=pe.toDP=function(r,e){var t=this,a=t.constructor;return t=new a(t),r===void 0?t:(Wr(r,0,Jt),e===void 0?e=a.rounding:Wr(e,0,8),_e(t,r+t.e+1,e))},pe.toExponential=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=bt(a,!0):(Wr(r,0,Jt),e===void 0?e=n.rounding:Wr(e,0,8),a=_e(new n(a),r+1,e),t=bt(a,!0,r+1)),a.isNeg()&&!a.isZero()?"-"+t:t},pe.toFixed=function(r,e){var t,a,n=this,i=n.constructor;return r===void 0?t=bt(n):(Wr(r,0,Jt),e===void 0?e=i.rounding:Wr(e,0,8),a=_e(new i(n),r+n.e+1,e),t=bt(a,!1,r+a.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},pe.toFraction=function(r){var e,t,a,n,i,c,m,f,l,s,o,u,p=this,v=p.d,h=p.constructor;if(!v)return new h(p);if(l=t=new h(1),a=f=new h(0),e=new h(a),i=e.e=wu(v)-p.e-1,c=i%qe,e.d[0]=Cr(10,c<0?qe+c:c),r==null)r=i>0?e:l;else{if(m=new h(r),!m.isInt()||m.lt(l))throw Error(Wt+m);r=m.gt(e)?i>0?e:l:m}for(Ue=!1,m=new h(Br(v)),s=h.precision,h.precision=i=v.length*qe*2;o=mr(m,e,0,1,1),n=t.plus(o.times(a)),n.cmp(r)!=1;)t=a,a=n,n=l,l=f.plus(o.times(n)),f=n,n=e,e=m.minus(o.times(n)),m=n;return n=mr(r.minus(t),a,0,1,1),f=f.plus(n.times(l)),t=t.plus(n.times(a)),f.s=l.s=p.s,u=mr(l,a,i,1).minus(p).abs().cmp(mr(f,t,i,1).minus(p).abs())<1?[l,a]:[f,t],h.precision=s,Ue=!0,u},pe.toHexadecimal=pe.toHex=function(r,e){return po(this,16,r,e)},pe.toNearest=function(r,e){var t=this,a=t.constructor;if(t=new a(t),r==null){if(!t.d)return t;r=new a(1),e=a.rounding}else{if(r=new a(r),e===void 0?e=a.rounding:Wr(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(Ue=!1,t=mr(t,r,0,e,1).times(r),Ue=!0,_e(t)):(r.s=t.s,t=r),t},pe.toNumber=function(){return+this},pe.toOctal=function(r,e){return po(this,8,r,e)},pe.toPower=pe.pow=function(r){var e,t,a,n,i,c,m=this,f=m.constructor,l=+(r=new f(r));if(!m.d||!r.d||!m.d[0]||!r.d[0])return new f(Cr(+m,l));if(m=new f(m),m.eq(1))return m;if(a=f.precision,i=f.rounding,r.eq(1))return _e(m,a,i);if(e=Fr(r.e/qe),e>=r.d.length-1&&(t=l<0?-l:l)<=sg)return n=Nu(f,m,t,a),r.s<0?new f(1).div(n):_e(n,a,i);if(c=m.s,c<0){if(e<r.d.length-1)return new f(NaN);if((r.d[e]&1)==0&&(c=1),m.e==0&&m.d[0]==1&&m.d.length==1)return m.s=c,m}return t=Cr(+m,l),e=t==0||!isFinite(t)?Fr(l*(Math.log("0."+Br(m.d))/Math.LN10+m.e+1)):new f(t+"").e,e>f.maxE+1||e<f.minE-1?new f(e>0?c/0:0):(Ue=!1,f.rounding=m.s=1,t=Math.min(12,(e+"").length),n=fo(r.times(Yt(m,a+t)),a),n.d&&(n=_e(n,a+5,1),da(n.d,a,i)&&(e=a+10,n=_e(fo(r.times(Yt(m,e+t)),e),e+5,1),+Br(n.d).slice(a+1,a+15)+1==1e14&&(n=_e(n,a+1,0)))),n.s=c,Ue=!0,f.rounding=i,_e(n,a,i))},pe.toPrecision=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=bt(a,a.e<=n.toExpNeg||a.e>=n.toExpPos):(Wr(r,1,Jt),e===void 0?e=n.rounding:Wr(e,0,8),a=_e(new n(a),r,e),t=bt(a,r<=a.e||a.e<=n.toExpNeg,r)),a.isNeg()&&!a.isZero()?"-"+t:t},pe.toSignificantDigits=pe.toSD=function(r,e){var t=this,a=t.constructor;return r===void 0?(r=a.precision,e=a.rounding):(Wr(r,1,Jt),e===void 0?e=a.rounding:Wr(e,0,8)),_e(new a(t),r,e)},pe.toString=function(){var r=this,e=r.constructor,t=bt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},pe.truncated=pe.trunc=function(){return _e(new this.constructor(this),this.e+1,1)},pe.valueOf=pe.toJSON=function(){var r=this,e=r.constructor,t=bt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function Br(r){var e,t,a,n=r.length-1,i="",c=r[0];if(n>0){for(i+=c,e=1;e<n;e++)a=r[e]+"",t=qe-a.length,t&&(i+=Xt(t)),i+=a;c=r[e],a=c+"",t=qe-a.length,t&&(i+=Xt(t))}else if(c===0)return"0";for(;c%10===0;)c/=10;return i+c}function Wr(r,e,t){if(r!==~~r||r<e||r>t)throw Error(Wt+r)}function da(r,e,t,a){var n,i,c,m;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=qe,n=0):(n=Math.ceil((e+1)/qe),e%=qe),i=Cr(10,qe-e),m=r[n]%i|0,a==null?e<3?(e==0?m=m/100|0:e==1&&(m=m/10|0),c=t<4&&m==99999||t>3&&m==49999||m==5e4||m==0):c=(t<4&&m+1==i||t>3&&m+1==i/2)&&(r[n+1]/i/100|0)==Cr(10,e-2)-1||(m==i/2||m==0)&&(r[n+1]/i/100|0)==0:e<4?(e==0?m=m/1e3|0:e==1?m=m/100|0:e==2&&(m=m/10|0),c=(a||t<4)&&m==9999||!a&&t>3&&m==4999):c=((a||t<4)&&m+1==i||!a&&t>3&&m+1==i/2)&&(r[n+1]/i/1e3|0)==Cr(10,e-3)-1,c}function ai(r,e,t){for(var a,n=[0],i,c=0,m=r.length;c<m;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=uo.indexOf(r.charAt(c++)),a=0;a<n.length;a++)n[a]>t-1&&(n[a+1]===void 0&&(n[a+1]=0),n[a+1]+=n[a]/t|0,n[a]%=t)}return n.reverse()}function cg(r,e){var t,a,n;if(e.isZero())return e;a=e.d.length,a<32?(t=Math.ceil(a/3),n=(1/si(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),r.precision+=t,e=Rn(r,1,e.times(n),new r(1));for(var i=t;i--;){var c=e.times(e);e=c.times(c).minus(c).times(8).plus(1)}return r.precision-=t,e}var mr=function(){function r(a,n,i){var c,m=0,f=a.length;for(a=a.slice();f--;)c=a[f]*n+m,a[f]=c%i|0,m=c/i|0;return m&&a.unshift(m),a}function e(a,n,i,c){var m,f;if(i!=c)f=i>c?1:-1;else for(m=f=0;m<i;m++)if(a[m]!=n[m]){f=a[m]>n[m]?1:-1;break}return f}function t(a,n,i,c){for(var m=0;i--;)a[i]-=m,m=a[i]<n[i]?1:0,a[i]=m*c+a[i]-n[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,n,i,c,m,f){var l,s,o,u,p,v,h,b,w,N,d,y,x,g,S,A,E,M,B,C,_=a.constructor,P=a.s==n.s?1:-1,I=a.d,T=n.d;if(!I||!I[0]||!T||!T[0])return new _(!a.s||!n.s||(I?T&&I[0]==T[0]:!T)?NaN:I&&I[0]==0||!T?P*0:P/0);for(f?(p=1,s=a.e-n.e):(f=lt,p=qe,s=Fr(a.e/p)-Fr(n.e/p)),B=T.length,E=I.length,w=new _(P),N=w.d=[],o=0;T[o]==(I[o]||0);o++);if(T[o]>(I[o]||0)&&s--,i==null?(g=i=_.precision,c=_.rounding):m?g=i+(a.e-n.e)+1:g=i,g<0)N.push(1),v=!0;else{if(g=g/p+2|0,o=0,B==1){for(u=0,T=T[0],g++;(o<E||u)&&g--;o++)S=u*f+(I[o]||0),N[o]=S/T|0,u=S%T|0;v=u||o<E}else{for(u=f/(T[0]+1)|0,u>1&&(T=r(T,u,f),I=r(I,u,f),B=T.length,E=I.length),A=B,d=I.slice(0,B),y=d.length;y<B;)d[y++]=0;C=T.slice(),C.unshift(0),M=T[0],T[1]>=f/2&&++M;do u=0,l=e(T,d,B,y),l<0?(x=d[0],B!=y&&(x=x*f+(d[1]||0)),u=x/M|0,u>1?(u>=f&&(u=f-1),h=r(T,u,f),b=h.length,y=d.length,l=e(h,d,b,y),l==1&&(u--,t(h,B<b?C:T,b,f))):(u==0&&(l=u=1),h=T.slice()),b=h.length,b<y&&h.unshift(0),t(d,h,y,f),l==-1&&(y=d.length,l=e(T,d,B,y),l<1&&(u++,t(d,B<y?C:T,y,f))),y=d.length):l===0&&(u++,d=[0]),N[o++]=u,l&&d[0]?d[y++]=I[A]||0:(d=[I[A]],y=1);while((A++<E||d[0]!==void 0)&&g--);v=d[0]!==void 0}N[0]||N.shift()}if(p==1)w.e=s,du=v;else{for(o=1,u=N[0];u>=10;u/=10)o++;w.e=o+s*p-1,_e(w,m?i+w.e+1:i,c,v)}return w}}();function _e(r,e,t,a){var n,i,c,m,f,l,s,o,u,p=r.constructor;e:if(e!=null){if(o=r.d,!o)return r;for(n=1,m=o[0];m>=10;m/=10)n++;if(i=e-n,i<0)i+=qe,c=e,s=o[u=0],f=s/Cr(10,n-c-1)%10|0;else if(u=Math.ceil((i+1)/qe),m=o.length,u>=m)if(a){for(;m++<=u;)o.push(0);s=f=0,n=1,i%=qe,c=i-qe+1}else break e;else{for(s=m=o[u],n=1;m>=10;m/=10)n++;i%=qe,c=i-qe+n,f=c<0?0:s/Cr(10,n-c-1)%10|0}if(a=a||e<0||o[u+1]!==void 0||(c<0?s:s%Cr(10,n-c-1)),l=t<4?(f||a)&&(t==0||t==(r.s<0?3:2)):f>5||f==5&&(t==4||a||t==6&&(i>0?c>0?s/Cr(10,n-c):0:o[u-1])%10&1||t==(r.s<0?8:7)),e<1||!o[0])return o.length=0,l?(e-=r.e+1,o[0]=Cr(10,(qe-e%qe)%qe),r.e=-e||0):o[0]=r.e=0,r;if(i==0?(o.length=u,m=1,u--):(o.length=u+1,m=Cr(10,qe-i),o[u]=c>0?(s/Cr(10,n-c)%Cr(10,c)|0)*m:0),l)for(;;)if(u==0){for(i=1,c=o[0];c>=10;c/=10)i++;for(c=o[0]+=m,m=1;c>=10;c/=10)m++;i!=m&&(r.e++,o[0]==lt&&(o[0]=1));break}else{if(o[u]+=m,o[u]!=lt)break;o[u--]=0,m=1}for(i=o.length;o[--i]===0;)o.pop()}return Ue&&(r.e>p.maxE?(r.d=null,r.e=NaN):r.e<p.minE&&(r.e=0,r.d=[0])),r}function bt(r,e,t){if(!r.isFinite())return Su(r);var a,n=r.e,i=Br(r.d),c=i.length;return e?(t&&(a=t-c)>0?i=i.charAt(0)+"."+i.slice(1)+Xt(a):c>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):n<0?(i="0."+Xt(-n-1)+i,t&&(a=t-c)>0&&(i+=Xt(a))):n>=c?(i+=Xt(n+1-c),t&&(a=t-n-1)>0&&(i=i+"."+Xt(a))):((a=n+1)<c&&(i=i.slice(0,a)+"."+i.slice(a)),t&&(a=t-c)>0&&(n+1===c&&(i+="."),i+=Xt(a))),i}function ii(r,e){var t=r[0];for(e*=qe;t>=10;t/=10)e++;return e}function oi(r,e,t){if(e>ug)throw Ue=!0,t&&(r.precision=t),Error(gu);return _e(new r(ri),e,1,!0)}function ft(r,e,t){if(e>lo)throw Error(gu);return _e(new r(ti),e,t,!0)}function wu(r){var e=r.length-1,t=e*qe+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function Xt(r){for(var e="";r--;)e+="0";return e}function Nu(r,e,t,a){var n,i=new r(1),c=Math.ceil(a/qe+4);for(Ue=!1;;){if(t%2&&(i=i.times(e),Cu(i.d,c)&&(n=!0)),t=Fr(t/2),t===0){t=i.d.length-1,n&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Cu(e.d,c)}return Ue=!0,i}function Mu(r){return r.d[r.d.length-1]&1}function Au(r,e,t){for(var a,n=new r(e[0]),i=0;++i<e.length;)if(a=new r(e[i]),a.s)n[t](a)&&(n=a);else{n=a;break}return n}function fo(r,e){var t,a,n,i,c,m,f,l=0,s=0,o=0,u=r.constructor,p=u.rounding,v=u.precision;if(!r.d||!r.d[0]||r.e>17)return new u(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(Ue=!1,f=v):f=e,m=new u(.03125);r.e>-2;)r=r.times(m),o+=5;for(a=Math.log(Cr(2,o))/Math.LN10*2+5|0,f+=a,t=i=c=new u(1),u.precision=f;;){if(i=_e(i.times(r),f,1),t=t.times(++s),m=c.plus(mr(i,t,f,1)),Br(m.d).slice(0,f)===Br(c.d).slice(0,f)){for(n=o;n--;)c=_e(c.times(c),f,1);if(e==null)if(l<3&&da(c.d,f-a,p,l))u.precision=f+=10,t=i=m=new u(1),s=0,l++;else return _e(c,u.precision=v,p,Ue=!0);else return u.precision=v,c}c=m}}function Yt(r,e){var t,a,n,i,c,m,f,l,s,o,u,p=1,v=10,h=r,b=h.d,w=h.constructor,N=w.rounding,d=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(e==null?(Ue=!1,s=d):s=e,w.precision=s+=v,t=Br(b),a=t.charAt(0),Math.abs(i=h.e)<15e14){for(;a<7&&a!=1||a==1&&t.charAt(1)>3;)h=h.times(r),t=Br(h.d),a=t.charAt(0),p++;i=h.e,a>1?(h=new w("0."+t),i++):h=new w(a+"."+t.slice(1))}else return l=oi(w,s+2,d).times(i+""),h=Yt(new w(a+"."+t.slice(1)),s-v).plus(l),w.precision=d,e==null?_e(h,d,N,Ue=!0):h;for(o=h,f=c=h=mr(h.minus(1),h.plus(1),s,1),u=_e(h.times(h),s,1),n=3;;){if(c=_e(c.times(u),s,1),l=f.plus(mr(c,new w(n),s,1)),Br(l.d).slice(0,s)===Br(f.d).slice(0,s))if(f=f.times(2),i!==0&&(f=f.plus(oi(w,s+2,d).times(i+""))),f=mr(f,new w(p),s,1),e==null)if(da(f.d,s-v,N,m))w.precision=s+=v,l=c=h=mr(o.minus(1),o.plus(1),s,1),u=_e(h.times(h),s,1),n=m=1;else return _e(f,w.precision=d,N,Ue=!0);else return w.precision=d,f;f=l,n+=2}}function Su(r){return String(r.s*r.s/0)}function mo(r,e){var t,a,n;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(a=e.search(/e/i))>0?(t<0&&(t=a),t+=+e.slice(a+1),e=e.substring(0,a)):t<0&&(t=e.length),a=0;e.charCodeAt(a)===48;a++);for(n=e.length;e.charCodeAt(n-1)===48;--n);if(e=e.slice(a,n),e){if(n-=a,r.e=t=t-a-1,r.d=[],a=(t+1)%qe,t<0&&(a+=qe),a<n){for(a&&r.d.push(+e.slice(0,a)),n-=qe;a<n;)r.d.push(+e.slice(a,a+=qe));e=e.slice(a),a=qe-e.length}else a-=n;for(;a--;)e+="0";r.d.push(+e),Ue&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function lg(r,e){var t,a,n,i,c,m,f,l,s;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),xu.test(e))return mo(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(ig.test(e))t=16,e=e.toLowerCase();else if(ag.test(e))t=2;else if(og.test(e))t=8;else throw Error(Wt+e);for(i=e.search(/p/i),i>0?(f=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),c=i>=0,a=r.constructor,c&&(e=e.replace(".",""),m=e.length,i=m-i,n=Nu(a,new a(t),i,i*2)),l=ai(e,t,lt),s=l.length-1,i=s;l[i]===0;--i)l.pop();return i<0?new a(r.s*0):(r.e=ii(l,s),r.d=l,Ue=!1,c&&(r=mr(r,n,m*4)),f&&(r=r.times(Math.abs(f)<54?Cr(2,f):Qt.pow(2,f))),Ue=!0,r)}function fg(r,e){var t,a=e.d.length;if(a<3)return e.isZero()?e:Rn(r,2,e,e);t=1.4*Math.sqrt(a),t=t>16?16:t|0,e=e.times(1/si(5,t)),e=Rn(r,2,e,e);for(var n,i=new r(5),c=new r(16),m=new r(20);t--;)n=e.times(e),e=e.times(i.plus(n.times(c.times(n).minus(m))));return e}function Rn(r,e,t,a,n){var i,c,m,f,l=r.precision,s=Math.ceil(l/qe);for(Ue=!1,f=t.times(t),m=new r(a);;){if(c=mr(m.times(f),new r(e++*e++),l,1),m=n?a.plus(c):a.minus(c),a=mr(c.times(f),new r(e++*e++),l,1),c=m.plus(a),c.d[s]!==void 0){for(i=s;c.d[i]===m.d[i]&&i--;);if(i==-1)break}i=m,m=a,a=c,c=i}return Ue=!0,c.d.length=s+1,c}function si(r,e){for(var t=r;--e;)t*=r;return t}function Eu(r,e){var t,a=e.s<0,n=ft(r,r.precision,1),i=n.times(.5);if(e=e.abs(),e.lte(i))return It=a?4:1,e;if(t=e.divToInt(n),t.isZero())It=a?3:2;else{if(e=e.minus(t.times(n)),e.lte(i))return It=Mu(t)?a?2:3:a?4:1,e;It=Mu(t)?a?1:4:a?3:2}return e.minus(n).abs()}function po(r,e,t,a){var n,i,c,m,f,l,s,o,u,p=r.constructor,v=t!==void 0;if(v?(Wr(t,1,Jt),a===void 0?a=p.rounding:Wr(a,0,8)):(t=p.precision,a=p.rounding),!r.isFinite())s=Su(r);else{for(s=bt(r),c=s.indexOf("."),v?(n=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):n=e,c>=0&&(s=s.replace(".",""),u=new p(1),u.e=s.length-c,u.d=ai(bt(u),10,n),u.e=u.d.length),o=ai(s,10,n),i=f=o.length;o[--f]==0;)o.pop();if(!o[0])s=v?"0p+0":"0";else{if(c<0?i--:(r=new p(r),r.d=o,r.e=i,r=mr(r,u,t,a,0,n),o=r.d,i=r.e,l=du),c=o[t],m=n/2,l=l||o[t+1]!==void 0,l=a<4?(c!==void 0||l)&&(a===0||a===(r.s<0?3:2)):c>m||c===m&&(a===4||l||a===6&&o[t-1]&1||a===(r.s<0?8:7)),o.length=t,l)for(;++o[--t]>n-1;)o[t]=0,t||(++i,o.unshift(1));for(f=o.length;!o[f-1];--f);for(c=0,s="";c<f;c++)s+=uo.charAt(o[c]);if(v){if(f>1)if(e==16||e==8){for(c=e==16?4:3,--f;f%c;f++)s+="0";for(o=ai(s,n,e),f=o.length;!o[f-1];--f);for(c=1,s="1.";c<f;c++)s+=uo.charAt(o[c])}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=(e==16?"0x":e==2?"0b":e==8?"0o":"")+s}return r.s<0?"-"+s:s}function Cu(r,e){if(r.length>e)return r.length=e,!0}function mg(r){return new this(r).abs()}function pg(r){return new this(r).acos()}function vg(r){return new this(r).acosh()}function hg(r,e){return new this(r).plus(e)}function dg(r){return new this(r).asin()}function gg(r){return new this(r).asinh()}function yg(r){return new this(r).atan()}function bg(r){return new this(r).atanh()}function xg(r,e){r=new this(r),e=new this(e);var t,a=this.precision,n=this.rounding,i=a+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=ft(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?ft(this,a,n):new this(0),t.s=r.s):!r.d||e.isZero()?(t=ft(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(mr(r,e,i,1)),e=ft(this,i,1),this.precision=a,this.rounding=n,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(mr(r,e,i,1)),t}function wg(r){return new this(r).cbrt()}function Ng(r){return _e(r=new this(r),r.e+1,2)}function Mg(r,e,t){return new this(r).clamp(e,t)}function Ag(r){if(!r||typeof r!="object")throw Error(ni+"Object expected");var e,t,a,n=r.defaults===!0,i=["precision",1,Jt,"rounding",0,8,"toExpNeg",-In,0,"toExpPos",0,In,"maxE",0,In,"minE",-In,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],n&&(this[t]=co[t]),(a=r[t])!==void 0)if(Fr(a)===a&&a>=i[e+1]&&a<=i[e+2])this[t]=a;else throw Error(Wt+t+": "+a);if(t="crypto",n&&(this[t]=co[t]),(a=r[t])!==void 0)if(a===!0||a===!1||a===0||a===1)if(a)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(yu);else this[t]=!1;else throw Error(Wt+t+": "+a);return this}function Sg(r){return new this(r).cos()}function Eg(r){return new this(r).cosh()}function Ou(r){var e,t,a;function n(i){var c,m,f,l=this;if(!(l instanceof n))return new n(i);if(l.constructor=n,$u(i)){l.s=i.s,Ue?!i.d||i.e>n.maxE?(l.e=NaN,l.d=null):i.e<n.minE?(l.e=0,l.d=[0]):(l.e=i.e,l.d=i.d.slice()):(l.e=i.e,l.d=i.d?i.d.slice():i.d);return}if(f=typeof i,f==="number"){if(i===0){l.s=1/i<0?-1:1,l.e=0,l.d=[0];return}if(i<0?(i=-i,l.s=-1):l.s=1,i===~~i&&i<1e7){for(c=0,m=i;m>=10;m/=10)c++;Ue?c>n.maxE?(l.e=NaN,l.d=null):c<n.minE?(l.e=0,l.d=[0]):(l.e=c,l.d=[i]):(l.e=c,l.d=[i]);return}else if(i*0!==0){i||(l.s=NaN),l.e=NaN,l.d=null;return}return mo(l,i.toString())}else if(f!=="string")throw Error(Wt+i);return(m=i.charCodeAt(0))===45?(i=i.slice(1),l.s=-1):(m===43&&(i=i.slice(1)),l.s=1),xu.test(i)?mo(l,i):lg(l,i)}if(n.prototype=pe,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=Ag,n.clone=Ou,n.isDecimal=$u,n.abs=mg,n.acos=pg,n.acosh=vg,n.add=hg,n.asin=dg,n.asinh=gg,n.atan=yg,n.atanh=bg,n.atan2=xg,n.cbrt=wg,n.ceil=Ng,n.clamp=Mg,n.cos=Sg,n.cosh=Eg,n.div=Cg,n.exp=Og,n.floor=$g,n.hypot=Tg,n.ln=Dg,n.log=Bg,n.log10=Ig,n.log2=_g,n.max=Rg,n.min=Fg,n.mod=qg,n.mul=zg,n.pow=Pg,n.random=Ug,n.round=Lg,n.sign=kg,n.sin=Vg,n.sinh=Gg,n.sqrt=Hg,n.sub=Zg,n.sum=Jg,n.tan=Wg,n.tanh=Xg,n.trunc=Yg,r===void 0&&(r={}),r&&r.defaults!==!0)for(a=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<a.length;)r.hasOwnProperty(t=a[e++])||(r[t]=this[t]);return n.config(r),n}function Cg(r,e){return new this(r).div(e)}function Og(r){return new this(r).exp()}function $g(r){return _e(r=new this(r),r.e+1,3)}function Tg(){var r,e,t=new this(0);for(Ue=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return Ue=!0,new this(1/0);t=e}return Ue=!0,t.sqrt()}function $u(r){return r instanceof Qt||r&&r.toStringTag===bu||!1}function Dg(r){return new this(r).ln()}function Bg(r,e){return new this(r).log(e)}function _g(r){return new this(r).log(2)}function Ig(r){return new this(r).log(10)}function Rg(){return Au(this,arguments,"lt")}function Fg(){return Au(this,arguments,"gt")}function qg(r,e){return new this(r).mod(e)}function zg(r,e){return new this(r).mul(e)}function Pg(r,e){return new this(r).pow(e)}function Ug(r){var e,t,a,n,i=0,c=new this(1),m=[];if(r===void 0?r=this.precision:Wr(r,1,Jt),a=Math.ceil(r/qe),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(a));i<a;)n=e[i],n>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:m[i++]=n%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(a*=4);i<a;)n=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(e,i):(m.push(n%1e7),i+=4);i=a/4}else throw Error(yu);else for(;i<a;)m[i++]=Math.random()*1e7|0;for(a=m[--i],r%=qe,a&&r&&(n=Cr(10,qe-r),m[i]=(a/n|0)*n);m[i]===0;i--)m.pop();if(i<0)t=0,m=[0];else{for(t=-1;m[0]===0;t-=qe)m.shift();for(a=1,n=m[0];n>=10;n/=10)a++;a<qe&&(t-=qe-a)}return c.e=t,c.d=m,c}function Lg(r){return _e(r=new this(r),r.e+1,this.rounding)}function kg(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function Vg(r){return new this(r).sin()}function Gg(r){return new this(r).sinh()}function Hg(r){return new this(r).sqrt()}function Zg(r,e){return new this(r).sub(e)}function Jg(){var r=0,e=arguments,t=new this(e[r]);for(Ue=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return Ue=!0,_e(t,this.precision,this.rounding)}function Wg(r){return new this(r).tan()}function Xg(r){return new this(r).tanh()}function Yg(r){return _e(r=new this(r),r.e+1,1)}pe[Symbol.for("nodejs.util.inspect.custom")]=pe.toString,pe[Symbol.toStringTag]="Decimal";var Qt=pe.constructor=Ou(co);ri=new Qt(ri),ti=new Qt(ti);var Qg="BigNumber",jg=["?on","config"],Kg=q(Qg,jg,r=>{var{on:e,config:t}=r,a=Qt.clone({precision:t.precision,modulo:Qt.EUCLID});return a.prototype=Object.create(a.prototype),a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(n){return new a(n.value)},e&&e("config",function(n,i){n.precision!==i.precision&&a.config({precision:n.precision})}),a},{isClass:!0}),Tu={exports:{}};/**
15
+ * @license Complex.js v2.1.1 12/05/2020
16
+ *
17
+ * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
18
+ * Dual licensed under the MIT or GPL Version 2 licenses.
19
+ **/(function(r,e){(function(t){var a=Math.cosh||function(o){return Math.abs(o)<1e-9?1-o:(Math.exp(o)+Math.exp(-o))*.5},n=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)},c=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 l=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=l(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 c(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)*a(u),Math.cos(o)*n(u))},cos:function(){var o=this.re,u=this.im;return new s(Math.cos(o)*a(u),-Math.sin(o)*n(u))},tan:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)+a(u);return new s(Math.sin(o)/p,n(u)/p)},cot:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)-a(u);return new s(-Math.sin(o)/p,n(u)/p)},sec:function(){var o=this.re,u=this.im,p=.5*a(2*u)+.5*Math.cos(2*o);return new s(Math.cos(o)*a(u)/p,Math.sin(o)*n(u)/p)},csc:function(){var o=this.re,u=this.im,p=.5*a(2*u)-.5*Math.cos(2*o);return new s(Math.sin(o)*a(u)/p,-Math.cos(o)*n(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(n(o)*Math.cos(u),a(o)*Math.sin(u))},cosh:function(){var o=this.re,u=this.im;return new s(a(o)*Math.cos(u),n(o)*Math.sin(u))},tanh:function(){var o=2*this.re,u=2*this.im,p=a(o)+Math.cos(u);return new s(n(o)/p,Math.sin(u)/p)},coth:function(){var o=2*this.re,u=2*this.im,p=a(o)-Math.cos(u);return new s(n(o)/p,-Math.sin(u)/p)},csch:function(){var o=this.re,u=this.im,p=Math.cos(2*u)-a(2*o);return new s(-2*n(o)*Math.cos(u)/p,2*a(o)*Math.sin(u)/p)},sech:function(){var o=this.re,u=this.im,p=Math.cos(2*u)+a(2*o);return new s(2*a(o)*Math.cos(u)/p,-2*n(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,r.exports=s})()})(Tu);const Xr=Qs(Tu.exports);var ey="Complex",ry=[],ty=q(ey,ry,()=>(Xr.prototype.type="Complex",Xr.prototype.isComplex=!0,Xr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Xr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Xr.prototype.format=function(r){var e="",t=this.im,a=this.re,n=fn(this.re,r),i=fn(this.im,r),c=Ye(r)?r:r?r.precision:null;if(c!==null){var m=Math.pow(10,-c);Math.abs(a/t)<m&&(a=0),Math.abs(t/a)<m&&(t=0)}return t===0?e=n:a===0?t===1?e="i":t===-1?e="-i":e=i+"i":t<0?t===-1?e=n+" - i":e=n+" - "+i.substring(1)+"i":t===1?e=n+" + i":e=n+" + "+i+"i",e},Xr.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Xr(e);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],a=arguments[1];if(Ye(t)){if(la(a)&&a.hasBase("ANGLE")&&(a=a.toNumber("rad")),Ye(a))return new Xr({r:t,phi:a});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")}},Xr.prototype.valueOf=Xr.prototype.toString,Xr.fromJSON=function(r){return new Xr(r)},Xr.compare=function(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0},Xr),{isClass:!0}),Du={exports:{}};/**
21
+ * @license Fraction.js v4.2.0 05/03/2022
22
+ * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
23
+ *
24
+ * Copyright (c) 2021, Robert Eisele (robert@xarg.org)
25
+ * Dual licensed under the MIT or GPL Version 2 licenses.
26
+ **/(function(r,e){(function(t){var a=2e3,n={s:1,n:0,d:1};function i(v,h){if(isNaN(v=parseInt(v,10)))throw p.InvalidParameter;return v*h}function c(v,h){if(h===0)throw p.DivisionByZero;var b=Object.create(p.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var w=u(v,h);return b.n=v/w,b.d=h/w,b}function m(v){for(var h={},b=v,w=2,N=4;N<=b;){for(;b%w===0;)b/=w,h[w]=(h[w]||0)+1;N+=1+2*w++}return b!==v?b>1&&(h[b]=(h[b]||0)+1):h[v]=(h[v]||0)+1,h}var f=function(v,h){var b=0,w=1,N=1,d=0,y=0,x=0,g=1,S=1,A=0,E=1,M=1,B=1,C=1e7,_;if(v!=null)if(h!==void 0){if(b=v,w=h,N=b*w,b%1!==0||w%1!==0)throw p.NonIntegerParameter}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,w=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(w=v[1]);else throw p.InvalidParameter;N=b*w;break}case"number":{if(v<0&&(N=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(S=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=S);E<=C&&B<=C;)if(_=(A+M)/(E+B),v===_){E+B<=C?(b=A+M,w=E+B):B>E?(b=M,w=B):(b=A,w=E);break}else v>_?(A+=M,E+=B):(M+=A,B+=E),E>C?(b=M,w=B):(b=A,w=E);b*=S}else(isNaN(v)||isNaN(h))&&(w=b=NaN);break}case"string":{if(E=v.match(/\d+|./g),E===null)throw p.InvalidParameter;if(E[A]==="-"?(N=-1,A++):E[A]==="+"&&A++,E.length===A+1?y=i(E[A++],N):E[A+1]==="."||E[A]==="."?(E[A]!=="."&&(d=i(E[A++],N)),A++,(A+1===E.length||E[A+1]==="("&&E[A+3]===")"||E[A+1]==="'"&&E[A+3]==="'")&&(y=i(E[A],N),g=Math.pow(10,E[A].length),A++),(E[A]==="("&&E[A+2]===")"||E[A]==="'"&&E[A+2]==="'")&&(x=i(E[A+1],N),S=Math.pow(10,E[A+1].length)-1,A+=3)):E[A+1]==="/"||E[A+1]===":"?(y=i(E[A],N),g=i(E[A+2],1),A+=3):E[A+3]==="/"&&E[A+1]===" "&&(d=i(E[A],N),y=i(E[A+2],N),g=i(E[A+4],1),A+=5),E.length<=A){w=g*S,N=b=x+w*d+S*y;break}}default:throw p.InvalidParameter}if(w===0)throw p.DivisionByZero;n.s=N<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(w)};function l(v,h,b){for(var w=1;h>0;v=v*v%b,h>>=1)h&1&&(w=w*v%b);return w}function s(v,h){for(;h%2===0;h/=2);for(;h%5===0;h/=5);if(h===1)return 0;for(var b=10%h,w=1;b!==1;w++)if(b=b*10%h,w>a)return 0;return w}function o(v,h,b){for(var w=1,N=l(10,b,h),d=0;d<300;d++){if(w===N)return d;w=w*10%h,N=N*10%h}return 0}function u(v,h){if(!v)return h;if(!h)return v;for(;;){if(v%=h,!v)return h;if(h%=v,!h)return v}}function p(v,h){if(f(v,h),this instanceof p)v=u(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return c(n.s*n.n,n.d)}p.DivisionByZero=new Error("Division by Zero"),p.InvalidParameter=new Error("Invalid argument"),p.NonIntegerParameter=new Error("Parameters must be integer"),p.prototype={s:1,n:0,d:1,abs:function(){return c(this.n,this.d)},neg:function(){return c(-this.s*this.n,this.d)},add:function(v,h){return f(v,h),c(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,h){return f(v,h),c(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,h){return f(v,h),c(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,h){return f(v,h),c(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return c(this.s*this.n,this.d)},mod:function(v,h){if(isNaN(this.n)||isNaN(this.d))return new p(NaN);if(v===void 0)return c(this.s*this.n%this.d,1);if(f(v,h),n.n===0&&this.d===0)throw p.DivisionByZero;return c(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,h){return f(v,h),c(u(n.n,this.n)*u(n.d,this.d),n.d*this.d)},lcm:function(v,h){return f(v,h),n.n===0&&this.n===0?c(0,1):c(n.n*this.n,u(n.n,this.n)*u(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new p(NaN):c(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new p(NaN):c(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new p(NaN):c(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return c(this.s*this.d,this.n)},pow:function(v,h){if(f(v,h),n.d===1)return n.s<0?c(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):c(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=m(this.n),w=m(this.d),N=1,d=1;for(var y in b)if(y!=="1"){if(y==="0"){N=0;break}if(b[y]*=n.n,b[y]%n.d===0)b[y]/=n.d;else return null;N*=Math.pow(y,b[y])}for(var y in w)if(y!=="1"){if(w[y]*=n.n,w[y]%n.d===0)w[y]/=n.d;else return null;d*=Math.pow(y,w[y])}return n.s<0?c(d,N):c(N,d)},equals:function(v,h){return f(v,h),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,h){f(v,h);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var h=this.abs(),b=h.toContinued(),w=1;w<b.length;w++){for(var N=c(b[w-1],1),d=w-2;d>=0;d--)N=N.inverse().add(b[d]);if(N.sub(h).abs().valueOf()<v)return N.mul(this.s)}return this},divisible:function(v,h){return f(v,h),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var h,b="",w=this.n,N=this.d;return this.s<0&&(b+="-"),N===1?b+=w:(v&&(h=Math.floor(w/N))>0&&(b+=h,b+=" ",w%=N),b+=w,b+="/",b+=N),b},toLatex:function(v){var h,b="",w=this.n,N=this.d;return this.s<0&&(b+="-"),N===1?b+=w:(v&&(h=Math.floor(w/N))>0&&(b+=h,w%=N),b+="\\frac{",b+=w,b+="}{",b+=N,b+="}"),b},toContinued:function(){var v,h=this.n,b=this.d,w=[];if(isNaN(h)||isNaN(b))return w;do w.push(Math.floor(h/b)),v=h%b,h=b,b=v;while(h!==1);return w},toString:function(v){var h=this.n,b=this.d;if(isNaN(h)||isNaN(b))return"NaN";v=v||15;var w=s(h,b),N=o(h,b,w),d=this.s<0?"-":"";if(d+=h/b|0,h%=b,h*=10,h&&(d+="."),w){for(var y=N;y--;)d+=h/b|0,h%=b,h*=10;d+="(";for(var y=w;y--;)d+=h/b|0,h%=b,h*=10;d+=")"}else for(var y=v;h&&y--;)d+=h/b|0,h%=b,h*=10;return d}},Object.defineProperty(p,"__esModule",{value:!0}),p.default=p,p.Fraction=p,r.exports=p})()})(Du);const Fn=Qs(Du.exports);var ny="Fraction",ay=[],iy=q(ny,ay,()=>(Fn.prototype.type="Fraction",Fn.prototype.isFraction=!0,Fn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Fn.fromJSON=function(r){return new Fn(r)},Fn),{isClass:!0}),oy="Range",sy=[],uy=q(oy,sy,()=>{function r(e,t,a){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");var n=e!=null,i=t!=null,c=a!=null;if(n){if(We(e))e=e.toNumber();else if(typeof e!="number")throw new TypeError("Parameter start must be a number")}if(i){if(We(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter end must be a number")}if(c){if(We(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter step must be a number")}this.start=n?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=c?parseFloat(a):1}return r.prototype.type="Range",r.prototype.isRange=!0,r.parse=function(e){if(typeof e!="string")return null;var t=e.split(":"),a=t.map(function(i){return parseFloat(i)}),n=a.some(function(i){return isNaN(i)});if(n)return null;switch(a.length){case 2:return new r(a[0],a[1]);case 3:return new r(a[0],a[2],a[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.prototype.size=function(){var e=0,t=this.start,a=this.step,n=this.end,i=n-t;return Zt(a)===Zt(i)?e=Math.ceil(i/a):i===0&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},r.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},r.prototype.forEach=function(e){var t=this.start,a=this.step,n=this.end,i=0;if(a>0)for(;t<n;)e(t,[i],this),t+=a,i++;else if(a<0)for(;t>n;)e(t,[i],this),t+=a,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(a,n,i){t[n[0]]=e(a,n,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,a){e[a[0]]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=fn(this.start,e);return this.step!==1&&(t+=":"+fn(this.step,e)),t+=":"+fn(this.end,e),t},r.prototype.toString=function(){return this.format()},r.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r},{isClass:!0}),cy="Matrix",ly=[],fy=q(cy,ly,()=>{function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.type="Matrix",r.prototype.isMatrix=!0,r.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},r.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},r.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},r.prototype.subset=function(e,t,a){throw new Error("Cannot invoke subset on a Matrix interface")},r.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},r.prototype.set=function(e,t,a){throw new Error("Cannot invoke set on a Matrix interface")},r.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},r.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},r.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},r.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},r.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},r.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},r.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},r.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},r.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},r.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},r.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},r},{isClass:!0}),my="DenseMatrix",py=["Matrix"],vy=q(my,py,r=>{var{Matrix:e}=r;function t(s,o){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(o&&!Zr(o))throw new Error("Invalid datatype: "+o);if(Fe(s))s.type==="DenseMatrix"?(this._data=Re(s._data),this._size=Re(s._size),this._datatype=o||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=o||s._datatype);else if(s&&ar(s.data)&&ar(s.size))this._data=s.data,this._size=s.size,iu(this._data,this._size),this._datatype=o||s.datatype;else if(ar(s))this._data=l(s),this._size=Je(this._data),iu(this._data,this._size),this._datatype=o;else{if(s)throw new TypeError("Unsupported type of data ("+cr(s)+")");this._data=[],this._size=[0],this._datatype=o}}t.prototype=new e,t.prototype.createDenseMatrix=function(s,o){return new t(s,o)},t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return ha(this._data,cr)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(s,o){return new t(s,o)},t.prototype.subset=function(s,o,u){switch(arguments.length){case 1:return a(this,s);case 2:case 3:return i(this,s,o,u);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(s){if(!ar(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new He(s.length,this._size.length);for(var o=0;o<s.length;o++)or(s[o],this._size[o]);for(var u=this._data,p=0,v=s.length;p<v;p++){var h=s[p];or(h,u.length),u=u[h]}return u},t.prototype.set=function(s,o,u){if(!ar(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new He(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],or(h,w.length),w=w[h];return h=s[s.length-1],or(h,w.length),w[h]=o,this};function a(s,o){if(!fa(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 He(p.length,s._size.length);for(var v=o.min(),h=o.max(),b=0,w=s._size.length;b<w;b++)or(v[b],s._size[b]),or(h[b],s._size[b]);return new t(n(s._data,o,p.length,0),s._datatype)}function n(s,o,u,p){var v=p===u-1,h=o.dimension(p);return v?h.map(function(b){return or(b,s.length),s[b]}).valueOf():h.map(function(b){or(b,s.length);var w=s[b];return n(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(Fe(u)?(b=u.size(),u=u.valueOf()):b=Je(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 He(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=cu(u,v.length,N,b)}if(!va(v,b))throw new He(v,b,">");var d=o.max().map(function(g){return g+1});f(s,d,p);var y=v.length,x=0;c(s._data,o,u,y,x)}return s}function c(s,o,u,p,v){var h=v===p-1,b=o.dimension(v);h?b.forEach(function(w,N){or(w),s[w]=u[N[0]]}):b.forEach(function(w,N){or(w),c(s[w],o,u[N[0]],p,v+1)})}t.prototype.resize=function(s,o,u){if(!Cn(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;ar(p);)p=p[0];return p}return s._size=o.slice(0),s._data=Dn(s._data,s._size,u),s}t.prototype.reshape=function(s,o){var u=o?this.clone():this;u._data=ou(u._data,s);var p=u._size.reduce((v,h)=>v*h);return u._size=ro(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)}t.prototype.clone=function(){var s=new t({data:Re(this._data),size:Re(this._size),datatype:this._datatype});return s},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(s){var o=this,u=function h(b,w){return ar(b)?b.map(function(N,d){return h(N,w.concat(d))}):s(b,w,o)},p=u(this._data,[]),v=this._datatype!==void 0?ha(p,cr):void 0;return new t(p,v)},t.prototype.forEach=function(s){var o=this,u=function p(v,h){ar(v)?v.forEach(function(b,w){p(b,h.concat(w))}):s(v,h,o)};u(this._data,[])},t.prototype[Symbol.iterator]=function*(){var s=function*o(u,p){if(ar(u))for(var v=0;v<u.length;v++)yield*o(u[v],p.concat(v));else yield{value:u,index:p}};yield*s(this._data,[])},t.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 t([p],this._datatype));return s},t.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(d=>[d[w]]);o.push(new t(N,s._datatype))},h=0;h<u[1];h++)v(h);return o},t.prototype.toArray=function(){return Re(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(s){return Ge(this._data,s)},t.prototype.toString=function(){return Ge(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(s){if(s){if(We(s)&&(s=s.toNumber()),!Ye(s)||!Be(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 t({data:b,size:[h],datatype:this._datatype})},t.diagonal=function(s,o,u,p){if(!ar(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(S){if(We(S)&&(S=S.toNumber()),!Ye(S)||!Be(S)||S<1)throw new Error("Size values must be positive integers");return S}),u){if(We(u)&&(u=u.toNumber()),!Ye(u)||!Be(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),d;if(ar(o)){if(o.length!==N)throw new Error("Invalid value array length");d=function(A){return o[A]}}else if(Fe(o)){var y=o.size();if(y.length!==1||y[0]!==N)throw new Error("Invalid matrix length");d=function(A){return o.get([A])}}else d=function(){return o};p||(p=We(d(0))?d(0).mul(0):0);var x=[];if(s.length>0){x=Dn(x,s,p);for(var g=0;g<N;g++)x[g+h][g+v]=d(g)}return new t({data:x,size:[b,w]})},t.fromJSON=function(s){return new t(s)},t.prototype.swapRows=function(s,o){if(!Ye(s)||!Be(s)||!Ye(o)||!Be(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 or(s,this._size[0]),or(o,this._size[0]),t._swapRows(s,o,this._data),this},t._swapRows=function(s,o,u){var p=u[s];u[s]=u[o],u[o]=p};function l(s){for(var o=0,u=s.length;o<u;o++){var p=s[o];ar(p)?s[o]=l(p):p&&p.isMatrix===!0&&(s[o]=l(p.valueOf()))}return s}return t},{isClass:!0}),Bu="clone",hy=["typed"],dy=q(Bu,hy,r=>{var{typed:e}=r;return e(Bu,{any:Re})});function _u(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var c=[];for(a=0;a<e;a++)c.push(r[a][n]);i.push(c)}return i}function qn(r){for(var e=0;e<r.length;e++)if(Cn(r[e]))return!0;return!1}function Rt(r,e){Fe(r)&&(r=r.valueOf());for(var t=0,a=r.length;t<a;t++){var n=r[t];Array.isArray(n)?Rt(n,e):e(n)}}function $e(r,e,t){return r&&typeof r.map=="function"?r.map(function(a){return $e(a,e)}):e(r)}function ui(r,e,t){var a=Array.isArray(r)?Je(r):r.size();if(e<0||e>=a.length)throw new ct(e,a.length);return Fe(r)?r.create(ci(r.valueOf(),e,t)):ci(r,e,t)}function ci(r,e,t){var a,n,i,c;if(e<=0)if(Array.isArray(r[0])){for(c=_u(r),n=[],a=0;a<c.length;a++)n[a]=ci(c[a],e-1,t);return n}else{for(i=r[0],a=1;a<r.length;a++)i=t(i,r[a]);return i}else{for(n=[],a=0;a<r.length;a++)n[a]=ci(r[a],e-1,t);return n}}function Iu(r,e,t,a,n,i,c,m,f,l,s){var o=r._values,u=r._index,p=r._ptr,v,h,b,w;if(a)for(h=p[e],b=p[e+1],v=h;v<b;v++)w=u[v],t[w]!==i?(t[w]=i,c.push(w),l?(a[w]=f?m(o[v],s):m(s,o[v]),n[w]=i):a[w]=o[v]):(a[w]=f?m(o[v],a[w]):m(a[w],o[v]),n[w]=i);else for(h=p[e],b=p[e+1],v=h;v<b;v++)w=u[v],t[w]!==i?(t[w]=i,c.push(w)):n[w]=i}var Ru="isInteger",gy=["typed"],yy=q(Ru,gy,r=>{var{typed:e}=r;return e(Ru,{number:Be,BigNumber:function(a){return a.isInt()},Fraction:function(a){return a.d===1&&isFinite(a.n)},"Array | Matrix":function(a){return $e(a,this)}})}),mt="number",mn="number, number";function Fu(r){return Math.abs(r)}Fu.signature=mt;function qu(r,e){return r+e}qu.signature=mn;function zu(r,e){return r*e}zu.signature=mn;function Pu(r){return-r}Pu.signature=mt;function Uu(r){return r}Uu.signature=mt;function ga(r){return Ad(r)}ga.signature=mt;function Lu(r){return r*r*r}Lu.signature=mt;function ku(r){return Math.exp(r)}ku.signature=mt;function Vu(r){return Sd(r)}Vu.signature=mt;function Gu(r,e){if(!Be(r)||!Be(e))throw new Error("Parameters in function gcd must be integer numbers");for(var t;e!==0;)t=r%e,r=e,e=t;return r<0?-r:r}Gu.signature=mn;function Hu(r,e){if(!Be(r)||!Be(e))throw new Error("Parameters in function lcm must be integer numbers");if(r===0||e===0)return 0;for(var t,a=r*e;e!==0;)t=e,e=r%t,r=t;return Math.abs(a/r)}Hu.signature=mn;function by(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function Zu(r){return Nd(r)}Zu.signature=mt;function Ju(r){return wd(r)}Ju.signature=mt;function Wu(r,e){if(e>0)return r-e*Math.floor(r/e);if(e===0)return r;throw new Error("Cannot calculate mod for a negative divisor")}Wu.signature=mn;function Xu(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,t=e<0;if(t&&(e=-e),e===0)throw new Error("Root must be non-zero");if(r<0&&Math.abs(e)%2!==1)throw new Error("Root must be odd when a is negative.");if(r===0)return t?1/0:0;if(!isFinite(r))return t?0:r;var a=Math.pow(Math.abs(r),1/e);return a=r<0?-a:a,t?1/a:a}function vo(r){return Zt(r)}vo.signature=mt;function Yu(r){return r*r}Yu.signature=mt;function Qu(r,e){var t,a,n,i=0,c=1,m=1,f=0;if(!Be(r)||!Be(e))throw new Error("Parameters in function xgcd must be integer numbers");for(;e;)a=Math.floor(r/e),n=r-a*e,t=i,i=c-a*i,c=t,t=m,m=f-a*m,f=t,r=e,e=n;var l;return r<0?l=[-r,-c,-f]:l=[r,r?c:0,f],l}Qu.signature=mn;function ju(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}ju.signature=mn;function Ku(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Be(e)||e<0||e>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(eu(r,e))}var xy="number",zn="number, number";function ec(r,e){if(!Be(r)||!Be(e))throw new Error("Integers expected in function bitAnd");return r&e}ec.signature=zn;function rc(r){if(!Be(r))throw new Error("Integer expected in function bitNot");return~r}rc.signature=xy;function tc(r,e){if(!Be(r)||!Be(e))throw new Error("Integers expected in function bitOr");return r|e}tc.signature=zn;function nc(r,e){if(!Be(r)||!Be(e))throw new Error("Integers expected in function bitXor");return r^e}nc.signature=zn;function ac(r,e){if(!Be(r)||!Be(e))throw new Error("Integers expected in function leftShift");return r<<e}ac.signature=zn;function ic(r,e){if(!Be(r)||!Be(e))throw new Error("Integers expected in function rightArithShift");return r>>e}ic.signature=zn;function oc(r,e){if(!Be(r)||!Be(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}oc.signature=zn;function Ft(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return Ft(r,t)*Ft(t+1,e)}function sc(r,e){if(!Be(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!Be(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(e>r)throw new TypeError("k must be less than or equal to n");for(var t=r-e,a=1,n=e<t?t+1:e+1,i=2,c=e<t?e:t,m=n;m<=r;++m)for(a*=m;i<=c&&a%i===0;)a/=i,++i;return i<=c&&(a/=Ft(i,c)),a}sc.signature="number, number";var wy=Math.PI,Ny=2*Math.PI,My=Math.E,Ay=1.618033988749895,Sy="number",ho="number, number";function uc(r){return!r}uc.signature=Sy;function cc(r,e){return!!(r||e)}cc.signature=ho;function lc(r,e){return!!r!=!!e}lc.signature=ho;function fc(r,e){return!!(r&&e)}fc.signature=ho;function go(r){var e;if(Be(r))return r<=0?isFinite(r)?1/0:NaN:r>171?1/0:Ft(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*go(1-r));if(r>=171.35)return 1/0;if(r>85){var t=r*r,a=t*r,n=a*r,i=n*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*t)-139/(51840*a)-571/(2488320*n)+163879/(209018880*i)+5246819/(75246796800*i*r))}--r,e=Pn[0];for(var c=1;c<Pn.length;++c)e+=Pn[c]/(r+c);var m=r+mc+.5;return Math.sqrt(2*Math.PI)*Math.pow(m,r+.5)*Math.exp(-m)*e}go.signature="number";var mc=4.7421875,Pn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],pc=.9189385332046728,Ey=5,Cy=7,vc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function li(r){if(r<0)return NaN;if(r===0)return 1/0;if(!isFinite(r))return r;if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-li(1-r);r=r-1;for(var e=r+Ey+.5,t=vc[0],a=Cy-1;a>=1;a--)t+=vc[a]/(r+a);return pc+(r+.5)*Math.log(e)-e+Math.log(t)}li.signature="number";var qr="number";function hc(r){return Td(r)}hc.signature=qr;function dc(r){return Math.atan(1/r)}dc.signature=qr;function gc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}gc.signature=qr;function yc(r){return Math.asin(1/r)}yc.signature=qr;function bc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}bc.signature=qr;function xc(r){return Math.acos(1/r)}xc.signature=qr;function wc(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}wc.signature=qr;function Nc(r){return Dd(r)}Nc.signature=qr;function Mc(r){return Bd(r)}Mc.signature=qr;function Ac(r){return 1/Math.tan(r)}Ac.signature=qr;function Sc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Sc.signature=qr;function Ec(r){return 1/Math.sin(r)}Ec.signature=qr;function Cc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*Zt(r)}Cc.signature=qr;function Oc(r){return 1/Math.cos(r)}Oc.signature=qr;function $c(r){return 2/(Math.exp(r)+Math.exp(-r))}$c.signature=qr;function Tc(r){return Id(r)}Tc.signature=qr;var fi="number";function Dc(r){return r<0}Dc.signature=fi;function Bc(r){return r>0}Bc.signature=fi;function _c(r){return r===0}_c.signature=fi;function Ic(r){return Number.isNaN(r)}Ic.signature=fi;var Rc="isNegative",Oy=["typed"],$y=q(Rc,Oy,r=>{var{typed:e}=r;return e(Rc,{number:Dc,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s<0},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),Fc="isNumeric",Ty=["typed"],Dy=q(Fc,Ty,r=>{var{typed:e}=r;return e(Fc,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(a){return $e(a,this)}})}),qc="hasNumericValue",By=["typed","isNumeric"],_y=q(qc,By,r=>{var{typed:e,isNumeric:t}=r;return e(qc,{string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),zc="isPositive",Iy=["typed"],Ry=q(zc,Iy,r=>{var{typed:e}=r;return e(zc,{number:Bc,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s>0&&a.n>0},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),Pc="isZero",Fy=["typed"],qy=q(Pc,Fy,r=>{var{typed:e}=r;return e(Pc,{number:_c,BigNumber:function(a){return a.isZero()},Complex:function(a){return a.re===0&&a.im===0},Fraction:function(a){return a.d===1&&a.n===0},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),Uc="isNaN",zy=["typed"],Py=q(Uc,zy,r=>{var{typed:e}=r;return e(Uc,{number:Ic,BigNumber:function(a){return a.isNaN()},Fraction:function(a){return!1},Complex:function(a){return a.isNaN()},Unit:function(a){return Number.isNaN(a.value)},"Array | Matrix":function(a){return $e(a,Number.isNaN)}})}),Lc="typeOf",Uy=["typed"],Ly=q(Lc,Uy,r=>{var{typed:e}=r;return e(Lc,{any:cr})});function xt(r,e,t){if(t==null)return r.eq(e);if(r.eq(e))return!0;if(r.isNaN()||e.isNaN())return!1;if(r.isFinite()&&e.isFinite()){var a=r.minus(e).abs();if(a.isZero())return!0;var n=r.constructor.max(r.abs(),e.abs());return a.lte(n.times(t))}return!1}function ky(r,e,t){return Yr(r.re,e.re,t)&&Yr(r.im,e.im,t)}var mi="equalScalar",Vy=["typed","config"],Gy=q(mi,Vy,r=>{var{typed:e,config:t}=r;return e(mi,{"boolean, boolean":function(n,i){return n===i},"number, number":function(n,i){return Yr(n,i,t.epsilon)},"BigNumber, BigNumber":function(n,i){return n.eq(i)||xt(n,i,t.epsilon)},"Fraction, Fraction":function(n,i){return n.equals(i)},"Complex, Complex":function(n,i){return ky(n,i,t.epsilon)},"Unit, Unit":function(n,i){if(!n.equalBase(i))throw new Error("Cannot compare units with different base");return this(n.value,i.value)}})});q(mi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(mi,{"number, number":function(n,i){return Yr(n,i,t.epsilon)}})});var Hy="SparseMatrix",Zy=["typed","equalScalar","Matrix"],Jy=q(Hy,Zy,r=>{var{typed:e,equalScalar:t,Matrix:a}=r;function n(h,b){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!Zr(b))throw new Error("Invalid datatype: "+b);if(Fe(h))i(this,h,b);else if(h&&ar(h.index)&&ar(h.ptr)&&ar(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(ar(h))c(this,h,b);else{if(h)throw new TypeError("Unsupported type of data ("+cr(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?Re(b._values):void 0,h._index=Re(b._index),h._ptr=Re(b._ptr),h._size=Re(b._size),h._datatype=w||b._datatype):c(h,b.valueOf(),w||b._datatype)}function c(h,b,w){h._values=[],h._index=[],h._ptr=[],h._datatype=w;var N=b.length,d=0,y=t,x=0;if(Zr(w)&&(y=e.find(t,[w,w])||t,x=e.convert(0,w)),N>0){var g=0;do{h._ptr.push(h._index.length);for(var S=0;S<N;S++){var A=b[S];if(ar(A)){if(g===0&&d<A.length&&(d=A.length),g<A.length){var E=A[g];y(E,x)||(h._values.push(E),h._index.push(S))}}else g===0&&d<1&&(d=1),y(A,x)||(h._values.push(A),h._index.push(S))}g++}while(g<d)}h._ptr.push(h._index.length),h._size=[N,d]}n.prototype=new a,n.prototype.createSparseMatrix=function(h,b){return new n(h,b)},n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return ha(this._values,cr)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(h,b){return new n(h,b)},n.prototype.density=function(){var h=this._size[0],b=this._size[1];return h!==0&&b!==0?this._index.length/(h*b):0},n.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(!fa(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 He(N.length,h._size.length);var d,y,x,g,S=b.min(),A=b.max();for(d=0,y=h._size.length;d<y;d++)or(S[d],h._size[d]),or(A[d],h._size[d]);var E=h._values,M=h._index,B=h._ptr,C=b.dimension(0),_=b.dimension(1),P=[],I=[];C.forEach(function($,H){I[$]=H[0],P[$]=!0});var T=E?[]:void 0,D=[],Z=[];return _.forEach(function($){for(Z.push(D.length),x=B[$],g=B[$+1];x<g;x++)d=M[x],P[d]===!0&&(D.push(I[d]),T&&T.push(E[x]))}),Z.push(D.length),new n({values:T,index:D,ptr:Z,size:N,datatype:h._datatype})}function f(h,b,w,N){if(!b||b.isIndex!==!0)throw new TypeError("Invalid index");var d=b.size(),y=b.isScalar(),x;if(Fe(w)?(x=w.size(),w=w.toArray()):x=Je(w),y){if(x.length!==0)throw new TypeError("Scalar expected");h.set(b.min(),w,N)}else{if(d.length!==1&&d.length!==2)throw new He(d.length,h._size.length,"<");if(x.length<d.length){for(var g=0,S=0;d[g]===1&&x[g]===1;)g++;for(;d[g]===1;)S++,g++;w=cu(w,d.length,S,x)}if(!va(d,x))throw new He(d,x,">");if(d.length===1){var A=b.dimension(0);A.forEach(function(B,C){or(B),h.set([B,0],w[C[0]],N)})}else{var E=b.dimension(0),M=b.dimension(1);E.forEach(function(B,C){or(B),M.forEach(function(_,P){or(_),h.set([B,_],w[C[0]][P[0]],N)})})}}return h}n.prototype.get=function(h){if(!ar(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new He(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];or(b,this._size[0]),or(w,this._size[1]);var N=l(b,this._ptr[w],this._ptr[w+1],this._index);return N<this._ptr[w+1]&&this._index[N]===b?this._values[N]:0},n.prototype.set=function(h,b,w){if(!ar(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new He(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=h[0],d=h[1],y=this._size[0],x=this._size[1],g=t,S=0;Zr(this._datatype)&&(g=e.find(t,[this._datatype,this._datatype])||t,S=e.convert(0,this._datatype)),(N>y-1||d>x-1)&&(u(this,Math.max(N+1,y),Math.max(d+1,x),w),y=this._size[0],x=this._size[1]),or(N,y),or(d,x);var A=l(N,this._ptr[d],this._ptr[d+1],this._index);return A<this._ptr[d+1]&&this._index[A]===N?g(b,S)?s(A,d,this._values,this._index,this._ptr):this._values[A]=b:o(A,N,d,b,this._values,this._index,this._ptr),this};function l(h,b,w,N){if(w-b===0)return w;for(var d=b;d<w;d++)if(N[d]===h)return d;return b}function s(h,b,w,N,d){w.splice(h,1),N.splice(h,1);for(var y=b+1;y<d.length;y++)d[y]--}function o(h,b,w,N,d,y,x){d.splice(h,0,N),y.splice(h,0,b);for(var g=w+1;g<x.length;g++)x[g]++}n.prototype.resize=function(h,b,w){if(!Cn(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(!Ye(y)||!Be(y)||y<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ge(N)+")")});var d=w?this.clone():this;return u(d,N[0],N[1],b)};function u(h,b,w,N){var d=N||0,y=t,x=0;Zr(h._datatype)&&(y=e.find(t,[h._datatype,h._datatype])||t,x=e.convert(0,h._datatype),d=e.convert(d,h._datatype));var g=!y(d,x),S=h._size[0],A=h._size[1],E,M,B;if(w>A){for(M=A;M<w;M++)if(h._ptr[M]=h._values.length,g)for(E=0;E<S;E++)h._values.push(d),h._index.push(E);h._ptr[w]=h._values.length}else w<A&&(h._ptr.splice(w+1,A-w),h._values.splice(h._ptr[w],h._values.length),h._index.splice(h._ptr[w],h._index.length));if(A=w,b>S){if(g){var C=0;for(M=0;M<A;M++){h._ptr[M]=h._ptr[M]+C,B=h._ptr[M+1]+C;var _=0;for(E=S;E<b;E++,_++)h._values.splice(B+_,0,d),h._index.splice(B+_,0,E),C++}h._ptr[A]=h._values.length}}else if(b<S){var P=0;for(M=0;M<A;M++){h._ptr[M]=h._ptr[M]-P;var I=h._ptr[M],T=h._ptr[M+1]-P;for(B=I;B<T;B++)E=h._index[B],E>b-1&&(h._values.splice(B,1),h._index.splice(B,1),P++)}h._ptr[M]=h._values.length}return h._size[0]=b,h._size[1]=w,h}n.prototype.reshape=function(h,b){if(!ar(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($){if(!Ye($)||!Be($)||$<=-2||$===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ge(h)+")")});var w=this._size[0]*this._size[1];h=ro(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 d=b?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return d;for(var y=[],x=0;x<d._ptr.length;x++)for(var g=0;g<d._ptr[x+1]-d._ptr[x];g++)y.push(x);for(var S=d._values.slice(),A=d._index.slice(),E=0;E<d._index.length;E++){var M=A[E],B=y[E],C=M*d._size[1]+B;y[E]=C%h[1],A[E]=Math.floor(C/h[1])}d._values.length=0,d._index.length=0,d._ptr.length=h[1]+1,d._size=h.slice();for(var _=0;_<d._ptr.length;_++)d._ptr[_]=0;for(var P=0;P<S.length;P++){var I=A[P],T=y[P],D=S[P],Z=l(I,d._ptr[T],d._ptr[T+1],d._index);o(Z,I,T,D,d._values,d._index,d._ptr)}return d},n.prototype.clone=function(){var h=new n({values:this._values?Re(this._values):void 0,index:Re(this._index),ptr:Re(this._ptr),size:Re(this._size),datatype:this._datatype});return h},n.prototype.size=function(){return this._size.slice(0)},n.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],d=this._size[1],y=function(g,S,A){return h(g,[S,A],w)};return p(this,0,N-1,0,d-1,y,b)};function p(h,b,w,N,d,y,x){var g=[],S=[],A=[],E=t,M=0;Zr(h._datatype)&&(E=e.find(t,[h._datatype,h._datatype])||t,M=e.convert(0,h._datatype));for(var B=function(J,re,oe){J=y(J,re,oe),E(J,M)||(g.push(J),S.push(re))},C=N;C<=d;C++){A.push(g.length);var _=h._ptr[C],P=h._ptr[C+1];if(x)for(var I=_;I<P;I++){var T=h._index[I];T>=b&&T<=w&&B(h._values[I],T-b,C-N)}else{for(var D={},Z=_;Z<P;Z++){var $=h._index[Z];D[$]=h._values[Z]}for(var H=b;H<=w;H++){var Q=H in D?D[H]:0;B(Q,H-b,C-N)}}}return A.push(g.length),new n({values:g,index:S,ptr:A,size:[w-b+1,d-N+1]})}n.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],d=this._size[1],y=0;y<d;y++){var x=this._ptr[y],g=this._ptr[y+1];if(b)for(var S=x;S<g;S++){var A=this._index[S];h(this._values[S],[A,y],w)}else{for(var E={},M=x;M<g;M++){var B=this._index[M];E[B]=this._values[M]}for(var C=0;C<N;C++){var _=C in E?E[C]:0;h(_,[C,y],w)}}}},n.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],d=w;d<N;d++){var y=this._index[d];yield{value:this._values[d],index:[y,b]}}},n.prototype.toArray=function(){return v(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return v(this._values,this._index,this._ptr,this._size,!1)};function v(h,b,w,N,d){var y=N[0],x=N[1],g=[],S,A;for(S=0;S<y;S++)for(g[S]=[],A=0;A<x;A++)g[S][A]=0;for(A=0;A<x;A++)for(var E=w[A],M=w[A+1],B=E;B<M;B++)S=b[B],g[S][A]=h?d?Re(h[B]):h[B]:1;return g}return n.prototype.format=function(h){for(var b=this._size[0],w=this._size[1],N=this.density(),d="Sparse Matrix ["+Ge(b,h)+" x "+Ge(w,h)+"] density: "+Ge(N,h)+`
27
+ `,y=0;y<w;y++)for(var x=this._ptr[y],g=this._ptr[y+1],S=x;S<g;S++){var A=this._index[S];d+=`
28
+ (`+Ge(A,h)+", "+Ge(y,h)+") ==> "+(this._values?Ge(this._values[S],h):"X")}return d},n.prototype.toString=function(){return Ge(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(h){if(h){if(We(h)&&(h=h.toNumber()),!Ye(h)||!Be(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],d=this._size[1],y=Math.min(N-w,d-b),x=[],g=[],S=[];S[0]=0;for(var A=b;A<d&&x.length<y;A++)for(var E=this._ptr[A],M=this._ptr[A+1],B=E;B<M;B++){var C=this._index[B];if(C===A-b+w){x.push(this._values[B]),g[x.length-1]=C-w;break}}return S.push(x.length),new n({values:x,index:g,ptr:S,size:[y,1]})},n.fromJSON=function(h){return new n(h)},n.diagonal=function(h,b,w,N,d){if(!ar(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($){if(We($)&&($=$.toNumber()),!Ye($)||!Be($)||$<1)throw new Error("Size values must be positive integers");return $}),w){if(We(w)&&(w=w.toNumber()),!Ye(w)||!Be(w))throw new TypeError("The parameter k must be an integer number")}else w=0;var y=t,x=0;Zr(d)&&(y=e.find(t,[d,d])||t,x=e.convert(0,d));var g=w>0?w:0,S=w<0?-w:0,A=h[0],E=h[1],M=Math.min(A-S,E-g),B;if(ar(b)){if(b.length!==M)throw new Error("Invalid value array length");B=function(H){return b[H]}}else if(Fe(b)){var C=b.size();if(C.length!==1||C[0]!==M)throw new Error("Invalid matrix length");B=function(H){return b.get([H])}}else B=function(){return b};for(var _=[],P=[],I=[],T=0;T<E;T++){I.push(_.length);var D=T-g;if(D>=0&&D<M){var Z=B(D);y(Z,x)||(P.push(D+S),_.push(Z))}}return I.push(_.length),new n({values:_,index:P,ptr:I,size:[A,E]})},n.prototype.swapRows=function(h,b){if(!Ye(h)||!Be(h)||!Ye(b)||!Be(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 or(h,this._size[0]),or(b,this._size[0]),n._swapRows(h,b,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(h,b,w,N,d){for(var y=N[h],x=N[h+1],g=y;g<x;g++)d(w[g],b[g])},n._swapRows=function(h,b,w,N,d,y){for(var x=0;x<w;x++){var g=y[x],S=y[x+1],A=l(h,g,S,d),E=l(b,g,S,d);if(A<S&&E<S&&d[A]===h&&d[E]===b){if(N){var M=N[A];N[A]=N[E],N[E]=M}continue}if(A<S&&d[A]===h&&(E>=S||d[E]!==b)){var B=N?N[A]:void 0;d.splice(E,0,b),N&&N.splice(E,0,B),d.splice(E<=A?A+1:A,1),N&&N.splice(E<=A?A+1:A,1);continue}if(E<S&&d[E]===b&&(A>=S||d[A]!==h)){var C=N?N[E]:void 0;d.splice(A,0,h),N&&N.splice(A,0,C),d.splice(A<=E?E+1:E,1),N&&N.splice(A<=E?E+1:E,1)}}},n},{isClass:!0}),Wy="number",Xy=["typed"];function Yy(r){var e=r.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],a=e[2],n=e[3];return{input:r,radix:t,integerPart:a,fractionalPart:n}}else return null}function Qy(r){for(var e=parseInt(r.integerPart,r.radix),t=0,a=0;a<r.fractionalPart.length;a++){var n=parseInt(r.fractionalPart[a],r.radix);t+=n/Math.pow(r.radix,a+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+r.input+'" is no valid number');return i}var jy=q(Wy,Xy,r=>{var{typed:e}=r,t=e("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Yy(n);if(i)return Qy(i);var c=0,m=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);m&&(c=Number(m[2]),n=m[1]);var f=Number(n);if(isNaN(f))throw new SyntaxError('String "'+n+'" is no valid number');if(m){if(f>2**c-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));f>=2**(c-1)&&(f=f-2**c)}return f},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:function(n){throw new Error("Second argument with valueless unit expected")},null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":function(n){return $e(n,this)}});return t.fromJSON=function(a){return parseFloat(a.value)},t}),kc="string",Ky=["typed"],e0=q(kc,Ky,r=>{var{typed:e}=r;return e(kc,{"":function(){return""},number:fn,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":function(a){return $e(a,this)},any:function(a){return String(a)}})}),Vc="boolean",r0=["typed"],t0=q(Vc,r0,r=>{var{typed:e}=r;return e(Vc,{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()},string:function(a){var n=a.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;var i=Number(a);if(a!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+a+'" to a boolean')},"Array | Matrix":function(a){return $e(a,this)}})}),n0="bignumber",a0=["typed","BigNumber"],i0=q(n0,a0,r=>{var{typed:e,BigNumber:t}=r;return e("bignumber",{"":function(){return new t(0)},number:function(n){return new t(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var c=i[2],m=t(i[1]),f=new t(2).pow(Number(c));if(m.gt(f.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var l=new t(2).pow(Number(c)-1);return m.gte(l)?m.sub(f):m}return new t(n)},BigNumber:function(n){return n},Fraction:function(n){return new t(n.n).div(n.d).times(n.s)},null:function(n){return new t(0)},"Array | Matrix":function(n){return $e(n,this)}})}),o0="complex",s0=["typed","Complex"],u0=q(o0,s0,r=>{var{typed:e,Complex:t}=r;return e("complex",{"":function(){return t.ZERO},number:function(n){return new t(n,0)},"number, number":function(n,i){return new t(n,i)},"BigNumber, BigNumber":function(n,i){return new t(n.toNumber(),i.toNumber())},Fraction:function(n){return new t(n.valueOf(),0)},Complex:function(n){return n.clone()},string:function(n){return t(n)},null:function(n){return t(0)},Object:function(n){if("re"in n&&"im"in n)return new t(n.re,n.im);if("r"in n&&"phi"in n||"abs"in n&&"arg"in n)return new t(n);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(n){return $e(n,this)}})}),c0="fraction",l0=["typed","Fraction"],f0=q(c0,l0,r=>{var{typed:e,Fraction:t}=r;return e("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new t(n)},string:function(n){return new t(n)},"number, number":function(n,i){return new t(n,i)},null:function(n){return new t(0)},BigNumber:function(n){return new t(n.toString())},Fraction:function(n){return n},Object:function(n){return new t(n)},"Array | Matrix":function(n){return $e(n,this)}})}),Gc="matrix",m0=["typed","Matrix","DenseMatrix","SparseMatrix"],p0=q(Gc,m0,r=>{var{typed:e,Matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(Gc,{"":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(c,m,f){if(m==="dense"||m==="default"||m===void 0)return new a(c,f);if(m==="sparse")return new n(c,f);throw new TypeError("Unknown matrix type "+JSON.stringify(m)+".")}}),Hc="matrixFromFunction",v0=["typed","matrix","isZero"],h0=q(Hc,v0,r=>{var{typed:e,matrix:t,isZero:a}=r;return e(Hc,{"Array | Matrix, function, string, string":function(c,m,f,l){return n(c,m,f,l)},"Array | Matrix, function, string":function(c,m,f){return n(c,m,f)},"Matrix, function":function(c,m){return n(c,m,"dense")},"Array, function":function(c,m){return n(c,m,"dense").toArray()},"Array | Matrix, string, function":function(c,m,f){return n(c,f,m)},"Array | Matrix, string, string, function":function(c,m,f,l){return n(c,l,m,f)}});function n(i,c,m,f){var l;return f!==void 0?l=t(m,f):l=t(m),l.resize(i),l.forEach(function(s,o){var u=c(o);a(u)||l.set(o,u)}),l}}),Zc="matrixFromRows",d0=["typed","matrix","flatten","size"],g0=q(Zc,d0,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(Zc,{"...Array":function(f){return i(f)},"...Matrix":function(f){return t(i(f.map(l=>l.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var f=c(m[0]),l=[];for(var s of m){var o=c(s);if(o!==f)throw new TypeError("The vectors had different length: "+(f|0)+" \u2260 "+(o|0));l.push(a(s))}return l}function c(m){var f=n(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.")}}),Jc="matrixFromColumns",y0=["typed","matrix","flatten","size"],b0=q(Jc,y0,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(Jc,{"...Array":function(f){return i(f)},"...Matrix":function(f){return t(i(f.map(l=>l.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var f=c(m[0]),l=[],s=0;s<f;s++)l[s]=[];for(var o of m){var u=c(o);if(u!==f)throw new TypeError("The vectors had different length: "+(f|0)+" \u2260 "+(u|0));for(var p=a(o),v=0;v<f;v++)l[v].push(p[v])}return l}function c(m){var f=n(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.")}}),Wc="splitUnit",x0=["typed"],w0=q(Wc,x0,r=>{var{typed:e}=r;return e(Wc,{"Unit, Array":function(a,n){return a.splitUnit(n)}})}),Xc="unaryMinus",N0=["typed"],M0=q(Xc,N0,r=>{var{typed:e}=r;return e(Xc,{number:Pu,Complex:function(a){return a.neg()},BigNumber:function(a){return a.neg()},Fraction:function(a){return a.neg()},Unit:function(a){var n=a.clone();return n.value=this(a.value),n},"Array | Matrix":function(a){return $e(a,this)}})}),Yc="unaryPlus",A0=["typed","config","BigNumber"],S0=q(Yc,A0,r=>{var{typed:e,config:t,BigNumber:a}=r;return e(Yc,{number:Uu,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 $e(i,this)},"boolean | string":function(i){return t.number==="BigNumber"?new a(+i):+i}})}),Qc="abs",E0=["typed"],C0=q(Qc,E0,r=>{var{typed:e}=r;return e(Qc,{number:Fu,Complex:function(a){return a.abs()},BigNumber:function(a){return a.abs()},Fraction:function(a){return a.abs()},"Array | Matrix":function(a){return $e(a,this)},Unit:function(a){return a.abs()}})}),jc="apply",O0=["typed","isInteger"],Kc=q(jc,O0,r=>{var{typed:e,isInteger:t}=r;return e(jc,{"Array | Matrix, number | BigNumber, function":function(n,i,c){if(!t(i))throw new TypeError("Integer number expected for dimension");var m=Array.isArray(n)?Je(n):n.size();if(i<0||i>=m.length)throw new ct(i,m.length);return Fe(n)?n.create(pi(n.valueOf(),i,c)):pi(n,i,c)}})});function pi(r,e,t){var a,n,i;if(e<=0)if(Array.isArray(r[0])){for(i=$0(r),n=[],a=0;a<i.length;a++)n[a]=pi(i[a],e-1,t);return n}else return t(r);else{for(n=[],a=0;a<r.length;a++)n[a]=pi(r[a],e-1,t);return n}}function $0(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var c=[];for(a=0;a<e;a++)c.push(r[a][n]);i.push(c)}return i}var el="addScalar",T0=["typed"],D0=q(el,T0,r=>{var{typed:e}=r;return e(el,{"number, number":qu,"Complex, Complex":function(a,n){return a.add(n)},"BigNumber, BigNumber":function(a,n){return a.plus(n)},"Fraction, Fraction":function(a,n){return a.add(n)},"Unit, Unit":function(a,n){if(a.value===null||a.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!a.equalBase(n))throw new Error("Units do not match");var i=a.clone();return i.value=this(i.value,n.value),i.fixPrefix=!1,i}})}),rl="cbrt",B0=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],_0=q(rl,B0,r=>{var{config:e,typed:t,isNegative:a,unaryMinus:n,matrix:i,Complex:c,BigNumber:m,Fraction:f}=r;return t(rl,{number:ga,Complex:l,"Complex, boolean":l,BigNumber:function(u){return u.cbrt()},Unit:s,"Array | Matrix":function(u){return $e(u,this)}});function l(o,u){var p=o.arg()/3,v=o.abs(),h=new c(ga(v),0).mul(new c(0,p).exp());if(u){var b=[h,new c(ga(v),0).mul(new c(0,p+Math.PI*2/3).exp()),new c(ga(v),0).mul(new c(0,p-Math.PI*2/3).exp())];return e.matrix==="Array"?b:i(b)}else return h}function s(o){if(o.value&&Dt(o.value)){var u=o.clone();return u.value=1,u=u.pow(1/3),u.value=l(o.value),u}else{var p=a(o.value);p&&(o.value=n(o.value));var v;We(o.value)?v=new m(1).div(3):En(o.value)?v=new f(1,3):v=1/3;var h=o.pow(v);return p&&(h.value=n(h.value)),h}}}),I0="algorithm11",R0=["typed","equalScalar"],_r=q(I0,R0,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,c,m){var f=n._values,l=n._index,s=n._ptr,o=n._size,u=n._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=t,w=0,N=c;typeof u=="string"&&(h=u,b=e.find(t,[h,h]),w=e.convert(0,h),i=e.convert(i,h),N=e.find(c,[h,h]));for(var d=[],y=[],x=[],g=0;g<v;g++){x[g]=y.length;for(var S=s[g],A=s[g+1],E=S;E<A;E++){var M=l[E],B=m?N(i,f[E]):N(f[E],i);b(B,w)||(y.push(M),d.push(B))}}return x[v]=y.length,n.createSparseMatrix({values:d,index:y,ptr:x,size:[p,v],datatype:h})}}),F0="algorithm12",q0=["typed","DenseMatrix"],$r=q(F0,q0,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,c,m){var f=n._values,l=n._index,s=n._ptr,o=n._size,u=n._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=c;typeof u=="string"&&(h=u,i=e.convert(i,h),b=e.find(c,[h,h]));for(var w=[],N=[],d=[],y=0;y<v;y++){for(var x=y+1,g=s[y],S=s[y+1],A=g;A<S;A++){var E=l[A];N[E]=f[A],d[E]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),d[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 t({data:w,size:[p,v],datatype:h})}}),z0="algorithm14",P0=["typed"],rr=q(z0,P0,r=>{var{typed:e}=r;return function(n,i,c,m){var f=n._data,l=n._size,s=n._datatype,o,u=c;typeof s=="string"&&(o=s,i=e.convert(i,o),u=e.find(c,[o,o]));var p=l.length>0?t(u,0,l,l[0],f,i,m):[];return n.createDenseMatrix({data:p,size:Re(l),datatype:o})};function t(a,n,i,c,m,f,l){var s=[];if(n===i.length-1)for(var o=0;o<c;o++)s[o]=l?a(f,m[o]):a(m[o],f);else for(var u=0;u<c;u++)s[u]=t(a,n+1,i,i[n+1],m[u],f,l);return s}}),yo="ceil",U0=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],L0=q(yo,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(yo,{number:function(i){return Yr(i,a(i),t.epsilon)?a(i):Math.ceil(i)},"number, number":function(i,c){if(Yr(i,a(i,c),t.epsilon))return a(i,c);var[m,f]="".concat(i,"e").split("e"),l=Math.ceil(Number("".concat(m,"e").concat(Number(f)+c)));return[m,f]="".concat(l,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-c))}})}),k0=q(yo,U0,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:c,DenseMatrix:m}=r,f=_r({typed:e,equalScalar:i}),l=$r({typed:e,DenseMatrix:m}),s=rr({typed:e}),o=L0({typed:e,config:t,round:a});return e("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 xt(p,a(p),t.epsilon)?a(p):p.ceil()},"BigNumber, BigNumber":function(p,v){return xt(p,a(p,v),t.epsilon)?a(p,v):p.toDecimalPlaces(v.toNumber(),Qt.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 $e(p,this)},"Array, number | BigNumber":function(p,v){return $e(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(n(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?c(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):l(v,p,this,!0)}})}),tl="cube",V0=["typed"],G0=q(tl,V0,r=>{var{typed:e}=r;return e(tl,{number:Lu,Complex:function(a){return a.mul(a).mul(a)},BigNumber:function(a){return a.times(a).times(a)},Fraction:function(a){return a.pow(3)},"Array | Matrix":function(a){return $e(a,this)},Unit:function(a){return a.pow(3)}})}),nl="exp",H0=["typed"],Z0=q(nl,H0,r=>{var{typed:e}=r;return e(nl,{number:ku,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()},"Array | Matrix":function(a){return $e(a,this)}})}),al="expm1",J0=["typed","Complex"],W0=q(al,J0,r=>{var{typed:e,Complex:t}=r;return e(al,{number:Vu,Complex:function(n){var i=Math.exp(n.re);return new t(i*Math.cos(n.im)-1,i*Math.sin(n.im))},BigNumber:function(n){return n.exp().minus(1)},"Array | Matrix":function(n){return $e(n,this)}})}),bo="fix",X0=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Y0=q(bo,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:a}=r;return e(bo,{number:function(i){return i>0?a(i):t(i)},"number, number":function(i,c){return i>0?a(i,c):t(i,c)}})}),Q0=q(bo,X0,r=>{var{typed:e,Complex:t,matrix:a,ceil:n,floor:i,equalScalar:c,zeros:m,DenseMatrix:f}=r,l=$r({typed:e,DenseMatrix:f}),s=rr({typed:e}),o=Y0({typed:e,ceil:n,floor:i});return e("fix",{number:o.signatures.number,"number, number | BigNumber":o.signatures["number,number"],Complex:function(p){return new t(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 t(p.re>0?i(p.re,v):n(p.re,v),p.im>0?i(p.im,v):n(p.im,v))},"Complex, BigNumber":function(p,v){var h=v.toNumber();return new t(p.re>0?i(p.re,h):n(p.re,h),p.im>0?i(p.im,h):n(p.im,h))},BigNumber:function(p){return p.isNegative()?n(p):i(p)},"BigNumber, number | BigNumber":function(p,v){return p.isNegative()?n(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?n(p,v):i(p,v)},"Array | Matrix":function(p){return $e(p,this)},"Array | Matrix, number | BigNumber":function(p,v){return $e(p,h=>this(h,v))},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(a(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return c(p,0)?m(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):l(v,p,this,!0)}})}),xo="floor",j0=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],K0=q(xo,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(xo,{number:function(i){return Yr(i,a(i),t.epsilon)?a(i):Math.floor(i)},"number, number":function(i,c){if(Yr(i,a(i,c),t.epsilon))return a(i,c);var[m,f]="".concat(i,"e").split("e"),l=Math.floor(Number("".concat(m,"e").concat(Number(f)+c)));return[m,f]="".concat(l,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-c))}})}),e1=q(xo,j0,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:c,DenseMatrix:m}=r,f=_r({typed:e,equalScalar:i}),l=$r({typed:e,DenseMatrix:m}),s=rr({typed:e}),o=K0({typed:e,config:t,round:a});return e("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 xt(p,a(p),t.epsilon)?a(p):p.floor()},"BigNumber, BigNumber":function(p,v){return xt(p,a(p,v),t.epsilon)?a(p,v):p.toDecimalPlaces(v.toNumber(),Qt.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 $e(p,this)},"Array, number | BigNumber":function(p,v){return $e(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(n(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?c(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):l(v,p,this,!0)}})}),r1="algorithm01",t1=["typed"],jt=q(r1,t1,r=>{var{typed:e}=r;return function(a,n,i,c){var m=a._data,f=a._size,l=a._datatype,s=n._values,o=n._index,u=n._ptr,p=n._size,v=n._datatype;if(f.length!==p.length)throw new He(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 l=="string"&&l===v?l:void 0,N=w?e.find(i,[w,w]):i,d,y,x=[];for(d=0;d<h;d++)x[d]=[];var g=[],S=[];for(y=0;y<b;y++){for(var A=y+1,E=u[y],M=u[y+1],B=E;B<M;B++)d=o[B],g[d]=c?N(s[B],m[d][y]):N(m[d][y],s[B]),S[d]=A;for(d=0;d<h;d++)S[d]===A?x[d][y]=g[d]:x[d][y]=m[d][y]}return a.createDenseMatrix({data:x,size:[h,b],datatype:w})}}),n1="algorithm04",a1=["typed","equalScalar"],wo=q(n1,a1,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,c){var m=n._values,f=n._index,l=n._ptr,s=n._size,o=n._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new He(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],d,y=t,x=0,g=c;typeof o=="string"&&o===b&&(d=o,y=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(c,[d,d]));var S=m&&u?[]:void 0,A=[],E=[],M=m&&u?[]:void 0,B=m&&u?[]:void 0,C=[],_=[],P,I,T,D,Z;for(I=0;I<N;I++){E[I]=A.length;var $=I+1;for(D=l[I],Z=l[I+1],T=D;T<Z;T++)P=f[T],A.push(P),C[P]=$,M&&(M[P]=m[T]);for(D=v[I],Z=v[I+1],T=D;T<Z;T++)if(P=p[T],C[P]===$){if(M){var H=g(M[P],u[T]);y(H,x)?C[P]=null:M[P]=H}}else A.push(P),_[P]=$,B&&(B[P]=u[T]);if(M&&B)for(T=E[I];T<A.length;)P=A[T],C[P]===$?(S[T]=M[P],T++):_[P]===$?(S[T]=B[P],T++):A.splice(T,1)}return E[N]=A.length,n.createSparseMatrix({values:S,index:A,ptr:E,size:[w,N],datatype:d})}}),i1="algorithm10",o1=["typed","DenseMatrix"],pn=q(i1,o1,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,c,m){var f=n._values,l=n._index,s=n._ptr,o=n._size,u=n._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=c;typeof u=="string"&&(h=u,i=e.convert(i,h),b=e.find(c,[h,h]));for(var w=[],N=[],d=[],y=0;y<v;y++){for(var x=y+1,g=s[y],S=s[y+1],A=g;A<S;A++){var E=l[A];N[E]=f[A],d[E]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),d[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=i}return new t({data:w,size:[p,v],datatype:h})}}),s1="algorithm13",u1=["typed"],lr=q(s1,u1,r=>{var{typed:e}=r;return function(n,i,c){var m=n._data,f=n._size,l=n._datatype,s=i._data,o=i._size,u=i._datatype,p=[];if(f.length!==o.length)throw new He(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=c;typeof l=="string"&&l===u&&(h=l,b=e.find(c,[h,h]));var w=p.length>0?t(b,0,p,p[0],m,s):[];return n.createDenseMatrix({data:w,size:p,datatype:h})};function t(a,n,i,c,m,f){var l=[];if(n===i.length-1)for(var s=0;s<c;s++)l[s]=a(m[s],f[s]);else for(var o=0;o<c;o++)l[o]=t(a,n+1,i,i[n+1],m[o],f[o]);return l}}),il="gcd",c1=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],l1=q(il,c1,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i}=r,c=jt({typed:e}),m=wo({typed:e,equalScalar:a}),f=pn({typed:e,DenseMatrix:i}),l=lr({typed:e}),s=rr({typed:e});return e(il,{"number, number":Gu,"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 c(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return c(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return l(p,v,this)},"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, 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(t(p),v,this,!1).valueOf()},"number | BigNumber, Array":function(p,v){return s(t(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 n(0);!p.isZero();){var h=u.mod(p);u=p,p=h}return u.lt(v)?u.neg():u}}),f1="algorithm02",m1=["typed","equalScalar"],pt=q(f1,m1,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,c,m){var f=n._data,l=n._size,s=n._datatype,o=i._values,u=i._index,p=i._ptr,v=i._size,h=i._datatype;if(l.length!==v.length)throw new He(l.length,v.length);if(l[0]!==v[0]||l[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+v+")");if(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var b=l[0],w=l[1],N,d=t,y=0,x=c;typeof s=="string"&&s===h&&(N=s,d=e.find(t,[N,N]),y=e.convert(0,N),x=e.find(c,[N,N]));for(var g=[],S=[],A=[],E=0;E<w;E++){A[E]=S.length;for(var M=p[E],B=p[E+1],C=M;C<B;C++){var _=u[C],P=m?x(o[C],f[_][E]):x(f[_][E],o[C]);d(P,y)||(S.push(_),g.push(P))}}return A[w]=S.length,i.createSparseMatrix({values:g,index:S,ptr:A,size:[b,w],datatype:N})}}),p1="algorithm06",v1=["typed","equalScalar"],vi=q(p1,v1,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,c){var m=n._values,f=n._size,l=n._datatype,s=i._values,o=i._size,u=i._datatype;if(f.length!==o.length)throw new He(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=t,w=0,N=c;typeof l=="string"&&l===u&&(h=l,b=e.find(t,[h,h]),w=e.convert(0,h),N=e.find(c,[h,h]));for(var d=m&&s?[]:void 0,y=[],x=[],g=d?[]:void 0,S=[],A=[],E=0;E<v;E++){x[E]=y.length;var M=E+1;if(Iu(n,E,S,g,A,M,y,N),Iu(i,E,S,g,A,M,y,N),g)for(var B=x[E];B<y.length;){var C=y[B];if(A[C]===M){var _=g[C];b(_,w)?y.splice(B,1):(d.push(_),B++)}else y.splice(B,1)}else for(var P=x[E];P<y.length;){var I=y[P];A[I]!==M?y.splice(P,1):P++}}return x[v]=y.length,n.createSparseMatrix({values:d,index:y,ptr:x,size:[p,v],datatype:h})}}),ol="lcm",h1=["typed","matrix","equalScalar"],d1=q(ol,h1,r=>{var{typed:e,matrix:t,equalScalar:a}=r,n=pt({typed:e,equalScalar:a}),i=vi({typed:e,equalScalar:a}),c=_r({typed:e,equalScalar:a}),m=lr({typed:e}),f=rr({typed:e});return e(ol,{"number, number":Hu,"BigNumber, BigNumber":l,"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 n(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return n(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return m(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, number | BigNumber":function(o,u){return c(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return f(o,u,this,!1)},"number | BigNumber, SparseMatrix":function(o,u){return c(u,o,this,!0)},"number | BigNumber, DenseMatrix":function(o,u){return f(u,o,this,!0)},"Array, number | BigNumber":function(o,u){return f(t(o),u,this,!1).valueOf()},"number | BigNumber, Array":function(o,u){return f(t(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 l(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()}}),sl="log10",g1=["typed","config","Complex"],y1=q(sl,g1,r=>{var{typed:e,config:t,Complex:a}=r;return e(sl,{number:function(i){return i>=0||t.predictable?Zu(i):new a(i,0).log().div(Math.LN10)},Complex:function(i){return new a(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||t.predictable?i.log():new a(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(i){return $e(i,this)}})}),ul="log2",b1=["typed","config","Complex"],x1=q(ul,b1,r=>{var{typed:e,config:t,Complex:a}=r;return e(ul,{number:function(c){return c>=0||t.predictable?Ju(c):n(new a(c,0))},Complex:n,BigNumber:function(c){return!c.isNegative()||t.predictable?c.log(2):n(new a(c.toNumber(),0))},"Array | Matrix":function(c){return $e(c,this)}});function n(i){var c=Math.sqrt(i.re*i.re+i.im*i.im);return new a(Math.log2?Math.log2(c):Math.log(c)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),w1="algorithm03",N1=["typed"],Lr=q(w1,N1,r=>{var{typed:e}=r;return function(a,n,i,c){var m=a._data,f=a._size,l=a._datatype,s=n._values,o=n._index,u=n._ptr,p=n._size,v=n._datatype;if(f.length!==p.length)throw new He(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,d=i;typeof l=="string"&&l===v&&(w=l,N=e.convert(0,w),d=e.find(i,[w,w]));for(var y=[],x=0;x<h;x++)y[x]=[];for(var g=[],S=[],A=0;A<b;A++){for(var E=A+1,M=u[A],B=u[A+1],C=M;C<B;C++){var _=o[C];g[_]=c?d(s[C],m[_][A]):d(m[_][A],s[C]),S[_]=E}for(var P=0;P<h;P++)S[P]===E?y[P][A]=g[P]:y[P][A]=c?d(N,m[P][A]):d(m[P][A],N)}return a.createDenseMatrix({data:y,size:[h,b],datatype:w})}}),M1="algorithm05",A1=["typed","equalScalar"],hi=q(M1,A1,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,c){var m=n._values,f=n._index,l=n._ptr,s=n._size,o=n._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new He(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],d,y=t,x=0,g=c;typeof o=="string"&&o===b&&(d=o,y=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(c,[d,d]));var S=m&&u?[]:void 0,A=[],E=[],M=S?[]:void 0,B=S?[]:void 0,C=[],_=[],P,I,T,D;for(I=0;I<N;I++){E[I]=A.length;var Z=I+1;for(T=l[I],D=l[I+1];T<D;T++)P=f[T],A.push(P),C[P]=Z,M&&(M[P]=m[T]);for(T=v[I],D=v[I+1];T<D;T++)P=p[T],C[P]!==Z&&A.push(P),_[P]=Z,B&&(B[P]=u[T]);if(S)for(T=E[I];T<A.length;){P=A[T];var $=C[P],H=_[P];if($===Z||H===Z){var Q=$===Z?M[P]:x,te=H===Z?B[P]:x,J=g(Q,te);y(J,x)?A.splice(T,1):(S.push(J),T++)}}}return E[N]=A.length,n.createSparseMatrix({values:S,index:A,ptr:E,size:[w,N],datatype:d})}}),cl="mod",S1=["typed","matrix","equalScalar","DenseMatrix"],E1=q(cl,S1,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=pt({typed:e,equalScalar:a}),c=Lr({typed:e}),m=hi({typed:e,equalScalar:a}),f=_r({typed:e,equalScalar:a}),l=$r({typed:e,DenseMatrix:n}),s=lr({typed:e}),o=rr({typed:e});return e(cl,{"number, number":Wu,"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 c(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,this)},"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 l(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()}})}),C1="multiplyScalar",O1=["typed"],$1=q(C1,O1,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":zu,"Complex, Complex":function(a,n){return a.mul(n)},"BigNumber, BigNumber":function(a,n){return a.times(n)},"Fraction, Fraction":function(a,n){return a.mul(n)},"number | Fraction | BigNumber | Complex, Unit":function(a,n){var i=n.clone();return i.value=i.value===null?i._normalize(a):this(i.value,a),i},"Unit, number | Fraction | BigNumber | Complex":function(a,n){var i=a.clone();return i.value=i.value===null?i._normalize(n):this(i.value,n),i},"Unit, Unit":function(a,n){return a.multiply(n)}})}),ll="multiply",T1=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],D1=q(ll,T1,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,equalScalar:i,dot:c}=r,m=_r({typed:e,equalScalar:i}),f=rr({typed:e});function l(x,g){switch(x.length){case 1:switch(g.length){case 1:if(x[0]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+g[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+g.length+" dimensions)")}break;case 2:switch(g.length){case 1:if(x[1]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+g[0]+")");break;case 2:if(x[1]!==g[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+g[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+g.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,g,S){if(S===0)throw new Error("Cannot multiply two empty vectors");return c(x,g)}function o(x,g){if(g.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return u(x,g)}function u(x,g){var S=x._data,A=x._size,E=x._datatype,M=g._data,B=g._size,C=g._datatype,_=A[0],P=B[1],I,T=a,D=n;E&&C&&E===C&&typeof E=="string"&&(I=E,T=e.find(a,[I,I]),D=e.find(n,[I,I]));for(var Z=[],$=0;$<P;$++){for(var H=D(S[0],M[0][$]),Q=1;Q<_;Q++)H=T(H,D(S[Q],M[Q][$]));Z[$]=H}return x.createDenseMatrix({data:Z,size:[P],datatype:I})}var p=e("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":N}),v=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":b,"DenseMatrix, SparseMatrix":w,"SparseMatrix, DenseMatrix":d,"SparseMatrix, SparseMatrix":y});function h(x,g){var S=x._data,A=x._size,E=x._datatype,M=g._data,B=g._datatype,C=A[0],_=A[1],P,I=a,T=n;E&&B&&E===B&&typeof E=="string"&&(P=E,I=e.find(a,[P,P]),T=e.find(n,[P,P]));for(var D=[],Z=0;Z<C;Z++){for(var $=S[Z],H=T($[0],M[0]),Q=1;Q<_;Q++)H=I(H,T($[Q],M[Q]));D[Z]=H}return x.createDenseMatrix({data:D,size:[C],datatype:P})}function b(x,g){var S=x._data,A=x._size,E=x._datatype,M=g._data,B=g._size,C=g._datatype,_=A[0],P=A[1],I=B[1],T,D=a,Z=n;E&&C&&E===C&&typeof E=="string"&&(T=E,D=e.find(a,[T,T]),Z=e.find(n,[T,T]));for(var $=[],H=0;H<_;H++){var Q=S[H];$[H]=[];for(var te=0;te<I;te++){for(var J=Z(Q[0],M[0][te]),re=1;re<P;re++)J=D(J,Z(Q[re],M[re][te]));$[H][te]=J}}return x.createDenseMatrix({data:$,size:[_,I],datatype:T})}function w(x,g){var S=x._data,A=x._size,E=x._datatype,M=g._values,B=g._index,C=g._ptr,_=g._size,P=g._datatype;if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var I=A[0],T=_[1],D,Z=a,$=n,H=i,Q=0;E&&P&&E===P&&typeof E=="string"&&(D=E,Z=e.find(a,[D,D]),$=e.find(n,[D,D]),H=e.find(i,[D,D]),Q=e.convert(0,D));for(var te=[],J=[],re=[],oe=g.createSparseMatrix({values:te,index:J,ptr:re,size:[I,T],datatype:D}),ae=0;ae<T;ae++){re[ae]=J.length;var ce=C[ae],se=C[ae+1];if(se>ce)for(var me=0,ne=0;ne<I;ne++){for(var Ae=ne+1,Ce=void 0,ge=ce;ge<se;ge++){var Se=B[ge];me!==Ae?(Ce=$(S[ne][Se],M[ge]),me=Ae):Ce=Z(Ce,$(S[ne][Se],M[ge]))}me===Ae&&!H(Ce,Q)&&(J.push(ne),te.push(Ce))}}return re[T]=J.length,oe}function N(x,g){var S=x._values,A=x._index,E=x._ptr,M=x._datatype;if(!S)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=g._data,C=g._datatype,_=x._size[0],P=g._size[0],I=[],T=[],D=[],Z,$=a,H=n,Q=i,te=0;M&&C&&M===C&&typeof M=="string"&&(Z=M,$=e.find(a,[Z,Z]),H=e.find(n,[Z,Z]),Q=e.find(i,[Z,Z]),te=e.convert(0,Z));var J=[],re=[];D[0]=0;for(var oe=0;oe<P;oe++){var ae=B[oe];if(!Q(ae,te))for(var ce=E[oe],se=E[oe+1],me=ce;me<se;me++){var ne=A[me];re[ne]?J[ne]=$(J[ne],H(ae,S[me])):(re[ne]=!0,T.push(ne),J[ne]=H(ae,S[me]))}}for(var Ae=T.length,Ce=0;Ce<Ae;Ce++){var ge=T[Ce];I[Ce]=J[ge]}return D[1]=T.length,x.createSparseMatrix({values:I,index:T,ptr:D,size:[_,1],datatype:Z})}function d(x,g){var S=x._values,A=x._index,E=x._ptr,M=x._datatype;if(!S)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=g._data,C=g._datatype,_=x._size[0],P=g._size[0],I=g._size[1],T,D=a,Z=n,$=i,H=0;M&&C&&M===C&&typeof M=="string"&&(T=M,D=e.find(a,[T,T]),Z=e.find(n,[T,T]),$=e.find(i,[T,T]),H=e.convert(0,T));for(var Q=[],te=[],J=[],re=x.createSparseMatrix({values:Q,index:te,ptr:J,size:[_,I],datatype:T}),oe=[],ae=[],ce=0;ce<I;ce++){J[ce]=te.length;for(var se=ce+1,me=0;me<P;me++){var ne=B[me][ce];if(!$(ne,H))for(var Ae=E[me],Ce=E[me+1],ge=Ae;ge<Ce;ge++){var Se=A[ge];ae[Se]!==se?(ae[Se]=se,te.push(Se),oe[Se]=Z(ne,S[ge])):oe[Se]=D(oe[Se],Z(ne,S[ge]))}}for(var z=J[ce],Y=te.length,V=z;V<Y;V++){var L=te[V];Q[V]=oe[L]}}return J[I]=te.length,re}function y(x,g){var S=x._values,A=x._index,E=x._ptr,M=x._datatype,B=g._values,C=g._index,_=g._ptr,P=g._datatype,I=x._size[0],T=g._size[1],D=S&&B,Z,$=a,H=n;M&&P&&M===P&&typeof M=="string"&&(Z=M,$=e.find(a,[Z,Z]),H=e.find(n,[Z,Z]));for(var Q=D?[]:void 0,te=[],J=[],re=x.createSparseMatrix({values:Q,index:te,ptr:J,size:[I,T],datatype:Z}),oe=D?[]:void 0,ae=[],ce,se,me,ne,Ae,Ce,ge,Se,z=0;z<T;z++){J[z]=te.length;var Y=z+1;for(Ae=_[z],Ce=_[z+1],ne=Ae;ne<Ce;ne++)if(Se=C[ne],D)for(se=E[Se],me=E[Se+1],ce=se;ce<me;ce++)ge=A[ce],ae[ge]!==Y?(ae[ge]=Y,te.push(ge),oe[ge]=H(B[ne],S[ce])):oe[ge]=$(oe[ge],H(B[ne],S[ce]));else for(se=E[Se],me=E[Se+1],ce=se;ce<me;ce++)ge=A[ce],ae[ge]!==Y&&(ae[ge]=Y,te.push(ge));if(D)for(var V=J[z],L=te.length,j=V;j<L;j++){var F=te[j];Q[j]=oe[F]}}return J[T]=te.length,re}return e(ll,Qi({"Array, Array":function(g,S){l(Je(g),Je(S));var A=this(t(g),t(S));return Fe(A)?A.valueOf():A},"Matrix, Matrix":function(g,S){var A=g.size(),E=S.size();return l(A,E),A.length===1?E.length===1?s(g,S,A[0]):o(g,S):E.length===1?p(g,S):v(g,S)},"Matrix, Array":function(g,S){return this(g,t(S))},"Array, Matrix":function(g,S){return this(t(g,S.storage()),S)},"SparseMatrix, any":function(g,S){return m(g,S,n,!1)},"DenseMatrix, any":function(g,S){return f(g,S,n,!1)},"any, SparseMatrix":function(g,S){return m(S,g,n,!0)},"any, DenseMatrix":function(g,S){return f(S,g,n,!0)},"Array, any":function(g,S){return f(t(g),S,n,!1).valueOf()},"any, Array":function(g,S){return f(t(S),g,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(g,S,A){for(var E=this(g,S),M=0;M<A.length;M++)E=this(E,A[M]);return E}},n.signatures))}),fl="nthRoot",B1=["typed","matrix","equalScalar","BigNumber"],_1=q(fl,B1,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n}=r,i=jt({typed:e}),c=pt({typed:e,equalScalar:a}),m=vi({typed:e,equalScalar:a}),f=_r({typed:e,equalScalar:a}),l=lr({typed:e}),s=rr({typed:e}),o="Complex number not supported in function nthRoot. Use nthRoots instead.";return e(fl,{number:Xu,"number, number":Xu,BigNumber:function(v){return u(v,new n(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 c(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 l(v,h,this)},"Array, Array":function(v,h){return this(t(v),t(h)).valueOf()},"Array, Matrix":function(v,h){return this(t(v),h)},"Matrix, Array":function(v,h){return this(v,t(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(t(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,t(h)).valueOf()}});function u(p,v){var h=n.precision,b=n.clone({precision:h+2}),w=new n(0),N=new b(1),d=v.isNegative();if(d&&(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 d?new b(1/0):0;if(!p.isFinite())return d?w:p;var y=p.abs().pow(N.div(v));return y=p.isNeg()?y.neg():y,new n((d?N.div(y):y).toPrecision(h))}}),ml="sign",I1=["typed","BigNumber","Fraction","complex"],R1=q(ml,I1,r=>{var{typed:e,BigNumber:t,complex:a,Fraction:n}=r;return e(ml,{number:vo,Complex:function(c){return c.im===0?a(vo(c.re)):c.sign()},BigNumber:function(c){return new t(c.cmp(0))},Fraction:function(c){return new n(c.s,1)},"Array | Matrix":function(c){return $e(c,this)},Unit:function(c){if(!c._isDerived()&&c.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return this(c.value)}})}),F1="sqrt",q1=["config","typed","Complex"],z1=q(F1,q1,r=>{var{config:e,typed:t,Complex:a}=r;return t("sqrt",{number:n,Complex:function(c){return c.sqrt()},BigNumber:function(c){return!c.isNegative()||e.predictable?c.sqrt():n(c.toNumber())},"Array | Matrix":function(c){return $e(c,this)},Unit:function(c){return c.pow(.5)}});function n(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new a(i,0).sqrt()}}),pl="square",P1=["typed"],U1=q(pl,P1,r=>{var{typed:e}=r;return e(pl,{number:Yu,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)},Fraction:function(a){return a.mul(a)},"Array | Matrix":function(a){return $e(a,this)},Unit:function(a){return a.pow(2)}})}),vl="subtract",L1=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],k1=q(vl,L1,r=>{var{typed:e,matrix:t,equalScalar:a,addScalar:n,unaryMinus:i,DenseMatrix:c}=r,m=jt({typed:e}),f=Lr({typed:e}),l=hi({typed:e,equalScalar:a}),s=pn({typed:e,DenseMatrix:c}),o=lr({typed:e}),u=rr({typed:e});return e(vl,{"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 di(v,h),l(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return di(v,h),f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return di(v,h),m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return di(v,h),o(v,h,this)},"Array, Array":function(v,h){return this(t(v),t(h)).valueOf()},"Array, Matrix":function(v,h){return this(t(v),h)},"Matrix, Array":function(v,h){return this(v,t(h))},"SparseMatrix, any":function(v,h){return s(v,i(h),n)},"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(t(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(t(h),v,this,!0).valueOf()}})});function di(r,e){var t=r.size(),a=e.size();if(t.length!==a.length)throw new He(t.length,a.length)}var hl="xgcd",V1=["typed","config","matrix","BigNumber"],G1=q(hl,V1,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(hl,{"number, number":function(m,f){var l=Qu(m,f);return t.matrix==="Array"?l:a(l)},"BigNumber, BigNumber":i});function i(c,m){var f,l,s,o=new n(0),u=new n(1),p=o,v=u,h=u,b=o;if(!c.isInt()||!m.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!m.isZero();)l=c.div(m).floor(),s=c.mod(m),f=p,p=v.minus(l.times(p)),v=f,f=h,h=b.minus(l.times(h)),b=f,c=m,m=s;var w;return c.lt(o)?w=[c.neg(),v.neg(),b.neg()]:w=[c,c.isZero()?0:v,b],t.matrix==="Array"?w:a(w)}}),dl="invmod",H1=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Z1=q(dl,H1,r=>{var{typed:e,config:t,BigNumber:a,xgcd:n,equal:i,smaller:c,mod:m,add:f,isInteger:l}=r;return e(dl,{"number, number":s,"BigNumber, BigNumber":s});function s(o,u){if(!l(o)||!l(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=n(o,u);p=p.valueOf();var[v,h]=p;return i(v,a(1))?(h=m(h,u),c(h,a(0))&&(h=f(h,u)),h):NaN}}),J1="algorithm09",W1=["typed","equalScalar"],gl=q(J1,W1,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,c){var m=n._values,f=n._index,l=n._ptr,s=n._size,o=n._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new He(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],d,y=t,x=0,g=c;typeof o=="string"&&o===b&&(d=o,y=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(c,[d,d]));var S=m&&u?[]:void 0,A=[],E=[],M=S?[]:void 0,B=[],C,_,P,I,T;for(_=0;_<N;_++){E[_]=A.length;var D=_+1;if(M)for(I=v[_],T=v[_+1],P=I;P<T;P++)C=p[P],B[C]=D,M[C]=u[P];for(I=l[_],T=l[_+1],P=I;P<T;P++)if(C=f[P],M){var Z=B[C]===D?M[C]:x,$=g(m[P],Z);y($,x)||(A.push(C),S.push($))}else A.push(C)}return E[N]=A.length,n.createSparseMatrix({values:S,index:A,ptr:E,size:[w,N],datatype:d})}}),yl="dotMultiply",X1=["typed","matrix","equalScalar","multiplyScalar"],Y1=q(yl,X1,r=>{var{typed:e,matrix:t,equalScalar:a,multiplyScalar:n}=r,i=pt({typed:e,equalScalar:a}),c=gl({typed:e,equalScalar:a}),m=_r({typed:e,equalScalar:a}),f=lr({typed:e}),l=rr({typed:e});return e(yl,{"any, any":n,"SparseMatrix, SparseMatrix":function(o,u){return c(o,u,n,!1)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,n,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,n,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,n)},"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,n,!1)},"DenseMatrix, any":function(o,u){return l(o,u,n,!1)},"any, SparseMatrix":function(o,u){return m(u,o,n,!0)},"any, DenseMatrix":function(o,u){return l(u,o,n,!0)},"Array, any":function(o,u){return l(t(o),u,n,!1).valueOf()},"any, Array":function(o,u){return l(t(u),o,n,!0).valueOf()}})});function Q1(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitAnd");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero()||e.eq(-1)||r.eq(e))return r;if(e.isZero()||r.eq(-1))return e;if(!r.isFinite()||!e.isFinite()){if(!r.isFinite()&&!e.isFinite())return r.isNegative()===e.isNegative()?r:new t(0);if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e;if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r}return No(r,e,function(a,n){return a&n})}function ya(r){if(r.isFinite()&&!r.isInteger())throw new Error("Integer expected in function bitNot");var e=r.constructor,t=e.precision;e.config({precision:1e9});var a=r.plus(new e(1));return a.s=-a.s||null,e.config({precision:t}),a}function j1(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitOr");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);var a=new t(-1);return r.isZero()||e.eq(a)||r.eq(e)?e:e.isZero()||r.eq(a)?r:!r.isFinite()||!e.isFinite()?!r.isFinite()&&!r.isNegative()&&e.isNegative()||r.isNegative()&&!e.isNegative()&&!e.isFinite()?a:r.isNegative()&&e.isNegative()?r.isFinite()?r:e:r.isFinite()?e:r:No(r,e,function(n,i){return n|i})}function No(r,e,t){var a=r.constructor,n,i,c=+(r.s<0),m=+(e.s<0);if(c){n=gi(ya(r));for(var f=0;f<n.length;++f)n[f]^=1}else n=gi(r);if(m){i=gi(ya(e));for(var l=0;l<i.length;++l)i[l]^=1}else i=gi(e);var s,o,u;n.length<=i.length?(s=n,o=i,u=c):(s=i,o=n,u=m);var p=s.length,v=o.length,h=t(c,m)^1,b=new a(h^1),w=new a(1),N=new a(2),d=a.precision;for(a.config({precision:1e9});p>0;)t(s[--p],o[--v])===h&&(b=b.plus(w)),w=w.times(N);for(;v>0;)t(u,o[--v])===h&&(b=b.plus(w)),w=w.times(N);return a.config({precision:d}),h===0&&(b.s=-b.s),b}function gi(r){for(var e=r.d,t=e[0]+"",a=1;a<e.length;++a){for(var n=e[a]+"",i=7-n.length;i--;)n="0"+n;t+=n}for(var c=t.length;t.charAt(c)==="0";)c--;var m=r.e,f=t.slice(0,c+1||1),l=f.length;if(m>0)if(++m>l)for(m-=l;m--;)f+="0";else m<l&&(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 K1(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitXor");var t=r.constructor;if(r.isNaN()||e.isNaN())return new t(NaN);if(r.isZero())return e;if(e.isZero())return r;if(r.eq(e))return new t(0);var a=new t(-1);return r.eq(a)?ya(e):e.eq(a)?ya(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?a:new t(r.isNegative()===e.isNegative()?1/0:-1/0):No(r,e,function(n,i){return n^i})}function eb(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function leftShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:!r.isFinite()&&!e.isFinite()?new t(NaN):e.lt(55)?r.times(Math.pow(2,e.toNumber())+""):r.times(new t(2).pow(e))}function rb(r,e){if(r.isFinite()&&!r.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function rightArithShift");var t=r.constructor;return r.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new t(NaN):r.isZero()||e.isZero()?r:e.isFinite()?e.lt(55)?r.div(Math.pow(2,e.toNumber())+"").floor():r.div(new t(2).pow(e)).floor():r.isNegative()?new t(-1):r.isFinite()?new t(0):new t(NaN)}var bl="bitAnd",tb=["typed","matrix","equalScalar"],nb=q(bl,tb,r=>{var{typed:e,matrix:t,equalScalar:a}=r,n=pt({typed:e,equalScalar:a}),i=vi({typed:e,equalScalar:a}),c=_r({typed:e,equalScalar:a}),m=lr({typed:e}),f=rr({typed:e});return e(bl,{"number, number":ec,"BigNumber, BigNumber":Q1,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this,!1)},"SparseMatrix, DenseMatrix":function(s,o){return n(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return n(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(t(s),t(o)).valueOf()},"Array, Matrix":function(s,o){return this(t(s),o)},"Matrix, Array":function(s,o){return this(s,t(o))},"SparseMatrix, any":function(s,o){return c(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return c(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(t(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(t(o),s,this,!0).valueOf()}})}),xl="bitNot",ab=["typed"],ib=q(xl,ab,r=>{var{typed:e}=r;return e(xl,{number:rc,BigNumber:ya,"Array | Matrix":function(a){return $e(a,this)}})}),wl="bitOr",ob=["typed","matrix","equalScalar","DenseMatrix"],sb=q(wl,ob,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=jt({typed:e}),c=wo({typed:e,equalScalar:a}),m=pn({typed:e,DenseMatrix:n}),f=lr({typed:e}),l=rr({typed:e});return e(wl,{"number, number":tc,"BigNumber, BigNumber":j1,"SparseMatrix, SparseMatrix":function(o,u){return c(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 l(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return l(u,o,this,!0)},"Array, any":function(o,u){return l(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return l(t(u),o,this,!0).valueOf()}})}),ub="algorithm07",cb=["typed","DenseMatrix"],wt=q(ub,cb,r=>{var{typed:e,DenseMatrix:t}=r;return function(i,c,m){var f=i._size,l=i._datatype,s=c._size,o=c._datatype;if(f.length!==s.length)throw new He(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 l=="string"&&l===o&&(v=l,h=e.convert(0,v),b=e.find(m,[v,v]));var w,N,d=[];for(w=0;w<u;w++)d[w]=[];var y=[],x=[],g=[],S=[];for(N=0;N<p;N++){var A=N+1;for(a(i,N,g,y,A),a(c,N,S,x,A),w=0;w<u;w++){var E=g[w]===A?y[w]:h,M=S[w]===A?x[w]:h;d[w][N]=b(E,M)}}return new t({data:d,size:[u,p],datatype:v})};function a(n,i,c,m,f){for(var l=n._values,s=n._index,o=n._ptr,u=o[i],p=o[i+1];u<p;u++){var v=s[u];c[v]=f,m[v]=l[u]}}}),Nl="bitXor",lb=["typed","matrix","DenseMatrix"],fb=q(Nl,lb,r=>{var{typed:e,matrix:t,DenseMatrix:a}=r,n=Lr({typed:e}),i=wt({typed:e,DenseMatrix:a}),c=$r({typed:e,DenseMatrix:a}),m=lr({typed:e}),f=rr({typed:e});return e(Nl,{"number, number":nc,"BigNumber, BigNumber":K1,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return n(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return n(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(t(s),t(o)).valueOf()},"Array, Matrix":function(s,o){return this(t(s),o)},"Matrix, Array":function(s,o){return this(s,t(o))},"SparseMatrix, any":function(s,o){return c(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return c(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(t(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(t(o),s,this,!0).valueOf()}})}),Ml="arg",mb=["typed"],pb=q(Ml,mb,r=>{var{typed:e}=r;return e(Ml,{number:function(a){return Math.atan2(0,a)},BigNumber:function(a){return a.constructor.atan2(0,a)},Complex:function(a){return a.arg()},"Array | Matrix":function(a){return $e(a,this)}})}),Al="conj",vb=["typed"],hb=q(Al,vb,r=>{var{typed:e}=r;return e(Al,{number:function(a){return a},BigNumber:function(a){return a},Complex:function(a){return a.conjugate()},"Array | Matrix":function(a){return $e(a,this)}})}),Sl="im",db=["typed"],gb=q(Sl,db,r=>{var{typed:e}=r;return e(Sl,{number:function(a){return 0},BigNumber:function(a){return a.mul(0)},Fraction:function(a){return a.mul(0)},Complex:function(a){return a.im},"Array | Matrix":function(a){return $e(a,this)}})}),El="re",yb=["typed"],bb=q(El,yb,r=>{var{typed:e}=r;return e(El,{number:function(a){return a},BigNumber:function(a){return a},Fraction:function(a){return a},Complex:function(a){return a.re},"Array | Matrix":function(a){return $e(a,this)}})}),Cl="not",xb=["typed"],wb=q(Cl,xb,r=>{var{typed:e}=r;return e(Cl,{number:uc,Complex:function(a){return a.re===0&&a.im===0},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:function(a){return a.value!==null?this(a.value):!0},"Array | Matrix":function(a){return $e(a,this)}})}),Ol="or",Nb=["typed","matrix","equalScalar","DenseMatrix"],Mb=q(Ol,Nb,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=Lr({typed:e}),c=hi({typed:e,equalScalar:a}),m=$r({typed:e,DenseMatrix:n}),f=lr({typed:e}),l=rr({typed:e});return e(Ol,{"number, number":cc,"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 c(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 l(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return l(u,o,this,!0)},"Array, any":function(o,u){return l(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return l(t(u),o,this,!0).valueOf()}})}),$l="xor",Ab=["typed","matrix","DenseMatrix"],Sb=q($l,Ab,r=>{var{typed:e,matrix:t,DenseMatrix:a}=r,n=Lr({typed:e}),i=wt({typed:e,DenseMatrix:a}),c=$r({typed:e,DenseMatrix:a}),m=lr({typed:e}),f=rr({typed:e});return e($l,{"number, number":lc,"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 n(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return n(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(t(s),t(o)).valueOf()},"Array, Matrix":function(s,o){return this(t(s),o)},"Matrix, Array":function(s,o){return this(s,t(o))},"SparseMatrix, any":function(s,o){return c(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return c(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(t(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(t(o),s,this,!0).valueOf()}})}),Tl="concat",Eb=["typed","matrix","isInteger"],Dl=q(Tl,Eb,r=>{var{typed:e,matrix:t,isInteger:a}=r;return e(Tl,{"...Array | Matrix | number | BigNumber":function(i){var c,m=i.length,f=-1,l,s=!1,o=[];for(c=0;c<m;c++){var u=i[c];if(Fe(u)&&(s=!0),Ye(u)||We(u)){if(c!==m-1)throw new Error("Dimension must be specified as last argument");if(l=f,f=u.valueOf(),!a(f))throw new TypeError("Integer number expected for dimension");if(f<0||c>0&&f>l)throw new ct(f,l+1)}else{var p=Re(u).valueOf(),v=Je(p);if(o[c]=p,l=f,f=v.length-1,c>0&&f!==l)throw new He(l+1,f+1)}}if(o.length===0)throw new SyntaxError("At least one matrix expected");for(var h=o.shift();o.length;)h=Bl(h,o.shift(),f,0);return s?t(h):h},"...string":function(i){return i.join("")}})});function Bl(r,e,t,a){if(a<t){if(r.length!==e.length)throw new He(r.length,e.length);for(var n=[],i=0;i<r.length;i++)n[i]=Bl(r[i],e[i],t,a+1);return n}else return r.concat(e)}var _l="column",Cb=["typed","Index","matrix","range"],Il=q(_l,Cb,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(_l,{"Matrix, number":i,"Array, number":function(m,f){return i(a(Re(m)),f).valueOf()}});function i(c,m){if(c.size().length!==2)throw new Error("Only two dimensional matrix is supported");or(m,c.size()[1]);var f=n(0,c.size()[0]),l=new t(f,m);return c.subset(l)}}),Rl="count",Ob=["typed","size","prod"],$b=q(Rl,Ob,r=>{var{typed:e,size:t,prod:a}=r;return e(Rl,{string:function(i){return i.length},"Matrix | Array":function(i){return a(t(i))}})}),Fl="cross",Tb=["typed","matrix","subtract","multiply"],Db=q(Fl,Tb,r=>{var{typed:e,matrix:t,subtract:a,multiply:n}=r;return e(Fl,{"Matrix, Matrix":function(m,f){return t(i(m.toArray(),f.toArray()))},"Matrix, Array":function(m,f){return t(i(m.toArray(),f))},"Array, Matrix":function(m,f){return t(i(m,f.toArray()))},"Array, Array":i});function i(c,m){var f=Math.max(Je(c).length,Je(m).length);c=Xa(c),m=Xa(m);var l=Je(c),s=Je(m);if(l.length!==1||s.length!==1||l[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+l.join(", ")+"], B = ["+s.join(", ")+"])");var o=[a(n(c[1],m[2]),n(c[2],m[1])),a(n(c[2],m[0]),n(c[0],m[2])),a(n(c[0],m[1]),n(c[1],m[0]))];return f>1?[o]:o}}),ql="diag",Bb=["typed","matrix","DenseMatrix","SparseMatrix"],_b=q(ql,Bb,r=>{var{typed:e,matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(ql,{Array:function(l){return i(l,0,Je(l),null)},"Array, number":function(l,s){return i(l,s,Je(l),null)},"Array, BigNumber":function(l,s){return i(l,s.toNumber(),Je(l),null)},"Array, string":function(l,s){return i(l,0,Je(l),s)},"Array, number, string":function(l,s,o){return i(l,s,Je(l),o)},"Array, BigNumber, string":function(l,s,o){return i(l,s.toNumber(),Je(l),o)},Matrix:function(l){return i(l,0,l.size(),l.storage())},"Matrix, number":function(l,s){return i(l,s,l.size(),l.storage())},"Matrix, BigNumber":function(l,s){return i(l,s.toNumber(),l.size(),l.storage())},"Matrix, string":function(l,s){return i(l,0,l.size(),s)},"Matrix, number, string":function(l,s,o){return i(l,s,l.size(),o)},"Matrix, BigNumber, string":function(l,s,o){return i(l,s.toNumber(),l.size(),o)}});function i(f,l,s,o){if(!Be(l))throw new TypeError("Second parameter in function diag must be an integer");var u=l>0?l:0,p=l<0?-l:0;switch(s.length){case 1:return c(f,l,o,s[0],p,u);case 2:return m(f,l,o,s,p,u)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function c(f,l,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"?n.diagonal(v,f,l):a.diagonal(v,f,l);return s!==null?h:h.valueOf()}function m(f,l,s,o,u,p){if(Fe(f)){var v=f.diagonal(l);return s!==null?s!==v.storage()?t(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?t(b):b}});function Ib(r){var e=0,t=1,a=Object.create(null),n=Object.create(null),i=0,c=function(f){var l=n[f];if(!!l&&(delete a[l],delete n[f],--e,t===l)){if(!e){i=0,t=1;return}for(;!hasOwnProperty.call(a,++t););}};return r=Math.abs(r),{hit:function(f){var l=n[f],s=++i;if(a[s]=f,n[f]=s,!l)return++e,e<=r?void 0:(f=a[t],c(f),f);if(delete a[l],t===l)for(;!hasOwnProperty.call(a,++t););},delete:c,clear:function(){e=i=0,t=1,a=Object.create(null),n=Object.create(null)}}}function ba(r){var{hasher:e,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t==null?Number.POSITIVE_INFINITY:t,e=e==null?JSON.stringify:e,function a(){typeof a.cache!="object"&&(a.cache={values:new Map,lru:Ib(t||Number.POSITIVE_INFINITY)});for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var c=e(n);if(a.cache.values.has(c))return a.cache.lru.hit(c),a.cache.values.get(c);var m=r.apply(r,n);return a.cache.values.set(c,m),a.cache.values.delete(a.cache.lru.hit(c)),m}}function Un(r){return Object.keys(r.signatures||{}).reduce(function(e,t){var a=(t.match(/,/g)||[]).length+1;return Math.max(e,a)},-1)}var Rb="filter",Fb=["typed"],qb=q(Rb,Fb,r=>{var{typed:e}=r;return e("filter",{"Array, function":zl,"Matrix, function":function(a,n){return a.create(zl(a.toArray(),n))},"Array, RegExp":Qa,"Matrix, RegExp":function(a,n){return a.create(Qa(a.toArray(),n))}})});function zl(r,e){var t=Un(e);return fu(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n]):e(a,[n],i)})}var Pl="flatten",zb=["typed","matrix"],Pb=q(Pl,zb,r=>{var{typed:e,matrix:t}=r;return e(Pl,{Array:function(n){return Qe(Re(n))},Matrix:function(n){var i=Qe(Re(n.toArray()));return t(i)}})}),Ul="forEach",Ub=["typed"],Lb=q(Ul,Ub,r=>{var{typed:e}=r;return e(Ul,{"Array, function":kb,"Matrix, function":function(a,n){return a.forEach(n)}})});function kb(r,e){var t=Un(e),a=function n(i,c){Array.isArray(i)?Ya(i,function(m,f){n(m,c.concat(f))}):t===1?e(i):t===2?e(i,c):e(i,c,r)};a(r,[])}var Ll="getMatrixDataType",Vb=["typed"],Gb=q(Ll,Vb,r=>{var{typed:e}=r;return e(Ll,{Array:function(a){return ha(a,cr)},Matrix:function(a){return a.getDataType()}})}),kl="identity",Hb=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Zb=q(kl,Hb,r=>{var{typed:e,config:t,matrix:a,BigNumber:n,DenseMatrix:i,SparseMatrix:c}=r;return e(kl,{"":function(){return t.matrix==="Matrix"?a([]):[]},string:function(s){return a(s)},"number | BigNumber":function(s){return f(s,s,t.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,t.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(l,s){switch(l.length){case 0:return s?a(s):[];case 1:return f(l[0],l[0],s);case 2:return f(l[0],l[1],s);default:throw new Error("Vector containing two values expected")}}function f(l,s,o){var u=We(l)||We(s)?n:null;if(We(l)&&(l=l.toNumber()),We(s)&&(s=s.toNumber()),!Be(l)||l<1)throw new Error("Parameters in function identity must be positive integers");if(!Be(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var p=u?new n(1):1,v=u?new u(0):0,h=[l,s];if(o){if(o==="sparse")return c.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=Dn([],h,v),w=l<s?l:s,N=0;N<w;N++)b[N][N]=p;return b}}),Vl="kron",Jb=["typed","matrix","multiplyScalar"],Wb=q(Vl,Jb,r=>{var{typed:e,matrix:t,multiplyScalar:a}=r;return e(Vl,{"Matrix, Matrix":function(c,m){return t(n(c.toArray(),m.toArray()))},"Matrix, Array":function(c,m){return t(n(c.toArray(),m))},"Array, Matrix":function(c,m){return t(n(c,m.toArray()))},"Array, Array":n});function n(i,c){if(Je(i).length===1&&(i=[i]),Je(c).length===1&&(c=[c]),Je(i).length>2||Je(c).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(c.length)+")");var m=[],f=[];return i.map(function(l){return c.map(function(s){return f=[],m.push(f),l.map(function(o){return s.map(function(u){return f.push(a(o,u))})})})})&&m}}),Gl="map",Xb=["typed"],Yb=q(Gl,Xb,r=>{var{typed:e}=r;return e(Gl,{"Array, function":Qb,"Matrix, function":function(a,n){return a.map(n)}})});function Qb(r,e){var t=Un(e),a=function n(i,c){if(Array.isArray(i))return i.map(function(l,s){return n(l,c.concat(s))});try{return t===1?e(i):t===2?e(i,c):e(i,c,r)}catch(l){if(l instanceof TypeError&&"data"in l&&l.data.category==="wrongType"){var m="map attempted to call '".concat(l.data.fn,"(").concat(i),f=JSON.stringify(c);throw t===2?m+=","+f:t!==1&&(m+=",".concat(f,",").concat(r)),m+=")' but argument ".concat(l.data.index+1," of type "),m+="".concat(l.data.actual," does not match expected type "),m+=l.data.expected.join(" or "),new TypeError(m)}throw l}};return a(r,[])}var Hl="diff",jb=["typed","matrix","subtract","number"],Zl=q(Hl,jb,r=>{var{typed:e,matrix:t,subtract:a,number:n}=r;return e(Hl,{"Array | Matrix":function(s){return Fe(s)?t(c(s.toArray())):c(s)},"Array | Matrix, number":function(s,o){if(!Be(o))throw new RangeError("Dimension must be a whole number");return Fe(s)?t(i(s.toArray(),o)):i(s,o)},"Array | Matrix, BigNumber":function(s,o){return this(s,n(o))}});function i(l,s){if(Fe(l)&&(l=l.toArray()),!Array.isArray(l))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var o=[];return l.forEach(u=>{o.push(i(u,s-1))}),o}else{if(s===0)return c(l);throw RangeError("Cannot have negative dimension")}}function c(l){var s=[],o=l.length;if(o<2)return l;for(var u=1;u<o;u++)s.push(m(l[u-1],l[u]));return s}function m(l,s){Fe(l)&&(l=l.toArray()),Fe(s)&&(s=s.toArray());var o=Array.isArray(l),u=Array.isArray(s);if(o&&u)return f(l,s);if(!o&&!u)return a(s,l);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function f(l,s){if(l.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var o=[],u=l.length,p=0;p<u;p++)o.push(m(l[p],s[p]));return o}}),Kb="ones",ex=["typed","config","matrix","BigNumber"],rx=q(Kb,ex,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e("ones",{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(l){var s=l[l.length-1];if(typeof s=="string"){var o=l.pop();return i(l,o)}else return t.matrix==="Array"?i(l):i(l,"default")},Array:i,Matrix:function(l){var s=l.storage();return i(l.valueOf(),s)},"Array | Matrix, string":function(l,s){return i(l.valueOf(),s)}});function i(f,l){var s=c(f),o=s?new n(1):1;if(m(f),l){var u=a(l);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?Dn(p,f,o):p}}function c(f){var l=!1;return f.forEach(function(s,o,u){We(s)&&(l=!0,u[o]=s.toNumber())}),l}function m(f){f.forEach(function(l){if(typeof l!="number"||!Be(l)||l<0)throw new Error("Parameters in function ones must be positive integers")})}});function Mo(){throw new Error('No "bignumber" implementation available')}function Jl(){throw new Error('No "fraction" implementation available')}function Wl(){throw new Error('No "matrix" implementation available')}var Xl="range",tx=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],Yl=q(Xl,tx,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:c,larger:m,largerEq:f}=r;return e(Xl,{string:s,"string, boolean":s,"number, number":function(w,N){return l(o(w,N,1))},"number, number, number":function(w,N,d){return l(o(w,N,d))},"number, number, boolean":function(w,N,d){return l(d?u(w,N,1):o(w,N,1))},"number, number, number, boolean":function(w,N,d,y){return l(y?u(w,N,d):o(w,N,d))},"BigNumber, BigNumber":function(w,N){var d=w.constructor;return l(p(w,N,new d(1)))},"BigNumber, BigNumber, BigNumber":function(w,N,d){return l(p(w,N,d))},"BigNumber, BigNumber, boolean":function(w,N,d){var y=w.constructor;return l(d?v(w,N,new y(1)):p(w,N,new y(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(w,N,d,y){return l(y?v(w,N,d):p(w,N,d))}});function l(b){return t.matrix==="Matrix"?a?a(b):Wl():b}function s(b,w){var N=h(b);if(!N)throw new SyntaxError('String "'+b+'" is no valid range');var d;return t.number==="BigNumber"?(n===void 0&&Mo(),d=w?v:p,l(d(n(N.start),n(N.end),n(N.step)))):(d=w?u:o,l(d(N.start,N.end,N.step)))}function o(b,w,N){var d=[],y=b;if(N>0)for(;i(y,w);)d.push(y),y+=N;else if(N<0)for(;m(y,w);)d.push(y),y+=N;return d}function u(b,w,N){var d=[],y=b;if(N>0)for(;c(y,w);)d.push(y),y+=N;else if(N<0)for(;f(y,w);)d.push(y),y+=N;return d}function p(b,w,N){var d=n(0),y=[],x=b;if(N.gt(d))for(;i(x,w);)y.push(x),x=x.plus(N);else if(N.lt(d))for(;m(x,w);)y.push(x),x=x.plus(N);return y}function v(b,w,N){var d=n(0),y=[],x=b;if(N.gt(d))for(;c(x,w);)y.push(x),x=x.plus(N);else if(N.lt(d))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)}),d=N.some(function(y){return isNaN(y)});if(d)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}}}),Ql="reshape",nx=["typed","isInteger","matrix"],ax=q(Ql,nx,r=>{var{typed:e,isInteger:t}=r;return e(Ql,{"Matrix, Array":function(n,i){return n.reshape(i)},"Array, Array":function(n,i){return i.forEach(function(c){if(!t(c))throw new TypeError("Invalid size for dimension: "+c)}),ou(n,i)}})});function Ln(r,e,t,a){if(!(this instanceof Ln))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=e,this.min=t,this.max=a,this.message="Wrong number of arguments in function "+r+" ("+e+" provided, "+t+(a!=null?"-"+a:"")+" expected)",this.stack=new Error().stack}Ln.prototype=new Error,Ln.prototype.constructor=Error,Ln.prototype.name="ArgumentsError",Ln.prototype.isArgumentsError=!0;var ix="resize",ox=["config","matrix"],sx=q(ix,ox,r=>{var{config:e,matrix:t}=r;return function(i,c,m){if(arguments.length!==2&&arguments.length!==3)throw new Ln("resize",arguments.length,2,3);if(Fe(c)&&(c=c.valueOf()),We(c[0])&&(c=c.map(function(s){return We(s)?s.toNumber():s})),Fe(i))return i.resize(c,m,!0);if(typeof i=="string")return a(i,c,m);var f=Array.isArray(i)?!1:e.matrix!=="Array";if(c.length===0){for(;Array.isArray(i);)i=i[0];return Re(i)}else{Array.isArray(i)||(i=[i]),i=Re(i);var l=Dn(i,c,m);return f?t(l):l}};function a(n,i,c){if(c!==void 0){if(typeof c!="string"||c.length!==1)throw new TypeError("Single character expected as defaultValue")}else c=" ";if(i.length!==1)throw new He(i.length,1);var m=i[0];if(typeof m!="number"||!Be(m))throw new TypeError("Invalid size, must contain positive integers (size: "+Ge(i)+")");if(n.length>m)return n.substring(0,m);if(n.length<m){for(var f=n,l=0,s=m-n.length;l<s;l++)f+=c;return f}else return n}}),jl="rotate",ux=["typed","multiply","rotationMatrix"],cx=q(jl,ux,r=>{var{typed:e,multiply:t,rotationMatrix:a}=r;return e(jl,{"Array , number | BigNumber | Complex | Unit":function(c,m){n(c,2);var f=t(a(m),c);return f.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(c,m){return n(c,2),t(a(m),c)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(c,m,f){n(c,3);var l=t(a(m,f),c);return l},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(c,m,f){return n(c,3),t(a(m,f),c)}});function n(i,c){var m=Array.isArray(i)?Je(i):i.size();if(m.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(c));if(m.length===2&&m[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(c));if(m[0]!==c)throw new RangeError("Vector must be of dimensions 1x".concat(c))}}),Kl="rotationMatrix",lx=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],fx=q(Kl,lx,r=>{var{typed:e,config:t,multiplyScalar:a,addScalar:n,unaryMinus:i,norm:c,BigNumber:m,matrix:f,DenseMatrix:l,SparseMatrix:s,cos:o,sin:u}=r;return e(Kl,{"":function(){return t.matrix==="Matrix"?f([]):[]},string:function(d){return f(d)},"number | BigNumber | Complex | Unit":function(d){return p(d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(d,y){return p(d,y)},"number | BigNumber | Complex | Unit, Array":function(d,y){var x=f(y);return v(x),w(d,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(d,y){v(y);var x=y.storage()||(t.matrix==="Matrix"?"dense":void 0);return w(d,y,x)},"number | BigNumber | Complex | Unit, Array, string":function(d,y,x){var g=f(y);return v(g),w(d,g,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(d,y,x){return v(y),w(d,y,x)}});function p(N,d){var y=We(N),x=y?new m(-1):-1,g=o(N),S=u(N),A=[[g,a(x,S)],[S,g]];return b(A,d)}function v(N){var d=N.size();if(d.length<1||d[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(N){return N.reduce((d,y)=>a(d,y))}function b(N,d){if(d){if(d==="sparse")return new s(N);if(d==="dense")return new l(N);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}return N}function w(N,d,y){var x=c(d);if(x===0)throw new RangeError("Rotation around zero vector");var g=We(N)?m:null,S=g?new g(1):1,A=g?new g(-1):-1,E=g?new g(d.get([0])/x):d.get([0])/x,M=g?new g(d.get([1])/x):d.get([1])/x,B=g?new g(d.get([2])/x):d.get([2])/x,C=o(N),_=n(S,i(C)),P=u(N),I=n(C,h([E,E,_])),T=n(h([E,M,_]),h([A,B,P])),D=n(h([E,B,_]),h([M,P])),Z=n(h([E,M,_]),h([B,P])),$=n(C,h([M,M,_])),H=n(h([M,B,_]),h([A,E,P])),Q=n(h([E,B,_]),h([A,M,P])),te=n(h([M,B,_]),h([E,P])),J=n(C,h([B,B,_])),re=[[I,T,D],[Z,$,H],[Q,te,J]];return b(re,y)}}),ef="row",mx=["typed","Index","matrix","range"],rf=q(ef,mx,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(ef,{"Matrix, number":i,"Array, number":function(m,f){return i(a(Re(m)),f).valueOf()}});function i(c,m){if(c.size().length!==2)throw new Error("Only two dimensional matrix is supported");or(m,c.size()[0]);var f=n(0,c.size()[1]),l=new t(m,f);return c.subset(l)}}),tf="size",px=["typed","config","?matrix"],vx=q(tf,px,r=>{var{typed:e,config:t,matrix:a}=r;return e(tf,{Matrix:function(i){return i.create(i.size())},Array:Je,string:function(i){return t.matrix==="Array"?[i.length]:a([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return t.matrix==="Array"?[]:a?a([]):Wl()}})}),nf="squeeze",hx=["typed","matrix"],dx=q(nf,hx,r=>{var{typed:e,matrix:t}=r;return e(nf,{Array:function(n){return Xa(Re(n))},Matrix:function(n){var i=Xa(n.toArray());return Array.isArray(i)?t(i):i},any:function(n){return Re(n)}})}),af="subset",gx=["typed","matrix"],of=q(af,gx,r=>{var{typed:e,matrix:t}=r;return e(af,{"Array, Index":function(n,i){var c=t(n),m=c.subset(i);return i.isScalar()?m:m.valueOf()},"Matrix, Index":function(n,i){return n.subset(i)},"Object, Index":bx,"string, Index":yx,"Array, Index, any":function(n,i,c){return t(Re(n)).subset(i,c,void 0).valueOf()},"Array, Index, any, any":function(n,i,c,m){return t(Re(n)).subset(i,c,m).valueOf()},"Matrix, Index, any":function(n,i,c){return n.clone().subset(i,c)},"Matrix, Index, any, any":function(n,i,c,m){return n.clone().subset(i,c,m)},"string, Index, string":sf,"string, Index, string, string":sf,"Object, Index, any":xx})});function yx(r,e){if(!fa(e))throw new TypeError("Index expected");if(e.size().length!==1)throw new He(e.size().length,1);var t=r.length;or(e.min()[0],t),or(e.max()[0],t);var a=e.dimension(0),n="";return a.forEach(function(i){n+=r.charAt(i)}),n}function sf(r,e,t,a){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(e.size().length!==1)throw new He(e.size().length,1);if(a!==void 0){if(typeof a!="string"||a.length!==1)throw new TypeError("Single character expected as defaultValue")}else a=" ";var n=e.dimension(0),i=n.size()[0];if(i!==t.length)throw new He(n.size()[0],t.length);var c=r.length;or(e.min()[0]),or(e.max()[0]);for(var m=[],f=0;f<c;f++)m[f]=r.charAt(f);if(n.forEach(function(o,u){m[o]=t.charAt(u[0])}),m.length>c)for(var l=c-1,s=m.length;l<s;l++)m[l]||(m[l]=a);return m.join("")}function bx(r,e){if(e.size().length!==1)throw new He(e.size(),1);var t=e.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return rt(r,t)}function xx(r,e,t){if(e.size().length!==1)throw new He(e.size(),1);var a=e.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");var n=Re(r);return _n(n,a,t),n}var wx="transpose",Nx=["typed","matrix"],Mx=q(wx,Nx,r=>{var{typed:e,matrix:t}=r;return e("transpose",{Array:function(c){return this(t(c)).valueOf()},Matrix:function(c){var m=c.size(),f;switch(m.length){case 1:f=c.clone();break;case 2:{var l=m[0],s=m[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ge(m)+")");switch(c.storage()){case"dense":f=a(c,l,s);break;case"sparse":f=n(c,l,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Ge(this._size)+")")}return f},any:function(c){return Re(c)}});function a(i,c,m){for(var f=i._data,l=[],s,o=0;o<m;o++){s=l[o]=[];for(var u=0;u<c;u++)s[u]=Re(f[u][o])}return i.createDenseMatrix({data:l,size:[m,c],datatype:i._datatype})}function n(i,c,m){for(var f=i._values,l=i._index,s=i._ptr,o=f?[]:void 0,u=[],p=[],v=[],h=0;h<c;h++)v[h]=0;var b,w,N;for(b=0,w=l.length;b<w;b++)v[l[b]]++;for(var d=0,y=0;y<c;y++)p.push(d),d+=v[y],v[y]=p[y];for(p.push(d),N=0;N<m;N++)for(var x=s[N],g=s[N+1],S=x;S<g;S++){var A=v[l[S]]++;u[A]=N,f&&(o[A]=Re(f[S]))}return i.createSparseMatrix({values:o,index:u,ptr:p,size:[m,c],datatype:i._datatype})}}),uf="ctranspose",Ax=["typed","transpose","conj"],Sx=q(uf,Ax,r=>{var{typed:e,transpose:t,conj:a}=r;return e(uf,{any:function(i){return a(t(i))}})}),cf="zeros",Ex=["typed","config","matrix","BigNumber"],Cx=q(cf,Ex,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(cf,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(l){var s=l[l.length-1];if(typeof s=="string"){var o=l.pop();return i(l,o)}else return t.matrix==="Array"?i(l):i(l,"default")},Array:i,Matrix:function(l){var s=l.storage();return i(l.valueOf(),s)},"Array | Matrix, string":function(l,s){return i(l.valueOf(),s)}});function i(f,l){var s=c(f),o=s?new n(0):0;if(m(f),l){var u=a(l);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?Dn(p,f,o):p}}function c(f){var l=!1;return f.forEach(function(s,o,u){We(s)&&(l=!0,u[o]=s.toNumber())}),l}function m(f){f.forEach(function(l){if(typeof l!="number"||!Be(l)||l<0)throw new Error("Parameters in function zeros must be positive integers")})}}),lf="fft",Ox=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],$x=q(lf,Ox,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,divideScalar:i,exp:c,tau:m,i:f}=r;return e(lf,{Array:l,Matrix:function(p){return p.create(l(p.toArray()))}});function l(u){var p=Je(u);return p.length===1?o(u,p[0]):s(u.map(v=>l(v,p.slice(1))),0)}function s(u,p){var v=Je(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=Je(b);return new Array(w[1]).fill(0).map((N,d)=>new Array(w[0]).fill(0).map((y,x)=>b[x][d]))}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,d)=>d%2===0)),...o(u.filter((N,d)=>d%2===1))],h=0;h<p/2;h++){var b=v[h],w=n(v[h+p/2],c(n(n(m,f),i(-h,p))));v[h]=a(b,w),v[h+p/2]=a(b,n(-1,w))}return v}throw new Error("Can only calculate FFT of power-of-two size")}}),ff="ifft",Tx=["typed","fft","dotDivide","conj"],Dx=q(ff,Tx,r=>{var{typed:e,fft:t,dotDivide:a,conj:n}=r;return e(ff,{"Array | Matrix":function(c){var m=Fe(c)?c.size():Je(c);return a(n(t(n(c))),m.reduce((f,l)=>f*l,1))}})}),Bx="erf",_x=["typed"],Ix=q(Bx,_x,r=>{var{typed:e}=r;return e("name",{number:function(c){var m=Math.abs(c);return m>=qx?Zt(c):m<=Rx?Zt(c)*t(m):m<=4?Zt(c)*(1-a(m)):Zt(c)*(1-n(m))},"Array | Matrix":function(c){return $e(c,this)}});function t(i){var c=i*i,m=qt[0][4]*c,f=c,l;for(l=0;l<3;l+=1)m=(m+qt[0][l])*c,f=(f+kn[0][l])*c;return i*(m+qt[0][3])/(f+kn[0][3])}function a(i){var c=qt[1][8]*i,m=i,f;for(f=0;f<7;f+=1)c=(c+qt[1][f])*i,m=(m+kn[1][f])*i;var l=(c+qt[1][7])/(m+kn[1][7]),s=parseInt(i*16)/16,o=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-o)*l}function n(i){var c=1/(i*i),m=qt[2][5]*c,f=c,l;for(l=0;l<4;l+=1)m=(m+qt[2][l])*c,f=(f+kn[2][l])*c;var s=c*(m+qt[2][4])/(f+kn[2][4]);s=(Fx-s)/i,c=parseInt(i*16)/16;var o=(i-c)*(i+c);return Math.exp(-c*c)*Math.exp(-o)*s}}),Rx=.46875,Fx=.5641895835477563,qt=[[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]],kn=[[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]],qx=Math.pow(2,53),mf="mode",zx=["typed","isNaN","isNumeric"],Px=q(mf,zx,r=>{var{typed:e,isNaN:t,isNumeric:a}=r;return e(mf,{"Array | Matrix":n,"...":function(c){return n(c)}});function n(i){i=Qe(i.valueOf());var c=i.length;if(c===0)throw new Error("Cannot calculate mode of an empty array");for(var m={},f=[],l=0,s=0;s<i.length;s++){var o=i[s];if(a(o)&&t(o))throw new Error("Cannot calculate mode of an array containing NaN values");o in m||(m[o]=0),m[o]++,m[o]===l?f.push(o):m[o]>l&&(l=m[o],f=[o])}return f}});function kr(r,e,t){var a;return String(r).indexOf("Unexpected type")!==-1?(a=arguments.length>2?" (type: "+cr(t)+", value: "+JSON.stringify(t)+")":" (type: "+r.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+a)):String(r).indexOf("complex numbers")!==-1?(a=arguments.length>2?" (type: "+cr(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+a)):r}var pf="prod",Ux=["typed","config","multiplyScalar","numeric"],Lx=q(pf,Ux,r=>{var{typed:e,config:t,multiplyScalar:a,numeric:n}=r;return e(pf,{"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(c){var m;if(Rt(c,function(f){try{m=m===void 0?f:a(m,f)}catch(l){throw kr(l,"prod",f)}}),typeof m=="string"&&(m=n(m,t.number)),m===void 0)throw new Error("Cannot calculate prod of an empty array");return m}}),vf="format",kx=["typed"],Vx=q(vf,kx,r=>{var{typed:e}=r;return e(vf,{any:Ge,"any, Object | function | number":Ge})}),hf="bin",Gx=["typed","format"],Hx=q(hf,Gx,r=>{var{typed:e,format:t}=r;return e(hf,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"bin",wordSize:i})}})}),df="oct",Zx=["typed","format"],Jx=q(df,Zx,r=>{var{typed:e,format:t}=r;return e(df,{"number | BigNumber":function(n){return t(n,{notation:"oct"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"oct",wordSize:i})}})}),gf="hex",Wx=["typed","format"],Xx=q(gf,Wx,r=>{var{typed:e,format:t}=r;return e(gf,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"hex",wordSize:i})}})}),yf="print",Yx=["typed"],Qx=q(yf,Yx,r=>{var{typed:e}=r;return e(yf,{"string, Object | Array":bf,"string, Object | Array, number | Object":bf})});function bf(r,e,t){return r.replace(/\$([\w.]+)/g,function(a,n){for(var i=n.split("."),c=e[i.shift()];i.length&&c!==void 0;){var m=i.shift();c=m?c[m]:c+"."}return c!==void 0?Zr(c)?c:Ge(c,t):a})}var xf="to",jx=["typed","matrix"],Kx=q(xf,jx,r=>{var{typed:e,matrix:t}=r,a=lr({typed:e}),n=rr({typed:e});return e(xf,{"Unit, Unit | string":function(c,m){return c.to(m)},"Matrix, Matrix":function(c,m){return a(c,m,this)},"Array, Array":function(c,m){return this(t(c),t(m)).valueOf()},"Array, Matrix":function(c,m){return this(t(c),m)},"Matrix, Array":function(c,m){return this(c,t(m))},"Matrix, any":function(c,m){return n(c,m,this,!1)},"any, Matrix":function(c,m){return n(m,c,this,!0)},"Array, any":function(c,m){return n(t(c),m,this,!1).valueOf()},"any, Array":function(c,m){return n(t(m),c,this,!0).valueOf()}})}),wf="isPrime",ew=["typed"],rw=q(wf,ew,r=>{var{typed:e}=r;return e(wf,{number:function(a){if(a*0!==0)return!1;if(a<=3)return a>1;if(a%2===0||a%3===0)return!1;for(var n=5;n*n<=a;n+=6)if(a%n===0||a%(n+2)===0)return!1;return!0},BigNumber:function(a){if(a.toNumber()*0!==0)return!1;if(a.lte(3))return a.gt(1);if(a.mod(2).eq(0)||a.mod(3).eq(0))return!1;if(a.lt(Math.pow(2,32))){for(var n=a.toNumber(),i=5;i*i<=n;i+=6)if(n%i===0||n%(i+2)===0)return!1;return!0}function c(N,d,y){for(var x=1;!d.eq(0);)d.mod(2).eq(0)?(d=d.div(2),N=N.mul(N).mod(y)):(d=d.sub(1),x=N.mul(x).mod(y));return x}var m=a.constructor.clone({precision:a.toFixed(0).length*2});a=new m(a);for(var f=0,l=a.sub(1);l.mod(2).eq(0);)l=l.div(2),f+=1;var s=null;if(a.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<a);else{var o=Math.min(a.toNumber()-2,Math.floor(2*Math.pow(a.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=c(a.sub(a).add(v),l,a);if(!h.eq(1)){for(var b=0,w=h;!w.eq(a.sub(1));b+=1,w=w.mul(w).mod(a))if(b===f-1)return!1}}return!0},"Array | Matrix":function(a){return $e(a,this)}})}),tw="numeric",nw=["number","?bignumber","?fraction"],aw=q(tw,nw,r=>{var{number:e,bignumber:t,fraction:a}=r,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:c=>e(c),BigNumber:t?c=>t(c):Mo,Fraction:a?c=>a(c):Jl};return function(m,f){var l=cr(m);if(!(l in n))throw new TypeError("Cannot convert "+m+' of type "'+l+'"; valid input types are '+Object.keys(n).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+m+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===l?m:i[f](m)}}),Nf="divideScalar",iw=["typed","numeric"],ow=q(Nf,iw,r=>{var{typed:e,numeric:t}=r;return e(Nf,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Fraction | BigNumber":function(n,i){var c=n.clone(),m=t(1,cr(i));return c.value=this(c.value===null?c._normalize(m):c.value,i),c},"number | Fraction | BigNumber, Unit":function(n,i){var c=i.clone();c=c.pow(-1);var m=t(1,cr(n));return c.value=this(n,i.value===null?i._normalize(m):i.value),c},"Unit, Unit":function(n,i){return n.divide(i)}})}),Mf="pow",sw=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],uw=q(Mf,sw,r=>{var{typed:e,config:t,identity:a,multiply:n,matrix:i,inv:c,number:m,fraction:f,Complex:l}=r;return e(Mf,{"number, number":s,"Complex, Complex":function(v,h){return v.pow(h)},"BigNumber, BigNumber":function(v,h){return h.isInteger()||v>=0||t.predictable?v.pow(h):new l(v.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(v,h){var b=v.pow(h);if(b!=null)return b;if(t.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(t.predictable&&!Be(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{}return t.predictable&&(p<-1&&v===1/0||p>-1&&p<0&&v===-1/0)?NaN:Be(v)||p>=0||t.predictable?ju(p,v):p*p<1&&v===1/0||p*p>1&&v===-1/0?0:new l(p,0).pow(v,0)}function o(p,v){if(!Be(v))throw new TypeError("For A^b, b must be an integer (value is "+v+")");var h=Je(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(c(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=a(h[0]).valueOf(),w=p;v>=1;)(v&1)===1&&(b=n(w,b)),v>>=1,w=n(w,w);return b}function u(p,v){return i(o(p.valueOf(),v))}}),Vn="Number of decimals in function round must be an integer",Af="round",cw=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],lw=q(Af,cw,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,BigNumber:i,DenseMatrix:c}=r,m=_r({typed:e,equalScalar:a}),f=$r({typed:e,DenseMatrix:c}),l=rr({typed:e});return e(Af,{number:Ku,"number, number":Ku,"number, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(Vn);return new i(o).toDecimalPlaces(u.toNumber())},Complex:function(o){return o.round()},"Complex, number":function(o,u){if(u%1)throw new TypeError(Vn);return o.round(u)},"Complex, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(Vn);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(Vn);return o.toDecimalPlaces(u.toNumber())},Fraction:function(o){return o.round()},"Fraction, number":function(o,u){if(u%1)throw new TypeError(Vn);return o.round(u)},"Fraction, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(Vn);return o.round(u.toNumber())},"Array | Matrix":function(o){return $e(o,this)},"SparseMatrix, number | BigNumber":function(o,u){return m(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return l(o,u,this,!1)},"Array, number | BigNumber":function(o,u){return l(t(o),u,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(o,u){return a(o,0)?n(u.size(),u.storage()):f(u,o,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(o,u){return a(o,0)?n(u.size(),u.storage()):l(u,o,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(o,u){return l(t(u),o,this,!0).valueOf()}})}),Sf="log",fw=["config","typed","divideScalar","Complex"],mw=q(Sf,fw,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r;return e(Sf,{number:function(c){return c>=0||t.predictable?by(c):new n(c,0).log()},Complex:function(c){return c.log()},BigNumber:function(c){return!c.isNegative()||t.predictable?c.ln():new n(c.toNumber(),0).log()},"Array | Matrix":function(c){return $e(c,this)},"any, any":function(c,m){return a(this(c),this(m))}})}),Ef="log1p",pw=["typed","config","divideScalar","log","Complex"],vw=q(Ef,pw,r=>{var{typed:e,config:t,divideScalar:a,log:n,Complex:i}=r;return e(Ef,{number:function(f){return f>=-1||t.predictable?Md(f):c(new i(f,0))},Complex:c,BigNumber:function(f){var l=f.plus(1);return!l.isNegative()||t.predictable?l.ln():c(new i(f.toNumber(),0))},"Array | Matrix":function(f){return $e(f,this)},"any, any":function(f,l){return a(this(f),n(l))}});function c(m){var f=m.re+1;return new i(Math.log(Math.sqrt(f*f+m.im*m.im)),Math.atan2(m.im,f))}}),Cf="nthRoots",hw=["config","typed","divideScalar","Complex"],dw=q(Cf,hw,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r,i=[function(f){return new n(f,0)},function(f){return new n(0,f)},function(f){return new n(-f,0)},function(f){return new n(0,-f)}];function c(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 n(0,0)];var l=typeof m=="number",s;(l||m.re===0||m.im===0)&&(l?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 n({r:v,phi:(o+2*Math.PI*h)/f}))}return p}return e(Cf,{Complex:function(f){return c(f,2)},"Complex, number":c})}),Of="dotPow",gw=["typed","equalScalar","matrix","pow","DenseMatrix"],yw=q(Of,gw,r=>{var{typed:e,equalScalar:t,matrix:a,pow:n,DenseMatrix:i}=r,c=Lr({typed:e}),m=wt({typed:e,DenseMatrix:i}),f=_r({typed:e,equalScalar:t}),l=$r({typed:e,DenseMatrix:i}),s=lr({typed:e}),o=rr({typed:e});return e(Of,{"any, any":n,"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,n,!1)},"SparseMatrix, DenseMatrix":function(p,v){return c(v,p,n,!0)},"DenseMatrix, SparseMatrix":function(p,v){return c(p,v,n,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,n)},"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 l(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()}})}),$f="dotDivide",bw=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],xw=q($f,bw,r=>{var{typed:e,matrix:t,equalScalar:a,divideScalar:n,DenseMatrix:i}=r,c=pt({typed:e,equalScalar:a}),m=Lr({typed:e}),f=wt({typed:e,DenseMatrix:i}),l=_r({typed:e,equalScalar:a}),s=$r({typed:e,DenseMatrix:i}),o=lr({typed:e}),u=rr({typed:e});return e($f,{"any, any":n,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,n,!1)},"SparseMatrix, DenseMatrix":function(v,h){return c(h,v,n,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,n,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,n)},"Array, Array":function(v,h){return this(t(v),t(h)).valueOf()},"Array, Matrix":function(v,h){return this(t(v),h)},"Matrix, Array":function(v,h){return this(v,t(h))},"SparseMatrix, any":function(v,h){return l(v,h,n,!1)},"DenseMatrix, any":function(v,h){return u(v,h,n,!1)},"any, SparseMatrix":function(v,h){return s(h,v,n,!0)},"any, DenseMatrix":function(v,h){return u(h,v,n,!0)},"Array, any":function(v,h){return u(t(v),h,n,!1).valueOf()},"any, Array":function(v,h){return u(t(h),v,n,!0).valueOf()}})});function xa(r){var{DenseMatrix:e}=r;return function(a,n,i){var c=a.size();if(c.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Ge(c)+")");var m=c[0],f=c[1];if(m!==f)throw new RangeError("Matrix must be square (size: "+Ge(c)+")");var l=[];if(Fe(n)){var s=n.size(),o=n._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++)l[u]=[o[u]];return new e({data:l,size:[m,1],datatype:n._datatype})}if(s.length===2){if(s[0]!==m||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(Va(n)){if(i){l=[];for(var p=0;p<m;p++)l[p]=[o[p][0]];return new e({data:l,size:[m,1],datatype:n._datatype})}return n}if(un(n)){for(var v=0;v<m;v++)l[v]=[0];for(var h=n._values,b=n._index,w=n._ptr,N=w[1],d=w[0];d<N;d++){var y=b[d];l[y][0]=h[d]}return new e({data:l,size:[m,1],datatype:n._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(ar(n)){var x=Je(n);if(x.length===1){if(x[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var g=0;g<m;g++)l[g]=[n[g]];return new e({data:l,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 S=0;S<m;S++)l[S]=[n[S][0]];return new e({data:l,size:[m,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Tf="lsolve",ww=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],Nw=q(Tf,ww,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:c,DenseMatrix:m}=r,f=xa({DenseMatrix:m});return e(Tf,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return l(u,p)},"Array, Array | Matrix":function(u,p){var v=t(u),h=l(v,p);return h.valueOf()}});function l(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 d=p[N][0]||0,y=void 0;if(c(d,0))y=0;else{var x=w[N][N];if(c(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=a(d,x);for(var g=N+1;g<v;g++)p[g]=[i(p[g][0]||0,n(y,w[g][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,d=[],y=0;y<h;y++){var x=p[y][0]||0;if(c(x,0))d[y]=[0];else{for(var g=0,S=[],A=[],E=N[y],M=N[y+1],B=E;B<M;B++){var C=w[B];C===y?g=b[B]:C>y&&(S.push(b[B]),A.push(C))}if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,g),P=0,I=A.length;P<I;P++){var T=A[P];p[T]=[i(p[T][0]||0,n(_,S[P]))]}d[y]=[_]}}return new m({data:d,size:[v,1]})}}),Df="usolve",Mw=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],Aw=q(Df,Mw,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:c,DenseMatrix:m}=r,f=xa({DenseMatrix:m});return e(Df,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return l(u,p)},"Array, Array | Matrix":function(u,p){var v=t(u),h=l(v,p);return h.valueOf()}});function l(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 d=p[N][0]||0,y=void 0;if(c(d,0))y=0;else{var x=w[N][N];if(c(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=a(d,x);for(var g=N-1;g>=0;g--)p[g]=[i(p[g][0]||0,n(y,w[g][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,d=[],y=h-1;y>=0;y--){var x=p[y][0]||0;if(c(x,0))d[y]=[0];else{for(var g=0,S=[],A=[],E=N[y],M=N[y+1],B=M-1;B>=E;B--){var C=w[B];C===y?g=b[B]:C<y&&(S.push(b[B]),A.push(C))}if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,g),P=0,I=A.length;P<I;P++){var T=A[P];p[T]=[i(p[T][0],n(_,S[P]))]}d[y]=[_]}}return new m({data:d,size:[v,1]})}}),Bf="lsolveAll",Sw=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],Ew=q(Bf,Sw,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:c,DenseMatrix:m}=r,f=xa({DenseMatrix:m});return e(Bf,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return l(u,p)},"Array, Array | Matrix":function(u,p){var v=t(u),h=l(v,p);return h.map(b=>b.valueOf())}});function l(o,u){for(var p=[f(o,u,!0)._data.map(A=>A[0])],v=o._data,h=o._size[0],b=o._size[1],w=0;w<b;w++)for(var N=p.length,d=0;d<N;d++){var y=p[d];if(c(v[w][w],0))if(c(y[w],0)){if(d===0){var g=[...y];g[w]=1;for(var S=w+1;S<b;S++)g[S]=i(g[S],v[S][w]);p.push(g)}}else{if(d===0)return[];p.splice(d,1),d-=1,N-=1}else{y[w]=a(y[w],v[w][w]);for(var x=w+1;x<b;x++)y[x]=i(y[x],n(y[w],v[x][w]))}}return p.map(A=>new m({data:A.map(E=>[E]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(Q=>Q[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,d=0;d<h;d++)for(var y=p.length,x=0;x<y;x++){for(var g=p[x],S=[],A=[],E=N[d],M=N[d+1],B=0,C=E;C<M;C++){var _=w[C];_===d?B=b[C]:_>d&&(S.push(b[C]),A.push(_))}if(c(B,0))if(c(g[d],0)){if(x===0){var D=[...g];D[d]=1;for(var Z=0,$=A.length;Z<$;Z++){var H=A[Z];D[H]=i(D[H],S[Z])}p.push(D)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{g[d]=a(g[d],B);for(var P=0,I=A.length;P<I;P++){var T=A[P];g[T]=i(g[T],n(g[d],S[P]))}}}return p.map(Q=>new m({data:Q.map(te=>[te]),size:[v,1]}))}}),_f="usolveAll",Cw=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],Ow=q(_f,Cw,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:c,DenseMatrix:m}=r,f=xa({DenseMatrix:m});return e(_f,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return l(u,p)},"Array, Array | Matrix":function(u,p){var v=t(u),h=l(v,p);return h.map(b=>b.valueOf())}});function l(o,u){for(var p=[f(o,u,!0)._data.map(A=>A[0])],v=o._data,h=o._size[0],b=o._size[1],w=b-1;w>=0;w--)for(var N=p.length,d=0;d<N;d++){var y=p[d];if(c(v[w][w],0))if(c(y[w],0)){if(d===0){var g=[...y];g[w]=1;for(var S=w-1;S>=0;S--)g[S]=i(g[S],v[S][w]);p.push(g)}}else{if(d===0)return[];p.splice(d,1),d-=1,N-=1}else{y[w]=a(y[w],v[w][w]);for(var x=w-1;x>=0;x--)y[x]=i(y[x],n(y[w],v[x][w]))}}return p.map(A=>new m({data:A.map(E=>[E]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(Q=>Q[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,d=h-1;d>=0;d--)for(var y=p.length,x=0;x<y;x++){for(var g=p[x],S=[],A=[],E=N[d],M=N[d+1],B=0,C=M-1;C>=E;C--){var _=w[C];_===d?B=b[C]:_<d&&(S.push(b[C]),A.push(_))}if(c(B,0))if(c(g[d],0)){if(x===0){var D=[...g];D[d]=1;for(var Z=0,$=A.length;Z<$;Z++){var H=A[Z];D[H]=i(D[H],S[Z])}p.push(D)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{g[d]=a(g[d],B);for(var P=0,I=A.length;P<I;P++){var T=A[P];g[T]=i(g[T],n(g[d],S[P]))}}}return p.map(Q=>new m({data:Q.map(te=>[te]),size:[v,1]}))}}),$w="algorithm08",Tw=["typed","equalScalar"],Ao=q($w,Tw,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,c){var m=n._values,f=n._index,l=n._ptr,s=n._size,o=n._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new He(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],d,y=t,x=0,g=c;typeof o=="string"&&o===b&&(d=o,y=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(c,[d,d]));for(var S=[],A=[],E=[],M=[],B=[],C,_,P,I,T=0;T<N;T++){E[T]=A.length;var D=T+1;for(_=l[T],P=l[T+1],C=_;C<P;C++)I=f[C],B[I]=D,M[I]=m[C],A.push(I);for(_=v[T],P=v[T+1],C=_;C<P;C++)I=p[C],B[I]===D&&(M[I]=g(M[I],u[C]));for(C=E[T];C<A.length;){I=A[C];var Z=M[I];y(Z,x)?A.splice(C,1):(S.push(Z),C++)}}return E[N]=A.length,n.createSparseMatrix({values:S,index:A,ptr:E,size:[w,N],datatype:d})}}),If="leftShift",Dw=["typed","matrix","equalScalar","zeros","DenseMatrix"],Bw=q(If,Dw,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,c=jt({typed:e}),m=pt({typed:e,equalScalar:a}),f=Ao({typed:e,equalScalar:a}),l=pn({typed:e,DenseMatrix:i}),s=_r({typed:e,equalScalar:a}),o=lr({typed:e}),u=rr({typed:e});return e(If,{"number, number":ac,"BigNumber, BigNumber":eb,"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 c(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(t(v),t(h)).valueOf()},"Array, Matrix":function(v,h){return this(t(v),h)},"Matrix, Array":function(v,h){return this(v,t(h))},"SparseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return a(v,0)?n(h.size(),h.storage()):l(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return a(v,0)?n(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(t(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,t(h)).valueOf()}})}),Rf="rightArithShift",_w=["typed","matrix","equalScalar","zeros","DenseMatrix"],Iw=q(Rf,_w,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,c=jt({typed:e}),m=pt({typed:e,equalScalar:a}),f=Ao({typed:e,equalScalar:a}),l=pn({typed:e,DenseMatrix:i}),s=_r({typed:e,equalScalar:a}),o=lr({typed:e}),u=rr({typed:e});return e(Rf,{"number, number":ic,"BigNumber, BigNumber":rb,"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 c(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(t(v),t(h)).valueOf()},"Array, Matrix":function(v,h){return this(t(v),h)},"Matrix, Array":function(v,h){return this(v,t(h))},"SparseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return a(v,0)?n(h.size(),h.storage()):l(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return a(v,0)?n(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(t(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,t(h)).valueOf()}})}),Ff="rightLogShift",Rw=["typed","matrix","equalScalar","zeros","DenseMatrix"],Fw=q(Ff,Rw,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,c=jt({typed:e}),m=pt({typed:e,equalScalar:a}),f=Ao({typed:e,equalScalar:a}),l=pn({typed:e,DenseMatrix:i}),s=_r({typed:e,equalScalar:a}),o=lr({typed:e}),u=rr({typed:e});return e(Ff,{"number, number":oc,"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 c(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(t(v),t(h)).valueOf()},"Array, Matrix":function(v,h){return this(t(v),h)},"Matrix, Array":function(v,h){return this(v,t(h))},"SparseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return a(v,0)?n(h.size(),h.storage()):l(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return a(v,0)?n(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(t(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,t(h)).valueOf()}})}),qf="and",qw=["typed","matrix","equalScalar","zeros","not"],zw=q(qf,qw,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,not:i}=r,c=pt({typed:e,equalScalar:a}),m=vi({typed:e,equalScalar:a}),f=_r({typed:e,equalScalar:a}),l=lr({typed:e}),s=rr({typed:e});return e(qf,{"number, number":fc,"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 c(p,u,this,!0)},"DenseMatrix, SparseMatrix":function(u,p){return c(u,p,this,!1)},"DenseMatrix, DenseMatrix":function(u,p){return l(u,p,this)},"Array, Array":function(u,p){return this(t(u),t(p)).valueOf()},"Array, Matrix":function(u,p){return this(t(u),p)},"Matrix, Array":function(u,p){return this(u,t(p))},"SparseMatrix, any":function(u,p){return i(p)?n(u.size(),u.storage()):f(u,p,this,!1)},"DenseMatrix, any":function(u,p){return i(p)?n(u.size(),u.storage()):s(u,p,this,!1)},"any, SparseMatrix":function(u,p){return i(u)?n(u.size(),u.storage()):f(p,u,this,!0)},"any, DenseMatrix":function(u,p){return i(u)?n(u.size(),u.storage()):s(p,u,this,!0)},"Array, any":function(u,p){return this(t(u),p).valueOf()},"any, Array":function(u,p){return this(u,t(p)).valueOf()}})}),zf="compare",Pw=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],Uw=q(zf,Pw,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,BigNumber:i,Fraction:c,DenseMatrix:m}=r,f=Lr({typed:e}),l=hi({typed:e,equalScalar:a}),s=$r({typed:e,DenseMatrix:m}),o=lr({typed:e}),u=rr({typed:e});return e(zf,{"boolean, boolean":function(v,h){return v===h?0:v>h?1:-1},"number, number":function(v,h){return Yr(v,h,t.epsilon)?0:v>h?1:-1},"BigNumber, BigNumber":function(v,h){return xt(v,h,t.epsilon)?new i(0):new i(v.cmp(h))},"Fraction, Fraction":function(v,h){return new c(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 l(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(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(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(n(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(n(h),v,this,!0).valueOf()}})}),Gn=function r(e,t){var a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,n=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,c=/^0x[0-9a-f]+$/i,m=/^0/,f=function(d){return r.insensitive&&(""+d).toLowerCase()||""+d},l=f(e).replace(n,"")||"",s=f(t).replace(n,"")||"",o=l.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),u=s.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=parseInt(l.match(c),16)||o.length!==1&&l.match(i)&&Date.parse(l),v=parseInt(s.match(c),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},Pf="compareNatural",Lw=["typed","compare"],kw=q(Pf,Lw,r=>{var{typed:e,compare:t}=r,a=t.signatures["boolean,boolean"];return e(Pf,{"any, any":function(f,l){var s=cr(f),o=cr(l),u;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(o==="number"||o==="BigNumber"||o==="Fraction"))return u=t(f,l),u.toString()!=="0"?u>0?1:-1:Gn(s,o);if(s==="Array"||s==="Matrix"||o==="Array"||o==="Matrix")return u=n(this,f,l),u!==0?u:Gn(s,o);if(s!==o)return Gn(s,o);if(s==="Complex")return Vw(f,l);if(s==="Unit")return f.equalBase(l)?this(f.value,l.value):i(this,f.formatUnits(),l.formatUnits());if(s==="boolean")return a(f,l);if(s==="string")return Gn(f,l);if(s==="Object")return c(this,f,l);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}});function n(m,f,l){return un(f)&&un(l)?i(m,f.toJSON().values,l.toJSON().values):un(f)?n(m,f.toArray(),l):un(l)?n(m,f,l.toArray()):Va(f)?n(m,f.toJSON().data,l):Va(l)?n(m,f,l.toJSON().data):Array.isArray(f)?Array.isArray(l)?i(m,f,l):n(m,f,[l]):n(m,[f],l)}function i(m,f,l){for(var s=0,o=Math.min(f.length,l.length);s<o;s++){var u=m(f[s],l[s]);if(u!==0)return u}return f.length>l.length?1:f.length<l.length?-1:0}function c(m,f,l){var s=Object.keys(f),o=Object.keys(l);s.sort(Gn),o.sort(Gn);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]],l[o[p]]);if(v!==0)return v}return 0}});function Vw(r,e){return r.re>e.re?1:r.re<e.re?-1:r.im>e.im?1:r.im<e.im?-1:0}var Uf="compareText",Gw=["typed","matrix"],Hw=q(Uf,Gw,r=>{var{typed:e,matrix:t}=r,a=lr({typed:e}),n=rr({typed:e});return e(Uf,{"any, any":Tn,"DenseMatrix, DenseMatrix":function(c,m){return a(c,m,Tn)},"Array, Array":function(c,m){return this(t(c),t(m)).valueOf()},"Array, Matrix":function(c,m){return this(t(c),m)},"Matrix, Array":function(c,m){return this(c,t(m))},"DenseMatrix, any":function(c,m){return n(c,m,Tn,!1)},"any, DenseMatrix":function(c,m){return n(m,c,Tn,!0)},"Array, any":function(c,m){return n(t(c),m,Tn,!1).valueOf()},"any, Array":function(c,m){return n(t(m),c,Tn,!0).valueOf()}})}),yi="equal",Zw=["typed","matrix","equalScalar","DenseMatrix"],Jw=q(yi,Zw,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=Lr({typed:e}),c=wt({typed:e,DenseMatrix:n}),m=$r({typed:e,DenseMatrix:n}),f=lr({typed:e}),l=rr({typed:e});return e(yi,{"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:a(o,u)},"SparseMatrix, SparseMatrix":function(o,u){return c(o,u,a)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,a,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,a,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,a)},"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,a,!1)},"DenseMatrix, any":function(o,u){return l(o,u,a,!1)},"any, SparseMatrix":function(o,u){return m(u,o,a,!0)},"any, DenseMatrix":function(o,u){return l(u,o,a,!0)},"Array, any":function(o,u){return l(t(o),u,a,!1).valueOf()},"any, Array":function(o,u){return l(t(u),o,a,!0).valueOf()}})});q(yi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(yi,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:t(n,i)}})});var Lf="equalText",Ww=["typed","compareText","isZero"],Xw=q(Lf,Ww,r=>{var{typed:e,compareText:t,isZero:a}=r;return e(Lf,{"any, any":function(i,c){return a(t(i,c))}})}),kf="smaller",Yw=["typed","config","matrix","DenseMatrix"],Qw=q(kf,Yw,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Lr({typed:e}),c=wt({typed:e,DenseMatrix:n}),m=$r({typed:e,DenseMatrix:n}),f=lr({typed:e}),l=rr({typed:e});return e(kf,{"boolean, boolean":function(o,u){return o<u},"number, number":function(o,u){return o<u&&!Yr(o,u,t.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lt(u)&&!xt(o,u,t.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 c(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 l(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return l(u,o,this,!0)},"Array, any":function(o,u){return l(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return l(a(u),o,this,!0).valueOf()}})}),Vf="smallerEq",jw=["typed","config","matrix","DenseMatrix"],Kw=q(Vf,jw,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Lr({typed:e}),c=wt({typed:e,DenseMatrix:n}),m=$r({typed:e,DenseMatrix:n}),f=lr({typed:e}),l=rr({typed:e});return e(Vf,{"boolean, boolean":function(o,u){return o<=u},"number, number":function(o,u){return o<=u||Yr(o,u,t.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lte(u)||xt(o,u,t.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 c(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 l(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return l(u,o,this,!0)},"Array, any":function(o,u){return l(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return l(a(u),o,this,!0).valueOf()}})}),Gf="larger",eN=["typed","config","matrix","DenseMatrix"],rN=q(Gf,eN,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Lr({typed:e}),c=wt({typed:e,DenseMatrix:n}),m=$r({typed:e,DenseMatrix:n}),f=lr({typed:e}),l=rr({typed:e});return e(Gf,{"boolean, boolean":function(o,u){return o>u},"number, number":function(o,u){return o>u&&!Yr(o,u,t.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gt(u)&&!xt(o,u,t.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 c(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 l(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return l(u,o,this,!0)},"Array, any":function(o,u){return l(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return l(a(u),o,this,!0).valueOf()}})}),Hf="largerEq",tN=["typed","config","matrix","DenseMatrix"],nN=q(Hf,tN,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Lr({typed:e}),c=wt({typed:e,DenseMatrix:n}),m=$r({typed:e,DenseMatrix:n}),f=lr({typed:e}),l=rr({typed:e});return e(Hf,{"boolean, boolean":function(o,u){return o>=u},"number, number":function(o,u){return o>=u||Yr(o,u,t.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gte(u)||xt(o,u,t.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 c(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 l(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return l(u,o,this,!0)},"Array, any":function(o,u){return l(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return l(a(u),o,this,!0).valueOf()}})}),Zf="deepEqual",aN=["typed","equal"],iN=q(Zf,aN,r=>{var{typed:e,equal:t}=r;return e(Zf,{"any, any":function(i,c){return a(i.valueOf(),c.valueOf())}});function a(n,i){if(Array.isArray(n))if(Array.isArray(i)){var c=n.length;if(c!==i.length)return!1;for(var m=0;m<c;m++)if(!a(n[m],i[m]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),So="unequal",oN=["typed","config","equalScalar","matrix","DenseMatrix"],sN=q(So,oN,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,DenseMatrix:i}=r,c=Lr({typed:e}),m=wt({typed:e,DenseMatrix:i}),f=$r({typed:e,DenseMatrix:i}),l=lr({typed:e}),s=rr({typed:e});return e("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 c(v,p,o,!0)},"DenseMatrix, SparseMatrix":function(p,v){return c(p,v,o,!1)},"DenseMatrix, DenseMatrix":function(p,v){return l(p,v,o)},"Array, Array":function(p,v){return this(n(p),n(v)).valueOf()},"Array, Matrix":function(p,v){return this(n(p),v)},"Matrix, Array":function(p,v){return this(p,n(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(n(p),v,o,!1).valueOf()},"any, Array":function(p,v){return s(n(v),p,o,!0).valueOf()}});function o(u,p){return!a(u,p)}});q(So,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(So,{"any, any":function(n,i){return n===null?i!==null:i===null?n!==null:n===void 0?i!==void 0:i===void 0?n!==void 0:!t(n,i)}})});var Jf="partitionSelect",uN=["typed","isNumeric","isNaN","compare"],cN=q(Jf,uN,r=>{var{typed:e,isNumeric:t,isNaN:a,compare:n}=r,i=n,c=(l,s)=>-n(l,s);return e(Jf,{"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,c);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":m});function m(l,s,o){if(!Be(s)||s<0)throw new Error("k must be a non-negative integer");if(Fe(l)){var u=l.size();if(u.length>1)throw new Error("Only one dimensional matrices supported");return f(l.valueOf(),s,o)}if(Array.isArray(l))return f(l,s,o)}function f(l,s,o){if(s>=l.length)throw new Error("k out of bounds");for(var u=0;u<l.length;u++)if(t(l[u])&&a(l[u]))return l[u];for(var p=0,v=l.length-1;p<v;){for(var h=p,b=v,w=l[Math.floor(Math.random()*(v-p+1))+p];h<b;)if(o(l[h],w)>=0){var N=l[b];l[b]=l[h],l[h]=N,--b}else++h;o(l[h],w)>0&&--h,s<=h?v=h:p=h+1}return l[s]}}),Wf="sort",lN=["typed","matrix","compare","compareNatural"],fN=q(Wf,lN,r=>{var{typed:e,matrix:t,compare:a,compareNatural:n}=r,i=a,c=(s,o)=>-a(s,o);return e(Wf,{Array:function(o){return f(o),o.sort(i)},Matrix:function(o){return l(o),t(o.toArray().sort(i),o.storage())},"Array, function":function(o,u){return f(o),o.sort(u)},"Matrix, function":function(o,u){return l(o),t(o.toArray().sort(u),o.storage())},"Array, string":function(o,u){return f(o),o.sort(m(u))},"Matrix, string":function(o,u){return l(o),t(o.toArray().sort(m(u)),o.storage())}});function m(s){if(s==="asc")return i;if(s==="desc")return c;if(s==="natural")return n;throw new Error('String "asc", "desc", or "natural" expected')}function f(s){if(Je(s).length!==1)throw new Error("One dimensional array expected")}function l(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),Xf="max",mN=["typed","config","numeric","larger"],Yf=q(Xf,mN,r=>{var{typed:e,config:t,numeric:a,larger:n}=r;return e(Xf,{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(f,l){return ui(f,l.valueOf(),i)},"...":function(f){if(qn(f))throw new TypeError("Scalar values expected in function max");return c(f)}});function i(m,f){try{return n(m,f)?m:f}catch(l){throw kr(l,"max",f)}}function c(m){var f;if(Rt(m,function(l){try{isNaN(l)&&typeof l=="number"?f=NaN:(f===void 0||n(l,f))&&(f=l)}catch(s){throw kr(s,"max",l)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=a(f,t.number)),f}}),Qf="min",pN=["typed","config","numeric","smaller"],jf=q(Qf,pN,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r;return e(Qf,{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(f,l){return ui(f,l.valueOf(),i)},"...":function(f){if(qn(f))throw new TypeError("Scalar values expected in function min");return c(f)}});function i(m,f){try{return n(m,f)?m:f}catch(l){throw kr(l,"min",f)}}function c(m){var f;if(Rt(m,function(l){try{isNaN(l)&&typeof l=="number"?f=NaN:(f===void 0||n(l,f))&&(f=l)}catch(s){throw kr(s,"min",l)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=a(f,t.number)),f}}),vN="ImmutableDenseMatrix",hN=["smaller","DenseMatrix"],dN=q(vN,hN,r=>{var{smaller:e,DenseMatrix:t}=r;function a(n,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!Zr(i))throw new Error("Invalid datatype: "+i);if(Fe(n)||ar(n)){var c=new t(n,i);this._data=c._data,this._size=c._size,this._datatype=c._datatype,this._min=null,this._max=null}else if(n&&ar(n.data)&&ar(n.size))this._data=n.data,this._size=n.size,this._datatype=n.datatype,this._min=typeof n.min<"u"?n.min:null,this._max=typeof n.max<"u"?n.max:null;else{if(n)throw new TypeError("Unsupported type of data ("+cr(n)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return a.prototype=new t,a.prototype.type="ImmutableDenseMatrix",a.prototype.isImmutableDenseMatrix=!0,a.prototype.subset=function(n){switch(arguments.length){case 1:{var i=t.prototype.subset.call(this,n);return Fe(i)?new a({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")}},a.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},a.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},a.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},a.prototype.clone=function(){return new a({data:Re(this._data),size:Re(this._size),datatype:this._datatype})},a.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.fromJSON=function(n){return new a(n)},a.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},a.prototype.min=function(){if(this._min===null){var n=null;this.forEach(function(i){(n===null||e(i,n))&&(n=i)}),this._min=n!==null?n:void 0}return this._min},a.prototype.max=function(){if(this._max===null){var n=null;this.forEach(function(i){(n===null||e(n,i))&&(n=i)}),this._max=n!==null?n:void 0}return this._max},a},{isClass:!0}),gN="Index",yN=["ImmutableDenseMatrix"],bN=q(gN,yN,r=>{var{ImmutableDenseMatrix:e}=r;function t(n){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,c=arguments.length;i<c;i++){var m=arguments[i];if(Ga(m))this._dimensions.push(m),this._isScalar=!1;else if(Array.isArray(m)||Fe(m)){var f=a(m.valueOf());this._dimensions.push(f);var l=f.size();(l.length!==1||l[0]!==1)&&(this._isScalar=!1)}else if(typeof m=="number")this._dimensions.push(a([m]));else if(typeof m=="string")this._dimensions.push(m);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}t.prototype.type="Index",t.prototype.isIndex=!0;function a(n){for(var i=0,c=n.length;i<c;i++)if(typeof n[i]!="number"||!Be(n[i]))throw new TypeError("Index parameters must be positive integer numbers");return new e(n)}return t.prototype.clone=function(){var n=new t;return n._dimensions=Re(this._dimensions),n._isScalar=this._isScalar,n},t.create=function(n){var i=new t;return t.apply(i,n),i},t.prototype.size=function(){for(var n=[],i=0,c=this._dimensions.length;i<c;i++){var m=this._dimensions[i];n[i]=typeof m=="string"?1:m.size()[0]}return n},t.prototype.max=function(){for(var n=[],i=0,c=this._dimensions.length;i<c;i++){var m=this._dimensions[i];n[i]=typeof m=="string"?m:m.max()}return n},t.prototype.min=function(){for(var n=[],i=0,c=this._dimensions.length;i<c;i++){var m=this._dimensions[i];n[i]=typeof m=="string"?m:m.min()}return n},t.prototype.forEach=function(n){for(var i=0,c=this._dimensions.length;i<c;i++)n(this._dimensions[i],i,this)},t.prototype.dimension=function(n){return this._dimensions[n]||null},t.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},t.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},t.prototype.isScalar=function(){return this._isScalar},t.prototype.toArray=function(){for(var n=[],i=0,c=this._dimensions.length;i<c;i++){var m=this._dimensions[i];n.push(typeof m=="string"?m:m.toArray())}return n},t.prototype.valueOf=t.prototype.toArray,t.prototype.toString=function(){for(var n=[],i=0,c=this._dimensions.length;i<c;i++){var m=this._dimensions[i];typeof m=="string"?n.push(JSON.stringify(m)):n.push(m.toString())}return"["+n.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},t.fromJSON=function(n){return t.create(n.dimensions)},t},{isClass:!0}),xN="FibonacciHeap",wN=["smaller","larger"],NN=q(xN,wN,r=>{var{smaller:e,larger:t}=r,a=1/Math.log((1+Math.sqrt(5))/2);function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}n.prototype.type="FibonacciHeap",n.prototype.isFibonacciHeap=!0,n.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,e(s,p.key)&&(this._minimum=u)}else u.left=u,u.right=u,this._minimum=u;return this._size++,u},n.prototype.size=function(){return this._size},n.prototype.clear=function(){this._minimum=null,this._size=0},n.prototype.isEmpty=function(){return this._size===0},n.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=l(o,this._size)),this._size--,this._minimum=o,s},n.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&&e(o.key,p.key)&&(c(s,o,p),m(s,p)),e(o.key,s.key)&&(s=o),s}function c(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?(c(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 l(s,o){var u=Math.floor(Math.log(o)*a)+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(t(h.key,b.key)){var d=b;b=h,h=d}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,e(b.key,s.key)&&(s=b)):s=b);return s}return n},{isClass:!0}),MN="Spa",AN=["addScalar","equalScalar","FibonacciHeap"],SN=q(MN,AN,r=>{var{addScalar:e,equalScalar:t,FibonacciHeap:a}=r;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new a}return n.prototype.type="Spa",n.prototype.isSpa=!0,n.prototype.set=function(i,c){if(this._values[i])this._values[i].value=c;else{var m=this._heap.insert(i,c);this._values[i]=m}},n.prototype.get=function(i){var c=this._values[i];return c?c.value:0},n.prototype.accumulate=function(i,c){var m=this._values[i];m?m.value=e(m.value,c):(m=this._heap.insert(i,c),this._values[i]=m)},n.prototype.forEach=function(i,c,m){var f=this._heap,l=this._values,s=[],o=f.extractMinimum();for(o&&s.push(o);o&&o.key<=c;)o.key>=i&&(t(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),l[o.key]=o}},n.prototype.swap=function(i,c){var m=this._values[i],f=this._values[c];if(!m&&f)m=this._heap.insert(i,f.value),this._heap.remove(f),this._values[i]=m,this._values[c]=void 0;else if(m&&!f)f=this._heap.insert(c,m.value),this._heap.remove(m),this._values[c]=f,this._values[i]=void 0;else if(m&&f){var l=m.value;m.value=f.value,f.value=l}},n},{isClass:!0});function Kf(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var EN=ba(function(r){return new r(1).exp()},{hasher:bi}),CN=ba(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:bi}),Eo=ba(function(r){return r.acos(-1)},{hasher:bi}),ON=ba(function(r){return Eo(r).times(2)},{hasher:bi});function bi(r){return r[0].precision}function em(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function Co(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?em(Object(t),!0).forEach(function(a){Kf(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):em(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var $N="Unit",TN=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],DN=q($N,TN,r=>{var{on:e,config:t,addScalar:a,subtract:n,multiplyScalar:i,divideScalar:c,pow:m,abs:f,fix:l,round:s,equal:o,isNumeric:u,format:p,number:v,Complex:h,BigNumber:b,Fraction:w}=r,N=v;function d(z,Y){if(!(this instanceof d))throw new Error("Constructor must be called with the new operator");if(!(z==null||u(z)||Dt(z)))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 V=d.parse(Y);this.units=V.units,this.dimensions=V.dimensions}else{this.units=[{unit:te,prefix:D.NONE,power:0}],this.dimensions=[];for(var L=0;L<Z.length;L++)this.dimensions[L]=0}this.value=z!=null?this._normalize(z):null,this.fixPrefix=!1,this.skipAutomaticSimplification=!0}d.prototype.type="Unit",d.prototype.isUnit=!0;var y,x,g;function S(){for(;g===" "||g===" ";)M()}function A(z){return z>="0"&&z<="9"||z==="."}function E(z){return z>="0"&&z<="9"}function M(){x++,g=y.charAt(x)}function B(z){x=z,g=y.charAt(x)}function C(){var z="",Y=x;if(g==="+"?M():g==="-"&&(z+=g,M()),!A(g))return B(Y),null;if(g==="."){if(z+=g,M(),!E(g))return B(Y),null}else{for(;E(g);)z+=g,M();g==="."&&(z+=g,M())}for(;E(g);)z+=g,M();if(g==="E"||g==="e"){var V="",L=x;if(V+=g,M(),(g==="+"||g==="-")&&(V+=g,M()),!E(g))return B(L),z;for(z=z+V;E(g);)z+=g,M()}return z}function _(){for(var z="";E(g)||d.isValidAlpha(g);)z+=g,M();var Y=z.charAt(0);return d.isValidAlpha(Y)?z:null}function P(z){return g===z?(M(),z):null}d.parse=function(z,Y){if(Y=Y||{},y=z,x=-1,g="",typeof y!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var V=new d;V.units=[];var L=1,j=!1;M(),S();var F=C(),U=null;if(F){if(t.number==="BigNumber")U=new b(F);else if(t.number==="Fraction")try{U=new w(F)}catch{U=parseFloat(F)}else U=parseFloat(F);S(),P("*")?(L=1,j=!0):P("/")&&(L=-1,j=!0)}for(var ee=[],k=1;;){for(S();g==="(";)ee.push(L),k*=L,L=1,M(),S();var fe=void 0;if(g){var ve=g;if(fe=_(),fe===null)throw new SyntaxError('Unexpected "'+ve+'" in "'+y+'" at index '+x.toString())}else break;var Me=I(fe);if(Me===null)throw new SyntaxError('Unit "'+fe+'" not found.');var be=L*k;if(S(),P("^")){S();var xe=C();if(xe===null)throw new SyntaxError('In "'+z+'", "^" must be followed by a floating-point number');be*=xe}V.units.push({unit:Me.unit,prefix:Me.prefix,power:be});for(var Te=0;Te<Z.length;Te++)V.dimensions[Te]+=(Me.unit.dimensions[Te]||0)*be;for(S();g===")";){if(ee.length===0)throw new SyntaxError('Unmatched ")" in "'+y+'" at index '+x.toString());k/=ee.pop(),M(),S()}if(j=!1,P("*")?(L=1,j=!0):P("/")?(L=-1,j=!0):L=1,Me.unit.base){var nr=Me.unit.base.key;ae.auto[nr]={unit:Me.unit,prefix:Me.prefix}}}if(S(),g)throw new SyntaxError('Could not parse: "'+z+'"');if(j)throw new SyntaxError('Trailing characters: "'+z+'"');if(ee.length!==0)throw new SyntaxError('Unmatched "(" in "'+y+'"');if(V.units.length===0&&!Y.allowNoUnits)throw new SyntaxError('"'+z+'" contains no units');return V.value=U!==void 0?V._normalize(U):null,V},d.prototype.clone=function(){var z=new d;z.fixPrefix=this.fixPrefix,z.skipAutomaticSimplification=this.skipAutomaticSimplification,z.value=Re(this.value),z.dimensions=this.dimensions.slice(0),z.units=[];for(var Y=0;Y<this.units.length;Y++){z.units[Y]={};for(var V in this.units[Y])De(this.units[Y],V)&&(z.units[Y][V]=this.units[Y][V])}return z},d.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},d.prototype._normalize=function(z){if(z==null||this.units.length===0)return z;for(var Y=z,V=d._getNumberConverter(cr(z)),L=0;L<this.units.length;L++){var j=V(this.units[L].unit.value),F=V(this.units[L].prefix.value),U=V(this.units[L].power);Y=i(Y,m(i(j,F),U))}return Y},d.prototype._denormalize=function(z,Y){if(z==null||this.units.length===0)return z;for(var V=z,L=d._getNumberConverter(cr(z)),j=0;j<this.units.length;j++){var F=L(this.units[j].unit.value),U=L(this.units[j].prefix.value),ee=L(this.units[j].power);V=c(V,m(i(F,U),ee))}return V};var I=ba(z=>{if(De(J,z)){var Y=J[z],V=Y.prefixes[""];return{unit:Y,prefix:V}}for(var L in J)if(De(J,L)&&Ud(z,L)){var j=J[L],F=z.length-L.length,U=z.substring(0,F),ee=De(j.prefixes,U)?j.prefixes[U]:void 0;if(ee!==void 0)return{unit:j,prefix:ee}}return null},{hasher:z=>z[0],limit:100});d.isValuelessUnit=function(z){return I(z)!==null},d.prototype.hasBase=function(z){if(typeof z=="string"&&(z=$[z]),!z)return!1;for(var Y=0;Y<Z.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(z.dimensions[Y]||0))>1e-12)return!1;return!0},d.prototype.equalBase=function(z){for(var Y=0;Y<Z.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(z.dimensions[Y]||0))>1e-12)return!1;return!0},d.prototype.equals=function(z){return this.equalBase(z)&&o(this.value,z.value)},d.prototype.multiply=function(z){for(var Y=this.clone(),V=0;V<Z.length;V++)Y.dimensions[V]=(this.dimensions[V]||0)+(z.dimensions[V]||0);for(var L=0;L<z.units.length;L++){var j=Co({},z.units[L]);Y.units.push(j)}if(this.value!==null||z.value!==null){var F=this.value===null?this._normalize(1):this.value,U=z.value===null?z._normalize(1):z.value;Y.value=i(F,U)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},d.prototype.divide=function(z){for(var Y=this.clone(),V=0;V<Z.length;V++)Y.dimensions[V]=(this.dimensions[V]||0)-(z.dimensions[V]||0);for(var L=0;L<z.units.length;L++){var j=Co(Co({},z.units[L]),{},{power:-z.units[L].power});Y.units.push(j)}if(this.value!==null||z.value!==null){var F=this.value===null?this._normalize(1):this.value,U=z.value===null?z._normalize(1):z.value;Y.value=c(F,U)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},d.prototype.pow=function(z){for(var Y=this.clone(),V=0;V<Z.length;V++)Y.dimensions[V]=(this.dimensions[V]||0)*z;for(var L=0;L<Y.units.length;L++)Y.units[L].power*=z;return Y.value!==null?Y.value=m(Y.value,z):Y.value=null,Y.skipAutomaticSimplification=!1,T(Y)};function T(z){return z.equalBase($.NONE)&&z.value!==null&&!t.predictable?z.value:z}d.prototype.abs=function(){var z=this.clone();if(z.value!==null)if(z._isDerived()||z.units[0].unit.offset===0)z.value=f(z.value);else{var Y=d._getNumberConverter(cr(z.value)),V=Y(z.units[0].unit.value),L=Y(z.units[0].unit.offset),j=i(V,L);z.value=n(f(a(z.value,j)),j)}for(var F in z.units)(z.units[F].unit.name==="VA"||z.units[F].unit.name==="VAR")&&(z.units[F].unit=J.W);return z},d.prototype.to=function(z){var Y=this.value===null?this._normalize(1):this.value,V;if(typeof z=="string")V=d.parse(z);else if(la(z))V=z.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(V))throw new Error("Units do not match ('".concat(V.toString(),"' != '").concat(this.toString(),"')"));if(V.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===V.units[0].unit.offset)V.value=Re(Y);else{var L=d._getNumberConverter(cr(Y)),j=L(this.units[0].unit.value),F=L(this.units[0].unit.offset),U=i(j,F),ee=L(V.units[0].unit.value),k=L(V.units[0].unit.offset),fe=i(ee,k);V.value=n(a(Y,U),fe)}return V.fixPrefix=!0,V.skipAutomaticSimplification=!0,V},d.prototype.toNumber=function(z){return N(this.toNumeric(z))},d.prototype.toNumeric=function(z){var Y;return z?Y=this.to(z):Y=this.clone(),Y._isDerived()||Y.units.length===0?Y._denormalize(Y.value):Y._denormalize(Y.value,Y.units[0].prefix.value)},d.prototype.toString=function(){return this.format()},d.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},d.fromJSON=function(z){var Y=new d(z.value,z.unit);return Y.fixPrefix=z.fixPrefix||!1,Y},d.prototype.valueOf=d.prototype.toString,d.prototype.simplify=function(){var z=this.clone(),Y=[],V;for(var L in ce)if(De(ce,L)&&z.hasBase($[L])){V=L;break}if(V==="NONE")z.units=[];else{var j;if(V&&De(ce,V)&&(j=ce[V]),j)z.units=[{unit:j.unit,prefix:j.prefix,power:1}];else{for(var F=!1,U=0;U<Z.length;U++){var ee=Z[U];Math.abs(z.dimensions[U]||0)>1e-12&&(De(ce,ee)?Y.push({unit:ce[ee].unit,prefix:ce[ee].prefix,power:z.dimensions[U]||0}):F=!0)}Y.length<z.units.length&&!F&&(z.units=Y)}}return z},d.prototype.toSI=function(){for(var z=this.clone(),Y=[],V=0;V<Z.length;V++){var L=Z[V];if(Math.abs(z.dimensions[V]||0)>1e-12)if(De(ae.si,L))Y.push({unit:ae.si[L].unit,prefix:ae.si[L].prefix,power:z.dimensions[V]||0});else throw new Error("Cannot express custom unit "+L+" in SI units")}return z.units=Y,z.fixPrefix=!0,z.skipAutomaticSimplification=!0,z},d.prototype.formatUnits=function(){for(var z="",Y="",V=0,L=0,j=0;j<this.units.length;j++)this.units[j].power>0?(V++,z+=" "+this.units[j].prefix.name+this.units[j].unit.name,Math.abs(this.units[j].power-1)>1e-15&&(z+="^"+this.units[j].power)):this.units[j].power<0&&L++;if(L>0)for(var F=0;F<this.units.length;F++)this.units[F].power<0&&(V>0?(Y+=" "+this.units[F].prefix.name+this.units[F].unit.name,Math.abs(this.units[F].power+1)>1e-15&&(Y+="^"+-this.units[F].power)):(Y+=" "+this.units[F].prefix.name+this.units[F].unit.name,Y+="^"+this.units[F].power));z=z.substr(1),Y=Y.substr(1),V>1&&L>0&&(z="("+z+")"),L>1&&V>0&&(Y="("+Y+")");var U=z;return V>0&&L>0&&(U+=" / "),U+=Y,U},d.prototype.format=function(z){var Y=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),V=!1;typeof Y.value<"u"&&Y.value!==null&&Dt(Y.value)&&(V=Math.abs(Y.value.re)<1e-14);for(var L in Y.units)De(Y.units,L)&&Y.units[L].unit&&(Y.units[L].unit.name==="VA"&&V?Y.units[L].unit=J.VAR:Y.units[L].unit.name==="VAR"&&!V&&(Y.units[L].unit=J.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),F=Y.value!==null?p(j,z||{}):"",U=Y.formatUnits();return Y.value&&Dt(Y.value)&&(F="("+F+")"),U.length>0&&F.length>0&&(F+=" "),F+=U,F},d.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 z=this.value!==null?f(this.value):0,Y=f(this.units[0].unit.value),V=this.units[0].prefix;if(z===0)return V;var L=this.units[0].power,j=Math.log(z/Math.pow(V.value*Y,L))/Math.LN10-1.2;if(j>-2.200001&&j<1.800001)return V;j=Math.abs(j);var F=this.units[0].unit.prefixes;for(var U in F)if(De(F,U)){var ee=F[U];if(ee.scientific){var k=Math.abs(Math.log(z/Math.pow(ee.value*Y,L))/Math.LN10-1.2);(k<j||k===j&&ee.name.length<V.name.length)&&(V=ee,j=k)}}return V},d.prototype.splitUnit=function(z){for(var Y=this.clone(),V=[],L=0;L<z.length&&(Y=Y.to(z[L]),L!==z.length-1);L++){var j=Y.toNumeric(),F=s(j),U=void 0,ee=o(F,j);ee?U=F:U=l(Y.toNumeric());var k=new d(U,z[L].toString());V.push(k),Y=n(Y,k)}for(var fe=0,ve=0;ve<V.length;ve++)fe=a(fe,V[ve].value);return o(fe,this.value)&&(Y.value=0),V.push(Y),V};var D={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}}};D.SHORTLONG=Rr({},D.SHORT,D.LONG),D.BINARY_SHORT=Rr({},D.BINARY_SHORT_SI,D.BINARY_SHORT_IEC),D.BINARY_LONG=Rr({},D.BINARY_LONG_SI,D.BINARY_LONG_IEC);var Z=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],$={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 $)De($,H)&&($[H].key=H);var Q={},te={name:"",base:Q,value:1,offset:0,dimensions:Z.map(z=>0)},J={meter:{name:"meter",base:$.LENGTH,prefixes:D.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:D.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:D.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:D.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:D.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:D.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:D.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:D.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:D.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:D.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:D.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:D.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:D.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:D.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:D.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:D.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:D.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:D.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:D.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:D.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:D.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:D.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:D.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:D.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:D.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:D.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:D.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:D.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:D.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:D.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:D.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:D.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:D.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:D.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:D.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:D.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:D.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:D.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:D.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:D.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:D.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:D.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:D.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:D.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:D.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:D.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:D.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:D.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:D.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:D.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:D.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:D.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:D.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:D.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:D.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:D.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:D.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:D.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:D.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:D.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:D.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:D.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:D.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:D.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:D.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:D.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:D.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:D.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:D.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:D.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:D.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:D.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:D.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:D.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:D.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:D.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:D.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:D.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:D.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:D.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:D.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:D.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:D.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:D.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:D.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:D.NONE,value:7*86400,offset:0},month:{name:"month",base:$.TIME,prefixes:D.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:D.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:D.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:D.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:D.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:D.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:D.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:D.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:D.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:D.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:D.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:D.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:D.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:D.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:D.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:D.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:D.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:D.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:D.NONE,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:D.NONE,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:D.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:D.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:D.NONE,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:D.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:D.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:D.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:D.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:D.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:D.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:D.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:D.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:D.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:D.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:D.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:D.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:D.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:D.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:D.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:D.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:D.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:D.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:D.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:D.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:D.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:D.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:D.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:D.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:D.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:D.SHORT,value:h.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:D.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:D.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:D.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:D.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:D.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:D.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:D.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:D.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:D.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:D.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:D.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:D.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:D.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:D.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:D.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:D.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:D.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:D.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:D.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:D.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:D.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:D.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:D.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:D.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:D.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:D.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:D.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:D.BINARY_LONG,value:8,offset:0}},re={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 oe(z){if(z.number==="BigNumber"){var Y=Eo(b);J.rad.value=new b(1),J.deg.value=Y.div(180),J.grad.value=Y.div(200),J.cycle.value=Y.times(2),J.arcsec.value=Y.div(648e3),J.arcmin.value=Y.div(10800)}else J.rad.value=1,J.deg.value=Math.PI/180,J.grad.value=Math.PI/200,J.cycle.value=Math.PI*2,J.arcsec.value=Math.PI/648e3,J.arcmin.value=Math.PI/10800;J.radian.value=J.rad.value,J.degree.value=J.deg.value,J.gradian.value=J.grad.value}oe(t),e&&e("config",function(z,Y){z.number!==Y.number&&oe(z)});var ae={si:{NONE:{unit:te,prefix:D.NONE[""]},LENGTH:{unit:J.m,prefix:D.SHORT[""]},MASS:{unit:J.g,prefix:D.SHORT.k},TIME:{unit:J.s,prefix:D.SHORT[""]},CURRENT:{unit:J.A,prefix:D.SHORT[""]},TEMPERATURE:{unit:J.K,prefix:D.SHORT[""]},LUMINOUS_INTENSITY:{unit:J.cd,prefix:D.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:J.mol,prefix:D.SHORT[""]},ANGLE:{unit:J.rad,prefix:D.SHORT[""]},BIT:{unit:J.bits,prefix:D.SHORT[""]},FORCE:{unit:J.N,prefix:D.SHORT[""]},ENERGY:{unit:J.J,prefix:D.SHORT[""]},POWER:{unit:J.W,prefix:D.SHORT[""]},PRESSURE:{unit:J.Pa,prefix:D.SHORT[""]},ELECTRIC_CHARGE:{unit:J.C,prefix:D.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:J.F,prefix:D.SHORT[""]},ELECTRIC_POTENTIAL:{unit:J.V,prefix:D.SHORT[""]},ELECTRIC_RESISTANCE:{unit:J.ohm,prefix:D.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:J.H,prefix:D.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:J.S,prefix:D.SHORT[""]},MAGNETIC_FLUX:{unit:J.Wb,prefix:D.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:J.T,prefix:D.SHORT[""]},FREQUENCY:{unit:J.Hz,prefix:D.SHORT[""]}}};ae.cgs=JSON.parse(JSON.stringify(ae.si)),ae.cgs.LENGTH={unit:J.m,prefix:D.SHORT.c},ae.cgs.MASS={unit:J.g,prefix:D.SHORT[""]},ae.cgs.FORCE={unit:J.dyn,prefix:D.SHORT[""]},ae.cgs.ENERGY={unit:J.erg,prefix:D.NONE[""]},ae.us=JSON.parse(JSON.stringify(ae.si)),ae.us.LENGTH={unit:J.ft,prefix:D.NONE[""]},ae.us.MASS={unit:J.lbm,prefix:D.NONE[""]},ae.us.TEMPERATURE={unit:J.degF,prefix:D.NONE[""]},ae.us.FORCE={unit:J.lbf,prefix:D.NONE[""]},ae.us.ENERGY={unit:J.BTU,prefix:D.BTU[""]},ae.us.POWER={unit:J.hp,prefix:D.NONE[""]},ae.us.PRESSURE={unit:J.psi,prefix:D.NONE[""]},ae.auto=JSON.parse(JSON.stringify(ae.si));var ce=ae.auto;d.setUnitSystem=function(z){if(De(ae,z))ce=ae[z];else throw new Error("Unit system "+z+" does not exist. Choices are: "+Object.keys(ae).join(", "))},d.getUnitSystem=function(){for(var z in ae)if(De(ae,z)&&ae[z]===ce)return z},d.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}},d._getNumberConverter=function(z){if(!d.typeConverters[z])throw new TypeError('Unsupported type "'+z+'"');return d.typeConverters[z]};for(var se in J)if(De(J,se)){var me=J[se];me.dimensions=me.base.dimensions}for(var ne in re)if(De(re,ne)){var Ae=J[re[ne]],Ce={};for(var ge in Ae)De(Ae,ge)&&(Ce[ge]=Ae[ge]);Ce.name=ne,J[ne]=Ce}d.isValidAlpha=function(Y){return/^[a-zA-Z]$/.test(Y)};function Se(z){for(var Y=0;Y<z.length;Y++){if(g=z.charAt(Y),Y===0&&!d.isValidAlpha(g))throw new Error('Invalid unit name (must begin with alpha character): "'+z+'"');if(Y>0&&!(d.isValidAlpha(g)||E(g)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+z+'"')}}return d.createUnit=function(z,Y){if(typeof z!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Y&&Y.override){for(var V in z)if(De(z,V)&&d.deleteUnit(V),z[V].aliases)for(var L=0;L<z[V].aliases.length;L++)d.deleteUnit(z[V].aliases[L])}var j;for(var F in z)De(z,F)&&(j=d.createUnitSingle(F,z[F]));return j},d.createUnitSingle=function(z,Y,V){if((typeof Y>"u"||Y===null)&&(Y={}),typeof z!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(De(J,z))throw new Error('Cannot create unit "'+z+'": a unit with that name already exists');Se(z);var L=null,j=[],F=0,U,ee,k;if(Y&&Y.type==="Unit")L=Y.clone();else if(typeof Y=="string")Y!==""&&(U=Y);else if(typeof Y=="object")U=Y.definition,ee=Y.prefixes,F=Y.offset,k=Y.baseName,Y.aliases&&(j=Y.aliases.valueOf());else throw new TypeError('Cannot create unit "'+z+'" from "'+Y.toString()+'": expecting "string" or "Unit" or "Object"');if(j){for(var fe=0;fe<j.length;fe++)if(De(J,j[fe]))throw new Error('Cannot create alias "'+j[fe]+'": a unit with that name already exists')}if(U&&typeof U=="string"&&!L)try{L=d.parse(U,{allowNoUnits:!0})}catch(O){throw O.message='Could not create unit "'+z+'" from "'+U+'": '+O.message,O}else U&&U.type==="Unit"&&(L=U.clone());j=j||[],F=F||0,ee&&ee.toUpperCase?ee=D[ee.toUpperCase()]||D.NONE:ee=D.NONE;var ve={};if(L){ve={name:z,value:L.value,dimensions:L.dimensions.slice(0),prefixes:ee,offset:F};var Te=!1;for(var nr in $)if(De($,nr)){for(var dr=!0,fr=0;fr<Z.length;fr++)if(Math.abs((ve.dimensions[fr]||0)-($[nr].dimensions[fr]||0))>1e-12){dr=!1;break}if(dr){Te=!0,ve.base=$[nr];break}}if(!Te){k=k||z+"_STUFF";var Gr={dimensions:L.dimensions.slice(0)};Gr.key=k,$[k]=Gr,ce[k]={unit:ve,prefix:D.NONE[""]},ve.base=$[k]}}else{if(k=k||z+"_STUFF",Z.indexOf(k)>=0)throw new Error('Cannot create new base unit "'+z+'": a base unit with that name already exists (and cannot be overridden)');Z.push(k);for(var Me in $)De($,Me)&&($[Me].dimensions[Z.length-1]=0);for(var be={dimensions:[]},xe=0;xe<Z.length;xe++)be.dimensions[xe]=0;be.dimensions[Z.length-1]=1,be.key=k,$[k]=be,ve={name:z,value:1,dimensions:$[k].dimensions.slice(0),prefixes:ee,offset:F,base:$[k]},ce[k]={unit:ve,prefix:D.NONE[""]}}d.UNITS[z]=ve;for(var Hr=0;Hr<j.length;Hr++){var st=j[Hr],er={};for(var $t in ve)De(ve,$t)&&(er[$t]=ve[$t]);er.name=st,d.UNITS[st]=er}return delete I.cache,new d(null,z)},d.deleteUnit=function(z){delete d.UNITS[z]},d.PREFIXES=D,d.BASE_DIMENSIONS=Z,d.BASE_UNITS=$,d.UNIT_SYSTEMS=ae,d.UNITS=J,d},{isClass:!0}),rm="unit",BN=["typed","Unit"],_N=q(rm,BN,r=>{var{typed:e,Unit:t}=r;return e(rm,{Unit:function(n){return n.clone()},string:function(n){return t.isValuelessUnit(n)?new t(null,n):t.parse(n,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(n,i){return new t(n,i)},"Array | Matrix":function(n){return $e(n,this)}})}),tm="sparse",IN=["typed","SparseMatrix"],RN=q(tm,IN,r=>{var{typed:e,SparseMatrix:t}=r;return e(tm,{"":function(){return new t([])},string:function(n){return new t([],n)},"Array | Matrix":function(n){return new t(n)},"Array | Matrix, string":function(n,i){return new t(n,i)}})}),nm="createUnit",FN=["typed","Unit"],qN=q(nm,FN,r=>{var{typed:e,Unit:t}=r;return e(nm,{"Object, Object":function(n,i){return t.createUnit(n,i)},Object:function(n){return t.createUnit(n,{})},"string, Unit | string | Object, Object":function(n,i,c){var m={};return m[n]=i,t.createUnit(m,c)},"string, Unit | string | Object":function(n,i){var c={};return c[n]=i,t.createUnit(c,{})},string:function(n){var i={};return i[n]={},t.createUnit(i,{})}})}),am="acos",zN=["typed","config","Complex"],PN=q(am,zN,r=>{var{typed:e,config:t,Complex:a}=r;return e(am,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.acos(i):new a(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()},"Array | Matrix":function(i){return $e(i,this)}})}),im="acosh",UN=["typed","config","Complex"],LN=q(im,UN,r=>{var{typed:e,config:t,Complex:a}=r;return e(im,{number:function(i){return i>=1||t.predictable?hc(i):i<=-1?new a(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new a(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()},"Array | Matrix":function(i){return $e(i,this)}})}),om="acot",kN=["typed","BigNumber"],VN=q(om,kN,r=>{var{typed:e,BigNumber:t}=r;return e(om,{number:dc,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()},"Array | Matrix":function(n){return $e(n,this)}})}),sm="acoth",GN=["typed","config","Complex","BigNumber"],HN=q(sm,GN,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(sm,{number:function(c){return c>=1||c<=-1||t.predictable?gc(c):new a(c,0).acoth()},Complex:function(c){return c.acoth()},BigNumber:function(c){return new n(1).div(c).atanh()},"Array | Matrix":function(c){return $e(c,this)}})}),um="acsc",ZN=["typed","config","Complex","BigNumber"],JN=q(um,ZN,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(um,{number:function(c){return c<=-1||c>=1||t.predictable?yc(c):new a(c,0).acsc()},Complex:function(c){return c.acsc()},BigNumber:function(c){return new n(1).div(c).asin()},"Array | Matrix":function(c){return $e(c,this)}})}),cm="acsch",WN=["typed","BigNumber"],XN=q(cm,WN,r=>{var{typed:e,BigNumber:t}=r;return e(cm,{number:bc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()},"Array | Matrix":function(n){return $e(n,this)}})}),lm="asec",YN=["typed","config","Complex","BigNumber"],QN=q(lm,YN,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(lm,{number:function(c){return c<=-1||c>=1||t.predictable?xc(c):new a(c,0).asec()},Complex:function(c){return c.asec()},BigNumber:function(c){return new n(1).div(c).acos()},"Array | Matrix":function(c){return $e(c,this)}})}),fm="asech",jN=["typed","config","Complex","BigNumber"],KN=q(fm,jN,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(fm,{number:function(c){if(c<=1&&c>=-1||t.predictable){var m=1/c;if(m>0||t.predictable)return wc(c);var f=Math.sqrt(m*m-1);return new a(Math.log(f-m),Math.PI)}return new a(c,0).asech()},Complex:function(c){return c.asech()},BigNumber:function(c){return new n(1).div(c).acosh()},"Array | Matrix":function(c){return $e(c,this)}})}),mm="asin",eM=["typed","config","Complex"],rM=q(mm,eM,r=>{var{typed:e,config:t,Complex:a}=r;return e(mm,{number:function(i){return i>=-1&&i<=1||t.predictable?Math.asin(i):new a(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()},"Array | Matrix":function(i){return $e(i,this)}})}),tM="asinh",nM=["typed"],aM=q(tM,nM,r=>{var{typed:e}=r;return e("asinh",{number:Nc,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()},"Array | Matrix":function(a){return $e(a,this)}})}),iM="atan",oM=["typed"],sM=q(iM,oM,r=>{var{typed:e}=r;return e("atan",{number:function(a){return Math.atan(a)},Complex:function(a){return a.atan()},BigNumber:function(a){return a.atan()},"Array | Matrix":function(a){return $e(a,this)}})}),pm="atan2",uM=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],cM=q(pm,uM,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i}=r,c=pt({typed:e,equalScalar:a}),m=Lr({typed:e}),f=gl({typed:e,equalScalar:a}),l=_r({typed:e,equalScalar:a}),s=$r({typed:e,DenseMatrix:i}),o=lr({typed:e}),u=rr({typed:e});return e(pm,{"number, number":Math.atan2,"BigNumber, BigNumber":function(v,h){return n.atan2(v,h)},"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return c(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(t(v),t(h)).valueOf()},"Array, Matrix":function(v,h){return this(t(v),h)},"Matrix, Array":function(v,h){return this(v,t(h))},"SparseMatrix, number | BigNumber":function(v,h){return l(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(t(v),h,this,!1).valueOf()},"number | BigNumber, Array":function(v,h){return u(t(h),v,this,!0).valueOf()}})}),vm="atanh",lM=["typed","config","Complex"],fM=q(vm,lM,r=>{var{typed:e,config:t,Complex:a}=r;return e(vm,{number:function(i){return i<=1&&i>=-1||t.predictable?Mc(i):new a(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()},"Array | Matrix":function(i){return $e(i,this)}})}),hm="cos",mM=["typed"],pM=q(hm,mM,r=>{var{typed:e}=r;return e(hm,{number:Math.cos,Complex:function(a){return a.cos()},BigNumber:function(a){return a.cos()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),dm="cosh",vM=["typed"],hM=q(dm,vM,r=>{var{typed:e}=r;return e(dm,{number:_d,Complex:function(a){return a.cosh()},BigNumber:function(a){return a.cosh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),gm="cot",dM=["typed","BigNumber"],gM=q(gm,dM,r=>{var{typed:e,BigNumber:t}=r;return e(gm,{number:Ac,Complex:function(n){return n.cot()},BigNumber:function(n){return new t(1).div(n.tan())},Unit:function(n){if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(n.value)},"Array | Matrix":function(n){return $e(n,this)}})}),ym="coth",yM=["typed","BigNumber"],bM=q(ym,yM,r=>{var{typed:e,BigNumber:t}=r;return e(ym,{number:Sc,Complex:function(n){return n.coth()},BigNumber:function(n){return new t(1).div(n.tanh())},Unit:function(n){if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(n.value)},"Array | Matrix":function(n){return $e(n,this)}})}),bm="csc",xM=["typed","BigNumber"],wM=q(bm,xM,r=>{var{typed:e,BigNumber:t}=r;return e(bm,{number:Ec,Complex:function(n){return n.csc()},BigNumber:function(n){return new t(1).div(n.sin())},Unit:function(n){if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(n.value)},"Array | Matrix":function(n){return $e(n,this)}})}),xm="csch",NM=["typed","BigNumber"],MM=q(xm,NM,r=>{var{typed:e,BigNumber:t}=r;return e(xm,{number:Cc,Complex:function(n){return n.csch()},BigNumber:function(n){return new t(1).div(n.sinh())},Unit:function(n){if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(n.value)},"Array | Matrix":function(n){return $e(n,this)}})}),wm="sec",AM=["typed","BigNumber"],SM=q(wm,AM,r=>{var{typed:e,BigNumber:t}=r;return e(wm,{number:Oc,Complex:function(n){return n.sec()},BigNumber:function(n){return new t(1).div(n.cos())},Unit:function(n){if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(n.value)},"Array | Matrix":function(n){return $e(n,this)}})}),Nm="sech",EM=["typed","BigNumber"],CM=q(Nm,EM,r=>{var{typed:e,BigNumber:t}=r;return e(Nm,{number:$c,Complex:function(n){return n.sech()},BigNumber:function(n){return new t(1).div(n.cosh())},Unit:function(n){if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(n.value)},"Array | Matrix":function(n){return $e(n,this)}})}),Mm="sin",OM=["typed"],$M=q(Mm,OM,r=>{var{typed:e}=r;return e(Mm,{number:Math.sin,Complex:function(a){return a.sin()},BigNumber:function(a){return a.sin()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),Am="sinh",TM=["typed"],DM=q(Am,TM,r=>{var{typed:e}=r;return e(Am,{number:Tc,Complex:function(a){return a.sinh()},BigNumber:function(a){return a.sinh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),Sm="tan",BM=["typed"],_M=q(Sm,BM,r=>{var{typed:e}=r;return e(Sm,{number:Math.tan,Complex:function(a){return a.tan()},BigNumber:function(a){return a.tan()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),IM="tanh",RM=["typed"],FM=q(IM,RM,r=>{var{typed:e}=r;return e("tanh",{number:Rd,Complex:function(a){return a.tanh()},BigNumber:function(a){return a.tanh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(a.value)},"Array | Matrix":function(a){return $e(a,this)}})}),Em="setCartesian",qM=["typed","size","subset","compareNatural","Index","DenseMatrix"],zM=q(Em,qM,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:c}=r;return e(Em,{"Array | Matrix, Array | Matrix":function(f,l){var s=[];if(a(t(f),new i(0))!==0&&a(t(l),new i(0))!==0){var o=Qe(Array.isArray(f)?f:f.toArray()).sort(n),u=Qe(Array.isArray(l)?l:l.toArray()).sort(n);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(l)?s:new c(s)}})}),Cm="setDifference",PM=["typed","size","subset","compareNatural","Index","DenseMatrix"],UM=q(Cm,PM,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:c}=r;return e(Cm,{"Array | Matrix, Array | Matrix":function(f,l){var s;if(a(t(f),new i(0))===0)s=[];else{if(a(t(l),new i(0))===0)return Qe(f.toArray());var o=Bn(Qe(Array.isArray(f)?f:f.toArray()).sort(n)),u=Bn(Qe(Array.isArray(l)?l:l.toArray()).sort(n));s=[];for(var p,v=0;v<o.length;v++){p=!1;for(var h=0;h<u.length;h++)if(n(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(l)?ja(s):new c(ja(s))}})}),Om="setDistinct",LM=["typed","size","subset","compareNatural","Index","DenseMatrix"],kM=q(Om,LM,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:c}=r;return e(Om,{"Array | Matrix":function(f){var l;if(a(t(f),new i(0))===0)l=[];else{var s=Qe(Array.isArray(f)?f:f.toArray()).sort(n);l=[],l.push(s[0]);for(var o=1;o<s.length;o++)n(s[o],s[o-1])!==0&&l.push(s[o])}return Array.isArray(f)?l:new c(l)}})}),$m="setIntersect",VM=["typed","size","subset","compareNatural","Index","DenseMatrix"],GM=q($m,VM,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:c}=r;return e($m,{"Array | Matrix, Array | Matrix":function(f,l){var s;if(a(t(f),new i(0))===0||a(t(l),new i(0))===0)s=[];else{var o=Bn(Qe(Array.isArray(f)?f:f.toArray()).sort(n)),u=Bn(Qe(Array.isArray(l)?l:l.toArray()).sort(n));s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)if(n(o[p].value,u[v].value)===0&&o[p].identifier===u[v].identifier){s.push(o[p]);break}}return Array.isArray(f)&&Array.isArray(l)?ja(s):new c(ja(s))}})}),Tm="setIsSubset",HM=["typed","size","subset","compareNatural","Index"],ZM=q(Tm,HM,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Tm,{"Array | Matrix, Array | Matrix":function(m,f){if(a(t(m),new i(0))===0)return!0;if(a(t(f),new i(0))===0)return!1;for(var l=Bn(Qe(Array.isArray(m)?m:m.toArray()).sort(n)),s=Bn(Qe(Array.isArray(f)?f:f.toArray()).sort(n)),o,u=0;u<l.length;u++){o=!1;for(var p=0;p<s.length;p++)if(n(l[u].value,s[p].value)===0&&l[u].identifier===s[p].identifier){o=!0;break}if(o===!1)return!1}return!0}})}),Dm="setMultiplicity",JM=["typed","size","subset","compareNatural","Index"],WM=q(Dm,JM,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Dm,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(m,f){if(a(t(f),new i(0))===0)return 0;for(var l=Qe(Array.isArray(f)?f:f.toArray()),s=0,o=0;o<l.length;o++)n(l[o],m)===0&&s++;return s}})}),Bm="setPowerset",XM=["typed","size","subset","compareNatural","Index"],YM=q(Bm,XM,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Bm,{"Array | Matrix":function(l){if(a(t(l),new i(0))===0)return[];for(var s=Qe(Array.isArray(l)?l:l.toArray()).sort(n),o=[],u=0;u.toString(2).length<=s.length;)o.push(c(s,u.toString(2).split("").reverse())),u++;return m(o)}});function c(f,l){for(var s=[],o=0;o<l.length;o++)l[o]==="1"&&s.push(f[o]);return s}function m(f){for(var l=[],s=f.length-1;s>0;s--)for(var o=0;o<s;o++)f[o].length>f[o+1].length&&(l=f[o],f[o]=f[o+1],f[o+1]=l);return f}}),_m="setSize",QM=["typed","compareNatural"],jM=q(_m,QM,r=>{var{typed:e,compareNatural:t}=r;return e(_m,{"Array | Matrix":function(n){return Array.isArray(n)?Qe(n).length:Qe(n.toArray()).length},"Array | Matrix, boolean":function(n,i){if(i===!1||n.length===0)return Array.isArray(n)?Qe(n).length:Qe(n.toArray()).length;for(var c=Qe(Array.isArray(n)?n:n.toArray()).sort(t),m=1,f=1;f<c.length;f++)t(c[f],c[f-1])!==0&&m++;return m}})}),Im="setSymDifference",KM=["typed","size","concat","subset","setDifference","Index"],e2=q(Im,KM,r=>{var{typed:e,size:t,concat:a,subset:n,setDifference:i,Index:c}=r;return e(Im,{"Array | Matrix, Array | Matrix":function(f,l){if(n(t(f),new c(0))===0)return Qe(l);if(n(t(l),new c(0))===0)return Qe(f);var s=Qe(f),o=Qe(l);return a(i(s,o),i(o,s))}})}),Rm="setUnion",r2=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],t2=q(Rm,r2,r=>{var{typed:e,size:t,concat:a,subset:n,setIntersect:i,setSymDifference:c,Index:m}=r;return e(Rm,{"Array | Matrix, Array | Matrix":function(l,s){if(n(t(l),new m(0))===0)return Qe(s);if(n(t(s),new m(0))===0)return Qe(l);var o=Qe(l),u=Qe(s);return a(c(o,u),i(o,u))}})}),Fm="add",n2=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],a2=q(Fm,n2,r=>{var{typed:e,matrix:t,addScalar:a,equalScalar:n,DenseMatrix:i,SparseMatrix:c}=r,m=jt({typed:e}),f=wo({typed:e,equalScalar:n}),l=pn({typed:e,DenseMatrix:i}),s=lr({typed:e}),o=rr({typed:e});return e(Fm,Qi({"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,a)},"DenseMatrix, SparseMatrix":function(p,v){return m(p,v,a,!1)},"SparseMatrix, DenseMatrix":function(p,v){return m(v,p,a,!0)},"SparseMatrix, SparseMatrix":function(p,v){return f(p,v,a)},"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))},"DenseMatrix, any":function(p,v){return o(p,v,a,!1)},"SparseMatrix, any":function(p,v){return l(p,v,a,!1)},"any, DenseMatrix":function(p,v){return o(v,p,a,!0)},"any, SparseMatrix":function(p,v){return l(v,p,a,!0)},"Array, any":function(p,v){return o(t(p),v,a,!1).valueOf()},"any, Array":function(p,v){return o(t(v),p,a,!0).valueOf()},"any, any":a,"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}},a.signatures))}),qm="hypot",i2=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],o2=q(qm,i2,r=>{var{typed:e,abs:t,addScalar:a,divideScalar:n,multiplyScalar:i,sqrt:c,smaller:m,isPositive:f}=r;return e(qm,{"... number | BigNumber":l,Array:function(o){return this.apply(this,Qe(o))},Matrix:function(o){return this.apply(this,Qe(o.toArray()))}});function l(s){for(var o=0,u=0,p=0;p<s.length;p++){var v=t(s[p]);m(u,v)?(o=i(o,i(n(u,v),n(u,v))),o=a(o,1),u=v):o=a(o,f(v)?i(n(v,u),n(v,u)):v)}return i(u,c(o))}}),zm="norm",s2=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],u2=q(zm,s2,r=>{var{typed:e,abs:t,add:a,pow:n,conj:i,sqrt:c,multiply:m,equalScalar:f,larger:l,smaller:s,matrix:o,ctranspose:u,eigs:p}=r;return e(zm,{number:Math.abs,Complex:function(A){return A.abs()},BigNumber:function(A){return A.abs()},boolean:function(A){return Math.abs(A)},Array:function(A){return g(o(A),2)},Matrix:function(A){return g(A,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(A){return this(A)},"Array, number | BigNumber | string":function(A,E){return g(o(A),E)},"Matrix, number | BigNumber | string":function(A,E){return g(A,E)}});function v(S){var A=0;return S.forEach(function(E){var M=t(E);l(M,A)&&(A=M)},!0),A}function h(S){var A;return S.forEach(function(E){var M=t(E);(!A||s(M,A))&&(A=M)},!0),A||0}function b(S,A){if(A===Number.POSITIVE_INFINITY||A==="inf")return v(S);if(A===Number.NEGATIVE_INFINITY||A==="-inf")return h(S);if(A==="fro")return g(S,2);if(typeof A=="number"&&!isNaN(A)){if(!f(A,0)){var E=0;return S.forEach(function(M){E=a(n(t(M),A),E)},!0),n(E,1/A)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function w(S){var A=0;return S.forEach(function(E,M){A=a(A,m(E,i(E)))}),t(c(A))}function N(S){var A=[],E=0;return S.forEach(function(M,B){var C=B[1],_=a(A[C]||0,t(M));l(_,E)&&(E=_),A[C]=_},!0),E}function d(S){var A=S.size();if(A[0]!==A[1])throw new RangeError("Invalid matrix dimensions");var E=u(S),M=m(E,S),B=p(M).values.toArray(),C=B[B.length-1];return t(c(C))}function y(S){var A=[],E=0;return S.forEach(function(M,B){var C=B[0],_=a(A[C]||0,t(M));l(_,E)&&(E=_),A[C]=_},!0),E}function x(S,A){if(A===1)return N(S);if(A===Number.POSITIVE_INFINITY||A==="inf")return y(S);if(A==="fro")return w(S);if(A===2)return d(S);throw new Error("Unsupported parameter value "+A)}function g(S,A){var E=S.size();if(E.length===1)return b(S,A);if(E.length===2){if(E[0]&&E[1])return x(S,A);throw new RangeError("Invalid matrix dimensions")}}}),Pm="dot",c2=["typed","addScalar","multiplyScalar","conj","size"],l2=q(Pm,c2,r=>{var{typed:e,addScalar:t,multiplyScalar:a,conj:n,size:i}=r;return e(Pm,{"Array | DenseMatrix, Array | DenseMatrix":m,"SparseMatrix, SparseMatrix":f});function c(s,o){var u=l(s),p=l(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=c(s,o),p=Fe(s)?s._data:s,v=Fe(s)?s._datatype:void 0,h=Fe(o)?o._data:o,b=Fe(o)?o._datatype:void 0,w=l(s).length===2,N=l(o).length===2,d=t,y=a;if(v&&b&&v===b&&typeof v=="string"){var x=v;d=e.find(t,[x,x]),y=e.find(a,[x,x])}if(!w&&!N){for(var g=y(n(p[0]),h[0]),S=1;S<u;S++)g=d(g,y(n(p[S]),h[S]));return g}if(!w&&N){for(var A=y(n(p[0]),h[0][0]),E=1;E<u;E++)A=d(A,y(n(p[E]),h[E][0]));return A}if(w&&!N){for(var M=y(n(p[0][0]),h[0]),B=1;B<u;B++)M=d(M,y(n(p[B][0]),h[B]));return M}if(w&&N){for(var C=y(n(p[0][0]),h[0][0]),_=1;_<u;_++)C=d(C,y(n(p[_][0]),h[_][0]));return C}}function f(s,o){c(s,o);for(var u=s._index,p=s._values,v=o._index,h=o._values,b=0,w=t,N=a,d=0,y=0;d<u.length&&y<v.length;){var x=u[d],g=v[y];if(x<g){d++;continue}if(x>g){y++;continue}x===g&&(b=w(b,N(p[d],h[y])),d++,y++)}return b}function l(s){return Fe(s)?s.size():i(s)}}),f2="trace",m2=["typed","matrix","add"],p2=q(f2,m2,r=>{var{typed:e,matrix:t,add:a}=r;return e("trace",{Array:function(m){return n(t(m))},SparseMatrix:i,DenseMatrix:n,any:Re});function n(c){var m=c._size,f=c._data;switch(m.length){case 1:if(m[0]===1)return Re(f[0]);throw new RangeError("Matrix must be square (size: "+Ge(m)+")");case 2:{var l=m[0],s=m[1];if(l===s){for(var o=0,u=0;u<l;u++)o=a(o,f[u][u]);return o}else throw new RangeError("Matrix must be square (size: "+Ge(m)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ge(m)+")")}}function i(c){var m=c._values,f=c._index,l=c._ptr,s=c._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=l[v],b=l[v+1],w=h;w<b;w++){var N=f[w];if(N===v){p=a(p,m[w]);break}if(N>v)break}return p}throw new RangeError("Matrix must be square (size: "+Ge(s)+")")}}),Um="index",v2=["typed","Index"],h2=q(Um,v2,r=>{var{typed:e,Index:t}=r;return e(Um,{"...number | string | BigNumber | Range | Array | Matrix":function(n){var i=n.map(function(m){return We(m)?m.toNumber():Array.isArray(m)||Fe(m)?m.map(function(f){return We(f)?f.toNumber():f}):m}),c=new t;return t.apply(c,i),c}})}),Lm=new Set(["end"]),d2="Node",g2=["mathWithTransform"],y2=q(d2,g2,r=>{var{mathWithTransform:e}=r;function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator")}t.prototype.evaluate=function(n){return this.compile().evaluate(n)},t.prototype.type="Node",t.prototype.isNode=!0,t.prototype.comment="",t.prototype.compile=function(){var n=this._compile(e,{}),i={},c=null;function m(f){var l=io(f);return a(l),n(l,i,c)}return{evaluate:m}},t.prototype._compile=function(n,i){throw new Error("Method _compile should be implemented by type "+this.type)},t.prototype.forEach=function(n){throw new Error("Cannot run forEach on a Node interface")},t.prototype.map=function(n){throw new Error("Cannot run map on a Node interface")},t.prototype._ifNode=function(n){if(!tr(n))throw new TypeError("Callback function must return a Node");return n},t.prototype.traverse=function(n){n(this,null,null);function i(c,m){c.forEach(function(f,l,s){m(f,l,s),i(f,m)})}i(this,n)},t.prototype.transform=function(n){function i(c,m,f){var l=n(c,m,f);return l!==c?l:c.map(i)}return i(this,null,null)},t.prototype.filter=function(n){var i=[];return this.traverse(function(c,m,f){n(c,m,f)&&i.push(c)}),i},t.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},t.prototype.cloneDeep=function(){return this.map(function(n){return n.cloneDeep()})},t.prototype.equals=function(n){return n?va(this,n):!1},t.prototype.toString=function(n){var i=this._getCustomString(n);return typeof i<"u"?i:this._toString(n)},t.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},t.prototype.toHTML=function(n){var i=this._getCustomString(n);return typeof i<"u"?i:this.toHTML(n)},t.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},t.prototype.toTex=function(n){var i=this._getCustomString(n);return typeof i<"u"?i:this._toTex(n)},t.prototype._toTex=function(n){throw new Error("_toTex not implemented for "+this.type)},t.prototype._getCustomString=function(n){if(n&&typeof n=="object")switch(typeof n.handler){case"object":case"undefined":return;case"function":return n.handler(this,n);default:throw new TypeError("Object or function expected as callback")}},t.prototype.getIdentifier=function(){return this.type},t.prototype.getContent=function(){return this};function a(n){for(var i of[...Lm])if(n.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}return t},{isClass:!0,isNode:!0});function Vr(r){return r&&r.isIndexError?new ct(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function km(r){var{subset:e}=r;return function(a,n){try{if(Array.isArray(a))return e(a,n);if(a&&typeof a.subset=="function")return a.subset(n);if(typeof a=="string")return e(a,n);if(typeof a=="object"){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return rt(a,n.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Vr(i)}}}var b2="AccessorNode",x2=["subset","Node"],w2=q(b2,x2,r=>{var{subset:e,Node:t}=r,a=km({subset:e});function n(c,m){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!tr(c))throw new TypeError('Node expected for parameter "object"');if(!On(m))throw new TypeError('IndexNode expected for parameter "index"');this.object=c||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")}})}n.prototype=new t,n.prototype.type="AccessorNode",n.prototype.isAccessorNode=!0,n.prototype._compile=function(c,m){var f=this.object._compile(c,m),l=this.index._compile(c,m);if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(u,p,v){return rt(f(u,p,v),s)}}else return function(u,p,v){var h=f(u,p,v),b=l(u,p,h);return a(h,b)}},n.prototype.forEach=function(c){c(this.object,"object",this),c(this.index,"index",this)},n.prototype.map=function(c){return new n(this._ifNode(c(this.object,"object",this)),this._ifNode(c(this.index,"index",this)))},n.prototype.clone=function(){return new n(this.object,this.index)},n.prototype._toString=function(c){var m=this.object.toString(c);return i(this.object)&&(m="("+m+")"),m+this.index.toString(c)},n.prototype.toHTML=function(c){var m=this.object.toHTML(c);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(c)},n.prototype._toTex=function(c){var m=this.object.toTex(c);return i(this.object)&&(m="\\left(' + object + '\\right)"),m+this.index.toTex(c)},n.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},n.fromJSON=function(c){return new n(c.object,c.index)};function i(c){return!(cn(c)||Kr(c)||ir(c)||ln(c)||Ha(c)||pa(c)||Dr(c))}return n},{isClass:!0,isNode:!0}),N2="ArrayNode",M2=["Node"],A2=q(N2,M2,r=>{var{Node:e}=r;function t(a){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=a||[],!Array.isArray(this.items)||!this.items.every(tr))throw new TypeError("Array containing Nodes expected")}return t.prototype=new e,t.prototype.type="ArrayNode",t.prototype.isArrayNode=!0,t.prototype._compile=function(a,n){var i=Bt(this.items,function(f){return f._compile(a,n)}),c=a.config.matrix!=="Array";if(c){var m=a.matrix;return function(l,s,o){return m(Bt(i,function(u){return u(l,s,o)}))}}else return function(l,s,o){return Bt(i,function(u){return u(l,s,o)})}},t.prototype.forEach=function(a){for(var n=0;n<this.items.length;n++){var i=this.items[n];a(i,"items["+n+"]",this)}},t.prototype.map=function(a){for(var n=[],i=0;i<this.items.length;i++)n[i]=this._ifNode(a(this.items[i],"items["+i+"]",this));return new t(n)},t.prototype.clone=function(){return new t(this.items.slice(0))},t.prototype._toString=function(a){var n=this.items.map(function(i){return i.toString(a)});return"["+n.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"ArrayNode",items:this.items}},t.fromJSON=function(a){return new t(a.items)},t.prototype.toHTML=function(a){var n=this.items.map(function(i){return i.toHTML(a)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+n.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},t.prototype._toTex=function(a){function n(i,c){var m=i.some(Kr)&&!i.every(Kr),f=c||m,l=f?"&":"\\\\",s=i.map(function(o){return o.items?n(o.items,!c):o.toTex(a)}).join(l);return m||!f||f&&!c?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}return n(this.items,!1)},t},{isClass:!0,isNode:!0});function S2(r){var{subset:e,matrix:t}=r;return function(n,i,c){try{if(Array.isArray(n))return t(n).subset(i,c).valueOf();if(n&&typeof n.subset=="function")return n.subset(i,c);if(typeof n=="string")return e(n,i,c);if(typeof n=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return _n(n,i.getObjectProperty(),c),n}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(m){throw Vr(m)}}}var Nt=[{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 sr(r,e){var t=r;e!=="keep"&&(t=r.getContent());for(var a=t.getIdentifier(),n=0;n<Nt.length;n++)if(a in Nt[n])return n;return null}function wa(r,e){var t=r;e!=="keep"&&(t=r.getContent());var a=t.getIdentifier(),n=sr(t,e);if(n===null)return null;var i=Nt[n][a];if(De(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+a+"' has the invalid associativity '"+i.associativity+"'.")}return null}function Oo(r,e,t){var a=t!=="keep"?r.getContent():r,n=t!=="keep"?r.getContent():e,i=a.getIdentifier(),c=n.getIdentifier(),m=sr(a,t);if(m===null)return null;var f=Nt[m][i];if(De(f,"associativeWith")&&f.associativeWith instanceof Array){for(var l=0;l<f.associativeWith.length;l++)if(f.associativeWith[l]===c)return!0;return!1}return null}var E2="AssignmentNode",C2=["subset","?matrix","Node"],O2=q(E2,C2,r=>{var{subset:e,matrix:t,Node:a}=r,n=km({subset:e}),i=S2({subset:e,matrix:t});function c(f,l,s){if(!(this instanceof c))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=f,this.index=s?l:null,this.value=s||l,!Dr(f)&&!cn(f))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(Dr(f)&&f.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!On(this.index))throw new TypeError('IndexNode expected as "index"');if(!tr(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")}})}c.prototype=new a,c.prototype.type="AssignmentNode",c.prototype.isAssignmentNode=!0,c.prototype._compile=function(f,l){var s=this.object._compile(f,l),o=this.index?this.index._compile(f,l):null,u=this.value._compile(f,l),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(d,y,x){var g=s(d,y,x),S=u(d,y,x);return _n(g,v,S),S}}else{if(Dr(this.object))return function(d,y,x){var g=s(d,y,x),S=u(d,y,x),A=o(d,y,g);return d.set(p,i(g,A,S)),S};var h=this.object.object._compile(f,l);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(d,y,x){var g=h(d,y,x),S=rt(g,b),A=o(d,y,S),E=u(d,y,x);return _n(g,b,i(S,A,E)),E}}else{var w=this.object.index._compile(f,l);return function(d,y,x){var g=h(d,y,x),S=w(d,y,g),A=n(g,S),E=o(d,y,A),M=u(d,y,x);return i(g,S,i(A,E,M)),M}}}else{if(!Dr(this.object))throw new TypeError("SymbolNode expected as object");return function(d,y,x){var g=u(d,y,x);return d.set(p,g),g}}},c.prototype.forEach=function(f){f(this.object,"object",this),this.index&&f(this.index,"index",this),f(this.value,"value",this)},c.prototype.map=function(f){var l=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 c(l,s,o)},c.prototype.clone=function(){return new c(this.object,this.index,this.value)};function m(f,l){l||(l="keep");var s=sr(f,l),o=sr(f.value,l);return l==="all"||o!==null&&o<=s}return c.prototype._toString=function(f){var l=this.object.toString(f),s=this.index?this.index.toString(f):"",o=this.value.toString(f);return m(this,f&&f.parenthesis)&&(o="("+o+")"),l+s+" = "+o},c.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},c.fromJSON=function(f){return new c(f.object,f.index,f.value)},c.prototype.toHTML=function(f){var l=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>'),l+s+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+o},c.prototype._toTex=function(f){var l=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)")),l+s+":="+o},c},{isClass:!0,isNode:!0}),$2="BlockNode",T2=["ResultSet","Node"],D2=q($2,T2,r=>{var{ResultSet:e,Node:t}=r;function a(n){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(n))throw new Error("Array expected");this.blocks=n.map(function(i){var c=i&&i.node,m=i&&i.visible!==void 0?i.visible:!0;if(!tr(c))throw new TypeError('Property "node" must be a Node');if(typeof m!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:c,visible:m}})}return a.prototype=new t,a.prototype.type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(n,i){var c=Bt(this.blocks,function(m){return{evaluate:m.node._compile(n,i),visible:m.visible}});return function(f,l,s){var o=[];return Ya(c,function(p){var v=p.evaluate(f,l,s);p.visible&&o.push(v)}),new e(o)}},a.prototype.forEach=function(n){for(var i=0;i<this.blocks.length;i++)n(this.blocks[i].node,"blocks["+i+"].node",this)},a.prototype.map=function(n){for(var i=[],c=0;c<this.blocks.length;c++){var m=this.blocks[c],f=this._ifNode(n(m.node,"blocks["+c+"].node",this));i[c]={node:f,visible:m.visible}}return new a(i)},a.prototype.clone=function(){var n=this.blocks.map(function(i){return{node:i.node,visible:i.visible}});return new a(n)},a.prototype._toString=function(n){return this.blocks.map(function(i){return i.node.toString(n)+(i.visible?"":";")}).join(`
29
+ `)},a.prototype.toJSON=function(){return{mathjs:"BlockNode",blocks:this.blocks}},a.fromJSON=function(n){return new a(n.blocks)},a.prototype.toHTML=function(n){return this.blocks.map(function(i){return i.node.toHTML(n)+(i.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')},a.prototype._toTex=function(n){return this.blocks.map(function(i){return i.node.toTex(n)+(i.visible?"":";")}).join(`\\;\\;
30
+ `)},a},{isClass:!0,isNode:!0}),B2="ConditionalNode",_2=["Node"],I2=q(B2,_2,r=>{var{Node:e}=r;function t(n,i,c){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!tr(n))throw new TypeError("Parameter condition must be a Node");if(!tr(i))throw new TypeError("Parameter trueExpr must be a Node");if(!tr(c))throw new TypeError("Parameter falseExpr must be a Node");this.condition=n,this.trueExpr=i,this.falseExpr=c}t.prototype=new e,t.prototype.type="ConditionalNode",t.prototype.isConditionalNode=!0,t.prototype._compile=function(n,i){var c=this.condition._compile(n,i),m=this.trueExpr._compile(n,i),f=this.falseExpr._compile(n,i);return function(s,o,u){return a(c(s,o,u))?m(s,o,u):f(s,o,u)}},t.prototype.forEach=function(n){n(this.condition,"condition",this),n(this.trueExpr,"trueExpr",this),n(this.falseExpr,"falseExpr",this)},t.prototype.map=function(n){return new t(this._ifNode(n(this.condition,"condition",this)),this._ifNode(n(this.trueExpr,"trueExpr",this)),this._ifNode(n(this.falseExpr,"falseExpr",this)))},t.prototype.clone=function(){return new t(this.condition,this.trueExpr,this.falseExpr)},t.prototype._toString=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=sr(this,i),m=this.condition.toString(n),f=sr(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=c)&&(m="("+m+")");var l=this.trueExpr.toString(n),s=sr(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=c)&&(l="("+l+")");var o=this.falseExpr.toString(n),u=sr(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=c)&&(o="("+o+")"),m+" ? "+l+" : "+o},t.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},t.fromJSON=function(n){return new t(n.condition,n.trueExpr,n.falseExpr)},t.prototype.toHTML=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=sr(this,i),m=this.condition.toHTML(n),f=sr(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=c)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>');var l=this.trueExpr.toHTML(n),s=sr(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=c)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>');var o=this.falseExpr.toHTML(n),u=sr(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=c)&&(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>'+l+'<span class="math-operator math-conditional-operator">:</span>'+o},t.prototype._toTex=function(n){return"\\begin{cases} {"+this.trueExpr.toTex(n)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(n)+"}\\\\{"+this.falseExpr.toTex(n)+"}, &\\quad{\\text{otherwise}}\\end{cases}"};function a(n){if(typeof n=="number"||typeof n=="boolean"||typeof n=="string")return!!n;if(n){if(We(n))return!n.isZero();if(Dt(n))return!!(n.re||n.im);if(la(n))return!!n.value}if(n==null)return!1;throw new TypeError('Unsupported type of condition "'+cr(n)+'"')}return t},{isClass:!0,isNode:!0}),$o=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},R2={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},F2={"\u2013":"\\--","\u2014":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},q2=function(e,t){return $o({},e,t)},z2=function(r){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.preserveFormatting,a=t===void 0?!1:t,n=e.escapeMapFn,i=n===void 0?q2:n,c=String(r),m="",f=i($o({},R2),a?$o({},F2):{}),l=Object.keys(f),s=function(){var u=!1;l.forEach(function(p,v){u||c.length>=p.length&&c.slice(0,p.length)===p&&(m+=f[l[v]],c=c.slice(p.length,c.length),u=!0)}),u||(m+=c.slice(0,1),c=c.slice(1,c.length))};c;)s();return m};const P2=z2;var To={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{?}"},Ke={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"},Vm={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(Ke.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(Ke.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(Ke.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(Ke.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(Ke.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(Ke.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(Ke.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(Ke.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(Ke.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(Ke.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(Ke.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(Ke.bitAnd,"${args[1]}\\right)")},bitNot:{1:Ke.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(Ke.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(Ke.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(Ke.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(Ke.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(Ke.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(Ke.and,"${args[1]}\\right)")},not:{1:Ke.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(Ke.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(Ke.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(Ke.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(Ke.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(Ke.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(Ke.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(Ke.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(Ke.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(Ke.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(Ke.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(Ke.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(Ke.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(Ke.to,"${args[1]}\\right)")},numeric:function(e,t){return e.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(To.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)"}},U2="\\mathrm{${name}}\\left(${args}\\right)",Gm={deg:"^\\circ"};function Do(r){return P2(r,{preserveFormatting:!0})}function Hm(r,e){return e=typeof e>"u"?!1:e,e?De(Gm,r)?Gm[r]:"\\mathrm{"+Do(r)+"}":De(To,r)?To[r]:Do(r)}var L2="ConstantNode",k2=["Node"],V2=q(L2,k2,r=>{var{Node:e}=r;function t(a){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.value=a}return t.prototype=new e,t.prototype.type="ConstantNode",t.prototype.isConstantNode=!0,t.prototype._compile=function(a,n){var i=this.value;return function(){return i}},t.prototype.forEach=function(a){},t.prototype.map=function(a){return this.clone()},t.prototype.clone=function(){return new t(this.value)},t.prototype._toString=function(a){return Ge(this.value,a)},t.prototype.toHTML=function(a){var n=this._toString(a);switch(cr(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+n+"</span>";case"string":return'<span class="math-string">'+n+"</span>";case"boolean":return'<span class="math-boolean">'+n+"</span>";case"null":return'<span class="math-null-symbol">'+n+"</span>";case"undefined":return'<span class="math-undefined">'+n+"</span>";default:return'<span class="math-symbol">'+n+"</span>"}},t.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},t.fromJSON=function(a){return new t(a.value)},t.prototype._toTex=function(a){var n=this._toString(a);switch(cr(this.value)){case"string":return"\\mathtt{"+Do(n)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var i=n.toLowerCase().indexOf("e");if(i!==-1)return n.substring(0,i)+"\\cdot10^{"+n.substring(i+1)+"}"}return n;case"Fraction":return this.value.toLatex();default:return n}},t},{isClass:!0,isNode:!0}),G2="FunctionAssignmentNode",H2=["typed","Node"],Z2=q(G2,H2,r=>{var{typed:e,Node:t}=r;function a(i,c,m){if(!(this instanceof a))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(c))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!tr(m))throw new TypeError('Node expected for parameter "expr"');if(Lm.has(i))throw new Error('Illegal function name, "'+i+'" is a reserved keyword');this.name=i,this.params=c.map(function(f){return f&&f.name||f}),this.types=c.map(function(f){return f&&f.type||"any"}),this.expr=m}a.prototype=new t,a.prototype.type="FunctionAssignmentNode",a.prototype.isFunctionAssignmentNode=!0,a.prototype._compile=function(i,c){var m=Object.create(c);Ya(this.params,function(p){m[p]=!0});var f=this.expr._compile(i,m),l=this.name,s=this.params,o=mu(this.types,","),u=l+"("+mu(this.params,", ")+")";return function(v,h,b){var w={};w[o]=function(){for(var d=Object.create(h),y=0;y<s.length;y++)d[s[y]]=arguments[y];return f(v,d,b)};var N=e(l,w);return N.syntax=u,v.set(l,N),N}},a.prototype.forEach=function(i){i(this.expr,"expr",this)},a.prototype.map=function(i){var c=this._ifNode(i(this.expr,"expr",this));return new a(this.name,this.params.slice(0),c)},a.prototype.clone=function(){return new a(this.name,this.params.slice(0),this.expr)};function n(i,c){var m=sr(i,c),f=sr(i.expr,c);return c==="all"||f!==null&&f<=m}return a.prototype._toString=function(i){var c=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toString(i);return n(this,c)&&(m="("+m+")"),this.name+"("+this.params.join(", ")+") = "+m},a.prototype.toJSON=function(){var i=this.types;return{mathjs:"FunctionAssignmentNode",name:this.name,params:this.params.map(function(c,m){return{name:c,type:i[m]}}),expr:this.expr}},a.fromJSON=function(i){return new a(i.name,i.params,i.expr)},a.prototype.toHTML=function(i){for(var c=i&&i.parenthesis?i.parenthesis:"keep",m=[],f=0;f<this.params.length;f++)m.push('<span class="math-symbol math-parameter">'+et(this.params[f])+"</span>");var l=this.expr.toHTML(i);return n(this,c)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+et(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>'+l},a.prototype._toTex=function(i){var c=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toTex(i);return n(this,c)&&(m="\\left(".concat(m,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(Hm).join(",")+"\\right):="+m},a},{isClass:!0,isNode:!0}),J2="IndexNode",W2=["Node","size"],X2=q(J2,W2,r=>{var{Node:e,size:t}=r;function a(n,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=n,this.dotNotation=i||!1,!Array.isArray(n)||!n.every(tr))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 a.prototype=new e,a.prototype.type="IndexNode",a.prototype.isIndexNode=!0,a.prototype._compile=function(n,i){var c=Bt(this.dimensions,function(f,l){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(n,o);return function(v,h,b){if(!Fe(b)&&!ar(b)&&!Zr(b))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+cr(b));var w=t(b).valueOf(),N=Object.create(h);return N.end=w[l],u(v,N,b)}}else return f._compile(n,i)}),m=rt(n,"index");return function(l,s,o){var u=Bt(c,function(p){return p(l,s,o)});return m(...u)}},a.prototype.forEach=function(n){for(var i=0;i<this.dimensions.length;i++)n(this.dimensions[i],"dimensions["+i+"]",this)},a.prototype.map=function(n){for(var i=[],c=0;c<this.dimensions.length;c++)i[c]=this._ifNode(n(this.dimensions[c],"dimensions["+c+"]",this));return new a(i,this.dotNotation)},a.prototype.clone=function(){return new a(this.dimensions.slice(0),this.dotNotation)},a.prototype.isObjectProperty=function(){return this.dimensions.length===1&&ir(this.dimensions[0])&&typeof this.dimensions[0].value=="string"},a.prototype.getObjectProperty=function(){return this.isObjectProperty()?this.dimensions[0].value:null},a.prototype._toString=function(n){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"IndexNode",dimensions:this.dimensions,dotNotation:this.dotNotation}},a.fromJSON=function(n){return new a(n.dimensions,n.dotNotation)},a.prototype.toHTML=function(n){for(var i=[],c=0;c<this.dimensions.length;c++)i[c]=this.dimensions[c].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+et(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>'},a.prototype._toTex=function(n){var i=this.dimensions.map(function(c){return c.toTex(n)});return this.dotNotation?"."+this.getObjectProperty():"_{"+i.join(",")+"}"},a},{isClass:!0,isNode:!0}),Y2="ObjectNode",Q2=["Node"],j2=q(Y2,Q2,r=>{var{Node:e}=r;function t(a){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=a||{},a&&(typeof a!="object"||!Object.keys(a).every(function(n){return tr(a[n])})))throw new TypeError("Object containing Nodes expected")}return t.prototype=new e,t.prototype.type="ObjectNode",t.prototype.isObjectNode=!0,t.prototype._compile=function(a,n){var i={};for(var c in this.properties)if(De(this.properties,c)){var m=Wa(c),f=JSON.parse(m);if(!to(this.properties,f))throw new Error('No access to property "'+f+'"');i[f]=this.properties[c]._compile(a,n)}return function(s,o,u){var p={};for(var v in i)De(i,v)&&(p[v]=i[v](s,o,u));return p}},t.prototype.forEach=function(a){for(var n in this.properties)De(this.properties,n)&&a(this.properties[n],"properties["+Wa(n)+"]",this)},t.prototype.map=function(a){var n={};for(var i in this.properties)De(this.properties,i)&&(n[i]=this._ifNode(a(this.properties[i],"properties["+Wa(i)+"]",this)));return new t(n)},t.prototype.clone=function(){var a={};for(var n in this.properties)De(this.properties,n)&&(a[n]=this.properties[n]);return new t(a)},t.prototype._toString=function(a){var n=[];for(var i in this.properties)De(this.properties,i)&&n.push(Wa(i)+": "+this.properties[i].toString(a));return"{"+n.join(", ")+"}"},t.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},t.fromJSON=function(a){return new t(a.properties)},t.prototype.toHTML=function(a){var n=[];for(var i in this.properties)De(this.properties,i)&&n.push('<span class="math-symbol math-property">'+et(i)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[i].toHTML(a));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+n.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'},t.prototype._toTex=function(a){var n=[];for(var i in this.properties)De(this.properties,i)&&n.push("\\mathbf{"+i+":} & "+this.properties[i].toTex(a)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(n.join(`
31
+ `),"\\end{array}\\right\\}")},t},{isClass:!0,isNode:!0}),K2="OperatorNode",eA=["Node"],rA=q(K2,eA,r=>{var{Node:e}=r;function t(n,i,c,m,f){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(typeof n!="string")throw new TypeError('string expected for parameter "op"');if(typeof i!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(c)||!c.every(tr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=m===!0,this.isPercentage=f===!0,this.op=n,this.fn=i,this.args=c||[]}t.prototype=new e,t.prototype.type="OperatorNode",t.prototype.isOperatorNode=!0,t.prototype._compile=function(n,i){if(typeof this.fn!="string"||!no(n,this.fn))throw n[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var c=rt(n,this.fn),m=Bt(this.args,function(o){return o._compile(n,i)});if(m.length===1){var f=m[0];return function(u,p,v){return c(f(u,p,v))}}else if(m.length===2){var l=m[0],s=m[1];return function(u,p,v){return c(l(u,p,v),s(u,p,v))}}else return function(u,p,v){return c.apply(null,Bt(m,function(h){return h(u,p,v)}))}},t.prototype.forEach=function(n){for(var i=0;i<this.args.length;i++)n(this.args[i],"args["+i+"]",this)},t.prototype.map=function(n){for(var i=[],c=0;c<this.args.length;c++)i[c]=this._ifNode(n(this.args[c],"args["+c+"]",this));return new t(this.op,this.fn,i,this.implicit,this.isPercentage)},t.prototype.clone=function(){return new t(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)},t.prototype.isUnary=function(){return this.args.length===1},t.prototype.isBinary=function(){return this.args.length===2};function a(n,i,c,m,f){var l=sr(n,i),s=wa(n,i);if(i==="all"||m.length>2&&n.getIdentifier()!=="OperatorNode:add"&&n.getIdentifier()!=="OperatorNode:multiply")return m.map(function(A){switch(A.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=sr(m[0],i);if(f&&u!==null){var p,v;if(i==="keep"?(p=m[0].getIdentifier(),v=n.getIdentifier()):(p=m[0].getContent().getIdentifier(),v=n.getContent().getIdentifier()),Nt[l][v].latexLeftParens===!1){o=[!1];break}if(Nt[u][p].latexParens===!1){o=[!1];break}}if(u===null){o=[!1];break}if(u<=l){o=[!0];break}o=[!1]}break;case 2:{var h,b=sr(m[0],i),w=Oo(n,m[0],i);b===null?h=!1:b===l&&s==="right"&&!w||b<l?h=!0:h=!1;var N,d=sr(m[1],i),y=Oo(n,m[1],i);if(d===null?N=!1:d===l&&s==="left"&&!y||d<l?N=!0:N=!1,f){var x,g,S;i==="keep"?(x=n.getIdentifier(),g=n.args[0].getIdentifier(),S=n.args[1].getIdentifier()):(x=n.getContent().getIdentifier(),g=n.args[0].getContent().getIdentifier(),S=n.args[1].getContent().getIdentifier()),b!==null&&(Nt[l][x].latexLeftParens===!1&&(h=!1),Nt[b][g].latexParens===!1&&(h=!1)),d!==null&&(Nt[l][x].latexRightParens===!1&&(N=!1),Nt[d][S].latexParens===!1&&(N=!1))}o=[h,N]}break;default:(n.getIdentifier()==="OperatorNode:add"||n.getIdentifier()==="OperatorNode:multiply")&&(o=m.map(function(A){var E=sr(A,i),M=Oo(n,A,i),B=wa(A,i);return E===null?!1:l===E&&s===B&&!M?!0:E<l}));break}return m.length>=2&&n.getIdentifier()==="OperatorNode:multiply"&&n.implicit&&i==="auto"&&c==="hide"&&(o=m.map(function(A,E){var M=A.getIdentifier()==="ParenthesisNode";return!!(o[E]||M)})),o}return t.prototype._toString=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=n&&n.implicit?n.implicit:"hide",m=this.args,f=a(this,i,c,m,!1);if(m.length===1){var l=wa(this,i),s=m[0].toString(n);f[0]&&(s="("+s+")");var o=/[a-zA-Z]+/.test(this.op);return l==="right"?this.op+(o?" ":"")+s:l==="left"?s+(o?" ":"")+this.op:s+this.op}else if(m.length===2){var u=m[0].toString(n),p=m[1].toString(n);return f[0]&&(u="("+u+")"),f[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&c==="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(n),f[b]&&(h="("+h+")"),h});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&c==="hide"?v.join(" "):v.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"},t.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},t.fromJSON=function(n){return new t(n.op,n.fn,n.args,n.implicit,n.isPercentage)},t.prototype.toHTML=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=n&&n.implicit?n.implicit:"hide",m=this.args,f=a(this,i,c,m,!1);if(m.length===1){var l=wa(this,i),s=m[0].toHTML(n);return f[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+et(this.op)+"</span>"+s:s+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+et(this.op)+"</span>"}else if(m.length===2){var o=m[0].toHTML(n),u=m[1].toHTML(n);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"&&c==="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">'+et(this.op)+"</span>"+u}else{var p=m.map(function(v,h){return v=v.toHTML(n),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"&&c==="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">'+et(this.op)+"</span>"):'<span class="math-function">'+et(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>'}},t.prototype._toTex=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=n&&n.implicit?n.implicit:"hide",m=this.args,f=a(this,i,c,m,!0),l=Ke[this.fn];if(l=typeof l>"u"?this.op:l,m.length===1){var s=wa(this,i),o=m[0].toTex(n);return f[0]&&(o="\\left(".concat(o,"\\right)")),s==="right"?l+o:o+l}else if(m.length===2){var u=m[0],p=u.toTex(n);f[0]&&(p="\\left(".concat(p,"\\right)"));var v=m[1],h=v.toTex(n);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 l+"{"+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&&c==="hide")return p+"~"+h}return p+l+h}else if(m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var w=m.map(function(N,d){return N=N.toTex(n),f[d]&&(N="\\left(".concat(N,"\\right)")),N});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit?w.join("~"):w.join(l)}else return"\\mathrm{"+this.fn+"}\\left("+m.map(function(N){return N.toTex(n)}).join(",")+"\\right)"},t.prototype.getIdentifier=function(){return this.type+":"+this.fn},t},{isClass:!0,isNode:!0}),tA="ParenthesisNode",nA=["Node"],aA=q(tA,nA,r=>{var{Node:e}=r;function t(a){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!tr(a))throw new TypeError('Node expected for parameter "content"');this.content=a}return t.prototype=new e,t.prototype.type="ParenthesisNode",t.prototype.isParenthesisNode=!0,t.prototype._compile=function(a,n){return this.content._compile(a,n)},t.prototype.getContent=function(){return this.content.getContent()},t.prototype.forEach=function(a){a(this.content,"content",this)},t.prototype.map=function(a){var n=a(this.content,"content",this);return new t(n)},t.prototype.clone=function(){return new t(this.content)},t.prototype._toString=function(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"("+this.content.toString(a)+")":this.content.toString(a)},t.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},t.fromJSON=function(a){return new t(a.content)},t.prototype.toHTML=function(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(a)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(a)},t.prototype._toTex=function(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"\\left(".concat(this.content.toTex(a),"\\right)"):this.content.toTex(a)},t},{isClass:!0,isNode:!0}),iA="RangeNode",oA=["Node"],sA=q(iA,oA,r=>{var{Node:e}=r;function t(n,i,c){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!tr(n))throw new TypeError("Node expected");if(!tr(i))throw new TypeError("Node expected");if(c&&!tr(c))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=n,this.end=i,this.step=c||null}t.prototype=new e,t.prototype.type="RangeNode",t.prototype.isRangeNode=!0,t.prototype.needsEnd=function(){var n=this.filter(function(i){return Dr(i)&&i.name==="end"});return n.length>0},t.prototype._compile=function(n,i){var c=n.range,m=this.start._compile(n,i),f=this.end._compile(n,i);if(this.step){var l=this.step._compile(n,i);return function(o,u,p){return c(m(o,u,p),f(o,u,p),l(o,u,p))}}else return function(o,u,p){return c(m(o,u,p),f(o,u,p))}},t.prototype.forEach=function(n){n(this.start,"start",this),n(this.end,"end",this),this.step&&n(this.step,"step",this)},t.prototype.map=function(n){return new t(this._ifNode(n(this.start,"start",this)),this._ifNode(n(this.end,"end",this)),this.step&&this._ifNode(n(this.step,"step",this)))},t.prototype.clone=function(){return new t(this.start,this.end,this.step&&this.step)};function a(n,i){var c=sr(n,i),m={},f=sr(n.start,i);if(m.start=f!==null&&f<=c||i==="all",n.step){var l=sr(n.step,i);m.step=l!==null&&l<=c||i==="all"}var s=sr(n.end,i);return m.end=s!==null&&s<=c||i==="all",m}return t.prototype._toString=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=a(this,i),m,f=this.start.toString(n);if(c.start&&(f="("+f+")"),m=f,this.step){var l=this.step.toString(n);c.step&&(l="("+l+")"),m+=":"+l}var s=this.end.toString(n);return c.end&&(s="("+s+")"),m+=":"+s,m},t.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},t.fromJSON=function(n){return new t(n.start,n.end,n.step)},t.prototype.toHTML=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=a(this,i),m,f=this.start.toHTML(n);if(c.start&&(f='<span class="math-parenthesis math-round-parenthesis">(</span>'+f+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m=f,this.step){var l=this.step.toHTML(n);c.step&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+='<span class="math-operator math-range-operator">:</span>'+l}var s=this.end.toHTML(n);return c.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},t.prototype._toTex=function(n){var i=n&&n.parenthesis?n.parenthesis:"keep",c=a(this,i),m=this.start.toTex(n);if(c.start&&(m="\\left(".concat(m,"\\right)")),this.step){var f=this.step.toTex(n);c.step&&(f="\\left(".concat(f,"\\right)")),m+=":"+f}var l=this.end.toTex(n);return c.end&&(l="\\left(".concat(l,"\\right)")),m+=":"+l,m},t},{isClass:!0,isNode:!0}),uA="RelationalNode",cA=["Node"],lA=q(uA,cA,r=>{var{Node:e}=r;function t(a,n){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(a))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(n))throw new TypeError("Parameter params must be an array");if(a.length!==n.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=a,this.params=n}return t.prototype=new e,t.prototype.type="RelationalNode",t.prototype.isRelationalNode=!0,t.prototype._compile=function(a,n){var i=this,c=this.params.map(m=>m._compile(a,n));return function(f,l,s){for(var o,u=c[0](f,l,s),p=0;p<i.conditionals.length;p++){o=u,u=c[p+1](f,l,s);var v=rt(a,i.conditionals[p]);if(!v(o,u))return!1}return!0}},t.prototype.forEach=function(a){this.params.forEach((n,i)=>a(n,"params["+i+"]",this),this)},t.prototype.map=function(a){return new t(this.conditionals.slice(),this.params.map((n,i)=>this._ifNode(a(n,"params["+i+"]",this)),this))},t.prototype.clone=function(){return new t(this.conditionals,this.params)},t.prototype._toString=function(a){for(var n=a&&a.parenthesis?a.parenthesis:"keep",i=sr(this,n),c=this.params.map(function(s,o){var u=sr(s,n);return n==="all"||u!==null&&u<=i?"("+s.toString(a)+")":s.toString(a)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=c[0],l=0;l<this.conditionals.length;l++)f+=" "+m[this.conditionals[l]]+" "+c[l+1];return f},t.prototype.toJSON=function(){return{mathjs:"RelationalNode",conditionals:this.conditionals,params:this.params}},t.fromJSON=function(a){return new t(a.conditionals,a.params)},t.prototype.toHTML=function(a){for(var n=a&&a.parenthesis?a.parenthesis:"keep",i=sr(this,n),c=this.params.map(function(s,o){var u=sr(s,n);return n==="all"||u!==null&&u<=i?'<span class="math-parenthesis math-round-parenthesis">(</span>'+s.toHTML(a)+'<span class="math-parenthesis math-round-parenthesis">)</span>':s.toHTML(a)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=c[0],l=0;l<this.conditionals.length;l++)f+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+et(m[this.conditionals[l]])+"</span>"+c[l+1];return f},t.prototype._toTex=function(a){for(var n=a&&a.parenthesis?a.parenthesis:"keep",i=sr(this,n),c=this.params.map(function(l,s){var o=sr(l,n);return n==="all"||o!==null&&o<=i?"\\left("+l.toTex(a)+"\right)":l.toTex(a)}),m=c[0],f=0;f<this.conditionals.length;f++)m+=Ke[this.conditionals[f]]+c[f+1];return m},t},{isClass:!0,isNode:!0}),fA="SymbolNode",mA=["math","?Unit","Node"],pA=q(fA,mA,r=>{var{math:e,Unit:t,Node:a}=r;function n(c){return t?t.isValuelessUnit(c):!1}function i(c){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(typeof c!="string")throw new TypeError('String expected for parameter "name"');this.name=c}return i.prototype=new a,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(c,m){var f=this.name;if(m[f]===!0)return function(s,o,u){return o[f]};if(f in c)return function(s,o,u){return s.has(f)?s.get(f):rt(c,f)};var l=n(f);return function(s,o,u){return s.has(f)?s.get(f):l?new t(null,f):i.onUndefinedSymbol(f)}},i.prototype.forEach=function(c){},i.prototype.map=function(c){return this.clone()},i.onUndefinedSymbol=function(c){throw new Error("Undefined symbol "+c)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(c){return this.name},i.prototype.toHTML=function(c){var m=et(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(c){return new i(c.name)},i.prototype._toTex=function(c){var m=!1;typeof e[this.name]>"u"&&n(this.name)&&(m=!0);var f=Hm(this.name,m);return f[0]==="\\"?f:" "+f},i},{isClass:!0,isNode:!0});function Na(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];return typeof r.createSubScope=="function"?vu(r.createSubScope(),...t):vu(_t(),r,...t)}var vA="FunctionNode",hA=["math","Node","SymbolNode"],dA=q(vA,hA,r=>{var{math:e,Node:t,SymbolNode:a}=r;function n(l,s){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(typeof l=="string"&&(l=new a(l)),!tr(l))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(s)||!s.every(tr))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=l,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")}})}n.prototype=new t,n.prototype.type="FunctionNode",n.prototype.isFunctionNode=!0;var i=l=>Ge(l,{truncate:78});n.prototype._compile=function(l,s){if(!(this instanceof n))throw new TypeError("No valid FunctionNode");var o=this.args.map(A=>A._compile(l,s));if(Dr(this.fn)){var u=this.fn.name;if(s[u]){var w=this.args;return function(E,M,B){var C=M[u];if(typeof C!="function")throw new TypeError("Argument '".concat(u,"' was not a function; received: ").concat(i(C)));if(C.rawArgs)return C(w,l,Na(E,M),E);var _=o.map(P=>P(E,M,B));return C.apply(C,_)}}else{var p=u in l?rt(l,u):void 0,v=typeof p=="function"&&p.rawArgs===!0,h=A=>{var E;if(A.has(u))E=A.get(u);else if(u in l)E=rt(l,u);else return n.onUndefinedFunction(u);if(typeof E=="function")return E;throw new TypeError("'".concat(u,`' is not a function; its value is:
32
+ `).concat(i(E)))};if(v){var b=this.args;return function(E,M,B){var C=h(E);return C(b,l,Na(E,M),E)}}else switch(o.length){case 0:return function(E,M,B){var C=h(E);return C()};case 1:return function(E,M,B){var C=h(E),_=o[0];return C(_(E,M,B))};case 2:return function(E,M,B){var C=h(E),_=o[0],P=o[1];return C(_(E,M,B),P(E,M,B))};default:return function(E,M,B){var C=h(E),_=o.map(P=>P(E,M,B));return C(..._)}}}}else if(cn(this.fn)&&On(this.fn.index)&&this.fn.index.isObjectProperty()){var N=this.fn.object._compile(l,s),d=this.fn.index.getObjectProperty(),y=this.args;return function(E,M,B){var C=N(E,M,B);Wd(C,d);var _=C[d]&&C[d].rawArgs;if(_)return C[d](y,l,Na(E,M),E);var P=o.map(I=>I(E,M,B));return C[d].apply(C,P)}}else{var x=this.fn.toString(),g=this.fn._compile(l,s),S=this.args;return function(E,M,B){var C=g(E,M,B);if(typeof C!="function")throw new TypeError("Expression '".concat(x,"' did not evaluate to a function; value is:")+`
33
+ `.concat(i(C)));if(C.rawArgs)return C(S,l,Na(E,M),E);var _=o.map(P=>P(E,M,B));return C.apply(C,_)}}},n.prototype.forEach=function(l){l(this.fn,"fn",this);for(var s=0;s<this.args.length;s++)l(this.args[s],"args["+s+"]",this)},n.prototype.map=function(l){for(var s=this._ifNode(l(this.fn,"fn",this)),o=[],u=0;u<this.args.length;u++)o[u]=this._ifNode(l(this.args[u],"args["+u+"]",this));return new n(s,o)},n.prototype.clone=function(){return new n(this.fn,this.args.slice(0))},n.onUndefinedFunction=function(l){throw new Error("Undefined function "+l)};var c=n.prototype.toString;n.prototype.toString=function(l){var s,o=this.fn.toString(l);return l&&typeof l.handler=="object"&&De(l.handler,o)&&(s=l.handler[o](this,l)),typeof s<"u"?s:c.call(this,l)},n.prototype._toString=function(l){var s=this.args.map(function(u){return u.toString(l)}),o=ma(this.fn)?"("+this.fn.toString(l)+")":this.fn.toString(l);return o+"("+s.join(", ")+")"},n.prototype.toJSON=function(){return{mathjs:"FunctionNode",fn:this.fn,args:this.args}},n.fromJSON=function(l){return new n(l.fn,l.args)},n.prototype.toHTML=function(l){var s=this.args.map(function(o){return o.toHTML(l)});return'<span class="math-function">'+et(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(l,s,o){for(var u="",p=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,v=0,h;(h=p.exec(l))!==null;)if(u+=l.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(tr(b))u+=b.toTex(o);else if(Array.isArray(b))u+=b.map(function(w,N){if(tr(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(tr(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+=l.slice(v),u}var f=n.prototype.toTex;return n.prototype.toTex=function(l){var s;return l&&typeof l.handler=="object"&&De(l.handler,this.name)&&(s=l.handler[this.name](this,l)),typeof s<"u"?s:f.call(this,l)},n.prototype._toTex=function(l){var s=this.args.map(function(p){return p.toTex(l)}),o;Vm[this.name]&&(o=Vm[this.name]),e[this.name]&&(typeof e[this.name].toTex=="function"||typeof e[this.name].toTex=="object"||typeof e[this.name].toTex=="string")&&(o=e[this.name].toTex);var u;switch(typeof o){case"function":u=o(this,l);break;case"string":u=m(o,this,l);break;case"object":switch(typeof o[s.length]){case"function":u=o[s.length](this,l);break;case"string":u=m(o[s.length],this,l);break}}return typeof u<"u"?u:m(U2,this,l)},n.prototype.getIdentifier=function(){return this.type+":"+this.name},n},{isClass:!0,isNode:!0}),Zm="parse",gA=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],yA=q(Zm,gA,r=>{var{typed:e,numeric:t,config:a,AccessorNode:n,ArrayNode:i,AssignmentNode:c,BlockNode:m,ConditionalNode:f,ConstantNode:l,FunctionAssignmentNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,RangeNode:b,RelationalNode:w,SymbolNode:N}=r,d=e(Zm,{string:function(X){return H(X,{})},"Array | Matrix":function(X){return y(X,{})},"string, Object":function(X,ue){var we=ue.nodes!==void 0?ue.nodes:{};return H(X,we)},"Array | Matrix, Object":y});function y(O){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ue=X.nodes!==void 0?X.nodes:{};return $e(O,function(we){if(typeof we!="string")throw new TypeError("String expected");return H(we,ue)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},g={",":!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},S={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},A={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function M(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function B(O,X){return O.expression.substr(O.index,X)}function C(O){return B(O,1)}function _(O){O.index++}function P(O){return O.expression.charAt(O.index-1)}function I(O){return O.expression.charAt(O.index+1)}function T(O){for(O.tokenType=x.NULL,O.token="",O.comment="";;){if(C(O)==="#")for(;C(O)!==`
34
+ `&&C(O)!=="";)O.comment+=C(O),_(O);if(d.isWhitespace(C(O),O.nestingLevel))_(O);else break}if(C(O)===""){O.tokenType=x.DELIMITER;return}if(C(O)===`
35
+ `&&!O.nestingLevel){O.tokenType=x.DELIMITER,O.token=C(O),_(O);return}var X=C(O),ue=B(O,2),we=B(O,3);if(we.length===3&&g[we]){O.tokenType=x.DELIMITER,O.token=we,_(O),_(O),_(O);return}if(ue.length===2&&g[ue]){O.tokenType=x.DELIMITER,O.token=ue,_(O),_(O);return}if(g[X]){O.tokenType=x.DELIMITER,O.token=X,_(O);return}if(d.isDigitDot(X)){O.tokenType=x.NUMBER;var ke=B(O,2);if(ke==="0b"||ke==="0o"||ke==="0x"){for(O.token+=C(O),_(O),O.token+=C(O),_(O);d.isHexDigit(C(O));)O.token+=C(O),_(O);if(C(O)===".")for(O.token+=".",_(O);d.isHexDigit(C(O));)O.token+=C(O),_(O);else if(C(O)==="i")for(O.token+="i",_(O);d.isDigit(C(O));)O.token+=C(O),_(O);return}if(C(O)==="."){if(O.token+=C(O),_(O),!d.isDigit(C(O))){O.tokenType=x.DELIMITER;return}}else{for(;d.isDigit(C(O));)O.token+=C(O),_(O);d.isDecimalMark(C(O),I(O))&&(O.token+=C(O),_(O))}for(;d.isDigit(C(O));)O.token+=C(O),_(O);if(C(O)==="E"||C(O)==="e"){if(d.isDigit(I(O))||I(O)==="-"||I(O)==="+"){if(O.token+=C(O),_(O),(C(O)==="+"||C(O)==="-")&&(O.token+=C(O),_(O)),!d.isDigit(C(O)))throw er(O,'Digit expected, got "'+C(O)+'"');for(;d.isDigit(C(O));)O.token+=C(O),_(O);if(d.isDecimalMark(C(O),I(O)))throw er(O,'Digit expected, got "'+C(O)+'"')}else if(I(O)===".")throw _(O),er(O,'Digit expected, got "'+C(O)+'"')}return}if(d.isAlpha(C(O),P(O),I(O))){for(;d.isAlpha(C(O),P(O),I(O))||d.isDigit(C(O));)O.token+=C(O),_(O);De(S,O.token)?O.tokenType=x.DELIMITER:O.tokenType=x.SYMBOL;return}for(O.tokenType=x.UNKNOWN;C(O)!=="";)O.token+=C(O),_(O);throw er(O,'Syntax error in part "'+O.token+'"')}function D(O){do T(O);while(O.token===`
36
+ `)}function Z(O){O.nestingLevel++}function $(O){O.nestingLevel--}d.isAlpha=function(X,ue,we){return d.isValidLatinOrGreek(X)||d.isValidMathSymbol(X,we)||d.isValidMathSymbol(ue,X)},d.isValidLatinOrGreek=function(X){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(X)},d.isValidMathSymbol=function(X,ue){return/^[\uD835]$/.test(X)&&/^[\uDC00-\uDFFF]$/.test(ue)&&/^[^\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(ue)},d.isWhitespace=function(X,ue){return X===" "||X===" "||X===`
37
+ `&&ue>0},d.isDecimalMark=function(X,ue){return X==="."&&ue!=="/"&&ue!=="*"&&ue!=="^"},d.isDigitDot=function(X){return X>="0"&&X<="9"||X==="."},d.isDigit=function(X){return X>="0"&&X<="9"},d.isHexDigit=function(X){return X>="0"&&X<="9"||X>="a"&&X<="f"||X>="A"&&X<="F"};function H(O,X){var ue=M();Rr(ue,{expression:O,extraNodes:X}),T(ue);var we=Q(ue);if(ue.token!=="")throw ue.tokenType===x.DELIMITER?$t(ue,"Unexpected operator "+ue.token):er(ue,'Unexpected part "'+ue.token+'"');return we}function Q(O){var X,ue=[],we;for(O.token!==""&&O.token!==`
38
+ `&&O.token!==";"&&(X=te(O),X.comment=O.comment);O.token===`
39
+ `||O.token===";";)ue.length===0&&X&&(we=O.token!==";",ue.push({node:X,visible:we})),T(O),O.token!==`
40
+ `&&O.token!==";"&&O.token!==""&&(X=te(O),X.comment=O.comment,we=O.token!==";",ue.push({node:X,visible:we}));return ue.length>0?new m(ue):(X||(X=new l(void 0),X.comment=O.comment),X)}function te(O){var X,ue,we,ke,Xe=J(O);if(O.token==="="){if(Dr(Xe))return X=Xe.name,D(O),we=te(O),new c(new N(X),we);if(cn(Xe))return D(O),we=te(O),new c(Xe.object,Xe.index,we);if(ln(Xe)&&Dr(Xe.fn)&&(ke=!0,ue=[],X=Xe.name,Xe.args.forEach(function(Sr,La){Dr(Sr)?ue[La]=Sr.name:ke=!1}),ke))return D(O),we=te(O),new s(X,ue,we);throw er(O,"Invalid left hand side of assignment operator =")}return Xe}function J(O){for(var X=re(O);O.token==="?";){var ue=O.conditionalLevel;O.conditionalLevel=O.nestingLevel,D(O);var we=X,ke=te(O);if(O.token!==":")throw er(O,"False part of conditional expression expected");O.conditionalLevel=null,D(O);var Xe=te(O);X=new f(we,ke,Xe),O.conditionalLevel=ue}return X}function re(O){for(var X=oe(O);O.token==="or";)D(O),X=new v("or","or",[X,oe(O)]);return X}function oe(O){for(var X=ae(O);O.token==="xor";)D(O),X=new v("xor","xor",[X,ae(O)]);return X}function ae(O){for(var X=ce(O);O.token==="and";)D(O),X=new v("and","and",[X,ce(O)]);return X}function ce(O){for(var X=se(O);O.token==="|";)D(O),X=new v("|","bitOr",[X,se(O)]);return X}function se(O){for(var X=me(O);O.token==="^|";)D(O),X=new v("^|","bitXor",[X,me(O)]);return X}function me(O){for(var X=ne(O);O.token==="&";)D(O),X=new v("&","bitAnd",[X,ne(O)]);return X}function ne(O){for(var X=[Ae(O)],ue=[],we={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};De(we,O.token);){var ke={name:O.token,fn:we[O.token]};ue.push(ke),D(O),X.push(Ae(O))}return X.length===1?X[0]:X.length===2?new v(ue[0].name,ue[0].fn,X):new w(ue.map(Xe=>Xe.fn),X)}function Ae(O){var X,ue,we,ke;X=Ce(O);for(var Xe={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};De(Xe,O.token);)ue=O.token,we=Xe[ue],D(O),ke=[X,Ce(O)],X=new v(ue,we,ke);return X}function Ce(O){var X,ue,we,ke;X=ge(O);for(var Xe={to:"to",in:"to"};De(Xe,O.token);)ue=O.token,we=Xe[ue],D(O),ue==="in"&&O.token===""?X=new v("*","multiply",[X,new N("in")],!0):(ke=[X,ge(O)],X=new v(ue,we,ke));return X}function ge(O){var X,ue=[];if(O.token===":"?X=new l(1):X=Se(O),O.token===":"&&O.conditionalLevel!==O.nestingLevel){for(ue.push(X);O.token===":"&&ue.length<3;)D(O),O.token===")"||O.token==="]"||O.token===","||O.token===""?ue.push(new N("end")):ue.push(Se(O));ue.length===3?X=new b(ue[0],ue[2],ue[1]):X=new b(ue[0],ue[1])}return X}function Se(O){var X,ue,we,ke;X=z(O);for(var Xe={"+":"add","-":"subtract"};De(Xe,O.token);){ue=O.token,we=Xe[ue],D(O);var Sr=z(O);Sr.isPercentage?ke=[X,new v("*","multiply",[X,Sr])]:ke=[X,Sr],X=new v(ue,we,ke)}return X}function z(O){var X,ue,we,ke;X=Y(O),ue=X;for(var Xe={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};De(Xe,O.token);)we=O.token,ke=Xe[we],D(O),ue=Y(O),X=new v(we,ke,[X,ue]);return X}function Y(O){var X,ue;for(X=V(O),ue=X;O.tokenType===x.SYMBOL||O.token==="in"&&ir(X)||O.tokenType===x.NUMBER&&!ir(ue)&&(!Jr(ue)||ue.op==="!")||O.token==="(";)ue=V(O),X=new v("*","multiply",[X,ue],!0);return X}function V(O){for(var X=L(O),ue=X,we=[];O.token==="/"&&ir(ue);)if(we.push(Rr({},O)),D(O),O.tokenType===x.NUMBER)if(we.push(Rr({},O)),D(O),O.tokenType===x.SYMBOL||O.token==="(")Rr(O,we.pop()),we.pop(),ue=L(O),X=new v("/","divide",[X,ue]);else{we.pop(),Rr(O,we.pop());break}else{Rr(O,we.pop());break}return X}function L(O){var X,ue,we,ke;X=j(O);for(var Xe={"%":"mod",mod:"mod"};De(Xe,O.token);)ue=O.token,we=Xe[ue],D(O),ue==="%"&&O.tokenType===x.DELIMITER&&O.token!=="("?X=new v("/","divide",[X,new l(100)],!1,!0):(ke=[X,j(O)],X=new v(ue,we,ke));return X}function j(O){var X,ue,we,ke={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return De(ke,O.token)?(we=ke[O.token],X=O.token,D(O),ue=[j(O)],new v(X,we,ue)):F(O)}function F(O){var X,ue,we,ke;return X=U(O),(O.token==="^"||O.token===".^")&&(ue=O.token,we=ue==="^"?"pow":"dotPow",D(O),ke=[X,j(O)],X=new v(ue,we,ke)),X}function U(O){var X,ue,we,ke;X=ee(O);for(var Xe={"!":"factorial","'":"ctranspose"};De(Xe,O.token);)ue=O.token,we=Xe[ue],T(O),ke=[X],X=new v(ue,we,ke),X=fe(O,X);return X}function ee(O){var X=[];if(O.tokenType===x.SYMBOL&&De(O.extraNodes,O.token)){var ue=O.extraNodes[O.token];if(T(O),O.token==="("){if(X=[],Z(O),T(O),O.token!==")")for(X.push(te(O));O.token===",";)T(O),X.push(te(O));if(O.token!==")")throw er(O,"Parenthesis ) expected");$(O),T(O)}return new ue(X)}return k(O)}function k(O){var X,ue;return O.tokenType===x.SYMBOL||O.tokenType===x.DELIMITER&&O.token in S?(ue=O.token,T(O),De(A,ue)?X=new l(A[ue]):E.indexOf(ue)!==-1?X=new l(t(ue,"number")):X=new N(ue),X=fe(O,X),X):ve(O)}function fe(O,X,ue){for(var we;(O.token==="("||O.token==="["||O.token===".")&&(!ue||ue.indexOf(O.token)!==-1);)if(we=[],O.token==="(")if(Dr(X)||cn(X)){if(Z(O),T(O),O.token!==")")for(we.push(te(O));O.token===",";)T(O),we.push(te(O));if(O.token!==")")throw er(O,"Parenthesis ) expected");$(O),T(O),X=new o(X,we)}else return X;else if(O.token==="["){if(Z(O),T(O),O.token!=="]")for(we.push(te(O));O.token===",";)T(O),we.push(te(O));if(O.token!=="]")throw er(O,"Parenthesis ] expected");$(O),T(O),X=new n(X,new u(we))}else{if(T(O),O.tokenType!==x.SYMBOL)throw er(O,"Property name expected after dot");we.push(new l(O.token)),T(O);var ke=!0;X=new n(X,new u(we,ke))}return X}function ve(O){var X,ue;return O.token==='"'?(ue=Me(O),X=new l(ue),X=fe(O,X),X):be(O)}function Me(O){for(var X="";C(O)!==""&&C(O)!=='"';)C(O)==="\\"&&(X+=C(O),_(O)),X+=C(O),_(O);if(T(O),O.token!=='"')throw er(O,'End of string " expected');return T(O),JSON.parse('"'+X+'"')}function be(O){var X,ue;return O.token==="'"?(ue=xe(O),X=new l(ue),X=fe(O,X),X):Te(O)}function xe(O){for(var X="";C(O)!==""&&C(O)!=="'";)C(O)==="\\"&&(X+=C(O),_(O)),X+=C(O),_(O);if(T(O),O.token!=="'")throw er(O,"End of string ' expected");return T(O),JSON.parse('"'+X+'"')}function Te(O){var X,ue,we,ke;if(O.token==="["){if(Z(O),T(O),O.token!=="]"){var Xe=nr(O);if(O.token===";"){for(we=1,ue=[Xe];O.token===";";)T(O),ue[we]=nr(O),we++;if(O.token!=="]")throw er(O,"End of matrix ] expected");$(O),T(O),ke=ue[0].items.length;for(var Sr=1;Sr<we;Sr++)if(ue[Sr].items.length!==ke)throw $t(O,"Column dimensions mismatch ("+ue[Sr].items.length+" !== "+ke+")");X=new i(ue)}else{if(O.token!=="]")throw er(O,"End of matrix ] expected");$(O),T(O),X=Xe}}else $(O),T(O),X=new i([]);return fe(O,X)}return dr(O)}function nr(O){for(var X=[te(O)],ue=1;O.token===",";)T(O),X[ue]=te(O),ue++;return new i(X)}function dr(O){if(O.token==="{"){Z(O);var X,ue={};do if(T(O),O.token!=="}"){if(O.token==='"')X=Me(O);else if(O.token==="'")X=xe(O);else if(O.tokenType===x.SYMBOL||O.tokenType===x.DELIMITER&&O.token in S)X=O.token,T(O);else throw er(O,"Symbol or string expected as object key");if(O.token!==":")throw er(O,"Colon : expected after object key");T(O),ue[X]=te(O)}while(O.token===",");if(O.token!=="}")throw er(O,"Comma , or bracket } expected after object value");$(O),T(O);var we=new p(ue);return we=fe(O,we),we}return fr(O)}function fr(O){var X;return O.tokenType===x.NUMBER?(X=O.token,T(O),new l(t(X,a.number))):Gr(O)}function Gr(O){var X;if(O.token==="("){if(Z(O),T(O),X=te(O),O.token!==")")throw er(O,"Parenthesis ) expected");return $(O),T(O),X=new h(X),X=fe(O,X),X}return Hr(O)}function Hr(O){throw O.token===""?er(O,"Unexpected end of expression"):er(O,"Value expected")}function st(O){return O.index-O.token.length+1}function er(O,X){var ue=st(O),we=new SyntaxError(X+" (char "+ue+")");return we.char=ue,we}function $t(O,X){var ue=st(O),we=new SyntaxError(X+" (char "+ue+")");return we.char=ue,we}return d}),Jm="compile",bA=["typed","parse"],xA=q(Jm,bA,r=>{var{typed:e,parse:t}=r;return e(Jm,{string:function(n){return t(n).compile()},"Array | Matrix":function(n){return $e(n,function(i){return t(i).compile()})}})}),Wm="evaluate",wA=["typed","parse"],NA=q(Wm,wA,r=>{var{typed:e,parse:t}=r;return e(Wm,{string:function(n){var i=_t();return t(n).compile().evaluate(i)},"string, Map | Object":function(n,i){return t(n).compile().evaluate(i)},"Array | Matrix":function(n){var i=_t();return $e(n,function(c){return t(c).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(n,i){return $e(n,function(c){return t(c).compile().evaluate(i)})}})}),MA="Parser",AA=["evaluate"],SA=q(MA,AA,r=>{var{evaluate:e}=r;function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:_t(),writable:!1})}return t.prototype.type="Parser",t.prototype.isParser=!0,t.prototype.evaluate=function(a){return e(a,this.scope)},t.prototype.get=function(a){if(this.scope.has(a))return this.scope.get(a)},t.prototype.getAll=function(){return Qd(this.scope)},t.prototype.getAllAsMap=function(){return this.scope},t.prototype.set=function(a,n){return this.scope.set(a,n),n},t.prototype.remove=function(a){this.scope.delete(a)},t.prototype.clear=function(){this.scope.clear()},t},{isClass:!0}),Xm="parser",EA=["typed","Parser"],CA=q(Xm,EA,r=>{var{typed:e,Parser:t}=r;return e(Xm,{"":function(){return new t}})}),Ym="lup",OA=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],$A=q(Ym,OA,r=>{var{typed:e,matrix:t,abs:a,addScalar:n,divideScalar:i,multiplyScalar:c,subtract:m,larger:f,equalScalar:l,unaryMinus:s,DenseMatrix:o,SparseMatrix:u,Spa:p}=r;return e(Ym,{DenseMatrix:function(w){return v(w)},SparseMatrix:function(w){return h(w)},Array:function(w){var N=t(w),d=v(N);return{L:d.L.valueOf(),U:d.U.valueOf(),p:d.p}}});function v(b){var w=b._size[0],N=b._size[1],d=Math.min(w,N),y=Re(b._data),x=[],g=[w,d],S=[],A=[d,N],E,M,B,C=[];for(E=0;E<w;E++)C[E]=E;for(M=0;M<N;M++){if(M>0)for(E=0;E<w;E++){var _=Math.min(E,M),P=0;for(B=0;B<_;B++)P=n(P,c(y[E][B],y[B][M]));y[E][M]=m(y[E][M],P)}var I=M,T=0,D=0;for(E=M;E<w;E++){var Z=y[E][M],$=a(Z);f($,T)&&(I=E,T=$,D=Z)}if(M!==I&&(C[M]=[C[I],C[I]=C[M]][0],o._swapRows(M,I,y)),M<w)for(E=M+1;E<w;E++){var H=y[E][M];l(H,0)||(y[E][M]=i(y[E][M],D))}}for(M=0;M<N;M++)for(E=0;E<w;E++){if(M===0&&(E<N&&(S[E]=[]),x[E]=[]),E<M){E<N&&(S[E][M]=y[E][M]),M<w&&(x[E][M]=0);continue}if(E===M){E<N&&(S[E][M]=y[E][M]),M<w&&(x[E][M]=1);continue}E<N&&(S[E][M]=0),M<w&&(x[E][M]=y[E][M])}var Q=new o({data:x,size:g}),te=new o({data:S,size:A}),J=[];for(E=0,d=C.length;E<d;E++)J[C[E]]=E;return{L:Q,U:te,p:J,toString:function(){return"L: "+this.L.toString()+`
41
+ U: `+this.U.toString()+`
42
+ P: `+this.p}}}function h(b){var w=b._size[0],N=b._size[1],d=Math.min(w,N),y=b._values,x=b._index,g=b._ptr,S=[],A=[],E=[],M=[w,d],B=[],C=[],_=[],P=[d,N],I,T,D,Z=[],$=[];for(I=0;I<w;I++)Z[I]=I,$[I]=I;var H=function(J,re){var oe=$[J],ae=$[re];Z[oe]=re,Z[ae]=J,$[J]=ae,$[re]=oe},Q=function(){var J=new p;T<w&&(E.push(S.length),S.push(1),A.push(T)),_.push(B.length);var re=g[T],oe=g[T+1];for(D=re;D<oe;D++)I=x[D],J.set(Z[I],y[D]);T>0&&J.forEach(0,T-1,function(me,ne){u._forEachRow(me,S,A,E,function(Ae,Ce){Ae>me&&J.accumulate(Ae,s(c(Ce,ne)))})});var ae=T,ce=J.get(T),se=a(ce);J.forEach(T+1,w-1,function(me,ne){var Ae=a(ne);f(Ae,se)&&(ae=me,se=Ae,ce=ne)}),T!==ae&&(u._swapRows(T,ae,M[1],S,A,E),u._swapRows(T,ae,P[1],B,C,_),J.swap(T,ae),H(T,ae)),J.forEach(0,w-1,function(me,ne){me<=T?(B.push(ne),C.push(me)):(ne=i(ne,ce),l(ne,0)||(S.push(ne),A.push(me)))})};for(T=0;T<N;T++)Q();return _.push(B.length),E.push(S.length),{L:new u({values:S,index:A,ptr:E,size:M}),U:new u({values:B,index:C,ptr:_,size:P}),p:Z,toString:function(){return"L: "+this.L.toString()+`
43
+ U: `+this.U.toString()+`
44
+ P: `+this.p}}}}),Qm="qr",TA=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],DA=q(Qm,TA,r=>{var{typed:e,matrix:t,zeros:a,identity:n,isZero:i,equal:c,sign:m,sqrt:f,conj:l,unaryMinus:s,addScalar:o,divideScalar:u,multiplyScalar:p,subtract:v,complex:h}=r;return Rr(e(Qm,{DenseMatrix:function(y){return w(y)},SparseMatrix:function(y){return N()},Array:function(y){var x=t(y),g=w(x);return{Q:g.Q.valueOf(),R:g.R.valueOf()}}}),{_denseQRimpl:b});function b(d){var y=d._size[0],x=d._size[1],g=n([y],"dense"),S=g._data,A=d.clone(),E=A._data,M,B,C,_=a([y],"");for(C=0;C<Math.min(x,y);++C){var P=E[C][C],I=s(c(P,0)?1:m(P)),T=l(I),D=0;for(M=C;M<y;M++)D=o(D,p(E[M][C],l(E[M][C])));var Z=p(I,f(D));if(!i(Z)){var $=v(P,Z);for(_[C]=1,M=C+1;M<y;M++)_[M]=u(E[M][C],$);var H=s(l(u($,Z))),Q=void 0;for(B=C;B<x;B++){for(Q=0,M=C;M<y;M++)Q=o(Q,p(l(_[M]),E[M][B]));for(Q=p(Q,H),M=C;M<y;M++)E[M][B]=p(v(E[M][B],p(_[M],Q)),T)}for(M=0;M<y;M++){for(Q=0,B=C;B<y;B++)Q=o(Q,p(S[M][B],_[B]));for(Q=p(Q,H),B=C;B<y;++B)S[M][B]=u(v(S[M][B],p(Q,l(_[B]))),T)}}}return{Q:g,R:A,toString:function(){return"Q: "+this.Q.toString()+`
45
+ R: `+this.R.toString()}}}function w(d){var y=b(d),x=y.R._data;if(d._data.length>0)for(var g=x[0][0].type==="Complex"?h(0):0,S=0;S<x.length;++S)for(var A=0;A<S&&A<(x[0]||[]).length;++A)x[S][A]=g;return y}function N(d){throw new Error("qr not implemented for sparse matrices yet")}});function BA(r,e,t,a){for(var n=r._values,i=r._index,c=r._ptr,m=r._size,f=r._datatype,l=m[0],s=m[1],o=a&&r._values?[]:null,u=[],p=[],v=0,h=0;h<s;h++){p[h]=v;for(var b=t?t[h]:h,w=c[b],N=c[b+1],d=w;d<N;d++){var y=e?e[i[d]]:i[d];u[v]=y,o&&(o[v]=n[d]),v++}}return p[s]=v,r.createSparseMatrix({values:o,index:u,ptr:p,size:[l,s],datatype:f})}function jm(r,e,t,a,n,i,c){var m=0;for(t[c]=r;m>=0;){var f=t[c+m],l=t[a+f];l===-1?(m--,i[e++]=f):(t[a+f]=t[n+l],++m,t[c+m]=l)}return e}function _A(r,e){if(!r)return null;var t=0,a,n=[],i=[],c=0,m=e,f=2*e;for(a=0;a<e;a++)i[c+a]=-1;for(a=e-1;a>=0;a--)r[a]!==-1&&(i[m+a]=i[c+r[a]],i[c+r[a]]=a);for(a=0;a<e;a++)r[a]===-1&&(t=jm(a,t,i,c,m,n,f));return n}function IA(r,e){if(!r)return null;var t=r._index,a=r._ptr,n=r._size,i=n[0],c=n[1],m=[],f=[],l=0,s=c,o,u;if(e)for(o=0;o<i;o++)f[s+o]=-1;for(var p=0;p<c;p++){m[p]=-1,f[l+p]=-1;for(var v=a[p],h=a[p+1],b=v;b<h;b++){var w=t[b];for(o=e?f[s+w]:w;o!==-1&&o<p;o=u)u=f[l+o],f[l+o]=p,u===-1&&(m[o]=p);e&&(f[s+w]=p)}}return m}function RA(r,e,t){for(var a=r._values,n=r._index,i=r._ptr,c=r._size,m=c[1],f=0,l=0;l<m;l++){var s=i[l];for(i[l]=f;s<i[l+1];s++)e(n[s],l,a?a[s]:1,t)&&(n[f]=n[s],a&&(a[f]=a[s]),f++)}return i[m]=f,n.splice(f,n.length-f),a&&a.splice(f,a.length-f),f}function Kt(r){return-r-2}var FA="csAmd",qA=["add","multiply","transpose"],zA=q(FA,qA,r=>{var{add:e,multiply:t,transpose:a}=r;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=n(s,o,p,v,b);RA(w,f,null);for(var N=w._index,d=w._ptr,y=d[v],x=[],g=[],S=0,A=v+1,E=2*(v+1),M=3*(v+1),B=4*(v+1),C=5*(v+1),_=6*(v+1),P=7*(v+1),I=x,T=i(v,d,g,S,M,I,E,P,A,_,B,C),D=c(v,d,g,C,B,_,b,A,M,I,E),Z=0,$,H,Q,te,J,re,oe,ae,ce,se,me,ne,Ae,Ce,ge,Se;D<v;){for(Q=-1;Z<v&&(Q=g[M+Z])===-1;Z++);g[E+Q]!==-1&&(I[g[E+Q]]=-1),g[M+Z]=g[E+Q];var z=g[B+Q],Y=g[A+Q];D+=Y;var V=0;g[A+Q]=-Y;var L=d[Q],j=z===0?L:y,F=j;for(te=1;te<=z+1;te++){for(te>z?(re=Q,oe=L,ae=g[S+Q]-z):(re=N[L++],oe=d[re],ae=g[S+re]),J=1;J<=ae;J++)$=N[oe++],!((ce=g[A+$])<=0)&&(V+=ce,g[A+$]=-ce,N[F++]=$,g[E+$]!==-1&&(I[g[E+$]]=I[$]),I[$]!==-1?g[E+I[$]]=g[E+$]:g[M+g[C+$]]=g[E+$]);re!==Q&&(d[re]=Kt(Q),g[_+re]=0)}for(z!==0&&(y=F),g[C+Q]=V,d[Q]=j,g[S+Q]=F-j,g[B+Q]=-2,T=m(T,h,g,_,v),se=j;se<F;se++)if($=N[se],!((me=g[B+$])<=0)){ce=-g[A+$];var U=T-ce;for(L=d[$],ne=d[$]+me-1;L<=ne;L++)re=N[L],g[_+re]>=T?g[_+re]-=ce:g[_+re]!==0&&(g[_+re]=g[C+re]+U)}for(se=j;se<F;se++){for($=N[se],ne=d[$],Ae=ne+g[B+$]-1,Ce=ne,ge=0,Se=0,L=ne;L<=Ae;L++)if(re=N[L],g[_+re]!==0){var ee=g[_+re]-T;ee>0?(Se+=ee,N[Ce++]=re,ge+=re):(d[re]=Kt(Q),g[_+re]=0)}g[B+$]=Ce-ne+1;var k=Ce,fe=ne+g[S+$];for(L=Ae+1;L<fe;L++){H=N[L];var ve=g[A+H];ve<=0||(Se+=ve,N[Ce++]=H,ge+=H)}Se===0?(d[$]=Kt(Q),ce=-g[A+$],V-=ce,Y+=ce,D+=ce,g[A+$]=0,g[B+$]=-1):(g[C+$]=Math.min(g[C+$],Se),N[Ce]=N[k],N[k]=N[ne],N[ne]=Q,g[S+$]=Ce-ne+1,ge=(ge<0?-ge:ge)%v,g[E+$]=g[P+ge],g[P+ge]=$,I[$]=ge)}for(g[C+Q]=V,h=Math.max(h,V),T=m(T+h,h,g,_,v),se=j;se<F;se++)if($=N[se],!(g[A+$]>=0))for(ge=I[$],$=g[P+ge],g[P+ge]=-1;$!==-1&&g[E+$]!==-1;$=g[E+$],T++){for(ae=g[S+$],me=g[B+$],L=d[$]+1;L<=d[$]+ae-1;L++)g[_+N[L]]=T;var Me=$;for(H=g[E+$];H!==-1;){var be=g[S+H]===ae&&g[B+H]===me;for(L=d[H]+1;be&&L<=d[H]+ae-1;L++)g[_+N[L]]!==T&&(be=0);be?(d[H]=Kt($),g[A+$]+=g[A+H],g[A+H]=0,g[B+H]=-1,H=g[E+H],g[E+Me]=H):(Me=H,H=g[E+H])}}for(L=j,se=j;se<F;se++)$=N[se],!((ce=-g[A+$])<=0)&&(g[A+$]=ce,Se=g[C+$]+V-ce,Se=Math.min(Se,v-D-ce),g[M+Se]!==-1&&(I[g[M+Se]]=$),g[E+$]=g[M+Se],I[$]=-1,g[M+Se]=$,Z=Math.min(Z,Se),g[C+$]=Se,N[L++]=$);g[A+Q]=Y,(g[S+Q]=L-j)===0&&(d[Q]=-1,g[_+Q]=0),z!==0&&(y=L)}for($=0;$<v;$++)d[$]=Kt(d[$]);for(H=0;H<=v;H++)g[M+H]=-1;for(H=v;H>=0;H--)g[A+H]>0||(g[E+H]=g[M+d[H]],g[M+d[H]]=H);for(re=v;re>=0;re--)g[A+re]<=0||d[re]!==-1&&(g[E+re]=g[M+d[re]],g[M+d[re]]=re);for(Q=0,$=0;$<=v;$++)d[$]===-1&&(Q=jm($,Q,g,M,E,x,_));return x.splice(x.length-1,1),x};function n(l,s,o,u,p){var v=a(s);if(l===1&&u===o)return e(s,v);if(l===2){for(var h=v._index,b=v._ptr,w=0,N=0;N<o;N++){var d=b[N];if(b[N]=w,!(b[N+1]-d>p))for(var y=b[N+1];d<y;d++)h[w++]=h[d]}return b[o]=w,s=a(v),t(v,s)}return t(v,s)}function i(l,s,o,u,p,v,h,b,w,N,d,y){for(var x=0;x<l;x++)o[u+x]=s[x+1]-s[x];o[u+l]=0;for(var g=0;g<=l;g++)o[p+g]=-1,v[g]=-1,o[h+g]=-1,o[b+g]=-1,o[w+g]=1,o[N+g]=1,o[d+g]=0,o[y+g]=o[u+g];var S=m(0,0,o,N,l);return o[d+l]=-2,s[l]=-1,o[N+l]=0,S}function c(l,s,o,u,p,v,h,b,w,N,d){for(var y=0,x=0;x<l;x++){var g=o[u+x];if(g===0)o[p+x]=-2,y++,s[x]=-1,o[v+x]=0;else if(g>h)o[b+x]=0,o[p+x]=-1,y++,s[x]=Kt(l),o[b+l]++;else{var S=o[w+g];S!==-1&&(N[S]=x),o[d+x]=o[w+g],o[w+g]=x}}return y}function m(l,s,o,u,p){if(l<2||l+s<0){for(var v=0;v<p;v++)o[u+v]!==0&&(o[u+v]=1);l=2}return l}function f(l,s){return l!==s}});function PA(r,e,t,a,n,i,c){var m,f,l=0,s;if(r<=e||t[a+e]<=t[n+r])return-1;t[n+r]=t[a+e];var o=t[i+r];if(t[i+r]=e,o===-1)l=1,s=r;else{for(l=2,s=o;s!==t[c+s];s=t[c+s]);for(m=o;m!==s;m=f)f=t[c+m],t[c+m]=s}return{jleaf:l,q:s}}var UA="csCounts",LA=["transpose"],kA=q(UA,LA,r=>{var{transpose:e}=r;return function(t,a,n,i){if(!t||!a||!n)return null;var c=t._size,m=c[0],f=c[1],l,s,o,u,p,v,h,b=4*f+(i?f+m+1:0),w=[],N=0,d=f,y=2*f,x=3*f,g=4*f,S=5*f+1;for(o=0;o<b;o++)w[o]=-1;var A=[],E=e(t),M=E._index,B=E._ptr;for(o=0;o<f;o++)for(s=n[o],A[s]=w[x+s]===-1?1:0;s!==-1&&w[x+s]===-1;s=a[s])w[x+s]=o;if(i){for(o=0;o<f;o++)w[n[o]]=o;for(l=0;l<m;l++){for(o=f,v=B[l],h=B[l+1],p=v;p<h;p++)o=Math.min(o,w[M[p]]);w[S+l]=w[g+o],w[g+o]=l}}for(l=0;l<f;l++)w[N+l]=l;for(o=0;o<f;o++){for(s=n[o],a[s]!==-1&&A[a[s]]--,u=i?w[g+o]:s;u!==-1;u=i?w[S+u]:-1)for(p=B[u];p<B[u+1];p++){l=M[p];var C=PA(l,s,w,x,d,y,N);C.jleaf>=1&&A[s]++,C.jleaf===2&&A[C.q]--}a[s]!==-1&&(w[N+s]=a[s])}for(s=0;s<f;s++)a[s]!==-1&&(A[a[s]]+=A[s]);return A}}),VA="csSqr",GA=["add","multiply","transpose"],HA=q(VA,GA,r=>{var{add:e,multiply:t,transpose:a}=r,n=zA({add:e,multiply:t,transpose:a}),i=kA({transpose:a});return function(f,l,s){var o=l._ptr,u=l._size,p=u[1],v,h={};if(h.q=n(f,l),f&&!h.q)return null;if(s){var b=f?BA(l,null,h.q,0):l;h.parent=IA(b,1);var w=_A(h.parent,p);if(h.cp=i(b,h.parent,w,1),b&&h.parent&&h.cp&&c(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 c(m,f){var l=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,d=u,y=u+p,x=u+2*p,g,S,A,E,M;for(S=0;S<p;S++)w[d+S]=-1,w[y+S]=-1,w[x+S]=0;for(g=0;g<u;g++)b[g]=-1;for(S=p-1;S>=0;S--)for(E=l[S],M=l[S+1],A=E;A<M;A++)b[s[A]]=S;for(g=u-1;g>=0;g--)h[g]=-1,S=b[g],S!==-1&&(w[x+S]++===0&&(w[y+S]=g),w[N+g]=w[d+S],w[d+S]=g);for(f.lnz=0,f.m2=u,S=0;S<p;S++)if(g=w[d+S],f.lnz++,g<0&&(g=f.m2++),h[g]=S,!(--x[S]<=0)){f.lnz+=w[x+S];var B=v[S];B!==-1&&(w[x+B]===0&&(w[y+B]=w[y+S]),w[N+w[y+S]]=w[d+B],w[d+B]=w[N+g],w[x+B]+=w[x+S])}for(g=0;g<u;g++)h[g]<0&&(h[g]=S++);return!0}});function Bo(r,e){return r[e]<0}function Km(r,e){r[e]=Kt(r[e])}function ep(r){return r<0?Kt(r):r}function ZA(r,e,t,a,n){var i=e._index,c=e._ptr,m=e._size,f=m[1],l,s,o,u=0;for(a[0]=r;u>=0;){r=a[u];var p=n?n[r]:r;Bo(c,r)||(Km(c,r),a[f+u]=p<0?0:ep(c[p]));var v=1;for(s=a[f+u],o=p<0?0:ep(c[p+1]);s<o;s++)if(l=i[s],!Bo(c,l)){a[f+u]=s,a[++u]=l,v=0;break}v&&(u--,a[--t]=r)}return t}function JA(r,e,t,a,n){var i=r._ptr,c=r._size,m=e._index,f=e._ptr,l=c[1],s,o,u,p=l;for(o=f[t],u=f[t+1],s=o;s<u;s++){var v=m[s];Bo(i,v)||(p=ZA(v,r,p,a,n))}for(s=p;s<l;s++)Km(i,a[s]);return p}var WA="csSpsolve",XA=["divideScalar","multiply","subtract"],YA=q(WA,XA,r=>{var{divideScalar:e,multiply:t,subtract:a}=r;return function(i,c,m,f,l,s,o){var u=i._values,p=i._index,v=i._ptr,h=i._size,b=h[1],w=c._values,N=c._index,d=c._ptr,y,x,g,S,A=JA(i,c,m,f,s);for(y=A;y<b;y++)l[f[y]]=0;for(x=d[m],g=d[m+1],y=x;y<g;y++)l[N[y]]=w[y];for(var E=A;E<b;E++){var M=f[E],B=s?s[M]:M;if(!(B<0))for(x=v[B],g=v[B+1],l[M]=e(l[M],u[o?x:g-1]),y=o?x+1:x,S=o?g:g-1;y<S;y++){var C=p[y];l[C]=a(l[C],t(u[y],l[M]))}}return A}}),QA="csLu",jA=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],KA=q(QA,jA,r=>{var{abs:e,divideScalar:t,multiply:a,subtract:n,larger:i,largerEq:c,SparseMatrix:m}=r,f=YA({divideScalar:t,multiply:a,subtract:n});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=[],d=[],y=[],x=new m({values:N,index:d,ptr:y,size:[v,v]}),g=[],S=[],A=[],E=new m({values:g,index:S,ptr:A,size:[v,v]}),M=[],B,C,_=[],P=[];for(B=0;B<v;B++)_[B]=0,M[B]=-1,y[B+1]=0;b=0,w=0;for(var I=0;I<v;I++){y[I]=b,A[I]=w;var T=h?h[I]:I,D=f(x,s,T,P,_,M,1),Z=-1,$=-1;for(C=D;C<v;C++)if(B=P[C],M[B]<0){var H=e(_[B]);i(H,$)&&($=H,Z=B)}else S[w]=M[B],g[w++]=_[B];if(Z===-1||$<=0)return null;M[T]<0&&c(e(_[T]),a($,u))&&(Z=T);var Q=_[Z];for(S[w]=I,g[w++]=Q,M[Z]=I,d[b]=Z,N[b++]=1,C=D;C<v;C++)B=P[C],M[B]<0&&(d[b]=B,N[b++]=t(_[B],Q)),_[B]=0}for(y[v]=b,A[v]=w,C=0;C<b;C++)d[C]=M[d[C]];return N.splice(b,N.length-b),d.splice(b,d.length-b),g.splice(w,g.length-w),S.splice(w,S.length-w),{L:x,U:E,pinv:M}}}),rp="slu",eS=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],rS=q(rp,eS,r=>{var{typed:e,abs:t,add:a,multiply:n,transpose:i,divideScalar:c,subtract:m,larger:f,largerEq:l,SparseMatrix:s}=r,o=HA({add:a,multiply:n,transpose:i}),u=KA({abs:t,divideScalar:c,multiply:n,subtract:m,larger:f,largerEq:l,SparseMatrix:s});return e(rp,{"SparseMatrix, number, number":function(v,h,b){if(!Be(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
+ U: `+this.U.toString()+`
47
+ p: `+this.p.toString()+(this.q?`
48
+ q: `+this.q.toString():"")+`
49
+ `}}}})});function tp(r,e){var t,a=e.length,n=[];if(r)for(t=0;t<a;t++)n[r[t]]=e[t];else for(t=0;t<a;t++)n[t]=e[t];return n}var np="lusolve",tS=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],nS=q(np,tS,r=>{var{typed:e,matrix:t,lup:a,slu:n,usolve:i,lsolve:c,DenseMatrix:m}=r,f=xa({DenseMatrix:m});return e(np,{"Array, Array | Matrix":function(u,p){u=t(u);var v=a(u),h=s(v.L,v.U,v.p,null,p);return h.valueOf()},"DenseMatrix, Array | Matrix":function(u,p){var v=a(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix":function(u,p){var v=a(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix, number, number":function(u,p,v,h){var b=n(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 l(o){if(Fe(o))return o;if(ar(o))return t(o);throw new TypeError("Invalid Matrix LU decomposition")}function s(o,u,p,v,h){o=l(o),u=l(u),p&&(h=f(o,h,!0),h._data=tp(p,h._data));var b=c(o,h),w=i(u,b);return v&&(w._data=tp(v,w._data)),w}}),aS="Help",iS=["parse"],oS=q(aS,iS,r=>{var{parse:e}=r;function t(a){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!a)throw new Error('Argument "doc" missing');this.doc=a}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var a=this.doc||{},n=`
50
+ `;if(a.name&&(n+="Name: "+a.name+`
51
+
52
+ `),a.category&&(n+="Category: "+a.category+`
53
+
54
+ `),a.description&&(n+=`Description:
55
+ `+a.description+`
56
+
57
+ `),a.syntax&&(n+=`Syntax:
58
+ `+a.syntax.join(`
59
+ `)+`
60
+
61
+ `),a.examples){n+=`Examples:
62
+ `;for(var i={},c=0;c<a.examples.length;c++){var m=a.examples[c];n+=" "+m+`
63
+ `;var f=void 0;try{f=e(m).compile().evaluate(i)}catch(l){f=l}f!==void 0&&!Wi(f)&&(n+=" "+Ge(f,{precision:14})+`
64
+ `)}n+=`
65
+ `}return a.mayThrow&&a.mayThrow.length&&(n+="Throws: "+a.mayThrow.join(", ")+`
66
+
67
+ `),a.seealso&&a.seealso.length&&(n+="See also: "+a.seealso.join(", ")+`
68
+ `),n},t.prototype.toJSON=function(){var a=Re(this.doc);return a.mathjs="Help",a},t.fromJSON=function(a){var n={};return Object.keys(a).filter(i=>i!=="mathjs").forEach(i=>{n[i]=a[i]}),new t(n)},t.prototype.valueOf=t.prototype.toString,t},{isClass:!0}),sS="Chain",uS=["?on","math"],cS=q(sS,uS,r=>{var{on:e,math:t}=r;function a(f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Yi(f)?this.value=f.value:this.value=f}a.prototype.type="Chain",a.prototype.isChain=!0,a.prototype.done=function(){return this.value},a.prototype.valueOf=function(){return this.value},a.prototype.toString=function(){return Ge(this.value)},a.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},a.fromJSON=function(f){return new a(f.value)};function n(f,l){typeof l=="function"&&(a.prototype[f]=c(l))}function i(f,l){dd(a.prototype,f,function(){var o=l();if(typeof o=="function")return c(o)})}function c(f){return function(){for(var l=[this.value],s=0;s<arguments.length;s++)l[s+1]=arguments[s];return new a(f.apply(f,l))}}a.createProxy=function(f,l){if(typeof f=="string")n(f,l);else{var s=function(p){De(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 a.createProxy(t),e&&e("import",function(f,l,s){s||i(f,l)}),a},{isClass:!0}),ap={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"]},lS={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},fS={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:[]},mS={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:[]},pS={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},vS={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},hS={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:[]},dS={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:[]},gS={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},yS={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},bS={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:[]},ip={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"]},xS={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:[]},wS={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},NS={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"]},MS={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},AS={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},SS={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"]},ES={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"]},CS={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"]},OS={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"]},$S={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"]},TS={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"]},DS={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"]},BS={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"]},_S={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"]},IS={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"]},RS={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"]},FS={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"]},qS={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:[]},zS={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:[]},PS={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:[]},US={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"]},LS={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"]},kS={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"]},VS={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"]},GS={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"]},HS={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"]},ZS={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"]},JS={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"]},WS={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"]},XS={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"]},YS={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"]},QS={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"]},jS={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"]},KS={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"]},eE={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"]},rE={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},tE={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"]},nE={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"]},aE={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"]},iE={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"]},oE={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"]},sE={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"]},uE={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"]},cE={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"]},lE={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"]},fE={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"]},mE={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"]},pE={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"]},vE={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"]},hE={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"]},dE={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"]},gE={name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax \u2263 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},yE={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"]},bE={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"]},xE={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"]},wE={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"]},NE={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"]},ME={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"]},AE={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"]},SE={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")']},EE={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"]},CE={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"]},OE={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"]},$E={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"]},TE={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"]},DE={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"]},BE={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"]},_E={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"]},IE={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"]},RE={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"]},FE={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},qE={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"]},zE={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"]},PE={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"]},UE={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"]},LE={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"]},kE={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"]},VE={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"]},GE={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"]},HE={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"]},ZE={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"]},JE={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"]},WE={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"]},XE={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"]},YE={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"]},QE={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"]},jE={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"]},KE={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:[]},eC={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},rC={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:[]},tC={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:[]},nC={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"]},aC={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"]},iC={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"]},oC={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"]},sC={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"]},uC={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"]},cC={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"]},lC={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"]},fC={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"]},mC={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"]},pC={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"]},vC={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"]},hC={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"]},dC={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"]},gC={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"]},yC={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"]},bC={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"]},xC={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"]},wC={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"]},NC={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"]},MC={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore\u2013Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},AC={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"]},SC={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"]},EC={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"]},CC={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"]},OC={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"]},$C={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"]},TC={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"]},DC={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"]},BC={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"]},_C={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"]},IC={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"]},RC={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"]},FC={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"]},qC={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"]},zC={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"]},PC={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"]},UC={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"]},LC={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"]},kC={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"]},VC={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"]},GC={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},HC={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},ZC={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"]},JC={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"]},WC={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"]},XC={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"]},YC={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"]},QC={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:[]},jC={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"]},KC={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"]},e3={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"]},r3={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"]},t3={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"]},n3={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"]},a3={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"]},i3={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"]},o3={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"]},s3={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"]},u3={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"]},c3={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"]},l3={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"]},f3={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"]},m3={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"]},p3={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"]},v3={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"]},h3={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"]},d3={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"]},g3={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"]},y3={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"]},b3={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"]},x3={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"]},w3={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"]},N3={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"]},M3={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"]},A3={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:[]},S3={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"]},E3={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"]},C3={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"]},O3={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"]},$3={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"]},T3={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"]},D3={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"]},B3={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
+
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"]},_3={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"]},I3={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"]},R3={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"]},F3={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"]},q3={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"]},z3={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"]},P3={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"]},U3={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"]},L3={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"]},k3={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"]},V3={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"]},G3={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},H3={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"]},Z3={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"]},J3={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"]},W3={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"]},X3={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"]},Y3={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"]},Q3={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},j3={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"]},K3={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"]},eO={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"]},rO={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"]},tO={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"]},nO={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"]},aO={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"]},iO={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},oO={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"]},sO={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"]},uO={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:[]},cO={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},lO={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:[]},fO={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"]},mO={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"]},pO={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},vO={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"]},hO={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"]},dO={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"]},gO={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"]},yO={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"]},bO={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"]},xO={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"]},wO={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"]},NO={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},MO={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"]},AO={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"]},SO={bignumber:SS,boolean:ES,complex:CS,createUnit:OS,fraction:$S,index:TS,matrix:DS,number:BS,sparse:_S,splitUnit:IS,string:RS,unit:FS,e:ap,E:ap,false:lS,i:fS,Infinity:mS,LN2:vS,LN10:pS,LOG2E:dS,LOG10E:hS,NaN:gS,null:yS,pi:ip,PI:ip,phi:bS,SQRT1_2:xS,SQRT2:wS,tau:NS,true:MS,version:AS,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:US,lsolve:kS,lsolveAll:VS,lup:GS,lusolve:HS,leafCount:LS,resolve:WS,simplify:XS,simplifyCore:YS,symbolicEqual:jS,rationalize:JS,slu:QS,usolve:KS,usolveAll:eE,qr:ZS,abs:rE,add:tE,cbrt:nE,ceil:aE,cube:iE,divide:oE,dotDivide:sE,dotMultiply:uE,dotPow:cE,exp:lE,expm:fE,expm1:mE,fix:pE,floor:vE,gcd:hE,hypot:dE,lcm:yE,log:bE,log2:NE,log1p:wE,log10:xE,mod:ME,multiply:AE,norm:SE,nthRoot:EE,nthRoots:CE,pow:OE,round:$E,sign:TE,sqrt:DE,sqrtm:BE,square:_E,subtract:IE,unaryMinus:RE,unaryPlus:FE,xgcd:qE,invmod:gE,bitAnd:zE,bitNot:PE,bitOr:UE,bitXor:LE,leftShift:kE,rightArithShift:VE,rightLogShift:GE,bellNumbers:HE,catalan:ZE,composition:JE,stirlingS2:WE,config:qS,import:zS,typed:PS,arg:XE,conj:YE,re:jE,im:QE,evaluate:KE,help:eC,distance:rC,intersect:tC,and:nC,not:aC,or:iC,xor:oC,concat:uC,count:cC,cross:lC,column:sC,ctranspose:fC,det:mC,diag:pC,diff:vC,dot:hC,getMatrixDataType:xC,identity:wC,filter:gC,flatten:yC,forEach:bC,inv:NC,pinv:MC,eigs:dC,kron:AC,matrixFromFunction:CC,matrixFromRows:OC,matrixFromColumns:EC,map:SC,ones:$C,partitionSelect:TC,range:DC,resize:_C,reshape:BC,rotate:IC,rotationMatrix:RC,row:FC,size:qC,sort:zC,squeeze:PC,subset:UC,trace:LC,transpose:kC,zeros:VC,fft:GC,ifft:HC,combinations:ZC,combinationsWithRep:JC,factorial:WC,gamma:XC,kldivergence:QC,lgamma:YC,multinomial:jC,permutations:KC,pickRandom:e3,random:r3,randomInt:t3,compare:n3,compareNatural:a3,compareText:i3,deepEqual:o3,equal:s3,equalText:u3,larger:c3,largerEq:l3,smaller:f3,smallerEq:m3,unequal:p3,setCartesian:v3,setDifference:h3,setDistinct:d3,setIntersect:g3,setIsSubset:y3,setMultiplicity:b3,setPowerset:x3,setSize:w3,setSymDifference:N3,setUnion:M3,erf:A3,cumsum:I3,mad:S3,max:E3,mean:C3,median:O3,min:$3,mode:T3,prod:D3,quantileSeq:B3,std:_3,sum:R3,variance:F3,acos:q3,acosh:z3,acot:P3,acoth:U3,acsc:L3,acsch:k3,asec:V3,asech:G3,asin:H3,asinh:Z3,atan:J3,atanh:X3,atan2:W3,cos:Y3,cosh:Q3,cot:j3,coth:K3,csc:eO,csch:rO,sec:tO,sech:nO,sin:aO,sinh:iO,tan:oO,tanh:sO,to:uO,clone:lO,format:fO,bin:cO,oct:NO,hex:pO,isNaN:hO,isInteger:vO,isNegative:dO,isNumeric:gO,hasNumericValue:mO,isPositive:yO,isPrime:bO,isZero:xO,print:MO,typeOf:AO,numeric:wO},op="help",EO=["typed","mathWithTransform","Help"],CO=q(op,EO,r=>{var{typed:e,mathWithTransform:t,Help:a}=r;return e(op,{any:function(i){var c,m=i;if(typeof i!="string"){for(c in t)if(De(t,c)&&i===t[c]){m=c;break}}var f=rt(SO,m);if(!f){var l=typeof m=="function"?m.name:m;throw new Error('No documentation found on "'+l+'"')}return new a(f)}})}),sp="chain",OO=["typed","Chain"],$O=q(sp,OO,r=>{var{typed:e,Chain:t}=r;return e(sp,{"":function(){return new t},any:function(n){return new t(n)}})}),up="det",TO=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],DO=q(up,TO,r=>{var{typed:e,matrix:t,subtract:a,multiply:n,divideScalar:i,isZero:c,unaryMinus:m}=r;return e(up,{any:function(s){return Re(s)},"Array | Matrix":function(s){var o;switch(Fe(s)?o=s.size():Array.isArray(s)?(s=t(s),o=s.size()):o=[],o.length){case 0:return Re(s);case 1:if(o[0]===1)return Re(s.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Ge(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: "+Ge(o)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ge(o)+")")}}});function f(l,s,o){if(s===1)return Re(l[0][0]);if(s===2)return a(n(l[0][0],l[1][1]),n(l[1][0],l[0][1]));for(var u=!1,p=new Array(s).fill(0).map((S,A)=>A),v=0;v<s;v++){var h=p[v];if(c(l[h][v])){var b=void 0;for(b=v+1;b<s;b++)if(!c(l[p[b]][v])){h=p[b],p[b]=p[v],p[v]=h,u=!u;break}if(b===s)return l[h][v]}for(var w=l[h][v],N=v===0?1:l[p[v-1]][v-1],d=v+1;d<s;d++)for(var y=p[d],x=v+1;x<s;x++)l[y][x]=i(a(n(l[y][x],w),n(l[y][v],l[h][x])),N)}var g=l[p[s-1]][s-1];return u?m(g):g}}),cp="inv",BO=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],_O=q(cp,BO,r=>{var{typed:e,matrix:t,divideScalar:a,addScalar:n,multiply:i,unaryMinus:c,det:m,identity:f,abs:l}=r;return e(cp,{"Array | Matrix":function(u){var p=Fe(u)?u.size():Je(u);switch(p.length){case 1:if(p[0]===1)return Fe(u)?t([a(1,u.valueOf()[0])]):[a(1,u[0])];throw new RangeError("Matrix must be square (size: "+Ge(p)+")");case 2:{var v=p[0],h=p[1];if(v===h)return Fe(u)?t(s(u.valueOf(),v,h),u.storage()):s(u,v,h);throw new RangeError("Matrix must be square (size: "+Ge(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ge(p)+")")}},any:function(u){return a(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[[a(1,w)]]}else if(u===2){var d=m(o);if(d===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(o[1][1],d),a(c(o[0][1]),d)],[a(c(o[1][0]),d),a(o[0][0],d)]]}else{var y=o.concat();for(v=0;v<u;v++)y[v]=y[v].concat();for(var x=f(u).valueOf(),g=0;g<p;g++){var S=l(y[g][g]),A=g;for(v=g+1;v<u;)l(y[v][g])>S&&(S=l(y[v][g]),A=v),v++;if(S===0)throw Error("Cannot calculate inverse, determinant is zero");v=A,v!==g&&(N=y[g],y[g]=y[v],y[v]=N,N=x[g],x[g]=x[v],x[v]=N);var E=y[g],M=x[g];for(v=0;v<u;v++){var B=y[v],C=x[v];if(v!==g){if(B[g]!==0){for(b=a(c(B[g]),E[g]),h=g;h<p;h++)B[h]=n(B[h],i(b,E[h]));for(h=0;h<p;h++)C[h]=n(C[h],i(b,M[h]))}}else{for(b=E[g],h=g;h<p;h++)B[h]=a(B[h],b);for(h=0;h<p;h++)C[h]=a(C[h],b)}}}return x}}}),lp="pinv",IO=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],RO=q(lp,IO,r=>{var{typed:e,matrix:t,inv:a,deepEqual:n,equal:i,dotDivide:c,dot:m,ctranspose:f,divideScalar:l,multiply:s,add:o,Complex:u}=r;return e(lp,{"Array | Matrix":function(d){var y=Fe(d)?d.size():Je(d);switch(y.length){case 1:return w(d)?f(d):y[0]===1?a(d):c(f(d),m(d,d));case 2:{if(w(d))return f(d);var x=y[0],g=y[1];if(x===g)try{return a(d)}catch(S){if(!(S instanceof Error&&S.message.match(/Cannot calculate inverse, determinant is zero/)))throw S}return Fe(d)?t(p(d.valueOf(),x,g),d.storage()):p(d,x,g)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ge(y)+")")}},any:function(d){return i(d,0)?Re(d):l(1,d)}});function p(N,d,y){var{C:x,F:g}=h(N,d,y),S=s(a(s(f(x),x)),f(x)),A=s(f(g),a(s(g,f(g))));return s(A,S)}function v(N,d,y){for(var x=Re(N),g=0,S=0;S<d;S++){if(y<=g)return x;for(var A=S;b(x[A][g]);)if(A++,d===A&&(A=S,g++,y===g))return x;[x[A],x[S]]=[x[S],x[A]];for(var E=x[S][g],M=0;M<y;M++)x[S][M]=c(x[S][M],E);for(var B=0;B<d;B++)if(B!==S){E=x[B][g];for(var C=0;C<y;C++)x[B][C]=o(x[B][C],s(-1,s(E,x[S][C])))}g++}return x}function h(N,d,y){var x=v(N,d,y),g=N.map((A,E)=>A.filter((M,B)=>B<d&&!b(m(x[B],x[B])))),S=x.filter((A,E)=>!b(m(x[E],x[E])));return{C:g,F:S}}function b(N){return i(o(N,u(1,1)),o(0,u(1,1)))}function w(N){return n(o(N,u(1,1)),o(s(N,0),u(1,1)))}});function FO(r){var{addScalar:e,subtract:t,flatten:a,multiply:n,multiplyScalar:i,divideScalar:c,sqrt:m,abs:f,bignumber:l,diag:s,inv:o,qr:u,usolve:p,usolveAll:v,equal:h,complex:b,larger:w,smaller:N,matrixFromColumns:d,dot:y}=r;function x(H,Q,te,J,re){re===void 0&&(re=!0);var oe=g(H,Q,te,J,re);S(H,Q,te,J,re,oe);var{values:ae,C:ce}=A(H,Q,te,J,re),se;return re&&(se=E(H,Q,ce,oe,ae,te,J),se=d(...se)),{values:ae,vectors:se}}function g(H,Q,te,J,re){var oe=J==="BigNumber",ae=J==="Complex",ce=oe?l(0):0,se=oe?l(1):ae?b(1):1,me=oe?l(1):1,ne=oe?l(10):2,Ae=i(ne,ne),Ce;re&&(Ce=Array(Q).fill(se));for(var ge=!1;!ge;){ge=!0;for(var Se=0;Se<Q;Se++){for(var z=ce,Y=ce,V=0;V<Q;V++)if(Se!==V){var L=f(H[Se][V]);z=e(z,L),Y=e(Y,L)}if(!h(z,0)&&!h(Y,0)){for(var j=me,F=z,U=c(Y,ne),ee=i(Y,ne);N(F,U);)F=i(F,Ae),j=i(j,ne);for(;w(F,ee);)F=c(F,Ae),j=c(j,ne);var k=N(c(e(F,Y),j),i(e(z,Y),.95));if(k){ge=!1;for(var fe=c(1,j),ve=0;ve<Q;ve++)Se!==ve&&(H[Se][ve]=i(H[Se][ve],j),H[ve][Se]=i(H[ve][Se],fe));re&&(Ce[Se]=i(Ce[Se],j))}}}}return s(Ce)}function S(H,Q,te,J,re,oe){var ae=J==="BigNumber",ce=J==="Complex",se=ae?l(0):ce?b(0):0;ae&&(te=l(te));for(var me=0;me<Q-2;me++){for(var ne=0,Ae=se,Ce=me+1;Ce<Q;Ce++){var ge=H[Ce][me];N(f(Ae),f(ge))&&(Ae=ge,ne=Ce)}if(!N(f(Ae),te)){if(ne!==me+1){var Se=H[ne];H[ne]=H[me+1],H[me+1]=Se;for(var z=0;z<Q;z++){var Y=H[z][ne];H[z][ne]=H[z][me+1],H[z][me+1]=Y}if(re){var V=oe[ne];oe[ne]=oe[me+1],oe[me+1]=V}}for(var L=me+2;L<Q;L++){var j=c(H[L][me],Ae);if(j!==0){for(var F=0;F<Q;F++)H[L][F]=t(H[L][F],i(j,H[me+1][F]));for(var U=0;U<Q;U++)H[U][me+1]=e(H[U][me+1],i(j,H[U][L]));if(re)for(var ee=0;ee<Q;ee++)oe[L][ee]=t(oe[L][ee],i(j,oe[me+1][ee]))}}}}return oe}function A(H,Q,te,J,re){var oe=J==="BigNumber",ae=J==="Complex",ce=oe?l(1):ae?b(1):1;oe&&(te=l(te));for(var se=Re(H),me=[],ne=Q,Ae=[],Ce=re?s(Array(Q).fill(ce)):void 0,ge=re?s(Array(ne).fill(ce)):void 0,Se=0;Se<=100;){Se+=1;for(var z=0,Y=0;Y<ne;Y++)se[Y][Y]=t(se[Y][Y],z);var{Q:V,R:L}=u(se);se=n(L,V);for(var j=0;j<ne;j++)se[j][j]=e(se[j][j],z);if(re&&(ge=n(ge,V)),ne===1||N(f(se[ne-1][ne-2]),te)){Se=0,me.push(se[ne-1][ne-1]),re&&(Ae.unshift([[1]]),C(ge,Q),Ce=n(Ce,ge),ne>1&&(ge=s(Array(ne-1).fill(ce)))),ne-=1,se.pop();for(var F=0;F<ne;F++)se[F].pop()}else if(ne===2||N(f(se[ne-2][ne-3]),te)){Se=0;var U=M(se[ne-2][ne-2],se[ne-2][ne-1],se[ne-1][ne-2],se[ne-1][ne-1]);me.push(...U),re&&(Ae.unshift(B(se[ne-2][ne-2],se[ne-2][ne-1],se[ne-1][ne-2],se[ne-1][ne-1],U[0],U[1],te,J)),C(ge,Q),Ce=n(Ce,ge),ne>2&&(ge=s(Array(ne-2).fill(ce)))),ne-=2,se.pop(),se.pop();for(var ee=0;ee<ne;ee++)se[ee].pop(),se[ee].pop()}if(ne===0)break}if(me.sort((ve,Me)=>+t(f(ve),f(Me))),Se>100){var k=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+me.join(", "));throw k.values=me,k.vectors=[],k}var fe=re?n(Ce,_(Ae,Q)):void 0;return{values:me,C:fe}}function E(H,Q,te,J,re,oe,ae){var ce=o(te),se=n(ce,H,te),me=ae==="BigNumber",ne=ae==="Complex",Ae=me?l(0):ne?b(0):0,Ce=me?l(1):ne?b(1):1,ge=[],Se=[];for(var z of re){var Y=P(ge,z,h);Y===-1?(ge.push(z),Se.push(1)):Se[Y]+=1}for(var V=[],L=ge.length,j=Array(Q).fill(Ae),F=s(Array(Q).fill(Ce)),U=[],ee=function(Me){var be=ge[Me],xe=t(se,n(be,F)),Te=v(xe,j);for(Te.shift();Te.length<Se[Me];){var nr=I(xe,Q,Te,oe,ae);if(nr==null){U.push(be);break}Te.push(nr)}var dr=n(o(J),te);Te=Te.map(fr=>n(dr,fr)),V.push(...Te.map(fr=>a(fr)))},k=0;k<L;k++)ee(k);if(U.length!==0){var fe=new Error("Failed to find eigenvectors for the following eigenvalues: "+U.join(", "));throw fe.values=re,fe.vectors=V,fe}return V}function M(H,Q,te,J){var re=e(H,J),oe=t(i(H,J),i(Q,te)),ae=i(re,.5),ce=i(m(t(i(re,re),i(4,oe))),.5);return[e(ae,ce),t(ae,ce)]}function B(H,Q,te,J,re,oe,ae,ce){var se=ce==="BigNumber",me=ce==="Complex",ne=se?l(0):me?b(0):0,Ae=se?l(1):me?b(1):1;if(N(f(te),ae))return[[Ae,ne],[ne,Ae]];if(w(f(t(re,oe)),ae))return[[t(re,J),t(oe,J)],[te,te]];var Ce=t(H,re),ge=t(Q,re),Se=t(te,re),z=t(J,re);return N(f(ge),ae)?[[Ce,Ae],[Se,ne]]:[[ge,ne],[z,Ae]]}function C(H,Q){for(var te=0;te<H.length;te++)H[te].push(...Array(Q-H[te].length).fill(0));for(var J=H.length;J<Q;J++)H.push(Array(Q).fill(0)),H[J][J]=1;return H}function _(H,Q){for(var te=[],J=0;J<Q;J++)te[J]=Array(Q).fill(0);var re=0;for(var oe of H){for(var ae=oe.length,ce=0;ce<ae;ce++)for(var se=0;se<ae;se++)te[re+ce][re+se]=oe[ce][se];re+=ae}return te}function P(H,Q,te){for(var J=0;J<H.length;J++)if(te(H[J],Q))return J;return-1}function I(H,Q,te,J,re){for(var oe=re==="BigNumber"?l(1e3):1e3,ae,ce=0;ae=T(Q,te,re),ae=p(H,ae),!w(Z(ae),oe);)if(++ce>=5)return null;for(ce=0;;){var se=p(H,ae);if(N(Z(D(ae,[se])),J))break;if(++ce>=10)return null;ae=$(se)}return ae}function T(H,Q,te){var J=te==="BigNumber",re=te==="Complex",oe=Array(H).fill(0).map(ae=>2*Math.random()-1);return J&&(oe=oe.map(ae=>l(ae))),re&&(oe=oe.map(ae=>b(ae))),oe=D(oe,Q),$(oe,te)}function D(H,Q){for(var te of Q)H=t(H,n(c(y(te,H),y(te,te)),te));return H}function Z(H){return f(m(y(H,H)))}function $(H,Q){var te=Q==="BigNumber",J=Q==="Complex",re=te?l(1):J?b(1):1;return n(c(re,Z(H)),H)}return x}function qO(r){var{config:e,addScalar:t,subtract:a,abs:n,atan:i,cos:c,sin:m,multiplyScalar:f,inv:l,bignumber:s,multiply:o,add:u}=r;function p(M,B){var C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.epsilon,_=arguments.length>3?arguments[3]:void 0;if(_==="number")return v(M,C);if(_==="BigNumber")return h(M,C);throw TypeError("Unsupported data type: "+_)}function v(M,B){for(var C=M.length,_=Math.abs(B/C),P,I=new Array(C),T=0;T<C;T++)I[T]=E(C,0),I[T][T]=1;for(var D=g(M);Math.abs(D[1])>=Math.abs(_);){var Z=D[0][0],$=D[0][1];P=b(M[Z][Z],M[$][$],M[Z][$]),M=x(M,P,Z,$),I=N(I,P,Z,$),D=g(M)}for(var H=E(C,0),Q=0;Q<C;Q++)H[Q]=M[Q][Q];return A(Re(H),Re(I))}function h(M,B){for(var C=M.length,_=n(B/C),P,I=new Array(C),T=0;T<C;T++)I[T]=E(C,0),I[T][T]=1;for(var D=S(M);n(D[1])>=n(_);){var Z=D[0][0],$=D[0][1];P=w(M[Z][Z],M[$][$],M[Z][$]),M=y(M,P,Z,$),I=d(I,P,Z,$),D=S(M)}for(var H=E(C,0),Q=0;Q<C;Q++)H[Q]=M[Q][Q];return A(Re(H),Re(I))}function b(M,B,C){var _=B-M;return Math.abs(_)<=e.epsilon?Math.PI/4:.5*Math.atan(2*C/(B-M))}function w(M,B,C){var _=a(B,M);return n(_)<=e.epsilon?s(-1).acos().div(4):f(.5,i(o(2,C,l(_))))}function N(M,B,C,_){for(var P=M.length,I=Math.cos(B),T=Math.sin(B),D=E(P,0),Z=E(P,0),$=0;$<P;$++)D[$]=I*M[$][C]-T*M[$][_],Z[$]=T*M[$][C]+I*M[$][_];for(var H=0;H<P;H++)M[H][C]=D[H],M[H][_]=Z[H];return M}function d(M,B,C,_){for(var P=M.length,I=c(B),T=m(B),D=E(P,s(0)),Z=E(P,s(0)),$=0;$<P;$++)D[$]=a(f(I,M[$][C]),f(T,M[$][_])),Z[$]=t(f(T,M[$][C]),f(I,M[$][_]));for(var H=0;H<P;H++)M[H][C]=D[H],M[H][_]=Z[H];return M}function y(M,B,C,_){for(var P=M.length,I=s(c(B)),T=s(m(B)),D=f(I,I),Z=f(T,T),$=E(P,s(0)),H=E(P,s(0)),Q=o(s(2),I,T,M[C][_]),te=t(a(f(D,M[C][C]),Q),f(Z,M[_][_])),J=u(f(Z,M[C][C]),Q,f(D,M[_][_])),re=0;re<P;re++)$[re]=a(f(I,M[C][re]),f(T,M[_][re])),H[re]=t(f(T,M[C][re]),f(I,M[_][re]));M[C][C]=te,M[_][_]=J,M[C][_]=s(0),M[_][C]=s(0);for(var oe=0;oe<P;oe++)oe!==C&&oe!==_&&(M[C][oe]=$[oe],M[oe][C]=$[oe],M[_][oe]=H[oe],M[oe][_]=H[oe]);return M}function x(M,B,C,_){for(var P=M.length,I=Math.cos(B),T=Math.sin(B),D=I*I,Z=T*T,$=E(P,0),H=E(P,0),Q=D*M[C][C]-2*I*T*M[C][_]+Z*M[_][_],te=Z*M[C][C]+2*I*T*M[C][_]+D*M[_][_],J=0;J<P;J++)$[J]=I*M[C][J]-T*M[_][J],H[J]=T*M[C][J]+I*M[_][J];M[C][C]=Q,M[_][_]=te,M[C][_]=0,M[_][C]=0;for(var re=0;re<P;re++)re!==C&&re!==_&&(M[C][re]=$[re],M[re][C]=$[re],M[_][re]=H[re],M[re][_]=H[re]);return M}function g(M){for(var B=M.length,C=0,_=[0,1],P=0;P<B;P++)for(var I=P+1;I<B;I++)Math.abs(C)<Math.abs(M[P][I])&&(C=Math.abs(M[P][I]),_=[P,I]);return[_,C]}function S(M){for(var B=M.length,C=0,_=[0,1],P=0;P<B;P++)for(var I=P+1;I<B;I++)n(C)<n(M[P][I])&&(C=n(M[P][I]),_=[P,I]);return[_,C]}function A(M,B){for(var C=M.length,_=Array(C),P=Array(C),I=0;I<C;I++)P[I]=Array(C);for(var T=0;T<C;T++){for(var D=0,Z=M[0],$=0;$<M.length;$++)n(M[$])<n(Z)&&(D=$,Z=M[D]);_[T]=M.splice(D,1)[0];for(var H=0;H<C;H++)P[H][T]=B[H][D],B[H].splice(D,1)}return{values:_,vectors:P}}function E(M,B){for(var C=new Array(M),_=0;_<M;_++)C[_]=B;return C}return p}var zO="eigs",PO=["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"],UO=q(zO,PO,r=>{var{config:e,typed:t,matrix:a,addScalar:n,subtract:i,equal:c,abs:m,atan:f,cos:l,sin:s,multiplyScalar:o,divideScalar:u,inv:p,bignumber:v,multiply:h,add:b,larger:w,column:N,flatten:d,number:y,complex:x,sqrt:g,diag:S,qr:A,usolve:E,usolveAll:M,im:B,re:C,smaller:_,matrixFromColumns:P,dot:I}=r,T=qO({config:e,addScalar:n,subtract:i,column:N,flatten:d,equal:c,abs:m,atan:f,cos:l,sin:s,multiplyScalar:o,inv:p,bignumber:v,complex:x,multiply:h,add:b}),D=FO({config:e,addScalar:n,subtract:i,multiply:h,multiplyScalar:o,flatten:d,divideScalar:u,sqrt:g,abs:m,bignumber:v,diag:S,qr:A,inv:p,usolve:E,usolveAll:M,equal:c,complex:x,larger:w,smaller:_,matrixFromColumns:P,dot:I});return t("eigs",{Array:function(re){var oe=a(re);return Z(oe)},"Array, number|BigNumber":function(re,oe){var ae=a(re);return Z(ae,oe)},Matrix:function(re){var{values:oe,vectors:ae}=Z(re);return{values:a(oe),vectors:a(ae)}},"Matrix, number|BigNumber":function(re,oe){var{values:ae,vectors:ce}=Z(re,oe);return{values:a(ae),vectors:a(ce)}}});function Z(J,re){re===void 0&&(re=e.epsilon);var oe=J.size();if(oe.length!==2||oe[0]!==oe[1])throw new RangeError("Matrix must be square (size: "+Ge(oe)+")");var ae=J.toArray(),ce=oe[0];if(H(ae,ce,re)&&(Q(ae,ce),$(ae,ce,re))){var se=te(J,ae,ce);return T(ae,ce,re,se)}var me=te(J,ae,ce);return D(ae,ce,re,me)}function $(J,re,oe){for(var ae=0;ae<re;ae++)for(var ce=ae;ce<re;ce++)if(w(v(m(i(J[ae][ce],J[ce][ae]))),oe))return!1;return!0}function H(J,re,oe){for(var ae=0;ae<re;ae++)for(var ce=0;ce<re;ce++)if(w(v(m(B(J[ae][ce]))),oe))return!1;return!0}function Q(J,re){for(var oe=0;oe<re;oe++)for(var ae=0;ae<re;ae++)J[oe][ae]=C(J[oe][ae])}function te(J,re,oe){var ae=J.datatype();if(ae==="number"||ae==="BigNumber"||ae==="Complex")return ae;for(var ce=!1,se=!1,me=!1,ne=0;ne<oe;ne++)for(var Ae=0;Ae<oe;Ae++){var Ce=re[ne][Ae];if(Ye(Ce)||En(Ce))ce=!0;else if(We(Ce))se=!0;else if(Dt(Ce))me=!0;else throw TypeError("Unsupported type in Matrix: "+cr(Ce))}if(se&&me&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),me){for(var ge=0;ge<oe;ge++)for(var Se=0;Se<oe;Se++)re[ge][Se]=x(re[ge][Se]);return"Complex"}if(se){for(var z=0;z<oe;z++)for(var Y=0;Y<oe;Y++)re[z][Y]=v(re[z][Y]);return"BigNumber"}if(ce){for(var V=0;V<oe;V++)for(var L=0;L<oe;L++)re[V][L]=y(re[V][L]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),fp="expm",LO=["typed","abs","add","identity","inv","multiply"],kO=q(fp,LO,r=>{var{typed:e,abs:t,add:a,identity:n,inv:i,multiply:c}=r;return e(fp,{Matrix:function(o){var u=o.size();if(u.length!==2||u[0]!==u[1])throw new RangeError("Matrix must be square (size: "+Ge(u)+")");for(var p=u[0],v=1e-15,h=m(o),b=f(h,v),w=b.q,N=b.j,d=c(o,Math.pow(2,-N)),y=n(p),x=n(p),g=1,S=d,A=-1,E=1;E<=w;E++)E>1&&(S=c(S,d),A=-A),g=g*(w-E+1)/((2*w-E+1)*E),y=a(y,c(g,S)),x=a(x,c(g*A,S));for(var M=c(i(x),y),B=0;B<N;B++)M=c(M,M);return un(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+=t(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(l(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 l(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)}}),mp="sqrtm",VO=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],GO=q(mp,VO,r=>{var{typed:e,abs:t,add:a,multiply:n,sqrt:i,subtract:c,inv:m,size:f,max:l,identity:s}=r,o=1e3,u=1e-6;function p(v){var h,b=0,w=v,N=s(f(v));do{var d=w;if(w=n(.5,a(d,m(N))),N=n(.5,a(N,m(d))),h=l(t(c(w,d))),h>u&&++b>o)throw new Error("computing square root of matrix: iterative method could not converge")}while(h>u);return w}return e(mp,{"Array | Matrix":function(h){var b=Fe(h)?h.size():Je(h);switch(b.length){case 1:if(b[0]===1)return i(h);throw new RangeError("Matrix must be square (size: "+Ge(b)+")");case 2:{var w=b[0],N=b[1];if(w===N)return p(h);throw new RangeError("Matrix must be square (size: "+Ge(b)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Ge(b)+")")}}})}),HO="divide",ZO=["typed","matrix","multiply","equalScalar","divideScalar","inv"],JO=q(HO,ZO,r=>{var{typed:e,matrix:t,multiply:a,equalScalar:n,divideScalar:i,inv:c}=r,m=_r({typed:e,equalScalar:n}),f=rr({typed:e});return e("divide",Qi({"Array | Matrix, Array | Matrix":function(s,o){return a(s,c(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(t(s),o,i,!1).valueOf()},"any, Array | Matrix":function(s,o){return a(s,c(o))}},i.signatures))}),pp="distance",WO=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],XO=q(pp,WO,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,unaryMinus:c,sqrt:m,abs:f}=r;return e(pp,{"Array, Array, Array":function(x,g,S){if(x.length===2&&g.length===2&&S.length===2){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(g))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(S))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var A=i(a(S[1],S[0]),a(g[1],g[0])),E=n(n(A,A),g[0]),M=c(n(A,g[0])),B=x[1];return b(x[0],x[1],E,M,B)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,g,S){if(Object.keys(x).length===2&&Object.keys(g).length===2&&Object.keys(S).length===2){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(g))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(S))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in g&&"lineOnePtY"in g&&"lineTwoPtX"in S&&"lineTwoPtY"in S){var A=i(a(S.lineTwoPtY,S.lineTwoPtX),a(g.lineOnePtY,g.lineOnePtX)),E=n(n(A,A),g.lineOnePtX),M=c(n(A,g.lineOnePtX)),B=x.pointX;return b(x.pointX,x.pointY,E,M,B)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,g){if(x.length===2&&g.length===3){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!o(g))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return b(x[0],x[1],g[0],g[1],g[2])}else if(x.length===3&&g.length===6){if(!o(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!p(g))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return w(x[0],x[1],x[2],g[0],g[1],g[2],g[3],g[4],g[5])}else if(x.length===g.length&&x.length>0){if(!u(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!u(g))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,g)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,g){if(Object.keys(x).length===2&&Object.keys(g).length===3){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!o(g))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in g&&"yCoeffLine"in g&&"constant"in g)return b(x.pointX,x.pointY,g.xCoeffLine,g.yCoeffLine,g.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(g).length===6){if(!o(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!p(g))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 g&&"y0"in g&&"z0"in g&&"a"in g&&"b"in g&&"c"in g)return w(x.pointX,x.pointY,x.pointZ,g.x0,g.y0,g.z0,g.a,g.b,g.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(g).length===2){if(!s(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(g))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in g&&"pointTwoY"in g)return N([x.pointOneX,x.pointOneY],[g.pointTwoX,g.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(g).length===3){if(!o(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!o(g))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 g&&"pointTwoY"in g&&"pointTwoZ"in g)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[g.pointTwoX,g.pointTwoY,g.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 d(x)}});function l(y){return typeof y=="number"||We(y)}function s(y){return y.constructor!==Array&&(y=v(y)),l(y[0])&&l(y[1])}function o(y){return y.constructor!==Array&&(y=v(y)),l(y[0])&&l(y[1])&&l(y[2])}function u(y){return Array.isArray(y)||(y=v(y)),y.every(l)}function p(y){return y.constructor!==Array&&(y=v(y)),l(y[0])&&l(y[1])&&l(y[2])&&l(y[3])&&l(y[4])&&l(y[5])}function v(y){for(var x=Object.keys(y),g=[],S=0;S<x.length;S++)g.push(y[x[S]]);return g}function h(y){if(y[0].length===2&&l(y[0][0])&&l(y[0][1])){if(y.some(x=>x.length!==2||!l(x[0])||!l(x[1])))return!1}else if(y[0].length===3&&l(y[0][0])&&l(y[0][1])&&l(y[0][2])){if(y.some(x=>x.length!==3||!l(x[0])||!l(x[1])||!l(x[2])))return!1}else return!1;return!0}function b(y,x,g,S,A){var E=f(t(t(n(g,y),n(S,x)),A)),M=m(t(n(g,g),n(S,S)));return i(E,M)}function w(y,x,g,S,A,E,M,B,C){var _=[a(n(a(A,x),C),n(a(E,g),B)),a(n(a(E,g),M),n(a(S,y),C)),a(n(a(S,y),B),n(a(A,x),M))];_=m(t(t(n(_[0],_[0]),n(_[1],_[1])),n(_[2],_[2])));var P=m(t(t(n(M,M),n(B,B)),n(C,C)));return i(_,P)}function N(y,x){for(var g=y.length,S=0,A=0,E=0;E<g;E++)A=a(y[E],x[E]),S=t(n(A,A),S);return m(S)}function d(y){for(var x=[],g=[],S=[],A=0;A<y.length-1;A++)for(var E=A+1;E<y.length;E++)y[0].length===2?(g=[y[A][0],y[A][1]],S=[y[E][0],y[E][1]]):y[0].length===3&&(g=[y[A][0],y[A][1],y[A][2]],S=[y[E][0],y[E][1],y[E][2]]),x.push(N(g,S));return x}}),YO="intersect",QO=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],jO=q(YO,QO,r=>{var{typed:e,config:t,abs:a,add:n,addScalar:i,matrix:c,multiply:m,multiplyScalar:f,divideScalar:l,subtract:s,smaller:o,equalScalar:u,flatten:p,isZero:v,isNumeric:h}=r;return e("intersect",{"Array, Array, Array":b,"Array, Array, Array, Array":w,"Matrix, Matrix, Matrix":function(B,C,_){var P=b(B.valueOf(),C.valueOf(),_.valueOf());return P===null?null:c(P)},"Matrix, Matrix, Matrix, Matrix":function(B,C,_,P){var I=w(B.valueOf(),C.valueOf(),_.valueOf(),P.valueOf());return I===null?null:c(I)}});function b(M,B,C){if(M=N(M),B=N(B),C=N(C),!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(B))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(C))throw new TypeError("Array with 4 numbers expected as third argument");return E(M[0],M[1],M[2],B[0],B[1],B[2],C[0],C[1],C[2],C[3])}function w(M,B,C,_){if(M=N(M),B=N(B),C=N(C),_=N(_),M.length===2){if(!d(M))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(B))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(C))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(_))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return g(M,B,C,_)}else if(M.length===3){if(!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(B))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(C))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 A(M[0],M[1],M[2],B[0],B[1],B[2],C[0],C[1],C[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(B=>Array.isArray(B)&&B.length===1)?p(M):M}function d(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 g(M,B,C,_){var P=M,I=C,T=s(P,B),D=s(I,_),Z=s(f(T[0],D[1]),f(D[0],T[1]));if(v(Z)||o(a(Z),t.epsilon))return null;var $=f(D[0],P[1]),H=f(D[1],P[0]),Q=f(D[0],I[1]),te=f(D[1],I[0]),J=l(i(s(s($,H),Q),te),Z);return n(m(T,J),P)}function S(M,B,C,_,P,I,T,D,Z,$,H,Q){var te=f(s(M,B),s(C,_)),J=f(s(P,I),s(T,D)),re=f(s(Z,$),s(H,Q));return i(i(te,J),re)}function A(M,B,C,_,P,I,T,D,Z,$,H,Q){var te=S(M,T,$,T,B,D,H,D,C,Z,Q,Z),J=S($,T,_,M,H,D,P,B,Q,Z,I,C),re=S(M,T,_,M,B,D,P,B,C,Z,I,C),oe=S($,T,$,T,H,D,H,D,Q,Z,Q,Z),ae=S(_,M,_,M,P,B,P,B,I,C,I,C),ce=s(f(te,J),f(re,oe)),se=s(f(ae,oe),f(J,J));if(v(se))return null;var me=l(ce,se),ne=l(i(te,f(me,J)),oe),Ae=i(M,f(me,s(_,M))),Ce=i(B,f(me,s(P,B))),ge=i(C,f(me,s(I,C))),Se=i(T,f(ne,s($,T))),z=i(D,f(ne,s(H,D))),Y=i(Z,f(ne,s(Q,Z)));return u(Ae,Se)&&u(Ce,z)&&u(ge,Y)?[Ae,Ce,ge]:null}function E(M,B,C,_,P,I,T,D,Z,$){var H=f(M,T),Q=f(_,T),te=f(B,D),J=f(P,D),re=f(C,Z),oe=f(I,Z),ae=s(s(s($,H),te),re),ce=s(s(s(i(i(Q,J),oe),H),te),re),se=l(ae,ce),me=i(M,f(se,s(_,M))),ne=i(B,f(se,s(P,B))),Ae=i(C,f(se,s(I,C)));return[me,ne,Ae]}}),vp="sum",KO=["typed","config","add","numeric"],hp=q(vp,KO,r=>{var{typed:e,config:t,add:a,numeric:n}=r;return e(vp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":c,"...":function(f){if(qn(f))throw new TypeError("Scalar values expected in function sum");return i(f)}});function i(m){var f;return Rt(m,function(l){try{f=f===void 0?l:a(f,l)}catch(s){throw kr(s,"sum",l)}}),f===void 0&&(f=n(0,t.number)),typeof f=="string"&&(f=n(f,t.number)),f}function c(m,f){try{var l=ui(m,f,a);return l}catch(s){throw kr(s,"sum")}}}),xi="cumsum",e$=["typed","add","unaryPlus"],dp=q(xi,e$,r=>{var{typed:e,add:t,unaryPlus:a}=r;return e(xi,{Array:n,Matrix:function(l){return l.create(n(l.valueOf()))},"Array, number | BigNumber":c,"Matrix, number | BigNumber":function(l,s){return l.create(c(l.valueOf(),s))},"...":function(l){if(qn(l))throw new TypeError("All values expected to be scalar in function cumsum");return n(l)}});function n(f){try{return i(f)}catch(l){throw kr(l,xi)}}function i(f){if(f.length===0)return[];for(var l=[a(f[0])],s=1;s<f.length;++s)l.push(t(l[s-1],f[s]));return l}function c(f,l){var s=Je(f);if(l<0||l>=s.length)throw new ct(l,s.length);try{return m(f,l)}catch(o){throw kr(o,xi)}}function m(f,l){var s,o,u;if(l<=0){var p=f[0][0];if(Array.isArray(p)){for(u=_u(f),o=[],s=0;s<u.length;s++)o[s]=m(u[s],l-1);return o}else return i(f)}else{for(o=[],s=0;s<f.length;s++)o[s]=m(f[s],l-1);return o}}}),gp="mean",r$=["typed","add","divide"],yp=q(gp,r$,r=>{var{typed:e,add:t,divide:a}=r;return e(gp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":n,"...":function(m){if(qn(m))throw new TypeError("Scalar values expected in function mean");return i(m)}});function n(c,m){try{var f=ui(c,m,t),l=Array.isArray(c)?Je(c):c.size();return a(f,l[m])}catch(s){throw kr(s,"mean")}}function i(c){var m,f=0;if(Rt(c,function(l){try{m=m===void 0?l:t(m,l),f++}catch(s){throw kr(s,"mean",l)}}),f===0)throw new Error("Cannot calculate the mean of an empty array");return a(m,f)}}),bp="median",t$=["typed","add","divide","compare","partitionSelect"],n$=q(bp,t$,r=>{var{typed:e,add:t,divide:a,compare:n,partitionSelect:i}=r;function c(l){try{l=Qe(l.valueOf());var s=l.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(l,o+1),p=l[o],v=0;v<o;++v)n(l[v],p)>0&&(p=l[v]);return f(p,u)}else{var h=i(l,(s-1)/2);return m(h)}}catch(b){throw kr(b,"median")}}var m=e({"number | BigNumber | Complex | Unit":function(s){return s}}),f=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(s,o){return a(t(s,o),2)}});return e(bp,{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(s,o){throw new Error("median(A, dim) is not yet supported")},"...":function(s){if(qn(s))throw new TypeError("Scalar values expected in function median");return c(s)}})}),xp="mad",a$=["typed","abs","map","median","subtract"],i$=q(xp,a$,r=>{var{typed:e,abs:t,map:a,median:n,subtract:i}=r;return e(xp,{"Array | Matrix":c,"...":function(f){return c(f)}});function c(m){if(m=Qe(m.valueOf()),m.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var f=n(m);return n(a(m,function(l){return t(i(l,f))}))}catch(l){throw l instanceof TypeError&&l.message.indexOf("median")!==-1?new TypeError(l.message.replace("median","mad")):kr(l,"mad")}}}),_o="unbiased",wp="variance",o$=["typed","add","subtract","multiply","divide","apply","isNaN"],Np=q(wp,o$,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:c,isNaN:m}=r;return e(wp,{"Array | Matrix":function(o){return f(o,_o)},"Array | Matrix, string":f,"Array | Matrix, number | BigNumber":function(o,u){return l(o,u,_o)},"Array | Matrix, number | BigNumber, string":l,"...":function(o){return f(o,_o)}});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(Rt(s,function(b){try{u=u===void 0?b:t(u,b),p++}catch(w){throw kr(w,"variance",b)}}),p===0)throw new Error("Cannot calculate variance of an empty array");var v=i(u,p);if(u=void 0,Rt(s,function(b){var w=a(b,v);u=u===void 0?n(w,w):t(u,n(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=We(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 l(s,o,u){try{if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return c(s,o,p=>f(p,u))}catch(p){throw kr(p,"variance")}}}),s$="quantileSeq",u$=["typed","add","multiply","partitionSelect","compare"],c$=q(s$,u$,r=>{var{typed:e,add:t,multiply:a,partitionSelect:n,compare:i}=r;function c(l,s,o){var u,p,v;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(Cn(l)){if(o=o||!1,typeof o=="boolean"){if(p=l.valueOf(),Ye(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(!Be(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(We(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 d=new w(N+1);u=new Array(N);for(var y=0;y<N;)u[y]=new w(m(p,new w(++y).div(d),o));return u}}if(Array.isArray(s)){u=new Array(s.length);for(var x=0;x<u.length;++x){var g=s[x];if(Ye(g)){if(g<0||g>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(We(g)){if(v=new g.constructor(1),g.isNegative()||g.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,g,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(l,s,o){var u=Qe(l),p=u.length;if(p===0)throw new Error("Cannot calculate quantile of an empty sequence");if(Ye(s)){var v=s*(p-1),h=v%1;if(h===0){var b=o?u[v]:n(u,v);return f(b),b}var w=Math.floor(v),N,d;if(o)N=u[w],d=u[w+1];else{d=n(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(d),t(a(N,1-h),a(d,h))}var x=s.times(p-1);if(x.isInteger()){x=x.toNumber();var g=o?u[x]:n(u,x);return f(g),g}var S=x.floor(),A=x.minus(S),E=S.toNumber(),M,B;if(o)M=u[E],B=u[E+1];else{B=n(u,E+1),M=u[E];for(var C=0;C<E;++C)i(u[C],M)>0&&(M=u[C])}f(M),f(B);var _=new A.constructor(1);return t(a(M,_.minus(A)),a(B,A))}var f=e({"number | BigNumber | Unit":function(s){return s}});return c}),Mp="std",l$=["typed","sqrt","variance"],Ap=q(Mp,l$,r=>{var{typed:e,sqrt:t,variance:a}=r;return e(Mp,{"Array | Matrix":n,"Array | Matrix, string":n,"Array | Matrix, number | BigNumber":n,"Array | Matrix, number | BigNumber, string":n,"...":function(c){return n(c)}});function n(i,c){if(i.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return t(a.apply(null,arguments))}catch(m){throw m instanceof TypeError&&m.message.indexOf(" variance")!==-1?new TypeError(m.message.replace(" variance"," std")):m}}}),Sp="combinations",f$=["typed"],m$=q(Sp,f$,r=>{var{typed:e}=r;return e(Sp,{"number, number":sc,"BigNumber, BigNumber":function(a,n){var i=a.constructor,c,m,f=a.minus(n),l=new i(1);if(!Ep(a)||!Ep(n))throw new TypeError("Positive integer value expected in function combinations");if(n.gt(a))throw new TypeError("k must be less than n in function combinations");if(c=l,n.lt(f))for(m=l;m.lte(f);m=m.plus(l))c=c.times(n.plus(m)).dividedBy(m);else for(m=l;m.lte(n);m=m.plus(l))c=c.times(f.plus(m)).dividedBy(m);return c}})});function Ep(r){return r.isInteger()&&r.gte(0)}var Cp="combinationsWithRep",p$=["typed"],v$=q(Cp,p$,r=>{var{typed:e}=r;return e(Cp,{"number, number":function(a,n){if(!Be(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!Be(n)||n<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a<1)throw new TypeError("k must be less than or equal to n + k - 1");if(n<a-1){var i=Ft(a,a+n-1);return i/Ft(1,n)}var c=Ft(n+1,a+n-1);return c/Ft(1,a-1)},"BigNumber, BigNumber":function(a,n){var i=a.constructor,c,m,f=new i(1),l=a.minus(f);if(!Op(a)||!Op(n))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a.lt(f))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(c=f,n.lt(l))for(m=f;m.lte(l);m=m.plus(f))c=c.times(n.plus(m)).dividedBy(m);else for(m=f;m.lte(n);m=m.plus(f))c=c.times(l.plus(m)).dividedBy(m);return c}})});function Op(r){return r.isInteger()&&r.gte(0)}var $p="gamma",h$=["typed","config","multiplyScalar","pow","BigNumber","Complex"],d$=q($p,h$,r=>{var{typed:e,config:t,multiplyScalar:a,pow:n,BigNumber:i,Complex:c}=r;return e($p,{number:go,Complex:function(l){if(l.im===0)return this(l.re);if(l.re<.5){var s=new c(1-l.re,-l.im),o=new c(Math.PI*l.re,Math.PI*l.im);return new c(Math.PI).div(o.sin()).div(this(s))}l=new c(l.re-1,l.im);for(var u=new c(Pn[0],0),p=1;p<Pn.length;++p){var v=new c(Pn[p],0);u=u.add(v.div(l.add(p)))}var h=new c(l.re+mc+.5,l.im),b=Math.sqrt(2*Math.PI),w=h.pow(l.add(.5)),N=h.neg().exp();return u.mul(b).mul(w).mul(N)},BigNumber:function(l){if(l.isInteger())return l.isNegative()||l.isZero()?new i(1/0):m(l.minus(1));if(!l.isFinite())return new i(l.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(l){return $e(l,this)}});function m(f){if(f<8)return new i([1,1,2,6,24,120,720,5040][f]);var l=t.precision+(Math.log(f.toNumber())|0),s=i.clone({precision:l});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))}}),Tp="lgamma",g$=["Complex","typed"],y$=q(Tp,g$,r=>{var{Complex:e,typed:t}=r,a=7,n=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Tp,{number:li,Complex:function(l){var s=6.283185307179586,o=1.1447298858494002,u=.1;if(l.isNaN())return new e(NaN,NaN);if(l.im===0)return new e(li(l.re),0);if(l.re>=a||Math.abs(l.im)>=n)return c(l);if(l.re<=u){var p=Fd(s,l.im)*Math.floor(.5*l.re+.25),v=l.mul(Math.PI).sin().log(),h=this(new e(1-l.re,-l.im));return new e(o,p).sub(v).sub(h)}else return l.im>=0?m(l):m(l.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function c(f){for(var l=f.sub(.5).mul(f.log()).sub(f).add(pc),s=new e(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 l.add(N)}function m(f){var l=0,s=0,o=f;for(f=f.add(1);f.re<=a;){o=o.mul(f);var u=o.im<0?1:0;u!==0&&s===0&&l++,s=u,f=f.add(1)}return c(f).sub(o.log()).sub(new e(0,l*2*Math.PI*1))}}),Dp="factorial",b$=["typed","gamma"],x$=q(Dp,b$,r=>{var{typed:e,gamma:t}=r;return e(Dp,{number:function(n){if(n<0)throw new Error("Value must be non-negative");return t(n+1)},BigNumber:function(n){if(n.isNegative())throw new Error("Value must be non-negative");return t(n.plus(1))},"Array | Matrix":function(n){return $e(n,this)}})}),Bp="kldivergence",w$=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],N$=q(Bp,w$,r=>{var{typed:e,matrix:t,divide:a,sum:n,multiply:i,dotDivide:c,log:m,isNumeric:f}=r;return e(Bp,{"Array, Array":function(o,u){return l(t(o),t(u))},"Matrix, Array":function(o,u){return l(o,t(u))},"Array, Matrix":function(o,u){return l(t(o),u)},"Matrix, Matrix":function(o,u){return l(o,u)}});function l(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=n(s);if(v===0)throw new Error("Sum of elements in first object must be non zero");var h=n(o);if(h===0)throw new Error("Sum of elements in second object must be non zero");var b=a(s,n(s)),w=a(o,n(o)),N=n(i(b,m(c(b,w))));return f(N)?N:Number.NaN}}),_p="multinomial",M$=["typed","add","divide","multiply","factorial","isInteger","isPositive"],A$=q(_p,M$,r=>{var{typed:e,add:t,divide:a,multiply:n,factorial:i,isInteger:c,isPositive:m}=r;return e(_p,{"Array | Matrix":function(l){var s=0,o=1;return Rt(l,function(u){if(!c(u)||!m(u))throw new TypeError("Positive integer value expected in function multinomial");s=t(s,u),o=n(o,i(u))}),a(i(s),o)}})}),Ip="permutations",S$=["typed","factorial"],E$=q(Ip,S$,r=>{var{typed:e,factorial:t}=r;return e(Ip,{"number | BigNumber":t,"number, number":function(n,i){if(!Be(n)||n<0)throw new TypeError("Positive integer value expected in function permutations");if(!Be(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>n)throw new TypeError("second argument k must be less than or equal to first argument n");return Ft(n-i+1,n)},"BigNumber, BigNumber":function(n,i){var c,m;if(!Rp(n)||!Rp(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(n))throw new TypeError("second argument k must be less than or equal to first argument n");var f=n.mul(0).add(1);for(c=f,m=n.minus(i).plus(1);m.lte(n);m=m.plus(1))c=c.times(m);return c}})});function Rp(r){return r.isInteger()&&r.gte(0)}var Fp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,s=m();l.next=function(){var o=2091639*l.s0+l.c*23283064365386963e-26;return l.s0=l.s1,l.s1=l.s2,l.s2=o-(l.c=o|0)},l.c=1,l.s0=s(" "),l.s1=s(" "),l.s2=s(" "),l.s0-=s(f),l.s0<0&&(l.s0+=1),l.s1-=s(f),l.s1<0&&(l.s1+=1),l.s2-=s(f),l.s2<0&&(l.s2+=1),s=null}function i(f,l){return l.c=f.c,l.s0=f.s0,l.s1=f.s1,l.s2=f.s2,l}function c(f,l){var s=new n(f),o=l&&l.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,l=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 l}t&&t.exports?t.exports=c:a&&a.amd?a(function(){return c}):this.alea=c})(Ht,r,!1)})(Fp);var qp={exports:{}};(function(r){(function(e,t,a){function n(m){var f=this,l="";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:l+=m;for(var s=0;s<l.length+64;s++)f.x^=l.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 c(m,f){var l=new n(m),s=f&&f.state,o=function(){return(l.next()>>>0)/4294967296};return o.double=function(){do var u=l.next()>>>11,p=(l.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=l.next,o.quick=o,s&&(typeof s=="object"&&i(s,l),o.state=function(){return i(l,{})}),o}t&&t.exports?t.exports=c:a&&a.amd?a(function(){return c}):this.xor128=c})(Ht,r,!1)})(qp);var zp={exports:{}};(function(r){(function(e,t,a){function n(m){var f=this,l="";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:l+=m;for(var s=0;s<l.length+64;s++)f.x^=l.charCodeAt(s)|0,s==l.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 c(m,f){var l=new n(m),s=f&&f.state,o=function(){return(l.next()>>>0)/4294967296};return o.double=function(){do var u=l.next()>>>11,p=(l.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=l.next,o.quick=o,s&&(typeof s=="object"&&i(s,l),o.state=function(){return i(l,{})}),o}t&&t.exports?t.exports=c:a&&a.amd?a(function(){return c}):this.xorwow=c})(Ht,r,!1)})(zp);var Pp={exports:{}};(function(r){(function(e,t,a){function n(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 l(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()}l(f,m)}function i(m,f){return f.x=m.x.slice(),f.i=m.i,f}function c(m,f){m==null&&(m=+new Date);var l=new n(m),s=f&&f.state,o=function(){return(l.next()>>>0)/4294967296};return o.double=function(){do var u=l.next()>>>11,p=(l.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=l.next,o.quick=o,s&&(s.x&&i(s,l),o.state=function(){return i(l,{})}),o}t&&t.exports?t.exports=c:a&&a.amd?a(function(){return c}):this.xorshift7=c})(Ht,r,!1)})(Pp);var Up={exports:{}};(function(r){(function(e,t,a){function n(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 l(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}l(f,m)}function i(m,f){return f.i=m.i,f.w=m.w,f.X=m.X.slice(),f}function c(m,f){m==null&&(m=+new Date);var l=new n(m),s=f&&f.state,o=function(){return(l.next()>>>0)/4294967296};return o.double=function(){do var u=l.next()>>>11,p=(l.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=l.next,o.quick=o,s&&(s.X&&i(s,l),o.state=function(){return i(l,{})}),o}t&&t.exports?t.exports=c:a&&a.amd?a(function(){return c}):this.xor4096=c})(Ht,r,!1)})(Up);var Lp={exports:{}};(function(r){(function(e,t,a){function n(m){var f=this,l="";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):l+=m;for(var s=0;s<l.length+20;s++)f.b^=l.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 c(m,f){var l=new n(m),s=f&&f.state,o=function(){return(l.next()>>>0)/4294967296};return o.double=function(){do var u=l.next()>>>11,p=(l.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=l.next,o.quick=o,s&&(typeof s=="object"&&i(s,l),o.state=function(){return i(l,{})}),o}t&&t.exports?t.exports=c:a&&a.amd?a(function(){return c}):this.tychei=c})(Ht,r,!1)})(Lp);var kp={exports:{}};const C$=xd(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,a){var n=256,i=6,c=52,m="random",f=a.pow(n,i),l=a.pow(2,c),s=l*2,o=n-1,u;function p(y,x,g){var S=[];x=x==!0?{entropy:!0}:x||{};var A=w(b(x.entropy?[y,d(t)]:y==null?N():y,3),S),E=new v(S),M=function(){for(var B=E.g(i),C=f,_=0;B<l;)B=(B+_)*n,C*=n,_=E.g(1);for(;B>=s;)B/=2,C/=2,_>>>=1;return(B+_)/C};return M.int32=function(){return E.g(4)|0},M.quick=function(){return E.g(4)/4294967296},M.double=M,w(d(E.S),t),(x.pass||g||function(B,C,_,P){return P&&(P.S&&h(P,E),B.state=function(){return h(E,{})}),_?(a[m]=B,C):B})(M,A,"global"in x?x.global:this==a,x.state)}function v(y){var x,g=y.length,S=this,A=0,E=S.i=S.j=0,M=S.S=[];for(g||(y=[g++]);A<n;)M[A]=A++;for(A=0;A<n;A++)M[A]=M[E=o&E+y[A%g]+(x=M[A])],M[E]=x;(S.g=function(B){for(var C,_=0,P=S.i,I=S.j,T=S.S;B--;)C=T[P=o&P+1],_=_*n+T[o&(T[P]=T[I=o&I+C])+(T[I]=C)];return S.i=P,S.j=I,_})(n)}function h(y,x){return x.i=y.i,x.j=y.j,x.S=y.S.slice(),x}function b(y,x){var g=[],S=typeof y,A;if(x&&S=="object")for(A in y)try{g.push(b(y[A],x-1))}catch{}return g.length?g:S=="string"?y:y+"\0"}function w(y,x){for(var g=y+"",S,A=0;A<g.length;)x[o&A]=o&(S^=x[o&A]*19)+g.charCodeAt(A++);return d(x)}function N(){try{var y;return u&&(y=u.randomBytes)?y=y(n):(y=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(y)),d(y)}catch{var x=e.navigator,g=x&&x.plugins;return[+new Date,e,g,e.screen,d(t)]}}function d(y){return String.fromCharCode.apply(0,y)}if(w(a.random(),t),r.exports){r.exports=p;try{u=C$}catch{}}else a["seed"+m]=p})(typeof self<"u"?self:Ht,[],Math)})(kp);var O$=Fp.exports,$$=qp.exports,T$=zp.exports,D$=Pp.exports,B$=Up.exports,_$=Lp.exports,vn=kp.exports;vn.alea=O$,vn.xor128=$$,vn.xorwow=T$,vn.xorshift7=D$,vn.xor4096=B$,vn.tychei=_$;var Vp=vn,I$=Vp(Date.now());function Hn(r){var e;function t(n){e=n===null?I$:Vp(String(n))}t(r);function a(){return e()}return a}var Gp="pickRandom",R$=["typed","config","?on"],F$=q(Gp,R$,r=>{var{typed:e,config:t,on:a}=r,n=Hn(t.randomSeed);return a&&a("config",function(c,m){c.randomSeed!==m.randomSeed&&(n=Hn(c.randomSeed))}),e(Gp,{"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,l){return i(m,{number:l,weights:f})},"Array | Matrix, number, Array | Matrix":function(m,f,l){return i(m,{number:f,weights:l})}});function i(c,m){var{number:f,weights:l,elementWise:s=!0}=m,o=typeof f>"u";o&&(f=1);var u=Fe(c)?c.create:Fe(l)?l.create:null;c=c.valueOf(),l&&(l=l.valueOf()),s===!0&&(c=Qe(c),l=Qe(l));var p=0;if(typeof l<"u"){if(l.length!==c.length)throw new Error("Weights must have the same length as possibles");for(var v=0,h=l.length;v<h;v++){if(!Ye(l[v])||l[v]<0)throw new Error("Weights must be an array of positive numbers");p+=l[v]}}for(var b=c.length,w=[],N;w.length<f;){if(typeof l>"u")N=c[Math.floor(n()*b)];else for(var d=n()*p,y=0,x=c.length;y<x;y++)if(d-=l[y],d<0){N=c[y];break}w.push(N)}return o?w[0]:u?u(w):w}});function Io(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var a=0,n=r.shift();a<n;a++)t.push(Io(r,e));else for(var i=0,c=r.shift();i<c;i++)t.push(e());return t}var Hp="random",q$=["typed","config","?on"],z$=q(Hp,q$,r=>{var{typed:e,config:t,on:a}=r,n=Hn(t.randomSeed);return a&&a("config",function(m,f){m.randomSeed!==f.randomSeed&&(n=Hn(m.randomSeed))}),e(Hp,{"":()=>c(0,1),number:m=>c(0,m),"number, number":(m,f)=>c(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,l)=>i(m,f,l)});function i(m,f,l){var s=Io(m.valueOf(),()=>c(f,l));return Fe(m)?m.create(s):s}function c(m,f){return m+n()*(f-m)}}),Zp="randomInt",P$=["typed","config","?on"],U$=q(Zp,P$,r=>{var{typed:e,config:t,on:a}=r,n=Hn(t.randomSeed);return a&&a("config",function(m,f){m.randomSeed!==f.randomSeed&&(n=Hn(m.randomSeed))}),e(Zp,{"":()=>c(0,1),number:m=>c(0,m),"number, number":(m,f)=>c(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,l)=>i(m,f,l)});function i(m,f,l){var s=Io(m.valueOf(),()=>c(f,l));return Fe(m)?m.create(s):s}function c(m,f){return Math.floor(m+n()*(f-m))}}),Jp="stirlingS2",L$=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],k$=q(Jp,L$,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,pow:c,factorial:m,combinations:f,isNegative:l,isInteger:s,number:o,bignumber:u,larger:p}=r,v=[],h=[];return e(Jp,{"number | BigNumber, number | BigNumber":function(w,N){if(!s(w)||l(w)||!s(N)||l(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 d=!(Ye(w)&&Ye(N)),y=d?h:v,x=d?u:o,g=o(w),S=o(N);if(y[g]&&y[g].length>S)return y[g][S];for(var A=0;A<=g;++A)if(y[A]||(y[A]=[x(A===0?1:0)]),A!==0)for(var E=y[A],M=y[A-1],B=E.length;B<=A&&B<=S;++B)B===A?E[B]=1:E[B]=t(n(x(B),M[B]),M[B-1]);return y[g][S]}})}),Wp="bellNumbers",V$=["typed","addScalar","isNegative","isInteger","stirlingS2"],G$=q(Wp,V$,r=>{var{typed:e,addScalar:t,isNegative:a,isInteger:n,stirlingS2:i}=r;return e(Wp,{"number | BigNumber":function(m){if(!n(m)||a(m))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var f=0,l=0;l<=m;l++)f=t(f,i(m,l));return f}})}),Xp="catalan",H$=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],Z$=q(Xp,H$,r=>{var{typed:e,addScalar:t,divideScalar:a,multiplyScalar:n,combinations:i,isNegative:c,isInteger:m}=r;return e(Xp,{"number | BigNumber":function(l){if(!m(l)||c(l))throw new TypeError("Non-negative integer value expected in function catalan");return a(i(n(l,2),l),t(l,1))}})}),Yp="composition",J$=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],W$=q(Yp,J$,r=>{var{typed:e,addScalar:t,combinations:a,isPositive:n,isNegative:i,isInteger:c,larger:m}=r;return e(Yp,{"number | BigNumber, number | BigNumber":function(l,s){if(!c(l)||!n(l)||!c(s)||!n(s))throw new TypeError("Positive integer value expected in function composition");if(m(s,l))throw new TypeError("k must be less than or equal to n in function composition");return a(t(l,-1),t(s,-1))}})}),Qp="leafCount",X$=["parse","typed"],Y$=q(Qp,X$,r=>{var{parse:e,typed:t}=r;function a(n){var i=0;return n.forEach(c=>{i+=a(c)}),i||1}return t(Qp,{string:function(i){return this(e(i))},Node:function(i){return a(i)}})});function jp(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,a)}return t}function Ro(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?jp(Object(t),!0).forEach(function(a){Kf(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):jp(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var Q$="simplifyUtil",j$=["FunctionNode","OperatorNode","SymbolNode"],Fo=q(Q$,j$,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:a}=r,n=!0,i=!1,c="defaultF",m={add:{trivial:n,total:n,commutative:n,associative:n},unaryPlus:{trivial:n,total:n,commutative:n,associative:n},subtract:{trivial:i,total:n,commutative:i,associative:i},multiply:{trivial:n,total:n,commutative:n,associative:n},divide:{trivial:i,total:n,commutative:i,associative:i},paren:{trivial:n,total:n,commutative:n,associative:i},defaultF:{trivial:i,total:n,commutative:i,associative:i}},f={divide:{total:i},log:{total:i}},l={subtract:{total:i},abs:{trivial:n},log:{total:n}};function s(d,y){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:m,g=c;if(typeof d=="string"?g=d:Jr(d)?g=d.fn.toString():ln(d)?g=d.name:pa(d)&&(g="paren"),De(x,g)){var S=x[g];if(De(S,y))return S[y];if(De(m,g))return m[g][y]}if(De(x,c)){var A=x[c];return De(A,y)?A[y]:m[c][y]}if(De(m,g)){var E=m[g];if(De(E,y))return E[y]}return m[c][y]}function o(d){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(d,"commutative",y)}function u(d){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(d,"associative",y)}function p(d,y){var x=Ro({},d);for(var g in y)De(d,g)?x[g]=Ro(Ro({},y[g]),d[g]):x[g]=y[g];return x}function v(d,y){if(!d.args||d.args.length===0)return d;d.args=h(d,y);for(var x=0;x<d.args.length;x++)v(d.args[x],y)}function h(d,y){var x,g=[],S=function A(E){for(var M=0;M<E.args.length;M++){var B=E.args[M];Jr(B)&&x===B.op?A(B):g.push(B)}};return u(d,y)?(x=d.op,S(d),g):d.args}function b(d,y){if(!(!d.args||d.args.length===0)){for(var x=N(d),g=d.args.length,S=0;S<g;S++)b(d.args[S],y);if(g>2&&u(d,y)){for(var A=d.args.pop();d.args.length>0;)A=x([d.args.pop(),A]);d.args=A.args}}}function w(d,y){if(!(!d.args||d.args.length===0)){for(var x=N(d),g=d.args.length,S=0;S<g;S++)w(d.args[S],y);if(g>2&&u(d,y)){for(var A=d.args.shift();d.args.length>0;)A=x([A,d.args.shift()]);d.args=A.args}}}function N(d){return Jr(d)?function(y){try{return new t(d.op,d.fn,y,d.implicit)}catch(x){return console.error(x),[]}}:function(y){return new e(new a(d.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:l}}),K$="simplifyConstant",eT=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],Kp=q(K$,eT,r=>{var{typed:e,config:t,mathWithTransform:a,matrix:n,fraction:i,bignumber:c,AccessorNode:m,ArrayNode:f,ConstantNode:l,FunctionNode:s,IndexNode:o,ObjectNode:u,OperatorNode:p,SymbolNode:v}=r,{isCommutative:h,isAssociative:b,allChildren:w,createMakeNodeFunction:N}=Fo({FunctionNode:s,OperatorNode:p,SymbolNode:v});function d(I,T){return S(P(I,T))}function y(I){return En(I)?I.valueOf():I instanceof Array?I.map(y):Fe(I)?n(y(I.valueOf())):I}function x(I,T,D){try{return a[I].apply(null,T)}catch{return T=T.map(y),E(a[I].apply(null,T),D)}}var g=e({Fraction:B,number:function(T){return T<0?M(new l(-T)):new l(T)},BigNumber:function(T){return T<0?M(new l(-T)):new l(T)},Complex:function(T){throw new Error("Cannot convert Complex number to Node")},string:function(T){return new l(T)},Matrix:function(T){return new f(T.valueOf().map(D=>g(D)))}});function S(I){return tr(I)?I:g(I)}function A(I,T){var D=T&&T.exactFractions!==!1;if(D&&isFinite(I)&&i){var Z=i(I),$=T&&typeof T.fractionsLimit=="number"?T.fractionsLimit:1/0;if(Z.valueOf()===I&&Z.n<$&&Z.d<$)return Z}return I}var E=e({"string, Object":function(T,D){if(t.number==="BigNumber")return c===void 0&&Mo(),c(T);if(t.number==="Fraction")return i===void 0&&Jl(),i(T);var Z=parseFloat(T);return A(Z,D)},"Fraction, Object":function(T,D){return T},"BigNumber, Object":function(T,D){return T},"number, Object":function(T,D){return A(T,D)},"Complex, Object":function(T,D){return T.im!==0?T:A(T.re,D)},"Matrix, Object":function(T,D){return n(A(T.valueOf()))},"Array, Object":function(T,D){return T.map(A)}});function M(I){return new p("-","unaryMinus",[I])}function B(I){var T,D=I.s*I.n;return D<0?T=new p("-","unaryMinus",[new l(-D)]):T=new l(D),I.d===1?T:new p("/","divide",[T,new l(I.d)])}function C(I,T,D){if(!On(T))return new m(S(I),S(T));if(Kr(I)||Fe(I)){for(var Z=Array.from(T.dimensions);Z.length>0;)if(ir(Z[0])&&typeof Z[0].value!="string"){var $=E(Z.shift().value,D);Kr(I)?I=I.items[$-1]:(I=I.valueOf()[$-1],I instanceof Array&&(I=n(I)))}else if(Z.length>1&&ir(Z[1])&&typeof Z[1].value!="string"){var H=E(Z[1].value,D),Q=[],te=Kr(I)?I.items:I.valueOf();for(var J of te)if(Kr(J))Q.push(J.items[H-1]);else if(Fe(I))Q.push(J[H-1]);else break;if(Q.length===te.length)Kr(I)?I=new f(Q):I=n(Q),Z.splice(1,1);else break}else break;return Z.length===T.dimensions.length?new m(S(I),T):Z.length>0?(T=new o(Z),new m(S(I),T)):I}if(Ha(I)&&T.dimensions.length===1&&ir(T.dimensions[0])){var re=T.dimensions[0].value;return re in I.properties?I.properties[re]:new l}return new m(S(I),T)}function _(I,T,D,Z){return T.reduce(function($,H){if(!tr($)&&!tr(H)){try{return x(I,[$,H],Z)}catch{}$=g($),H=g(H)}else tr($)?tr(H)||(H=g(H)):$=g($);return D([$,H])})}function P(I,T){switch(I.type){case"SymbolNode":return I;case"ConstantNode":switch(typeof I.value){case"number":return E(I.value,T);case"string":return I.value;default:if(!isNaN(I.value))return E(I.value,T)}return I;case"FunctionNode":if(a[I.name]&&a[I.name].rawArgs)return I;{var D=["add","multiply"];if(D.indexOf(I.name)===-1){var Z=I.args.map(Ae=>P(Ae,T));if(!Z.some(tr))try{return x(I.name,Z,T)}catch{}if(I.name==="size"&&Z.length===1&&Kr(Z[0])){for(var $=[],H=Z[0];Kr(H);)$.push(H.items.length),H=H.items[0];return n($)}return new s(I.name,Z.map(S))}}case"OperatorNode":{var Q=I.fn.toString(),te,J,re=N(I);if(Jr(I)&&I.isUnary())te=[P(I.args[0],T)],tr(te[0])?J=re(te):J=x(Q,te,T);else if(b(I,T.context))if(te=w(I,T.context),te=te.map(Ae=>P(Ae,T)),h(Q,T.context)){for(var oe=[],ae=[],ce=0;ce<te.length;ce++)tr(te[ce])?ae.push(te[ce]):oe.push(te[ce]);oe.length>1?(J=_(Q,oe,re,T),ae.unshift(J),J=_(Q,ae,re,T)):J=_(Q,te,re,T)}else J=_(Q,te,re,T);else te=I.args.map(Ae=>P(Ae,T)),J=_(Q,te,re,T);return J}case"ParenthesisNode":return P(I.content,T);case"AccessorNode":return C(P(I.object,T),P(I.index,T),T);case"ArrayNode":{var se=I.items.map(Ae=>P(Ae,T));return se.some(tr)?new f(se.map(S)):n(se)}case"IndexNode":return new o(I.dimensions.map(Ae=>d(Ae,T)));case"ObjectNode":{var me={};for(var ne in I.properties)me[ne]=d(I.properties[ne],T);return new u(me)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(I.type))}}return d}),rT="simplify",tT=["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"],nT=q(rT,tT,r=>{var{config:e,typed:t,parse:a,add:n,subtract:i,multiply:c,divide:m,pow:f,isZero:l,equal:s,resolve:o,simplifyCore:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:d,FunctionNode:y,IndexNode:x,ObjectNode:g,OperatorNode:S,ParenthesisNode:A,SymbolNode:E}=r,M=Kp({typed:t,config:e,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:d,FunctionNode:y,IndexNode:x,ObjectNode:g,OperatorNode:S,SymbolNode:E}),{hasProperty:B,isCommutative:C,isAssociative:_,mergeContext:P,flatten:I,unflattenr:T,unflattenl:D,createMakeNodeFunction:Z,defaultContext:$,realContext:H,positiveContext:Q}=Fo({FunctionNode:y,OperatorNode:S,SymbolNode:E}),te=t("simplify",{string:function(L){return this(a(L),this.rules,_t(),{})},"string, Map | Object":function(L,j){return this(a(L),this.rules,j,{})},"string, Map | Object, Object":function(L,j,F){return this(a(L),this.rules,j,F)},"string, Array":function(L,j){return this(a(L),j,_t(),{})},"string, Array, Map | Object":function(L,j,F){return this(a(L),j,F,{})},"string, Array, Map | Object, Object":function(L,j,F,U){return this(a(L),j,F,U)},"Node, Map | Object":function(L,j){return this(L,this.rules,j,{})},"Node, Map | Object, Object":function(L,j,F){return this(L,this.rules,j,F)},Node:function(L){return this(L,this.rules,_t(),{})},"Node, Array":function(L,j){return this(L,j,_t(),{})},"Node, Array, Map | Object":function(L,j,F){return this(L,j,F,{})},"Node, Array, Object, Object":function(L,j,F,U){return this(L,j,io(F),U)},"Node, Array, Map, Object":function(L,j,F,U){var ee=U.consoleDebug;j=ae(j,U.context);var k=o(L,F);k=J(k);for(var fe={},ve=k.toString({parenthesis:"all"});!fe[ve];){fe[ve]=!0,ce=0;var Me=ve;ee&&console.log("Working on: ",ve);for(var be=0;be<j.length;be++){var xe="";if(typeof j[be]=="function"?(k=j[be](k,U),ee&&(xe=j[be].name)):(I(k,U.context),k=ne(k,j[be],U.context),ee&&(xe="".concat(j[be].l.toString()," -> ").concat(j[be].r.toString()))),ee){var Te=k.toString({parenthesis:"all"});Te!==Me&&(console.log("Applying",xe,"produced",Te),Me=Te)}D(k,U.context)}ve=k.toString({parenthesis:"all"})}return k}});te.defaultContext=$,te.realContext=H,te.positiveContext=Q;function J(V){return V.transform(function(L,j,F){return pa(L)?J(L.content):L})}var re={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};te.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 oe(V,L){var j={};if(V.s){var F=V.s.split("->");if(F.length===2)j.l=F[0],j.r=F[1];else throw SyntaxError("Could not parse rule: "+V.s)}else j.l=V.l,j.r=V.r;j.l=J(a(j.l)),j.r=J(a(j.r));for(var U of["imposeContext","repeat","assuming"])U in V&&(j[U]=V[U]);if(V.evaluate&&(j.evaluate=a(V.evaluate)),_(j.l,L)){var ee=Z(j.l),k=se();j.expanded={},j.expanded.l=ee([j.l.clone(),k]),I(j.expanded.l,L),T(j.expanded.l,L),j.expanded.r=ee([j.r,k])}return j}function ae(V,L){for(var j=[],F=0;F<V.length;F++){var U=V[F],ee=void 0,k=typeof U;switch(k){case"string":U={s:U};case"object":ee=oe(U,L);break;case"function":ee=U;break;default:throw TypeError("Unsupported type of rule: "+k)}j.push(ee)}return j}var ce=0;function se(){return new E("_p"+ce++)}function me(V,L,j){var F=V;if(V)for(var U=0;U<V.length;++U){var ee=ne(V[U],L,j);ee!==V[U]&&(F===V&&(F=V.slice()),F[U]=ee)}return F}function ne(V,L,j){if(L.assuming){for(var F in L.assuming)for(var U in L.assuming[F])if(B(F,U,j)!==L.assuming[F][U])return V}var ee=P(L.imposeContext,j),k=V;if(k instanceof S||k instanceof y){var fe=me(k.args,L,j);fe!==k.args&&(k=k.clone(),k.args=fe)}else if(k instanceof A){if(k.content){var ve=ne(k.content,L,j);ve!==k.content&&(k=new A(ve))}}else if(k instanceof N){var Me=me(k.items,L,j);Me!==k.items&&(k=new N(Me))}else if(k instanceof w){var be=k.object;k.object&&(be=ne(k.object,L,j));var xe=k.index;k.index&&(xe=ne(k.index,L,j)),(be!==k.object||xe!==k.index)&&(k=new w(be,xe))}else if(k instanceof x){var Te=me(k.dimensions,L,j);Te!==k.dimensions&&(k=new x(Te))}else if(k instanceof g){var nr=!1,dr={};for(var fr in k.properties)dr[fr]=ne(k.properties[fr],L,j),dr[fr]!==k.properties[fr]&&(nr=!0);nr&&(k=new g(dr))}var Gr=L.r,Hr=z(L.l,k,ee)[0];if(!Hr&&L.expanded&&(Gr=L.expanded.r,Hr=z(L.expanded.l,k,ee)[0]),Hr){var st=k.implicit;k=Gr.clone(),st&&"implicit"in Gr&&(k.implicit=!0),k=k.transform(function(er){return er.isSymbolNode&&De(Hr.placeholders,er.name)?Hr.placeholders[er.name].clone():er})}return L.repeat&&k!==V&&(k=ne(k,L,j)),k}function Ae(V,L){var j=[],F,U,ee=Z(V);if(C(V,L))for(var k=0;k<V.args.length;k++)U=V.args.slice(0),U.splice(k,1),F=U.length===1?U[0]:ee(U),j.push(ee([V.args[k],F]));else for(var fe=1;fe<V.args.length;fe++){var ve=V.args[0];fe>1&&(ve=ee(V.args.slice(0,fe))),U=V.args.slice(fe),F=U.length===1?U[0]:ee(U),j.push(ee([ve,F]))}return j}function Ce(V,L){var j={placeholders:{}};if(!V.placeholders&&!L.placeholders)return j;if(V.placeholders){if(!L.placeholders)return V}else return L;for(var F in V.placeholders)if(De(V.placeholders,F)&&(j.placeholders[F]=V.placeholders[F],De(L.placeholders,F)&&!Y(V.placeholders[F],L.placeholders[F])))return null;for(var U in L.placeholders)De(L.placeholders,U)&&(j.placeholders[U]=L.placeholders[U]);return j}function ge(V,L){var j=[];if(V.length===0||L.length===0)return j;for(var F,U=0;U<V.length;U++)for(var ee=0;ee<L.length;ee++)F=Ce(V[U],L[ee]),F&&j.push(F);return j}function Se(V){if(V.length===0)return V;for(var L=V.reduce(ge),j=[],F={},U=0;U<L.length;U++){var ee=JSON.stringify(L[U]);F[ee]||(F[ee]=!0,j.push(L[U]))}return j}function z(V,L,j,F){var U=[{placeholders:{}}];if(V instanceof S&&L instanceof S||V instanceof y&&L instanceof y){if(V instanceof S){if(V.op!==L.op||V.fn!==L.fn)return[]}else if(V instanceof y&&V.name!==L.name)return[];if(L.args.length===1&&V.args.length===1||!_(L,j)&&L.args.length===V.args.length||F){for(var ee=[],k=0;k<V.args.length;k++){var fe=z(V.args[k],L.args[k],j);if(fe.length===0)break;ee.push(fe)}if(ee.length!==V.args.length){if(!C(L,j)||V.args.length===1)return[];if(V.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var ve=z(V.args[0],L.args[1],j);if(ve.length===0)return[];var Me=z(V.args[1],L.args[0],j);if(Me.length===0)return[];ee=[ve,Me]}U=Se(ee)}else if(L.args.length>=2&&V.args.length===2){for(var be=Ae(L,j),xe=[],Te=0;Te<be.length;Te++){var nr=z(V,be[Te],j,!0);xe=xe.concat(nr)}return xe}else{if(V.args.length>2)throw Error("Unexpected non-binary associative function: "+V.toString());return[]}}else if(V instanceof E){if(V.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(re[V.name]){if(V.name!==L.name)return[]}else if(V.name[0]==="n"||V.name.substring(0,2)==="_p")U[0].placeholders[V.name]=L;else if(V.name[0]==="v")if(!ir(L))U[0].placeholders[V.name]=L;else return[];else if(V.name[0]==="c")if(L instanceof d)U[0].placeholders[V.name]=L;else return[];else throw new Error("Invalid symbol in rule: "+V.name)}else if(V instanceof d){if(!s(V.value,L.value))return[]}else return[];return U}function Y(V,L){if(V instanceof d&&L instanceof d){if(!s(V.value,L.value))return!1}else if(V instanceof E&&L instanceof E){if(V.name!==L.name)return!1}else if(V instanceof S&&L instanceof S||V instanceof y&&L instanceof y){if(V instanceof S){if(V.op!==L.op||V.fn!==L.fn)return!1}else if(V instanceof y&&V.name!==L.name)return!1;if(V.args.length!==L.args.length)return!1;for(var j=0;j<V.args.length;j++)if(!Y(V.args[j],L.args[j]))return!1}else return!1;return!0}return te}),aT="simplifyCore",iT=["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],oT=q(aT,iT,r=>{var{equal:e,isZero:t,add:a,subtract:n,multiply:i,divide:c,pow:m,AccessorNode:f,ArrayNode:l,ConstantNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,SymbolNode:b}=r,w=new s(0),N=new s(1),{hasProperty:d,isCommutative:y}=Fo({FunctionNode:o,OperatorNode:v,SymbolNode:b});function x(g,S){var A=S?S.context:void 0;if(d(g,"trivial",A)){if(ln(g)&&g.args.length===1)return x(g.args[0],S);var E=!1,M=0;if(g.forEach($=>{++M,M===1&&(E=x($,S))}),M===1)return E}if(Jr(g)&&g.isUnary()){var B=x(g.args[0],S);if(g.op==="-"){if(Jr(B)){if(B.isUnary()&&B.op==="-")return B.args[0];if(B.isBinary()&&B.fn==="subtract")return new v("-","subtract",[B.args[1],B.args[0]])}return new v(g.op,g.fn,[B])}}else if(Jr(g)&&g.isBinary()){var C=x(g.args[0],S),_=x(g.args[1],S);if(g.op==="+"){if(ir(C)){if(t(C.value))return _;if(ir(_))return new s(a(C.value,_.value))}return ir(_)&&t(_.value)?C:Jr(_)&&_.isUnary()&&_.op==="-"?new v("-","subtract",[C,_.args[0]]):new v(g.op,g.fn,_?[C,_]:[C])}else if(g.op==="-"){if(ir(C)&&_){if(ir(_))return new s(n(C.value,_.value));if(t(C.value))return new v("-","unaryMinus",[_])}if(g.fn==="subtract")return ir(_)&&t(_.value)?C:Jr(_)&&_.isUnary()&&_.op==="-"?x(new v("+","add",[C,_.args[0]]),S):new v(g.op,g.fn,[C,_])}else if(g.op==="*"){if(ir(C)){if(t(C.value))return w;if(e(C.value,1))return _;if(ir(_))return new s(i(C.value,_.value))}if(ir(_)){if(t(_.value))return w;if(e(_.value,1))return C;if(Jr(C)&&C.isBinary()&&C.op===g.op&&y(g,A)){var P=C.args[0];if(ir(P)){var I=new s(i(P.value,_.value));return new v(g.op,g.fn,[I,C.args[1]],g.implicit)}}return y(g,A)?new v(g.op,g.fn,[_,C],g.implicit):new v(g.op,g.fn,[C,_],g.implicit)}return new v(g.op,g.fn,[C,_],g.implicit)}else if(g.op==="/"){if(ir(C)){if(t(C.value))return w;if(ir(_)&&(e(_.value,1)||e(_.value,2)||e(_.value,4)))return new s(c(C.value,_.value))}return new v(g.op,g.fn,[C,_])}else if(g.op==="^"&&ir(_)){if(t(_.value))return N;if(e(_.value,1))return C;if(ir(C))return new s(m(C.value,_.value));if(Jr(C)&&C.isBinary()&&C.op==="^"){var T=C.args[1];if(ir(T))return new v(g.op,g.fn,[C.args[0],new s(i(T.value,_.value))])}}return new v(g.op,g.fn,[C,_])}else{if(ln(g))return new o(x(g.fn),g.args.map($=>x($,S)));if(Kr(g))return new l(g.items.map($=>x($,S)));if(cn(g))return new f(x(g.object,S),x(g.index,S));if(On(g))return new u(g.dimensions.map($=>x($,S)));if(Ha(g)){var D={};for(var Z in g.properties)D[Z]=x(g.properties[Z],S);return new p(D)}}return g}return x}),sT="resolve",uT=["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],cT=q(sT,uT,r=>{var{parse:e,ConstantNode:t,FunctionNode:a,OperatorNode:n,ParenthesisNode:i}=r;function c(m,f){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!f)return m;if(Ka(f)||(f=io(f)),Dr(m)){if(l.has(m.name)){var s=Array.from(l).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(s,"}"))}var o=f.get(m.name);if(tr(o)){var u=new Set(l);return u.add(m.name),c(o,f,u)}else return typeof o=="number"?e(String(o)):o!==void 0?new t(o):m}else if(Jr(m)){var p=m.args.map(function(h){return c(h,f,l)});return new n(m.op,m.fn,p,m.implicit)}else{if(pa(m))return new i(c(m.content,f,l));if(ln(m)){var v=m.args.map(function(h){return c(h,f,l)});return new a(m.name,v)}}return m.map(h=>c(h,f,l))}return c}),ev="symbolicEqual",lT=["parse","simplify","typed","OperatorNode"],fT=q(ev,lT,r=>{var{parse:e,simplify:t,typed:a,OperatorNode:n}=r;return a(ev,{"string, string":function(c,m){return this(e(c),e(m),{})},"string, string, Object":function(c,m,f){return this(e(c),e(m),f)},"Node, string":function(c,m){return this(c,e(m),{})},"Node, string, Object":function(c,m,f){return this(c,e(m),f)},"string, Node":function(c,m){return this(e(c),m,{})},"string, Node, Object":function(c,m,f){return this(e(c),m,f)},"Node, Node":function(c,m){return this(c,m,{})},"Node, Node, Object":function(c,m,f){var l=new n("-","subtract",[c,m]),s=t(l,{},f);return ir(s)&&!s.value}})}),mT="derivative",pT=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],vT=q(mT,pT,r=>{var{typed:e,config:t,parse:a,simplify:n,equal:i,isZero:c,numeric:m,ConstantNode:f,FunctionNode:l,OperatorNode:s,ParenthesisNode:o,SymbolNode:u}=r,p=e("derivative",{"Node, SymbolNode, Object":function(y,x,g){var S={};h(S,y,x.name);var A=b(y,S);return g.simplify?n(A):A},"Node, SymbolNode":function(y,x){return this(y,x,{simplify:!0})},"string, SymbolNode":function(y,x){return this(a(y),x)},"string, SymbolNode, Object":function(y,x,g){return this(a(y),x,g)},"string, string":function(y,x){return this(a(y),a(x))},"string, string, Object":function(y,x,g){return this(a(y),a(x),g)},"Node, string":function(y,x){return this(y,a(x))},"Node, string, Object":function(y,x,g){return this(y,a(x),g)}});p._simplify=!0,p.toTex=function(d){return v.apply(null,d.args)};var v=e("_derivTex",{"Node, SymbolNode":function(y,x){return ir(y)&&cr(y.value)==="string"?v(a(y.value).toString(),x.toString(),1):v(y.toTex(),x.toString(),1)},"Node, ConstantNode":function(y,x){if(cr(x.value)==="string")return v(y,a(x.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(y,x,g){return v(y.toString(),x.name,g.value)},"string, string, number":function(y,x,g){var S;return g===1?S="{d\\over d"+x+"}":S="{d^{"+g+"}\\over d"+x+"^{"+g+"}}",S+"\\left[".concat(y,"\\right]")}}),h=e("constTag",{"Object, ConstantNode, string":function(y,x){return y[x]=!0,!0},"Object, SymbolNode, string":function(y,x,g){return x.name!==g?(y[x]=!0,!0):!1},"Object, ParenthesisNode, string":function(y,x,g){return h(y,x.content,g)},"Object, FunctionAssignmentNode, string":function(y,x,g){return x.params.indexOf(g)===-1?(y[x]=!0,!0):h(y,x.expr,g)},"Object, FunctionNode | OperatorNode, string":function(y,x,g){if(x.args.length>0){for(var S=h(y,x.args[0],g),A=1;A<x.args.length;++A)S=h(y,x.args[A],g)&&S;if(S)return y[x]=!0,!0}return!1}}),b=e("_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 g=y.args[0],S,A=!1,E=!1,M;switch(y.name){case"cbrt":A=!0,M=new s("*","multiply",[N(3),new s("^","pow",[g,new s("/","divide",[N(2),N(3)])])]);break;case"sqrt":case"nthRoot":if(y.args.length===1)A=!0,M=new s("*","multiply",[N(2),new l("sqrt",[g])]);else if(y.args.length===2)return S=new s("/","divide",[N(1),y.args[1]]),x[S]=x[y.args[1]],b(new s("^","pow",[g,S]),x);break;case"log10":S=N(10);case"log":if(!S&&y.args.length===1)M=g.clone(),A=!0;else if(y.args.length===1&&S||y.args.length===2&&x[y.args[1]]!==void 0)M=new s("*","multiply",[g.clone(),new l("log",[S||y.args[1]])]),A=!0;else if(y.args.length===2)return b(new s("/","divide",[new l("log",[g]),new l("log",[y.args[1]])]),x);break;case"pow":return x[S]=x[y.args[1]],b(new s("^","pow",[g,y.args[1]]),x);case"exp":M=new l("exp",[g.clone()]);break;case"sin":M=new l("cos",[g.clone()]);break;case"cos":M=new s("-","unaryMinus",[new l("sin",[g.clone()])]);break;case"tan":M=new s("^","pow",[new l("sec",[g.clone()]),N(2)]);break;case"sec":M=new s("*","multiply",[y,new l("tan",[g.clone()])]);break;case"csc":E=!0,M=new s("*","multiply",[y,new l("cot",[g.clone()])]);break;case"cot":E=!0,M=new s("^","pow",[new l("csc",[g.clone()]),N(2)]);break;case"asin":A=!0,M=new l("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[g.clone(),N(2)])])]);break;case"acos":A=!0,E=!0,M=new l("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[g.clone(),N(2)])])]);break;case"atan":A=!0,M=new s("+","add",[new s("^","pow",[g.clone(),N(2)]),N(1)]);break;case"asec":A=!0,M=new s("*","multiply",[new l("abs",[g.clone()]),new l("sqrt",[new s("-","subtract",[new s("^","pow",[g.clone(),N(2)]),N(1)])])]);break;case"acsc":A=!0,E=!0,M=new s("*","multiply",[new l("abs",[g.clone()]),new l("sqrt",[new s("-","subtract",[new s("^","pow",[g.clone(),N(2)]),N(1)])])]);break;case"acot":A=!0,E=!0,M=new s("+","add",[new s("^","pow",[g.clone(),N(2)]),N(1)]);break;case"sinh":M=new l("cosh",[g.clone()]);break;case"cosh":M=new l("sinh",[g.clone()]);break;case"tanh":M=new s("^","pow",[new l("sech",[g.clone()]),N(2)]);break;case"sech":E=!0,M=new s("*","multiply",[y,new l("tanh",[g.clone()])]);break;case"csch":E=!0,M=new s("*","multiply",[y,new l("coth",[g.clone()])]);break;case"coth":E=!0,M=new s("^","pow",[new l("csch",[g.clone()]),N(2)]);break;case"asinh":A=!0,M=new l("sqrt",[new s("+","add",[new s("^","pow",[g.clone(),N(2)]),N(1)])]);break;case"acosh":A=!0,M=new l("sqrt",[new s("-","subtract",[new s("^","pow",[g.clone(),N(2)]),N(1)])]);break;case"atanh":A=!0,M=new s("-","subtract",[N(1),new s("^","pow",[g.clone(),N(2)])]);break;case"asech":A=!0,E=!0,M=new s("*","multiply",[g.clone(),new l("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[g.clone(),N(2)])])])]);break;case"acsch":A=!0,E=!0,M=new s("*","multiply",[new l("abs",[g.clone()]),new l("sqrt",[new s("+","add",[new s("^","pow",[g.clone(),N(2)]),N(1)])])]);break;case"acoth":A=!0,E=!0,M=new s("-","subtract",[N(1),new s("^","pow",[g.clone(),N(2)])]);break;case"abs":M=new s("/","divide",[new l(new u("abs"),[g.clone()]),g.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 B,C;A?(B="/",C="divide"):(B="*",C="multiply");var _=b(g,x);return E&&(_=new s("-","unaryMinus",[_])),new s(B,C,[_,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 g=y.args.filter(function(I){return x[I]!==void 0});if(g.length>0){var S=y.args.filter(function(I){return x[I]===void 0}),A=S.length===1?S[0]:new s("*","multiply",S),E=g.concat(b(A,x));return new s("*","multiply",E)}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],B=y.args[1];return x[B]!==void 0?new s("/","divide",[b(M,x),B]):x[M]!==void 0?new s("*","multiply",[new s("-","unaryMinus",[M]),new s("/","divide",[b(B,x),new s("^","pow",[B.clone(),N(2)])])]):new s("/","divide",[new s("-","subtract",[new s("*","multiply",[b(M,x),B.clone()]),new s("*","multiply",[M.clone(),b(B,x)])]),new s("^","pow",[B.clone(),N(2)])])}if(y.op==="^"&&y.isBinary()){var C=y.args[0],_=y.args[1];if(x[C]!==void 0)return ir(C)&&(c(C.value)||i(C.value,1))?N(0):new s("*","multiply",[y,new s("*","multiply",[new l("log",[C.clone()]),b(_.clone(),x)])]);if(x[_]!==void 0){if(ir(_)){if(c(_.value))return N(0);if(i(_.value,1))return b(C,x)}var P=new s("^","pow",[C.clone(),new s("-","subtract",[_,N(1)])]);return new s("*","multiply",[_.clone(),new s("*","multiply",[b(C,x),P])])}return new s("*","multiply",[new s("^","pow",[C.clone(),_.clone()]),new s("+","add",[new s("*","multiply",[b(C,x),new s("/","divide",[_.clone(),C.clone()])]),new s("*","multiply",[b(_,x),new l("log",[C.clone()])])])])}throw new Error('Operator "'+y.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function w(d){if(!((d.name==="log"||d.name==="nthRoot"||d.name==="pow")&&d.args.length===2)){for(var y=0;y<d.args.length;++y)d.args[y]=N(0);throw d.compile().evaluate(),new Error("Expected TypeError, but none found")}}function N(d,y){return new f(m(d,y||t.number))}return p}),rv="rationalize",hT=["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"],dT=q(rv,hT,r=>{var{config:e,typed:t,equal:a,isZero:n,add:i,subtract:c,multiply:m,divide:f,pow:l,parse:s,simplifyCore:o,simplify:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:d,FunctionNode:y,IndexNode:x,ObjectNode:g,OperatorNode:S,SymbolNode:A,ParenthesisNode:E}=r,M=Kp({typed:t,config:e,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:d,FunctionNode:y,IndexNode:x,ObjectNode:g,OperatorNode:S,SymbolNode:A});return t(rv,{string:function(T){return this(s(T),{},!1)},"string, boolean":function(T,D){return this(s(T),{},D)},"string, Object":function(T,D){return this(s(T),D,!1)},"string, Object, boolean":function(T,D,Z){return this(s(T),D,Z)},Node:function(T){return this(T,{},!1)},"Node, boolean":function(T,D){return this(T,{},D)},"Node, Object":function(T,D){return this(T,D,!1)},"Node, Object, boolean":function(T,D,Z){var $=C(),H=B(T,D,!0,$.firstRules),Q=H.variables.length,te={exactFractions:!1},J={exactFractions:!0};if(T=H.expression,Q>=1){T=_(T);var re,oe,ae=!0,ce=!1;T=u(T,$.firstRules,{},te);for(var se;oe=ae?$.distrDivRules:$.sucDivRules,T=u(T,oe,{},J),ae=!ae,se=T.toString(),se!==re;)ce=!0,re=se;ce&&(T=u(T,$.firstRulesAgain,{},te)),T=u(T,$.finalRules,{},te)}var me=[],ne={};return T.type==="OperatorNode"&&T.isBinary()&&T.op==="/"?(Q===1&&(T.args[0]=P(T.args[0],me),T.args[1]=P(T.args[1])),Z&&(ne.numerator=T.args[0],ne.denominator=T.args[1])):(Q===1&&(T=P(T,me)),Z&&(ne.numerator=T,ne.denominator=null)),Z?(ne.coefficients=me,ne.variables=H.variables,ne.expression=T,ne):T}});function B(I,T,D,Z){var $=[],H=u(I,Z,T,{exactFractions:!1});D=!!D;var Q="+-*"+(D?"/":"");J(H);var te={};return te.expression=H,te.variables=$,te;function J(re){var oe=re.type;if(oe==="FunctionNode")throw new Error("There is an unsolved function call");if(oe==="OperatorNode")if(re.op==="^"){if(re.args[1].type!=="ConstantNode"||!Be(parseFloat(re.args[1].value)))throw new Error("There is a non-integer exponent");J(re.args[0])}else{if(Q.indexOf(re.op)===-1)throw new Error("Operator "+re.op+" invalid in polynomial expression");for(var ae=0;ae<re.args.length;ae++)J(re.args[ae])}else if(oe==="SymbolNode"){var ce=re.name,se=$.indexOf(ce);se===-1&&$.push(ce)}else if(oe==="ParenthesisNode")J(re.content);else if(oe!=="ConstantNode")throw new Error("type "+oe+" is not allowed in polynomial expression")}}function C(){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)"}],D=[{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)"}],Z=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],$={};return $.firstRules=I.concat(T,Z),$.distrDivRules=D,$.sucDivRules=Z,$.firstRulesAgain=I.concat(T),$.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))"}],$}function _(I,T,D){var Z=I.type,$=arguments.length>1;if(Z==="OperatorNode"&&I.isBinary()){var H=!1,Q;if(I.op==="^"&&(I.args[0].type==="ParenthesisNode"||I.args[0].type==="OperatorNode")&&I.args[1].type==="ConstantNode"&&(Q=parseFloat(I.args[1].value),H=Q>=2&&Be(Q)),H){if(Q>2){var te=I.args[0],J=new S("^","pow",[I.args[0].cloneDeep(),new d(Q-1)]);I=new S("*","multiply",[te,J])}else I=new S("*","multiply",[I.args[0],I.args[0].cloneDeep()]);$&&(D==="content"?T.content=I:T.args[D]=I)}}if(Z==="ParenthesisNode")_(I.content,I,"content");else if(Z!=="ConstantNode"&&Z!=="SymbolNode")for(var re=0;re<I.args.length;re++)_(I.args[re],I,re);if(!$)return I}function P(I,T){T===void 0&&(T=[]),T[0]=0;var D={};D.cte=1,D.oper="+",D.fire="";var Z=0,$="";ce(I,null,D),Z=T.length-1;for(var H=!0,Q,te=Z;te>=0;te--)if(T[te]!==0){var J=new d(H?T[te]:Math.abs(T[te])),re=T[te]<0?"-":"+";if(te>0){var oe=new A($);if(te>1){var ae=new d(te);oe=new S("^","pow",[oe,ae])}T[te]===-1&&H?J=new S("-","unaryMinus",[oe]):Math.abs(T[te])===1?J=oe:J=new S("*","multiply",[J,oe])}H?Q=J:re==="+"?Q=new S("+","add",[Q,J]):Q=new S("-","subtract",[Q,J]),H=!1}if(H)return new d(0);return Q;function ce(se,me,ne){var Ae=se.type;if(Ae==="FunctionNode")throw new Error("There is an unsolved function call");if(Ae==="OperatorNode"){if("+-*^".indexOf(se.op)===-1)throw new Error("Operator "+se.op+" invalid");if(me!==null){if((se.fn==="unaryMinus"||se.fn==="pow")&&me.fn!=="add"&&me.fn!=="subtract"&&me.fn!=="multiply")throw new Error("Invalid "+se.op+" placing");if((se.fn==="subtract"||se.fn==="add"||se.fn==="multiply")&&me.fn!=="add"&&me.fn!=="subtract")throw new Error("Invalid "+se.op+" placing");if((se.fn==="subtract"||se.fn==="add"||se.fn==="unaryMinus")&&ne.noFil!==0)throw new Error("Invalid "+se.op+" placing")}(se.op==="^"||se.op==="*")&&(ne.fire=se.op);for(var Ce=0;Ce<se.args.length;Ce++)se.fn==="unaryMinus"&&(ne.oper="-"),(se.op==="+"||se.fn==="subtract")&&(ne.fire="",ne.cte=1,ne.oper=Ce===0?"+":se.op),ne.noFil=Ce,ce(se.args[Ce],se,ne)}else if(Ae==="SymbolNode"){if(se.name!==$&&$!=="")throw new Error("There is more than one variable");if($=se.name,me===null){T[1]=1;return}if(me.op==="^"&&ne.noFil!==0)throw new Error("In power the variable should be the first parameter");if(me.op==="*"&&ne.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(ne.fire===""||ne.fire==="*")&&(Z<1&&(T[1]=0),T[1]+=ne.cte*(ne.oper==="+"?1:-1),Z=Math.max(1,Z))}else if(Ae==="ConstantNode"){var ge=parseFloat(se.value);if(me===null){T[0]=ge;return}if(me.op==="^"){if(ne.noFil!==1)throw new Error("Constant cannot be powered");if(!Be(ge)||ge<=0)throw new Error("Non-integer exponent is not allowed");for(var Se=Z+1;Se<ge;Se++)T[Se]=0;ge>Z&&(T[ge]=0),T[ge]+=ne.cte*(ne.oper==="+"?1:-1),Z=Math.max(ge,Z);return}ne.cte=ge,ne.fire===""&&(T[0]+=ne.cte*(ne.oper==="+"?1:-1))}else throw new Error("Type "+Ae+" is not allowed")}}}),gT="reviver",yT=["classes"],bT=q(gT,yT,r=>{var{classes:e}=r;return function(a,n){var i=e[n&&n.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(n):n}}),xT="replacer",wT=[],NT=q(xT,wT,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),MT="10.6.4",AT=q("true",[],()=>!0),ST=q("false",[],()=>!1),ET=q("null",[],()=>null),CT=Qr("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),OT=Qr("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),$T=Qr("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?Eo(t):wy}),TT=Qr("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?ON(t):Ny}),DT=Qr("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?EN(t):My}),BT=Qr("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?CN(t):Ay}),_T=Qr("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),IT=Qr("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),RT=Qr("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),FT=Qr("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),qT=Qr("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),zT=Qr("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),PT=Qr("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),UT=q("version",[],()=>MT);function Qr(r,e,t){return q(r,e,t,{recreateOnConfigChange:!0})}var LT=Le("speedOfLight","299792458","m s^-1"),kT=Le("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),VT=Le("planckConstant","6.62607015e-34","J s"),GT=Le("reducedPlanckConstant","1.0545718176461565e-34","J s"),HT=Le("magneticConstant","1.25663706212e-6","N A^-2"),ZT=Le("electricConstant","8.8541878128e-12","F m^-1"),JT=Le("vacuumImpedance","376.730313667","ohm"),WT=Le("coulomb","8.987551792261171e9","N m^2 C^-2"),XT=Le("elementaryCharge","1.602176634e-19","C"),YT=Le("bohrMagneton","9.2740100783e-24","J T^-1"),QT=Le("conductanceQuantum","7.748091729863649e-5","S"),jT=Le("inverseConductanceQuantum","12906.403729652257","ohm"),KT=Le("magneticFluxQuantum","2.0678338484619295e-15","Wb"),e4=Le("nuclearMagneton","5.0507837461e-27","J T^-1"),r4=Le("klitzing","25812.807459304513","ohm"),t4=Le("bohrRadius","5.29177210903e-11","m"),n4=Le("classicalElectronRadius","2.8179403262e-15","m"),a4=Le("electronMass","9.1093837015e-31","kg"),i4=Le("fermiCoupling","1.1663787e-5","GeV^-2"),o4=wi("fineStructure",.0072973525693),s4=Le("hartreeEnergy","4.3597447222071e-18","J"),u4=Le("protonMass","1.67262192369e-27","kg"),c4=Le("deuteronMass","3.3435830926e-27","kg"),l4=Le("neutronMass","1.6749271613e-27","kg"),f4=Le("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),m4=Le("rydberg","10973731.568160","m^-1"),p4=Le("thomsonCrossSection","6.6524587321e-29","m^2"),v4=wi("weakMixingAngle",.2229),h4=wi("efimovFactor",22.7),d4=Le("atomicMass","1.66053906660e-27","kg"),g4=Le("avogadro","6.02214076e23","mol^-1"),y4=Le("boltzmann","1.380649e-23","J K^-1"),b4=Le("faraday","96485.33212331001","C mol^-1"),x4=Le("firstRadiation","3.7417718521927573e-16","W m^2"),w4=Le("loschmidt","2.686780111798444e25","m^-3"),N4=Le("gasConstant","8.31446261815324","J K^-1 mol^-1"),M4=Le("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),A4=Le("molarVolume","0.022413969545014137","m^3 mol^-1"),S4=wi("sackurTetrode",-1.16487052358),E4=Le("secondRadiation","0.014387768775039337","m K"),C4=Le("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),O4=Le("wienDisplacement","2.897771955e-3","m K"),$4=Le("molarMass","0.99999999965e-3","kg mol^-1"),T4=Le("molarMassC12","11.9999999958e-3","kg mol^-1"),D4=Le("gravity","9.80665","m s^-2"),B4=Le("planckLength","1.616255e-35","m"),_4=Le("planckMass","2.176435e-8","kg"),I4=Le("planckTime","5.391245e-44","s"),R4=Le("planckCharge","1.87554603778e-18","C"),F4=Le("planckTemperature","1.416785e+32","K");function Le(r,e,t){var a=["config","Unit","BigNumber"];return q(r,a,n=>{var{config:i,Unit:c,BigNumber:m}=n,f=i.number==="BigNumber"?new m(e):parseFloat(e),l=new c(f,t);return l.fixPrefix=!0,l})}function wi(r,e){var t=["config","BigNumber"];return q(r,t,a=>{var{config:n,BigNumber:i}=a;return n.number==="BigNumber"?new i(e):e})}var q4="apply",z4=["typed","isInteger"],P4=q(q4,z4,r=>{var{typed:e,isInteger:t}=r,a=Kc({typed:e,isInteger:t});return e("apply",{"...any":function(i){var c=i[1];Ye(c)?i[1]=c-1:We(c)&&(i[1]=c.minus(1));try{return a.apply(null,i)}catch(m){throw Vr(m)}}})},{isTransformFunction:!0}),U4="column",L4=["typed","Index","matrix","range"],k4=q(U4,L4,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=Il({typed:e,Index:t,matrix:a,range:n});return e("column",{"...any":function(m){var f=m.length-1,l=m[f];Ye(l)&&(m[f]=l-1);try{return i.apply(null,m)}catch(s){throw Vr(s)}}})},{isTransformFunction:!0});function qo(r,e,t){var a=r.filter(function(m){return Dr(m)&&!(m.name in e)&&!t.has(m.name)})[0];if(!a)throw new Error('No undefined variable found in inline expression "'+r+'"');var n=a.name,i=Na(t),c=r.compile();return function(f){return i.set(n,f),c.evaluate(i)}}var V4="filter",G4=["typed"],H4=q(V4,G4,r=>{var{typed:e}=r;function t(n,i,c){var m,f;return n[0]&&(m=n[0].compile().evaluate(c)),n[1]&&(Dr(n[1])||ma(n[1])?f=n[1].compile().evaluate(c):f=qo(n[1],i,c)),a(m,f)}t.rawArgs=!0;var a=e("filter",{"Array, function":tv,"Matrix, function":function(i,c){return i.create(tv(i.toArray(),c))},"Array, RegExp":Qa,"Matrix, RegExp":function(i,c){return i.create(Qa(i.toArray(),c))}});return t},{isTransformFunction:!0});function tv(r,e){var t=Un(e);return fu(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n+1]):e(a,[n+1],i)})}var Z4="forEach",J4=["typed"],W4=q(Z4,J4,r=>{var{typed:e}=r;function t(n,i,c){var m,f;return n[0]&&(m=n[0].compile().evaluate(c)),n[1]&&(Dr(n[1])||ma(n[1])?f=n[1].compile().evaluate(c):f=qo(n[1],i,c)),a(m,f)}t.rawArgs=!0;var a=e("forEach",{"Array | Matrix, function":function(i,c){var m=Un(c),f=function l(s,o){Array.isArray(s)?Ya(s,function(u,p){l(u,o.concat(p+1))}):m===1?c(s):m===2?c(s,o):c(s,o,i)};f(i.valueOf(),[])}});return t},{isTransformFunction:!0}),X4="index",Y4=["Index"],Q4=q(X4,Y4,r=>{var{Index:e}=r;return function(){for(var a=[],n=0,i=arguments.length;n<i;n++){var c=arguments[n];if(Ga(c))c.start--,c.end-=c.step>0?0:2;else if(c&&c.isSet===!0)c=c.map(function(f){return f-1});else if(ar(c)||Fe(c))c=c.map(function(f){return f-1});else if(Ye(c))c--;else if(We(c))c=c.toNumber()-1;else if(typeof c!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");a[n]=c}var m=new e;return e.apply(m,a),m}},{isTransformFunction:!0}),j4="map",K4=["typed"],eD=q(j4,K4,r=>{var{typed:e}=r;function t(n,i,c){var m,f;return n[0]&&(m=n[0].compile().evaluate(c)),n[1]&&(Dr(n[1])||ma(n[1])?f=n[1].compile().evaluate(c):f=qo(n[1],i,c)),a(m,f)}t.rawArgs=!0;var a=e("map",{"Array, function":function(i,c){return nv(i,c,i)},"Matrix, function":function(i,c){return i.create(nv(i.valueOf(),c,i))}});return t},{isTransformFunction:!0});function nv(r,e,t){var a=Un(e);function n(i,c){return Array.isArray(i)?Bt(i,function(m,f){return n(m,c.concat(f+1))}):a===1?e(i):a===2?e(i,c):e(i,c,t)}return n(r,[])}function hn(r){if(r.length===2&&Cn(r[0])){r=r.slice();var e=r[1];Ye(e)?r[1]=e-1:We(e)&&(r[1]=e.minus(1))}return r}var rD="max",tD=["typed","config","numeric","larger"],nD=q(rD,tD,r=>{var{typed:e,config:t,numeric:a,larger:n}=r,i=Yf({typed:e,config:t,numeric:a,larger:n});return e("max",{"...any":function(m){m=hn(m);try{return i.apply(null,m)}catch(f){throw Vr(f)}}})},{isTransformFunction:!0}),aD="mean",iD=["typed","add","divide"],oD=q(aD,iD,r=>{var{typed:e,add:t,divide:a}=r,n=yp({typed:e,add:t,divide:a});return e("mean",{"...any":function(c){c=hn(c);try{return n.apply(null,c)}catch(m){throw Vr(m)}}})},{isTransformFunction:!0}),sD="min",uD=["typed","config","numeric","smaller"],cD=q(sD,uD,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r,i=jf({typed:e,config:t,numeric:a,smaller:n});return e("min",{"...any":function(m){m=hn(m);try{return i.apply(null,m)}catch(f){throw Vr(f)}}})},{isTransformFunction:!0}),lD="range",fD=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],mD=q(lD,fD,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:c,larger:m,largerEq:f}=r,l=Yl({typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:c,larger:m,largerEq:f});return e("range",{"...any":function(o){var u=o.length-1,p=o[u];return typeof p!="boolean"&&o.push(!0),l.apply(null,o)}})},{isTransformFunction:!0}),pD="row",vD=["typed","Index","matrix","range"],hD=q(pD,vD,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=rf({typed:e,Index:t,matrix:a,range:n});return e("row",{"...any":function(m){var f=m.length-1,l=m[f];Ye(l)&&(m[f]=l-1);try{return i.apply(null,m)}catch(s){throw Vr(s)}}})},{isTransformFunction:!0}),dD="subset",gD=["typed","matrix"],yD=q(dD,gD,r=>{var{typed:e,matrix:t}=r,a=of({typed:e,matrix:t});return e("subset",{"...any":function(i){try{return a.apply(null,i)}catch(c){throw Vr(c)}}})},{isTransformFunction:!0}),bD="concat",xD=["typed","matrix","isInteger"],wD=q(bD,xD,r=>{var{typed:e,matrix:t,isInteger:a}=r,n=Dl({typed:e,matrix:t,isInteger:a});return e("concat",{"...any":function(c){var m=c.length-1,f=c[m];Ye(f)?c[m]=f-1:We(f)&&(c[m]=f.minus(1));try{return n.apply(null,c)}catch(l){throw Vr(l)}}})},{isTransformFunction:!0}),av="diff",ND=["typed","matrix","subtract","number","bignumber"],MD=q(av,ND,r=>{var{typed:e,matrix:t,subtract:a,number:n,bignumber:i}=r,c=Zl({typed:e,matrix:t,subtract:a,number:n,bignumber:i});return e(av,{"...any":function(f){f=hn(f);try{return c.apply(null,f)}catch(l){throw Vr(l)}}})},{isTransformFunction:!0}),AD="std",SD=["typed","sqrt","variance"],ED=q(AD,SD,r=>{var{typed:e,sqrt:t,variance:a}=r,n=Ap({typed:e,sqrt:t,variance:a});return e("std",{"...any":function(c){c=hn(c);try{return n.apply(null,c)}catch(m){throw Vr(m)}}})},{isTransformFunction:!0}),iv="sum",CD=["typed","config","add","numeric"],OD=q(iv,CD,r=>{var{typed:e,config:t,add:a,numeric:n}=r,i=hp({typed:e,config:t,add:a,numeric:n});return e(iv,{"...any":function(m){m=hn(m);try{return i.apply(null,m)}catch(f){throw Vr(f)}}})},{isTransformFunction:!0}),ov="cumsum",$D=["typed","add","unaryPlus"],TD=q(ov,$D,r=>{var{typed:e,add:t,unaryPlus:a}=r,n=dp({typed:e,add:t,unaryPlus:a});return e(ov,{"...any":function(c){if(c.length===2&&Cn(c[0])){var m=c[1];Ye(m)?c[1]=m-1:We(m)&&(c[1]=m.minus(1))}try{return n.apply(null,c)}catch(f){throw Vr(f)}}})},{isTransformFunction:!0}),sv="variance",DD=["typed","add","subtract","multiply","divide","apply","isNaN"],BD=q(sv,DD,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:c,isNaN:m}=r,f=Np({typed:e,add:t,subtract:a,multiply:n,divide:i,apply:c,isNaN:m});return e(sv,{"...any":function(s){s=hn(s);try{return f.apply(null,s)}catch(o){throw Vr(o)}}})},{isTransformFunction:!0}),ye=Kg({config:le}),hr=ty({}),uv=DT({BigNumber:ye,config:le}),_D=ST({}),ID=o4({BigNumber:ye,config:le}),dn=iy({}),cv=PT({Complex:hr}),RD=CT({BigNumber:ye,config:le}),FD=IT({BigNumber:ye,config:le}),qD=FT({BigNumber:ye,config:le}),Ni=fy({}),zD=OT({BigNumber:ye,config:le}),PD=ET({}),UD=BT({BigNumber:ye,config:le}),LD=uy({}),lv=ng({}),kD=qT({BigNumber:ye,config:le}),VD=S4({BigNumber:ye,config:le}),fv=TT({BigNumber:ye,config:le}),GD=AT({}),HD=UT({}),Ze=vy({Matrix:Ni}),ZD=h4({BigNumber:ye,config:le}),JD=_T({BigNumber:ye,config:le}),mv=$T({BigNumber:ye,config:le}),WD=NT({}),XD=zT({BigNumber:ye,config:le}),W=Kd({BigNumber:ye,Complex:hr,DenseMatrix:Ze,Fraction:dn}),zo=S0({BigNumber:ye,config:le,typed:W}),YD=v4({BigNumber:ye,config:le}),jr=C0({typed:W}),QD=PN({Complex:hr,config:le,typed:W}),jD=VN({BigNumber:ye,typed:W}),KD=JN({BigNumber:ye,Complex:hr,config:le,typed:W}),Er=D0({typed:W}),eB=pb({typed:W}),rB=KN({BigNumber:ye,Complex:hr,config:le,typed:W}),tB=aM({typed:W}),pv=sM({typed:W}),nB=fM({Complex:hr,config:le,typed:W}),zt=i0({BigNumber:ye,typed:W}),aB=ib({typed:W}),iB=t0({typed:W}),oB=dy({typed:W}),Mi=m$({typed:W}),Ai=u0({Complex:hr,typed:W}),Zn=hb({typed:W}),sB=hM({typed:W}),uB=bM({BigNumber:ye,typed:W}),cB=wM({BigNumber:ye,typed:W}),lB=G0({typed:W}),je=Gy({config:le,typed:W}),fB=Ix({typed:W}),vv=Z0({typed:W}),mB=W0({Complex:hr,typed:W}),pB=qb({typed:W}),vB=Lb({typed:W}),Ma=Vx({typed:W}),hB=Gb({typed:W}),dB=Xx({format:Ma,typed:W}),hv=gb({typed:W}),tt=yy({typed:W}),Jn=$y({typed:W}),Si=Ry({typed:W}),Mt=qy({typed:W}),gB=RT({BigNumber:ye,config:le}),yB=y$({Complex:hr,typed:W}),bB=y1({Complex:hr,config:le,typed:W}),xB=x1({Complex:hr,config:le,typed:W}),dv=Yb({typed:W}),wr=$1({typed:W}),gv=wb({typed:W}),en=jy({typed:W}),wB=Jx({format:Ma,typed:W}),NB=F$({config:le,typed:W}),MB=Qx({typed:W}),AB=z$({config:le,typed:W}),yv=bb({typed:W}),SB=SM({BigNumber:ye,typed:W}),bv=R1({BigNumber:ye,Fraction:dn,complex:Ai,typed:W}),Po=$M({typed:W}),Pt=Jy({Matrix:Ni,equalScalar:je,typed:W}),EB=w0({typed:W}),CB=U1({typed:W}),OB=e0({typed:W}),$B=_M({typed:W}),TB=Ly({typed:W}),DB=LN({Complex:hr,config:le,typed:W}),BB=XN({BigNumber:ye,typed:W}),Uo=Kc({isInteger:tt,typed:W}),_B=QN({BigNumber:ye,Complex:hr,config:le,typed:W}),IB=Hx({format:Ma,typed:W}),RB=v$({typed:W}),Lo=pM({typed:W}),FB=MM({BigNumber:ye,typed:W}),Aa=Py({typed:W}),qB=rw({typed:W}),zB=U$({config:le,typed:W}),PB=CM({BigNumber:ye,typed:W}),UB=DM({typed:W}),LB=RN({SparseMatrix:Pt,typed:W}),Ut=z1({Complex:hr,config:le,typed:W}),kB=FM({typed:W}),Lt=M0({typed:W}),VB=HN({BigNumber:ye,Complex:hr,config:le,typed:W}),GB=gM({BigNumber:ye,typed:W}),Sa=f0({Fraction:dn,typed:W}),gn=Dy({typed:W}),Ne=p0({DenseMatrix:Ze,Matrix:Ni,SparseMatrix:Pt,typed:W}),HB=h0({isZero:Mt,matrix:Ne,typed:W}),xv=E1({DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W}),ZB=_1({BigNumber:ye,equalScalar:je,matrix:Ne,typed:W}),vt=aw({bignumber:zt,fraction:Sa,number:en}),JB=Mb({DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W}),wv=Lx({config:le,multiplyScalar:wr,numeric:vt,typed:W}),WB=ax({isInteger:tt,matrix:Ne,typed:W}),zr=vx({matrix:Ne,config:le,typed:W}),nt=Qw({DenseMatrix:Ze,config:le,matrix:Ne,typed:W}),XB=dx({matrix:Ne,typed:W}),at=of({matrix:Ne,typed:W}),gr=k1({DenseMatrix:Ze,addScalar:Er,equalScalar:je,matrix:Ne,typed:W,unaryMinus:Lt}),YB=Kx({matrix:Ne,typed:W}),ko=Mx({matrix:Ne,typed:W}),Nv=G1({BigNumber:ye,config:le,matrix:Ne,typed:W}),At=Cx({BigNumber:ye,config:le,matrix:Ne,typed:W}),QB=zw({equalScalar:je,matrix:Ne,not:gv,typed:W,zeros:At}),jB=nb({equalScalar:je,matrix:Ne,typed:W}),KB=fb({DenseMatrix:Ze,matrix:Ne,typed:W}),e_=_0({BigNumber:ye,Complex:hr,Fraction:dn,config:le,isNegative:Jn,matrix:Ne,typed:W,unaryMinus:Lt}),Wn=Uw({BigNumber:ye,DenseMatrix:Ze,Fraction:dn,config:le,equalScalar:je,matrix:Ne,typed:W}),Mv=Hw({matrix:Ne,typed:W}),Vo=Dl({isInteger:tt,matrix:Ne,typed:W}),r_=$b({prod:wv,size:zr,typed:W}),Go=Sx({conj:Zn,transpose:ko,typed:W}),Av=_b({DenseMatrix:Ze,SparseMatrix:Pt,matrix:Ne,typed:W}),yr=ow({numeric:vt,typed:W}),Ei=xw({DenseMatrix:Ze,divideScalar:yr,equalScalar:je,matrix:Ne,typed:W}),ht=Jw({DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W}),Sv=$x({addScalar:Er,divideScalar:yr,exp:vv,i:cv,matrix:Ne,multiplyScalar:wr,tau:fv,typed:W}),Ea=Pb({matrix:Ne,typed:W}),t_=l1({BigNumber:ye,DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W}),n_=_y({isNumeric:gn,typed:W}),a_=o2({abs:jr,addScalar:Er,divideScalar:yr,isPositive:Si,multiplyScalar:wr,smaller:nt,sqrt:Ut,typed:W}),i_=Dx({conj:Zn,dotDivide:Ei,fft:Sv,typed:W}),o_=Wb({matrix:Ne,multiplyScalar:wr,typed:W}),Ci=nN({DenseMatrix:Ze,config:le,matrix:Ne,typed:W}),s_=Bw({DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W,zeros:At}),Ev=Nw({DenseMatrix:Ze,divideScalar:yr,equalScalar:je,matrix:Ne,multiplyScalar:wr,subtract:gr,typed:W}),Cv=b0({flatten:Ea,matrix:Ne,size:zr,typed:W}),u_=jf({config:le,numeric:vt,smaller:nt,typed:W}),c_=Px({isNaN:Aa,isNumeric:gn,typed:W}),l_=dw({Complex:hr,config:le,divideScalar:yr,typed:W}),f_=rx({BigNumber:ye,config:le,matrix:Ne,typed:W}),Ho=cN({compare:Wn,isNaN:Aa,isNumeric:gn,typed:W}),m_=sx({config:le,matrix:Ne}),p_=Iw({DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W,zeros:At}),Oi=lw({BigNumber:ye,DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W,zeros:At}),Zo=Kw({DenseMatrix:Ze,config:le,matrix:Ne,typed:W}),v_=sN({DenseMatrix:Ze,config:le,equalScalar:je,matrix:Ne,typed:W}),Jo=Aw({DenseMatrix:Ze,divideScalar:yr,equalScalar:je,matrix:Ne,multiplyScalar:wr,subtract:gr,typed:W}),h_=Sb({DenseMatrix:Ze,matrix:Ne,typed:W}),br=a2({DenseMatrix:Ze,SparseMatrix:Pt,addScalar:Er,equalScalar:je,matrix:Ne,typed:W}),d_=cM({BigNumber:ye,DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W}),g_=sb({DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W}),y_=Z$({addScalar:Er,combinations:Mi,divideScalar:yr,isInteger:tt,isNegative:Jn,multiplyScalar:wr,typed:W}),St=kw({compare:Wn,typed:W}),b_=dp({add:br,typed:W,unaryPlus:zo}),Ov=iN({equal:ht,typed:W}),x_=Zl({matrix:Ne,number:en,subtract:gr,typed:W}),$i=l2({addScalar:Er,conj:Zn,multiplyScalar:wr,size:zr,typed:W}),w_=Xw({compareText:Mv,isZero:Mt,typed:W}),$v=e1({DenseMatrix:Ze,config:le,equalScalar:je,matrix:Ne,round:Oi,typed:W,zeros:At}),Xn=Zb({BigNumber:ye,DenseMatrix:Ze,SparseMatrix:Pt,config:le,matrix:Ne,typed:W}),N_=Z1({BigNumber:ye,add:br,config:le,equal:ht,isInteger:tt,mod:xv,smaller:nt,typed:W,xgcd:Nv}),it=rN({DenseMatrix:Ze,config:le,matrix:Ne,typed:W}),Wo=mw({Complex:hr,config:le,divideScalar:yr,typed:W}),M_=Ew({DenseMatrix:Ze,divideScalar:yr,equalScalar:je,matrix:Ne,multiplyScalar:wr,subtract:gr,typed:W}),A_=g0({flatten:Ea,matrix:Ne,size:zr,typed:W}),Nr=D1({addScalar:Er,dot:$i,equalScalar:je,matrix:Ne,multiplyScalar:wr,typed:W}),Tv=DA({addScalar:Er,complex:Ai,conj:Zn,divideScalar:yr,equal:ht,identity:Xn,isZero:Mt,matrix:Ne,multiplyScalar:wr,sign:bv,sqrt:Ut,subtract:gr,typed:W,unaryMinus:Lt,zeros:At}),Ca=Yl({bignumber:zt,matrix:Ne,config:le,larger:it,largerEq:Ci,smaller:nt,smallerEq:Zo,typed:W}),S_=Fw({DenseMatrix:Ze,equalScalar:je,matrix:Ne,typed:W,zeros:At}),E_=jM({compareNatural:St,typed:W}),Dv=rS({SparseMatrix:Pt,abs:jr,add:br,divideScalar:yr,larger:it,largerEq:Ci,multiply:Nr,subtract:gr,transpose:ko,typed:W}),Bv=hp({add:br,config:le,numeric:vt,typed:W}),C_=p2({add:br,matrix:Ne,typed:W}),_v=Ow({DenseMatrix:Ze,divideScalar:yr,equalScalar:je,matrix:Ne,multiplyScalar:wr,subtract:gr,typed:W}),O_=rM({Complex:hr,config:le,typed:W}),Iv=k0({DenseMatrix:Ze,config:le,equalScalar:je,matrix:Ne,round:Oi,typed:W,zeros:At}),$_=W$({addScalar:Er,combinations:Mi,isInteger:tt,isNegative:Jn,isPositive:Si,larger:it,typed:W}),T_=Db({matrix:Ne,multiply:Nr,subtract:gr,typed:W}),Rv=DO({divideScalar:yr,isZero:Mt,matrix:Ne,multiply:Nr,subtract:gr,typed:W,unaryMinus:Lt}),D_=XO({abs:jr,addScalar:Er,divideScalar:yr,multiplyScalar:wr,sqrt:Ut,subtract:gr,typed:W,unaryMinus:Lt}),B_=Y1({equalScalar:je,matrix:Ne,multiplyScalar:wr,typed:W}),Fv=NN({larger:it,smaller:nt}),qv=Q0({Complex:hr,DenseMatrix:Ze,ceil:Iv,equalScalar:je,floor:$v,matrix:Ne,typed:W,zeros:At}),zv=dN({DenseMatrix:Ze,smaller:nt}),Pr=bN({ImmutableDenseMatrix:zv}),__=jO({abs:jr,add:br,addScalar:Er,config:le,divideScalar:yr,equalScalar:je,flatten:Ea,isNumeric:gn,isZero:Mt,matrix:Ne,multiply:Nr,multiplyScalar:wr,smaller:nt,subtract:gr,typed:W}),I_=d1({equalScalar:je,matrix:Ne,typed:W}),R_=vw({Complex:hr,config:le,divideScalar:yr,log:Wo,typed:W}),Pv=Yf({config:le,larger:it,numeric:vt,typed:W}),F_=c$({add:br,compare:Wn,multiply:Nr,partitionSelect:Ho,typed:W}),q_=rf({Index:Pr,matrix:Ne,range:Ca,typed:W}),z_=zM({DenseMatrix:Ze,Index:Pr,compareNatural:St,size:zr,subset:at,typed:W}),P_=kM({DenseMatrix:Ze,Index:Pr,compareNatural:St,size:zr,subset:at,typed:W}),U_=ZM({Index:Pr,compareNatural:St,size:zr,subset:at,typed:W}),L_=YM({Index:Pr,compareNatural:St,size:zr,subset:at,typed:W}),k_=fN({compare:Wn,compareNatural:St,matrix:Ne,typed:W}),Uv=Il({Index:Pr,matrix:Ne,range:Ca,typed:W}),V_=h2({Index:Pr,typed:W}),yn=_O({abs:jr,addScalar:Er,det:Rv,divideScalar:yr,identity:Xn,matrix:Ne,multiply:Nr,typed:W,unaryMinus:Lt}),G_=RO({Complex:hr,add:br,ctranspose:Go,deepEqual:Ov,divideScalar:yr,dot:$i,dotDivide:Ei,equal:ht,inv:yn,matrix:Ne,multiply:Nr,typed:W}),kt=uw({Complex:hr,config:le,fraction:Sa,identity:Xn,inv:yn,matrix:Ne,multiply:Nr,number:en,typed:W}),Lv=UM({DenseMatrix:Ze,Index:Pr,compareNatural:St,size:zr,subset:at,typed:W}),H_=WM({Index:Pr,compareNatural:St,size:zr,subset:at,typed:W}),kv=SN({FibonacciHeap:Fv,addScalar:Er,equalScalar:je}),Z_=GO({abs:jr,add:br,identity:Xn,inv:yn,max:Pv,multiply:Nr,size:zr,sqrt:Ut,subtract:gr,typed:W}),ze=DN({BigNumber:ye,Complex:hr,Fraction:dn,abs:jr,addScalar:Er,config:le,divideScalar:yr,equal:ht,fix:qv,format:Ma,isNumeric:gn,multiplyScalar:wr,number:en,pow:kt,round:Oi,subtract:gr}),J_=JT({BigNumber:ye,Unit:ze,config:le}),W_=O4({BigNumber:ye,Unit:ze,config:le}),X_=d4({BigNumber:ye,Unit:ze,config:le}),Y_=YT({BigNumber:ye,Unit:ze,config:le}),Q_=y4({BigNumber:ye,Unit:ze,config:le}),j_=QT({BigNumber:ye,Unit:ze,config:le}),K_=qN({Unit:ze,typed:W}),e5=c4({BigNumber:ye,Unit:ze,config:le}),r5=yw({DenseMatrix:Ze,equalScalar:je,matrix:Ne,pow:kt,typed:W}),t5=ZT({BigNumber:ye,Unit:ze,config:le}),n5=XT({BigNumber:ye,Unit:ze,config:le}),a5=kO({abs:jr,add:br,identity:Xn,inv:yn,multiply:Nr,typed:W}),i5=b4({BigNumber:ye,Unit:ze,config:le}),o5=x4({BigNumber:ye,Unit:ze,config:le}),Vv=d$({BigNumber:ye,Complex:hr,config:le,multiplyScalar:wr,pow:kt,typed:W}),s5=kT({BigNumber:ye,Unit:ze,config:le}),u5=s4({BigNumber:ye,Unit:ze,config:le}),c5=r4({BigNumber:ye,Unit:ze,config:le}),l5=w4({BigNumber:ye,Unit:ze,config:le}),f5=HT({BigNumber:ye,Unit:ze,config:le}),m5=$4({BigNumber:ye,Unit:ze,config:le}),p5=M4({BigNumber:ye,Unit:ze,config:le}),v5=l4({BigNumber:ye,Unit:ze,config:le}),h5=e4({BigNumber:ye,Unit:ze,config:le}),d5=R4({BigNumber:ye,Unit:ze,config:le}),g5=B4({BigNumber:ye,Unit:ze,config:le}),y5=F4({BigNumber:ye,Unit:ze,config:le}),b5=u4({BigNumber:ye,Unit:ze,config:le}),x5=GT({BigNumber:ye,Unit:ze,config:le}),w5=m4({BigNumber:ye,Unit:ze,config:le}),Gv=GM({DenseMatrix:Ze,Index:Pr,compareNatural:St,size:zr,subset:at,typed:W}),N5=LT({BigNumber:ye,Unit:ze,config:le}),M5=C4({BigNumber:ye,Unit:ze,config:le}),A5=p4({BigNumber:ye,Unit:ze,config:le}),S5=g4({BigNumber:ye,Unit:ze,config:le}),E5=t4({BigNumber:ye,Unit:ze,config:le}),C5=WT({BigNumber:ye,Unit:ze,config:le}),dt=JO({divideScalar:yr,equalScalar:je,inv:yn,matrix:Ne,multiply:Nr,typed:W}),O5=a4({BigNumber:ye,Unit:ze,config:le}),Ti=x$({gamma:Vv,typed:W}),$5=D4({BigNumber:ye,Unit:ze,config:le}),T5=jT({BigNumber:ye,Unit:ze,config:le}),Hv=$A({DenseMatrix:Ze,Spa:kv,SparseMatrix:Pt,abs:jr,addScalar:Er,divideScalar:yr,equalScalar:je,larger:it,matrix:Ne,multiplyScalar:wr,subtract:gr,typed:W,unaryMinus:Lt}),D5=KT({BigNumber:ye,Unit:ze,config:le}),B5=T4({BigNumber:ye,Unit:ze,config:le}),_5=A$({add:br,divide:dt,factorial:Ti,isInteger:tt,isPositive:Si,multiply:Nr,typed:W}),I5=E$({factorial:Ti,typed:W}),R5=_4({BigNumber:ye,Unit:ze,config:le}),F5=f4({BigNumber:ye,Unit:ze,config:le}),q5=E4({BigNumber:ye,Unit:ze,config:le}),Zv=k$({bignumber:zt,addScalar:Er,combinations:Mi,divideScalar:yr,factorial:Ti,isInteger:tt,isNegative:Jn,larger:it,multiplyScalar:wr,number:en,pow:kt,subtract:gr,typed:W}),z5=_N({Unit:ze,typed:W}),P5=G$({addScalar:Er,isInteger:tt,isNegative:Jn,stirlingS2:Zv,typed:W}),Jv=UO({abs:jr,add:br,addScalar:Er,atan:pv,bignumber:zt,column:Uv,complex:Ai,config:le,cos:Lo,diag:Av,divideScalar:yr,dot:$i,equal:ht,flatten:Ea,im:hv,inv:yn,larger:it,matrix:Ne,matrixFromColumns:Cv,multiply:Nr,multiplyScalar:wr,number:en,qr:Tv,re:yv,sin:Po,smaller:nt,sqrt:Ut,subtract:gr,typed:W,usolve:Jo,usolveAll:_v}),U5=i4({BigNumber:ye,Unit:ze,config:le}),L5=yp({add:br,divide:dt,typed:W}),k5=A4({BigNumber:ye,Unit:ze,config:le}),V5=VT({BigNumber:ye,Unit:ze,config:le}),Wv=e2({Index:Pr,concat:Vo,setDifference:Lv,size:zr,subset:at,typed:W}),G5=n4({BigNumber:ye,Unit:ze,config:le}),H5=nS({DenseMatrix:Ze,lsolve:Ev,lup:Hv,matrix:Ne,slu:Dv,typed:W,usolve:Jo}),Xv=n$({add:br,compare:Wn,divide:dt,partitionSelect:Ho,typed:W}),Z5=t2({Index:Pr,concat:Vo,setIntersect:Gv,setSymDifference:Wv,size:zr,subset:at,typed:W}),Xo=Np({add:br,apply:Uo,divide:dt,isNaN:Aa,multiply:Nr,subtract:gr,typed:W}),J5=N$({divide:dt,dotDivide:Ei,isNumeric:gn,log:Wo,matrix:Ne,multiply:Nr,sum:Bv,typed:W}),Yv=u2({abs:jr,add:br,conj:Zn,ctranspose:Go,eigs:Jv,equalScalar:je,larger:it,matrix:Ne,multiply:Nr,pow:kt,smaller:nt,sqrt:Ut,typed:W}),W5=I4({BigNumber:ye,Unit:ze,config:le}),Qv=fx({BigNumber:ye,DenseMatrix:Ze,SparseMatrix:Pt,addScalar:Er,config:le,cos:Lo,matrix:Ne,multiplyScalar:wr,norm:Yv,sin:Po,typed:W,unaryMinus:Lt}),X5=N4({BigNumber:ye,Unit:ze,config:le}),Y5=Ap({sqrt:Ut,typed:W,variance:Xo}),Q5=i$({abs:jr,map:dv,median:Xv,subtract:gr,typed:W}),j5=cx({multiply:Nr,rotationMatrix:Qv,typed:W}),Yn={},Oa={},jv={},Yo=cS({math:Yn}),Ur=y2({mathWithTransform:Oa}),$a=j2({Node:Ur}),rn=rA({Node:Ur}),bn=aA({Node:Ur}),Kv=lA({Node:Ur}),Ta=A2({Node:Ur}),eh=D2({Node:Ur,ResultSet:lv}),rh=I2({Node:Ur}),xn=V2({Node:Ur}),th=sA({Node:Ur}),K5=bT({classes:jv}),eI=$O({Chain:Yo,typed:W}),nh=Z2({Node:Ur,typed:W}),Da=w2({Node:Ur,subset:at}),ah=O2({matrix:Ne,Node:Ur,subset:at}),Ba=X2({Node:Ur,size:zr}),wn=pA({Unit:ze,Node:Ur,math:Yn}),Nn=dA({Node:Ur,SymbolNode:wn,math:Yn}),Et=yA({AccessorNode:Da,ArrayNode:Ta,AssignmentNode:ah,BlockNode:eh,ConditionalNode:rh,ConstantNode:xn,FunctionAssignmentNode:nh,FunctionNode:Nn,IndexNode:Ba,ObjectNode:$a,OperatorNode:rn,ParenthesisNode:bn,RangeNode:th,RelationalNode:Kv,SymbolNode:wn,config:le,numeric:vt,typed:W}),ih=cT({ConstantNode:xn,FunctionNode:Nn,OperatorNode:rn,ParenthesisNode:bn,parse:Et}),Qo=oT({AccessorNode:Da,ArrayNode:Ta,ConstantNode:xn,FunctionNode:Nn,IndexNode:Ba,ObjectNode:$a,OperatorNode:rn,ParenthesisNode:bn,SymbolNode:wn,add:br,divide:dt,equal:ht,isZero:Mt,multiply:Nr,pow:kt,subtract:gr}),rI=xA({parse:Et,typed:W}),oh=oS({parse:Et}),tI=Y$({parse:Et,typed:W}),Di=nT({bignumber:zt,fraction:Sa,AccessorNode:Da,ArrayNode:Ta,ConstantNode:xn,FunctionNode:Nn,IndexNode:Ba,ObjectNode:$a,OperatorNode:rn,ParenthesisNode:bn,SymbolNode:wn,add:br,config:le,divide:dt,equal:ht,isZero:Mt,mathWithTransform:Oa,matrix:Ne,multiply:Nr,parse:Et,pow:kt,resolve:ih,simplifyCore:Qo,subtract:gr,typed:W}),nI=fT({OperatorNode:rn,parse:Et,simplify:Di,typed:W}),jo=NA({parse:Et,typed:W}),aI=CO({Help:oh,mathWithTransform:Oa,typed:W}),sh=SA({evaluate:jo}),iI=dT({bignumber:zt,fraction:Sa,AccessorNode:Da,ArrayNode:Ta,ConstantNode:xn,FunctionNode:Nn,IndexNode:Ba,ObjectNode:$a,OperatorNode:rn,ParenthesisNode:bn,SymbolNode:wn,add:br,config:le,divide:dt,equal:ht,isZero:Mt,mathWithTransform:Oa,matrix:Ne,multiply:Nr,parse:Et,pow:kt,simplify:Di,simplifyCore:Qo,subtract:gr,typed:W}),oI=vT({ConstantNode:xn,FunctionNode:Nn,OperatorNode:rn,ParenthesisNode:bn,SymbolNode:wn,config:le,equal:ht,isZero:Mt,numeric:vt,parse:Et,simplify:Di,typed:W}),sI=CA({Parser:sh,typed:W});Rr(Yn,{e:uv,false:_D,fineStructure:ID,i:cv,Infinity:RD,LN10:FD,LOG10E:qD,NaN:zD,null:PD,phi:UD,SQRT1_2:kD,sackurTetrode:VD,tau:fv,true:GD,E:uv,version:HD,efimovFactor:ZD,LN2:JD,pi:mv,replacer:WD,reviver:K5,SQRT2:XD,typed:W,unaryPlus:zo,PI:mv,weakMixingAngle:YD,abs:jr,acos:QD,acot:jD,acsc:KD,addScalar:Er,arg:eB,asech:rB,asinh:tB,atan:pv,atanh:nB,bignumber:zt,bitNot:aB,boolean:iB,chain:eI,clone:oB,combinations:Mi,complex:Ai,conj:Zn,cosh:sB,coth:uB,csc:cB,cube:lB,equalScalar:je,erf:fB,exp:vv,expm1:mB,filter:pB,forEach:vB,format:Ma,getMatrixDataType:hB,hex:dB,im:hv,isInteger:tt,isNegative:Jn,isPositive:Si,isZero:Mt,LOG2E:gB,lgamma:yB,log10:bB,log2:xB,map:dv,multiplyScalar:wr,not:gv,number:en,oct:wB,pickRandom:NB,print:MB,random:AB,re:yv,sec:SB,sign:bv,sin:Po,splitUnit:EB,square:CB,string:OB,tan:$B,typeOf:TB,acosh:DB,acsch:BB,apply:Uo,asec:_B,bin:IB,combinationsWithRep:RB,cos:Lo,csch:FB,isNaN:Aa,isPrime:qB,randomInt:zB,sech:PB,sinh:UB,sparse:LB,sqrt:Ut,tanh:kB,unaryMinus:Lt,acoth:VB,cot:GB,fraction:Sa,isNumeric:gn,matrix:Ne,matrixFromFunction:HB,mod:xv,nthRoot:ZB,numeric:vt,or:JB,prod:wv,reshape:WB,size:zr,smaller:nt,squeeze:XB,subset:at,subtract:gr,to:YB,transpose:ko,xgcd:Nv,zeros:At,and:QB,bitAnd:jB,bitXor:KB,cbrt:e_,compare:Wn,compareText:Mv,concat:Vo,count:r_,ctranspose:Go,diag:Av,divideScalar:yr,dotDivide:Ei,equal:ht,fft:Sv,flatten:Ea,gcd:t_,hasNumericValue:n_,hypot:a_,ifft:i_,kron:o_,largerEq:Ci,leftShift:s_,lsolve:Ev,matrixFromColumns:Cv,min:u_,mode:c_,nthRoots:l_,ones:f_,partitionSelect:Ho,resize:m_,rightArithShift:p_,round:Oi,smallerEq:Zo,unequal:v_,usolve:Jo,xor:h_,add:br,atan2:d_,bitOr:g_,catalan:y_,compareNatural:St,cumsum:b_,deepEqual:Ov,diff:x_,dot:$i,equalText:w_,floor:$v,identity:Xn,invmod:N_,larger:it,log:Wo,lsolveAll:M_,matrixFromRows:A_,multiply:Nr,qr:Tv,range:Ca,rightLogShift:S_,setSize:E_,slu:Dv,sum:Bv,trace:C_,usolveAll:_v,asin:O_,ceil:Iv,composition:$_,cross:T_,det:Rv,distance:D_,dotMultiply:B_,fix:qv,intersect:__,lcm:I_,log1p:R_,max:Pv,quantileSeq:F_,row:q_,setCartesian:z_,setDistinct:P_,setIsSubset:U_,setPowerset:L_,sort:k_,column:Uv,index:V_,inv:yn,pinv:G_,pow:kt,setDifference:Lv,setMultiplicity:H_,sqrtm:Z_,vacuumImpedance:J_,wienDisplacement:W_,atomicMass:X_,bohrMagneton:Y_,boltzmann:Q_,conductanceQuantum:j_,createUnit:K_,deuteronMass:e5,dotPow:r5,electricConstant:t5,elementaryCharge:n5,expm:a5,faraday:i5,firstRadiation:o5,gamma:Vv,gravitationConstant:s5,hartreeEnergy:u5,klitzing:c5,loschmidt:l5,magneticConstant:f5,molarMass:m5,molarPlanckConstant:p5,neutronMass:v5,nuclearMagneton:h5,planckCharge:d5,planckLength:g5,planckTemperature:y5,protonMass:b5,reducedPlanckConstant:x5,rydberg:w5,setIntersect:Gv,speedOfLight:N5,stefanBoltzmann:M5,thomsonCrossSection:A5,avogadro:S5,bohrRadius:E5,coulomb:C5,divide:dt,electronMass:O5,factorial:Ti,gravity:$5,inverseConductanceQuantum:T5,lup:Hv,magneticFluxQuantum:D5,molarMassC12:B5,multinomial:_5,parse:Et,permutations:I5,planckMass:R5,quantumOfCirculation:F5,resolve:ih,secondRadiation:q5,simplifyCore:Qo,stirlingS2:Zv,unit:z5,bellNumbers:P5,compile:rI,eigs:Jv,fermiCoupling:U5,leafCount:tI,mean:L5,molarVolume:k5,planckConstant:V5,setSymDifference:Wv,simplify:Di,symbolicEqual:nI,classicalElectronRadius:G5,evaluate:jo,help:aI,lusolve:H5,median:Xv,rationalize:iI,setUnion:Z5,variance:Xo,derivative:oI,kldivergence:J5,norm:Yv,planckTime:W5,rotationMatrix:Qv,gasConstant:X5,parser:sI,std:Y5,mad:Q5,rotate:j5,config:le}),Rr(Oa,Yn,{filter:H4({typed:W}),forEach:W4({typed:W}),map:eD({typed:W}),apply:P4({isInteger:tt,typed:W}),diff:MD({bignumber:zt,matrix:Ne,number:en,subtract:gr,typed:W}),subset:yD({matrix:Ne,typed:W}),concat:wD({isInteger:tt,matrix:Ne,typed:W}),max:nD({config:le,larger:it,numeric:vt,typed:W}),min:cD({config:le,numeric:vt,smaller:nt,typed:W}),range:mD({bignumber:zt,matrix:Ne,config:le,larger:it,largerEq:Ci,smaller:nt,smallerEq:Zo,typed:W}),sum:OD({add:br,config:le,numeric:vt,typed:W}),cumsum:TD({add:br,typed:W,unaryPlus:zo}),row:hD({Index:Pr,matrix:Ne,range:Ca,typed:W}),column:k4({Index:Pr,matrix:Ne,range:Ca,typed:W}),index:Q4({Index:Pr}),mean:oD({add:br,divide:dt,typed:W}),variance:BD({add:br,apply:Uo,divide:dt,isNaN:Aa,multiply:Nr,subtract:gr,typed:W}),std:ED({sqrt:Ut,typed:W,variance:Xo})}),Rr(jv,{BigNumber:ye,Chain:Yo,Complex:hr,Fraction:dn,Matrix:Ni,Node:Ur,ObjectNode:$a,OperatorNode:rn,ParenthesisNode:bn,Range:LD,RelationalNode:Kv,ResultSet:lv,ArrayNode:Ta,BlockNode:eh,ConditionalNode:rh,ConstantNode:xn,DenseMatrix:Ze,RangeNode:th,FunctionAssignmentNode:nh,SparseMatrix:Pt,AccessorNode:Da,AssignmentNode:ah,IndexNode:Ba,FibonacciHeap:Fv,ImmutableDenseMatrix:zv,Index:Pr,Spa:kv,Unit:ze,SymbolNode:wn,FunctionNode:Nn,Help:oh,Parser:sh}),Yo.createProxy(Yn);/**
71
+ * @dice-roller/rpg-dice-roller - An advanced JS based dice roller that can roll various types of dice and modifiers, along with mathematical equations.
72
+ *
73
+ * @version 5.1.0
74
+ * @license MIT
75
+ * @author GreenImp Media <info@greenimp.co.uk> (http://greenimp.co.uk)
76
+ * @link https://dice-roller.github.io/documentation
77
+ */class Ko extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,Ko),this.name="CompareOperatorError",this.operator=e}}class es extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,es),this.name="ImportError",this.data=e}}class Bi extends Error{constructor(e,t=null){super(`Die "${e}" must have more than 1 possible value to ${t||"do this action"}`),Error.captureStackTrace&&Error.captureStackTrace(this,Bi),this.name="DieActionValueError",this.action=t,this.die=e}}class _i extends Error{constructor(e){super(`Notation "${e}" is invalid`),Error.captureStackTrace&&Error.captureStackTrace(this,_i),this.name="NotationError",this.notation=e}}class Ct extends Error{constructor(e=null){super(`Missing argument${e?` "${e}"`:""}`),Error.captureStackTrace&&Error.captureStackTrace(this,Ct),this.argumentName=e}}const uI=(r,e,t)=>{const a=Number(r),n=Number(e);let i;if(Number.isNaN(a)||Number.isNaN(n))return!1;switch(t){case"=":case"==":i=a===n;break;case"<":i=a<n;break;case">":i=a>n;break;case"<=":i=a<=n;break;case">=":i=a>=n;break;case"!":case"!=":case"<>":i=a!==n;break;default:i=!1;break}return i},uh=r=>jo(r),Mr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),rs=r=>{if(!Mr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},cI=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Mr(t)?parseFloat(`${t}`):0),0):0,lI=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),Or=9007199254740992,_a=Or-1,Ii=-1>>>0,ot=Ii+1,Vt=ot/2,ts=Vt-1,Ia=1<<21,Mn=Ia-1;function ns(r){return r.next()|0}function tn(r,e){return e===0?r:t=>r(t)+e}function as(r){const e=r.next()|0,t=r.next()>>>0;return(e&Mn)*ot+t+(e&Ia?-Or:0)}function ch(r){for(;;){const e=r.next()|0;if(e&4194304){if((e&8388607)===4194304&&(r.next()|0)===0)return Or}else{const t=r.next()>>>0;return(e&Mn)*ot+t+(e&Ia?-Or:0)}}}function lh(r){return r.next()>>>0}function Ri(r){const e=r.next()&Mn,t=r.next()>>>0;return e*ot+t}function is(r){for(;;){const e=r.next()|0;if(e&Ia){if((e&Mn)===0&&(r.next()|0)===0)return Or}else{const t=r.next()>>>0;return(e&Mn)*ot+t}}}function fh(r){return(r+1&r)===0}function fI(r){return e=>e.next()&r}function mI(r){const e=r+1,t=e*Math.floor(ot/e);return a=>{let n=0;do n=a.next()>>>0;while(n>=t);return n%e}}function pI(r){return fh(r)?fI(r):mI(r)}function vI(r){return(r|0)===0}function hI(r){return e=>{const t=e.next()&r,a=e.next()>>>0;return t*ot+a}}function dI(r){const e=r*Math.floor(Or/r);return t=>{let a=0;do{const n=t.next()&Mn,i=t.next()>>>0;a=n*ot+i}while(a>=e);return a%r}}function gI(r){const e=r+1;if(vI(e)){const t=(e/ot|0)-1;if(fh(t))return hI(t)}return dI(e)}function mh(r,e){return t=>{let a=0;do{const n=t.next()|0,i=t.next()>>>0;a=(n&Mn)*ot+i+(n&Ia?-Or:0)}while(a<r||a>e);return a}}function An(r,e){if(r=Math.floor(r),e=Math.floor(e),r<-Or||!isFinite(r))throw new RangeError(`Expected min to be at least ${-Or}`);if(e>Or||!isFinite(e))throw new RangeError(`Expected max to be at most ${Or}`);const t=e-r;return t<=0||!isFinite(t)?()=>r:t===Ii?r===0?lh:tn(ns,r+Vt):t<Ii?tn(pI(t),r):t===_a?tn(Ri,r):t<_a?tn(gI(t),r):e-1-r===_a?tn(is,r):r===-Or&&e===Or?ch:r===-Or&&e===_a?as:r===-_a&&e===Or?tn(as,1):e===Or?tn(mh(r-1,e-1),1):mh(r,e)}function yI(r){return(r.next()&1)===1}function os(r,e){return t=>r(t)<e}function bI(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*ot;return e%1===0?os(ns,e-Vt|0):os(Ri,Math.round(r*Or))}}function xI(r,e){return e==null?r==null?yI:bI(r):r<=0?()=>!1:r>=e?()=>!0:os(An(0,e-1),r)}function wI(r,e){const t=An(+r,+e);return a=>new Date(t(a))}function ph(r){return An(1,r)}function NI(r,e){const t=ph(r);return a=>{const n=[];for(let i=0;i<e;++i)n.push(t(a));return n}}const MI="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function ss(r=MI){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=An(0,e-1);return(a,n)=>{let i="";for(let c=0;c<n;++c){const m=t(a);i+=r.charAt(m)}return i}}const vh="0123456789abcdef",AI=ss(vh),SI=ss(vh.toUpperCase());function EI(r){return r?SI:AI}function hh(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function dh(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function CI(r,e,t,a){const n=e.length;if(n===0)throw new RangeError("Cannot pick from an empty array");const i=t==null?0:hh(dh(t),n),c=a===void 0?n:hh(dh(a),n);if(i>=c)throw new RangeError(`Cannot pick between bounds ${i} and ${c}`);const m=An(i,c-1);return e[m(r)]}function OI(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function gh(r){return Ri(r)/Or}function yh(r){return is(r)/Or}function $I(r,e,t=!1){if(isFinite(r)){if(!isFinite(e))throw new RangeError("Expected max to be a finite number")}else throw new RangeError("Expected min to be a finite number");return tn(OI(t?yh:gh,e-r),r)}const TI=Array.prototype.slice;function us(r,e,t=0){const a=e.length;if(a)for(let n=a-1>>>0;n>t;--n){const c=An(0,n)(r);if(n!==c){const m=e[n];e[n]=e[c],e[c]=m}}return e}function DI(r,e,t){if(t<0||t>e.length||!isFinite(t))throw new RangeError("Expected sampleSize to be within 0 and the length of the population");if(t===0)return[];const a=TI.call(e),n=a.length;if(n===t)return us(r,a,0);const i=n-t;return us(r,a,i-1).slice(i)}const BI=(()=>{try{if("x".repeat(3)==="xxx")return(r,e)=>r.repeat(e)}catch{}return(r,e)=>{let t="";for(;e>0;)e&1&&(t+=r),e>>=1,r+=r;return t}})();function Qn(r,e){return BI("0",e-r.length)+r}function _I(r){const e=r.next()>>>0,t=r.next()|0,a=r.next()|0,n=r.next()>>>0;return Qn(e.toString(16),8)+"-"+Qn((t&65535).toString(16),4)+"-"+Qn((t>>4&4095|16384).toString(16),4)+"-"+Qn((a&16383|32768).toString(16),4)+"-"+Qn((a>>4&65535).toString(16),4)+Qn(n.toString(16),8)}const jn={next(){return Math.random()*ot|0}};class II{constructor(e=jn){this.engine=e}int32(){return ns(this.engine)}uint32(){return lh(this.engine)}uint53(){return Ri(this.engine)}uint53Full(){return is(this.engine)}int53(){return as(this.engine)}int53Full(){return ch(this.engine)}integer(e,t){return An(e,t)(this.engine)}realZeroToOneInclusive(){return yh(this.engine)}realZeroToOneExclusive(){return gh(this.engine)}real(e,t,a=!1){return $I(e,t,a)(this.engine)}bool(e,t){return xI(e,t)(this.engine)}pick(e,t,a){return CI(this.engine,e,t,a)}shuffle(e){return us(this.engine,e)}sample(e,t){return DI(this.engine,e,t)}die(e){return ph(e)(this.engine)}dice(e,t){return NI(e,t)(this.engine)}uuid4(){return _I(this.engine)}string(e,t){return ss(t)(this.engine,e)}hex(e,t){return EI(t)(this.engine,e)}date(e,t){return wI(e,t)(this.engine)}}const bh=(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=Vt,e[0]===-Vt)return Int32Array}catch{}return Array})();let Fi=null;const cs=128;let ls=cs;const RI={next(){return ls>=cs&&(Fi===null&&(Fi=new bh(cs)),crypto.getRandomValues(Fi),ls=0),Fi[ls++]|0}};function FI(r=jn,e=16){const t=[];t.push(new Date().getTime()|0);for(let a=1;a<e;++a)t[a]=r.next()|0;return t}const fs=(()=>{try{if(Math.imul(Ii,5)===-5)return Math.imul}catch{}const r=65535;return(e,t)=>{const a=e>>>16&r,n=e&r,i=t>>>16&r,c=t&r;return n*c+(a*c+n*i<<16>>>0)|0}})(),Ot=624,nn=Ot-1,ms=397,xh=Ot-ms,ps=2567483615;class Ra{constructor(){this.data=new bh(Ot),this.index=0,this.uses=0}static seed(e){return new Ra().seed(e)}static seedWithArray(e){return new Ra().seedWithArray(e)}static autoSeed(){return Ra.seedWithArray(FI())}next(){(this.index|0)>=Ot&&(vs(this.data),this.index=0);const e=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,qI(e)|0}getUseCount(){return this.uses}discard(e){if(e<=0)return this;for(this.uses+=e,(this.index|0)>=Ot&&(vs(this.data),this.index=0);e+this.index>Ot;)e-=Ot-this.index,vs(this.data),this.index=0;return this.index=this.index+e|0,this}seed(e){let t=0;this.data[0]=t=e|0;for(let a=1;a<Ot;a=a+1|0)this.data[a]=t=fs(t^t>>>30,1812433253)+a|0;return this.index=Ot,this.uses=0,this}seedWithArray(e){return this.seed(19650218),zI(this.data,e),this}}function vs(r){let e=0,t=0;for(;(e|0)<xh;e=e+1|0)t=r[e]&Vt|r[e+1|0]&ts,r[e]=r[e+ms|0]^t>>>1^(t&1?ps:0);for(;(e|0)<nn;e=e+1|0)t=r[e]&Vt|r[e+1|0]&ts,r[e]=r[e-xh|0]^t>>>1^(t&1?ps:0);t=r[nn]&Vt|r[0]&ts,r[nn]=r[ms-1]^t>>>1^(t&1?ps:0)}function qI(r){return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^r>>>18}function zI(r,e){let t=1,a=0;const n=e.length;let i=Math.max(n,Ot)|0,c=r[0]|0;for(;(i|0)>0;--i)r[t]=c=(r[t]^fs(c^c>>>30,1664525))+(e[a]|0)+(a|0)|0,t=t+1|0,++a,(t|0)>nn&&(r[0]=r[nn],t=1),a>=n&&(a=0);for(i=nn;(i|0)>0;--i)r[t]=c=(r[t]^fs(c^c>>>30,1566083941))-t|0,t=t+1|0,(t|0)>nn&&(r[0]=r[nn],t=1);r[0]=Vt}let wh=null;const hs=128;let ds=hs;const PI={next(){return ds>=hs&&(wh=new Int32Array(new Int8Array(require("crypto").randomBytes(4*hs)).buffer),ds=0),wh[ds++]|0}},Fa=Symbol("engine"),gs=Symbol("random"),Nh={browserCrypto:RI,nodeCrypto:PI,MersenneTwister19937:Ra,nativeMath:jn,min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class UI{constructor(e=jn){this.engine=e||jn}get engine(){return this[Fa]}set engine(e){if(e&&typeof e.next!="function")throw new TypeError("engine must have function `next()`");this[Fa]=e||jn,this[gs]=new II(this[Fa])}integer(e,t){return this[Fa].range=[e,t],this[gs].integer(e,t)}real(e,t,a=!1){return this[Fa].range=[e,t],this[gs].real(e,t,a)}}const Kn=new UI,Mh=Symbol("operator"),Ah=Symbol("value");class qa{constructor(e,t){if(e){if(!t&&t!==0)throw new Ct("value")}else throw new Ct("operator");this.operator=e,this.value=t}static isValidOperator(e){return typeof e=="string"&&/^(?:[<>!]?=|[<>]|<>)$/.test(e)}set operator(e){if(!this.constructor.isValidOperator(e))throw new Ko(e);this[Mh]=e}get operator(){return this[Mh]}set value(e){if(!Mr(e))throw new TypeError("value must be a finite number");this[Ah]=Number(e)}get value(){return this[Ah]}isMatch(e){return uI(e,this.value,this.operator)}toJSON(){const{operator:e,value:t}=this;return{operator:e,type:"compare-point",value:t}}toString(){return`${this.operator}${this.value}`}}class an{constructor(){this.order=999}get name(){return"modifier"}get notation(){return""}get maxIterations(){return 1e3}run(e,t){return e}toJSON(){const{notation:e,name:t}=this;return{name:t,notation:e,type:"modifier"}}toString(){return this.notation}}const Sh=Symbol("compare-point");class za extends an{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[Sh]}set comparePoint(e){if(!(e instanceof qa))throw new TypeError("comparePoint must be instance of ComparePoint");this[Sh]=e}get name(){return"comparison"}get notation(){return`${this.comparePoint||""}`}isComparePoint(e){return this.comparePoint?this.comparePoint.isMatch(e):!1}toJSON(){const{comparePoint:e}=this;return Object.assign(super.toJSON(),{comparePoint:e})}}const Eh=Symbol("compound"),Ch=Symbol("penetrate");class Oh extends za{constructor(e=null,t=!1,a=!1){super(e),this[Eh]=!!t,this[Ch]=!!a,this.order=3}get compound(){return this[Eh]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[Ch]}run(e,t){if(t.min===t.max)throw new Bi(t,"explode");const a=e;return a.rolls=e.rolls.map(n=>{const i=[n];let c=n.value;for(let m=0;m<this.maxIterations&&this.isComparePoint(c);m++){const f=i[i.length-1],l=t.rollOnce();c=l.value,f.modifiers.add("explode"),this.penetrate&&(f.modifiers.add("penetrate"),l.value-=1),i.push(l)}return this.compound&&i.length>1?(n.value=cI(i.map(m=>m.value)),n.modifiers=["explode","compound"],this.penetrate&&n.modifiers.add("penetrate"),n):i}).flat(),a}toJSON(){const{compound:e,penetrate:t}=this;return Object.assign(super.toJSON(),{compound:e,penetrate:t})}}const LI={compound:"!",explode:"!","critical-failure":"__","critical-success":"**",drop:"d",max:"v",min:"^",penetrate:"p","re-roll":"r","re-roll-once":"ro","target-failure":"_","target-success":"*"},$h=(...r)=>[...r].reduce((e,t)=>{let a;return t instanceof an?a=t.name:a=t,e+(LI[a]||a)},""),ys=Symbol("calculation-value"),bs=Symbol("modifiers"),Pa=Symbol("initial-value"),Th=Symbol("use-in-total"),xs=Symbol("value");class qi{constructor(e,t=[],a=!0){if(Mr(e))this[Pa]=Number(e),this.modifiers=t||[],this.useInTotal=a;else if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Mr(e.initialValue)?e.initialValue:e.value;if(!Mr(n))throw new TypeError(`Result value is invalid: ${n}`);this[Pa]=Number(n),Mr(e.value)&&Number(e.value)!==this[Pa]&&(this.value=e.value),Mr(e.calculationValue)&&parseFloat(`${e.calculationValue}`)!==this.value&&(this.calculationValue=e.calculationValue),this.modifiers=e.modifiers||t||[],this.useInTotal=typeof e.useInTotal=="boolean"?e.useInTotal:a||!1}else throw e===1/0?new RangeError("Result value must be a finite number"):new TypeError(`Result value is invalid: ${e}`)}get calculationValue(){return Mr(this[ys])?parseFloat(this[ys]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Result calculation value must be a finite number");if(e&&!t)throw new TypeError(`Result calculation value is invalid: ${e}`);this[ys]=t?parseFloat(`${e}`):null}get initialValue(){return this[Pa]}get modifierFlags(){return $h(...this.modifiers)}get modifiers(){return this[bs]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string")){this[bs]=new Set([...e]);return}if(!e&&e!==0){this[bs]=new Set;return}throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get useInTotal(){return!!this[Th]}set useInTotal(e){this[Th]=!!e}get value(){return Mr(this[xs])?this[xs]:this[Pa]}set value(e){if(e===1/0)throw new RangeError("Result value must be a finite number");if(!Mr(e))throw new TypeError(`Result value is invalid: ${e}`);this[xs]=Number(e)}toJSON(){const{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:n,useInTotal:i,value:c}=this;return{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:[...n],type:"result",useInTotal:i,value:c}}toString(){return this.value+this.modifierFlags}}const ws=Symbol("rolls");class Gt{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[ws]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[ws]=[],e.forEach(t=>{this.addRoll(t)})}get value(){return this.rolls.reduce((e,t)=>e+(t.useInTotal?t.calculationValue:0),0)}addRoll(e){const t=e instanceof qi?e:new qi(e);this[ws].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const Dh=Symbol("once");class Bh extends za{constructor(e=!1,t=null){super(t),this.once=!!e,this.order=4}get name(){return"re-roll"}get notation(){return`r${this.once?"o":""}${super.notation}`}get once(){return!!this[Dh]}set once(e){this[Dh]=!!e}run(e,t){if(t.min===t.max)throw new Bi(t,"re-roll");return e.rolls.map(a=>{for(let n=0;n<this.maxIterations&&this.isComparePoint(a.value);n++){const i=t.rollOnce();if(a.value=i.value,a.modifiers.add(`re-roll${this.once?"-once":""}`),this.once)break}return a}),e}toJSON(){const{once:e}=this;return Object.assign(super.toJSON(),{once:e})}}const zi=Symbol("modifiers"),_h=Symbol("qty"),Ih=Symbol("sides"),Rh=Symbol("min-value"),Fh=Symbol("max-value");class ea{constructor(e,t=1,a=null,n=1,i=null){if(!e&&e!==0)throw new Ct("sides");if(e===1/0)throw new RangeError("numerical sides must be finite number");if(Mr(e)){if(e<1||!rs(e))throw new RangeError("numerical sides must be a positive finite number")}else if(typeof e!="string")throw new TypeError("non-numerical sides must be a string");if(Mr(t)){if(t<1||t>999)throw new RangeError("qty must be between 1 and 999")}else throw new TypeError("qty must be a positive finite integer");if(Mr(n)){if(!rs(n))throw new RangeError("min must a finite number")}else throw new TypeError("min must a finite number");if(i&&!Mr(i))throw new TypeError("max must a finite number");if(i&&!rs(i))throw new RangeError("max must a finite number");this[_h]=parseInt(`${t}`,10),this[Ih]=e,a&&(this.modifiers=a),this[Rh]=parseInt(n,10),this[Fh]=i?parseInt(`${i}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[zi]?new Map([...this[zi]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof an)))throw new TypeError("modifiers must only contain Modifier instances");this[zi]=t,this[zi].forEach(a=>{a instanceof Oh&&!a.comparePoint?a.comparePoint=new qa("=",this.max):a instanceof Bh&&!a.comparePoint&&(a.comparePoint=new qa("=",this.min))})}get max(){return this[Fh]}get min(){return this[Rh]}get name(){return"standard"}get notation(){let e=`${this.qty}d${this.sides}`;return this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}get qty(){return this[_h]}get sides(){return this[Ih]}roll(){const e=new Gt;for(let t=0;t<this.qty;t++)e.addRoll(this.rollOnce());return(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}rollOnce(){return new qi(Kn.integer(this.min,this.max))}toJSON(){const{average:e,max:t,min:a,modifiers:n,name:i,notation:c,qty:m,sides:f}=this;return{average:e,max:t,min:a,modifiers:n,name:i,notation:c,qty:m,sides:f,type:"die"}}toString(){return this.notation}}class kI extends ea{constructor(e=2,t=1,a=null){let n=e;if(!n&&n!==0)n=2;else if(n!==1&&n!==2)throw new RangeError("nonBlanks must be 1 or 2");super(n,t,a,-1,1)}get name(){return"fudge"}get nonBlanks(){return super.sides}get sides(){return`F.${this.nonBlanks}`}rollOnce(){let e=0;if(this.nonBlanks===2)e=Kn.integer(1,3)-2;else if(this.nonBlanks===1){const t=Kn.integer(1,6);t===1?e=-1:t===6&&(e=1)}return new qi(e)}}class VI extends ea{constructor(e=1,t=null,a=!1){super(100,e,t),this.sidesAsNumber=!!a}get name(){return"percentile"}get sides(){return this.sidesAsNumber?super.sides:"%"}}class GI extends za{constructor(e){super(e),this.order=9}get name(){return"critical-failure"}get notation(){return`cf${super.notation}`}run(e,t){return e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-failure"),a)),e}}class HI extends za{constructor(e){super(e),this.order=8}get name(){return"critical-success"}get notation(){return`cs${super.notation}`}run(e,t){return e.rolls.forEach(a=>(this.isComparePoint(a.value)&&a.modifiers.add("critical-success"),a)),e}}const Ns=Symbol("calculation-value"),qh=Symbol("is-roll-group"),Ms=Symbol("modifiers"),As=Symbol("results"),zh=Symbol("use-in-total");class Ir{constructor(e=[],t=[],a=!1,n=!0){this.isRollGroup=a,this.modifiers=t,this.results=e,this.useInTotal=n}get calculationValue(){return Mr(this[Ns])?parseFloat(this[Ns]):this.value}set calculationValue(e){const t=Mr(e);if(e===1/0)throw new RangeError("Results calculation value must be a finite number");if(e&&!t)throw new TypeError(`Results calculation value is invalid: ${e}`);this[Ns]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[qh]}set isRollGroup(e){this[qh]=!!e}get length(){return this.results.length||0}get modifierFlags(){return $h(...this.modifiers)}get modifiers(){return this[Ms]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string"))this[Ms]=new Set([...e]);else if(!e&&e!==0)this[Ms]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[As]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[As]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[zh]}set useInTotal(e){this[zh]=!!e}get value(){if(!this.results.length)return 0;const e=this.results.reduce((t,a)=>{let n=a;return a instanceof Ir?n=a.useInTotal?a.calculationValue:0:a instanceof Gt&&(n=a.value),t+n},typeof this.results[0]=="string"?"":0);return typeof e=="string"?uh(e):e}addResult(e){let t;if(e instanceof Ir||e instanceof Gt)t=e;else if(typeof e=="string"||Mr(e))t=e;else throw new TypeError("value must be one of ResultGroup, RollResults, string, or number");this[As].push(t)}toJSON(){const{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:n,results:i,useInTotal:c,value:m}=this;return{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:[...n],results:i,type:"result-group",useInTotal:c,value:m}}toString(){let e;return this.isRollGroup?e=`{${this.results.join(", ")}}`:e=this.results.join(""),this.modifierFlags&&(e=`(${e})${this.modifierFlags}`),e}}const Ph=Symbol("end"),Uh=Symbol("qty");class Lh extends an{constructor(e="h",t=1){super(),this.end=e,this.qty=t,this.order=5}get end(){return this[Ph]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[Ph]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[Uh]}set qty(e){if(e===1/0)throw new RangeError("qty must be a finite number");if(!Mr(e)||e<1)throw new TypeError("qty must be a positive finite integer");this[Uh]=Math.floor(e)}rangeToDrop(e){return this.end==="h"?[0,e.length-this.qty]:[this.qty,e.length]}run(e,t){let a,n;return e instanceof Ir?(a=e.results,a.length===1&&a[0]instanceof Ir?n=a[0].results.map((i,c)=>i instanceof Gt?i.rolls.map((m,f)=>({value:m.value,index:[c,f]})):null).flat().filter(Boolean):n=[...a].map((i,c)=>({value:i.value,index:c}))):(a=e.rolls,n=[...a].map((i,c)=>({value:i.value,index:c}))),n=n.sort((i,c)=>i.value-c.value).map(i=>i.index).slice(...this.rangeToDrop(n)),n.forEach(i=>{let c;Array.isArray(i)?c=a[0].results[i[0]].rolls[i[1]]:c=a[i],c.modifiers.add("drop"),c.useInTotal=!1}),e}toJSON(){const{end:e,qty:t}=this;return Object.assign(super.toJSON(),{end:e,qty:t})}}class ZI extends Lh{constructor(e="l",t=1){super(e,t),this.order=6}get name(){return`drop-${this.end}`}get notation(){return`d${this.end}${this.qty}`}rangeToDrop(e){return this.end==="h"?[e.length-this.qty,e.length]:[0,this.qty]}}const kh=Symbol("max");class JI extends an{constructor(e){super(),this.max=e,this.order=2}get max(){return this[kh]}set max(e){if(!Mr(e))throw new TypeError("max must be a number");this[kh]=parseFloat(`${e}`)}get name(){return"max"}get notation(){return`max${this.max}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value>this.max&&(i.value=this.max,i.modifiers.add("max")),i}),a}toJSON(){const{max:e}=this;return Object.assign(super.toJSON(),{max:e})}}const Vh=Symbol("min");class WI extends an{constructor(e){super(),this.min=e,this.order=1}get min(){return this[Vh]}set min(e){if(!Mr(e))throw new TypeError("min must be a number");this[Vh]=parseFloat(`${e}`)}get name(){return"min"}get notation(){return`min${this.min}`}run(e,t){const a=e;return a.rolls=e.rolls.map(n=>{const i=n;return n.value<this.min&&(i.value=this.min,i.modifiers.add("min")),i}),a}toJSON(){const{min:e}=this;return Object.assign(super.toJSON(),{min:e})}}const Gh=Symbol("direction");class XI extends an{constructor(e="a"){super(),this.direction=e,this.order=10}get direction(){return this[Gh]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[Gh]=e}get name(){return"sorting"}get notation(){return`s${this.direction}`}run(e,t){let a;return e instanceof Ir?a="results":a="rolls",e[a]=e[a].sort((n,i)=>this.direction==="d"?i.value-n.value:n.value-i.value),e instanceof Ir&&(e[a]=e[a].map(n=>n instanceof Ir||n instanceof Gt?this.run(n,t):n)),e}toJSON(){const{direction:e}=this;return Object.assign(super.toJSON(),{direction:e})}}const Hh=Symbol("failure-cp");class YI extends za{constructor(e,t=null){super(e),this.failureComparePoint=t,this.order=7}get failureComparePoint(){return this[Hh]}set failureComparePoint(e){if(e&&!(e instanceof qa))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[Hh]=e||null}get name(){return"target"}get notation(){return`${super.notation}${this.failureComparePoint?`f${this.failureComparePoint}`:""}`}get successComparePoint(){return this.comparePoint}set successComparePoint(e){super.comparePoint=e}getStateValue(e){return this.isSuccess(e)?1:this.isFailure(e)?-1:0}isFailure(e){return this.failureComparePoint?this.failureComparePoint.isMatch(e):!1}isNeutral(e){return!this.isSuccess(e)&&!this.isFailure(e)}isSuccess(e){return this.isComparePoint(e)}run(e,t){let a;return e instanceof Ir?a=e.results:a=e.rolls,a.forEach(n=>{this.isSuccess(n.value)?n.modifiers.add("target-success"):this.isFailure(n.value)&&n.modifiers.add("target-failure"),n.calculationValue=this.getStateValue(n.value)}),e}toJSON(){const{failureComparePoint:e,successComparePoint:t}=this,a=super.toJSON();return delete a.comparePoint,Object.assign(a,{failureComparePoint:e,successComparePoint:t})}}const QI=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},jI=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},Ss=Symbol("modifiers"),Es=Symbol("expressions");class Zh{constructor(e=[],t=[]){this.expressions=e,this.modifiers=t}get expressions(){return[...this[Es]||[]]}set expressions(e){if(!e)throw new Ct("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[Es]=[],e.forEach(t=>{if(!t||!Array.isArray(t))throw new TypeError(`Expressions must be an array of arrays: ${e}`);if(t.length===0)throw new TypeError(`Sub expressions cannot be empty: ${e}`);if(!t.every(a=>a instanceof ea||typeof a=="string"||typeof a=="number"))throw new TypeError("Sub expression items must be Dice, numbers, or strings");this[Es].push(t)})}get modifiers(){return this[Ss]?new Map([...this[Ss]].sort((e,t)=>e[1].order-t[1].order)):null}set modifiers(e){let t;if(e instanceof Map)t=e;else if(Array.isArray(e))t=new Map(e.map(a=>[a.name,a]));else if(typeof e=="object")t=new Map(Object.entries(e));else throw new TypeError("modifiers should be a Map, array, or an Object containing Modifiers");if(t.size&&[...t.entries()].some(a=>!(a[1]instanceof an)))throw new TypeError("modifiers must only contain Modifier instances");this[Ss]=t}get notation(){let e=this.expressions.map(t=>t.reduce((a,n)=>a+n,"")).join(", ");return e=`{${e}}`,this.modifiers&&this.modifiers.size&&(e+=[...this.modifiers.values()].reduce((t,a)=>t+a.notation,"")),e}roll(){const e=new Ir(this.expressions.map(t=>{const a=t.map(n=>n instanceof ea?n.roll():n);return new Ir(a)}));return e.isRollGroup=!0,(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}toJSON(){const{modifiers:e,notation:t,expressions:a}=this;return{expressions:a,modifiers:e,notation:t,type:"group"}}toString(){return this.notation}}function KI(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function ra(r,e,t,a){var n=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(n,ra.prototype),n.expected=e,n.found=t,n.location=a,n.name="SyntaxError",n}KI(ra,Error);function Cs(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}ra.prototype.format=function(r){var e="Error: "+this.message;if(this.location){var t=null,a;for(a=0;a<r.length;a++)if(r[a].source===this.location.source){t=r[a].text.split(/\r\n|\n|\r/g);break}var n=this.location.start,i=this.location.source+":"+n.line+":"+n.column;if(t){var c=this.location.end,m=Cs("",n.line.toString().length),f=t[n.line-1],l=n.line===c.line?c.column:f.length+1;e+=`
78
+ --> `+i+`
79
+ `+m+` |
80
+ `+n.line+" | "+f+`
81
+ `+m+" | "+Cs("",n.column-1)+Cs("",l-n.column,"^")}else e+=`
82
+ at `+i}return e},ra.buildMessage=function(r,e){var t={literal:function(l){return'"'+n(l.text)+'"'},class:function(l){var s=l.parts.map(function(o){return Array.isArray(o)?i(o[0])+"-"+i(o[1]):i(o)});return"["+(l.inverted?"^":"")+s+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(l){return l.description}};function a(l){return l.charCodeAt(0).toString(16).toUpperCase()}function n(l){return l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(s){return"\\x0"+a(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+a(s)})}function i(l){return l.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(s){return"\\x0"+a(s)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(s){return"\\x"+a(s)})}function c(l){return t[l.type](l)}function m(l){var s=l.map(c),o,u;if(s.sort(),s.length>0){for(o=1,u=1;o<s.length;o++)s[o-1]!==s[o]&&(s[u]=s[o],u++);s.length=u}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}function f(l){return l?'"'+n(l)+'"':"end of input"}return"Expected "+m(r)+" but "+f(e)+" found."};function eR(r,e){e=e!==void 0?e:{};var t={},a=e.grammarSource,n={Main:nd},i=nd,c="{",m=",",f="}",l="d",s="d%",o="dF",u=".",p="!",v="p",h="k",b="max",w="min",N="r",d="o",y="cs",x="cf",g="s",S="a",A="f",E="!=",M="<=",B=">=",C="=",_="<>",P=">",I="<",T="(",D=")",Z="abs",$="ceil",H="cos",Q="exp",te="floor",J="log",re="round",oe="sign",ae="sin",ce="sqrt",se="tan",me="pow",ne="-",Ae="**",Ce="*",ge="^",Se="%",z="/",Y="+",V=/^[12]/,L=/^[lh]/,j=/^[.]/,F=/^[1-9]/,U=/^[0-9]/,ee=/^[ \t\n\r]/,k=Pe("{",!1),fe=Pe(",",!1),ve=Pe("}",!1),Me=Pe("d",!1),be=Pe("d%",!1),xe=Pe("dF",!1),Te=Pe(".",!1),nr=sa(["1","2"],!1,!1),dr=Pe("!",!1),fr=Pe("p",!1),Gr=sa(["l","h"],!1,!1),Hr=Pe("k",!1),st=Pe("max",!1),er=Pe("min",!1),$t=Pe("r",!1),O=Pe("o",!1),X=Pe("cs",!1),ue=Pe("cf",!1),we=Pe("s",!1),ke=Pe("a",!1),Xe=Pe("f",!1),Sr=Pe("!=",!1),La=Pe("<=",!1),_s=Pe(">=",!1),Is=Pe("=",!1),Rs=Pe("<>",!1),Fs=Pe(">",!1),qs=Pe("<",!1),ia=Pe("(",!1),oa=Pe(")",!1),zs=Pe("abs",!1),Ps=Pe("ceil",!1),Us=Pe("cos",!1),Ls=Pe("exp",!1),ks=Pe("floor",!1),Vs=Pe("log",!1),Gs=Pe("round",!1),ka=Pe("sign",!1),pr=Pe("sin",!1),Tr=Pe("sqrt",!1),ut=Pe("tan",!1),ER=Pe("pow",!1),jh=Pe("-",!1),CR=sa(["."],!1,!1),OR=sa([["1","9"]],!1,!1),ki=sa([["0","9"]],!1,!1),$R=Pe("**",!1),TR=Pe("*",!1),DR=Pe("^",!1),BR=Pe("%",!1),_R=Pe("/",!1),IR=Pe("+",!1),RR=sF("whitespace"),Kh=sa([" "," ",`
83
+ `,"\r"],!1,!1),FR=function(R,K,ie){return new Zh([R,...K.map(de=>de[3])],Object.assign({},...ie.map(de=>({[de.name]:de}))))},qR=function(R,K){return R.modifiers=Object.assign({},...K.map(ie=>({[ie.name]:ie}))),R},zR=function(R,K){return new ea(K,R||1)},PR=function(R){return new VI(R||1)},UR=function(R,K){return new kI(K?parseInt(K[1],10):2,R||1)},LR=function(R,K,ie){return new Oh(ie,!!R,!!K)},kR=function(R,K){return new YI(R,K)},VR=function(R,K){return new ZI(R||"l",K)},GR=function(R,K){return new Lh(R||"h",K)},HR=function(R){return new JI(R)},ZR=function(R){return new WI(R)},JR=function(R,K){return new Bh(!!R,K)},WR=function(R){return new HI(R)},XR=function(R){return new GI(R)},YR=function(R){return new XI(R||"a")},QR=function(R){return R},jR=function(R,K){return new qa(R,K)},KR=function(R,K,ie){return uh(Zs())},eF=function(R,K){return R=Array.isArray(R)?R:[R],[...R,...K.map(([,ie,,de])=>[ie,de]).flat(2)]},rF=function(R,K,ie){return[R,...K,ie]},tF=function(R,K){return[`${R}(`,...K,")"]},nF=function(R,K,ie){return[`${R}(`,...K,",",...ie,")"]},aF=function(){return parseFloat(Zs())},ed=function(){return parseInt(Zs(),10)},iF=function(){return"^"},G=0,vr=0,Vi=[{line:1,column:1}],Tt=0,Hs=[],Ee=0,Gi;if("startRule"in e){if(!(e.startRule in n))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');i=n[e.startRule]}function Zs(){return r.substring(vr,G)}function Pe(R,K){return{type:"literal",text:R,ignoreCase:K}}function sa(R,K,ie){return{type:"class",parts:R,inverted:K,ignoreCase:ie}}function oF(){return{type:"end"}}function sF(R){return{type:"other",description:R}}function rd(R){var K=Vi[R],ie;if(K)return K;for(ie=R-1;!Vi[ie];)ie--;for(K=Vi[ie],K={line:K.line,column:K.column};ie<R;)r.charCodeAt(ie)===10?(K.line++,K.column=1):K.column++,ie++;return Vi[R]=K,K}function td(R,K){var ie=rd(R),de=rd(K);return{source:a,start:{offset:R,line:ie.line,column:ie.column},end:{offset:K,line:de.line,column:de.column}}}function Oe(R){G<Tt||(G>Tt&&(Tt=G,Hs=[]),Hs.push(R))}function uF(R,K,ie){return new ra(ra.buildMessage(R,K),R,K,ie)}function nd(){var R;return R=sn(),R}function cF(){var R,K,ie,de,Ie,Ve,ur,Ar,gt;if(R=G,r.charCodeAt(G)===123?(K=c,G++):(K=t,Ee===0&&Oe(k)),K!==t)if(xr(),ie=sn(),ie!==t){for(de=[],Ie=G,Ve=xr(),r.charCodeAt(G)===44?(ur=m,G++):(ur=t,Ee===0&&Oe(fe)),ur!==t?(Ar=xr(),gt=sn(),gt!==t?(Ve=[Ve,ur,Ar,gt],Ie=Ve):(G=Ie,Ie=t)):(G=Ie,Ie=t);Ie!==t;)de.push(Ie),Ie=G,Ve=xr(),r.charCodeAt(G)===44?(ur=m,G++):(ur=t,Ee===0&&Oe(fe)),ur!==t?(Ar=xr(),gt=sn(),gt!==t?(Ve=[Ve,ur,Ar,gt],Ie=Ve):(G=Ie,Ie=t)):(G=Ie,Ie=t);if(Ie=xr(),r.charCodeAt(G)===125?(Ve=f,G++):(Ve=t,Ee===0&&Oe(ve)),Ve!==t){for(ur=[],Ar=Hi();Ar!==t;)ur.push(Ar),Ar=Hi();vr=R,R=FR(ie,de,ur)}else G=R,R=t}else G=R,R=t;else G=R,R=t;return R}function lF(){var R,K,ie,de;if(R=G,K=fF(),K===t&&(K=mF(),K===t&&(K=pF())),K!==t){for(ie=[],de=Hi();de!==t;)ie.push(de),de=Hi();vr=R,R=qR(K,ie)}else G=R,R=t;return R}function fF(){var R,K,ie,de;return R=G,K=Zi(),K===t&&(K=null),r.charCodeAt(G)===100?(ie=l,G++):(ie=t,Ee===0&&Oe(Me)),ie!==t?(de=Zi(),de!==t?(vr=R,R=zR(K,de)):(G=R,R=t)):(G=R,R=t),R}function mF(){var R,K,ie;return R=G,K=Zi(),K===t&&(K=null),r.substr(G,2)===s?(ie=s,G+=2):(ie=t,Ee===0&&Oe(be)),ie!==t?(vr=R,R=PR(K)):(G=R,R=t),R}function pF(){var R,K,ie,de,Ie,Ve;return R=G,K=Zi(),K===t&&(K=null),r.substr(G,2)===o?(ie=o,G+=2):(ie=t,Ee===0&&Oe(xe)),ie!==t?(de=G,r.charCodeAt(G)===46?(Ie=u,G++):(Ie=t,Ee===0&&Oe(Te)),Ie!==t?(V.test(r.charAt(G))?(Ve=r.charAt(G),G++):(Ve=t,Ee===0&&Oe(nr)),Ve!==t?(Ie=[Ie,Ve],de=Ie):(G=de,de=t)):(G=de,de=t),de===t&&(de=null),vr=R,R=UR(K,de)):(G=R,R=t),R}function Hi(){var R;return R=vF(),R===t&&(R=hF(),R===t&&(R=dF(),R===t&&(R=gF(),R===t&&(R=xF(),R===t&&(R=wF(),R===t&&(R=NF(),R===t&&(R=MF(),R===t&&(R=yF(),R===t&&(R=bF()))))))))),R}function vF(){var R,K,ie,de,Ie;return R=G,r.charCodeAt(G)===33?(K=p,G++):(K=t,Ee===0&&Oe(dr)),K!==t?(r.charCodeAt(G)===33?(ie=p,G++):(ie=t,Ee===0&&Oe(dr)),ie===t&&(ie=null),r.charCodeAt(G)===112?(de=v,G++):(de=t,Ee===0&&Oe(fr)),de===t&&(de=null),Ie=ua(),Ie===t&&(Ie=null),vr=R,R=LR(ie,de,Ie)):(G=R,R=t),R}function hF(){var R,K,ie;return R=G,K=ua(),K!==t?(ie=AF(),ie===t&&(ie=null),vr=R,R=kR(K,ie)):(G=R,R=t),R}function dF(){var R,K,ie,de;return R=G,r.charCodeAt(G)===100?(K=l,G++):(K=t,Ee===0&&Oe(Me)),K!==t?(L.test(r.charAt(G))?(ie=r.charAt(G),G++):(ie=t,Ee===0&&Oe(Gr)),ie===t&&(ie=null),de=Ws(),de!==t?(vr=R,R=VR(ie,de)):(G=R,R=t)):(G=R,R=t),R}function gF(){var R,K,ie,de;return R=G,r.charCodeAt(G)===107?(K=h,G++):(K=t,Ee===0&&Oe(Hr)),K!==t?(L.test(r.charAt(G))?(ie=r.charAt(G),G++):(ie=t,Ee===0&&Oe(Gr)),ie===t&&(ie=null),de=Ws(),de!==t?(vr=R,R=GR(ie,de)):(G=R,R=t)):(G=R,R=t),R}function yF(){var R,K,ie;return R=G,r.substr(G,3)===b?(K=b,G+=3):(K=t,Ee===0&&Oe(st)),K!==t?(ie=Sn(),ie!==t?(vr=R,R=HR(ie)):(G=R,R=t)):(G=R,R=t),R}function bF(){var R,K,ie;return R=G,r.substr(G,3)===w?(K=w,G+=3):(K=t,Ee===0&&Oe(er)),K!==t?(ie=Sn(),ie!==t?(vr=R,R=ZR(ie)):(G=R,R=t)):(G=R,R=t),R}function xF(){var R,K,ie,de;return R=G,r.charCodeAt(G)===114?(K=N,G++):(K=t,Ee===0&&Oe($t)),K!==t?(r.charCodeAt(G)===111?(ie=d,G++):(ie=t,Ee===0&&Oe(O)),ie===t&&(ie=null),de=ua(),de===t&&(de=null),vr=R,R=JR(ie,de)):(G=R,R=t),R}function wF(){var R,K,ie;return R=G,r.substr(G,2)===y?(K=y,G+=2):(K=t,Ee===0&&Oe(X)),K!==t?(ie=ua(),ie!==t?(vr=R,R=WR(ie)):(G=R,R=t)):(G=R,R=t),R}function NF(){var R,K,ie;return R=G,r.substr(G,2)===x?(K=x,G+=2):(K=t,Ee===0&&Oe(ue)),K!==t?(ie=ua(),ie!==t?(vr=R,R=XR(ie)):(G=R,R=t)):(G=R,R=t),R}function MF(){var R,K,ie;return R=G,r.charCodeAt(G)===115?(K=g,G++):(K=t,Ee===0&&Oe(we)),K!==t?(r.charCodeAt(G)===97?(ie=S,G++):(ie=t,Ee===0&&Oe(ke)),ie===t&&(r.charCodeAt(G)===100?(ie=l,G++):(ie=t,Ee===0&&Oe(Me))),ie===t&&(ie=null),vr=R,R=YR(ie)):(G=R,R=t),R}function AF(){var R,K,ie;return R=G,r.charCodeAt(G)===102?(K=A,G++):(K=t,Ee===0&&Oe(Xe)),K!==t?(ie=ua(),ie!==t?(vr=R,R=QR(ie)):(G=R,R=t)):(G=R,R=t),R}function ua(){var R,K,ie;return R=G,K=SF(),K!==t?(ie=Sn(),ie!==t?(vr=R,R=jR(K,ie)):(G=R,R=t)):(G=R,R=t),R}function SF(){var R;return r.substr(G,2)===E?(R=E,G+=2):(R=t,Ee===0&&Oe(Sr)),R===t&&(r.substr(G,2)===M?(R=M,G+=2):(R=t,Ee===0&&Oe(La)),R===t&&(r.substr(G,2)===B?(R=B,G+=2):(R=t,Ee===0&&Oe(_s)),R===t&&(r.charCodeAt(G)===61?(R=C,G++):(R=t,Ee===0&&Oe(Is)),R===t&&(r.substr(G,2)===_?(R=_,G+=2):(R=t,Ee===0&&Oe(Rs)),R===t&&(r.charCodeAt(G)===62?(R=P,G++):(R=t,Ee===0&&Oe(Fs)),R===t&&(r.charCodeAt(G)===60?(R=I,G++):(R=t,Ee===0&&Oe(qs)))))))),R}function Zi(){var R,K,ie,de,Ie,Ve,ur,Ar,gt,ca;if(R=Ws(),R===t)if(R=G,r.charCodeAt(G)===40?(K=T,G++):(K=t,Ee===0&&Oe(ia)),K!==t){if(xr(),ie=G,de=Sn(),de!==t){if(Ie=[],Ve=G,ur=xr(),Ar=Ji(),Ar!==t?(gt=xr(),ca=Sn(),ca!==t?(ur=[ur,Ar,gt,ca],Ve=ur):(G=Ve,Ve=t)):(G=Ve,Ve=t),Ve!==t)for(;Ve!==t;)Ie.push(Ve),Ve=G,ur=xr(),Ar=Ji(),Ar!==t?(gt=xr(),ca=Sn(),ca!==t?(ur=[ur,Ar,gt,ca],Ve=ur):(G=Ve,Ve=t)):(G=Ve,Ve=t);else Ie=t;Ie!==t?(de=[de,Ie],ie=de):(G=ie,ie=t)}else G=ie,ie=t;ie!==t?(de=xr(),r.charCodeAt(G)===41?(Ie=D,G++):(Ie=t,Ee===0&&Oe(oa)),Ie!==t?(vr=R,R=KR()):(G=R,R=t)):(G=R,R=t)}else G=R,R=t;return R}function sn(){var R,K,ie,de,Ie,Ve,ur,Ar;if(R=G,K=Js(),K!==t){for(ie=[],de=G,Ie=xr(),Ve=Ji(),Ve!==t?(ur=xr(),Ar=Js(),Ar!==t?(Ie=[Ie,Ve,ur,Ar],de=Ie):(G=de,de=t)):(G=de,de=t);de!==t;)ie.push(de),de=G,Ie=xr(),Ve=Ji(),Ve!==t?(ur=xr(),Ar=Js(),Ar!==t?(Ie=[Ie,Ve,ur,Ar],de=Ie):(G=de,de=t)):(G=de,de=t);vr=R,R=eF(K,ie)}else G=R,R=t;return R}function Js(){var R,K,ie,de;return R=EF(),R===t&&(R=lF(),R===t&&(R=Sn(),R===t&&(R=G,r.charCodeAt(G)===40?(K=T,G++):(K=t,Ee===0&&Oe(ia)),K!==t?(xr(),ie=sn(),ie!==t?(xr(),r.charCodeAt(G)===41?(de=D,G++):(de=t,Ee===0&&Oe(oa)),de!==t?(vr=R,R=rF(K,ie,de)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R===t&&(R=cF())))),R}function EF(){var R,K,ie,de,Ie,Ve,ur;return R=G,r.substr(G,3)===Z?(K=Z,G+=3):(K=t,Ee===0&&Oe(zs)),K===t&&(r.substr(G,4)===$?(K=$,G+=4):(K=t,Ee===0&&Oe(Ps)),K===t&&(r.substr(G,3)===H?(K=H,G+=3):(K=t,Ee===0&&Oe(Us)),K===t&&(r.substr(G,3)===Q?(K=Q,G+=3):(K=t,Ee===0&&Oe(Ls)),K===t&&(r.substr(G,5)===te?(K=te,G+=5):(K=t,Ee===0&&Oe(ks)),K===t&&(r.substr(G,3)===J?(K=J,G+=3):(K=t,Ee===0&&Oe(Vs)),K===t&&(r.substr(G,5)===re?(K=re,G+=5):(K=t,Ee===0&&Oe(Gs)),K===t&&(r.substr(G,4)===oe?(K=oe,G+=4):(K=t,Ee===0&&Oe(ka)),K===t&&(r.substr(G,3)===ae?(K=ae,G+=3):(K=t,Ee===0&&Oe(pr)),K===t&&(r.substr(G,4)===ce?(K=ce,G+=4):(K=t,Ee===0&&Oe(Tr)),K===t&&(r.substr(G,3)===se?(K=se,G+=3):(K=t,Ee===0&&Oe(ut)))))))))))),K!==t?(r.charCodeAt(G)===40?(ie=T,G++):(ie=t,Ee===0&&Oe(ia)),ie!==t?(xr(),de=sn(),de!==t?(xr(),r.charCodeAt(G)===41?(Ie=D,G++):(Ie=t,Ee===0&&Oe(oa)),Ie!==t?(vr=R,R=tF(K,de)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R===t&&(R=G,r.substr(G,3)===me?(K=me,G+=3):(K=t,Ee===0&&Oe(ER)),K===t&&(r.substr(G,3)===b?(K=b,G+=3):(K=t,Ee===0&&Oe(st)),K===t&&(r.substr(G,3)===w?(K=w,G+=3):(K=t,Ee===0&&Oe(er)))),K!==t?(r.charCodeAt(G)===40?(ie=T,G++):(ie=t,Ee===0&&Oe(ia)),ie!==t?(xr(),de=sn(),de!==t?(xr(),r.charCodeAt(G)===44?(Ie=m,G++):(Ie=t,Ee===0&&Oe(fe)),Ie!==t?(xr(),Ve=sn(),Ve!==t?(xr(),r.charCodeAt(G)===41?(ur=D,G++):(ur=t,Ee===0&&Oe(oa)),ur!==t?(vr=R,R=nF(K,de,Ve)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)),R}function Sn(){var R,K,ie,de,Ie;return R=G,r.charCodeAt(G)===45?G++:Ee===0&&Oe(jh),K=ad(),K!==t?(ie=G,j.test(r.charAt(G))?(de=r.charAt(G),G++):(de=t,Ee===0&&Oe(CR)),de!==t?(Ie=ad(),Ie!==t?(de=[de,Ie],ie=de):(G=ie,ie=t)):(G=ie,ie=t),ie===t&&(ie=null),vr=R,R=aF()):(G=R,R=t),R}function Ws(){var R,K,ie,de;if(R=G,F.test(r.charAt(G))?(K=r.charAt(G),G++):(K=t,Ee===0&&Oe(OR)),K!==t){for(ie=[],U.test(r.charAt(G))?(de=r.charAt(G),G++):(de=t,Ee===0&&Oe(ki));de!==t;)ie.push(de),U.test(r.charAt(G))?(de=r.charAt(G),G++):(de=t,Ee===0&&Oe(ki));vr=R,R=ed()}else G=R,R=t;return R}function ad(){var R,K,ie;if(R=G,K=[],U.test(r.charAt(G))?(ie=r.charAt(G),G++):(ie=t,Ee===0&&Oe(ki)),ie!==t)for(;ie!==t;)K.push(ie),U.test(r.charAt(G))?(ie=r.charAt(G),G++):(ie=t,Ee===0&&Oe(ki));else K=t;return K!==t&&(vr=R,K=ed()),R=K,R}function Ji(){var R,K;return R=G,r.substr(G,2)===Ae?(K=Ae,G+=2):(K=t,Ee===0&&Oe($R)),K!==t&&(vr=R,K=iF()),R=K,R===t&&(r.charCodeAt(G)===42?(R=Ce,G++):(R=t,Ee===0&&Oe(TR)),R===t&&(r.charCodeAt(G)===94?(R=ge,G++):(R=t,Ee===0&&Oe(DR)),R===t&&(r.charCodeAt(G)===37?(R=Se,G++):(R=t,Ee===0&&Oe(BR)),R===t&&(r.charCodeAt(G)===47?(R=z,G++):(R=t,Ee===0&&Oe(_R)),R===t&&(r.charCodeAt(G)===43?(R=Y,G++):(R=t,Ee===0&&Oe(IR)),R===t&&(r.charCodeAt(G)===45?(R=ne,G++):(R=t,Ee===0&&Oe(jh)))))))),R}function xr(){var R,K;for(Ee++,R=[],ee.test(r.charAt(G))?(K=r.charAt(G),G++):(K=t,Ee===0&&Oe(Kh));K!==t;)R.push(K),ee.test(r.charAt(G))?(K=r.charAt(G),G++):(K=t,Ee===0&&Oe(Kh));return Ee--,K=t,Ee===0&&Oe(RR),R}if(Gi=i(),Gi!==t&&G===r.length)return Gi;throw Gi!==t&&G<r.length&&Oe(oF()),uF(Hs,Tt<r.length?r.charAt(Tt):null,Tt<r.length?td(Tt,Tt+1):td(Tt,Tt))}class Jh{static parse(e){if(!e)throw new Ct("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return eR(e)}}const ta=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),Os=Symbol("notation"),$s=Symbol("maxTotal"),Ts=Symbol("minTotal"),na=Symbol("expressions"),Pi=Symbol("roll-method"),on=Symbol("rolls"),Wh=Symbol("set-rolls"),Ui=Symbol("total"),Ds=r=>lI(r.calculationValue,2);class Ua{constructor(e){if(!e)throw new Ct("notation");if(this[na]=[],e instanceof Object&&!Array.isArray(e)){if(e.notation){if(typeof e.notation!="string")throw new _i(e.notation);e.rolls&&this[Wh](e.rolls)}else throw new Ct("notation");this[Os]=e.notation,this[na]=Jh.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[Os]=e,this[na]=Jh.parse(this.notation),this.roll();else throw new _i(e)}get averageTotal(){return(this.maxTotal+this.minTotal)/2}get maxTotal(){if(!this.hasExpressions())return 0;if(!this[$s]){const e=this[Pi](Nh.max);this[$s]=Ds(e)}return this[$s]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[Ts]){const e=this[Pi](Nh.min);this[Ts]=Ds(e)}return this[Ts]}get notation(){return this[Os]}get output(){let e=`${this.notation}: `;return this.hasRolls()?e+=`${this[on]} = ${this.total}`:e+="No dice rolled",e}get rolls(){return this[on]?this[on].results:[]}get total(){return!this[Ui]&&this.hasRolls()&&(this[Ui]=Ds(this[on])),this[Ui]||0}export(e=ta.JSON){switch(e){case ta.BASE_64:return btoa(this.export(ta.JSON));case ta.JSON:return JSON.stringify(this);case ta.OBJECT:return JSON.parse(this.export(ta.JSON));default:throw new TypeError(`Invalid export format "${e}"`)}}hasExpressions(){return this[na]&&this[na].length>0}hasRolls(){return this.hasExpressions()&&this.rolls.length>0}roll(){return this[Ui]=0,this[on]=this[Pi](),this.rolls}toJSON(){const{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:c,total:m}=this;return{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:c,total:m,type:"dice-roll"}}toString(){return this.output}static import(e){if(e){if(jI(e))return Ua.import(JSON.parse(e));if(QI(e))return Ua.import(atob(e));if(typeof e=="object")return new Ua(e);throw new es(e)}else throw new Ct("data")}[Pi](e){let t;e&&(t=Kn.engine,Kn.engine=e);const a=new Ir(this[na].map(n=>n instanceof ea||n instanceof Zh?n.roll():n).filter(n=>!!n||n===0));return e&&(Kn.engine=t),a}[Wh](e){if(e instanceof Ir)this[on]=e;else if(e instanceof Gt)this[on]=new Ir([e]);else if(Array.isArray(e))this[on]=new Ir(e.map(t=>{if(t instanceof Ir||t instanceof Gt)return t;if(Array.isArray(t))return new Gt(t);if(typeof t=="object"){if(Array.isArray(t.results))return new Ir(t.results,t.modifiers||[],t.isRollGroup||!1,typeof t.useInTotal=="boolean"?t.useInTotal:!0);if(Array.isArray(t.rolls))return new Gt(t.rolls)}return t}));else throw new TypeError("Rolls must be a valid result object, or an array")}}const Li={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=r,a=he.ref(`${t.notation||""}`),n=he.ref(null),i=he.ref(null),c=async()=>{n.value=null;try{i.value=a.value?new Ua(he.unref(a)):null}catch(f){i.value=null,f.name==="SyntaxError"?n.value=`Invalid notation; ${f.message}`:n.value=`An error has occurred: ${f.message}`}finally{e("roll",he.unref(a),he.unref(i))}},m=f=>{a.value=f,e("notation:change",f)};return(f,l)=>he.renderSlot(f.$slots,"default",{currentNotation:a.value,error:n.value,output:i.value,roll:c,bind:{value:a.value},on:{input:s=>m(s.target.value),change:s=>m(s.target.value),keyup:s=>s.keyCode===13?c():void 0}})}},rR=()=>(crypto==null?void 0:crypto.randomUUID())||`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function Bs(r){const e=he.ref(null);return e.value=`${r}${rR()}`,{id:e}}const tR=["id"],nR=["for"],aR=["for"],iR=["id","placeholder"],oR=["onClick"],sR={__name:"DiceRoller",props:{btnLabel:{type:String,default:"Roll"},className:{type:String,default:"dice-roller"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Bs(`${e.id||"dice-roller"}-`);return(a,n)=>(he.openBlock(),he.createBlock(Li,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:he.withCtx(({error:i,output:c,roll:m,on:f,bind:l})=>[he.createElementVNode("section",{id:r.id,class:he.normalizeClass(r.className)},[c?(he.openBlock(),he.createElementBlock("output",{key:0,name:"output",for:he.unref(t),class:he.normalizeClass(`${r.className}-output`)},he.toDisplayString(c),11,nR)):he.createCommentVNode("",!0),he.createElementVNode("div",{class:he.normalizeClass(`${r.className}-input-group`)},[he.createElementVNode("label",{for:he.unref(t),class:he.normalizeClass(`${r.className}-label`)}," Notation ",10,aR),he.createElementVNode("input",he.mergeProps({type:"text",name:"notation",id:he.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,i?`${r.className}-input-invalid`:null]},he.toHandlers(f,!0),l),null,16,iR),he.createElementVNode("button",{type:"button",class:he.normalizeClass(`${r.className}-button`),onClick:m},[he.renderSlot(a.$slots,"button",{},()=>[he.createTextVNode(he.toDisplayString(r.btnLabel),1)])],10,oR)],2),i?(he.openBlock(),he.createElementBlock("span",{key:1,class:he.normalizeClass(`${r.className}-error`)},he.toDisplayString(i),3)):he.createCommentVNode("",!0)],10,tR)]),_:3},8,["notation"]))}},uR=["id"],cR=["for"],lR={class:"flex flex-col sm:flex-row gap-y-4"},fR=["for"],mR=["id","placeholder"],pR=["onClick"],vR={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},hR={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=Bs(`${e.id||"dice-roller"}-`);return(a,n)=>(he.openBlock(),he.createBlock(Li,{notation:r.notation,"onNotation:change":n[0]||(n[0]=i=>a.$emit("notation:change",i)),onRoll:n[1]||(n[1]=i=>a.$emit("roll",i))},{default:he.withCtx(({error:i,output:c,roll:m,on:f,bind:l})=>[he.createElementVNode("div",{id:r.id,class:"dice-roller p-4 rounded bg-slate-100 text-gray-800 dark:bg-gray-600 dark:text-gray-200"},[c?(he.openBlock(),he.createElementBlock("output",{key:0,name:"output",for:he.unref(t),class:"block mb-8 p-4 text-2xl rounded bg-white text-black dark:bg-gray-300 dark:text-gray-800 border-l-8 border-[#d4f4c6]"},he.toDisplayString(c),9,cR)):he.createCommentVNode("",!0),he.createElementVNode("div",lR,[he.createElementVNode("label",{for:he.unref(t),class:"sr-only"}," Notation ",8,fR),he.createElementVNode("input",he.mergeProps({type:"text",name:"notation",id:he.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:["flex-auto block w-full h-11 py-2 px-4 text-base border shadow-sm rounded placeholder-gray-500 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none focus:placeholder-gray-400 dark:focus:placeholder-gray-400 invalid:text-red-600 invalid:border-red-200 invalid:bg-red-50 sm:border-r-0 sm:rounded-r-none",i?"text-red-600 border-red-200 bg-red-50":"bg-white text-gray-900 border-gray-300 dark:text-gray-600 dark:bg-gray-50 dark:border-gray-700"]},he.toHandlers(f,!0),l),null,16,mR),he.createElementVNode("button",{type:"button",class:"block px-8 h-11 font-bold text-gray-600 bg-gradient-to-br from-[#eda18b] to-[#d4f4c6] border border-l-0 border-gray-300 rounded transition dark:border-gray-700 focus:from-[#e88c71] focus:to-[#bbf0a3] focus:text-gray-800 focus:ring-[#d4f4c6] focus:border-[#d4f4c6] focus:outline-none hover:from-[#e88c71] hover:to-[#bbf0a3] hover:text-gray-800 sm:rounded-l-none",onClick:m},[he.renderSlot(a.$slots,"button",{},()=>[he.createTextVNode(he.toDisplayString(r.btnLabel),1)])],8,pR)]),i?(he.openBlock(),he.createElementBlock("span",vR,he.toDisplayString(i),1)):he.createCommentVNode("",!0)],8,uR)]),_:3},8,["notation"]))}},dR=["id"],gR={class:"card-body"},yR=["for"],bR=["for"],xR={class:"input-group"},wR=["id","placeholder"],NR=["onClick"],MR={key:1,class:"d-block mt-3 invalid-feedback"},aa=["primary","secondary","success","danger","warning","info","light","dark"],Xh=[...aa,"body","white","transparent"],Yh=[...aa,"body","muted","white","black-50","white-50"],AR=[...aa,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],Qh=[...aa,"white"],SR={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return Xh.includes(r)}},borderVariant:{type:String,validator(r){return Qh.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return AR.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return Xh.includes(r)}},outputBorderVariant:{type:String,validator(r){return Qh.includes(r)}},outputTextVariant:{type:String,validator(r){return Yh.includes(r)}},outputVariant:{type:String,validator(r){return aa.includes(r)}},textVariant:{type:String,validator(r){return Yh.includes(r)}},variant:{type:String,validator(r){return aa.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=he.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),a=he.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=he.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:i}=Bs(`${e.id||"dice-roller"}-`);return(c,m)=>(he.openBlock(),he.createBlock(Li,{notation:r.notation,"onNotation:change":m[0]||(m[0]=f=>c.$emit("notation:change",f)),onRoll:m[1]||(m[1]=f=>c.$emit("roll",f))},{default:he.withCtx(({error:f,output:l,roll:s,on:o,bind:u})=>[he.createElementVNode("div",{id:r.id,class:he.normalizeClass(["dice-roller card",he.unref(t)])},[he.createElementVNode("div",gR,[l?(he.openBlock(),he.createElementBlock("output",{key:0,name:"output",for:he.unref(i),class:he.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",he.unref(a)])},he.toDisplayString(l),11,yR)):he.createCommentVNode("",!0),he.createElementVNode("label",{for:he.unref(i),class:"form-label visually-hidden"}," Notation ",8,bR),he.createElementVNode("div",xR,[he.createElementVNode("input",he.mergeProps({type:"text",name:"notation",id:he.unref(i),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",f?"is-invalid":""]},he.toHandlers(o,!0),u),null,16,wR),he.createElementVNode("button",{type:"button",class:he.normalizeClass(["btn",he.unref(n)]),onClick:s},[he.renderSlot(c.$slots,"button",{},()=>[he.createTextVNode(he.toDisplayString(r.btnLabel),1)])],10,NR)]),f?(he.openBlock(),he.createElementBlock("span",MR,he.toDisplayString(f),1)):he.createCommentVNode("",!0)])],10,dR)]),_:3},8,["notation"]))}};yt.DiceRoller=sR,yt.DiceRollerBootstrap=SR,yt.DiceRollerRenderless=Li,yt.DiceRollerTailwind=hR,Object.defineProperties(yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});