@dice-roller/vue 1.0.3 → 1.1.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.
- package/dist/vue.js +16245 -16668
- package/dist/vue.umd.cjs +38 -36
- package/package.json +2 -2
package/dist/vue.umd.cjs
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(kr,xe){typeof exports=="object"&&typeof module<"u"?xe(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],xe):(kr=typeof globalThis<"u"?globalThis:kr||self,xe(kr.DiceRollerVue={},kr.Vue))})(this,function(kr,xe){"use strict";var R7=Object.defineProperty;var q7=(kr,xe,Ar)=>xe in kr?R7(kr,xe,{enumerable:!0,configurable:!0,writable:!0,value:Ar}):kr[xe]=Ar;var u0=(kr,xe,Ar)=>(q7(kr,typeof xe!="symbol"?xe+"":xe,Ar),Ar);function Ar(){return Ar=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},Ar.apply(this,arguments)}var Wu={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function tr(r){return typeof r=="number"}function rr(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 zt(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isComplex===!0||!1}function _a(r){return r&&typeof r=="object"&&Object.getPrototypeOf(r).isFraction===!0||!1}function Pt(r){return r&&r.constructor.prototype.isUnit===!0||!1}function Wr(r){return typeof r=="string"}var ur=Array.isArray;function He(r){return r&&r.constructor.prototype.isMatrix===!0||!1}function Lt(r){return Array.isArray(r)||He(r)}function ni(r){return r&&r.isDenseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Nn(r){return r&&r.isSparseMatrix&&r.constructor.prototype.isMatrix===!0||!1}function Ro(r){return r&&r.constructor.prototype.isRange===!0||!1}function ai(r){return r&&r.constructor.prototype.isIndex===!0||!1}function l0(r){return typeof r=="boolean"}function c0(r){return r&&r.constructor.prototype.isResultSet===!0||!1}function Xu(r){return r&&r.constructor.prototype.isHelp===!0||!1}function f0(r){return typeof r=="function"}function m0(r){return r instanceof Date}function v0(r){return r instanceof RegExp}function qo(r){return!!(r&&typeof r=="object"&&r.constructor===Object&&!zt(r)&&!_a(r))}function p0(r){return r===null}function h0(r){return r===void 0}function Dn(r){return r&&r.isAccessorNode===!0&&r.constructor.prototype.isNode===!0||!1}function nt(r){return r&&r.isArrayNode===!0&&r.constructor.prototype.isNode===!0||!1}function d0(r){return r&&r.isAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function g0(r){return r&&r.isBlockNode===!0&&r.constructor.prototype.isNode===!0||!1}function y0(r){return r&&r.isConditionalNode===!0&&r.constructor.prototype.isNode===!0||!1}function sr(r){return r&&r.isConstantNode===!0&&r.constructor.prototype.isNode===!0||!1}function zo(r){return sr(r)||_r(r)&&r.args.length===1&&sr(r.args[0])&&"-+~".includes(r.op)}function Ia(r){return r&&r.isFunctionAssignmentNode===!0&&r.constructor.prototype.isNode===!0||!1}function An(r){return r&&r.isFunctionNode===!0&&r.constructor.prototype.isNode===!0||!1}function Ln(r){return r&&r.isIndexNode===!0&&r.constructor.prototype.isNode===!0||!1}function or(r){return r&&r.isNode===!0&&r.constructor.prototype.isNode===!0||!1}function ii(r){return r&&r.isObjectNode===!0&&r.constructor.prototype.isNode===!0||!1}function _r(r){return r&&r.isOperatorNode===!0&&r.constructor.prototype.isNode===!0||!1}function rn(r){return r&&r.isParenthesisNode===!0&&r.constructor.prototype.isNode===!0||!1}function b0(r){return r&&r.isRangeNode===!0&&r.constructor.prototype.isNode===!0||!1}function x0(r){return r&&r.isRelationalNode===!0&&r.constructor.prototype.isNode===!0||!1}function qr(r){return r&&r.isSymbolNode===!0&&r.constructor.prototype.isNode===!0||!1}function Yu(r){return r&&r.constructor.prototype.isChain===!0||!1}function gr(r){var e=typeof r;return e==="object"?r===null?"null":rr(r)?"BigNumber":r.constructor&&r.constructor.name?r.constructor.name:"Object":e}function ke(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 ke(t)});if(r instanceof Date)return new Date(r.valueOf());if(rr(r))return r;if(r instanceof RegExp)throw new TypeError("Cannot clone "+r);return w0(r,ke)}function w0(r,e){var t={};for(var a in r)Re(r,a)&&(t[a]=e(r[a]));return t}function Qu(r,e){for(var t in e)Re(e,t)&&(r[t]=e[t]);return r}function Ra(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(!Ra(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)||!Ra(r[t],e[t]))return!1;for(t in e)if(!(t in r))return!1;return!0}else return r===e}}function N0(r,e,t){var a=!0,n;Object.defineProperty(r,e,{get:function(){return a&&(n=t(),a=!1),n},set:function(s){n=s,a=!1},configurable:!0,enumerable:!0})}function Re(r,e){return r&&Object.hasOwnProperty.call(r,e)}function D0(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 A0=["Matrix","Array"],E0=["number","BigNumber","Fraction"],de=function(e){if(e)throw new Error(`The global config is readonly.
|
|
2
2
|
Please create a mathjs instance if you want to change the default configuration.
|
|
3
3
|
Example:
|
|
4
4
|
|
|
5
5
|
import { create, all } from 'mathjs';
|
|
6
6
|
const mathjs = create(all);
|
|
7
7
|
mathjs.config({ number: 'BigNumber' });
|
|
8
|
-
`);return Object.freeze(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,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),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
|
|
8
|
+
`);return Object.freeze(Wu)};Ar(de,Wu,{MATRIX_OPTIONS:A0,NUMBER_OPTIONS:E0});function vt(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=S0(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var a=0,n=function(){};return{s:n,n:function(){return a>=r.length?{done:!0}:{done:!1,value:r[a++]}},e:function(u){throw u},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
9
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,s=!1,f;return{s:function(){t=t.call(r)},n:function(){var u=t.next();return i=u.done,u},e:function(u){s=!0,f=u},f:function(){try{!i&&t.return!=null&&t.return()}finally{if(s)throw f}}}}function S0(r,e){if(!!r){if(typeof r=="string")return Ku(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Ku(r,e)}}function Ku(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,a=new Array(e);t<e;t++)a[t]=r[t];return a}function Un(r){return Un=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Un(r)}function ju(){return!0}function at(){return!1}function kn(){}var el="Argument is not a typed-function.";function rl(){function r(q){return Un(q)==="object"&&q!==null&&q.constructor===Object}var e=[{name:"number",test:function(z){return typeof z=="number"}},{name:"string",test:function(z){return typeof z=="string"}},{name:"boolean",test:function(z){return typeof z=="boolean"}},{name:"Function",test:function(z){return typeof z=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(z){return z instanceof Date}},{name:"RegExp",test:function(z){return z instanceof RegExp}},{name:"Object",test:r},{name:"null",test:function(z){return z===null}},{name:"undefined",test:function(z){return z===void 0}}],t={name:"any",test:ju,isAny:!0},a,n,i=0,s={createCount:0};function f(q){var z=a.get(q);if(z)return z;var ee='Unknown type "'+q+'"',ue=q.toLowerCase(),me,ye=vt(n),be;try{for(ye.s();!(be=ye.n()).done;)if(me=be.value,me.toLowerCase()===ue){ee+='. Did you mean "'+me+'" ?';break}}catch(ve){ye.e(ve)}finally{ye.f()}throw new TypeError(ee)}function l(q){for(var z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any",ee=z?f(z).index:n.length,ue=[],me=0;me<q.length;++me){if(!q[me]||typeof q[me].name!="string"||typeof q[me].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");var ye=q[me].name;if(a.has(ye))throw new TypeError('Duplicate type name "'+ye+'"');ue.push(ye),a.set(ye,{name:ye,test:q[me].test,isAny:q[me].isAny,index:ee+me,conversionsTo:[]})}var be=n.slice(ee);n=n.slice(0,ee).concat(ue).concat(be);for(var ve=ee+ue.length;ve<n.length;++ve)a.get(n[ve]).index=ve}function u(){a=new Map,n=[],i=0,l([t],!1)}u(),l(e);function o(){var q,z=vt(n),ee;try{for(z.s();!(ee=z.n()).done;)q=ee.value,a.get(q).conversionsTo=[]}catch(ue){z.e(ue)}finally{z.f()}i=0}function c(q){var z=n.filter(function(ee){var ue=a.get(ee);return!ue.isAny&&ue.test(q)});return z.length?z:["any"]}function m(q){return q&&typeof q=="function"&&"_typedFunctionData"in q}function v(q,z,ee){if(!m(q))throw new TypeError(el);var ue=ee&&ee.exact,me=Array.isArray(z)?z.join(","):z,ye=w(me),be=y(ye);if(!ue||be in q.signatures){var ve=q._typedFunctionData.signatureMap.get(be);if(ve)return ve}var Ne=ye.length,Ie;if(ue){Ie=[];var Ge;for(Ge in q.signatures)Ie.push(q._typedFunctionData.signatureMap.get(Ge))}else Ie=q._typedFunctionData.signatures;for(var Be=0;Be<Ne;++Be){var lr=ye[Be],Je=[],cr=void 0,M=vt(Ie),H;try{for(M.s();!(H=M.n()).done;){cr=H.value;var se=N(cr.params,Be);if(!(!se||lr.restParam&&!se.restParam)){if(!se.hasAny){var De=function(){var Rr=d(se);if(lr.types.some(function(en){return!Rr.has(en.name)}))return"continue"}();if(De==="continue")continue}Je.push(cr)}}}catch(Rr){M.e(Rr)}finally{M.f()}if(Ie=Je,Ie.length===0)break}var ze,Le=vt(Ie),Mr;try{for(Le.s();!(Mr=Le.n()).done;)if(ze=Mr.value,ze.params.length<=Ne)return ze}catch(Rr){Le.e(Rr)}finally{Le.f()}throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+y(ye,", ")+"))")}function p(q,z,ee){return v(q,z,ee).implementation}function h(q,z){var ee=f(z);if(ee.test(q))return q;var ue=ee.conversionsTo;if(ue.length===0)throw new Error("There are no conversions to "+z+" defined.");for(var me=0;me<ue.length;me++){var ye=f(ue[me].from);if(ye.test(q))return ue[me].convert(q)}throw new Error("Cannot convert "+q+" to "+z)}function y(q){var z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return q.map(function(ee){return ee.name}).join(z)}function b(q){var z=q.indexOf("...")===0,ee=z?q.length>3?q.slice(3):"any":q,ue=ee.split("|").map(function(ve){return f(ve.trim())}),me=!1,ye=z?"...":"",be=ue.map(function(ve){return me=ve.isAny||me,ye+=ve.name+"|",{name:ve.name,typeIndex:ve.index,test:ve.test,isAny:ve.isAny,conversion:null,conversionIndex:-1}});return{types:be,name:ye.slice(0,-1),hasAny:me,hasConversion:!1,restParam:z}}function A(q){var z=q.types.map(function(be){return be.name}),ee=F(z),ue=q.hasAny,me=q.name,ye=ee.map(function(be){var ve=f(be.from);return ue=ve.isAny||ue,me+="|"+be.from,{name:be.from,typeIndex:ve.index,test:ve.test,isAny:ve.isAny,conversion:be,conversionIndex:be.index}});return{types:q.types.concat(ye),name:me,hasAny:ue,hasConversion:ye.length>0,restParam:q.restParam}}function d(q){return q.typeSet||(q.typeSet=new Set,q.types.forEach(function(z){return q.typeSet.add(z.name)})),q.typeSet}function w(q){var z=[];if(typeof q!="string")throw new TypeError("Signatures must be strings");var ee=q.trim();if(ee==="")return z;for(var ue=ee.split(","),me=0;me<ue.length;++me){var ye=b(ue[me].trim());if(ye.restParam&&me!==ue.length-1)throw new SyntaxError('Unexpected rest parameter "'+ue[me]+'": only allowed for the last parameter');if(ye.types.length===0)return null;z.push(ye)}return z}function x(q){var z=ce(q);return z?z.restParam:!1}function g(q){if(!q||q.types.length===0)return ju;if(q.types.length===1)return f(q.types[0].name).test;if(q.types.length===2){var z=f(q.types[0].name).test,ee=f(q.types[1].name).test;return function(ye){return z(ye)||ee(ye)}}else{var ue=q.types.map(function(me){return f(me.name).test});return function(ye){for(var be=0;be<ue.length;be++)if(ue[be](ye))return!0;return!1}}}function E(q){var z,ee,ue;if(x(q)){z=pe(q).map(g);var me=z.length,ye=g(ce(q)),be=function(Ne){for(var Ie=me;Ie<Ne.length;Ie++)if(!ye(Ne[Ie]))return!1;return!0};return function(Ne){for(var Ie=0;Ie<z.length;Ie++)if(!z[Ie](Ne[Ie]))return!1;return be(Ne)&&Ne.length>=me+1}}else return q.length===0?function(Ne){return Ne.length===0}:q.length===1?(ee=g(q[0]),function(Ne){return ee(Ne[0])&&Ne.length===1}):q.length===2?(ee=g(q[0]),ue=g(q[1]),function(Ne){return ee(Ne[0])&&ue(Ne[1])&&Ne.length===2}):(z=q.map(g),function(Ne){for(var Ie=0;Ie<z.length;Ie++)if(!z[Ie](Ne[Ie]))return!1;return Ne.length===z.length})}function N(q,z){return z<q.length?q[z]:x(q)?ce(q):null}function S(q,z){var ee=N(q,z);return ee?d(ee):new Set}function D(q){return q.conversion===null||q.conversion===void 0}function T(q,z){var ee=new Set;return q.forEach(function(ue){var me=S(ue.params,z),ye,be=vt(me),ve;try{for(be.s();!(ve=be.n()).done;)ye=ve.value,ee.add(ye)}catch(Ne){be.e(Ne)}finally{be.f()}}),ee.has("any")?["any"]:Array.from(ee)}function B(q,z,ee){var ue,me,ye=q||"unnamed",be=ee,ve,Ne=function(){var M=[];if(be.forEach(function(se){var De=N(se.params,ve),ze=g(De);(ve<se.params.length||x(se.params))&&ze(z[ve])&&M.push(se)}),M.length===0){if(me=T(be,ve),me.length>0){var H=c(z[ve]);return ue=new TypeError("Unexpected type of argument in function "+ye+" (expected: "+me.join(" or ")+", actual: "+H.join(" | ")+", index: "+ve+")"),ue.data={category:"wrongType",fn:ye,index:ve,actual:H,expected:me},{v:ue}}}else be=M};for(ve=0;ve<z.length;ve++){var Ie=Ne();if(Un(Ie)==="object")return Ie.v}var Ge=be.map(function(cr){return x(cr.params)?1/0:cr.params.length});if(z.length<Math.min.apply(null,Ge))return me=T(be,ve),ue=new TypeError("Too few arguments in function "+ye+" (expected: "+me.join(" or ")+", index: "+z.length+")"),ue.data={category:"tooFewArgs",fn:ye,index:z.length,expected:me},ue;var Be=Math.max.apply(null,Ge);if(z.length>Be)return ue=new TypeError("Too many arguments in function "+ye+" (expected: "+Be+", actual: "+z.length+")"),ue.data={category:"tooManyArgs",fn:ye,index:z.length,expectedLength:Be},ue;for(var lr=[],Je=0;Je<z.length;++Je)lr.push(c(z[Je]).join("|"));return ue=new TypeError('Arguments of type "'+lr.join(", ")+'" do not match any of the defined signatures of function '+ye+"."),ue.data={category:"mismatch",actual:lr},ue}function _(q){for(var z=n.length+1,ee=0;ee<q.types.length;ee++)D(q.types[ee])&&(z=Math.min(z,q.types[ee].typeIndex));return z}function L(q){for(var z=i+1,ee=0;ee<q.types.length;ee++)D(q.types[ee])||(z=Math.min(z,q.types[ee].conversionIndex));return z}function G(q,z){if(q.hasAny){if(!z.hasAny)return 1}else if(z.hasAny)return-1;if(q.restParam){if(!z.restParam)return 1}else if(z.restParam)return-1;if(q.hasConversion){if(!z.hasConversion)return 1}else if(z.hasConversion)return-1;var ee=_(q)-_(z);if(ee<0)return-1;if(ee>0)return 1;var ue=L(q)-L(z);return ue<0?-1:ue>0?1:0}function C(q,z){var ee=q.params,ue=z.params,me=ce(ee),ye=ce(ue),be=x(ee),ve=x(ue);if(be&&me.hasAny){if(!ve||!ye.hasAny)return 1}else if(ve&&ye.hasAny)return-1;var Ne=0,Ie=0,Ge,Be=vt(ee),lr;try{for(Be.s();!(lr=Be.n()).done;)Ge=lr.value,Ge.hasAny&&++Ne,Ge.hasConversion&&++Ie}catch(qn){Be.e(qn)}finally{Be.f()}var Je=0,cr=0,M=vt(ue),H;try{for(M.s();!(H=M.n()).done;)Ge=H.value,Ge.hasAny&&++Je,Ge.hasConversion&&++cr}catch(qn){M.e(qn)}finally{M.f()}if(Ne!==Je)return Ne-Je;if(be&&me.hasConversion){if(!ve||!ye.hasConversion)return 1}else if(ve&&ye.hasConversion)return-1;if(Ie!==cr)return Ie-cr;if(be){if(!ve)return 1}else if(ve)return-1;var se=(ee.length-ue.length)*(be?-1:1);if(se!==0)return se;for(var De=[],ze=0,Le=0;Le<ee.length;++Le){var Mr=G(ee[Le],ue[Le]);De.push(Mr),ze+=Mr}if(ze!==0)return ze;for(var Rr,en=0,Ca=De;en<Ca.length;en++)if(Rr=Ca[en],Rr!==0)return Rr;return 0}function F(q){if(q.length===0)return[];var z=q.map(f);q.length>1&&z.sort(function(Ne,Ie){return Ne.index-Ie.index});var ee=z[0].conversionsTo;if(q.length===1)return ee;ee=ee.concat([]);for(var ue=new Set(q),me=1;me<z.length;++me){var ye=void 0,be=vt(z[me].conversionsTo),ve;try{for(be.s();!(ve=be.n()).done;)ye=ve.value,ue.has(ye.from)||(ee.push(ye),ue.add(ye.from))}catch(Ne){be.e(Ne)}finally{be.f()}}return ee}function Z(q,z){var ee=z;if(q.some(function(ve){return ve.hasConversion})){var ue=x(q),me=q.map($);ee=function(){for(var Ne=[],Ie=ue?arguments.length-1:arguments.length,Ge=0;Ge<Ie;Ge++)Ne[Ge]=me[Ge](arguments[Ge]);return ue&&(Ne[Ie]=arguments[Ie].map(me[Ie])),z.apply(this,Ne)}}var ye=ee;if(x(q)){var be=q.length-1;ye=function(){return ee.apply(this,oe(arguments,0,be).concat([oe(arguments,be)]))}}return ye}function $(q){var z,ee,ue,me,ye=[],be=[];switch(q.types.forEach(function(ve){ve.conversion&&(ye.push(f(ve.conversion.from).test),be.push(ve.conversion.convert))}),be.length){case 0:return function(Ne){return Ne};case 1:return z=ye[0],ue=be[0],function(Ne){return z(Ne)?ue(Ne):Ne};case 2:return z=ye[0],ee=ye[1],ue=be[0],me=be[1],function(Ne){return z(Ne)?ue(Ne):ee(Ne)?me(Ne):Ne};default:return function(Ne){for(var Ie=0;Ie<be.length;Ie++)if(ye[Ie](Ne))return be[Ie](Ne);return Ne}}}function U(q){function z(ee,ue,me){if(ue<ee.length){var ye=ee[ue],be=[];if(ye.restParam){var ve=ye.types.filter(D);ve.length<ye.types.length&&be.push({types:ve,name:"..."+ve.map(function(Ne){return Ne.name}).join("|"),hasAny:ve.some(function(Ne){return Ne.isAny}),hasConversion:!1,restParam:!0}),be.push(ye)}else be=ye.types.map(function(Ne){return{types:[Ne],name:Ne.name,hasAny:Ne.isAny,hasConversion:Ne.conversion,restParam:!1}});return Oe(be,function(Ne){return z(ee,ue+1,me.concat([Ne]))})}else return[me]}return z(q,0,[])}function Y(q,z){for(var ee=Math.max(q.length,z.length),ue=0;ue<ee;ue++){var me=S(q,ue),ye=S(z,ue),be=!1,ve=void 0,Ne=vt(ye),Ie;try{for(Ne.s();!(Ie=Ne.n()).done;)if(ve=Ie.value,me.has(ve)){be=!0;break}}catch(cr){Ne.e(cr)}finally{Ne.f()}if(!be)return!1}var Ge=q.length,Be=z.length,lr=x(q),Je=x(z);return lr?Je?Ge===Be:Be>=Ge:Je?Ge>=Be:Ge===Be}function j(q){return q.map(function(z){return ie(z)?k(z.referToSelf.callback):W(z)?$e(z.referTo.references,z.referTo.callback):z})}function P(q,z,ee){var ue=[],me,ye=vt(q),be;try{for(ye.s();!(be=ye.n()).done;){me=be.value;var ve=ee[me];if(typeof ve!="number")throw new TypeError('No definition for referenced signature "'+me+'"');if(ve=z[ve],typeof ve!="function")return!1;ue.push(ve)}}catch(Ne){ye.e(Ne)}finally{ye.f()}return ue}function K(q,z,ee){for(var ue=j(q),me=new Array(ue.length).fill(!1),ye=!0;ye;){ye=!1;for(var be=!0,ve=0;ve<ue.length;++ve)if(!me[ve]){var Ne=ue[ve];if(ie(Ne))ue[ve]=Ne.referToSelf.callback(ee),ue[ve].referToSelf=Ne.referToSelf,me[ve]=!0,be=!1;else if(W(Ne)){var Ie=P(Ne.referTo.references,ue,z);Ie?(ue[ve]=Ne.referTo.callback.apply(this,Ie),ue[ve].referTo=Ne.referTo,me[ve]=!0,be=!1):ye=!0}}if(be&&ye)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ue}function ne(q){var z=/\bthis(\(|\.signatures\b)/;Object.keys(q).forEach(function(ee){var ue=q[ee];if(z.test(ue.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function re(q,z){if(s.createCount++,Object.keys(z).length===0)throw new SyntaxError("No signatures provided");s.warnAgainstDeprecatedThis&&ne(z);var ee=[],ue=[],me={},ye=[],be,ve=function(){if(!Object.prototype.hasOwnProperty.call(z,be))return"continue";var Or=w(be);if(!Or)return"continue";ee.forEach(function(Rt){if(Y(Rt,Or))throw new TypeError('Conflicting signatures "'+y(Rt)+'" and "'+y(Or)+'".')}),ee.push(Or);var Eo=ue.length;ue.push(z[be]);var Vu=Or.map(A),Ta=void 0,Ba=vt(U(Vu)),So;try{for(Ba.s();!(So=Ba.n()).done;){Ta=So.value;var Co=y(Ta);ye.push({params:Ta,name:Co,fn:Eo}),Ta.every(function(Rt){return!Rt.hasConversion})&&(me[Co]=Eo)}}catch(Rt){Ba.e(Rt)}finally{Ba.f()}};for(be in z)var Ne=ve();ye.sort(C);var Ie=K(ue,me,It),Ge;for(Ge in me)Object.prototype.hasOwnProperty.call(me,Ge)&&(me[Ge]=Ie[me[Ge]]);for(var Be=[],lr=new Map,Je=0,cr=ye;Je<cr.length;Je++)Ge=cr[Je],lr.has(Ge.name)||(Ge.fn=Ie[Ge.fn],Be.push(Ge),lr.set(Ge.name,Ge));for(var M=Be[0]&&Be[0].params.length<=2&&!x(Be[0].params),H=Be[1]&&Be[1].params.length<=2&&!x(Be[1].params),se=Be[2]&&Be[2].params.length<=2&&!x(Be[2].params),De=Be[3]&&Be[3].params.length<=2&&!x(Be[3].params),ze=Be[4]&&Be[4].params.length<=2&&!x(Be[4].params),Le=Be[5]&&Be[5].params.length<=2&&!x(Be[5].params),Mr=M&&H&&se&&De&&ze&&Le,Rr=0;Rr<Be.length;++Rr)Be[Rr].test=E(Be[Rr].params);for(var en=M?g(Be[0].params[0]):at,Ca=H?g(Be[1].params[0]):at,qn=se?g(Be[2].params[0]):at,xu=De?g(Be[3].params[0]):at,wu=ze?g(Be[4].params[0]):at,Nu=Le?g(Be[5].params[0]):at,Du=M?g(Be[0].params[1]):at,Au=H?g(Be[1].params[1]):at,Eu=se?g(Be[2].params[1]):at,Su=De?g(Be[3].params[1]):at,Cu=ze?g(Be[4].params[1]):at,Mu=Le?g(Be[5].params[1]):at,zn=0;zn<Be.length;++zn)Be[zn].implementation=Z(Be[zn].params,Be[zn].fn);var Ma=M?Be[0].implementation:kn,Fa=H?Be[1].implementation:kn,Fu=se?Be[2].implementation:kn,Tu=De?Be[3].implementation:kn,Bu=ze?Be[4].implementation:kn,$u=Le?Be[5].implementation:kn,Ou=M?Be[0].params.length:-1,_u=H?Be[1].params.length:-1,Iu=se?Be[2].params.length:-1,Ru=De?Be[3].params.length:-1,qu=ze?Be[4].params.length:-1,zu=Le?Be[5].params.length:-1,Pu=Mr?6:0,Lu=Be.length,Ao=Be.map(function(Kr){return Kr.test}),Uu=Be.map(function(Kr){return Kr.implementation}),ku=function(){for(var Or=Pu;Or<Lu;Or++)if(Ao[Or](arguments))return Uu[Or].apply(this,arguments);return s.onMismatch(q,arguments,Be)};function It(Kr,Or){return arguments.length===Ou&&en(Kr)&&Du(Or)?Ma.apply(this,arguments):arguments.length===_u&&Ca(Kr)&&Au(Or)?Fa.apply(this,arguments):arguments.length===Iu&&qn(Kr)&&Eu(Or)?Fu.apply(this,arguments):arguments.length===Ru&&xu(Kr)&&Su(Or)?Tu.apply(this,arguments):arguments.length===qu&&wu(Kr)&&Cu(Or)?Bu.apply(this,arguments):arguments.length===zu&&Nu(Kr)&&Mu(Or)?$u.apply(this,arguments):ku.apply(this,arguments)}try{Object.defineProperty(It,"name",{value:q})}catch{}return It.signatures=me,It._typedFunctionData={signatures:Be,signatureMap:lr},It}function fe(q,z,ee){throw B(q,z,ee)}function pe(q){return oe(q,0,q.length-1)}function ce(q){return q[q.length-1]}function oe(q,z,ee){return Array.prototype.slice.call(q,z,ee)}function Ce(q,z){for(var ee=0;ee<q.length;ee++)if(z(q[ee]))return q[ee]}function Oe(q,z){return Array.prototype.concat.apply([],q.map(z))}function Me(){var q=pe(arguments).map(function(ee){return y(w(ee))}),z=ce(arguments);if(typeof z!="function")throw new TypeError("Callback function expected as last argument");return $e(q,z)}function $e(q,z){return{referTo:{references:q,callback:z}}}function k(q){if(typeof q!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:q}}}function W(q){return q&&Un(q.referTo)==="object"&&Array.isArray(q.referTo.references)&&typeof q.referTo.callback=="function"}function ie(q){return q&&Un(q.referToSelf)==="object"&&typeof q.referToSelf.callback=="function"}function V(q,z){if(!q)return z;if(z&&z!==q){var ee=new Error("Function names do not match (expected: "+q+", actual: "+z+")");throw ee.data={actual:z,expected:q},ee}return q}function Q(q){var z;for(var ee in q)Object.prototype.hasOwnProperty.call(q,ee)&&(m(q[ee])||typeof q[ee].signature=="string")&&(z=V(z,q[ee].name));return z}function te(q,z){var ee;for(ee in z)if(Object.prototype.hasOwnProperty.call(z,ee)){if(ee in q&&z[ee]!==q[ee]){var ue=new Error('Signature "'+ee+'" is defined twice');throw ue.data={signature:ee,sourceFunction:z[ee],destFunction:q[ee]},ue}q[ee]=z[ee]}}var ge=s;s=function(z){for(var ee=typeof z=="string",ue=ee?1:0,me=ee?z:"",ye={},be=ue;be<arguments.length;++be){var ve=arguments[be],Ne={},Ie=void 0;if(typeof ve=="function"?(Ie=ve.name,typeof ve.signature=="string"?Ne[ve.signature]=ve:m(ve)&&(Ne=ve.signatures)):r(ve)&&(Ne=ve,ee||(Ie=Q(ve))),Object.keys(Ne).length===0){var Ge=new TypeError("Argument to 'typed' at index "+be+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw Ge.data={index:be,argument:ve},Ge}ee||(me=V(me,Ie)),te(ye,Ne)}return re(me||"",ye)},s.create=rl,s.createCount=ge.createCount,s.onMismatch=fe,s.throwMismatchError=fe,s.createError=B,s.clear=u,s.clearConversions=o,s.addTypes=l,s._findType=f,s.referTo=Me,s.referToSelf=k,s.convert=h,s.findSignature=v,s.find=p,s.isTypedFunction=m,s.warnAgainstDeprecatedThis=!0,s.addType=function(q,z){var ee="any";z!==!1&&a.has("Object")&&(ee="Object"),s.addTypes([q],ee)};function he(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(q.to===q.from)throw new SyntaxError('Illegal to define conversion from "'+q.from+'" to itself.')}return s.addConversion=function(q){he(q);var z=f(q.to);if(z.conversionsTo.every(function(ee){return ee.from!==q.from}))z.conversionsTo.push({from:q.from,convert:q.convert,index:i++});else throw new Error('There is already a conversion from "'+q.from+'" to "'+z.name+'"')},s.addConversions=function(q){q.forEach(s.addConversion)},s.removeConversion=function(q){he(q);var z=f(q.to),ee=Ce(z.conversionsTo,function(me){return me.from===q.from});if(!ee)throw new Error("Attempt to remove nonexistent conversion from "+q.from+" to "+q.to);if(ee.convert!==q.convert)throw new Error("Conversion to remove does not match existing conversion");var ue=z.conversionsTo.indexOf(ee);z.conversionsTo.splice(ue,1)},s.resolve=function(q,z){if(!m(q))throw new TypeError(el);for(var ee=q._typedFunctionData.signatures,ue=0;ue<ee.length;++ue)if(ee[ue].test(z))return ee[ue];return null},s}const tl=rl();function qe(r){return typeof r=="boolean"?!0:isFinite(r)?r===Math.round(r):!1}var tn=Math.sign||function(r){return r>0?1:r<0?-1:0},C0=Math.log2||function(e){return Math.log(e)/Math.LN2},M0=Math.log10||function(e){return Math.log(e)/Math.LN10},F0=Math.log1p||function(r){return Math.log(r+1)},T0=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},B0=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Po(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(!qe(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(!qe(r))throw new Error("Value must be an integer");r<0&&(r=r+2**t),i="i".concat(t)}var s="";return r<0&&(r=-r,s="-"),"".concat(s).concat(n).concat(r.toString(e)).concat(i)}function En(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),tr(e)?a=e:tr(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 nl(r,a);case"exponential":return al(r,a);case"engineering":return $0(r,a);case"bin":return Po(r,2,n);case"oct":return Po(r,8,n);case"hex":return Po(r,16,n);case"auto":return O0(r,a,e&&e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],s=arguments[4];return i!=="."?i+s:s});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function oi(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 s=a.replace(".","").replace(/^0*/,function(f){return n-=f.length,""}).replace(/0*$/,"").split("").map(function(f){return parseInt(f)});return s.length===0&&(s.push(0),n++),{sign:t,coefficients:s,exponent:n}}function $0(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=oi(r),a=si(t,e),n=a.exponent,i=a.coefficients,s=n%3===0?n:n<0?n-3-n%3:n-n%3;if(tr(e))for(;e>i.length||n-s+1>i.length;)i.push(0);else for(var f=Math.abs(n-s)-(i.length-1),l=0;l<f;l++)i.push(0);for(var u=Math.abs(n-s),o=1;u>0;)o++,u--;var c=i.slice(o).join(""),m=tr(e)&&c.length||c.match(/[1-9]/)?"."+c:"",v=i.slice(0,o).join("")+m+"e"+(n>=0?"+":"")+s.toString();return a.sign+v}function nl(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=oi(r),a=typeof e=="number"?si(t,t.exponent+1+e):t,n=a.coefficients,i=a.exponent+1,s=i+(e||0);return n.length<s&&(n=n.concat(Vn(s-n.length))),i<0&&(n=Vn(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),a.sign+n.join("")}function al(r,e){if(isNaN(r)||!isFinite(r))return String(r);var t=oi(r),a=e?si(t,e):t,n=a.coefficients,i=a.exponent;n.length<e&&(n=n.concat(Vn(e-n.length)));var s=n.shift();return a.sign+s+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function O0(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=oi(r),s=e?si(i,e):i;if(s.exponent<a||s.exponent>=n)return al(r,e);var f=s.coefficients,l=s.exponent;f.length<e&&(f=f.concat(Vn(e-f.length))),f=f.concat(Vn(l-f.length+1+(f.length<e?e-f.length:0))),f=Vn(-l).concat(f);var u=l>0?l:0;return u<f.length-1&&f.splice(u+1,0,"."),s.sign+f.join("")}function si(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 Vn(r){for(var e=[],t=0;t<r;t++)e.push(0);return e}function _0(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var I0=Number.EPSILON||2220446049250313e-31;function et(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<I0?!0:a<=Math.max(Math.abs(r),Math.abs(e))*t}return!1}var R0=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)},q0=Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},z0=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2},P0=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2},L0=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2},U0=Math.tanh||function(r){var e=Math.exp(2*r);return(e-1)/(e+1)};function k0(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 Lo(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(!qe(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 V0(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 H0(r,a);case"exponential":return il(r,a);case"engineering":return G0(r,a);case"bin":return Lo(r,2,n);case"oct":return Lo(r,8,n);case"hex":return Lo(r,16,n);case"auto":{var i=e&&e.lowerExp!==void 0?e.lowerExp:-3,s=e&&e.upperExp!==void 0?e.upperExp:5;if(r.isZero())return"0";var f,l=r.toSignificantDigits(a),u=l.e;return u>=i&&u<s?f=l.toFixed():f=il(r,a),f.replace(/((\.\d*?)(0+))($|e)/,function(){var o=arguments[2],c=arguments[4];return o!=="."?o+c:c})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function G0(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 il(r,e){return e!==void 0?r.toExponential(e-1):r.toExponential()}function H0(r,e){return r.toFixed(e)}function Z0(r,e){var t=r.length-e.length,a=r.length;return r.substring(t,a)===e}function Ye(r,e){var t=J0(r,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function J0(r,e){if(typeof r=="number")return En(r,e);if(rr(r))return V0(r,e);if(W0(r))return!e||e.fraction!=="decimal"?r.s*r.n+"/"+r.d:r.toString();if(Array.isArray(r))return ol(r,e);if(Wr(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+'": '+Ye(r[a],e));return"{"+t.join(", ")+"}"}return String(r)}function ui(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 it(r){var e=String(r);return e=e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),e}function ol(r,e){if(Array.isArray(r)){for(var t="[",a=r.length,n=0;n<a;n++)n!==0&&(t+=", "),t+=ol(r[n],e);return t+="]",t}else return Ye(r,e)}function W0(r){return r&&typeof r=="object"&&typeof r.s=="number"&&typeof r.n=="number"&&typeof r.d=="number"||!1}function Uo(r,e){if(!Wr(r))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+gr(r)+", index: 0)");if(!Wr(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+gr(e)+", index: 1)");return r===e?0:r>e?1:-1}function Ke(r,e,t){if(!(this instanceof Ke))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}Ke.prototype=new RangeError,Ke.prototype.constructor=RangeError,Ke.prototype.name="DimensionError",Ke.prototype.isDimensionError=!0;function pt(r,e,t){if(!(this instanceof pt))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}pt.prototype=new RangeError,pt.prototype.constructor=RangeError,pt.prototype.name="IndexError",pt.prototype.isIndexError=!0;function er(r){for(var e=[];Array.isArray(r);)e.push(r.length),r=r[0];return e}function sl(r,e,t){var a,n=r.length;if(n!==e[t])throw new Ke(n,e[t]);if(t<e.length-1){var i=t+1;for(a=0;a<n;a++){var s=r[a];if(!Array.isArray(s))throw new Ke(e.length-1,e.length,"<");sl(r[a],e,i)}}else for(a=0;a<n;a++)if(Array.isArray(r[a]))throw new Ke(e.length+1,e.length,">")}function ul(r,e){var t=e.length===0;if(t){if(Array.isArray(r))throw new Ke(r.length,0)}else sl(r,e,0)}function mr(r,e){if(!tr(r)||!qe(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||typeof e=="number"&&r>=e)throw new pt(r,e)}function Gn(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(!tr(n)||!qe(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(e)+")")});var a=t!==void 0?t:0;return ko(r,e,0,a),r}function ko(r,e,t,a){var n,i,s=r.length,f=e[t],l=Math.min(s,f);if(r.length=f,t<e.length-1){var u=t+1;for(n=0;n<l;n++)i=r[n],Array.isArray(i)||(i=[i],r[n]=i),ko(i,e,u,a);for(n=l;n<f;n++)i=[],r[n]=i,ko(i,e,u,a)}else{for(n=0;n<l;n++)for(;Array.isArray(r[n]);)r[n]=r[n][0];for(n=l;n<f;n++)r[n]=a}}function ll(r,e){var t=ar(r),a=t.length;if(!Array.isArray(r)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Ke(0,a,"!=");e=Vo(e,a);var n=cl(e);if(a!==n)throw new Ke(n,a,"!=");try{return X0(t,e)}catch(i){throw i instanceof Ke?new Ke(n,a,"!="):i}}function Vo(r,e){var t=cl(r),a=r.slice(),n=-1,i=r.indexOf(n),s=r.indexOf(n,i+1)>=0;if(s)throw new Error("More than one wildcard in sizes");var f=i>=0,l=e%t===0;if(f)if(l)a[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return a}function cl(r){return r.reduce((e,t)=>e*t,1)}function X0(r,e){for(var t=r,a,n=e.length-1;n>0;n--){var i=e[n];a=[];for(var s=t.length/i,f=0;f<s;f++)a.push(t.slice(f*i,(f+1)*i));t=a}return t}function li(r,e){for(var t=e||er(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=fl(r,a,0),t.length=a),r}function fl(r,e,t){var a,n;if(t<e){var i=t+1;for(a=0,n=r.length;a<n;a++)r[a]=fl(r[a],e,i)}else for(;Array.isArray(r);)r=r[0];return r}function ml(r,e,t,a){var n=a||er(r);if(t)for(var i=0;i<t;i++)r=[r],n.unshift(1);for(r=vl(r,e,0);n.length<e;)n.push(1);return r}function vl(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]=vl(r[a],e,i)}else for(var s=t;s<e;s++)r=[r];return r}function ar(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 Ut(r,e){return Array.prototype.map.call(r,e)}function ci(r,e){Array.prototype.forEach.call(r,e)}function pl(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,e)}function fi(r,e){if(er(r).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(r,t=>e.test(t))}function hl(r,e){return Array.prototype.join.call(r,e)}function Hn(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 mi(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 qa(r,e){for(var t,a=0,n=0;n<r.length;n++){var i=r[n],s=Array.isArray(i);if(n===0&&s&&(a=i.length),s&&i.length!==a)return;var f=s?qa(i,e):e(i);if(t===void 0)t=f;else if(t!==f)return"mixed"}return t}function R(r,e,t,a){function n(i){var s=D0(i,e.map(K0));return Y0(r,e,i),t(s)}return n.isFactory=!0,n.fn=r,n.dependencies=e.slice().sort(),a&&(n.meta=a),n}function Y0(r,e,t){var a=e.filter(i=>!Q0(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 Q0(r){return r&&r[0]==="?"}function K0(r){return r&&r[0]==="?"?r.slice(1):r}function ot(r,e){if(dl(r)&&Go(r,e))return r[e];throw typeof r[e]=="function"&&Ho(r,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function Zn(r,e,t){if(dl(r)&&Go(r,e))return r[e]=t,t;throw new Error('No access to property "'+e+'"')}function j0(r,e){return e in r}function Go(r,e){return!r||typeof r!="object"?!1:Re(rg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function eg(r,e){if(!Ho(r,e))throw new Error('No access to method "'+e+'"')}function Ho(r,e){return r==null||typeof r[e]!="function"||Re(r,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(r)?!1:Re(tg,e)?!0:!(e in Object.prototype||e in Function.prototype)}function dl(r){return typeof r=="object"&&r&&r.constructor===Object}var rg={length:!0,name:!0},tg={toString:!0,valueOf:!0,toLocaleString:!0};class Zo{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return ot(this.wrappedObject,e)}set(e,t){return Zn(this.wrappedObject,e,t),this}has(e){return j0(this.wrappedObject,e)}}function Jn(){return new Map}function Wn(r){if(!r)return Jn();if(Jo(r))return r;if(qo(r))return new Zo(r);throw new Error("createMap can create maps from objects or Maps")}function ng(r){if(r instanceof Zo)return r.wrappedObject;var e={};for(var t of r.keys()){var a=r.get(t);Zn(e,t,a)}return e}function Jo(r){return r?r instanceof Map||r instanceof Zo||typeof r.set=="function"&&typeof r.get=="function"&&typeof r.keys=="function"&&typeof r.has=="function":!1}function gl(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(Jo(n))for(var i of n.keys())r.set(i,n.get(i));else if(qo(n))for(var s of Object.keys(n))r.set(s,n[s])}return r}var yl=function(){return yl=tl.create,tl},ag=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],ig=R("typed",ag,function(e){var{BigNumber:t,Complex:a,DenseMatrix:n,Fraction:i}=e,s=yl();return s.clear(),s.addTypes([{name:"number",test:tr},{name:"Complex",test:zt},{name:"BigNumber",test:rr},{name:"Fraction",test:_a},{name:"Unit",test:Pt},{name:"identifier",test:f=>Wr&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])*$/.test(f)},{name:"string",test:Wr},{name:"Chain",test:Yu},{name:"Array",test:ur},{name:"Matrix",test:He},{name:"DenseMatrix",test:ni},{name:"SparseMatrix",test:Nn},{name:"Range",test:Ro},{name:"Index",test:ai},{name:"boolean",test:l0},{name:"ResultSet",test:c0},{name:"Help",test:Xu},{name:"function",test:f0},{name:"Date",test:m0},{name:"RegExp",test:v0},{name:"null",test:p0},{name:"undefined",test:h0},{name:"AccessorNode",test:Dn},{name:"ArrayNode",test:nt},{name:"AssignmentNode",test:d0},{name:"BlockNode",test:g0},{name:"ConditionalNode",test:y0},{name:"ConstantNode",test:sr},{name:"FunctionNode",test:An},{name:"FunctionAssignmentNode",test:Ia},{name:"IndexNode",test:Ln},{name:"Node",test:or},{name:"ObjectNode",test:ii},{name:"OperatorNode",test:_r},{name:"ParenthesisNode",test:rn},{name:"RangeNode",test:b0},{name:"RelationalNode",test:x0},{name:"SymbolNode",test:qr},{name:"Map",test:Jo},{name:"Object",test:qo}]),s.addConversions([{from:"number",to:"BigNumber",convert:function(l){if(t||Wo(l),_0(l)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+l+"). Use function bignumber(x) to convert to BigNumber.");return new t(l)}},{from:"number",to:"Complex",convert:function(l){return a||vi(l),new a(l,0)}},{from:"BigNumber",to:"Complex",convert:function(l){return a||vi(l),new a(l.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(l){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(l){return a||vi(l),new a(l.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(l){i||Xo(l);var u=new i(l);if(u.valueOf()!==l)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+l+"). Use function fraction(x) to convert to Fraction.");return u}},{from:"string",to:"number",convert:function(l){var u=Number(l);if(isNaN(u))throw new Error('Cannot convert "'+l+'" to a number');return u}},{from:"string",to:"BigNumber",convert:function(l){t||Wo(l);try{return new t(l)}catch{throw new Error('Cannot convert "'+l+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(l){i||Xo(l);try{return new i(l)}catch{throw new Error('Cannot convert "'+l+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(l){a||vi(l);try{return new a(l)}catch{throw new Error('Cannot convert "'+l+'" to Complex')}}},{from:"boolean",to:"number",convert:function(l){return+l}},{from:"boolean",to:"BigNumber",convert:function(l){return t||Wo(l),new t(+l)}},{from:"boolean",to:"Fraction",convert:function(l){return i||Xo(l),new i(+l)}},{from:"boolean",to:"string",convert:function(l){return String(l)}},{from:"Array",to:"Matrix",convert:function(l){return n||og(),new n(l)}},{from:"Matrix",to:"Array",convert:function(l){return l.valueOf()}}]),s.onMismatch=(f,l,u)=>{var o=s.createError(f,l,u);if(["wrongType","mismatch"].includes(o.data.category)&&l.length===1&&Lt(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=o.data,c}throw o},s.onMismatch=(f,l,u)=>{var o=s.createError(f,l,u);if(["wrongType","mismatch"].includes(o.data.category)&&l.length===1&&Lt(l[0])&&u.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(f,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(f,")'."));throw c.data=o.data,c}throw o},s});function Wo(r){throw new Error("Cannot convert value ".concat(r," into a BigNumber: no class 'BigNumber' provided"))}function vi(r){throw new Error("Cannot convert value ".concat(r," into a Complex number: no class 'Complex' provided"))}function og(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function Xo(r){throw new Error("Cannot convert value ".concat(r," into a Fraction, no class 'Fraction' provided."))}var sg="ResultSet",ug=[],lg=R(sg,ug,()=>{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});/*!
|
|
10
|
+
* decimal.js v10.4.2
|
|
10
11
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
11
12
|
* https://github.com/MikeMcl/decimal.js
|
|
12
13
|
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
13
14
|
* 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
|
+
*/var Xn=9e15,nn=1e9,Yo="0123456789abcdef",pi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",hi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Qo={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Xn,maxE:Xn,crypto:!1},bl,kt,We=!0,di="[DecimalError] ",an=di+"Invalid argument: ",xl=di+"Precision limit exceeded",wl=di+"crypto unavailable",Nl="[object Decimal]",Vr=Math.floor,Tr=Math.pow,cg=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,fg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,mg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Dl=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ht=1e7,Ve=7,vg=9007199254740991,pg=pi.length-1,Ko=hi.length-1,we={toStringTag:Nl};we.absoluteValue=we.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Pe(r)},we.ceil=function(){return Pe(new this.constructor(this),this.e+1,2)},we.clampedTo=we.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(an+e);return t=a.cmp(r),t<0?r:a.cmp(e)>0?e:new n(a)},we.comparedTo=we.cmp=function(r){var e,t,a,n,i=this,s=i.d,f=(r=new i.constructor(r)).d,l=i.s,u=r.s;if(!s||!f)return!l||!u?NaN:l!==u?l:s===f?0:!s^l<0?1:-1;if(!s[0]||!f[0])return s[0]?l:f[0]?-u:0;if(l!==u)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(a=s.length,n=f.length,e=0,t=a<n?a:n;e<t;++e)if(s[e]!==f[e])return s[e]>f[e]^l<0?1:-1;return a===n?0:a>n^l<0?1:-1},we.cosine=we.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())+Ve,a.rounding=1,t=hg(a,Fl(a,t)),a.precision=r,a.rounding=e,Pe(kt==2||kt==3?t.neg():t,r,e,!0)):new a(1):new a(NaN)},we.cubeRoot=we.cbrt=function(){var r,e,t,a,n,i,s,f,l,u,o=this,c=o.constructor;if(!o.isFinite()||o.isZero())return new c(o);for(We=!1,i=o.s*Tr(o.s*o,1/3),!i||Math.abs(i)==1/0?(t=zr(o.d),r=o.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Tr(t,1/3),r=Vr((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 c(t),a.s=o.s):a=new c(i.toString()),s=(r=c.precision)+3;;)if(f=a,l=f.times(f).times(f),u=l.plus(o),a=dr(u.plus(o).times(f),u.plus(l),s+2,1),zr(f.d).slice(0,s)===(t=zr(a.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!n&&t=="4999"){if(!n&&(Pe(f,r+1,0),f.times(f).times(f).eq(o))){a=f;break}s+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Pe(a,r+1,1),e=!a.times(a).times(a).eq(o));break}return We=!0,Pe(a,r,c.rounding,e)},we.decimalPlaces=we.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-Vr(this.e/Ve))*Ve,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t},we.dividedBy=we.div=function(r){return dr(this,new this.constructor(r))},we.dividedToIntegerBy=we.divToInt=function(r){var e=this,t=e.constructor;return Pe(dr(e,new t(r),0,1,1),t.precision,t.rounding)},we.equals=we.eq=function(r){return this.cmp(r)===0},we.floor=function(){return Pe(new this.constructor(this),this.e+1,3)},we.greaterThan=we.gt=function(r){return this.cmp(r)>0},we.greaterThanOrEqualTo=we.gte=function(r){var e=this.cmp(r);return e==1||e===0},we.hyperbolicCosine=we.cosh=function(){var r,e,t,a,n,i=this,s=i.constructor,f=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return f;t=s.precision,a=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,n=i.d.length,n<32?(r=Math.ceil(n/3),e=(1/xi(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=Yn(s,1,i.times(e),new s(1),!0);for(var l,u=r,o=new s(8);u--;)l=i.times(i),i=f.minus(l.times(o.minus(l.times(o))));return Pe(i,s.precision=t,s.rounding=a,!0)},we.hyperbolicSine=we.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=Yn(i,2,n,n,!0);else{r=1.4*Math.sqrt(a),r=r>16?16:r|0,n=n.times(1/xi(5,r)),n=Yn(i,2,n,n,!0);for(var s,f=new i(5),l=new i(16),u=new i(20);r--;)s=n.times(n),n=n.times(f.plus(s.times(l.times(s).plus(u))))}return i.precision=e,i.rounding=t,Pe(n,e,t,!0)},we.hyperbolicTangent=we.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,dr(t.sinh(),t.cosh(),a.precision=r,a.rounding=e)):new a(t.s)},we.inverseCosine=we.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()?dt(t,n,i):new t(0):new t(NaN):e.isZero()?dt(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=dt(t,n+4,i).times(.5),t.precision=n,t.rounding=i,r.minus(e))},we.inverseHyperbolicCosine=we.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,We=!1,t=t.times(t).minus(1).sqrt().plus(t),We=!0,a.precision=r,a.rounding=e,t.ln()):new a(t)},we.inverseHyperbolicSine=we.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,We=!1,t=t.times(t).plus(1).sqrt().plus(t),We=!0,a.precision=r,a.rounding=e,t.ln())},we.inverseHyperbolicTangent=we.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?Pe(new i(n),r,e,!0):(i.precision=t=a-n.e,n=dr(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)},we.inverseSine=we.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=dt(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)))},we.inverseTangent=we.atan=function(){var r,e,t,a,n,i,s,f,l,u=this,o=u.constructor,c=o.precision,m=o.rounding;if(u.isFinite()){if(u.isZero())return new o(u);if(u.abs().eq(1)&&c+4<=Ko)return s=dt(o,c+4,m).times(.25),s.s=u.s,s}else{if(!u.s)return new o(NaN);if(c+4<=Ko)return s=dt(o,c+4,m).times(.5),s.s=u.s,s}for(o.precision=f=c+10,o.rounding=1,t=Math.min(28,f/Ve+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(We=!1,e=Math.ceil(f/Ve),a=1,l=u.times(u),s=new o(u),n=u;r!==-1;)if(n=n.times(l),i=s.minus(n.div(a+=2)),n=n.times(l),s=i.plus(n.div(a+=2)),s.d[e]!==void 0)for(r=e;s.d[r]===i.d[r]&&r--;);return t&&(s=s.times(2<<t-1)),We=!0,Pe(s,o.precision=c,o.rounding=m,!0)},we.isFinite=function(){return!!this.d},we.isInteger=we.isInt=function(){return!!this.d&&Vr(this.e/Ve)>this.d.length-2},we.isNaN=function(){return!this.s},we.isNegative=we.isNeg=function(){return this.s<0},we.isPositive=we.isPos=function(){return this.s>0},we.isZero=function(){return!!this.d&&this.d[0]===0},we.lessThan=we.lt=function(r){return this.cmp(r)<0},we.lessThanOrEqualTo=we.lte=function(r){return this.cmp(r)<1},we.logarithm=we.log=function(r){var e,t,a,n,i,s,f,l,u=this,o=u.constructor,c=o.precision,m=o.rounding,v=5;if(r==null)r=new o(10),e=!0;else{if(r=new o(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new o(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new o(t&&!t[0]?-1/0:u.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(We=!1,f=c+v,s=sn(u,f),a=e?bi(o,f+10):sn(r,f),l=dr(s,a,f,1),za(l.d,n=c,m))do if(f+=10,s=sn(u,f),a=e?bi(o,f+10):sn(r,f),l=dr(s,a,f,1),!i){+zr(l.d).slice(n+1,n+15)+1==1e14&&(l=Pe(l,c+1,0));break}while(za(l.d,n+=10,m));return We=!0,Pe(l,c,m)},we.minus=we.sub=function(r){var e,t,a,n,i,s,f,l,u,o,c,m,v=this,p=v.constructor;if(r=new p(r),!v.d||!r.d)return!v.s||!r.s?r=new p(NaN):v.d?r.s=-r.s:r=new p(r.d||v.s!==r.s?v:NaN),r;if(v.s!=r.s)return r.s=-r.s,v.plus(r);if(u=v.d,m=r.d,f=p.precision,l=p.rounding,!u[0]||!m[0]){if(m[0])r.s=-r.s;else if(u[0])r=new p(v);else return new p(l===3?-0:0);return We?Pe(r,f,l):r}if(t=Vr(r.e/Ve),o=Vr(v.e/Ve),u=u.slice(),i=o-t,i){for(c=i<0,c?(e=u,i=-i,s=m.length):(e=m,t=o,s=u.length),a=Math.max(Math.ceil(f/Ve),s)+2,i>a&&(i=a,e.length=1),e.reverse(),a=i;a--;)e.push(0);e.reverse()}else{for(a=u.length,s=m.length,c=a<s,c&&(s=a),a=0;a<s;a++)if(u[a]!=m[a]){c=u[a]<m[a];break}i=0}for(c&&(e=u,u=m,m=e,r.s=-r.s),s=u.length,a=m.length-s;a>0;--a)u[s++]=0;for(a=m.length;a>i;){if(u[--a]<m[a]){for(n=a;n&&u[--n]===0;)u[n]=ht-1;--u[n],u[a]+=ht}u[a]-=m[a]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=yi(u,t),We?Pe(r,f,l):r):new p(l===3?-0:0)},we.modulo=we.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]?Pe(new a(t),a.precision,a.rounding):(We=!1,a.modulo==9?(e=dr(t,r.abs(),0,3,1),e.s*=r.s):e=dr(t,r,0,a.modulo,1),e=e.times(r),We=!0,t.minus(e))},we.naturalExponential=we.exp=function(){return jo(this)},we.naturalLogarithm=we.ln=function(){return sn(this)},we.negated=we.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Pe(r)},we.plus=we.add=function(r){var e,t,a,n,i,s,f,l,u,o,c=this,m=c.constructor;if(r=new m(r),!c.d||!r.d)return!c.s||!r.s?r=new m(NaN):c.d||(r=new m(r.d||c.s===r.s?c:NaN)),r;if(c.s!=r.s)return r.s=-r.s,c.minus(r);if(u=c.d,o=r.d,f=m.precision,l=m.rounding,!u[0]||!o[0])return o[0]||(r=new m(c)),We?Pe(r,f,l):r;if(i=Vr(c.e/Ve),a=Vr(r.e/Ve),u=u.slice(),n=i-a,n){for(n<0?(t=u,n=-n,s=o.length):(t=o,a=i,s=u.length),i=Math.ceil(f/Ve),s=i>s?i+1:s+1,n>s&&(n=s,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for(s=u.length,n=o.length,s-n<0&&(n=s,t=o,o=u,u=t),e=0;n;)e=(u[--n]=u[n]+o[n]+e)/ht|0,u[n]%=ht;for(e&&(u.unshift(e),++a),s=u.length;u[--s]==0;)u.pop();return r.d=u,r.e=yi(u,a),We?Pe(r,f,l):r},we.precision=we.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(an+r);return t.d?(e=Al(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e},we.round=function(){var r=this,e=r.constructor;return Pe(new e(r),r.e+1,e.rounding)},we.sine=we.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())+Ve,a.rounding=1,t=gg(a,Fl(a,t)),a.precision=r,a.rounding=e,Pe(kt>2?t.neg():t,r,e,!0)):new a(NaN)},we.squareRoot=we.sqrt=function(){var r,e,t,a,n,i,s=this,f=s.d,l=s.e,u=s.s,o=s.constructor;if(u!==1||!f||!f[0])return new o(!u||u<0&&(!f||f[0])?NaN:f?s:1/0);for(We=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=zr(f),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=Vr((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),a=new o(e)):a=new o(u.toString()),t=(l=o.precision)+3;;)if(i=a,a=i.plus(dr(s,i,t+2,1)).times(.5),zr(i.d).slice(0,t)===(e=zr(a.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!n&&e=="4999"){if(!n&&(Pe(i,l+1,0),i.times(i).eq(s))){a=i;break}t+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Pe(a,l+1,1),r=!a.times(a).eq(s));break}return We=!0,Pe(a,l,o.rounding,r)},we.tangent=we.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=dr(t,new a(1).minus(t.times(t)).sqrt(),r+10,0),a.precision=r,a.rounding=e,Pe(kt==2||kt==4?t.neg():t,r,e,!0)):new a(NaN)},we.times=we.mul=function(r){var e,t,a,n,i,s,f,l,u,o=this,c=o.constructor,m=o.d,v=(r=new c(r)).d;if(r.s*=o.s,!m||!m[0]||!v||!v[0])return new c(!r.s||m&&!m[0]&&!v||v&&!v[0]&&!m?NaN:!m||!v?r.s/0:r.s*0);for(t=Vr(o.e/Ve)+Vr(r.e/Ve),l=m.length,u=v.length,l<u&&(i=m,m=v,v=i,s=l,l=u,u=s),i=[],s=l+u,a=s;a--;)i.push(0);for(a=u;--a>=0;){for(e=0,n=l+a;n>a;)f=i[n]+v[a]*m[n-a-1]+e,i[n--]=f%ht|0,e=f/ht|0;i[n]=(i[n]+e)%ht|0}for(;!i[--s];)i.pop();return e?++t:i.shift(),r.d=i,r.e=yi(i,t),We?Pe(r,c.precision,c.rounding):r},we.toBinary=function(r,e){return rs(this,2,r,e)},we.toDecimalPlaces=we.toDP=function(r,e){var t=this,a=t.constructor;return t=new a(t),r===void 0?t:(jr(r,0,nn),e===void 0?e=a.rounding:jr(e,0,8),Pe(t,r+t.e+1,e))},we.toExponential=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=St(a,!0):(jr(r,0,nn),e===void 0?e=n.rounding:jr(e,0,8),a=Pe(new n(a),r+1,e),t=St(a,!0,r+1)),a.isNeg()&&!a.isZero()?"-"+t:t},we.toFixed=function(r,e){var t,a,n=this,i=n.constructor;return r===void 0?t=St(n):(jr(r,0,nn),e===void 0?e=i.rounding:jr(e,0,8),a=Pe(new i(n),r+n.e+1,e),t=St(a,!1,r+a.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},we.toFraction=function(r){var e,t,a,n,i,s,f,l,u,o,c,m,v=this,p=v.d,h=v.constructor;if(!p)return new h(v);if(u=t=new h(1),a=l=new h(0),e=new h(a),i=e.e=Al(p)-v.e-1,s=i%Ve,e.d[0]=Tr(10,s<0?Ve+s:s),r==null)r=i>0?e:u;else{if(f=new h(r),!f.isInt()||f.lt(u))throw Error(an+f);r=f.gt(e)?i>0?e:u:f}for(We=!1,f=new h(zr(p)),o=h.precision,h.precision=i=p.length*Ve*2;c=dr(f,e,0,1,1),n=t.plus(c.times(a)),n.cmp(r)!=1;)t=a,a=n,n=u,u=l.plus(c.times(n)),l=n,n=e,e=f.minus(c.times(n)),f=n;return n=dr(r.minus(t),a,0,1,1),l=l.plus(n.times(u)),t=t.plus(n.times(a)),l.s=u.s=v.s,m=dr(u,a,i,1).minus(v).abs().cmp(dr(l,t,i,1).minus(v).abs())<1?[u,a]:[l,t],h.precision=o,We=!0,m},we.toHexadecimal=we.toHex=function(r,e){return rs(this,16,r,e)},we.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:jr(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]?(We=!1,t=dr(t,r,0,e,1).times(r),We=!0,Pe(t)):(r.s=t.s,t=r),t},we.toNumber=function(){return+this},we.toOctal=function(r,e){return rs(this,8,r,e)},we.toPower=we.pow=function(r){var e,t,a,n,i,s,f=this,l=f.constructor,u=+(r=new l(r));if(!f.d||!r.d||!f.d[0]||!r.d[0])return new l(Tr(+f,u));if(f=new l(f),f.eq(1))return f;if(a=l.precision,i=l.rounding,r.eq(1))return Pe(f,a,i);if(e=Vr(r.e/Ve),e>=r.d.length-1&&(t=u<0?-u:u)<=vg)return n=El(l,f,t,a),r.s<0?new l(1).div(n):Pe(n,a,i);if(s=f.s,s<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(s=1),f.e==0&&f.d[0]==1&&f.d.length==1)return f.s=s,f}return t=Tr(+f,u),e=t==0||!isFinite(t)?Vr(u*(Math.log("0."+zr(f.d))/Math.LN10+f.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?s/0:0):(We=!1,l.rounding=f.s=1,t=Math.min(12,(e+"").length),n=jo(r.times(sn(f,a+t)),a),n.d&&(n=Pe(n,a+5,1),za(n.d,a,i)&&(e=a+10,n=Pe(jo(r.times(sn(f,e+t)),e),e+5,1),+zr(n.d).slice(a+1,a+15)+1==1e14&&(n=Pe(n,a+1,0)))),n.s=s,We=!0,l.rounding=i,Pe(n,a,i))},we.toPrecision=function(r,e){var t,a=this,n=a.constructor;return r===void 0?t=St(a,a.e<=n.toExpNeg||a.e>=n.toExpPos):(jr(r,1,nn),e===void 0?e=n.rounding:jr(e,0,8),a=Pe(new n(a),r,e),t=St(a,r<=a.e||a.e<=n.toExpNeg,r)),a.isNeg()&&!a.isZero()?"-"+t:t},we.toSignificantDigits=we.toSD=function(r,e){var t=this,a=t.constructor;return r===void 0?(r=a.precision,e=a.rounding):(jr(r,1,nn),e===void 0?e=a.rounding:jr(e,0,8)),Pe(new a(t),r,e)},we.toString=function(){var r=this,e=r.constructor,t=St(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t},we.truncated=we.trunc=function(){return Pe(new this.constructor(this),this.e+1,1)},we.valueOf=we.toJSON=function(){var r=this,e=r.constructor,t=St(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function zr(r){var e,t,a,n=r.length-1,i="",s=r[0];if(n>0){for(i+=s,e=1;e<n;e++)a=r[e]+"",t=Ve-a.length,t&&(i+=on(t)),i+=a;s=r[e],a=s+"",t=Ve-a.length,t&&(i+=on(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function jr(r,e,t){if(r!==~~r||r<e||r>t)throw Error(an+r)}function za(r,e,t,a){var n,i,s,f;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=Ve,n=0):(n=Math.ceil((e+1)/Ve),e%=Ve),i=Tr(10,Ve-e),f=r[n]%i|0,a==null?e<3?(e==0?f=f/100|0:e==1&&(f=f/10|0),s=t<4&&f==99999||t>3&&f==49999||f==5e4||f==0):s=(t<4&&f+1==i||t>3&&f+1==i/2)&&(r[n+1]/i/100|0)==Tr(10,e-2)-1||(f==i/2||f==0)&&(r[n+1]/i/100|0)==0:e<4?(e==0?f=f/1e3|0:e==1?f=f/100|0:e==2&&(f=f/10|0),s=(a||t<4)&&f==9999||!a&&t>3&&f==4999):s=((a||t<4)&&f+1==i||!a&&t>3&&f+1==i/2)&&(r[n+1]/i/1e3|0)==Tr(10,e-3)-1,s}function gi(r,e,t){for(var a,n=[0],i,s=0,f=r.length;s<f;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=Yo.indexOf(r.charAt(s++)),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 hg(r,e){var t,a,n;if(e.isZero())return e;a=e.d.length,a<32?(t=Math.ceil(a/3),n=(1/xi(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),r.precision+=t,e=Yn(r,1,e.times(n),new r(1));for(var i=t;i--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return r.precision-=t,e}var dr=function(){function r(a,n,i){var s,f=0,l=a.length;for(a=a.slice();l--;)s=a[l]*n+f,a[l]=s%i|0,f=s/i|0;return f&&a.unshift(f),a}function e(a,n,i,s){var f,l;if(i!=s)l=i>s?1:-1;else for(f=l=0;f<i;f++)if(a[f]!=n[f]){l=a[f]>n[f]?1:-1;break}return l}function t(a,n,i,s){for(var f=0;i--;)a[i]-=f,f=a[i]<n[i]?1:0,a[i]=f*s+a[i]-n[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,n,i,s,f,l){var u,o,c,m,v,p,h,y,b,A,d,w,x,g,E,N,S,D,T,B,_=a.constructor,L=a.s==n.s?1:-1,G=a.d,C=n.d;if(!G||!G[0]||!C||!C[0])return new _(!a.s||!n.s||(G?C&&G[0]==C[0]:!C)?NaN:G&&G[0]==0||!C?L*0:L/0);for(l?(v=1,o=a.e-n.e):(l=ht,v=Ve,o=Vr(a.e/v)-Vr(n.e/v)),T=C.length,S=G.length,b=new _(L),A=b.d=[],c=0;C[c]==(G[c]||0);c++);if(C[c]>(G[c]||0)&&o--,i==null?(g=i=_.precision,s=_.rounding):f?g=i+(a.e-n.e)+1:g=i,g<0)A.push(1),p=!0;else{if(g=g/v+2|0,c=0,T==1){for(m=0,C=C[0],g++;(c<S||m)&&g--;c++)E=m*l+(G[c]||0),A[c]=E/C|0,m=E%C|0;p=m||c<S}else{for(m=l/(C[0]+1)|0,m>1&&(C=r(C,m,l),G=r(G,m,l),T=C.length,S=G.length),N=T,d=G.slice(0,T),w=d.length;w<T;)d[w++]=0;B=C.slice(),B.unshift(0),D=C[0],C[1]>=l/2&&++D;do m=0,u=e(C,d,T,w),u<0?(x=d[0],T!=w&&(x=x*l+(d[1]||0)),m=x/D|0,m>1?(m>=l&&(m=l-1),h=r(C,m,l),y=h.length,w=d.length,u=e(h,d,y,w),u==1&&(m--,t(h,T<y?B:C,y,l))):(m==0&&(u=m=1),h=C.slice()),y=h.length,y<w&&h.unshift(0),t(d,h,w,l),u==-1&&(w=d.length,u=e(C,d,T,w),u<1&&(m++,t(d,T<w?B:C,w,l))),w=d.length):u===0&&(m++,d=[0]),A[c++]=m,u&&d[0]?d[w++]=G[N]||0:(d=[G[N]],w=1);while((N++<S||d[0]!==void 0)&&g--);p=d[0]!==void 0}A[0]||A.shift()}if(v==1)b.e=o,bl=p;else{for(c=1,m=A[0];m>=10;m/=10)c++;b.e=c+o*v-1,Pe(b,f?i+b.e+1:i,s,p)}return b}}();function Pe(r,e,t,a){var n,i,s,f,l,u,o,c,m,v=r.constructor;e:if(e!=null){if(c=r.d,!c)return r;for(n=1,f=c[0];f>=10;f/=10)n++;if(i=e-n,i<0)i+=Ve,s=e,o=c[m=0],l=o/Tr(10,n-s-1)%10|0;else if(m=Math.ceil((i+1)/Ve),f=c.length,m>=f)if(a){for(;f++<=m;)c.push(0);o=l=0,n=1,i%=Ve,s=i-Ve+1}else break e;else{for(o=f=c[m],n=1;f>=10;f/=10)n++;i%=Ve,s=i-Ve+n,l=s<0?0:o/Tr(10,n-s-1)%10|0}if(a=a||e<0||c[m+1]!==void 0||(s<0?o:o%Tr(10,n-s-1)),u=t<4?(l||a)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||a||t==6&&(i>0?s>0?o/Tr(10,n-s):0:c[m-1])%10&1||t==(r.s<0?8:7)),e<1||!c[0])return c.length=0,u?(e-=r.e+1,c[0]=Tr(10,(Ve-e%Ve)%Ve),r.e=-e||0):c[0]=r.e=0,r;if(i==0?(c.length=m,f=1,m--):(c.length=m+1,f=Tr(10,Ve-i),c[m]=s>0?(o/Tr(10,n-s)%Tr(10,s)|0)*f:0),u)for(;;)if(m==0){for(i=1,s=c[0];s>=10;s/=10)i++;for(s=c[0]+=f,f=1;s>=10;s/=10)f++;i!=f&&(r.e++,c[0]==ht&&(c[0]=1));break}else{if(c[m]+=f,c[m]!=ht)break;c[m--]=0,f=1}for(i=c.length;c[--i]===0;)c.pop()}return We&&(r.e>v.maxE?(r.d=null,r.e=NaN):r.e<v.minE&&(r.e=0,r.d=[0])),r}function St(r,e,t){if(!r.isFinite())return Ml(r);var a,n=r.e,i=zr(r.d),s=i.length;return e?(t&&(a=t-s)>0?i=i.charAt(0)+"."+i.slice(1)+on(a):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):n<0?(i="0."+on(-n-1)+i,t&&(a=t-s)>0&&(i+=on(a))):n>=s?(i+=on(n+1-s),t&&(a=t-n-1)>0&&(i=i+"."+on(a))):((a=n+1)<s&&(i=i.slice(0,a)+"."+i.slice(a)),t&&(a=t-s)>0&&(n+1===s&&(i+="."),i+=on(a))),i}function yi(r,e){var t=r[0];for(e*=Ve;t>=10;t/=10)e++;return e}function bi(r,e,t){if(e>pg)throw We=!0,t&&(r.precision=t),Error(xl);return Pe(new r(pi),e,1,!0)}function dt(r,e,t){if(e>Ko)throw Error(xl);return Pe(new r(hi),e,t,!0)}function Al(r){var e=r.length-1,t=e*Ve+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 on(r){for(var e="";r--;)e+="0";return e}function El(r,e,t,a){var n,i=new r(1),s=Math.ceil(a/Ve+4);for(We=!1;;){if(t%2&&(i=i.times(e),Tl(i.d,s)&&(n=!0)),t=Vr(t/2),t===0){t=i.d.length-1,n&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Tl(e.d,s)}return We=!0,i}function Sl(r){return r.d[r.d.length-1]&1}function Cl(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 jo(r,e){var t,a,n,i,s,f,l,u=0,o=0,c=0,m=r.constructor,v=m.rounding,p=m.precision;if(!r.d||!r.d[0]||r.e>17)return new m(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(We=!1,l=p):l=e,f=new m(.03125);r.e>-2;)r=r.times(f),c+=5;for(a=Math.log(Tr(2,c))/Math.LN10*2+5|0,l+=a,t=i=s=new m(1),m.precision=l;;){if(i=Pe(i.times(r),l,1),t=t.times(++o),f=s.plus(dr(i,t,l,1)),zr(f.d).slice(0,l)===zr(s.d).slice(0,l)){for(n=c;n--;)s=Pe(s.times(s),l,1);if(e==null)if(u<3&&za(s.d,l-a,v,u))m.precision=l+=10,t=i=f=new m(1),o=0,u++;else return Pe(s,m.precision=p,v,We=!0);else return m.precision=p,s}s=f}}function sn(r,e){var t,a,n,i,s,f,l,u,o,c,m,v=1,p=10,h=r,y=h.d,b=h.constructor,A=b.rounding,d=b.precision;if(h.s<0||!y||!y[0]||!h.e&&y[0]==1&&y.length==1)return new b(y&&!y[0]?-1/0:h.s!=1?NaN:y?0:h);if(e==null?(We=!1,o=d):o=e,b.precision=o+=p,t=zr(y),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=zr(h.d),a=t.charAt(0),v++;i=h.e,a>1?(h=new b("0."+t),i++):h=new b(a+"."+t.slice(1))}else return u=bi(b,o+2,d).times(i+""),h=sn(new b(a+"."+t.slice(1)),o-p).plus(u),b.precision=d,e==null?Pe(h,d,A,We=!0):h;for(c=h,l=s=h=dr(h.minus(1),h.plus(1),o,1),m=Pe(h.times(h),o,1),n=3;;){if(s=Pe(s.times(m),o,1),u=l.plus(dr(s,new b(n),o,1)),zr(u.d).slice(0,o)===zr(l.d).slice(0,o))if(l=l.times(2),i!==0&&(l=l.plus(bi(b,o+2,d).times(i+""))),l=dr(l,new b(v),o,1),e==null)if(za(l.d,o-p,A,f))b.precision=o+=p,u=s=h=dr(c.minus(1),c.plus(1),o,1),m=Pe(h.times(h),o,1),n=f=1;else return Pe(l,b.precision=d,A,We=!0);else return b.precision=d,l;l=u,n+=2}}function Ml(r){return String(r.s*r.s/0)}function es(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)%Ve,t<0&&(a+=Ve),a<n){for(a&&r.d.push(+e.slice(0,a)),n-=Ve;a<n;)r.d.push(+e.slice(a,a+=Ve));e=e.slice(a),a=Ve-e.length}else a-=n;for(;a--;)e+="0";r.d.push(+e),We&&(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 dg(r,e){var t,a,n,i,s,f,l,u,o;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Dl.test(e))return es(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(fg.test(e))t=16,e=e.toLowerCase();else if(cg.test(e))t=2;else if(mg.test(e))t=8;else throw Error(an+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),s=i>=0,a=r.constructor,s&&(e=e.replace(".",""),f=e.length,i=f-i,n=El(a,new a(t),i,i*2)),u=gi(e,t,ht),o=u.length-1,i=o;u[i]===0;--i)u.pop();return i<0?new a(r.s*0):(r.e=yi(u,o),r.d=u,We=!1,s&&(r=dr(r,n,f*4)),l&&(r=r.times(Math.abs(l)<54?Tr(2,l):un.pow(2,l))),We=!0,r)}function gg(r,e){var t,a=e.d.length;if(a<3)return e.isZero()?e:Yn(r,2,e,e);t=1.4*Math.sqrt(a),t=t>16?16:t|0,e=e.times(1/xi(5,t)),e=Yn(r,2,e,e);for(var n,i=new r(5),s=new r(16),f=new r(20);t--;)n=e.times(e),e=e.times(i.plus(n.times(s.times(n).minus(f))));return e}function Yn(r,e,t,a,n){var i,s,f,l,u=r.precision,o=Math.ceil(u/Ve);for(We=!1,l=t.times(t),f=new r(a);;){if(s=dr(f.times(l),new r(e++*e++),u,1),f=n?a.plus(s):a.minus(s),a=dr(s.times(l),new r(e++*e++),u,1),s=f.plus(a),s.d[o]!==void 0){for(i=o;s.d[i]===f.d[i]&&i--;);if(i==-1)break}i=f,f=a,a=s,s=i}return We=!0,s.d.length=o+1,s}function xi(r,e){for(var t=r;--e;)t*=r;return t}function Fl(r,e){var t,a=e.s<0,n=dt(r,r.precision,1),i=n.times(.5);if(e=e.abs(),e.lte(i))return kt=a?4:1,e;if(t=e.divToInt(n),t.isZero())kt=a?3:2;else{if(e=e.minus(t.times(n)),e.lte(i))return kt=Sl(t)?a?2:3:a?4:1,e;kt=Sl(t)?a?1:4:a?3:2}return e.minus(n).abs()}function rs(r,e,t,a){var n,i,s,f,l,u,o,c,m,v=r.constructor,p=t!==void 0;if(p?(jr(t,1,nn),a===void 0?a=v.rounding:jr(a,0,8)):(t=v.precision,a=v.rounding),!r.isFinite())o=Ml(r);else{for(o=St(r),s=o.indexOf("."),p?(n=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):n=e,s>=0&&(o=o.replace(".",""),m=new v(1),m.e=o.length-s,m.d=gi(St(m),10,n),m.e=m.d.length),c=gi(o,10,n),i=l=c.length;c[--l]==0;)c.pop();if(!c[0])o=p?"0p+0":"0";else{if(s<0?i--:(r=new v(r),r.d=c,r.e=i,r=dr(r,m,t,a,0,n),c=r.d,i=r.e,u=bl),s=c[t],f=n/2,u=u||c[t+1]!==void 0,u=a<4?(s!==void 0||u)&&(a===0||a===(r.s<0?3:2)):s>f||s===f&&(a===4||u||a===6&&c[t-1]&1||a===(r.s<0?8:7)),c.length=t,u)for(;++c[--t]>n-1;)c[t]=0,t||(++i,c.unshift(1));for(l=c.length;!c[l-1];--l);for(s=0,o="";s<l;s++)o+=Yo.charAt(c[s]);if(p){if(l>1)if(e==16||e==8){for(s=e==16?4:3,--l;l%s;l++)o+="0";for(c=gi(o,n,e),l=c.length;!c[l-1];--l);for(s=1,o="1.";s<l;s++)o+=Yo.charAt(c[s])}else o=o.charAt(0)+"."+o.slice(1);o=o+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)o="0"+o;o="0."+o}else if(++i>l)for(i-=l;i--;)o+="0";else i<l&&(o=o.slice(0,i)+"."+o.slice(i))}o=(e==16?"0x":e==2?"0b":e==8?"0o":"")+o}return r.s<0?"-"+o:o}function Tl(r,e){if(r.length>e)return r.length=e,!0}function yg(r){return new this(r).abs()}function bg(r){return new this(r).acos()}function xg(r){return new this(r).acosh()}function wg(r,e){return new this(r).plus(e)}function Ng(r){return new this(r).asin()}function Dg(r){return new this(r).asinh()}function Ag(r){return new this(r).atan()}function Eg(r){return new this(r).atanh()}function Sg(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=dt(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?dt(this,a,n):new this(0),t.s=r.s):!r.d||e.isZero()?(t=dt(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(dr(r,e,i,1)),e=dt(this,i,1),this.precision=a,this.rounding=n,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(dr(r,e,i,1)),t}function Cg(r){return new this(r).cbrt()}function Mg(r){return Pe(r=new this(r),r.e+1,2)}function Fg(r,e,t){return new this(r).clamp(e,t)}function Tg(r){if(!r||typeof r!="object")throw Error(di+"Object expected");var e,t,a,n=r.defaults===!0,i=["precision",1,nn,"rounding",0,8,"toExpNeg",-Xn,0,"toExpPos",0,Xn,"maxE",0,Xn,"minE",-Xn,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],n&&(this[t]=Qo[t]),(a=r[t])!==void 0)if(Vr(a)===a&&a>=i[e+1]&&a<=i[e+2])this[t]=a;else throw Error(an+t+": "+a);if(t="crypto",n&&(this[t]=Qo[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(wl);else this[t]=!1;else throw Error(an+t+": "+a);return this}function Bg(r){return new this(r).cos()}function $g(r){return new this(r).cosh()}function Bl(r){var e,t,a;function n(i){var s,f,l,u=this;if(!(u instanceof n))return new n(i);if(u.constructor=n,$l(i)){u.s=i.s,We?!i.d||i.e>n.maxE?(u.e=NaN,u.d=null):i.e<n.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(s=0,f=i;f>=10;f/=10)s++;We?s>n.maxE?(u.e=NaN,u.d=null):s<n.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return es(u,i.toString())}else if(l!=="string")throw Error(an+i);return(f=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(f===43&&(i=i.slice(1)),u.s=1),Dl.test(i)?es(u,i):dg(u,i)}if(n.prototype=we,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=Tg,n.clone=Bl,n.isDecimal=$l,n.abs=yg,n.acos=bg,n.acosh=xg,n.add=wg,n.asin=Ng,n.asinh=Dg,n.atan=Ag,n.atanh=Eg,n.atan2=Sg,n.cbrt=Cg,n.ceil=Mg,n.clamp=Fg,n.cos=Bg,n.cosh=$g,n.div=Og,n.exp=_g,n.floor=Ig,n.hypot=Rg,n.ln=qg,n.log=zg,n.log10=Lg,n.log2=Pg,n.max=Ug,n.min=kg,n.mod=Vg,n.mul=Gg,n.pow=Hg,n.random=Zg,n.round=Jg,n.sign=Wg,n.sin=Xg,n.sinh=Yg,n.sqrt=Qg,n.sub=Kg,n.sum=jg,n.tan=e1,n.tanh=r1,n.trunc=t1,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 Og(r,e){return new this(r).div(e)}function _g(r){return new this(r).exp()}function Ig(r){return Pe(r=new this(r),r.e+1,3)}function Rg(){var r,e,t=new this(0);for(We=!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 We=!0,new this(1/0);t=e}return We=!0,t.sqrt()}function $l(r){return r instanceof un||r&&r.toStringTag===Nl||!1}function qg(r){return new this(r).ln()}function zg(r,e){return new this(r).log(e)}function Pg(r){return new this(r).log(2)}function Lg(r){return new this(r).log(10)}function Ug(){return Cl(this,arguments,"lt")}function kg(){return Cl(this,arguments,"gt")}function Vg(r,e){return new this(r).mod(e)}function Gg(r,e){return new this(r).mul(e)}function Hg(r,e){return new this(r).pow(e)}function Zg(r){var e,t,a,n,i=0,s=new this(1),f=[];if(r===void 0?r=this.precision:jr(r,1,nn),a=Math.ceil(r/Ve),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]:f[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):(f.push(n%1e7),i+=4);i=a/4}else throw Error(wl);else for(;i<a;)f[i++]=Math.random()*1e7|0;for(a=f[--i],r%=Ve,a&&r&&(n=Tr(10,Ve-r),f[i]=(a/n|0)*n);f[i]===0;i--)f.pop();if(i<0)t=0,f=[0];else{for(t=-1;f[0]===0;t-=Ve)f.shift();for(a=1,n=f[0];n>=10;n/=10)a++;a<Ve&&(t-=Ve-a)}return s.e=t,s.d=f,s}function Jg(r){return Pe(r=new this(r),r.e+1,this.rounding)}function Wg(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function Xg(r){return new this(r).sin()}function Yg(r){return new this(r).sinh()}function Qg(r){return new this(r).sqrt()}function Kg(r,e){return new this(r).sub(e)}function jg(){var r=0,e=arguments,t=new this(e[r]);for(We=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return We=!0,Pe(t,this.precision,this.rounding)}function e1(r){return new this(r).tan()}function r1(r){return new this(r).tanh()}function t1(r){return Pe(r=new this(r),r.e+1,1)}we[Symbol.for("nodejs.util.inspect.custom")]=we.toString,we[Symbol.toStringTag]="Decimal";var un=we.constructor=Bl(Qo);pi=new un(pi),hi=new un(hi);var n1="BigNumber",a1=["?on","config"],i1=R(n1,a1,r=>{var{on:e,config:t}=r,a=un.clone({precision:t.precision,modulo:un.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}),Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ol(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function o1(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 _l={exports:{}};/**
|
|
15
16
|
* @license Complex.js v2.1.1 12/05/2020
|
|
16
17
|
*
|
|
17
18
|
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
|
18
19
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
19
|
-
**/(function(r,e){(function(t){var a=Math.cosh||function(
|
|
20
|
-
`||(
|
|
20
|
+
**/(function(r,e){(function(t){var a=Math.cosh||function(c){return Math.abs(c)<1e-9?1-c:(Math.exp(c)+Math.exp(-c))*.5},n=Math.sinh||function(c){return Math.abs(c)<1e-9?c:(Math.exp(c)-Math.exp(-c))*.5},i=function(c){var m=Math.PI/4;if(-m>c||c>m)return Math.cos(c)-1;var v=c*c;return v*(v*(v*(v*(v*(v*(v*(v/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},s=function(c,m){var v=Math.abs(c),p=Math.abs(m);return v<3e3&&p<3e3?Math.sqrt(v*v+p*p):(v<p?(v=p,p=c/m):p=m/c,v*Math.sqrt(1+p*p))},f=function(){throw SyntaxError("Invalid Param")};function l(c,m){var v=Math.abs(c),p=Math.abs(m);return c===0?Math.log(p):m===0?Math.log(v):v<3e3&&p<3e3?Math.log(c*c+m*m)*.5:(c=c/2,m=m/2,.5*Math.log(c*c+m*m)+Math.LN2)}var u=function(c,m){var v={re:0,im:0};if(c==null)v.re=v.im=0;else if(m!==void 0)v.re=c,v.im=m;else switch(typeof c){case"object":if("im"in c&&"re"in c)v.re=c.re,v.im=c.im;else if("abs"in c&&"arg"in c){if(!Number.isFinite(c.abs)&&Number.isFinite(c.arg))return o.INFINITY;v.re=c.abs*Math.cos(c.arg),v.im=c.abs*Math.sin(c.arg)}else if("r"in c&&"phi"in c){if(!Number.isFinite(c.r)&&Number.isFinite(c.phi))return o.INFINITY;v.re=c.r*Math.cos(c.phi),v.im=c.r*Math.sin(c.phi)}else c.length===2?(v.re=c[0],v.im=c[1]):f();break;case"string":v.im=v.re=0;var p=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),h=1,y=0;p===null&&f();for(var b=0;b<p.length;b++){var A=p[b];A===" "||A===" "||A===`
|
|
21
|
+
`||(A==="+"?h++:A==="-"?y++:A==="i"||A==="I"?(h+y===0&&f(),p[b+1]!==" "&&!isNaN(p[b+1])?(v.im+=parseFloat((y%2?"-":"")+p[b+1]),b++):v.im+=parseFloat((y%2?"-":"")+"1"),h=y=0):((h+y===0||isNaN(A))&&f(),p[b+1]==="i"||p[b+1]==="I"?(v.im+=parseFloat((y%2?"-":"")+A),b++):v.re+=parseFloat((y%2?"-":"")+A),h=y=0))}h+y>0&&f();break;case"number":v.im=0,v.re=c;break;default:f()}return isNaN(v.re)||isNaN(v.im),v};function o(c,m){if(!(this instanceof o))return new o(c,m);var v=u(c,m);this.re=v.re,this.im=v.im}o.prototype={re:0,im:0,sign:function(){var c=this.abs();return new o(this.re/c,this.im/c)},add:function(c,m){var v=new o(c,m);return this.isInfinite()&&v.isInfinite()?o.NAN:this.isInfinite()||v.isInfinite()?o.INFINITY:new o(this.re+v.re,this.im+v.im)},sub:function(c,m){var v=new o(c,m);return this.isInfinite()&&v.isInfinite()?o.NAN:this.isInfinite()||v.isInfinite()?o.INFINITY:new o(this.re-v.re,this.im-v.im)},mul:function(c,m){var v=new o(c,m);return this.isInfinite()&&v.isZero()||this.isZero()&&v.isInfinite()?o.NAN:this.isInfinite()||v.isInfinite()?o.INFINITY:v.im===0&&this.im===0?new o(this.re*v.re,0):new o(this.re*v.re-this.im*v.im,this.re*v.im+this.im*v.re)},div:function(c,m){var v=new o(c,m);if(this.isZero()&&v.isZero()||this.isInfinite()&&v.isInfinite())return o.NAN;if(this.isInfinite()||v.isZero())return o.INFINITY;if(this.isZero()||v.isInfinite())return o.ZERO;c=this.re,m=this.im;var p=v.re,h=v.im,y,b;return h===0?new o(c/p,m/p):Math.abs(p)<Math.abs(h)?(b=p/h,y=p*b+h,new o((c*b+m)/y,(m*b-c)/y)):(b=h/p,y=h*b+p,new o((c+m*b)/y,(m-c*b)/y))},pow:function(c,m){var v=new o(c,m);if(c=this.re,m=this.im,v.isZero())return o.ONE;if(v.im===0){if(m===0&&c>0)return new o(Math.pow(c,v.re),0);if(c===0)switch((v.re%4+4)%4){case 0:return new o(Math.pow(m,v.re),0);case 1:return new o(0,Math.pow(m,v.re));case 2:return new o(-Math.pow(m,v.re),0);case 3:return new o(0,-Math.pow(m,v.re))}}if(c===0&&m===0&&v.re>0&&v.im>=0)return o.ZERO;var p=Math.atan2(m,c),h=l(c,m);return c=Math.exp(v.re*h-v.im*p),m=v.im*h+v.re*p,new o(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),p,h;if(c>=0){if(m===0)return new o(Math.sqrt(c),0);p=.5*Math.sqrt(2*(v+c))}else p=Math.abs(m)/Math.sqrt(2*(v-c));return c<=0?h=.5*Math.sqrt(2*(v-c)):h=Math.abs(m)/Math.sqrt(2*(v+c)),new o(p,m<0?-h:h)},exp:function(){var c=Math.exp(this.re);return this.im,new o(c*Math.cos(this.im),c*Math.sin(this.im))},expm1:function(){var c=this.re,m=this.im;return new o(Math.expm1(c)*Math.cos(m)+i(m),Math.exp(c)*Math.sin(m))},log:function(){var c=this.re,m=this.im;return new o(l(c,m),Math.atan2(m,c))},abs:function(){return s(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,m=this.im;return new o(Math.sin(c)*a(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new o(Math.cos(c)*a(m),-Math.sin(c)*n(m))},tan:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)+a(m);return new o(Math.sin(c)/v,n(m)/v)},cot:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)-a(m);return new o(-Math.sin(c)/v,n(m)/v)},sec:function(){var c=this.re,m=this.im,v=.5*a(2*m)+.5*Math.cos(2*c);return new o(Math.cos(c)*a(m)/v,Math.sin(c)*n(m)/v)},csc:function(){var c=this.re,m=this.im,v=.5*a(2*m)-.5*Math.cos(2*c);return new o(Math.sin(c)*a(m)/v,-Math.cos(c)*n(m)/v)},asin:function(){var c=this.re,m=this.im,v=new o(m*m-c*c+1,-2*c*m).sqrt(),p=new o(v.re-m,v.im+c).log();return new o(p.im,-p.re)},acos:function(){var c=this.re,m=this.im,v=new o(m*m-c*c+1,-2*c*m).sqrt(),p=new o(v.re-m,v.im+c).log();return new o(Math.PI/2-p.im,p.re)},atan:function(){var c=this.re,m=this.im;if(c===0){if(m===1)return new o(0,1/0);if(m===-1)return new o(0,-1/0)}var v=c*c+(1-m)*(1-m),p=new o((1-m*m-c*c)/v,-2*c/v).log();return new o(-.5*p.im,.5*p.re)},acot:function(){var c=this.re,m=this.im;if(m===0)return new o(Math.atan2(1,c),0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).atan():new o(c!==0?c/0:0,m!==0?-m/0:0).atan()},asec:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new o(0,1/0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).acos():new o(c!==0?c/0:0,m!==0?-m/0:0).acos()},acsc:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new o(Math.PI/2,1/0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).asin():new o(c!==0?c/0:0,m!==0?-m/0:0).asin()},sinh:function(){var c=this.re,m=this.im;return new o(n(c)*Math.cos(m),a(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new o(a(c)*Math.cos(m),n(c)*Math.sin(m))},tanh:function(){var c=2*this.re,m=2*this.im,v=a(c)+Math.cos(m);return new o(n(c)/v,Math.sin(m)/v)},coth:function(){var c=2*this.re,m=2*this.im,v=a(c)-Math.cos(m);return new o(n(c)/v,-Math.sin(m)/v)},csch:function(){var c=this.re,m=this.im,v=Math.cos(2*m)-a(2*c);return new o(-2*n(c)*Math.cos(m)/v,2*a(c)*Math.sin(m)/v)},sech:function(){var c=this.re,m=this.im,v=Math.cos(2*m)+a(2*c);return new o(2*a(c)*Math.cos(m)/v,-2*n(c)*Math.sin(m)/v)},asinh:function(){var c=this.im;this.im=-this.re,this.re=c;var m=this.asin();return this.re=-this.im,this.im=c,c=m.re,m.re=-m.im,m.im=c,m},acosh:function(){var c=this.acos();if(c.im<=0){var m=c.re;c.re=-c.im,c.im=m}else{var m=c.im;c.im=-c.re,c.re=m}return c},atanh:function(){var c=this.re,m=this.im,v=c>1&&m===0,p=1-c,h=1+c,y=p*p+m*m,b=y!==0?new o((h*p-m*m)/y,(m*p+h*m)/y):new o(c!==-1?c/0:0,m!==0?m/0:0),A=b.re;return b.re=l(b.re,b.im)/2,b.im=Math.atan2(b.im,A)/2,v&&(b.im=-b.im),b},acoth:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new o(0,Math.PI/2);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).atanh():new o(c!==0?c/0:0,m!==0?-m/0:0).atanh()},acsch:function(){var c=this.re,m=this.im;if(m===0)return new o(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var v=c*c+m*m;return v!==0?new o(c/v,-m/v).asinh():new o(c!==0?c/0:0,m!==0?-m/0:0).asinh()},asech:function(){var c=this.re,m=this.im;if(this.isZero())return o.INFINITY;var v=c*c+m*m;return v!==0?new o(c/v,-m/v).acosh():new o(c!==0?c/0:0,m!==0?-m/0:0).acosh()},inverse:function(){if(this.isZero())return o.INFINITY;if(this.isInfinite())return o.ZERO;var c=this.re,m=this.im,v=c*c+m*m;return new o(c/v,-m/v)},conjugate:function(){return new o(this.re,-this.im)},neg:function(){return new o(-this.re,-this.im)},ceil:function(c){return c=Math.pow(10,c||0),new o(Math.ceil(this.re*c)/c,Math.ceil(this.im*c)/c)},floor:function(c){return c=Math.pow(10,c||0),new o(Math.floor(this.re*c)/c,Math.floor(this.im*c)/c)},round:function(c){return c=Math.pow(10,c||0),new o(Math.round(this.re*c)/c,Math.round(this.im*c)/c)},equals:function(c,m){var v=new o(c,m);return Math.abs(v.re-this.re)<=o.EPSILON&&Math.abs(v.im-this.im)<=o.EPSILON},clone:function(){return new o(this.re,this.im)},toString:function(){var c=this.re,m=this.im,v="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<o.EPSILON&&(c=0),Math.abs(m)<o.EPSILON&&(m=0),m===0?v+c:(c!==0?(v+=c,v+=" ",m<0?(m=-m,v+="-"):v+="+",v+=" "):m<0&&(m=-m,v+="-"),m!==1&&(v+=m),v+"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())}},o.ZERO=new o(0,0),o.ONE=new o(1,0),o.I=new o(0,1),o.PI=new o(Math.PI,0),o.E=new o(Math.E,0),o.INFINITY=new o(1/0,1/0),o.NAN=new o(NaN,NaN),o.EPSILON=1e-15,Object.defineProperty(o,"__esModule",{value:!0}),o.default=o,o.Complex=o,r.exports=o})()})(_l);const Pr=Ol(_l.exports);var s1="Complex",u1=[],l1=R(s1,u1,()=>(Object.defineProperty(Pr,"name",{value:"Complex"}),Pr.prototype.constructor=Pr,Pr.prototype.type="Complex",Pr.prototype.isComplex=!0,Pr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Pr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Pr.prototype.format=function(r){var e="",t=this.im,a=this.re,n=En(this.re,r),i=En(this.im,r),s=tr(r)?r:r?r.precision:null;if(s!==null){var f=Math.pow(10,-s);Math.abs(a/t)<f&&(a=0),Math.abs(t/a)<f&&(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},Pr.fromPolar=function(r){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Pr(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(tr(t)){if(Pt(a)&&a.hasBase("ANGLE")&&(a=a.toNumber("rad")),tr(a))return new Pr({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")}},Pr.prototype.valueOf=Pr.prototype.toString,Pr.fromJSON=function(r){return new Pr(r)},Pr.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},Pr),{isClass:!0}),Il={exports:{}};/**
|
|
21
22
|
* @license Fraction.js v4.2.0 05/03/2022
|
|
22
23
|
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
|
23
24
|
*
|
|
24
25
|
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
|
|
25
26
|
* 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
|
-
`,
|
|
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
|
-
`)}
|
|
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(
|
|
33
|
-
`.concat(
|
|
34
|
-
`&&
|
|
35
|
-
`&&!
|
|
36
|
-
`)}function Z(
|
|
37
|
-
`&&
|
|
38
|
-
`&&
|
|
39
|
-
`||
|
|
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()+`
|
|
27
|
+
**/(function(r,e){(function(t){var a=2e3,n={s:1,n:0,d:1};function i(p,h){if(isNaN(p=parseInt(p,10)))throw v.InvalidParameter;return p*h}function s(p,h){if(h===0)throw v.DivisionByZero;var y=Object.create(v.prototype);y.s=p<0?-1:1,p=p<0?-p:p;var b=m(p,h);return y.n=p/b,y.d=h/b,y}function f(p){for(var h={},y=p,b=2,A=4;A<=y;){for(;y%b===0;)y/=b,h[b]=(h[b]||0)+1;A+=1+2*b++}return y!==p?y>1&&(h[y]=(h[y]||0)+1):h[p]=(h[p]||0)+1,h}var l=function(p,h){var y=0,b=1,A=1,d=0,w=0,x=0,g=1,E=1,N=0,S=1,D=1,T=1,B=1e7,_;if(p!=null)if(h!==void 0){if(y=p,b=h,A=y*b,y%1!==0||b%1!==0)throw v.NonIntegerParameter}else switch(typeof p){case"object":{if("d"in p&&"n"in p)y=p.n,b=p.d,"s"in p&&(y*=p.s);else if(0 in p)y=p[0],1 in p&&(b=p[1]);else throw v.InvalidParameter;A=y*b;break}case"number":{if(p<0&&(A=p,p=-p),p%1===0)y=p;else if(p>0){for(p>=1&&(E=Math.pow(10,Math.floor(1+Math.log(p)/Math.LN10)),p/=E);S<=B&&T<=B;)if(_=(N+D)/(S+T),p===_){S+T<=B?(y=N+D,b=S+T):T>S?(y=D,b=T):(y=N,b=S);break}else p>_?(N+=D,S+=T):(D+=N,T+=S),S>B?(y=D,b=T):(y=N,b=S);y*=E}else(isNaN(p)||isNaN(h))&&(b=y=NaN);break}case"string":{if(S=p.match(/\d+|./g),S===null)throw v.InvalidParameter;if(S[N]==="-"?(A=-1,N++):S[N]==="+"&&N++,S.length===N+1?w=i(S[N++],A):S[N+1]==="."||S[N]==="."?(S[N]!=="."&&(d=i(S[N++],A)),N++,(N+1===S.length||S[N+1]==="("&&S[N+3]===")"||S[N+1]==="'"&&S[N+3]==="'")&&(w=i(S[N],A),g=Math.pow(10,S[N].length),N++),(S[N]==="("&&S[N+2]===")"||S[N]==="'"&&S[N+2]==="'")&&(x=i(S[N+1],A),E=Math.pow(10,S[N+1].length)-1,N+=3)):S[N+1]==="/"||S[N+1]===":"?(w=i(S[N],A),g=i(S[N+2],1),N+=3):S[N+3]==="/"&&S[N+1]===" "&&(d=i(S[N],A),w=i(S[N+2],A),g=i(S[N+4],1),N+=5),S.length<=N){b=g*E,A=y=x+b*d+E*w;break}}default:throw v.InvalidParameter}if(b===0)throw v.DivisionByZero;n.s=A<0?-1:1,n.n=Math.abs(y),n.d=Math.abs(b)};function u(p,h,y){for(var b=1;h>0;p=p*p%y,h>>=1)h&1&&(b=b*p%y);return b}function o(p,h){for(;h%2===0;h/=2);for(;h%5===0;h/=5);if(h===1)return 0;for(var y=10%h,b=1;y!==1;b++)if(y=y*10%h,b>a)return 0;return b}function c(p,h,y){for(var b=1,A=u(10,y,h),d=0;d<300;d++){if(b===A)return d;b=b*10%h,A=A*10%h}return 0}function m(p,h){if(!p)return h;if(!h)return p;for(;;){if(p%=h,!p)return h;if(h%=p,!h)return p}}function v(p,h){if(l(p,h),this instanceof v)p=m(n.d,n.n),this.s=n.s,this.n=n.n/p,this.d=n.d/p;else return s(n.s*n.n,n.d)}v.DivisionByZero=new Error("Division by Zero"),v.InvalidParameter=new Error("Invalid argument"),v.NonIntegerParameter=new Error("Parameters must be integer"),v.prototype={s:1,n:0,d:1,abs:function(){return s(this.n,this.d)},neg:function(){return s(-this.s*this.n,this.d)},add:function(p,h){return l(p,h),s(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(p,h){return l(p,h),s(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(p,h){return l(p,h),s(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(p,h){return l(p,h),s(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return s(this.s*this.n,this.d)},mod:function(p,h){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(p===void 0)return s(this.s*this.n%this.d,1);if(l(p,h),n.n===0&&this.d===0)throw v.DivisionByZero;return s(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(p,h){return l(p,h),s(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(p,h){return l(p,h),n.n===0&&this.n===0?s(0,1):s(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):s(Math.ceil(p*this.s*this.n/this.d),p)},floor:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):s(Math.floor(p*this.s*this.n/this.d),p)},round:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):s(Math.round(p*this.s*this.n/this.d),p)},inverse:function(){return s(this.s*this.d,this.n)},pow:function(p,h){if(l(p,h),n.d===1)return n.s<0?s(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):s(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var y=f(this.n),b=f(this.d),A=1,d=1;for(var w in y)if(w!=="1"){if(w==="0"){A=0;break}if(y[w]*=n.n,y[w]%n.d===0)y[w]/=n.d;else return null;A*=Math.pow(w,y[w])}for(var w in b)if(w!=="1"){if(b[w]*=n.n,b[w]%n.d===0)b[w]/=n.d;else return null;d*=Math.pow(w,b[w])}return n.s<0?s(d,A):s(A,d)},equals:function(p,h){return l(p,h),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(p,h){l(p,h);var y=this.s*this.n*n.d-n.s*n.n*this.d;return(0<y)-(y<0)},simplify:function(p){if(isNaN(this.n)||isNaN(this.d))return this;p=p||.001;for(var h=this.abs(),y=h.toContinued(),b=1;b<y.length;b++){for(var A=s(y[b-1],1),d=b-2;d>=0;d--)A=A.inverse().add(y[d]);if(A.sub(h).abs().valueOf()<p)return A.mul(this.s)}return this},divisible:function(p,h){return l(p,h),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(p){var h,y="",b=this.n,A=this.d;return this.s<0&&(y+="-"),A===1?y+=b:(p&&(h=Math.floor(b/A))>0&&(y+=h,y+=" ",b%=A),y+=b,y+="/",y+=A),y},toLatex:function(p){var h,y="",b=this.n,A=this.d;return this.s<0&&(y+="-"),A===1?y+=b:(p&&(h=Math.floor(b/A))>0&&(y+=h,b%=A),y+="\\frac{",y+=b,y+="}{",y+=A,y+="}"),y},toContinued:function(){var p,h=this.n,y=this.d,b=[];if(isNaN(h)||isNaN(y))return b;do b.push(Math.floor(h/y)),p=h%y,h=y,y=p;while(h!==1);return b},toString:function(p){var h=this.n,y=this.d;if(isNaN(h)||isNaN(y))return"NaN";p=p||15;var b=o(h,y),A=c(h,y,b),d=this.s<0?"-":"";if(d+=h/y|0,h%=y,h*=10,h&&(d+="."),b){for(var w=A;w--;)d+=h/y|0,h%=y,h*=10;d+="(";for(var w=b;w--;)d+=h/y|0,h%=y,h*=10;d+=")"}else for(var w=p;h&&w--;)d+=h/y|0,h%=y,h*=10;return d}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,r.exports=v})()})(Il);const Vt=Ol(Il.exports);var c1="Fraction",f1=[],m1=R(c1,f1,()=>(Object.defineProperty(Vt,"name",{value:"Fraction"}),Vt.prototype.constructor=Vt,Vt.prototype.type="Fraction",Vt.prototype.isFraction=!0,Vt.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Vt.fromJSON=function(r){return new Vt(r)},Vt),{isClass:!0}),v1="Range",p1=[],h1=R(v1,p1,()=>{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,s=a!=null;if(n){if(rr(e))e=e.toNumber();else if(typeof e!="number")throw new TypeError("Parameter start must be a number")}if(i){if(rr(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter end must be a number")}if(s){if(rr(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=s?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 tn(a)===tn(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=En(this.start,e);return this.step!==1&&(t+=":"+En(this.step,e)),t+=":"+En(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}),d1="Matrix",g1=[],y1=R(d1,g1,()=>{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});function b1(r){var e=0,t=1,a=Object.create(null),n=Object.create(null),i=0,s=function(l){var u=n[l];if(!!u&&(delete a[u],delete n[l],--e,t===u)){if(!e){i=0,t=1;return}for(;!hasOwnProperty.call(a,++t););}};return r=Math.abs(r),{hit:function(l){var u=n[l],o=++i;if(a[o]=l,n[l]=o,!u)return++e,e<=r?void 0:(l=a[t],s(l),l);if(delete a[u],t===u)for(;!hasOwnProperty.call(a,++t););},delete:s,clear:function(){e=i=0,t=1,a=Object.create(null),n=Object.create(null)}}}function Pa(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:b1(t||Number.POSITIVE_INFINITY)});for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=e(n);if(a.cache.values.has(s))return a.cache.lru.hit(s),a.cache.values.get(s);var f=r.apply(r,n);return a.cache.values.set(s,f),a.cache.values.delete(a.cache.lru.hit(s)),f}}function ln(r){return Object.keys(r.signatures||{}).reduce(function(e,t){var a=(t.match(/,/g)||[]).length+1;return Math.max(e,a)},-1)}var x1="DenseMatrix",w1=["Matrix"],N1=R(x1,w1,r=>{var{Matrix:e}=r;function t(o,c){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Wr(c))throw new Error("Invalid datatype: "+c);if(He(o))o.type==="DenseMatrix"?(this._data=ke(o._data),this._size=ke(o._size),this._datatype=c||o._datatype):(this._data=o.toArray(),this._size=o.size(),this._datatype=c||o._datatype);else if(o&&ur(o.data)&&ur(o.size))this._data=o.data,this._size=o.size,ul(this._data,this._size),this._datatype=c||o.datatype;else if(ur(o))this._data=u(o),this._size=er(this._data),ul(this._data,this._size),this._datatype=c;else{if(o)throw new TypeError("Unsupported type of data ("+gr(o)+")");this._data=[],this._size=[0],this._datatype=c}}t.prototype=new e,t.prototype.createDenseMatrix=function(o,c){return new t(o,c)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return qa(this._data,gr)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(o,c){return new t(o,c)},t.prototype.subset=function(o,c,m){switch(arguments.length){case 1:return a(this,o);case 2:case 3:return i(this,o,c,m);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(o){if(!ur(o))throw new TypeError("Array expected");if(o.length!==this._size.length)throw new Ke(o.length,this._size.length);for(var c=0;c<o.length;c++)mr(o[c],this._size[c]);for(var m=this._data,v=0,p=o.length;v<p;v++){var h=o[v];mr(h,m.length),m=m[h]}return m},t.prototype.set=function(o,c,m){if(!ur(o))throw new TypeError("Array expected");if(o.length<this._size.length)throw new Ke(o.length,this._size.length,"<");var v,p,h,y=o.map(function(A){return A+1});l(this,y,m);var b=this._data;for(v=0,p=o.length-1;v<p;v++)h=o[v],mr(h,b.length),b=b[h];return h=o[o.length-1],mr(h,b.length),b[h]=c,this};function a(o,c){if(!ai(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return o.get(c.min());var v=c.size();if(v.length!==o._size.length)throw new Ke(v.length,o._size.length);for(var p=c.min(),h=c.max(),y=0,b=o._size.length;y<b;y++)mr(p[y],o._size[y]),mr(h[y],o._size[y]);return new t(n(o._data,c,v.length,0),o._datatype)}function n(o,c,m,v){var p=v===m-1,h=c.dimension(v);return p?h.map(function(y){return mr(y,o.length),o[y]}).valueOf():h.map(function(y){mr(y,o.length);var b=o[y];return n(b,c,m,v+1)}).valueOf()}function i(o,c,m,v){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var p=c.size(),h=c.isScalar(),y;if(He(m)?(y=m.size(),m=m.valueOf()):y=er(m),h){if(y.length!==0)throw new TypeError("Scalar expected");o.set(c.min(),m,v)}else{if(p.length<o._size.length)throw new Ke(p.length,o._size.length,"<");if(y.length<p.length){for(var b=0,A=0;p[b]===1&&y[b]===1;)b++;for(;p[b]===1;)A++,b++;m=ml(m,p.length,A,y)}if(!Ra(p,y))throw new Ke(p,y,">");var d=c.max().map(function(g){return g+1});l(o,d,v);var w=p.length,x=0;s(o._data,c,m,w,x)}return o}function s(o,c,m,v,p){var h=p===v-1,y=c.dimension(p);h?y.forEach(function(b,A){mr(b),o[b]=m[A[0]]}):y.forEach(function(b,A){mr(b),s(o[b],c,m[A[0]],v,p+1)})}t.prototype.resize=function(o,c,m){if(!Lt(o))throw new TypeError("Array or Matrix expected");var v=o.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),p=m?this.clone():this;return f(p,v,c)};function f(o,c,m){if(c.length===0){for(var v=o._data;ur(v);)v=v[0];return v}return o._size=c.slice(0),o._data=Gn(o._data,o._size,m),o}t.prototype.reshape=function(o,c){var m=c?this.clone():this;m._data=ll(m._data,o);var v=m._size.reduce((p,h)=>p*h);return m._size=Vo(o,v),m};function l(o,c,m){for(var v=o._size.slice(0),p=!1;v.length<c.length;)v.push(0),p=!0;for(var h=0,y=c.length;h<y;h++)c[h]>v[h]&&(v[h]=c[h],p=!0);p&&f(o,v,m)}t.prototype.clone=function(){var o=new t({data:ke(this._data),size:ke(this._size),datatype:this._datatype});return o},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(o){var c=this,m=ln(o),v=function y(b,A){return ur(b)?b.map(function(d,w){return y(d,A.concat(w))}):m===1?o(b):m===2?o(b,A):o(b,A,c)},p=v(this._data,[]),h=this._datatype!==void 0?qa(p,gr):void 0;return new t(p,h)},t.prototype.forEach=function(o){var c=this,m=function v(p,h){ur(p)?p.forEach(function(y,b){v(y,h.concat(b))}):o(p,h,c)};m(this._data,[])},t.prototype[Symbol.iterator]=function*(){var o=function*c(m,v){if(ur(m))for(var p=0;p<m.length;p++)yield*c(m[p],v.concat(p));else yield{value:m,index:v}};yield*o(this._data,[])},t.prototype.rows=function(){var o=[],c=this.size();if(c.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var v of m)o.push(new t([v],this._datatype));return o},t.prototype.columns=function(){var o=this,c=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var v=this._data,p=function(b){var A=v.map(d=>[d[b]]);c.push(new t(A,o._datatype))},h=0;h<m[1];h++)p(h);return c},t.prototype.toArray=function(){return ke(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(o){return Ye(this._data,o)},t.prototype.toString=function(){return Ye(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(o){if(o){if(rr(o)&&(o=o.toNumber()),!tr(o)||!qe(o))throw new TypeError("The parameter k must be an integer number")}else o=0;for(var c=o>0?o:0,m=o<0?-o:0,v=this._size[0],p=this._size[1],h=Math.min(v-m,p-c),y=[],b=0;b<h;b++)y[b]=this._data[b+m][b+c];return new t({data:y,size:[h],datatype:this._datatype})},t.diagonal=function(o,c,m,v){if(!ur(o))throw new TypeError("Array expected, size parameter");if(o.length!==2)throw new Error("Only two dimensions matrix are supported");if(o=o.map(function(E){if(rr(E)&&(E=E.toNumber()),!tr(E)||!qe(E)||E<1)throw new Error("Size values must be positive integers");return E}),m){if(rr(m)&&(m=m.toNumber()),!tr(m)||!qe(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var p=m>0?m:0,h=m<0?-m:0,y=o[0],b=o[1],A=Math.min(y-h,b-p),d;if(ur(c)){if(c.length!==A)throw new Error("Invalid value array length");d=function(N){return c[N]}}else if(He(c)){var w=c.size();if(w.length!==1||w[0]!==A)throw new Error("Invalid matrix length");d=function(N){return c.get([N])}}else d=function(){return c};v||(v=rr(d(0))?d(0).mul(0):0);var x=[];if(o.length>0){x=Gn(x,o,v);for(var g=0;g<A;g++)x[g+h][g+p]=d(g)}return new t({data:x,size:[y,b]})},t.fromJSON=function(o){return new t(o)},t.prototype.swapRows=function(o,c){if(!tr(o)||!qe(o)||!tr(c)||!qe(c))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return mr(o,this._size[0]),mr(c,this._size[0]),t._swapRows(o,c,this._data),this},t._swapRows=function(o,c,m){var v=m[o];m[o]=m[c],m[c]=v};function u(o){for(var c=0,m=o.length;c<m;c++){var v=o[c];ur(v)?o[c]=u(v):v&&v.isMatrix===!0&&(o[c]=u(v.valueOf()))}return o}return t},{isClass:!0}),Rl="clone",D1=["typed"],A1=R(Rl,D1,r=>{var{typed:e}=r;return e(Rl,{any:ke})});function ql(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var s=[];for(a=0;a<e;a++)s.push(r[a][n]);i.push(s)}return i}function Qn(r){for(var e=0;e<r.length;e++)if(Lt(r[e]))return!0;return!1}function Gt(r,e){He(r)&&(r=r.valueOf());for(var t=0,a=r.length;t<a;t++){var n=r[t];Array.isArray(n)?Gt(n,e):e(n)}}function je(r,e,t){return r&&typeof r.map=="function"?r.map(function(a){return je(a,e)}):e(r)}function wi(r,e,t){var a=Array.isArray(r)?er(r):r.size();if(e<0||e>=a.length)throw new pt(e,a.length);return He(r)?r.create(Ni(r.valueOf(),e,t)):Ni(r,e,t)}function Ni(r,e,t){var a,n,i,s;if(e<=0)if(Array.isArray(r[0])){for(s=ql(r),n=[],a=0;a<s.length;a++)n[a]=Ni(s[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]=Ni(r[a],e-1,t);return n}}function zl(r,e,t,a,n,i,s,f,l,u,o){var c=r._values,m=r._index,v=r._ptr,p,h,y,b;if(a)for(h=v[e],y=v[e+1],p=h;p<y;p++)b=m[p],t[b]!==i?(t[b]=i,s.push(b),u?(a[b]=l?f(c[p],o):f(o,c[p]),n[b]=i):a[b]=c[p]):(a[b]=l?f(c[p],a[b]):f(a[b],c[p]),n[b]=i);else for(h=v[e],y=v[e+1],p=h;p<y;p++)b=m[p],t[b]!==i?(t[b]=i,s.push(b)):n[b]=i}var Pl="isInteger",E1=["typed"],S1=R(Pl,E1,r=>{var{typed:e}=r;return e(Pl,{number:qe,BigNumber:function(a){return a.isInt()},Fraction:function(a){return a.d===1&&isFinite(a.n)},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),gt="number",Cn="number, number";function Ll(r){return Math.abs(r)}Ll.signature=gt;function Ul(r,e){return r+e}Ul.signature=Cn;function kl(r,e){return r*e}kl.signature=Cn;function Vl(r){return-r}Vl.signature=gt;function Gl(r){return r}Gl.signature=gt;function La(r){return T0(r)}La.signature=gt;function Hl(r){return r*r*r}Hl.signature=gt;function Zl(r){return Math.exp(r)}Zl.signature=gt;function Jl(r){return B0(r)}Jl.signature=gt;function Wl(r,e){if(!qe(r)||!qe(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}Wl.signature=Cn;function Xl(r,e){if(!qe(r)||!qe(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)}Xl.signature=Cn;function C1(r,e){return e?Math.log(r)/Math.log(e):Math.log(r)}function Yl(r){return M0(r)}Yl.signature=gt;function Ql(r){return C0(r)}Ql.signature=gt;function Kl(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")}Kl.signature=Cn;function jl(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 ts(r){return tn(r)}ts.signature=gt;function ec(r){return r*r}ec.signature=gt;function rc(r,e){var t,a,n,i=0,s=1,f=1,l=0;if(!qe(r)||!qe(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=s-a*i,s=t,t=f,f=l-a*f,l=t,r=e,e=n;var u;return r<0?u=[-r,-s,-l]:u=[r,r?s:0,l],u}rc.signature=Cn;function tc(r,e){return r*r<1&&e===1/0||r*r>1&&e===-1/0?0:Math.pow(r,e)}tc.signature=Cn;function nc(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!qe(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(nl(r,e))}var M1="number",Kn="number, number";function ac(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitAnd");return r&e}ac.signature=Kn;function ic(r){if(!qe(r))throw new Error("Integer expected in function bitNot");return~r}ic.signature=M1;function oc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitOr");return r|e}oc.signature=Kn;function sc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function bitXor");return r^e}sc.signature=Kn;function uc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function leftShift");return r<<e}uc.signature=Kn;function lc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightArithShift");return r>>e}lc.signature=Kn;function cc(r,e){if(!qe(r)||!qe(e))throw new Error("Integers expected in function rightLogShift");return r>>>e}cc.signature=Kn;function Ht(r,e){if(e<r)return 1;if(e===r)return e;var t=e+r>>1;return Ht(r,t)*Ht(t+1,e)}function fc(r,e){if(!qe(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!qe(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,s=e<t?e:t,f=n;f<=r;++f)for(a*=f;i<=s&&a%i===0;)a/=i,++i;return i<=s&&(a/=Ht(i,s)),a}fc.signature="number, number";var F1=Math.PI,T1=2*Math.PI,B1=Math.E,$1=1.618033988749895,O1="number",ns="number, number";function mc(r){return!r}mc.signature=O1;function vc(r,e){return!!(r||e)}vc.signature=ns;function pc(r,e){return!!r!=!!e}pc.signature=ns;function hc(r,e){return!!(r&&e)}hc.signature=ns;function Di(r){var e;if(qe(r))return r<=0?isFinite(r)?1/0:NaN:r>171?1/0:Ht(1,r-1);if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*Di(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=jn[0];for(var s=1;s<jn.length;++s)e+=jn[s]/(r+s);var f=r+dc+.5;return Math.sqrt(2*Math.PI)*Math.pow(f,r+.5)*Math.exp(-f)*e}Di.signature="number";var dc=4.7421875,jn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],gc=.9189385332046728,_1=5,I1=7,yc=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Ai(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))-Ai(1-r);r=r-1;for(var e=r+_1+.5,t=yc[0],a=I1-1;a>=1;a--)t+=yc[a]/(r+a);return gc+(r+.5)*Math.log(e)-e+Math.log(t)}Ai.signature="number";var Gr="number";function bc(r){return R0(r)}bc.signature=Gr;function xc(r){return Math.atan(1/r)}xc.signature=Gr;function wc(r){return isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0}wc.signature=Gr;function Nc(r){return Math.asin(1/r)}Nc.signature=Gr;function Dc(r){var e=1/r;return Math.log(e+Math.sqrt(e*e+1))}Dc.signature=Gr;function Ac(r){return Math.acos(1/r)}Ac.signature=Gr;function Ec(r){var e=1/r,t=Math.sqrt(e*e-1);return Math.log(t+e)}Ec.signature=Gr;function Sc(r){return q0(r)}Sc.signature=Gr;function Cc(r){return z0(r)}Cc.signature=Gr;function Mc(r){return 1/Math.tan(r)}Mc.signature=Gr;function Fc(r){var e=Math.exp(2*r);return(e+1)/(e-1)}Fc.signature=Gr;function Tc(r){return 1/Math.sin(r)}Tc.signature=Gr;function Bc(r){return r===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*tn(r)}Bc.signature=Gr;function $c(r){return 1/Math.cos(r)}$c.signature=Gr;function Oc(r){return 2/(Math.exp(r)+Math.exp(-r))}Oc.signature=Gr;function _c(r){return L0(r)}_c.signature=Gr;var Ei="number";function Ic(r){return r<0}Ic.signature=Ei;function Rc(r){return r>0}Rc.signature=Ei;function qc(r){return r===0}qc.signature=Ei;function zc(r){return Number.isNaN(r)}zc.signature=Ei;var Pc="isNegative",R1=["typed"],q1=R(Pc,R1,r=>{var{typed:e}=r;return e(Pc,{number:Ic,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s<0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Lc="isNumeric",z1=["typed"],P1=R(Lc,z1,r=>{var{typed:e}=r;return e(Lc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Uc="hasNumericValue",L1=["typed","isNumeric"],U1=R(Uc,L1,r=>{var{typed:e,isNumeric:t}=r;return e(Uc,{boolean:()=>!0,string:function(n){return n.trim().length>0&&!isNaN(Number(n))},any:function(n){return t(n)}})}),kc="isPositive",k1=["typed"],V1=R(kc,k1,r=>{var{typed:e}=r;return e(kc,{number:Rc,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s>0&&a.n>0},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Vc="isZero",G1=["typed"],H1=R(Vc,G1,r=>{var{typed:e}=r;return e(Vc,{number:qc,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:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Gc="isNaN",Z1=["typed"],J1=R(Gc,Z1,r=>{var{typed:e}=r;return e(Gc,{number:zc,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 je(a,Number.isNaN)}})}),Hc="typeOf",W1=["typed"],X1=R(Hc,W1,r=>{var{typed:e}=r;return e(Hc,{any:gr})});function Ct(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 Y1(r,e,t){return et(r.re,e.re,t)&&et(r.im,e.im,t)}var ea=R("compareUnits",["typed"],r=>{var{typed:e}=r;return{"Unit, Unit":e.referToSelf(t=>(a,n)=>{if(!a.equalBase(n))throw new Error("Cannot compare units with different base");return e.find(t,[a.valueType(),n.valueType()])(a.value,n.value)})}}),Si="equalScalar",Q1=["typed","config"],K1=R(Si,Q1,r=>{var{typed:e,config:t}=r,a=ea({typed:e});return e(Si,{"boolean, boolean":function(i,s){return i===s},"number, number":function(i,s){return et(i,s,t.epsilon)},"BigNumber, BigNumber":function(i,s){return i.eq(s)||Ct(i,s,t.epsilon)},"Fraction, Fraction":function(i,s){return i.equals(s)},"Complex, Complex":function(i,s){return Y1(i,s,t.epsilon)}},a)});R(Si,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Si,{"number, number":function(n,i){return et(n,i,t.epsilon)}})});var j1="SparseMatrix",ey=["typed","equalScalar","Matrix"],ry=R(j1,ey,r=>{var{typed:e,equalScalar:t,Matrix:a}=r;function n(h,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!Wr(y))throw new Error("Invalid datatype: "+y);if(He(h))i(this,h,y);else if(h&&ur(h.index)&&ur(h.ptr)&&ur(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=y||h.datatype;else if(ur(h))s(this,h,y);else{if(h)throw new TypeError("Unsupported type of data ("+gr(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function i(h,y,b){y.type==="SparseMatrix"?(h._values=y._values?ke(y._values):void 0,h._index=ke(y._index),h._ptr=ke(y._ptr),h._size=ke(y._size),h._datatype=b||y._datatype):s(h,y.valueOf(),b||y._datatype)}function s(h,y,b){h._values=[],h._index=[],h._ptr=[],h._datatype=b;var A=y.length,d=0,w=t,x=0;if(Wr(b)&&(w=e.find(t,[b,b])||t,x=e.convert(0,b)),A>0){var g=0;do{h._ptr.push(h._index.length);for(var E=0;E<A;E++){var N=y[E];if(ur(N)){if(g===0&&d<N.length&&(d=N.length),g<N.length){var S=N[g];w(S,x)||(h._values.push(S),h._index.push(E))}}else g===0&&d<1&&(d=1),w(N,x)||(h._values.push(N),h._index.push(E))}g++}while(g<d)}h._ptr.push(h._index.length),h._size=[A,d]}n.prototype=new a,n.prototype.createSparseMatrix=function(h,y){return new n(h,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return qa(this._values,gr)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(h,y){return new n(h,y)},n.prototype.density=function(){var h=this._size[0],y=this._size[1];return h!==0&&y!==0?this._index.length/(h*y):0},n.prototype.subset=function(h,y,b){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return f(this,h);case 2:case 3:return l(this,h,y,b);default:throw new SyntaxError("Wrong number of arguments")}};function f(h,y){if(!ai(y))throw new TypeError("Invalid index");var b=y.isScalar();if(b)return h.get(y.min());var A=y.size();if(A.length!==h._size.length)throw new Ke(A.length,h._size.length);var d,w,x,g,E=y.min(),N=y.max();for(d=0,w=h._size.length;d<w;d++)mr(E[d],h._size[d]),mr(N[d],h._size[d]);var S=h._values,D=h._index,T=h._ptr,B=y.dimension(0),_=y.dimension(1),L=[],G=[];B.forEach(function($,U){G[$]=U[0],L[$]=!0});var C=S?[]:void 0,F=[],Z=[];return _.forEach(function($){for(Z.push(F.length),x=T[$],g=T[$+1];x<g;x++)d=D[x],L[d]===!0&&(F.push(G[d]),C&&C.push(S[x]))}),Z.push(F.length),new n({values:C,index:F,ptr:Z,size:A,datatype:h._datatype})}function l(h,y,b,A){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var d=y.size(),w=y.isScalar(),x;if(He(b)?(x=b.size(),b=b.toArray()):x=er(b),w){if(x.length!==0)throw new TypeError("Scalar expected");h.set(y.min(),b,A)}else{if(d.length!==1&&d.length!==2)throw new Ke(d.length,h._size.length,"<");if(x.length<d.length){for(var g=0,E=0;d[g]===1&&x[g]===1;)g++;for(;d[g]===1;)E++,g++;b=ml(b,d.length,E,x)}if(!Ra(d,x))throw new Ke(d,x,">");if(d.length===1){var N=y.dimension(0);N.forEach(function(T,B){mr(T),h.set([T,0],b[B[0]],A)})}else{var S=y.dimension(0),D=y.dimension(1);S.forEach(function(T,B){mr(T),D.forEach(function(_,L){mr(_),h.set([T,_],b[B[0]][L[0]],A)})})}}return h}n.prototype.get=function(h){if(!ur(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Ke(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=h[0],b=h[1];mr(y,this._size[0]),mr(b,this._size[1]);var A=u(y,this._ptr[b],this._ptr[b+1],this._index);return A<this._ptr[b+1]&&this._index[A]===y?this._values[A]:0},n.prototype.set=function(h,y,b){if(!ur(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Ke(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var A=h[0],d=h[1],w=this._size[0],x=this._size[1],g=t,E=0;Wr(this._datatype)&&(g=e.find(t,[this._datatype,this._datatype])||t,E=e.convert(0,this._datatype)),(A>w-1||d>x-1)&&(m(this,Math.max(A+1,w),Math.max(d+1,x),b),w=this._size[0],x=this._size[1]),mr(A,w),mr(d,x);var N=u(A,this._ptr[d],this._ptr[d+1],this._index);return N<this._ptr[d+1]&&this._index[N]===A?g(y,E)?o(N,d,this._values,this._index,this._ptr):this._values[N]=y:c(N,A,d,y,this._values,this._index,this._ptr),this};function u(h,y,b,A){if(b-y===0)return b;for(var d=y;d<b;d++)if(A[d]===h)return d;return y}function o(h,y,b,A,d){b.splice(h,1),A.splice(h,1);for(var w=y+1;w<d.length;w++)d[w]--}function c(h,y,b,A,d,w,x){d.splice(h,0,A),w.splice(h,0,y);for(var g=b+1;g<x.length;g++)x[g]++}n.prototype.resize=function(h,y,b){if(!Lt(h))throw new TypeError("Array or Matrix expected");var A=h.valueOf().map(w=>Array.isArray(w)&&w.length===1?w[0]:w);if(A.length!==2)throw new Error("Only two dimensions matrix are supported");A.forEach(function(w){if(!tr(w)||!qe(w)||w<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(A)+")")});var d=b?this.clone():this;return m(d,A[0],A[1],y)};function m(h,y,b,A){var d=A||0,w=t,x=0;Wr(h._datatype)&&(w=e.find(t,[h._datatype,h._datatype])||t,x=e.convert(0,h._datatype),d=e.convert(d,h._datatype));var g=!w(d,x),E=h._size[0],N=h._size[1],S,D,T;if(b>N){for(D=N;D<b;D++)if(h._ptr[D]=h._values.length,g)for(S=0;S<E;S++)h._values.push(d),h._index.push(S);h._ptr[b]=h._values.length}else b<N&&(h._ptr.splice(b+1,N-b),h._values.splice(h._ptr[b],h._values.length),h._index.splice(h._ptr[b],h._index.length));if(N=b,y>E){if(g){var B=0;for(D=0;D<N;D++){h._ptr[D]=h._ptr[D]+B,T=h._ptr[D+1]+B;var _=0;for(S=E;S<y;S++,_++)h._values.splice(T+_,0,d),h._index.splice(T+_,0,S),B++}h._ptr[N]=h._values.length}}else if(y<E){var L=0;for(D=0;D<N;D++){h._ptr[D]=h._ptr[D]-L;var G=h._ptr[D],C=h._ptr[D+1]-L;for(T=G;T<C;T++)S=h._index[T],S>y-1&&(h._values.splice(T,1),h._index.splice(T,1),L++)}h._ptr[D]=h._values.length}return h._size[0]=y,h._size[1]=b,h}n.prototype.reshape=function(h,y){if(!ur(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(!tr($)||!qe($)||$<=-2||$===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ye(h)+")")});var b=this._size[0]*this._size[1];h=Vo(h,b);var A=h[0]*h[1];if(b!==A)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var d=y?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return d;for(var w=[],x=0;x<d._ptr.length;x++)for(var g=0;g<d._ptr[x+1]-d._ptr[x];g++)w.push(x);for(var E=d._values.slice(),N=d._index.slice(),S=0;S<d._index.length;S++){var D=N[S],T=w[S],B=D*d._size[1]+T;w[S]=B%h[1],N[S]=Math.floor(B/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 L=0;L<E.length;L++){var G=N[L],C=w[L],F=E[L],Z=u(G,d._ptr[C],d._ptr[C+1],d._index);c(Z,G,C,F,d._values,d._index,d._ptr)}return d},n.prototype.clone=function(){var h=new n({values:this._values?ke(this._values):void 0,index:ke(this._index),ptr:ke(this._ptr),size:ke(this._size),datatype:this._datatype});return h},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(h,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var b=this,A=this._size[0],d=this._size[1],w=ln(h),x=function(E,N,S){return w===1?h(E):w===2?h(E,[N,S]):h(E,[N,S],b)};return v(this,0,A-1,0,d-1,x,y)};function v(h,y,b,A,d,w,x){var g=[],E=[],N=[],S=t,D=0;Wr(h._datatype)&&(S=e.find(t,[h._datatype,h._datatype])||t,D=e.convert(0,h._datatype));for(var T=function(P,K,ne){P=w(P,K,ne),S(P,D)||(g.push(P),E.push(K))},B=A;B<=d;B++){N.push(g.length);var _=h._ptr[B],L=h._ptr[B+1];if(x)for(var G=_;G<L;G++){var C=h._index[G];C>=y&&C<=b&&T(h._values[G],C-y,B-A)}else{for(var F={},Z=_;Z<L;Z++){var $=h._index[Z];F[$]=h._values[Z]}for(var U=y;U<=b;U++){var Y=U in F?F[U]:0;T(Y,U-y,B-A)}}}return N.push(g.length),new n({values:g,index:E,ptr:N,size:[b-y+1,d-A+1]})}n.prototype.forEach=function(h,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var b=this,A=this._size[0],d=this._size[1],w=0;w<d;w++){var x=this._ptr[w],g=this._ptr[w+1];if(y)for(var E=x;E<g;E++){var N=this._index[E];h(this._values[E],[N,w],b)}else{for(var S={},D=x;D<g;D++){var T=this._index[D];S[T]=this._values[D]}for(var B=0;B<A;B++){var _=B in S?S[B]:0;h(_,[B,w],b)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],y=0;y<h;y++)for(var b=this._ptr[y],A=this._ptr[y+1],d=b;d<A;d++){var w=this._index[d];yield{value:this._values[d],index:[w,y]}}},n.prototype.toArray=function(){return p(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return p(this._values,this._index,this._ptr,this._size,!1)};function p(h,y,b,A,d){var w=A[0],x=A[1],g=[],E,N;for(E=0;E<w;E++)for(g[E]=[],N=0;N<x;N++)g[E][N]=0;for(N=0;N<x;N++)for(var S=b[N],D=b[N+1],T=S;T<D;T++)E=y[T],g[E][N]=h?d?ke(h[T]):h[T]:1;return g}return n.prototype.format=function(h){for(var y=this._size[0],b=this._size[1],A=this.density(),d="Sparse Matrix ["+Ye(y,h)+" x "+Ye(b,h)+"] density: "+Ye(A,h)+`
|
|
28
|
+
`,w=0;w<b;w++)for(var x=this._ptr[w],g=this._ptr[w+1],E=x;E<g;E++){var N=this._index[E];d+=`
|
|
29
|
+
(`+Ye(N,h)+", "+Ye(w,h)+") ==> "+(this._values?Ye(this._values[E],h):"X")}return d},n.prototype.toString=function(){return Ye(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(rr(h)&&(h=h.toNumber()),!tr(h)||!qe(h))throw new TypeError("The parameter k must be an integer number")}else h=0;var y=h>0?h:0,b=h<0?-h:0,A=this._size[0],d=this._size[1],w=Math.min(A-b,d-y),x=[],g=[],E=[];E[0]=0;for(var N=y;N<d&&x.length<w;N++)for(var S=this._ptr[N],D=this._ptr[N+1],T=S;T<D;T++){var B=this._index[T];if(B===N-y+b){x.push(this._values[T]),g[x.length-1]=B-b;break}}return E.push(x.length),new n({values:x,index:g,ptr:E,size:[w,1]})},n.fromJSON=function(h){return new n(h)},n.diagonal=function(h,y,b,A,d){if(!ur(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(rr($)&&($=$.toNumber()),!tr($)||!qe($)||$<1)throw new Error("Size values must be positive integers");return $}),b){if(rr(b)&&(b=b.toNumber()),!tr(b)||!qe(b))throw new TypeError("The parameter k must be an integer number")}else b=0;var w=t,x=0;Wr(d)&&(w=e.find(t,[d,d])||t,x=e.convert(0,d));var g=b>0?b:0,E=b<0?-b:0,N=h[0],S=h[1],D=Math.min(N-E,S-g),T;if(ur(y)){if(y.length!==D)throw new Error("Invalid value array length");T=function(U){return y[U]}}else if(He(y)){var B=y.size();if(B.length!==1||B[0]!==D)throw new Error("Invalid matrix length");T=function(U){return y.get([U])}}else T=function(){return y};for(var _=[],L=[],G=[],C=0;C<S;C++){G.push(_.length);var F=C-g;if(F>=0&&F<D){var Z=T(F);w(Z,x)||(L.push(F+E),_.push(Z))}}return G.push(_.length),new n({values:_,index:L,ptr:G,size:[N,S]})},n.prototype.swapRows=function(h,y){if(!tr(h)||!qe(h)||!tr(y)||!qe(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return mr(h,this._size[0]),mr(y,this._size[0]),n._swapRows(h,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(h,y,b,A,d){for(var w=A[h],x=A[h+1],g=w;g<x;g++)d(b[g],y[g])},n._swapRows=function(h,y,b,A,d,w){for(var x=0;x<b;x++){var g=w[x],E=w[x+1],N=u(h,g,E,d),S=u(y,g,E,d);if(N<E&&S<E&&d[N]===h&&d[S]===y){if(A){var D=A[N];A[N]=A[S],A[S]=D}continue}if(N<E&&d[N]===h&&(S>=E||d[S]!==y)){var T=A?A[N]:void 0;d.splice(S,0,y),A&&A.splice(S,0,T),d.splice(S<=N?N+1:N,1),A&&A.splice(S<=N?N+1:N,1);continue}if(S<E&&d[S]===y&&(N>=E||d[N]!==h)){var B=A?A[S]:void 0;d.splice(N,0,h),A&&A.splice(N,0,B),d.splice(N<=S?S+1:S,1),A&&A.splice(N<=S?S+1:S,1)}}},n},{isClass:!0}),ty="number",ny=["typed"];function ay(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 iy(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 oy=R(ty,ny,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=ay(n);if(i)return iy(i);var s=0,f=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);f&&(s=Number(f[2]),n=f[1]);var l=Number(n);if(isNaN(l))throw new SyntaxError('String "'+n+'" is no valid number');if(f){if(l>2**s-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));l>=2**(s-1)&&(l=l-2**s)}return l},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":e.referToSelf(a=>n=>je(n,a))});return t.fromJSON=function(a){return parseFloat(a.value)},t}),Zc="string",sy=["typed"],uy=R(Zc,sy,r=>{var{typed:e}=r;return e(Zc,{"":function(){return""},number:En,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":e.referToSelf(t=>a=>je(a,t)),any:function(a){return String(a)}})}),Jc="boolean",ly=["typed"],cy=R(Jc,ly,r=>{var{typed:e}=r;return e(Jc,{"":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":e.referToSelf(t=>a=>je(a,t))})}),fy="bignumber",my=["typed","BigNumber"],vy=R(fy,my,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 s=i[2],f=t(i[1]),l=new t(2).pow(Number(s));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var u=new t(2).pow(Number(s)-1);return f.gte(u)?f.sub(l):f}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":e.referToSelf(a=>n=>je(n,a))})}),py="complex",hy=["typed","Complex"],dy=R(py,hy,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":e.referToSelf(a=>n=>je(n,a))})}),gy="fraction",yy=["typed","Fraction"],by=R(gy,yy,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":e.referToSelf(a=>n=>je(n,a))})}),Wc="matrix",xy=["typed","Matrix","DenseMatrix","SparseMatrix"],wy=R(Wc,xy,r=>{var{typed:e,Matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(Wc,{"":function(){return i([])},string:function(f){return i([],f)},"string, string":function(f,l){return i([],f,l)},Array:function(f){return i(f)},Matrix:function(f){return i(f,f.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(s,f,l){if(f==="dense"||f==="default"||f===void 0)return new a(s,l);if(f==="sparse")return new n(s,l);throw new TypeError("Unknown matrix type "+JSON.stringify(f)+".")}}),Xc="matrixFromFunction",Ny=["typed","matrix","isZero"],Dy=R(Xc,Ny,r=>{var{typed:e,matrix:t,isZero:a}=r;return e(Xc,{"Array | Matrix, function, string, string":function(s,f,l,u){return n(s,f,l,u)},"Array | Matrix, function, string":function(s,f,l){return n(s,f,l)},"Matrix, function":function(s,f){return n(s,f,"dense")},"Array, function":function(s,f){return n(s,f,"dense").toArray()},"Array | Matrix, string, function":function(s,f,l){return n(s,l,f)},"Array | Matrix, string, string, function":function(s,f,l,u){return n(s,u,f,l)}});function n(i,s,f,l){var u;return l!==void 0?u=t(f,l):u=t(f),u.resize(i),u.forEach(function(o,c){var m=s(c);a(m)||u.set(c,m)}),u}}),Yc="matrixFromRows",Ay=["typed","matrix","flatten","size"],Ey=R(Yc,Ay,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(Yc,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var l=s(f[0]),u=[];for(var o of f){var c=s(o);if(c!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(c|0));u.push(a(o))}return u}function s(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[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.")}}),Qc="matrixFromColumns",Sy=["typed","matrix","flatten","size"],Cy=R(Qc,Sy,r=>{var{typed:e,matrix:t,flatten:a,size:n}=r;return e(Qc,{"...Array":function(l){return i(l)},"...Matrix":function(l){return t(i(l.map(u=>u.toArray())))}});function i(f){if(f.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var l=s(f[0]),u=[],o=0;o<l;o++)u[o]=[];for(var c of f){var m=s(c);if(m!==l)throw new TypeError("The vectors had different length: "+(l|0)+" \u2260 "+(m|0));for(var v=a(c),p=0;p<l;p++)u[p].push(v[p])}return u}function s(f){var l=n(f);if(l.length===1)return l[0];if(l.length===2){if(l[0]===1)return l[1];if(l[1]===1)return l[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.")}}),Kc="splitUnit",My=["typed"],Fy=R(Kc,My,r=>{var{typed:e}=r;return e(Kc,{"Unit, Array":function(a,n){return a.splitUnit(n)}})}),jc="unaryMinus",Ty=["typed"],By=R(jc,Ty,r=>{var{typed:e}=r;return e(jc,{number:Vl,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>a=>{var n=a.clone();return n.value=e.find(t,n.valueType())(a.value),n}),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),ef="unaryPlus",$y=["typed","config","BigNumber"],Oy=R(ef,$y,r=>{var{typed:e,config:t,BigNumber:a}=r;return e(ef,{number:Gl,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":e.referToSelf(n=>i=>je(i,n)),"boolean | string":function(i){return t.number==="BigNumber"?new a(+i):+i}})}),rf="abs",_y=["typed"],Iy=R(rf,_y,r=>{var{typed:e}=r;return e(rf,{number:Ll,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),tf="apply",Ry=["typed","isInteger"],nf=R(tf,Ry,r=>{var{typed:e,isInteger:t}=r;return e(tf,{"Array | Matrix, number | BigNumber, function":function(n,i,s){if(!t(i))throw new TypeError("Integer number expected for dimension");var f=Array.isArray(n)?er(n):n.size();if(i<0||i>=f.length)throw new pt(i,f.length);return He(n)?n.create(Ci(n.valueOf(),i,s)):Ci(n,i,s)}})});function Ci(r,e,t){var a,n,i;if(e<=0)if(Array.isArray(r[0])){for(i=qy(r),n=[],a=0;a<i.length;a++)n[a]=Ci(i[a],e-1,t);return n}else return t(r);else{for(n=[],a=0;a<r.length;a++)n[a]=Ci(r[a],e-1,t);return n}}function qy(r){var e=r.length,t=r[0].length,a,n,i=[];for(n=0;n<t;n++){var s=[];for(a=0;a<e;a++)s.push(r[a][n]);i.push(s)}return i}var af="addScalar",zy=["typed"],Py=R(af,zy,r=>{var{typed:e}=r;return e(af,{"number, number":Ul,"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":e.referToSelf(t=>(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=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),of="cbrt",Ly=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],Uy=R(of,Ly,r=>{var{config:e,typed:t,isNegative:a,unaryMinus:n,matrix:i,Complex:s,BigNumber:f,Fraction:l}=r;return t(of,{number:La,Complex:u,"Complex, boolean":u,BigNumber:function(m){return m.cbrt()},Unit:o});function u(c,m){var v=c.arg()/3,p=c.abs(),h=new s(La(p),0).mul(new s(0,v).exp());if(m){var y=[h,new s(La(p),0).mul(new s(0,v+Math.PI*2/3).exp()),new s(La(p),0).mul(new s(0,v-Math.PI*2/3).exp())];return e.matrix==="Array"?y:i(y)}else return h}function o(c){if(c.value&&zt(c.value)){var m=c.clone();return m.value=1,m=m.pow(1/3),m.value=u(c.value),m}else{var v=a(c.value);v&&(c.value=n(c.value));var p;rr(c.value)?p=new f(1).div(3):_a(c.value)?p=new l(1,3):p=1/3;var h=c.pow(p);return v&&(h.value=n(h.value)),h}}}),ky="matAlgo11xS0s",Vy=["typed","equalScalar"],Lr=R(ky,Vy,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s,f){var l=n._values,u=n._index,o=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],p=c[1],h,y=t,b=0,A=s;typeof m=="string"&&(h=m,y=e.find(t,[h,h]),b=e.convert(0,h),i=e.convert(i,h),A=e.find(s,[h,h]));for(var d=[],w=[],x=[],g=0;g<p;g++){x[g]=w.length;for(var E=o[g],N=o[g+1],S=E;S<N;S++){var D=u[S],T=f?A(i,l[S]):A(l[S],i);y(T,b)||(w.push(D),d.push(T))}}return x[p]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,p],datatype:h})}}),Gy="matAlgo12xSfs",Hy=["typed","DenseMatrix"],Br=R(Gy,Hy,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,s,f){var l=n._values,u=n._index,o=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],p=c[1],h,y=s;typeof m=="string"&&(h=m,i=e.convert(i,h),y=e.find(s,[h,h]));for(var b=[],A=[],d=[],w=0;w<p;w++){for(var x=w+1,g=o[w],E=o[w+1],N=g;N<E;N++){var S=u[N];A[S]=l[N],d[S]=x}for(var D=0;D<v;D++)w===0&&(b[D]=[]),d[D]===x?b[D][w]=f?y(i,A[D]):y(A[D],i):b[D][w]=f?y(i,0):y(0,i)}return new t({data:b,size:[v,p],datatype:h})}}),Zy="matAlgo14xDs",Jy=["typed"],yt=R(Zy,Jy,r=>{var{typed:e}=r;return function(n,i,s,f){var l=n._data,u=n._size,o=n._datatype,c,m=s;typeof o=="string"&&(c=o,i=e.convert(i,c),m=e.find(s,[c,c]));var v=u.length>0?t(m,0,u,u[0],l,i,f):[];return n.createDenseMatrix({data:v,size:ke(u),datatype:c})};function t(a,n,i,s,f,l,u){var o=[];if(n===i.length-1)for(var c=0;c<s;c++)o[c]=u?a(l,f[c]):a(f[c],l);else for(var m=0;m<s;m++)o[m]=t(a,n+1,i,i[n+1],f[m],l,u);return o}}),as="ceil",Wy=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Xy=R(as,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(as,{number:function(i){return et(i,a(i),t.epsilon)?a(i):Math.ceil(i)},"number, number":function(i,s){if(et(i,a(i,s),t.epsilon))return a(i,s);var[f,l]="".concat(i,"e").split("e"),u=Math.ceil(Number("".concat(f,"e").concat(Number(l)+s)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-s))}})}),Yy=R(as,Wy,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:s,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Br({typed:e,DenseMatrix:f}),o=yt({typed:e}),c=Xy({typed:e,config:t,round:a});return e("ceil",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.ceil()},"Complex, number":function(v,p){return v.ceil(p)},"Complex, BigNumber":function(v,p){return v.ceil(p.toNumber())},BigNumber:function(v){return Ct(v,a(v),t.epsilon)?a(v):v.ceil()},"BigNumber, BigNumber":function(v,p){return Ct(v,a(v,p),t.epsilon)?a(v,p):v.toDecimalPlaces(p.toNumber(),un.ROUND_CEIL)},Fraction:function(v){return v.ceil()},"Fraction, number":function(v,p){return v.ceil(p)},"Fraction, BigNumber":function(v,p){return v.ceil(p.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,p)=>je(v,h=>m(h,p))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>l(v,p,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>o(v,p,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>o(n(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>i(v,0)?s(p.size(),p.storage()):p.storage()==="dense"?o(p,v,m,!0):u(p,v,m,!0))})}),sf="cube",Qy=["typed"],Ky=R(sf,Qy,r=>{var{typed:e}=r;return e(sf,{number:Hl,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)},Unit:function(a){return a.pow(3)}})}),uf="exp",jy=["typed"],eb=R(uf,jy,r=>{var{typed:e}=r;return e(uf,{number:Zl,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()}})}),lf="expm1",rb=["typed","Complex"],tb=R(lf,rb,r=>{var{typed:e,Complex:t}=r;return e(lf,{number:Jl,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)}})}),is="fix",nb=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],ab=R(is,["typed","ceil","floor"],r=>{var{typed:e,ceil:t,floor:a}=r;return e(is,{number:function(i){return i>0?a(i):t(i)},"number, number":function(i,s){return i>0?a(i,s):t(i,s)}})}),ib=R(is,nb,r=>{var{typed:e,Complex:t,matrix:a,ceil:n,floor:i,equalScalar:s,zeros:f,DenseMatrix:l}=r,u=Br({typed:e,DenseMatrix:l}),o=yt({typed:e}),c=ab({typed:e,ceil:n,floor:i});return e("fix",{number:c.signatures.number,"number, number | BigNumber":c.signatures["number,number"],Complex:function(v){return new t(v.re>0?Math.floor(v.re):Math.ceil(v.re),v.im>0?Math.floor(v.im):Math.ceil(v.im))},"Complex, number":function(v,p){return new t(v.re>0?i(v.re,p):n(v.re,p),v.im>0?i(v.im,p):n(v.im,p))},"Complex, BigNumber":function(v,p){var h=p.toNumber();return new t(v.re>0?i(v.re,h):n(v.re,h),v.im>0?i(v.im,h):n(v.im,h))},BigNumber:function(v){return v.isNegative()?n(v):i(v)},"BigNumber, number | BigNumber":function(v,p){return v.isNegative()?n(v,p):i(v,p)},Fraction:function(v){return v.s<0?v.ceil():v.floor()},"Fraction, number | BigNumber":function(v,p){return v.s<0?n(v,p):i(v,p)},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array | Matrix, number | BigNumber":e.referToSelf(m=>(v,p)=>je(v,h=>m(h,p))),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>o(a(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>s(v,0)?f(p.size(),p.storage()):p.storage()==="dense"?o(p,v,m,!0):u(p,v,m,!0))})}),os="floor",ob=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],sb=R(os,["typed","config","round"],r=>{var{typed:e,config:t,round:a}=r;return e(os,{number:function(i){return et(i,a(i),t.epsilon)?a(i):Math.floor(i)},"number, number":function(i,s){if(et(i,a(i,s),t.epsilon))return a(i,s);var[f,l]="".concat(i,"e").split("e"),u=Math.floor(Number("".concat(f,"e").concat(Number(l)+s)));return[f,l]="".concat(u,"e").split("e"),Number("".concat(f,"e").concat(Number(l)-s))}})}),ub=R(os,ob,r=>{var{typed:e,config:t,round:a,matrix:n,equalScalar:i,zeros:s,DenseMatrix:f}=r,l=Lr({typed:e,equalScalar:i}),u=Br({typed:e,DenseMatrix:f}),o=yt({typed:e}),c=sb({typed:e,config:t,round:a});return e("floor",{number:c.signatures.number,"number,number":c.signatures["number,number"],Complex:function(v){return v.floor()},"Complex, number":function(v,p){return v.floor(p)},"Complex, BigNumber":function(v,p){return v.floor(p.toNumber())},BigNumber:function(v){return Ct(v,a(v),t.epsilon)?a(v):v.floor()},"BigNumber, BigNumber":function(v,p){return Ct(v,a(v,p),t.epsilon)?a(v,p):v.toDecimalPlaces(p.toNumber(),un.ROUND_FLOOR)},Fraction:function(v){return v.floor()},"Fraction, number":function(v,p){return v.floor(p)},"Fraction, BigNumber":function(v,p){return v.floor(p.toNumber())},"Array | Matrix":e.referToSelf(m=>v=>je(v,m)),"Array, number | BigNumber":e.referToSelf(m=>(v,p)=>je(v,h=>m(h,p))),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>l(v,p,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(v,p)=>o(v,p,m,!1)),"number | Complex | Fraction | BigNumber, Array":e.referToSelf(m=>(v,p)=>o(n(p),v,m,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":e.referToSelf(m=>(v,p)=>i(v,0)?s(p.size(),p.storage()):p.storage()==="dense"?o(p,v,m,!0):u(p,v,m,!0))})}),lb="matAlgo01xDSid",cb=["typed"],cn=R(lb,cb,r=>{var{typed:e}=r;return function(a,n,i,s){var f=a._data,l=a._size,u=a._datatype,o=n._values,c=n._index,m=n._ptr,v=n._size,p=n._datatype;if(l.length!==v.length)throw new Ke(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 h=l[0],y=l[1],b=typeof u=="string"&&u===p?u:void 0,A=b?e.find(i,[b,b]):i,d,w,x=[];for(d=0;d<h;d++)x[d]=[];var g=[],E=[];for(w=0;w<y;w++){for(var N=w+1,S=m[w],D=m[w+1],T=S;T<D;T++)d=c[T],g[d]=s?A(o[T],f[d][w]):A(f[d][w],o[T]),E[d]=N;for(d=0;d<h;d++)E[d]===N?x[d][w]=g[d]:x[d][w]=f[d][w]}return a.createDenseMatrix({data:x,size:[h,y],datatype:b})}}),fb="matAlgo04xSidSid",mb=["typed","equalScalar"],ss=R(fb,mb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));var E=f&&m?[]:void 0,N=[],S=[],D=f&&m?[]:void 0,T=f&&m?[]:void 0,B=[],_=[],L,G,C,F,Z;for(G=0;G<A;G++){S[G]=N.length;var $=G+1;for(F=u[G],Z=u[G+1],C=F;C<Z;C++)L=l[C],N.push(L),B[L]=$,D&&(D[L]=f[C]);for(F=p[G],Z=p[G+1],C=F;C<Z;C++)if(L=v[C],B[L]===$){if(D){var U=g(D[L],m[C]);w(U,x)?B[L]=null:D[L]=U}}else N.push(L),_[L]=$,T&&(T[L]=m[C]);if(D&&T)for(C=S[G];C<N.length;)L=N[C],B[L]===$?(E[C]=D[L],C++):_[L]===$?(E[C]=T[L],C++):N.splice(C,1)}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),vb="matAlgo10xSids",pb=["typed","DenseMatrix"],Mn=R(vb,pb,r=>{var{typed:e,DenseMatrix:t}=r;return function(n,i,s,f){var l=n._values,u=n._index,o=n._ptr,c=n._size,m=n._datatype;if(!l)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],p=c[1],h,y=s;typeof m=="string"&&(h=m,i=e.convert(i,h),y=e.find(s,[h,h]));for(var b=[],A=[],d=[],w=0;w<p;w++){for(var x=w+1,g=o[w],E=o[w+1],N=g;N<E;N++){var S=u[N];A[S]=l[N],d[S]=x}for(var D=0;D<v;D++)w===0&&(b[D]=[]),d[D]===x?b[D][w]=f?y(i,A[D]):y(A[D],i):b[D][w]=i}return new t({data:b,size:[v,p],datatype:h})}}),hb="matAlgo13xDD",db=["typed"],gb=R(hb,db,r=>{var{typed:e}=r;return function(n,i,s){var f=n._data,l=n._size,u=n._datatype,o=i._data,c=i._size,m=i._datatype,v=[];if(l.length!==c.length)throw new Ke(l.length,c.length);for(var p=0;p<l.length;p++){if(l[p]!==c[p])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");v[p]=l[p]}var h,y=s;typeof u=="string"&&u===m&&(h=u,y=e.find(s,[h,h]));var b=v.length>0?t(y,0,v,v[0],f,o):[];return n.createDenseMatrix({data:b,size:v,datatype:h})};function t(a,n,i,s,f,l){var u=[];if(n===i.length-1)for(var o=0;o<s;o++)u[o]=a(f[o],l[o]);else for(var c=0;c<s;c++)u[c]=t(a,n+1,i,i[n+1],f[c],l[c]);return u}}),yb="matrixAlgorithmSuite",bb=["typed","matrix"],hr=R(yb,bb,r=>{var{typed:e,matrix:t}=r,a=gb({typed:e}),n=yt({typed:e});return function(s){var f=s.elop,l=s.SD||s.DS,u;f?(u={"DenseMatrix, DenseMatrix":(v,p)=>a(v,p,f),"Array, Array":(v,p)=>a(t(v),t(p),f).valueOf(),"Array, DenseMatrix":(v,p)=>a(t(v),p,f),"DenseMatrix, Array":(v,p)=>a(v,t(p),f)},s.SS&&(u["SparseMatrix, SparseMatrix"]=(v,p)=>s.SS(v,p,f,!1)),s.DS&&(u["DenseMatrix, SparseMatrix"]=(v,p)=>s.DS(v,p,f,!1),u["Array, SparseMatrix"]=(v,p)=>s.DS(t(v),p,f,!1)),l&&(u["SparseMatrix, DenseMatrix"]=(v,p)=>l(p,v,f,!0),u["SparseMatrix, Array"]=(v,p)=>l(t(p),v,f,!0))):(u={"DenseMatrix, DenseMatrix":e.referToSelf(v=>(p,h)=>a(p,h,v)),"Array, Array":e.referToSelf(v=>(p,h)=>a(t(p),t(h),v).valueOf()),"Array, DenseMatrix":e.referToSelf(v=>(p,h)=>a(t(p),h,v)),"DenseMatrix, Array":e.referToSelf(v=>(p,h)=>a(p,t(h),v))},s.SS&&(u["SparseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,h)=>s.SS(p,h,v,!1))),s.DS&&(u["DenseMatrix, SparseMatrix"]=e.referToSelf(v=>(p,h)=>s.DS(p,h,v,!1)),u["Array, SparseMatrix"]=e.referToSelf(v=>(p,h)=>s.DS(t(p),h,v,!1))),l&&(u["SparseMatrix, DenseMatrix"]=e.referToSelf(v=>(p,h)=>l(h,p,v,!0)),u["SparseMatrix, Array"]=e.referToSelf(v=>(p,h)=>l(t(h),p,v,!0))));var o=s.scalar||"any",c=s.Ds||s.Ss;c&&(f?(u["DenseMatrix,"+o]=(v,p)=>n(v,p,f,!1),u[o+", DenseMatrix"]=(v,p)=>n(p,v,f,!0),u["Array,"+o]=(v,p)=>n(t(v),p,f,!1).valueOf(),u[o+", Array"]=(v,p)=>n(t(p),v,f,!0).valueOf()):(u["DenseMatrix,"+o]=e.referToSelf(v=>(p,h)=>n(p,h,v,!1)),u[o+", DenseMatrix"]=e.referToSelf(v=>(p,h)=>n(h,p,v,!0)),u["Array,"+o]=e.referToSelf(v=>(p,h)=>n(t(p),h,v,!1).valueOf()),u[o+", Array"]=e.referToSelf(v=>(p,h)=>n(t(h),p,v,!0).valueOf())));var m=s.sS!==void 0?s.sS:s.Ss;return f?(s.Ss&&(u["SparseMatrix,"+o]=(v,p)=>s.Ss(v,p,f,!1)),m&&(u[o+", SparseMatrix"]=(v,p)=>m(p,v,f,!0))):(s.Ss&&(u["SparseMatrix,"+o]=e.referToSelf(v=>(p,h)=>s.Ss(p,h,v,!1))),m&&(u[o+", SparseMatrix"]=e.referToSelf(v=>(p,h)=>m(h,p,v,!0)))),f&&f.signatures&&Qu(u,f.signatures),u}}),cf="gcd",xb=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],wb=R(cf,xb,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i}=r,s=cn({typed:e}),f=ss({typed:e,equalScalar:a}),l=Mn({typed:e,DenseMatrix:i}),u=hr({typed:e,matrix:t}),o="number | BigNumber | Fraction | Matrix | Array",c={};return c["".concat(o,", ").concat(o,", ...").concat(o)]=e.referToSelf(v=>(p,h,y)=>{for(var b=v(p,h),A=0;A<y.length;A++)b=v(b,y[A]);return b}),e(cf,{"number, number":Wl,"BigNumber, BigNumber":m,"Fraction, Fraction":(v,p)=>v.gcd(p)},u({SS:f,DS:s,Ss:l}),c);function m(v,p){if(!v.isInt()||!p.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var h=new n(0);!p.isZero();){var y=v.mod(p);v=p,p=y}return v.lt(h)?v.neg():v}}),Nb="matAlgo02xDS0",Db=["typed","equalScalar"],bt=R(Nb,Db,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s,f){var l=n._data,u=n._size,o=n._datatype,c=i._values,m=i._index,v=i._ptr,p=i._size,h=i._datatype;if(u.length!==p.length)throw new Ke(u.length,p.length);if(u[0]!==p[0]||u[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=u[0],b=u[1],A,d=t,w=0,x=s;typeof o=="string"&&o===h&&(A=o,d=e.find(t,[A,A]),w=e.convert(0,A),x=e.find(s,[A,A]));for(var g=[],E=[],N=[],S=0;S<b;S++){N[S]=E.length;for(var D=v[S],T=v[S+1],B=D;B<T;B++){var _=m[B],L=f?x(c[B],l[_][S]):x(l[_][S],c[B]);d(L,w)||(E.push(_),g.push(L))}}return N[b]=E.length,i.createSparseMatrix({values:g,index:E,ptr:N,size:[y,b],datatype:A})}}),Ab="matAlgo06xS0S0",Eb=["typed","equalScalar"],Mi=R(Ab,Eb,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._size,u=n._datatype,o=i._values,c=i._size,m=i._datatype;if(l.length!==c.length)throw new Ke(l.length,c.length);if(l[0]!==c[0]||l[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");var v=l[0],p=l[1],h,y=t,b=0,A=s;typeof u=="string"&&u===m&&(h=u,y=e.find(t,[h,h]),b=e.convert(0,h),A=e.find(s,[h,h]));for(var d=f&&o?[]:void 0,w=[],x=[],g=d?[]:void 0,E=[],N=[],S=0;S<p;S++){x[S]=w.length;var D=S+1;if(zl(n,S,E,g,N,D,w,A),zl(i,S,E,g,N,D,w,A),g)for(var T=x[S];T<w.length;){var B=w[T];if(N[B]===D){var _=g[B];y(_,b)?w.splice(T,1):(d.push(_),T++)}else w.splice(T,1)}else for(var L=x[S];L<w.length;){var G=w[L];N[G]!==D?w.splice(L,1):L++}}return x[p]=w.length,n.createSparseMatrix({values:d,index:w,ptr:x,size:[v,p],datatype:h})}}),ff="lcm",Sb=["typed","matrix","equalScalar"],Cb=R(ff,Sb,r=>{var{typed:e,matrix:t,equalScalar:a}=r,n=bt({typed:e,equalScalar:a}),i=Mi({typed:e,equalScalar:a}),s=Lr({typed:e,equalScalar:a}),f=hr({typed:e,matrix:t}),l="number | BigNumber | Fraction | Matrix | Array",u={};return u["".concat(l,", ").concat(l,", ...").concat(l)]=e.referToSelf(c=>(m,v,p)=>{for(var h=c(m,v),y=0;y<p.length;y++)h=c(h,p[y]);return h}),e(ff,{"number, number":Xl,"BigNumber, BigNumber":o,"Fraction, Fraction":(c,m)=>c.lcm(m)},f({SS:i,DS:n,Ss:s}),u);function o(c,m){if(!c.isInt()||!m.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(c.isZero())return c;if(m.isZero())return m;for(var v=c.times(m);!m.isZero();){var p=m;m=c.mod(p),c=p}return v.div(c).abs()}}),mf="log10",Mb=["typed","config","Complex"],Fb=R(mf,Mb,r=>{var{typed:e,config:t,Complex:a}=r;return e(mf,{number:function(i){return i>=0||t.predictable?Yl(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":e.referToSelf(n=>i=>je(i,n))})}),vf="log2",Tb=["typed","config","Complex"],Bb=R(vf,Tb,r=>{var{typed:e,config:t,Complex:a}=r;return e(vf,{number:function(s){return s>=0||t.predictable?Ql(s):n(new a(s,0))},Complex:n,BigNumber:function(s){return!s.isNegative()||t.predictable?s.log(2):n(new a(s.toNumber(),0))},"Array | Matrix":e.referToSelf(i=>s=>je(s,i))});function n(i){var s=Math.sqrt(i.re*i.re+i.im*i.im);return new a(Math.log2?Math.log2(s):Math.log(s)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),$b="matAlgo03xDSf",Ob=["typed"],Xr=R($b,Ob,r=>{var{typed:e}=r;return function(a,n,i,s){var f=a._data,l=a._size,u=a._datatype,o=n._values,c=n._index,m=n._ptr,v=n._size,p=n._datatype;if(l.length!==v.length)throw new Ke(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 h=l[0],y=l[1],b,A=0,d=i;typeof u=="string"&&u===p&&(b=u,A=e.convert(0,b),d=e.find(i,[b,b]));for(var w=[],x=0;x<h;x++)w[x]=[];for(var g=[],E=[],N=0;N<y;N++){for(var S=N+1,D=m[N],T=m[N+1],B=D;B<T;B++){var _=c[B];g[_]=s?d(o[B],f[_][N]):d(f[_][N],o[B]),E[_]=S}for(var L=0;L<h;L++)E[L]===S?w[L][N]=g[L]:w[L][N]=s?d(A,f[L][N]):d(f[L][N],A)}return a.createDenseMatrix({data:w,size:[h,y],datatype:b})}}),_b="matAlgo05xSfSf",Ib=["typed","equalScalar"],Fi=R(_b,Ib,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));var E=f&&m?[]:void 0,N=[],S=[],D=E?[]:void 0,T=E?[]:void 0,B=[],_=[],L,G,C,F;for(G=0;G<A;G++){S[G]=N.length;var Z=G+1;for(C=u[G],F=u[G+1];C<F;C++)L=l[C],N.push(L),B[L]=Z,D&&(D[L]=f[C]);for(C=p[G],F=p[G+1];C<F;C++)L=v[C],B[L]!==Z&&N.push(L),_[L]=Z,T&&(T[L]=m[C]);if(E)for(C=S[G];C<N.length;){L=N[C];var $=B[L],U=_[L];if($===Z||U===Z){var Y=$===Z?D[L]:x,j=U===Z?T[L]:x,P=g(Y,j);w(P,x)?N.splice(C,1):(E.push(P),C++)}}}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),pf="mod",Rb=["typed","matrix","equalScalar","DenseMatrix"],qb=R(pf,Rb,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=bt({typed:e,equalScalar:a}),s=Xr({typed:e}),f=Fi({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=Br({typed:e,DenseMatrix:n}),o=hr({typed:e,matrix:t});return e(pf,{"number, number":Kl,"BigNumber, BigNumber":function(m,v){if(v.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return v.isZero()?m:m.mod(v)},"Fraction, Fraction":function(m,v){if(v.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return m.compare(0)>=0?m.mod(v):m.mod(v).add(v).mod(v)}},o({SS:f,DS:s,SD:i,Ss:l,sS:u}))}),zb="multiplyScalar",Pb=["typed"],Lb=R(zb,Pb,r=>{var{typed:e}=r;return e("multiplyScalar",{"number, number":kl,"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":(t,a)=>a.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,a)=>t.multiply(a)})}),hf="multiply",Ub=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],kb=R(hf,Ub,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,equalScalar:i,dot:s}=r,f=Lr({typed:e,equalScalar:i}),l=yt({typed:e});function u(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 o(x,g,E){if(E===0)throw new Error("Cannot multiply two empty vectors");return s(x,g)}function c(x,g){if(g.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,g)}function m(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._data,T=g._size,B=g._datatype,_=N[0],L=T[1],G,C=a,F=n;S&&B&&S===B&&typeof S=="string"&&(G=S,C=e.find(a,[G,G]),F=e.find(n,[G,G]));for(var Z=[],$=0;$<L;$++){for(var U=F(E[0],D[0][$]),Y=1;Y<_;Y++)U=C(U,F(E[Y],D[Y][$]));Z[$]=U}return x.createDenseMatrix({data:Z,size:[L],datatype:G})}var v=e("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":A}),p=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":b,"SparseMatrix, DenseMatrix":d,"SparseMatrix, SparseMatrix":w});function h(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._data,T=g._datatype,B=N[0],_=N[1],L,G=a,C=n;S&&T&&S===T&&typeof S=="string"&&(L=S,G=e.find(a,[L,L]),C=e.find(n,[L,L]));for(var F=[],Z=0;Z<B;Z++){for(var $=E[Z],U=C($[0],D[0]),Y=1;Y<_;Y++)U=G(U,C($[Y],D[Y]));F[Z]=U}return x.createDenseMatrix({data:F,size:[B],datatype:L})}function y(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._data,T=g._size,B=g._datatype,_=N[0],L=N[1],G=T[1],C,F=a,Z=n;S&&B&&S===B&&typeof S=="string"&&(C=S,F=e.find(a,[C,C]),Z=e.find(n,[C,C]));for(var $=[],U=0;U<_;U++){var Y=E[U];$[U]=[];for(var j=0;j<G;j++){for(var P=Z(Y[0],D[0][j]),K=1;K<L;K++)P=F(P,Z(Y[K],D[K][j]));$[U][j]=P}}return x.createDenseMatrix({data:$,size:[_,G],datatype:C})}function b(x,g){var E=x._data,N=x._size,S=x._datatype,D=g._values,T=g._index,B=g._ptr,_=g._size,L=g._datatype;if(!D)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var G=N[0],C=_[1],F,Z=a,$=n,U=i,Y=0;S&&L&&S===L&&typeof S=="string"&&(F=S,Z=e.find(a,[F,F]),$=e.find(n,[F,F]),U=e.find(i,[F,F]),Y=e.convert(0,F));for(var j=[],P=[],K=[],ne=g.createSparseMatrix({values:j,index:P,ptr:K,size:[G,C],datatype:F}),re=0;re<C;re++){K[re]=P.length;var fe=B[re],pe=B[re+1];if(pe>fe)for(var ce=0,oe=0;oe<G;oe++){for(var Ce=oe+1,Oe=void 0,Me=fe;Me<pe;Me++){var $e=T[Me];ce!==Ce?(Oe=$(E[oe][$e],D[Me]),ce=Ce):Oe=Z(Oe,$(E[oe][$e],D[Me]))}ce===Ce&&!U(Oe,Y)&&(P.push(oe),j.push(Oe))}}return K[C]=P.length,ne}function A(x,g){var E=x._values,N=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=g._data,B=g._datatype,_=x._size[0],L=g._size[0],G=[],C=[],F=[],Z,$=a,U=n,Y=i,j=0;D&&B&&D===B&&typeof D=="string"&&(Z=D,$=e.find(a,[Z,Z]),U=e.find(n,[Z,Z]),Y=e.find(i,[Z,Z]),j=e.convert(0,Z));var P=[],K=[];F[0]=0;for(var ne=0;ne<L;ne++){var re=T[ne];if(!Y(re,j))for(var fe=S[ne],pe=S[ne+1],ce=fe;ce<pe;ce++){var oe=N[ce];K[oe]?P[oe]=$(P[oe],U(re,E[ce])):(K[oe]=!0,C.push(oe),P[oe]=U(re,E[ce]))}}for(var Ce=C.length,Oe=0;Oe<Ce;Oe++){var Me=C[Oe];G[Oe]=P[Me]}return F[1]=C.length,x.createSparseMatrix({values:G,index:C,ptr:F,size:[_,1],datatype:Z})}function d(x,g){var E=x._values,N=x._index,S=x._ptr,D=x._datatype;if(!E)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var T=g._data,B=g._datatype,_=x._size[0],L=g._size[0],G=g._size[1],C,F=a,Z=n,$=i,U=0;D&&B&&D===B&&typeof D=="string"&&(C=D,F=e.find(a,[C,C]),Z=e.find(n,[C,C]),$=e.find(i,[C,C]),U=e.convert(0,C));for(var Y=[],j=[],P=[],K=x.createSparseMatrix({values:Y,index:j,ptr:P,size:[_,G],datatype:C}),ne=[],re=[],fe=0;fe<G;fe++){P[fe]=j.length;for(var pe=fe+1,ce=0;ce<L;ce++){var oe=T[ce][fe];if(!$(oe,U))for(var Ce=S[ce],Oe=S[ce+1],Me=Ce;Me<Oe;Me++){var $e=N[Me];re[$e]!==pe?(re[$e]=pe,j.push($e),ne[$e]=Z(oe,E[Me])):ne[$e]=F(ne[$e],Z(oe,E[Me]))}}for(var k=P[fe],W=j.length,ie=k;ie<W;ie++){var V=j[ie];Y[ie]=ne[V]}}return P[G]=j.length,K}function w(x,g){var E=x._values,N=x._index,S=x._ptr,D=x._datatype,T=g._values,B=g._index,_=g._ptr,L=g._datatype,G=x._size[0],C=g._size[1],F=E&&T,Z,$=a,U=n;D&&L&&D===L&&typeof D=="string"&&(Z=D,$=e.find(a,[Z,Z]),U=e.find(n,[Z,Z]));for(var Y=F?[]:void 0,j=[],P=[],K=x.createSparseMatrix({values:Y,index:j,ptr:P,size:[G,C],datatype:Z}),ne=F?[]:void 0,re=[],fe,pe,ce,oe,Ce,Oe,Me,$e,k=0;k<C;k++){P[k]=j.length;var W=k+1;for(Ce=_[k],Oe=_[k+1],oe=Ce;oe<Oe;oe++)if($e=B[oe],F)for(pe=S[$e],ce=S[$e+1],fe=pe;fe<ce;fe++)Me=N[fe],re[Me]!==W?(re[Me]=W,j.push(Me),ne[Me]=U(T[oe],E[fe])):ne[Me]=$(ne[Me],U(T[oe],E[fe]));else for(pe=S[$e],ce=S[$e+1],fe=pe;fe<ce;fe++)Me=N[fe],re[Me]!==W&&(re[Me]=W,j.push(Me));if(F)for(var ie=P[k],V=j.length,Q=ie;Q<V;Q++){var te=j[Q];Y[Q]=ne[te]}}return P[C]=j.length,K}return e(hf,n,{"Array, Array":e.referTo("Matrix, Matrix",x=>(g,E)=>{u(er(g),er(E));var N=x(t(g),t(E));return He(N)?N.valueOf():N}),"Matrix, Matrix":function(g,E){var N=g.size(),S=E.size();return u(N,S),N.length===1?S.length===1?o(g,E,N[0]):c(g,E):S.length===1?v(g,E):p(g,E)},"Matrix, Array":e.referTo("Matrix,Matrix",x=>(g,E)=>x(g,t(E))),"Array, Matrix":e.referToSelf(x=>(g,E)=>x(t(g,E.storage()),E)),"SparseMatrix, any":function(g,E){return f(g,E,n,!1)},"DenseMatrix, any":function(g,E){return l(g,E,n,!1)},"any, SparseMatrix":function(g,E){return f(E,g,n,!0)},"any, DenseMatrix":function(g,E){return l(E,g,n,!0)},"Array, any":function(g,E){return l(t(g),E,n,!1).valueOf()},"any, Array":function(g,E){return l(t(E),g,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(x=>(g,E,N)=>{for(var S=x(g,E),D=0;D<N.length;D++)S=x(S,N[D]);return S})})}),df="nthRoot",Vb=["typed","matrix","equalScalar","BigNumber"],Gb=R(df,Vb,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n}=r,i=cn({typed:e}),s=bt({typed:e,equalScalar:a}),f=Mi({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=hr({typed:e,matrix:t});function o(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return e(df,{number:jl,"number, number":jl,BigNumber:m=>c(m,new n(2)),"BigNumber, BigNumber":c,Complex:o,"Complex, number":o,Array:e.referTo("DenseMatrix,number",m=>v=>m(t(v),2).valueOf()),DenseMatrix:e.referTo("DenseMatrix,number",m=>v=>m(v,2)),SparseMatrix:e.referTo("SparseMatrix,number",m=>v=>m(v,2)),"SparseMatrix, SparseMatrix":e.referToSelf(m=>(v,p)=>{if(p.density()===1)return f(v,p,m);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":e.referToSelf(m=>(v,p)=>{if(p.density()===1)return i(v,p,m,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":e.referTo("DenseMatrix,SparseMatrix",m=>(v,p)=>m(t(v),p)),"number | BigNumber, SparseMatrix":e.referToSelf(m=>(v,p)=>{if(p.density()===1)return l(p,v,m,!0);throw new Error("Root must be non-zero")})},u({scalar:"number | BigNumber",SD:s,Ss:l,sS:!1}));function c(m,v){var p=n.precision,h=n.clone({precision:p+2}),y=new n(0),b=new h(1),A=v.isNegative();if(A&&(v=v.neg()),v.isZero())throw new Error("Root must be non-zero");if(m.isNegative()&&!v.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(m.isZero())return A?new h(1/0):0;if(!m.isFinite())return A?y:m;var d=m.abs().pow(b.div(v));return d=m.isNeg()?d.neg():d,new n((A?b.div(d):d).toPrecision(p))}}),gf="sign",Hb=["typed","BigNumber","Fraction","complex"],Zb=R(gf,Hb,r=>{var{typed:e,BigNumber:t,complex:a,Fraction:n}=r;return e(gf,{number:ts,Complex:function(s){return s.im===0?a(ts(s.re)):s.sign()},BigNumber:function(s){return new t(s.cmp(0))},Fraction:function(s){return new n(s.s,1)},"Array | Matrix":e.referToSelf(i=>s=>je(s,i)),Unit:e.referToSelf(i=>s=>{if(!s._isDerived()&&s.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return e.find(i,s.valueType())(s.value)})})}),Jb="sqrt",Wb=["config","typed","Complex"],Xb=R(Jb,Wb,r=>{var{config:e,typed:t,Complex:a}=r;return t("sqrt",{number:n,Complex:function(s){return s.sqrt()},BigNumber:function(s){return!s.isNegative()||e.predictable?s.sqrt():n(s.toNumber())},Unit:function(s){return s.pow(.5)}});function n(i){return isNaN(i)?NaN:i>=0||e.predictable?Math.sqrt(i):new a(i,0).sqrt()}}),yf="square",Yb=["typed"],Qb=R(yf,Yb,r=>{var{typed:e}=r;return e(yf,{number:ec,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)},Fraction:function(a){return a.mul(a)},Unit:function(a){return a.pow(2)}})}),bf="subtract",Kb=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],jb=R(bf,Kb,r=>{var{typed:e,matrix:t,equalScalar:a,addScalar:n,unaryMinus:i,DenseMatrix:s}=r,f=cn({typed:e}),l=Xr({typed:e}),u=Fi({typed:e,equalScalar:a}),o=Mn({typed:e,DenseMatrix:s}),c=Br({typed:e,DenseMatrix:s}),m=hr({typed:e,matrix:t});return e(bf,{"number, number":(v,p)=>v-p,"Complex, Complex":(v,p)=>v.sub(p),"BigNumber, BigNumber":(v,p)=>v.minus(p),"Fraction, Fraction":(v,p)=>v.sub(p),"Unit, Unit":e.referToSelf(v=>(p,h)=>{if(p.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(!p.equalBase(h))throw new Error("Units do not match");var y=p.clone();return y.value=e.find(v,[y.valueType(),h.valueType()])(y.value,h.value),y.fixPrefix=!1,y})},m({SS:u,DS:f,SD:l,Ss:c,sS:o}))}),xf="xgcd",ex=["typed","config","matrix","BigNumber"],rx=R(xf,ex,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(xf,{"number, number":function(f,l){var u=rc(f,l);return t.matrix==="Array"?u:a(u)},"BigNumber, BigNumber":i});function i(s,f){var l,u,o,c=new n(0),m=new n(1),v=c,p=m,h=m,y=c;if(!s.isInt()||!f.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!f.isZero();)u=s.div(f).floor(),o=s.mod(f),l=v,v=p.minus(u.times(v)),p=l,l=h,h=y.minus(u.times(h)),y=l,s=f,f=o;var b;return s.lt(c)?b=[s.neg(),p.neg(),y.neg()]:b=[s,s.isZero()?0:p,y],t.matrix==="Array"?b:a(b)}}),wf="invmod",tx=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],nx=R(wf,tx,r=>{var{typed:e,config:t,BigNumber:a,xgcd:n,equal:i,smaller:s,mod:f,add:l,isInteger:u}=r;return e(wf,{"number, number":o,"BigNumber, BigNumber":o});function o(c,m){if(!u(c)||!u(m))throw new Error("Parameters in function invmod must be integer numbers");if(c=f(c,m),i(m,0))throw new Error("Divisor must be non zero");var v=n(c,m);v=v.valueOf();var[p,h]=v;return i(p,a(1))?(h=f(h,m),s(h,a(0))&&(h=l(h,m)),h):NaN}}),ax="matAlgo09xS0Sf",ix=["typed","equalScalar"],Nf=R(ax,ix,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));var E=f&&m?[]:void 0,N=[],S=[],D=E?[]:void 0,T=[],B,_,L,G,C;for(_=0;_<A;_++){S[_]=N.length;var F=_+1;if(D)for(G=p[_],C=p[_+1],L=G;L<C;L++)B=v[L],T[B]=F,D[B]=m[L];for(G=u[_],C=u[_+1],L=G;L<C;L++)if(B=l[L],D){var Z=T[B]===F?D[B]:x,$=g(f[L],Z);w($,x)||(N.push(B),E.push($))}else N.push(B)}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),Df="dotMultiply",ox=["typed","matrix","equalScalar","multiplyScalar"],sx=R(Df,ox,r=>{var{typed:e,matrix:t,equalScalar:a,multiplyScalar:n}=r,i=bt({typed:e,equalScalar:a}),s=Nf({typed:e,equalScalar:a}),f=Lr({typed:e,equalScalar:a}),l=hr({typed:e,matrix:t});return e(Df,l({elop:n,SS:s,DS:i,Ss:f}))});function ux(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 us(r,e,function(a,n){return a&n})}function Ua(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 lx(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:us(r,e,function(n,i){return n|i})}function us(r,e,t){var a=r.constructor,n,i,s=+(r.s<0),f=+(e.s<0);if(s){n=Ti(Ua(r));for(var l=0;l<n.length;++l)n[l]^=1}else n=Ti(r);if(f){i=Ti(Ua(e));for(var u=0;u<i.length;++u)i[u]^=1}else i=Ti(e);var o,c,m;n.length<=i.length?(o=n,c=i,m=s):(o=i,c=n,m=f);var v=o.length,p=c.length,h=t(s,f)^1,y=new a(h^1),b=new a(1),A=new a(2),d=a.precision;for(a.config({precision:1e9});v>0;)t(o[--v],c[--p])===h&&(y=y.plus(b)),b=b.times(A);for(;p>0;)t(m,c[--p])===h&&(y=y.plus(b)),b=b.times(A);return a.config({precision:d}),h===0&&(y.s=-y.s),y}function Ti(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 s=t.length;t.charAt(s)==="0";)s--;var f=r.e,l=t.slice(0,s+1||1),u=l.length;if(f>0)if(++f>u)for(f-=u;f--;)l+="0";else f<u&&(l=l.slice(0,f)+"."+l.slice(f));for(var o=[0],c=0;c<l.length;){for(var m=o.length;m--;)o[m]*=10;o[0]+=parseInt(l.charAt(c++));for(var v=0;v<o.length;++v)o[v]>1&&((o[v+1]===null||o[v+1]===void 0)&&(o[v+1]=0),o[v+1]+=o[v]>>1,o[v]&=1)}return o.reverse()}function cx(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)?Ua(e):e.eq(a)?Ua(r):!r.isFinite()||!e.isFinite()?!r.isFinite()&&!e.isFinite()?a:new t(r.isNegative()===e.isNegative()?1/0:-1/0):us(r,e,function(n,i){return n^i})}function fx(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 mx(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 Af="bitAnd",vx=["typed","matrix","equalScalar"],px=R(Af,vx,r=>{var{typed:e,matrix:t,equalScalar:a}=r,n=bt({typed:e,equalScalar:a}),i=Mi({typed:e,equalScalar:a}),s=Lr({typed:e,equalScalar:a}),f=hr({typed:e,matrix:t});return e(Af,{"number, number":ac,"BigNumber, BigNumber":ux},f({SS:i,DS:n,Ss:s}))}),Ef="bitNot",hx=["typed"],dx=R(Ef,hx,r=>{var{typed:e}=r;return e(Ef,{number:ic,BigNumber:Ua,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Sf="bitOr",gx=["typed","matrix","equalScalar","DenseMatrix"],yx=R(Sf,gx,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=cn({typed:e}),s=ss({typed:e,equalScalar:a}),f=Mn({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:t});return e(Sf,{"number, number":oc,"BigNumber, BigNumber":lx},l({SS:s,DS:i,Ss:f}))}),bx="matAlgo07xSSf",xx=["typed","DenseMatrix"],Mt=R(bx,xx,r=>{var{typed:e,DenseMatrix:t}=r;return function(i,s,f){var l=i._size,u=i._datatype,o=s._size,c=s._datatype;if(l.length!==o.length)throw new Ke(l.length,o.length);if(l[0]!==o[0]||l[1]!==o[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+o+")");var m=l[0],v=l[1],p,h=0,y=f;typeof u=="string"&&u===c&&(p=u,h=e.convert(0,p),y=e.find(f,[p,p]));var b,A,d=[];for(b=0;b<m;b++)d[b]=[];var w=[],x=[],g=[],E=[];for(A=0;A<v;A++){var N=A+1;for(a(i,A,g,w,N),a(s,A,E,x,N),b=0;b<m;b++){var S=g[b]===N?w[b]:h,D=E[b]===N?x[b]:h;d[b][A]=y(S,D)}}return new t({data:d,size:[m,v],datatype:p})};function a(n,i,s,f,l){for(var u=n._values,o=n._index,c=n._ptr,m=c[i],v=c[i+1];m<v;m++){var p=o[m];s[p]=l,f[p]=u[m]}}}),Cf="bitXor",wx=["typed","matrix","DenseMatrix"],Nx=R(Cf,wx,r=>{var{typed:e,matrix:t,DenseMatrix:a}=r,n=Xr({typed:e}),i=Mt({typed:e,DenseMatrix:a}),s=Br({typed:e,DenseMatrix:a}),f=hr({typed:e,matrix:t});return e(Cf,{"number, number":sc,"BigNumber, BigNumber":cx},f({SS:i,DS:n,Ss:s}))}),Mf="arg",Dx=["typed"],Ax=R(Mf,Dx,r=>{var{typed:e}=r;return e(Mf,{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":e.referToSelf(t=>a=>je(a,t))})}),Ff="conj",Ex=["typed"],Sx=R(Ff,Ex,r=>{var{typed:e}=r;return e(Ff,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Tf="im",Cx=["typed"],Mx=R(Tf,Cx,r=>{var{typed:e}=r;return e(Tf,{number:()=>0,"BigNumber | Fraction":t=>t.mul(0),Complex:t=>t.im,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Bf="re",Fx=["typed"],Tx=R(Bf,Fx,r=>{var{typed:e}=r;return e(Bf,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.re,"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),$f="not",Bx=["typed"],$x=R($f,Bx,r=>{var{typed:e}=r;return e($f,{"null | undefined":()=>!0,number:mc,Complex:function(a){return a.re===0&&a.im===0},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:e.referToSelf(t=>a=>e.find(t,a.valueType())(a.value)),"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),Of="or",Ox=["typed","matrix","equalScalar","DenseMatrix"],_x=R(Of,Ox,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Fi({typed:e,equalScalar:a}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:t});return e(Of,{"number, number":vc,"Complex, Complex":function(o,c){return o.re!==0||o.im!==0||c.re!==0||c.im!==0},"BigNumber, BigNumber":function(o,c){return!o.isZero()&&!o.isNaN()||!c.isZero()&&!c.isNaN()},"Unit, Unit":e.referToSelf(u=>(o,c)=>u(o.value||0,c.value||0))},l({SS:s,DS:i,Ss:f}))}),_f="xor",Ix=["typed","matrix","DenseMatrix"],Rx=R(_f,Ix,r=>{var{typed:e,matrix:t,DenseMatrix:a}=r,n=Xr({typed:e}),i=Mt({typed:e,DenseMatrix:a}),s=Br({typed:e,DenseMatrix:a}),f=hr({typed:e,matrix:t});return e(_f,{"number, number":pc,"Complex, Complex":function(u,o){return(u.re!==0||u.im!==0)!=(o.re!==0||o.im!==0)},"BigNumber, BigNumber":function(u,o){return(!u.isZero()&&!u.isNaN())!=(!o.isZero()&&!o.isNaN())},"Unit, Unit":e.referToSelf(l=>(u,o)=>l(u.value||0,o.value||0))},f({SS:i,DS:n,Ss:s}))}),If="concat",qx=["typed","matrix","isInteger"],Rf=R(If,qx,r=>{var{typed:e,matrix:t,isInteger:a}=r;return e(If,{"...Array | Matrix | number | BigNumber":function(i){var s,f=i.length,l=-1,u,o=!1,c=[];for(s=0;s<f;s++){var m=i[s];if(He(m)&&(o=!0),tr(m)||rr(m)){if(s!==f-1)throw new Error("Dimension must be specified as last argument");if(u=l,l=m.valueOf(),!a(l))throw new TypeError("Integer number expected for dimension");if(l<0||s>0&&l>u)throw new pt(l,u+1)}else{var v=ke(m).valueOf(),p=er(v);if(c[s]=v,u=l,l=p.length-1,s>0&&l!==u)throw new Ke(u+1,l+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var h=c.shift();c.length;)h=qf(h,c.shift(),l,0);return o?t(h):h},"...string":function(i){return i.join("")}})});function qf(r,e,t,a){if(a<t){if(r.length!==e.length)throw new Ke(r.length,e.length);for(var n=[],i=0;i<r.length;i++)n[i]=qf(r[i],e[i],t,a+1);return n}else return r.concat(e)}var zf="column",zx=["typed","Index","matrix","range"],Pf=R(zf,zx,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(zf,{"Matrix, number":i,"Array, number":function(f,l){return i(a(ke(f)),l).valueOf()}});function i(s,f){if(s.size().length!==2)throw new Error("Only two dimensional matrix is supported");mr(f,s.size()[1]);var l=n(0,s.size()[0]),u=new t(l,f);return s.subset(u)}}),Lf="count",Px=["typed","size","prod"],Lx=R(Lf,Px,r=>{var{typed:e,size:t,prod:a}=r;return e(Lf,{string:function(i){return i.length},"Matrix | Array":function(i){return a(t(i))}})}),Uf="cross",Ux=["typed","matrix","subtract","multiply"],kx=R(Uf,Ux,r=>{var{typed:e,matrix:t,subtract:a,multiply:n}=r;return e(Uf,{"Matrix, Matrix":function(f,l){return t(i(f.toArray(),l.toArray()))},"Matrix, Array":function(f,l){return t(i(f.toArray(),l))},"Array, Matrix":function(f,l){return t(i(f,l.toArray()))},"Array, Array":i});function i(s,f){var l=Math.max(er(s).length,er(f).length);s=li(s),f=li(f);var u=er(s),o=er(f);if(u.length!==1||o.length!==1||u[0]!==3||o[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+u.join(", ")+"], B = ["+o.join(", ")+"])");var c=[a(n(s[1],f[2]),n(s[2],f[1])),a(n(s[2],f[0]),n(s[0],f[2])),a(n(s[0],f[1]),n(s[1],f[0]))];return l>1?[c]:c}}),kf="diag",Vx=["typed","matrix","DenseMatrix","SparseMatrix"],Gx=R(kf,Vx,r=>{var{typed:e,matrix:t,DenseMatrix:a,SparseMatrix:n}=r;return e(kf,{Array:function(u){return i(u,0,er(u),null)},"Array, number":function(u,o){return i(u,o,er(u),null)},"Array, BigNumber":function(u,o){return i(u,o.toNumber(),er(u),null)},"Array, string":function(u,o){return i(u,0,er(u),o)},"Array, number, string":function(u,o,c){return i(u,o,er(u),c)},"Array, BigNumber, string":function(u,o,c){return i(u,o.toNumber(),er(u),c)},Matrix:function(u){return i(u,0,u.size(),u.storage())},"Matrix, number":function(u,o){return i(u,o,u.size(),u.storage())},"Matrix, BigNumber":function(u,o){return i(u,o.toNumber(),u.size(),u.storage())},"Matrix, string":function(u,o){return i(u,0,u.size(),o)},"Matrix, number, string":function(u,o,c){return i(u,o,u.size(),c)},"Matrix, BigNumber, string":function(u,o,c){return i(u,o.toNumber(),u.size(),c)}});function i(l,u,o,c){if(!qe(u))throw new TypeError("Second parameter in function diag must be an integer");var m=u>0?u:0,v=u<0?-u:0;switch(o.length){case 1:return s(l,u,c,o[0],v,m);case 2:return f(l,u,c,o,v,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function s(l,u,o,c,m,v){var p=[c+m,c+v];if(o&&o!=="sparse"&&o!=="dense")throw new TypeError("Unknown matrix type ".concat(o,'"'));var h=o==="sparse"?n.diagonal(p,l,u):a.diagonal(p,l,u);return o!==null?h:h.valueOf()}function f(l,u,o,c,m,v){if(He(l)){var p=l.diagonal(u);return o!==null?o!==p.storage()?t(p,o):p:p.valueOf()}for(var h=Math.min(c[0]-m,c[1]-v),y=[],b=0;b<h;b++)y[b]=l[b+m][b+v];return o!==null?t(y):y}}),Hx="filter",Zx=["typed"],Jx=R(Hx,Zx,r=>{var{typed:e}=r;return e("filter",{"Array, function":Vf,"Matrix, function":function(a,n){return a.create(Vf(a.toArray(),n))},"Array, RegExp":fi,"Matrix, RegExp":function(a,n){return a.create(fi(a.toArray(),n))}})});function Vf(r,e){var t=ln(e);return pl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n]):e(a,[n],i)})}var Gf="flatten",Wx=["typed","matrix"],Xx=R(Gf,Wx,r=>{var{typed:e,matrix:t}=r;return e(Gf,{Array:function(n){return ar(n)},Matrix:function(n){var i=ar(n.toArray());return t(i)}})}),Hf="forEach",Yx=["typed"],Qx=R(Hf,Yx,r=>{var{typed:e}=r;return e(Hf,{"Array, function":Kx,"Matrix, function":function(a,n){return a.forEach(n)}})});function Kx(r,e){var t=ln(e),a=function n(i,s){Array.isArray(i)?ci(i,function(f,l){n(f,s.concat(l))}):t===1?e(i):t===2?e(i,s):e(i,s,r)};a(r,[])}var Zf="getMatrixDataType",jx=["typed"],ew=R(Zf,jx,r=>{var{typed:e}=r;return e(Zf,{Array:function(a){return qa(a,gr)},Matrix:function(a){return a.getDataType()}})}),Jf="identity",rw=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],tw=R(Jf,rw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n,DenseMatrix:i,SparseMatrix:s}=r;return e(Jf,{"":function(){return t.matrix==="Matrix"?a([]):[]},string:function(o){return a(o)},"number | BigNumber":function(o){return l(o,o,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(o,c){return l(o,o,c)},"number | BigNumber, number | BigNumber":function(o,c){return l(o,c,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(o,c,m){return l(o,c,m)},Array:function(o){return f(o)},"Array, string":function(o,c){return f(o,c)},Matrix:function(o){return f(o.valueOf(),o.storage())},"Matrix, string":function(o,c){return f(o.valueOf(),c)}});function f(u,o){switch(u.length){case 0:return o?a(o):[];case 1:return l(u[0],u[0],o);case 2:return l(u[0],u[1],o);default:throw new Error("Vector containing two values expected")}}function l(u,o,c){var m=rr(u)||rr(o)?n:null;if(rr(u)&&(u=u.toNumber()),rr(o)&&(o=o.toNumber()),!qe(u)||u<1)throw new Error("Parameters in function identity must be positive integers");if(!qe(o)||o<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new n(1):1,p=m?new m(0):0,h=[u,o];if(c){if(c==="sparse")return s.diagonal(h,v,0,p);if(c==="dense")return i.diagonal(h,v,0,p);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var y=Gn([],h,p),b=u<o?u:o,A=0;A<b;A++)y[A][A]=v;return y}}),Wf="kron",nw=["typed","matrix","multiplyScalar"],aw=R(Wf,nw,r=>{var{typed:e,matrix:t,multiplyScalar:a}=r;return e(Wf,{"Matrix, Matrix":function(s,f){return t(n(s.toArray(),f.toArray()))},"Matrix, Array":function(s,f){return t(n(s.toArray(),f))},"Array, Matrix":function(s,f){return t(n(s,f.toArray()))},"Array, Array":n});function n(i,s){if(er(i).length===1&&(i=[i]),er(s).length===1&&(s=[s]),er(i).length>2||er(s).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(s.length)+")");var f=[],l=[];return i.map(function(u){return s.map(function(o){return l=[],f.push(l),u.map(function(c){return o.map(function(m){return l.push(a(c,m))})})})})&&f}}),Xf="map",iw=["typed"],ow=R(Xf,iw,r=>{var{typed:e}=r;return e(Xf,{"Array, function":sw,"Matrix, function":function(a,n){return a.map(n)}})});function sw(r,e){var t=ln(e),a=function n(i,s){if(Array.isArray(i))return i.map(function(u,o){return n(u,s.concat(o))});try{return t===1?e(i):t===2?e(i,s):e(i,s,r)}catch(u){if(u instanceof TypeError&&"data"in u&&u.data.category==="wrongType"){var f="map attempted to call '".concat(u.data.fn,"(").concat(i),l=JSON.stringify(s);throw t===2?f+=","+l:t!==1&&(f+=",".concat(l,",").concat(r)),f+=")' but argument ".concat(u.data.index+1," of type "),f+="".concat(u.data.actual," does not match expected type "),f+=u.data.expected.join(" or "),new TypeError(f)}throw u}};return a(r,[])}var Yf="diff",uw=["typed","matrix","subtract","number"],Qf=R(Yf,uw,r=>{var{typed:e,matrix:t,subtract:a,number:n}=r;return e(Yf,{"Array | Matrix":function(o){return He(o)?t(s(o.toArray())):s(o)},"Array | Matrix, number":function(o,c){if(!qe(c))throw new RangeError("Dimension must be a whole number");return He(o)?t(i(o.toArray(),c)):i(o,c)},"Array, BigNumber":e.referTo("Array,number",u=>(o,c)=>u(o,n(c))),"Matrix, BigNumber":e.referTo("Matrix,number",u=>(o,c)=>u(o,n(c)))});function i(u,o){if(He(u)&&(u=u.toArray()),!Array.isArray(u))throw RangeError("Array/Matrix does not have that many dimensions");if(o>0){var c=[];return u.forEach(m=>{c.push(i(m,o-1))}),c}else{if(o===0)return s(u);throw RangeError("Cannot have negative dimension")}}function s(u){for(var o=[],c=u.length,m=1;m<c;m++)o.push(f(u[m-1],u[m]));return o}function f(u,o){He(u)&&(u=u.toArray()),He(o)&&(o=o.toArray());var c=Array.isArray(u),m=Array.isArray(o);if(c&&m)return l(u,o);if(!c&&!m)return a(o,u);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function l(u,o){if(u.length!==o.length)throw RangeError("Not all sub-arrays have the same length");for(var c=[],m=u.length,v=0;v<m;v++)c.push(f(u[v],o[v]));return c}}),lw="ones",cw=["typed","config","matrix","BigNumber"],fw=R(lw,cw,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(u){var o=u[u.length-1];if(typeof o=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var o=u.storage();return i(u.valueOf(),o)},"Array | Matrix, string":function(u,o){return i(u.valueOf(),o)}});function i(l,u){var o=s(l),c=o?new n(1):1;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Gn(v,l,c):v}}function s(l){var u=!1;return l.forEach(function(o,c,m){rr(o)&&(u=!0,m[c]=o.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function ones must be positive integers")})}});function ls(){throw new Error('No "bignumber" implementation available')}function Kf(){throw new Error('No "fraction" implementation available')}function jf(){throw new Error('No "matrix" implementation available')}var em="range",mw=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],rm=R(em,mw,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:s,larger:f,largerEq:l}=r;return e(em,{string:o,"string, boolean":o,"number, number":function(b,A){return u(c(b,A,1))},"number, number, number":function(b,A,d){return u(c(b,A,d))},"number, number, boolean":function(b,A,d){return u(d?m(b,A,1):c(b,A,1))},"number, number, number, boolean":function(b,A,d,w){return u(w?m(b,A,d):c(b,A,d))},"BigNumber, BigNumber":function(b,A){var d=b.constructor;return u(v(b,A,new d(1)))},"BigNumber, BigNumber, BigNumber":function(b,A,d){return u(v(b,A,d))},"BigNumber, BigNumber, boolean":function(b,A,d){var w=b.constructor;return u(d?p(b,A,new w(1)):v(b,A,new w(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(b,A,d,w){return u(w?p(b,A,d):v(b,A,d))}});function u(y){return t.matrix==="Matrix"?a?a(y):jf():y}function o(y,b){var A=h(y);if(!A)throw new SyntaxError('String "'+y+'" is no valid range');var d;return t.number==="BigNumber"?(n===void 0&&ls(),d=b?p:v,u(d(n(A.start),n(A.end),n(A.step)))):(d=b?m:c,u(d(A.start,A.end,A.step)))}function c(y,b,A){var d=[],w=y;if(A>0)for(;i(w,b);)d.push(w),w+=A;else if(A<0)for(;f(w,b);)d.push(w),w+=A;return d}function m(y,b,A){var d=[],w=y;if(A>0)for(;s(w,b);)d.push(w),w+=A;else if(A<0)for(;l(w,b);)d.push(w),w+=A;return d}function v(y,b,A){var d=n(0),w=[],x=y;if(A.gt(d))for(;i(x,b);)w.push(x),x=x.plus(A);else if(A.lt(d))for(;f(x,b);)w.push(x),x=x.plus(A);return w}function p(y,b,A){var d=n(0),w=[],x=y;if(A.gt(d))for(;s(x,b);)w.push(x),x=x.plus(A);else if(A.lt(d))for(;l(x,b);)w.push(x),x=x.plus(A);return w}function h(y){var b=y.split(":"),A=b.map(function(w){return Number(w)}),d=A.some(function(w){return isNaN(w)});if(d)return null;switch(A.length){case 2:return{start:A[0],end:A[1],step:1};case 3:return{start:A[0],end:A[2],step:A[1]};default:return null}}}),tm="reshape",vw=["typed","isInteger","matrix"],pw=R(tm,vw,r=>{var{typed:e,isInteger:t}=r;return e(tm,{"Matrix, Array":function(n,i){return n.reshape(i)},"Array, Array":function(n,i){return i.forEach(function(s){if(!t(s))throw new TypeError("Invalid size for dimension: "+s)}),ll(n,i)}})});function ra(r,e,t,a){if(!(this instanceof ra))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}ra.prototype=new Error,ra.prototype.constructor=Error,ra.prototype.name="ArgumentsError",ra.prototype.isArgumentsError=!0;var hw="resize",dw=["config","matrix"],gw=R(hw,dw,r=>{var{config:e,matrix:t}=r;return function(i,s,f){if(arguments.length!==2&&arguments.length!==3)throw new ra("resize",arguments.length,2,3);if(He(s)&&(s=s.valueOf()),rr(s[0])&&(s=s.map(function(o){return rr(o)?o.toNumber():o})),He(i))return i.resize(s,f,!0);if(typeof i=="string")return a(i,s,f);var l=Array.isArray(i)?!1:e.matrix!=="Array";if(s.length===0){for(;Array.isArray(i);)i=i[0];return ke(i)}else{Array.isArray(i)||(i=[i]),i=ke(i);var u=Gn(i,s,f);return l?t(u):u}};function a(n,i,s){if(s!==void 0){if(typeof s!="string"||s.length!==1)throw new TypeError("Single character expected as defaultValue")}else s=" ";if(i.length!==1)throw new Ke(i.length,1);var f=i[0];if(typeof f!="number"||!qe(f))throw new TypeError("Invalid size, must contain positive integers (size: "+Ye(i)+")");if(n.length>f)return n.substring(0,f);if(n.length<f){for(var l=n,u=0,o=f-n.length;u<o;u++)l+=s;return l}else return n}}),nm="rotate",yw=["typed","multiply","rotationMatrix"],bw=R(nm,yw,r=>{var{typed:e,multiply:t,rotationMatrix:a}=r;return e(nm,{"Array , number | BigNumber | Complex | Unit":function(s,f){n(s,2);var l=t(a(f),s);return l.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(s,f){return n(s,2),t(a(f),s)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(s,f,l){n(s,3);var u=t(a(f,l),s);return u},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(s,f,l){return n(s,3),t(a(f,l),s)}});function n(i,s){var f=Array.isArray(i)?er(i):i.size();if(f.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(s));if(f.length===2&&f[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(s));if(f[0]!==s)throw new RangeError("Vector must be of dimensions 1x".concat(s))}}),am="rotationMatrix",xw=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],ww=R(am,xw,r=>{var{typed:e,config:t,multiplyScalar:a,addScalar:n,unaryMinus:i,norm:s,BigNumber:f,matrix:l,DenseMatrix:u,SparseMatrix:o,cos:c,sin:m}=r;return e(am,{"":function(){return t.matrix==="Matrix"?l([]):[]},string:function(d){return l(d)},"number | BigNumber | Complex | Unit":function(d){return v(d,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(d,w){return v(d,w)},"number | BigNumber | Complex | Unit, Array":function(d,w){var x=l(w);return p(x),b(d,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(d,w){p(w);var x=w.storage()||(t.matrix==="Matrix"?"dense":void 0);return b(d,w,x)},"number | BigNumber | Complex | Unit, Array, string":function(d,w,x){var g=l(w);return p(g),b(d,g,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(d,w,x){return p(w),b(d,w,x)}});function v(A,d){var w=rr(A),x=w?new f(-1):-1,g=c(A),E=m(A),N=[[g,a(x,E)],[E,g]];return y(N,d)}function p(A){var d=A.size();if(d.length<1||d[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(A){return A.reduce((d,w)=>a(d,w))}function y(A,d){if(d){if(d==="sparse")return new o(A);if(d==="dense")return new u(A);throw new TypeError('Unknown matrix type "'.concat(d,'"'))}return A}function b(A,d,w){var x=s(d);if(x===0)throw new RangeError("Rotation around zero vector");var g=rr(A)?f:null,E=g?new g(1):1,N=g?new g(-1):-1,S=g?new g(d.get([0])/x):d.get([0])/x,D=g?new g(d.get([1])/x):d.get([1])/x,T=g?new g(d.get([2])/x):d.get([2])/x,B=c(A),_=n(E,i(B)),L=m(A),G=n(B,h([S,S,_])),C=n(h([S,D,_]),h([N,T,L])),F=n(h([S,T,_]),h([D,L])),Z=n(h([S,D,_]),h([T,L])),$=n(B,h([D,D,_])),U=n(h([D,T,_]),h([N,S,L])),Y=n(h([S,T,_]),h([N,D,L])),j=n(h([D,T,_]),h([S,L])),P=n(B,h([T,T,_])),K=[[G,C,F],[Z,$,U],[Y,j,P]];return y(K,w)}}),im="row",Nw=["typed","Index","matrix","range"],om=R(im,Nw,r=>{var{typed:e,Index:t,matrix:a,range:n}=r;return e(im,{"Matrix, number":i,"Array, number":function(f,l){return i(a(ke(f)),l).valueOf()}});function i(s,f){if(s.size().length!==2)throw new Error("Only two dimensional matrix is supported");mr(f,s.size()[0]);var l=n(0,s.size()[1]),u=new t(f,l);return s.subset(u)}}),sm="size",Dw=["typed","config","?matrix"],Aw=R(sm,Dw,r=>{var{typed:e,config:t,matrix:a}=r;return e(sm,{Matrix:function(i){return i.create(i.size())},Array:er,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([]):jf()}})}),um="squeeze",Ew=["typed","matrix"],Sw=R(um,Ew,r=>{var{typed:e,matrix:t}=r;return e(um,{Array:function(n){return li(ke(n))},Matrix:function(n){var i=li(n.toArray());return Array.isArray(i)?t(i):i},any:function(n){return ke(n)}})}),lm="subset",Cw=["typed","matrix"],cm=R(lm,Cw,r=>{var{typed:e,matrix:t}=r;return e(lm,{"Array, Index":function(n,i){var s=t(n),f=s.subset(i);return i.isScalar()?f:f.valueOf()},"Matrix, Index":function(n,i){return n.subset(i)},"Object, Index":Fw,"string, Index":Mw,"Array, Index, any":function(n,i,s){return t(ke(n)).subset(i,s,void 0).valueOf()},"Array, Index, any, any":function(n,i,s,f){return t(ke(n)).subset(i,s,f).valueOf()},"Matrix, Index, any":function(n,i,s){return n.clone().subset(i,s)},"Matrix, Index, any, any":function(n,i,s,f){return n.clone().subset(i,s,f)},"string, Index, string":fm,"string, Index, string, string":fm,"Object, Index, any":Tw})});function Mw(r,e){if(!ai(e))throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(e.size().length,1);var t=r.length;mr(e.min()[0],t),mr(e.max()[0],t);var a=e.dimension(0),n="";return a.forEach(function(i){n+=r.charAt(i)}),n}function fm(r,e,t,a){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(e.size().length!==1)throw new Ke(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 Ke(n.size()[0],t.length);var s=r.length;mr(e.min()[0]),mr(e.max()[0]);for(var f=[],l=0;l<s;l++)f[l]=r.charAt(l);if(n.forEach(function(c,m){f[c]=t.charAt(m[0])}),f.length>s)for(var u=s-1,o=f.length;u<o;u++)f[u]||(f[u]=a);return f.join("")}function Fw(r,e){if(e.size().length!==1)throw new Ke(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 ot(r,t)}function Tw(r,e,t){if(e.size().length!==1)throw new Ke(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=ke(r);return Zn(n,a,t),n}var mm="transpose",Bw=["typed","matrix"],$w=R(mm,Bw,r=>{var{typed:e,matrix:t}=r;return e(mm,{Array:s=>a(t(s)).valueOf(),Matrix:a,any:ke});function a(s){var f=s.size(),l;switch(f.length){case 1:l=s.clone();break;case 2:{var u=f[0],o=f[1];if(o===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ye(f)+")");switch(s.storage()){case"dense":l=n(s,u,o);break;case"sparse":l=i(s,u,o);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Ye(f)+")")}return l}function n(s,f,l){for(var u=s._data,o=[],c,m=0;m<l;m++){c=o[m]=[];for(var v=0;v<f;v++)c[v]=ke(u[v][m])}return s.createDenseMatrix({data:o,size:[l,f],datatype:s._datatype})}function i(s,f,l){for(var u=s._values,o=s._index,c=s._ptr,m=u?[]:void 0,v=[],p=[],h=[],y=0;y<f;y++)h[y]=0;var b,A,d;for(b=0,A=o.length;b<A;b++)h[o[b]]++;for(var w=0,x=0;x<f;x++)p.push(w),w+=h[x],h[x]=p[x];for(p.push(w),d=0;d<l;d++)for(var g=c[d],E=c[d+1],N=g;N<E;N++){var S=h[o[N]]++;v[S]=d,u&&(m[S]=ke(u[N]))}return s.createSparseMatrix({values:m,index:v,ptr:p,size:[l,f],datatype:s._datatype})}}),vm="ctranspose",Ow=["typed","transpose","conj"],_w=R(vm,Ow,r=>{var{typed:e,transpose:t,conj:a}=r;return e(vm,{any:function(i){return a(t(i))}})}),pm="zeros",Iw=["typed","config","matrix","BigNumber"],Rw=R(pm,Iw,r=>{var{typed:e,config:t,matrix:a,BigNumber:n}=r;return e(pm,{"":function(){return t.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(u){var o=u[u.length-1];if(typeof o=="string"){var c=u.pop();return i(u,c)}else return t.matrix==="Array"?i(u):i(u,"default")},Array:i,Matrix:function(u){var o=u.storage();return i(u.valueOf(),o)},"Array | Matrix, string":function(u,o){return i(u.valueOf(),o)}});function i(l,u){var o=s(l),c=o?new n(0):0;if(f(l),u){var m=a(u);return l.length>0?m.resize(l,c):m}else{var v=[];return l.length>0?Gn(v,l,c):v}}function s(l){var u=!1;return l.forEach(function(o,c,m){rr(o)&&(u=!0,m[c]=o.toNumber())}),u}function f(l){l.forEach(function(u){if(typeof u!="number"||!qe(u)||u<0)throw new Error("Parameters in function zeros must be positive integers")})}}),hm="fft",qw=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],zw=R(hm,qw,r=>{var{typed:e,matrix:t,addScalar:a,multiplyScalar:n,divideScalar:i,exp:s,tau:f,i:l}=r;return e(hm,{Array:u,Matrix:function(v){return v.create(u(v.toArray()))}});function u(m){var v=er(m);return v.length===1?c(m,v[0]):o(m.map(p=>u(p,v.slice(1))),0)}function o(m,v){var p=er(m);if(v!==0)return new Array(p[0]).fill(0).map((y,b)=>o(m[b],v-1));if(p.length===1)return c(m);function h(y){var b=er(y);return new Array(b[1]).fill(0).map((A,d)=>new Array(b[0]).fill(0).map((w,x)=>y[x][d]))}return h(o(h(m),1))}function c(m){var v=m.length;if(v===1)return[m[0]];if(v%2===0){for(var p=[...c(m.filter((A,d)=>d%2===0)),...c(m.filter((A,d)=>d%2===1))],h=0;h<v/2;h++){var y=p[h],b=n(p[h+v/2],s(n(n(f,l),i(-h,v))));p[h]=a(y,b),p[h+v/2]=a(y,n(-1,b))}return p}throw new Error("Can only calculate FFT of power-of-two size")}}),dm="ifft",Pw=["typed","fft","dotDivide","conj"],Lw=R(dm,Pw,r=>{var{typed:e,fft:t,dotDivide:a,conj:n}=r;return e(dm,{"Array | Matrix":function(s){var f=He(s)?s.size():er(s);return a(n(t(n(s))),f.reduce((l,u)=>l*u,1))}})}),Uw="erf",kw=["typed"],Vw=R(Uw,kw,r=>{var{typed:e}=r;return e("name",{number:function(s){var f=Math.abs(s);return f>=Zw?tn(s):f<=Gw?tn(s)*t(f):f<=4?tn(s)*(1-a(f)):tn(s)*(1-n(f))},"Array | Matrix":e.referToSelf(i=>s=>je(s,i))});function t(i){var s=i*i,f=Zt[0][4]*s,l=s,u;for(u=0;u<3;u+=1)f=(f+Zt[0][u])*s,l=(l+ta[0][u])*s;return i*(f+Zt[0][3])/(l+ta[0][3])}function a(i){var s=Zt[1][8]*i,f=i,l;for(l=0;l<7;l+=1)s=(s+Zt[1][l])*i,f=(f+ta[1][l])*i;var u=(s+Zt[1][7])/(f+ta[1][7]),o=parseInt(i*16)/16,c=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-c)*u}function n(i){var s=1/(i*i),f=Zt[2][5]*s,l=s,u;for(u=0;u<4;u+=1)f=(f+Zt[2][u])*s,l=(l+ta[2][u])*s;var o=s*(f+Zt[2][4])/(l+ta[2][4]);o=(Hw-o)/i,s=parseInt(i*16)/16;var c=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-c)*o}}),Gw=.46875,Hw=.5641895835477563,Zt=[[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]],ta=[[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]],Zw=Math.pow(2,53),gm="mode",Jw=["typed","isNaN","isNumeric"],Ww=R(gm,Jw,r=>{var{typed:e,isNaN:t,isNumeric:a}=r;return e(gm,{"Array | Matrix":n,"...":function(s){return n(s)}});function n(i){i=ar(i.valueOf());var s=i.length;if(s===0)throw new Error("Cannot calculate mode of an empty array");for(var f={},l=[],u=0,o=0;o<i.length;o++){var c=i[o];if(a(c)&&t(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in f||(f[c]=0),f[c]++,f[c]===u?l.push(c):f[c]>u&&(u=f[c],l=[c])}return l}});function Yr(r,e,t){var a;return String(r).indexOf("Unexpected type")!==-1?(a=arguments.length>2?" (type: "+gr(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: "+gr(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+a)):r}var ym="prod",Xw=["typed","config","multiplyScalar","numeric"],Yw=R(ym,Xw,r=>{var{typed:e,config:t,multiplyScalar:a,numeric:n}=r;return e(ym,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(f,l){throw new Error("prod(A, dim) is not yet supported")},"...":function(f){return i(f)}});function i(s){var f;if(Gt(s,function(l){try{f=f===void 0?l:a(f,l)}catch(u){throw Yr(u,"prod",l)}}),typeof f=="string"&&(f=n(f,t.number)),f===void 0)throw new Error("Cannot calculate prod of an empty array");return f}}),bm="format",Qw=["typed"],Kw=R(bm,Qw,r=>{var{typed:e}=r;return e(bm,{any:Ye,"any, Object | function | number":Ye})}),xm="bin",jw=["typed","format"],eN=R(xm,jw,r=>{var{typed:e,format:t}=r;return e(xm,{"number | BigNumber":function(n){return t(n,{notation:"bin"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"bin",wordSize:i})}})}),wm="oct",rN=["typed","format"],tN=R(wm,rN,r=>{var{typed:e,format:t}=r;return e(wm,{"number | BigNumber":function(n){return t(n,{notation:"oct"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"oct",wordSize:i})}})}),Nm="hex",nN=["typed","format"],aN=R(Nm,nN,r=>{var{typed:e,format:t}=r;return e(Nm,{"number | BigNumber":function(n){return t(n,{notation:"hex"})},"number | BigNumber, number":function(n,i){return t(n,{notation:"hex",wordSize:i})}})}),Dm="print",iN=["typed"],oN=R(Dm,iN,r=>{var{typed:e}=r;return e(Dm,{"string, Object | Array":Am,"string, Object | Array, number | Object":Am})});function Am(r,e,t){return r.replace(/\$([\w.]+)/g,function(a,n){for(var i=n.split("."),s=e[i.shift()];i.length&&s!==void 0;){var f=i.shift();s=f?s[f]:s+"."}return s!==void 0?Wr(s)?s:Ye(s,t):a})}var Em="to",sN=["typed","matrix"],uN=R(Em,sN,r=>{var{typed:e,matrix:t}=r,a=hr({typed:e,matrix:t});return e(Em,{"Unit, Unit | string":(n,i)=>n.to(i)},a({Ds:!0}))}),Sm="isPrime",lN=["typed"],cN=R(Sm,lN,r=>{var{typed:e}=r;return e(Sm,{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 s(A,d,w){for(var x=1;!d.eq(0);)d.mod(2).eq(0)?(d=d.div(2),A=A.mul(A).mod(w)):(d=d.sub(1),x=A.mul(x).mod(w));return x}var f=a.constructor.clone({precision:a.toFixed(0).length*2});a=new f(a);for(var l=0,u=a.sub(1);u.mod(2).eq(0);)u=u.div(2),l+=1;var o=null;if(a.lt("3317044064679887385961981"))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(A=>A<a);else{var c=Math.min(a.toNumber()-2,Math.floor(2*Math.pow(a.toFixed(0).length*Math.log(10),2)));o=[];for(var m=2;m<=c;m+=1)o.push(c)}for(var v=0;v<o.length;v+=1){var p=o[v],h=s(a.sub(a).add(p),u,a);if(!h.eq(1)){for(var y=0,b=h;!b.eq(a.sub(1));y+=1,b=b.mul(b).mod(a))if(y===l-1)return!1}}return!0},"Array | Matrix":e.referToSelf(t=>a=>je(a,t))})}),fN="numeric",mN=["number","?bignumber","?fraction"],vN=R(fN,mN,r=>{var{number:e,bignumber:t,fraction:a}=r,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:s=>e(s),BigNumber:t?s=>t(s):ls,Fraction:a?s=>a(s):Kf};return function(f){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",u=arguments.length>2?arguments[2]:void 0;if(u!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var o=gr(f);if(!(o in n))throw new TypeError("Cannot convert "+f+' of type "'+o+'"; valid input types are '+Object.keys(n).join(", "));if(!(l in i))throw new TypeError("Cannot convert "+f+' to type "'+l+'"; valid output types are '+Object.keys(i).join(", "));return l===o?f:i[l](f)}}),Cm="divideScalar",pN=["typed","numeric"],hN=R(Cm,pN,r=>{var{typed:e,numeric:t}=r;return e(Cm,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(a,n)=>a.divide(n),"number | Fraction | Complex | BigNumber, Unit":(a,n)=>n.divideInto(a)})}),Mm="pow",dN=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],gN=R(Mm,dN,r=>{var{typed:e,config:t,identity:a,multiply:n,matrix:i,inv:s,number:f,fraction:l,Complex:u}=r;return e(Mm,{"number, number":o,"Complex, Complex":function(p,h){return p.pow(h)},"BigNumber, BigNumber":function(p,h){return h.isInteger()||p>=0||t.predictable?p.pow(h):new u(p.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(p,h){var y=p.pow(h);if(y!=null)return y;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return o(p.valueOf(),h.valueOf())},"Array, number":c,"Array, BigNumber":function(p,h){return c(p,h.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(p,h){return m(p,h.toNumber())},"Unit, number | BigNumber":function(p,h){return p.pow(h)}});function o(v,p){if(t.predictable&&!qe(p)&&v<0)try{var h=l(p),y=f(h);if((p===y||Math.abs((p-y)/p)<1e-14)&&h.d%2===1)return(h.n%2===0?1:-1)*Math.pow(-v,p)}catch{}return t.predictable&&(v<-1&&p===1/0||v>-1&&v<0&&p===-1/0)?NaN:qe(p)||v>=0||t.predictable?tc(v,p):v*v<1&&p===1/0||v*v>1&&p===-1/0?0:new u(v,0).pow(p,0)}function c(v,p){if(!qe(p))throw new TypeError("For A^b, b must be an integer (value is "+p+")");var h=er(v);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(p<0)try{return c(s(v),-p)}catch(A){throw A.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+p+")"):A}for(var y=a(h[0]).valueOf(),b=v;p>=1;)(p&1)===1&&(y=n(b,y)),p>>=1,b=n(b,b);return y}function m(v,p){return i(c(v.valueOf(),p))}}),na="Number of decimals in function round must be an integer",Fm="round",yN=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],bN=R(Fm,yN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,BigNumber:i,DenseMatrix:s}=r,f=Lr({typed:e,equalScalar:a}),l=Br({typed:e,DenseMatrix:s}),u=yt({typed:e});return e(Fm,{number:nc,"number, number":nc,"number, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);return new i(c).toDecimalPlaces(m.toNumber())},Complex:function(c){return c.round()},"Complex, number":function(c,m){if(m%1)throw new TypeError(na);return c.round(m)},"Complex, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);var v=m.toNumber();return c.round(v)},BigNumber:function(c){return c.toDecimalPlaces(0)},"BigNumber, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);return c.toDecimalPlaces(m.toNumber())},Fraction:function(c){return c.round()},"Fraction, number":function(c,m){if(m%1)throw new TypeError(na);return c.round(m)},"Fraction, BigNumber":function(c,m){if(!m.isInteger())throw new TypeError(na);return c.round(m.toNumber())},"Array | Matrix":e.referToSelf(o=>c=>je(c,o)),"SparseMatrix, number | BigNumber":e.referToSelf(o=>(c,m)=>f(c,m,o,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(o=>(c,m)=>u(c,m,o,!1)),"Array, number | BigNumber":e.referToSelf(o=>(c,m)=>u(t(c),m,o,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(o=>(c,m)=>a(c,0)?n(m.size(),m.storage()):l(m,c,o,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(o=>(c,m)=>a(c,0)?n(m.size(),m.storage()):u(m,c,o,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(o=>(c,m)=>u(t(m),c,o,!0).valueOf())})}),Tm="log",xN=["config","typed","divideScalar","Complex"],wN=R(Tm,xN,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r;return e(Tm,{number:function(s){return s>=0||t.predictable?C1(s):new n(s,0).log()},Complex:function(s){return s.log()},BigNumber:function(s){return!s.isNegative()||t.predictable?s.ln():new n(s.toNumber(),0).log()},"any, any":e.referToSelf(i=>(s,f)=>a(i(s),i(f)))})}),Bm="log1p",NN=["typed","config","divideScalar","log","Complex"],DN=R(Bm,NN,r=>{var{typed:e,config:t,divideScalar:a,log:n,Complex:i}=r;return e(Bm,{number:function(l){return l>=-1||t.predictable?F0(l):s(new i(l,0))},Complex:s,BigNumber:function(l){var u=l.plus(1);return!u.isNegative()||t.predictable?u.ln():s(new i(l.toNumber(),0))},"Array | Matrix":e.referToSelf(f=>l=>je(l,f)),"any, any":e.referToSelf(f=>(l,u)=>a(f(l),n(u)))});function s(f){var l=f.re+1;return new i(Math.log(Math.sqrt(l*l+f.im*f.im)),Math.atan2(f.im,l))}}),$m="nthRoots",AN=["config","typed","divideScalar","Complex"],EN=R($m,AN,r=>{var{typed:e,config:t,divideScalar:a,Complex:n}=r,i=[function(l){return new n(l,0)},function(l){return new n(0,l)},function(l){return new n(-l,0)},function(l){return new n(0,-l)}];function s(f,l){if(l<0)throw new Error("Root must be greater than zero");if(l===0)throw new Error("Root must be non-zero");if(l%1!==0)throw new Error("Root must be an integer");if(f===0||f.abs()===0)return[new n(0,0)];var u=typeof f=="number",o;(u||f.re===0||f.im===0)&&(u?o=2*+(f<0):f.im===0?o=2*+(f.re<0):o=2*+(f.im<0)+1);for(var c=f.arg(),m=f.abs(),v=[],p=Math.pow(m,1/l),h=0;h<l;h++){var y=(o+4*h)/l;if(y===Math.round(y)){v.push(i[y%4](p));continue}v.push(new n({r:p,phi:(c+2*Math.PI*h)/l}))}return v}return e($m,{Complex:function(l){return s(l,2)},"Complex, number":s})}),Om="dotPow",SN=["typed","equalScalar","matrix","pow","DenseMatrix"],CN=R(Om,SN,r=>{var{typed:e,equalScalar:t,matrix:a,pow:n,DenseMatrix:i}=r,s=Xr({typed:e}),f=Mt({typed:e,DenseMatrix:i}),l=Lr({typed:e,equalScalar:t}),u=Br({typed:e,DenseMatrix:i}),o=hr({typed:e,matrix:a}),c={};for(var m in n.signatures)Object.prototype.hasOwnProperty.call(n.signatures,m)&&!m.includes("Matrix")&&!m.includes("Array")&&(c[m]=n.signatures[m]);var v=e(c);return e(Om,o({elop:v,SS:f,DS:s,Ss:l,sS:u}))}),_m="dotDivide",MN=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],FN=R(_m,MN,r=>{var{typed:e,matrix:t,equalScalar:a,divideScalar:n,DenseMatrix:i}=r,s=bt({typed:e,equalScalar:a}),f=Xr({typed:e}),l=Mt({typed:e,DenseMatrix:i}),u=Lr({typed:e,equalScalar:a}),o=Br({typed:e,DenseMatrix:i}),c=hr({typed:e,matrix:t});return e(_m,c({elop:n,SS:l,DS:f,SD:s,Ss:u,sS:o}))});function ka(r){var{DenseMatrix:e}=r;return function(a,n,i){var s=a.size();if(s.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Ye(s)+")");var f=s[0],l=s[1];if(f!==l)throw new RangeError("Matrix must be square (size: "+Ye(s)+")");var u=[];if(He(n)){var o=n.size(),c=n._data;if(o.length===1){if(o[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m<f;m++)u[m]=[c[m]];return new e({data:u,size:[f,1],datatype:n._datatype})}if(o.length===2){if(o[0]!==f||o[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(ni(n)){if(i){u=[];for(var v=0;v<f;v++)u[v]=[c[v][0]];return new e({data:u,size:[f,1],datatype:n._datatype})}return n}if(Nn(n)){for(var p=0;p<f;p++)u[p]=[0];for(var h=n._values,y=n._index,b=n._ptr,A=b[1],d=b[0];d<A;d++){var w=y[d];u[w][0]=h[d]}return new e({data:u,size:[f,1],datatype:n._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(ur(n)){var x=er(n);if(x.length===1){if(x[0]!==f)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var g=0;g<f;g++)u[g]=[n[g]];return new e({data:u,size:[f,1]})}if(x.length===2){if(x[0]!==f||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var E=0;E<f;E++)u[E]=[n[E][0]];return new e({data:u,size:[f,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Im="lsolve",TN=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],BN=R(Im,TN,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(Im,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=[],b=c._data,A=0;A<h;A++){var d=v[A][0]||0,w=void 0;if(s(d,0))w=0;else{var x=b[A][A];if(s(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var g=A+1;g<p;g++)v[g]=[i(v[g][0]||0,n(w,b[g][A]))]}y[A]=[w]}return new f({data:y,size:[p,1]})}function o(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=[],w=0;w<h;w++){var x=v[w][0]||0;if(s(x,0))d[w]=[0];else{for(var g=0,E=[],N=[],S=A[w],D=A[w+1],T=S;T<D;T++){var B=b[T];B===w?g=y[T]:B>w&&(E.push(y[T]),N.push(B))}if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,g),L=0,G=N.length;L<G;L++){var C=N[L];v[C]=[i(v[C][0]||0,n(_,E[L]))]}d[w]=[_]}}return new f({data:d,size:[p,1]})}}),Rm="usolve",$N=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ON=R(Rm,$N,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(Rm,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.valueOf()}});function u(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=[],b=c._data,A=h-1;A>=0;A--){var d=v[A][0]||0,w=void 0;if(s(d,0))w=0;else{var x=b[A][A];if(s(x,0))throw new Error("Linear system cannot be solved since matrix is singular");w=a(d,x);for(var g=A-1;g>=0;g--)v[g]=[i(v[g][0]||0,n(w,b[g][A]))]}y[A]=[w]}return new f({data:y,size:[p,1]})}function o(c,m){m=l(c,m,!0);for(var v=m._data,p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=[],w=h-1;w>=0;w--){var x=v[w][0]||0;if(s(x,0))d[w]=[0];else{for(var g=0,E=[],N=[],S=A[w],D=A[w+1],T=D-1;T>=S;T--){var B=b[T];B===w?g=y[T]:B<w&&(E.push(y[T]),N.push(B))}if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,g),L=0,G=N.length;L<G;L++){var C=N[L];v[C]=[i(v[C][0],n(_,E[L]))]}d[w]=[_]}}return new f({data:d,size:[p,1]})}}),qm="lsolveAll",_N=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],IN=R(qm,_N,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(qm,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.map(y=>y.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(N=>N[0])],p=c._data,h=c._size[0],y=c._size[1],b=0;b<y;b++)for(var A=v.length,d=0;d<A;d++){var w=v[d];if(s(p[b][b],0))if(s(w[b],0)){if(d===0){var g=[...w];g[b]=1;for(var E=b+1;E<y;E++)g[E]=i(g[E],p[E][b]);v.push(g)}}else{if(d===0)return[];v.splice(d,1),d-=1,A-=1}else{w[b]=a(w[b],p[b][b]);for(var x=b+1;x<y;x++)w[x]=i(w[x],n(w[b],p[x][b]))}}return v.map(N=>new f({data:N.map(S=>[S]),size:[h,1]}))}function o(c,m){for(var v=[l(c,m,!0)._data.map(Y=>Y[0])],p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=0;d<h;d++)for(var w=v.length,x=0;x<w;x++){for(var g=v[x],E=[],N=[],S=A[d],D=A[d+1],T=0,B=S;B<D;B++){var _=b[B];_===d?T=y[B]:_>d&&(E.push(y[B]),N.push(_))}if(s(T,0))if(s(g[d],0)){if(x===0){var F=[...g];F[d]=1;for(var Z=0,$=N.length;Z<$;Z++){var U=N[Z];F[U]=i(F[U],E[Z])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{g[d]=a(g[d],T);for(var L=0,G=N.length;L<G;L++){var C=N[L];g[C]=i(g[C],n(g[d],E[L]))}}}return v.map(Y=>new f({data:Y.map(j=>[j]),size:[p,1]}))}}),zm="usolveAll",RN=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],qN=R(zm,RN,r=>{var{typed:e,matrix:t,divideScalar:a,multiplyScalar:n,subtract:i,equalScalar:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(zm,{"SparseMatrix, Array | Matrix":function(m,v){return o(m,v)},"DenseMatrix, Array | Matrix":function(m,v){return u(m,v)},"Array, Array | Matrix":function(m,v){var p=t(m),h=u(p,v);return h.map(y=>y.valueOf())}});function u(c,m){for(var v=[l(c,m,!0)._data.map(N=>N[0])],p=c._data,h=c._size[0],y=c._size[1],b=y-1;b>=0;b--)for(var A=v.length,d=0;d<A;d++){var w=v[d];if(s(p[b][b],0))if(s(w[b],0)){if(d===0){var g=[...w];g[b]=1;for(var E=b-1;E>=0;E--)g[E]=i(g[E],p[E][b]);v.push(g)}}else{if(d===0)return[];v.splice(d,1),d-=1,A-=1}else{w[b]=a(w[b],p[b][b]);for(var x=b-1;x>=0;x--)w[x]=i(w[x],n(w[b],p[x][b]))}}return v.map(N=>new f({data:N.map(S=>[S]),size:[h,1]}))}function o(c,m){for(var v=[l(c,m,!0)._data.map(Y=>Y[0])],p=c._size[0],h=c._size[1],y=c._values,b=c._index,A=c._ptr,d=h-1;d>=0;d--)for(var w=v.length,x=0;x<w;x++){for(var g=v[x],E=[],N=[],S=A[d],D=A[d+1],T=0,B=D-1;B>=S;B--){var _=b[B];_===d?T=y[B]:_<d&&(E.push(y[B]),N.push(_))}if(s(T,0))if(s(g[d],0)){if(x===0){var F=[...g];F[d]=1;for(var Z=0,$=N.length;Z<$;Z++){var U=N[Z];F[U]=i(F[U],E[Z])}v.push(F)}}else{if(x===0)return[];v.splice(x,1),x-=1,w-=1}else{g[d]=a(g[d],T);for(var L=0,G=N.length;L<G;L++){var C=N[L];g[C]=i(g[C],n(g[d],E[L]))}}}return v.map(Y=>new f({data:Y.map(j=>[j]),size:[p,1]}))}}),zN="matAlgo08xS0Sid",PN=["typed","equalScalar"],cs=R(zN,PN,r=>{var{typed:e,equalScalar:t}=r;return function(n,i,s){var f=n._values,l=n._index,u=n._ptr,o=n._size,c=n._datatype,m=i._values,v=i._index,p=i._ptr,h=i._size,y=i._datatype;if(o.length!==h.length)throw new Ke(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");if(!f||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var b=o[0],A=o[1],d,w=t,x=0,g=s;typeof c=="string"&&c===y&&(d=c,w=e.find(t,[d,d]),x=e.convert(0,d),g=e.find(s,[d,d]));for(var E=[],N=[],S=[],D=[],T=[],B,_,L,G,C=0;C<A;C++){S[C]=N.length;var F=C+1;for(_=u[C],L=u[C+1],B=_;B<L;B++)G=l[B],T[G]=F,D[G]=f[B],N.push(G);for(_=p[C],L=p[C+1],B=_;B<L;B++)G=v[B],T[G]===F&&(D[G]=g(D[G],m[B]));for(B=S[C];B<N.length;){G=N[B];var Z=D[G];w(Z,x)?N.splice(B,1):(E.push(Z),B++)}}return S[A]=N.length,n.createSparseMatrix({values:E,index:N,ptr:S,size:[b,A],datatype:d})}}),fs=R("useMatrixForArrayScalar",["typed","matrix"],r=>{var{typed:e,matrix:t}=r;return{"Array, number":e.referTo("DenseMatrix, number",a=>(n,i)=>a(t(n),i).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",a=>(n,i)=>a(t(n),i).valueOf()),"number, Array":e.referTo("number, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",a=>(n,i)=>a(n,t(i)).valueOf())}}),Pm="leftShift",LN=["typed","matrix","equalScalar","zeros","DenseMatrix"],UN=R(Pm,LN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,s=cn({typed:e}),f=bt({typed:e,equalScalar:a}),l=cs({typed:e,equalScalar:a}),u=Mn({typed:e,DenseMatrix:i}),o=Lr({typed:e,equalScalar:a}),c=yt({typed:e}),m=hr({typed:e,matrix:t}),v=fs({typed:e,matrix:t});return e(Pm,{"number, number":uc,"BigNumber, BigNumber":fx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():o(h,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():c(h,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):u(y,h,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):c(y,h,p,!0))},v,m({SS:l,DS:s,SD:f}))}),Lm="rightArithShift",kN=["typed","matrix","equalScalar","zeros","DenseMatrix"],VN=R(Lm,kN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,s=cn({typed:e}),f=bt({typed:e,equalScalar:a}),l=cs({typed:e,equalScalar:a}),u=Mn({typed:e,DenseMatrix:i}),o=Lr({typed:e,equalScalar:a}),c=yt({typed:e}),m=hr({typed:e,matrix:t}),v=fs({typed:e,matrix:t});return e(Lm,{"number, number":lc,"BigNumber, BigNumber":mx,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():o(h,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():c(h,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):u(y,h,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):c(y,h,p,!0))},v,m({SS:l,DS:s,SD:f}))}),Um="rightLogShift",GN=["typed","matrix","equalScalar","zeros","DenseMatrix"],HN=R(Um,GN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,DenseMatrix:i}=r,s=cn({typed:e}),f=bt({typed:e,equalScalar:a}),l=cs({typed:e,equalScalar:a}),u=Mn({typed:e,DenseMatrix:i}),o=Lr({typed:e,equalScalar:a}),c=yt({typed:e}),m=hr({typed:e,matrix:t}),v=fs({typed:e,matrix:t});return e(Um,{"number, number":cc,"SparseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():o(h,y,p,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(p=>(h,y)=>a(y,0)?h.clone():c(h,y,p,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):u(y,h,p,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(p=>(h,y)=>a(h,0)?n(y.size(),y.storage()):c(y,h,p,!0))},v,m({SS:l,DS:s,SD:f}))}),km="and",ZN=["typed","matrix","equalScalar","zeros","not"],JN=R(km,ZN,r=>{var{typed:e,matrix:t,equalScalar:a,zeros:n,not:i}=r,s=bt({typed:e,equalScalar:a}),f=Mi({typed:e,equalScalar:a}),l=Lr({typed:e,equalScalar:a}),u=yt({typed:e}),o=hr({typed:e,matrix:t});return e(km,{"number, number":hc,"Complex, Complex":function(m,v){return(m.re!==0||m.im!==0)&&(v.re!==0||v.im!==0)},"BigNumber, BigNumber":function(m,v){return!m.isZero()&&!v.isZero()&&!m.isNaN()&&!v.isNaN()},"Unit, Unit":e.referToSelf(c=>(m,v)=>c(m.value||0,v.value||0)),"SparseMatrix, any":e.referToSelf(c=>(m,v)=>i(v)?n(m.size(),m.storage()):l(m,v,c,!1)),"DenseMatrix, any":e.referToSelf(c=>(m,v)=>i(v)?n(m.size(),m.storage()):u(m,v,c,!1)),"any, SparseMatrix":e.referToSelf(c=>(m,v)=>i(m)?n(m.size(),m.storage()):l(v,m,c,!0)),"any, DenseMatrix":e.referToSelf(c=>(m,v)=>i(m)?n(m.size(),m.storage()):u(v,m,c,!0)),"Array, any":e.referToSelf(c=>(m,v)=>c(t(m),v).valueOf()),"any, Array":e.referToSelf(c=>(m,v)=>c(m,t(v)).valueOf())},o({SS:f,DS:s}))}),Bi="compare",WN=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],XN=R(Bi,WN,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,BigNumber:i,Fraction:s,DenseMatrix:f}=r,l=Xr({typed:e}),u=Fi({typed:e,equalScalar:a}),o=Br({typed:e,DenseMatrix:f}),c=hr({typed:e,matrix:n}),m=ea({typed:e});return e(Bi,YN({typed:e,config:t}),{"boolean, boolean":function(p,h){return p===h?0:p>h?1:-1},"BigNumber, BigNumber":function(p,h){return Ct(p,h,t.epsilon)?new i(0):new i(p.cmp(h))},"Fraction, Fraction":function(p,h){return new s(p.compare(h))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,c({SS:u,DS:l,Ss:o}))}),YN=R(Bi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Bi,{"number, number":function(n,i){return et(n,i,t.epsilon)?0:n>i?1:-1}})}),aa=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})/,s=/^0x[0-9a-f]+$/i,f=/^0/,l=function(d){return r.insensitive&&(""+d).toLowerCase()||""+d},u=l(e).replace(n,"")||"",o=l(t).replace(n,"")||"",c=u.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=o.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),v=parseInt(u.match(s),16)||c.length!==1&&u.match(i)&&Date.parse(u),p=parseInt(o.match(s),16)||v&&o.match(i)&&Date.parse(o)||null,h,y;if(p){if(v<p)return-1;if(v>p)return 1}for(var b=0,A=Math.max(c.length,m.length);b<A;b++){if(h=!(c[b]||"").match(f)&&parseFloat(c[b])||c[b]||0,y=!(m[b]||"").match(f)&&parseFloat(m[b])||m[b]||0,isNaN(h)!==isNaN(y))return isNaN(h)?1:-1;if(typeof h!=typeof y&&(h+="",y+=""),h<y)return-1;if(h>y)return 1}return 0},Vm="compareNatural",QN=["typed","compare"],KN=R(Vm,QN,r=>{var{typed:e,compare:t}=r,a=t.signatures["boolean,boolean"];return e(Vm,{"any, any":n});function n(l,u){var o=gr(l),c=gr(u),m;if((o==="number"||o==="BigNumber"||o==="Fraction")&&(c==="number"||c==="BigNumber"||c==="Fraction"))return m=t(l,u),m.toString()!=="0"?m>0?1:-1:aa(o,c);var v=["Array","DenseMatrix","SparseMatrix"];if(v.includes(o)||v.includes(c))return m=i(n,l,u),m!==0?m:aa(o,c);if(o!==c)return aa(o,c);if(o==="Complex")return jN(l,u);if(o==="Unit")return l.equalBase(u)?n(l.value,u.value):s(n,l.formatUnits(),u.formatUnits());if(o==="boolean")return a(l,u);if(o==="string")return aa(l,u);if(o==="Object")return f(n,l,u);if(o==="null"||o==="undefined")return 0;throw new TypeError('Unsupported type of value "'+o+'"')}function i(l,u,o){return Nn(u)&&Nn(o)?s(l,u.toJSON().values,o.toJSON().values):Nn(u)?i(l,u.toArray(),o):Nn(o)?i(l,u,o.toArray()):ni(u)?i(l,u.toJSON().data,o):ni(o)?i(l,u,o.toJSON().data):Array.isArray(u)?Array.isArray(o)?s(l,u,o):i(l,u,[o]):i(l,[u],o)}function s(l,u,o){for(var c=0,m=Math.min(u.length,o.length);c<m;c++){var v=l(u[c],o[c]);if(v!==0)return v}return u.length>o.length?1:u.length<o.length?-1:0}function f(l,u,o){var c=Object.keys(u),m=Object.keys(o);c.sort(aa),m.sort(aa);var v=s(l,c,m);if(v!==0)return v;for(var p=0;p<c.length;p++){var h=l(u[c[p]],o[m[p]]);if(h!==0)return h}return 0}});function jN(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 Gm="compareText",e2=["typed","matrix"];Uo.signature="any, any";var r2=R(Gm,e2,r=>{var{typed:e,matrix:t}=r,a=hr({typed:e,matrix:t});return e(Gm,Uo,a({elop:Uo,Ds:!0}))}),$i="equal",t2=["typed","matrix","equalScalar","DenseMatrix"],n2=R($i,t2,r=>{var{typed:e,matrix:t,equalScalar:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:t});return e($i,a2({typed:e,equalScalar:a}),l({elop:a,SS:s,DS:i,Ss:f}))}),a2=R($i,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e($i,{"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)}})}),Hm="equalText",i2=["typed","compareText","isZero"],o2=R(Hm,i2,r=>{var{typed:e,compareText:t,isZero:a}=r;return e(Hm,{"any, any":function(i,s){return a(t(i,s))}})}),Oi="smaller",s2=["typed","config","matrix","DenseMatrix"],u2=R(Oi,s2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(Oi,l2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o<c,"BigNumber, BigNumber":function(c,m){return c.lt(m)&&!Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)===-1,"Complex, Complex":function(c,m){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),l2=R(Oi,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Oi,{"number, number":function(n,i){return n<i&&!et(n,i,t.epsilon)}})}),_i="smallerEq",c2=["typed","config","matrix","DenseMatrix"],f2=R(_i,c2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(_i,m2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o<=c,"BigNumber, BigNumber":function(c,m){return c.lte(m)||Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),m2=R(_i,["typed","config"],r=>{var{typed:e,config:t}=r;return e(_i,{"number, number":function(n,i){return n<=i||et(n,i,t.epsilon)}})}),Ii="larger",v2=["typed","config","matrix","DenseMatrix"],p2=R(Ii,v2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(Ii,h2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o>c,"BigNumber, BigNumber":function(c,m){return c.gt(m)&&!Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),h2=R(Ii,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ii,{"number, number":function(n,i){return n>i&&!et(n,i,t.epsilon)}})}),Ri="largerEq",d2=["typed","config","matrix","DenseMatrix"],g2=R(Ri,d2,r=>{var{typed:e,config:t,matrix:a,DenseMatrix:n}=r,i=Xr({typed:e}),s=Mt({typed:e,DenseMatrix:n}),f=Br({typed:e,DenseMatrix:n}),l=hr({typed:e,matrix:a}),u=ea({typed:e});return e(Ri,y2({typed:e,config:t}),{"boolean, boolean":(o,c)=>o>=c,"BigNumber, BigNumber":function(c,m){return c.gte(m)||Ct(c,m,t.epsilon)},"Fraction, Fraction":(o,c)=>o.compare(c)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},u,l({SS:s,DS:i,Ss:f}))}),y2=R(Ri,["typed","config"],r=>{var{typed:e,config:t}=r;return e(Ri,{"number, number":function(n,i){return n>=i||et(n,i,t.epsilon)}})}),Zm="deepEqual",b2=["typed","equal"],x2=R(Zm,b2,r=>{var{typed:e,equal:t}=r;return e(Zm,{"any, any":function(i,s){return a(i.valueOf(),s.valueOf())}});function a(n,i){if(Array.isArray(n))if(Array.isArray(i)){var s=n.length;if(s!==i.length)return!1;for(var f=0;f<s;f++)if(!a(n[f],i[f]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),qi="unequal",w2=["typed","config","equalScalar","matrix","DenseMatrix"],N2=R(qi,w2,r=>{var{typed:e,config:t,equalScalar:a,matrix:n,DenseMatrix:i}=r,s=Xr({typed:e}),f=Mt({typed:e,DenseMatrix:i}),l=Br({typed:e,DenseMatrix:i}),u=hr({typed:e,matrix:n});return e(qi,D2({typed:e,equalScalar:a}),u({elop:o,SS:f,DS:s,Ss:l}));function o(c,m){return!a(c,m)}}),D2=R(qi,["typed","equalScalar"],r=>{var{typed:e,equalScalar:t}=r;return e(qi,{"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)}})}),Jm="partitionSelect",A2=["typed","isNumeric","isNaN","compare"],E2=R(Jm,A2,r=>{var{typed:e,isNumeric:t,isNaN:a,compare:n}=r,i=n,s=(u,o)=>-n(u,o);return e(Jm,{"Array | Matrix, number":function(o,c){return f(o,c,i)},"Array | Matrix, number, string":function(o,c,m){if(m==="asc")return f(o,c,i);if(m==="desc")return f(o,c,s);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":f});function f(u,o,c){if(!qe(o)||o<0)throw new Error("k must be a non-negative integer");if(He(u)){var m=u.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return l(u.valueOf(),o,c)}if(Array.isArray(u))return l(u,o,c)}function l(u,o,c){if(o>=u.length)throw new Error("k out of bounds");for(var m=0;m<u.length;m++)if(t(u[m])&&a(u[m]))return u[m];for(var v=0,p=u.length-1;v<p;){for(var h=v,y=p,b=u[Math.floor(Math.random()*(p-v+1))+v];h<y;)if(c(u[h],b)>=0){var A=u[y];u[y]=u[h],u[h]=A,--y}else++h;c(u[h],b)>0&&--h,o<=h?p=h:v=h+1}return u[o]}}),Wm="sort",S2=["typed","matrix","compare","compareNatural"],C2=R(Wm,S2,r=>{var{typed:e,matrix:t,compare:a,compareNatural:n}=r,i=a,s=(o,c)=>-a(o,c);return e(Wm,{Array:function(c){return l(c),c.sort(i)},Matrix:function(c){return u(c),t(c.toArray().sort(i),c.storage())},"Array, function":function(c,m){return l(c),c.sort(m)},"Matrix, function":function(c,m){return u(c),t(c.toArray().sort(m),c.storage())},"Array, string":function(c,m){return l(c),c.sort(f(m))},"Matrix, string":function(c,m){return u(c),t(c.toArray().sort(f(m)),c.storage())}});function f(o){if(o==="asc")return i;if(o==="desc")return s;if(o==="natural")return n;throw new Error('String "asc", "desc", or "natural" expected')}function l(o){if(er(o).length!==1)throw new Error("One dimensional array expected")}function u(o){if(o.size().length!==1)throw new Error("One dimensional matrix expected")}}),Xm="max",M2=["typed","config","numeric","larger"],Ym=R(Xm,M2,r=>{var{typed:e,config:t,numeric:a,larger:n}=r;return e(Xm,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,u){return wi(l,u.valueOf(),i)},"...":function(l){if(Qn(l))throw new TypeError("Scalar values expected in function max");return s(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Yr(u,"max",l)}}function s(f){var l;if(Gt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(o){throw Yr(o,"max",u)}}),l===void 0)throw new Error("Cannot calculate max of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),Qm="min",F2=["typed","config","numeric","smaller"],Km=R(Qm,F2,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r;return e(Qm,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,u){return wi(l,u.valueOf(),i)},"...":function(l){if(Qn(l))throw new TypeError("Scalar values expected in function min");return s(l)}});function i(f,l){try{return n(f,l)?f:l}catch(u){throw Yr(u,"min",l)}}function s(f){var l;if(Gt(f,function(u){try{isNaN(u)&&typeof u=="number"?l=NaN:(l===void 0||n(u,l))&&(l=u)}catch(o){throw Yr(o,"min",u)}}),l===void 0)throw new Error("Cannot calculate min of an empty array");return typeof l=="string"&&(l=a(l,t.number)),l}}),T2="ImmutableDenseMatrix",B2=["smaller","DenseMatrix"],$2=R(T2,B2,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&&!Wr(i))throw new Error("Invalid datatype: "+i);if(He(n)||ur(n)){var s=new t(n,i);this._data=s._data,this._size=s._size,this._datatype=s._datatype,this._min=null,this._max=null}else if(n&&ur(n.data)&&ur(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 ("+gr(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 He(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:ke(this._data),size:ke(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}),O2="Index",_2=["ImmutableDenseMatrix"],I2=R(O2,_2,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,s=arguments.length;i<s;i++){var f=arguments[i];if(Ro(f))this._dimensions.push(f),this._isScalar=!1;else if(Array.isArray(f)||He(f)){var l=a(f.valueOf());this._dimensions.push(l);var u=l.size();(u.length!==1||u[0]!==1)&&(this._isScalar=!1)}else if(typeof f=="number")this._dimensions.push(a([f]));else if(typeof f=="string")this._dimensions.push(f);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,s=n.length;i<s;i++)if(typeof n[i]!="number"||!qe(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=ke(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,s=this._dimensions.length;i<s;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?1:f.size()[0]}return n},t.prototype.max=function(){for(var n=[],i=0,s=this._dimensions.length;i<s;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.max()}return n},t.prototype.min=function(){for(var n=[],i=0,s=this._dimensions.length;i<s;i++){var f=this._dimensions[i];n[i]=typeof f=="string"?f:f.min()}return n},t.prototype.forEach=function(n){for(var i=0,s=this._dimensions.length;i<s;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,s=this._dimensions.length;i<s;i++){var f=this._dimensions[i];n.push(typeof f=="string"?f:f.toArray())}return n},t.prototype.valueOf=t.prototype.toArray,t.prototype.toString=function(){for(var n=[],i=0,s=this._dimensions.length;i<s;i++){var f=this._dimensions[i];typeof f=="string"?n.push(JSON.stringify(f)):n.push(f.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}),R2="FibonacciHeap",q2=["smaller","larger"],z2=R(R2,q2,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(o,c){var m={key:o,value:c,degree:0};if(this._minimum){var v=this._minimum;m.left=v,m.right=v.right,v.right=m,m.right.left=m,e(o,v.key)&&(this._minimum=m)}else m.left=m,m.right=m,this._minimum=m;return this._size++,m},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 o=this._minimum;if(o===null)return o;for(var c=this._minimum,m=o.degree,v=o.child;m>0;){var p=v.right;v.left.right=v.right,v.right.left=v.left,v.left=c,v.right=c.right,c.right=v,v.right.left=v,v.parent=null,v=p,m--}return o.left.right=o.right,o.right.left=o.left,o===o.right?c=null:(c=o.right,c=u(c,this._size)),this._size--,this._minimum=c,o},n.prototype.remove=function(o){this._minimum=i(this._minimum,o,-1),this.extractMinimum()};function i(o,c,m){c.key=m;var v=c.parent;return v&&e(c.key,v.key)&&(s(o,c,v),f(o,v)),e(c.key,o.key)&&(o=c),o}function s(o,c,m){c.left.right=c.right,c.right.left=c.left,m.degree--,m.child===c&&(m.child=c.right),m.degree===0&&(m.child=null),c.left=o,c.right=o.right,o.right=c,c.right.left=c,c.parent=null,c.mark=!1}function f(o,c){var m=c.parent;!m||(c.mark?(s(o,c,m),f(m)):c.mark=!0)}var l=function(c,m){c.left.right=c.right,c.right.left=c.left,c.parent=m,m.child?(c.left=m.child,c.right=m.child.right,m.child.right=c,c.right.left=c):(m.child=c,c.right=c,c.left=c),m.degree++,c.mark=!1};function u(o,c){var m=Math.floor(Math.log(c)*a)+1,v=new Array(m),p=0,h=o;if(h)for(p++,h=h.right;h!==o;)p++,h=h.right;for(var y;p>0;){for(var b=h.degree,A=h.right;y=v[b],!!y;){if(t(h.key,y.key)){var d=y;y=h,h=d}l(y,h),v[b]=null,b++}v[b]=h,h=A,p--}o=null;for(var w=0;w<m;w++)y=v[w],y&&(o?(y.left.right=y.right,y.right.left=y.left,y.left=o,y.right=o.right,o.right=y,y.right.left=y,e(y.key,o.key)&&(o=y)):o=y);return o}return n},{isClass:!0}),P2="Spa",L2=["addScalar","equalScalar","FibonacciHeap"],U2=R(P2,L2,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,s){if(this._values[i])this._values[i].value=s;else{var f=this._heap.insert(i,s);this._values[i]=f}},n.prototype.get=function(i){var s=this._values[i];return s?s.value:0},n.prototype.accumulate=function(i,s){var f=this._values[i];f?f.value=e(f.value,s):(f=this._heap.insert(i,s),this._values[i]=f)},n.prototype.forEach=function(i,s,f){var l=this._heap,u=this._values,o=[],c=l.extractMinimum();for(c&&o.push(c);c&&c.key<=s;)c.key>=i&&(t(c.value,0)||f(c.key,c.value,this)),c=l.extractMinimum(),c&&o.push(c);for(var m=0;m<o.length;m++){var v=o[m];c=l.insert(v.key,v.value),u[c.key]=c}},n.prototype.swap=function(i,s){var f=this._values[i],l=this._values[s];if(!f&&l)f=this._heap.insert(i,l.value),this._heap.remove(l),this._values[i]=f,this._values[s]=void 0;else if(f&&!l)l=this._heap.insert(s,f.value),this._heap.remove(f),this._values[s]=l,this._values[i]=void 0;else if(f&&l){var u=f.value;f.value=l.value,l.value=u}},n},{isClass:!0});function Ir(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var k2=Pa(function(r){return new r(1).exp()},{hasher:zi}),V2=Pa(function(r){return new r(1).plus(new r(5).sqrt()).div(2)},{hasher:zi}),ms=Pa(function(r){return r.acos(-1)},{hasher:zi}),G2=Pa(function(r){return ms(r).times(2)},{hasher:zi});function zi(r){return r[0].precision}function jm(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 vs(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?jm(Object(t),!0).forEach(function(a){Ir(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):jm(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var H2="Unit",Z2=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],J2=R(H2,Z2,r=>{var{on:e,config:t,addScalar:a,subtract:n,multiplyScalar:i,divideScalar:s,pow:f,abs:l,fix:u,round:o,equal:c,isNumeric:m,format:v,number:p,Complex:h,BigNumber:y,Fraction:b}=r,A=p;function d(k,W){if(!(this instanceof d))throw new Error("Constructor must be called with the new operator");if(!(k==null||m(k)||zt(k)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,W===void 0)this.units=[],this.dimensions=Z.map(V=>0);else if(typeof W=="string"){var ie=d.parse(W);this.units=ie.units,this.dimensions=ie.dimensions}else if(Pt(W)&&W.value===null)this.fixPrefix=W.fixPrefix,this.skipAutomaticSimplification=W.skipAutomaticSimplification,this.dimensions=W.dimensions.slice(0),this.units=W.units.map(V=>Ar({},V));else throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.value=this._normalize(k)}Object.defineProperty(d,"name",{value:"Unit"}),d.prototype.constructor=d,d.prototype.type="Unit",d.prototype.isUnit=!0;var w,x,g;function E(){for(;g===" "||g===" ";)D()}function N(k){return k>="0"&&k<="9"||k==="."}function S(k){return k>="0"&&k<="9"}function D(){x++,g=w.charAt(x)}function T(k){x=k,g=w.charAt(x)}function B(){var k="",W=x;if(g==="+"?D():g==="-"&&(k+=g,D()),!N(g))return T(W),null;if(g==="."){if(k+=g,D(),!S(g))return T(W),null}else{for(;S(g);)k+=g,D();g==="."&&(k+=g,D())}for(;S(g);)k+=g,D();if(g==="E"||g==="e"){var ie="",V=x;if(ie+=g,D(),(g==="+"||g==="-")&&(ie+=g,D()),!S(g))return T(V),k;for(k=k+ie;S(g);)k+=g,D()}return k}function _(){for(var k="";S(g)||d.isValidAlpha(g);)k+=g,D();var W=k.charAt(0);return d.isValidAlpha(W)?k:null}function L(k){return g===k?(D(),k):null}d.parse=function(k,W){if(W=W||{},w=k,x=-1,g="",typeof w!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var ie=new d;ie.units=[];var V=1,Q=!1;D(),E();var te=B(),ge=null;if(te){if(t.number==="BigNumber")ge=new y(te);else if(t.number==="Fraction")try{ge=new b(te)}catch{ge=parseFloat(te)}else ge=parseFloat(te);E(),L("*")?(V=1,Q=!0):L("/")&&(V=-1,Q=!0)}for(var he=[],q=1;;){for(E();g==="(";)he.push(V),q*=V,V=1,D(),E();var z=void 0;if(g){var ee=g;if(z=_(),z===null)throw new SyntaxError('Unexpected "'+ee+'" in "'+w+'" at index '+x.toString())}else break;var ue=G(z);if(ue===null)throw new SyntaxError('Unit "'+z+'" not found.');var me=V*q;if(E(),L("^")){E();var ye=B();if(ye===null)throw new SyntaxError('In "'+k+'", "^" must be followed by a floating-point number');me*=ye}ie.units.push({unit:ue.unit,prefix:ue.prefix,power:me});for(var be=0;be<Z.length;be++)ie.dimensions[be]+=(ue.unit.dimensions[be]||0)*me;for(E();g===")";){if(he.length===0)throw new SyntaxError('Unmatched ")" in "'+w+'" at index '+x.toString());q/=he.pop(),D(),E()}if(Q=!1,L("*")?(V=1,Q=!0):L("/")?(V=-1,Q=!0):V=1,ue.unit.base){var ve=ue.unit.base.key;re.auto[ve]={unit:ue.unit,prefix:ue.prefix}}}if(E(),g)throw new SyntaxError('Could not parse: "'+k+'"');if(Q)throw new SyntaxError('Trailing characters: "'+k+'"');if(he.length!==0)throw new SyntaxError('Unmatched "(" in "'+w+'"');if(ie.units.length===0&&!W.allowNoUnits)throw new SyntaxError('"'+k+'" contains no units');return ie.value=ge!==void 0?ie._normalize(ge):null,ie},d.prototype.clone=function(){var k=new d;k.fixPrefix=this.fixPrefix,k.skipAutomaticSimplification=this.skipAutomaticSimplification,k.value=ke(this.value),k.dimensions=this.dimensions.slice(0),k.units=[];for(var W=0;W<this.units.length;W++){k.units[W]={};for(var ie in this.units[W])Re(this.units[W],ie)&&(k.units[W][ie]=this.units[W][ie])}return k},d.prototype.valueType=function(){return gr(this.value)},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(k){if(k==null||this.units.length===0)return k;for(var W=k,ie=d._getNumberConverter(gr(k)),V=0;V<this.units.length;V++){var Q=ie(this.units[V].unit.value),te=ie(this.units[V].prefix.value),ge=ie(this.units[V].power);W=i(W,f(i(Q,te),ge))}return W},d.prototype._denormalize=function(k,W){if(k==null||this.units.length===0)return k;for(var ie=k,V=d._getNumberConverter(gr(k)),Q=0;Q<this.units.length;Q++){var te=V(this.units[Q].unit.value),ge=V(this.units[Q].prefix.value),he=V(this.units[Q].power);ie=s(ie,f(i(te,ge),he))}return ie};var G=Pa(k=>{if(Re(P,k)){var W=P[k],ie=W.prefixes[""];return{unit:W,prefix:ie}}for(var V in P)if(Re(P,V)&&Z0(k,V)){var Q=P[V],te=k.length-V.length,ge=k.substring(0,te),he=Re(Q.prefixes,ge)?Q.prefixes[ge]:void 0;if(he!==void 0)return{unit:Q,prefix:he}}return null},{hasher:k=>k[0],limit:100});d.isValuelessUnit=function(k){return G(k)!==null},d.prototype.hasBase=function(k){if(typeof k=="string"&&(k=$[k]),!k)return!1;for(var W=0;W<Z.length;W++)if(Math.abs((this.dimensions[W]||0)-(k.dimensions[W]||0))>1e-12)return!1;return!0},d.prototype.equalBase=function(k){for(var W=0;W<Z.length;W++)if(Math.abs((this.dimensions[W]||0)-(k.dimensions[W]||0))>1e-12)return!1;return!0},d.prototype.equals=function(k){return this.equalBase(k)&&c(this.value,k.value)},d.prototype.multiply=function(k){for(var W=this.clone(),ie=Pt(k)?k:new d(k),V=0;V<Z.length;V++)W.dimensions[V]=(this.dimensions[V]||0)+(ie.dimensions[V]||0);for(var Q=0;Q<ie.units.length;Q++){var te=vs({},ie.units[Q]);W.units.push(te)}if(this.value!==null||ie.value!==null){var ge=this.value===null?this._normalize(1):this.value,he=ie.value===null?ie._normalize(1):ie.value;W.value=i(ge,he)}else W.value=null;return Pt(k)&&(W.skipAutomaticSimplification=!1),C(W)},d.prototype.divideInto=function(k){return new d(k).divide(this)},d.prototype.divide=function(k){for(var W=this.clone(),ie=Pt(k)?k:new d(k),V=0;V<Z.length;V++)W.dimensions[V]=(this.dimensions[V]||0)-(ie.dimensions[V]||0);for(var Q=0;Q<ie.units.length;Q++){var te=vs(vs({},ie.units[Q]),{},{power:-ie.units[Q].power});W.units.push(te)}if(this.value!==null||ie.value!==null){var ge=this.value===null?this._normalize(1):this.value,he=ie.value===null?ie._normalize(1):ie.value;W.value=s(ge,he)}else W.value=null;return Pt(k)&&(W.skipAutomaticSimplification=!1),C(W)},d.prototype.pow=function(k){for(var W=this.clone(),ie=0;ie<Z.length;ie++)W.dimensions[ie]=(this.dimensions[ie]||0)*k;for(var V=0;V<W.units.length;V++)W.units[V].power*=k;return W.value!==null?W.value=f(W.value,k):W.value=null,W.skipAutomaticSimplification=!1,C(W)};function C(k){return k.equalBase($.NONE)&&k.value!==null&&!t.predictable?k.value:k}d.prototype.abs=function(){var k=this.clone();if(k.value!==null)if(k._isDerived()||k.units[0].unit.offset===0)k.value=l(k.value);else{var W=k._numberConverter(),ie=W(k.units[0].unit.value),V=W(k.units[0].unit.offset),Q=i(ie,V);k.value=n(l(a(k.value,Q)),Q)}for(var te in k.units)(k.units[te].unit.name==="VA"||k.units[te].unit.name==="VAR")&&(k.units[te].unit=P.W);return k},d.prototype.to=function(k){var W=this.value===null?this._normalize(1):this.value,ie;if(typeof k=="string")ie=d.parse(k);else if(Pt(k))ie=k.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(ie))throw new Error("Units do not match ('".concat(ie.toString(),"' != '").concat(this.toString(),"')"));if(ie.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===ie.units[0].unit.offset)ie.value=ke(W);else{var V=d._getNumberConverter(gr(W)),Q=V(this.units[0].unit.value),te=V(this.units[0].unit.offset),ge=i(Q,te),he=V(ie.units[0].unit.value),q=V(ie.units[0].unit.offset),z=i(he,q);ie.value=n(a(W,ge),z)}return ie.fixPrefix=!0,ie.skipAutomaticSimplification=!0,ie},d.prototype.toNumber=function(k){return A(this.toNumeric(k))},d.prototype.toNumeric=function(k){var W;return k?W=this.to(k):W=this.clone(),W._isDerived()||W.units.length===0?W._denormalize(W.value):W._denormalize(W.value,W.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(k){var W=new d(k.value,k.unit);return W.fixPrefix=k.fixPrefix||!1,W},d.prototype.valueOf=d.prototype.toString,d.prototype.simplify=function(){var k=this.clone(),W=[],ie;for(var V in fe)if(Re(fe,V)&&k.hasBase($[V])){ie=V;break}if(ie==="NONE")k.units=[];else{var Q;if(ie&&Re(fe,ie)&&(Q=fe[ie]),Q)k.units=[{unit:Q.unit,prefix:Q.prefix,power:1}];else{for(var te=!1,ge=0;ge<Z.length;ge++){var he=Z[ge];Math.abs(k.dimensions[ge]||0)>1e-12&&(Re(fe,he)?W.push({unit:fe[he].unit,prefix:fe[he].prefix,power:k.dimensions[ge]||0}):te=!0)}W.length<k.units.length&&!te&&(k.units=W)}}return k},d.prototype.toSI=function(){for(var k=this.clone(),W=[],ie=0;ie<Z.length;ie++){var V=Z[ie];if(Math.abs(k.dimensions[ie]||0)>1e-12)if(Re(re.si,V))W.push({unit:re.si[V].unit,prefix:re.si[V].prefix,power:k.dimensions[ie]||0});else throw new Error("Cannot express custom unit "+V+" in SI units")}return k.units=W,k.fixPrefix=!0,k.skipAutomaticSimplification=!0,k},d.prototype.formatUnits=function(){for(var k="",W="",ie=0,V=0,Q=0;Q<this.units.length;Q++)this.units[Q].power>0?(ie++,k+=" "+this.units[Q].prefix.name+this.units[Q].unit.name,Math.abs(this.units[Q].power-1)>1e-15&&(k+="^"+this.units[Q].power)):this.units[Q].power<0&&V++;if(V>0)for(var te=0;te<this.units.length;te++)this.units[te].power<0&&(ie>0?(W+=" "+this.units[te].prefix.name+this.units[te].unit.name,Math.abs(this.units[te].power+1)>1e-15&&(W+="^"+-this.units[te].power)):(W+=" "+this.units[te].prefix.name+this.units[te].unit.name,W+="^"+this.units[te].power));k=k.substr(1),W=W.substr(1),ie>1&&V>0&&(k="("+k+")"),V>1&&ie>0&&(W="("+W+")");var ge=k;return ie>0&&V>0&&(ge+=" / "),ge+=W,ge},d.prototype.format=function(k){var W=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),ie=!1;typeof W.value<"u"&&W.value!==null&&zt(W.value)&&(ie=Math.abs(W.value.re)<1e-14);for(var V in W.units)Re(W.units,V)&&W.units[V].unit&&(W.units[V].unit.name==="VA"&&ie?W.units[V].unit=P.VAR:W.units[V].unit.name==="VAR"&&!ie&&(W.units[V].unit=P.VA));W.units.length===1&&!W.fixPrefix&&Math.abs(W.units[0].power-Math.round(W.units[0].power))<1e-14&&(W.units[0].prefix=W._bestPrefix());var Q=W._denormalize(W.value),te=W.value!==null?v(Q,k||{}):"",ge=W.formatUnits();return W.value&&zt(W.value)&&(te="("+te+")"),ge.length>0&&te.length>0&&(te+=" "),te+=ge,te},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 k=this.value!==null?l(this.value):0,W=l(this.units[0].unit.value),ie=this.units[0].prefix;if(k===0)return ie;var V=this.units[0].power,Q=Math.log(k/Math.pow(ie.value*W,V))/Math.LN10-1.2;if(Q>-2.200001&&Q<1.800001)return ie;Q=Math.abs(Q);var te=this.units[0].unit.prefixes;for(var ge in te)if(Re(te,ge)){var he=te[ge];if(he.scientific){var q=Math.abs(Math.log(k/Math.pow(he.value*W,V))/Math.LN10-1.2);(q<Q||q===Q&&he.name.length<ie.name.length)&&(ie=he,Q=q)}}return ie},d.prototype.splitUnit=function(k){for(var W=this.clone(),ie=[],V=0;V<k.length&&(W=W.to(k[V]),V!==k.length-1);V++){var Q=W.toNumeric(),te=o(Q),ge=void 0,he=c(te,Q);he?ge=te:ge=u(W.toNumeric());var q=new d(ge,k[V].toString());ie.push(q),W=n(W,q)}for(var z=0,ee=0;ee<ie.length;ee++)z=a(z,ie[ee].value);return c(z,this.value)&&(W.value=0),ie.push(W),ie};var F={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}}};F.SHORTLONG=Ar({},F.SHORT,F.LONG),F.BINARY_SHORT=Ar({},F.BINARY_SHORT_SI,F.BINARY_SHORT_IEC),F.BINARY_LONG=Ar({},F.BINARY_LONG_SI,F.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 U in $)Re($,U)&&($[U].key=U);var Y={},j={name:"",base:Y,value:1,offset:0,dimensions:Z.map(k=>0)},P={meter:{name:"meter",base:$.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:F.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:F.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:F.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:F.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:F.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:F.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:F.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:F.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:F.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:F.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:F.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:F.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:"month",base:$.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:F.NONE,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:F.NONE,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:F.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:F.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:F.NONE,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:F.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:F.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:F.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:F.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:F.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:F.SHORT,value:h.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},K={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function ne(k){if(k.number==="BigNumber"){var W=ms(y);P.rad.value=new y(1),P.deg.value=W.div(180),P.grad.value=W.div(200),P.cycle.value=W.times(2),P.arcsec.value=W.div(648e3),P.arcmin.value=W.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=Math.PI*2,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}ne(t),e&&e("config",function(k,W){k.number!==W.number&&ne(k)});var re={si:{NONE:{unit:j,prefix:F.NONE[""]},LENGTH:{unit:P.m,prefix:F.SHORT[""]},MASS:{unit:P.g,prefix:F.SHORT.k},TIME:{unit:P.s,prefix:F.SHORT[""]},CURRENT:{unit:P.A,prefix:F.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:F.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:F.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:F.SHORT[""]},ANGLE:{unit:P.rad,prefix:F.SHORT[""]},BIT:{unit:P.bits,prefix:F.SHORT[""]},FORCE:{unit:P.N,prefix:F.SHORT[""]},ENERGY:{unit:P.J,prefix:F.SHORT[""]},POWER:{unit:P.W,prefix:F.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:F.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:F.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:F.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:F.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:F.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:F.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:F.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:F.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:F.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:F.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:P.m,prefix:F.SHORT.c},re.cgs.MASS={unit:P.g,prefix:F.SHORT[""]},re.cgs.FORCE={unit:P.dyn,prefix:F.SHORT[""]},re.cgs.ENERGY={unit:P.erg,prefix:F.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:P.ft,prefix:F.NONE[""]},re.us.MASS={unit:P.lbm,prefix:F.NONE[""]},re.us.TEMPERATURE={unit:P.degF,prefix:F.NONE[""]},re.us.FORCE={unit:P.lbf,prefix:F.NONE[""]},re.us.ENERGY={unit:P.BTU,prefix:F.BTU[""]},re.us.POWER={unit:P.hp,prefix:F.NONE[""]},re.us.PRESSURE={unit:P.psi,prefix:F.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var fe=re.auto;d.setUnitSystem=function(k){if(Re(re,k))fe=re[k];else throw new Error("Unit system "+k+" does not exist. Choices are: "+Object.keys(re).join(", "))},d.getUnitSystem=function(){for(var k in re)if(Re(re,k)&&re[k]===fe)return k},d.typeConverters={BigNumber:function(W){return new y(W+"")},Fraction:function(W){return new b(W)},Complex:function(W){return W},number:function(W){return W}},d.prototype._numberConverter=function(){var k=d.typeConverters[this.valueType()];if(k)return k;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},d._getNumberConverter=function(k){if(!d.typeConverters[k])throw new TypeError('Unsupported type "'+k+'"');return d.typeConverters[k]};for(var pe in P)if(Re(P,pe)){var ce=P[pe];ce.dimensions=ce.base.dimensions}for(var oe in K)if(Re(K,oe)){var Ce=P[K[oe]],Oe={};for(var Me in Ce)Re(Ce,Me)&&(Oe[Me]=Ce[Me]);Oe.name=oe,P[oe]=Oe}d.isValidAlpha=function(W){return/^[a-zA-Z]$/.test(W)};function $e(k){for(var W=0;W<k.length;W++){if(g=k.charAt(W),W===0&&!d.isValidAlpha(g))throw new Error('Invalid unit name (must begin with alpha character): "'+k+'"');if(W>0&&!(d.isValidAlpha(g)||S(g)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+k+'"')}}return d.createUnit=function(k,W){if(typeof k!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(W&&W.override){for(var ie in k)if(Re(k,ie)&&d.deleteUnit(ie),k[ie].aliases)for(var V=0;V<k[ie].aliases.length;V++)d.deleteUnit(k[ie].aliases[V])}var Q;for(var te in k)Re(k,te)&&(Q=d.createUnitSingle(te,k[te]));return Q},d.createUnitSingle=function(k,W){if((typeof W>"u"||W===null)&&(W={}),typeof k!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Re(P,k))throw new Error('Cannot create unit "'+k+'": a unit with that name already exists');$e(k);var ie=null,V=[],Q=0,te,ge,he;if(W&&W.type==="Unit")ie=W.clone();else if(typeof W=="string")W!==""&&(te=W);else if(typeof W=="object")te=W.definition,ge=W.prefixes,Q=W.offset,he=W.baseName,W.aliases&&(V=W.aliases.valueOf());else throw new TypeError('Cannot create unit "'+k+'" from "'+W.toString()+'": expecting "string" or "Unit" or "Object"');if(V){for(var q=0;q<V.length;q++)if(Re(P,V[q]))throw new Error('Cannot create alias "'+V[q]+'": a unit with that name already exists')}if(te&&typeof te=="string"&&!ie)try{ie=d.parse(te,{allowNoUnits:!0})}catch(cr){throw cr.message='Could not create unit "'+k+'" from "'+te+'": '+cr.message,cr}else te&&te.type==="Unit"&&(ie=te.clone());V=V||[],Q=Q||0,ge&&ge.toUpperCase?ge=F[ge.toUpperCase()]||F.NONE:ge=F.NONE;var z={};if(ie){z={name:k,value:ie.value,dimensions:ie.dimensions.slice(0),prefixes:ge,offset:Q};var ye=!1;for(var be in $)if(Re($,be)){for(var ve=!0,Ne=0;Ne<Z.length;Ne++)if(Math.abs((z.dimensions[Ne]||0)-($[be].dimensions[Ne]||0))>1e-12){ve=!1;break}if(ve){ye=!0,z.base=$[be];break}}if(!ye){he=he||k+"_STUFF";var Ie={dimensions:ie.dimensions.slice(0)};Ie.key=he,$[he]=Ie,fe[he]={unit:z,prefix:F.NONE[""]},z.base=$[he]}}else{if(he=he||k+"_STUFF",Z.indexOf(he)>=0)throw new Error('Cannot create new base unit "'+k+'": a base unit with that name already exists (and cannot be overridden)');Z.push(he);for(var ee in $)Re($,ee)&&($[ee].dimensions[Z.length-1]=0);for(var ue={dimensions:[]},me=0;me<Z.length;me++)ue.dimensions[me]=0;ue.dimensions[Z.length-1]=1,ue.key=he,$[he]=ue,z={name:k,value:1,dimensions:$[he].dimensions.slice(0),prefixes:ge,offset:Q,base:$[he]},fe[he]={unit:z,prefix:F.NONE[""]}}d.UNITS[k]=z;for(var Ge=0;Ge<V.length;Ge++){var Be=V[Ge],lr={};for(var Je in z)Re(z,Je)&&(lr[Je]=z[Je]);lr.name=Be,d.UNITS[Be]=lr}return delete G.cache,new d(null,k)},d.deleteUnit=function(k){delete d.UNITS[k]},d.PREFIXES=F,d.BASE_DIMENSIONS=Z,d.BASE_UNITS=$,d.UNIT_SYSTEMS=re,d.UNITS=P,d},{isClass:!0}),ev="unit",W2=["typed","Unit"],X2=R(ev,W2,r=>{var{typed:e,Unit:t}=r;return e(ev,{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 | Unit":function(n,i){return new t(n,i)},"number | BigNumber | Fraction":function(n){return new t(n)},"Array | Matrix":e.referToSelf(a=>n=>je(n,a))})}),rv="sparse",Y2=["typed","SparseMatrix"],Q2=R(rv,Y2,r=>{var{typed:e,SparseMatrix:t}=r;return e(rv,{"":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)}})}),tv="createUnit",K2=["typed","Unit"],j2=R(tv,K2,r=>{var{typed:e,Unit:t}=r;return e(tv,{"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,s){var f={};return f[n]=i,t.createUnit(f,s)},"string, Unit | string | Object":function(n,i){var s={};return s[n]=i,t.createUnit(s,{})},string:function(n){var i={};return i[n]={},t.createUnit(i,{})}})}),nv="acos",eD=["typed","config","Complex"],rD=R(nv,eD,r=>{var{typed:e,config:t,Complex:a}=r;return e(nv,{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()}})}),av="acosh",tD=["typed","config","Complex"],nD=R(av,tD,r=>{var{typed:e,config:t,Complex:a}=r;return e(av,{number:function(i){return i>=1||t.predictable?bc(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()}})}),iv="acot",aD=["typed","BigNumber"],iD=R(iv,aD,r=>{var{typed:e,BigNumber:t}=r;return e(iv,{number:xc,Complex:function(n){return n.acot()},BigNumber:function(n){return new t(1).div(n).atan()}})}),ov="acoth",oD=["typed","config","Complex","BigNumber"],sD=R(ov,oD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(ov,{number:function(s){return s>=1||s<=-1||t.predictable?wc(s):new a(s,0).acoth()},Complex:function(s){return s.acoth()},BigNumber:function(s){return new n(1).div(s).atanh()}})}),sv="acsc",uD=["typed","config","Complex","BigNumber"],lD=R(sv,uD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(sv,{number:function(s){return s<=-1||s>=1||t.predictable?Nc(s):new a(s,0).acsc()},Complex:function(s){return s.acsc()},BigNumber:function(s){return new n(1).div(s).asin()}})}),uv="acsch",cD=["typed","BigNumber"],fD=R(uv,cD,r=>{var{typed:e,BigNumber:t}=r;return e(uv,{number:Dc,Complex:function(n){return n.acsch()},BigNumber:function(n){return new t(1).div(n).asinh()}})}),lv="asec",mD=["typed","config","Complex","BigNumber"],vD=R(lv,mD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(lv,{number:function(s){return s<=-1||s>=1||t.predictable?Ac(s):new a(s,0).asec()},Complex:function(s){return s.asec()},BigNumber:function(s){return new n(1).div(s).acos()}})}),cv="asech",pD=["typed","config","Complex","BigNumber"],hD=R(cv,pD,r=>{var{typed:e,config:t,Complex:a,BigNumber:n}=r;return e(cv,{number:function(s){if(s<=1&&s>=-1||t.predictable){var f=1/s;if(f>0||t.predictable)return Ec(s);var l=Math.sqrt(f*f-1);return new a(Math.log(l-f),Math.PI)}return new a(s,0).asech()},Complex:function(s){return s.asech()},BigNumber:function(s){return new n(1).div(s).acosh()}})}),fv="asin",dD=["typed","config","Complex"],gD=R(fv,dD,r=>{var{typed:e,config:t,Complex:a}=r;return e(fv,{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()}})}),yD="asinh",bD=["typed"],xD=R(yD,bD,r=>{var{typed:e}=r;return e("asinh",{number:Sc,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()}})}),wD="atan",ND=["typed"],DD=R(wD,ND,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()}})}),mv="atan2",AD=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],ED=R(mv,AD,r=>{var{typed:e,matrix:t,equalScalar:a,BigNumber:n,DenseMatrix:i}=r,s=bt({typed:e,equalScalar:a}),f=Xr({typed:e}),l=Nf({typed:e,equalScalar:a}),u=Lr({typed:e,equalScalar:a}),o=Br({typed:e,DenseMatrix:i}),c=hr({typed:e,matrix:t});return e(mv,{"number, number":Math.atan2,"BigNumber, BigNumber":(m,v)=>n.atan2(m,v)},c({scalar:"number | BigNumber",SS:l,DS:f,SD:s,Ss:u,sS:o}))}),vv="atanh",SD=["typed","config","Complex"],CD=R(vv,SD,r=>{var{typed:e,config:t,Complex:a}=r;return e(vv,{number:function(i){return i<=1&&i>=-1||t.predictable?Cc(i):new a(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()}})}),ia=R("trigUnit",["typed"],r=>{var{typed:e}=r;return{Unit:e.referToSelf(t=>a=>{if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return e.find(t,a.valueType())(a.value)})}}),pv="cos",MD=["typed"],FD=R(pv,MD,r=>{var{typed:e}=r,t=ia({typed:e});return e(pv,{number:Math.cos,"Complex | BigNumber":a=>a.cos()},t)}),hv="cosh",TD=["typed"],BD=R(hv,TD,r=>{var{typed:e}=r;return e(hv,{number:P0,"Complex | BigNumber":t=>t.cosh()})}),dv="cot",$D=["typed","BigNumber"],OD=R(dv,$D,r=>{var{typed:e,BigNumber:t}=r,a=ia({typed:e});return e(dv,{number:Mc,Complex:n=>n.cot(),BigNumber:n=>new t(1).div(n.tan())},a)}),gv="coth",_D=["typed","BigNumber"],ID=R(gv,_D,r=>{var{typed:e,BigNumber:t}=r;return e(gv,{number:Fc,Complex:a=>a.coth(),BigNumber:a=>new t(1).div(a.tanh())})}),yv="csc",RD=["typed","BigNumber"],qD=R(yv,RD,r=>{var{typed:e,BigNumber:t}=r,a=ia({typed:e});return e(yv,{number:Tc,Complex:n=>n.csc(),BigNumber:n=>new t(1).div(n.sin())},a)}),bv="csch",zD=["typed","BigNumber"],PD=R(bv,zD,r=>{var{typed:e,BigNumber:t}=r;return e(bv,{number:Bc,Complex:a=>a.csch(),BigNumber:a=>new t(1).div(a.sinh())})}),xv="sec",LD=["typed","BigNumber"],UD=R(xv,LD,r=>{var{typed:e,BigNumber:t}=r,a=ia({typed:e});return e(xv,{number:$c,Complex:n=>n.sec(),BigNumber:n=>new t(1).div(n.cos())},a)}),wv="sech",kD=["typed","BigNumber"],VD=R(wv,kD,r=>{var{typed:e,BigNumber:t}=r;return e(wv,{number:Oc,Complex:a=>a.sech(),BigNumber:a=>new t(1).div(a.cosh())})}),Nv="sin",GD=["typed"],HD=R(Nv,GD,r=>{var{typed:e}=r,t=ia({typed:e});return e(Nv,{number:Math.sin,"Complex | BigNumber":a=>a.sin()},t)}),Dv="sinh",ZD=["typed"],JD=R(Dv,ZD,r=>{var{typed:e}=r;return e(Dv,{number:_c,"Complex | BigNumber":t=>t.sinh()})}),Av="tan",WD=["typed"],XD=R(Av,WD,r=>{var{typed:e}=r,t=ia({typed:e});return e(Av,{number:Math.tan,"Complex | BigNumber":a=>a.tan()},t)}),YD="tanh",QD=["typed"],KD=R(YD,QD,r=>{var{typed:e}=r;return e("tanh",{number:U0,"Complex | BigNumber":t=>t.tanh()})}),Ev="setCartesian",jD=["typed","size","subset","compareNatural","Index","DenseMatrix"],eA=R(Ev,jD,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Ev,{"Array | Matrix, Array | Matrix":function(l,u){var o=[];if(a(t(l),new i(0))!==0&&a(t(u),new i(0))!==0){var c=ar(Array.isArray(l)?l:l.toArray()).sort(n),m=ar(Array.isArray(u)?u:u.toArray()).sort(n);o=[];for(var v=0;v<c.length;v++)for(var p=0;p<m.length;p++)o.push([c[v],m[p]])}return Array.isArray(l)&&Array.isArray(u)?o:new s(o)}})}),Sv="setDifference",rA=["typed","size","subset","compareNatural","Index","DenseMatrix"],tA=R(Sv,rA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Sv,{"Array | Matrix, Array | Matrix":function(l,u){var o;if(a(t(l),new i(0))===0)o=[];else{if(a(t(u),new i(0))===0)return ar(l.toArray());var c=Hn(ar(Array.isArray(l)?l:l.toArray()).sort(n)),m=Hn(ar(Array.isArray(u)?u:u.toArray()).sort(n));o=[];for(var v,p=0;p<c.length;p++){v=!1;for(var h=0;h<m.length;h++)if(n(c[p].value,m[h].value)===0&&c[p].identifier===m[h].identifier){v=!0;break}v||o.push(c[p])}}return Array.isArray(l)&&Array.isArray(u)?mi(o):new s(mi(o))}})}),Cv="setDistinct",nA=["typed","size","subset","compareNatural","Index","DenseMatrix"],aA=R(Cv,nA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Cv,{"Array | Matrix":function(l){var u;if(a(t(l),new i(0))===0)u=[];else{var o=ar(Array.isArray(l)?l:l.toArray()).sort(n);u=[],u.push(o[0]);for(var c=1;c<o.length;c++)n(o[c],o[c-1])!==0&&u.push(o[c])}return Array.isArray(l)?u:new s(u)}})}),Mv="setIntersect",iA=["typed","size","subset","compareNatural","Index","DenseMatrix"],oA=R(Mv,iA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i,DenseMatrix:s}=r;return e(Mv,{"Array | Matrix, Array | Matrix":function(l,u){var o;if(a(t(l),new i(0))===0||a(t(u),new i(0))===0)o=[];else{var c=Hn(ar(Array.isArray(l)?l:l.toArray()).sort(n)),m=Hn(ar(Array.isArray(u)?u:u.toArray()).sort(n));o=[];for(var v=0;v<c.length;v++)for(var p=0;p<m.length;p++)if(n(c[v].value,m[p].value)===0&&c[v].identifier===m[p].identifier){o.push(c[v]);break}}return Array.isArray(l)&&Array.isArray(u)?mi(o):new s(mi(o))}})}),Fv="setIsSubset",sA=["typed","size","subset","compareNatural","Index"],uA=R(Fv,sA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Fv,{"Array | Matrix, Array | Matrix":function(f,l){if(a(t(f),new i(0))===0)return!0;if(a(t(l),new i(0))===0)return!1;for(var u=Hn(ar(Array.isArray(f)?f:f.toArray()).sort(n)),o=Hn(ar(Array.isArray(l)?l:l.toArray()).sort(n)),c,m=0;m<u.length;m++){c=!1;for(var v=0;v<o.length;v++)if(n(u[m].value,o[v].value)===0&&u[m].identifier===o[v].identifier){c=!0;break}if(c===!1)return!1}return!0}})}),Tv="setMultiplicity",lA=["typed","size","subset","compareNatural","Index"],cA=R(Tv,lA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Tv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(f,l){if(a(t(l),new i(0))===0)return 0;for(var u=ar(Array.isArray(l)?l:l.toArray()),o=0,c=0;c<u.length;c++)n(u[c],f)===0&&o++;return o}})}),Bv="setPowerset",fA=["typed","size","subset","compareNatural","Index"],mA=R(Bv,fA,r=>{var{typed:e,size:t,subset:a,compareNatural:n,Index:i}=r;return e(Bv,{"Array | Matrix":function(u){if(a(t(u),new i(0))===0)return[];for(var o=ar(Array.isArray(u)?u:u.toArray()).sort(n),c=[],m=0;m.toString(2).length<=o.length;)c.push(s(o,m.toString(2).split("").reverse())),m++;return f(c)}});function s(l,u){for(var o=[],c=0;c<u.length;c++)u[c]==="1"&&o.push(l[c]);return o}function f(l){for(var u=[],o=l.length-1;o>0;o--)for(var c=0;c<o;c++)l[c].length>l[c+1].length&&(u=l[c],l[c]=l[c+1],l[c+1]=u);return l}}),$v="setSize",vA=["typed","compareNatural"],pA=R($v,vA,r=>{var{typed:e,compareNatural:t}=r;return e($v,{"Array | Matrix":function(n){return Array.isArray(n)?ar(n).length:ar(n.toArray()).length},"Array | Matrix, boolean":function(n,i){if(i===!1||n.length===0)return Array.isArray(n)?ar(n).length:ar(n.toArray()).length;for(var s=ar(Array.isArray(n)?n:n.toArray()).sort(t),f=1,l=1;l<s.length;l++)t(s[l],s[l-1])!==0&&f++;return f}})}),Ov="setSymDifference",hA=["typed","size","concat","subset","setDifference","Index"],dA=R(Ov,hA,r=>{var{typed:e,size:t,concat:a,subset:n,setDifference:i,Index:s}=r;return e(Ov,{"Array | Matrix, Array | Matrix":function(l,u){if(n(t(l),new s(0))===0)return ar(u);if(n(t(u),new s(0))===0)return ar(l);var o=ar(l),c=ar(u);return a(i(o,c),i(c,o))}})}),_v="setUnion",gA=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],yA=R(_v,gA,r=>{var{typed:e,size:t,concat:a,subset:n,setIntersect:i,setSymDifference:s,Index:f}=r;return e(_v,{"Array | Matrix, Array | Matrix":function(u,o){if(n(t(u),new f(0))===0)return ar(o);if(n(t(o),new f(0))===0)return ar(u);var c=ar(u),m=ar(o);return a(s(c,m),i(c,m))}})}),Iv="add",bA=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],xA=R(Iv,bA,r=>{var{typed:e,matrix:t,addScalar:a,equalScalar:n,DenseMatrix:i,SparseMatrix:s}=r,f=cn({typed:e}),l=ss({typed:e,equalScalar:n}),u=Mn({typed:e,DenseMatrix:i}),o=hr({typed:e,matrix:t});return e(Iv,{"any, any":a,"any, any, ...any":e.referToSelf(c=>(m,v,p)=>{for(var h=c(m,v),y=0;y<p.length;y++)h=c(h,p[y]);return h})},o({elop:a,DS:f,SS:l,Ss:u}))}),Rv="hypot",wA=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],NA=R(Rv,wA,r=>{var{typed:e,abs:t,addScalar:a,divideScalar:n,multiplyScalar:i,sqrt:s,smaller:f,isPositive:l}=r;return e(Rv,{"... number | BigNumber":u,Array:u,Matrix:o=>u(ar(o.toArray()))});function u(o){for(var c=0,m=0,v=0;v<o.length;v++){if(zt(o[v]))throw new TypeError("Unexpected type of argument to hypot");var p=t(o[v]);f(m,p)?(c=i(c,i(n(m,p),n(m,p))),c=a(c,1),m=p):c=a(c,l(p)?i(n(p,m),n(p,m)):p)}return i(m,s(c))}}),qv="norm",DA=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],AA=R(qv,DA,r=>{var{typed:e,abs:t,add:a,pow:n,conj:i,sqrt:s,multiply:f,equalScalar:l,larger:u,smaller:o,matrix:c,ctranspose:m,eigs:v}=r;return e(qv,{number:Math.abs,Complex:function(N){return N.abs()},BigNumber:function(N){return N.abs()},boolean:function(N){return Math.abs(N)},Array:function(N){return g(c(N),2)},Matrix:function(N){return g(N,2)},"Array, number | BigNumber | string":function(N,S){return g(c(N),S)},"Matrix, number | BigNumber | string":function(N,S){return g(N,S)}});function p(E){var N=0;return E.forEach(function(S){var D=t(S);u(D,N)&&(N=D)},!0),N}function h(E){var N;return E.forEach(function(S){var D=t(S);(!N||o(D,N))&&(N=D)},!0),N||0}function y(E,N){if(N===Number.POSITIVE_INFINITY||N==="inf")return p(E);if(N===Number.NEGATIVE_INFINITY||N==="-inf")return h(E);if(N==="fro")return g(E,2);if(typeof N=="number"&&!isNaN(N)){if(!l(N,0)){var S=0;return E.forEach(function(D){S=a(n(t(D),N),S)},!0),n(S,1/N)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function b(E){var N=0;return E.forEach(function(S,D){N=a(N,f(S,i(S)))}),t(s(N))}function A(E){var N=[],S=0;return E.forEach(function(D,T){var B=T[1],_=a(N[B]||0,t(D));u(_,S)&&(S=_),N[B]=_},!0),S}function d(E){var N=E.size();if(N[0]!==N[1])throw new RangeError("Invalid matrix dimensions");var S=m(E),D=f(S,E),T=v(D).values.toArray(),B=T[T.length-1];return t(s(B))}function w(E){var N=[],S=0;return E.forEach(function(D,T){var B=T[0],_=a(N[B]||0,t(D));u(_,S)&&(S=_),N[B]=_},!0),S}function x(E,N){if(N===1)return A(E);if(N===Number.POSITIVE_INFINITY||N==="inf")return w(E);if(N==="fro")return b(E);if(N===2)return d(E);throw new Error("Unsupported parameter value "+N)}function g(E,N){var S=E.size();if(S.length===1)return y(E,N);if(S.length===2){if(S[0]&&S[1])return x(E,N);throw new RangeError("Invalid matrix dimensions")}}}),zv="dot",EA=["typed","addScalar","multiplyScalar","conj","size"],SA=R(zv,EA,r=>{var{typed:e,addScalar:t,multiplyScalar:a,conj:n,size:i}=r;return e(zv,{"Array | DenseMatrix, Array | DenseMatrix":f,"SparseMatrix, SparseMatrix":l});function s(o,c){var m=u(o),v=u(c),p,h;if(m.length===1)p=m[0];else if(m.length===2&&m[1]===1)p=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v.length===1)h=v[0];else if(v.length===2&&v[1]===1)h=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(p!==h)throw new RangeError("Vectors must have equal length ("+p+" != "+h+")");if(p===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return p}function f(o,c){var m=s(o,c),v=He(o)?o._data:o,p=He(o)?o._datatype:void 0,h=He(c)?c._data:c,y=He(c)?c._datatype:void 0,b=u(o).length===2,A=u(c).length===2,d=t,w=a;if(p&&y&&p===y&&typeof p=="string"){var x=p;d=e.find(t,[x,x]),w=e.find(a,[x,x])}if(!b&&!A){for(var g=w(n(v[0]),h[0]),E=1;E<m;E++)g=d(g,w(n(v[E]),h[E]));return g}if(!b&&A){for(var N=w(n(v[0]),h[0][0]),S=1;S<m;S++)N=d(N,w(n(v[S]),h[S][0]));return N}if(b&&!A){for(var D=w(n(v[0][0]),h[0]),T=1;T<m;T++)D=d(D,w(n(v[T][0]),h[T]));return D}if(b&&A){for(var B=w(n(v[0][0]),h[0][0]),_=1;_<m;_++)B=d(B,w(n(v[_][0]),h[_][0]));return B}}function l(o,c){s(o,c);for(var m=o._index,v=o._values,p=c._index,h=c._values,y=0,b=t,A=a,d=0,w=0;d<m.length&&w<p.length;){var x=m[d],g=p[w];if(x<g){d++;continue}if(x>g){w++;continue}x===g&&(y=b(y,A(v[d],h[w])),d++,w++)}return y}function u(o){return He(o)?o.size():i(o)}}),CA="trace",MA=["typed","matrix","add"],FA=R(CA,MA,r=>{var{typed:e,matrix:t,add:a}=r;return e("trace",{Array:function(f){return n(t(f))},SparseMatrix:i,DenseMatrix:n,any:ke});function n(s){var f=s._size,l=s._data;switch(f.length){case 1:if(f[0]===1)return ke(l[0]);throw new RangeError("Matrix must be square (size: "+Ye(f)+")");case 2:{var u=f[0],o=f[1];if(u===o){for(var c=0,m=0;m<u;m++)c=a(c,l[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+Ye(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(f)+")")}}function i(s){var f=s._values,l=s._index,u=s._ptr,o=s._size,c=o[0],m=o[1];if(c===m){var v=0;if(f.length>0)for(var p=0;p<m;p++)for(var h=u[p],y=u[p+1],b=h;b<y;b++){var A=l[b];if(A===p){v=a(v,f[b]);break}if(A>p)break}return v}throw new RangeError("Matrix must be square (size: "+Ye(o)+")")}}),Pv="index",TA=["typed","Index"],BA=R(Pv,TA,r=>{var{typed:e,Index:t}=r;return e(Pv,{"...number | string | BigNumber | Range | Array | Matrix":function(n){var i=n.map(function(f){return rr(f)?f.toNumber():Array.isArray(f)||He(f)?f.map(function(l){return rr(l)?l.toNumber():l}):f}),s=new t;return t.apply(s,i),s}})}),Lv=new Set(["end"]),$A="Node",OA=["mathWithTransform"],_A=R($A,OA,r=>{var{mathWithTransform:e}=r;function t(n){for(var i of[...Lv])if(n.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}class a{get type(){return"Node"}get isNode(){return!0}evaluate(i){return this.compile().evaluate(i)}compile(){var i=this._compile(e,{}),s={},f=null;function l(u){var o=Wn(u);return t(o),i(o,s,f)}return{evaluate:l}}_compile(i,s){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(i){throw new Error("Cannot run forEach on a Node interface")}map(i){throw new Error("Cannot run map on a Node interface")}_ifNode(i){if(!or(i))throw new TypeError("Callback function must return a Node");return i}traverse(i){i(this,null,null);function s(f,l){f.forEach(function(u,o,c){l(u,o,c),s(u,l)})}s(this,i)}transform(i){function s(f,l,u){var o=i(f,l,u);return o!==f?o:f.map(s)}return s(this,null,null)}filter(i){var s=[];return this.traverse(function(f,l,u){i(f,l,u)&&s.push(f)}),s}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(i){return i.cloneDeep()})}equals(i){return i?this.type===i.type&&Ra(this,i):!1}toString(i){var s=this._getCustomString(i);return typeof s<"u"?s:this._toString(i)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(i){var s=this._getCustomString(i);return typeof s<"u"?s:this.toHTML(i)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(i){var s=this._getCustomString(i);return typeof s<"u"?s:this._toTex(i)}_toTex(i){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(i){if(i&&typeof i=="object")switch(typeof i.handler){case"object":case"undefined":return;case"function":return i.handler(this,i);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}return a},{isClass:!0,isNode:!0});function Qr(r){return r&&r.isIndexError?new pt(r.index+1,r.min+1,r.max!==void 0?r.max+1:void 0):r}function Uv(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 ot(a,n.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Qr(i)}}}var Pi="AccessorNode",IA=["subset","Node"],RA=R(Pi,IA,r=>{var{subset:e,Node:t}=r,a=Uv({subset:e});function n(s){return!(Dn(s)||nt(s)||sr(s)||An(s)||ii(s)||rn(s)||qr(s))}class i extends t{constructor(f,l){if(super(),!or(f))throw new TypeError('Node expected for parameter "object"');if(!Ln(l))throw new TypeError('IndexNode expected for parameter "index"');this.object=f,this.index=l}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Pi}get isAccessorNode(){return!0}_compile(f,l){var u=this.object._compile(f,l),o=this.index._compile(f,l);if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(v,p,h){return ot(u(v,p,h),c)}}else return function(v,p,h){var y=u(v,p,h),b=o(v,p,y);return a(y,b)}}forEach(f){f(this.object,"object",this),f(this.index,"index",this)}map(f){return new i(this._ifNode(f(this.object,"object",this)),this._ifNode(f(this.index,"index",this)))}clone(){return new i(this.object,this.index)}_toString(f){var l=this.object.toString(f);return n(this.object)&&(l="("+l+")"),l+this.index.toString(f)}toHTML(f){var l=this.object.toHTML(f);return n(this.object)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+this.index.toHTML(f)}_toTex(f){var l=this.object.toTex(f);return n(this.object)&&(l="\\left(' + object + '\\right)"),l+this.index.toTex(f)}toJSON(){return{mathjs:Pi,object:this.object,index:this.index}}static fromJSON(f){return new i(f.object,f.index)}}return Ir(i,"name",Pi),i},{isClass:!0,isNode:!0}),Li="ArrayNode",qA=["Node"],zA=R(Li,qA,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.items=n||[],!Array.isArray(this.items)||!this.items.every(or))throw new TypeError("Array containing Nodes expected")}get type(){return Li}get isArrayNode(){return!0}_compile(n,i){var s=Ut(this.items,function(u){return u._compile(n,i)}),f=n.config.matrix!=="Array";if(f){var l=n.matrix;return function(o,c,m){return l(Ut(s,function(v){return v(o,c,m)}))}}else return function(o,c,m){return Ut(s,function(v){return v(o,c,m)})}}forEach(n){for(var i=0;i<this.items.length;i++){var s=this.items[i];n(s,"items["+i+"]",this)}}map(n){for(var i=[],s=0;s<this.items.length;s++)i[s]=this._ifNode(n(this.items[s],"items["+s+"]",this));return new t(i)}clone(){return new t(this.items.slice(0))}_toString(n){var i=this.items.map(function(s){return s.toString(n)});return"["+i.join(", ")+"]"}toJSON(){return{mathjs:Li,items:this.items}}static fromJSON(n){return new t(n.items)}toHTML(n){var i=this.items.map(function(s){return s.toHTML(n)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(n){function i(s,f){var l=s.some(nt)&&!s.every(nt),u=f||l,o=u?"&":"\\\\",c=s.map(function(m){return m.items?i(m.items,!f):m.toTex(n)}).join(o);return l||!u||u&&!f?"\\begin{bmatrix}"+c+"\\end{bmatrix}":c}return i(this.items,!1)}}return Ir(t,"name",Li),t},{isClass:!0,isNode:!0});function PA(r){var{subset:e,matrix:t}=r;return function(n,i,s){try{if(Array.isArray(n))return t(n).subset(i,s).valueOf();if(n&&typeof n.subset=="function")return n.subset(i,s);if(typeof n=="string")return e(n,i,s);if(typeof n=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Zn(n,i.getObjectProperty(),s),n}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(f){throw Qr(f)}}}var xt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Ui(r,e){if(!e||e!=="auto")return r;for(var t=r;rn(t);)t=t.content;return t}function vr(r,e,t,a){var n=r;e!=="keep"&&(n=r.getContent());for(var i=n.getIdentifier(),s=null,f=0;f<xt.length;f++)if(i in xt[f]){s=f;break}if(i==="OperatorNode:multiply"&&n.implicit&&t!=="show"){var l=Ui(n.args[0],e);!(sr(l)&&a&&a.getIdentifier()==="OperatorNode:divide"&&zo(Ui(a.args[0],e)))&&!(l.getIdentifier()==="OperatorNode:divide"&&zo(Ui(l.args[0],e))&&sr(Ui(l.args[1])))&&(s+=1)}return s}function Va(r,e){var t=r;e!=="keep"&&(t=r.getContent());var a=t.getIdentifier(),n=vr(t,e);if(n===null)return null;var i=xt[n][a];if(Re(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 ps(r,e,t){var a=t!=="keep"?r.getContent():r,n=t!=="keep"?r.getContent():e,i=a.getIdentifier(),s=n.getIdentifier(),f=vr(a,t);if(f===null)return null;var l=xt[f][i];if(Re(l,"associativeWith")&&l.associativeWith instanceof Array){for(var u=0;u<l.associativeWith.length;u++)if(l.associativeWith[u]===s)return!0;return!1}return null}function LA(r){var e="OperatorNode:"+r;for(var t of xt)if(e in t)return t[e].op;return null}var ki="AssignmentNode",UA=["subset","?matrix","Node"],kA=R(ki,UA,r=>{var{subset:e,matrix:t,Node:a}=r,n=Uv({subset:e}),i=PA({subset:e,matrix:t});function s(l,u,o){u||(u="keep");var c=vr(l,u,o),m=vr(l.value,u,o);return u==="all"||m!==null&&m<=c}class f extends a{constructor(u,o,c){if(super(),this.object=u,this.index=c?o:null,this.value=c||o,!qr(u)&&!Dn(u))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(qr(u)&&u.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!Ln(this.index))throw new TypeError('IndexNode expected as "index"');if(!or(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return ki}get isAssignmentNode(){return!0}_compile(u,o){var c=this.object._compile(u,o),m=this.index?this.index._compile(u,o):null,v=this.value._compile(u,o),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var h=this.index.getObjectProperty();return function(w,x,g){var E=c(w,x,g),N=v(w,x,g);return Zn(E,h,N),N}}else{if(qr(this.object))return function(w,x,g){var E=c(w,x,g),N=v(w,x,g),S=m(w,x,E);return w.set(p,i(E,S,N)),N};var y=this.object.object._compile(u,o);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(w,x,g){var E=y(w,x,g),N=ot(E,b),S=m(w,x,N),D=v(w,x,g);return Zn(E,b,i(N,S,D)),D}}else{var A=this.object.index._compile(u,o);return function(w,x,g){var E=y(w,x,g),N=A(w,x,E),S=n(E,N),D=m(w,x,S),T=v(w,x,g);return i(E,N,i(S,D,T)),T}}}else{if(!qr(this.object))throw new TypeError("SymbolNode expected as object");return function(w,x,g){var E=v(w,x,g);return w.set(p,E),E}}}forEach(u){u(this.object,"object",this),this.index&&u(this.index,"index",this),u(this.value,"value",this)}map(u){var o=this._ifNode(u(this.object,"object",this)),c=this.index?this._ifNode(u(this.index,"index",this)):null,m=this._ifNode(u(this.value,"value",this));return new f(o,c,m)}clone(){return new f(this.object,this.index,this.value)}_toString(u){var o=this.object.toString(u),c=this.index?this.index.toString(u):"",m=this.value.toString(u);return s(this,u&&u.parenthesis,u&&u.implicit)&&(m="("+m+")"),o+c+" = "+m}toJSON(){return{mathjs:ki,object:this.object,index:this.index,value:this.value}}static fromJSON(u){return new f(u.object,u.index,u.value)}toHTML(u){var o=this.object.toHTML(u),c=this.index?this.index.toHTML(u):"",m=this.value.toHTML(u);return s(this,u&&u.parenthesis,u&&u.implicit)&&(m='<span class="math-paranthesis math-round-parenthesis">(</span>'+m+'<span class="math-paranthesis math-round-parenthesis">)</span>'),o+c+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+m}_toTex(u){var o=this.object.toTex(u),c=this.index?this.index.toTex(u):"",m=this.value.toTex(u);return s(this,u&&u.parenthesis,u&&u.implicit)&&(m="\\left(".concat(m,"\\right)")),o+c+":="+m}}return Ir(f,"name",ki),f},{isClass:!0,isNode:!0}),Vi="BlockNode",VA=["ResultSet","Node"],GA=R(Vi,VA,r=>{var{ResultSet:e,Node:t}=r;class a extends t{constructor(i){if(super(),!Array.isArray(i))throw new Error("Array expected");this.blocks=i.map(function(s){var f=s&&s.node,l=s&&s.visible!==void 0?s.visible:!0;if(!or(f))throw new TypeError('Property "node" must be a Node');if(typeof l!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:f,visible:l}})}get type(){return Vi}get isBlockNode(){return!0}_compile(i,s){var f=Ut(this.blocks,function(l){return{evaluate:l.node._compile(i,s),visible:l.visible}});return function(u,o,c){var m=[];return ci(f,function(p){var h=p.evaluate(u,o,c);p.visible&&m.push(h)}),new e(m)}}forEach(i){for(var s=0;s<this.blocks.length;s++)i(this.blocks[s].node,"blocks["+s+"].node",this)}map(i){for(var s=[],f=0;f<this.blocks.length;f++){var l=this.blocks[f],u=this._ifNode(i(l.node,"blocks["+f+"].node",this));s[f]={node:u,visible:l.visible}}return new a(s)}clone(){var i=this.blocks.map(function(s){return{node:s.node,visible:s.visible}});return new a(i)}_toString(i){return this.blocks.map(function(s){return s.node.toString(i)+(s.visible?"":";")}).join(`
|
|
30
|
+
`)}toJSON(){return{mathjs:Vi,blocks:this.blocks}}static fromJSON(i){return new a(i.blocks)}toHTML(i){return this.blocks.map(function(s){return s.node.toHTML(i)+(s.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')}_toTex(i){return this.blocks.map(function(s){return s.node.toTex(i)+(s.visible?"":";")}).join(`\\;\\;
|
|
31
|
+
`)}}return Ir(a,"name",Vi),a},{isClass:!0,isNode:!0}),Gi="ConditionalNode",HA=["Node"],ZA=R(Gi,HA,r=>{var{Node:e}=r;function t(n){if(typeof n=="number"||typeof n=="boolean"||typeof n=="string")return!!n;if(n){if(rr(n))return!n.isZero();if(zt(n))return!!(n.re||n.im);if(Pt(n))return!!n.value}if(n==null)return!1;throw new TypeError('Unsupported type of condition "'+gr(n)+'"')}class a extends e{constructor(i,s,f){if(super(),!or(i))throw new TypeError("Parameter condition must be a Node");if(!or(s))throw new TypeError("Parameter trueExpr must be a Node");if(!or(f))throw new TypeError("Parameter falseExpr must be a Node");this.condition=i,this.trueExpr=s,this.falseExpr=f}get type(){return Gi}get isConditionalNode(){return!0}_compile(i,s){var f=this.condition._compile(i,s),l=this.trueExpr._compile(i,s),u=this.falseExpr._compile(i,s);return function(c,m,v){return t(f(c,m,v))?l(c,m,v):u(c,m,v)}}forEach(i){i(this.condition,"condition",this),i(this.trueExpr,"trueExpr",this),i(this.falseExpr,"falseExpr",this)}map(i){return new a(this._ifNode(i(this.condition,"condition",this)),this._ifNode(i(this.trueExpr,"trueExpr",this)),this._ifNode(i(this.falseExpr,"falseExpr",this)))}clone(){return new a(this.condition,this.trueExpr,this.falseExpr)}_toString(i){var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.condition.toString(i),u=vr(this.condition,s,i&&i.implicit);(s==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l="("+l+")");var o=this.trueExpr.toString(i),c=vr(this.trueExpr,s,i&&i.implicit);(s==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(o="("+o+")");var m=this.falseExpr.toString(i),v=vr(this.falseExpr,s,i&&i.implicit);return(s==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m="("+m+")"),l+" ? "+o+" : "+m}toJSON(){return{mathjs:Gi,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(i){return new a(i.condition,i.trueExpr,i.falseExpr)}toHTML(i){var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.condition.toHTML(i),u=vr(this.condition,s,i&&i.implicit);(s==="all"||this.condition.type==="OperatorNode"||u!==null&&u<=f)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>');var o=this.trueExpr.toHTML(i),c=vr(this.trueExpr,s,i&&i.implicit);(s==="all"||this.trueExpr.type==="OperatorNode"||c!==null&&c<=f)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>');var m=this.falseExpr.toHTML(i),v=vr(this.falseExpr,s,i&&i.implicit);return(s==="all"||this.falseExpr.type==="OperatorNode"||v!==null&&v<=f)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+'<span class="math-operator math-conditional-operator">?</span>'+o+'<span class="math-operator math-conditional-operator">:</span>'+m}_toTex(i){return"\\begin{cases} {"+this.trueExpr.toTex(i)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(i)+"}\\\\{"+this.falseExpr.toTex(i)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return Ir(a,"name",Gi),a},{isClass:!0,isNode:!0}),hs=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},JA={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},WA={"\u2013":"\\--","\u2014":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},XA=function(e,t){return hs({},e,t)},YA=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?XA:n,s=String(r),f="",l=i(hs({},JA),a?hs({},WA):{}),u=Object.keys(l),o=function(){var m=!1;u.forEach(function(v,p){m||s.length>=v.length&&s.slice(0,v.length)===v&&(f+=l[u[p]],s=s.slice(v.length,s.length),m=!0)}),m||(f+=s.slice(0,1),s=s.slice(1,s.length))};s;)o();return f};const QA=YA;var ds={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{?}"},ir={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"},kv={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(ir.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(ir.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(ir.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(ir.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(ir.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(ir.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(ir.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(ir.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(ir.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(ir.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(ir.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(ir.bitAnd,"${args[1]}\\right)")},bitNot:{1:ir.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(ir.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(ir.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(ir.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(ir.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(ir.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(ir.and,"${args[1]}\\right)")},not:{1:ir.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(ir.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(ir.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(ir.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(ir.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(ir.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(ir.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(ir.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(ir.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(ir.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(ir.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(ir.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(ir.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(ir.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(ds.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)"}},KA="\\mathrm{${name}}\\left(${args}\\right)",Vv={deg:"^\\circ"};function gs(r){return QA(r,{preserveFormatting:!0})}function Gv(r,e){return e=typeof e>"u"?!1:e,e?Re(Vv,r)?Vv[r]:"\\mathrm{"+gs(r)+"}":Re(ds,r)?ds[r]:gs(r)}var Hi="ConstantNode",jA=["Node"],eE=R(Hi,jA,r=>{var{Node:e}=r;class t extends e{constructor(n){super(),this.value=n}get type(){return Hi}get isConstantNode(){return!0}_compile(n,i){var s=this.value;return function(){return s}}forEach(n){}map(n){return this.clone()}clone(){return new t(this.value)}_toString(n){return Ye(this.value,n)}toHTML(n){var i=this._toString(n);switch(gr(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+i+"</span>";case"string":return'<span class="math-string">'+i+"</span>";case"boolean":return'<span class="math-boolean">'+i+"</span>";case"null":return'<span class="math-null-symbol">'+i+"</span>";case"undefined":return'<span class="math-undefined">'+i+"</span>";default:return'<span class="math-symbol">'+i+"</span>"}}toJSON(){return{mathjs:Hi,value:this.value}}static fromJSON(n){return new t(n.value)}_toTex(n){var i=this._toString(n);switch(gr(this.value)){case"string":return"\\mathtt{"+gs(i)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var s=i.toLowerCase().indexOf("e");if(s!==-1)return i.substring(0,s)+"\\cdot10^{"+i.substring(s+1)+"}"}return i;case"Fraction":return this.value.toLatex();default:return i}}}return Ir(t,"name",Hi),t},{isClass:!0,isNode:!0}),Zi="FunctionAssignmentNode",rE=["typed","Node"],tE=R(Zi,rE,r=>{var{typed:e,Node:t}=r;function a(i,s,f){var l=vr(i,s,f),u=vr(i.expr,s,f);return s==="all"||u!==null&&u<=l}class n extends t{constructor(s,f,l){if(super(),typeof s!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(f))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!or(l))throw new TypeError('Node expected for parameter "expr"');if(Lv.has(s))throw new Error('Illegal function name, "'+s+'" is a reserved keyword');var u=new Set;for(var o of f){var c=typeof o=="string"?o:o.name;if(u.has(c))throw new Error('Duplicate parameter name "'.concat(c,'"'));u.add(c)}this.name=s,this.params=f.map(function(m){return m&&m.name||m}),this.types=f.map(function(m){return m&&m.type||"any"}),this.expr=l}get type(){return Zi}get isFunctionAssignmentNode(){return!0}_compile(s,f){var l=Object.create(f);ci(this.params,function(p){l[p]=!0});var u=this.expr._compile(s,l),o=this.name,c=this.params,m=hl(this.types,","),v=o+"("+hl(this.params,", ")+")";return function(h,y,b){var A={};A[m]=function(){for(var w=Object.create(y),x=0;x<c.length;x++)w[c[x]]=arguments[x];return u(h,w,b)};var d=e(o,A);return d.syntax=v,h.set(o,d),d}}forEach(s){s(this.expr,"expr",this)}map(s){var f=this._ifNode(s(this.expr,"expr",this));return new n(this.name,this.params.slice(0),f)}clone(){return new n(this.name,this.params.slice(0),this.expr)}_toString(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=this.expr.toString(s);return a(this,f,s&&s.implicit)&&(l="("+l+")"),this.name+"("+this.params.join(", ")+") = "+l}toJSON(){var s=this.types;return{mathjs:Zi,name:this.name,params:this.params.map(function(f,l){return{name:f,type:s[l]}}),expr:this.expr}}static fromJSON(s){return new n(s.name,s.params,s.expr)}toHTML(s){for(var f=s&&s.parenthesis?s.parenthesis:"keep",l=[],u=0;u<this.params.length;u++)l.push('<span class="math-symbol math-parameter">'+it(this.params[u])+"</span>");var o=this.expr.toHTML(s);return a(this,f,s&&s.implicit)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+it(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+l.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>'+o}_toTex(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=this.expr.toTex(s);return a(this,f,s&&s.implicit)&&(l="\\left(".concat(l,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(Gv).join(",")+"\\right):="+l}}return Ir(n,"name",Zi),n},{isClass:!0,isNode:!0}),Ji="IndexNode",nE=["Node","size"],aE=R(Ji,nE,r=>{var{Node:e,size:t}=r;class a extends e{constructor(i,s){if(super(),this.dimensions=i,this.dotNotation=s||!1,!Array.isArray(i)||!i.every(or))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return Ji}get isIndexNode(){return!0}_compile(i,s){var f=Ut(this.dimensions,function(u,o){var c=u.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(c){var m=Object.create(s);m.end=!0;var v=u._compile(i,m);return function(h,y,b){if(!He(b)&&!ur(b)&&!Wr(b))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+gr(b));var A=t(b).valueOf(),d=Object.create(y);return d.end=A[o],v(h,d,b)}}else return u._compile(i,s)}),l=ot(i,"index");return function(o,c,m){var v=Ut(f,function(p){return p(o,c,m)});return l(...v)}}forEach(i){for(var s=0;s<this.dimensions.length;s++)i(this.dimensions[s],"dimensions["+s+"]",this)}map(i){for(var s=[],f=0;f<this.dimensions.length;f++)s[f]=this._ifNode(i(this.dimensions[f],"dimensions["+f+"]",this));return new a(s,this.dotNotation)}clone(){return new a(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&sr(this.dimensions[0])&&typeof this.dimensions[0].value=="string"}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(i){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:Ji,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(i){return new a(i.dimensions,i.dotNotation)}toHTML(i){for(var s=[],f=0;f<this.dimensions.length;f++)s[f]=this.dimensions[f].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+it(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+s.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(i){var s=this.dimensions.map(function(f){return f.toTex(i)});return this.dotNotation?"."+this.getObjectProperty():"_{"+s.join(",")+"}"}}return Ir(a,"name",Ji),a},{isClass:!0,isNode:!0}),Wi="ObjectNode",iE=["Node"],oE=R(Wi,iE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),this.properties=n||{},n&&(typeof n!="object"||!Object.keys(n).every(function(i){return or(n[i])})))throw new TypeError("Object containing Nodes expected")}get type(){return Wi}get isObjectNode(){return!0}_compile(n,i){var s={};for(var f in this.properties)if(Re(this.properties,f)){var l=ui(f),u=JSON.parse(l);if(!Go(this.properties,u))throw new Error('No access to property "'+u+'"');s[u]=this.properties[f]._compile(n,i)}return function(c,m,v){var p={};for(var h in s)Re(s,h)&&(p[h]=s[h](c,m,v));return p}}forEach(n){for(var i in this.properties)Re(this.properties,i)&&n(this.properties[i],"properties["+ui(i)+"]",this)}map(n){var i={};for(var s in this.properties)Re(this.properties,s)&&(i[s]=this._ifNode(n(this.properties[s],"properties["+ui(s)+"]",this)));return new t(i)}clone(){var n={};for(var i in this.properties)Re(this.properties,i)&&(n[i]=this.properties[i]);return new t(n)}_toString(n){var i=[];for(var s in this.properties)Re(this.properties,s)&&i.push(ui(s)+": "+this.properties[s].toString(n));return"{"+i.join(", ")+"}"}toJSON(){return{mathjs:Wi,properties:this.properties}}static fromJSON(n){return new t(n.properties)}toHTML(n){var i=[];for(var s in this.properties)Re(this.properties,s)&&i.push('<span class="math-symbol math-property">'+it(s)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[s].toHTML(n));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(n){var i=[];for(var s in this.properties)Re(this.properties,s)&&i.push("\\mathbf{"+s+":} & "+this.properties[s].toTex(n)+"\\\\");var f="\\left\\{\\begin{array}{ll}"+i.join(`
|
|
32
|
+
`)+"\\end{array}\\right\\}";return f}}return Ir(t,"name",Wi),t},{isClass:!0,isNode:!0}),Xi="OperatorNode",sE=["Node"],uE=R(Xi,sE,r=>{var{Node:e}=r;function t(i,s){var f=i;if(s==="auto")for(;rn(f);)f=f.content;return sr(f)?!0:_r(f)?t(f.args[0],s):!1}function a(i,s,f,l,u){var o=vr(i,s,f),c=Va(i,s);if(s==="all"||l.length>2&&i.getIdentifier()!=="OperatorNode:add"&&i.getIdentifier()!=="OperatorNode:multiply")return l.map(function(D){switch(D.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var m;switch(l.length){case 0:m=[];break;case 1:{var v=vr(l[0],s,f,i);if(u&&v!==null){var p,h;if(s==="keep"?(p=l[0].getIdentifier(),h=i.getIdentifier()):(p=l[0].getContent().getIdentifier(),h=i.getContent().getIdentifier()),xt[o][h].latexLeftParens===!1){m=[!1];break}if(xt[v][p].latexParens===!1){m=[!1];break}}if(v===null){m=[!1];break}if(v<=o){m=[!0];break}m=[!1]}break;case 2:{var y,b=vr(l[0],s,f,i),A=ps(i,l[0],s);b===null?y=!1:b===o&&c==="right"&&!A||b<o?y=!0:y=!1;var d,w=vr(l[1],s,f,i),x=ps(i,l[1],s);if(w===null?d=!1:w===o&&c==="left"&&!x||w<o?d=!0:d=!1,u){var g,E,N;s==="keep"?(g=i.getIdentifier(),E=i.args[0].getIdentifier(),N=i.args[1].getIdentifier()):(g=i.getContent().getIdentifier(),E=i.args[0].getContent().getIdentifier(),N=i.args[1].getContent().getIdentifier()),b!==null&&(xt[o][g].latexLeftParens===!1&&(y=!1),xt[b][E].latexParens===!1&&(y=!1)),w!==null&&(xt[o][g].latexRightParens===!1&&(d=!1),xt[w][N].latexParens===!1&&(d=!1))}m=[y,d]}break;default:(i.getIdentifier()==="OperatorNode:add"||i.getIdentifier()==="OperatorNode:multiply")&&(m=l.map(function(D){var T=vr(D,s,f,i),B=ps(i,D,s),_=Va(D,s);return T===null?!1:o===T&&c===_&&!B?!0:T<o}));break}if(l.length>=2&&i.getIdentifier()==="OperatorNode:multiply"&&i.implicit&&s!=="all"&&f==="hide")for(var S=1;S<m.length;++S)t(l[S],s)&&!m[S-1]&&(s!=="keep"||!rn(l[S-1]))&&(m[S]=!0);return m}class n extends e{constructor(s,f,l,u,o){if(super(),typeof s!="string")throw new TypeError('string expected for parameter "op"');if(typeof f!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(l)||!l.every(or))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=u===!0,this.isPercentage=o===!0,this.op=s,this.fn=f,this.args=l||[]}get type(){return Xi}get isOperatorNode(){return!0}_compile(s,f){if(typeof this.fn!="string"||!Ho(s,this.fn))throw s[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=ot(s,this.fn),u=Ut(this.args,function(v){return v._compile(s,f)});if(u.length===1){var o=u[0];return function(p,h,y){return l(o(p,h,y))}}else if(u.length===2){var c=u[0],m=u[1];return function(p,h,y){return l(c(p,h,y),m(p,h,y))}}else return function(p,h,y){return l.apply(null,Ut(u,function(b){return b(p,h,y)}))}}forEach(s){for(var f=0;f<this.args.length;f++)s(this.args[f],"args["+f+"]",this)}map(s){for(var f=[],l=0;l<this.args.length;l++)f[l]=this._ifNode(s(this.args[l],"args["+l+"]",this));return new n(this.op,this.fn,f,this.implicit,this.isPercentage)}clone(){return new n(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return this.args.length===1}isBinary(){return this.args.length===2}_toString(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=s&&s.implicit?s.implicit:"hide",u=this.args,o=a(this,f,l,u,!1);if(u.length===1){var c=Va(this,f),m=u[0].toString(s);o[0]&&(m="("+m+")");var v=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(v?" ":"")+m:c==="left"?m+(v?" ":"")+this.op:m+this.op}else if(u.length===2){var p=u[0].toString(s),h=u[1].toString(s);return o[0]&&(p="("+p+")"),o[1]&&(h="("+h+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p+" "+h:p+" "+this.op+" "+h}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var y=u.map(function(b,A){return b=b.toString(s),o[A]&&(b="("+b+")"),b});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?y.join(" "):y.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:Xi,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(s){return new n(s.op,s.fn,s.args,s.implicit,s.isPercentage)}toHTML(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=s&&s.implicit?s.implicit:"hide",u=this.args,o=a(this,f,l,u,!1);if(u.length===1){var c=Va(this,f),m=u[0].toHTML(s);return o[0]&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+it(this.op)+"</span>"+m:m+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+it(this.op)+"</span>"}else if(u.length===2){var v=u[0].toHTML(s),p=u[1].toHTML(s);return o[0]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),o[1]&&(p='<span class="math-parenthesis math-round-parenthesis">(</span>'+p+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?v+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+p:v+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+it(this.op)+"</span>"+p}else{var h=u.map(function(y,b){return y=y.toHTML(s),o[b]&&(y='<span class="math-parenthesis math-round-parenthesis">(</span>'+y+'<span class="math-parenthesis math-round-parenthesis">)</span>'),y});return u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?h.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):h.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+it(this.op)+"</span>"):'<span class="math-function">'+it(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+h.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(s){var f=s&&s.parenthesis?s.parenthesis:"keep",l=s&&s.implicit?s.implicit:"hide",u=this.args,o=a(this,f,l,u,!0),c=ir[this.fn];if(c=typeof c>"u"?this.op:c,u.length===1){var m=Va(this,f),v=u[0].toTex(s);return o[0]&&(v="\\left(".concat(v,"\\right)")),m==="right"?c+v:v+c}else if(u.length===2){var p=u[0],h=p.toTex(s);o[0]&&(h="\\left(".concat(h,"\\right)"));var y=u[1],b=y.toTex(s);o[1]&&(b="\\left(".concat(b,"\\right)"));var A;switch(f==="keep"?A=p.getIdentifier():A=p.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+h+"}{"+b+"}";case"OperatorNode:pow":switch(h="{"+h+"}",b="{"+b+"}",A){case"ConditionalNode":case"OperatorNode:divide":h="\\left(".concat(h,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return h+"~"+b}return h+c+b}else if(u.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var d=u.map(function(w,x){return w=w.toTex(s),o[x]&&(w="\\left(".concat(w,"\\right)")),w});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit&&l==="hide"?d.join("~"):d.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+u.map(function(w){return w.toTex(s)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return Ir(n,"name",Xi),n},{isClass:!0,isNode:!0}),Yi="ParenthesisNode",lE=["Node"],cE=R(Yi,lE,r=>{var{Node:e}=r;class t extends e{constructor(n){if(super(),!or(n))throw new TypeError('Node expected for parameter "content"');this.content=n}get type(){return Yi}get isParenthesisNode(){return!0}_compile(n,i){return this.content._compile(n,i)}getContent(){return this.content.getContent()}forEach(n){n(this.content,"content",this)}map(n){var i=n(this.content,"content",this);return new t(i)}clone(){return new t(this.content)}_toString(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"("+this.content.toString(n)+")":this.content.toString(n)}toJSON(){return{mathjs:Yi,content:this.content}}static fromJSON(n){return new t(n.content)}toHTML(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(n)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(n)}_toTex(n){return!n||n&&!n.parenthesis||n&&n.parenthesis==="keep"?"\\left(".concat(this.content.toTex(n),"\\right)"):this.content.toTex(n)}}return Ir(t,"name",Yi),t},{isClass:!0,isNode:!0}),Qi="RangeNode",fE=["Node"],mE=R(Qi,fE,r=>{var{Node:e}=r;function t(n,i,s){var f=vr(n,i,s),l={},u=vr(n.start,i,s);if(l.start=u!==null&&u<=f||i==="all",n.step){var o=vr(n.step,i,s);l.step=o!==null&&o<=f||i==="all"}var c=vr(n.end,i,s);return l.end=c!==null&&c<=f||i==="all",l}class a extends e{constructor(i,s,f){if(super(),!or(i))throw new TypeError("Node expected");if(!or(s))throw new TypeError("Node expected");if(f&&!or(f))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=i,this.end=s,this.step=f||null}get type(){return Qi}get isRangeNode(){return!0}needsEnd(){var i=this.filter(function(s){return qr(s)&&s.name==="end"});return i.length>0}_compile(i,s){var f=i.range,l=this.start._compile(i,s),u=this.end._compile(i,s);if(this.step){var o=this.step._compile(i,s);return function(m,v,p){return f(l(m,v,p),u(m,v,p),o(m,v,p))}}else return function(m,v,p){return f(l(m,v,p),u(m,v,p))}}forEach(i){i(this.start,"start",this),i(this.end,"end",this),this.step&&i(this.step,"step",this)}map(i){return new a(this._ifNode(i(this.start,"start",this)),this._ifNode(i(this.end,"end",this)),this.step&&this._ifNode(i(this.step,"step",this)))}clone(){return new a(this.start,this.end,this.step&&this.step)}_toString(i){var s=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,s,i&&i.implicit),l,u=this.start.toString(i);if(f.start&&(u="("+u+")"),l=u,this.step){var o=this.step.toString(i);f.step&&(o="("+o+")"),l+=":"+o}var c=this.end.toString(i);return f.end&&(c="("+c+")"),l+=":"+c,l}toJSON(){return{mathjs:Qi,start:this.start,end:this.end,step:this.step}}static fromJSON(i){return new a(i.start,i.end,i.step)}toHTML(i){var s=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,s,i&&i.implicit),l,u=this.start.toHTML(i);if(f.start&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l=u,this.step){var o=this.step.toHTML(i);f.step&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+o}var c=this.end.toHTML(i);return f.end&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+c,l}_toTex(i){var s=i&&i.parenthesis?i.parenthesis:"keep",f=t(this,s,i&&i.implicit),l=this.start.toTex(i);if(f.start&&(l="\\left(".concat(l,"\\right)")),this.step){var u=this.step.toTex(i);f.step&&(u="\\left(".concat(u,"\\right)")),l+=":"+u}var o=this.end.toTex(i);return f.end&&(o="\\left(".concat(o,"\\right)")),l+=":"+o,l}}return Ir(a,"name",Qi),a},{isClass:!0,isNode:!0}),Ki="RelationalNode",vE=["Node"],pE=R(Ki,vE,r=>{var{Node:e}=r,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class a extends e{constructor(i,s){if(super(),!Array.isArray(i))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(s))throw new TypeError("Parameter params must be an array");if(i.length!==s.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=i,this.params=s}get type(){return Ki}get isRelationalNode(){return!0}_compile(i,s){var f=this,l=this.params.map(u=>u._compile(i,s));return function(o,c,m){for(var v,p=l[0](o,c,m),h=0;h<f.conditionals.length;h++){v=p,p=l[h+1](o,c,m);var y=ot(i,f.conditionals[h]);if(!y(v,p))return!1}return!0}}forEach(i){this.params.forEach((s,f)=>i(s,"params["+f+"]",this),this)}map(i){return new a(this.conditionals.slice(),this.params.map((s,f)=>this._ifNode(i(s,"params["+f+"]",this)),this))}clone(){return new a(this.conditionals,this.params)}_toString(i){for(var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.params.map(function(c,m){var v=vr(c,s,i&&i.implicit);return s==="all"||v!==null&&v<=f?"("+c.toString(i)+")":c.toString(i)}),u=l[0],o=0;o<this.conditionals.length;o++)u+=" "+t[this.conditionals[o]],u+=" "+l[o+1];return u}toJSON(){return{mathjs:Ki,conditionals:this.conditionals,params:this.params}}static fromJSON(i){return new a(i.conditionals,i.params)}toHTML(i){for(var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.params.map(function(c,m){var v=vr(c,s,i&&i.implicit);return s==="all"||v!==null&&v<=f?'<span class="math-parenthesis math-round-parenthesis">(</span>'+c.toHTML(i)+'<span class="math-parenthesis math-round-parenthesis">)</span>':c.toHTML(i)}),u=l[0],o=0;o<this.conditionals.length;o++)u+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+it(t[this.conditionals[o]])+"</span>"+l[o+1];return u}_toTex(i){for(var s=i&&i.parenthesis?i.parenthesis:"keep",f=vr(this,s,i&&i.implicit),l=this.params.map(function(c,m){var v=vr(c,s,i&&i.implicit);return s==="all"||v!==null&&v<=f?"\\left("+c.toTex(i)+"\right)":c.toTex(i)}),u=l[0],o=0;o<this.conditionals.length;o++)u+=ir[this.conditionals[o]]+l[o+1];return u}}return Ir(a,"name",Ki),a},{isClass:!0,isNode:!0}),hE="SymbolNode",dE=["math","?Unit","Node"],gE=R(hE,dE,r=>{var{math:e,Unit:t,Node:a}=r;function n(s){return t?t.isValuelessUnit(s):!1}class i extends a{constructor(f){if(super(),typeof f!="string")throw new TypeError('String expected for parameter "name"');this.name=f}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(f,l){var u=this.name;if(l[u]===!0)return function(c,m,v){return m[u]};if(u in f)return function(c,m,v){return c.has(u)?c.get(u):ot(f,u)};var o=n(u);return function(c,m,v){return c.has(u)?c.get(u):o?new t(null,u):i.onUndefinedSymbol(u)}}forEach(f){}map(f){return this.clone()}static onUndefinedSymbol(f){throw new Error("Undefined symbol "+f)}clone(){return new i(this.name)}_toString(f){return this.name}toHTML(f){var l=it(this.name);return l==="true"||l==="false"?'<span class="math-symbol math-boolean">'+l+"</span>":l==="i"?'<span class="math-symbol math-imaginary-symbol">'+l+"</span>":l==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+l+"</span>":l==="NaN"?'<span class="math-symbol math-nan-symbol">'+l+"</span>":l==="null"?'<span class="math-symbol math-null-symbol">'+l+"</span>":l==="undefined"?'<span class="math-symbol math-undefined-symbol">'+l+"</span>":'<span class="math-symbol">'+l+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(f){return new i(f.name)}_toTex(f){var l=!1;typeof e[this.name]>"u"&&n(this.name)&&(l=!0);var u=Gv(this.name,l);return u[0]==="\\"?u:" "+u}}return i},{isClass:!0,isNode:!0});function Ga(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"?gl(r.createSubScope(),...t):gl(Jn(),r,...t)}var ji="FunctionNode",yE=["math","Node","SymbolNode"],bE=R(ji,yE,r=>{var{math:e,Node:t,SymbolNode:a}=r,n=f=>Ye(f,{truncate:78});function i(f,l,u){for(var o="",c=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,m=0,v;(v=c.exec(f))!==null;)if(o+=f.substring(m,v.index),m=v.index,v[0]==="$$")o+="$",m++;else{m+=v[0].length;var p=l[v[1]];if(!p)throw new ReferenceError("Template: Property "+v[1]+" does not exist.");if(v[2]===void 0)switch(typeof p){case"string":o+=p;break;case"object":if(or(p))o+=p.toTex(u);else if(Array.isArray(p))o+=p.map(function(h,y){if(or(h))return h.toTex(u);throw new TypeError("Template: "+v[1]+"["+y+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+v[1]+" has to be a Node, String or array of Nodes")}else if(or(p[v[2]]&&p[v[2]]))o+=p[v[2]].toTex(u);else throw new TypeError("Template: "+v[1]+"["+v[2]+"] is not a Node.")}return o+=f.slice(m),o}class s extends t{constructor(l,u){if(super(),typeof l=="string"&&(l=new a(l)),!or(l))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(u)||!u.every(or))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=l,this.args=u||[]}get name(){return this.fn.name||""}get type(){return ji}get isFunctionNode(){return!0}_compile(l,u){var o=this.args.map(E=>E._compile(l,u));if(qr(this.fn)){var c=this.fn.name;if(u[c]){var y=this.args;return function(N,S,D){var T=S[c];if(typeof T!="function")throw new TypeError("Argument '".concat(c,"' was not a function; received: ").concat(n(T)));if(T.rawArgs)return T(y,l,Ga(N,S),N);var B=o.map(_=>_(N,S,D));return T.apply(T,B)}}else{var m=c in l?ot(l,c):void 0,v=typeof m=="function"&&m.rawArgs===!0,p=E=>{var N;if(E.has(c))N=E.get(c);else if(c in l)N=ot(l,c);else return s.onUndefinedFunction(c);if(typeof N=="function")return N;throw new TypeError("'".concat(c,`' is not a function; its value is:
|
|
33
|
+
`).concat(n(N)))};if(v){var h=this.args;return function(N,S,D){var T=p(N);return T(h,l,Ga(N,S),N)}}else switch(o.length){case 0:return function(N,S,D){var T=p(N);return T()};case 1:return function(N,S,D){var T=p(N),B=o[0];return T(B(N,S,D))};case 2:return function(N,S,D){var T=p(N),B=o[0],_=o[1];return T(B(N,S,D),_(N,S,D))};default:return function(N,S,D){var T=p(N),B=o.map(_=>_(N,S,D));return T(...B)}}}}else if(Dn(this.fn)&&Ln(this.fn.index)&&this.fn.index.isObjectProperty()){var b=this.fn.object._compile(l,u),A=this.fn.index.getObjectProperty(),d=this.args;return function(N,S,D){var T=b(N,S,D);eg(T,A);var B=T[A]&&T[A].rawArgs;if(B)return T[A](d,l,Ga(N,S),N);var _=o.map(L=>L(N,S,D));return T[A].apply(T,_)}}else{var w=this.fn.toString(),x=this.fn._compile(l,u),g=this.args;return function(N,S,D){var T=x(N,S,D);if(typeof T!="function")throw new TypeError("Expression '".concat(w,"' did not evaluate to a function; value is:")+`
|
|
34
|
+
`.concat(n(T)));if(T.rawArgs)return T(g,l,Ga(N,S),N);var B=o.map(_=>_(N,S,D));return T.apply(T,B)}}}forEach(l){l(this.fn,"fn",this);for(var u=0;u<this.args.length;u++)l(this.args[u],"args["+u+"]",this)}map(l){for(var u=this._ifNode(l(this.fn,"fn",this)),o=[],c=0;c<this.args.length;c++)o[c]=this._ifNode(l(this.args[c],"args["+c+"]",this));return new s(u,o)}clone(){return new s(this.fn,this.args.slice(0))}toString(l){var u,o=this.fn.toString(l);return l&&typeof l.handler=="object"&&Re(l.handler,o)&&(u=l.handler[o](this,l)),typeof u<"u"?u:super.toString(l)}_toString(l){var u=this.args.map(function(c){return c.toString(l)}),o=Ia(this.fn)?"("+this.fn.toString(l)+")":this.fn.toString(l);return o+"("+u.join(", ")+")"}toJSON(){return{mathjs:ji,fn:this.fn,args:this.args}}toHTML(l){var u=this.args.map(function(o){return o.toHTML(l)});return'<span class="math-function">'+it(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+u.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(l){var u;return l&&typeof l.handler=="object"&&Re(l.handler,this.name)&&(u=l.handler[this.name](this,l)),typeof u<"u"?u:super.toTex(l)}_toTex(l){var u=this.args.map(function(m){return m.toTex(l)}),o;kv[this.name]&&(o=kv[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 c;switch(typeof o){case"function":c=o(this,l);break;case"string":c=i(o,this,l);break;case"object":switch(typeof o[u.length]){case"function":c=o[u.length](this,l);break;case"string":c=i(o[u.length],this,l);break}}return typeof c<"u"?c:i(KA,this,l)}getIdentifier(){return this.type+":"+this.name}}return Ir(s,"name",ji),Ir(s,"onUndefinedFunction",function(f){throw new Error("Undefined function "+f)}),Ir(s,"fromJSON",function(f){return new s(f.fn,f.args)}),s},{isClass:!0,isNode:!0}),Hv="parse",xE=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],wE=R(Hv,xE,r=>{var{typed:e,numeric:t,config:a,AccessorNode:n,ArrayNode:i,AssignmentNode:s,BlockNode:f,ConditionalNode:l,ConstantNode:u,FunctionAssignmentNode:o,FunctionNode:c,IndexNode:m,ObjectNode:v,OperatorNode:p,ParenthesisNode:h,RangeNode:y,RelationalNode:b,SymbolNode:A}=r,d=e(Hv,{string:function(H){return U(H,{})},"Array | Matrix":function(H){return w(H,{})},"string, Object":function(H,se){var De=se.nodes!==void 0?se.nodes:{};return U(H,De)},"Array | Matrix, Object":w});function w(M){var H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=H.nodes!==void 0?H.nodes:{};return je(M,function(De){if(typeof De!="string")throw new TypeError("String expected");return U(De,se)})}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},E={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},N={true:!0,false:!1,null:null,undefined:void 0},S=["NaN","Infinity"];function D(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function T(M,H){return M.expression.substr(M.index,H)}function B(M){return T(M,1)}function _(M){M.index++}function L(M){return M.expression.charAt(M.index-1)}function G(M){return M.expression.charAt(M.index+1)}function C(M){for(M.tokenType=x.NULL,M.token="",M.comment="";;){if(B(M)==="#")for(;B(M)!==`
|
|
35
|
+
`&&B(M)!=="";)M.comment+=B(M),_(M);if(d.isWhitespace(B(M),M.nestingLevel))_(M);else break}if(B(M)===""){M.tokenType=x.DELIMITER;return}if(B(M)===`
|
|
36
|
+
`&&!M.nestingLevel){M.tokenType=x.DELIMITER,M.token=B(M),_(M);return}var H=B(M),se=T(M,2),De=T(M,3);if(De.length===3&&g[De]){M.tokenType=x.DELIMITER,M.token=De,_(M),_(M),_(M);return}if(se.length===2&&g[se]){M.tokenType=x.DELIMITER,M.token=se,_(M),_(M);return}if(g[H]){M.tokenType=x.DELIMITER,M.token=H,_(M);return}if(d.isDigitDot(H)){M.tokenType=x.NUMBER;var ze=T(M,2);if(ze==="0b"||ze==="0o"||ze==="0x"){for(M.token+=B(M),_(M),M.token+=B(M),_(M);d.isHexDigit(B(M));)M.token+=B(M),_(M);if(B(M)===".")for(M.token+=".",_(M);d.isHexDigit(B(M));)M.token+=B(M),_(M);else if(B(M)==="i")for(M.token+="i",_(M);d.isDigit(B(M));)M.token+=B(M),_(M);return}if(B(M)==="."){if(M.token+=B(M),_(M),!d.isDigit(B(M))){M.tokenType=x.DELIMITER;return}}else{for(;d.isDigit(B(M));)M.token+=B(M),_(M);d.isDecimalMark(B(M),G(M))&&(M.token+=B(M),_(M))}for(;d.isDigit(B(M));)M.token+=B(M),_(M);if(B(M)==="E"||B(M)==="e"){if(d.isDigit(G(M))||G(M)==="-"||G(M)==="+"){if(M.token+=B(M),_(M),(B(M)==="+"||B(M)==="-")&&(M.token+=B(M),_(M)),!d.isDigit(B(M)))throw Je(M,'Digit expected, got "'+B(M)+'"');for(;d.isDigit(B(M));)M.token+=B(M),_(M);if(d.isDecimalMark(B(M),G(M)))throw Je(M,'Digit expected, got "'+B(M)+'"')}else if(G(M)===".")throw _(M),Je(M,'Digit expected, got "'+B(M)+'"')}return}if(d.isAlpha(B(M),L(M),G(M))){for(;d.isAlpha(B(M),L(M),G(M))||d.isDigit(B(M));)M.token+=B(M),_(M);Re(E,M.token)?M.tokenType=x.DELIMITER:M.tokenType=x.SYMBOL;return}for(M.tokenType=x.UNKNOWN;B(M)!=="";)M.token+=B(M),_(M);throw Je(M,'Syntax error in part "'+M.token+'"')}function F(M){do C(M);while(M.token===`
|
|
37
|
+
`)}function Z(M){M.nestingLevel++}function $(M){M.nestingLevel--}d.isAlpha=function(H,se,De){return d.isValidLatinOrGreek(H)||d.isValidMathSymbol(H,De)||d.isValidMathSymbol(se,H)},d.isValidLatinOrGreek=function(H){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(H)},d.isValidMathSymbol=function(H,se){return/^[\uD835]$/.test(H)&&/^[\uDC00-\uDFFF]$/.test(se)&&/^[^\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(se)},d.isWhitespace=function(H,se){return H===" "||H===" "||H===`
|
|
38
|
+
`&&se>0},d.isDecimalMark=function(H,se){return H==="."&&se!=="/"&&se!=="*"&&se!=="^"},d.isDigitDot=function(H){return H>="0"&&H<="9"||H==="."},d.isDigit=function(H){return H>="0"&&H<="9"},d.isHexDigit=function(H){return H>="0"&&H<="9"||H>="a"&&H<="f"||H>="A"&&H<="F"};function U(M,H){var se=D();Ar(se,{expression:M,extraNodes:H}),C(se);var De=Y(se);if(se.token!=="")throw se.tokenType===x.DELIMITER?cr(se,"Unexpected operator "+se.token):Je(se,'Unexpected part "'+se.token+'"');return De}function Y(M){var H,se=[],De;for(M.token!==""&&M.token!==`
|
|
39
|
+
`&&M.token!==";"&&(H=j(M),M.comment&&(H.comment=M.comment));M.token===`
|
|
40
|
+
`||M.token===";";)se.length===0&&H&&(De=M.token!==";",se.push({node:H,visible:De})),C(M),M.token!==`
|
|
41
|
+
`&&M.token!==";"&&M.token!==""&&(H=j(M),M.comment&&(H.comment=M.comment),De=M.token!==";",se.push({node:H,visible:De}));return se.length>0?new f(se):(H||(H=new u(void 0),M.comment&&(H.comment=M.comment)),H)}function j(M){var H,se,De,ze,Le=P(M);if(M.token==="="){if(qr(Le))return H=Le.name,F(M),De=j(M),new s(new A(H),De);if(Dn(Le))return F(M),De=j(M),new s(Le.object,Le.index,De);if(An(Le)&&qr(Le.fn)&&(ze=!0,se=[],H=Le.name,Le.args.forEach(function(Mr,Rr){qr(Mr)?se[Rr]=Mr.name:ze=!1}),ze))return F(M),De=j(M),new o(H,se,De);throw Je(M,"Invalid left hand side of assignment operator =")}return Le}function P(M){for(var H=K(M);M.token==="?";){var se=M.conditionalLevel;M.conditionalLevel=M.nestingLevel,F(M);var De=H,ze=j(M);if(M.token!==":")throw Je(M,"False part of conditional expression expected");M.conditionalLevel=null,F(M);var Le=j(M);H=new l(De,ze,Le),M.conditionalLevel=se}return H}function K(M){for(var H=ne(M);M.token==="or";)F(M),H=new p("or","or",[H,ne(M)]);return H}function ne(M){for(var H=re(M);M.token==="xor";)F(M),H=new p("xor","xor",[H,re(M)]);return H}function re(M){for(var H=fe(M);M.token==="and";)F(M),H=new p("and","and",[H,fe(M)]);return H}function fe(M){for(var H=pe(M);M.token==="|";)F(M),H=new p("|","bitOr",[H,pe(M)]);return H}function pe(M){for(var H=ce(M);M.token==="^|";)F(M),H=new p("^|","bitXor",[H,ce(M)]);return H}function ce(M){for(var H=oe(M);M.token==="&";)F(M),H=new p("&","bitAnd",[H,oe(M)]);return H}function oe(M){for(var H=[Ce(M)],se=[],De={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Re(De,M.token);){var ze={name:M.token,fn:De[M.token]};se.push(ze),F(M),H.push(Ce(M))}return H.length===1?H[0]:H.length===2?new p(se[0].name,se[0].fn,H):new b(se.map(Le=>Le.fn),H)}function Ce(M){var H,se,De,ze;H=Oe(M);for(var Le={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Re(Le,M.token);)se=M.token,De=Le[se],F(M),ze=[H,Oe(M)],H=new p(se,De,ze);return H}function Oe(M){var H,se,De,ze;H=Me(M);for(var Le={to:"to",in:"to"};Re(Le,M.token);)se=M.token,De=Le[se],F(M),se==="in"&&M.token===""?H=new p("*","multiply",[H,new A("in")],!0):(ze=[H,Me(M)],H=new p(se,De,ze));return H}function Me(M){var H,se=[];if(M.token===":"?H=new u(1):H=$e(M),M.token===":"&&M.conditionalLevel!==M.nestingLevel){for(se.push(H);M.token===":"&&se.length<3;)F(M),M.token===")"||M.token==="]"||M.token===","||M.token===""?se.push(new A("end")):se.push($e(M));se.length===3?H=new y(se[0],se[2],se[1]):H=new y(se[0],se[1])}return H}function $e(M){var H,se,De,ze;H=k(M);for(var Le={"+":"add","-":"subtract"};Re(Le,M.token);){se=M.token,De=Le[se],F(M);var Mr=k(M);Mr.isPercentage?ze=[H,new p("*","multiply",[H,Mr])]:ze=[H,Mr],H=new p(se,De,ze)}return H}function k(M){var H,se,De,ze;H=W(M),se=H;for(var Le={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Re(Le,M.token);)De=M.token,ze=Le[De],F(M),se=W(M),H=new p(De,ze,[H,se]);return H}function W(M){var H,se;for(H=ie(M),se=H;M.tokenType===x.SYMBOL||M.token==="in"&&sr(H)||M.tokenType===x.NUMBER&&!sr(se)&&(!_r(se)||se.op==="!")||M.token==="(";)se=ie(M),H=new p("*","multiply",[H,se],!0);return H}function ie(M){for(var H=V(M),se=H,De=[];M.token==="/"&&zo(se);)if(De.push(Ar({},M)),F(M),M.tokenType===x.NUMBER)if(De.push(Ar({},M)),F(M),M.tokenType===x.SYMBOL||M.token==="(")Ar(M,De.pop()),De.pop(),se=V(M),H=new p("/","divide",[H,se]);else{De.pop(),Ar(M,De.pop());break}else{Ar(M,De.pop());break}return H}function V(M){var H,se,De,ze;H=Q(M);for(var Le={"%":"mod",mod:"mod"};Re(Le,M.token);)se=M.token,De=Le[se],F(M),se==="%"&&M.tokenType===x.DELIMITER&&M.token!=="("?H=new p("/","divide",[H,new u(100)],!1,!0):(ze=[H,Q(M)],H=new p(se,De,ze));return H}function Q(M){var H,se,De,ze={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Re(ze,M.token)?(De=ze[M.token],H=M.token,F(M),se=[Q(M)],new p(H,De,se)):te(M)}function te(M){var H,se,De,ze;return H=ge(M),(M.token==="^"||M.token===".^")&&(se=M.token,De=se==="^"?"pow":"dotPow",F(M),ze=[H,Q(M)],H=new p(se,De,ze)),H}function ge(M){var H,se,De,ze;H=he(M);for(var Le={"!":"factorial","'":"ctranspose"};Re(Le,M.token);)se=M.token,De=Le[se],C(M),ze=[H],H=new p(se,De,ze),H=z(M,H);return H}function he(M){var H=[];if(M.tokenType===x.SYMBOL&&Re(M.extraNodes,M.token)){var se=M.extraNodes[M.token];if(C(M),M.token==="("){if(H=[],Z(M),C(M),M.token!==")")for(H.push(j(M));M.token===",";)C(M),H.push(j(M));if(M.token!==")")throw Je(M,"Parenthesis ) expected");$(M),C(M)}return new se(H)}return q(M)}function q(M){var H,se;return M.tokenType===x.SYMBOL||M.tokenType===x.DELIMITER&&M.token in E?(se=M.token,C(M),Re(N,se)?H=new u(N[se]):S.indexOf(se)!==-1?H=new u(t(se,"number")):H=new A(se),H=z(M,H),H):ee(M)}function z(M,H,se){for(var De;(M.token==="("||M.token==="["||M.token===".")&&(!se||se.indexOf(M.token)!==-1);)if(De=[],M.token==="(")if(qr(H)||Dn(H)){if(Z(M),C(M),M.token!==")")for(De.push(j(M));M.token===",";)C(M),De.push(j(M));if(M.token!==")")throw Je(M,"Parenthesis ) expected");$(M),C(M),H=new c(H,De)}else return H;else if(M.token==="["){if(Z(M),C(M),M.token!=="]")for(De.push(j(M));M.token===",";)C(M),De.push(j(M));if(M.token!=="]")throw Je(M,"Parenthesis ] expected");$(M),C(M),H=new n(H,new m(De))}else{if(C(M),M.tokenType!==x.SYMBOL)throw Je(M,"Property name expected after dot");De.push(new u(M.token)),C(M);var ze=!0;H=new n(H,new m(De,ze))}return H}function ee(M){var H,se;return M.token==='"'?(se=ue(M),H=new u(se),H=z(M,H),H):me(M)}function ue(M){for(var H="";B(M)!==""&&B(M)!=='"';)B(M)==="\\"&&(H+=B(M),_(M)),H+=B(M),_(M);if(C(M),M.token!=='"')throw Je(M,'End of string " expected');return C(M),JSON.parse('"'+H+'"')}function me(M){var H,se;return M.token==="'"?(se=ye(M),H=new u(se),H=z(M,H),H):be(M)}function ye(M){for(var H="";B(M)!==""&&B(M)!=="'";)B(M)==="\\"&&(H+=B(M),_(M)),H+=B(M),_(M);if(C(M),M.token!=="'")throw Je(M,"End of string ' expected");return C(M),JSON.parse('"'+H+'"')}function be(M){var H,se,De,ze;if(M.token==="["){if(Z(M),C(M),M.token!=="]"){var Le=ve(M);if(M.token===";"){for(De=1,se=[Le];M.token===";";)C(M),se[De]=ve(M),De++;if(M.token!=="]")throw Je(M,"End of matrix ] expected");$(M),C(M),ze=se[0].items.length;for(var Mr=1;Mr<De;Mr++)if(se[Mr].items.length!==ze)throw cr(M,"Column dimensions mismatch ("+se[Mr].items.length+" !== "+ze+")");H=new i(se)}else{if(M.token!=="]")throw Je(M,"End of matrix ] expected");$(M),C(M),H=Le}}else $(M),C(M),H=new i([]);return z(M,H)}return Ne(M)}function ve(M){for(var H=[j(M)],se=1;M.token===",";)C(M),H[se]=j(M),se++;return new i(H)}function Ne(M){if(M.token==="{"){Z(M);var H,se={};do if(C(M),M.token!=="}"){if(M.token==='"')H=ue(M);else if(M.token==="'")H=ye(M);else if(M.tokenType===x.SYMBOL||M.tokenType===x.DELIMITER&&M.token in E)H=M.token,C(M);else throw Je(M,"Symbol or string expected as object key");if(M.token!==":")throw Je(M,"Colon : expected after object key");C(M),se[H]=j(M)}while(M.token===",");if(M.token!=="}")throw Je(M,"Comma , or bracket } expected after object value");$(M),C(M);var De=new v(se);return De=z(M,De),De}return Ie(M)}function Ie(M){var H;return M.tokenType===x.NUMBER?(H=M.token,C(M),new u(t(H,a.number))):Ge(M)}function Ge(M){var H;if(M.token==="("){if(Z(M),C(M),H=j(M),M.token!==")")throw Je(M,"Parenthesis ) expected");return $(M),C(M),H=new h(H),H=z(M,H),H}return Be(M)}function Be(M){throw M.token===""?Je(M,"Unexpected end of expression"):Je(M,"Value expected")}function lr(M){return M.index-M.token.length+1}function Je(M,H){var se=lr(M),De=new SyntaxError(H+" (char "+se+")");return De.char=se,De}function cr(M,H){var se=lr(M),De=new SyntaxError(H+" (char "+se+")");return De.char=se,De}return e.addConversion({from:"string",to:"Node",convert:d}),d}),Zv="compile",NE=["typed","parse"],DE=R(Zv,NE,r=>{var{typed:e,parse:t}=r;return e(Zv,{string:function(n){return t(n).compile()},"Array | Matrix":function(n){return je(n,function(i){return t(i).compile()})}})}),Jv="evaluate",AE=["typed","parse"],EE=R(Jv,AE,r=>{var{typed:e,parse:t}=r;return e(Jv,{string:function(n){var i=Jn();return t(n).compile().evaluate(i)},"string, Map | Object":function(n,i){return t(n).compile().evaluate(i)},"Array | Matrix":function(n){var i=Jn();return je(n,function(s){return t(s).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(n,i){return je(n,function(s){return t(s).compile().evaluate(i)})}})}),SE="Parser",CE=["evaluate"],ME=R(SE,CE,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:Jn(),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 ng(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}),Wv="parser",FE=["typed","Parser"],TE=R(Wv,FE,r=>{var{typed:e,Parser:t}=r;return e(Wv,{"":function(){return new t}})}),Xv="lup",BE=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],$E=R(Xv,BE,r=>{var{typed:e,matrix:t,abs:a,addScalar:n,divideScalar:i,multiplyScalar:s,subtract:f,larger:l,equalScalar:u,unaryMinus:o,DenseMatrix:c,SparseMatrix:m,Spa:v}=r;return e(Xv,{DenseMatrix:function(b){return p(b)},SparseMatrix:function(b){return h(b)},Array:function(b){var A=t(b),d=p(A);return{L:d.L.valueOf(),U:d.U.valueOf(),p:d.p}}});function p(y){var b=y._size[0],A=y._size[1],d=Math.min(b,A),w=ke(y._data),x=[],g=[b,d],E=[],N=[d,A],S,D,T,B=[];for(S=0;S<b;S++)B[S]=S;for(D=0;D<A;D++){if(D>0)for(S=0;S<b;S++){var _=Math.min(S,D),L=0;for(T=0;T<_;T++)L=n(L,s(w[S][T],w[T][D]));w[S][D]=f(w[S][D],L)}var G=D,C=0,F=0;for(S=D;S<b;S++){var Z=w[S][D],$=a(Z);l($,C)&&(G=S,C=$,F=Z)}if(D!==G&&(B[D]=[B[G],B[G]=B[D]][0],c._swapRows(D,G,w)),D<b)for(S=D+1;S<b;S++){var U=w[S][D];u(U,0)||(w[S][D]=i(w[S][D],F))}}for(D=0;D<A;D++)for(S=0;S<b;S++){if(D===0&&(S<A&&(E[S]=[]),x[S]=[]),S<D){S<A&&(E[S][D]=w[S][D]),D<b&&(x[S][D]=0);continue}if(S===D){S<A&&(E[S][D]=w[S][D]),D<b&&(x[S][D]=1);continue}S<A&&(E[S][D]=0),D<b&&(x[S][D]=w[S][D])}var Y=new c({data:x,size:g}),j=new c({data:E,size:N}),P=[];for(S=0,d=B.length;S<d;S++)P[B[S]]=S;return{L:Y,U:j,p:P,toString:function(){return"L: "+this.L.toString()+`
|
|
41
42
|
U: `+this.U.toString()+`
|
|
42
|
-
P: `+this.p}}}function h(
|
|
43
|
+
P: `+this.p}}}function h(y){var b=y._size[0],A=y._size[1],d=Math.min(b,A),w=y._values,x=y._index,g=y._ptr,E=[],N=[],S=[],D=[b,d],T=[],B=[],_=[],L=[d,A],G,C,F,Z=[],$=[];for(G=0;G<b;G++)Z[G]=G,$[G]=G;var U=function(P,K){var ne=$[P],re=$[K];Z[ne]=K,Z[re]=P,$[P]=re,$[K]=ne},Y=function(){var P=new v;C<b&&(S.push(E.length),E.push(1),N.push(C)),_.push(T.length);var K=g[C],ne=g[C+1];for(F=K;F<ne;F++)G=x[F],P.set(Z[G],w[F]);C>0&&P.forEach(0,C-1,function(ce,oe){m._forEachRow(ce,E,N,S,function(Ce,Oe){Ce>ce&&P.accumulate(Ce,o(s(Oe,oe)))})});var re=C,fe=P.get(C),pe=a(fe);P.forEach(C+1,b-1,function(ce,oe){var Ce=a(oe);l(Ce,pe)&&(re=ce,pe=Ce,fe=oe)}),C!==re&&(m._swapRows(C,re,D[1],E,N,S),m._swapRows(C,re,L[1],T,B,_),P.swap(C,re),U(C,re)),P.forEach(0,b-1,function(ce,oe){ce<=C?(T.push(oe),B.push(ce)):(oe=i(oe,fe),u(oe,0)||(E.push(oe),N.push(ce)))})};for(C=0;C<A;C++)Y();return _.push(T.length),S.push(E.length),{L:new m({values:E,index:N,ptr:S,size:D}),U:new m({values:T,index:B,ptr:_,size:L}),p:Z,toString:function(){return"L: "+this.L.toString()+`
|
|
43
44
|
U: `+this.U.toString()+`
|
|
44
|
-
P: `+this.p}}}}),
|
|
45
|
-
R: `+this.R.toString()}}}function
|
|
45
|
+
P: `+this.p}}}}),Yv="qr",OE=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],_E=R(Yv,OE,r=>{var{typed:e,matrix:t,zeros:a,identity:n,isZero:i,equal:s,sign:f,sqrt:l,conj:u,unaryMinus:o,addScalar:c,divideScalar:m,multiplyScalar:v,subtract:p,complex:h}=r;return Ar(e(Yv,{DenseMatrix:function(w){return b(w)},SparseMatrix:function(w){return A()},Array:function(w){var x=t(w),g=b(x);return{Q:g.Q.valueOf(),R:g.R.valueOf()}}}),{_denseQRimpl:y});function y(d){var w=d._size[0],x=d._size[1],g=n([w],"dense"),E=g._data,N=d.clone(),S=N._data,D,T,B,_=a([w],"");for(B=0;B<Math.min(x,w);++B){var L=S[B][B],G=o(s(L,0)?1:f(L)),C=u(G),F=0;for(D=B;D<w;D++)F=c(F,v(S[D][B],u(S[D][B])));var Z=v(G,l(F));if(!i(Z)){var $=p(L,Z);for(_[B]=1,D=B+1;D<w;D++)_[D]=m(S[D][B],$);var U=o(u(m($,Z))),Y=void 0;for(T=B;T<x;T++){for(Y=0,D=B;D<w;D++)Y=c(Y,v(u(_[D]),S[D][T]));for(Y=v(Y,U),D=B;D<w;D++)S[D][T]=v(p(S[D][T],v(_[D],Y)),C)}for(D=0;D<w;D++){for(Y=0,T=B;T<w;T++)Y=c(Y,v(E[D][T],_[T]));for(Y=v(Y,U),T=B;T<w;++T)E[D][T]=m(p(E[D][T],v(Y,u(_[T]))),C)}}}return{Q:g,R:N,toString:function(){return"Q: "+this.Q.toString()+`
|
|
46
|
+
R: `+this.R.toString()}}}function b(d){var w=y(d),x=w.R._data;if(d._data.length>0)for(var g=x[0][0].type==="Complex"?h(0):0,E=0;E<x.length;++E)for(var N=0;N<E&&N<(x[0]||[]).length;++N)x[E][N]=g;return w}function A(d){throw new Error("qr not implemented for sparse matrices yet")}});function IE(r,e,t,a){for(var n=r._values,i=r._index,s=r._ptr,f=r._size,l=r._datatype,u=f[0],o=f[1],c=a&&r._values?[]:null,m=[],v=[],p=0,h=0;h<o;h++){v[h]=p;for(var y=t?t[h]:h,b=s[y],A=s[y+1],d=b;d<A;d++){var w=e?e[i[d]]:i[d];m[p]=w,c&&(c[p]=n[d]),p++}}return v[o]=p,r.createSparseMatrix({values:c,index:m,ptr:v,size:[u,o],datatype:l})}function Qv(r,e,t,a,n,i,s){var f=0;for(t[s]=r;f>=0;){var l=t[s+f],u=t[a+l];u===-1?(f--,i[e++]=l):(t[a+l]=t[n+u],++f,t[s+f]=u)}return e}function RE(r,e){if(!r)return null;var t=0,a,n=[],i=[],s=0,f=e,l=2*e;for(a=0;a<e;a++)i[s+a]=-1;for(a=e-1;a>=0;a--)r[a]!==-1&&(i[f+a]=i[s+r[a]],i[s+r[a]]=a);for(a=0;a<e;a++)r[a]===-1&&(t=Qv(a,t,i,s,f,n,l));return n}function qE(r,e){if(!r)return null;var t=r._index,a=r._ptr,n=r._size,i=n[0],s=n[1],f=[],l=[],u=0,o=s,c,m;if(e)for(c=0;c<i;c++)l[o+c]=-1;for(var v=0;v<s;v++){f[v]=-1,l[u+v]=-1;for(var p=a[v],h=a[v+1],y=p;y<h;y++){var b=t[y];for(c=e?l[o+b]:b;c!==-1&&c<v;c=m)m=l[u+c],l[u+c]=v,m===-1&&(f[c]=v);e&&(l[o+b]=v)}}return f}function zE(r,e,t){for(var a=r._values,n=r._index,i=r._ptr,s=r._size,f=s[1],l=0,u=0;u<f;u++){var o=i[u];for(i[u]=l;o<i[u+1];o++)e(n[o],u,a?a[o]:1,t)&&(n[l]=n[o],a&&(a[l]=a[o]),l++)}return i[f]=l,n.splice(l,n.length-l),a&&a.splice(l,a.length-l),l}function fn(r){return-r-2}var PE="csAmd",LE=["add","multiply","transpose"],UE=R(PE,LE,r=>{var{add:e,multiply:t,transpose:a}=r;return function(o,c){if(!c||o<=0||o>3)return null;var m=c._size,v=m[0],p=m[1],h=0,y=Math.max(16,10*Math.sqrt(p));y=Math.min(p-2,y);var b=n(o,c,v,p,y);zE(b,l,null);for(var A=b._index,d=b._ptr,w=d[p],x=[],g=[],E=0,N=p+1,S=2*(p+1),D=3*(p+1),T=4*(p+1),B=5*(p+1),_=6*(p+1),L=7*(p+1),G=x,C=i(p,d,g,E,D,G,S,L,N,_,T,B),F=s(p,d,g,B,T,_,y,N,D,G,S),Z=0,$,U,Y,j,P,K,ne,re,fe,pe,ce,oe,Ce,Oe,Me,$e;F<p;){for(Y=-1;Z<p&&(Y=g[D+Z])===-1;Z++);g[S+Y]!==-1&&(G[g[S+Y]]=-1),g[D+Z]=g[S+Y];var k=g[T+Y],W=g[N+Y];F+=W;var ie=0;g[N+Y]=-W;var V=d[Y],Q=k===0?V:w,te=Q;for(j=1;j<=k+1;j++){for(j>k?(K=Y,ne=V,re=g[E+Y]-k):(K=A[V++],ne=d[K],re=g[E+K]),P=1;P<=re;P++)$=A[ne++],!((fe=g[N+$])<=0)&&(ie+=fe,g[N+$]=-fe,A[te++]=$,g[S+$]!==-1&&(G[g[S+$]]=G[$]),G[$]!==-1?g[S+G[$]]=g[S+$]:g[D+g[B+$]]=g[S+$]);K!==Y&&(d[K]=fn(Y),g[_+K]=0)}for(k!==0&&(w=te),g[B+Y]=ie,d[Y]=Q,g[E+Y]=te-Q,g[T+Y]=-2,C=f(C,h,g,_,p),pe=Q;pe<te;pe++)if($=A[pe],!((ce=g[T+$])<=0)){fe=-g[N+$];var ge=C-fe;for(V=d[$],oe=d[$]+ce-1;V<=oe;V++)K=A[V],g[_+K]>=C?g[_+K]-=fe:g[_+K]!==0&&(g[_+K]=g[B+K]+ge)}for(pe=Q;pe<te;pe++){for($=A[pe],oe=d[$],Ce=oe+g[T+$]-1,Oe=oe,Me=0,$e=0,V=oe;V<=Ce;V++)if(K=A[V],g[_+K]!==0){var he=g[_+K]-C;he>0?($e+=he,A[Oe++]=K,Me+=K):(d[K]=fn(Y),g[_+K]=0)}g[T+$]=Oe-oe+1;var q=Oe,z=oe+g[E+$];for(V=Ce+1;V<z;V++){U=A[V];var ee=g[N+U];ee<=0||($e+=ee,A[Oe++]=U,Me+=U)}$e===0?(d[$]=fn(Y),fe=-g[N+$],ie-=fe,W+=fe,F+=fe,g[N+$]=0,g[T+$]=-1):(g[B+$]=Math.min(g[B+$],$e),A[Oe]=A[q],A[q]=A[oe],A[oe]=Y,g[E+$]=Oe-oe+1,Me=(Me<0?-Me:Me)%p,g[S+$]=g[L+Me],g[L+Me]=$,G[$]=Me)}for(g[B+Y]=ie,h=Math.max(h,ie),C=f(C+h,h,g,_,p),pe=Q;pe<te;pe++)if($=A[pe],!(g[N+$]>=0))for(Me=G[$],$=g[L+Me],g[L+Me]=-1;$!==-1&&g[S+$]!==-1;$=g[S+$],C++){for(re=g[E+$],ce=g[T+$],V=d[$]+1;V<=d[$]+re-1;V++)g[_+A[V]]=C;var ue=$;for(U=g[S+$];U!==-1;){var me=g[E+U]===re&&g[T+U]===ce;for(V=d[U]+1;me&&V<=d[U]+re-1;V++)g[_+A[V]]!==C&&(me=0);me?(d[U]=fn($),g[N+$]+=g[N+U],g[N+U]=0,g[T+U]=-1,U=g[S+U],g[S+ue]=U):(ue=U,U=g[S+U])}}for(V=Q,pe=Q;pe<te;pe++)$=A[pe],!((fe=-g[N+$])<=0)&&(g[N+$]=fe,$e=g[B+$]+ie-fe,$e=Math.min($e,p-F-fe),g[D+$e]!==-1&&(G[g[D+$e]]=$),g[S+$]=g[D+$e],G[$]=-1,g[D+$e]=$,Z=Math.min(Z,$e),g[B+$]=$e,A[V++]=$);g[N+Y]=W,(g[E+Y]=V-Q)===0&&(d[Y]=-1,g[_+Y]=0),k!==0&&(w=V)}for($=0;$<p;$++)d[$]=fn(d[$]);for(U=0;U<=p;U++)g[D+U]=-1;for(U=p;U>=0;U--)g[N+U]>0||(g[S+U]=g[D+d[U]],g[D+d[U]]=U);for(K=p;K>=0;K--)g[N+K]<=0||d[K]!==-1&&(g[S+K]=g[D+d[K]],g[D+d[K]]=K);for(Y=0,$=0;$<=p;$++)d[$]===-1&&(Y=Qv($,Y,g,D,S,x,_));return x.splice(x.length-1,1),x};function n(u,o,c,m,v){var p=a(o);if(u===1&&m===c)return e(o,p);if(u===2){for(var h=p._index,y=p._ptr,b=0,A=0;A<c;A++){var d=y[A];if(y[A]=b,!(y[A+1]-d>v))for(var w=y[A+1];d<w;d++)h[b++]=h[d]}return y[c]=b,o=a(p),t(p,o)}return t(p,o)}function i(u,o,c,m,v,p,h,y,b,A,d,w){for(var x=0;x<u;x++)c[m+x]=o[x+1]-o[x];c[m+u]=0;for(var g=0;g<=u;g++)c[v+g]=-1,p[g]=-1,c[h+g]=-1,c[y+g]=-1,c[b+g]=1,c[A+g]=1,c[d+g]=0,c[w+g]=c[m+g];var E=f(0,0,c,A,u);return c[d+u]=-2,o[u]=-1,c[A+u]=0,E}function s(u,o,c,m,v,p,h,y,b,A,d){for(var w=0,x=0;x<u;x++){var g=c[m+x];if(g===0)c[v+x]=-2,w++,o[x]=-1,c[p+x]=0;else if(g>h)c[y+x]=0,c[v+x]=-1,w++,o[x]=fn(u),c[y+u]++;else{var E=c[b+g];E!==-1&&(A[E]=x),c[d+x]=c[b+g],c[b+g]=x}}return w}function f(u,o,c,m,v){if(u<2||u+o<0){for(var p=0;p<v;p++)c[m+p]!==0&&(c[m+p]=1);u=2}return u}function l(u,o){return u!==o}});function kE(r,e,t,a,n,i,s){var f,l,u=0,o;if(r<=e||t[a+e]<=t[n+r])return-1;t[n+r]=t[a+e];var c=t[i+r];if(t[i+r]=e,c===-1)u=1,o=r;else{for(u=2,o=c;o!==t[s+o];o=t[s+o]);for(f=c;f!==o;f=l)l=t[s+f],t[s+f]=o}return{jleaf:u,q:o}}var VE="csCounts",GE=["transpose"],HE=R(VE,GE,r=>{var{transpose:e}=r;return function(t,a,n,i){if(!t||!a||!n)return null;var s=t._size,f=s[0],l=s[1],u,o,c,m,v,p,h,y=4*l+(i?l+f+1:0),b=[],A=0,d=l,w=2*l,x=3*l,g=4*l,E=5*l+1;for(c=0;c<y;c++)b[c]=-1;var N=[],S=e(t),D=S._index,T=S._ptr;for(c=0;c<l;c++)for(o=n[c],N[o]=b[x+o]===-1?1:0;o!==-1&&b[x+o]===-1;o=a[o])b[x+o]=c;if(i){for(c=0;c<l;c++)b[n[c]]=c;for(u=0;u<f;u++){for(c=l,p=T[u],h=T[u+1],v=p;v<h;v++)c=Math.min(c,b[D[v]]);b[E+u]=b[g+c],b[g+c]=u}}for(u=0;u<l;u++)b[A+u]=u;for(c=0;c<l;c++){for(o=n[c],a[o]!==-1&&N[a[o]]--,m=i?b[g+c]:o;m!==-1;m=i?b[E+m]:-1)for(v=T[m];v<T[m+1];v++){u=D[v];var B=kE(u,o,b,x,d,w,A);B.jleaf>=1&&N[o]++,B.jleaf===2&&N[B.q]--}a[o]!==-1&&(b[A+o]=a[o])}for(o=0;o<l;o++)a[o]!==-1&&(N[a[o]]+=N[o]);return N}}),ZE="csSqr",JE=["add","multiply","transpose"],WE=R(ZE,JE,r=>{var{add:e,multiply:t,transpose:a}=r,n=UE({add:e,multiply:t,transpose:a}),i=HE({transpose:a});return function(l,u,o){var c=u._ptr,m=u._size,v=m[1],p,h={};if(h.q=n(l,u),l&&!h.q)return null;if(o){var y=l?IE(u,null,h.q,0):u;h.parent=qE(y,1);var b=RE(h.parent,v);if(h.cp=i(y,h.parent,b,1),y&&h.parent&&h.cp&&s(y,h))for(h.unz=0,p=0;p<v;p++)h.unz+=h.cp[p]}else h.unz=4*c[v]+v,h.lnz=h.unz;return h};function s(f,l){var u=f._ptr,o=f._index,c=f._size,m=c[0],v=c[1];l.pinv=[],l.leftmost=[];var p=l.parent,h=l.pinv,y=l.leftmost,b=[],A=0,d=m,w=m+v,x=m+2*v,g,E,N,S,D;for(E=0;E<v;E++)b[d+E]=-1,b[w+E]=-1,b[x+E]=0;for(g=0;g<m;g++)y[g]=-1;for(E=v-1;E>=0;E--)for(S=u[E],D=u[E+1],N=S;N<D;N++)y[o[N]]=E;for(g=m-1;g>=0;g--)h[g]=-1,E=y[g],E!==-1&&(b[x+E]++===0&&(b[w+E]=g),b[A+g]=b[d+E],b[d+E]=g);for(l.lnz=0,l.m2=m,E=0;E<v;E++)if(g=b[d+E],l.lnz++,g<0&&(g=l.m2++),h[g]=E,!(--x[E]<=0)){l.lnz+=b[x+E];var T=p[E];T!==-1&&(b[x+T]===0&&(b[w+T]=b[w+E]),b[A+b[w+E]]=b[d+T],b[d+T]=b[A+g],b[x+T]+=b[x+E])}for(g=0;g<m;g++)h[g]<0&&(h[g]=E++);return!0}});function ys(r,e){return r[e]<0}function Kv(r,e){r[e]=fn(r[e])}function jv(r){return r<0?fn(r):r}function XE(r,e,t,a,n){var i=e._index,s=e._ptr,f=e._size,l=f[1],u,o,c,m=0;for(a[0]=r;m>=0;){r=a[m];var v=n?n[r]:r;ys(s,r)||(Kv(s,r),a[l+m]=v<0?0:jv(s[v]));var p=1;for(o=a[l+m],c=v<0?0:jv(s[v+1]);o<c;o++)if(u=i[o],!ys(s,u)){a[l+m]=o,a[++m]=u,p=0;break}p&&(m--,a[--t]=r)}return t}function YE(r,e,t,a,n){var i=r._ptr,s=r._size,f=e._index,l=e._ptr,u=s[1],o,c,m,v=u;for(c=l[t],m=l[t+1],o=c;o<m;o++){var p=f[o];ys(i,p)||(v=XE(p,r,v,a,n))}for(o=v;o<u;o++)Kv(i,a[o]);return v}var QE="csSpsolve",KE=["divideScalar","multiply","subtract"],jE=R(QE,KE,r=>{var{divideScalar:e,multiply:t,subtract:a}=r;return function(i,s,f,l,u,o,c){var m=i._values,v=i._index,p=i._ptr,h=i._size,y=h[1],b=s._values,A=s._index,d=s._ptr,w,x,g,E,N=YE(i,s,f,l,o);for(w=N;w<y;w++)u[l[w]]=0;for(x=d[f],g=d[f+1],w=x;w<g;w++)u[A[w]]=b[w];for(var S=N;S<y;S++){var D=l[S],T=o?o[D]:D;if(!(T<0))for(x=p[T],g=p[T+1],u[D]=e(u[D],m[c?x:g-1]),w=c?x+1:x,E=c?g:g-1;w<E;w++){var B=v[w];u[B]=a(u[B],t(m[w],u[D]))}}return N}}),eS="csLu",rS=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],tS=R(eS,rS,r=>{var{abs:e,divideScalar:t,multiply:a,subtract:n,larger:i,largerEq:s,SparseMatrix:f}=r,l=jE({divideScalar:t,multiply:a,subtract:n});return function(o,c,m){if(!o)return null;var v=o._size,p=v[1],h,y=100,b=100;c&&(h=c.q,y=c.lnz||y,b=c.unz||b);var A=[],d=[],w=[],x=new f({values:A,index:d,ptr:w,size:[p,p]}),g=[],E=[],N=[],S=new f({values:g,index:E,ptr:N,size:[p,p]}),D=[],T,B,_=[],L=[];for(T=0;T<p;T++)_[T]=0,D[T]=-1,w[T+1]=0;y=0,b=0;for(var G=0;G<p;G++){w[G]=y,N[G]=b;var C=h?h[G]:G,F=l(x,o,C,L,_,D,1),Z=-1,$=-1;for(B=F;B<p;B++)if(T=L[B],D[T]<0){var U=e(_[T]);i(U,$)&&($=U,Z=T)}else E[b]=D[T],g[b++]=_[T];if(Z===-1||$<=0)return null;D[C]<0&&s(e(_[C]),a($,m))&&(Z=C);var Y=_[Z];for(E[b]=G,g[b++]=Y,D[Z]=G,d[y]=Z,A[y++]=1,B=F;B<p;B++)T=L[B],D[T]<0&&(d[y]=T,A[y++]=t(_[T],Y)),_[T]=0}for(w[p]=y,N[p]=b,B=0;B<y;B++)d[B]=D[d[B]];return A.splice(y,A.length-y),d.splice(y,d.length-y),g.splice(b,g.length-b),E.splice(b,E.length-b),{L:x,U:S,pinv:D}}}),ep="slu",nS=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],aS=R(ep,nS,r=>{var{typed:e,abs:t,add:a,multiply:n,transpose:i,divideScalar:s,subtract:f,larger:l,largerEq:u,SparseMatrix:o}=r,c=WE({add:a,multiply:n,transpose:i}),m=tS({abs:t,divideScalar:s,multiply:n,subtract:f,larger:l,largerEq:u,SparseMatrix:o});return e(ep,{"SparseMatrix, number, number":function(p,h,y){if(!qe(h)||h<0||h>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(y<0||y>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var b=c(h,p,!1),A=m(p,b,y);return{L:A.L,U:A.U,p:A.pinv,q:b.q,toString:function(){return"L: "+this.L.toString()+`
|
|
46
47
|
U: `+this.U.toString()+`
|
|
47
48
|
p: `+this.p.toString()+(this.q?`
|
|
48
49
|
q: `+this.q.toString():"")+`
|
|
49
|
-
`}}}})});function
|
|
50
|
+
`}}}})});function rp(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 tp="lusolve",iS=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],oS=R(tp,iS,r=>{var{typed:e,matrix:t,lup:a,slu:n,usolve:i,lsolve:s,DenseMatrix:f}=r,l=ka({DenseMatrix:f});return e(tp,{"Array, Array | Matrix":function(m,v){m=t(m);var p=a(m),h=o(p.L,p.U,p.p,null,v);return h.valueOf()},"DenseMatrix, Array | Matrix":function(m,v){var p=a(m);return o(p.L,p.U,p.p,null,v)},"SparseMatrix, Array | Matrix":function(m,v){var p=a(m);return o(p.L,p.U,p.p,null,v)},"SparseMatrix, Array | Matrix, number, number":function(m,v,p,h){var y=n(m,p,h);return o(y.L,y.U,y.p,y.q,v)},"Object, Array | Matrix":function(m,v){return o(m.L,m.U,m.p,m.q,v)}});function u(c){if(He(c))return c;if(ur(c))return t(c);throw new TypeError("Invalid Matrix LU decomposition")}function o(c,m,v,p,h){c=u(c),m=u(m),v&&(h=l(c,h,!0),h._data=rp(v,h._data));var y=s(c,h),b=i(m,y);return p&&(b._data=rp(p,b._data)),b}}),sS="Help",uS=["parse"],lS=R(sS,uS,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
51
|
`;if(a.name&&(n+="Name: "+a.name+`
|
|
51
52
|
|
|
52
53
|
`),a.category&&(n+="Category: "+a.category+`
|
|
@@ -59,25 +60,26 @@ q: `+this.q.toString():"")+`
|
|
|
59
60
|
`)+`
|
|
60
61
|
|
|
61
62
|
`),a.examples){n+=`Examples:
|
|
62
|
-
`;for(var i={},
|
|
63
|
-
`;var
|
|
63
|
+
`;for(var i={},s=0;s<a.examples.length;s++){var f=a.examples[s];n+=" "+f+`
|
|
64
|
+
`;var l=void 0;try{l=e(f).compile().evaluate(i)}catch(u){l=u}l!==void 0&&!Xu(l)&&(n+=" "+Ye(l,{precision:14})+`
|
|
64
65
|
`)}n+=`
|
|
65
66
|
`}return a.mayThrow&&a.mayThrow.length&&(n+="Throws: "+a.mayThrow.join(", ")+`
|
|
66
67
|
|
|
67
68
|
`),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
|
+
`),n},t.prototype.toJSON=function(){var a=ke(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}),cS="Chain",fS=["?on","math","typed"],mS=R(cS,fS,r=>{var{on:e,math:t,typed:a}=r;function n(u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Yu(u)?this.value=u.value:this.value=u}n.prototype.type="Chain",n.prototype.isChain=!0,n.prototype.done=function(){return this.value},n.prototype.valueOf=function(){return this.value},n.prototype.toString=function(){return Ye(this.value)},n.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},n.fromJSON=function(u){return new n(u.value)};function i(u,o){typeof o=="function"&&(n.prototype[u]=f(o))}function s(u,o){N0(n.prototype,u,function(){var m=o();if(typeof m=="function")return f(m)})}function f(u){return function(){if(arguments.length===0)return new n(u(this.value));for(var o=[this.value],c=0;c<arguments.length;c++)o[c+1]=arguments[c];if(a.isTypedFunction(u)){var m=a.resolve(u,o);if(m.params.length===1)throw new Error("chain function "+u.name+" cannot match rest parameter between chain value and additional arguments.");return new n(m.implementation.apply(u,o))}return new n(u.apply(u,o))}}n.createProxy=function(u,o){if(typeof u=="string")i(u,o);else{var c=function(p){Re(u,p)&&l[p]===void 0&&s(p,()=>u[p])};for(var m in u)c(m)}};var l={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(t),e&&e("import",function(u,o,c){c||s(u,o)}),n},{isClass:!0}),np={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"]},vS={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},pS={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:[]},hS={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:[]},dS={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},gS={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},yS={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:[]},bS={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:[]},xS={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},wS={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},NS={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:[]},ap={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"]},DS={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:[]},AS={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},ES={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"]},SS={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},CS={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},MS={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"]},FS={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"]},TS={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"]},BS={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"]},OS={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[1:2, 1:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},_S={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"]},IS={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"]},RS={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"]},qS={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"]},zS={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"]},PS={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"]},LS={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:[]},US={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:[]},kS={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:[]},VS={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"]},GS={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"]},HS={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"]},ZS={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"]},JS={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"]},WS={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"]},XS={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"]},YS={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"]},QS={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"]},KS={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"]},jS={name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConatant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},eC={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","simplifyConstant","evaluate"]},rC={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"]},tC={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"]},nC={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"]},aC={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"]},iC={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},oC={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"]},sC={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"]},uC={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"]},lC={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"]},cC={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"]},fC={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"]},mC={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"]},vC={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"]},pC={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"]},hC={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"]},dC={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"]},gC={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"]},yC={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"]},bC={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"]},xC={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"]},wC={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"]},NC={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"]},DC={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"]},AC={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"]},EC={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"]},SC={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"]},CC={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"]},MC={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"]},FC={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")']},TC={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"]},BC={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"]},$C={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"]},OC={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"]},_C={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"]},IC={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"]},RC={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"]},qC={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"]},zC={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"]},PC={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"]},LC={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},UC={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"]},kC={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"]},VC={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"]},GC={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"]},HC={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"]},ZC={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"]},JC={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"]},WC={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"]},XC={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"]},YC={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"]},QC={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"]},KC={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"]},jC={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"]},eM={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"]},rM={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"]},tM={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"]},nM={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:[]},aM={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},iM={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:[]},oM={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:[]},sM={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"]},uM={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"]},lM={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"]},cM={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"]},fM={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"]},mM={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"]},vM={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"]},pM={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"]},hM={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"]},dM={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"]},gM={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"]},yM={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"]},bM={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"]},xM={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"]},wM={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"]},NM={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"]},DM={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"]},AM={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"]},EM={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"]},SM={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"]},CM={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"]},MM={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"]},FM={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"]},TM={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"]},BM={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"]},$M={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"]},OM={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"]},_M={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"]},IM={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"]},RM={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"]},qM={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"]},zM={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"]},PM={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"]},LM={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"]},UM={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"]},kM={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"]},VM={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"]},GM={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"]},HM={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"]},ZM={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"]},JM={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"]},WM={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},XM={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},YM={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"]},QM={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"]},KM={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"]},jM={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"]},e3={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"]},r3={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:[]},t3={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"]},n3={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"]},a3={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"]},i3={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"]},o3={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"]},s3={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"]},u3={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"]},l3={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"]},c3={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"]},f3={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"]},m3={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"]},v3={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"]},p3={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"]},h3={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"]},d3={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"]},g3={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"]},y3={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"]},b3={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"]},x3={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"]},w3={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"]},N3={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"]},D3={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"]},A3={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"]},E3={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"]},S3={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"]},C3={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"]},M3={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:[]},F3={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"]},T3={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"]},B3={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"]},$3={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"]},O3={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"]},_3={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"]},I3={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"]},R3={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
|
|
|
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
|
+
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"]},q3={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"]},z3={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"]},P3={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"]},L3={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"]},U3={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"]},k3={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"]},V3={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"]},G3={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"]},H3={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"]},Z3={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"]},J3={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"]},W3={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},X3={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"]},Y3={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"]},Q3={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"]},K3={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"]},j3={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"]},eF={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"]},rF={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},tF={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"]},nF={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"]},aF={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"]},iF={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"]},oF={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"]},sF={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"]},uF={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"]},lF={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},cF={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"]},fF={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"]},mF={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:[]},vF={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},pF={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:[]},hF={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"]},dF={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"]},gF={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},yF={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"]},bF={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"]},xF={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"]},wF={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"]},NF={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"]},DF={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"]},AF={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"]},EF={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"]},SF={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},CF={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"]},MF={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"]},FF={bignumber:MS,boolean:FS,complex:TS,createUnit:BS,fraction:$S,index:OS,matrix:_S,number:IS,sparse:RS,splitUnit:qS,string:zS,unit:PS,e:np,E:np,false:vS,i:pS,Infinity:hS,LN2:gS,LN10:dS,LOG2E:bS,LOG10E:yS,NaN:xS,null:wS,pi:ap,PI:ap,phi:NS,SQRT1_2:DS,SQRT2:AS,tau:ES,true:SS,version:CS,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:VS,lsolve:HS,lsolveAll:ZS,lup:JS,lusolve:WS,leafCount:GS,resolve:QS,simplify:KS,simplifyConstant:jS,simplifyCore:eC,symbolicEqual:tC,rationalize:YS,slu:rC,usolve:nC,usolveAll:aC,qr:XS,abs:iC,add:oC,cbrt:sC,ceil:uC,cube:lC,divide:cC,dotDivide:fC,dotMultiply:mC,dotPow:vC,exp:pC,expm:hC,expm1:dC,fix:gC,floor:yC,gcd:bC,hypot:xC,lcm:NC,log:DC,log2:SC,log1p:EC,log10:AC,mod:CC,multiply:MC,norm:FC,nthRoot:TC,nthRoots:BC,pow:$C,round:OC,sign:_C,sqrt:IC,sqrtm:RC,square:qC,subtract:zC,unaryMinus:PC,unaryPlus:LC,xgcd:UC,invmod:wC,bitAnd:kC,bitNot:VC,bitOr:GC,bitXor:HC,leftShift:ZC,rightArithShift:JC,rightLogShift:WC,bellNumbers:XC,catalan:YC,composition:QC,stirlingS2:KC,config:LS,import:US,typed:kS,arg:jC,conj:eM,re:tM,im:rM,evaluate:nM,help:aM,distance:iM,intersect:oM,and:sM,not:uM,or:lM,xor:cM,concat:mM,count:vM,cross:pM,column:fM,ctranspose:hM,det:dM,diag:gM,diff:yM,dot:bM,getMatrixDataType:AM,identity:EM,filter:wM,flatten:NM,forEach:DM,inv:SM,pinv:CM,eigs:xM,kron:MM,matrixFromFunction:BM,matrixFromRows:$M,matrixFromColumns:TM,map:FM,ones:OM,partitionSelect:_M,range:IM,resize:qM,reshape:RM,rotate:zM,rotationMatrix:PM,row:LM,size:UM,sort:kM,squeeze:VM,subset:GM,trace:HM,transpose:ZM,zeros:JM,fft:WM,ifft:XM,combinations:YM,combinationsWithRep:QM,factorial:KM,gamma:jM,kldivergence:r3,lgamma:e3,multinomial:t3,permutations:n3,pickRandom:a3,random:i3,randomInt:o3,compare:s3,compareNatural:u3,compareText:l3,deepEqual:c3,equal:f3,equalText:m3,larger:v3,largerEq:p3,smaller:h3,smallerEq:d3,unequal:g3,setCartesian:y3,setDifference:b3,setDistinct:x3,setIntersect:w3,setIsSubset:N3,setMultiplicity:D3,setPowerset:A3,setSize:E3,setSymDifference:S3,setUnion:C3,erf:M3,cumsum:z3,mad:F3,max:T3,mean:B3,median:$3,min:O3,mode:_3,prod:I3,quantileSeq:R3,std:q3,sum:P3,variance:L3,acos:U3,acosh:k3,acot:V3,acoth:G3,acsc:H3,acsch:Z3,asec:J3,asech:W3,asin:X3,asinh:Y3,atan:Q3,atanh:j3,atan2:K3,cos:eF,cosh:rF,cot:tF,coth:nF,csc:aF,csch:iF,sec:oF,sech:sF,sin:uF,sinh:lF,tan:cF,tanh:fF,to:mF,clone:pF,format:hF,bin:vF,oct:SF,hex:gF,isNaN:bF,isInteger:yF,isNegative:xF,isNumeric:wF,hasNumericValue:dF,isPositive:NF,isPrime:DF,isZero:AF,print:CF,typeOf:MF,numeric:EF},ip="help",TF=["typed","mathWithTransform","Help"],BF=R(ip,TF,r=>{var{typed:e,mathWithTransform:t,Help:a}=r;return e(ip,{any:function(i){var s,f=i;if(typeof i!="string"){for(s in t)if(Re(t,s)&&i===t[s]){f=s;break}}var l=ot(FF,f);if(!l){var u=typeof f=="function"?f.name:f;throw new Error('No documentation found on "'+u+'"')}return new a(l)}})}),op="chain",$F=["typed","Chain"],OF=R(op,$F,r=>{var{typed:e,Chain:t}=r;return e(op,{"":function(){return new t},any:function(n){return new t(n)}})}),sp="det",_F=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],IF=R(sp,_F,r=>{var{typed:e,matrix:t,subtract:a,multiply:n,divideScalar:i,isZero:s,unaryMinus:f}=r;return e(sp,{any:function(o){return ke(o)},"Array | Matrix":function(o){var c;switch(He(o)?c=o.size():Array.isArray(o)?(o=t(o),c=o.size()):c=[],c.length){case 0:return ke(o);case 1:if(c[0]===1)return ke(o.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Ye(c)+")");case 2:{var m=c[0],v=c[1];if(m===v)return l(o.clone().valueOf(),m);throw new RangeError("Matrix must be square (size: "+Ye(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(c)+")")}}});function l(u,o,c){if(o===1)return ke(u[0][0]);if(o===2)return a(n(u[0][0],u[1][1]),n(u[1][0],u[0][1]));for(var m=!1,v=new Array(o).fill(0).map((E,N)=>N),p=0;p<o;p++){var h=v[p];if(s(u[h][p])){var y=void 0;for(y=p+1;y<o;y++)if(!s(u[v[y]][p])){h=v[y],v[y]=v[p],v[p]=h,m=!m;break}if(y===o)return u[h][p]}for(var b=u[h][p],A=p===0?1:u[v[p-1]][p-1],d=p+1;d<o;d++)for(var w=v[d],x=p+1;x<o;x++)u[w][x]=i(a(n(u[w][x],b),n(u[w][p],u[h][x])),A)}var g=u[v[o-1]][o-1];return m?f(g):g}}),up="inv",RF=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],qF=R(up,RF,r=>{var{typed:e,matrix:t,divideScalar:a,addScalar:n,multiply:i,unaryMinus:s,det:f,identity:l,abs:u}=r;return e(up,{"Array | Matrix":function(m){var v=He(m)?m.size():er(m);switch(v.length){case 1:if(v[0]===1)return He(m)?t([a(1,m.valueOf()[0])]):[a(1,m[0])];throw new RangeError("Matrix must be square (size: "+Ye(v)+")");case 2:{var p=v[0],h=v[1];if(p===h)return He(m)?t(o(m.valueOf(),p,h),m.storage()):o(m,p,h);throw new RangeError("Matrix must be square (size: "+Ye(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(v)+")")}},any:function(m){return a(1,m)}});function o(c,m,v){var p,h,y,b,A;if(m===1){if(b=c[0][0],b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(1,b)]]}else if(m===2){var d=f(c);if(d===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(c[1][1],d),a(s(c[0][1]),d)],[a(s(c[1][0]),d),a(c[0][0],d)]]}else{var w=c.concat();for(p=0;p<m;p++)w[p]=w[p].concat();for(var x=l(m).valueOf(),g=0;g<v;g++){var E=u(w[g][g]),N=g;for(p=g+1;p<m;)u(w[p][g])>E&&(E=u(w[p][g]),N=p),p++;if(E===0)throw Error("Cannot calculate inverse, determinant is zero");p=N,p!==g&&(A=w[g],w[g]=w[p],w[p]=A,A=x[g],x[g]=x[p],x[p]=A);var S=w[g],D=x[g];for(p=0;p<m;p++){var T=w[p],B=x[p];if(p!==g){if(T[g]!==0){for(y=a(s(T[g]),S[g]),h=g;h<v;h++)T[h]=n(T[h],i(y,S[h]));for(h=0;h<v;h++)B[h]=n(B[h],i(y,D[h]))}}else{for(y=S[g],h=g;h<v;h++)T[h]=a(T[h],y);for(h=0;h<v;h++)B[h]=a(B[h],y)}}}return x}}}),lp="pinv",zF=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],PF=R(lp,zF,r=>{var{typed:e,matrix:t,inv:a,deepEqual:n,equal:i,dotDivide:s,dot:f,ctranspose:l,divideScalar:u,multiply:o,add:c,Complex:m}=r;return e(lp,{"Array | Matrix":function(d){var w=He(d)?d.size():er(d);switch(w.length){case 1:return b(d)?l(d):w[0]===1?a(d):s(l(d),f(d,d));case 2:{if(b(d))return l(d);var x=w[0],g=w[1];if(x===g)try{return a(d)}catch(E){if(!(E instanceof Error&&E.message.match(/Cannot calculate inverse, determinant is zero/)))throw E}return He(d)?t(v(d.valueOf(),x,g),d.storage()):v(d,x,g)}default:throw new RangeError("Matrix must be two dimensional (size: "+Ye(w)+")")}},any:function(d){return i(d,0)?ke(d):u(1,d)}});function v(A,d,w){var{C:x,F:g}=h(A,d,w),E=o(a(o(l(x),x)),l(x)),N=o(l(g),a(o(g,l(g))));return o(N,E)}function p(A,d,w){for(var x=ke(A),g=0,E=0;E<d;E++){if(w<=g)return x;for(var N=E;y(x[N][g]);)if(N++,d===N&&(N=E,g++,w===g))return x;[x[N],x[E]]=[x[E],x[N]];for(var S=x[E][g],D=0;D<w;D++)x[E][D]=s(x[E][D],S);for(var T=0;T<d;T++)if(T!==E){S=x[T][g];for(var B=0;B<w;B++)x[T][B]=c(x[T][B],o(-1,o(S,x[E][B])))}g++}return x}function h(A,d,w){var x=p(A,d,w),g=A.map((N,S)=>N.filter((D,T)=>T<d&&!y(f(x[T],x[T])))),E=x.filter((N,S)=>!y(f(x[S],x[S])));return{C:g,F:E}}function y(A){return i(c(A,m(1,1)),c(0,m(1,1)))}function b(A){return n(c(A,m(1,1)),c(o(A,0),m(1,1)))}});function LF(r){var{addScalar:e,subtract:t,flatten:a,multiply:n,multiplyScalar:i,divideScalar:s,sqrt:f,abs:l,bignumber:u,diag:o,inv:c,qr:m,usolve:v,usolveAll:p,equal:h,complex:y,larger:b,smaller:A,matrixFromColumns:d,dot:w}=r;function x(U,Y,j,P,K){K===void 0&&(K=!0);var ne=g(U,Y,j,P,K);E(U,Y,j,P,K,ne);var{values:re,C:fe}=N(U,Y,j,P,K),pe;return K&&(pe=S(U,Y,fe,ne,re,j,P),pe=d(...pe)),{values:re,vectors:pe}}function g(U,Y,j,P,K){var ne=P==="BigNumber",re=P==="Complex",fe=ne?u(0):0,pe=ne?u(1):re?y(1):1,ce=ne?u(1):1,oe=ne?u(10):2,Ce=i(oe,oe),Oe;K&&(Oe=Array(Y).fill(pe));for(var Me=!1;!Me;){Me=!0;for(var $e=0;$e<Y;$e++){for(var k=fe,W=fe,ie=0;ie<Y;ie++)if($e!==ie){var V=l(U[$e][ie]);k=e(k,V),W=e(W,V)}if(!h(k,0)&&!h(W,0)){for(var Q=ce,te=k,ge=s(W,oe),he=i(W,oe);A(te,ge);)te=i(te,Ce),Q=i(Q,oe);for(;b(te,he);)te=s(te,Ce),Q=s(Q,oe);var q=A(s(e(te,W),Q),i(e(k,W),.95));if(q){Me=!1;for(var z=s(1,Q),ee=0;ee<Y;ee++)$e!==ee&&(U[$e][ee]=i(U[$e][ee],Q),U[ee][$e]=i(U[ee][$e],z));K&&(Oe[$e]=i(Oe[$e],Q))}}}}return o(Oe)}function E(U,Y,j,P,K,ne){var re=P==="BigNumber",fe=P==="Complex",pe=re?u(0):fe?y(0):0;re&&(j=u(j));for(var ce=0;ce<Y-2;ce++){for(var oe=0,Ce=pe,Oe=ce+1;Oe<Y;Oe++){var Me=U[Oe][ce];A(l(Ce),l(Me))&&(Ce=Me,oe=Oe)}if(!A(l(Ce),j)){if(oe!==ce+1){var $e=U[oe];U[oe]=U[ce+1],U[ce+1]=$e;for(var k=0;k<Y;k++){var W=U[k][oe];U[k][oe]=U[k][ce+1],U[k][ce+1]=W}if(K){var ie=ne[oe];ne[oe]=ne[ce+1],ne[ce+1]=ie}}for(var V=ce+2;V<Y;V++){var Q=s(U[V][ce],Ce);if(Q!==0){for(var te=0;te<Y;te++)U[V][te]=t(U[V][te],i(Q,U[ce+1][te]));for(var ge=0;ge<Y;ge++)U[ge][ce+1]=e(U[ge][ce+1],i(Q,U[ge][V]));if(K)for(var he=0;he<Y;he++)ne[V][he]=t(ne[V][he],i(Q,ne[ce+1][he]))}}}}return ne}function N(U,Y,j,P,K){var ne=P==="BigNumber",re=P==="Complex",fe=ne?u(1):re?y(1):1;ne&&(j=u(j));for(var pe=ke(U),ce=[],oe=Y,Ce=[],Oe=K?o(Array(Y).fill(fe)):void 0,Me=K?o(Array(oe).fill(fe)):void 0,$e=0;$e<=100;){$e+=1;for(var k=0,W=0;W<oe;W++)pe[W][W]=t(pe[W][W],k);var{Q:ie,R:V}=m(pe);pe=n(V,ie);for(var Q=0;Q<oe;Q++)pe[Q][Q]=e(pe[Q][Q],k);if(K&&(Me=n(Me,ie)),oe===1||A(l(pe[oe-1][oe-2]),j)){$e=0,ce.push(pe[oe-1][oe-1]),K&&(Ce.unshift([[1]]),B(Me,Y),Oe=n(Oe,Me),oe>1&&(Me=o(Array(oe-1).fill(fe)))),oe-=1,pe.pop();for(var te=0;te<oe;te++)pe[te].pop()}else if(oe===2||A(l(pe[oe-2][oe-3]),j)){$e=0;var ge=D(pe[oe-2][oe-2],pe[oe-2][oe-1],pe[oe-1][oe-2],pe[oe-1][oe-1]);ce.push(...ge),K&&(Ce.unshift(T(pe[oe-2][oe-2],pe[oe-2][oe-1],pe[oe-1][oe-2],pe[oe-1][oe-1],ge[0],ge[1],j,P)),B(Me,Y),Oe=n(Oe,Me),oe>2&&(Me=o(Array(oe-2).fill(fe)))),oe-=2,pe.pop(),pe.pop();for(var he=0;he<oe;he++)pe[he].pop(),pe[he].pop()}if(oe===0)break}if(ce.sort((ee,ue)=>+t(l(ee),l(ue))),$e>100){var q=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ce.join(", "));throw q.values=ce,q.vectors=[],q}var z=K?n(Oe,_(Ce,Y)):void 0;return{values:ce,C:z}}function S(U,Y,j,P,K,ne,re){var fe=c(j),pe=n(fe,U,j),ce=re==="BigNumber",oe=re==="Complex",Ce=ce?u(0):oe?y(0):0,Oe=ce?u(1):oe?y(1):1,Me=[],$e=[];for(var k of K){var W=L(Me,k,h);W===-1?(Me.push(k),$e.push(1)):$e[W]+=1}for(var ie=[],V=Me.length,Q=Array(Y).fill(Ce),te=o(Array(Y).fill(Oe)),ge=[],he=function(ue){var me=Me[ue],ye=t(pe,n(me,te)),be=p(ye,Q);for(be.shift();be.length<$e[ue];){var ve=G(ye,Y,be,ne,re);if(ve==null){ge.push(me);break}be.push(ve)}var Ne=n(c(P),j);be=be.map(Ie=>n(Ne,Ie)),ie.push(...be.map(Ie=>a(Ie)))},q=0;q<V;q++)he(q);if(ge.length!==0){var z=new Error("Failed to find eigenvectors for the following eigenvalues: "+ge.join(", "));throw z.values=K,z.vectors=ie,z}return ie}function D(U,Y,j,P){var K=e(U,P),ne=t(i(U,P),i(Y,j)),re=i(K,.5),fe=i(f(t(i(K,K),i(4,ne))),.5);return[e(re,fe),t(re,fe)]}function T(U,Y,j,P,K,ne,re,fe){var pe=fe==="BigNumber",ce=fe==="Complex",oe=pe?u(0):ce?y(0):0,Ce=pe?u(1):ce?y(1):1;if(A(l(j),re))return[[Ce,oe],[oe,Ce]];if(b(l(t(K,ne)),re))return[[t(K,P),t(ne,P)],[j,j]];var Oe=t(U,K),Me=t(Y,K),$e=t(j,K),k=t(P,K);return A(l(Me),re)?[[Oe,Ce],[$e,oe]]:[[Me,oe],[k,Ce]]}function B(U,Y){for(var j=0;j<U.length;j++)U[j].push(...Array(Y-U[j].length).fill(0));for(var P=U.length;P<Y;P++)U.push(Array(Y).fill(0)),U[P][P]=1;return U}function _(U,Y){for(var j=[],P=0;P<Y;P++)j[P]=Array(Y).fill(0);var K=0;for(var ne of U){for(var re=ne.length,fe=0;fe<re;fe++)for(var pe=0;pe<re;pe++)j[K+fe][K+pe]=ne[fe][pe];K+=re}return j}function L(U,Y,j){for(var P=0;P<U.length;P++)if(j(U[P],Y))return P;return-1}function G(U,Y,j,P,K){for(var ne=K==="BigNumber"?u(1e3):1e3,re,fe=0;re=C(Y,j,K),re=v(U,re),!b(Z(re),ne);)if(++fe>=5)return null;for(fe=0;;){var pe=v(U,re);if(A(Z(F(re,[pe])),P))break;if(++fe>=10)return null;re=$(pe)}return re}function C(U,Y,j){var P=j==="BigNumber",K=j==="Complex",ne=Array(U).fill(0).map(re=>2*Math.random()-1);return P&&(ne=ne.map(re=>u(re))),K&&(ne=ne.map(re=>y(re))),ne=F(ne,Y),$(ne,j)}function F(U,Y){for(var j of Y)U=t(U,n(s(w(j,U),w(j,j)),j));return U}function Z(U){return l(f(w(U,U)))}function $(U,Y){var j=Y==="BigNumber",P=Y==="Complex",K=j?u(1):P?y(1):1;return n(s(K,Z(U)),U)}return x}function UF(r){var{config:e,addScalar:t,subtract:a,abs:n,atan:i,cos:s,sin:f,multiplyScalar:l,inv:u,bignumber:o,multiply:c,add:m}=r;function v(D,T){var B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.epsilon,_=arguments.length>3?arguments[3]:void 0;if(_==="number")return p(D,B);if(_==="BigNumber")return h(D,B);throw TypeError("Unsupported data type: "+_)}function p(D,T){for(var B=D.length,_=Math.abs(T/B),L,G=new Array(B),C=0;C<B;C++)G[C]=S(B,0),G[C][C]=1;for(var F=g(D);Math.abs(F[1])>=Math.abs(_);){var Z=F[0][0],$=F[0][1];L=y(D[Z][Z],D[$][$],D[Z][$]),D=x(D,L,Z,$),G=A(G,L,Z,$),F=g(D)}for(var U=S(B,0),Y=0;Y<B;Y++)U[Y]=D[Y][Y];return N(ke(U),ke(G))}function h(D,T){for(var B=D.length,_=n(T/B),L,G=new Array(B),C=0;C<B;C++)G[C]=S(B,0),G[C][C]=1;for(var F=E(D);n(F[1])>=n(_);){var Z=F[0][0],$=F[0][1];L=b(D[Z][Z],D[$][$],D[Z][$]),D=w(D,L,Z,$),G=d(G,L,Z,$),F=E(D)}for(var U=S(B,0),Y=0;Y<B;Y++)U[Y]=D[Y][Y];return N(ke(U),ke(G))}function y(D,T,B){var _=T-D;return Math.abs(_)<=e.epsilon?Math.PI/4:.5*Math.atan(2*B/(T-D))}function b(D,T,B){var _=a(T,D);return n(_)<=e.epsilon?o(-1).acos().div(4):l(.5,i(c(2,B,u(_))))}function A(D,T,B,_){for(var L=D.length,G=Math.cos(T),C=Math.sin(T),F=S(L,0),Z=S(L,0),$=0;$<L;$++)F[$]=G*D[$][B]-C*D[$][_],Z[$]=C*D[$][B]+G*D[$][_];for(var U=0;U<L;U++)D[U][B]=F[U],D[U][_]=Z[U];return D}function d(D,T,B,_){for(var L=D.length,G=s(T),C=f(T),F=S(L,o(0)),Z=S(L,o(0)),$=0;$<L;$++)F[$]=a(l(G,D[$][B]),l(C,D[$][_])),Z[$]=t(l(C,D[$][B]),l(G,D[$][_]));for(var U=0;U<L;U++)D[U][B]=F[U],D[U][_]=Z[U];return D}function w(D,T,B,_){for(var L=D.length,G=o(s(T)),C=o(f(T)),F=l(G,G),Z=l(C,C),$=S(L,o(0)),U=S(L,o(0)),Y=c(o(2),G,C,D[B][_]),j=t(a(l(F,D[B][B]),Y),l(Z,D[_][_])),P=m(l(Z,D[B][B]),Y,l(F,D[_][_])),K=0;K<L;K++)$[K]=a(l(G,D[B][K]),l(C,D[_][K])),U[K]=t(l(C,D[B][K]),l(G,D[_][K]));D[B][B]=j,D[_][_]=P,D[B][_]=o(0),D[_][B]=o(0);for(var ne=0;ne<L;ne++)ne!==B&&ne!==_&&(D[B][ne]=$[ne],D[ne][B]=$[ne],D[_][ne]=U[ne],D[ne][_]=U[ne]);return D}function x(D,T,B,_){for(var L=D.length,G=Math.cos(T),C=Math.sin(T),F=G*G,Z=C*C,$=S(L,0),U=S(L,0),Y=F*D[B][B]-2*G*C*D[B][_]+Z*D[_][_],j=Z*D[B][B]+2*G*C*D[B][_]+F*D[_][_],P=0;P<L;P++)$[P]=G*D[B][P]-C*D[_][P],U[P]=C*D[B][P]+G*D[_][P];D[B][B]=Y,D[_][_]=j,D[B][_]=0,D[_][B]=0;for(var K=0;K<L;K++)K!==B&&K!==_&&(D[B][K]=$[K],D[K][B]=$[K],D[_][K]=U[K],D[K][_]=U[K]);return D}function g(D){for(var T=D.length,B=0,_=[0,1],L=0;L<T;L++)for(var G=L+1;G<T;G++)Math.abs(B)<Math.abs(D[L][G])&&(B=Math.abs(D[L][G]),_=[L,G]);return[_,B]}function E(D){for(var T=D.length,B=0,_=[0,1],L=0;L<T;L++)for(var G=L+1;G<T;G++)n(B)<n(D[L][G])&&(B=n(D[L][G]),_=[L,G]);return[_,B]}function N(D,T){for(var B=D.length,_=Array(B),L=Array(B),G=0;G<B;G++)L[G]=Array(B);for(var C=0;C<B;C++){for(var F=0,Z=D[0],$=0;$<D.length;$++)n(D[$])<n(Z)&&(F=$,Z=D[F]);_[C]=D.splice(F,1)[0];for(var U=0;U<B;U++)L[U][C]=T[U][F],T[U].splice(F,1)}return{values:_,vectors:L}}function S(D,T){for(var B=new Array(D),_=0;_<D;_++)B[_]=T;return B}return v}var kF="eigs",VF=["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"],GF=R(kF,VF,r=>{var{config:e,typed:t,matrix:a,addScalar:n,subtract:i,equal:s,abs:f,atan:l,cos:u,sin:o,multiplyScalar:c,divideScalar:m,inv:v,bignumber:p,multiply:h,add:y,larger:b,column:A,flatten:d,number:w,complex:x,sqrt:g,diag:E,qr:N,usolve:S,usolveAll:D,im:T,re:B,smaller:_,matrixFromColumns:L,dot:G}=r,C=UF({config:e,addScalar:n,subtract:i,column:A,flatten:d,equal:s,abs:f,atan:l,cos:u,sin:o,multiplyScalar:c,inv:v,bignumber:p,complex:x,multiply:h,add:y}),F=LF({config:e,addScalar:n,subtract:i,multiply:h,multiplyScalar:c,flatten:d,divideScalar:m,sqrt:g,abs:f,bignumber:p,diag:E,qr:N,inv:v,usolve:S,usolveAll:D,equal:s,complex:x,larger:b,smaller:_,matrixFromColumns:L,dot:G});return t("eigs",{Array:function(K){var ne=a(K);return Z(ne)},"Array, number|BigNumber":function(K,ne){var re=a(K);return Z(re,ne)},Matrix:function(K){var{values:ne,vectors:re}=Z(K);return{values:a(ne),vectors:a(re)}},"Matrix, number|BigNumber":function(K,ne){var{values:re,vectors:fe}=Z(K,ne);return{values:a(re),vectors:a(fe)}}});function Z(P,K){K===void 0&&(K=e.epsilon);var ne=P.size();if(ne.length!==2||ne[0]!==ne[1])throw new RangeError("Matrix must be square (size: "+Ye(ne)+")");var re=P.toArray(),fe=ne[0];if(U(re,fe,K)&&(Y(re,fe),$(re,fe,K))){var pe=j(P,re,fe);return C(re,fe,K,pe)}var ce=j(P,re,fe);return F(re,fe,K,ce)}function $(P,K,ne){for(var re=0;re<K;re++)for(var fe=re;fe<K;fe++)if(b(p(f(i(P[re][fe],P[fe][re]))),ne))return!1;return!0}function U(P,K,ne){for(var re=0;re<K;re++)for(var fe=0;fe<K;fe++)if(b(p(f(T(P[re][fe]))),ne))return!1;return!0}function Y(P,K){for(var ne=0;ne<K;ne++)for(var re=0;re<K;re++)P[ne][re]=B(P[ne][re])}function j(P,K,ne){var re=P.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var fe=!1,pe=!1,ce=!1,oe=0;oe<ne;oe++)for(var Ce=0;Ce<ne;Ce++){var Oe=K[oe][Ce];if(tr(Oe)||_a(Oe))fe=!0;else if(rr(Oe))pe=!0;else if(zt(Oe))ce=!0;else throw TypeError("Unsupported type in Matrix: "+gr(Oe))}if(pe&&ce&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ce){for(var Me=0;Me<ne;Me++)for(var $e=0;$e<ne;$e++)K[Me][$e]=x(K[Me][$e]);return"Complex"}if(pe){for(var k=0;k<ne;k++)for(var W=0;W<ne;W++)K[k][W]=p(K[k][W]);return"BigNumber"}if(fe){for(var ie=0;ie<ne;ie++)for(var V=0;V<ne;V++)K[ie][V]=w(K[ie][V]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),cp="expm",HF=["typed","abs","add","identity","inv","multiply"],ZF=R(cp,HF,r=>{var{typed:e,abs:t,add:a,identity:n,inv:i,multiply:s}=r;return e(cp,{Matrix:function(c){var m=c.size();if(m.length!==2||m[0]!==m[1])throw new RangeError("Matrix must be square (size: "+Ye(m)+")");for(var v=m[0],p=1e-15,h=f(c),y=l(h,p),b=y.q,A=y.j,d=s(c,Math.pow(2,-A)),w=n(v),x=n(v),g=1,E=d,N=-1,S=1;S<=b;S++)S>1&&(E=s(E,d),N=-N),g=g*(b-S+1)/((2*b-S+1)*S),w=a(w,s(g,E)),x=a(x,s(g*N,E));for(var D=s(i(x),w),T=0;T<A;T++)D=s(D,D);return Nn(c)?c.createSparseMatrix(D):D}});function f(o){for(var c=o.size()[0],m=0,v=0;v<c;v++){for(var p=0,h=0;h<c;h++)p+=t(o.get([v,h]));m=Math.max(p,m)}return m}function l(o,c){for(var m=30,v=0;v<m;v++)for(var p=0;p<=v;p++){var h=v-p;if(u(o,p,h)<c)return{q:p,j:h}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function u(o,c,m){for(var v=1,p=2;p<=c;p++)v*=p;for(var h=v,y=c+1;y<=2*c;y++)h*=y;var b=h*(2*c+1);return 8*Math.pow(o/Math.pow(2,m),2*c)*v*v/(h*b)}}),fp="sqrtm",JF=["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],WF=R(fp,JF,r=>{var{typed:e,abs:t,add:a,multiply:n,map:i,sqrt:s,subtract:f,inv:l,size:u,max:o,identity:c}=r,m=1e3,v=1e-6;function p(h){var y,b=0,A=h,d=c(u(h));do{var w=A;if(A=n(.5,a(w,l(d))),d=n(.5,a(d,l(w))),y=o(t(f(A,w))),y>v&&++b>m)throw new Error("computing square root of matrix: iterative method could not converge")}while(y>v);return A}return e(fp,{"Array | Matrix":function(y){var b=He(y)?y.size():er(y);switch(b.length){case 1:if(b[0]===1)return i(y,s);throw new RangeError("Matrix must be square (size: "+Ye(b)+")");case 2:{var A=b[0],d=b[1];if(A===d)return p(y);throw new RangeError("Matrix must be square (size: "+Ye(b)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Ye(b)+")")}}})}),XF="divide",YF=["typed","matrix","multiply","equalScalar","divideScalar","inv"],QF=R(XF,YF,r=>{var{typed:e,matrix:t,multiply:a,equalScalar:n,divideScalar:i,inv:s}=r,f=Lr({typed:e,equalScalar:n}),l=yt({typed:e});return e("divide",Qu({"Array | Matrix, Array | Matrix":function(o,c){return a(o,s(c))},"DenseMatrix, any":function(o,c){return l(o,c,i,!1)},"SparseMatrix, any":function(o,c){return f(o,c,i,!1)},"Array, any":function(o,c){return l(t(o),c,i,!1).valueOf()},"any, Array | Matrix":function(o,c){return a(o,s(c))}},i.signatures))}),mp="distance",KF=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],jF=R(mp,KF,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,unaryMinus:s,sqrt:f,abs:l}=r;return e(mp,{"Array, Array, Array":function(x,g,E){if(x.length===2&&g.length===2&&E.length===2){if(!o(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!o(g))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!o(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var N=i(a(E[1],E[0]),a(g[1],g[0])),S=n(n(N,N),g[0]),D=s(n(N,g[0])),T=x[1];return y(x[0],x[1],S,D,T)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,g,E){if(Object.keys(x).length===2&&Object.keys(g).length===2&&Object.keys(E).length===2){if(!o(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!o(g))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!o(E))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 E&&"lineTwoPtY"in E){var N=i(a(E.lineTwoPtY,E.lineTwoPtX),a(g.lineOnePtY,g.lineOnePtX)),S=n(n(N,N),g.lineOnePtX),D=s(n(N,g.lineOnePtX)),T=x.pointX;return y(x.pointX,x.pointY,S,D,T)}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(!o(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(g))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(x[0],x[1],g[0],g[1],g[2])}else if(x.length===3&&g.length===6){if(!c(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(g))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return b(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(!m(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(g))throw new TypeError("All values of an array should be numbers or BigNumbers");return A(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(!o(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(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 y(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(!c(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!v(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 b(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(!o(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!o(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 A([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(!c(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!c(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 A([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 u(w){return typeof w=="number"||rr(w)}function o(w){return w.constructor!==Array&&(w=p(w)),u(w[0])&&u(w[1])}function c(w){return w.constructor!==Array&&(w=p(w)),u(w[0])&&u(w[1])&&u(w[2])}function m(w){return Array.isArray(w)||(w=p(w)),w.every(u)}function v(w){return w.constructor!==Array&&(w=p(w)),u(w[0])&&u(w[1])&&u(w[2])&&u(w[3])&&u(w[4])&&u(w[5])}function p(w){for(var x=Object.keys(w),g=[],E=0;E<x.length;E++)g.push(w[x[E]]);return g}function h(w){if(w[0].length===2&&u(w[0][0])&&u(w[0][1])){if(w.some(x=>x.length!==2||!u(x[0])||!u(x[1])))return!1}else if(w[0].length===3&&u(w[0][0])&&u(w[0][1])&&u(w[0][2])){if(w.some(x=>x.length!==3||!u(x[0])||!u(x[1])||!u(x[2])))return!1}else return!1;return!0}function y(w,x,g,E,N){var S=l(t(t(n(g,w),n(E,x)),N)),D=f(t(n(g,g),n(E,E)));return i(S,D)}function b(w,x,g,E,N,S,D,T,B){var _=[a(n(a(N,x),B),n(a(S,g),T)),a(n(a(S,g),D),n(a(E,w),B)),a(n(a(E,w),T),n(a(N,x),D))];_=f(t(t(n(_[0],_[0]),n(_[1],_[1])),n(_[2],_[2])));var L=f(t(t(n(D,D),n(T,T)),n(B,B)));return i(_,L)}function A(w,x){for(var g=w.length,E=0,N=0,S=0;S<g;S++)N=a(w[S],x[S]),E=t(n(N,N),E);return f(E)}function d(w){for(var x=[],g=[],E=[],N=0;N<w.length-1;N++)for(var S=N+1;S<w.length;S++)w[0].length===2?(g=[w[N][0],w[N][1]],E=[w[S][0],w[S][1]]):w[0].length===3&&(g=[w[N][0],w[N][1],w[N][2]],E=[w[S][0],w[S][1],w[S][2]]),x.push(A(g,E));return x}}),e4="intersect",r4=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],t4=R(e4,r4,r=>{var{typed:e,config:t,abs:a,add:n,addScalar:i,matrix:s,multiply:f,multiplyScalar:l,divideScalar:u,subtract:o,smaller:c,equalScalar:m,flatten:v,isZero:p,isNumeric:h}=r;return e("intersect",{"Array, Array, Array":y,"Array, Array, Array, Array":b,"Matrix, Matrix, Matrix":function(T,B,_){var L=y(T.valueOf(),B.valueOf(),_.valueOf());return L===null?null:s(L)},"Matrix, Matrix, Matrix, Matrix":function(T,B,_,L){var G=b(T.valueOf(),B.valueOf(),_.valueOf(),L.valueOf());return G===null?null:s(G)}});function y(D,T,B){if(D=A(D),T=A(T),B=A(B),!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(B))throw new TypeError("Array with 4 numbers expected as third argument");return S(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],B[3])}function b(D,T,B,_){if(D=A(D),T=A(T),B=A(B),_=A(_),D.length===2){if(!d(D))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(T))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(B))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(D,T,B,_)}else if(D.length===3){if(!w(D))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!w(T))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!w(B))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!w(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return N(D[0],D[1],D[2],T[0],T[1],T[2],B[0],B[1],B[2],_[0],_[1],_[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function A(D){return D.length===1?D[0]:D.length>1&&Array.isArray(D[0])&&D.every(T=>Array.isArray(T)&&T.length===1)?v(D):D}function d(D){return D.length===2&&h(D[0])&&h(D[1])}function w(D){return D.length===3&&h(D[0])&&h(D[1])&&h(D[2])}function x(D){return D.length===4&&h(D[0])&&h(D[1])&&h(D[2])&&h(D[3])}function g(D,T,B,_){var L=D,G=B,C=o(L,T),F=o(G,_),Z=o(l(C[0],F[1]),l(F[0],C[1]));if(p(Z)||c(a(Z),t.epsilon))return null;var $=l(F[0],L[1]),U=l(F[1],L[0]),Y=l(F[0],G[1]),j=l(F[1],G[0]),P=u(i(o(o($,U),Y),j),Z);return n(f(C,P),L)}function E(D,T,B,_,L,G,C,F,Z,$,U,Y){var j=l(o(D,T),o(B,_)),P=l(o(L,G),o(C,F)),K=l(o(Z,$),o(U,Y));return i(i(j,P),K)}function N(D,T,B,_,L,G,C,F,Z,$,U,Y){var j=E(D,C,$,C,T,F,U,F,B,Z,Y,Z),P=E($,C,_,D,U,F,L,T,Y,Z,G,B),K=E(D,C,_,D,T,F,L,T,B,Z,G,B),ne=E($,C,$,C,U,F,U,F,Y,Z,Y,Z),re=E(_,D,_,D,L,T,L,T,G,B,G,B),fe=o(l(j,P),l(K,ne)),pe=o(l(re,ne),l(P,P));if(p(pe))return null;var ce=u(fe,pe),oe=u(i(j,l(ce,P)),ne),Ce=i(D,l(ce,o(_,D))),Oe=i(T,l(ce,o(L,T))),Me=i(B,l(ce,o(G,B))),$e=i(C,l(oe,o($,C))),k=i(F,l(oe,o(U,F))),W=i(Z,l(oe,o(Y,Z)));return m(Ce,$e)&&m(Oe,k)&&m(Me,W)?[Ce,Oe,Me]:null}function S(D,T,B,_,L,G,C,F,Z,$){var U=l(D,C),Y=l(_,C),j=l(T,F),P=l(L,F),K=l(B,Z),ne=l(G,Z),re=o(o(o($,U),j),K),fe=o(o(o(i(i(Y,P),ne),U),j),K),pe=u(re,fe),ce=i(D,l(pe,o(_,D))),oe=i(T,l(pe,o(L,T))),Ce=i(B,l(pe,o(G,B)));return[ce,oe,Ce]}}),vp="sum",n4=["typed","config","add","numeric"],pp=R(vp,n4,r=>{var{typed:e,config:t,add:a,numeric:n}=r;return e(vp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":s,"...":function(l){if(Qn(l))throw new TypeError("Scalar values expected in function sum");return i(l)}});function i(f){var l;return Gt(f,function(u){try{l=l===void 0?u:a(l,u)}catch(o){throw Yr(o,"sum",u)}}),l===void 0&&(l=n(0,t.number)),typeof l=="string"&&(l=n(l,t.number)),l}function s(f,l){try{var u=wi(f,l,a);return u}catch(o){throw Yr(o,"sum")}}}),eo="cumsum",a4=["typed","add","unaryPlus"],hp=R(eo,a4,r=>{var{typed:e,add:t,unaryPlus:a}=r;return e(eo,{Array:n,Matrix:function(u){return u.create(n(u.valueOf()))},"Array, number | BigNumber":s,"Matrix, number | BigNumber":function(u,o){return u.create(s(u.valueOf(),o))},"...":function(u){if(Qn(u))throw new TypeError("All values expected to be scalar in function cumsum");return n(u)}});function n(l){try{return i(l)}catch(u){throw Yr(u,eo)}}function i(l){if(l.length===0)return[];for(var u=[a(l[0])],o=1;o<l.length;++o)u.push(t(u[o-1],l[o]));return u}function s(l,u){var o=er(l);if(u<0||u>=o.length)throw new pt(u,o.length);try{return f(l,u)}catch(c){throw Yr(c,eo)}}function f(l,u){var o,c,m;if(u<=0){var v=l[0][0];if(Array.isArray(v)){for(m=ql(l),c=[],o=0;o<m.length;o++)c[o]=f(m[o],u-1);return c}else return i(l)}else{for(c=[],o=0;o<l.length;o++)c[o]=f(l[o],u-1);return c}}}),dp="mean",i4=["typed","add","divide"],gp=R(dp,i4,r=>{var{typed:e,add:t,divide:a}=r;return e(dp,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":n,"...":function(f){if(Qn(f))throw new TypeError("Scalar values expected in function mean");return i(f)}});function n(s,f){try{var l=wi(s,f,t),u=Array.isArray(s)?er(s):s.size();return a(l,u[f])}catch(o){throw Yr(o,"mean")}}function i(s){var f,l=0;if(Gt(s,function(u){try{f=f===void 0?u:t(f,u),l++}catch(o){throw Yr(o,"mean",u)}}),l===0)throw new Error("Cannot calculate the mean of an empty array");return a(f,l)}}),yp="median",o4=["typed","add","divide","compare","partitionSelect"],s4=R(yp,o4,r=>{var{typed:e,add:t,divide:a,compare:n,partitionSelect:i}=r;function s(u){try{u=ar(u.valueOf());var o=u.length;if(o===0)throw new Error("Cannot calculate median of an empty array");if(o%2===0){for(var c=o/2-1,m=i(u,c+1),v=u[c],p=0;p<c;++p)n(u[p],v)>0&&(v=u[p]);return l(v,m)}else{var h=i(u,(o-1)/2);return f(h)}}catch(y){throw Yr(y,"median")}}var f=e({"number | BigNumber | Complex | Unit":function(o){return o}}),l=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(o,c){return a(t(o,c),2)}});return e(yp,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(o,c){throw new Error("median(A, dim) is not yet supported")},"...":function(o){if(Qn(o))throw new TypeError("Scalar values expected in function median");return s(o)}})}),bp="mad",u4=["typed","abs","map","median","subtract"],l4=R(bp,u4,r=>{var{typed:e,abs:t,map:a,median:n,subtract:i}=r;return e(bp,{"Array | Matrix":s,"...":function(l){return s(l)}});function s(f){if(f=ar(f.valueOf()),f.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var l=n(f);return n(a(f,function(u){return t(i(u,l))}))}catch(u){throw u instanceof TypeError&&u.message.indexOf("median")!==-1?new TypeError(u.message.replace("median","mad")):Yr(u,"mad")}}}),bs="unbiased",xp="variance",c4=["typed","add","subtract","multiply","divide","apply","isNaN"],wp=R(xp,c4,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:s,isNaN:f}=r;return e(xp,{"Array | Matrix":function(c){return l(c,bs)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(c,m){return u(c,m,bs)},"Array | Matrix, number | BigNumber, string":u,"...":function(c){return l(c,bs)}});function l(o,c){var m,v=0;if(o.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Gt(o,function(y){try{m=m===void 0?y:t(m,y),v++}catch(b){throw Yr(b,"variance",y)}}),v===0)throw new Error("Cannot calculate variance of an empty array");var p=i(m,v);if(m=void 0,Gt(o,function(y){var b=a(y,p);m=m===void 0?n(b,b):t(m,n(b,b))}),f(m))return m;switch(c){case"uncorrected":return i(m,v);case"biased":return i(m,v+1);case"unbiased":{var h=rr(m)?m.mul(0):0;return v===1?h:i(m,v-1)}default:throw new Error('Unknown normalization "'+c+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function u(o,c,m){try{if(o.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(o,c,v=>l(v,m))}catch(v){throw Yr(v,"variance")}}}),f4="quantileSeq",m4=["typed","add","multiply","partitionSelect","compare"],v4=R(f4,m4,r=>{var{typed:e,add:t,multiply:a,partitionSelect:n,compare:i}=r;function s(u,o,c){var m,v,p;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(Lt(u)){if(c=c||!1,typeof c=="boolean"){if(v=u.valueOf(),tr(o)){if(o<0)throw new Error("N/prob must be non-negative");if(o<=1)return f(v,o,c);if(o>1){if(!qe(o))throw new Error("N must be a positive integer");var h=o+1;m=new Array(o);for(var y=0;y<o;)m[y]=f(v,++y/h,c);return m}}if(rr(o)){var b=o.constructor;if(o.isNegative())throw new Error("N/prob must be non-negative");if(p=new b(1),o.lte(p))return new b(f(v,o,c));if(o.gt(p)){if(!o.isInteger())throw new Error("N must be a positive integer");var A=o.toNumber();if(A>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 b(A+1);m=new Array(A);for(var w=0;w<A;)m[w]=new b(f(v,new b(++w).div(d),c));return m}}if(Array.isArray(o)){m=new Array(o.length);for(var x=0;x<m.length;++x){var g=o[x];if(tr(g)){if(g<0||g>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(rr(g)){if(p=new g.constructor(1),g.isNegative()||g.gt(p))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");m[x]=f(v,g,c)}return m}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 f(u,o,c){var m=ar(u),v=m.length;if(v===0)throw new Error("Cannot calculate quantile of an empty sequence");if(tr(o)){var p=o*(v-1),h=p%1;if(h===0){var y=c?m[p]:n(m,p);return l(y),y}var b=Math.floor(p),A,d;if(c)A=m[b],d=m[b+1];else{d=n(m,b+1),A=m[b];for(var w=0;w<b;++w)i(m[w],A)>0&&(A=m[w])}return l(A),l(d),t(a(A,1-h),a(d,h))}var x=o.times(v-1);if(x.isInteger()){x=x.toNumber();var g=c?m[x]:n(m,x);return l(g),g}var E=x.floor(),N=x.minus(E),S=E.toNumber(),D,T;if(c)D=m[S],T=m[S+1];else{T=n(m,S+1),D=m[S];for(var B=0;B<S;++B)i(m[B],D)>0&&(D=m[B])}l(D),l(T);var _=new N.constructor(1);return t(a(D,_.minus(N)),a(T,N))}var l=e({"number | BigNumber | Unit":function(o){return o}});return s}),Np="std",p4=["typed","map","sqrt","variance"],Dp=R(Np,p4,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r;return e(Np,{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(f){return i(f)}});function i(s,f){if(s.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var l=n.apply(null,arguments);return Lt(l)?t(l,a):a(l)}catch(u){throw u instanceof TypeError&&u.message.indexOf(" variance")!==-1?new TypeError(u.message.replace(" variance"," std")):u}}}),Ap="combinations",h4=["typed"],d4=R(Ap,h4,r=>{var{typed:e}=r;return e(Ap,{"number, number":fc,"BigNumber, BigNumber":function(a,n){var i=a.constructor,s,f,l=a.minus(n),u=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(s=u,n.lt(l))for(f=u;f.lte(l);f=f.plus(u))s=s.times(n.plus(f)).dividedBy(f);else for(f=u;f.lte(n);f=f.plus(u))s=s.times(l.plus(f)).dividedBy(f);return s}})});function Ep(r){return r.isInteger()&&r.gte(0)}var Sp="combinationsWithRep",g4=["typed"],y4=R(Sp,g4,r=>{var{typed:e}=r;return e(Sp,{"number, number":function(a,n){if(!qe(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!qe(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=Ht(a,a+n-1);return i/Ht(1,n)}var s=Ht(n+1,a+n-1);return s/Ht(1,a-1)},"BigNumber, BigNumber":function(a,n){var i=a.constructor,s,f,l=new i(1),u=a.minus(l);if(!Cp(a)||!Cp(n))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a.lt(l))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(s=l,n.lt(u))for(f=l;f.lte(u);f=f.plus(l))s=s.times(n.plus(f)).dividedBy(f);else for(f=l;f.lte(n);f=f.plus(l))s=s.times(u.plus(f)).dividedBy(f);return s}})});function Cp(r){return r.isInteger()&&r.gte(0)}var Mp="gamma",b4=["typed","config","multiplyScalar","pow","BigNumber","Complex"],x4=R(Mp,b4,r=>{var{typed:e,config:t,multiplyScalar:a,pow:n,BigNumber:i,Complex:s}=r;function f(u){if(u.im===0)return Di(u.re);if(u.re<.5){var o=new s(1-u.re,-u.im),c=new s(Math.PI*u.re,Math.PI*u.im);return new s(Math.PI).div(c.sin()).div(f(o))}u=new s(u.re-1,u.im);for(var m=new s(jn[0],0),v=1;v<jn.length;++v){var p=new s(jn[v],0);m=m.add(p.div(u.add(v)))}var h=new s(u.re+dc+.5,u.im),y=Math.sqrt(2*Math.PI),b=h.pow(u.add(.5)),A=h.neg().exp();return m.mul(y).mul(b).mul(A)}return e(Mp,{number:Di,Complex:f,BigNumber:function(o){if(o.isInteger())return o.isNegative()||o.isZero()?new i(1/0):l(o.minus(1));if(!o.isFinite())return new i(o.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function l(u){if(u<8)return new i([1,1,2,6,24,120,720,5040][u]);var o=t.precision+(Math.log(u.toNumber())|0),c=i.clone({precision:o});if(u%2===1)return u.times(l(new i(u-1)));for(var m=u,v=new c(u),p=u.toNumber();m>2;)m-=2,p+=m,v=v.times(p);return new i(v.toPrecision(i.precision))}}),Fp="lgamma",w4=["Complex","typed"],N4=R(Fp,w4,r=>{var{Complex:e,typed:t}=r,a=7,n=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(Fp,{number:Ai,Complex:s,BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function s(u){var o=6.283185307179586,c=1.1447298858494002,m=.1;if(u.isNaN())return new e(NaN,NaN);if(u.im===0)return new e(Ai(u.re),0);if(u.re>=a||Math.abs(u.im)>=n)return f(u);if(u.re<=m){var v=k0(o,u.im)*Math.floor(.5*u.re+.25),p=u.mul(Math.PI).sin().log(),h=s(new e(1-u.re,-u.im));return new e(c,v).sub(p).sub(h)}else return u.im>=0?l(u):l(u.conjugate()).conjugate()}function f(u){for(var o=u.sub(.5).mul(u.log()).sub(u).add(gc),c=new e(1,0).div(u),m=c.div(u),v=i[0],p=i[1],h=2*m.re,y=m.re*m.re+m.im*m.im,b=2;b<8;b++){var A=p;p=-y*v+i[b],v=h*v+A}var d=c.mul(m.mul(v).add(p));return o.add(d)}function l(u){var o=0,c=0,m=u;for(u=u.add(1);u.re<=a;){m=m.mul(u);var v=m.im<0?1:0;v!==0&&c===0&&o++,c=v,u=u.add(1)}return f(u).sub(m.log()).sub(new e(0,o*2*Math.PI*1))}}),Tp="factorial",D4=["typed","gamma"],A4=R(Tp,D4,r=>{var{typed:e,gamma:t}=r;return e(Tp,{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":e.referToSelf(a=>n=>je(n,a))})}),Bp="kldivergence",E4=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],S4=R(Bp,E4,r=>{var{typed:e,matrix:t,divide:a,sum:n,multiply:i,map:s,dotDivide:f,log:l,isNumeric:u}=r;return e(Bp,{"Array, Array":function(m,v){return o(t(m),t(v))},"Matrix, Array":function(m,v){return o(m,t(v))},"Array, Matrix":function(m,v){return o(t(m),v)},"Matrix, Matrix":function(m,v){return o(m,v)}});function o(c,m){var v=m.size().length,p=c.size().length;if(v>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(v!==p)throw new Error("Length of two vectors must be equal");var h=n(c);if(h===0)throw new Error("Sum of elements in first object must be non zero");var y=n(m);if(y===0)throw new Error("Sum of elements in second object must be non zero");var b=a(c,n(c)),A=a(m,n(m)),d=n(i(b,s(f(b,A),w=>l(w))));return u(d)?d:Number.NaN}}),$p="multinomial",C4=["typed","add","divide","multiply","factorial","isInteger","isPositive"],M4=R($p,C4,r=>{var{typed:e,add:t,divide:a,multiply:n,factorial:i,isInteger:s,isPositive:f}=r;return e($p,{"Array | Matrix":function(u){var o=0,c=1;return Gt(u,function(m){if(!s(m)||!f(m))throw new TypeError("Positive integer value expected in function multinomial");o=t(o,m),c=n(c,i(m))}),a(i(o),c)}})}),Op="permutations",F4=["typed","factorial"],T4=R(Op,F4,r=>{var{typed:e,factorial:t}=r;return e(Op,{"number | BigNumber":t,"number, number":function(n,i){if(!qe(n)||n<0)throw new TypeError("Positive integer value expected in function permutations");if(!qe(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 Ht(n-i+1,n)},"BigNumber, BigNumber":function(n,i){var s,f;if(!_p(n)||!_p(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 l=n.mul(0).add(1);for(s=l,f=n.minus(i).plus(1);f.lte(n);f=f.plus(1))s=s.times(f);return s}})});function _p(r){return r.isInteger()&&r.gte(0)}var Ip={exports:{}};(function(r){(function(e,t,a){function n(l){var u=this,o=f();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=o(" "),u.s1=o(" "),u.s2=o(" "),u.s0-=o(l),u.s0<0&&(u.s0+=1),u.s1-=o(l),u.s1<0&&(u.s1+=1),u.s2-=o(l),u.s2<0&&(u.s2+=1),o=null}function i(l,u){return u.c=l.c,u.s0=l.s0,u.s1=l.s1,u.s2=l.s2,u}function s(l,u){var o=new n(l),c=u&&u.state,m=o.next;return m.int32=function(){return o.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,c&&(typeof c=="object"&&i(c,o),m.state=function(){return i(o,{})}),m}function f(){var l=4022871197,u=function(o){o=String(o);for(var c=0;c<o.length;c++){l+=o.charCodeAt(c);var m=.02519603282416938*l;l=m>>>0,m-=l,m*=l,l=m>>>0,m-=l,l+=m*4294967296}return(l>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.alea=s})(Sn,r,!1)})(Ip);var Rp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var c=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^c^c>>>8},f===(f|0)?l.x=f:u+=f;for(var o=0;o<u.length+64;o++)l.x^=u.charCodeAt(o)|0,l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l}function s(f,l){var u=new n(f),o=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(typeof o=="object"&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xor128=s})(Sn,r,!1)})(Rp);var qp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(c^c<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,f===(f|0)?l.x=f:u+=f;for(var o=0;o<u.length+64;o++)l.x^=u.charCodeAt(o)|0,o==u.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function i(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l.v=f.v,l.d=f.d,l}function s(f,l){var u=new n(f),o=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(typeof o=="object"&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xorwow=s})(Sn,r,!1)})(qp);var zp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var o=l.x,c=l.i,m,v;return m=o[c],m^=m>>>7,v=m^m<<24,m=o[c+1&7],v^=m^m>>>10,m=o[c+3&7],v^=m^m>>>3,m=o[c+4&7],v^=m^m<<7,m=o[c+7&7],m=m^m<<13,v^=m^m<<9,o[c]=v,l.i=c+1&7,v};function u(o,c){var m,v=[];if(c===(c|0))v[0]=c;else for(c=""+c,m=0;m<c.length;++m)v[m&7]=v[m&7]<<15^c.charCodeAt(m)+v[m+1&7]<<13;for(;v.length<8;)v.push(0);for(m=0;m<8&&v[m]===0;++m);for(m==8?v[7]=-1:v[m],o.x=v,o.i=0,m=256;m>0;--m)o.next()}u(l,f)}function i(f,l){return l.x=f.x.slice(),l.i=f.i,l}function s(f,l){f==null&&(f=+new Date);var u=new n(f),o=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(o.x&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xorshift7=s})(Sn,r,!1)})(zp);var Pp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this;l.next=function(){var o=l.w,c=l.X,m=l.i,v,p;return l.w=o=o+1640531527|0,p=c[m+34&127],v=c[m=m+1&127],p^=p<<13,v^=v<<17,p^=p>>>15,v^=v>>>12,p=c[m]=p^v,l.i=m,p+(o^o>>>16)|0};function u(o,c){var m,v,p,h,y,b=[],A=128;for(c===(c|0)?(v=c,c=null):(c=c+"\0",v=0,A=Math.max(A,c.length)),p=0,h=-32;h<A;++h)c&&(v^=c.charCodeAt((h+32)%c.length)),h===0&&(y=v),v^=v<<10,v^=v>>>15,v^=v<<4,v^=v>>>13,h>=0&&(y=y+1640531527|0,m=b[h&127]^=v+y,p=m==0?p+1:0);for(p>=128&&(b[(c&&c.length||0)&127]=-1),p=127,h=4*128;h>0;--h)v=b[p+34&127],m=b[p=p+1&127],v^=v<<13,m^=m<<17,v^=v>>>15,m^=m>>>12,b[p]=v^m;o.w=y,o.X=b,o.i=p}u(l,f)}function i(f,l){return l.i=f.i,l.w=f.w,l.X=f.X.slice(),l}function s(f,l){f==null&&(f=+new Date);var u=new n(f),o=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(o.X&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.xor4096=s})(Sn,r,!1)})(Pp);var Lp={exports:{}};(function(r){(function(e,t,a){function n(f){var l=this,u="";l.next=function(){var c=l.b,m=l.c,v=l.d,p=l.a;return c=c<<25^c>>>7^m,m=m-v|0,v=v<<24^v>>>8^p,p=p-c|0,l.b=c=c<<20^c>>>12^m,l.c=m=m-v|0,l.d=v<<16^m>>>16^p,l.a=p-c|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,f===Math.floor(f)?(l.a=f/4294967296|0,l.b=f|0):u+=f;for(var o=0;o<u.length+20;o++)l.b^=u.charCodeAt(o)|0,l.next()}function i(f,l){return l.a=f.a,l.b=f.b,l.c=f.c,l.d=f.d,l}function s(f,l){var u=new n(f),o=l&&l.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var m=u.next()>>>11,v=(u.next()>>>0)/4294967296,p=(m+v)/(1<<21);while(p===0);return p},c.int32=u.next,c.quick=c,o&&(typeof o=="object"&&i(o,u),c.state=function(){return i(u,{})}),c}t&&t.exports?t.exports=s:a&&a.amd?a(function(){return s}):this.tychei=s})(Sn,r,!1)})(Lp);var Up={exports:{}};const B4=o1(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e,t,a){var n=256,i=6,s=52,f="random",l=a.pow(n,i),u=a.pow(2,s),o=u*2,c=n-1,m;function v(w,x,g){var E=[];x=x==!0?{entropy:!0}:x||{};var N=b(y(x.entropy?[w,d(t)]:w==null?A():w,3),E),S=new p(E),D=function(){for(var T=S.g(i),B=l,_=0;T<u;)T=(T+_)*n,B*=n,_=S.g(1);for(;T>=o;)T/=2,B/=2,_>>>=1;return(T+_)/B};return D.int32=function(){return S.g(4)|0},D.quick=function(){return S.g(4)/4294967296},D.double=D,b(d(S.S),t),(x.pass||g||function(T,B,_,L){return L&&(L.S&&h(L,S),T.state=function(){return h(S,{})}),_?(a[f]=T,B):T})(D,N,"global"in x?x.global:this==a,x.state)}function p(w){var x,g=w.length,E=this,N=0,S=E.i=E.j=0,D=E.S=[];for(g||(w=[g++]);N<n;)D[N]=N++;for(N=0;N<n;N++)D[N]=D[S=c&S+w[N%g]+(x=D[N])],D[S]=x;(E.g=function(T){for(var B,_=0,L=E.i,G=E.j,C=E.S;T--;)B=C[L=c&L+1],_=_*n+C[c&(C[L]=C[G=c&G+B])+(C[G]=B)];return E.i=L,E.j=G,_})(n)}function h(w,x){return x.i=w.i,x.j=w.j,x.S=w.S.slice(),x}function y(w,x){var g=[],E=typeof w,N;if(x&&E=="object")for(N in w)try{g.push(y(w[N],x-1))}catch{}return g.length?g:E=="string"?w:w+"\0"}function b(w,x){for(var g=w+"",E,N=0;N<g.length;)x[c&N]=c&(E^=x[c&N]*19)+g.charCodeAt(N++);return d(x)}function A(){try{var w;return m&&(w=m.randomBytes)?w=w(n):(w=new Uint8Array(n),(e.crypto||e.msCrypto).getRandomValues(w)),d(w)}catch{var x=e.navigator,g=x&&x.plugins;return[+new Date,e,g,e.screen,d(t)]}}function d(w){return String.fromCharCode.apply(0,w)}if(b(a.random(),t),r.exports){r.exports=v;try{m=B4}catch{}}else a["seed"+f]=v})(typeof self<"u"?self:Sn,[],Math)})(Up);var $4=Ip.exports,O4=Rp.exports,_4=qp.exports,I4=zp.exports,R4=Pp.exports,q4=Lp.exports,Fn=Up.exports;Fn.alea=$4,Fn.xor128=O4,Fn.xorwow=_4,Fn.xorshift7=I4,Fn.xor4096=R4,Fn.tychei=q4;var kp=Fn,z4=kp(Date.now());function oa(r){var e;function t(n){e=n===null?z4:kp(String(n))}t(r);function a(){return e()}return a}var Vp="pickRandom",P4=["typed","config","?on"],L4=R(Vp,P4,r=>{var{typed:e,config:t,on:a}=r,n=oa(t.randomSeed);return a&&a("config",function(s,f){s.randomSeed!==f.randomSeed&&(n=oa(s.randomSeed))}),e(Vp,{"Array | Matrix":function(f){return i(f,{})},"Array | Matrix, Object":function(f,l){return i(f,l)},"Array | Matrix, number":function(f,l){return i(f,{number:l})},"Array | Matrix, Array | Matrix":function(f,l){return i(f,{weights:l})},"Array | Matrix, Array | Matrix, number":function(f,l,u){return i(f,{number:u,weights:l})},"Array | Matrix, number, Array | Matrix":function(f,l,u){return i(f,{number:l,weights:u})}});function i(s,f){var{number:l,weights:u,elementWise:o=!0}=f,c=typeof l>"u";c&&(l=1);var m=He(s)?s.create:He(u)?u.create:null;s=s.valueOf(),u&&(u=u.valueOf()),o===!0&&(s=ar(s),u=ar(u));var v=0;if(typeof u<"u"){if(u.length!==s.length)throw new Error("Weights must have the same length as possibles");for(var p=0,h=u.length;p<h;p++){if(!tr(u[p])||u[p]<0)throw new Error("Weights must be an array of positive numbers");v+=u[p]}}for(var y=s.length,b=[],A;b.length<l;){if(typeof u>"u")A=s[Math.floor(n()*y)];else for(var d=n()*v,w=0,x=s.length;w<x;w++)if(d-=u[w],d<0){A=s[w];break}b.push(A)}return c?b[0]:m?m(b):b}});function xs(r,e){var t=[];if(r=r.slice(0),r.length>1)for(var a=0,n=r.shift();a<n;a++)t.push(xs(r,e));else for(var i=0,s=r.shift();i<s;i++)t.push(e());return t}var Gp="random",U4=["typed","config","?on"],k4=R(Gp,U4,r=>{var{typed:e,config:t,on:a}=r,n=oa(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=oa(f.randomSeed))}),e(Gp,{"":()=>s(0,1),number:f=>s(0,f),"number, number":(f,l)=>s(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var o=xs(f.valueOf(),()=>s(l,u));return He(f)?f.create(o):o}function s(f,l){return f+n()*(l-f)}}),Hp="randomInt",V4=["typed","config","?on"],G4=R(Hp,V4,r=>{var{typed:e,config:t,on:a}=r,n=oa(t.randomSeed);return a&&a("config",function(f,l){f.randomSeed!==l.randomSeed&&(n=oa(f.randomSeed))}),e(Hp,{"":()=>s(0,1),number:f=>s(0,f),"number, number":(f,l)=>s(f,l),"Array | Matrix":f=>i(f,0,1),"Array | Matrix, number":(f,l)=>i(f,0,l),"Array | Matrix, number, number":(f,l,u)=>i(f,l,u)});function i(f,l,u){var o=xs(f.valueOf(),()=>s(l,u));return He(f)?f.create(o):o}function s(f,l){return Math.floor(f+n()*(l-f))}}),Zp="stirlingS2",H4=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],Z4=R(Zp,H4,r=>{var{typed:e,addScalar:t,subtract:a,multiplyScalar:n,divideScalar:i,pow:s,factorial:f,combinations:l,isNegative:u,isInteger:o,number:c,bignumber:m,larger:v}=r,p=[],h=[];return e(Zp,{"number | BigNumber, number | BigNumber":function(b,A){if(!o(b)||u(b)||!o(A)||u(A))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(v(A,b))throw new TypeError("k must be less than or equal to n in function stirlingS2");var d=!(tr(b)&&tr(A)),w=d?h:p,x=d?m:c,g=c(b),E=c(A);if(w[g]&&w[g].length>E)return w[g][E];for(var N=0;N<=g;++N)if(w[N]||(w[N]=[x(N===0?1:0)]),N!==0)for(var S=w[N],D=w[N-1],T=S.length;T<=N&&T<=E;++T)T===N?S[T]=1:S[T]=t(n(x(T),D[T]),D[T-1]);return w[g][E]}})}),Jp="bellNumbers",J4=["typed","addScalar","isNegative","isInteger","stirlingS2"],W4=R(Jp,J4,r=>{var{typed:e,addScalar:t,isNegative:a,isInteger:n,stirlingS2:i}=r;return e(Jp,{"number | BigNumber":function(f){if(!n(f)||a(f))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var l=0,u=0;u<=f;u++)l=t(l,i(f,u));return l}})}),Wp="catalan",X4=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],Y4=R(Wp,X4,r=>{var{typed:e,addScalar:t,divideScalar:a,multiplyScalar:n,combinations:i,isNegative:s,isInteger:f}=r;return e(Wp,{"number | BigNumber":function(u){if(!f(u)||s(u))throw new TypeError("Non-negative integer value expected in function catalan");return a(i(n(u,2),u),t(u,1))}})}),Xp="composition",Q4=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],K4=R(Xp,Q4,r=>{var{typed:e,addScalar:t,combinations:a,isPositive:n,isNegative:i,isInteger:s,larger:f}=r;return e(Xp,{"number | BigNumber, number | BigNumber":function(u,o){if(!s(u)||!n(u)||!s(o)||!n(o))throw new TypeError("Positive integer value expected in function composition");if(f(o,u))throw new TypeError("k must be less than or equal to n in function composition");return a(t(u,-1),t(o,-1))}})}),Yp="leafCount",j4=["parse","typed"],eT=R(Yp,j4,r=>{var{parse:e,typed:t}=r;function a(n){var i=0;return n.forEach(s=>{i+=a(s)}),i||1}return t(Yp,{Node:function(i){return a(i)}})});function Qp(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 ws(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Qp(Object(t),!0).forEach(function(a){Ir(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Qp(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}var rT="simplifyUtil",tT=["FunctionNode","OperatorNode","SymbolNode"],Ns=R(rT,tT,r=>{var{FunctionNode:e,OperatorNode:t,SymbolNode:a}=r,n=!0,i=!1,s="defaultF",f={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}},l={divide:{total:i},log:{total:i}},u={subtract:{total:i},abs:{trivial:n},log:{total:n}};function o(d,w){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f,g=s;if(typeof d=="string"?g=d:_r(d)?g=d.fn.toString():An(d)?g=d.name:rn(d)&&(g="paren"),Re(x,g)){var E=x[g];if(Re(E,w))return E[w];if(Re(f,g))return f[g][w]}if(Re(x,s)){var N=x[s];return Re(N,w)?N[w]:f[s][w]}if(Re(f,g)){var S=f[g];if(Re(S,w))return S[w]}return f[s][w]}function c(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return o(d,"commutative",w)}function m(d){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;return o(d,"associative",w)}function v(d,w){var x=ws({},d);for(var g in w)Re(d,g)?x[g]=ws(ws({},w[g]),d[g]):x[g]=w[g];return x}function p(d,w){if(!d.args||d.args.length===0)return d;d.args=h(d,w);for(var x=0;x<d.args.length;x++)p(d.args[x],w)}function h(d,w){var x,g=[],E=function N(S){for(var D=0;D<S.args.length;D++){var T=S.args[D];_r(T)&&x===T.op?N(T):g.push(T)}};return m(d,w)?(x=d.op,E(d),g):d.args}function y(d,w){if(!(!d.args||d.args.length===0)){for(var x=A(d),g=d.args.length,E=0;E<g;E++)y(d.args[E],w);if(g>2&&m(d,w)){for(var N=d.args.pop();d.args.length>0;)N=x([d.args.pop(),N]);d.args=N.args}}}function b(d,w){if(!(!d.args||d.args.length===0)){for(var x=A(d),g=d.args.length,E=0;E<g;E++)b(d.args[E],w);if(g>2&&m(d,w)){for(var N=d.args.shift();d.args.length>0;)N=x([N,d.args.shift()]);d.args=N.args}}}function A(d){return _r(d)?function(w){try{return new t(d.op,d.fn,w,d.implicit)}catch(x){return console.error(x),[]}}:function(w){return new e(new a(d.name),w)}}return{createMakeNodeFunction:A,hasProperty:o,isCommutative:c,isAssociative:m,mergeContext:v,flatten:p,allChildren:h,unflattenr:y,unflattenl:b,defaultContext:f,realContext:l,positiveContext:u}}),nT="simplify",aT=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyConstant","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],iT=R(nT,aT,r=>{var{config:e,typed:t,parse:a,add:n,subtract:i,multiply:s,divide:f,pow:l,isZero:u,equal:o,resolve:c,simplifyConstant:m,simplifyCore:v,fraction:p,bignumber:h,mathWithTransform:y,matrix:b,AccessorNode:A,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:g,ObjectNode:E,OperatorNode:N,ParenthesisNode:S,SymbolNode:D}=r,{hasProperty:T,isCommutative:B,isAssociative:_,mergeContext:L,flatten:G,unflattenr:C,unflattenl:F,createMakeNodeFunction:Z,defaultContext:$,realContext:U,positiveContext:Y}=Ns({FunctionNode:x,OperatorNode:N,SymbolNode:D});t.addConversion({from:"Object",to:"Map",convert:Wn});var j=t("simplify",{Node:ce,"Node, Map":(V,Q)=>ce(V,!1,Q),"Node, Map, Object":(V,Q,te)=>ce(V,!1,Q,te),"Node, Array":ce,"Node, Array, Map":ce,"Node, Array, Map, Object":ce});t.removeConversion({from:"Object",to:"Map",convert:Wn}),j.defaultContext=$,j.realContext=U,j.positiveContext=Y;function P(V){return V.transform(function(Q,te,ge){return rn(Q)?P(Q.content):Q})}var K={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};j.rules=[v,{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 ne(V,Q){var te={};if(V.s){var ge=V.s.split("->");if(ge.length===2)te.l=ge[0],te.r=ge[1];else throw SyntaxError("Could not parse rule: "+V.s)}else te.l=V.l,te.r=V.r;te.l=P(a(te.l)),te.r=P(a(te.r));for(var he of["imposeContext","repeat","assuming"])he in V&&(te[he]=V[he]);if(V.evaluate&&(te.evaluate=a(V.evaluate)),_(te.l,Q)){var q=Z(te.l),z=pe();te.expanded={},te.expanded.l=q([te.l.clone(),z]),G(te.expanded.l,Q),C(te.expanded.l,Q),te.expanded.r=q([te.r,z])}return te}function re(V,Q){for(var te=[],ge=0;ge<V.length;ge++){var he=V[ge],q=void 0,z=typeof he;switch(z){case"string":he={s:he};case"object":q=ne(he,Q);break;case"function":q=he;break;default:throw TypeError("Unsupported type of rule: "+z)}te.push(q)}return te}var fe=0;function pe(){return new D("_p"+fe++)}function ce(V,Q){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jn(),ge=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},he=ge.consoleDebug;Q=re(Q||j.rules,ge.context);var q=c(V,te);q=P(q);for(var z={},ee=q.toString({parenthesis:"all"});!z[ee];){z[ee]=!0,fe=0;var ue=ee;he&&console.log("Working on: ",ee);for(var me=0;me<Q.length;me++){var ye="";if(typeof Q[me]=="function"?(q=Q[me](q,ge),he&&(ye=Q[me].name)):(G(q,ge.context),q=Ce(q,Q[me],ge.context),he&&(ye="".concat(Q[me].l.toString()," -> ").concat(Q[me].r.toString()))),he){var be=q.toString({parenthesis:"all"});be!==ue&&(console.log("Applying",ye,"produced",be),ue=be)}F(q,ge.context)}ee=q.toString({parenthesis:"all"})}return q}function oe(V,Q,te){var ge=V;if(V)for(var he=0;he<V.length;++he){var q=Ce(V[he],Q,te);q!==V[he]&&(ge===V&&(ge=V.slice()),ge[he]=q)}return ge}function Ce(V,Q,te){if(Q.assuming){for(var ge in Q.assuming)for(var he in Q.assuming[ge])if(T(ge,he,te)!==Q.assuming[ge][he])return V}var q=L(Q.imposeContext,te),z=V;if(z instanceof N||z instanceof x){var ee=oe(z.args,Q,te);ee!==z.args&&(z=z.clone(),z.args=ee)}else if(z instanceof S){if(z.content){var ue=Ce(z.content,Q,te);ue!==z.content&&(z=new S(ue))}}else if(z instanceof d){var me=oe(z.items,Q,te);me!==z.items&&(z=new d(me))}else if(z instanceof A){var ye=z.object;z.object&&(ye=Ce(z.object,Q,te));var be=z.index;z.index&&(be=Ce(z.index,Q,te)),(ye!==z.object||be!==z.index)&&(z=new A(ye,be))}else if(z instanceof g){var ve=oe(z.dimensions,Q,te);ve!==z.dimensions&&(z=new g(ve))}else if(z instanceof E){var Ne=!1,Ie={};for(var Ge in z.properties)Ie[Ge]=Ce(z.properties[Ge],Q,te),Ie[Ge]!==z.properties[Ge]&&(Ne=!0);Ne&&(z=new E(Ie))}var Be=Q.r,lr=W(Q.l,z,q)[0];if(!lr&&Q.expanded&&(Be=Q.expanded.r,lr=W(Q.expanded.l,z,q)[0]),lr){var Je=z.implicit;z=Be.clone(),Je&&"implicit"in Be&&(z.implicit=!0),z=z.transform(function(cr){return cr.isSymbolNode&&Re(lr.placeholders,cr.name)?lr.placeholders[cr.name].clone():cr})}return Q.repeat&&z!==V&&(z=Ce(z,Q,te)),z}function Oe(V,Q){var te=[],ge,he,q=Z(V);if(B(V,Q))for(var z=0;z<V.args.length;z++)he=V.args.slice(0),he.splice(z,1),ge=he.length===1?he[0]:q(he),te.push(q([V.args[z],ge]));else for(var ee=1;ee<V.args.length;ee++){var ue=V.args[0];ee>1&&(ue=q(V.args.slice(0,ee))),he=V.args.slice(ee),ge=he.length===1?he[0]:q(he),te.push(q([ue,ge]))}return te}function Me(V,Q){var te={placeholders:{}};if(!V.placeholders&&!Q.placeholders)return te;if(V.placeholders){if(!Q.placeholders)return V}else return Q;for(var ge in V.placeholders)if(Re(V.placeholders,ge)&&(te.placeholders[ge]=V.placeholders[ge],Re(Q.placeholders,ge)&&!ie(V.placeholders[ge],Q.placeholders[ge])))return null;for(var he in Q.placeholders)Re(Q.placeholders,he)&&(te.placeholders[he]=Q.placeholders[he]);return te}function $e(V,Q){var te=[];if(V.length===0||Q.length===0)return te;for(var ge,he=0;he<V.length;he++)for(var q=0;q<Q.length;q++)ge=Me(V[he],Q[q]),ge&&te.push(ge);return te}function k(V){if(V.length===0)return V;for(var Q=V.reduce($e),te=[],ge={},he=0;he<Q.length;he++){var q=JSON.stringify(Q[he]);ge[q]||(ge[q]=!0,te.push(Q[he]))}return te}function W(V,Q,te,ge){var he=[{placeholders:{}}];if(V instanceof N&&Q instanceof N||V instanceof x&&Q instanceof x){if(V instanceof N){if(V.op!==Q.op||V.fn!==Q.fn)return[]}else if(V instanceof x&&V.name!==Q.name)return[];if(Q.args.length===1&&V.args.length===1||!_(Q,te)&&Q.args.length===V.args.length||ge){for(var q=[],z=0;z<V.args.length;z++){var ee=W(V.args[z],Q.args[z],te);if(ee.length===0)break;q.push(ee)}if(q.length!==V.args.length){if(!B(Q,te)||V.args.length===1)return[];if(V.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var ue=W(V.args[0],Q.args[1],te);if(ue.length===0)return[];var me=W(V.args[1],Q.args[0],te);if(me.length===0)return[];q=[ue,me]}he=k(q)}else if(Q.args.length>=2&&V.args.length===2){for(var ye=Oe(Q,te),be=[],ve=0;ve<ye.length;ve++){var Ne=W(V,ye[ve],te,!0);be=be.concat(Ne)}return be}else{if(V.args.length>2)throw Error("Unexpected non-binary associative function: "+V.toString());return[]}}else if(V instanceof D){if(V.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(K[V.name]){if(V.name!==Q.name)return[]}else if(V.name[0]==="n"||V.name.substring(0,2)==="_p")he[0].placeholders[V.name]=Q;else if(V.name[0]==="v")if(!sr(Q))he[0].placeholders[V.name]=Q;else return[];else if(V.name[0]==="c")if(Q instanceof w)he[0].placeholders[V.name]=Q;else return[];else throw new Error("Invalid symbol in rule: "+V.name)}else if(V instanceof w){if(!o(V.value,Q.value))return[]}else return[];return he}function ie(V,Q){if(V instanceof w&&Q instanceof w){if(!o(V.value,Q.value))return!1}else if(V instanceof D&&Q instanceof D){if(V.name!==Q.name)return!1}else if(V instanceof N&&Q instanceof N||V instanceof x&&Q instanceof x){if(V instanceof N){if(V.op!==Q.op||V.fn!==Q.fn)return!1}else if(V instanceof x&&V.name!==Q.name)return!1;if(V.args.length!==Q.args.length)return!1;for(var te=0;te<V.args.length;te++)if(!ie(V.args[te],Q.args[te]))return!1}else return!1;return!0}return j}),oT="simplifyConstant",sT=["typed","parse","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],uT=R(oT,sT,r=>{var{typed:e,parse:t,config:a,mathWithTransform:n,matrix:i,fraction:s,bignumber:f,AccessorNode:l,ArrayNode:u,ConstantNode:o,FunctionNode:c,IndexNode:m,ObjectNode:v,OperatorNode:p,SymbolNode:h}=r,{isCommutative:y,isAssociative:b,allChildren:A,createMakeNodeFunction:d}=Ns({FunctionNode:c,OperatorNode:p,SymbolNode:h}),w=e("simplifyConstant",{Node:C=>N(G(C,{})),"Node, Object":function(F,Z){return N(G(F,Z))}});function x(C){return _a(C)?C.valueOf():C instanceof Array?C.map(x):He(C)?i(x(C.valueOf())):C}function g(C,F,Z){try{return n[C].apply(null,F)}catch{return F=F.map(x),D(n[C].apply(null,F),Z)}}var E=e({Fraction:B,number:function(F){return F<0?T(new o(-F)):new o(F)},BigNumber:function(F){return F<0?T(new o(-F)):new o(F)},Complex:function(F){throw new Error("Cannot convert Complex number to Node")},string:function(F){return new o(F)},Matrix:function(F){return new u(F.valueOf().map(Z=>E(Z)))}});function N(C){return or(C)?C:E(C)}function S(C,F){var Z=F&&F.exactFractions!==!1;if(Z&&isFinite(C)&&s){var $=s(C),U=F&&typeof F.fractionsLimit=="number"?F.fractionsLimit:1/0;if($.valueOf()===C&&$.n<U&&$.d<U)return $}return C}var D=e({"string, Object":function(F,Z){if(a.number==="BigNumber")return f===void 0&&ls(),f(F);if(a.number==="Fraction")return s===void 0&&Kf(),s(F);var $=parseFloat(F);return S($,Z)},"Fraction, Object":function(F,Z){return F},"BigNumber, Object":function(F,Z){return F},"number, Object":function(F,Z){return S(F,Z)},"Complex, Object":function(F,Z){return F.im!==0?F:S(F.re,Z)},"Matrix, Object":function(F,Z){return i(S(F.valueOf()))},"Array, Object":function(F,Z){return F.map(S)}});function T(C){return new p("-","unaryMinus",[C])}function B(C){var F,Z=C.s*C.n;return Z<0?F=new p("-","unaryMinus",[new o(-Z)]):F=new o(Z),C.d===1?F:new p("/","divide",[F,new o(C.d)])}function _(C,F,Z){if(!Ln(F))return new l(N(C),N(F));if(nt(C)||He(C)){for(var $=Array.from(F.dimensions);$.length>0;)if(sr($[0])&&typeof $[0].value!="string"){var U=D($.shift().value,Z);nt(C)?C=C.items[U-1]:(C=C.valueOf()[U-1],C instanceof Array&&(C=i(C)))}else if($.length>1&&sr($[1])&&typeof $[1].value!="string"){var Y=D($[1].value,Z),j=[],P=nt(C)?C.items:C.valueOf();for(var K of P)if(nt(K))j.push(K.items[Y-1]);else if(He(C))j.push(K[Y-1]);else break;if(j.length===P.length)nt(C)?C=new u(j):C=i(j),$.splice(1,1);else break}else break;return $.length===F.dimensions.length?new l(N(C),F):$.length>0?(F=new m($),new l(N(C),F)):C}if(ii(C)&&F.dimensions.length===1&&sr(F.dimensions[0])){var ne=F.dimensions[0].value;return ne in C.properties?C.properties[ne]:new o}return new l(N(C),F)}function L(C,F,Z,$){return F.reduce(function(U,Y){if(!or(U)&&!or(Y)){try{return g(C,[U,Y],$)}catch{}U=E(U),Y=E(Y)}else or(U)?or(Y)||(Y=E(Y)):U=E(U);return Z([U,Y])})}function G(C,F){switch(C.type){case"SymbolNode":return C;case"ConstantNode":switch(typeof C.value){case"number":return D(C.value,F);case"string":return C.value;default:if(!isNaN(C.value))return D(C.value,F)}return C;case"FunctionNode":if(n[C.name]&&n[C.name].rawArgs)return C;{var Z=["add","multiply"];if(Z.indexOf(C.name)===-1){var $=C.args.map(Oe=>G(Oe,F));if(!$.some(or))try{return g(C.name,$,F)}catch{}if(C.name==="size"&&$.length===1&&nt($[0])){for(var U=[],Y=$[0];nt(Y);)U.push(Y.items.length),Y=Y.items[0];return i(U)}return new c(C.name,$.map(N))}}case"OperatorNode":{var j=C.fn.toString(),P,K,ne=d(C);if(_r(C)&&C.isUnary())P=[G(C.args[0],F)],or(P[0])?K=ne(P):K=g(j,P,F);else if(b(C,F.context))if(P=A(C,F.context),P=P.map(Oe=>G(Oe,F)),y(j,F.context)){for(var re=[],fe=[],pe=0;pe<P.length;pe++)or(P[pe])?fe.push(P[pe]):re.push(P[pe]);re.length>1?(K=L(j,re,ne,F),fe.unshift(K),K=L(j,fe,ne,F)):K=L(j,P,ne,F)}else K=L(j,P,ne,F);else P=C.args.map(Oe=>G(Oe,F)),K=L(j,P,ne,F);return K}case"ParenthesisNode":return G(C.content,F);case"AccessorNode":return _(G(C.object,F),G(C.index,F),F);case"ArrayNode":{var ce=C.items.map(Oe=>G(Oe,F));return ce.some(or)?new u(ce.map(N)):i(ce)}case"IndexNode":return new m(C.dimensions.map(Oe=>w(Oe,F)));case"ObjectNode":{var oe={};for(var Ce in C.properties)oe[Ce]=w(C.properties[Ce],F);return new v(oe)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(C.type))}}return w}),Kp="simplifyCore",lT=["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],cT=R(Kp,lT,r=>{var{typed:e,parse:t,equal:a,isZero:n,add:i,subtract:s,multiply:f,divide:l,pow:u,AccessorNode:o,ArrayNode:c,ConstantNode:m,FunctionNode:v,IndexNode:p,ObjectNode:h,OperatorNode:y,ParenthesisNode:b,SymbolNode:A}=r,d=new m(0),w=new m(1),x=new m(!0),g=new m(!1);function E(T){return _r(T)&&["and","not","or"].includes(T.op)}var{hasProperty:N,isCommutative:S}=Ns({FunctionNode:v,OperatorNode:y,SymbolNode:A});function D(T){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=B?B.context:void 0;if(N(T,"trivial",_)){if(An(T)&&T.args.length===1)return D(T.args[0],B);var L=!1,G=0;if(T.forEach(re=>{++G,G===1&&(L=D(re,B))}),G===1)return L}var C=T;if(An(C)){var F=LA(C.name);if(F){if(C.args.length>2&&N(C,"associative",_))for(;C.args.length>2;){var Z=C.args.pop(),$=C.args.pop();C.args.push(new y(F,C.name,[Z,$]))}C=new y(F,C.name,C.args)}else return new v(D(C.fn),C.args.map(re=>D(re,B)))}if(_r(C)&&C.isUnary()){var U=D(C.args[0],B);if(C.op==="~"&&_r(U)&&U.isUnary()&&U.op==="~"||C.op==="not"&&_r(U)&&U.isUnary()&&U.op==="not"&&E(U.args[0]))return U.args[0];var Y=!0;if(C.op==="-"&&_r(U)&&(U.isBinary()&&U.fn==="subtract"&&(C=new y("-","subtract",[U.args[1],U.args[0]]),Y=!1),U.isUnary()&&U.op==="-"))return U.args[0];if(Y)return new y(C.op,C.fn,[U])}if(_r(C)&&C.isBinary()){var j=D(C.args[0],B),P=D(C.args[1],B);if(C.op==="+"){if(sr(j)&&n(j.value))return P;if(sr(P)&&n(P.value))return j;_r(P)&&P.isUnary()&&P.op==="-"&&(P=P.args[0],C=new y("-","subtract",[j,P]))}if(C.op==="-")return _r(P)&&P.isUnary()&&P.op==="-"?D(new y("+","add",[j,P.args[0]]),B):sr(j)&&n(j.value)?D(new y("-","unaryMinus",[P])):sr(P)&&n(P.value)?j:new y(C.op,C.fn,[j,P]);if(C.op==="*"){if(sr(j)){if(n(j.value))return d;if(a(j.value,1))return P}if(sr(P)){if(n(P.value))return d;if(a(P.value,1))return j;if(S(C,_))return new y(C.op,C.fn,[P,j],C.implicit)}return new y(C.op,C.fn,[j,P],C.implicit)}if(C.op==="/")return sr(j)&&n(j.value)?d:sr(P)&&a(P.value,1)?j:new y(C.op,C.fn,[j,P]);if(C.op==="^"&&sr(P)){if(n(P.value))return w;if(a(P.value,1))return j}if(C.op==="and"){if(sr(j))if(j.value){if(E(P))return P}else return g;if(sr(P))if(P.value){if(E(j))return j}else return g}if(C.op==="or"){if(sr(j)){if(j.value)return x;if(E(P))return P}if(sr(P)){if(P.value)return x;if(E(j))return j}}return new y(C.op,C.fn,[j,P])}if(_r(C))return new y(C.op,C.fn,C.args.map(re=>D(re,B)));if(nt(C))return new c(C.items.map(re=>D(re,B)));if(Dn(C))return new o(D(C.object,B),D(C.index,B));if(Ln(C))return new p(C.dimensions.map(re=>D(re,B)));if(ii(C)){var K={};for(var ne in C.properties)K[ne]=D(C.properties[ne],B);return new h(K)}return C}return e(Kp,{Node:D,"Node,Object":D})}),fT="resolve",mT=["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],vT=R(fT,mT,r=>{var{typed:e,parse:t,ConstantNode:a,FunctionNode:n,OperatorNode:i,ParenthesisNode:s}=r;function f(l,u){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!u)return l;if(qr(l)){if(o.has(l.name)){var c=Array.from(o).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var m=u.get(l.name);if(or(m)){var v=new Set(o);return v.add(l.name),f(m,u,v)}else return typeof m=="number"?t(String(m)):m!==void 0?new a(m):l}else if(_r(l)){var p=l.args.map(function(y){return f(y,u,o)});return new i(l.op,l.fn,p,l.implicit)}else{if(rn(l))return new s(f(l.content,u,o));if(An(l)){var h=l.args.map(function(y){return f(y,u,o)});return new n(l.name,h)}}return l.map(y=>f(y,u,o))}return e("resolve",{Node:f,"Node, Map | null | undefined":f,"Node, Object":(l,u)=>f(l,Wn(u)),"Array | Matrix":e.referToSelf(l=>u=>u.map(o=>l(o))),"Array | Matrix, null | undefined":e.referToSelf(l=>u=>u.map(o=>l(o))),"Array, Object":e.referTo("Array,Map",l=>(u,o)=>l(u,Wn(o))),"Matrix, Object":e.referTo("Matrix,Map",l=>(u,o)=>l(u,Wn(o))),"Array | Matrix, Map":e.referToSelf(l=>(u,o)=>u.map(c=>l(c,o)))})}),jp="symbolicEqual",pT=["parse","simplify","typed","OperatorNode"],hT=R(jp,pT,r=>{var{parse:e,simplify:t,typed:a,OperatorNode:n}=r;function i(s,f){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=new n("-","subtract",[s,f]),o=t(u,{},l);return sr(o)&&!o.value}return a(jp,{"Node, Node":i,"Node, Node, Object":i})}),eh="derivative",dT=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],gT=R(eh,dT,r=>{var{typed:e,config:t,parse:a,simplify:n,equal:i,isZero:s,numeric:f,ConstantNode:l,FunctionNode:u,OperatorNode:o,ParenthesisNode:c,SymbolNode:m}=r;function v(w,x){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},E={};y(E,w,x.name);var N=b(w,E);return g.simplify?n(N):N}e.addConversion({from:"identifier",to:"SymbolNode",convert:a});var p=e(eh,{"Node, SymbolNode":v,"Node, SymbolNode, Object":v});e.removeConversion({from:"identifier",to:"SymbolNode",convert:a}),p._simplify=!0,p.toTex=function(w){return h.apply(null,w.args)};var h=e("_derivTex",{"Node, SymbolNode":function(x,g){return sr(x)&&gr(x.value)==="string"?h(a(x.value).toString(),g.toString(),1):h(x.toTex(),g.toString(),1)},"Node, ConstantNode":function(x,g){if(gr(g.value)==="string")return h(x,a(g.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(x,g,E){return h(x.toString(),g.name,E.value)},"string, string, number":function(x,g,E){var N;return E===1?N="{d\\over d"+g+"}":N="{d^{"+E+"}\\over d"+g+"^{"+E+"}}",N+"\\left[".concat(x,"\\right]")}}),y=e("constTag",{"Object, ConstantNode, string":function(x,g){return x[g]=!0,!0},"Object, SymbolNode, string":function(x,g,E){return g.name!==E?(x[g]=!0,!0):!1},"Object, ParenthesisNode, string":function(x,g,E){return y(x,g.content,E)},"Object, FunctionAssignmentNode, string":function(x,g,E){return g.params.indexOf(E)===-1?(x[g]=!0,!0):y(x,g.expr,E)},"Object, FunctionNode | OperatorNode, string":function(x,g,E){if(g.args.length>0){for(var N=y(x,g.args[0],E),S=1;S<g.args.length;++S)N=y(x,g.args[S],E)&&N;if(N)return x[g]=!0,!0}return!1}}),b=e("_derivative",{"ConstantNode, Object":function(x){return d(0)},"SymbolNode, Object":function(x,g){return g[x]!==void 0?d(0):d(1)},"ParenthesisNode, Object":function(x,g){return new c(b(x.content,g))},"FunctionAssignmentNode, Object":function(x,g){return g[x]!==void 0?d(0):b(x.expr,g)},"FunctionNode, Object":function(x,g){if(x.args.length!==1&&A(x),g[x]!==void 0)return d(0);var E=x.args[0],N,S=!1,D=!1,T;switch(x.name){case"cbrt":S=!0,T=new o("*","multiply",[d(3),new o("^","pow",[E,new o("/","divide",[d(2),d(3)])])]);break;case"sqrt":case"nthRoot":if(x.args.length===1)S=!0,T=new o("*","multiply",[d(2),new u("sqrt",[E])]);else if(x.args.length===2)return N=new o("/","divide",[d(1),x.args[1]]),g[N]=g[x.args[1]],b(new o("^","pow",[E,N]),g);break;case"log10":N=d(10);case"log":if(!N&&x.args.length===1)T=E.clone(),S=!0;else if(x.args.length===1&&N||x.args.length===2&&g[x.args[1]]!==void 0)T=new o("*","multiply",[E.clone(),new u("log",[N||x.args[1]])]),S=!0;else if(x.args.length===2)return b(new o("/","divide",[new u("log",[E]),new u("log",[x.args[1]])]),g);break;case"pow":return g[N]=g[x.args[1]],b(new o("^","pow",[E,x.args[1]]),g);case"exp":T=new u("exp",[E.clone()]);break;case"sin":T=new u("cos",[E.clone()]);break;case"cos":T=new o("-","unaryMinus",[new u("sin",[E.clone()])]);break;case"tan":T=new o("^","pow",[new u("sec",[E.clone()]),d(2)]);break;case"sec":T=new o("*","multiply",[x,new u("tan",[E.clone()])]);break;case"csc":D=!0,T=new o("*","multiply",[x,new u("cot",[E.clone()])]);break;case"cot":D=!0,T=new o("^","pow",[new u("csc",[E.clone()]),d(2)]);break;case"asin":S=!0,T=new u("sqrt",[new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])])]);break;case"acos":S=!0,D=!0,T=new u("sqrt",[new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])])]);break;case"atan":S=!0,T=new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)]);break;case"asec":S=!0,T=new o("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new o("-","subtract",[new o("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acsc":S=!0,D=!0,T=new o("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new o("-","subtract",[new o("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acot":S=!0,D=!0,T=new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)]);break;case"sinh":T=new u("cosh",[E.clone()]);break;case"cosh":T=new u("sinh",[E.clone()]);break;case"tanh":T=new o("^","pow",[new u("sech",[E.clone()]),d(2)]);break;case"sech":D=!0,T=new o("*","multiply",[x,new u("tanh",[E.clone()])]);break;case"csch":D=!0,T=new o("*","multiply",[x,new u("coth",[E.clone()])]);break;case"coth":D=!0,T=new o("^","pow",[new u("csch",[E.clone()]),d(2)]);break;case"asinh":S=!0,T=new u("sqrt",[new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"acosh":S=!0,T=new u("sqrt",[new o("-","subtract",[new o("^","pow",[E.clone(),d(2)]),d(1)])]);break;case"atanh":S=!0,T=new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])]);break;case"asech":S=!0,D=!0,T=new o("*","multiply",[E.clone(),new u("sqrt",[new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])])])]);break;case"acsch":S=!0,D=!0,T=new o("*","multiply",[new u("abs",[E.clone()]),new u("sqrt",[new o("+","add",[new o("^","pow",[E.clone(),d(2)]),d(1)])])]);break;case"acoth":S=!0,D=!0,T=new o("-","subtract",[d(1),new o("^","pow",[E.clone(),d(2)])]);break;case"abs":T=new o("/","divide",[new u(new m("abs"),[E.clone()]),E.clone()]);break;case"gamma":default:throw new Error('Function "'+x.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var B,_;S?(B="/",_="divide"):(B="*",_="multiply");var L=b(E,g);return D&&(L=new o("-","unaryMinus",[L])),new o(B,_,[L,T])},"OperatorNode, Object":function(x,g){if(g[x]!==void 0)return d(0);if(x.op==="+")return new o(x.op,x.fn,x.args.map(function(C){return b(C,g)}));if(x.op==="-"){if(x.isUnary())return new o(x.op,x.fn,[b(x.args[0],g)]);if(x.isBinary())return new o(x.op,x.fn,[b(x.args[0],g),b(x.args[1],g)])}if(x.op==="*"){var E=x.args.filter(function(C){return g[C]!==void 0});if(E.length>0){var N=x.args.filter(function(C){return g[C]===void 0}),S=N.length===1?N[0]:new o("*","multiply",N),D=E.concat(b(S,g));return new o("*","multiply",D)}return new o("+","add",x.args.map(function(C){return new o("*","multiply",x.args.map(function(F){return F===C?b(F,g):F.clone()}))}))}if(x.op==="/"&&x.isBinary()){var T=x.args[0],B=x.args[1];return g[B]!==void 0?new o("/","divide",[b(T,g),B]):g[T]!==void 0?new o("*","multiply",[new o("-","unaryMinus",[T]),new o("/","divide",[b(B,g),new o("^","pow",[B.clone(),d(2)])])]):new o("/","divide",[new o("-","subtract",[new o("*","multiply",[b(T,g),B.clone()]),new o("*","multiply",[T.clone(),b(B,g)])]),new o("^","pow",[B.clone(),d(2)])])}if(x.op==="^"&&x.isBinary()){var _=x.args[0],L=x.args[1];if(g[_]!==void 0)return sr(_)&&(s(_.value)||i(_.value,1))?d(0):new o("*","multiply",[x,new o("*","multiply",[new u("log",[_.clone()]),b(L.clone(),g)])]);if(g[L]!==void 0){if(sr(L)){if(s(L.value))return d(0);if(i(L.value,1))return b(_,g)}var G=new o("^","pow",[_.clone(),new o("-","subtract",[L,d(1)])]);return new o("*","multiply",[L.clone(),new o("*","multiply",[b(_,g),G])])}return new o("*","multiply",[new o("^","pow",[_.clone(),L.clone()]),new o("+","add",[new o("*","multiply",[b(_,g),new o("/","divide",[L.clone(),_.clone()])]),new o("*","multiply",[b(L,g),new u("log",[_.clone()])])])])}throw new Error('Operator "'+x.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function A(w){if(!((w.name==="log"||w.name==="nthRoot"||w.name==="pow")&&w.args.length===2)){for(var x=0;x<w.args.length;++x)w.args[x]=d(0);throw w.compile().evaluate(),new Error("Expected TypeError, but none found")}}function d(w,x){return new l(f(w,x||t.number))}return p}),rh="rationalize",yT=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],bT=R(rh,yT,r=>{var{config:e,typed:t,equal:a,isZero:n,add:i,subtract:s,multiply:f,divide:l,pow:u,parse:o,simplifyConstant:c,simplifyCore:m,simplify:v,fraction:p,bignumber:h,mathWithTransform:y,matrix:b,AccessorNode:A,ArrayNode:d,ConstantNode:w,FunctionNode:x,IndexNode:g,ObjectNode:E,OperatorNode:N,SymbolNode:S,ParenthesisNode:D}=r;function T(C){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,$=_(),U=B(C,F,!0,$.firstRules),Y=U.variables.length,j={exactFractions:!1},P={exactFractions:!0};if(C=U.expression,Y>=1){C=L(C);var K,ne,re=!0,fe=!1;C=v(C,$.firstRules,{},j);for(var pe;ne=re?$.distrDivRules:$.sucDivRules,C=v(C,ne,{},P),re=!re,pe=C.toString(),pe!==K;)fe=!0,K=pe;fe&&(C=v(C,$.firstRulesAgain,{},j)),C=v(C,$.finalRules,{},j)}var ce=[],oe={};return C.type==="OperatorNode"&&C.isBinary()&&C.op==="/"?(Y===1&&(C.args[0]=G(C.args[0],ce),C.args[1]=G(C.args[1])),Z&&(oe.numerator=C.args[0],oe.denominator=C.args[1])):(Y===1&&(C=G(C,ce)),Z&&(oe.numerator=C,oe.denominator=null)),Z?(oe.coefficients=ce,oe.variables=U.variables,oe.expression=C,oe):C}return t(rh,{Node:T,"Node, boolean":(C,F)=>T(C,{},F),"Node, Object":T,"Node, Object, boolean":T});function B(C,F,Z,$){var U=[],Y=v(C,$,F,{exactFractions:!1});Z=!!Z;var j="+-*"+(Z?"/":"");K(Y);var P={};return P.expression=Y,P.variables=U,P;function K(ne){var re=ne.type;if(re==="FunctionNode")throw new Error("There is an unsolved function call");if(re==="OperatorNode")if(ne.op==="^"){if(ne.args[1].type!=="ConstantNode"||!qe(parseFloat(ne.args[1].value)))throw new Error("There is a non-integer exponent");K(ne.args[0])}else{if(j.indexOf(ne.op)===-1)throw new Error("Operator "+ne.op+" invalid in polynomial expression");for(var fe=0;fe<ne.args.length;fe++)K(ne.args[fe])}else if(re==="SymbolNode"){var pe=ne.name,ce=U.indexOf(pe);ce===-1&&U.push(pe)}else if(re==="ParenthesisNode")K(ne.content);else if(re!=="ConstantNode")throw new Error("type "+re+" is not allowed in polynomial expression")}}function _(){var C=[m,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},c,{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"}],F=[{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)"}],Z=[{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)"}],$=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],U={};return U.firstRules=C.concat(F,$),U.distrDivRules=Z,U.sucDivRules=$,U.firstRulesAgain=C.concat(F),U.finalRules=[m,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},c,{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))"}],U}function L(C,F,Z){var $=C.type,U=arguments.length>1;if($==="OperatorNode"&&C.isBinary()){var Y=!1,j;if(C.op==="^"&&(C.args[0].type==="ParenthesisNode"||C.args[0].type==="OperatorNode")&&C.args[1].type==="ConstantNode"&&(j=parseFloat(C.args[1].value),Y=j>=2&&qe(j)),Y){if(j>2){var P=C.args[0],K=new N("^","pow",[C.args[0].cloneDeep(),new w(j-1)]);C=new N("*","multiply",[P,K])}else C=new N("*","multiply",[C.args[0],C.args[0].cloneDeep()]);U&&(Z==="content"?F.content=C:F.args[Z]=C)}}if($==="ParenthesisNode")L(C.content,C,"content");else if($!=="ConstantNode"&&$!=="SymbolNode")for(var ne=0;ne<C.args.length;ne++)L(C.args[ne],C,ne);if(!U)return C}function G(C,F){F===void 0&&(F=[]),F[0]=0;var Z={};Z.cte=1,Z.oper="+",Z.fire="";var $=0,U="";pe(C,null,Z),$=F.length-1;for(var Y=!0,j,P=$;P>=0;P--)if(F[P]!==0){var K=new w(Y?F[P]:Math.abs(F[P])),ne=F[P]<0?"-":"+";if(P>0){var re=new S(U);if(P>1){var fe=new w(P);re=new N("^","pow",[re,fe])}F[P]===-1&&Y?K=new N("-","unaryMinus",[re]):Math.abs(F[P])===1?K=re:K=new N("*","multiply",[K,re])}Y?j=K:ne==="+"?j=new N("+","add",[j,K]):j=new N("-","subtract",[j,K]),Y=!1}if(Y)return new w(0);return j;function pe(ce,oe,Ce){var Oe=ce.type;if(Oe==="FunctionNode")throw new Error("There is an unsolved function call");if(Oe==="OperatorNode"){if("+-*^".indexOf(ce.op)===-1)throw new Error("Operator "+ce.op+" invalid");if(oe!==null){if((ce.fn==="unaryMinus"||ce.fn==="pow")&&oe.fn!=="add"&&oe.fn!=="subtract"&&oe.fn!=="multiply")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="multiply")&&oe.fn!=="add"&&oe.fn!=="subtract")throw new Error("Invalid "+ce.op+" placing");if((ce.fn==="subtract"||ce.fn==="add"||ce.fn==="unaryMinus")&&Ce.noFil!==0)throw new Error("Invalid "+ce.op+" placing")}(ce.op==="^"||ce.op==="*")&&(Ce.fire=ce.op);for(var Me=0;Me<ce.args.length;Me++)ce.fn==="unaryMinus"&&(Ce.oper="-"),(ce.op==="+"||ce.fn==="subtract")&&(Ce.fire="",Ce.cte=1,Ce.oper=Me===0?"+":ce.op),Ce.noFil=Me,pe(ce.args[Me],ce,Ce)}else if(Oe==="SymbolNode"){if(ce.name!==U&&U!=="")throw new Error("There is more than one variable");if(U=ce.name,oe===null){F[1]=1;return}if(oe.op==="^"&&Ce.noFil!==0)throw new Error("In power the variable should be the first parameter");if(oe.op==="*"&&Ce.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(Ce.fire===""||Ce.fire==="*")&&($<1&&(F[1]=0),F[1]+=Ce.cte*(Ce.oper==="+"?1:-1),$=Math.max(1,$))}else if(Oe==="ConstantNode"){var $e=parseFloat(ce.value);if(oe===null){F[0]=$e;return}if(oe.op==="^"){if(Ce.noFil!==1)throw new Error("Constant cannot be powered");if(!qe($e)||$e<=0)throw new Error("Non-integer exponent is not allowed");for(var k=$+1;k<$e;k++)F[k]=0;$e>$&&(F[$e]=0),F[$e]+=Ce.cte*(Ce.oper==="+"?1:-1),$=Math.max($e,$);return}Ce.cte=$e,Ce.fire===""&&(F[0]+=Ce.cte*(Ce.oper==="+"?1:-1))}else throw new Error("Type "+Oe+" is not allowed")}}}),xT="reviver",wT=["classes"],NT=R(xT,wT,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}}),DT="replacer",AT=[],ET=R(DT,AT,()=>function(e,t){return typeof t=="number"&&(!isFinite(t)||isNaN(t))?{mathjs:"number",value:String(t)}:t}),ST="11.3.1",CT=R("true",[],()=>!0),MT=R("false",[],()=>!1),FT=R("null",[],()=>null),TT=rt("Infinity",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1/0):1/0}),BT=rt("NaN",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(NaN):NaN}),$T=rt("pi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?ms(t):F1}),OT=rt("tau",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?G2(t):T1}),_T=rt("e",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?k2(t):B1}),IT=rt("phi",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?V2(t):$1}),RT=rt("LN2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).ln():Math.LN2}),qT=rt("LN10",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(10).ln():Math.LN10}),zT=rt("LOG2E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(2).ln()):Math.LOG2E}),PT=rt("LOG10E",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(1).div(new t(10).ln()):Math.LOG10E}),LT=rt("SQRT1_2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t("0.5").sqrt():Math.SQRT1_2}),UT=rt("SQRT2",["config","?BigNumber"],r=>{var{config:e,BigNumber:t}=r;return e.number==="BigNumber"?new t(2).sqrt():Math.SQRT2}),kT=rt("i",["Complex"],r=>{var{Complex:e}=r;return e.I}),VT=R("version",[],()=>ST);function rt(r,e,t){return R(r,e,t,{recreateOnConfigChange:!0})}var GT=Xe("speedOfLight","299792458","m s^-1"),HT=Xe("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ZT=Xe("planckConstant","6.62607015e-34","J s"),JT=Xe("reducedPlanckConstant","1.0545718176461565e-34","J s"),WT=Xe("magneticConstant","1.25663706212e-6","N A^-2"),XT=Xe("electricConstant","8.8541878128e-12","F m^-1"),YT=Xe("vacuumImpedance","376.730313667","ohm"),QT=Xe("coulomb","8.987551792261171e9","N m^2 C^-2"),KT=Xe("elementaryCharge","1.602176634e-19","C"),jT=Xe("bohrMagneton","9.2740100783e-24","J T^-1"),eB=Xe("conductanceQuantum","7.748091729863649e-5","S"),rB=Xe("inverseConductanceQuantum","12906.403729652257","ohm"),tB=Xe("magneticFluxQuantum","2.0678338484619295e-15","Wb"),nB=Xe("nuclearMagneton","5.0507837461e-27","J T^-1"),aB=Xe("klitzing","25812.807459304513","ohm"),iB=Xe("bohrRadius","5.29177210903e-11","m"),oB=Xe("classicalElectronRadius","2.8179403262e-15","m"),sB=Xe("electronMass","9.1093837015e-31","kg"),uB=Xe("fermiCoupling","1.1663787e-5","GeV^-2"),lB=ro("fineStructure",.0072973525693),cB=Xe("hartreeEnergy","4.3597447222071e-18","J"),fB=Xe("protonMass","1.67262192369e-27","kg"),mB=Xe("deuteronMass","3.3435830926e-27","kg"),vB=Xe("neutronMass","1.6749271613e-27","kg"),pB=Xe("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),hB=Xe("rydberg","10973731.568160","m^-1"),dB=Xe("thomsonCrossSection","6.6524587321e-29","m^2"),gB=ro("weakMixingAngle",.2229),yB=ro("efimovFactor",22.7),bB=Xe("atomicMass","1.66053906660e-27","kg"),xB=Xe("avogadro","6.02214076e23","mol^-1"),wB=Xe("boltzmann","1.380649e-23","J K^-1"),NB=Xe("faraday","96485.33212331001","C mol^-1"),DB=Xe("firstRadiation","3.7417718521927573e-16","W m^2"),AB=Xe("loschmidt","2.686780111798444e25","m^-3"),EB=Xe("gasConstant","8.31446261815324","J K^-1 mol^-1"),SB=Xe("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),CB=Xe("molarVolume","0.022413969545014137","m^3 mol^-1"),MB=ro("sackurTetrode",-1.16487052358),FB=Xe("secondRadiation","0.014387768775039337","m K"),TB=Xe("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),BB=Xe("wienDisplacement","2.897771955e-3","m K"),$B=Xe("molarMass","0.99999999965e-3","kg mol^-1"),OB=Xe("molarMassC12","11.9999999958e-3","kg mol^-1"),_B=Xe("gravity","9.80665","m s^-2"),IB=Xe("planckLength","1.616255e-35","m"),RB=Xe("planckMass","2.176435e-8","kg"),qB=Xe("planckTime","5.391245e-44","s"),zB=Xe("planckCharge","1.87554603778e-18","C"),PB=Xe("planckTemperature","1.416785e+32","K");function Xe(r,e,t){var a=["config","Unit","BigNumber"];return R(r,a,n=>{var{config:i,Unit:s,BigNumber:f}=n,l=i.number==="BigNumber"?new f(e):parseFloat(e),u=new s(l,t);return u.fixPrefix=!0,u})}function ro(r,e){var t=["config","BigNumber"];return R(r,t,a=>{var{config:n,BigNumber:i}=a;return n.number==="BigNumber"?new i(e):e})}var LB="apply",UB=["typed","isInteger"],kB=R(LB,UB,r=>{var{typed:e,isInteger:t}=r,a=nf({typed:e,isInteger:t});return e("apply",{"...any":function(i){var s=i[1];tr(s)?i[1]=s-1:rr(s)&&(i[1]=s.minus(1));try{return a.apply(null,i)}catch(f){throw Qr(f)}}})},{isTransformFunction:!0}),VB="column",GB=["typed","Index","matrix","range"],HB=R(VB,GB,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=Pf({typed:e,Index:t,matrix:a,range:n});return e("column",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(o){throw Qr(o)}}})},{isTransformFunction:!0});function Ds(r,e,t){var a=r.filter(function(f){return qr(f)&&!(f.name in e)&&!t.has(f.name)})[0];if(!a)throw new Error('No undefined variable found in inline expression "'+r+'"');var n=a.name,i=Ga(t),s=r.compile();return function(l){return i.set(n,l),s.evaluate(i)}}var ZB="filter",JB=["typed"],WB=R(ZB,JB,r=>{var{typed:e}=r;function t(n,i,s){var f,l;return n[0]&&(f=n[0].compile().evaluate(s)),n[1]&&(qr(n[1])||Ia(n[1])?l=n[1].compile().evaluate(s):l=Ds(n[1],i,s)),a(f,l)}t.rawArgs=!0;var a=e("filter",{"Array, function":th,"Matrix, function":function(i,s){return i.create(th(i.toArray(),s))},"Array, RegExp":fi,"Matrix, RegExp":function(i,s){return i.create(fi(i.toArray(),s))}});return t},{isTransformFunction:!0});function th(r,e){var t=ln(e);return pl(r,function(a,n,i){return t===1?e(a):t===2?e(a,[n+1]):e(a,[n+1],i)})}var XB="forEach",YB=["typed"],QB=R(XB,YB,r=>{var{typed:e}=r;function t(n,i,s){var f,l;return n[0]&&(f=n[0].compile().evaluate(s)),n[1]&&(qr(n[1])||Ia(n[1])?l=n[1].compile().evaluate(s):l=Ds(n[1],i,s)),a(f,l)}t.rawArgs=!0;var a=e("forEach",{"Array | Matrix, function":function(i,s){var f=ln(s),l=function u(o,c){Array.isArray(o)?ci(o,function(m,v){u(m,c.concat(v+1))}):f===1?s(o):f===2?s(o,c):s(o,c,i)};l(i.valueOf(),[])}});return t},{isTransformFunction:!0}),KB="index",jB=["Index"],e$=R(KB,jB,r=>{var{Index:e}=r;return function(){for(var a=[],n=0,i=arguments.length;n<i;n++){var s=arguments[n];if(Ro(s))s.start--,s.end-=s.step>0?0:2;else if(s&&s.isSet===!0)s=s.map(function(l){return l-1});else if(ur(s)||He(s))s=s.map(function(l){return l-1});else if(tr(s))s--;else if(rr(s))s=s.toNumber()-1;else if(typeof s!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");a[n]=s}var f=new e;return e.apply(f,a),f}},{isTransformFunction:!0}),r$="map",t$=["typed"],n$=R(r$,t$,r=>{var{typed:e}=r;function t(n,i,s){var f,l;return n[0]&&(f=n[0].compile().evaluate(s)),n[1]&&(qr(n[1])||Ia(n[1])?l=n[1].compile().evaluate(s):l=Ds(n[1],i,s)),a(f,l)}t.rawArgs=!0;var a=e("map",{"Array, function":function(i,s){return nh(i,s,i)},"Matrix, function":function(i,s){return i.create(nh(i.valueOf(),s,i))}});return t},{isTransformFunction:!0});function nh(r,e,t){var a=ln(e);function n(i,s){return Array.isArray(i)?Ut(i,function(f,l){return n(f,s.concat(l+1))}):a===1?e(i):a===2?e(i,s):e(i,s,t)}return n(r,[])}function Tn(r){if(r.length===2&&Lt(r[0])){r=r.slice();var e=r[1];tr(e)?r[1]=e-1:rr(e)&&(r[1]=e.minus(1))}return r}var a$="max",i$=["typed","config","numeric","larger"],o$=R(a$,i$,r=>{var{typed:e,config:t,numeric:a,larger:n}=r,i=Ym({typed:e,config:t,numeric:a,larger:n});return e("max",{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),s$="mean",u$=["typed","add","divide"],l$=R(s$,u$,r=>{var{typed:e,add:t,divide:a}=r,n=gp({typed:e,add:t,divide:a});return e("mean",{"...any":function(s){s=Tn(s);try{return n.apply(null,s)}catch(f){throw Qr(f)}}})},{isTransformFunction:!0}),c$="min",f$=["typed","config","numeric","smaller"],m$=R(c$,f$,r=>{var{typed:e,config:t,numeric:a,smaller:n}=r,i=Km({typed:e,config:t,numeric:a,smaller:n});return e("min",{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),v$="range",p$=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],h$=R(v$,p$,r=>{var{typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:s,larger:f,largerEq:l}=r,u=rm({typed:e,config:t,matrix:a,bignumber:n,smaller:i,smallerEq:s,larger:f,largerEq:l});return e("range",{"...any":function(c){var m=c.length-1,v=c[m];return typeof v!="boolean"&&c.push(!0),u.apply(null,c)}})},{isTransformFunction:!0}),d$="row",g$=["typed","Index","matrix","range"],y$=R(d$,g$,r=>{var{typed:e,Index:t,matrix:a,range:n}=r,i=om({typed:e,Index:t,matrix:a,range:n});return e("row",{"...any":function(f){var l=f.length-1,u=f[l];tr(u)&&(f[l]=u-1);try{return i.apply(null,f)}catch(o){throw Qr(o)}}})},{isTransformFunction:!0}),b$="subset",x$=["typed","matrix"],w$=R(b$,x$,r=>{var{typed:e,matrix:t}=r,a=cm({typed:e,matrix:t});return e("subset",{"...any":function(i){try{return a.apply(null,i)}catch(s){throw Qr(s)}}})},{isTransformFunction:!0}),N$="concat",D$=["typed","matrix","isInteger"],A$=R(N$,D$,r=>{var{typed:e,matrix:t,isInteger:a}=r,n=Rf({typed:e,matrix:t,isInteger:a});return e("concat",{"...any":function(s){var f=s.length-1,l=s[f];tr(l)?s[f]=l-1:rr(l)&&(s[f]=l.minus(1));try{return n.apply(null,s)}catch(u){throw Qr(u)}}})},{isTransformFunction:!0}),ah="diff",E$=["typed","matrix","subtract","number","bignumber"],S$=R(ah,E$,r=>{var{typed:e,matrix:t,subtract:a,number:n,bignumber:i}=r,s=Qf({typed:e,matrix:t,subtract:a,number:n,bignumber:i});return e(ah,{"...any":function(l){l=Tn(l);try{return s.apply(null,l)}catch(u){throw Qr(u)}}})},{isTransformFunction:!0}),C$="std",M$=["typed","map","sqrt","variance"],F$=R(C$,M$,r=>{var{typed:e,map:t,sqrt:a,variance:n}=r,i=Dp({typed:e,map:t,sqrt:a,variance:n});return e("std",{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),ih="sum",T$=["typed","config","add","numeric"],B$=R(ih,T$,r=>{var{typed:e,config:t,add:a,numeric:n}=r,i=pp({typed:e,config:t,add:a,numeric:n});return e(ih,{"...any":function(f){f=Tn(f);try{return i.apply(null,f)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),oh="cumsum",$$=["typed","add","unaryPlus"],O$=R(oh,$$,r=>{var{typed:e,add:t,unaryPlus:a}=r,n=hp({typed:e,add:t,unaryPlus:a});return e(oh,{"...any":function(s){if(s.length===2&&Lt(s[0])){var f=s[1];tr(f)?s[1]=f-1:rr(f)&&(s[1]=f.minus(1))}try{return n.apply(null,s)}catch(l){throw Qr(l)}}})},{isTransformFunction:!0}),sh="variance",_$=["typed","add","subtract","multiply","divide","apply","isNaN"],I$=R(sh,_$,r=>{var{typed:e,add:t,subtract:a,multiply:n,divide:i,apply:s,isNaN:f}=r,l=wp({typed:e,add:t,subtract:a,multiply:n,divide:i,apply:s,isNaN:f});return e(sh,{"...any":function(o){o=Tn(o);try{return l.apply(null,o)}catch(c){throw Qr(c)}}})},{isTransformFunction:!0}),Se=i1({config:de}),yr=l1({}),uh=_T({BigNumber:Se,config:de}),R$=MT({}),q$=lB({BigNumber:Se,config:de}),Bn=m1({}),lh=kT({Complex:yr}),z$=TT({BigNumber:Se,config:de}),P$=qT({BigNumber:Se,config:de}),L$=PT({BigNumber:Se,config:de}),to=y1({}),U$=BT({BigNumber:Se,config:de}),k$=FT({}),V$=IT({BigNumber:Se,config:de}),G$=h1({}),ch=lg({}),H$=LT({BigNumber:Se,config:de}),Z$=MB({BigNumber:Se,config:de}),fh=OT({BigNumber:Se,config:de}),J$=CT({}),W$=VT({}),Qe=N1({Matrix:to}),X$=yB({BigNumber:Se,config:de}),Y$=RT({BigNumber:Se,config:de}),mh=$T({BigNumber:Se,config:de}),Q$=ET({}),K$=UT({BigNumber:Se,config:de}),J=ig({BigNumber:Se,Complex:yr,DenseMatrix:Qe,Fraction:Bn}),As=Oy({BigNumber:Se,config:de,typed:J}),j$=gB({BigNumber:Se,config:de}),tt=Iy({typed:J}),eO=rD({Complex:yr,config:de,typed:J}),rO=iD({BigNumber:Se,typed:J}),tO=lD({BigNumber:Se,Complex:yr,config:de,typed:J}),Fr=Py({typed:J}),nO=Ax({typed:J}),aO=hD({BigNumber:Se,Complex:yr,config:de,typed:J}),iO=xD({typed:J}),vh=DD({typed:J}),oO=CD({Complex:yr,config:de,typed:J}),Ft=vy({BigNumber:Se,typed:J}),sO=dx({typed:J}),uO=cy({typed:J}),lO=A1({typed:J}),no=d4({typed:J}),ao=dy({Complex:yr,typed:J}),sa=Sx({typed:J}),cO=BD({typed:J}),fO=ID({BigNumber:Se,typed:J}),mO=qD({BigNumber:Se,typed:J}),vO=Ky({typed:J}),nr=K1({config:de,typed:J}),pO=Vw({typed:J}),ph=eb({typed:J}),hO=tb({Complex:yr,typed:J}),dO=Jx({typed:J}),gO=Qx({typed:J}),Ha=Kw({typed:J}),yO=ew({typed:J}),bO=aN({format:Ha,typed:J}),hh=Mx({typed:J}),st=S1({typed:J}),ua=q1({typed:J}),io=V1({typed:J}),Tt=H1({typed:J}),xO=zT({BigNumber:Se,config:de}),wO=N4({Complex:yr,typed:J}),NO=Fb({Complex:yr,config:de,typed:J}),DO=Bb({Complex:yr,config:de,typed:J}),la=ow({typed:J}),Er=Lb({typed:J}),dh=$x({typed:J}),mn=oy({typed:J}),AO=tN({format:Ha,typed:J}),EO=L4({config:de,typed:J}),SO=oN({typed:J}),CO=k4({config:de,typed:J}),gh=Tx({typed:J}),MO=UD({BigNumber:Se,typed:J}),yh=Zb({BigNumber:Se,Fraction:Bn,complex:ao,typed:J}),Es=HD({typed:J}),Jt=ry({Matrix:to,equalScalar:nr,typed:J}),FO=Fy({typed:J}),TO=Qb({typed:J}),BO=uy({typed:J}),$O=XD({typed:J}),OO=X1({typed:J}),_O=nD({Complex:yr,config:de,typed:J}),IO=fD({BigNumber:Se,typed:J}),Ss=nf({isInteger:st,typed:J}),RO=vD({BigNumber:Se,Complex:yr,config:de,typed:J}),qO=eN({format:Ha,typed:J}),zO=y4({typed:J}),Cs=FD({typed:J}),PO=PD({BigNumber:Se,typed:J}),Za=J1({typed:J}),LO=cN({typed:J}),UO=G4({config:de,typed:J}),kO=VD({BigNumber:Se,typed:J}),VO=JD({typed:J}),GO=Q2({SparseMatrix:Jt,typed:J}),Wt=Xb({Complex:yr,config:de,typed:J}),HO=KD({typed:J}),Xt=By({typed:J}),ZO=sD({BigNumber:Se,Complex:yr,config:de,typed:J}),JO=OD({BigNumber:Se,typed:J}),ca=by({Fraction:Bn,typed:J}),$n=P1({typed:J}),Te=wy({DenseMatrix:Qe,Matrix:to,SparseMatrix:Jt,typed:J}),WO=Dy({isZero:Tt,matrix:Te,typed:J}),bh=qb({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),XO=Gb({BigNumber:Se,equalScalar:nr,matrix:Te,typed:J}),wt=vN({bignumber:Ft,fraction:ca,number:mn}),YO=_x({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),xh=Yw({config:de,multiplyScalar:Er,numeric:wt,typed:J}),QO=pw({isInteger:st,matrix:Te,typed:J}),Hr=Aw({matrix:Te,config:de,typed:J}),ut=u2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),KO=Sw({matrix:Te,typed:J}),lt=cm({matrix:Te,typed:J}),br=jb({DenseMatrix:Qe,addScalar:Fr,equalScalar:nr,matrix:Te,typed:J,unaryMinus:Xt}),jO=uN({matrix:Te,typed:J}),Ms=$w({matrix:Te,typed:J}),wh=rx({BigNumber:Se,config:de,matrix:Te,typed:J}),Bt=Rw({BigNumber:Se,config:de,matrix:Te,typed:J}),e5=JN({equalScalar:nr,matrix:Te,not:dh,typed:J,zeros:Bt}),r5=px({equalScalar:nr,matrix:Te,typed:J}),t5=Nx({DenseMatrix:Qe,matrix:Te,typed:J}),n5=Uy({BigNumber:Se,Complex:yr,Fraction:Bn,config:de,isNegative:ua,matrix:Te,typed:J,unaryMinus:Xt}),fa=XN({BigNumber:Se,DenseMatrix:Qe,Fraction:Bn,config:de,equalScalar:nr,matrix:Te,typed:J}),Nh=r2({matrix:Te,typed:J}),Fs=Rf({isInteger:st,matrix:Te,typed:J}),a5=Lx({prod:xh,size:Hr,typed:J}),Ts=_w({conj:sa,transpose:Ms,typed:J}),Dh=Gx({DenseMatrix:Qe,SparseMatrix:Jt,matrix:Te,typed:J}),xr=hN({numeric:wt,typed:J}),oo=FN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,typed:J}),Nt=n2({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),Ah=zw({addScalar:Fr,divideScalar:xr,exp:ph,i:lh,matrix:Te,multiplyScalar:Er,tau:fh,typed:J}),Ja=Xx({matrix:Te,typed:J}),i5=wb({BigNumber:Se,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),o5=U1({isNumeric:$n,typed:J}),s5=NA({abs:tt,addScalar:Fr,divideScalar:xr,isPositive:io,multiplyScalar:Er,smaller:ut,sqrt:Wt,typed:J}),u5=Lw({conj:sa,dotDivide:oo,fft:Ah,typed:J}),l5=aw({matrix:Te,multiplyScalar:Er,typed:J}),so=g2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),c5=UN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),Eh=BN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),Sh=Cy({flatten:Ja,matrix:Te,size:Hr,typed:J}),f5=Km({config:de,numeric:wt,smaller:ut,typed:J}),m5=Ww({isNaN:Za,isNumeric:$n,typed:J}),v5=EN({Complex:yr,config:de,divideScalar:xr,typed:J}),p5=fw({BigNumber:Se,config:de,matrix:Te,typed:J}),Bs=E2({compare:fa,isNaN:Za,isNumeric:$n,typed:J}),h5=gw({config:de,matrix:Te}),d5=VN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),uo=bN({BigNumber:Se,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),$s=f2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),g5=N2({DenseMatrix:Qe,config:de,equalScalar:nr,matrix:Te,typed:J}),Os=ON({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),y5=Rx({DenseMatrix:Qe,matrix:Te,typed:J}),wr=xA({DenseMatrix:Qe,SparseMatrix:Jt,addScalar:Fr,equalScalar:nr,matrix:Te,typed:J}),b5=ED({BigNumber:Se,DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),x5=yx({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J}),w5=Y4({addScalar:Fr,combinations:no,divideScalar:xr,isInteger:st,isNegative:ua,multiplyScalar:Er,typed:J}),$t=KN({compare:fa,typed:J}),N5=hp({add:wr,typed:J,unaryPlus:As}),Ch=x2({equal:Nt,typed:J}),D5=Qf({matrix:Te,number:mn,subtract:br,typed:J}),lo=SA({addScalar:Fr,conj:sa,multiplyScalar:Er,size:Hr,typed:J}),A5=o2({compareText:Nh,isZero:Tt,typed:J}),Mh=ub({DenseMatrix:Qe,config:de,equalScalar:nr,matrix:Te,round:uo,typed:J,zeros:Bt}),ma=tw({BigNumber:Se,DenseMatrix:Qe,SparseMatrix:Jt,config:de,matrix:Te,typed:J}),E5=nx({BigNumber:Se,add:wr,config:de,equal:Nt,isInteger:st,mod:bh,smaller:ut,typed:J,xgcd:wh}),ct=p2({DenseMatrix:Qe,config:de,matrix:Te,typed:J}),_s=wN({Complex:yr,config:de,divideScalar:xr,typed:J}),S5=IN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),C5=Ey({flatten:Ja,matrix:Te,size:Hr,typed:J}),Sr=kb({addScalar:Fr,dot:lo,equalScalar:nr,matrix:Te,multiplyScalar:Er,typed:J}),Fh=_E({addScalar:Fr,complex:ao,conj:sa,divideScalar:xr,equal:Nt,identity:ma,isZero:Tt,matrix:Te,multiplyScalar:Er,sign:yh,sqrt:Wt,subtract:br,typed:J,unaryMinus:Xt,zeros:Bt}),Wa=rm({bignumber:Ft,matrix:Te,config:de,larger:ct,largerEq:so,smaller:ut,smallerEq:$s,typed:J}),M5=HN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,typed:J,zeros:Bt}),F5=pA({compareNatural:$t,typed:J}),Th=aS({SparseMatrix:Jt,abs:tt,add:wr,divideScalar:xr,larger:ct,largerEq:so,multiply:Sr,subtract:br,transpose:Ms,typed:J}),Bh=pp({add:wr,config:de,numeric:wt,typed:J}),T5=FA({add:wr,matrix:Te,typed:J}),$h=qN({DenseMatrix:Qe,divideScalar:xr,equalScalar:nr,matrix:Te,multiplyScalar:Er,subtract:br,typed:J}),B5=gD({Complex:yr,config:de,typed:J}),Oh=Yy({DenseMatrix:Qe,config:de,equalScalar:nr,matrix:Te,round:uo,typed:J,zeros:Bt}),$5=K4({addScalar:Fr,combinations:no,isInteger:st,isNegative:ua,isPositive:io,larger:ct,typed:J}),O5=kx({matrix:Te,multiply:Sr,subtract:br,typed:J}),_h=IF({divideScalar:xr,isZero:Tt,matrix:Te,multiply:Sr,subtract:br,typed:J,unaryMinus:Xt}),_5=jF({abs:tt,addScalar:Fr,divideScalar:xr,multiplyScalar:Er,sqrt:Wt,subtract:br,typed:J,unaryMinus:Xt}),I5=sx({equalScalar:nr,matrix:Te,multiplyScalar:Er,typed:J}),Ih=z2({larger:ct,smaller:ut}),Rh=ib({Complex:yr,DenseMatrix:Qe,ceil:Oh,equalScalar:nr,floor:Mh,matrix:Te,typed:J,zeros:Bt}),qh=$2({DenseMatrix:Qe,smaller:ut}),Zr=I2({ImmutableDenseMatrix:qh}),R5=t4({abs:tt,add:wr,addScalar:Fr,config:de,divideScalar:xr,equalScalar:nr,flatten:Ja,isNumeric:$n,isZero:Tt,matrix:Te,multiply:Sr,multiplyScalar:Er,smaller:ut,subtract:br,typed:J}),q5=Cb({equalScalar:nr,matrix:Te,typed:J}),z5=DN({Complex:yr,config:de,divideScalar:xr,log:_s,typed:J}),zh=Ym({config:de,larger:ct,numeric:wt,typed:J}),P5=v4({add:wr,compare:fa,multiply:Sr,partitionSelect:Bs,typed:J}),L5=om({Index:Zr,matrix:Te,range:Wa,typed:J}),U5=eA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),k5=aA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),V5=uA({Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),G5=mA({Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),H5=C2({compare:fa,compareNatural:$t,matrix:Te,typed:J}),Ph=Pf({Index:Zr,matrix:Te,range:Wa,typed:J}),Z5=BA({Index:Zr,typed:J}),On=qF({abs:tt,addScalar:Fr,det:_h,divideScalar:xr,identity:ma,matrix:Te,multiply:Sr,typed:J,unaryMinus:Xt}),J5=PF({Complex:yr,add:wr,ctranspose:Ts,deepEqual:Ch,divideScalar:xr,dot:lo,dotDivide:oo,equal:Nt,inv:On,matrix:Te,multiply:Sr,typed:J}),Yt=gN({Complex:yr,config:de,fraction:ca,identity:ma,inv:On,matrix:Te,multiply:Sr,number:mn,typed:J}),Lh=tA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),W5=cA({Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),Uh=U2({FibonacciHeap:Ih,addScalar:Fr,equalScalar:nr}),X5=WF({abs:tt,add:wr,identity:ma,inv:On,map:la,max:zh,multiply:Sr,size:Hr,sqrt:Wt,subtract:br,typed:J}),Ze=J2({BigNumber:Se,Complex:yr,Fraction:Bn,abs:tt,addScalar:Fr,config:de,divideScalar:xr,equal:Nt,fix:Rh,format:Ha,isNumeric:$n,multiplyScalar:Er,number:mn,pow:Yt,round:uo,subtract:br}),Y5=YT({BigNumber:Se,Unit:Ze,config:de}),Q5=BB({BigNumber:Se,Unit:Ze,config:de}),K5=bB({BigNumber:Se,Unit:Ze,config:de}),j5=jT({BigNumber:Se,Unit:Ze,config:de}),e8=wB({BigNumber:Se,Unit:Ze,config:de}),r8=eB({BigNumber:Se,Unit:Ze,config:de}),t8=j2({Unit:Ze,typed:J}),n8=mB({BigNumber:Se,Unit:Ze,config:de}),a8=CN({DenseMatrix:Qe,equalScalar:nr,matrix:Te,pow:Yt,typed:J}),i8=XT({BigNumber:Se,Unit:Ze,config:de}),o8=KT({BigNumber:Se,Unit:Ze,config:de}),s8=ZF({abs:tt,add:wr,identity:ma,inv:On,multiply:Sr,typed:J}),u8=NB({BigNumber:Se,Unit:Ze,config:de}),l8=DB({BigNumber:Se,Unit:Ze,config:de}),kh=x4({BigNumber:Se,Complex:yr,config:de,multiplyScalar:Er,pow:Yt,typed:J}),c8=HT({BigNumber:Se,Unit:Ze,config:de}),f8=cB({BigNumber:Se,Unit:Ze,config:de}),m8=aB({BigNumber:Se,Unit:Ze,config:de}),v8=AB({BigNumber:Se,Unit:Ze,config:de}),p8=WT({BigNumber:Se,Unit:Ze,config:de}),h8=$B({BigNumber:Se,Unit:Ze,config:de}),d8=SB({BigNumber:Se,Unit:Ze,config:de}),g8=vB({BigNumber:Se,Unit:Ze,config:de}),y8=nB({BigNumber:Se,Unit:Ze,config:de}),b8=zB({BigNumber:Se,Unit:Ze,config:de}),x8=IB({BigNumber:Se,Unit:Ze,config:de}),w8=PB({BigNumber:Se,Unit:Ze,config:de}),N8=fB({BigNumber:Se,Unit:Ze,config:de}),D8=JT({BigNumber:Se,Unit:Ze,config:de}),A8=hB({BigNumber:Se,Unit:Ze,config:de}),Vh=oA({DenseMatrix:Qe,Index:Zr,compareNatural:$t,size:Hr,subset:lt,typed:J}),E8=GT({BigNumber:Se,Unit:Ze,config:de}),S8=TB({BigNumber:Se,Unit:Ze,config:de}),C8=dB({BigNumber:Se,Unit:Ze,config:de}),M8=xB({BigNumber:Se,Unit:Ze,config:de}),F8=iB({BigNumber:Se,Unit:Ze,config:de}),T8=QT({BigNumber:Se,Unit:Ze,config:de}),Dt=QF({divideScalar:xr,equalScalar:nr,inv:On,matrix:Te,multiply:Sr,typed:J}),B8=sB({BigNumber:Se,Unit:Ze,config:de}),co=A4({gamma:kh,typed:J}),$8=_B({BigNumber:Se,Unit:Ze,config:de}),O8=rB({BigNumber:Se,Unit:Ze,config:de}),Gh=$E({DenseMatrix:Qe,Spa:Uh,SparseMatrix:Jt,abs:tt,addScalar:Fr,divideScalar:xr,equalScalar:nr,larger:ct,matrix:Te,multiplyScalar:Er,subtract:br,typed:J,unaryMinus:Xt}),_8=tB({BigNumber:Se,Unit:Ze,config:de}),I8=OB({BigNumber:Se,Unit:Ze,config:de}),R8=M4({add:wr,divide:Dt,factorial:co,isInteger:st,isPositive:io,multiply:Sr,typed:J}),q8=T4({factorial:co,typed:J}),z8=RB({BigNumber:Se,Unit:Ze,config:de}),P8=pB({BigNumber:Se,Unit:Ze,config:de}),L8=FB({BigNumber:Se,Unit:Ze,config:de}),Hh=Z4({bignumber:Ft,addScalar:Fr,combinations:no,divideScalar:xr,factorial:co,isInteger:st,isNegative:ua,larger:ct,multiplyScalar:Er,number:mn,pow:Yt,subtract:br,typed:J}),U8=X2({Unit:Ze,typed:J}),k8=W4({addScalar:Fr,isInteger:st,isNegative:ua,stirlingS2:Hh,typed:J}),Zh=GF({abs:tt,add:wr,addScalar:Fr,atan:vh,bignumber:Ft,column:Ph,complex:ao,config:de,cos:Cs,diag:Dh,divideScalar:xr,dot:lo,equal:Nt,flatten:Ja,im:hh,inv:On,larger:ct,matrix:Te,matrixFromColumns:Sh,multiply:Sr,multiplyScalar:Er,number:mn,qr:Fh,re:gh,sin:Es,smaller:ut,sqrt:Wt,subtract:br,typed:J,usolve:Os,usolveAll:$h}),V8=uB({BigNumber:Se,Unit:Ze,config:de}),G8=gp({add:wr,divide:Dt,typed:J}),H8=CB({BigNumber:Se,Unit:Ze,config:de}),Z8=ZT({BigNumber:Se,Unit:Ze,config:de}),Jh=dA({Index:Zr,concat:Fs,setDifference:Lh,size:Hr,subset:lt,typed:J}),Is=wp({add:wr,apply:Ss,divide:Dt,isNaN:Za,multiply:Sr,subtract:br,typed:J}),J8=oB({BigNumber:Se,Unit:Ze,config:de}),W8=oS({DenseMatrix:Qe,lsolve:Eh,lup:Gh,matrix:Te,slu:Th,typed:J,usolve:Os}),Wh=s4({add:wr,compare:fa,divide:Dt,partitionSelect:Bs,typed:J}),X8=yA({Index:Zr,concat:Fs,setIntersect:Vh,setSymDifference:Jh,size:Hr,subset:lt,typed:J}),Y8=Dp({map:la,sqrt:Wt,typed:J,variance:Is}),Q8=EB({BigNumber:Se,Unit:Ze,config:de}),K8=l4({abs:tt,map:la,median:Wh,subtract:br,typed:J}),Xh=AA({abs:tt,add:wr,conj:sa,ctranspose:Ts,eigs:Zh,equalScalar:nr,larger:ct,matrix:Te,multiply:Sr,pow:Yt,smaller:ut,sqrt:Wt,typed:J}),Yh=ww({BigNumber:Se,DenseMatrix:Qe,SparseMatrix:Jt,addScalar:Fr,config:de,cos:Cs,matrix:Te,multiplyScalar:Er,norm:Xh,sin:Es,typed:J,unaryMinus:Xt}),j8=S4({divide:Dt,dotDivide:oo,isNumeric:$n,log:_s,map:la,matrix:Te,multiply:Sr,sum:Bh,typed:J}),e6=bw({multiply:Sr,rotationMatrix:Yh,typed:J}),r6=qB({BigNumber:Se,Unit:Ze,config:de}),va={},pa={},Qh={},Jr=_A({mathWithTransform:pa}),ha=oE({Node:Jr}),Qt=uE({Node:Jr}),_n=cE({Node:Jr}),Kh=pE({Node:Jr}),da=zA({Node:Jr}),jh=GA({Node:Jr,ResultSet:ch}),ed=ZA({Node:Jr}),vn=eE({Node:Jr}),rd=mE({Node:Jr}),t6=NT({classes:Qh}),Rs=mS({math:va,typed:J}),td=tE({Node:Jr,typed:J}),n6=OF({Chain:Rs,typed:J}),ga=RA({Node:Jr,subset:lt}),nd=kA({matrix:Te,Node:Jr,subset:lt}),ya=aE({Node:Jr,size:Hr}),pn=gE({Unit:Ze,Node:Jr,math:va}),hn=bE({Node:Jr,SymbolNode:pn,math:va}),ft=wE({AccessorNode:ga,ArrayNode:da,AssignmentNode:nd,BlockNode:jh,ConditionalNode:ed,ConstantNode:vn,FunctionAssignmentNode:td,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,RangeNode:rd,RelationalNode:Kh,SymbolNode:pn,config:de,numeric:wt,typed:J}),ad=vT({ConstantNode:vn,FunctionNode:hn,OperatorNode:Qt,ParenthesisNode:_n,parse:ft,typed:J}),qs=uT({bignumber:Ft,fraction:ca,AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,SymbolNode:pn,config:de,mathWithTransform:pa,matrix:Te,parse:ft,typed:J}),a6=DE({parse:ft,typed:J}),id=lS({parse:ft}),i6=eT({parse:ft,typed:J}),zs=cT({AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,add:wr,divide:Dt,equal:Nt,isZero:Tt,multiply:Sr,parse:ft,pow:Yt,subtract:br,typed:J}),Ps=EE({parse:ft,typed:J}),o6=BF({Help:id,mathWithTransform:pa,typed:J}),od=ME({evaluate:Ps}),s6=TE({Parser:od,typed:J}),fo=iT({bignumber:Ft,fraction:ca,AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,add:wr,config:de,divide:Dt,equal:Nt,isZero:Tt,mathWithTransform:pa,matrix:Te,multiply:Sr,parse:ft,pow:Yt,resolve:ad,simplifyConstant:qs,simplifyCore:zs,subtract:br,typed:J}),u6=hT({OperatorNode:Qt,parse:ft,simplify:fo,typed:J}),l6=gT({ConstantNode:vn,FunctionNode:hn,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,config:de,equal:Nt,isZero:Tt,numeric:wt,parse:ft,simplify:fo,typed:J}),c6=bT({bignumber:Ft,fraction:ca,AccessorNode:ga,ArrayNode:da,ConstantNode:vn,FunctionNode:hn,IndexNode:ya,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,SymbolNode:pn,add:wr,config:de,divide:Dt,equal:Nt,isZero:Tt,mathWithTransform:pa,matrix:Te,multiply:Sr,parse:ft,pow:Yt,simplify:fo,simplifyConstant:qs,simplifyCore:zs,subtract:br,typed:J});Ar(va,{e:uh,false:R$,fineStructure:q$,i:lh,Infinity:z$,LN10:P$,LOG10E:L$,NaN:U$,null:k$,phi:V$,SQRT1_2:H$,sackurTetrode:Z$,tau:fh,true:J$,E:uh,version:W$,efimovFactor:X$,LN2:Y$,pi:mh,replacer:Q$,reviver:t6,SQRT2:K$,typed:J,unaryPlus:As,PI:mh,weakMixingAngle:j$,abs:tt,acos:eO,acot:rO,acsc:tO,addScalar:Fr,arg:nO,asech:aO,asinh:iO,atan:vh,atanh:oO,bignumber:Ft,bitNot:sO,boolean:uO,clone:lO,combinations:no,complex:ao,conj:sa,cosh:cO,coth:fO,csc:mO,cube:vO,equalScalar:nr,erf:pO,exp:ph,expm1:hO,filter:dO,forEach:gO,format:Ha,getMatrixDataType:yO,hex:bO,im:hh,isInteger:st,isNegative:ua,isPositive:io,isZero:Tt,LOG2E:xO,lgamma:wO,log10:NO,log2:DO,map:la,multiplyScalar:Er,not:dh,number:mn,oct:AO,pickRandom:EO,print:SO,random:CO,re:gh,sec:MO,sign:yh,sin:Es,splitUnit:FO,square:TO,string:BO,tan:$O,typeOf:OO,acosh:_O,acsch:IO,apply:Ss,asec:RO,bin:qO,chain:n6,combinationsWithRep:zO,cos:Cs,csch:PO,isNaN:Za,isPrime:LO,randomInt:UO,sech:kO,sinh:VO,sparse:GO,sqrt:Wt,tanh:HO,unaryMinus:Xt,acoth:ZO,cot:JO,fraction:ca,isNumeric:$n,matrix:Te,matrixFromFunction:WO,mod:bh,nthRoot:XO,numeric:wt,or:YO,prod:xh,reshape:QO,size:Hr,smaller:ut,squeeze:KO,subset:lt,subtract:br,to:jO,transpose:Ms,xgcd:wh,zeros:Bt,and:e5,bitAnd:r5,bitXor:t5,cbrt:n5,compare:fa,compareText:Nh,concat:Fs,count:a5,ctranspose:Ts,diag:Dh,divideScalar:xr,dotDivide:oo,equal:Nt,fft:Ah,flatten:Ja,gcd:i5,hasNumericValue:o5,hypot:s5,ifft:u5,kron:l5,largerEq:so,leftShift:c5,lsolve:Eh,matrixFromColumns:Sh,min:f5,mode:m5,nthRoots:v5,ones:p5,partitionSelect:Bs,resize:h5,rightArithShift:d5,round:uo,smallerEq:$s,unequal:g5,usolve:Os,xor:y5,add:wr,atan2:b5,bitOr:x5,catalan:w5,compareNatural:$t,cumsum:N5,deepEqual:Ch,diff:D5,dot:lo,equalText:A5,floor:Mh,identity:ma,invmod:E5,larger:ct,log:_s,lsolveAll:S5,matrixFromRows:C5,multiply:Sr,qr:Fh,range:Wa,rightLogShift:M5,setSize:F5,slu:Th,sum:Bh,trace:T5,usolveAll:$h,asin:B5,ceil:Oh,composition:$5,cross:O5,det:_h,distance:_5,dotMultiply:I5,fix:Rh,intersect:R5,lcm:q5,log1p:z5,max:zh,quantileSeq:P5,row:L5,setCartesian:U5,setDistinct:k5,setIsSubset:V5,setPowerset:G5,sort:H5,column:Ph,index:Z5,inv:On,pinv:J5,pow:Yt,setDifference:Lh,setMultiplicity:W5,sqrtm:X5,vacuumImpedance:Y5,wienDisplacement:Q5,atomicMass:K5,bohrMagneton:j5,boltzmann:e8,conductanceQuantum:r8,createUnit:t8,deuteronMass:n8,dotPow:a8,electricConstant:i8,elementaryCharge:o8,expm:s8,faraday:u8,firstRadiation:l8,gamma:kh,gravitationConstant:c8,hartreeEnergy:f8,klitzing:m8,loschmidt:v8,magneticConstant:p8,molarMass:h8,molarPlanckConstant:d8,neutronMass:g8,nuclearMagneton:y8,planckCharge:b8,planckLength:x8,planckTemperature:w8,protonMass:N8,reducedPlanckConstant:D8,rydberg:A8,setIntersect:Vh,speedOfLight:E8,stefanBoltzmann:S8,thomsonCrossSection:C8,avogadro:M8,bohrRadius:F8,coulomb:T8,divide:Dt,electronMass:B8,factorial:co,gravity:$8,inverseConductanceQuantum:O8,lup:Gh,magneticFluxQuantum:_8,molarMassC12:I8,multinomial:R8,parse:ft,permutations:q8,planckMass:z8,quantumOfCirculation:P8,resolve:ad,secondRadiation:L8,simplifyConstant:qs,stirlingS2:Hh,unit:U8,bellNumbers:k8,compile:a6,eigs:Zh,fermiCoupling:V8,leafCount:i6,mean:G8,molarVolume:H8,planckConstant:Z8,setSymDifference:Jh,simplifyCore:zs,variance:Is,classicalElectronRadius:J8,evaluate:Ps,help:o6,lusolve:W8,median:Wh,setUnion:X8,std:Y8,gasConstant:Q8,mad:K8,parser:s6,simplify:fo,symbolicEqual:u6,derivative:l6,norm:Xh,rationalize:c6,rotationMatrix:Yh,kldivergence:j8,rotate:e6,planckTime:r6,config:de}),Ar(pa,va,{filter:WB({typed:J}),forEach:QB({typed:J}),map:n$({typed:J}),apply:kB({isInteger:st,typed:J}),diff:S$({bignumber:Ft,matrix:Te,number:mn,subtract:br,typed:J}),subset:w$({matrix:Te,typed:J}),concat:A$({isInteger:st,matrix:Te,typed:J}),max:o$({config:de,larger:ct,numeric:wt,typed:J}),min:m$({config:de,numeric:wt,smaller:ut,typed:J}),range:h$({bignumber:Ft,matrix:Te,config:de,larger:ct,largerEq:so,smaller:ut,smallerEq:$s,typed:J}),sum:B$({add:wr,config:de,numeric:wt,typed:J}),cumsum:O$({add:wr,typed:J,unaryPlus:As}),row:y$({Index:Zr,matrix:Te,range:Wa,typed:J}),column:HB({Index:Zr,matrix:Te,range:Wa,typed:J}),index:e$({Index:Zr}),mean:l$({add:wr,divide:Dt,typed:J}),variance:I$({add:wr,apply:Ss,divide:Dt,isNaN:Za,multiply:Sr,subtract:br,typed:J}),std:F$({map:la,sqrt:Wt,typed:J,variance:Is})}),Ar(Qh,{BigNumber:Se,Complex:yr,Fraction:Bn,Matrix:to,Node:Jr,ObjectNode:ha,OperatorNode:Qt,ParenthesisNode:_n,Range:G$,RelationalNode:Kh,ResultSet:ch,ArrayNode:da,BlockNode:jh,ConditionalNode:ed,ConstantNode:vn,DenseMatrix:Qe,RangeNode:rd,Chain:Rs,FunctionAssignmentNode:td,SparseMatrix:Jt,AccessorNode:ga,AssignmentNode:nd,IndexNode:ya,FibonacciHeap:Ih,ImmutableDenseMatrix:qh,Index:Zr,Spa:Uh,Unit:Ze,SymbolNode:pn,FunctionNode:hn,Help:id,Parser:od}),Rs.createProxy(va);/**
|
|
71
72
|
* @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
|
*
|
|
73
|
-
* @version 5.
|
|
74
|
+
* @version 5.2.0
|
|
74
75
|
* @license MIT
|
|
75
76
|
* @author GreenImp Media <info@greenimp.co.uk> (http://greenimp.co.uk)
|
|
76
77
|
* @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
|
+
*/class Ls extends TypeError{constructor(e){super(`Operator "${e}" is invalid`),TypeError.captureStackTrace&&TypeError.captureStackTrace(this,Ls),this.name="CompareOperatorError",this.operator=e}}class Us extends Error{constructor(e){super(`Invalid data format: ${e}`),Error.captureStackTrace&&Error.captureStackTrace(this,Us),this.name="ImportError",this.data=e}}class mo 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,mo),this.name="DieActionValueError",this.action=t,this.die=e}}class vo extends Error{constructor(e){super(`Notation "${e}" is invalid`),Error.captureStackTrace&&Error.captureStackTrace(this,vo),this.name="NotationError",this.notation=e}}class Ot extends Error{constructor(e=null){super(`Missing argument${e?` "${e}"`:""}`),Error.captureStackTrace&&Error.captureStackTrace(this,Ot),this.argumentName=e}}const f6=(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},sd=r=>Ps(r),Cr=r=>typeof r!="number"&&typeof r!="string"?!1:!Number.isNaN(r)&&Number.isFinite(Number(r)),ks=r=>{if(!Cr(r))return!1;const e=Number(r);return e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER},m6=r=>Array.isArray(r)?r.reduce((e,t)=>e+(Cr(t)?parseFloat(`${t}`):0),0):0,v6=(r,e=0)=>parseFloat(parseFloat(`${r}`).toFixed(e||0)),$r=9007199254740992,Xa=$r-1,po=-1>>>0,mt=po+1,Kt=mt/2,Vs=Kt-1,Ya=1<<21,In=Ya-1;function Gs(r){return r.next()|0}function dn(r,e){return e===0?r:t=>r(t)+e}function Hs(r){const e=r.next()|0,t=r.next()>>>0;return(e&In)*mt+t+(e&Ya?-$r:0)}function ud(r){for(;;){const e=r.next()|0;if(e&4194304){if((e&8388607)===4194304&&(r.next()|0)===0)return $r}else{const t=r.next()>>>0;return(e&In)*mt+t+(e&Ya?-$r:0)}}}function ld(r){return r.next()>>>0}function ho(r){const e=r.next()&In,t=r.next()>>>0;return e*mt+t}function Zs(r){for(;;){const e=r.next()|0;if(e&Ya){if((e&In)===0&&(r.next()|0)===0)return $r}else{const t=r.next()>>>0;return(e&In)*mt+t}}}function cd(r){return(r+1&r)===0}function p6(r){return e=>e.next()&r}function h6(r){const e=r+1,t=e*Math.floor(mt/e);return a=>{let n=0;do n=a.next()>>>0;while(n>=t);return n%e}}function d6(r){return cd(r)?p6(r):h6(r)}function g6(r){return(r|0)===0}function y6(r){return e=>{const t=e.next()&r,a=e.next()>>>0;return t*mt+a}}function b6(r){const e=r*Math.floor($r/r);return t=>{let a=0;do{const n=t.next()&In,i=t.next()>>>0;a=n*mt+i}while(a>=e);return a%r}}function x6(r){const e=r+1;if(g6(e)){const t=(e/mt|0)-1;if(cd(t))return y6(t)}return b6(e)}function fd(r,e){return t=>{let a=0;do{const n=t.next()|0,i=t.next()>>>0;a=(n&In)*mt+i+(n&Ya?-$r:0)}while(a<r||a>e);return a}}function Rn(r,e){if(r=Math.floor(r),e=Math.floor(e),r<-$r||!isFinite(r))throw new RangeError(`Expected min to be at least ${-$r}`);if(e>$r||!isFinite(e))throw new RangeError(`Expected max to be at most ${$r}`);const t=e-r;return t<=0||!isFinite(t)?()=>r:t===po?r===0?ld:dn(Gs,r+Kt):t<po?dn(d6(t),r):t===Xa?dn(ho,r):t<Xa?dn(x6(t),r):e-1-r===Xa?dn(Zs,r):r===-$r&&e===$r?ud:r===-$r&&e===Xa?Hs:r===-Xa&&e===$r?dn(Hs,1):e===$r?dn(fd(r-1,e-1),1):fd(r,e)}function w6(r){return(r.next()&1)===1}function Js(r,e){return t=>r(t)<e}function N6(r){if(r<=0)return()=>!1;if(r>=1)return()=>!0;{const e=r*mt;return e%1===0?Js(Gs,e-Kt|0):Js(ho,Math.round(r*$r))}}function D6(r,e){return e==null?r==null?w6:N6(r):r<=0?()=>!1:r>=e?()=>!0:Js(Rn(0,e-1),r)}function A6(r,e){const t=Rn(+r,+e);return a=>new Date(t(a))}function md(r){return Rn(1,r)}function E6(r,e){const t=md(r);return a=>{const n=[];for(let i=0;i<e;++i)n.push(t(a));return n}}const S6="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";function Ws(r=S6){const e=r.length;if(!e)throw new Error("Expected pool not to be an empty string");const t=Rn(0,e-1);return(a,n)=>{let i="";for(let s=0;s<n;++s){const f=t(a);i+=r.charAt(f)}return i}}const vd="0123456789abcdef",C6=Ws(vd),M6=Ws(vd.toUpperCase());function F6(r){return r?M6:C6}function pd(r,e){return r<0?Math.max(r+e,0):Math.min(r,e)}function hd(r){const e=+r;return e<0?Math.ceil(e):Math.floor(e)}function T6(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:pd(hd(t),n),s=a===void 0?n:pd(hd(a),n);if(i>=s)throw new RangeError(`Cannot pick between bounds ${i} and ${s}`);const f=Rn(i,s-1);return e[f(r)]}function B6(r,e){return e===1?r:e===0?()=>0:t=>r(t)*e}function dd(r){return ho(r)/$r}function gd(r){return Zs(r)/$r}function $6(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 dn(B6(t?gd:dd,e-r),r)}const O6=Array.prototype.slice;function Xs(r,e,t=0){const a=e.length;if(a)for(let n=a-1>>>0;n>t;--n){const s=Rn(0,n)(r);if(n!==s){const f=e[n];e[n]=e[s],e[s]=f}}return e}function _6(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=O6.call(e),n=a.length;if(n===t)return Xs(r,a,0);const i=n-t;return Xs(r,a,i-1).slice(i)}const I6=(()=>{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 ba(r,e){return I6("0",e-r.length)+r}function R6(r){const e=r.next()>>>0,t=r.next()|0,a=r.next()|0,n=r.next()>>>0;return ba(e.toString(16),8)+"-"+ba((t&65535).toString(16),4)+"-"+ba((t>>4&4095|16384).toString(16),4)+"-"+ba((a&16383|32768).toString(16),4)+"-"+ba((a>>4&65535).toString(16),4)+ba(n.toString(16),8)}const xa={next(){return Math.random()*mt|0}};class q6{constructor(e=xa){this.engine=e}int32(){return Gs(this.engine)}uint32(){return ld(this.engine)}uint53(){return ho(this.engine)}uint53Full(){return Zs(this.engine)}int53(){return Hs(this.engine)}int53Full(){return ud(this.engine)}integer(e,t){return Rn(e,t)(this.engine)}realZeroToOneInclusive(){return gd(this.engine)}realZeroToOneExclusive(){return dd(this.engine)}real(e,t,a=!1){return $6(e,t,a)(this.engine)}bool(e,t){return D6(e,t)(this.engine)}pick(e,t,a){return T6(this.engine,e,t,a)}shuffle(e){return Xs(this.engine,e)}sample(e,t){return _6(this.engine,e,t)}die(e){return md(e)(this.engine)}dice(e,t){return E6(e,t)(this.engine)}uuid4(){return R6(this.engine)}string(e,t){return Ws(t)(this.engine,e)}hex(e,t){return F6(t)(this.engine,e)}date(e,t){return A6(e,t)(this.engine)}}const yd=(()=>{try{const r=new ArrayBuffer(4),e=new Int32Array(r);if(e[0]=Kt,e[0]===-Kt)return Int32Array}catch{}return Array})();let go=null;const Ys=128;let Qs=Ys;const z6={next(){return Qs>=Ys&&(go===null&&(go=new yd(Ys)),crypto.getRandomValues(go),Qs=0),go[Qs++]|0}};function P6(r=xa,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 Ks=(()=>{try{if(Math.imul(po,5)===-5)return Math.imul}catch{}const r=65535;return(e,t)=>{const a=e>>>16&r,n=e&r,i=t>>>16&r,s=t&r;return n*s+(a*s+n*i<<16>>>0)|0}})(),_t=624,gn=_t-1,js=397,bd=_t-js,eu=2567483615;class Qa{constructor(){this.data=new yd(_t),this.index=0,this.uses=0}static seed(e){return new Qa().seed(e)}static seedWithArray(e){return new Qa().seedWithArray(e)}static autoSeed(){return Qa.seedWithArray(P6())}next(){(this.index|0)>=_t&&(ru(this.data),this.index=0);const e=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,L6(e)|0}getUseCount(){return this.uses}discard(e){if(e<=0)return this;for(this.uses+=e,(this.index|0)>=_t&&(ru(this.data),this.index=0);e+this.index>_t;)e-=_t-this.index,ru(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<_t;a=a+1|0)this.data[a]=t=Ks(t^t>>>30,1812433253)+a|0;return this.index=_t,this.uses=0,this}seedWithArray(e){return this.seed(19650218),U6(this.data,e),this}}function ru(r){let e=0,t=0;for(;(e|0)<bd;e=e+1|0)t=r[e]&Kt|r[e+1|0]&Vs,r[e]=r[e+js|0]^t>>>1^(t&1?eu:0);for(;(e|0)<gn;e=e+1|0)t=r[e]&Kt|r[e+1|0]&Vs,r[e]=r[e-bd|0]^t>>>1^(t&1?eu:0);t=r[gn]&Kt|r[0]&Vs,r[gn]=r[js-1]^t>>>1^(t&1?eu:0)}function L6(r){return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^r>>>18}function U6(r,e){let t=1,a=0;const n=e.length;let i=Math.max(n,_t)|0,s=r[0]|0;for(;(i|0)>0;--i)r[t]=s=(r[t]^Ks(s^s>>>30,1664525))+(e[a]|0)+(a|0)|0,t=t+1|0,++a,(t|0)>gn&&(r[0]=r[gn],t=1),a>=n&&(a=0);for(i=gn;(i|0)>0;--i)r[t]=s=(r[t]^Ks(s^s>>>30,1566083941))-t|0,t=t+1|0,(t|0)>gn&&(r[0]=r[gn],t=1);r[0]=Kt}let xd=null;const tu=128;let nu=tu;const k6={next(){return nu>=tu&&(xd=new Int32Array(new Int8Array(require("crypto").randomBytes(4*tu)).buffer),nu=0),xd[nu++]|0}},Ka=Symbol("engine"),au=Symbol("random"),wd={browserCrypto:z6,nodeCrypto:k6,MersenneTwister19937:Qa,nativeMath:xa,min:{next(){return 0}},max:{range:[],next(){return this.range[1]-this.range[0]}}};class V6{constructor(e=xa){this.engine=e||xa}get engine(){return this[Ka]}set engine(e){if(e&&typeof e.next!="function")throw new TypeError("engine must have function `next()`");this[Ka]=e||xa,this[au]=new q6(this[Ka])}integer(e,t){return this[Ka].range=[e,t],this[au].integer(e,t)}real(e,t,a=!1){return this[Ka].range=[e,t],this[au].real(e,t,a)}}const wa=new V6,Nd=Symbol("operator"),Dd=Symbol("value");class ja{constructor(e,t){if(e){if(!t&&t!==0)throw new Ot("value")}else throw new Ot("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 Ls(e);this[Nd]=e}get operator(){return this[Nd]}set value(e){if(!Cr(e))throw new TypeError("value must be a finite number");this[Dd]=Number(e)}get value(){return this[Dd]}isMatch(e){return f6(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 yn{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 Ad=Symbol("compare-point");class ei extends yn{constructor(e){super(),e&&(this.comparePoint=e)}get comparePoint(){return this[Ad]}set comparePoint(e){if(!(e instanceof ja))throw new TypeError("comparePoint must be instance of ComparePoint");this[Ad]=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 Ed=Symbol("compound"),Sd=Symbol("penetrate");class Cd extends ei{constructor(e=null,t=!1,a=!1){super(e),this[Ed]=!!t,this[Sd]=!!a,this.order=3}get compound(){return this[Ed]}get name(){return"explode"}get notation(){return`!${this.compound?"!":""}${this.penetrate?"p":""}${super.notation}`}get penetrate(){return this[Sd]}run(e,t){if(t.min===t.max)throw new mo(t,"explode");const a=e;return a.rolls=e.rolls.map(n=>{const i=[n];let s=n.value;for(let f=0;f<this.maxIterations&&this.isComparePoint(s);f++){const l=i[i.length-1],u=t.rollOnce();s=u.value,l.modifiers.add("explode"),this.penetrate&&(l.modifiers.add("penetrate"),u.value-=1),i.push(u)}return this.compound&&i.length>1?(n.value=m6(i.map(f=>f.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 Md=Symbol("text"),Fd=Symbol("type");class At{constructor(e,t=this.constructor.types.INLINE){this.text=e,this.type=t}get text(){return this[Md]}set text(e){if(typeof e=="object")throw new TypeError("Description text is invalid");if(!e&&e!==0||`${e}`.trim()==="")throw new TypeError("Description text cannot be empty");this[Md]=`${e}`.trim()}get type(){return this[Fd]}set type(e){const t=Object.values(this.constructor.types);if(typeof e!="string")throw new TypeError("Description type must be a string");if(!t.includes(e))throw new RangeError(`Description type must be one of; ${t.join(", ")}`);this[Fd]=e}toJSON(){const{text:e,type:t}=this;return{text:e,type:t}}toString(){return this.type===this.constructor.types.INLINE?`# ${this.text}`:`[${this.text}]`}}u0(At,"types",{MULTILINE:"multiline",INLINE:"inline"});const yo=Symbol("description");class Td{constructor(e=null){this.description=e}get description(){return this[yo]||null}set description(e){if(!e&&e!==0)this[yo]=null;else if(e instanceof At)this[yo]=e;else if(typeof e=="string")this[yo]=new At(e);else throw new TypeError(`description must be of type Description, string or null. Received ${typeof e}`)}toJSON(){const{description:e}=this;return{description:e}}toString(){return this.description?`${this.description}`:""}}const G6={compound:"!",explode:"!","critical-failure":"__","critical-success":"**",drop:"d",max:"v",min:"^",penetrate:"p","re-roll":"r","re-roll-once":"ro","target-failure":"_","target-success":"*"},Bd=(...r)=>[...r].reduce((e,t)=>{let a;return t instanceof yn?a=t.name:a=t,e+(G6[a]||a)},""),iu=Symbol("calculation-value"),ou=Symbol("modifiers"),ri=Symbol("initial-value"),$d=Symbol("use-in-total"),su=Symbol("value");class bo{constructor(e,t=[],a=!0){if(Cr(e))this[ri]=Number(e),this.modifiers=t||[],this.useInTotal=a;else if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Cr(e.initialValue)?e.initialValue:e.value;if(!Cr(n))throw new TypeError(`Result value is invalid: ${n}`);this[ri]=Number(n),Cr(e.value)&&Number(e.value)!==this[ri]&&(this.value=e.value),Cr(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 Cr(this[iu])?parseFloat(this[iu]):this.value}set calculationValue(e){const t=Cr(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[iu]=t?parseFloat(`${e}`):null}get initialValue(){return this[ri]}get modifierFlags(){return Bd(...this.modifiers)}get modifiers(){return this[ou]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string")){this[ou]=new Set([...e]);return}if(!e&&e!==0){this[ou]=new Set;return}throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get useInTotal(){return!!this[$d]}set useInTotal(e){this[$d]=!!e}get value(){return Cr(this[su])?this[su]:this[ri]}set value(e){if(e===1/0)throw new RangeError("Result value must be a finite number");if(!Cr(e))throw new TypeError(`Result value is invalid: ${e}`);this[su]=Number(e)}toJSON(){const{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:n,useInTotal:i,value:s}=this;return{calculationValue:e,initialValue:t,modifierFlags:a,modifiers:[...n],type:"result",useInTotal:i,value:s}}toString(){return this.value+this.modifierFlags}}const uu=Symbol("rolls");class jt{constructor(e=[]){this.rolls=e}get length(){return this.rolls.length||0}get rolls(){return[...this[uu]]}set rolls(e){if(!e||!Array.isArray(e))throw new TypeError(`rolls must be an array: ${e}`);this[uu]=[],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 bo?e:new bo(e);this[uu].push(t)}toJSON(){const{rolls:e,value:t}=this;return{rolls:e,type:"roll-results",value:t}}toString(){return`[${this.rolls.join(", ")}]`}}const Od=Symbol("once");class _d extends ei{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[Od]}set once(e){this[Od]=!!e}run(e,t){if(t.min===t.max)throw new mo(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 xo=Symbol("modifiers"),Id=Symbol("qty"),Rd=Symbol("sides"),qd=Symbol("min-value"),zd=Symbol("max-value");class Na extends Td{constructor(e,t=1,a=null,n=1,i=null,s=null){if(super(s),!e&&e!==0)throw new Ot("sides");if(e===1/0)throw new RangeError("numerical sides must be finite number");if(Cr(e)){if(e<1||!ks(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(Cr(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");let f=n;if(f==null)f=1;else if(Cr(f)){if(!ks(f))throw new RangeError("min must a finite number")}else throw new TypeError("min must a finite number");if(i&&!Cr(i))throw new TypeError("max must a finite number");if(i&&!ks(i))throw new RangeError("max must a finite number");this[Id]=parseInt(`${t}`,10),this[Rd]=e,a&&(this.modifiers=a),this[qd]=parseInt(f,10),this[zd]=i?parseInt(`${i}`,10):e}get average(){return(this.min+this.max)/2}get modifiers(){return this[xo]?new Map([...this[xo]].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 yn)))throw new TypeError("modifiers must only contain Modifier instances");this[xo]=t,this[xo].forEach(a=>{a instanceof Cd&&!a.comparePoint?a.comparePoint=new ja("=",this.max):a instanceof _d&&!a.comparePoint&&(a.comparePoint=new ja("=",this.min))})}get max(){return this[zd]}get min(){return this[qd]}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[Id]}get sides(){return this[Rd]}roll(){const e=new jt;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 bo(wa.integer(this.min,this.max))}toJSON(){const{average:e,max:t,min:a,modifiers:n,name:i,notation:s,qty:f,sides:l}=this;return Object.assign(super.toJSON(),{average:e,max:t,min:a,modifiers:n,name:i,notation:s,qty:f,sides:l,type:"die"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}class H6 extends Na{constructor(e=2,t=1,a=null,n=null){let i=e;if(!i&&i!==0)i=2;else if(i!==1&&i!==2)throw new RangeError("nonBlanks must be 1 or 2");super(i,t,a,-1,1,n)}get name(){return"fudge"}get nonBlanks(){return super.sides}get sides(){return`F.${this.nonBlanks}`}rollOnce(){let e=0;if(this.nonBlanks===2)e=wa.integer(1,3)-2;else if(this.nonBlanks===1){const t=wa.integer(1,6);t===1?e=-1:t===6&&(e=1)}return new bo(e)}}class Z6 extends Na{constructor(e=1,t=null,a=!1,n=null){super(100,e,t,null,null,n),this.sidesAsNumber=!!a}get name(){return"percentile"}get sides(){return this.sidesAsNumber?super.sides:"%"}}class J6 extends ei{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 W6 extends ei{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 lu=Symbol("calculation-value"),Pd=Symbol("is-roll-group"),cu=Symbol("modifiers"),fu=Symbol("results"),Ld=Symbol("use-in-total");class Ur{constructor(e=[],t=[],a=!1,n=!0){this.isRollGroup=a,this.modifiers=t,this.results=e,this.useInTotal=n}get calculationValue(){return Cr(this[lu])?parseFloat(this[lu]):this.value}set calculationValue(e){const t=Cr(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[lu]=t?parseFloat(`${e}`):null}get isRollGroup(){return this[Pd]}set isRollGroup(e){this[Pd]=!!e}get length(){return this.results.length||0}get modifierFlags(){return Bd(...this.modifiers)}get modifiers(){return this[cu]}set modifiers(e){if((Array.isArray(e)||e instanceof Set)&&[...e].every(t=>typeof t=="string"))this[cu]=new Set([...e]);else if(!e&&e!==0)this[cu]=new Set;else throw new TypeError(`modifiers must be a Set or array of modifier names: ${e}`)}get results(){return[...this[fu]]}set results(e){if(!e||!Array.isArray(e))throw new TypeError(`results must be an array: ${e}`);this[fu]=[],e.forEach(t=>{this.addResult(t)})}get useInTotal(){return!!this[Ld]}set useInTotal(e){this[Ld]=!!e}get value(){if(!this.results.length)return 0;const e=this.results.reduce((t,a)=>{let n=a;return a instanceof Ur?n=a.useInTotal?a.calculationValue:0:a instanceof jt&&(n=a.value),t+n},typeof this.results[0]=="string"?"":0);return typeof e=="string"?sd(e):e}addResult(e){let t;if(e instanceof Ur||e instanceof jt)t=e;else if(typeof e=="string"||Cr(e))t=e;else throw new TypeError("value must be one of ResultGroup, RollResults, string, or number");this[fu].push(t)}toJSON(){const{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:n,results:i,useInTotal:s,value:f}=this;return{calculationValue:e,isRollGroup:t,modifierFlags:a,modifiers:[...n],results:i,type:"result-group",useInTotal:s,value:f}}toString(){let e;return this.isRollGroup?e=`{${this.results.join(", ")}}`:e=this.results.join(""),this.modifierFlags&&(e=`(${e})${this.modifierFlags}`),e}}const Ud=Symbol("end"),kd=Symbol("qty");class Vd extends yn{constructor(e="h",t=1){super(),this.end=e,this.qty=t,this.order=5}get end(){return this[Ud]}set end(e){if(e!=="h"&&e!=="l")throw new RangeError('End must be "h" or "l"');this[Ud]=e}get name(){return`keep-${this.end}`}get notation(){return`k${this.end}${this.qty}`}get qty(){return this[kd]}set qty(e){if(e===1/0)throw new RangeError("qty must be a finite number");if(!Cr(e)||e<1)throw new TypeError("qty must be a positive finite integer");this[kd]=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 Ur?(a=e.results,a.length===1&&a[0]instanceof Ur?n=a[0].results.map((i,s)=>i instanceof jt?i.rolls.map((f,l)=>({value:f.value,index:[s,l]})):null).flat().filter(Boolean):n=[...a].map((i,s)=>({value:i.value,index:s}))):(a=e.rolls,n=[...a].map((i,s)=>({value:i.value,index:s}))),n=n.sort((i,s)=>i.value-s.value).map(i=>i.index).slice(...this.rangeToDrop(n)),n.forEach(i=>{let s;Array.isArray(i)?s=a[0].results[i[0]].rolls[i[1]]:s=a[i],s.modifiers.add("drop"),s.useInTotal=!1}),e}toJSON(){const{end:e,qty:t}=this;return Object.assign(super.toJSON(),{end:e,qty:t})}}class X6 extends Vd{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 Gd=Symbol("max");class Y6 extends yn{constructor(e){super(),this.max=e,this.order=2}get max(){return this[Gd]}set max(e){if(!Cr(e))throw new TypeError("max must be a number");this[Gd]=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 Hd=Symbol("min");class Q6 extends yn{constructor(e){super(),this.min=e,this.order=1}get min(){return this[Hd]}set min(e){if(!Cr(e))throw new TypeError("min must be a number");this[Hd]=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 Zd=Symbol("direction");class K6 extends yn{constructor(e="a"){super(),this.direction=e,this.order=10}get direction(){return this[Zd]}set direction(e){if(e!=="a"&&e!=="d")throw new RangeError('Direction must be "a" (Ascending) or "d" (Descending)');this[Zd]=e}get name(){return"sorting"}get notation(){return`s${this.direction}`}run(e,t){let a;return e instanceof Ur?a="results":a="rolls",e[a]=e[a].sort((n,i)=>this.direction==="d"?i.value-n.value:n.value-i.value),e instanceof Ur&&(e[a]=e[a].map(n=>n instanceof Ur||n instanceof jt?this.run(n,t):n)),e}toJSON(){const{direction:e}=this;return Object.assign(super.toJSON(),{direction:e})}}const Jd=Symbol("failure-cp");class j6 extends ei{constructor(e,t=null){super(e),this.failureComparePoint=t,this.order=7}get failureComparePoint(){return this[Jd]}set failureComparePoint(e){if(e&&!(e instanceof ja))throw new TypeError("failure comparePoint must be instance of ComparePoint or null");this[Jd]=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 Ur?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 e9=r=>{try{return!!(r&&btoa(atob(r))===r)}catch{return!1}},r9=r=>{try{const e=r?JSON.parse(r):!1;return!!(e&&typeof e=="object")}catch{return!1}},mu=Symbol("expressions"),vu=Symbol("modifiers");class Wd extends Td{constructor(e=[],t=[],a=null){super(a),this.expressions=e,this.modifiers=t}get expressions(){return[...this[mu]||[]]}set expressions(e){if(!e)throw new Ot("expressions");if(!Array.isArray(e))throw new TypeError(`expressions must be an array: ${e}`);this[mu]=[],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 Na||typeof a=="string"||typeof a=="number"))throw new TypeError("Sub expression items must be Dice, numbers, or strings");this[mu].push(t)})}get modifiers(){return this[vu]?new Map([...this[vu]].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 yn)))throw new TypeError("modifiers must only contain Modifier instances");this[vu]=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 Ur(this.expressions.map(t=>{const a=t.map(n=>n instanceof Na?n.roll():n);return new Ur(a)}));return e.isRollGroup=!0,(this.modifiers||[]).forEach(t=>{t.run(e,this)}),e}toJSON(){const{modifiers:e,notation:t,expressions:a}=this;return Object.assign(super.toJSON(),{expressions:a,modifiers:e,notation:t,type:"group"})}toString(){return`${this.notation}${this.description?` ${this.description}`:""}`}}function t9(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function Da(r,e,t,a){var n=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(n,Da.prototype),n.expected=e,n.found=t,n.location=a,n.name="SyntaxError",n}t9(Da,Error);function pu(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}Da.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 s=this.location.end,f=pu("",n.line.toString().length," "),l=t[n.line-1],u=n.line===s.line?s.column:l.length+1,o=u-n.column||1;e+=`
|
|
78
79
|
--> `+i+`
|
|
79
|
-
`+
|
|
80
|
-
`+n.line+" | "+
|
|
81
|
-
`+
|
|
82
|
-
at `+i}return e},
|
|
83
|
-
`,"\r"],!1,!1),qR=function(R,K,ie){return new Zh([R,...K.map(de=>de[3])],Object.assign({},...ie.map(de=>({[de.name]:de}))))},zR=function(R,K){return R.modifiers=Object.assign({},...K.map(ie=>({[ie.name]:ie}))),R},PR=function(R,K){return new ea(K,R||1)},UR=function(R){return new VI(R||1)},LR=function(R,K){return new kI(K?parseInt(K[1],10):2,R||1)},kR=function(R,K,ie){return new Oh(ie,!!R,!!K)},VR=function(R,K){return new YI(R,K)},GR=function(R,K){return new ZI(R||"l",K)},HR=function(R,K){return new Lh(R||"h",K)},ZR=function(R){return new JI(R)},JR=function(R){return new WI(R)},WR=function(R,K){return new Bh(!!R,K)},XR=function(R){return new HI(R)},YR=function(R){return new GI(R)},QR=function(R){return new XI(R||"a")},jR=function(R){return R},KR=function(R,K){return new qa(R,K)},eF=function(R,K,ie){return uh(Zs())},rF=function(R,K){return R=Array.isArray(R)?R:[R],[...R,...K.map(([,ie,,de])=>[ie,de]).flat(2)]},tF=function(R,K,ie){return[R,...K,ie]},nF=function(R,K){return[`${R}(`,...K,")"]},aF=function(R,K,ie){return[`${R}(`,...K,",",...ie,")"]},iF=function(){return parseFloat(Zs())},ed=function(){return parseInt(Zs(),10)},oF=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 sF(){return{type:"end"}}function uF(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 cF(R,K,ie){return new ra(ra.buildMessage(R,K),R,K,ie)}function nd(){var R;return R=sn(),R}function lF(){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=qR(ie,de,ur)}else G=R,R=t}else G=R,R=t;else G=R,R=t;return R}function fF(){var R,K,ie,de;if(R=G,K=mF(),K===t&&(K=pF(),K===t&&(K=vF())),K!==t){for(ie=[],de=Hi();de!==t;)ie.push(de),de=Hi();vr=R,R=zR(K,ie)}else G=R,R=t;return R}function mF(){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=PR(K,de)):(G=R,R=t)):(G=R,R=t),R}function pF(){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=UR(K)):(G=R,R=t),R}function vF(){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=LR(K,de)):(G=R,R=t),R}function Hi(){var R;return R=hF(),R===t&&(R=dF(),R===t&&(R=gF(),R===t&&(R=yF(),R===t&&(R=wF(),R===t&&(R=NF(),R===t&&(R=MF(),R===t&&(R=AF(),R===t&&(R=bF(),R===t&&(R=xF()))))))))),R}function hF(){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=kR(ie,de,Ie)):(G=R,R=t),R}function dF(){var R,K,ie;return R=G,K=ua(),K!==t?(ie=SF(),ie===t&&(ie=null),vr=R,R=VR(K,ie)):(G=R,R=t),R}function gF(){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=GR(ie,de)):(G=R,R=t)):(G=R,R=t),R}function yF(){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=HR(ie,de)):(G=R,R=t)):(G=R,R=t),R}function bF(){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=ZR(ie)):(G=R,R=t)):(G=R,R=t),R}function xF(){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=JR(ie)):(G=R,R=t)):(G=R,R=t),R}function wF(){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=WR(ie,de)):(G=R,R=t),R}function NF(){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=XR(ie)):(G=R,R=t)):(G=R,R=t),R}function MF(){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=YR(ie)):(G=R,R=t)):(G=R,R=t),R}function AF(){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=QR(ie)):(G=R,R=t),R}function SF(){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=jR(ie)):(G=R,R=t)):(G=R,R=t),R}function ua(){var R,K,ie;return R=G,K=EF(),K!==t?(ie=Sn(),ie!==t?(vr=R,R=KR(K,ie)):(G=R,R=t)):(G=R,R=t),R}function EF(){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=eF()):(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=rF(K,ie)}else G=R,R=t;return R}function Js(){var R,K,ie,de;return R=CF(),R===t&&(R=fF(),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=tF(K,ie,de)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R===t&&(R=lF())))),R}function CF(){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=nF(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(CR)),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=aF(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(OR)),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=iF()):(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($R)),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(TR)),K!==t&&(vr=R,K=oF()),R=K,R===t&&(r.charCodeAt(G)===42?(R=Ce,G++):(R=t,Ee===0&&Oe(DR)),R===t&&(r.charCodeAt(G)===94?(R=ge,G++):(R=t,Ee===0&&Oe(BR)),R===t&&(r.charCodeAt(G)===37?(R=Se,G++):(R=t,Ee===0&&Oe(_R)),R===t&&(r.charCodeAt(G)===47?(R=z,G++):(R=t,Ee===0&&Oe(IR)),R===t&&(r.charCodeAt(G)===43?(R=Y,G++):(R=t,Ee===0&&Oe(RR)),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(FR),R}if(Gi=i(),Gi!==t&&G===r.length)return Gi;throw Gi!==t&&G<r.length&&Oe(sF()),cF(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=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,tR=()=>rR()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function Bs(r){const e=he.ref(null);return e.value=`${r}${tR()}`,{id:e}}const nR=["id"],aR=["for"],iR=["for"],oR=["id","placeholder"],sR=["onClick"],uR={__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,aR)):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,iR),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,oR),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,sR)],2),i?(he.openBlock(),he.createElementBlock("span",{key:1,class:he.normalizeClass(`${r.className}-error`)},he.toDisplayString(i),3)):he.createCommentVNode("",!0)],10,nR)]),_:3},8,["notation"]))}},cR=["id"],lR=["for"],fR={class:"flex flex-col sm:flex-row gap-y-4"},mR=["for"],pR=["id","placeholder"],vR=["onClick"],hR={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},dR={__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,lR)):he.createCommentVNode("",!0),he.createElementVNode("div",fR,[he.createElementVNode("label",{for:he.unref(t),class:"sr-only"}," Notation ",8,mR),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,pR),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,vR)]),i?(he.openBlock(),he.createElementBlock("span",hR,he.toDisplayString(i),1)):he.createCommentVNode("",!0)],8,cR)]),_:3},8,["notation"]))}},gR=["id"],yR={class:"card-body"},bR=["for"],xR=["for"],wR={class:"input-group"},NR=["id","placeholder"],MR=["onClick"],AR={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"],SR=[...aa,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],Qh=[...aa,"white"],ER={__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 SR.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",yR,[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,bR)):he.createCommentVNode("",!0),he.createElementVNode("label",{for:he.unref(i),class:"form-label visually-hidden"}," Notation ",8,xR),he.createElementVNode("div",wR,[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,NR),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,MR)]),f?(he.openBlock(),he.createElementBlock("span",AR,he.toDisplayString(f),1)):he.createCommentVNode("",!0)])],10,gR)]),_:3},8,["notation"]))}};yt.DiceRoller=uR,yt.DiceRollerBootstrap=ER,yt.DiceRollerRenderless=Li,yt.DiceRollerTailwind=dR,Object.defineProperties(yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
80
|
+
`+f+` |
|
|
81
|
+
`+n.line+" | "+l+`
|
|
82
|
+
`+f+" | "+pu("",n.column-1," ")+pu("",o,"^")}else e+=`
|
|
83
|
+
at `+i}return e},Da.buildMessage=function(r,e){var t={literal:function(u){return'"'+n(u.text)+'"'},class:function(u){var o=u.parts.map(function(c){return Array.isArray(c)?i(c[0])+"-"+i(c[1]):i(c)});return"["+(u.inverted?"^":"")+o.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(u){return u.description}};function a(u){return u.charCodeAt(0).toString(16).toUpperCase()}function n(u){return u.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(o){return"\\x0"+a(o)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(o){return"\\x"+a(o)})}function i(u){return u.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(o){return"\\x0"+a(o)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(o){return"\\x"+a(o)})}function s(u){return t[u.type](u)}function f(u){var o=u.map(s),c,m;if(o.sort(),o.length>0){for(c=1,m=1;c<o.length;c++)o[c-1]!==o[c]&&(o[m]=o[c],m++);o.length=m}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}function l(u){return u?'"'+n(u)+'"':"end of input"}return"Expected "+f(r)+" but "+l(e)+" found."};function n9(r,e){e=e!==void 0?e:{};var t={},a=e.grammarSource,n={Main:n0},i=n0,s="{",f=",",l="}",u="d",o="d%",c="dF",m=".",v="!",p="p",h="k",y="max",b="min",A="r",d="o",w="cs",x="cf",g="s",E="a",N="f",S="!=",D="<=",T=">=",B="=",_="<>",L=">",G="<",C="(",F=")",Z="abs",$="ceil",U="cos",Y="exp",j="floor",P="log",K="round",ne="sign",re="sin",fe="sqrt",pe="tan",ce="pow",oe="-",Ce="**",Oe="*",Me="^",$e="%",k="/",W="+",ie="/*",V="*/",Q="[",te="]",ge="//",he="#",q=/^[12]/,z=/^[lh]/,ee=/^[.]/,ue=/^[1-9]/,me=/^[0-9]/,ye=/^[^\]]/,be=/^[\n\r\u2028\u2029]/,ve=/^[ \t\n\r]/,Ne=Ue("{",!1),Ie=Ue(",",!1),Ge=Ue("}",!1),Be=Ue("d",!1),lr=Ue("d%",!1),Je=Ue("dF",!1),cr=Ue(".",!1),M=xn(["1","2"],!1,!1),H=Ue("!",!1),se=Ue("p",!1),De=xn(["l","h"],!1,!1),ze=Ue("k",!1),Le=Ue("max",!1),Mr=Ue("min",!1),Rr=Ue("r",!1),en=Ue("o",!1),Ca=Ue("cs",!1),qn=Ue("cf",!1),xu=Ue("s",!1),wu=Ue("a",!1),Nu=Ue("f",!1),Du=Ue("!=",!1),Au=Ue("<=",!1),Eu=Ue(">=",!1),Su=Ue("=",!1),Cu=Ue("<>",!1),Mu=Ue(">",!1),zn=Ue("<",!1),Ma=Ue("(",!1),Fa=Ue(")",!1),Fu=Ue("abs",!1),Tu=Ue("ceil",!1),Bu=Ue("cos",!1),$u=Ue("exp",!1),Ou=Ue("floor",!1),_u=Ue("log",!1),Iu=Ue("round",!1),Ru=Ue("sign",!1),qu=Ue("sin",!1),zu=Ue("sqrt",!1),Pu=Ue("tan",!1),Lu=Ue("pow",!1),Ao=Ue("-",!1),Uu=xn(["."],!1,!1),ku=xn([["1","9"]],!1,!1),It=xn([["0","9"]],!1,!1),Kr=Ue("**",!1),Or=Ue("*",!1),Eo=Ue("^",!1),Vu=Ue("%",!1),Ta=Ue("/",!1),Ba=Ue("+",!1),So=Hu("comment"),Co=Ue("/*",!1),Rt=Ue("*/",!1),Mo=v7(),T9=Ue("[",!1),e0=xn(["]"],!0,!1),B9=Ue("]",!1),$9=Ue("//",!1),O9=Ue("#",!1),_9=xn([`
|
|
84
|
+
`,"\r","\u2028","\u2029"],!1,!1),I9=Hu("whitespace"),R9=xn([" "," ",`
|
|
85
|
+
`,"\r"],!1,!1),q9=Hu("whitespace or comment"),z9=function(O,X,ae,le){return new Wd([O,...X.map(Ee=>Ee[3])],Object.assign({},...ae.map(Ee=>({[Ee.name]:Ee}))),le.find(Ee=>Ee instanceof At))},P9=function(O,X,ae){return O.modifiers=Object.assign({},...X.map(le=>({[le.name]:le}))),O.description=ae.find(le=>le instanceof At),O},L9=function(O,X){return new Na(X,O||1)},U9=function(O){return new Z6(O||1)},k9=function(O,X){return new H6(X?parseInt(X[1],10):2,O||1)},V9=function(O,X,ae){return new Cd(ae,!!O,!!X)},G9=function(O,X){return new j6(O,X)},H9=function(O,X){return new X6(O||"l",X)},Z9=function(O,X){return new Vd(O||"h",X)},J9=function(O){return new Y6(O)},W9=function(O){return new Q6(O)},X9=function(O,X){return new _d(!!O,X)},Y9=function(O){return new W6(O)},Q9=function(O){return new J6(O)},K9=function(O){return new K6(O||"a")},j9=function(O){return O},e7=function(O,X){return new ja(O,X)},r7=function(O,X,ae){return sd(Bo())},t7=function(O,X){return O=Array.isArray(O)?O:[O],[...O,...X.map(([,ae,,le])=>[ae,le]).flat(2)]},n7=function(O,X,ae){return[O,...X,ae]},a7=function(O,X){return[`${O}(`,...X,")"]},i7=function(O,X,ae){return[`${O}(`,...X,",",...ae,")"]},o7=function(){return parseFloat(Bo())},s7=function(){return parseInt(Bo(),10)},u7=function(){return parseInt(Bo(),10)},l7=function(){return"^"},c7=function(O){return new At(O.flat().join(""),At.types.MULTILINE)},f7=function(O){return new At(O.flat().join(""),At.types.MULTILINE)},m7=function(O){return new At(O.flat().join(""),At.types.INLINE)},I=0,fr=0,Fo=[{line:1,column:1}],qt=0,Gu=[],Ae=0,To;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 Bo(){return r.substring(fr,I)}function Ue(O,X){return{type:"literal",text:O,ignoreCase:X}}function xn(O,X,ae){return{type:"class",parts:O,inverted:X,ignoreCase:ae}}function v7(){return{type:"any"}}function p7(){return{type:"end"}}function Hu(O){return{type:"other",description:O}}function r0(O){var X=Fo[O],ae;if(X)return X;for(ae=O-1;!Fo[ae];)ae--;for(X=Fo[ae],X={line:X.line,column:X.column};ae<O;)r.charCodeAt(ae)===10?(X.line++,X.column=1):X.column++,ae++;return Fo[O]=X,X}function t0(O,X){var ae=r0(O),le=r0(X);return{source:a,start:{offset:O,line:ae.line,column:ae.column},end:{offset:X,line:le.line,column:le.column}}}function Fe(O){I<qt||(I>qt&&(qt=I,Gu=[]),Gu.push(O))}function h7(O,X,ae){return new Da(Da.buildMessage(O,X),O,X,ae)}function n0(){var O;return O=wn(),O}function d7(){var O,X,ae,le,Ee,_e,pr,Dr,Et;if(O=I,r.charCodeAt(I)===123?(X=s,I++):(X=t,Ae===0&&Fe(Ne)),X!==t)if(Nr(),ae=wn(),ae!==t){for(le=[],Ee=I,_e=Nr(),r.charCodeAt(I)===44?(pr=f,I++):(pr=t,Ae===0&&Fe(Ie)),pr!==t?(Dr=Nr(),Et=wn(),Et!==t?(_e=[_e,pr,Dr,Et],Ee=_e):(I=Ee,Ee=t)):(I=Ee,Ee=t);Ee!==t;)le.push(Ee),Ee=I,_e=Nr(),r.charCodeAt(I)===44?(pr=f,I++):(pr=t,Ae===0&&Fe(Ie)),pr!==t?(Dr=Nr(),Et=wn(),Et!==t?(_e=[_e,pr,Dr,Et],Ee=_e):(I=Ee,Ee=t)):(I=Ee,Ee=t);if(Ee=Nr(),r.charCodeAt(I)===125?(_e=l,I++):(_e=t,Ae===0&&Fe(Ge)),_e!==t){for(pr=[],Dr=$o();Dr!==t;)pr.push(Dr),Dr=$o();Dr=s0(),fr=O,O=z9(ae,le,pr,Dr)}else I=O,O=t}else I=O,O=t;else I=O,O=t;return O}function g7(){var O,X,ae,le;if(O=I,X=y7(),X===t&&(X=b7(),X===t&&(X=x7())),X!==t){for(ae=[],le=$o();le!==t;)ae.push(le),le=$o();le=s0(),fr=O,O=P9(X,ae,le)}else I=O,O=t;return O}function y7(){var O,X,ae,le;return O=I,X=Oo(),X===t&&(X=null),r.charCodeAt(I)===100?(ae=u,I++):(ae=t,Ae===0&&Fe(Be)),ae!==t?(le=Oo(),le!==t?(fr=O,O=L9(X,le)):(I=O,O=t)):(I=O,O=t),O}function b7(){var O,X,ae;return O=I,X=Oo(),X===t&&(X=null),r.substr(I,2)===o?(ae=o,I+=2):(ae=t,Ae===0&&Fe(lr)),ae!==t?(fr=O,O=U9(X)):(I=O,O=t),O}function x7(){var O,X,ae,le,Ee,_e;return O=I,X=Oo(),X===t&&(X=null),r.substr(I,2)===c?(ae=c,I+=2):(ae=t,Ae===0&&Fe(Je)),ae!==t?(le=I,r.charCodeAt(I)===46?(Ee=m,I++):(Ee=t,Ae===0&&Fe(cr)),Ee!==t?(q.test(r.charAt(I))?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(M)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t),le===t&&(le=null),fr=O,O=k9(X,le)):(I=O,O=t),O}function $o(){var O;return O=w7(),O===t&&(O=N7(),O===t&&(O=D7(),O===t&&(O=A7(),O===t&&(O=C7(),O===t&&(O=M7(),O===t&&(O=F7(),O===t&&(O=T7(),O===t&&(O=E7(),O===t&&(O=S7()))))))))),O}function w7(){var O,X,ae,le,Ee;return O=I,r.charCodeAt(I)===33?(X=v,I++):(X=t,Ae===0&&Fe(H)),X!==t?(r.charCodeAt(I)===33?(ae=v,I++):(ae=t,Ae===0&&Fe(H)),ae===t&&(ae=null),r.charCodeAt(I)===112?(le=p,I++):(le=t,Ae===0&&Fe(se)),le===t&&(le=null),Ee=$a(),Ee===t&&(Ee=null),fr=O,O=V9(ae,le,Ee)):(I=O,O=t),O}function N7(){var O,X,ae;return O=I,X=$a(),X!==t?(ae=B7(),ae===t&&(ae=null),fr=O,O=G9(X,ae)):(I=O,O=t),O}function D7(){var O,X,ae,le;return O=I,r.charCodeAt(I)===100?(X=u,I++):(X=t,Ae===0&&Fe(Be)),X!==t?(z.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(De)),ae===t&&(ae=null),le=Ju(),le!==t?(fr=O,O=H9(ae,le)):(I=O,O=t)):(I=O,O=t),O}function A7(){var O,X,ae,le;return O=I,r.charCodeAt(I)===107?(X=h,I++):(X=t,Ae===0&&Fe(ze)),X!==t?(z.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(De)),ae===t&&(ae=null),le=Ju(),le!==t?(fr=O,O=Z9(ae,le)):(I=O,O=t)):(I=O,O=t),O}function E7(){var O,X,ae;return O=I,r.substr(I,3)===y?(X=y,I+=3):(X=t,Ae===0&&Fe(Le)),X!==t?(ae=Pn(),ae!==t?(fr=O,O=J9(ae)):(I=O,O=t)):(I=O,O=t),O}function S7(){var O,X,ae;return O=I,r.substr(I,3)===b?(X=b,I+=3):(X=t,Ae===0&&Fe(Mr)),X!==t?(ae=Pn(),ae!==t?(fr=O,O=W9(ae)):(I=O,O=t)):(I=O,O=t),O}function C7(){var O,X,ae,le;return O=I,r.charCodeAt(I)===114?(X=A,I++):(X=t,Ae===0&&Fe(Rr)),X!==t?(r.charCodeAt(I)===111?(ae=d,I++):(ae=t,Ae===0&&Fe(en)),ae===t&&(ae=null),le=$a(),le===t&&(le=null),fr=O,O=X9(ae,le)):(I=O,O=t),O}function M7(){var O,X,ae;return O=I,r.substr(I,2)===w?(X=w,I+=2):(X=t,Ae===0&&Fe(Ca)),X!==t?(ae=$a(),ae!==t?(fr=O,O=Y9(ae)):(I=O,O=t)):(I=O,O=t),O}function F7(){var O,X,ae;return O=I,r.substr(I,2)===x?(X=x,I+=2):(X=t,Ae===0&&Fe(qn)),X!==t?(ae=$a(),ae!==t?(fr=O,O=Q9(ae)):(I=O,O=t)):(I=O,O=t),O}function T7(){var O,X,ae;return O=I,r.charCodeAt(I)===115?(X=g,I++):(X=t,Ae===0&&Fe(xu)),X!==t?(r.charCodeAt(I)===97?(ae=E,I++):(ae=t,Ae===0&&Fe(wu)),ae===t&&(r.charCodeAt(I)===100?(ae=u,I++):(ae=t,Ae===0&&Fe(Be))),ae===t&&(ae=null),fr=O,O=K9(ae)):(I=O,O=t),O}function B7(){var O,X,ae;return O=I,r.charCodeAt(I)===102?(X=N,I++):(X=t,Ae===0&&Fe(Nu)),X!==t?(ae=$a(),ae!==t?(fr=O,O=j9(ae)):(I=O,O=t)):(I=O,O=t),O}function $a(){var O,X,ae;return O=I,X=$7(),X!==t?(ae=Pn(),ae!==t?(fr=O,O=e7(X,ae)):(I=O,O=t)):(I=O,O=t),O}function $7(){var O;return r.substr(I,2)===S?(O=S,I+=2):(O=t,Ae===0&&Fe(Du)),O===t&&(r.substr(I,2)===D?(O=D,I+=2):(O=t,Ae===0&&Fe(Au)),O===t&&(r.substr(I,2)===T?(O=T,I+=2):(O=t,Ae===0&&Fe(Eu)),O===t&&(r.charCodeAt(I)===61?(O=B,I++):(O=t,Ae===0&&Fe(Su)),O===t&&(r.substr(I,2)===_?(O=_,I+=2):(O=t,Ae===0&&Fe(Cu)),O===t&&(r.charCodeAt(I)===62?(O=L,I++):(O=t,Ae===0&&Fe(Mu)),O===t&&(r.charCodeAt(I)===60?(O=G,I++):(O=t,Ae===0&&Fe(zn)))))))),O}function Oo(){var O,X,ae,le,Ee,_e,pr,Dr,Et,Oa;if(O=Ju(),O===t)if(O=I,r.charCodeAt(I)===40?(X=C,I++):(X=t,Ae===0&&Fe(Ma)),X!==t){if(Nr(),ae=I,le=Pn(),le!==t){if(Ee=[],_e=I,pr=Nr(),Dr=_o(),Dr!==t?(Et=Nr(),Oa=Pn(),Oa!==t?(pr=[pr,Dr,Et,Oa],_e=pr):(I=_e,_e=t)):(I=_e,_e=t),_e!==t)for(;_e!==t;)Ee.push(_e),_e=I,pr=Nr(),Dr=_o(),Dr!==t?(Et=Nr(),Oa=Pn(),Oa!==t?(pr=[pr,Dr,Et,Oa],_e=pr):(I=_e,_e=t)):(I=_e,_e=t);else Ee=t;Ee!==t?(le=[le,Ee],ae=le):(I=ae,ae=t)}else I=ae,ae=t;ae!==t?(le=Nr(),r.charCodeAt(I)===41?(Ee=F,I++):(Ee=t,Ae===0&&Fe(Fa)),Ee!==t?(fr=O,O=r7()):(I=O,O=t)):(I=O,O=t)}else I=O,O=t;return O}function wn(){var O,X,ae,le,Ee,_e,pr,Dr;if(O=I,X=Zu(),X!==t){for(ae=[],le=I,Ee=Nr(),_e=_o(),_e!==t?(pr=Nr(),Dr=Zu(),Dr!==t?(Ee=[Ee,_e,pr,Dr],le=Ee):(I=le,le=t)):(I=le,le=t);le!==t;)ae.push(le),le=I,Ee=Nr(),_e=_o(),_e!==t?(pr=Nr(),Dr=Zu(),Dr!==t?(Ee=[Ee,_e,pr,Dr],le=Ee):(I=le,le=t)):(I=le,le=t);fr=O,O=t7(X,ae)}else I=O,O=t;return O}function Zu(){var O,X,ae,le;return O=O7(),O===t&&(O=g7(),O===t&&(O=Pn(),O===t&&(O=I,r.charCodeAt(I)===40?(X=C,I++):(X=t,Ae===0&&Fe(Ma)),X!==t?(Nr(),ae=wn(),ae!==t?(Nr(),r.charCodeAt(I)===41?(le=F,I++):(le=t,Ae===0&&Fe(Fa)),le!==t?(fr=O,O=n7(X,ae,le)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t),O===t&&(O=d7())))),O}function O7(){var O,X,ae,le,Ee,_e,pr;return O=I,r.substr(I,3)===Z?(X=Z,I+=3):(X=t,Ae===0&&Fe(Fu)),X===t&&(r.substr(I,4)===$?(X=$,I+=4):(X=t,Ae===0&&Fe(Tu)),X===t&&(r.substr(I,3)===U?(X=U,I+=3):(X=t,Ae===0&&Fe(Bu)),X===t&&(r.substr(I,3)===Y?(X=Y,I+=3):(X=t,Ae===0&&Fe($u)),X===t&&(r.substr(I,5)===j?(X=j,I+=5):(X=t,Ae===0&&Fe(Ou)),X===t&&(r.substr(I,3)===P?(X=P,I+=3):(X=t,Ae===0&&Fe(_u)),X===t&&(r.substr(I,5)===K?(X=K,I+=5):(X=t,Ae===0&&Fe(Iu)),X===t&&(r.substr(I,4)===ne?(X=ne,I+=4):(X=t,Ae===0&&Fe(Ru)),X===t&&(r.substr(I,3)===re?(X=re,I+=3):(X=t,Ae===0&&Fe(qu)),X===t&&(r.substr(I,4)===fe?(X=fe,I+=4):(X=t,Ae===0&&Fe(zu)),X===t&&(r.substr(I,3)===pe?(X=pe,I+=3):(X=t,Ae===0&&Fe(Pu)))))))))))),X!==t?(r.charCodeAt(I)===40?(ae=C,I++):(ae=t,Ae===0&&Fe(Ma)),ae!==t?(Nr(),le=wn(),le!==t?(Nr(),r.charCodeAt(I)===41?(Ee=F,I++):(Ee=t,Ae===0&&Fe(Fa)),Ee!==t?(fr=O,O=a7(X,le)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t),O===t&&(O=I,r.substr(I,3)===ce?(X=ce,I+=3):(X=t,Ae===0&&Fe(Lu)),X===t&&(r.substr(I,3)===y?(X=y,I+=3):(X=t,Ae===0&&Fe(Le)),X===t&&(r.substr(I,3)===b?(X=b,I+=3):(X=t,Ae===0&&Fe(Mr)))),X!==t?(r.charCodeAt(I)===40?(ae=C,I++):(ae=t,Ae===0&&Fe(Ma)),ae!==t?(Nr(),le=wn(),le!==t?(Nr(),r.charCodeAt(I)===44?(Ee=f,I++):(Ee=t,Ae===0&&Fe(Ie)),Ee!==t?(Nr(),_e=wn(),_e!==t?(Nr(),r.charCodeAt(I)===41?(pr=F,I++):(pr=t,Ae===0&&Fe(Fa)),pr!==t?(fr=O,O=i7(X,le,_e)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)):(I=O,O=t)),O}function Pn(){var O,X,ae,le,Ee;return O=I,r.charCodeAt(I)===45?I++:Ae===0&&Fe(Ao),X=a0(),X!==t?(ae=I,ee.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(Uu)),le!==t?(Ee=a0(),Ee!==t?(le=[le,Ee],ae=le):(I=ae,ae=t)):(I=ae,ae=t),ae===t&&(ae=null),fr=O,O=o7()):(I=O,O=t),O}function Ju(){var O,X,ae,le;if(O=I,ue.test(r.charAt(I))?(X=r.charAt(I),I++):(X=t,Ae===0&&Fe(ku)),X!==t){for(ae=[],me.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(It));le!==t;)ae.push(le),me.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(It));fr=O,O=s7()}else I=O,O=t;return O}function a0(){var O,X,ae;if(O=I,X=[],me.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(It)),ae!==t)for(;ae!==t;)X.push(ae),me.test(r.charAt(I))?(ae=r.charAt(I),I++):(ae=t,Ae===0&&Fe(It));else X=t;return X!==t&&(fr=O,X=u7()),O=X,O}function _o(){var O,X;return O=I,r.substr(I,2)===Ce?(X=Ce,I+=2):(X=t,Ae===0&&Fe(Kr)),X!==t&&(fr=O,X=l7()),O=X,O===t&&(r.charCodeAt(I)===42?(O=Oe,I++):(O=t,Ae===0&&Fe(Or)),O===t&&(r.charCodeAt(I)===94?(O=Me,I++):(O=t,Ae===0&&Fe(Eo)),O===t&&(r.charCodeAt(I)===37?(O=$e,I++):(O=t,Ae===0&&Fe(Vu)),O===t&&(r.charCodeAt(I)===47?(O=k,I++):(O=t,Ae===0&&Fe(Ta)),O===t&&(r.charCodeAt(I)===43?(O=W,I++):(O=t,Ae===0&&Fe(Ba)),O===t&&(r.charCodeAt(I)===45?(O=oe,I++):(O=t,Ae===0&&Fe(Ao)))))))),O}function i0(){var O;return Ae++,O=_7(),O===t&&(O=I7()),Ae--,O===t&&Ae===0&&Fe(So),O}function _7(){var O,X,ae,le,Ee,_e;if(O=I,r.substr(I,2)===ie?(X=ie,I+=2):(X=t,Ae===0&&Fe(Co)),X!==t){for(ae=[],le=I,Ee=I,Ae++,r.substr(I,2)===V?(_e=V,I+=2):(_e=t,Ae===0&&Fe(Rt)),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);le!==t;)ae.push(le),le=I,Ee=I,Ae++,r.substr(I,2)===V?(_e=V,I+=2):(_e=t,Ae===0&&Fe(Rt)),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);r.substr(I,2)===V?(le=V,I+=2):(le=t,Ae===0&&Fe(Rt)),le!==t?(fr=O,O=c7(ae)):(I=O,O=t)}else I=O,O=t;if(O===t)if(O=I,r.charCodeAt(I)===91?(X=Q,I++):(X=t,Ae===0&&Fe(T9)),X!==t){for(ae=[],ye.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(e0));le!==t;)ae.push(le),ye.test(r.charAt(I))?(le=r.charAt(I),I++):(le=t,Ae===0&&Fe(e0));r.charCodeAt(I)===93?(le=te,I++):(le=t,Ae===0&&Fe(B9)),le!==t?(fr=O,O=f7(ae)):(I=O,O=t)}else I=O,O=t;return O}function I7(){var O,X,ae,le,Ee,_e;if(O=I,r.substr(I,2)===ge?(X=ge,I+=2):(X=t,Ae===0&&Fe($9)),X===t&&(r.charCodeAt(I)===35?(X=he,I++):(X=t,Ae===0&&Fe(O9))),X!==t){for(ae=[],le=I,Ee=I,Ae++,_e=o0(),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);le!==t;)ae.push(le),le=I,Ee=I,Ae++,_e=o0(),Ae--,_e===t?Ee=void 0:(I=Ee,Ee=t),Ee!==t?(r.length>I?(_e=r.charAt(I),I++):(_e=t,Ae===0&&Fe(Mo)),_e!==t?(Ee=[Ee,_e],le=Ee):(I=le,le=t)):(I=le,le=t);fr=O,O=m7(ae)}else I=O,O=t;return O}function o0(){var O;return be.test(r.charAt(I))?(O=r.charAt(I),I++):(O=t,Ae===0&&Fe(_9)),O}function Io(){var O;return Ae++,ve.test(r.charAt(I))?(O=r.charAt(I),I++):(O=t,Ae===0&&Fe(R9)),Ae--,O===t&&Ae===0&&Fe(I9),O}function Nr(){var O,X;for(O=[],X=Io();X!==t;)O.push(X),X=Io();return O}function s0(){var O,X;for(Ae++,O=[],X=Io(),X===t&&(X=i0());X!==t;)O.push(X),X=Io(),X===t&&(X=i0());return Ae--,X=t,Ae===0&&Fe(q9),O}if(To=i(),To!==t&&I===r.length)return To;throw To!==t&&I<r.length&&Fe(p7()),h7(Gu,qt<r.length?r.charAt(qt):null,qt<r.length?t0(qt,qt+1):t0(qt,qt))}class Xd{static parse(e){if(!e)throw new Ot("notation");if(typeof e!="string")throw new TypeError("Notation must be a string");return n9(e)}}const Aa=Object.freeze({BASE_64:1,JSON:0,OBJECT:2}),hu=Symbol("notation"),du=Symbol("maxTotal"),gu=Symbol("minTotal"),Ea=Symbol("expressions"),wo=Symbol("roll-method"),bn=Symbol("rolls"),Yd=Symbol("set-rolls"),No=Symbol("total"),yu=r=>v6(r.calculationValue,2);class ti{constructor(e){if(!e)throw new Ot("notation");if(this[Ea]=[],e instanceof Object&&!Array.isArray(e)){if(e.notation){if(typeof e.notation!="string")throw new vo(e.notation);e.rolls&&this[Yd](e.rolls)}else throw new Ot("notation");this[hu]=e.notation,this[Ea]=Xd.parse(this.notation),this.hasRolls()||this.roll()}else if(typeof e=="string")this[hu]=e,this[Ea]=Xd.parse(this.notation),this.roll();else throw new vo(e)}get averageTotal(){return(this.maxTotal+this.minTotal)/2}get maxTotal(){if(!this.hasExpressions())return 0;if(!this[du]){const e=this[wo](wd.max);this[du]=yu(e)}return this[du]}get minTotal(){if(!this.hasExpressions())return 0;if(!this[gu]){const e=this[wo](wd.min);this[gu]=yu(e)}return this[gu]}get notation(){return this[hu]}get output(){let e=`${this.notation}: `;return this.hasRolls()?e+=`${this[bn]} = ${this.total}`:e+="No dice rolled",e}get rolls(){return this[bn]?this[bn].results:[]}get total(){return!this[No]&&this.hasRolls()&&(this[No]=yu(this[bn])),this[No]||0}export(e=Aa.JSON){switch(e){case Aa.BASE_64:return btoa(this.export(Aa.JSON));case Aa.JSON:return JSON.stringify(this);case Aa.OBJECT:return JSON.parse(this.export(Aa.JSON));default:throw new TypeError(`Invalid export format "${e}"`)}}hasExpressions(){return this[Ea]&&this[Ea].length>0}hasRolls(){return this.hasExpressions()&&this.rolls.length>0}roll(){return this[No]=0,this[bn]=this[wo](),this.rolls}toJSON(){const{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:s,total:f}=this;return{averageTotal:e,maxTotal:t,minTotal:a,notation:n,output:i,rolls:s,total:f,type:"dice-roll"}}toString(){return this.output}static import(e){if(e){if(r9(e))return ti.import(JSON.parse(e));if(e9(e))return ti.import(atob(e));if(typeof e=="object")return new ti(e);throw new Us(e)}else throw new Ot("data")}[wo](e){let t;e&&(t=wa.engine,wa.engine=e);const a=new Ur(this[Ea].map(n=>n instanceof Na||n instanceof Wd?n.roll():n).filter(n=>!!n||n===0));return e&&(wa.engine=t),a}[Yd](e){if(e instanceof Ur)this[bn]=e;else if(e instanceof jt)this[bn]=new Ur([e]);else if(Array.isArray(e))this[bn]=new Ur(e.map(t=>{if(t instanceof Ur||t instanceof jt)return t;if(Array.isArray(t))return new jt(t);if(typeof t=="object"){if(Array.isArray(t.results))return new Ur(t.results,t.modifiers||[],t.isRollGroup||!1,typeof t.useInTotal=="boolean"?t.useInTotal:!0);if(Array.isArray(t.rolls))return new jt(t.rolls)}return t}));else throw new TypeError("Rolls must be a valid result object, or an array")}}const Do={__name:"DiceRollerRenderless",props:{notation:String},emits:["notation:change","roll"],setup(r,{emit:e}){const t=r,a=xe.ref(`${t.notation||""}`),n=xe.ref(null),i=xe.ref(null),s=async()=>{n.value=null;try{i.value=a.value?new ti(xe.unref(a)):null}catch(l){i.value=null,l.name==="SyntaxError"?n.value=`Invalid notation; ${l.message}`:n.value=`An error has occurred: ${l.message}`}finally{e("roll",xe.unref(a),xe.unref(i))}},f=l=>{a.value=l,e("notation:change",l)};return(l,u)=>xe.renderSlot(l.$slots,"default",{currentNotation:a.value,error:n.value,output:i.value,roll:s,bind:{value:a.value},on:{input:o=>f(o.target.value),change:o=>f(o.target.value),keyup:o=>o.keyCode===13?s():void 0}})}},a9=()=>typeof crypto<"u"&&crypto&&crypto.randomUUID,i9=()=>a9()?crypto.randomUUID():`${Date.now().toString(32)}-${Math.random().toString(36).substring(2)}`;function bu(r){const e=xe.ref(null);return e.value=`${r}${i9()}`,{id:e}}const o9=["id"],s9=["for"],u9=["for"],l9=["id","placeholder"],c9=["onClick"],f9={__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}=bu(`${e.id||"dice-roller"}-`);return(a,n)=>(xe.openBlock(),xe.createBlock(Do,{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:xe.withCtx(({error:i,output:s,roll:f,on:l,bind:u})=>[xe.createElementVNode("section",{id:r.id,class:xe.normalizeClass(r.className)},[s?(xe.openBlock(),xe.createElementBlock("output",{key:0,name:"output",for:xe.unref(t),class:xe.normalizeClass(`${r.className}-output`)},xe.toDisplayString(s),11,s9)):xe.createCommentVNode("",!0),xe.createElementVNode("div",{class:xe.normalizeClass(`${r.className}-input-group`)},[xe.createElementVNode("label",{for:xe.unref(t),class:xe.normalizeClass(`${r.className}-label`)}," Notation ",10,u9),xe.createElementVNode("input",xe.mergeProps({type:"text",name:"notation",id:xe.unref(t),placeholder:`e.g. ${r.notation||"4d6"}`,class:[`${r.className}-input`,i?`${r.className}-input-invalid`:null]},xe.toHandlers(l,!0),u),null,16,l9),xe.createElementVNode("button",{type:"button",class:xe.normalizeClass(`${r.className}-button`),onClick:f},[xe.renderSlot(a.$slots,"button",{},()=>[xe.createTextVNode(xe.toDisplayString(r.btnLabel),1)])],10,c9)],2),i?(xe.openBlock(),xe.createElementBlock("span",{key:1,class:xe.normalizeClass(`${r.className}-error`)},xe.toDisplayString(i),3)):xe.createCommentVNode("",!0)],10,o9)]),_:3},8,["notation"]))}},m9=["id"],v9=["for"],p9={class:"flex flex-col sm:flex-row gap-y-4"},h9=["for"],d9=["id","placeholder"],g9=["onClick"],y9={key:1,class:"block mt-4 text-red-600 text-sm dark:text-red-200"},b9={__name:"DiceRollerTailwind",props:{btnLabel:{type:String,default:"Roll"},id:String,notation:String},emits:["notation:change","roll"],setup(r){const e=r,{id:t}=bu(`${e.id||"dice-roller"}-`);return(a,n)=>(xe.openBlock(),xe.createBlock(Do,{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:xe.withCtx(({error:i,output:s,roll:f,on:l,bind:u})=>[xe.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"},[s?(xe.openBlock(),xe.createElementBlock("output",{key:0,name:"output",for:xe.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]"},xe.toDisplayString(s),9,v9)):xe.createCommentVNode("",!0),xe.createElementVNode("div",p9,[xe.createElementVNode("label",{for:xe.unref(t),class:"sr-only"}," Notation ",8,h9),xe.createElementVNode("input",xe.mergeProps({type:"text",name:"notation",id:xe.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"]},xe.toHandlers(l,!0),u),null,16,d9),xe.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:f},[xe.renderSlot(a.$slots,"button",{},()=>[xe.createTextVNode(xe.toDisplayString(r.btnLabel),1)])],8,g9)]),i?(xe.openBlock(),xe.createElementBlock("span",y9,xe.toDisplayString(i),1)):xe.createCommentVNode("",!0)],8,m9)]),_:3},8,["notation"]))}},x9=["id"],w9={class:"card-body"},N9=["for"],D9=["for"],A9={class:"input-group"},E9=["id","placeholder"],S9=["onClick"],C9={key:1,class:"d-block mt-3 invalid-feedback"},Sa=["primary","secondary","success","danger","warning","info","light","dark"],Qd=[...Sa,"body","white","transparent"],Kd=[...Sa,"body","muted","white","black-50","white-50"],M9=[...Sa,"link","outline-primary","outline-secondary","outline-success","outline-danger","outline-warning","outline-info","outline-light","outline-dark"],jd=[...Sa,"white"],F9={__name:"DiceRollerBootstrap",props:{bgVariant:{type:String,validator(r){return Qd.includes(r)}},borderVariant:{type:String,validator(r){return jd.includes(r)}},btnLabel:{type:String,default:"Roll"},btnVariant:{type:String,default:"primary",validator(r){return M9.includes(r)}},id:String,notation:String,outputBgVariant:{type:String,validator(r){return Qd.includes(r)}},outputBorderVariant:{type:String,validator(r){return jd.includes(r)}},outputTextVariant:{type:String,validator(r){return Kd.includes(r)}},outputVariant:{type:String,validator(r){return Sa.includes(r)}},textVariant:{type:String,validator(r){return Kd.includes(r)}},variant:{type:String,validator(r){return Sa.includes(r)}}},emits:["notation:change","roll"],setup(r){const e=r,t=xe.computed(()=>({[`text-bg-${e.variant}`]:e.variant,[`bg-${e.bgVariant}`]:e.bgVariant,[`text-${e.textVariant}`]:e.textVariant,[`border-${e.borderVariant}`]:e.borderVariant})),a=xe.computed(()=>({[`text-bg-${e.outputVariant}`]:e.outputVariant,[`bg-${e.outputBgVariant}`]:e.outputBgVariant,[`text-${e.outputTextVariant}`]:e.outputTextVariant,[`border-${e.outputBorderVariant}`]:e.outputBorderVariant})),n=xe.computed(()=>`btn-${e.btnVariant||"primary"}`),{id:i}=bu(`${e.id||"dice-roller"}-`);return(s,f)=>(xe.openBlock(),xe.createBlock(Do,{notation:r.notation,"onNotation:change":f[0]||(f[0]=l=>s.$emit("notation:change",l)),onRoll:f[1]||(f[1]=l=>s.$emit("roll",l))},{default:xe.withCtx(({error:l,output:u,roll:o,on:c,bind:m})=>[xe.createElementVNode("div",{id:r.id,class:xe.normalizeClass(["dice-roller card",xe.unref(t)])},[xe.createElementVNode("div",w9,[u?(xe.openBlock(),xe.createElementBlock("output",{key:0,name:"output",for:xe.unref(i),class:xe.normalizeClass(["d-block mb-4 p-3 fs-4 rounded border",xe.unref(a)])},xe.toDisplayString(u),11,N9)):xe.createCommentVNode("",!0),xe.createElementVNode("label",{for:xe.unref(i),class:"form-label visually-hidden"}," Notation ",8,D9),xe.createElementVNode("div",A9,[xe.createElementVNode("input",xe.mergeProps({type:"text",name:"notation",id:xe.unref(i),placeholder:`e.g. ${r.notation||"4d6"}`,class:["form-control",l?"is-invalid":""]},xe.toHandlers(c,!0),m),null,16,E9),xe.createElementVNode("button",{type:"button",class:xe.normalizeClass(["btn",xe.unref(n)]),onClick:o},[xe.renderSlot(s.$slots,"button",{},()=>[xe.createTextVNode(xe.toDisplayString(r.btnLabel),1)])],10,S9)]),l?(xe.openBlock(),xe.createElementBlock("span",C9,xe.toDisplayString(l),1)):xe.createCommentVNode("",!0)])],10,x9)]),_:3},8,["notation"]))}};kr.DiceRoller=f9,kr.DiceRollerBootstrap=F9,kr.DiceRollerRenderless=Do,kr.DiceRollerTailwind=b9,Object.defineProperties(kr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|