rf-touchstone 0.0.2 → 0.0.3
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/coverage/coverage-badge.svg +4 -4
- package/dist/Touchstone.cjs.js +6 -6
- package/dist/Touchstone.es.js +1103 -1221
- package/dist/Touchstone.umd.js +6 -6
- package/dist/frequency.d.ts +56 -258
- package/dist/index.d.ts +2 -2
- package/dist/touchstone.d.ts +119 -88
- package/package.json +6 -8
- package/readme.md +30 -13
- package/src/frequency.ts +56 -258
- package/src/index.ts +14 -15
- package/src/touchstone.ts +225 -100
package/dist/Touchstone.umd.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(ge,pr){typeof exports=="object"&&typeof module<"u"?pr(exports):typeof define=="function"&&define.amd?define(["exports"],pr):(ge=typeof globalThis<"u"?globalThis:ge||self,pr(ge.Touchstone={}))})(this,(function(ge){"use strict";function pr(){return pr=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},pr.apply(null,arguments)}var
|
|
1
|
+
(function(ge,pr){typeof exports=="object"&&typeof module<"u"?pr(exports):typeof define=="function"&&define.amd?define(["exports"],pr):(ge=typeof globalThis<"u"?globalThis:ge||self,pr(ge.Touchstone={}))})(this,(function(ge){"use strict";function pr(){return pr=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},pr.apply(null,arguments)}var pn={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null,legacySubset:!1};function mn(e,r){if(rt(e,r))return e[r];throw typeof e[r]=="function"&&su(e,r)?new Error('Cannot access method "'+r+'" as a property'):new Error('No access to property "'+r+'"')}function Dn(e,r,t){if(rt(e,r))return e[r]=t,t;throw new Error('No access to property "'+r+'"')}function rt(e,r){return!fu(e)&&!Array.isArray(e)?!1:Hr(cu,r)?!0:!(r in Object.prototype||r in Function.prototype)}function su(e,r){return e==null||typeof e[r]!="function"||Hr(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e)?!1:Hr(lu,r)?!0:!(r in Object.prototype||r in Function.prototype)}function fu(e){return typeof e=="object"&&e&&e.constructor===Object}var cu={length:!0,name:!0},lu={toString:!0,valueOf:!0,toLocaleString:!0};class hu{constructor(r){this.wrappedObject=r,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter(r=>this.has(r)).values()}get(r){return mn(this.wrappedObject,r)}set(r,t){return Dn(this.wrappedObject,r,t),this}has(r){return rt(this.wrappedObject,r)&&r in this.wrappedObject}entries(){return pu(this.keys(),r=>[r,this.get(r)])}forEach(r){for(var t of this.keys())r(this.get(t),t,this)}delete(r){rt(this.wrappedObject,r)&&delete this.wrappedObject[r]}clear(){for(var r of this.keys())this.delete(r)}get size(){return Object.keys(this.wrappedObject).length}}function pu(e,r){return{next:()=>{var t=e.next();return t.done?t:{value:r(t.value),done:!1}}}}function ne(e){return typeof e=="number"}function Ee(e){return!e||typeof e!="object"||typeof e.constructor!="function"?!1:e.isBigNumber===!0&&typeof e.constructor.prototype=="object"&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal=="function"&&e.constructor.isDecimal(e)===!0}function mu(e){return typeof e=="bigint"}function dn(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function gn(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function vn(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Me(e){return typeof e=="string"}var ve=Array.isArray;function we(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function tt(e){return Array.isArray(e)||we(e)}function Du(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function du(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function wn(e){return e&&e.constructor.prototype.isRange===!0||!1}function nt(e){return e&&e.constructor.prototype.isIndex===!0||!1}function gu(e){return typeof e=="boolean"}function vu(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function wu(e){return e&&e.constructor.prototype.isHelp===!0||!1}function yu(e){return typeof e=="function"}function Fu(e){return e instanceof Date}function Eu(e){return e instanceof RegExp}function Lt(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!dn(e)&&!gn(e))}function Au(e){return e?e instanceof Map||e instanceof hu||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function bu(e){return e===null}function Cu(e){return e===void 0}function _u(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Bu(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function Nu(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Su(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function Mu(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function xu(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function Tu(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Iu(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function zu(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ou(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function $u(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function Pu(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function qu(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function Uu(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ru(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Lu(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function Hu(e){return e&&e.constructor.prototype.isChain===!0||!1}function ur(e){var r=typeof e;return r==="object"?e===null?"null":Ee(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":r}function me(e){var r=typeof e;if(r==="number"||r==="bigint"||r==="string"||r==="boolean"||e===null||e===void 0)return e;if(typeof e.clone=="function")return e.clone();if(Array.isArray(e))return e.map(function(t){return me(t)});if(e instanceof Date)return new Date(e.valueOf());if(Ee(e))return e;if(Lt(e))return Zu(e,me);if(r==="function")return e;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function Zu(e,r){var t={};for(var n in e)Hr(e,n)&&(t[n]=r(e[n]));return t}function Wu(e,r){for(var t in r)Hr(r,t)&&(e[t]=r[t]);return e}function mr(e,r){var t,n,i;if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(n=0,i=e.length;n<i;n++)if(!mr(e[n],r[n]))return!1;return!0}else{if(typeof e=="function")return e===r;if(e instanceof Object){if(Array.isArray(r)||!(r instanceof Object))return!1;for(t in e)if(!(t in r)||!mr(e[t],r[t]))return!1;for(t in r)if(!(t in e))return!1;return!0}else return e===r}}function Hr(e,r){return e&&Object.hasOwnProperty.call(e,r)}function Vu(e,r){for(var t={},n=0;n<r.length;n++){var i=r[n],u=e[i];u!==void 0&&(t[i]=u)}return t}var Gu=["Matrix","Array"],Ju=["number","BigNumber","bigint","Fraction"],Pe=function(r){if(r)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(hn)};pr(Pe,hn,{MATRIX_OPTIONS:Vu,NUMBER_OPTIONS:Gu});function wn(){return!0}function ke(){return!1}function _r(){}const yn="Argument is not a typed-function.";function Fn(){function e(E){return typeof E=="object"&&E!==null&&E.constructor===Object}const r=[{name:"number",test:function(E){return typeof E=="number"}},{name:"string",test:function(E){return typeof E=="string"}},{name:"boolean",test:function(E){return typeof E=="boolean"}},{name:"Function",test:function(E){return typeof E=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(E){return E instanceof Date}},{name:"RegExp",test:function(E){return E instanceof RegExp}},{name:"Object",test:e},{name:"null",test:function(E){return E===null}},{name:"undefined",test:function(E){return E===void 0}}],t={name:"any",test:wn,isAny:!0};let n,i,u=0,o={createCount:0};function a(E){const C=n.get(E);if(C)return C;let N='Unknown type "'+E+'"';const T=E.toLowerCase();let P;for(P of i)if(P.toLowerCase()===T){N+='. Did you mean "'+P+'" ?';break}throw new TypeError(N)}function s(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const N=C?a(C).index:i.length,T=[];for(let z=0;z<E.length;++z){if(!E[z]||typeof E[z].name!="string"||typeof E[z].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const Z=E[z].name;if(n.has(Z))throw new TypeError('Duplicate type name "'+Z+'"');T.push(Z),n.set(Z,{name:Z,test:E[z].test,isAny:E[z].isAny,index:N+z,conversionsTo:[]})}const P=i.slice(N);i=i.slice(0,N).concat(T).concat(P);for(let z=N+T.length;z<i.length;++z)n.get(i[z]).index=z}function f(){n=new Map,i=[],u=0,s([t],!1)}f(),s(r);function m(){let E;for(E of i)n.get(E).conversionsTo=[];u=0}function l(E){const C=i.filter(N=>{const T=n.get(N);return!T.isAny&&T.test(E)});return C.length?C:["any"]}function h(E){return E&&typeof E=="function"&&"_typedFunctionData"in E}function p(E,C,N){if(!h(E))throw new TypeError(yn);const T=N&&N.exact,P=Array.isArray(C)?C.join(","):C,z=A(P),Z=d(z);if(!T||Z in E.signatures){const fe=E._typedFunctionData.signatureMap.get(Z);if(fe)return fe}const U=z.length;let W;if(T){W=[];let fe;for(fe in E.signatures)W.push(E._typedFunctionData.signatureMap.get(fe))}else W=E._typedFunctionData.signatures;for(let fe=0;fe<U;++fe){const de=z[fe],Ne=[];let Ge;for(Ge of W){const He=b(Ge.params,fe);if(!(!He||de.restParam&&!He.restParam)){if(!He.hasAny){const nr=g(He);if(de.types.some(ir=>!nr.has(ir.name)))continue}Ne.push(Ge)}}if(W=Ne,W.length===0)break}let q;for(q of W)if(q.params.length<=U)return q;throw new TypeError("Signature not found (signature: "+(E.name||"unnamed")+"("+d(z,", ")+"))")}function D(E,C,N){return p(E,C,N).implementation}function c(E,C){const N=a(C);if(N.test(E))return E;const T=N.conversionsTo;if(T.length===0)throw new Error("There are no conversions to "+C+" defined.");for(let P=0;P<T.length;P++)if(a(T[P].from).test(E))return T[P].convert(E);throw new Error("Cannot convert "+E+" to "+C)}function d(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return E.map(N=>N.name).join(C)}function v(E){const C=E.indexOf("...")===0,T=(C?E.length>3?E.slice(3):"any":E).split("|").map(U=>a(U.trim()));let P=!1,z=C?"...":"";return{types:T.map(function(U){return P=U.isAny||P,z+=U.name+"|",{name:U.name,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:null,conversionIndex:-1}}),name:z.slice(0,-1),hasAny:P,hasConversion:!1,restParam:C}}function y(E){const C=E.types.map(Z=>Z.name),N=Q(C);let T=E.hasAny,P=E.name;const z=N.map(function(Z){const U=a(Z.from);return T=U.isAny||T,P+="|"+Z.from,{name:Z.from,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:Z,conversionIndex:Z.index}});return{types:E.types.concat(z),name:P,hasAny:T,hasConversion:z.length>0,restParam:E.restParam}}function g(E){return E.typeSet||(E.typeSet=new Set,E.types.forEach(C=>E.typeSet.add(C.name))),E.typeSet}function A(E){const C=[];if(typeof E!="string")throw new TypeError("Signatures must be strings");const N=E.trim();if(N==="")return C;const T=N.split(",");for(let P=0;P<T.length;++P){const z=v(T[P].trim());if(z.restParam&&P!==T.length-1)throw new SyntaxError('Unexpected rest parameter "'+T[P]+'": only allowed for the last parameter');if(z.types.length===0)return null;C.push(z)}return C}function F(E){const C=he(E);return C?C.restParam:!1}function w(E){if(!E||E.types.length===0)return wn;if(E.types.length===1)return a(E.types[0].name).test;if(E.types.length===2){const C=a(E.types[0].name).test,N=a(E.types[1].name).test;return function(P){return C(P)||N(P)}}else{const C=E.types.map(function(N){return a(N.name).test});return function(T){for(let P=0;P<C.length;P++)if(C[P](T))return!0;return!1}}}function _(E){let C,N,T;if(F(E)){C=Le(E).map(w);const P=C.length,z=w(he(E)),Z=function(U){for(let W=P;W<U.length;W++)if(!z(U[W]))return!1;return!0};return function(W){for(let q=0;q<C.length;q++)if(!C[q](W[q]))return!1;return Z(W)&&W.length>=P+1}}else return E.length===0?function(z){return z.length===0}:E.length===1?(N=w(E[0]),function(z){return N(z[0])&&z.length===1}):E.length===2?(N=w(E[0]),T=w(E[1]),function(z){return N(z[0])&&T(z[1])&&z.length===2}):(C=E.map(w),function(z){for(let Z=0;Z<C.length;Z++)if(!C[Z](z[Z]))return!1;return z.length===C.length})}function b(E,C){return C<E.length?E[C]:F(E)?he(E):null}function B(E,C){const N=b(E,C);return N?g(N):new Set}function S(E){return E.conversion===null||E.conversion===void 0}function x(E,C){const N=new Set;return E.forEach(T=>{const P=B(T.params,C);let z;for(z of P)N.add(z)}),N.has("any")?["any"]:Array.from(N)}function O(E,C,N){let T,P;const z=E||"unnamed";let Z=N,U;for(U=0;U<C.length;U++){const de=[];if(Z.forEach(Ne=>{const Ge=b(Ne.params,U),He=w(Ge);(U<Ne.params.length||F(Ne.params))&&He(C[U])&&de.push(Ne)}),de.length===0){if(P=x(Z,U),P.length>0){const Ne=l(C[U]);return T=new TypeError("Unexpected type of argument in function "+z+" (expected: "+P.join(" or ")+", actual: "+Ne.join(" | ")+", index: "+U+")"),T.data={category:"wrongType",fn:z,index:U,actual:Ne,expected:P},T}}else Z=de}const W=Z.map(function(de){return F(de.params)?1/0:de.params.length});if(C.length<Math.min.apply(null,W))return P=x(Z,U),T=new TypeError("Too few arguments in function "+z+" (expected: "+P.join(" or ")+", index: "+C.length+")"),T.data={category:"tooFewArgs",fn:z,index:C.length,expected:P},T;const q=Math.max.apply(null,W);if(C.length>q)return T=new TypeError("Too many arguments in function "+z+" (expected: "+q+", actual: "+C.length+")"),T.data={category:"tooManyArgs",fn:z,index:C.length,expectedLength:q},T;const fe=[];for(let de=0;de<C.length;++de)fe.push(l(C[de]).join("|"));return T=new TypeError('Arguments of type "'+fe.join(", ")+'" do not match any of the defined signatures of function '+z+"."),T.data={category:"mismatch",actual:fe},T}function G(E){let C=i.length+1;for(let N=0;N<E.types.length;N++)S(E.types[N])&&(C=Math.min(C,E.types[N].typeIndex));return C}function R(E){let C=u+1;for(let N=0;N<E.types.length;N++)S(E.types[N])||(C=Math.min(C,E.types[N].conversionIndex));return C}function H(E,C){if(E.hasAny){if(!C.hasAny)return 1}else if(C.hasAny)return-1;if(E.restParam){if(!C.restParam)return 1}else if(C.restParam)return-1;if(E.hasConversion){if(!C.hasConversion)return 1}else if(C.hasConversion)return-1;const N=G(E)-G(C);if(N<0)return-1;if(N>0)return 1;const T=R(E)-R(C);return T<0?-1:T>0?1:0}function $(E,C){const N=E.params,T=C.params,P=he(N),z=he(T),Z=F(N),U=F(T);if(Z&&P.hasAny){if(!U||!z.hasAny)return 1}else if(U&&z.hasAny)return-1;let W=0,q=0,fe;for(fe of N)fe.hasAny&&++W,fe.hasConversion&&++q;let de=0,Ne=0;for(fe of T)fe.hasAny&&++de,fe.hasConversion&&++Ne;if(W!==de)return W-de;if(Z&&P.hasConversion){if(!U||!z.hasConversion)return 1}else if(U&&z.hasConversion)return-1;if(q!==Ne)return q-Ne;if(Z){if(!U)return 1}else if(U)return-1;const Ge=(N.length-T.length)*(Z?-1:1);if(Ge!==0)return Ge;const He=[];let nr=0;for(let Lr=0;Lr<N.length;++Lr){const Ut=H(N[Lr],T[Lr]);He.push(Ut),nr+=Ut}if(nr!==0)return nr;let ir;for(ir of He)if(ir!==0)return ir;return 0}function Q(E){if(E.length===0)return[];const C=E.map(a);E.length>1&&C.sort((P,z)=>P.index-z.index);let N=C[0].conversionsTo;if(E.length===1)return N;N=N.concat([]);const T=new Set(E);for(let P=1;P<C.length;++P){let z;for(z of C[P].conversionsTo)T.has(z.from)||(N.push(z),T.add(z.from))}return N}function J(E,C){let N=C;if(E.some(P=>P.hasConversion)){const P=F(E),z=E.map(X);N=function(){const U=[],W=P?arguments.length-1:arguments.length;for(let q=0;q<W;q++)U[q]=z[q](arguments[q]);return P&&(U[W]=arguments[W].map(z[W])),C.apply(this,U)}}let T=N;if(F(E)){const P=E.length-1;T=function(){return N.apply(this,se(arguments,0,P).concat([se(arguments,P)]))}}return T}function X(E){let C,N,T,P;const z=[],Z=[];switch(E.types.forEach(function(U){U.conversion&&(z.push(a(U.conversion.from).test),Z.push(U.conversion.convert))}),Z.length){case 0:return function(W){return W};case 1:return C=z[0],T=Z[0],function(W){return C(W)?T(W):W};case 2:return C=z[0],N=z[1],T=Z[0],P=Z[1],function(W){return C(W)?T(W):N(W)?P(W):W};default:return function(W){for(let q=0;q<Z.length;q++)if(z[q](W))return Z[q](W);return W}}}function ee(E){function C(N,T,P){if(T<N.length){const z=N[T];let Z=[];if(z.restParam){const U=z.types.filter(S);U.length<z.types.length&&Z.push({types:U,name:"..."+U.map(W=>W.name).join("|"),hasAny:U.some(W=>W.isAny),hasConversion:!1,restParam:!0}),Z.push(z)}else Z=z.types.map(function(U){return{types:[U],name:U.name,hasAny:U.isAny,hasConversion:U.conversion,restParam:!1}});return $e(Z,function(U){return C(N,T+1,P.concat([U]))})}else return[P]}return C(E,0,[])}function ue(E,C){const N=Math.max(E.length,C.length);for(let U=0;U<N;U++){const W=B(E,U),q=B(C,U);let fe=!1,de;for(de of q)if(W.has(de)){fe=!0;break}if(!fe)return!1}const T=E.length,P=C.length,z=F(E),Z=F(C);return z?Z?T===P:P>=T:Z?T>=P:T===P}function oe(E){return E.map(C=>hr(C)?Ke(C.referToSelf.callback):lr(C)?Ie(C.referTo.references,C.referTo.callback):C)}function le(E,C,N){const T=[];let P;for(P of E){let z=N[P];if(typeof z!="number")throw new TypeError('No definition for referenced signature "'+P+'"');if(z=C[z],typeof z!="function")return!1;T.push(z)}return T}function Be(E,C,N){const T=oe(E),P=new Array(T.length).fill(!1);let z=!0;for(;z;){z=!1;let Z=!0;for(let U=0;U<T.length;++U){if(P[U])continue;const W=T[U];if(hr(W))T[U]=W.referToSelf.callback(N),T[U].referToSelf=W.referToSelf,P[U]=!0,Z=!1;else if(lr(W)){const q=le(W.referTo.references,T,C);q?(T[U]=W.referTo.callback.apply(this,q),T[U].referTo=W.referTo,P[U]=!0,Z=!1):z=!0}}if(Z&&z)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return T}function Ce(E){const C=/\bthis(\(|\.signatures\b)/;Object.keys(E).forEach(N=>{const T=E[N];if(C.test(T.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 be(E,C){if(o.createCount++,Object.keys(C).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&Ce(C);const N=[],T=[],P={},z=[];let Z;for(Z in C){if(!Object.prototype.hasOwnProperty.call(C,Z))continue;const ae=A(Z);if(!ae)continue;N.forEach(function(et){if(ue(et,ae))throw new TypeError('Conflicting signatures "'+d(et)+'" and "'+d(ae)+'".')}),N.push(ae);const Je=T.length;T.push(C[Z]);const il=ae.map(y);let Rt;for(Rt of ee(il)){const et=d(Rt);z.push({params:Rt,name:et,fn:Je}),Rt.every(ul=>!ul.hasConversion)&&(P[et]=Je)}}z.sort($);const U=Be(T,P,jr);let W;for(W in P)Object.prototype.hasOwnProperty.call(P,W)&&(P[W]=U[P[W]]);const q=[],fe=new Map;for(W of z)fe.has(W.name)||(W.fn=U[W.fn],q.push(W),fe.set(W.name,W));const de=q[0]&&q[0].params.length<=2&&!F(q[0].params),Ne=q[1]&&q[1].params.length<=2&&!F(q[1].params),Ge=q[2]&&q[2].params.length<=2&&!F(q[2].params),He=q[3]&&q[3].params.length<=2&&!F(q[3].params),nr=q[4]&&q[4].params.length<=2&&!F(q[4].params),ir=q[5]&&q[5].params.length<=2&&!F(q[5].params),Lr=de&&Ne&&Ge&&He&&nr&&ir;for(let ae=0;ae<q.length;++ae)q[ae].test=_(q[ae].params);const Ut=de?w(q[0].params[0]):ke,Mc=Ne?w(q[1].params[0]):ke,xc=Ge?w(q[2].params[0]):ke,Tc=He?w(q[3].params[0]):ke,Ic=nr?w(q[4].params[0]):ke,zc=ir?w(q[5].params[0]):ke,Oc=de?w(q[0].params[1]):ke,$c=Ne?w(q[1].params[1]):ke,Pc=Ge?w(q[2].params[1]):ke,qc=He?w(q[3].params[1]):ke,Uc=nr?w(q[4].params[1]):ke,Rc=ir?w(q[5].params[1]):ke;for(let ae=0;ae<q.length;++ae)q[ae].implementation=J(q[ae].params,q[ae].fn);const Lc=de?q[0].implementation:_r,Hc=Ne?q[1].implementation:_r,Zc=Ge?q[2].implementation:_r,Wc=He?q[3].implementation:_r,Vc=nr?q[4].implementation:_r,Gc=ir?q[5].implementation:_r,Jc=de?q[0].params.length:-1,kc=Ne?q[1].params.length:-1,Yc=Ge?q[2].params.length:-1,Xc=He?q[3].params.length:-1,Qc=nr?q[4].params.length:-1,Kc=ir?q[5].params.length:-1,jc=Lr?6:0,el=q.length,rl=q.map(ae=>ae.test),tl=q.map(ae=>ae.implementation),nl=function(){for(let Je=jc;Je<el;Je++)if(rl[Je](arguments))return tl[Je].apply(this,arguments);return o.onMismatch(E,arguments,q)};function jr(ae,Je){return arguments.length===Jc&&Ut(ae)&&Oc(Je)?Lc.apply(this,arguments):arguments.length===kc&&Mc(ae)&&$c(Je)?Hc.apply(this,arguments):arguments.length===Yc&&xc(ae)&&Pc(Je)?Zc.apply(this,arguments):arguments.length===Xc&&Tc(ae)&&qc(Je)?Wc.apply(this,arguments):arguments.length===Qc&&Ic(ae)&&Uc(Je)?Vc.apply(this,arguments):arguments.length===Kc&&zc(ae)&&Rc(Je)?Gc.apply(this,arguments):nl.apply(this,arguments)}try{Object.defineProperty(jr,"name",{value:E})}catch{}return jr.signatures=P,jr._typedFunctionData={signatures:q,signatureMap:fe},jr}function Fe(E,C,N){throw O(E,C,N)}function Le(E){return se(E,0,E.length-1)}function he(E){return E[E.length-1]}function se(E,C,N){return Array.prototype.slice.call(E,C,N)}function Qe(E,C){for(let N=0;N<E.length;N++)if(C(E[N]))return E[N]}function $e(E,C){return Array.prototype.concat.apply([],E.map(C))}function pe(){const E=Le(arguments).map(N=>d(A(N))),C=he(arguments);if(typeof C!="function")throw new TypeError("Callback function expected as last argument");return Ie(E,C)}function Ie(E,C){return{referTo:{references:E,callback:C}}}function Ke(E){if(typeof E!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:E}}}function lr(E){return E&&typeof E.referTo=="object"&&Array.isArray(E.referTo.references)&&typeof E.referTo.callback=="function"}function hr(E){return E&&typeof E.referToSelf=="object"&&typeof E.referToSelf.callback=="function"}function Ur(E,C){if(!E)return C;if(C&&C!==E){const N=new Error("Function names do not match (expected: "+E+", actual: "+C+")");throw N.data={actual:C,expected:E},N}return E}function Rr(E){let C;for(const N in E)Object.prototype.hasOwnProperty.call(E,N)&&(h(E[N])||typeof E[N].signature=="string")&&(C=Ur(C,E[N].name));return C}function ln(E,C){let N;for(N in C)if(Object.prototype.hasOwnProperty.call(C,N)){if(N in E&&C[N]!==E[N]){const T=new Error('Signature "'+N+'" is defined twice');throw T.data={signature:N,sourceFunction:C[N],destFunction:E[N]},T}E[N]=C[N]}}const Sc=o;o=function(E){const C=typeof E=="string",N=C?1:0;let T=C?E:"";const P={};for(let z=N;z<arguments.length;++z){const Z=arguments[z];let U={},W;if(typeof Z=="function"?(W=Z.name,typeof Z.signature=="string"?U[Z.signature]=Z:h(Z)&&(U=Z.signatures)):e(Z)&&(U=Z,C||(W=Rr(Z))),Object.keys(U).length===0){const q=new TypeError("Argument to 'typed' at index "+z+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw q.data={index:z,argument:Z},q}C||(T=Ur(T,W)),ln(P,U)}return be(T||"",P)},o.create=Fn,o.createCount=Sc.createCount,o.onMismatch=Fe,o.throwMismatchError=Fe,o.createError=O,o.clear=f,o.clearConversions=m,o.addTypes=s,o._findType=a,o.referTo=pe,o.referToSelf=Ke,o.convert=c,o.findSignature=p,o.find=D,o.isTypedFunction=h,o.warnAgainstDeprecatedThis=!0,o.addType=function(E,C){let N="any";C!==!1&&n.has("Object")&&(N="Object"),o.addTypes([E],N)};function ou(E){if(!E||typeof E.from!="string"||typeof E.to!="string"||typeof E.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(E.to===E.from)throw new SyntaxError('Illegal to define conversion from "'+E.from+'" to itself.')}return o.addConversion=function(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};ou(E);const N=a(E.to),T=N.conversionsTo.find(P=>P.from===E.from);if(T)if(C&&C.override)o.removeConversion({from:T.from,to:E.to,convert:T.convert});else throw new Error('There is already a conversion from "'+E.from+'" to "'+N.name+'"');N.conversionsTo.push({from:E.from,convert:E.convert,index:u++})},o.addConversions=function(E,C){E.forEach(N=>o.addConversion(N,C))},o.removeConversion=function(E){ou(E);const C=a(E.to),N=Qe(C.conversionsTo,P=>P.from===E.from);if(!N)throw new Error("Attempt to remove nonexistent conversion from "+E.from+" to "+E.to);if(N.convert!==E.convert)throw new Error("Conversion to remove does not match existing conversion");const T=C.conversionsTo.indexOf(N);C.conversionsTo.splice(T,1)},o.resolve=function(E,C){if(!h(E))throw new TypeError(yn);const N=E._typedFunctionData.signatures;for(let T=0;T<N.length;++T)if(N[T].test(C))return N[T];return null},o}const it=Fn();function V(e,r,t,n){function i(u){var o=Wu(u,r.map(Yu));return Ju(e,r,u),t(o)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function Ju(e,r,t){var n=r.filter(u=>!ku(u)).every(u=>t[u]!==void 0);if(!n){var i=r.filter(u=>t[u]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(i.map(u=>'"'.concat(u,'"')).join(", "),"."))}}function ku(e){return e&&e[0]==="?"}function Yu(e){return e&&e[0]==="?"?e.slice(1):e}function ye(e){return typeof e=="boolean"?!0:Number.isFinite(e)?e===Math.round(e):!1}var Xu=Math.log10||function(r){return Math.log(r)/Math.LN10};function Ht(e,r,t){var n={2:"0b",8:"0o",16:"0x"},i=n[r],u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ye(t))throw new Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ye(e))throw new Error("Value must be an integer");e<0&&(e=e+2**t),u="i".concat(t)}var o="";return e<0&&(e=-e,o="-"),"".concat(o).concat(i).concat(e.toString(r)).concat(u)}function Zt(e,r){if(typeof r=="function")return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:t,precision:n,wordSize:i}=En(r);switch(t){case"fixed":return An(e,n);case"exponential":return bn(e,n);case"engineering":return Qu(e,n);case"bin":return Ht(e,2,i);case"oct":return Ht(e,8,i);case"hex":return Ht(e,16,i);case"auto":return Ku(e,n,r).replace(/((\.\d*?)(0+))($|e)/,function(){var u=arguments[2],o=arguments[4];return u!=="."?u+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function En(e){var r="auto",t,n;if(e!==void 0)if(ne(e))t=e;else if(Ee(e))t=e.toNumber();else if(Lt(e))e.precision!==void 0&&(t=Cn(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),e.wordSize!==void 0&&(n=Cn(e.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),e.notation&&(r=e.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:r,precision:t,wordSize:n}}function Zr(e){var r=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),u=n.indexOf(".");i+=u!==-1?u-1:n.length-1;var o=n.replace(".","").replace(/^0*/,function(a){return i-=a.length,""}).replace(/0*$/,"").split("").map(function(a){return parseInt(a)});return o.length===0&&(o.push(0),i++),{sign:t,coefficients:o,exponent:i}}function Qu(e,r){if(isNaN(e)||!Number.isFinite(e))return String(e);var t=Zr(e),n=ut(t,r),i=n.exponent,u=n.coefficients,o=i%3===0?i:i<0?i-3-i%3:i-i%3;if(ne(r))for(;r>u.length||i-o+1>u.length;)u.push(0);else for(var a=Math.abs(i-o)-(u.length-1),s=0;s<a;s++)u.push(0);for(var f=Math.abs(i-o),m=1;f>0;)m++,f--;var l=u.slice(m).join(""),h=ne(r)&&l.length||l.match(/[1-9]/)?"."+l:"",p=u.slice(0,m).join("")+h+"e"+(i>=0?"+":"")+o.toString();return n.sign+p}function An(e,r){if(isNaN(e)||!Number.isFinite(e))return String(e);var t=Zr(e),n=typeof r=="number"?ut(t,t.exponent+1+r):t,i=n.coefficients,u=n.exponent+1,o=u+(r||0);return i.length<o&&(i=i.concat(Br(o-i.length))),u<0&&(i=Br(-u+1).concat(i),u=1),u<i.length&&i.splice(u,0,u===0?"0.":"."),n.sign+i.join("")}function bn(e,r){if(isNaN(e)||!Number.isFinite(Number(e)))return String(e);var t=Zr(e),n=r?ut(t,r):t,i=n.coefficients,u=n.exponent;i.length<r&&(i=i.concat(Br(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(u>=0?"+":"")+u}function Ku(e,r,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=_n(t?.lowerExp,-3),i=_n(t?.upperExp,5),u=Zr(e),o=r?ut(u,r):u;if(o.exponent<n||o.exponent>=i)return bn(e,r);var a=o.coefficients,s=o.exponent;a.length<r&&(a=a.concat(Br(r-a.length))),a=a.concat(Br(s-a.length+1+(a.length<r?r-a.length:0))),a=Br(-s).concat(a);var f=s>0?s:0;return f<a.length-1&&a.splice(f+1,0,"."),o.sign+a.join("")}function ut(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r){var i=n.splice(r,n.length-r);if(i[0]>=5){var u=r-1;for(n[u]++;n[u]===10;)n.pop(),u===0&&(n.unshift(0),t.exponent++,u++),u--,n[u]++}}return t}function Br(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function ju(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function je(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return isNaN(e)||isNaN(r)?!1:!Number.isFinite(e)||!Number.isFinite(r)?e===r:e===r?!0:Math.abs(e-r)<=Math.max(t*Math.max(Math.abs(e),Math.abs(r)),n)}function Cn(e,r){if(ne(e))return e;if(Ee(e))return e.toNumber();r()}function _n(e,r){return ne(e)?e:Ee(e)?e.toNumber():r}var Bn=function(){return Bn=it.create,it},eo=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],ro=V("typed",eo,function(r){var{BigNumber:t,Complex:n,DenseMatrix:i,Fraction:u}=r,o=Bn();return o.clear(),o.addTypes([{name:"number",test:ne},{name:"Complex",test:mn},{name:"BigNumber",test:Ee},{name:"bigint",test:pu},{name:"Fraction",test:dn},{name:"Unit",test:gn},{name:"identifier",test:a=>Me&&/^(?:[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-\u1C8A\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-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\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\uDDC0-\uDDF3\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\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\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\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\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-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\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\uDDC0-\uDDF3\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\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\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\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(a)},{name:"string",test:Me},{name:"Chain",test:Lu},{name:"Array",test:ve},{name:"Matrix",test:we},{name:"DenseMatrix",test:Du},{name:"SparseMatrix",test:mu},{name:"Range",test:vn},{name:"Index",test:nt},{name:"boolean",test:du},{name:"ResultSet",test:gu},{name:"Help",test:vu},{name:"function",test:wu},{name:"Date",test:yu},{name:"RegExp",test:Fu},{name:"null",test:Au},{name:"undefined",test:bu},{name:"AccessorNode",test:Cu},{name:"ArrayNode",test:_u},{name:"AssignmentNode",test:Bu},{name:"BlockNode",test:Nu},{name:"ConditionalNode",test:Su},{name:"ConstantNode",test:Mu},{name:"FunctionNode",test:Tu},{name:"FunctionAssignmentNode",test:xu},{name:"IndexNode",test:Iu},{name:"Node",test:zu},{name:"ObjectNode",test:Ou},{name:"OperatorNode",test:$u},{name:"ParenthesisNode",test:Pu},{name:"RangeNode",test:qu},{name:"RelationalNode",test:Uu},{name:"SymbolNode",test:Ru},{name:"Map",test:Eu},{name:"Object",test:Lt}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(s){if(t||ot(s),ju(s)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+s+"). Use function bignumber(x) to convert to BigNumber.");return new t(s)}},{from:"number",to:"Complex",convert:function(s){return n||at(s),new n(s,0)}},{from:"BigNumber",to:"Complex",convert:function(s){return n||at(s),new n(s.toNumber(),0)}},{from:"bigint",to:"number",convert:function(s){if(s>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+s+")");return Number(s)}},{from:"bigint",to:"BigNumber",convert:function(s){return t||ot(s),new t(s.toString())}},{from:"bigint",to:"Fraction",convert:function(s){return u||st(s),new u(s)}},{from:"Fraction",to:"BigNumber",convert:function(s){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(s){return n||at(s),new n(s.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(s){u||st(s);var f=new u(s);if(f.valueOf()!==s)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+s+"). Use function fraction(x) to convert to Fraction.");return f}},{from:"string",to:"number",convert:function(s){var f=Number(s);if(isNaN(f))throw new Error('Cannot convert "'+s+'" to a number');return f}},{from:"string",to:"BigNumber",convert:function(s){t||ot(s);try{return new t(s)}catch{throw new Error('Cannot convert "'+s+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(s){try{return BigInt(s)}catch{throw new Error('Cannot convert "'+s+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(s){u||st(s);try{return new u(s)}catch{throw new Error('Cannot convert "'+s+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(s){n||at(s);try{return new n(s)}catch{throw new Error('Cannot convert "'+s+'" to Complex')}}},{from:"boolean",to:"number",convert:function(s){return+s}},{from:"boolean",to:"BigNumber",convert:function(s){return t||ot(s),new t(+s)}},{from:"boolean",to:"bigint",convert:function(s){return BigInt(+s)}},{from:"boolean",to:"Fraction",convert:function(s){return u||st(s),new u(+s)}},{from:"boolean",to:"string",convert:function(s){return String(s)}},{from:"Array",to:"Matrix",convert:function(s){return i||to(),new i(s)}},{from:"Matrix",to:"Array",convert:function(s){return s.valueOf()}}]),o.onMismatch=(a,s,f)=>{var m=o.createError(a,s,f);if(["wrongType","mismatch"].includes(m.data.category)&&s.length===1&&tt(s[0])&&f.some(h=>!h.params.includes(","))){var l=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw l.data=m.data,l}throw m},o.onMismatch=(a,s,f)=>{var m=o.createError(a,s,f);if(["wrongType","mismatch"].includes(m.data.category)&&s.length===1&&tt(s[0])&&f.some(h=>!h.params.includes(","))){var l=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw l.data=m.data,l}throw m},o});function ot(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function at(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function to(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function st(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Nr=9e15,mr=1e9,Wt="0123456789abcdef",ft="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ct="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Vt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Nr,maxE:Nr,crypto:!1},Nn,sr,j=!0,lt="[DecimalError] ",dr=lt+"Invalid argument: ",Sn=lt+"Precision limit exceeded",Mn=lt+"crypto unavailable",xn="[object Decimal]",qe=Math.floor,Se=Math.pow,no=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,io=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,uo=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Tn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,er=1e7,K=7,oo=9007199254740991,ao=ft.length-1,Gt=ct.length-1,I={toStringTag:xn};I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),k(e)},I.ceil=function(){return k(new this.constructor(this),this.e+1,2)},I.clampedTo=I.clamp=function(e,r){var t,n=this,i=n.constructor;if(e=new i(e),r=new i(r),!e.s||!r.s)return new i(NaN);if(e.gt(r))throw Error(dr+r);return t=n.cmp(e),t<0?e:n.cmp(r)>0?r:new i(n)},I.comparedTo=I.cmp=function(e){var r,t,n,i,u=this,o=u.d,a=(e=new u.constructor(e)).d,s=u.s,f=e.s;if(!o||!a)return!s||!f?NaN:s!==f?s:o===a?0:!o^s<0?1:-1;if(!o[0]||!a[0])return o[0]?s:a[0]?-f:0;if(s!==f)return s;if(u.e!==e.e)return u.e>e.e^s<0?1:-1;for(n=o.length,i=a.length,r=0,t=n<i?n:i;r<t;++r)if(o[r]!==a[r])return o[r]>a[r]^s<0?1:-1;return n===i?0:n>i^s<0?1:-1},I.cosine=I.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=so(n,qn(n,t)),n.precision=e,n.rounding=r,k(sr==2||sr==3?t.neg():t,e,r,!0)):new n(1):new n(NaN)},I.cubeRoot=I.cbrt=function(){var e,r,t,n,i,u,o,a,s,f,m=this,l=m.constructor;if(!m.isFinite()||m.isZero())return new l(m);for(j=!1,u=m.s*Se(m.s*m,1/3),!u||Math.abs(u)==1/0?(t=ze(m.d),e=m.e,(u=(e-t.length+1)%3)&&(t+=u==1||u==-2?"0":"00"),u=Se(t,1/3),e=qe((e+1)/3)-(e%3==(e<0?-1:2)),u==1/0?t="5e"+e:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new l(t),n.s=m.s):n=new l(u.toString()),o=(e=l.precision)+3;;)if(a=n,s=a.times(a).times(a),f=s.plus(m),n=ce(f.plus(m).times(a),f.plus(s),o+2,1),ze(a.d).slice(0,o)===(t=ze(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(k(a,e+1,0),a.times(a).times(a).eq(m))){n=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(k(n,e+1,1),r=!n.times(n).times(n).eq(m));break}return j=!0,k(n,e,l.rounding,r)},I.decimalPlaces=I.dp=function(){var e,r=this.d,t=NaN;if(r){if(e=r.length-1,t=(e-qe(this.e/K))*K,e=r[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},I.dividedBy=I.div=function(e){return ce(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var r=this,t=r.constructor;return k(ce(r,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return this.cmp(e)===0},I.floor=function(){return k(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var r=this.cmp(e);return r==1||r===0},I.hyperbolicCosine=I.cosh=function(){var e,r,t,n,i,u=this,o=u.constructor,a=new o(1);if(!u.isFinite())return new o(u.s?1/0:NaN);if(u.isZero())return a;t=o.precision,n=o.rounding,o.precision=t+Math.max(u.e,u.sd())+4,o.rounding=1,i=u.d.length,i<32?(e=Math.ceil(i/3),r=(1/dt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),u=Sr(o,1,u.times(r),new o(1),!0);for(var s,f=e,m=new o(8);f--;)s=u.times(u),u=a.minus(s.times(m.minus(s.times(m))));return k(u,o.precision=t,o.rounding=n,!0)},I.hyperbolicSine=I.sinh=function(){var e,r,t,n,i=this,u=i.constructor;if(!i.isFinite()||i.isZero())return new u(i);if(r=u.precision,t=u.rounding,u.precision=r+Math.max(i.e,i.sd())+4,u.rounding=1,n=i.d.length,n<3)i=Sr(u,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/dt(5,e)),i=Sr(u,2,i,i,!0);for(var o,a=new u(5),s=new u(16),f=new u(20);e--;)o=i.times(i),i=i.times(a.plus(o.times(s.times(o).plus(f))))}return u.precision=r,u.rounding=t,k(i,r,t,!0)},I.hyperbolicTangent=I.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+7,n.rounding=1,ce(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)},I.inverseCosine=I.acos=function(){var e=this,r=e.constructor,t=e.abs().cmp(1),n=r.precision,i=r.rounding;return t!==-1?t===0?e.isNeg()?ar(r,n,i):new r(0):new r(NaN):e.isZero()?ar(r,n+4,i).times(.5):(r.precision=n+6,r.rounding=1,e=new r(1).minus(e).div(e.plus(1)).sqrt().atan(),r.precision=n,r.rounding=i,e.times(2))},I.inverseHyperbolicCosine=I.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(e=n.precision,r=n.rounding,n.precision=e+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,j=!1,t=t.times(t).minus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)},I.inverseHyperbolicSine=I.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,j=!1,t=t.times(t).plus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln())},I.inverseHyperbolicTangent=I.atanh=function(){var e,r,t,n,i=this,u=i.constructor;return i.isFinite()?i.e>=0?new u(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=u.precision,r=u.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?k(new u(i),e,r,!0):(u.precision=t=n-i.e,i=ce(i.plus(1),new u(1).minus(i),t+e,1),u.precision=e+4,u.rounding=1,i=i.ln(),u.precision=e,u.rounding=r,i.times(.5))):new u(NaN)},I.inverseSine=I.asin=function(){var e,r,t,n,i=this,u=i.constructor;return i.isZero()?new u(i):(r=i.abs().cmp(1),t=u.precision,n=u.rounding,r!==-1?r===0?(e=ar(u,t+4,n).times(.5),e.s=i.s,e):new u(NaN):(u.precision=t+6,u.rounding=1,i=i.div(new u(1).minus(i.times(i)).sqrt().plus(1)).atan(),u.precision=t,u.rounding=n,i.times(2)))},I.inverseTangent=I.atan=function(){var e,r,t,n,i,u,o,a,s,f=this,m=f.constructor,l=m.precision,h=m.rounding;if(f.isFinite()){if(f.isZero())return new m(f);if(f.abs().eq(1)&&l+4<=Gt)return o=ar(m,l+4,h).times(.25),o.s=f.s,o}else{if(!f.s)return new m(NaN);if(l+4<=Gt)return o=ar(m,l+4,h).times(.5),o.s=f.s,o}for(m.precision=a=l+10,m.rounding=1,t=Math.min(28,a/K+2|0),e=t;e;--e)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(j=!1,r=Math.ceil(a/K),n=1,s=f.times(f),o=new m(f),i=f;e!==-1;)if(i=i.times(s),u=o.minus(i.div(n+=2)),i=i.times(s),o=u.plus(i.div(n+=2)),o.d[r]!==void 0)for(e=r;o.d[e]===u.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),j=!0,k(o,m.precision=l,m.rounding=h,!0)},I.isFinite=function(){return!!this.d},I.isInteger=I.isInt=function(){return!!this.d&&qe(this.e/K)>this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&this.d[0]===0},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.log=function(e){var r,t,n,i,u,o,a,s,f=this,m=f.constructor,l=m.precision,h=m.rounding,p=5;if(e==null)e=new m(10),r=!0;else{if(e=new m(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new m(NaN);r=e.eq(10)}if(t=f.d,f.s<0||!t||!t[0]||f.eq(1))return new m(t&&!t[0]?-1/0:f.s!=1?NaN:t?0:1/0);if(r)if(t.length>1)u=!0;else{for(i=t[0];i%10===0;)i/=10;u=i!==1}if(j=!1,a=l+p,o=vr(f,a),n=r?Dt(m,a+10):vr(e,a),s=ce(o,n,a,1),Wr(s.d,i=l,h))do if(a+=10,o=vr(f,a),n=r?Dt(m,a+10):vr(e,a),s=ce(o,n,a,1),!u){+ze(s.d).slice(i+1,i+15)+1==1e14&&(s=k(s,l+1,0));break}while(Wr(s.d,i+=10,h));return j=!0,k(s,l,h)},I.minus=I.sub=function(e){var r,t,n,i,u,o,a,s,f,m,l,h,p=this,D=p.constructor;if(e=new D(e),!p.d||!e.d)return!p.s||!e.s?e=new D(NaN):p.d?e.s=-e.s:e=new D(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(f=p.d,h=e.d,a=D.precision,s=D.rounding,!f[0]||!h[0]){if(h[0])e.s=-e.s;else if(f[0])e=new D(p);else return new D(s===3?-0:0);return j?k(e,a,s):e}if(t=qe(e.e/K),m=qe(p.e/K),f=f.slice(),u=m-t,u){for(l=u<0,l?(r=f,u=-u,o=h.length):(r=h,t=m,o=f.length),n=Math.max(Math.ceil(a/K),o)+2,u>n&&(u=n,r.length=1),r.reverse(),n=u;n--;)r.push(0);r.reverse()}else{for(n=f.length,o=h.length,l=n<o,l&&(o=n),n=0;n<o;n++)if(f[n]!=h[n]){l=f[n]<h[n];break}u=0}for(l&&(r=f,f=h,h=r,e.s=-e.s),o=f.length,n=h.length-o;n>0;--n)f[o++]=0;for(n=h.length;n>u;){if(f[--n]<h[n]){for(i=n;i&&f[--i]===0;)f[i]=er-1;--f[i],f[n]+=er}f[n]-=h[n]}for(;f[--o]===0;)f.pop();for(;f[0]===0;f.shift())--t;return f[0]?(e.d=f,e.e=pt(f,t),j?k(e,a,s):e):new D(s===3?-0:0)},I.modulo=I.mod=function(e){var r,t=this,n=t.constructor;return e=new n(e),!t.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||t.d&&!t.d[0]?k(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(r=ce(t,e.abs(),0,3,1),r.s*=e.s):r=ce(t,e,0,n.modulo,1),r=r.times(e),j=!0,t.minus(r))},I.naturalExponential=I.exp=function(){return Jt(this)},I.naturalLogarithm=I.ln=function(){return vr(this)},I.negated=I.neg=function(){var e=new this.constructor(this);return e.s=-e.s,k(e)},I.plus=I.add=function(e){var r,t,n,i,u,o,a,s,f,m,l=this,h=l.constructor;if(e=new h(e),!l.d||!e.d)return!l.s||!e.s?e=new h(NaN):l.d||(e=new h(e.d||l.s===e.s?l:NaN)),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(f=l.d,m=e.d,a=h.precision,s=h.rounding,!f[0]||!m[0])return m[0]||(e=new h(l)),j?k(e,a,s):e;if(u=qe(l.e/K),n=qe(e.e/K),f=f.slice(),i=u-n,i){for(i<0?(t=f,i=-i,o=m.length):(t=m,n=u,o=f.length),u=Math.ceil(a/K),o=u>o?u+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=f.length,i=m.length,o-i<0&&(i=o,t=m,m=f,f=t),r=0;i;)r=(f[--i]=f[i]+m[i]+r)/er|0,f[i]%=er;for(r&&(f.unshift(r),++n),o=f.length;f[--o]==0;)f.pop();return e.d=f,e.e=pt(f,n),j?k(e,a,s):e},I.precision=I.sd=function(e){var r,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(dr+e);return t.d?(r=In(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r},I.round=function(){var e=this,r=e.constructor;return k(new r(e),e.e+1,r.rounding)},I.sine=I.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=co(n,qn(n,t)),n.precision=e,n.rounding=r,k(sr>2?t.neg():t,e,r,!0)):new n(NaN)},I.squareRoot=I.sqrt=function(){var e,r,t,n,i,u,o=this,a=o.d,s=o.e,f=o.s,m=o.constructor;if(f!==1||!a||!a[0])return new m(!f||f<0&&(!a||a[0])?NaN:a?o:1/0);for(j=!1,f=Math.sqrt(+o),f==0||f==1/0?(r=ze(a),(r.length+s)%2==0&&(r+="0"),f=Math.sqrt(r),s=qe((s+1)/2)-(s<0||s%2),f==1/0?r="5e"+s:(r=f.toExponential(),r=r.slice(0,r.indexOf("e")+1)+s),n=new m(r)):n=new m(f.toString()),t=(s=m.precision)+3;;)if(u=n,n=u.plus(ce(o,u,t+2,1)).times(.5),ze(u.d).slice(0,t)===(r=ze(n.d)).slice(0,t))if(r=r.slice(t-3,t+1),r=="9999"||!i&&r=="4999"){if(!i&&(k(u,s+1,0),u.times(u).eq(o))){n=u;break}t+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(k(n,s+1,1),e=!n.times(n).eq(o));break}return j=!0,k(n,s,m.rounding,e)},I.tangent=I.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+10,n.rounding=1,t=t.sin(),t.s=1,t=ce(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,k(sr==2||sr==4?t.neg():t,e,r,!0)):new n(NaN)},I.times=I.mul=function(e){var r,t,n,i,u,o,a,s,f,m=this,l=m.constructor,h=m.d,p=(e=new l(e)).d;if(e.s*=m.s,!h||!h[0]||!p||!p[0])return new l(!e.s||h&&!h[0]&&!p||p&&!p[0]&&!h?NaN:!h||!p?e.s/0:e.s*0);for(t=qe(m.e/K)+qe(e.e/K),s=h.length,f=p.length,s<f&&(u=h,h=p,p=u,o=s,s=f,f=o),u=[],o=s+f,n=o;n--;)u.push(0);for(n=f;--n>=0;){for(r=0,i=s+n;i>n;)a=u[i]+p[n]*h[i-n-1]+r,u[i--]=a%er|0,r=a/er|0;u[i]=(u[i]+r)%er|0}for(;!u[--o];)u.pop();return r?++t:u.shift(),e.d=u,e.e=pt(u,t),j?k(e,l.precision,l.rounding):e},I.toBinary=function(e,r){return kt(this,2,e,r)},I.toDecimalPlaces=I.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),e===void 0?t:(Ze(e,0,mr),r===void 0?r=n.rounding:Ze(r,0,8),k(t,e+t.e+1,r))},I.toExponential=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=or(n,!0):(Ze(e,0,mr),r===void 0?r=i.rounding:Ze(r,0,8),n=k(new i(n),e+1,r),t=or(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toFixed=function(e,r){var t,n,i=this,u=i.constructor;return e===void 0?t=or(i):(Ze(e,0,mr),r===void 0?r=u.rounding:Ze(r,0,8),n=k(new u(i),e+i.e+1,r),t=or(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},I.toFraction=function(e){var r,t,n,i,u,o,a,s,f,m,l,h,p=this,D=p.d,c=p.constructor;if(!D)return new c(p);if(f=t=new c(1),n=s=new c(0),r=new c(n),u=r.e=In(D)-p.e-1,o=u%K,r.d[0]=Se(10,o<0?K+o:o),e==null)e=u>0?r:f;else{if(a=new c(e),!a.isInt()||a.lt(f))throw Error(dr+a);e=a.gt(r)?u>0?r:f:a}for(j=!1,a=new c(ze(D)),m=c.precision,c.precision=u=D.length*K*2;l=ce(a,r,0,1,1),i=t.plus(l.times(n)),i.cmp(e)!=1;)t=n,n=i,i=f,f=s.plus(l.times(i)),s=i,i=r,r=a.minus(l.times(i)),a=i;return i=ce(e.minus(t),n,0,1,1),s=s.plus(i.times(f)),t=t.plus(i.times(n)),s.s=f.s=p.s,h=ce(f,n,u,1).minus(p).abs().cmp(ce(s,t,u,1).minus(p).abs())<1?[f,n]:[s,t],c.precision=m,j=!0,h},I.toHexadecimal=I.toHex=function(e,r){return kt(this,16,e,r)},I.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),e==null){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),r===void 0?r=n.rounding:Ze(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(j=!1,t=ce(t,e,0,r,1).times(e),j=!0,k(t)):(e.s=t.s,t=e),t},I.toNumber=function(){return+this},I.toOctal=function(e,r){return kt(this,8,e,r)},I.toPower=I.pow=function(e){var r,t,n,i,u,o,a=this,s=a.constructor,f=+(e=new s(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new s(Se(+a,f));if(a=new s(a),a.eq(1))return a;if(n=s.precision,u=s.rounding,e.eq(1))return k(a,n,u);if(r=qe(e.e/K),r>=e.d.length-1&&(t=f<0?-f:f)<=oo)return i=zn(s,a,t,n),e.s<0?new s(1).div(i):k(i,n,u);if(o=a.s,o<0){if(r<e.d.length-1)return new s(NaN);if((e.d[r]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=Se(+a,f),r=t==0||!isFinite(t)?qe(f*(Math.log("0."+ze(a.d))/Math.LN10+a.e+1)):new s(t+"").e,r>s.maxE+1||r<s.minE-1?new s(r>0?o/0:0):(j=!1,s.rounding=a.s=1,t=Math.min(12,(r+"").length),i=Jt(e.times(vr(a,n+t)),n),i.d&&(i=k(i,n+5,1),Wr(i.d,n,u)&&(r=n+10,i=k(Jt(e.times(vr(a,r+t)),r),r+5,1),+ze(i.d).slice(n+1,n+15)+1==1e14&&(i=k(i,n+1,0)))),i.s=o,j=!0,s.rounding=u,k(i,n,u))},I.toPrecision=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=or(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Ze(e,1,mr),r===void 0?r=i.rounding:Ze(r,0,8),n=k(new i(n),e,r),t=or(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toSignificantDigits=I.toSD=function(e,r){var t=this,n=t.constructor;return e===void 0?(e=n.precision,r=n.rounding):(Ze(e,1,mr),r===void 0?r=n.rounding:Ze(r,0,8)),k(new n(t),e,r)},I.toString=function(){var e=this,r=e.constructor,t=or(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},I.truncated=I.trunc=function(){return k(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var e=this,r=e.constructor,t=or(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};function ze(e){var r,t,n,i=e.length-1,u="",o=e[0];if(i>0){for(u+=o,r=1;r<i;r++)n=e[r]+"",t=K-n.length,t&&(u+=gr(t)),u+=n;o=e[r],n=o+"",t=K-n.length,t&&(u+=gr(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return u+o}function Ze(e,r,t){if(e!==~~e||e<r||e>t)throw Error(dr+e)}function Wr(e,r,t,n){var i,u,o,a;for(u=e[0];u>=10;u/=10)--r;return--r<0?(r+=K,i=0):(i=Math.ceil((r+1)/K),r%=K),u=Se(10,K-r),a=e[i]%u|0,n==null?r<3?(r==0?a=a/100|0:r==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==u||t>3&&a+1==u/2)&&(e[i+1]/u/100|0)==Se(10,r-2)-1||(a==u/2||a==0)&&(e[i+1]/u/100|0)==0:r<4?(r==0?a=a/1e3|0:r==1?a=a/100|0:r==2&&(a=a/10|0),o=(n||t<4)&&a==9999||!n&&t>3&&a==4999):o=((n||t<4)&&a+1==u||!n&&t>3&&a+1==u/2)&&(e[i+1]/u/1e3|0)==Se(10,r-3)-1,o}function ht(e,r,t){for(var n,i=[0],u,o=0,a=e.length;o<a;){for(u=i.length;u--;)i[u]*=r;for(i[0]+=Wt.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function so(e,r){var t,n,i;if(r.isZero())return r;n=r.d.length,n<32?(t=Math.ceil(n/3),i=(1/dt(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Sr(e,1,r.times(i),new e(1));for(var u=t;u--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}var ce=(function(){function e(n,i,u){var o,a=0,s=n.length;for(n=n.slice();s--;)o=n[s]*i+a,n[s]=o%u|0,a=o/u|0;return a&&n.unshift(a),n}function r(n,i,u,o){var a,s;if(u!=o)s=u>o?1:-1;else for(a=s=0;a<u;a++)if(n[a]!=i[a]){s=n[a]>i[a]?1:-1;break}return s}function t(n,i,u,o){for(var a=0;u--;)n[u]-=a,a=n[u]<i[u]?1:0,n[u]=a*o+n[u]-i[u];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,u,o,a,s){var f,m,l,h,p,D,c,d,v,y,g,A,F,w,_,b,B,S,x,O,G=n.constructor,R=n.s==i.s?1:-1,H=n.d,$=i.d;if(!H||!H[0]||!$||!$[0])return new G(!n.s||!i.s||(H?$&&H[0]==$[0]:!$)?NaN:H&&H[0]==0||!$?R*0:R/0);for(s?(p=1,m=n.e-i.e):(s=er,p=K,m=qe(n.e/p)-qe(i.e/p)),x=$.length,B=H.length,v=new G(R),y=v.d=[],l=0;$[l]==(H[l]||0);l++);if($[l]>(H[l]||0)&&m--,u==null?(w=u=G.precision,o=G.rounding):a?w=u+(n.e-i.e)+1:w=u,w<0)y.push(1),D=!0;else{if(w=w/p+2|0,l=0,x==1){for(h=0,$=$[0],w++;(l<B||h)&&w--;l++)_=h*s+(H[l]||0),y[l]=_/$|0,h=_%$|0;D=h||l<B}else{for(h=s/($[0]+1)|0,h>1&&($=e($,h,s),H=e(H,h,s),x=$.length,B=H.length),b=x,g=H.slice(0,x),A=g.length;A<x;)g[A++]=0;O=$.slice(),O.unshift(0),S=$[0],$[1]>=s/2&&++S;do h=0,f=r($,g,x,A),f<0?(F=g[0],x!=A&&(F=F*s+(g[1]||0)),h=F/S|0,h>1?(h>=s&&(h=s-1),c=e($,h,s),d=c.length,A=g.length,f=r(c,g,d,A),f==1&&(h--,t(c,x<d?O:$,d,s))):(h==0&&(f=h=1),c=$.slice()),d=c.length,d<A&&c.unshift(0),t(g,c,A,s),f==-1&&(A=g.length,f=r($,g,x,A),f<1&&(h++,t(g,x<A?O:$,A,s))),A=g.length):f===0&&(h++,g=[0]),y[l++]=h,f&&g[0]?g[A++]=H[b]||0:(g=[H[b]],A=1);while((b++<B||g[0]!==void 0)&&w--);D=g[0]!==void 0}y[0]||y.shift()}if(p==1)v.e=m,Nn=D;else{for(l=1,h=y[0];h>=10;h/=10)l++;v.e=l+m*p-1,k(v,a?u+v.e+1:u,o,D)}return v}})();function k(e,r,t,n){var i,u,o,a,s,f,m,l,h,p=e.constructor;e:if(r!=null){if(l=e.d,!l)return e;for(i=1,a=l[0];a>=10;a/=10)i++;if(u=r-i,u<0)u+=K,o=r,m=l[h=0],s=m/Se(10,i-o-1)%10|0;else if(h=Math.ceil((u+1)/K),a=l.length,h>=a)if(n){for(;a++<=h;)l.push(0);m=s=0,i=1,u%=K,o=u-K+1}else break e;else{for(m=a=l[h],i=1;a>=10;a/=10)i++;u%=K,o=u-K+i,s=o<0?0:m/Se(10,i-o-1)%10|0}if(n=n||r<0||l[h+1]!==void 0||(o<0?m:m%Se(10,i-o-1)),f=t<4?(s||n)&&(t==0||t==(e.s<0?3:2)):s>5||s==5&&(t==4||n||t==6&&(u>0?o>0?m/Se(10,i-o):0:l[h-1])%10&1||t==(e.s<0?8:7)),r<1||!l[0])return l.length=0,f?(r-=e.e+1,l[0]=Se(10,(K-r%K)%K),e.e=-r||0):l[0]=e.e=0,e;if(u==0?(l.length=h,a=1,h--):(l.length=h+1,a=Se(10,K-u),l[h]=o>0?(m/Se(10,i-o)%Se(10,o)|0)*a:0),f)for(;;)if(h==0){for(u=1,o=l[0];o>=10;o/=10)u++;for(o=l[0]+=a,a=1;o>=10;o/=10)a++;u!=a&&(e.e++,l[0]==er&&(l[0]=1));break}else{if(l[h]+=a,l[h]!=er)break;l[h--]=0,a=1}for(u=l.length;l[--u]===0;)l.pop()}return j&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function or(e,r,t){if(!e.isFinite())return Pn(e);var n,i=e.e,u=ze(e.d),o=u.length;return r?(t&&(n=t-o)>0?u=u.charAt(0)+"."+u.slice(1)+gr(n):o>1&&(u=u.charAt(0)+"."+u.slice(1)),u=u+(e.e<0?"e":"e+")+e.e):i<0?(u="0."+gr(-i-1)+u,t&&(n=t-o)>0&&(u+=gr(n))):i>=o?(u+=gr(i+1-o),t&&(n=t-i-1)>0&&(u=u+"."+gr(n))):((n=i+1)<o&&(u=u.slice(0,n)+"."+u.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(u+="."),u+=gr(n))),u}function pt(e,r){var t=e[0];for(r*=K;t>=10;t/=10)r++;return r}function Dt(e,r,t){if(r>ao)throw j=!0,t&&(e.precision=t),Error(Sn);return k(new e(ft),r,1,!0)}function ar(e,r,t){if(r>Gt)throw Error(Sn);return k(new e(ct),r,t,!0)}function In(e){var r=e.length-1,t=r*K+1;if(r=e[r],r){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function gr(e){for(var r="";e--;)r+="0";return r}function zn(e,r,t,n){var i,u=new e(1),o=Math.ceil(n/K+4);for(j=!1;;){if(t%2&&(u=u.times(r),Un(u.d,o)&&(i=!0)),t=qe(t/2),t===0){t=u.d.length-1,i&&u.d[t]===0&&++u.d[t];break}r=r.times(r),Un(r.d,o)}return j=!0,u}function On(e){return e.d[e.d.length-1]&1}function $n(e,r,t){for(var n,i,u=new e(r[0]),o=0;++o<r.length;){if(i=new e(r[o]),!i.s){u=i;break}n=u.cmp(i),(n===t||n===0&&u.s===t)&&(u=i)}return u}function Jt(e,r){var t,n,i,u,o,a,s,f=0,m=0,l=0,h=e.constructor,p=h.rounding,D=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(r==null?(j=!1,s=D):s=r,a=new h(.03125);e.e>-2;)e=e.times(a),l+=5;for(n=Math.log(Se(2,l))/Math.LN10*2+5|0,s+=n,t=u=o=new h(1),h.precision=s;;){if(u=k(u.times(e),s,1),t=t.times(++m),a=o.plus(ce(u,t,s,1)),ze(a.d).slice(0,s)===ze(o.d).slice(0,s)){for(i=l;i--;)o=k(o.times(o),s,1);if(r==null)if(f<3&&Wr(o.d,s-n,p,f))h.precision=s+=10,t=u=a=new h(1),m=0,f++;else return k(o,h.precision=D,p,j=!0);else return h.precision=D,o}o=a}}function vr(e,r){var t,n,i,u,o,a,s,f,m,l,h,p=1,D=10,c=e,d=c.d,v=c.constructor,y=v.rounding,g=v.precision;if(c.s<0||!d||!d[0]||!c.e&&d[0]==1&&d.length==1)return new v(d&&!d[0]?-1/0:c.s!=1?NaN:d?0:c);if(r==null?(j=!1,m=g):m=r,v.precision=m+=D,t=ze(d),n=t.charAt(0),Math.abs(u=c.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)c=c.times(e),t=ze(c.d),n=t.charAt(0),p++;u=c.e,n>1?(c=new v("0."+t),u++):c=new v(n+"."+t.slice(1))}else return f=Dt(v,m+2,g).times(u+""),c=vr(new v(n+"."+t.slice(1)),m-D).plus(f),v.precision=g,r==null?k(c,g,y,j=!0):c;for(l=c,s=o=c=ce(c.minus(1),c.plus(1),m,1),h=k(c.times(c),m,1),i=3;;){if(o=k(o.times(h),m,1),f=s.plus(ce(o,new v(i),m,1)),ze(f.d).slice(0,m)===ze(s.d).slice(0,m))if(s=s.times(2),u!==0&&(s=s.plus(Dt(v,m+2,g).times(u+""))),s=ce(s,new v(p),m,1),r==null)if(Wr(s.d,m-D,y,a))v.precision=m+=D,f=o=c=ce(l.minus(1),l.plus(1),m,1),h=k(c.times(c),m,1),i=a=1;else return k(s,v.precision=g,y,j=!0);else return v.precision=g,s;s=f,i+=2}}function Pn(e){return String(e.s*e.s/0)}function mt(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;r.charCodeAt(n)===48;n++);for(i=r.length;r.charCodeAt(i-1)===48;--i);if(r=r.slice(n,i),r){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%K,t<0&&(n+=K),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=K;n<i;)e.d.push(+r.slice(n,n+=K));r=r.slice(n),n=K-r.length}else n-=i;for(;n--;)r+="0";e.d.push(+r),j&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function fo(e,r){var t,n,i,u,o,a,s,f,m;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),Tn.test(r))return mt(e,r)}else if(r==="Infinity"||r==="NaN")return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(io.test(r))t=16,r=r.toLowerCase();else if(no.test(r))t=2;else if(uo.test(r))t=8;else throw Error(dr+r);for(u=r.search(/p/i),u>0?(s=+r.slice(u+1),r=r.substring(2,u)):r=r.slice(2),u=r.indexOf("."),o=u>=0,n=e.constructor,o&&(r=r.replace(".",""),a=r.length,u=a-u,i=zn(n,new n(t),u,u*2)),f=ht(r,t,er),m=f.length-1,u=m;f[u]===0;--u)f.pop();return u<0?new n(e.s*0):(e.e=pt(f,m),e.d=f,j=!1,o&&(e=ce(e,i,a*4)),s&&(e=e.times(Math.abs(s)<54?Se(2,s):Mr.pow(2,s))),j=!0,e)}function co(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Sr(e,2,r,r);t=1.4*Math.sqrt(n),t=t>16?16:t|0,r=r.times(1/dt(5,t)),r=Sr(e,2,r,r);for(var i,u=new e(5),o=new e(16),a=new e(20);t--;)i=r.times(r),r=r.times(u.plus(i.times(o.times(i).minus(a))));return r}function Sr(e,r,t,n,i){var u,o,a,s,f=e.precision,m=Math.ceil(f/K);for(j=!1,s=t.times(t),a=new e(n);;){if(o=ce(a.times(s),new e(r++*r++),f,1),a=i?n.plus(o):n.minus(o),n=ce(o.times(s),new e(r++*r++),f,1),o=a.plus(n),o.d[m]!==void 0){for(u=m;o.d[u]===a.d[u]&&u--;);if(u==-1)break}u=a,a=n,n=o,o=u}return j=!0,o.d.length=m+1,o}function dt(e,r){for(var t=e;--r;)t*=e;return t}function qn(e,r){var t,n=r.s<0,i=ar(e,e.precision,1),u=i.times(.5);if(r=r.abs(),r.lte(u))return sr=n?4:1,r;if(t=r.divToInt(i),t.isZero())sr=n?3:2;else{if(r=r.minus(t.times(i)),r.lte(u))return sr=On(t)?n?2:3:n?4:1,r;sr=On(t)?n?1:4:n?3:2}return r.minus(i).abs()}function kt(e,r,t,n){var i,u,o,a,s,f,m,l,h,p=e.constructor,D=t!==void 0;if(D?(Ze(t,1,mr),n===void 0?n=p.rounding:Ze(n,0,8)):(t=p.precision,n=p.rounding),!e.isFinite())m=Pn(e);else{for(m=or(e),o=m.indexOf("."),D?(i=2,r==16?t=t*4-3:r==8&&(t=t*3-2)):i=r,o>=0&&(m=m.replace(".",""),h=new p(1),h.e=m.length-o,h.d=ht(or(h),10,i),h.e=h.d.length),l=ht(m,10,i),u=s=l.length;l[--s]==0;)l.pop();if(!l[0])m=D?"0p+0":"0";else{if(o<0?u--:(e=new p(e),e.d=l,e.e=u,e=ce(e,h,t,n,0,i),l=e.d,u=e.e,f=Nn),o=l[t],a=i/2,f=f||l[t+1]!==void 0,f=n<4?(o!==void 0||f)&&(n===0||n===(e.s<0?3:2)):o>a||o===a&&(n===4||f||n===6&&l[t-1]&1||n===(e.s<0?8:7)),l.length=t,f)for(;++l[--t]>i-1;)l[t]=0,t||(++u,l.unshift(1));for(s=l.length;!l[s-1];--s);for(o=0,m="";o<s;o++)m+=Wt.charAt(l[o]);if(D){if(s>1)if(r==16||r==8){for(o=r==16?4:3,--s;s%o;s++)m+="0";for(l=ht(m,i,r),s=l.length;!l[s-1];--s);for(o=1,m="1.";o<s;o++)m+=Wt.charAt(l[o])}else m=m.charAt(0)+"."+m.slice(1);m=m+(u<0?"p":"p+")+u}else if(u<0){for(;++u;)m="0"+m;m="0."+m}else if(++u>s)for(u-=s;u--;)m+="0";else u<s&&(m=m.slice(0,u)+"."+m.slice(u))}m=(r==16?"0x":r==2?"0b":r==8?"0o":"")+m}return e.s<0?"-"+m:m}function Un(e,r){if(e.length>r)return e.length=r,!0}function lo(e){return new this(e).abs()}function ho(e){return new this(e).acos()}function po(e){return new this(e).acosh()}function Do(e,r){return new this(e).plus(r)}function mo(e){return new this(e).asin()}function go(e){return new this(e).asinh()}function vo(e){return new this(e).atan()}function wo(e){return new this(e).atanh()}function yo(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,u=n+4;return!e.s||!r.s?t=new this(NaN):!e.d&&!r.d?(t=ar(this,u,1).times(r.s>0?.25:.75),t.s=e.s):!r.d||e.isZero()?(t=r.s<0?ar(this,n,i):new this(0),t.s=e.s):!e.d||r.isZero()?(t=ar(this,u,1).times(.5),t.s=e.s):r.s<0?(this.precision=u,this.rounding=1,t=this.atan(ce(e,r,u,1)),r=ar(this,u,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(ce(e,r,u,1)),t}function Fo(e){return new this(e).cbrt()}function Eo(e){return k(e=new this(e),e.e+1,2)}function Ao(e,r,t){return new this(e).clamp(r,t)}function bo(e){if(!e||typeof e!="object")throw Error(lt+"Object expected");var r,t,n,i=e.defaults===!0,u=["precision",1,mr,"rounding",0,8,"toExpNeg",-Nr,0,"toExpPos",0,Nr,"maxE",0,Nr,"minE",-Nr,0,"modulo",0,9];for(r=0;r<u.length;r+=3)if(t=u[r],i&&(this[t]=Vt[t]),(n=e[t])!==void 0)if(qe(n)===n&&n>=u[r+1]&&n<=u[r+2])this[t]=n;else throw Error(dr+t+": "+n);if(t="crypto",i&&(this[t]=Vt[t]),(n=e[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Mn);else this[t]=!1;else throw Error(dr+t+": "+n);return this}function Co(e){return new this(e).cos()}function _o(e){return new this(e).cosh()}function Rn(e){var r,t,n;function i(u){var o,a,s,f=this;if(!(f instanceof i))return new i(u);if(f.constructor=i,Ln(u)){f.s=u.s,j?!u.d||u.e>i.maxE?(f.e=NaN,f.d=null):u.e<i.minE?(f.e=0,f.d=[0]):(f.e=u.e,f.d=u.d.slice()):(f.e=u.e,f.d=u.d?u.d.slice():u.d);return}if(s=typeof u,s==="number"){if(u===0){f.s=1/u<0?-1:1,f.e=0,f.d=[0];return}if(u<0?(u=-u,f.s=-1):f.s=1,u===~~u&&u<1e7){for(o=0,a=u;a>=10;a/=10)o++;j?o>i.maxE?(f.e=NaN,f.d=null):o<i.minE?(f.e=0,f.d=[0]):(f.e=o,f.d=[u]):(f.e=o,f.d=[u]);return}if(u*0!==0){u||(f.s=NaN),f.e=NaN,f.d=null;return}return mt(f,u.toString())}if(s==="string")return(a=u.charCodeAt(0))===45?(u=u.slice(1),f.s=-1):(a===43&&(u=u.slice(1)),f.s=1),Tn.test(u)?mt(f,u):fo(f,u);if(s==="bigint")return u<0?(u=-u,f.s=-1):f.s=1,mt(f,u.toString());throw Error(dr+u)}if(i.prototype=I,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=bo,i.clone=Rn,i.isDecimal=Ln,i.abs=lo,i.acos=ho,i.acosh=po,i.add=Do,i.asin=mo,i.asinh=go,i.atan=vo,i.atanh=wo,i.atan2=yo,i.cbrt=Fo,i.ceil=Eo,i.clamp=Ao,i.cos=Co,i.cosh=_o,i.div=Bo,i.exp=No,i.floor=So,i.hypot=Mo,i.ln=xo,i.log=To,i.log10=zo,i.log2=Io,i.max=Oo,i.min=$o,i.mod=Po,i.mul=qo,i.pow=Uo,i.random=Ro,i.round=Lo,i.sign=Ho,i.sin=Zo,i.sinh=Wo,i.sqrt=Vo,i.sub=Go,i.sum=Jo,i.tan=ko,i.tanh=Yo,i.trunc=Xo,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<n.length;)e.hasOwnProperty(t=n[r++])||(e[t]=this[t]);return i.config(e),i}function Bo(e,r){return new this(e).div(r)}function No(e){return new this(e).exp()}function So(e){return k(e=new this(e),e.e+1,3)}function Mo(){var e,r,t=new this(0);for(j=!1,e=0;e<arguments.length;)if(r=new this(arguments[e++]),r.d)t.d&&(t=t.plus(r.times(r)));else{if(r.s)return j=!0,new this(1/0);t=r}return j=!0,t.sqrt()}function Ln(e){return e instanceof Mr||e&&e.toStringTag===xn||!1}function xo(e){return new this(e).ln()}function To(e,r){return new this(e).log(r)}function Io(e){return new this(e).log(2)}function zo(e){return new this(e).log(10)}function Oo(){return $n(this,arguments,-1)}function $o(){return $n(this,arguments,1)}function Po(e,r){return new this(e).mod(r)}function qo(e,r){return new this(e).mul(r)}function Uo(e,r){return new this(e).pow(r)}function Ro(e){var r,t,n,i,u=0,o=new this(1),a=[];if(e===void 0?e=this.precision:Ze(e,1,mr),n=Math.ceil(e/K),this.crypto)if(crypto.getRandomValues)for(r=crypto.getRandomValues(new Uint32Array(n));u<n;)i=r[u],i>=429e7?r[u]=crypto.getRandomValues(new Uint32Array(1))[0]:a[u++]=i%1e7;else if(crypto.randomBytes){for(r=crypto.randomBytes(n*=4);u<n;)i=r[u]+(r[u+1]<<8)+(r[u+2]<<16)+((r[u+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(r,u):(a.push(i%1e7),u+=4);u=n/4}else throw Error(Mn);else for(;u<n;)a[u++]=Math.random()*1e7|0;for(n=a[--u],e%=K,n&&e&&(i=Se(10,K-e),a[u]=(n/i|0)*i);a[u]===0;u--)a.pop();if(u<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=K)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<K&&(t-=K-n)}return o.e=t,o.d=a,o}function Lo(e){return k(e=new this(e),e.e+1,this.rounding)}function Ho(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Zo(e){return new this(e).sin()}function Wo(e){return new this(e).sinh()}function Vo(e){return new this(e).sqrt()}function Go(e,r){return new this(e).sub(r)}function Jo(){var e=0,r=arguments,t=new this(r[e]);for(j=!1;t.s&&++e<r.length;)t=t.plus(r[e]);return j=!0,k(t,this.precision,this.rounding)}function ko(e){return new this(e).tan()}function Yo(e){return new this(e).tanh()}function Xo(e){return k(e=new this(e),e.e+1,1)}I[Symbol.for("nodejs.util.inspect.custom")]=I.toString,I[Symbol.toStringTag]="Decimal";var Mr=I.constructor=Rn(Vt);ft=new Mr(ft),ct=new Mr(ct);var Qo="BigNumber",Ko=["?on","config"],jo=V(Qo,Ko,e=>{var{on:r,config:t}=e,n=Mr.clone({precision:t.precision,modulo:Mr.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(i){return new n(i.value)},r&&r("config",function(i,u){i.precision!==u.precision&&n.config({precision:i.precision})}),n},{isClass:!0});const Ue=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},Ye=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},ea=function(e){const r=Math.PI/4;if(-r>e||e>r)return Math.cos(e)-1;const t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Yt=function(e,r){return e=Math.abs(e),r=Math.abs(r),e<r&&([e,r]=[r,e]),e<1e8?Math.sqrt(e*e+r*r):(r/=e,e*Math.sqrt(1+r*r))},xr=function(){throw SyntaxError("Invalid Param")};function Xt(e,r){const t=Math.abs(e),n=Math.abs(r);return e===0?Math.log(n):r===0?Math.log(t):t<3e3&&n<3e3?Math.log(e*e+r*r)*.5:(e=e*.5,r=r*.5,.5*Math.log(e*e+r*r)+Math.LN2)}const ra={re:0,im:0},Er=function(e,r){const t=ra;if(e==null)t.re=t.im=0;else if(r!==void 0)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return M.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return M.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else e.length===2?(t.re=e[0],t.im=e[1]):xr();break;case"string":t.im=t.re=0;const n=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let i=1,u=0;n===null&&xr();for(let o=0;o<n.length;o++){const a=n[o];a===" "||a===" "||a===`
|
|
9
|
-
`||(a==="+"?i++:a==="-"?u++:a==="i"||a==="I"?(i+u===0&&xr(),n[o+1]!==" "&&!isNaN(n[o+1])?(t.im+=parseFloat((u%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((u%2?"-":"")+"1"),i=u=0):((i+u===0||isNaN(a))&&xr(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((u%2?"-":"")+a),o++):t.re+=parseFloat((u%2?"-":"")+a),i=u=0))}i+u>0&&xr();break;case"number":t.im=0,t.re=e;break;default:xr()}return isNaN(t.re)||isNaN(t.im),t};function M(e,r){if(!(this instanceof M))return new M(e,r);const t=Er(e,r);this.re=t.re,this.im=t.im}M.prototype={re:0,im:0,sign:function(){const e=Yt(this.re,this.im);return new M(this.re/e,this.im/e)},add:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?M.NAN:M.INFINITY:new M(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?M.NAN:M.INFINITY:new M(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;return n&&o||i&&u?M.NAN:n||i?M.INFINITY:t.im===0&&this.im===0?new M(this.re*t.re,0):new M(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;if(u&&o||n&&i)return M.NAN;if(o||n)return M.INFINITY;if(u||i)return M.ZERO;if(t.im===0)return new M(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const a=t.re/t.im,s=t.re*a+t.im;return new M((this.re*a+this.im)/s,(this.im*a-this.re)/s)}else{const a=t.im/t.re,s=t.im*a+t.re;return new M((this.re+this.im*a)/s,(this.im-this.re*a)/s)}},pow:function(e,r){const t=Er(e,r),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return M.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new M(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new M(Math.pow(this.im,t.re),0);case 1:return new M(0,Math.pow(this.im,t.re));case 2:return new M(-Math.pow(this.im,t.re),0);case 3:return new M(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return M.ZERO;const u=Math.atan2(this.im,this.re),o=Xt(this.re,this.im);let a=Math.exp(t.re*o-t.im*u),s=t.im*o+t.re*u;return new M(a*Math.cos(s),a*Math.sin(s))},sqrt:function(){const e=this.re,r=this.im;if(r===0)return e>=0?new M(Math.sqrt(e),0):new M(0,Math.sqrt(-e));const t=Yt(e,r);let n=Math.sqrt(.5*(t+Math.abs(e))),i=Math.abs(r)/(2*n);return e>=0?new M(n,r<0?-i:i):new M(i,r<0?-n:n)},exp:function(){const e=Math.exp(this.re);return this.im===0?new M(e,0):new M(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new M(Math.expm1(e)*Math.cos(r)+ea(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return r===0&&e>0?new M(Math.log(e),0):new M(Xt(e,r),Math.atan2(r,e))},abs:function(){return Yt(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,r=this.im;return new M(Math.sin(e)*Ue(r),Math.cos(e)*Ye(r))},cos:function(){const e=this.re,r=this.im;return new M(Math.cos(e)*Ue(r),-Math.sin(e)*Ye(r))},tan:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)+Ue(r);return new M(Math.sin(e)/t,Ye(r)/t)},cot:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)-Ue(r);return new M(-Math.sin(e)/t,Ye(r)/t)},sec:function(){const e=this.re,r=this.im,t=.5*Ue(2*r)+.5*Math.cos(2*e);return new M(Math.cos(e)*Ue(r)/t,Math.sin(e)*Ye(r)/t)},csc:function(){const e=this.re,r=this.im,t=.5*Ue(2*r)-.5*Math.cos(2*e);return new M(Math.sin(e)*Ue(r)/t,-Math.cos(e)*Ye(r)/t)},asin:function(){const e=this.re,r=this.im,t=new M(r*r-e*e+1,-2*e*r).sqrt(),n=new M(t.re-r,t.im+e).log();return new M(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new M(r*r-e*e+1,-2*e*r).sqrt(),n=new M(t.re-r,t.im+e).log();return new M(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(e===0){if(r===1)return new M(0,1/0);if(r===-1)return new M(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new M((1-r*r-e*e)/t,-2*e/t).log();return new M(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(r===0)return new M(Math.atan2(1,e),0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).atan():new M(e!==0?e/0:0,r!==0?-r/0:0).atan()},asec:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(0,1/0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).acos():new M(e!==0?e/0:0,r!==0?-r/0:0).acos()},acsc:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(Math.PI/2,1/0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).asin():new M(e!==0?e/0:0,r!==0?-r/0:0).asin()},sinh:function(){const e=this.re,r=this.im;return new M(Ye(e)*Math.cos(r),Ue(e)*Math.sin(r))},cosh:function(){const e=this.re,r=this.im;return new M(Ue(e)*Math.cos(r),Ye(e)*Math.sin(r))},tanh:function(){const e=2*this.re,r=2*this.im,t=Ue(e)+Math.cos(r);return new M(Ye(e)/t,Math.sin(r)/t)},coth:function(){const e=2*this.re,r=2*this.im,t=Ue(e)-Math.cos(r);return new M(Ye(e)/t,-Math.sin(r)/t)},csch:function(){const e=this.re,r=this.im,t=Math.cos(2*r)-Ue(2*e);return new M(-2*Ye(e)*Math.cos(r)/t,2*Ue(e)*Math.sin(r)/t)},sech:function(){const e=this.re,r=this.im,t=Math.cos(2*r)+Ue(2*e);return new M(2*Ue(e)*Math.cos(r)/t,-2*Ye(e)*Math.sin(r)/t)},asinh:function(){let e=this.im;this.im=-this.re,this.re=e;const r=this.asin();return this.re=-this.im,this.im=e,e=r.re,r.re=-r.im,r.im=e,r},acosh:function(){const e=this.acos();if(e.im<=0){const r=e.re;e.re=-e.im,e.im=r}else{const r=e.im;e.im=-e.re,e.re=r}return e},atanh:function(){const e=this.re,r=this.im,t=e>1&&r===0,n=1-e,i=1+e,u=n*n+r*r,o=u!==0?new M((i*n-r*r)/u,(r*n+i*r)/u):new M(e!==-1?e/0:0,r!==0?r/0:0),a=o.re;return o.re=Xt(o.re,o.im)/2,o.im=Math.atan2(o.im,a)/2,t&&(o.im=-o.im),o},acoth:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(0,Math.PI/2);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).atanh():new M(e!==0?e/0:0,r!==0?-r/0:0).atanh()},acsch:function(){const e=this.re,r=this.im;if(r===0)return new M(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).asinh():new M(e!==0?e/0:0,r!==0?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return M.INFINITY;const t=e*e+r*r;return t!==0?new M(e/t,-r/t).acosh():new M(e!==0?e/0:0,r!==0?-r/0:0).acosh()},inverse:function(){if(this.isZero())return M.INFINITY;if(this.isInfinite())return M.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new M(e/t,-r/t)},conjugate:function(){return new M(this.re,-this.im)},neg:function(){return new M(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new M(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new M(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new M(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=Er(e,r);return Math.abs(t.re-this.re)<=M.EPSILON&&Math.abs(t.im-this.im)<=M.EPSILON},clone:function(){return new M(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<M.EPSILON&&(e=0),Math.abs(r)<M.EPSILON&&(r=0),r===0?t+e:(e!==0?(t+=e,t+=" ",r<0?(r=-r,t+="-"):t+="+",t+=" "):r<0&&(r=-r,t+="-"),r!==1&&(t+=r),t+"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.isFinite()}},M.ZERO=new M(0,0),M.ONE=new M(1,0),M.I=new M(0,1),M.PI=new M(Math.PI,0),M.E=new M(Math.E,0),M.INFINITY=new M(1/0,1/0),M.NAN=new M(NaN,NaN),M.EPSILON=1e-15;var ta="Complex",na=[],ia=V(ta,na,()=>(Object.defineProperty(M,"name",{value:"Complex"}),M.prototype.constructor=M,M.prototype.type="Complex",M.prototype.isComplex=!0,M.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},M.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},M.prototype.format=function(e){var r="",t=this.im,n=this.re,i=Zt(this.re,e),u=Zt(this.im,e),o=ne(e)?e:e?e.precision:null;if(o!==null){var a=Math.pow(10,-o);Math.abs(n/t)<a&&(n=0),Math.abs(t/n)<a&&(t=0)}return t===0?r=i:n===0?t===1?r="i":t===-1?r="-i":r=u+"i":t<0?t===-1?r=i+" - i":r=i+" - "+u.substring(1)+"i":t===1?r=i+" + i":r=i+" + "+u+"i",r},M.fromPolar=function(e){switch(arguments.length){case 1:{var r=arguments[0];if(typeof r=="object")return M(r);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],n=arguments[1];if(ne(t)){if(gn(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),ne(n))return new M({r:t,phi:n});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")}},M.prototype.valueOf=M.prototype.toString,M.fromJSON=function(e){return new M(e)},M.compare=function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0},M),{isClass:!0});typeof BigInt>"u"&&(BigInt=function(e){if(isNaN(e))throw new Error("");return e});const Y=BigInt(0),re=BigInt(1),Vr=BigInt(2),Qt=BigInt(5),We=BigInt(10),ua=2e3,L={s:re,n:Y,d:re};function fr(e,r){try{e=BigInt(e)}catch{throw wr()}return e*r}function rr(e){return typeof e=="bigint"?e:Math.floor(e)}function Ae(e,r){if(r===Y)throw Kt();const t=Object.create(Xe.prototype);t.s=e<Y?-re:re,e=e<Y?-e:e;const n=Ar(e,r);return t.n=e/n,t.d=r/n,t}function Tr(e){const r={};let t=e,n=Vr,i=Qt-re;for(;i<=t;){for(;t%n===Y;)t/=n,r[n]=(r[n]||Y)+re;i+=re+Vr*n++}return t!==e?t>1&&(r[t]=(r[t]||Y)+re):r[e]=(r[e]||Y)+re,r}const xe=function(e,r){let t=Y,n=re,i=re;if(e!=null)if(r!==void 0){if(typeof e=="bigint")t=e;else{if(isNaN(e))throw wr();if(e%1!==0)throw Hn();t=BigInt(e)}if(typeof r=="bigint")n=r;else{if(isNaN(r))throw wr();if(r%1!==0)throw Hn();n=BigInt(r)}i=t*n}else if(typeof e=="object"){if("d"in e&&"n"in e)t=BigInt(e.n),n=BigInt(e.d),"s"in e&&(t*=BigInt(e.s));else if(0 in e)t=BigInt(e[0]),1 in e&&(n=BigInt(e[1]));else if(typeof e=="bigint")t=e;else throw wr();i=t*n}else if(typeof e=="number"){if(isNaN(e))throw wr();if(e<0&&(i=-re,e=-e),e%1===0)t=BigInt(e);else{let u=1,o=0,a=1,s=1,f=1,m=1e7;for(e>=1&&(u=10**Math.floor(1+Math.log10(e)),e/=u);a<=m&&f<=m;){let l=(o+s)/(a+f);if(e===l){a+f<=m?(t=o+s,n=a+f):f>a?(t=s,n=f):(t=o,n=a);break}else e>l?(o+=s,a+=f):(s+=o,f+=a),a>m?(t=s,n=f):(t=o,n=a)}t=BigInt(t)*BigInt(u),n=BigInt(n)}}else if(typeof e=="string"){let u=0,o=Y,a=Y,s=Y,f=re,m=re,l=e.replace(/_/g,"").match(/\d+|./g);if(l===null)throw wr();if(l[u]==="-"?(i=-re,u++):l[u]==="+"&&u++,l.length===u+1?a=fr(l[u++],i):l[u+1]==="."||l[u]==="."?(l[u]!=="."&&(o=fr(l[u++],i)),u++,(u+1===l.length||l[u+1]==="("&&l[u+3]===")"||l[u+1]==="'"&&l[u+3]==="'")&&(a=fr(l[u],i),f=We**BigInt(l[u].length),u++),(l[u]==="("&&l[u+2]===")"||l[u]==="'"&&l[u+2]==="'")&&(s=fr(l[u+1],i),m=We**BigInt(l[u+1].length)-re,u+=3)):l[u+1]==="/"||l[u+1]===":"?(a=fr(l[u],i),f=fr(l[u+2],re),u+=3):l[u+3]==="/"&&l[u+1]===" "&&(o=fr(l[u],i),a=fr(l[u+2],i),f=fr(l[u+4],re),u+=5),l.length<=u)n=f*m,i=t=s+n*o+m*a;else throw wr()}else if(typeof e=="bigint")t=e,i=e,n=re;else throw wr();if(n===Y)throw Kt();L.s=i<Y?-re:re,L.n=t<Y?-t:t,L.d=n<Y?-n:n};function oa(e,r,t){let n=re;for(;r>Y;e=e*e%t,r>>=re)r&re&&(n=n*e%t);return n}function aa(e,r){for(;r%Vr===Y;r/=Vr);for(;r%Qt===Y;r/=Qt);if(r===re)return Y;let t=We%r,n=1;for(;t!==re;n++)if(t=t*We%r,n>ua)return Y;return BigInt(n)}function sa(e,r,t){let n=re,i=oa(We,t,r);for(let u=0;u<300;u++){if(n===i)return BigInt(u);n=n*We%r,i=i*We%r}return 0}function Ar(e,r){if(!e)return r;if(!r)return e;for(;;){if(e%=r,!e)return r;if(r%=e,!r)return e}}function Xe(e,r){if(xe(e,r),this instanceof Xe)e=Ar(L.d,L.n),this.s=L.s,this.n=L.n/e,this.d=L.d/e;else return Ae(L.s*L.n,L.d)}var Kt=function(){return new Error("Division by Zero")},wr=function(){return new Error("Invalid argument")},Hn=function(){return new Error("Parameters must be integer")};Xe.prototype={s:re,n:Y,d:re,abs:function(){return Ae(this.n,this.d)},neg:function(){return Ae(-this.s*this.n,this.d)},add:function(e,r){return xe(e,r),Ae(this.s*this.n*L.d+L.s*this.d*L.n,this.d*L.d)},sub:function(e,r){return xe(e,r),Ae(this.s*this.n*L.d-L.s*this.d*L.n,this.d*L.d)},mul:function(e,r){return xe(e,r),Ae(this.s*L.s*this.n*L.n,this.d*L.d)},div:function(e,r){return xe(e,r),Ae(this.s*L.s*this.n*L.d,this.d*L.n)},clone:function(){return Ae(this.s*this.n,this.d)},mod:function(e,r){if(e===void 0)return Ae(this.s*this.n%this.d,re);if(xe(e,r),Y===L.n*this.d)throw Kt();return Ae(this.s*(L.d*this.n)%(L.n*this.d),L.d*this.d)},gcd:function(e,r){return xe(e,r),Ae(Ar(L.n,this.n)*Ar(L.d,this.d),L.d*this.d)},lcm:function(e,r){return xe(e,r),L.n===Y&&this.n===Y?Ae(Y,re):Ae(L.n*this.n,Ar(L.n,this.n)*Ar(L.d,this.d))},inverse:function(){return Ae(this.s*this.d,this.n)},pow:function(e,r){if(xe(e,r),L.d===re)return L.s<Y?Ae((this.s*this.d)**L.n,this.n**L.n):Ae((this.s*this.n)**L.n,this.d**L.n);if(this.s<Y)return null;let t=Tr(this.n),n=Tr(this.d),i=re,u=re;for(let o in t)if(o!=="1"){if(o==="0"){i=Y;break}if(t[o]*=L.n,t[o]%L.d===Y)t[o]/=L.d;else return null;i*=BigInt(o)**t[o]}for(let o in n)if(o!=="1"){if(n[o]*=L.n,n[o]%L.d===Y)n[o]/=L.d;else return null;u*=BigInt(o)**n[o]}return L.s<Y?Ae(u,i):Ae(i,u)},log:function(e,r){if(xe(e,r),this.s<=Y||L.s<=Y)return null;const t={},n=Tr(L.n),i=Tr(L.d),u=Tr(this.n),o=Tr(this.d);for(const f in i)n[f]=(n[f]||Y)-i[f];for(const f in o)u[f]=(u[f]||Y)-o[f];for(const f in n)f!=="1"&&(t[f]=!0);for(const f in u)f!=="1"&&(t[f]=!0);let a=null,s=null;for(const f in t){const m=n[f]||Y,l=u[f]||Y;if(m===Y){if(l!==Y)return null;continue}let h=l,p=m;const D=Ar(h,p);if(h/=D,p/=D,a===null&&s===null)a=h,s=p;else if(h*s!==a*p)return null}return a!==null&&s!==null?Ae(a,s):null},equals:function(e,r){return xe(e,r),this.s*this.n*L.d===L.s*L.n*this.d},lt:function(e,r){return xe(e,r),this.s*this.n*L.d<L.s*L.n*this.d},lte:function(e,r){return xe(e,r),this.s*this.n*L.d<=L.s*L.n*this.d},gt:function(e,r){return xe(e,r),this.s*this.n*L.d>L.s*L.n*this.d},gte:function(e,r){return xe(e,r),this.s*this.n*L.d>=L.s*L.n*this.d},compare:function(e,r){xe(e,r);let t=this.s*this.n*L.d-L.s*L.n*this.d;return(Y<t)-(t<Y)},ceil:function(e){return e=We**BigInt(e||0),Ae(rr(this.s*e*this.n/this.d)+(e*this.n%this.d>Y&&this.s>=Y?re:Y),e)},floor:function(e){return e=We**BigInt(e||0),Ae(rr(this.s*e*this.n/this.d)-(e*this.n%this.d>Y&&this.s<Y?re:Y),e)},round:function(e){return e=We**BigInt(e||0),Ae(rr(this.s*e*this.n/this.d)+this.s*((this.s>=Y?re:Y)+Vr*(e*this.n%this.d)>this.d?re:Y),e)},roundTo:function(e,r){xe(e,r);const t=this.n*L.d,n=this.d*L.n,i=t%n;let u=rr(t/n);return i+i>=n&&u++,Ae(this.s*u*L.n,L.d)},divisible:function(e,r){return xe(e,r),!(!(L.n*this.d)||this.n*L.d%(L.n*this.d))},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e){let r=this.n,t=this.d;e=e||15;let n=aa(r,t),i=sa(r,t,n),u=this.s<Y?"-":"";if(u+=rr(r/t),r%=t,r*=We,r&&(u+="."),n){for(let o=i;o--;)u+=rr(r/t),r%=t,r*=We;u+="(";for(let o=n;o--;)u+=rr(r/t),r%=t,r*=We;u+=")"}else for(let o=e;r&&o--;)u+=rr(r/t),r%=t,r*=We;return u},toFraction:function(e){let r=this.n,t=this.d,n=this.s<Y?"-":"";if(t===re)n+=r;else{let i=rr(r/t);e&&i>Y&&(n+=i,n+=" ",r%=t),n+=r,n+="/",n+=t}return n},toLatex:function(e){let r=this.n,t=this.d,n=this.s<Y?"-":"";if(t===re)n+=r;else{let i=rr(r/t);e&&i>Y&&(n+=i,r%=t),n+="\\frac{",n+=r,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let e=this.n,r=this.d,t=[];do{t.push(rr(e/r));let n=e%r;e=r,r=n}while(e!==re);return t},simplify:function(e){const r=BigInt(1/(e||.001)|0),t=this.abs(),n=t.toContinued();for(let i=1;i<n.length;i++){let u=Ae(n[i-1],re);for(let a=i-2;a>=0;a--)u=u.inverse().add(n[a]);let o=u.sub(t);if(o.n*r<o.d)return u.mul(this.s)}return this}};var fa="Fraction",ca=[],la=V(fa,ca,()=>(Object.defineProperty(Xe,"name",{value:"Fraction"}),Xe.prototype.constructor=Xe,Xe.prototype.type="Fraction",Xe.prototype.isFraction=!0,Xe.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},Xe.fromJSON=function(e){return new Xe(e)},Xe),{isClass:!0}),ha="Matrix",pa=[],Da=V(ha,pa,()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(r,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(r,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(r){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(r,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(r,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(r,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(r,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(r){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(r){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0});function jt(e,r,t){var n=e.constructor,i=new n(2),u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ye(t))throw new Error("size must be an integer");if(e.greaterThan(i.pow(t-1).sub(1))||e.lessThan(i.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(i.pow(t))),u="i".concat(t)}switch(r){case 2:return"".concat(e.toBinary()).concat(u);case 8:return"".concat(e.toOctal()).concat(u);case 16:return"".concat(e.toHexadecimal()).concat(u);default:throw new Error("Base ".concat(r," not supported "))}}function ma(e,r){if(typeof r=="function")return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:i}=En(r);switch(t){case"fixed":return ga(e,n);case"exponential":return Zn(e,n);case"engineering":return da(e,n);case"bin":return jt(e,2,i);case"oct":return jt(e,8,i);case"hex":return jt(e,16,i);case"auto":{var u=Wn(r?.lowerExp,-3),o=Wn(r?.upperExp,5);if(e.isZero())return"0";var a,s=e.toSignificantDigits(n),f=s.e;return f>=u&&f<o?a=s.toFixed():a=Zn(e,n),a.replace(/((\.\d*?)(0+))($|e)/,function(){var m=arguments[2],l=arguments[4];return m!=="."?m+l:l})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function da(e,r){var t=e.e,n=t%3===0?t:t<0?t-3-t%3:t-t%3,i=e.mul(Math.pow(10,-n)),u=i.toPrecision(r);if(u.includes("e")){var o=e.constructor;u=new o(u).toFixed()}return u+"e"+(t>=0?"+":"")+n.toString()}function Zn(e,r){return r!==void 0?e.toExponential(r-1):e.toExponential()}function ga(e,r){return e.toFixed(r)}function Wn(e,r){return ne(e)?e:Ee(e)?e.toNumber():r}function _e(e,r){var t=va(e,r);return r&&typeof r=="object"&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function va(e,r){if(typeof e=="number")return Zt(e,r);if(Ee(e))return ma(e,r);if(wa(e))return!r||r.fraction!=="decimal"?"".concat(e.s*e.n,"/").concat(e.d):e.toString();if(Array.isArray(e))return Jn(e,r);if(Me(e))return Vn(e);if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(r);if(e&&e.toString(r)!=={}.toString())return e.toString(r);var t=Object.keys(e).map(n=>Vn(n)+": "+_e(e[n],r));return"{"+t.join(", ")+"}"}return String(e)}function Vn(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Gn?Gn[i]:i,n++}return'"'+t+'"'}var Gn={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Jn(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)i!==0&&(t+=", "),t+=Jn(e[i],r);return t+="]",t}else return _e(e,r)}function wa(e){return e&&typeof e=="object"&&typeof e.s=="bigint"&&typeof e.n=="bigint"&&typeof e.d=="bigint"||!1}function ie(e,r,t){if(!(this instanceof ie))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=new Error().stack}ie.prototype=new RangeError,ie.prototype.constructor=RangeError,ie.prototype.name="DimensionError",ie.prototype.isDimensionError=!0;function br(e,r,t){if(!(this instanceof br))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,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}br.prototype=new RangeError,br.prototype.constructor=RangeError,br.prototype.name="IndexError",br.prototype.isIndexError=!0;function Oe(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function kn(e,r,t){var n,i=e.length;if(i!==r[t])throw new ie(i,r[t]);if(t<r.length-1){var u=t+1;for(n=0;n<i;n++){var o=e[n];if(!Array.isArray(o))throw new ie(r.length-1,r.length,"<");kn(e[n],r,u)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new ie(r.length+1,r.length,">")}function Yn(e,r){var t=r.length===0;if(t){if(Array.isArray(e))throw new ie(e.length,0)}else kn(e,r,0)}function gt(e,r){var t=e.isMatrix?e._size:Oe(e),n=r._sourceSize;n.forEach((i,u)=>{if(i!==null&&i!==t[u])throw new ie(i,t[u])})}function me(e,r){if(e!==void 0){if(!ne(e)||!ye(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof r=="number"&&e>=r)throw new br(e,r)}}function Ir(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&ve(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(Me(t)&&t.length===0)return!0}return!1}function vt(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new Error("Resizing to scalar is not supported");r.forEach(function(i){if(!ne(i)||!ye(i)||i<0)throw new TypeError("Invalid size, must contain positive integers (size: "+_e(r)+")")}),(ne(e)||Ee(e))&&(e=[e]);var n=t!==void 0?t:0;return en(e,r,0,n),e}function en(e,r,t,n){var i,u,o=e.length,a=r[t],s=Math.min(o,a);if(e.length=a,t<r.length-1){var f=t+1;for(i=0;i<s;i++)u=e[i],Array.isArray(u)||(u=[u],e[i]=u),en(u,r,f,n);for(i=s;i<a;i++)u=[],e[i]=u,en(u,r,f,n)}else{for(i=0;i<s;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=s;i<a;i++)e[i]=n}}function Xn(e,r){var t=Fa(e,!0),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new ie(0,n,"!=");r=rn(r,n);var i=Qn(r);if(n!==i)throw new ie(i,n,"!=");try{return ya(t,r)}catch(u){throw u instanceof ie?new ie(i,n,"!="):u}}function rn(e,r){var t=Qn(e),n=e.slice(),i=-1,u=e.indexOf(i),o=e.indexOf(i,u+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var a=u>=0,s=r%t===0;if(a)if(s)n[u]=-r/t;else throw new Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);return n}function Qn(e){return e.reduce((r,t)=>r*t,1)}function ya(e,r){for(var t=e,n,i=r.length-1;i>0;i--){var u=r[i];n=[];for(var o=t.length/u,a=0;a<o;a++)n.push(t.slice(a*u,(a+1)*u));t=n}return t}function Kn(e,r,t,n){var i=n||Oe(e);if(t)for(var u=0;u<t;u++)e=[e],i.unshift(1);for(e=jn(e,r,0);i.length<r;)i.push(1);return e}function jn(e,r,t){var n,i;if(Array.isArray(e)){var u=t+1;for(n=0,i=e.length;n<i;n++)e[n]=jn(e[n],r,u)}else for(var o=t;o<r;o++)e=[e];return e}function Fa(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof r!="boolean")throw new TypeError("Boolean expected for second argument of flatten");var t=[];return r?i(e):n(e),t;function n(u){for(var o=0;o<u.length;o++){var a=u[o];Array.isArray(a)?n(a):t.push(a)}}function i(u){if(Array.isArray(u[0]))for(var o=0;o<u.length;o++)i(u[o]);else for(var a=0;a<u.length;a++)t.push(u[a])}}function wt(e,r){for(var t,n=0,i=0;i<e.length;i++){var u=e[i],o=Array.isArray(u);if(i===0&&o&&(n=u.length),o&&u.length!==n)return;var a=o?wt(u,r):r(u);if(t===void 0)t=a;else if(t!==a)return"mixed"}return t}function ei(e,r,t,n){if(n<t){if(e.length!==r.length)throw new ie(e.length,r.length);for(var i=[],u=0;u<e.length;u++)i[u]=ei(e[u],r[u],t,n+1);return i}else return e.concat(r)}function ri(){var e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(e.length===1)return e[0];if(e.length>1)return e.slice(1).reduce(function(t,n){return ei(t,n,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function ti(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map(h=>h.length),i=Math.max(...n),u=new Array(i).fill(null),o=0;o<r.length;o++)for(var a=r[o],s=n[o],f=0;f<s;f++){var m=i-s+f;a[f]>u[m]&&(u[m]=a[f])}for(var l=0;l<r.length;l++)ni(r[l],u);return u}function ni(e,r){for(var t=r.length,n=e.length,i=0;i<n;i++){var u=t-n+i;if(e[i]<r[u]&&e[i]>1||e[i]>r[u])throw new Error("shape mismatch: mismatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(r[u]))}}function tn(e,r){var t=Oe(e);if(Dr(t,r))return e;ni(t,r);var n=ti(t,r),i=n.length,u=[...Array(i-t.length).fill(1),...t],o=Aa(e);t.length<i&&(o=Xn(o,u),t=Oe(o));for(var a=0;a<i;a++)t[a]<n[a]&&(o=Ea(o,n[a],a),t=Oe(o));return o}function Ea(e,r,t){return ri(...Array(r).fill(e),t)}function ii(e,r){if(!Array.isArray(e))throw new Error("Array expected");var t=Oe(e);if(r.length!==t.length)throw new ie(r.length,t.length);for(var n=0;n<r.length;n++)me(r[n],t[n]);return r.reduce((i,u)=>i[u],e)}function ui(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(t)return u(e);var n=[];return i(e,0);function i(o,a){if(Array.isArray(o)){for(var s=o.length,f=Array(s),m=0;m<s;m++)n[a]=m,f[m]=i(o[m],a+1);return f}else return r(o,n.slice(0,a),e)}function u(o){if(Array.isArray(o)){for(var a=o.length,s=Array(a),f=0;f<a;f++)s[f]=u(o[f]);return s}else return r(o)}}function Aa(e){return pr([],e)}function yt(e,r,t,n){if(it.isTypedFunction(e)){var i;if(n)i=1;else{var u=r.isMatrix?r.size():Oe(r),o=u.length?u[u.length-1]===0:!0;if(o)return{isUnary:n,fn:e};var a=u.map(()=>0),s=r.isMatrix?r.get(a):ii(r,a);i=_a(e,s,a,r)}var f;if(r.isMatrix&&r.dataType!=="mixed"&&r.dataType!==void 0){var m=ba(e,i);f=m!==void 0?m:e}else f=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){for(var h=arguments.length,p=new Array(h),D=0;D<h;D++)p[D]=arguments[D];return oi(f,p.slice(0,i),t,e.name)}}:{isUnary:!1,fn:function(){for(var h=arguments.length,p=new Array(h),D=0;D<h;D++)p[D]=arguments[D];return oi(f,p,t,e.name)}}}return n===void 0?{isUnary:Ca(e),fn:e}:{isUnary:n,fn:e}}function ba(e,r){var t=[];if(Object.entries(e.signatures).forEach(n=>{var[i,u]=n;i.split(",").length===r&&t.push(u)}),t.length===1)return t[0]}function Ca(e){if(e.length!==1)return!1;var r=e.toString();if(/arguments/.test(r))return!1;var t=r.match(/\(.*?\)/);return!/\.\.\./.test(t)}function _a(e,r,t,n){for(var i=[r,t,n],u=3;u>0;u--){var o=i.slice(0,u);if(it.resolve(e,o)!==null)return u}}function oi(e,r,t,n){try{return e(...r)}catch(i){Ba(i,r,t,n)}}function Ba(e,r,t,n){var i;if(e instanceof TypeError&&((i=e.data)===null||i===void 0?void 0:i.category)==="wrongType"){var u=[];throw u.push("value: ".concat(ur(r[0]))),r.length>=2&&u.push("index: ".concat(ur(r[1]))),r.length>=3&&u.push("array: ".concat(ur(r[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(u.join(", "),") at index ").concat(JSON.stringify(r[1])))}else throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}var Na="DenseMatrix",Sa=["Matrix","config"],Ma=V(Na,Sa,e=>{var{Matrix:r,config:t}=e;function n(l,h){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!Me(h))throw new Error("Invalid datatype: "+h);if(we(l))l.type==="DenseMatrix"?(this._data=De(l._data),this._size=De(l._size),this._datatype=h||l._datatype):(this._data=l.toArray(),this._size=l.size(),this._datatype=h||l._datatype);else if(l&&ve(l.data)&&ve(l.size))this._data=l.data,this._size=l.size,Yn(this._data,this._size),this._datatype=h||l.datatype;else if(ve(l))this._data=m(l),this._size=Oe(this._data),Yn(this._data,this._size),this._datatype=h;else{if(l)throw new TypeError("Unsupported type of data ("+ur(l)+")");this._data=[],this._size=[0],this._datatype=h}}n.prototype=new r,n.prototype.createDenseMatrix=function(l,h){return new n(l,h)},Object.defineProperty(n,"name",{value:"DenseMatrix"}),n.prototype.constructor=n,n.prototype.type="DenseMatrix",n.prototype.isDenseMatrix=!0,n.prototype.getDataType=function(){return wt(this._data,ur)},n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(l,h){return new n(l,h)},n.prototype.subset=function(l,h,p){switch(arguments.length){case 1:return i(this,l);case 2:case 3:return o(this,l,h,p);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(l){return ii(this._data,l)},n.prototype.set=function(l,h,p){if(!ve(l))throw new TypeError("Array expected");if(l.length<this._size.length)throw new ie(l.length,this._size.length,"<");var D,c,d,v=l.map(function(g){return g+1});f(this,v,p);var y=this._data;for(D=0,c=l.length-1;D<c;D++)d=l[D],me(d,y.length),y=y[d];return d=l[l.length-1],me(d,y.length),y[d]=h,this};function i(l,h){if(!nt(h))throw new TypeError("Invalid index");var p=t.legacySubset?h.size().every(F=>F===1):h.isScalar();if(p)return l.get(h.min());var D=h.size();if(D.length!==l._size.length)throw new ie(D.length,l._size.length);for(var c=h.min(),d=h.max(),v=0,y=l._size.length;v<y;v++)me(c[v],l._size[v]),me(d[v],l._size[v]);var g=new n,A=u(l._data,h);return g._size=A.size,g._datatype=l._datatype,g._data=A.data,t.legacySubset?g.reshape(h.size()):g}function u(l,h){var p=h.size().length-1,D=Array(p);return{data:c(l),size:D.filter(d=>d!==null)};function c(d){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,y=h.dimension(v);function g(A,F){return ne(A)?F(A):A.map(F).valueOf()}return ne(y)?D[v]=null:D[v]=y.size()[0],v<p?g(y,A=>(me(A,d.length),c(d[A],v+1))):g(y,A=>(me(A,d.length),d[A]))}}function o(l,h,p,D){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var c=h.size(),d=h.isScalar(),v;if(we(p)?(v=p.size(),p=p.valueOf()):v=Oe(p),d){if(v.length!==0)throw new TypeError("Scalar expected");l.set(h.min(),p,D)}else{if(!Dr(v,c)){if(v.length===0)p=tn([p],c);else try{p=tn(p,c)}catch{}v=Oe(p)}if(c.length<l._size.length)throw new ie(c.length,l._size.length,"<");if(v.length<c.length){for(var y=0,g=0;c[y]===1&&v[y]===1;)y++;for(;c[y]===1;)g++,y++;p=Kn(p,c.length,g,v)}if(!Dr(c,v))throw new ie(c,v,">");var A=h.max().map(function(F){return F+1});f(l,A,D),a(l._data,h,p)}return l}function a(l,h,p){var D=h.size().length-1;c(l,p);function c(d,v){var y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,g=h.dimension(y),A=(w,_)=>{me(w,d.length),c(d[w],v[_[0]],y+1)},F=(w,_)=>{me(w,d.length),d[w]=v[_[0]]};y<D?ne(g)?A(g,[0]):g.forEach(A):ne(g)?F(g,[0]):g.forEach(F)}}n.prototype.resize=function(l,h,p){if(!tt(l))throw new TypeError("Array or Matrix expected");var D=l.valueOf().map(d=>Array.isArray(d)&&d.length===1?d[0]:d),c=p?this.clone():this;return s(c,D,h)};function s(l,h,p){if(h.length===0){for(var D=l._data;ve(D);)D=D[0];return D}return l._size=h.slice(0),l._data=vt(l._data,l._size,p),l}n.prototype.reshape=function(l,h){var p=h?this.clone():this;p._data=Xn(p._data,l);var D=p._size.reduce((c,d)=>c*d);return p._size=rn(l,D),p};function f(l,h,p){for(var D=l._size.slice(0),c=!1;D.length<h.length;)D.push(0),c=!0;for(var d=0,v=h.length;d<v;d++)h[d]>D[d]&&(D[d]=h[d],c=!0);c&&s(l,D,p)}n.prototype.clone=function(){var l=new n({data:De(this._data),size:De(this._size),datatype:this._datatype});return l},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(l){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,p=this,D=p._size.length-1;if(D<0)return p.clone();var c=yt(l,p,"map",h),d=c.fn,v=p.create(void 0,p._datatype);if(v._size=p._size,h||c.isUnary)return v._data=_(p._data),v;if(D===0){for(var y=p.valueOf(),g=Array(y.length),A=0;A<y.length;A++)g[A]=d(y[A],[A],p);return v._data=g,v}var F=[];return v._data=w(p._data),v;function w(b){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(b.length);if(B<D)for(var x=0;x<b.length;x++)F[B]=x,S[x]=w(b[x],B+1);else for(var O=0;O<b.length;O++)F[B]=O,S[O]=d(b[O],F.slice(),p);return S}function _(b){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(b.length);if(B<D)for(var x=0;x<b.length;x++)S[x]=_(b[x],B+1);else for(var O=0;O<b.length;O++)S[O]=d(b[O]);return S}},n.prototype.forEach=function(l){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,p=this,D=p._size.length-1;if(D<0)return;var c=yt(l,p,"map",h),d=c.fn;if(h||c.isUnary){A(p._data);return}if(D===0){for(var v=0;v<p._data.length;v++)d(p._data[v],[v],p);return}var y=[];g(p._data);function g(F){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(w<D)for(var _=0;_<F.length;_++)y[w]=_,g(F[_],w+1);else for(var b=0;b<F.length;b++)y[w]=b,d(F[b],y.slice(),p)}function A(F){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(w<D)for(var _=0;_<F.length;_++)A(F[_],w+1);else for(var b=0;b<F.length;b++)d(F[b])}},n.prototype[Symbol.iterator]=function*(){var l=this._size.length-1;if(!(l<0)){if(l===0){for(var h=0;h<this._data.length;h++)yield{value:this._data[h],index:[h]};return}for(var p=Array(l+1).fill(0),D=this._size.reduce((g,A)=>g*A,1),c=0;c<D;c++){for(var d=this._data,v=0;v<l;v++)d=d[p[v]];yield{value:d[p[l]],index:p.slice()};for(var y=l;y>=0&&(p[y]++,!(p[y]<this._size[y]));y--)p[y]=0}}},n.prototype.rows=function(){var l=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var p=this._data;for(var D of p)l.push(new n([D],this._datatype));return l},n.prototype.columns=function(){var l=this,h=[],p=this.size();if(p.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var D=this._data,c=function(y){var g=D.map(A=>[A[y]]);h.push(new n(g,l._datatype))},d=0;d<p[1];d++)c(d);return h},n.prototype.toArray=function(){return De(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(l){return _e(this._data,l)},n.prototype.toString=function(){return _e(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(l){if(l){if(Ee(l)&&(l=l.toNumber()),!ne(l)||!ye(l))throw new TypeError("The parameter k must be an integer number")}else l=0;for(var h=l>0?l:0,p=l<0?-l:0,D=this._size[0],c=this._size[1],d=Math.min(D-p,c-h),v=[],y=0;y<d;y++)v[y]=this._data[y+p][y+h];return new n({data:v,size:[d],datatype:this._datatype})},n.diagonal=function(l,h,p,D){if(!ve(l))throw new TypeError("Array expected, size parameter");if(l.length!==2)throw new Error("Only two dimensions matrix are supported");if(l=l.map(function(b){if(Ee(b)&&(b=b.toNumber()),!ne(b)||!ye(b)||b<1)throw new Error("Size values must be positive integers");return b}),p){if(Ee(p)&&(p=p.toNumber()),!ne(p)||!ye(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var c=p>0?p:0,d=p<0?-p:0,v=l[0],y=l[1],g=Math.min(v-d,y-c),A;if(ve(h)){if(h.length!==g)throw new Error("Invalid value array length");A=function(B){return h[B]}}else if(we(h)){var F=h.size();if(F.length!==1||F[0]!==g)throw new Error("Invalid matrix length");A=function(B){return h.get([B])}}else A=function(){return h};D||(D=Ee(A(0))?A(0).mul(0):0);var w=[];if(l.length>0){w=vt(w,l,D);for(var _=0;_<g;_++)w[_+d][_+c]=A(_)}return new n({data:w,size:[v,y]})},n.fromJSON=function(l){return new n(l)},n.prototype.swapRows=function(l,h){if(!ne(l)||!ye(l)||!ne(h)||!ye(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return me(l,this._size[0]),me(h,this._size[0]),n._swapRows(l,h,this._data),this},n._swapRows=function(l,h,p){var D=p[l];p[l]=p[h],p[h]=D};function m(l){return we(l)?m(l.valueOf()):ve(l)?l.map(m):l}return n},{isClass:!0});function Ve(e,r,t){if(!t)return we(e)?e.map(i=>r(i),!1,!0):ui(e,r,!0);var n=i=>i===0?i:r(i);return we(e)?e.map(i=>n(i),!1,!0):ui(e,n,!0)}var ai="isInteger",xa=["typed","equal"],Ta=V(ai,xa,e=>{var{typed:r,equal:t}=e;return r(ai,{number:n=>Number.isFinite(n)?t(n,Math.round(n)):!1,BigNumber:n=>n.isFinite()?t(n.round(),n):!1,bigint:n=>!0,Fraction:n=>n.d===1n,"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),nn="number",Ft="number, number";function si(e){return Math.abs(e)}si.signature=nn;function fi(e,r){return e+r}fi.signature=Ft;function ci(e,r){return e-r}ci.signature=Ft;function li(e,r){return e*r}li.signature=Ft;function hi(e){return-e}hi.signature=nn;function Et(e){return Xu(e)}Et.signature=nn;function pi(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}pi.signature=Ft;function Gr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!ye(r)||r<0||r>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(An(e,r))}var Ia=Math.PI,za="number";function Di(e){return e>0}Di.signature=za;function yr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return e.isNaN()||r.isNaN()?!1:!e.isFinite()||!r.isFinite()?e.eq(r):e.eq(r)?!0:e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(),r.abs()).mul(t),n))}var mi="isPositive",Oa=["typed","config"],$a=V(mi,Oa,e=>{var{typed:r,config:t}=e;return r(mi,{number:n=>je(n,0,t.relTol,t.absTol)?!1:Di(n),BigNumber:n=>yr(n,new n.constructor(0),t.relTol,t.absTol)?!1:!n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n>0n,Fraction:n=>n.s>0n&&n.n>0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),di="isZero",Pa=["typed","equalScalar"],qa=V(di,Pa,e=>{var{typed:r,equalScalar:t}=e;return r(di,{"number | BigNumber | Complex | Fraction":n=>t(n,0),bigint:n=>n===0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})});function Ua(e,r,t,n){return je(e.re,r.re,t,n)&&je(e.im,r.im,t,n)}var Jr=V("compareUnits",["typed"],e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(!n.equalBase(i))throw new Error("Cannot compare units with different base");return r.find(t,[n.valueType(),i.valueType()])(n.value,i.value)})}}),At="equalScalar",Ra=["typed","config"],La=V(At,Ra,e=>{var{typed:r,config:t}=e,n=Jr({typed:r});return r(At,{"boolean, boolean":function(u,o){return u===o},"number, number":function(u,o){return je(u,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(u,o){return u.eq(o)||yr(u,o,t.relTol,t.absTol)},"bigint, bigint":function(u,o){return u===o},"Fraction, Fraction":function(u,o){return u.equals(o)},"Complex, Complex":function(u,o){return Ua(u,o,t.relTol,t.absTol)}},n)});V(At,["typed","config"],e=>{var{typed:r,config:t}=e;return r(At,{"number, number":function(i,u){return je(i,u,t.relTol,t.absTol)}})});var Ha="SparseMatrix",Za=["typed","equalScalar","Matrix"],Wa=V(Ha,Za,e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function i(c,d){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(d&&!Me(d))throw new Error("Invalid datatype: "+d);if(we(c))u(this,c,d);else if(c&&ve(c.index)&&ve(c.ptr)&&ve(c.size))this._values=c.values,this._index=c.index,this._ptr=c.ptr,this._size=c.size,this._datatype=d||c.datatype;else if(ve(c))o(this,c,d);else{if(c)throw new TypeError("Unsupported type of data ("+ur(c)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=d}}function u(c,d,v){d.type==="SparseMatrix"?(c._values=d._values?De(d._values):void 0,c._index=De(d._index),c._ptr=De(d._ptr),c._size=De(d._size),c._datatype=v||d._datatype):o(c,d.valueOf(),v||d._datatype)}function o(c,d,v){c._values=[],c._index=[],c._ptr=[],c._datatype=v;var y=d.length,g=0,A=t,F=0;if(Me(v)&&(A=r.find(t,[v,v])||t,F=r.convert(0,v)),y>0){var w=0;do{c._ptr.push(c._index.length);for(var _=0;_<y;_++){var b=d[_];if(ve(b)){if(w===0&&g<b.length&&(g=b.length),w<b.length){var B=b[w];A(B,F)||(c._values.push(B),c._index.push(_))}}else w===0&&g<1&&(g=1),A(b,F)||(c._values.push(b),c._index.push(_))}w++}while(w<g)}for(;c._ptr.length<=g;)c._ptr.push(c._index.length);c._size=[y,g]}i.prototype=new n,i.prototype.createSparseMatrix=function(c,d){return new i(c,d)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return wt(this._values,ur)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(c,d){return new i(c,d)},i.prototype.density=function(){var c=this._size[0],d=this._size[1];return c!==0&&d!==0?this._index.length/(c*d):0},i.prototype.subset=function(c,d,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return a(this,c);case 2:case 3:return s(this,c,d,v);default:throw new SyntaxError("Wrong number of arguments")}};function a(c,d){if(!nt(d))throw new TypeError("Invalid index");var v=d.isScalar();if(v)return c.get(d.min());var y=d.size();if(y.length!==c._size.length)throw new ie(y.length,c._size.length);var g,A,F,w,_=d.min(),b=d.max();for(g=0,A=c._size.length;g<A;g++)me(_[g],c._size[g]),me(b[g],c._size[g]);var B=c._values,S=c._index,x=c._ptr,O=d.dimension(0),G=d.dimension(1),R=[],H=[];function $(ue,oe){H[ue]=oe[0],R[ue]=!0}Number.isInteger(O)?$(O,[0]):O.forEach($);var Q=B?[]:void 0,J=[],X=[];function ee(ue){for(X.push(J.length),F=x[ue],w=x[ue+1];F<w;F++)g=S[F],R[g]===!0&&(J.push(H[g]),Q&&Q.push(B[F]))}return Number.isInteger(G)?ee(G):G.forEach(ee),X.push(J.length),new i({values:Q,index:J,ptr:X,size:y,datatype:c._datatype})}function s(c,d,v,y){if(!d||d.isIndex!==!0)throw new TypeError("Invalid index");var g=d.size(),A=d.isScalar(),F;if(we(v)?(F=v.size(),v=v.toArray()):F=Oe(v),A){if(F.length!==0)throw new TypeError("Scalar expected");c.set(d.min(),v,y)}else{if(g.length!==1&&g.length!==2)throw new ie(g.length,c._size.length,"<");if(F.length<g.length){for(var w=0,_=0;g[w]===1&&F[w]===1;)w++;for(;g[w]===1;)_++,w++;v=Kn(v,g.length,_,F)}if(!Dr(g,F))throw new ie(g,F,">");if(g.length===1){var b=d.dimension(0);x(b,(O,G)=>{me(O),c.set([O,0],v[G[0]],y)})}else{var B=d.dimension(0),S=d.dimension(1);x(B,(O,G)=>{me(O),x(S,(R,H)=>{me(R),c.set([O,R],v[G[0]][H[0]],y)})})}}return c;function x(O,G){ne(O)?G(O,[0]):O.forEach(G)}}i.prototype.get=function(c){if(!ve(c))throw new TypeError("Array expected");if(c.length!==this._size.length)throw new ie(c.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var d=c[0],v=c[1];me(d,this._size[0]),me(v,this._size[1]);var y=f(d,this._ptr[v],this._ptr[v+1],this._index);return y<this._ptr[v+1]&&this._index[y]===d?this._values[y]:0},i.prototype.set=function(c,d,v){if(!ve(c))throw new TypeError("Array expected");if(c.length!==this._size.length)throw new ie(c.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var y=c[0],g=c[1],A=this._size[0],F=this._size[1],w=t,_=0;Me(this._datatype)&&(w=r.find(t,[this._datatype,this._datatype])||t,_=r.convert(0,this._datatype)),(y>A-1||g>F-1)&&(h(this,Math.max(y+1,A),Math.max(g+1,F),v),A=this._size[0],F=this._size[1]),me(y,A),me(g,F);var b=f(y,this._ptr[g],this._ptr[g+1],this._index);return b<this._ptr[g+1]&&this._index[b]===y?w(d,_)?m(b,g,this._values,this._index,this._ptr):this._values[b]=d:w(d,_)||l(b,y,g,d,this._values,this._index,this._ptr),this};function f(c,d,v,y){if(v-d===0)return v;for(var g=d;g<v;g++)if(y[g]===c)return g;return d}function m(c,d,v,y,g){v.splice(c,1),y.splice(c,1);for(var A=d+1;A<g.length;A++)g[A]--}function l(c,d,v,y,g,A,F){g.splice(c,0,y),A.splice(c,0,d);for(var w=v+1;w<F.length;w++)F[w]++}i.prototype.resize=function(c,d,v){if(!tt(c))throw new TypeError("Array or Matrix expected");var y=c.valueOf().map(A=>Array.isArray(A)&&A.length===1?A[0]:A);if(y.length!==2)throw new Error("Only two dimensions matrix are supported");y.forEach(function(A){if(!ne(A)||!ye(A)||A<0)throw new TypeError("Invalid size, must contain positive integers (size: "+_e(y)+")")});var g=v?this.clone():this;return h(g,y[0],y[1],d)};function h(c,d,v,y){var g=y||0,A=t,F=0;Me(c._datatype)&&(A=r.find(t,[c._datatype,c._datatype])||t,F=r.convert(0,c._datatype),g=r.convert(g,c._datatype));var w=!A(g,F),_=c._size[0],b=c._size[1],B,S,x;if(v>b){for(S=b;S<v;S++)if(c._ptr[S]=c._values.length,w)for(B=0;B<_;B++)c._values.push(g),c._index.push(B);c._ptr[v]=c._values.length}else v<b&&(c._ptr.splice(v+1,b-v),c._values.splice(c._ptr[v],c._values.length),c._index.splice(c._ptr[v],c._index.length));if(b=v,d>_){if(w){var O=0;for(S=0;S<b;S++){c._ptr[S]=c._ptr[S]+O,x=c._ptr[S+1]+O;var G=0;for(B=_;B<d;B++,G++)c._values.splice(x+G,0,g),c._index.splice(x+G,0,B),O++}c._ptr[b]=c._values.length}}else if(d<_){var R=0;for(S=0;S<b;S++){c._ptr[S]=c._ptr[S]-R;var H=c._ptr[S],$=c._ptr[S+1]-R;for(x=H;x<$;x++)B=c._index[x],B>d-1&&(c._values.splice(x,1),c._index.splice(x,1),R++)}c._ptr[S]=c._values.length}return c._size[0]=d,c._size[1]=v,c}i.prototype.reshape=function(c,d){if(!ve(c))throw new TypeError("Array expected");if(c.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");c.forEach(function(X){if(!ne(X)||!ye(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+_e(c)+")")});var v=this._size[0]*this._size[1];c=rn(c,v);var y=c[0]*c[1];if(v!==y)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=d?this.clone():this;if(this._size[0]===c[0]&&this._size[1]===c[1])return g;for(var A=[],F=0;F<g._ptr.length;F++)for(var w=0;w<g._ptr[F+1]-g._ptr[F];w++)A.push(F);for(var _=g._values.slice(),b=g._index.slice(),B=0;B<g._index.length;B++){var S=b[B],x=A[B],O=S*g._size[1]+x;A[B]=O%c[1],b[B]=Math.floor(O/c[1])}g._values.length=0,g._index.length=0,g._ptr.length=c[1]+1,g._size=c.slice();for(var G=0;G<g._ptr.length;G++)g._ptr[G]=0;for(var R=0;R<_.length;R++){var H=b[R],$=A[R],Q=_[R],J=f(H,g._ptr[$],g._ptr[$+1],g._index);l(J,H,$,Q,g._values,g._index,g._ptr)}return g},i.prototype.clone=function(){var c=new i({values:this._values?De(this._values):void 0,index:De(this._index),ptr:De(this._ptr),size:De(this._size),datatype:this._datatype});return c},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(c,d){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,y=this._size[0],g=this._size[1],A=yt(c,v,"map"),F=function(_,b,B){return A.fn(_,[b,B],v)};return p(this,0,y-1,0,g-1,F,d)};function p(c,d,v,y,g,A,F){var w=[],_=[],b=[],B=t,S=0;Me(c._datatype)&&(B=r.find(t,[c._datatype,c._datatype])||t,S=r.convert(0,c._datatype));for(var x=function(le,Be,Ce){var be=A(le,Be,Ce);B(be,S)||(w.push(be),_.push(Be))},O=y;O<=g;O++){b.push(w.length);var G=c._ptr[O],R=c._ptr[O+1];if(F)for(var H=G;H<R;H++){var $=c._index[H];$>=d&&$<=v&&x(c._values[H],$-d,O-y)}else{for(var Q={},J=G;J<R;J++){var X=c._index[J];Q[X]=c._values[J]}for(var ee=d;ee<=v;ee++){var ue=ee in Q?Q[ee]:0;x(ue,ee-d,O-y)}}}return b.push(w.length),new i({values:w,index:_,ptr:b,size:[v-d+1,g-y+1]})}i.prototype.forEach=function(c,d){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,y=this._size[0],g=this._size[1],A=yt(c,v,"forEach"),F=0;F<g;F++){var w=this._ptr[F],_=this._ptr[F+1];if(d)for(var b=w;b<_;b++){var B=this._index[b];A.fn(this._values[b],[B,F],v)}else{for(var S={},x=w;x<_;x++){var O=this._index[x];S[O]=this._values[x]}for(var G=0;G<y;G++){var R=G in S?S[G]:0;A.fn(R,[G,F],v)}}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var c=this._size[1],d=0;d<c;d++)for(var v=this._ptr[d],y=this._ptr[d+1],g=v;g<y;g++){var A=this._index[g];yield{value:this._values[g],index:[A,d]}}},i.prototype.toArray=function(){return D(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return D(this._values,this._index,this._ptr,this._size,!1)};function D(c,d,v,y,g){var A=y[0],F=y[1],w=[],_,b;for(_=0;_<A;_++)for(w[_]=[],b=0;b<F;b++)w[_][b]=0;for(b=0;b<F;b++)for(var B=v[b],S=v[b+1],x=B;x<S;x++)_=d[x],w[_][b]=c?g?De(c[x]):c[x]:1;return w}return i.prototype.format=function(c){for(var d=this._size[0],v=this._size[1],y=this.density(),g="Sparse Matrix ["+_e(d,c)+" x "+_e(v,c)+"] density: "+_e(y,c)+`
|
|
8
|
+
`);return Object.freeze(pn)};pr(Pe,pn,{MATRIX_OPTIONS:Gu,NUMBER_OPTIONS:Ju});function yn(){return!0}function ke(){return!1}function _r(){}const Fn="Argument is not a typed-function.";function En(){function e(E){return typeof E=="object"&&E!==null&&E.constructor===Object}const r=[{name:"number",test:function(E){return typeof E=="number"}},{name:"string",test:function(E){return typeof E=="string"}},{name:"boolean",test:function(E){return typeof E=="boolean"}},{name:"Function",test:function(E){return typeof E=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(E){return E instanceof Date}},{name:"RegExp",test:function(E){return E instanceof RegExp}},{name:"Object",test:e},{name:"null",test:function(E){return E===null}},{name:"undefined",test:function(E){return E===void 0}}],t={name:"any",test:yn,isAny:!0};let n,i,u=0,o={createCount:0};function a(E){const C=n.get(E);if(C)return C;let N='Unknown type "'+E+'"';const T=E.toLowerCase();let P;for(P of i)if(P.toLowerCase()===T){N+='. Did you mean "'+P+'" ?';break}throw new TypeError(N)}function s(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const N=C?a(C).index:i.length,T=[];for(let z=0;z<E.length;++z){if(!E[z]||typeof E[z].name!="string"||typeof E[z].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const Z=E[z].name;if(n.has(Z))throw new TypeError('Duplicate type name "'+Z+'"');T.push(Z),n.set(Z,{name:Z,test:E[z].test,isAny:E[z].isAny,index:N+z,conversionsTo:[]})}const P=i.slice(N);i=i.slice(0,N).concat(T).concat(P);for(let z=N+T.length;z<i.length;++z)n.get(i[z]).index=z}function f(){n=new Map,i=[],u=0,s([t],!1)}f(),s(r);function D(){let E;for(E of i)n.get(E).conversionsTo=[];u=0}function l(E){const C=i.filter(N=>{const T=n.get(N);return!T.isAny&&T.test(E)});return C.length?C:["any"]}function h(E){return E&&typeof E=="function"&&"_typedFunctionData"in E}function p(E,C,N){if(!h(E))throw new TypeError(Fn);const T=N&&N.exact,P=Array.isArray(C)?C.join(","):C,z=A(P),Z=d(z);if(!T||Z in E.signatures){const fe=E._typedFunctionData.signatureMap.get(Z);if(fe)return fe}const U=z.length;let W;if(T){W=[];let fe;for(fe in E.signatures)W.push(E._typedFunctionData.signatureMap.get(fe))}else W=E._typedFunctionData.signatures;for(let fe=0;fe<U;++fe){const de=z[fe],Ne=[];let Ge;for(Ge of W){const He=b(Ge.params,fe);if(!(!He||de.restParam&&!He.restParam)){if(!He.hasAny){const nr=g(He);if(de.types.some(ir=>!nr.has(ir.name)))continue}Ne.push(Ge)}}if(W=Ne,W.length===0)break}let q;for(q of W)if(q.params.length<=U)return q;throw new TypeError("Signature not found (signature: "+(E.name||"unnamed")+"("+d(z,", ")+"))")}function m(E,C,N){return p(E,C,N).implementation}function c(E,C){const N=a(C);if(N.test(E))return E;const T=N.conversionsTo;if(T.length===0)throw new Error("There are no conversions to "+C+" defined.");for(let P=0;P<T.length;P++)if(a(T[P].from).test(E))return T[P].convert(E);throw new Error("Cannot convert "+E+" to "+C)}function d(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return E.map(N=>N.name).join(C)}function v(E){const C=E.indexOf("...")===0,T=(C?E.length>3?E.slice(3):"any":E).split("|").map(U=>a(U.trim()));let P=!1,z=C?"...":"";return{types:T.map(function(U){return P=U.isAny||P,z+=U.name+"|",{name:U.name,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:null,conversionIndex:-1}}),name:z.slice(0,-1),hasAny:P,hasConversion:!1,restParam:C}}function y(E){const C=E.types.map(Z=>Z.name),N=Q(C);let T=E.hasAny,P=E.name;const z=N.map(function(Z){const U=a(Z.from);return T=U.isAny||T,P+="|"+Z.from,{name:Z.from,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:Z,conversionIndex:Z.index}});return{types:E.types.concat(z),name:P,hasAny:T,hasConversion:z.length>0,restParam:E.restParam}}function g(E){return E.typeSet||(E.typeSet=new Set,E.types.forEach(C=>E.typeSet.add(C.name))),E.typeSet}function A(E){const C=[];if(typeof E!="string")throw new TypeError("Signatures must be strings");const N=E.trim();if(N==="")return C;const T=N.split(",");for(let P=0;P<T.length;++P){const z=v(T[P].trim());if(z.restParam&&P!==T.length-1)throw new SyntaxError('Unexpected rest parameter "'+T[P]+'": only allowed for the last parameter');if(z.types.length===0)return null;C.push(z)}return C}function F(E){const C=he(E);return C?C.restParam:!1}function w(E){if(!E||E.types.length===0)return yn;if(E.types.length===1)return a(E.types[0].name).test;if(E.types.length===2){const C=a(E.types[0].name).test,N=a(E.types[1].name).test;return function(P){return C(P)||N(P)}}else{const C=E.types.map(function(N){return a(N.name).test});return function(T){for(let P=0;P<C.length;P++)if(C[P](T))return!0;return!1}}}function _(E){let C,N,T;if(F(E)){C=Le(E).map(w);const P=C.length,z=w(he(E)),Z=function(U){for(let W=P;W<U.length;W++)if(!z(U[W]))return!1;return!0};return function(W){for(let q=0;q<C.length;q++)if(!C[q](W[q]))return!1;return Z(W)&&W.length>=P+1}}else return E.length===0?function(z){return z.length===0}:E.length===1?(N=w(E[0]),function(z){return N(z[0])&&z.length===1}):E.length===2?(N=w(E[0]),T=w(E[1]),function(z){return N(z[0])&&T(z[1])&&z.length===2}):(C=E.map(w),function(z){for(let Z=0;Z<C.length;Z++)if(!C[Z](z[Z]))return!1;return z.length===C.length})}function b(E,C){return C<E.length?E[C]:F(E)?he(E):null}function B(E,C){const N=b(E,C);return N?g(N):new Set}function S(E){return E.conversion===null||E.conversion===void 0}function x(E,C){const N=new Set;return E.forEach(T=>{const P=B(T.params,C);let z;for(z of P)N.add(z)}),N.has("any")?["any"]:Array.from(N)}function O(E,C,N){let T,P;const z=E||"unnamed";let Z=N,U;for(U=0;U<C.length;U++){const de=[];if(Z.forEach(Ne=>{const Ge=b(Ne.params,U),He=w(Ge);(U<Ne.params.length||F(Ne.params))&&He(C[U])&&de.push(Ne)}),de.length===0){if(P=x(Z,U),P.length>0){const Ne=l(C[U]);return T=new TypeError("Unexpected type of argument in function "+z+" (expected: "+P.join(" or ")+", actual: "+Ne.join(" | ")+", index: "+U+")"),T.data={category:"wrongType",fn:z,index:U,actual:Ne,expected:P},T}}else Z=de}const W=Z.map(function(de){return F(de.params)?1/0:de.params.length});if(C.length<Math.min.apply(null,W))return P=x(Z,U),T=new TypeError("Too few arguments in function "+z+" (expected: "+P.join(" or ")+", index: "+C.length+")"),T.data={category:"tooFewArgs",fn:z,index:C.length,expected:P},T;const q=Math.max.apply(null,W);if(C.length>q)return T=new TypeError("Too many arguments in function "+z+" (expected: "+q+", actual: "+C.length+")"),T.data={category:"tooManyArgs",fn:z,index:C.length,expectedLength:q},T;const fe=[];for(let de=0;de<C.length;++de)fe.push(l(C[de]).join("|"));return T=new TypeError('Arguments of type "'+fe.join(", ")+'" do not match any of the defined signatures of function '+z+"."),T.data={category:"mismatch",actual:fe},T}function G(E){let C=i.length+1;for(let N=0;N<E.types.length;N++)S(E.types[N])&&(C=Math.min(C,E.types[N].typeIndex));return C}function R(E){let C=u+1;for(let N=0;N<E.types.length;N++)S(E.types[N])||(C=Math.min(C,E.types[N].conversionIndex));return C}function H(E,C){if(E.hasAny){if(!C.hasAny)return 1}else if(C.hasAny)return-1;if(E.restParam){if(!C.restParam)return 1}else if(C.restParam)return-1;if(E.hasConversion){if(!C.hasConversion)return 1}else if(C.hasConversion)return-1;const N=G(E)-G(C);if(N<0)return-1;if(N>0)return 1;const T=R(E)-R(C);return T<0?-1:T>0?1:0}function $(E,C){const N=E.params,T=C.params,P=he(N),z=he(T),Z=F(N),U=F(T);if(Z&&P.hasAny){if(!U||!z.hasAny)return 1}else if(U&&z.hasAny)return-1;let W=0,q=0,fe;for(fe of N)fe.hasAny&&++W,fe.hasConversion&&++q;let de=0,Ne=0;for(fe of T)fe.hasAny&&++de,fe.hasConversion&&++Ne;if(W!==de)return W-de;if(Z&&P.hasConversion){if(!U||!z.hasConversion)return 1}else if(U&&z.hasConversion)return-1;if(q!==Ne)return q-Ne;if(Z){if(!U)return 1}else if(U)return-1;const Ge=(N.length-T.length)*(Z?-1:1);if(Ge!==0)return Ge;const He=[];let nr=0;for(let Lr=0;Lr<N.length;++Lr){const Ut=H(N[Lr],T[Lr]);He.push(Ut),nr+=Ut}if(nr!==0)return nr;let ir;for(ir of He)if(ir!==0)return ir;return 0}function Q(E){if(E.length===0)return[];const C=E.map(a);E.length>1&&C.sort((P,z)=>P.index-z.index);let N=C[0].conversionsTo;if(E.length===1)return N;N=N.concat([]);const T=new Set(E);for(let P=1;P<C.length;++P){let z;for(z of C[P].conversionsTo)T.has(z.from)||(N.push(z),T.add(z.from))}return N}function J(E,C){let N=C;if(E.some(P=>P.hasConversion)){const P=F(E),z=E.map(X);N=function(){const U=[],W=P?arguments.length-1:arguments.length;for(let q=0;q<W;q++)U[q]=z[q](arguments[q]);return P&&(U[W]=arguments[W].map(z[W])),C.apply(this,U)}}let T=N;if(F(E)){const P=E.length-1;T=function(){return N.apply(this,se(arguments,0,P).concat([se(arguments,P)]))}}return T}function X(E){let C,N,T,P;const z=[],Z=[];switch(E.types.forEach(function(U){U.conversion&&(z.push(a(U.conversion.from).test),Z.push(U.conversion.convert))}),Z.length){case 0:return function(W){return W};case 1:return C=z[0],T=Z[0],function(W){return C(W)?T(W):W};case 2:return C=z[0],N=z[1],T=Z[0],P=Z[1],function(W){return C(W)?T(W):N(W)?P(W):W};default:return function(W){for(let q=0;q<Z.length;q++)if(z[q](W))return Z[q](W);return W}}}function ee(E){function C(N,T,P){if(T<N.length){const z=N[T];let Z=[];if(z.restParam){const U=z.types.filter(S);U.length<z.types.length&&Z.push({types:U,name:"..."+U.map(W=>W.name).join("|"),hasAny:U.some(W=>W.isAny),hasConversion:!1,restParam:!0}),Z.push(z)}else Z=z.types.map(function(U){return{types:[U],name:U.name,hasAny:U.isAny,hasConversion:U.conversion,restParam:!1}});return $e(Z,function(U){return C(N,T+1,P.concat([U]))})}else return[P]}return C(E,0,[])}function ue(E,C){const N=Math.max(E.length,C.length);for(let U=0;U<N;U++){const W=B(E,U),q=B(C,U);let fe=!1,de;for(de of q)if(W.has(de)){fe=!0;break}if(!fe)return!1}const T=E.length,P=C.length,z=F(E),Z=F(C);return z?Z?T===P:P>=T:Z?T>=P:T===P}function oe(E){return E.map(C=>hr(C)?Ke(C.referToSelf.callback):lr(C)?Ie(C.referTo.references,C.referTo.callback):C)}function le(E,C,N){const T=[];let P;for(P of E){let z=N[P];if(typeof z!="number")throw new TypeError('No definition for referenced signature "'+P+'"');if(z=C[z],typeof z!="function")return!1;T.push(z)}return T}function Be(E,C,N){const T=oe(E),P=new Array(T.length).fill(!1);let z=!0;for(;z;){z=!1;let Z=!0;for(let U=0;U<T.length;++U){if(P[U])continue;const W=T[U];if(hr(W))T[U]=W.referToSelf.callback(N),T[U].referToSelf=W.referToSelf,P[U]=!0,Z=!1;else if(lr(W)){const q=le(W.referTo.references,T,C);q?(T[U]=W.referTo.callback.apply(this,q),T[U].referTo=W.referTo,P[U]=!0,Z=!1):z=!0}}if(Z&&z)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return T}function Ce(E){const C=/\bthis(\(|\.signatures\b)/;Object.keys(E).forEach(N=>{const T=E[N];if(C.test(T.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 be(E,C){if(o.createCount++,Object.keys(C).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&Ce(C);const N=[],T=[],P={},z=[];let Z;for(Z in C){if(!Object.prototype.hasOwnProperty.call(C,Z))continue;const ae=A(Z);if(!ae)continue;N.forEach(function(et){if(ue(et,ae))throw new TypeError('Conflicting signatures "'+d(et)+'" and "'+d(ae)+'".')}),N.push(ae);const Je=T.length;T.push(C[Z]);const il=ae.map(y);let Rt;for(Rt of ee(il)){const et=d(Rt);z.push({params:Rt,name:et,fn:Je}),Rt.every(ul=>!ul.hasConversion)&&(P[et]=Je)}}z.sort($);const U=Be(T,P,jr);let W;for(W in P)Object.prototype.hasOwnProperty.call(P,W)&&(P[W]=U[P[W]]);const q=[],fe=new Map;for(W of z)fe.has(W.name)||(W.fn=U[W.fn],q.push(W),fe.set(W.name,W));const de=q[0]&&q[0].params.length<=2&&!F(q[0].params),Ne=q[1]&&q[1].params.length<=2&&!F(q[1].params),Ge=q[2]&&q[2].params.length<=2&&!F(q[2].params),He=q[3]&&q[3].params.length<=2&&!F(q[3].params),nr=q[4]&&q[4].params.length<=2&&!F(q[4].params),ir=q[5]&&q[5].params.length<=2&&!F(q[5].params),Lr=de&&Ne&&Ge&&He&&nr&&ir;for(let ae=0;ae<q.length;++ae)q[ae].test=_(q[ae].params);const Ut=de?w(q[0].params[0]):ke,Mc=Ne?w(q[1].params[0]):ke,xc=Ge?w(q[2].params[0]):ke,Tc=He?w(q[3].params[0]):ke,Ic=nr?w(q[4].params[0]):ke,zc=ir?w(q[5].params[0]):ke,Oc=de?w(q[0].params[1]):ke,$c=Ne?w(q[1].params[1]):ke,Pc=Ge?w(q[2].params[1]):ke,qc=He?w(q[3].params[1]):ke,Uc=nr?w(q[4].params[1]):ke,Rc=ir?w(q[5].params[1]):ke;for(let ae=0;ae<q.length;++ae)q[ae].implementation=J(q[ae].params,q[ae].fn);const Lc=de?q[0].implementation:_r,Hc=Ne?q[1].implementation:_r,Zc=Ge?q[2].implementation:_r,Wc=He?q[3].implementation:_r,Vc=nr?q[4].implementation:_r,Gc=ir?q[5].implementation:_r,Jc=de?q[0].params.length:-1,kc=Ne?q[1].params.length:-1,Yc=Ge?q[2].params.length:-1,Xc=He?q[3].params.length:-1,Qc=nr?q[4].params.length:-1,Kc=ir?q[5].params.length:-1,jc=Lr?6:0,el=q.length,rl=q.map(ae=>ae.test),tl=q.map(ae=>ae.implementation),nl=function(){for(let Je=jc;Je<el;Je++)if(rl[Je](arguments))return tl[Je].apply(this,arguments);return o.onMismatch(E,arguments,q)};function jr(ae,Je){return arguments.length===Jc&&Ut(ae)&&Oc(Je)?Lc.apply(this,arguments):arguments.length===kc&&Mc(ae)&&$c(Je)?Hc.apply(this,arguments):arguments.length===Yc&&xc(ae)&&Pc(Je)?Zc.apply(this,arguments):arguments.length===Xc&&Tc(ae)&&qc(Je)?Wc.apply(this,arguments):arguments.length===Qc&&Ic(ae)&&Uc(Je)?Vc.apply(this,arguments):arguments.length===Kc&&zc(ae)&&Rc(Je)?Gc.apply(this,arguments):nl.apply(this,arguments)}try{Object.defineProperty(jr,"name",{value:E})}catch{}return jr.signatures=P,jr._typedFunctionData={signatures:q,signatureMap:fe},jr}function Fe(E,C,N){throw O(E,C,N)}function Le(E){return se(E,0,E.length-1)}function he(E){return E[E.length-1]}function se(E,C,N){return Array.prototype.slice.call(E,C,N)}function Qe(E,C){for(let N=0;N<E.length;N++)if(C(E[N]))return E[N]}function $e(E,C){return Array.prototype.concat.apply([],E.map(C))}function pe(){const E=Le(arguments).map(N=>d(A(N))),C=he(arguments);if(typeof C!="function")throw new TypeError("Callback function expected as last argument");return Ie(E,C)}function Ie(E,C){return{referTo:{references:E,callback:C}}}function Ke(E){if(typeof E!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:E}}}function lr(E){return E&&typeof E.referTo=="object"&&Array.isArray(E.referTo.references)&&typeof E.referTo.callback=="function"}function hr(E){return E&&typeof E.referToSelf=="object"&&typeof E.referToSelf.callback=="function"}function Ur(E,C){if(!E)return C;if(C&&C!==E){const N=new Error("Function names do not match (expected: "+E+", actual: "+C+")");throw N.data={actual:C,expected:E},N}return E}function Rr(E){let C;for(const N in E)Object.prototype.hasOwnProperty.call(E,N)&&(h(E[N])||typeof E[N].signature=="string")&&(C=Ur(C,E[N].name));return C}function hn(E,C){let N;for(N in C)if(Object.prototype.hasOwnProperty.call(C,N)){if(N in E&&C[N]!==E[N]){const T=new Error('Signature "'+N+'" is defined twice');throw T.data={signature:N,sourceFunction:C[N],destFunction:E[N]},T}E[N]=C[N]}}const Sc=o;o=function(E){const C=typeof E=="string",N=C?1:0;let T=C?E:"";const P={};for(let z=N;z<arguments.length;++z){const Z=arguments[z];let U={},W;if(typeof Z=="function"?(W=Z.name,typeof Z.signature=="string"?U[Z.signature]=Z:h(Z)&&(U=Z.signatures)):e(Z)&&(U=Z,C||(W=Rr(Z))),Object.keys(U).length===0){const q=new TypeError("Argument to 'typed' at index "+z+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw q.data={index:z,argument:Z},q}C||(T=Ur(T,W)),hn(P,U)}return be(T||"",P)},o.create=En,o.createCount=Sc.createCount,o.onMismatch=Fe,o.throwMismatchError=Fe,o.createError=O,o.clear=f,o.clearConversions=D,o.addTypes=s,o._findType=a,o.referTo=pe,o.referToSelf=Ke,o.convert=c,o.findSignature=p,o.find=m,o.isTypedFunction=h,o.warnAgainstDeprecatedThis=!0,o.addType=function(E,C){let N="any";C!==!1&&n.has("Object")&&(N="Object"),o.addTypes([E],N)};function au(E){if(!E||typeof E.from!="string"||typeof E.to!="string"||typeof E.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(E.to===E.from)throw new SyntaxError('Illegal to define conversion from "'+E.from+'" to itself.')}return o.addConversion=function(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};au(E);const N=a(E.to),T=N.conversionsTo.find(P=>P.from===E.from);if(T)if(C&&C.override)o.removeConversion({from:T.from,to:E.to,convert:T.convert});else throw new Error('There is already a conversion from "'+E.from+'" to "'+N.name+'"');N.conversionsTo.push({from:E.from,convert:E.convert,index:u++})},o.addConversions=function(E,C){E.forEach(N=>o.addConversion(N,C))},o.removeConversion=function(E){au(E);const C=a(E.to),N=Qe(C.conversionsTo,P=>P.from===E.from);if(!N)throw new Error("Attempt to remove nonexistent conversion from "+E.from+" to "+E.to);if(N.convert!==E.convert)throw new Error("Conversion to remove does not match existing conversion");const T=C.conversionsTo.indexOf(N);C.conversionsTo.splice(T,1)},o.resolve=function(E,C){if(!h(E))throw new TypeError(Fn);const N=E._typedFunctionData.signatures;for(let T=0;T<N.length;++T)if(N[T].test(C))return N[T];return null},o}const it=En();function V(e,r,t,n){function i(u){var o=Vu(u,r.map(Xu));return ku(e,r,u),t(o)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function ku(e,r,t){var n=r.filter(u=>!Yu(u)).every(u=>t[u]!==void 0);if(!n){var i=r.filter(u=>t[u]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(i.map(u=>'"'.concat(u,'"')).join(", "),"."))}}function Yu(e){return e&&e[0]==="?"}function Xu(e){return e&&e[0]==="?"?e.slice(1):e}function ye(e){return typeof e=="boolean"?!0:Number.isFinite(e)?e===Math.round(e):!1}var Qu=Math.log10||function(r){return Math.log(r)/Math.LN10};function Ht(e,r,t){var n={2:"0b",8:"0o",16:"0x"},i=n[r],u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ye(t))throw new Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ye(e))throw new Error("Value must be an integer");e<0&&(e=e+2**t),u="i".concat(t)}var o="";return e<0&&(e=-e,o="-"),"".concat(o).concat(i).concat(e.toString(r)).concat(u)}function Zt(e,r){if(typeof r=="function")return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:t,precision:n,wordSize:i}=An(r);switch(t){case"fixed":return bn(e,n);case"exponential":return Cn(e,n);case"engineering":return Ku(e,n);case"bin":return Ht(e,2,i);case"oct":return Ht(e,8,i);case"hex":return Ht(e,16,i);case"auto":return ju(e,n,r).replace(/((\.\d*?)(0+))($|e)/,function(){var u=arguments[2],o=arguments[4];return u!=="."?u+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function An(e){var r="auto",t,n;if(e!==void 0)if(ne(e))t=e;else if(Ee(e))t=e.toNumber();else if(Lt(e))e.precision!==void 0&&(t=_n(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),e.wordSize!==void 0&&(n=_n(e.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),e.notation&&(r=e.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:r,precision:t,wordSize:n}}function Zr(e){var r=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),u=n.indexOf(".");i+=u!==-1?u-1:n.length-1;var o=n.replace(".","").replace(/^0*/,function(a){return i-=a.length,""}).replace(/0*$/,"").split("").map(function(a){return parseInt(a)});return o.length===0&&(o.push(0),i++),{sign:t,coefficients:o,exponent:i}}function Ku(e,r){if(isNaN(e)||!Number.isFinite(e))return String(e);var t=Zr(e),n=ut(t,r),i=n.exponent,u=n.coefficients,o=i%3===0?i:i<0?i-3-i%3:i-i%3;if(ne(r))for(;r>u.length||i-o+1>u.length;)u.push(0);else for(var a=Math.abs(i-o)-(u.length-1),s=0;s<a;s++)u.push(0);for(var f=Math.abs(i-o),D=1;f>0;)D++,f--;var l=u.slice(D).join(""),h=ne(r)&&l.length||l.match(/[1-9]/)?"."+l:"",p=u.slice(0,D).join("")+h+"e"+(i>=0?"+":"")+o.toString();return n.sign+p}function bn(e,r){if(isNaN(e)||!Number.isFinite(e))return String(e);var t=Zr(e),n=typeof r=="number"?ut(t,t.exponent+1+r):t,i=n.coefficients,u=n.exponent+1,o=u+(r||0);return i.length<o&&(i=i.concat(Br(o-i.length))),u<0&&(i=Br(-u+1).concat(i),u=1),u<i.length&&i.splice(u,0,u===0?"0.":"."),n.sign+i.join("")}function Cn(e,r){if(isNaN(e)||!Number.isFinite(Number(e)))return String(e);var t=Zr(e),n=r?ut(t,r):t,i=n.coefficients,u=n.exponent;i.length<r&&(i=i.concat(Br(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(u>=0?"+":"")+u}function ju(e,r,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Bn(t?.lowerExp,-3),i=Bn(t?.upperExp,5),u=Zr(e),o=r?ut(u,r):u;if(o.exponent<n||o.exponent>=i)return Cn(e,r);var a=o.coefficients,s=o.exponent;a.length<r&&(a=a.concat(Br(r-a.length))),a=a.concat(Br(s-a.length+1+(a.length<r?r-a.length:0))),a=Br(-s).concat(a);var f=s>0?s:0;return f<a.length-1&&a.splice(f+1,0,"."),o.sign+a.join("")}function ut(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r){var i=n.splice(r,n.length-r);if(i[0]>=5){var u=r-1;for(n[u]++;n[u]===10;)n.pop(),u===0&&(n.unshift(0),t.exponent++,u++),u--,n[u]++}}return t}function Br(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function eo(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function je(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return isNaN(e)||isNaN(r)?!1:!Number.isFinite(e)||!Number.isFinite(r)?e===r:e===r?!0:Math.abs(e-r)<=Math.max(t*Math.max(Math.abs(e),Math.abs(r)),n)}function _n(e,r){if(ne(e))return e;if(Ee(e))return e.toNumber();r()}function Bn(e,r){return ne(e)?e:Ee(e)?e.toNumber():r}var Nn=function(){return Nn=it.create,it},ro=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],to=V("typed",ro,function(r){var{BigNumber:t,Complex:n,DenseMatrix:i,Fraction:u}=r,o=Nn();return o.clear(),o.addTypes([{name:"number",test:ne},{name:"Complex",test:dn},{name:"BigNumber",test:Ee},{name:"bigint",test:mu},{name:"Fraction",test:gn},{name:"Unit",test:vn},{name:"identifier",test:a=>Me&&/^(?:[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-\u1C8A\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-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\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\uDDC0-\uDDF3\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\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\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\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\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-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\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\uDDC0-\uDDF3\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\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\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\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(a)},{name:"string",test:Me},{name:"Chain",test:Hu},{name:"Array",test:ve},{name:"Matrix",test:we},{name:"DenseMatrix",test:Du},{name:"SparseMatrix",test:du},{name:"Range",test:wn},{name:"Index",test:nt},{name:"boolean",test:gu},{name:"ResultSet",test:vu},{name:"Help",test:wu},{name:"function",test:yu},{name:"Date",test:Fu},{name:"RegExp",test:Eu},{name:"null",test:bu},{name:"undefined",test:Cu},{name:"AccessorNode",test:_u},{name:"ArrayNode",test:Bu},{name:"AssignmentNode",test:Nu},{name:"BlockNode",test:Su},{name:"ConditionalNode",test:Mu},{name:"ConstantNode",test:xu},{name:"FunctionNode",test:Iu},{name:"FunctionAssignmentNode",test:Tu},{name:"IndexNode",test:zu},{name:"Node",test:Ou},{name:"ObjectNode",test:$u},{name:"OperatorNode",test:Pu},{name:"ParenthesisNode",test:qu},{name:"RangeNode",test:Uu},{name:"RelationalNode",test:Ru},{name:"SymbolNode",test:Lu},{name:"Map",test:Au},{name:"Object",test:Lt}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(s){if(t||ot(s),eo(s)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+s+"). Use function bignumber(x) to convert to BigNumber.");return new t(s)}},{from:"number",to:"Complex",convert:function(s){return n||at(s),new n(s,0)}},{from:"BigNumber",to:"Complex",convert:function(s){return n||at(s),new n(s.toNumber(),0)}},{from:"bigint",to:"number",convert:function(s){if(s>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+s+")");return Number(s)}},{from:"bigint",to:"BigNumber",convert:function(s){return t||ot(s),new t(s.toString())}},{from:"bigint",to:"Fraction",convert:function(s){return u||st(s),new u(s)}},{from:"Fraction",to:"BigNumber",convert:function(s){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(s){return n||at(s),new n(s.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(s){u||st(s);var f=new u(s);if(f.valueOf()!==s)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+s+"). Use function fraction(x) to convert to Fraction.");return f}},{from:"string",to:"number",convert:function(s){var f=Number(s);if(isNaN(f))throw new Error('Cannot convert "'+s+'" to a number');return f}},{from:"string",to:"BigNumber",convert:function(s){t||ot(s);try{return new t(s)}catch{throw new Error('Cannot convert "'+s+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(s){try{return BigInt(s)}catch{throw new Error('Cannot convert "'+s+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(s){u||st(s);try{return new u(s)}catch{throw new Error('Cannot convert "'+s+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(s){n||at(s);try{return new n(s)}catch{throw new Error('Cannot convert "'+s+'" to Complex')}}},{from:"boolean",to:"number",convert:function(s){return+s}},{from:"boolean",to:"BigNumber",convert:function(s){return t||ot(s),new t(+s)}},{from:"boolean",to:"bigint",convert:function(s){return BigInt(+s)}},{from:"boolean",to:"Fraction",convert:function(s){return u||st(s),new u(+s)}},{from:"boolean",to:"string",convert:function(s){return String(s)}},{from:"Array",to:"Matrix",convert:function(s){return i||no(),new i(s)}},{from:"Matrix",to:"Array",convert:function(s){return s.valueOf()}}]),o.onMismatch=(a,s,f)=>{var D=o.createError(a,s,f);if(["wrongType","mismatch"].includes(D.data.category)&&s.length===1&&tt(s[0])&&f.some(h=>!h.params.includes(","))){var l=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw l.data=D.data,l}throw D},o.onMismatch=(a,s,f)=>{var D=o.createError(a,s,f);if(["wrongType","mismatch"].includes(D.data.category)&&s.length===1&&tt(s[0])&&f.some(h=>!h.params.includes(","))){var l=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw l.data=D.data,l}throw D},o});function ot(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function at(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function no(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function st(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Nr=9e15,Dr=1e9,Wt="0123456789abcdef",ft="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ct="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Vt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Nr,maxE:Nr,crypto:!1},Sn,sr,j=!0,lt="[DecimalError] ",dr=lt+"Invalid argument: ",Mn=lt+"Precision limit exceeded",xn=lt+"crypto unavailable",Tn="[object Decimal]",qe=Math.floor,Se=Math.pow,io=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,uo=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,oo=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,In=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,er=1e7,K=7,ao=9007199254740991,so=ft.length-1,Gt=ct.length-1,I={toStringTag:Tn};I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),k(e)},I.ceil=function(){return k(new this.constructor(this),this.e+1,2)},I.clampedTo=I.clamp=function(e,r){var t,n=this,i=n.constructor;if(e=new i(e),r=new i(r),!e.s||!r.s)return new i(NaN);if(e.gt(r))throw Error(dr+r);return t=n.cmp(e),t<0?e:n.cmp(r)>0?r:new i(n)},I.comparedTo=I.cmp=function(e){var r,t,n,i,u=this,o=u.d,a=(e=new u.constructor(e)).d,s=u.s,f=e.s;if(!o||!a)return!s||!f?NaN:s!==f?s:o===a?0:!o^s<0?1:-1;if(!o[0]||!a[0])return o[0]?s:a[0]?-f:0;if(s!==f)return s;if(u.e!==e.e)return u.e>e.e^s<0?1:-1;for(n=o.length,i=a.length,r=0,t=n<i?n:i;r<t;++r)if(o[r]!==a[r])return o[r]>a[r]^s<0?1:-1;return n===i?0:n>i^s<0?1:-1},I.cosine=I.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=fo(n,Un(n,t)),n.precision=e,n.rounding=r,k(sr==2||sr==3?t.neg():t,e,r,!0)):new n(1):new n(NaN)},I.cubeRoot=I.cbrt=function(){var e,r,t,n,i,u,o,a,s,f,D=this,l=D.constructor;if(!D.isFinite()||D.isZero())return new l(D);for(j=!1,u=D.s*Se(D.s*D,1/3),!u||Math.abs(u)==1/0?(t=ze(D.d),e=D.e,(u=(e-t.length+1)%3)&&(t+=u==1||u==-2?"0":"00"),u=Se(t,1/3),e=qe((e+1)/3)-(e%3==(e<0?-1:2)),u==1/0?t="5e"+e:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new l(t),n.s=D.s):n=new l(u.toString()),o=(e=l.precision)+3;;)if(a=n,s=a.times(a).times(a),f=s.plus(D),n=ce(f.plus(D).times(a),f.plus(s),o+2,1),ze(a.d).slice(0,o)===(t=ze(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(k(a,e+1,0),a.times(a).times(a).eq(D))){n=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(k(n,e+1,1),r=!n.times(n).times(n).eq(D));break}return j=!0,k(n,e,l.rounding,r)},I.decimalPlaces=I.dp=function(){var e,r=this.d,t=NaN;if(r){if(e=r.length-1,t=(e-qe(this.e/K))*K,e=r[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},I.dividedBy=I.div=function(e){return ce(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var r=this,t=r.constructor;return k(ce(r,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return this.cmp(e)===0},I.floor=function(){return k(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var r=this.cmp(e);return r==1||r===0},I.hyperbolicCosine=I.cosh=function(){var e,r,t,n,i,u=this,o=u.constructor,a=new o(1);if(!u.isFinite())return new o(u.s?1/0:NaN);if(u.isZero())return a;t=o.precision,n=o.rounding,o.precision=t+Math.max(u.e,u.sd())+4,o.rounding=1,i=u.d.length,i<32?(e=Math.ceil(i/3),r=(1/dt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),u=Sr(o,1,u.times(r),new o(1),!0);for(var s,f=e,D=new o(8);f--;)s=u.times(u),u=a.minus(s.times(D.minus(s.times(D))));return k(u,o.precision=t,o.rounding=n,!0)},I.hyperbolicSine=I.sinh=function(){var e,r,t,n,i=this,u=i.constructor;if(!i.isFinite()||i.isZero())return new u(i);if(r=u.precision,t=u.rounding,u.precision=r+Math.max(i.e,i.sd())+4,u.rounding=1,n=i.d.length,n<3)i=Sr(u,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/dt(5,e)),i=Sr(u,2,i,i,!0);for(var o,a=new u(5),s=new u(16),f=new u(20);e--;)o=i.times(i),i=i.times(a.plus(o.times(s.times(o).plus(f))))}return u.precision=r,u.rounding=t,k(i,r,t,!0)},I.hyperbolicTangent=I.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+7,n.rounding=1,ce(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)},I.inverseCosine=I.acos=function(){var e=this,r=e.constructor,t=e.abs().cmp(1),n=r.precision,i=r.rounding;return t!==-1?t===0?e.isNeg()?ar(r,n,i):new r(0):new r(NaN):e.isZero()?ar(r,n+4,i).times(.5):(r.precision=n+6,r.rounding=1,e=new r(1).minus(e).div(e.plus(1)).sqrt().atan(),r.precision=n,r.rounding=i,e.times(2))},I.inverseHyperbolicCosine=I.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(e=n.precision,r=n.rounding,n.precision=e+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,j=!1,t=t.times(t).minus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)},I.inverseHyperbolicSine=I.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,j=!1,t=t.times(t).plus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln())},I.inverseHyperbolicTangent=I.atanh=function(){var e,r,t,n,i=this,u=i.constructor;return i.isFinite()?i.e>=0?new u(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=u.precision,r=u.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?k(new u(i),e,r,!0):(u.precision=t=n-i.e,i=ce(i.plus(1),new u(1).minus(i),t+e,1),u.precision=e+4,u.rounding=1,i=i.ln(),u.precision=e,u.rounding=r,i.times(.5))):new u(NaN)},I.inverseSine=I.asin=function(){var e,r,t,n,i=this,u=i.constructor;return i.isZero()?new u(i):(r=i.abs().cmp(1),t=u.precision,n=u.rounding,r!==-1?r===0?(e=ar(u,t+4,n).times(.5),e.s=i.s,e):new u(NaN):(u.precision=t+6,u.rounding=1,i=i.div(new u(1).minus(i.times(i)).sqrt().plus(1)).atan(),u.precision=t,u.rounding=n,i.times(2)))},I.inverseTangent=I.atan=function(){var e,r,t,n,i,u,o,a,s,f=this,D=f.constructor,l=D.precision,h=D.rounding;if(f.isFinite()){if(f.isZero())return new D(f);if(f.abs().eq(1)&&l+4<=Gt)return o=ar(D,l+4,h).times(.25),o.s=f.s,o}else{if(!f.s)return new D(NaN);if(l+4<=Gt)return o=ar(D,l+4,h).times(.5),o.s=f.s,o}for(D.precision=a=l+10,D.rounding=1,t=Math.min(28,a/K+2|0),e=t;e;--e)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(j=!1,r=Math.ceil(a/K),n=1,s=f.times(f),o=new D(f),i=f;e!==-1;)if(i=i.times(s),u=o.minus(i.div(n+=2)),i=i.times(s),o=u.plus(i.div(n+=2)),o.d[r]!==void 0)for(e=r;o.d[e]===u.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),j=!0,k(o,D.precision=l,D.rounding=h,!0)},I.isFinite=function(){return!!this.d},I.isInteger=I.isInt=function(){return!!this.d&&qe(this.e/K)>this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&this.d[0]===0},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.log=function(e){var r,t,n,i,u,o,a,s,f=this,D=f.constructor,l=D.precision,h=D.rounding,p=5;if(e==null)e=new D(10),r=!0;else{if(e=new D(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new D(NaN);r=e.eq(10)}if(t=f.d,f.s<0||!t||!t[0]||f.eq(1))return new D(t&&!t[0]?-1/0:f.s!=1?NaN:t?0:1/0);if(r)if(t.length>1)u=!0;else{for(i=t[0];i%10===0;)i/=10;u=i!==1}if(j=!1,a=l+p,o=vr(f,a),n=r?mt(D,a+10):vr(e,a),s=ce(o,n,a,1),Wr(s.d,i=l,h))do if(a+=10,o=vr(f,a),n=r?mt(D,a+10):vr(e,a),s=ce(o,n,a,1),!u){+ze(s.d).slice(i+1,i+15)+1==1e14&&(s=k(s,l+1,0));break}while(Wr(s.d,i+=10,h));return j=!0,k(s,l,h)},I.minus=I.sub=function(e){var r,t,n,i,u,o,a,s,f,D,l,h,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(f=p.d,h=e.d,a=m.precision,s=m.rounding,!f[0]||!h[0]){if(h[0])e.s=-e.s;else if(f[0])e=new m(p);else return new m(s===3?-0:0);return j?k(e,a,s):e}if(t=qe(e.e/K),D=qe(p.e/K),f=f.slice(),u=D-t,u){for(l=u<0,l?(r=f,u=-u,o=h.length):(r=h,t=D,o=f.length),n=Math.max(Math.ceil(a/K),o)+2,u>n&&(u=n,r.length=1),r.reverse(),n=u;n--;)r.push(0);r.reverse()}else{for(n=f.length,o=h.length,l=n<o,l&&(o=n),n=0;n<o;n++)if(f[n]!=h[n]){l=f[n]<h[n];break}u=0}for(l&&(r=f,f=h,h=r,e.s=-e.s),o=f.length,n=h.length-o;n>0;--n)f[o++]=0;for(n=h.length;n>u;){if(f[--n]<h[n]){for(i=n;i&&f[--i]===0;)f[i]=er-1;--f[i],f[n]+=er}f[n]-=h[n]}for(;f[--o]===0;)f.pop();for(;f[0]===0;f.shift())--t;return f[0]?(e.d=f,e.e=pt(f,t),j?k(e,a,s):e):new m(s===3?-0:0)},I.modulo=I.mod=function(e){var r,t=this,n=t.constructor;return e=new n(e),!t.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||t.d&&!t.d[0]?k(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(r=ce(t,e.abs(),0,3,1),r.s*=e.s):r=ce(t,e,0,n.modulo,1),r=r.times(e),j=!0,t.minus(r))},I.naturalExponential=I.exp=function(){return Jt(this)},I.naturalLogarithm=I.ln=function(){return vr(this)},I.negated=I.neg=function(){var e=new this.constructor(this);return e.s=-e.s,k(e)},I.plus=I.add=function(e){var r,t,n,i,u,o,a,s,f,D,l=this,h=l.constructor;if(e=new h(e),!l.d||!e.d)return!l.s||!e.s?e=new h(NaN):l.d||(e=new h(e.d||l.s===e.s?l:NaN)),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(f=l.d,D=e.d,a=h.precision,s=h.rounding,!f[0]||!D[0])return D[0]||(e=new h(l)),j?k(e,a,s):e;if(u=qe(l.e/K),n=qe(e.e/K),f=f.slice(),i=u-n,i){for(i<0?(t=f,i=-i,o=D.length):(t=D,n=u,o=f.length),u=Math.ceil(a/K),o=u>o?u+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=f.length,i=D.length,o-i<0&&(i=o,t=D,D=f,f=t),r=0;i;)r=(f[--i]=f[i]+D[i]+r)/er|0,f[i]%=er;for(r&&(f.unshift(r),++n),o=f.length;f[--o]==0;)f.pop();return e.d=f,e.e=pt(f,n),j?k(e,a,s):e},I.precision=I.sd=function(e){var r,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(dr+e);return t.d?(r=zn(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r},I.round=function(){var e=this,r=e.constructor;return k(new r(e),e.e+1,r.rounding)},I.sine=I.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=lo(n,Un(n,t)),n.precision=e,n.rounding=r,k(sr>2?t.neg():t,e,r,!0)):new n(NaN)},I.squareRoot=I.sqrt=function(){var e,r,t,n,i,u,o=this,a=o.d,s=o.e,f=o.s,D=o.constructor;if(f!==1||!a||!a[0])return new D(!f||f<0&&(!a||a[0])?NaN:a?o:1/0);for(j=!1,f=Math.sqrt(+o),f==0||f==1/0?(r=ze(a),(r.length+s)%2==0&&(r+="0"),f=Math.sqrt(r),s=qe((s+1)/2)-(s<0||s%2),f==1/0?r="5e"+s:(r=f.toExponential(),r=r.slice(0,r.indexOf("e")+1)+s),n=new D(r)):n=new D(f.toString()),t=(s=D.precision)+3;;)if(u=n,n=u.plus(ce(o,u,t+2,1)).times(.5),ze(u.d).slice(0,t)===(r=ze(n.d)).slice(0,t))if(r=r.slice(t-3,t+1),r=="9999"||!i&&r=="4999"){if(!i&&(k(u,s+1,0),u.times(u).eq(o))){n=u;break}t+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(k(n,s+1,1),e=!n.times(n).eq(o));break}return j=!0,k(n,s,D.rounding,e)},I.tangent=I.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+10,n.rounding=1,t=t.sin(),t.s=1,t=ce(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,k(sr==2||sr==4?t.neg():t,e,r,!0)):new n(NaN)},I.times=I.mul=function(e){var r,t,n,i,u,o,a,s,f,D=this,l=D.constructor,h=D.d,p=(e=new l(e)).d;if(e.s*=D.s,!h||!h[0]||!p||!p[0])return new l(!e.s||h&&!h[0]&&!p||p&&!p[0]&&!h?NaN:!h||!p?e.s/0:e.s*0);for(t=qe(D.e/K)+qe(e.e/K),s=h.length,f=p.length,s<f&&(u=h,h=p,p=u,o=s,s=f,f=o),u=[],o=s+f,n=o;n--;)u.push(0);for(n=f;--n>=0;){for(r=0,i=s+n;i>n;)a=u[i]+p[n]*h[i-n-1]+r,u[i--]=a%er|0,r=a/er|0;u[i]=(u[i]+r)%er|0}for(;!u[--o];)u.pop();return r?++t:u.shift(),e.d=u,e.e=pt(u,t),j?k(e,l.precision,l.rounding):e},I.toBinary=function(e,r){return kt(this,2,e,r)},I.toDecimalPlaces=I.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),e===void 0?t:(Ze(e,0,Dr),r===void 0?r=n.rounding:Ze(r,0,8),k(t,e+t.e+1,r))},I.toExponential=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=or(n,!0):(Ze(e,0,Dr),r===void 0?r=i.rounding:Ze(r,0,8),n=k(new i(n),e+1,r),t=or(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toFixed=function(e,r){var t,n,i=this,u=i.constructor;return e===void 0?t=or(i):(Ze(e,0,Dr),r===void 0?r=u.rounding:Ze(r,0,8),n=k(new u(i),e+i.e+1,r),t=or(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},I.toFraction=function(e){var r,t,n,i,u,o,a,s,f,D,l,h,p=this,m=p.d,c=p.constructor;if(!m)return new c(p);if(f=t=new c(1),n=s=new c(0),r=new c(n),u=r.e=zn(m)-p.e-1,o=u%K,r.d[0]=Se(10,o<0?K+o:o),e==null)e=u>0?r:f;else{if(a=new c(e),!a.isInt()||a.lt(f))throw Error(dr+a);e=a.gt(r)?u>0?r:f:a}for(j=!1,a=new c(ze(m)),D=c.precision,c.precision=u=m.length*K*2;l=ce(a,r,0,1,1),i=t.plus(l.times(n)),i.cmp(e)!=1;)t=n,n=i,i=f,f=s.plus(l.times(i)),s=i,i=r,r=a.minus(l.times(i)),a=i;return i=ce(e.minus(t),n,0,1,1),s=s.plus(i.times(f)),t=t.plus(i.times(n)),s.s=f.s=p.s,h=ce(f,n,u,1).minus(p).abs().cmp(ce(s,t,u,1).minus(p).abs())<1?[f,n]:[s,t],c.precision=D,j=!0,h},I.toHexadecimal=I.toHex=function(e,r){return kt(this,16,e,r)},I.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),e==null){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),r===void 0?r=n.rounding:Ze(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(j=!1,t=ce(t,e,0,r,1).times(e),j=!0,k(t)):(e.s=t.s,t=e),t},I.toNumber=function(){return+this},I.toOctal=function(e,r){return kt(this,8,e,r)},I.toPower=I.pow=function(e){var r,t,n,i,u,o,a=this,s=a.constructor,f=+(e=new s(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new s(Se(+a,f));if(a=new s(a),a.eq(1))return a;if(n=s.precision,u=s.rounding,e.eq(1))return k(a,n,u);if(r=qe(e.e/K),r>=e.d.length-1&&(t=f<0?-f:f)<=ao)return i=On(s,a,t,n),e.s<0?new s(1).div(i):k(i,n,u);if(o=a.s,o<0){if(r<e.d.length-1)return new s(NaN);if((e.d[r]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=Se(+a,f),r=t==0||!isFinite(t)?qe(f*(Math.log("0."+ze(a.d))/Math.LN10+a.e+1)):new s(t+"").e,r>s.maxE+1||r<s.minE-1?new s(r>0?o/0:0):(j=!1,s.rounding=a.s=1,t=Math.min(12,(r+"").length),i=Jt(e.times(vr(a,n+t)),n),i.d&&(i=k(i,n+5,1),Wr(i.d,n,u)&&(r=n+10,i=k(Jt(e.times(vr(a,r+t)),r),r+5,1),+ze(i.d).slice(n+1,n+15)+1==1e14&&(i=k(i,n+1,0)))),i.s=o,j=!0,s.rounding=u,k(i,n,u))},I.toPrecision=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=or(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Ze(e,1,Dr),r===void 0?r=i.rounding:Ze(r,0,8),n=k(new i(n),e,r),t=or(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toSignificantDigits=I.toSD=function(e,r){var t=this,n=t.constructor;return e===void 0?(e=n.precision,r=n.rounding):(Ze(e,1,Dr),r===void 0?r=n.rounding:Ze(r,0,8)),k(new n(t),e,r)},I.toString=function(){var e=this,r=e.constructor,t=or(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},I.truncated=I.trunc=function(){return k(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var e=this,r=e.constructor,t=or(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};function ze(e){var r,t,n,i=e.length-1,u="",o=e[0];if(i>0){for(u+=o,r=1;r<i;r++)n=e[r]+"",t=K-n.length,t&&(u+=gr(t)),u+=n;o=e[r],n=o+"",t=K-n.length,t&&(u+=gr(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return u+o}function Ze(e,r,t){if(e!==~~e||e<r||e>t)throw Error(dr+e)}function Wr(e,r,t,n){var i,u,o,a;for(u=e[0];u>=10;u/=10)--r;return--r<0?(r+=K,i=0):(i=Math.ceil((r+1)/K),r%=K),u=Se(10,K-r),a=e[i]%u|0,n==null?r<3?(r==0?a=a/100|0:r==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==u||t>3&&a+1==u/2)&&(e[i+1]/u/100|0)==Se(10,r-2)-1||(a==u/2||a==0)&&(e[i+1]/u/100|0)==0:r<4?(r==0?a=a/1e3|0:r==1?a=a/100|0:r==2&&(a=a/10|0),o=(n||t<4)&&a==9999||!n&&t>3&&a==4999):o=((n||t<4)&&a+1==u||!n&&t>3&&a+1==u/2)&&(e[i+1]/u/1e3|0)==Se(10,r-3)-1,o}function ht(e,r,t){for(var n,i=[0],u,o=0,a=e.length;o<a;){for(u=i.length;u--;)i[u]*=r;for(i[0]+=Wt.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function fo(e,r){var t,n,i;if(r.isZero())return r;n=r.d.length,n<32?(t=Math.ceil(n/3),i=(1/dt(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Sr(e,1,r.times(i),new e(1));for(var u=t;u--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}var ce=(function(){function e(n,i,u){var o,a=0,s=n.length;for(n=n.slice();s--;)o=n[s]*i+a,n[s]=o%u|0,a=o/u|0;return a&&n.unshift(a),n}function r(n,i,u,o){var a,s;if(u!=o)s=u>o?1:-1;else for(a=s=0;a<u;a++)if(n[a]!=i[a]){s=n[a]>i[a]?1:-1;break}return s}function t(n,i,u,o){for(var a=0;u--;)n[u]-=a,a=n[u]<i[u]?1:0,n[u]=a*o+n[u]-i[u];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,u,o,a,s){var f,D,l,h,p,m,c,d,v,y,g,A,F,w,_,b,B,S,x,O,G=n.constructor,R=n.s==i.s?1:-1,H=n.d,$=i.d;if(!H||!H[0]||!$||!$[0])return new G(!n.s||!i.s||(H?$&&H[0]==$[0]:!$)?NaN:H&&H[0]==0||!$?R*0:R/0);for(s?(p=1,D=n.e-i.e):(s=er,p=K,D=qe(n.e/p)-qe(i.e/p)),x=$.length,B=H.length,v=new G(R),y=v.d=[],l=0;$[l]==(H[l]||0);l++);if($[l]>(H[l]||0)&&D--,u==null?(w=u=G.precision,o=G.rounding):a?w=u+(n.e-i.e)+1:w=u,w<0)y.push(1),m=!0;else{if(w=w/p+2|0,l=0,x==1){for(h=0,$=$[0],w++;(l<B||h)&&w--;l++)_=h*s+(H[l]||0),y[l]=_/$|0,h=_%$|0;m=h||l<B}else{for(h=s/($[0]+1)|0,h>1&&($=e($,h,s),H=e(H,h,s),x=$.length,B=H.length),b=x,g=H.slice(0,x),A=g.length;A<x;)g[A++]=0;O=$.slice(),O.unshift(0),S=$[0],$[1]>=s/2&&++S;do h=0,f=r($,g,x,A),f<0?(F=g[0],x!=A&&(F=F*s+(g[1]||0)),h=F/S|0,h>1?(h>=s&&(h=s-1),c=e($,h,s),d=c.length,A=g.length,f=r(c,g,d,A),f==1&&(h--,t(c,x<d?O:$,d,s))):(h==0&&(f=h=1),c=$.slice()),d=c.length,d<A&&c.unshift(0),t(g,c,A,s),f==-1&&(A=g.length,f=r($,g,x,A),f<1&&(h++,t(g,x<A?O:$,A,s))),A=g.length):f===0&&(h++,g=[0]),y[l++]=h,f&&g[0]?g[A++]=H[b]||0:(g=[H[b]],A=1);while((b++<B||g[0]!==void 0)&&w--);m=g[0]!==void 0}y[0]||y.shift()}if(p==1)v.e=D,Sn=m;else{for(l=1,h=y[0];h>=10;h/=10)l++;v.e=l+D*p-1,k(v,a?u+v.e+1:u,o,m)}return v}})();function k(e,r,t,n){var i,u,o,a,s,f,D,l,h,p=e.constructor;e:if(r!=null){if(l=e.d,!l)return e;for(i=1,a=l[0];a>=10;a/=10)i++;if(u=r-i,u<0)u+=K,o=r,D=l[h=0],s=D/Se(10,i-o-1)%10|0;else if(h=Math.ceil((u+1)/K),a=l.length,h>=a)if(n){for(;a++<=h;)l.push(0);D=s=0,i=1,u%=K,o=u-K+1}else break e;else{for(D=a=l[h],i=1;a>=10;a/=10)i++;u%=K,o=u-K+i,s=o<0?0:D/Se(10,i-o-1)%10|0}if(n=n||r<0||l[h+1]!==void 0||(o<0?D:D%Se(10,i-o-1)),f=t<4?(s||n)&&(t==0||t==(e.s<0?3:2)):s>5||s==5&&(t==4||n||t==6&&(u>0?o>0?D/Se(10,i-o):0:l[h-1])%10&1||t==(e.s<0?8:7)),r<1||!l[0])return l.length=0,f?(r-=e.e+1,l[0]=Se(10,(K-r%K)%K),e.e=-r||0):l[0]=e.e=0,e;if(u==0?(l.length=h,a=1,h--):(l.length=h+1,a=Se(10,K-u),l[h]=o>0?(D/Se(10,i-o)%Se(10,o)|0)*a:0),f)for(;;)if(h==0){for(u=1,o=l[0];o>=10;o/=10)u++;for(o=l[0]+=a,a=1;o>=10;o/=10)a++;u!=a&&(e.e++,l[0]==er&&(l[0]=1));break}else{if(l[h]+=a,l[h]!=er)break;l[h--]=0,a=1}for(u=l.length;l[--u]===0;)l.pop()}return j&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function or(e,r,t){if(!e.isFinite())return qn(e);var n,i=e.e,u=ze(e.d),o=u.length;return r?(t&&(n=t-o)>0?u=u.charAt(0)+"."+u.slice(1)+gr(n):o>1&&(u=u.charAt(0)+"."+u.slice(1)),u=u+(e.e<0?"e":"e+")+e.e):i<0?(u="0."+gr(-i-1)+u,t&&(n=t-o)>0&&(u+=gr(n))):i>=o?(u+=gr(i+1-o),t&&(n=t-i-1)>0&&(u=u+"."+gr(n))):((n=i+1)<o&&(u=u.slice(0,n)+"."+u.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(u+="."),u+=gr(n))),u}function pt(e,r){var t=e[0];for(r*=K;t>=10;t/=10)r++;return r}function mt(e,r,t){if(r>so)throw j=!0,t&&(e.precision=t),Error(Mn);return k(new e(ft),r,1,!0)}function ar(e,r,t){if(r>Gt)throw Error(Mn);return k(new e(ct),r,t,!0)}function zn(e){var r=e.length-1,t=r*K+1;if(r=e[r],r){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function gr(e){for(var r="";e--;)r+="0";return r}function On(e,r,t,n){var i,u=new e(1),o=Math.ceil(n/K+4);for(j=!1;;){if(t%2&&(u=u.times(r),Rn(u.d,o)&&(i=!0)),t=qe(t/2),t===0){t=u.d.length-1,i&&u.d[t]===0&&++u.d[t];break}r=r.times(r),Rn(r.d,o)}return j=!0,u}function $n(e){return e.d[e.d.length-1]&1}function Pn(e,r,t){for(var n,i,u=new e(r[0]),o=0;++o<r.length;){if(i=new e(r[o]),!i.s){u=i;break}n=u.cmp(i),(n===t||n===0&&u.s===t)&&(u=i)}return u}function Jt(e,r){var t,n,i,u,o,a,s,f=0,D=0,l=0,h=e.constructor,p=h.rounding,m=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(r==null?(j=!1,s=m):s=r,a=new h(.03125);e.e>-2;)e=e.times(a),l+=5;for(n=Math.log(Se(2,l))/Math.LN10*2+5|0,s+=n,t=u=o=new h(1),h.precision=s;;){if(u=k(u.times(e),s,1),t=t.times(++D),a=o.plus(ce(u,t,s,1)),ze(a.d).slice(0,s)===ze(o.d).slice(0,s)){for(i=l;i--;)o=k(o.times(o),s,1);if(r==null)if(f<3&&Wr(o.d,s-n,p,f))h.precision=s+=10,t=u=a=new h(1),D=0,f++;else return k(o,h.precision=m,p,j=!0);else return h.precision=m,o}o=a}}function vr(e,r){var t,n,i,u,o,a,s,f,D,l,h,p=1,m=10,c=e,d=c.d,v=c.constructor,y=v.rounding,g=v.precision;if(c.s<0||!d||!d[0]||!c.e&&d[0]==1&&d.length==1)return new v(d&&!d[0]?-1/0:c.s!=1?NaN:d?0:c);if(r==null?(j=!1,D=g):D=r,v.precision=D+=m,t=ze(d),n=t.charAt(0),Math.abs(u=c.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)c=c.times(e),t=ze(c.d),n=t.charAt(0),p++;u=c.e,n>1?(c=new v("0."+t),u++):c=new v(n+"."+t.slice(1))}else return f=mt(v,D+2,g).times(u+""),c=vr(new v(n+"."+t.slice(1)),D-m).plus(f),v.precision=g,r==null?k(c,g,y,j=!0):c;for(l=c,s=o=c=ce(c.minus(1),c.plus(1),D,1),h=k(c.times(c),D,1),i=3;;){if(o=k(o.times(h),D,1),f=s.plus(ce(o,new v(i),D,1)),ze(f.d).slice(0,D)===ze(s.d).slice(0,D))if(s=s.times(2),u!==0&&(s=s.plus(mt(v,D+2,g).times(u+""))),s=ce(s,new v(p),D,1),r==null)if(Wr(s.d,D-m,y,a))v.precision=D+=m,f=o=c=ce(l.minus(1),l.plus(1),D,1),h=k(c.times(c),D,1),i=a=1;else return k(s,v.precision=g,y,j=!0);else return v.precision=g,s;s=f,i+=2}}function qn(e){return String(e.s*e.s/0)}function Dt(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;r.charCodeAt(n)===48;n++);for(i=r.length;r.charCodeAt(i-1)===48;--i);if(r=r.slice(n,i),r){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%K,t<0&&(n+=K),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=K;n<i;)e.d.push(+r.slice(n,n+=K));r=r.slice(n),n=K-r.length}else n-=i;for(;n--;)r+="0";e.d.push(+r),j&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function co(e,r){var t,n,i,u,o,a,s,f,D;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),In.test(r))return Dt(e,r)}else if(r==="Infinity"||r==="NaN")return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(uo.test(r))t=16,r=r.toLowerCase();else if(io.test(r))t=2;else if(oo.test(r))t=8;else throw Error(dr+r);for(u=r.search(/p/i),u>0?(s=+r.slice(u+1),r=r.substring(2,u)):r=r.slice(2),u=r.indexOf("."),o=u>=0,n=e.constructor,o&&(r=r.replace(".",""),a=r.length,u=a-u,i=On(n,new n(t),u,u*2)),f=ht(r,t,er),D=f.length-1,u=D;f[u]===0;--u)f.pop();return u<0?new n(e.s*0):(e.e=pt(f,D),e.d=f,j=!1,o&&(e=ce(e,i,a*4)),s&&(e=e.times(Math.abs(s)<54?Se(2,s):Mr.pow(2,s))),j=!0,e)}function lo(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Sr(e,2,r,r);t=1.4*Math.sqrt(n),t=t>16?16:t|0,r=r.times(1/dt(5,t)),r=Sr(e,2,r,r);for(var i,u=new e(5),o=new e(16),a=new e(20);t--;)i=r.times(r),r=r.times(u.plus(i.times(o.times(i).minus(a))));return r}function Sr(e,r,t,n,i){var u,o,a,s,f=e.precision,D=Math.ceil(f/K);for(j=!1,s=t.times(t),a=new e(n);;){if(o=ce(a.times(s),new e(r++*r++),f,1),a=i?n.plus(o):n.minus(o),n=ce(o.times(s),new e(r++*r++),f,1),o=a.plus(n),o.d[D]!==void 0){for(u=D;o.d[u]===a.d[u]&&u--;);if(u==-1)break}u=a,a=n,n=o,o=u}return j=!0,o.d.length=D+1,o}function dt(e,r){for(var t=e;--r;)t*=e;return t}function Un(e,r){var t,n=r.s<0,i=ar(e,e.precision,1),u=i.times(.5);if(r=r.abs(),r.lte(u))return sr=n?4:1,r;if(t=r.divToInt(i),t.isZero())sr=n?3:2;else{if(r=r.minus(t.times(i)),r.lte(u))return sr=$n(t)?n?2:3:n?4:1,r;sr=$n(t)?n?1:4:n?3:2}return r.minus(i).abs()}function kt(e,r,t,n){var i,u,o,a,s,f,D,l,h,p=e.constructor,m=t!==void 0;if(m?(Ze(t,1,Dr),n===void 0?n=p.rounding:Ze(n,0,8)):(t=p.precision,n=p.rounding),!e.isFinite())D=qn(e);else{for(D=or(e),o=D.indexOf("."),m?(i=2,r==16?t=t*4-3:r==8&&(t=t*3-2)):i=r,o>=0&&(D=D.replace(".",""),h=new p(1),h.e=D.length-o,h.d=ht(or(h),10,i),h.e=h.d.length),l=ht(D,10,i),u=s=l.length;l[--s]==0;)l.pop();if(!l[0])D=m?"0p+0":"0";else{if(o<0?u--:(e=new p(e),e.d=l,e.e=u,e=ce(e,h,t,n,0,i),l=e.d,u=e.e,f=Sn),o=l[t],a=i/2,f=f||l[t+1]!==void 0,f=n<4?(o!==void 0||f)&&(n===0||n===(e.s<0?3:2)):o>a||o===a&&(n===4||f||n===6&&l[t-1]&1||n===(e.s<0?8:7)),l.length=t,f)for(;++l[--t]>i-1;)l[t]=0,t||(++u,l.unshift(1));for(s=l.length;!l[s-1];--s);for(o=0,D="";o<s;o++)D+=Wt.charAt(l[o]);if(m){if(s>1)if(r==16||r==8){for(o=r==16?4:3,--s;s%o;s++)D+="0";for(l=ht(D,i,r),s=l.length;!l[s-1];--s);for(o=1,D="1.";o<s;o++)D+=Wt.charAt(l[o])}else D=D.charAt(0)+"."+D.slice(1);D=D+(u<0?"p":"p+")+u}else if(u<0){for(;++u;)D="0"+D;D="0."+D}else if(++u>s)for(u-=s;u--;)D+="0";else u<s&&(D=D.slice(0,u)+"."+D.slice(u))}D=(r==16?"0x":r==2?"0b":r==8?"0o":"")+D}return e.s<0?"-"+D:D}function Rn(e,r){if(e.length>r)return e.length=r,!0}function ho(e){return new this(e).abs()}function po(e){return new this(e).acos()}function mo(e){return new this(e).acosh()}function Do(e,r){return new this(e).plus(r)}function go(e){return new this(e).asin()}function vo(e){return new this(e).asinh()}function wo(e){return new this(e).atan()}function yo(e){return new this(e).atanh()}function Fo(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,u=n+4;return!e.s||!r.s?t=new this(NaN):!e.d&&!r.d?(t=ar(this,u,1).times(r.s>0?.25:.75),t.s=e.s):!r.d||e.isZero()?(t=r.s<0?ar(this,n,i):new this(0),t.s=e.s):!e.d||r.isZero()?(t=ar(this,u,1).times(.5),t.s=e.s):r.s<0?(this.precision=u,this.rounding=1,t=this.atan(ce(e,r,u,1)),r=ar(this,u,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(ce(e,r,u,1)),t}function Eo(e){return new this(e).cbrt()}function Ao(e){return k(e=new this(e),e.e+1,2)}function bo(e,r,t){return new this(e).clamp(r,t)}function Co(e){if(!e||typeof e!="object")throw Error(lt+"Object expected");var r,t,n,i=e.defaults===!0,u=["precision",1,Dr,"rounding",0,8,"toExpNeg",-Nr,0,"toExpPos",0,Nr,"maxE",0,Nr,"minE",-Nr,0,"modulo",0,9];for(r=0;r<u.length;r+=3)if(t=u[r],i&&(this[t]=Vt[t]),(n=e[t])!==void 0)if(qe(n)===n&&n>=u[r+1]&&n<=u[r+2])this[t]=n;else throw Error(dr+t+": "+n);if(t="crypto",i&&(this[t]=Vt[t]),(n=e[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(xn);else this[t]=!1;else throw Error(dr+t+": "+n);return this}function _o(e){return new this(e).cos()}function Bo(e){return new this(e).cosh()}function Ln(e){var r,t,n;function i(u){var o,a,s,f=this;if(!(f instanceof i))return new i(u);if(f.constructor=i,Hn(u)){f.s=u.s,j?!u.d||u.e>i.maxE?(f.e=NaN,f.d=null):u.e<i.minE?(f.e=0,f.d=[0]):(f.e=u.e,f.d=u.d.slice()):(f.e=u.e,f.d=u.d?u.d.slice():u.d);return}if(s=typeof u,s==="number"){if(u===0){f.s=1/u<0?-1:1,f.e=0,f.d=[0];return}if(u<0?(u=-u,f.s=-1):f.s=1,u===~~u&&u<1e7){for(o=0,a=u;a>=10;a/=10)o++;j?o>i.maxE?(f.e=NaN,f.d=null):o<i.minE?(f.e=0,f.d=[0]):(f.e=o,f.d=[u]):(f.e=o,f.d=[u]);return}if(u*0!==0){u||(f.s=NaN),f.e=NaN,f.d=null;return}return Dt(f,u.toString())}if(s==="string")return(a=u.charCodeAt(0))===45?(u=u.slice(1),f.s=-1):(a===43&&(u=u.slice(1)),f.s=1),In.test(u)?Dt(f,u):co(f,u);if(s==="bigint")return u<0?(u=-u,f.s=-1):f.s=1,Dt(f,u.toString());throw Error(dr+u)}if(i.prototype=I,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Co,i.clone=Ln,i.isDecimal=Hn,i.abs=ho,i.acos=po,i.acosh=mo,i.add=Do,i.asin=go,i.asinh=vo,i.atan=wo,i.atanh=yo,i.atan2=Fo,i.cbrt=Eo,i.ceil=Ao,i.clamp=bo,i.cos=_o,i.cosh=Bo,i.div=No,i.exp=So,i.floor=Mo,i.hypot=xo,i.ln=To,i.log=Io,i.log10=Oo,i.log2=zo,i.max=$o,i.min=Po,i.mod=qo,i.mul=Uo,i.pow=Ro,i.random=Lo,i.round=Ho,i.sign=Zo,i.sin=Wo,i.sinh=Vo,i.sqrt=Go,i.sub=Jo,i.sum=ko,i.tan=Yo,i.tanh=Xo,i.trunc=Qo,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<n.length;)e.hasOwnProperty(t=n[r++])||(e[t]=this[t]);return i.config(e),i}function No(e,r){return new this(e).div(r)}function So(e){return new this(e).exp()}function Mo(e){return k(e=new this(e),e.e+1,3)}function xo(){var e,r,t=new this(0);for(j=!1,e=0;e<arguments.length;)if(r=new this(arguments[e++]),r.d)t.d&&(t=t.plus(r.times(r)));else{if(r.s)return j=!0,new this(1/0);t=r}return j=!0,t.sqrt()}function Hn(e){return e instanceof Mr||e&&e.toStringTag===Tn||!1}function To(e){return new this(e).ln()}function Io(e,r){return new this(e).log(r)}function zo(e){return new this(e).log(2)}function Oo(e){return new this(e).log(10)}function $o(){return Pn(this,arguments,-1)}function Po(){return Pn(this,arguments,1)}function qo(e,r){return new this(e).mod(r)}function Uo(e,r){return new this(e).mul(r)}function Ro(e,r){return new this(e).pow(r)}function Lo(e){var r,t,n,i,u=0,o=new this(1),a=[];if(e===void 0?e=this.precision:Ze(e,1,Dr),n=Math.ceil(e/K),this.crypto)if(crypto.getRandomValues)for(r=crypto.getRandomValues(new Uint32Array(n));u<n;)i=r[u],i>=429e7?r[u]=crypto.getRandomValues(new Uint32Array(1))[0]:a[u++]=i%1e7;else if(crypto.randomBytes){for(r=crypto.randomBytes(n*=4);u<n;)i=r[u]+(r[u+1]<<8)+(r[u+2]<<16)+((r[u+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(r,u):(a.push(i%1e7),u+=4);u=n/4}else throw Error(xn);else for(;u<n;)a[u++]=Math.random()*1e7|0;for(n=a[--u],e%=K,n&&e&&(i=Se(10,K-e),a[u]=(n/i|0)*i);a[u]===0;u--)a.pop();if(u<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=K)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<K&&(t-=K-n)}return o.e=t,o.d=a,o}function Ho(e){return k(e=new this(e),e.e+1,this.rounding)}function Zo(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Wo(e){return new this(e).sin()}function Vo(e){return new this(e).sinh()}function Go(e){return new this(e).sqrt()}function Jo(e,r){return new this(e).sub(r)}function ko(){var e=0,r=arguments,t=new this(r[e]);for(j=!1;t.s&&++e<r.length;)t=t.plus(r[e]);return j=!0,k(t,this.precision,this.rounding)}function Yo(e){return new this(e).tan()}function Xo(e){return new this(e).tanh()}function Qo(e){return k(e=new this(e),e.e+1,1)}I[Symbol.for("nodejs.util.inspect.custom")]=I.toString,I[Symbol.toStringTag]="Decimal";var Mr=I.constructor=Ln(Vt);ft=new Mr(ft),ct=new Mr(ct);var Ko="BigNumber",jo=["?on","config"],ea=V(Ko,jo,e=>{var{on:r,config:t}=e,n=Mr.clone({precision:t.precision,modulo:Mr.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(i){return new n(i.value)},r&&r("config",function(i,u){i.precision!==u.precision&&n.config({precision:i.precision})}),n},{isClass:!0});const Ue=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},Ye=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},ra=function(e){const r=Math.PI/4;if(-r>e||e>r)return Math.cos(e)-1;const t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Yt=function(e,r){return e=Math.abs(e),r=Math.abs(r),e<r&&([e,r]=[r,e]),e<1e8?Math.sqrt(e*e+r*r):(r/=e,e*Math.sqrt(1+r*r))},xr=function(){throw SyntaxError("Invalid Param")};function Xt(e,r){const t=Math.abs(e),n=Math.abs(r);return e===0?Math.log(n):r===0?Math.log(t):t<3e3&&n<3e3?Math.log(e*e+r*r)*.5:(e=e*.5,r=r*.5,.5*Math.log(e*e+r*r)+Math.LN2)}const ta={re:0,im:0},Er=function(e,r){const t=ta;if(e==null)t.re=t.im=0;else if(r!==void 0)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return M.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return M.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else e.length===2?(t.re=e[0],t.im=e[1]):xr();break;case"string":t.im=t.re=0;const n=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let i=1,u=0;n===null&&xr();for(let o=0;o<n.length;o++){const a=n[o];a===" "||a===" "||a===`
|
|
9
|
+
`||(a==="+"?i++:a==="-"?u++:a==="i"||a==="I"?(i+u===0&&xr(),n[o+1]!==" "&&!isNaN(n[o+1])?(t.im+=parseFloat((u%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((u%2?"-":"")+"1"),i=u=0):((i+u===0||isNaN(a))&&xr(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((u%2?"-":"")+a),o++):t.re+=parseFloat((u%2?"-":"")+a),i=u=0))}i+u>0&&xr();break;case"number":t.im=0,t.re=e;break;default:xr()}return isNaN(t.re)||isNaN(t.im),t};function M(e,r){if(!(this instanceof M))return new M(e,r);const t=Er(e,r);this.re=t.re,this.im=t.im}M.prototype={re:0,im:0,sign:function(){const e=Yt(this.re,this.im);return new M(this.re/e,this.im/e)},add:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?M.NAN:M.INFINITY:new M(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?M.NAN:M.INFINITY:new M(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;return n&&o||i&&u?M.NAN:n||i?M.INFINITY:t.im===0&&this.im===0?new M(this.re*t.re,0):new M(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=Er(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;if(u&&o||n&&i)return M.NAN;if(o||n)return M.INFINITY;if(u||i)return M.ZERO;if(t.im===0)return new M(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const a=t.re/t.im,s=t.re*a+t.im;return new M((this.re*a+this.im)/s,(this.im*a-this.re)/s)}else{const a=t.im/t.re,s=t.im*a+t.re;return new M((this.re+this.im*a)/s,(this.im-this.re*a)/s)}},pow:function(e,r){const t=Er(e,r),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return M.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new M(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new M(Math.pow(this.im,t.re),0);case 1:return new M(0,Math.pow(this.im,t.re));case 2:return new M(-Math.pow(this.im,t.re),0);case 3:return new M(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return M.ZERO;const u=Math.atan2(this.im,this.re),o=Xt(this.re,this.im);let a=Math.exp(t.re*o-t.im*u),s=t.im*o+t.re*u;return new M(a*Math.cos(s),a*Math.sin(s))},sqrt:function(){const e=this.re,r=this.im;if(r===0)return e>=0?new M(Math.sqrt(e),0):new M(0,Math.sqrt(-e));const t=Yt(e,r);let n=Math.sqrt(.5*(t+Math.abs(e))),i=Math.abs(r)/(2*n);return e>=0?new M(n,r<0?-i:i):new M(i,r<0?-n:n)},exp:function(){const e=Math.exp(this.re);return this.im===0?new M(e,0):new M(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new M(Math.expm1(e)*Math.cos(r)+ra(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return r===0&&e>0?new M(Math.log(e),0):new M(Xt(e,r),Math.atan2(r,e))},abs:function(){return Yt(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,r=this.im;return new M(Math.sin(e)*Ue(r),Math.cos(e)*Ye(r))},cos:function(){const e=this.re,r=this.im;return new M(Math.cos(e)*Ue(r),-Math.sin(e)*Ye(r))},tan:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)+Ue(r);return new M(Math.sin(e)/t,Ye(r)/t)},cot:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)-Ue(r);return new M(-Math.sin(e)/t,Ye(r)/t)},sec:function(){const e=this.re,r=this.im,t=.5*Ue(2*r)+.5*Math.cos(2*e);return new M(Math.cos(e)*Ue(r)/t,Math.sin(e)*Ye(r)/t)},csc:function(){const e=this.re,r=this.im,t=.5*Ue(2*r)-.5*Math.cos(2*e);return new M(Math.sin(e)*Ue(r)/t,-Math.cos(e)*Ye(r)/t)},asin:function(){const e=this.re,r=this.im,t=new M(r*r-e*e+1,-2*e*r).sqrt(),n=new M(t.re-r,t.im+e).log();return new M(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new M(r*r-e*e+1,-2*e*r).sqrt(),n=new M(t.re-r,t.im+e).log();return new M(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(e===0){if(r===1)return new M(0,1/0);if(r===-1)return new M(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new M((1-r*r-e*e)/t,-2*e/t).log();return new M(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(r===0)return new M(Math.atan2(1,e),0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).atan():new M(e!==0?e/0:0,r!==0?-r/0:0).atan()},asec:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(0,1/0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).acos():new M(e!==0?e/0:0,r!==0?-r/0:0).acos()},acsc:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(Math.PI/2,1/0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).asin():new M(e!==0?e/0:0,r!==0?-r/0:0).asin()},sinh:function(){const e=this.re,r=this.im;return new M(Ye(e)*Math.cos(r),Ue(e)*Math.sin(r))},cosh:function(){const e=this.re,r=this.im;return new M(Ue(e)*Math.cos(r),Ye(e)*Math.sin(r))},tanh:function(){const e=2*this.re,r=2*this.im,t=Ue(e)+Math.cos(r);return new M(Ye(e)/t,Math.sin(r)/t)},coth:function(){const e=2*this.re,r=2*this.im,t=Ue(e)-Math.cos(r);return new M(Ye(e)/t,-Math.sin(r)/t)},csch:function(){const e=this.re,r=this.im,t=Math.cos(2*r)-Ue(2*e);return new M(-2*Ye(e)*Math.cos(r)/t,2*Ue(e)*Math.sin(r)/t)},sech:function(){const e=this.re,r=this.im,t=Math.cos(2*r)+Ue(2*e);return new M(2*Ue(e)*Math.cos(r)/t,-2*Ye(e)*Math.sin(r)/t)},asinh:function(){let e=this.im;this.im=-this.re,this.re=e;const r=this.asin();return this.re=-this.im,this.im=e,e=r.re,r.re=-r.im,r.im=e,r},acosh:function(){const e=this.acos();if(e.im<=0){const r=e.re;e.re=-e.im,e.im=r}else{const r=e.im;e.im=-e.re,e.re=r}return e},atanh:function(){const e=this.re,r=this.im,t=e>1&&r===0,n=1-e,i=1+e,u=n*n+r*r,o=u!==0?new M((i*n-r*r)/u,(r*n+i*r)/u):new M(e!==-1?e/0:0,r!==0?r/0:0),a=o.re;return o.re=Xt(o.re,o.im)/2,o.im=Math.atan2(o.im,a)/2,t&&(o.im=-o.im),o},acoth:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(0,Math.PI/2);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).atanh():new M(e!==0?e/0:0,r!==0?-r/0:0).atanh()},acsch:function(){const e=this.re,r=this.im;if(r===0)return new M(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).asinh():new M(e!==0?e/0:0,r!==0?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return M.INFINITY;const t=e*e+r*r;return t!==0?new M(e/t,-r/t).acosh():new M(e!==0?e/0:0,r!==0?-r/0:0).acosh()},inverse:function(){if(this.isZero())return M.INFINITY;if(this.isInfinite())return M.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new M(e/t,-r/t)},conjugate:function(){return new M(this.re,-this.im)},neg:function(){return new M(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new M(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new M(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new M(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=Er(e,r);return Math.abs(t.re-this.re)<=M.EPSILON&&Math.abs(t.im-this.im)<=M.EPSILON},clone:function(){return new M(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<M.EPSILON&&(e=0),Math.abs(r)<M.EPSILON&&(r=0),r===0?t+e:(e!==0?(t+=e,t+=" ",r<0?(r=-r,t+="-"):t+="+",t+=" "):r<0&&(r=-r,t+="-"),r!==1&&(t+=r),t+"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.isFinite()}},M.ZERO=new M(0,0),M.ONE=new M(1,0),M.I=new M(0,1),M.PI=new M(Math.PI,0),M.E=new M(Math.E,0),M.INFINITY=new M(1/0,1/0),M.NAN=new M(NaN,NaN),M.EPSILON=1e-15;var na="Complex",ia=[],ua=V(na,ia,()=>(Object.defineProperty(M,"name",{value:"Complex"}),M.prototype.constructor=M,M.prototype.type="Complex",M.prototype.isComplex=!0,M.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},M.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},M.prototype.format=function(e){var r="",t=this.im,n=this.re,i=Zt(this.re,e),u=Zt(this.im,e),o=ne(e)?e:e?e.precision:null;if(o!==null){var a=Math.pow(10,-o);Math.abs(n/t)<a&&(n=0),Math.abs(t/n)<a&&(t=0)}return t===0?r=i:n===0?t===1?r="i":t===-1?r="-i":r=u+"i":t<0?t===-1?r=i+" - i":r=i+" - "+u.substring(1)+"i":t===1?r=i+" + i":r=i+" + "+u+"i",r},M.fromPolar=function(e){switch(arguments.length){case 1:{var r=arguments[0];if(typeof r=="object")return M(r);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],n=arguments[1];if(ne(t)){if(vn(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),ne(n))return new M({r:t,phi:n});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")}},M.prototype.valueOf=M.prototype.toString,M.fromJSON=function(e){return new M(e)},M.compare=function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0},M),{isClass:!0});typeof BigInt>"u"&&(BigInt=function(e){if(isNaN(e))throw new Error("");return e});const Y=BigInt(0),re=BigInt(1),Vr=BigInt(2),Qt=BigInt(5),We=BigInt(10),oa=2e3,L={s:re,n:Y,d:re};function fr(e,r){try{e=BigInt(e)}catch{throw wr()}return e*r}function rr(e){return typeof e=="bigint"?e:Math.floor(e)}function Ae(e,r){if(r===Y)throw Kt();const t=Object.create(Xe.prototype);t.s=e<Y?-re:re,e=e<Y?-e:e;const n=Ar(e,r);return t.n=e/n,t.d=r/n,t}function Tr(e){const r={};let t=e,n=Vr,i=Qt-re;for(;i<=t;){for(;t%n===Y;)t/=n,r[n]=(r[n]||Y)+re;i+=re+Vr*n++}return t!==e?t>1&&(r[t]=(r[t]||Y)+re):r[e]=(r[e]||Y)+re,r}const xe=function(e,r){let t=Y,n=re,i=re;if(e!=null)if(r!==void 0){if(typeof e=="bigint")t=e;else{if(isNaN(e))throw wr();if(e%1!==0)throw Zn();t=BigInt(e)}if(typeof r=="bigint")n=r;else{if(isNaN(r))throw wr();if(r%1!==0)throw Zn();n=BigInt(r)}i=t*n}else if(typeof e=="object"){if("d"in e&&"n"in e)t=BigInt(e.n),n=BigInt(e.d),"s"in e&&(t*=BigInt(e.s));else if(0 in e)t=BigInt(e[0]),1 in e&&(n=BigInt(e[1]));else if(typeof e=="bigint")t=e;else throw wr();i=t*n}else if(typeof e=="number"){if(isNaN(e))throw wr();if(e<0&&(i=-re,e=-e),e%1===0)t=BigInt(e);else{let u=1,o=0,a=1,s=1,f=1,D=1e7;for(e>=1&&(u=10**Math.floor(1+Math.log10(e)),e/=u);a<=D&&f<=D;){let l=(o+s)/(a+f);if(e===l){a+f<=D?(t=o+s,n=a+f):f>a?(t=s,n=f):(t=o,n=a);break}else e>l?(o+=s,a+=f):(s+=o,f+=a),a>D?(t=s,n=f):(t=o,n=a)}t=BigInt(t)*BigInt(u),n=BigInt(n)}}else if(typeof e=="string"){let u=0,o=Y,a=Y,s=Y,f=re,D=re,l=e.replace(/_/g,"").match(/\d+|./g);if(l===null)throw wr();if(l[u]==="-"?(i=-re,u++):l[u]==="+"&&u++,l.length===u+1?a=fr(l[u++],i):l[u+1]==="."||l[u]==="."?(l[u]!=="."&&(o=fr(l[u++],i)),u++,(u+1===l.length||l[u+1]==="("&&l[u+3]===")"||l[u+1]==="'"&&l[u+3]==="'")&&(a=fr(l[u],i),f=We**BigInt(l[u].length),u++),(l[u]==="("&&l[u+2]===")"||l[u]==="'"&&l[u+2]==="'")&&(s=fr(l[u+1],i),D=We**BigInt(l[u+1].length)-re,u+=3)):l[u+1]==="/"||l[u+1]===":"?(a=fr(l[u],i),f=fr(l[u+2],re),u+=3):l[u+3]==="/"&&l[u+1]===" "&&(o=fr(l[u],i),a=fr(l[u+2],i),f=fr(l[u+4],re),u+=5),l.length<=u)n=f*D,i=t=s+n*o+D*a;else throw wr()}else if(typeof e=="bigint")t=e,i=e,n=re;else throw wr();if(n===Y)throw Kt();L.s=i<Y?-re:re,L.n=t<Y?-t:t,L.d=n<Y?-n:n};function aa(e,r,t){let n=re;for(;r>Y;e=e*e%t,r>>=re)r&re&&(n=n*e%t);return n}function sa(e,r){for(;r%Vr===Y;r/=Vr);for(;r%Qt===Y;r/=Qt);if(r===re)return Y;let t=We%r,n=1;for(;t!==re;n++)if(t=t*We%r,n>oa)return Y;return BigInt(n)}function fa(e,r,t){let n=re,i=aa(We,t,r);for(let u=0;u<300;u++){if(n===i)return BigInt(u);n=n*We%r,i=i*We%r}return 0}function Ar(e,r){if(!e)return r;if(!r)return e;for(;;){if(e%=r,!e)return r;if(r%=e,!r)return e}}function Xe(e,r){if(xe(e,r),this instanceof Xe)e=Ar(L.d,L.n),this.s=L.s,this.n=L.n/e,this.d=L.d/e;else return Ae(L.s*L.n,L.d)}var Kt=function(){return new Error("Division by Zero")},wr=function(){return new Error("Invalid argument")},Zn=function(){return new Error("Parameters must be integer")};Xe.prototype={s:re,n:Y,d:re,abs:function(){return Ae(this.n,this.d)},neg:function(){return Ae(-this.s*this.n,this.d)},add:function(e,r){return xe(e,r),Ae(this.s*this.n*L.d+L.s*this.d*L.n,this.d*L.d)},sub:function(e,r){return xe(e,r),Ae(this.s*this.n*L.d-L.s*this.d*L.n,this.d*L.d)},mul:function(e,r){return xe(e,r),Ae(this.s*L.s*this.n*L.n,this.d*L.d)},div:function(e,r){return xe(e,r),Ae(this.s*L.s*this.n*L.d,this.d*L.n)},clone:function(){return Ae(this.s*this.n,this.d)},mod:function(e,r){if(e===void 0)return Ae(this.s*this.n%this.d,re);if(xe(e,r),Y===L.n*this.d)throw Kt();return Ae(this.s*(L.d*this.n)%(L.n*this.d),L.d*this.d)},gcd:function(e,r){return xe(e,r),Ae(Ar(L.n,this.n)*Ar(L.d,this.d),L.d*this.d)},lcm:function(e,r){return xe(e,r),L.n===Y&&this.n===Y?Ae(Y,re):Ae(L.n*this.n,Ar(L.n,this.n)*Ar(L.d,this.d))},inverse:function(){return Ae(this.s*this.d,this.n)},pow:function(e,r){if(xe(e,r),L.d===re)return L.s<Y?Ae((this.s*this.d)**L.n,this.n**L.n):Ae((this.s*this.n)**L.n,this.d**L.n);if(this.s<Y)return null;let t=Tr(this.n),n=Tr(this.d),i=re,u=re;for(let o in t)if(o!=="1"){if(o==="0"){i=Y;break}if(t[o]*=L.n,t[o]%L.d===Y)t[o]/=L.d;else return null;i*=BigInt(o)**t[o]}for(let o in n)if(o!=="1"){if(n[o]*=L.n,n[o]%L.d===Y)n[o]/=L.d;else return null;u*=BigInt(o)**n[o]}return L.s<Y?Ae(u,i):Ae(i,u)},log:function(e,r){if(xe(e,r),this.s<=Y||L.s<=Y)return null;const t={},n=Tr(L.n),i=Tr(L.d),u=Tr(this.n),o=Tr(this.d);for(const f in i)n[f]=(n[f]||Y)-i[f];for(const f in o)u[f]=(u[f]||Y)-o[f];for(const f in n)f!=="1"&&(t[f]=!0);for(const f in u)f!=="1"&&(t[f]=!0);let a=null,s=null;for(const f in t){const D=n[f]||Y,l=u[f]||Y;if(D===Y){if(l!==Y)return null;continue}let h=l,p=D;const m=Ar(h,p);if(h/=m,p/=m,a===null&&s===null)a=h,s=p;else if(h*s!==a*p)return null}return a!==null&&s!==null?Ae(a,s):null},equals:function(e,r){return xe(e,r),this.s*this.n*L.d===L.s*L.n*this.d},lt:function(e,r){return xe(e,r),this.s*this.n*L.d<L.s*L.n*this.d},lte:function(e,r){return xe(e,r),this.s*this.n*L.d<=L.s*L.n*this.d},gt:function(e,r){return xe(e,r),this.s*this.n*L.d>L.s*L.n*this.d},gte:function(e,r){return xe(e,r),this.s*this.n*L.d>=L.s*L.n*this.d},compare:function(e,r){xe(e,r);let t=this.s*this.n*L.d-L.s*L.n*this.d;return(Y<t)-(t<Y)},ceil:function(e){return e=We**BigInt(e||0),Ae(rr(this.s*e*this.n/this.d)+(e*this.n%this.d>Y&&this.s>=Y?re:Y),e)},floor:function(e){return e=We**BigInt(e||0),Ae(rr(this.s*e*this.n/this.d)-(e*this.n%this.d>Y&&this.s<Y?re:Y),e)},round:function(e){return e=We**BigInt(e||0),Ae(rr(this.s*e*this.n/this.d)+this.s*((this.s>=Y?re:Y)+Vr*(e*this.n%this.d)>this.d?re:Y),e)},roundTo:function(e,r){xe(e,r);const t=this.n*L.d,n=this.d*L.n,i=t%n;let u=rr(t/n);return i+i>=n&&u++,Ae(this.s*u*L.n,L.d)},divisible:function(e,r){return xe(e,r),!(!(L.n*this.d)||this.n*L.d%(L.n*this.d))},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e){let r=this.n,t=this.d;e=e||15;let n=sa(r,t),i=fa(r,t,n),u=this.s<Y?"-":"";if(u+=rr(r/t),r%=t,r*=We,r&&(u+="."),n){for(let o=i;o--;)u+=rr(r/t),r%=t,r*=We;u+="(";for(let o=n;o--;)u+=rr(r/t),r%=t,r*=We;u+=")"}else for(let o=e;r&&o--;)u+=rr(r/t),r%=t,r*=We;return u},toFraction:function(e){let r=this.n,t=this.d,n=this.s<Y?"-":"";if(t===re)n+=r;else{let i=rr(r/t);e&&i>Y&&(n+=i,n+=" ",r%=t),n+=r,n+="/",n+=t}return n},toLatex:function(e){let r=this.n,t=this.d,n=this.s<Y?"-":"";if(t===re)n+=r;else{let i=rr(r/t);e&&i>Y&&(n+=i,r%=t),n+="\\frac{",n+=r,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let e=this.n,r=this.d,t=[];do{t.push(rr(e/r));let n=e%r;e=r,r=n}while(e!==re);return t},simplify:function(e){const r=BigInt(1/(e||.001)|0),t=this.abs(),n=t.toContinued();for(let i=1;i<n.length;i++){let u=Ae(n[i-1],re);for(let a=i-2;a>=0;a--)u=u.inverse().add(n[a]);let o=u.sub(t);if(o.n*r<o.d)return u.mul(this.s)}return this}};var ca="Fraction",la=[],ha=V(ca,la,()=>(Object.defineProperty(Xe,"name",{value:"Fraction"}),Xe.prototype.constructor=Xe,Xe.prototype.type="Fraction",Xe.prototype.isFraction=!0,Xe.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},Xe.fromJSON=function(e){return new Xe(e)},Xe),{isClass:!0}),pa="Matrix",ma=[],Da=V(pa,ma,()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(r,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(r,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(r){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(r,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(r,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(r,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(r,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(r){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(r){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0});function jt(e,r,t){var n=e.constructor,i=new n(2),u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ye(t))throw new Error("size must be an integer");if(e.greaterThan(i.pow(t-1).sub(1))||e.lessThan(i.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(i.pow(t))),u="i".concat(t)}switch(r){case 2:return"".concat(e.toBinary()).concat(u);case 8:return"".concat(e.toOctal()).concat(u);case 16:return"".concat(e.toHexadecimal()).concat(u);default:throw new Error("Base ".concat(r," not supported "))}}function da(e,r){if(typeof r=="function")return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:i}=An(r);switch(t){case"fixed":return va(e,n);case"exponential":return Wn(e,n);case"engineering":return ga(e,n);case"bin":return jt(e,2,i);case"oct":return jt(e,8,i);case"hex":return jt(e,16,i);case"auto":{var u=Vn(r?.lowerExp,-3),o=Vn(r?.upperExp,5);if(e.isZero())return"0";var a,s=e.toSignificantDigits(n),f=s.e;return f>=u&&f<o?a=s.toFixed():a=Wn(e,n),a.replace(/((\.\d*?)(0+))($|e)/,function(){var D=arguments[2],l=arguments[4];return D!=="."?D+l:l})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ga(e,r){var t=e.e,n=t%3===0?t:t<0?t-3-t%3:t-t%3,i=e.mul(Math.pow(10,-n)),u=i.toPrecision(r);if(u.includes("e")){var o=e.constructor;u=new o(u).toFixed()}return u+"e"+(t>=0?"+":"")+n.toString()}function Wn(e,r){return r!==void 0?e.toExponential(r-1):e.toExponential()}function va(e,r){return e.toFixed(r)}function Vn(e,r){return ne(e)?e:Ee(e)?e.toNumber():r}function _e(e,r){var t=wa(e,r);return r&&typeof r=="object"&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function wa(e,r){if(typeof e=="number")return Zt(e,r);if(Ee(e))return da(e,r);if(ya(e))return!r||r.fraction!=="decimal"?"".concat(e.s*e.n,"/").concat(e.d):e.toString();if(Array.isArray(e))return kn(e,r);if(Me(e))return Gn(e);if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(r);if(e&&e.toString(r)!=={}.toString())return e.toString(r);var t=Object.keys(e).map(n=>Gn(n)+": "+_e(e[n],r));return"{"+t.join(", ")+"}"}return String(e)}function Gn(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Jn?Jn[i]:i,n++}return'"'+t+'"'}var Jn={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function kn(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)i!==0&&(t+=", "),t+=kn(e[i],r);return t+="]",t}else return _e(e,r)}function ya(e){return e&&typeof e=="object"&&typeof e.s=="bigint"&&typeof e.n=="bigint"&&typeof e.d=="bigint"||!1}function ie(e,r,t){if(!(this instanceof ie))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=new Error().stack}ie.prototype=new RangeError,ie.prototype.constructor=RangeError,ie.prototype.name="DimensionError",ie.prototype.isDimensionError=!0;function br(e,r,t){if(!(this instanceof br))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,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}br.prototype=new RangeError,br.prototype.constructor=RangeError,br.prototype.name="IndexError",br.prototype.isIndexError=!0;function Oe(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function Yn(e,r,t){var n,i=e.length;if(i!==r[t])throw new ie(i,r[t]);if(t<r.length-1){var u=t+1;for(n=0;n<i;n++){var o=e[n];if(!Array.isArray(o))throw new ie(r.length-1,r.length,"<");Yn(e[n],r,u)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new ie(r.length+1,r.length,">")}function Xn(e,r){var t=r.length===0;if(t){if(Array.isArray(e))throw new ie(e.length,0)}else Yn(e,r,0)}function gt(e,r){var t=e.isMatrix?e._size:Oe(e),n=r._sourceSize;n.forEach((i,u)=>{if(i!==null&&i!==t[u])throw new ie(i,t[u])})}function De(e,r){if(e!==void 0){if(!ne(e)||!ye(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof r=="number"&&e>=r)throw new br(e,r)}}function Ir(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&ve(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(Me(t)&&t.length===0)return!0}return!1}function vt(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new Error("Resizing to scalar is not supported");r.forEach(function(i){if(!ne(i)||!ye(i)||i<0)throw new TypeError("Invalid size, must contain positive integers (size: "+_e(r)+")")}),(ne(e)||Ee(e))&&(e=[e]);var n=t!==void 0?t:0;return en(e,r,0,n),e}function en(e,r,t,n){var i,u,o=e.length,a=r[t],s=Math.min(o,a);if(e.length=a,t<r.length-1){var f=t+1;for(i=0;i<s;i++)u=e[i],Array.isArray(u)||(u=[u],e[i]=u),en(u,r,f,n);for(i=s;i<a;i++)u=[],e[i]=u,en(u,r,f,n)}else{for(i=0;i<s;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=s;i<a;i++)e[i]=n}}function Qn(e,r){var t=Ea(e,!0),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new ie(0,n,"!=");r=rn(r,n);var i=Kn(r);if(n!==i)throw new ie(i,n,"!=");try{return Fa(t,r)}catch(u){throw u instanceof ie?new ie(i,n,"!="):u}}function rn(e,r){var t=Kn(e),n=e.slice(),i=-1,u=e.indexOf(i),o=e.indexOf(i,u+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var a=u>=0,s=r%t===0;if(a)if(s)n[u]=-r/t;else throw new Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);return n}function Kn(e){return e.reduce((r,t)=>r*t,1)}function Fa(e,r){for(var t=e,n,i=r.length-1;i>0;i--){var u=r[i];n=[];for(var o=t.length/u,a=0;a<o;a++)n.push(t.slice(a*u,(a+1)*u));t=n}return t}function jn(e,r,t,n){var i=n||Oe(e);if(t)for(var u=0;u<t;u++)e=[e],i.unshift(1);for(e=ei(e,r,0);i.length<r;)i.push(1);return e}function ei(e,r,t){var n,i;if(Array.isArray(e)){var u=t+1;for(n=0,i=e.length;n<i;n++)e[n]=ei(e[n],r,u)}else for(var o=t;o<r;o++)e=[e];return e}function Ea(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof r!="boolean")throw new TypeError("Boolean expected for second argument of flatten");var t=[];return r?i(e):n(e),t;function n(u){for(var o=0;o<u.length;o++){var a=u[o];Array.isArray(a)?n(a):t.push(a)}}function i(u){if(Array.isArray(u[0]))for(var o=0;o<u.length;o++)i(u[o]);else for(var a=0;a<u.length;a++)t.push(u[a])}}function wt(e,r){for(var t,n=0,i=0;i<e.length;i++){var u=e[i],o=Array.isArray(u);if(i===0&&o&&(n=u.length),o&&u.length!==n)return;var a=o?wt(u,r):r(u);if(t===void 0)t=a;else if(t!==a)return"mixed"}return t}function ri(e,r,t,n){if(n<t){if(e.length!==r.length)throw new ie(e.length,r.length);for(var i=[],u=0;u<e.length;u++)i[u]=ri(e[u],r[u],t,n+1);return i}else return e.concat(r)}function ti(){var e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(e.length===1)return e[0];if(e.length>1)return e.slice(1).reduce(function(t,n){return ri(t,n,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function ni(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map(h=>h.length),i=Math.max(...n),u=new Array(i).fill(null),o=0;o<r.length;o++)for(var a=r[o],s=n[o],f=0;f<s;f++){var D=i-s+f;a[f]>u[D]&&(u[D]=a[f])}for(var l=0;l<r.length;l++)ii(r[l],u);return u}function ii(e,r){for(var t=r.length,n=e.length,i=0;i<n;i++){var u=t-n+i;if(e[i]<r[u]&&e[i]>1||e[i]>r[u])throw new Error("shape mismatch: mismatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(r[u]))}}function tn(e,r){var t=Oe(e);if(mr(t,r))return e;ii(t,r);var n=ni(t,r),i=n.length,u=[...Array(i-t.length).fill(1),...t],o=ba(e);t.length<i&&(o=Qn(o,u),t=Oe(o));for(var a=0;a<i;a++)t[a]<n[a]&&(o=Aa(o,n[a],a),t=Oe(o));return o}function Aa(e,r,t){return ti(...Array(r).fill(e),t)}function ui(e,r){if(!Array.isArray(e))throw new Error("Array expected");var t=Oe(e);if(r.length!==t.length)throw new ie(r.length,t.length);for(var n=0;n<r.length;n++)De(r[n],t[n]);return r.reduce((i,u)=>i[u],e)}function oi(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(t)return u(e);var n=[];return i(e,0);function i(o,a){if(Array.isArray(o)){for(var s=o.length,f=Array(s),D=0;D<s;D++)n[a]=D,f[D]=i(o[D],a+1);return f}else return r(o,n.slice(0,a),e)}function u(o){if(Array.isArray(o)){for(var a=o.length,s=Array(a),f=0;f<a;f++)s[f]=u(o[f]);return s}else return r(o)}}function ba(e){return pr([],e)}function yt(e,r,t,n){if(it.isTypedFunction(e)){var i;if(n)i=1;else{var u=r.isMatrix?r.size():Oe(r),o=u.length?u[u.length-1]===0:!0;if(o)return{isUnary:n,fn:e};var a=u.map(()=>0),s=r.isMatrix?r.get(a):ui(r,a);i=Ba(e,s,a,r)}var f;if(r.isMatrix&&r.dataType!=="mixed"&&r.dataType!==void 0){var D=Ca(e,i);f=D!==void 0?D:e}else f=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){for(var h=arguments.length,p=new Array(h),m=0;m<h;m++)p[m]=arguments[m];return ai(f,p.slice(0,i),t,e.name)}}:{isUnary:!1,fn:function(){for(var h=arguments.length,p=new Array(h),m=0;m<h;m++)p[m]=arguments[m];return ai(f,p,t,e.name)}}}return n===void 0?{isUnary:_a(e),fn:e}:{isUnary:n,fn:e}}function Ca(e,r){var t=[];if(Object.entries(e.signatures).forEach(n=>{var[i,u]=n;i.split(",").length===r&&t.push(u)}),t.length===1)return t[0]}function _a(e){if(e.length!==1)return!1;var r=e.toString();if(/arguments/.test(r))return!1;var t=r.match(/\(.*?\)/);return!/\.\.\./.test(t)}function Ba(e,r,t,n){for(var i=[r,t,n],u=3;u>0;u--){var o=i.slice(0,u);if(it.resolve(e,o)!==null)return u}}function ai(e,r,t,n){try{return e(...r)}catch(i){Na(i,r,t,n)}}function Na(e,r,t,n){var i;if(e instanceof TypeError&&((i=e.data)===null||i===void 0?void 0:i.category)==="wrongType"){var u=[];throw u.push("value: ".concat(ur(r[0]))),r.length>=2&&u.push("index: ".concat(ur(r[1]))),r.length>=3&&u.push("array: ".concat(ur(r[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(u.join(", "),") at index ").concat(JSON.stringify(r[1])))}else throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}var Sa="DenseMatrix",Ma=["Matrix","config"],xa=V(Sa,Ma,e=>{var{Matrix:r,config:t}=e;function n(l,h){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!Me(h))throw new Error("Invalid datatype: "+h);if(we(l))l.type==="DenseMatrix"?(this._data=me(l._data),this._size=me(l._size),this._datatype=h||l._datatype):(this._data=l.toArray(),this._size=l.size(),this._datatype=h||l._datatype);else if(l&&ve(l.data)&&ve(l.size))this._data=l.data,this._size=l.size,Xn(this._data,this._size),this._datatype=h||l.datatype;else if(ve(l))this._data=D(l),this._size=Oe(this._data),Xn(this._data,this._size),this._datatype=h;else{if(l)throw new TypeError("Unsupported type of data ("+ur(l)+")");this._data=[],this._size=[0],this._datatype=h}}n.prototype=new r,n.prototype.createDenseMatrix=function(l,h){return new n(l,h)},Object.defineProperty(n,"name",{value:"DenseMatrix"}),n.prototype.constructor=n,n.prototype.type="DenseMatrix",n.prototype.isDenseMatrix=!0,n.prototype.getDataType=function(){return wt(this._data,ur)},n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(l,h){return new n(l,h)},n.prototype.subset=function(l,h,p){switch(arguments.length){case 1:return i(this,l);case 2:case 3:return o(this,l,h,p);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(l){return ui(this._data,l)},n.prototype.set=function(l,h,p){if(!ve(l))throw new TypeError("Array expected");if(l.length<this._size.length)throw new ie(l.length,this._size.length,"<");var m,c,d,v=l.map(function(g){return g+1});f(this,v,p);var y=this._data;for(m=0,c=l.length-1;m<c;m++)d=l[m],De(d,y.length),y=y[d];return d=l[l.length-1],De(d,y.length),y[d]=h,this};function i(l,h){if(!nt(h))throw new TypeError("Invalid index");var p=t.legacySubset?h.size().every(F=>F===1):h.isScalar();if(p)return l.get(h.min());var m=h.size();if(m.length!==l._size.length)throw new ie(m.length,l._size.length);for(var c=h.min(),d=h.max(),v=0,y=l._size.length;v<y;v++)De(c[v],l._size[v]),De(d[v],l._size[v]);var g=new n,A=u(l._data,h);return g._size=A.size,g._datatype=l._datatype,g._data=A.data,t.legacySubset?g.reshape(h.size()):g}function u(l,h){var p=h.size().length-1,m=Array(p);return{data:c(l),size:m.filter(d=>d!==null)};function c(d){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,y=h.dimension(v);function g(A,F){return ne(A)?F(A):A.map(F).valueOf()}return ne(y)?m[v]=null:m[v]=y.size()[0],v<p?g(y,A=>(De(A,d.length),c(d[A],v+1))):g(y,A=>(De(A,d.length),d[A]))}}function o(l,h,p,m){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var c=h.size(),d=h.isScalar(),v;if(we(p)?(v=p.size(),p=p.valueOf()):v=Oe(p),d){if(v.length!==0)throw new TypeError("Scalar expected");l.set(h.min(),p,m)}else{if(!mr(v,c)){if(v.length===0)p=tn([p],c);else try{p=tn(p,c)}catch{}v=Oe(p)}if(c.length<l._size.length)throw new ie(c.length,l._size.length,"<");if(v.length<c.length){for(var y=0,g=0;c[y]===1&&v[y]===1;)y++;for(;c[y]===1;)g++,y++;p=jn(p,c.length,g,v)}if(!mr(c,v))throw new ie(c,v,">");var A=h.max().map(function(F){return F+1});f(l,A,m),a(l._data,h,p)}return l}function a(l,h,p){var m=h.size().length-1;c(l,p);function c(d,v){var y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,g=h.dimension(y),A=(w,_)=>{De(w,d.length),c(d[w],v[_[0]],y+1)},F=(w,_)=>{De(w,d.length),d[w]=v[_[0]]};y<m?ne(g)?A(g,[0]):g.forEach(A):ne(g)?F(g,[0]):g.forEach(F)}}n.prototype.resize=function(l,h,p){if(!tt(l))throw new TypeError("Array or Matrix expected");var m=l.valueOf().map(d=>Array.isArray(d)&&d.length===1?d[0]:d),c=p?this.clone():this;return s(c,m,h)};function s(l,h,p){if(h.length===0){for(var m=l._data;ve(m);)m=m[0];return m}return l._size=h.slice(0),l._data=vt(l._data,l._size,p),l}n.prototype.reshape=function(l,h){var p=h?this.clone():this;p._data=Qn(p._data,l);var m=p._size.reduce((c,d)=>c*d);return p._size=rn(l,m),p};function f(l,h,p){for(var m=l._size.slice(0),c=!1;m.length<h.length;)m.push(0),c=!0;for(var d=0,v=h.length;d<v;d++)h[d]>m[d]&&(m[d]=h[d],c=!0);c&&s(l,m,p)}n.prototype.clone=function(){var l=new n({data:me(this._data),size:me(this._size),datatype:this._datatype});return l},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(l){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,p=this,m=p._size.length-1;if(m<0)return p.clone();var c=yt(l,p,"map",h),d=c.fn,v=p.create(void 0,p._datatype);if(v._size=p._size,h||c.isUnary)return v._data=_(p._data),v;if(m===0){for(var y=p.valueOf(),g=Array(y.length),A=0;A<y.length;A++)g[A]=d(y[A],[A],p);return v._data=g,v}var F=[];return v._data=w(p._data),v;function w(b){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(b.length);if(B<m)for(var x=0;x<b.length;x++)F[B]=x,S[x]=w(b[x],B+1);else for(var O=0;O<b.length;O++)F[B]=O,S[O]=d(b[O],F.slice(),p);return S}function _(b){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(b.length);if(B<m)for(var x=0;x<b.length;x++)S[x]=_(b[x],B+1);else for(var O=0;O<b.length;O++)S[O]=d(b[O]);return S}},n.prototype.forEach=function(l){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,p=this,m=p._size.length-1;if(m<0)return;var c=yt(l,p,"map",h),d=c.fn;if(h||c.isUnary){A(p._data);return}if(m===0){for(var v=0;v<p._data.length;v++)d(p._data[v],[v],p);return}var y=[];g(p._data);function g(F){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(w<m)for(var _=0;_<F.length;_++)y[w]=_,g(F[_],w+1);else for(var b=0;b<F.length;b++)y[w]=b,d(F[b],y.slice(),p)}function A(F){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(w<m)for(var _=0;_<F.length;_++)A(F[_],w+1);else for(var b=0;b<F.length;b++)d(F[b])}},n.prototype[Symbol.iterator]=function*(){var l=this._size.length-1;if(!(l<0)){if(l===0){for(var h=0;h<this._data.length;h++)yield{value:this._data[h],index:[h]};return}for(var p=Array(l+1).fill(0),m=this._size.reduce((g,A)=>g*A,1),c=0;c<m;c++){for(var d=this._data,v=0;v<l;v++)d=d[p[v]];yield{value:d[p[l]],index:p.slice()};for(var y=l;y>=0&&(p[y]++,!(p[y]<this._size[y]));y--)p[y]=0}}},n.prototype.rows=function(){var l=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var p=this._data;for(var m of p)l.push(new n([m],this._datatype));return l},n.prototype.columns=function(){var l=this,h=[],p=this.size();if(p.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var m=this._data,c=function(y){var g=m.map(A=>[A[y]]);h.push(new n(g,l._datatype))},d=0;d<p[1];d++)c(d);return h},n.prototype.toArray=function(){return me(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(l){return _e(this._data,l)},n.prototype.toString=function(){return _e(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(l){if(l){if(Ee(l)&&(l=l.toNumber()),!ne(l)||!ye(l))throw new TypeError("The parameter k must be an integer number")}else l=0;for(var h=l>0?l:0,p=l<0?-l:0,m=this._size[0],c=this._size[1],d=Math.min(m-p,c-h),v=[],y=0;y<d;y++)v[y]=this._data[y+p][y+h];return new n({data:v,size:[d],datatype:this._datatype})},n.diagonal=function(l,h,p,m){if(!ve(l))throw new TypeError("Array expected, size parameter");if(l.length!==2)throw new Error("Only two dimensions matrix are supported");if(l=l.map(function(b){if(Ee(b)&&(b=b.toNumber()),!ne(b)||!ye(b)||b<1)throw new Error("Size values must be positive integers");return b}),p){if(Ee(p)&&(p=p.toNumber()),!ne(p)||!ye(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var c=p>0?p:0,d=p<0?-p:0,v=l[0],y=l[1],g=Math.min(v-d,y-c),A;if(ve(h)){if(h.length!==g)throw new Error("Invalid value array length");A=function(B){return h[B]}}else if(we(h)){var F=h.size();if(F.length!==1||F[0]!==g)throw new Error("Invalid matrix length");A=function(B){return h.get([B])}}else A=function(){return h};m||(m=Ee(A(0))?A(0).mul(0):0);var w=[];if(l.length>0){w=vt(w,l,m);for(var _=0;_<g;_++)w[_+d][_+c]=A(_)}return new n({data:w,size:[v,y]})},n.fromJSON=function(l){return new n(l)},n.prototype.swapRows=function(l,h){if(!ne(l)||!ye(l)||!ne(h)||!ye(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return De(l,this._size[0]),De(h,this._size[0]),n._swapRows(l,h,this._data),this},n._swapRows=function(l,h,p){var m=p[l];p[l]=p[h],p[h]=m};function D(l){return we(l)?D(l.valueOf()):ve(l)?l.map(D):l}return n},{isClass:!0});function Ve(e,r,t){if(!t)return we(e)?e.map(i=>r(i),!1,!0):oi(e,r,!0);var n=i=>i===0?i:r(i);return we(e)?e.map(i=>n(i),!1,!0):oi(e,n,!0)}var si="isInteger",Ta=["typed","equal"],Ia=V(si,Ta,e=>{var{typed:r,equal:t}=e;return r(si,{number:n=>Number.isFinite(n)?t(n,Math.round(n)):!1,BigNumber:n=>n.isFinite()?t(n.round(),n):!1,bigint:n=>!0,Fraction:n=>n.d===1n,"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),nn="number",Ft="number, number";function fi(e){return Math.abs(e)}fi.signature=nn;function ci(e,r){return e+r}ci.signature=Ft;function li(e,r){return e-r}li.signature=Ft;function hi(e,r){return e*r}hi.signature=Ft;function pi(e){return-e}pi.signature=nn;function Et(e){return Qu(e)}Et.signature=nn;function mi(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}mi.signature=Ft;function Gr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!ye(r)||r<0||r>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(bn(e,r))}var za=Math.PI,Oa="number";function Di(e){return e>0}Di.signature=Oa;function yr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return e.isNaN()||r.isNaN()?!1:!e.isFinite()||!r.isFinite()?e.eq(r):e.eq(r)?!0:e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(),r.abs()).mul(t),n))}var di="isPositive",$a=["typed","config"],Pa=V(di,$a,e=>{var{typed:r,config:t}=e;return r(di,{number:n=>je(n,0,t.relTol,t.absTol)?!1:Di(n),BigNumber:n=>yr(n,new n.constructor(0),t.relTol,t.absTol)?!1:!n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n>0n,Fraction:n=>n.s>0n&&n.n>0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),gi="isZero",qa=["typed","equalScalar"],Ua=V(gi,qa,e=>{var{typed:r,equalScalar:t}=e;return r(gi,{"number | BigNumber | Complex | Fraction":n=>t(n,0),bigint:n=>n===0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})});function Ra(e,r,t,n){return je(e.re,r.re,t,n)&&je(e.im,r.im,t,n)}var Jr=V("compareUnits",["typed"],e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(!n.equalBase(i))throw new Error("Cannot compare units with different base");return r.find(t,[n.valueType(),i.valueType()])(n.value,i.value)})}}),At="equalScalar",La=["typed","config"],Ha=V(At,La,e=>{var{typed:r,config:t}=e,n=Jr({typed:r});return r(At,{"boolean, boolean":function(u,o){return u===o},"number, number":function(u,o){return je(u,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(u,o){return u.eq(o)||yr(u,o,t.relTol,t.absTol)},"bigint, bigint":function(u,o){return u===o},"Fraction, Fraction":function(u,o){return u.equals(o)},"Complex, Complex":function(u,o){return Ra(u,o,t.relTol,t.absTol)}},n)});V(At,["typed","config"],e=>{var{typed:r,config:t}=e;return r(At,{"number, number":function(i,u){return je(i,u,t.relTol,t.absTol)}})});var Za="SparseMatrix",Wa=["typed","equalScalar","Matrix"],Va=V(Za,Wa,e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function i(c,d){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(d&&!Me(d))throw new Error("Invalid datatype: "+d);if(we(c))u(this,c,d);else if(c&&ve(c.index)&&ve(c.ptr)&&ve(c.size))this._values=c.values,this._index=c.index,this._ptr=c.ptr,this._size=c.size,this._datatype=d||c.datatype;else if(ve(c))o(this,c,d);else{if(c)throw new TypeError("Unsupported type of data ("+ur(c)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=d}}function u(c,d,v){d.type==="SparseMatrix"?(c._values=d._values?me(d._values):void 0,c._index=me(d._index),c._ptr=me(d._ptr),c._size=me(d._size),c._datatype=v||d._datatype):o(c,d.valueOf(),v||d._datatype)}function o(c,d,v){c._values=[],c._index=[],c._ptr=[],c._datatype=v;var y=d.length,g=0,A=t,F=0;if(Me(v)&&(A=r.find(t,[v,v])||t,F=r.convert(0,v)),y>0){var w=0;do{c._ptr.push(c._index.length);for(var _=0;_<y;_++){var b=d[_];if(ve(b)){if(w===0&&g<b.length&&(g=b.length),w<b.length){var B=b[w];A(B,F)||(c._values.push(B),c._index.push(_))}}else w===0&&g<1&&(g=1),A(b,F)||(c._values.push(b),c._index.push(_))}w++}while(w<g)}for(;c._ptr.length<=g;)c._ptr.push(c._index.length);c._size=[y,g]}i.prototype=new n,i.prototype.createSparseMatrix=function(c,d){return new i(c,d)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return wt(this._values,ur)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(c,d){return new i(c,d)},i.prototype.density=function(){var c=this._size[0],d=this._size[1];return c!==0&&d!==0?this._index.length/(c*d):0},i.prototype.subset=function(c,d,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return a(this,c);case 2:case 3:return s(this,c,d,v);default:throw new SyntaxError("Wrong number of arguments")}};function a(c,d){if(!nt(d))throw new TypeError("Invalid index");var v=d.isScalar();if(v)return c.get(d.min());var y=d.size();if(y.length!==c._size.length)throw new ie(y.length,c._size.length);var g,A,F,w,_=d.min(),b=d.max();for(g=0,A=c._size.length;g<A;g++)De(_[g],c._size[g]),De(b[g],c._size[g]);var B=c._values,S=c._index,x=c._ptr,O=d.dimension(0),G=d.dimension(1),R=[],H=[];function $(ue,oe){H[ue]=oe[0],R[ue]=!0}Number.isInteger(O)?$(O,[0]):O.forEach($);var Q=B?[]:void 0,J=[],X=[];function ee(ue){for(X.push(J.length),F=x[ue],w=x[ue+1];F<w;F++)g=S[F],R[g]===!0&&(J.push(H[g]),Q&&Q.push(B[F]))}return Number.isInteger(G)?ee(G):G.forEach(ee),X.push(J.length),new i({values:Q,index:J,ptr:X,size:y,datatype:c._datatype})}function s(c,d,v,y){if(!d||d.isIndex!==!0)throw new TypeError("Invalid index");var g=d.size(),A=d.isScalar(),F;if(we(v)?(F=v.size(),v=v.toArray()):F=Oe(v),A){if(F.length!==0)throw new TypeError("Scalar expected");c.set(d.min(),v,y)}else{if(g.length!==1&&g.length!==2)throw new ie(g.length,c._size.length,"<");if(F.length<g.length){for(var w=0,_=0;g[w]===1&&F[w]===1;)w++;for(;g[w]===1;)_++,w++;v=jn(v,g.length,_,F)}if(!mr(g,F))throw new ie(g,F,">");if(g.length===1){var b=d.dimension(0);x(b,(O,G)=>{De(O),c.set([O,0],v[G[0]],y)})}else{var B=d.dimension(0),S=d.dimension(1);x(B,(O,G)=>{De(O),x(S,(R,H)=>{De(R),c.set([O,R],v[G[0]][H[0]],y)})})}}return c;function x(O,G){ne(O)?G(O,[0]):O.forEach(G)}}i.prototype.get=function(c){if(!ve(c))throw new TypeError("Array expected");if(c.length!==this._size.length)throw new ie(c.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var d=c[0],v=c[1];De(d,this._size[0]),De(v,this._size[1]);var y=f(d,this._ptr[v],this._ptr[v+1],this._index);return y<this._ptr[v+1]&&this._index[y]===d?this._values[y]:0},i.prototype.set=function(c,d,v){if(!ve(c))throw new TypeError("Array expected");if(c.length!==this._size.length)throw new ie(c.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var y=c[0],g=c[1],A=this._size[0],F=this._size[1],w=t,_=0;Me(this._datatype)&&(w=r.find(t,[this._datatype,this._datatype])||t,_=r.convert(0,this._datatype)),(y>A-1||g>F-1)&&(h(this,Math.max(y+1,A),Math.max(g+1,F),v),A=this._size[0],F=this._size[1]),De(y,A),De(g,F);var b=f(y,this._ptr[g],this._ptr[g+1],this._index);return b<this._ptr[g+1]&&this._index[b]===y?w(d,_)?D(b,g,this._values,this._index,this._ptr):this._values[b]=d:w(d,_)||l(b,y,g,d,this._values,this._index,this._ptr),this};function f(c,d,v,y){if(v-d===0)return v;for(var g=d;g<v;g++)if(y[g]===c)return g;return d}function D(c,d,v,y,g){v.splice(c,1),y.splice(c,1);for(var A=d+1;A<g.length;A++)g[A]--}function l(c,d,v,y,g,A,F){g.splice(c,0,y),A.splice(c,0,d);for(var w=v+1;w<F.length;w++)F[w]++}i.prototype.resize=function(c,d,v){if(!tt(c))throw new TypeError("Array or Matrix expected");var y=c.valueOf().map(A=>Array.isArray(A)&&A.length===1?A[0]:A);if(y.length!==2)throw new Error("Only two dimensions matrix are supported");y.forEach(function(A){if(!ne(A)||!ye(A)||A<0)throw new TypeError("Invalid size, must contain positive integers (size: "+_e(y)+")")});var g=v?this.clone():this;return h(g,y[0],y[1],d)};function h(c,d,v,y){var g=y||0,A=t,F=0;Me(c._datatype)&&(A=r.find(t,[c._datatype,c._datatype])||t,F=r.convert(0,c._datatype),g=r.convert(g,c._datatype));var w=!A(g,F),_=c._size[0],b=c._size[1],B,S,x;if(v>b){for(S=b;S<v;S++)if(c._ptr[S]=c._values.length,w)for(B=0;B<_;B++)c._values.push(g),c._index.push(B);c._ptr[v]=c._values.length}else v<b&&(c._ptr.splice(v+1,b-v),c._values.splice(c._ptr[v],c._values.length),c._index.splice(c._ptr[v],c._index.length));if(b=v,d>_){if(w){var O=0;for(S=0;S<b;S++){c._ptr[S]=c._ptr[S]+O,x=c._ptr[S+1]+O;var G=0;for(B=_;B<d;B++,G++)c._values.splice(x+G,0,g),c._index.splice(x+G,0,B),O++}c._ptr[b]=c._values.length}}else if(d<_){var R=0;for(S=0;S<b;S++){c._ptr[S]=c._ptr[S]-R;var H=c._ptr[S],$=c._ptr[S+1]-R;for(x=H;x<$;x++)B=c._index[x],B>d-1&&(c._values.splice(x,1),c._index.splice(x,1),R++)}c._ptr[S]=c._values.length}return c._size[0]=d,c._size[1]=v,c}i.prototype.reshape=function(c,d){if(!ve(c))throw new TypeError("Array expected");if(c.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");c.forEach(function(X){if(!ne(X)||!ye(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+_e(c)+")")});var v=this._size[0]*this._size[1];c=rn(c,v);var y=c[0]*c[1];if(v!==y)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=d?this.clone():this;if(this._size[0]===c[0]&&this._size[1]===c[1])return g;for(var A=[],F=0;F<g._ptr.length;F++)for(var w=0;w<g._ptr[F+1]-g._ptr[F];w++)A.push(F);for(var _=g._values.slice(),b=g._index.slice(),B=0;B<g._index.length;B++){var S=b[B],x=A[B],O=S*g._size[1]+x;A[B]=O%c[1],b[B]=Math.floor(O/c[1])}g._values.length=0,g._index.length=0,g._ptr.length=c[1]+1,g._size=c.slice();for(var G=0;G<g._ptr.length;G++)g._ptr[G]=0;for(var R=0;R<_.length;R++){var H=b[R],$=A[R],Q=_[R],J=f(H,g._ptr[$],g._ptr[$+1],g._index);l(J,H,$,Q,g._values,g._index,g._ptr)}return g},i.prototype.clone=function(){var c=new i({values:this._values?me(this._values):void 0,index:me(this._index),ptr:me(this._ptr),size:me(this._size),datatype:this._datatype});return c},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(c,d){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,y=this._size[0],g=this._size[1],A=yt(c,v,"map"),F=function(_,b,B){return A.fn(_,[b,B],v)};return p(this,0,y-1,0,g-1,F,d)};function p(c,d,v,y,g,A,F){var w=[],_=[],b=[],B=t,S=0;Me(c._datatype)&&(B=r.find(t,[c._datatype,c._datatype])||t,S=r.convert(0,c._datatype));for(var x=function(le,Be,Ce){var be=A(le,Be,Ce);B(be,S)||(w.push(be),_.push(Be))},O=y;O<=g;O++){b.push(w.length);var G=c._ptr[O],R=c._ptr[O+1];if(F)for(var H=G;H<R;H++){var $=c._index[H];$>=d&&$<=v&&x(c._values[H],$-d,O-y)}else{for(var Q={},J=G;J<R;J++){var X=c._index[J];Q[X]=c._values[J]}for(var ee=d;ee<=v;ee++){var ue=ee in Q?Q[ee]:0;x(ue,ee-d,O-y)}}}return b.push(w.length),new i({values:w,index:_,ptr:b,size:[v-d+1,g-y+1]})}i.prototype.forEach=function(c,d){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,y=this._size[0],g=this._size[1],A=yt(c,v,"forEach"),F=0;F<g;F++){var w=this._ptr[F],_=this._ptr[F+1];if(d)for(var b=w;b<_;b++){var B=this._index[b];A.fn(this._values[b],[B,F],v)}else{for(var S={},x=w;x<_;x++){var O=this._index[x];S[O]=this._values[x]}for(var G=0;G<y;G++){var R=G in S?S[G]:0;A.fn(R,[G,F],v)}}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var c=this._size[1],d=0;d<c;d++)for(var v=this._ptr[d],y=this._ptr[d+1],g=v;g<y;g++){var A=this._index[g];yield{value:this._values[g],index:[A,d]}}},i.prototype.toArray=function(){return m(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return m(this._values,this._index,this._ptr,this._size,!1)};function m(c,d,v,y,g){var A=y[0],F=y[1],w=[],_,b;for(_=0;_<A;_++)for(w[_]=[],b=0;b<F;b++)w[_][b]=0;for(b=0;b<F;b++)for(var B=v[b],S=v[b+1],x=B;x<S;x++)_=d[x],w[_][b]=c?g?me(c[x]):c[x]:1;return w}return i.prototype.format=function(c){for(var d=this._size[0],v=this._size[1],y=this.density(),g="Sparse Matrix ["+_e(d,c)+" x "+_e(v,c)+"] density: "+_e(y,c)+`
|
|
10
10
|
`,A=0;A<v;A++)for(var F=this._ptr[A],w=this._ptr[A+1],_=F;_<w;_++){var b=this._index[_];g+=`
|
|
11
|
-
(`+_e(b,c)+", "+_e(A,c)+") ==> "+(this._values?_e(this._values[_],c):"X")}return g},i.prototype.toString=function(){return _e(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(c){if(c){if(Ee(c)&&(c=c.toNumber()),!ne(c)||!ye(c))throw new TypeError("The parameter k must be an integer number")}else c=0;var d=c>0?c:0,v=c<0?-c:0,y=this._size[0],g=this._size[1],A=Math.min(y-v,g-d),F=[],w=[],_=[];_[0]=0;for(var b=d;b<g&&F.length<A;b++)for(var B=this._ptr[b],S=this._ptr[b+1],x=B;x<S;x++){var O=this._index[x];if(O===b-d+v){F.push(this._values[x]),w[F.length-1]=O-v;break}}return _.push(F.length),new i({values:F,index:w,ptr:_,size:[A,1]})},i.fromJSON=function(c){return new i(c)},i.diagonal=function(c,d,v,y,g){if(!ve(c))throw new TypeError("Array expected, size parameter");if(c.length!==2)throw new Error("Only two dimensions matrix are supported");if(c=c.map(function(X){if(Ee(X)&&(X=X.toNumber()),!ne(X)||!ye(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Ee(v)&&(v=v.toNumber()),!ne(v)||!ye(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var A=t,F=0;Me(g)&&(A=r.find(t,[g,g])||t,F=r.convert(0,g));var w=v>0?v:0,_=v<0?-v:0,b=c[0],B=c[1],S=Math.min(b-_,B-w),x;if(ve(d)){if(d.length!==S)throw new Error("Invalid value array length");x=function(ee){return d[ee]}}else if(we(d)){var O=d.size();if(O.length!==1||O[0]!==S)throw new Error("Invalid matrix length");x=function(ee){return d.get([ee])}}else x=function(){return d};for(var G=[],R=[],H=[],$=0;$<B;$++){H.push(G.length);var Q=$-w;if(Q>=0&&Q<S){var J=x(Q);A(J,F)||(R.push(Q+_),G.push(J))}}return H.push(G.length),new i({values:G,index:R,ptr:H,size:[b,B]})},i.prototype.swapRows=function(c,d){if(!ne(c)||!ye(c)||!ne(d)||!ye(d))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return me(c,this._size[0]),me(d,this._size[0]),i._swapRows(c,d,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(c,d,v,y,g){for(var A=y[c],F=y[c+1],w=A;w<F;w++)g(v[w],d[w])},i._swapRows=function(c,d,v,y,g,A){for(var F=0;F<v;F++){var w=A[F],_=A[F+1],b=f(c,w,_,g),B=f(d,w,_,g);if(b<_&&B<_&&g[b]===c&&g[B]===d){if(y){var S=y[b];y[b]=y[B],y[B]=S}continue}if(b<_&&g[b]===c&&(B>=_||g[B]!==d)){var x=y?y[b]:void 0;g.splice(B,0,d),y&&y.splice(B,0,x),g.splice(B<=b?b+1:b,1),y&&y.splice(B<=b?b+1:b,1);continue}if(B<_&&g[B]===d&&(b>=_||g[b]!==c)){var O=y?y[B]:void 0;g.splice(b,0,c),y&&y.splice(b,0,O),g.splice(b<=B?B+1:B,1),y&&y.splice(b<=B?B+1:B,1)}}},i},{isClass:!0}),Va="number",Ga=["typed"];function Ja(e){var r=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(r){var t={"0b":2,"0o":8,"0x":16}[r[1]],n=r[2],i=r[3];return{input:e,radix:t,integerPart:n,fractionalPart:i}}else return null}function ka(e){for(var r=parseInt(e.integerPart,e.radix),t=0,n=0;n<e.fractionalPart.length;n++){var i=parseInt(e.fractionalPart[n],e.radix);t+=i/Math.pow(e.radix,n+1)}var u=r+t;if(isNaN(u))throw new SyntaxError('String "'+e.input+'" is not a valid number');return u}var Ya=V(Va,Ga,e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(i){return i},string:function(i){if(i==="NaN")return NaN;var u=Ja(i);if(u)return ka(u);var o=0,a=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);a&&(o=Number(a[2]),i=a[1]);var s=Number(i);if(isNaN(s))throw new SyntaxError('String "'+i+'" is not a valid number');if(a){if(s>2**o-1)throw new SyntaxError('String "'.concat(i,'" is out of range'));s>=2**(o-1)&&(s=s-2**o)}return s},BigNumber:function(i){return i.toNumber()},bigint:function(i){return Number(i)},Fraction:function(i){return i.valueOf()},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),null:function(i){return 0},"Unit, string | Unit":function(i,u){return i.toNumber(u)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),Xa="bignumber",Qa=["typed","BigNumber"],Ka=V(Xa,Qa,e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(i){return new t(i+"")},string:function(i){var u=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(u){var o=u[2],a=t(u[1]),s=new t(2).pow(Number(o));if(a.gt(s.sub(1)))throw new SyntaxError('String "'.concat(i,'" is out of range'));var f=new t(2).pow(Number(o)-1);return a.gte(f)?a.sub(s):a}return new t(i)},BigNumber:function(i){return i},bigint:function(i){return new t(i.toString())},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Fraction:function(i){return new t(String(i.n)).div(String(i.d)).times(String(i.s))},null:function(i){return new t(0)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),ja="complex",es=["typed","Complex"],rs=V(ja,es,e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(i){return new t(i,0)},"number, number":function(i,u){return new t(i,u)},"BigNumber, BigNumber":function(i,u){return new t(i.toNumber(),u.toNumber())},Fraction:function(i){return new t(i.valueOf(),0)},Complex:function(i){return i.clone()},string:function(i){return t(i)},null:function(i){return t(0)},Object:function(i){if("re"in i&&"im"in i)return new t(i.re,i.im);if("r"in i&&"phi"in i||"abs"in i&&"arg"in i)return new t(i);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),ts="fraction",ns=["typed","Fraction"],is=V(ts,ns,e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(i){if(!Number.isFinite(i)||isNaN(i))throw new Error(i+" cannot be represented as a fraction");return new t(i)},string:function(i){return new t(i)},"number, number":function(i,u){return new t(i,u)},"bigint, bigint":function(i,u){return new t(i,u)},null:function(i){return new t(0)},BigNumber:function(i){return new t(i.toString())},bigint:function(i){return new t(i.toString())},Fraction:function(i){return i},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Object:function(i){return new t(i)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),gi="matrix",us=["typed","Matrix","DenseMatrix","SparseMatrix"],os=V(gi,us,e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(gi,{"":function(){return u([])},string:function(a){return u([],a)},"string, string":function(a,s){return u([],a,s)},Array:function(a){return u(a)},Matrix:function(a){return u(a,a.storage())},"Array | Matrix, string":u,"Array | Matrix, string, string":u});function u(o,a,s){if(a==="dense"||a==="default"||a===void 0)return new n(o,s);if(a==="sparse")return new i(o,s);throw new TypeError("Unknown matrix type "+JSON.stringify(a)+".")}}),vi="unaryMinus",as=["typed"],ss=V(vi,as,e=>{var{typed:r}=e;return r(vi,{number:hi,"Complex | BigNumber | Fraction":t=>t.neg(),bigint:t=>-t,Unit:r.referToSelf(t=>n=>{var i=n.clone();return i.value=r.find(t,i.valueType())(n.value),i}),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),wi="abs",fs=["typed"],cs=V(wi,fs,e=>{var{typed:r}=e;return r(wi,{number:si,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),yi="addScalar",ls=["typed"],hs=V(yi,ls,e=>{var{typed:r}=e;return r(yi,{"number, number":fi,"Complex, Complex":function(n,i){return n.add(i)},"BigNumber, BigNumber":function(n,i){return n.plus(i)},"bigint, bigint":function(n,i){return n+i},"Fraction, Fraction":function(n,i){return n.add(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),Fi="subtractScalar",ps=["typed"],Ds=V(Fi,ps,e=>{var{typed:r}=e;return r(Fi,{"number, number":ci,"Complex, Complex":function(n,i){return n.sub(i)},"BigNumber, BigNumber":function(n,i){return n.minus(i)},"bigint, bigint":function(n,i){return n-i},"Fraction, Fraction":function(n,i){return n.sub(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),ms="matAlgo11xS0s",ds=["typed","equalScalar"],Ei=V(ms,ds,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,m=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],D=l[1],c,d=t,v=0,y=o;typeof h=="string"&&(c=h,d=r.find(t,[c,c]),v=r.convert(0,c),u=r.convert(u,c),y=r.find(o,[c,c]));for(var g=[],A=[],F=[],w=0;w<D;w++){F[w]=A.length;for(var _=m[w],b=m[w+1],B=_;B<b;B++){var S=f[B],x=a?y(u,s[B]):y(s[B],u);d(x,v)||(A.push(S),g.push(x))}}return F[D]=A.length,i.createSparseMatrix({values:g,index:A,ptr:F,size:[p,D],datatype:c})}}),gs="matAlgo12xSfs",vs=["typed","DenseMatrix"],zr=V(gs,vs,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,m=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],D=l[1],c,d=o;typeof h=="string"&&(c=h,u=r.convert(u,c),d=r.find(o,[c,c]));for(var v=[],y=[],g=[],A=0;A<D;A++){for(var F=A+1,w=m[A],_=m[A+1],b=w;b<_;b++){var B=f[b];y[B]=s[b],g[B]=F}for(var S=0;S<p;S++)A===0&&(v[S]=[]),g[S]===F?v[S][A]=a?d(u,y[S]):d(y[S],u):v[S][A]=a?d(u,0):d(0,u)}return new t({data:v,size:[p,D],datatype:c})}}),ws="matAlgo14xDs",ys=["typed"],un=V(ws,ys,e=>{var{typed:r}=e;return function(i,u,o,a){var s=i._data,f=i._size,m=i._datatype,l,h=o;typeof m=="string"&&(l=m,u=r.convert(u,l),h=r.find(o,[l,l]));var p=f.length>0?t(h,0,f,f[0],s,u,a):[];return i.createDenseMatrix({data:p,size:De(f),datatype:l})};function t(n,i,u,o,a,s,f){var m=[];if(i===u.length-1)for(var l=0;l<o;l++)m[l]=f?n(s,a[l]):n(a[l],s);else for(var h=0;h<o;h++)m[h]=t(n,i+1,u,u[i+1],a[h],s,f);return m}}),Fs="matAlgo03xDSf",Es=["typed"],kr=V(Fs,Es,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,s=n._size,f=n._datatype||n.getDataType(),m=i._values,l=i._index,h=i._ptr,p=i._size,D=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ie(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!m)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var c=s[0],d=s[1],v,y=0,g=u;typeof f=="string"&&f===D&&f!=="mixed"&&(v=f,y=r.convert(0,v),g=r.find(u,[v,v]));for(var A=[],F=0;F<c;F++)A[F]=[];for(var w=[],_=[],b=0;b<d;b++){for(var B=b+1,S=h[b],x=h[b+1],O=S;O<x;O++){var G=l[O];w[G]=o?g(m[O],a[G][b]):g(a[G][b],m[O]),_[G]=B}for(var R=0;R<c;R++)_[R]===B?A[R][b]=w[R]:A[R][b]=o?g(y,a[R][b]):g(a[R][b],y)}return n.createDenseMatrix({data:A,size:[c,d],datatype:f===n._datatype&&D===i._datatype?v:void 0})}}),As="matAlgo13xDD",bs=["typed"],Cs=V(As,bs,e=>{var{typed:r}=e;return function(i,u,o){var a=i._data,s=i._size,f=i._datatype,m=u._data,l=u._size,h=u._datatype,p=[];if(s.length!==l.length)throw new ie(s.length,l.length);for(var D=0;D<s.length;D++){if(s[D]!==l[D])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");p[D]=s[D]}var c,d=o;typeof f=="string"&&f===h&&(c=f,d=r.find(o,[c,c]));var v=p.length>0?t(d,0,p,p[0],a,m):[];return i.createDenseMatrix({data:v,size:p,datatype:c})};function t(n,i,u,o,a,s){var f=[];if(i===u.length-1)for(var m=0;m<o;m++)f[m]=n(a[m],s[m]);else for(var l=0;l<o;l++)f[l]=t(n,i+1,u,u[i+1],a[l],s[l]);return f}});function Te(e,r){if(Dr(e.size(),r.size()))return[e,r];var t=ti(e.size(),r.size());return[e,r].map(n=>_s(n,t))}function _s(e,r){return Dr(e.size(),r)?e:e.create(tn(e.valueOf(),r),e.datatype())}var Bs="matrixAlgorithmSuite",Ns=["typed","matrix"],Or=V(Bs,Ns,e=>{var{typed:r,matrix:t}=e,n=Cs({typed:r}),i=un({typed:r});return function(o){var a=o.elop,s=o.SD||o.DS,f;a?(f={"DenseMatrix, DenseMatrix":(p,D)=>n(...Te(p,D),a),"Array, Array":(p,D)=>n(...Te(t(p),t(D)),a).valueOf(),"Array, DenseMatrix":(p,D)=>n(...Te(t(p),D),a),"DenseMatrix, Array":(p,D)=>n(...Te(p,t(D)),a)},o.SS&&(f["SparseMatrix, SparseMatrix"]=(p,D)=>o.SS(...Te(p,D),a,!1)),o.DS&&(f["DenseMatrix, SparseMatrix"]=(p,D)=>o.DS(...Te(p,D),a,!1),f["Array, SparseMatrix"]=(p,D)=>o.DS(...Te(t(p),D),a,!1)),s&&(f["SparseMatrix, DenseMatrix"]=(p,D)=>s(...Te(D,p),a,!0),f["SparseMatrix, Array"]=(p,D)=>s(...Te(t(D),p),a,!0))):(f={"DenseMatrix, DenseMatrix":r.referToSelf(p=>(D,c)=>n(...Te(D,c),p)),"Array, Array":r.referToSelf(p=>(D,c)=>n(...Te(t(D),t(c)),p).valueOf()),"Array, DenseMatrix":r.referToSelf(p=>(D,c)=>n(...Te(t(D),c),p)),"DenseMatrix, Array":r.referToSelf(p=>(D,c)=>n(...Te(D,t(c)),p))},o.SS&&(f["SparseMatrix, SparseMatrix"]=r.referToSelf(p=>(D,c)=>o.SS(...Te(D,c),p,!1))),o.DS&&(f["DenseMatrix, SparseMatrix"]=r.referToSelf(p=>(D,c)=>o.DS(...Te(D,c),p,!1)),f["Array, SparseMatrix"]=r.referToSelf(p=>(D,c)=>o.DS(...Te(t(D),c),p,!1))),s&&(f["SparseMatrix, DenseMatrix"]=r.referToSelf(p=>(D,c)=>s(...Te(c,D),p,!0)),f["SparseMatrix, Array"]=r.referToSelf(p=>(D,c)=>s(...Te(t(c),D),p,!0))));var m=o.scalar||"any",l=o.Ds||o.Ss;l&&(a?(f["DenseMatrix,"+m]=(p,D)=>i(p,D,a,!1),f[m+", DenseMatrix"]=(p,D)=>i(D,p,a,!0),f["Array,"+m]=(p,D)=>i(t(p),D,a,!1).valueOf(),f[m+", Array"]=(p,D)=>i(t(D),p,a,!0).valueOf()):(f["DenseMatrix,"+m]=r.referToSelf(p=>(D,c)=>i(D,c,p,!1)),f[m+", DenseMatrix"]=r.referToSelf(p=>(D,c)=>i(c,D,p,!0)),f["Array,"+m]=r.referToSelf(p=>(D,c)=>i(t(D),c,p,!1).valueOf()),f[m+", Array"]=r.referToSelf(p=>(D,c)=>i(t(c),D,p,!0).valueOf())));var h=o.sS!==void 0?o.sS:o.Ss;return a?(o.Ss&&(f["SparseMatrix,"+m]=(p,D)=>o.Ss(p,D,a,!1)),h&&(f[m+", SparseMatrix"]=(p,D)=>h(D,p,a,!0))):(o.Ss&&(f["SparseMatrix,"+m]=r.referToSelf(p=>(D,c)=>o.Ss(D,c,p,!1))),h&&(f[m+", SparseMatrix"]=r.referToSelf(p=>(D,c)=>h(c,D,p,!0)))),a&&a.signatures&&Zu(f,a.signatures),f}}),Ss="matAlgo01xDSid",Ms=["typed"],xs=V(Ss,Ms,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,s=n._size,f=n._datatype||n.getDataType(),m=i._values,l=i._index,h=i._ptr,p=i._size,D=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ie(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!m)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var c=s[0],d=s[1],v=typeof f=="string"&&f!=="mixed"&&f===D?f:void 0,y=v?r.find(u,[v,v]):u,g,A,F=[];for(g=0;g<c;g++)F[g]=[];var w=[],_=[];for(A=0;A<d;A++){for(var b=A+1,B=h[A],S=h[A+1],x=B;x<S;x++)g=l[x],w[g]=o?y(m[x],a[g][A]):y(a[g][A],m[x]),_[g]=b;for(g=0;g<c;g++)_[g]===b?F[g][A]=w[g]:F[g][A]=a[g][A]}return n.createDenseMatrix({data:F,size:[c,d],datatype:f===n._datatype&&D===i._datatype?v:void 0})}}),Ts="matAlgo04xSidSid",Is=["typed","equalScalar"],zs=V(Ts,Is,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o){var a=i._values,s=i._index,f=i._ptr,m=i._size,l=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=u._values,p=u._index,D=u._ptr,c=u._size,d=u._datatype||u._data===void 0?u._datatype:u.getDataType();if(m.length!==c.length)throw new ie(m.length,c.length);if(m[0]!==c[0]||m[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+m+") must match Matrix B ("+c+")");var v=m[0],y=m[1],g,A=t,F=0,w=o;typeof l=="string"&&l===d&&l!=="mixed"&&(g=l,A=r.find(t,[g,g]),F=r.convert(0,g),w=r.find(o,[g,g]));var _=a&&h?[]:void 0,b=[],B=[],S=a&&h?[]:void 0,x=a&&h?[]:void 0,O=[],G=[],R,H,$,Q,J;for(H=0;H<y;H++){B[H]=b.length;var X=H+1;for(Q=f[H],J=f[H+1],$=Q;$<J;$++)R=s[$],b.push(R),O[R]=X,S&&(S[R]=a[$]);for(Q=D[H],J=D[H+1],$=Q;$<J;$++)if(R=p[$],O[R]===X){if(S){var ee=w(S[R],h[$]);A(ee,F)?O[R]=null:S[R]=ee}}else b.push(R),G[R]=X,x&&(x[R]=h[$]);if(S&&x)for($=B[H];$<b.length;)R=b[$],O[R]===X?(_[$]=S[R],$++):G[R]===X?(_[$]=x[R],$++):b.splice($,1)}return B[y]=b.length,i.createSparseMatrix({values:_,index:b,ptr:B,size:[v,y],datatype:l===i._datatype&&d===u._datatype?g:void 0})}}),Os="matAlgo10xSids",$s=["typed","DenseMatrix"],Ps=V(Os,$s,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,m=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],D=l[1],c,d=o;typeof h=="string"&&(c=h,u=r.convert(u,c),d=r.find(o,[c,c]));for(var v=[],y=[],g=[],A=0;A<D;A++){for(var F=A+1,w=m[A],_=m[A+1],b=w;b<_;b++){var B=f[b];y[B]=s[b],g[B]=F}for(var S=0;S<p;S++)A===0&&(v[S]=[]),g[S]===F?v[S][A]=a?d(u,y[S]):d(y[S],u):v[S][A]=u}return new t({data:v,size:[p,D],datatype:c})}});function qs(e,r,t,n){return function(i){if(i>0||t.predictable){if(i<=0)return NaN;var u=i.toString(16),o=u.substring(0,15);return e*(u.length-o.length)+r(+("0x"+o))}return n(i.toNumber())}}var Ai="log10",Us=["typed","config","Complex"],Rs=Et(16),Ls=V(Ai,Us,e=>{var{typed:r,config:t,Complex:n}=e;function i(o){return o.log().div(Math.LN10)}function u(o){return i(new n(o,0))}return r(Ai,{number:function(a){return a>=0||t.predictable?Et(a):u(a)},bigint:qs(Rs,Et,t,u),Complex:i,BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():u(a.toNumber())},"Array | Matrix":r.referToSelf(o=>a=>Ve(a,o))})}),Hs="multiplyScalar",Zs=["typed"],Ws=V(Hs,Zs,e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":li,"Complex, Complex":function(n,i){return n.mul(i)},"BigNumber, BigNumber":function(n,i){return n.times(i)},"bigint, bigint":function(n,i){return n*i},"Fraction, Fraction":function(n,i){return n.mul(i)},"number | Fraction | BigNumber | Complex, Unit":(t,n)=>n.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,n)=>t.multiply(n)})}),bi="multiply",Vs=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Gs=V(bi,Vs,e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:u,dot:o}=e,a=Ei({typed:r,equalScalar:u}),s=un({typed:r});function f(F,w){switch(F.length){case 1:switch(w.length){case 1:if(F[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(F[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+F[0]+") must match Matrix rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;case 2:switch(w.length){case 1:if(F[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+F[1]+") must match Vector length ("+w[0]+")");break;case 2:if(F[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+F[1]+") must match Matrix B rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+F.length+" dimensions)")}}function m(F,w,_){if(_===0)throw new Error("Cannot multiply two empty vectors");return o(F,w)}function l(F,w){if(w.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return h(F,w)}function h(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._size,O=w._datatype||w.getDataType(),G=b[0],R=x[1],H,$=n,Q=i;B&&O&&B===O&&typeof B=="string"&&B!=="mixed"&&(H=B,$=r.find(n,[H,H]),Q=r.find(i,[H,H]));for(var J=[],X=0;X<R;X++){for(var ee=Q(_[0],S[0][X]),ue=1;ue<G;ue++)ee=$(ee,Q(_[ue],S[ue][X]));J[X]=ee}return F.createDenseMatrix({data:J,size:[R],datatype:B===F._datatype&&O===w._datatype?H:void 0})}var p=r("_multiplyMatrixVector",{"DenseMatrix, any":c,"SparseMatrix, any":y}),D=r("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":d,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":A});function c(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._datatype||w.getDataType(),O=b[0],G=b[1],R,H=n,$=i;B&&x&&B===x&&typeof B=="string"&&B!=="mixed"&&(R=B,H=r.find(n,[R,R]),$=r.find(i,[R,R]));for(var Q=[],J=0;J<O;J++){for(var X=_[J],ee=$(X[0],S[0]),ue=1;ue<G;ue++)ee=H(ee,$(X[ue],S[ue]));Q[J]=ee}return F.createDenseMatrix({data:Q,size:[O],datatype:B===F._datatype&&x===w._datatype?R:void 0})}function d(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._size,O=w._datatype||w.getDataType(),G=b[0],R=b[1],H=x[1],$,Q=n,J=i;B&&O&&B===O&&typeof B=="string"&&B!=="mixed"&&B!=="mixed"&&($=B,Q=r.find(n,[$,$]),J=r.find(i,[$,$]));for(var X=[],ee=0;ee<G;ee++){var ue=_[ee];X[ee]=[];for(var oe=0;oe<H;oe++){for(var le=J(ue[0],S[0][oe]),Be=1;Be<R;Be++)le=Q(le,J(ue[Be],S[Be][oe]));X[ee][oe]=le}}return F.createDenseMatrix({data:X,size:[G,H],datatype:B===F._datatype&&O===w._datatype?$:void 0})}function v(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._values,x=w._index,O=w._ptr,G=w._size,R=w._datatype||w._data===void 0?w._datatype:w.getDataType();if(!S)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var H=b[0],$=G[1],Q,J=n,X=i,ee=u,ue=0;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&(Q=B,J=r.find(n,[Q,Q]),X=r.find(i,[Q,Q]),ee=r.find(u,[Q,Q]),ue=r.convert(0,Q));for(var oe=[],le=[],Be=[],Ce=w.createSparseMatrix({values:oe,index:le,ptr:Be,size:[H,$],datatype:B===F._datatype&&R===w._datatype?Q:void 0}),be=0;be<$;be++){Be[be]=le.length;var Fe=O[be],Le=O[be+1];if(Le>Fe)for(var he=0,se=0;se<H;se++){for(var Qe=se+1,$e=void 0,pe=Fe;pe<Le;pe++){var Ie=x[pe];he!==Qe?($e=X(_[se][Ie],S[pe]),he=Qe):$e=J($e,X(_[se][Ie],S[pe]))}he===Qe&&!ee($e,ue)&&(le.push(se),oe.push($e))}}return Be[$]=le.length,Ce}function y(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!_)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var x=w._data,O=w._datatype||w.getDataType(),G=F._size[0],R=w._size[0],H=[],$=[],Q=[],J,X=n,ee=i,ue=u,oe=0;S&&O&&S===O&&typeof S=="string"&&S!=="mixed"&&(J=S,X=r.find(n,[J,J]),ee=r.find(i,[J,J]),ue=r.find(u,[J,J]),oe=r.convert(0,J));var le=[],Be=[];Q[0]=0;for(var Ce=0;Ce<R;Ce++){var be=x[Ce];if(!ue(be,oe))for(var Fe=B[Ce],Le=B[Ce+1],he=Fe;he<Le;he++){var se=b[he];Be[se]?le[se]=X(le[se],ee(be,_[he])):(Be[se]=!0,$.push(se),le[se]=ee(be,_[he]))}}for(var Qe=$.length,$e=0;$e<Qe;$e++){var pe=$[$e];H[$e]=le[pe]}return Q[1]=$.length,F.createSparseMatrix({values:H,index:$,ptr:Q,size:[G,1],datatype:S===F._datatype&&O===w._datatype?J:void 0})}function g(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!_)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var x=w._data,O=w._datatype||w.getDataType(),G=F._size[0],R=w._size[0],H=w._size[1],$,Q=n,J=i,X=u,ee=0;S&&O&&S===O&&typeof S=="string"&&S!=="mixed"&&($=S,Q=r.find(n,[$,$]),J=r.find(i,[$,$]),X=r.find(u,[$,$]),ee=r.convert(0,$));for(var ue=[],oe=[],le=[],Be=F.createSparseMatrix({values:ue,index:oe,ptr:le,size:[G,H],datatype:S===F._datatype&&O===w._datatype?$:void 0}),Ce=[],be=[],Fe=0;Fe<H;Fe++){le[Fe]=oe.length;for(var Le=Fe+1,he=0;he<R;he++){var se=x[he][Fe];if(!X(se,ee))for(var Qe=B[he],$e=B[he+1],pe=Qe;pe<$e;pe++){var Ie=b[pe];be[Ie]!==Le?(be[Ie]=Le,oe.push(Ie),Ce[Ie]=J(se,_[pe])):Ce[Ie]=Q(Ce[Ie],J(se,_[pe]))}}for(var Ke=le[Fe],lr=oe.length,hr=Ke;hr<lr;hr++){var Ur=oe[hr];ue[hr]=Ce[Ur]}}return le[H]=oe.length,Be}function A(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType(),x=w._values,O=w._index,G=w._ptr,R=w._datatype||w._data===void 0?w._datatype:w.getDataType(),H=F._size[0],$=w._size[1],Q=_&&x,J,X=n,ee=i;S&&R&&S===R&&typeof S=="string"&&S!=="mixed"&&(J=S,X=r.find(n,[J,J]),ee=r.find(i,[J,J]));for(var ue=Q?[]:void 0,oe=[],le=[],Be=F.createSparseMatrix({values:ue,index:oe,ptr:le,size:[H,$],datatype:S===F._datatype&&R===w._datatype?J:void 0}),Ce=Q?[]:void 0,be=[],Fe,Le,he,se,Qe,$e,pe,Ie,Ke=0;Ke<$;Ke++){le[Ke]=oe.length;var lr=Ke+1;for(Qe=G[Ke],$e=G[Ke+1],se=Qe;se<$e;se++)if(Ie=O[se],Q)for(Le=B[Ie],he=B[Ie+1],Fe=Le;Fe<he;Fe++)pe=b[Fe],be[pe]!==lr?(be[pe]=lr,oe.push(pe),Ce[pe]=ee(x[se],_[Fe])):Ce[pe]=X(Ce[pe],ee(x[se],_[Fe]));else for(Le=B[Ie],he=B[Ie+1],Fe=Le;Fe<he;Fe++)pe=b[Fe],be[pe]!==lr&&(be[pe]=lr,oe.push(pe));if(Q)for(var hr=le[Ke],Ur=oe.length,Rr=hr;Rr<Ur;Rr++){var ln=oe[Rr];ue[Rr]=Ce[ln]}}return le[$]=oe.length,Be}return r(bi,i,{"Array, Array":r.referTo("Matrix, Matrix",F=>(w,_)=>{f(Oe(w),Oe(_));var b=F(t(w),t(_));return we(b)?b.valueOf():b}),"Matrix, Matrix":function(w,_){var b=w.size(),B=_.size();return f(b,B),b.length===1?B.length===1?m(w,_,b[0]):l(w,_):B.length===1?p(w,_):D(w,_)},"Matrix, Array":r.referTo("Matrix,Matrix",F=>(w,_)=>F(w,t(_))),"Array, Matrix":r.referToSelf(F=>(w,_)=>F(t(w,_.storage()),_)),"SparseMatrix, any":function(w,_){return a(w,_,i,!1)},"DenseMatrix, any":function(w,_){return s(w,_,i,!1)},"any, SparseMatrix":function(w,_){return a(_,w,i,!0)},"any, DenseMatrix":function(w,_){return s(_,w,i,!0)},"Array, any":function(w,_){return s(t(w),_,i,!1).valueOf()},"any, Array":function(w,_){return s(t(_),w,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf(F=>(w,_,b)=>{for(var B=F(w,_),S=0;S<b.length;S++)B=F(B,b[S]);return B})})}),Js="matAlgo07xSSf",ks=["typed","SparseMatrix"],Yr=V(Js,ks,e=>{var{typed:r,SparseMatrix:t}=e;return function(u,o,a){var s=u._size,f=u._datatype||u._data===void 0?u._datatype:u.getDataType(),m=o._size,l=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(s.length!==m.length)throw new ie(s.length,m.length);if(s[0]!==m[0]||s[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+m+")");var h=s[0],p=s[1],D,c=0,d=a;typeof f=="string"&&f===l&&f!=="mixed"&&(D=f,c=r.convert(0,D),d=r.find(a,[D,D]));for(var v=[],y=[],g=new Array(p+1).fill(0),A=[],F=[],w=[],_=[],b=0;b<p;b++){var B=b+1,S=0;n(u,b,w,A,B),n(o,b,_,F,B);for(var x=0;x<h;x++){var O=w[x]===B?A[x]:c,G=_[x]===B?F[x]:c,R=d(O,G);R!==0&&R!==!1&&(y.push(x),v.push(R),S++)}g[b+1]=g[b]+S}return new t({values:v,index:y,ptr:g,size:[h,p],datatype:f===u._datatype&&l===o._datatype?D:void 0})};function n(i,u,o,a,s){for(var f=i._values,m=i._index,l=i._ptr,h=l[u],p=l[u+1];h<p;h++){var D=m[h];o[D]=s,a[D]=f[h]}}}),Ci="arg",Ys=["typed"],Xs=V(Ci,Ys,e=>{var{typed:r}=e;return r(Ci,{number:function(n){return Math.atan2(0,n)},BigNumber:function(n){return n.constructor.atan2(0,n)},Complex:function(n){return n.arg()},"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),_i="conj",Qs=["typed"],Ks=V(_i,Qs,e=>{var{typed:r}=e;return r(_i,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),Unit:r.referToSelf(t=>n=>new n.constructor(t(n.toNumeric()),n.formatUnits())),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),Bi="concat",js=["typed","matrix","isInteger"],ef=V(Bi,js,e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Bi,{"...Array | Matrix | number | BigNumber":function(u){var o,a=u.length,s=-1,f,m=!1,l=[];for(o=0;o<a;o++){var h=u[o];if(we(h)&&(m=!0),ne(h)||Ee(h)){if(o!==a-1)throw new Error("Dimension must be specified as last argument");if(f=s,s=h.valueOf(),!n(s))throw new TypeError("Integer number expected for dimension");if(s<0||o>0&&s>f)throw new br(s,f+1)}else{var p=De(h).valueOf(),D=Oe(p);if(l[o]=p,f=s,s=D.length-1,o>0&&s!==f)throw new ie(f+1,s+1)}}if(l.length===0)throw new SyntaxError("At least one matrix expected");for(var c=l.shift();l.length;)c=ri(c,l.shift(),s);return m?t(c):c},"...string":function(u){return u.join("")}})}),Ni="getMatrixDataType",rf=["typed"],tf=V(Ni,rf,e=>{var{typed:r}=e;return r(Ni,{Array:function(n){return wt(n,ur)},Matrix:function(n){return n.getDataType()}})}),Si="identity",nf=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],uf=V(Si,nf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:u,SparseMatrix:o}=e;return r(Si,{"":function(){return t.matrix==="Matrix"?n([]):[]},string:function(m){return n(m)},"number | BigNumber":function(m){return s(m,m,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(m,l){return s(m,m,l)},"number | BigNumber, number | BigNumber":function(m,l){return s(m,l,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(m,l,h){return s(m,l,h)},Array:function(m){return a(m)},"Array, string":function(m,l){return a(m,l)},Matrix:function(m){return a(m.valueOf(),m.storage())},"Matrix, string":function(m,l){return a(m.valueOf(),l)}});function a(f,m){switch(f.length){case 0:return m?n(m):[];case 1:return s(f[0],f[0],m);case 2:return s(f[0],f[1],m);default:throw new Error("Vector containing two values expected")}}function s(f,m,l){var h=Ee(f)||Ee(m)?i:null;if(Ee(f)&&(f=f.toNumber()),Ee(m)&&(m=m.toNumber()),!ye(f)||f<1)throw new Error("Parameters in function identity must be positive integers");if(!ye(m)||m<1)throw new Error("Parameters in function identity must be positive integers");var p=h?new i(1):1,D=h?new h(0):0,c=[f,m];if(l){if(l==="sparse")return o.diagonal(c,p,0,D);if(l==="dense")return u.diagonal(c,p,0,D);throw new TypeError('Unknown matrix type "'.concat(l,'"'))}for(var d=vt([],c,D),v=f<m?f:m,y=0;y<v;y++)d[y][y]=p;return d}});function Mi(){throw new Error('No "bignumber" implementation available')}function of(){throw new Error('No "fraction" implementation available')}function af(){throw new Error('No "matrix" implementation available')}var xi="range",sf=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],ff=V(xi,sf,e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:u,smallerEq:o,larger:a,largerEq:s,add:f,isZero:m,isPositive:l}=e;return r(xi,{string:p,"string, boolean":p,number:function(v){throw new TypeError("Too few arguments to function range(): ".concat(v))},boolean:function(v){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(v,", number|bigint|BigNumber|Fraction"))},"number, number":function(v,y){return h(D(v,y,1,!1))},"number, number, number":function(v,y,g){return h(D(v,y,g,!1))},"number, number, boolean":function(v,y,g){return h(D(v,y,1,g))},"number, number, number, boolean":function(v,y,g,A){return h(D(v,y,g,A))},"bigint, bigint|number":function(v,y){return h(D(v,y,1n,!1))},"number, bigint":function(v,y){return h(D(BigInt(v),y,1n,!1))},"bigint, bigint|number, bigint|number":function(v,y,g){return h(D(v,y,BigInt(g),!1))},"number, bigint, bigint|number":function(v,y,g){return h(D(BigInt(v),y,BigInt(g),!1))},"bigint, bigint|number, boolean":function(v,y,g){return h(D(v,y,1n,g))},"number, bigint, boolean":function(v,y,g){return h(D(BigInt(v),y,1n,g))},"bigint, bigint|number, bigint|number, boolean":function(v,y,g,A){return h(D(v,y,BigInt(g),A))},"number, bigint, bigint|number, boolean":function(v,y,g,A){return h(D(BigInt(v),y,BigInt(g),A))},"BigNumber, BigNumber":function(v,y){var g=v.constructor;return h(D(v,y,new g(1),!1))},"BigNumber, BigNumber, BigNumber":function(v,y,g){return h(D(v,y,g,!1))},"BigNumber, BigNumber, boolean":function(v,y,g){var A=v.constructor;return h(D(v,y,new A(1),g))},"BigNumber, BigNumber, BigNumber, boolean":function(v,y,g,A){return h(D(v,y,g,A))},"Fraction, Fraction":function(v,y){return h(D(v,y,1,!1))},"Fraction, Fraction, Fraction":function(v,y,g){return h(D(v,y,g,!1))},"Fraction, Fraction, boolean":function(v,y,g){return h(D(v,y,1,g))},"Fraction, Fraction, Fraction, boolean":function(v,y,g,A){return h(D(v,y,g,A))},"Unit, Unit, Unit":function(v,y,g){return h(D(v,y,g,!1))},"Unit, Unit, Unit, boolean":function(v,y,g,A){return h(D(v,y,g,A))}});function h(d){return t.matrix==="Matrix"?n?n(d):af():d}function p(d,v){var y=c(d);if(!y)throw new SyntaxError('String "'+d+'" is no valid range');return t.number==="BigNumber"?(i===void 0&&Mi(),h(D(i(y.start),i(y.end),i(y.step)))):h(D(y.start,y.end,y.step,v))}function D(d,v,y,g){var A=[];if(m(y))throw new Error("Step must be non-zero");for(var F=l(y)?g?o:u:g?s:a,w=d;F(w,v);)A.push(w),w=f(w,y);return A}function c(d){var v=d.split(":"),y=v.map(function(A){return Number(A)}),g=y.some(function(A){return isNaN(A)});if(g)return null;switch(y.length){case 2:return{start:y[0],end:y[1],step:1};case 3:return{start:y[0],end:y[2],step:y[1]};default:return null}}}),Ti="size",cf=["typed"],lf=V(Ti,cf,e=>{var{typed:r}=e;return r(Ti,{Matrix:t=>t.size(),Array:Oe,string:t=>[t.length],"number | Complex | BigNumber | Unit | boolean | null":t=>[]})}),Ii="subset",hf=["typed","matrix","zeros","add"],pf=V(Ii,hf,e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(Ii,{"Matrix, Index":function(a,s){return Ir(s)?t():(gt(a,s),a.subset(s))},"Array, Index":r.referTo("Matrix, Index",function(o){return function(a,s){var f=o(t(a),s);return s.isScalar()?f:f.valueOf()}}),"Object, Index":mf,"string, Index":Df,"Matrix, Index, any, any":function(a,s,f,m){return Ir(s)?a:(gt(a,s),a.clone().subset(s,u(f,s),m))},"Array, Index, any, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f,m){var l=o(t(a),s,f,m);return l.isMatrix?l.valueOf():l}}),"Array, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f){return o(t(a),s,f,void 0).valueOf()}}),"Matrix, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f){return o(a,s,f,void 0)}}),"string, Index, string":zi,"string, Index, string, string":zi,"Object, Index, any":df});function u(o,a){if(typeof o=="string")throw new Error("can't boradcast a string");if(a.isScalar())return o;var s=a.size();if(s.every(f=>f>0))try{return i(o,n(s))}catch{return o}else return o}});function Df(e,r){if(!nt(r))throw new TypeError("Index expected");if(Ir(r))return"";if(gt(Array.from(e),r),r.size().length!==1)throw new ie(r.size().length,1);var t=e.length;me(r.min()[0],t),me(r.max()[0],t);var n=r.dimension(0),i="";function u(o){i+=e.charAt(o)}return Number.isInteger(n)?u(n):n.forEach(u),i}function zi(e,r,t,n){if(!r||r.isIndex!==!0)throw new TypeError("Index expected");if(Ir(r))return e;if(gt(Array.from(e),r),r.size().length!==1)throw new ie(r.size().length,1);if(n!==void 0){if(typeof n!="string"||n.length!==1)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=r.dimension(0),u=Number.isInteger(i)?1:i.size()[0];if(u!==t.length)throw new ie(i.size()[0],t.length);var o=e.length;me(r.min()[0]),me(r.max()[0]);for(var a=[],s=0;s<o;s++)a[s]=e.charAt(s);function f(h,p){a[h]=t.charAt(p[0])}if(Number.isInteger(i)?f(i,[0]):i.forEach(f),a.length>o)for(var m=o-1,l=a.length;m<l;m++)a[m]||(a[m]=n);return a.join("")}function mf(e,r){if(!Ir(r)){if(r.size().length!==1)throw new ie(r.size(),1);var t=r.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return pn(e,t)}}function df(e,r,t){if(Ir(r))return e;if(r.size().length!==1)throw new ie(r.size(),1);var n=r.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");var i=De(e);return Dn(i,n,t),i}var Oi="zeros",gf=["typed","config","matrix","BigNumber"],vf=V(Oi,gf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(Oi,{"":function(){return t.matrix==="Array"?u([]):u([],"default")},"...number | BigNumber | string":function(f){var m=f[f.length-1];if(typeof m=="string"){var l=f.pop();return u(f,l)}else return t.matrix==="Array"?u(f):u(f,"default")},Array:u,Matrix:function(f){var m=f.storage();return u(f.valueOf(),m)},"Array | Matrix, string":function(f,m){return u(f.valueOf(),m)}});function u(s,f){var m=o(s),l=m?new i(0):0;if(a(s),f){var h=n(f);return s.length>0?h.resize(s,l):h}else{var p=[];return s.length>0?vt(p,s,l):p}}function o(s){var f=!1;return s.forEach(function(m,l,h){Ee(m)&&(f=!0,h[l]=m.toNumber())}),f}function a(s){s.forEach(function(f){if(typeof f!="number"||!ye(f)||f<0)throw new Error("Parameters in function zeros must be positive integers")})}}),wf="numeric",yf=["number","?bignumber","?fraction"],Ff=V(wf,yf,e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},u={number:o=>r(o),BigNumber:t?o=>t(o):Mi,bigint:o=>BigInt(o),Fraction:n?o=>n(o):of};return function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",f=arguments.length>2?arguments[2]:void 0;if(f!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var m=ur(a);if(!(m in i))throw new TypeError("Cannot convert "+a+' of type "'+m+'"; valid input types are '+Object.keys(i).join(", "));if(!(s in u))throw new TypeError("Cannot convert "+a+' to type "'+s+'"; valid output types are '+Object.keys(u).join(", "));return s===m?a:u[s](a)}}),$i="divideScalar",Ef=["typed","numeric"],Af=V($i,Ef,e=>{var{typed:r,numeric:t}=e;return r($i,{"number, number":function(i,u){return i/u},"Complex, Complex":function(i,u){return i.div(u)},"BigNumber, BigNumber":function(i,u){return i.div(u)},"bigint, bigint":function(i,u){return i/u},"Fraction, Fraction":function(i,u){return i.div(u)},"Unit, number | Complex | Fraction | BigNumber | Unit":(n,i)=>n.divide(i),"number | Fraction | Complex | BigNumber, Unit":(n,i)=>i.divideInto(n)})}),Pi="pow",bf=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Cf=V(Pi,bf,e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:u,inv:o,number:a,fraction:s,Complex:f}=e;return r(Pi,{"number, number":m,"Complex, Complex":function(D,c){return D.pow(c)},"BigNumber, BigNumber":function(D,c){return c.isInteger()||D>=0||t.predictable?D.pow(c):new f(D.toNumber(),0).pow(c.toNumber(),0)},"bigint, bigint":(p,D)=>p**D,"Fraction, Fraction":function(D,c){var d=D.pow(c);if(d!=null)return d;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return m(D.valueOf(),c.valueOf())},"Array, number":l,"Array, BigNumber":function(D,c){return l(D,c.toNumber())},"Matrix, number":h,"Matrix, BigNumber":function(D,c){return h(D,c.toNumber())},"Unit, number | BigNumber":function(D,c){return D.pow(c)}});function m(p,D){if(t.predictable&&!ye(D)&&p<0)try{var c=s(D),d=a(c);if((D===d||Math.abs((D-d)/D)<1e-14)&&c.d%2n===1n)return(c.n%2n===0n?1:-1)*Math.pow(-p,D)}catch{}return t.predictable&&(p<-1&&D===1/0||p>-1&&p<0&&D===-1/0)?NaN:ye(D)||p>=0||t.predictable?pi(p,D):p*p<1&&D===1/0||p*p>1&&D===-1/0?0:new f(p,0).pow(D,0)}function l(p,D){if(!ye(D))throw new TypeError("For A^b, b must be an integer (value is "+D+")");var c=Oe(p);if(c.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+c.length+" dimensions)");if(c[0]!==c[1])throw new Error("For A^b, A must be square (size is "+c[0]+"x"+c[1]+")");if(D<0)try{return l(o(p),-D)}catch(y){throw y.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+D+")"):y}for(var d=n(c[0]).valueOf(),v=p;D>=1;)(D&1)===1&&(d=i(v,d)),D>>=1,v=i(v,v);return d}function h(p,D){return u(l(p.valueOf(),D))}}),$r="Number of decimals in function round must be an integer",qi="round",_f=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],Bf=V(qi,_f,e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:u,BigNumber:o,DenseMatrix:a}=e,s=Ei({typed:r,equalScalar:i}),f=zr({typed:r,DenseMatrix:a}),m=un({typed:r});function l(h){return Math.abs(Zr(h).exponent)}return r(qi,{number:function(p){var D=Gr(p,l(t.relTol)),c=je(p,D,t.relTol,t.absTol)?D:p;return Gr(c)},"number, number":function(p,D){var c=l(t.relTol);if(D>=c)return Gr(p,D);var d=Gr(p,c),v=je(p,d,t.relTol,t.absTol)?d:p;return Gr(v,D)},"number, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError($r);return new o(p).toDecimalPlaces(D.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,D){if(D%1)throw new TypeError($r);return p.round(D)},"Complex, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError($r);var c=D.toNumber();return p.round(c)},BigNumber:function(p){var D=new o(p).toDecimalPlaces(l(t.relTol)),c=yr(p,D,t.relTol,t.absTol)?D:p;return c.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError($r);var c=l(t.relTol);if(D>=c)return p.toDecimalPlaces(D.toNumber());var d=p.toDecimalPlaces(c),v=yr(p,d,t.relTol,t.absTol)?d:p;return v.toDecimalPlaces(D.toNumber())},bigint:h=>h,"bigint, number":(h,p)=>h,"bigint, BigNumber":(h,p)=>h,Fraction:function(p){return p.round()},"Fraction, number":function(p,D){if(D%1)throw new TypeError($r);return p.round(D)},"Fraction, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError($r);return p.round(D.toNumber())},"Unit, number, Unit":r.referToSelf(h=>function(p,D,c){var d=p.toNumeric(c);return c.multiply(h(d,D))}),"Unit, BigNumber, Unit":r.referToSelf(h=>(p,D,c)=>h(p,D.toNumber(),c)),"Array | Matrix, number | BigNumber, Unit":r.referToSelf(h=>(p,D,c)=>Ve(p,d=>h(d,D,c),!0)),"Array | Matrix | Unit, Unit":r.referToSelf(h=>(p,D)=>h(p,0,D)),"Array | Matrix":r.referToSelf(h=>p=>Ve(p,h,!0)),"SparseMatrix, number | BigNumber":r.referToSelf(h=>(p,D)=>s(p,D,h,!1)),"DenseMatrix, number | BigNumber":r.referToSelf(h=>(p,D)=>m(p,D,h,!1)),"Array, number | BigNumber":r.referToSelf(h=>(p,D)=>m(n(p),D,h,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf(h=>(p,D)=>i(p,0)?u(D.size(),D.storage()):f(D,p,h,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf(h=>(p,D)=>i(p,0)?u(D.size(),D.storage()):m(D,p,h,!0)),"number | Complex | BigNumber | Fraction, Array":r.referToSelf(h=>(p,D)=>m(n(D),p,h,!0).valueOf())})}),bt="equal",Nf=["typed","matrix","equalScalar","DenseMatrix","SparseMatrix"],Sf=V(bt,Nf,e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=kr({typed:r}),s=Yr({typed:r,SparseMatrix:o}),f=zr({typed:r,DenseMatrix:i}),m=Or({typed:r,matrix:t});return r(bt,Mf({typed:r,equalScalar:n}),m({elop:n,SS:s,DS:a,Ss:f}))}),Mf=V(bt,["typed","equalScalar"],e=>{var{typed:r,equalScalar:t}=e;return r(bt,{"any, any":function(i,u){return i===null?u===null:u===null?i===null:i===void 0?u===void 0:u===void 0?i===void 0:t(i,u)}})}),Ct="smaller",xf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],Tf=V(Ct,xf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,s=kr({typed:r}),f=Yr({typed:r,SparseMatrix:a}),m=zr({typed:r,DenseMatrix:u}),l=Or({typed:r,matrix:i,concat:o}),h=Jr({typed:r});function p(D,c){return D.lt(c)&&!yr(D,c,t.relTol,t.absTol)}return r(Ct,If({typed:r,config:t}),{"boolean, boolean":(D,c)=>D<c,"BigNumber, BigNumber":p,"bigint, bigint":(D,c)=>D<c,"Fraction, Fraction":(D,c)=>D.compare(c)===-1,"Fraction, BigNumber":function(c,d){return p(n(c),d)},"BigNumber, Fraction":function(c,d){return p(c,n(d))},"Complex, Complex":function(c,d){throw new TypeError("No ordering relation is defined for complex numbers")}},h,l({SS:f,DS:s,Ss:m}))}),If=V(Ct,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ct,{"number, number":function(i,u){return i<u&&!je(i,u,t.relTol,t.absTol)}})}),_t="smallerEq",zf=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],Of=V(_t,zf,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=kr({typed:r}),s=Yr({typed:r,SparseMatrix:o}),f=zr({typed:r,DenseMatrix:i}),m=Or({typed:r,matrix:n,concat:u}),l=Jr({typed:r});return r(_t,$f({typed:r,config:t}),{"boolean, boolean":(h,p)=>h<=p,"BigNumber, BigNumber":function(p,D){return p.lte(D)||yr(p,D,t.relTol,t.absTol)},"bigint, bigint":(h,p)=>h<=p,"Fraction, Fraction":(h,p)=>h.compare(p)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,m({SS:s,DS:a,Ss:f}))}),$f=V(_t,["typed","config"],e=>{var{typed:r,config:t}=e;return r(_t,{"number, number":function(i,u){return i<=u||je(i,u,t.relTol,t.absTol)}})}),Bt="larger",Pf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],qf=V(Bt,Pf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,s=kr({typed:r}),f=Yr({typed:r,SparseMatrix:a}),m=zr({typed:r,DenseMatrix:u}),l=Or({typed:r,matrix:i,concat:o}),h=Jr({typed:r});function p(D,c){return D.gt(c)&&!yr(D,c,t.relTol,t.absTol)}return r(Bt,Uf({typed:r,config:t}),{"boolean, boolean":(D,c)=>D>c,"BigNumber, BigNumber":p,"bigint, bigint":(D,c)=>D>c,"Fraction, Fraction":(D,c)=>D.compare(c)===1,"Fraction, BigNumber":function(c,d){return p(n(c),d)},"BigNumber, Fraction":function(c,d){return p(c,n(d))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,l({SS:f,DS:s,Ss:m}))}),Uf=V(Bt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Bt,{"number, number":function(i,u){return i>u&&!je(i,u,t.relTol,t.absTol)}})}),Nt="largerEq",Rf=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],Lf=V(Nt,Rf,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=kr({typed:r}),s=Yr({typed:r,SparseMatrix:o}),f=zr({typed:r,DenseMatrix:i}),m=Or({typed:r,matrix:n,concat:u}),l=Jr({typed:r});return r(Nt,Hf({typed:r,config:t}),{"boolean, boolean":(h,p)=>h>=p,"BigNumber, BigNumber":function(p,D){return p.gte(D)||yr(p,D,t.relTol,t.absTol)},"bigint, bigint":function(p,D){return p>=D},"Fraction, Fraction":(h,p)=>h.compare(p)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,m({SS:s,DS:a,Ss:f}))}),Hf=V(Nt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Nt,{"number, number":function(i,u){return i>=u||je(i,u,t.relTol,t.absTol)}})}),Zf="ImmutableDenseMatrix",Wf=["smaller","DenseMatrix"],Vf=V(Zf,Wf,e=>{var{smaller:r,DenseMatrix:t}=e;function n(i,u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(u&&!Me(u))throw new Error("Invalid datatype: "+u);if(we(i)||ve(i)){var o=new t(i,u);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(i&&ve(i.data)&&ve(i.size))this._data=i.data,this._size=i.size,this._datatype=i.datatype,this._min=typeof i.min<"u"?i.min:null,this._max=typeof i.max<"u"?i.max:null;else{if(i)throw new TypeError("Unsupported type of data ("+ur(i)+")");this._data=[],this._size=[0],this._datatype=u,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(i){switch(arguments.length){case 1:{var u=t.prototype.subset.call(this,i);return we(u)?new n({data:u._data,size:u._size,datatype:u._datatype}):u}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:De(this._data),size:De(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(i){return new n(i)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(this._min===null){var i=null;this.forEach(function(u){(i===null||r(u,i))&&(i=u)}),this._min=i!==null?i:void 0}return this._min},n.prototype.max=function(){if(this._max===null){var i=null;this.forEach(function(u){(i===null||r(i,u))&&(i=u)}),this._max=i!==null?i:void 0}return this._max},n},{isClass:!0}),Gf="Index",Jf=["ImmutableDenseMatrix","getMatrixDataType"],kf=V(Gf,Jf,e=>{var{ImmutableDenseMatrix:r,getMatrixDataType:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var u=0,o=arguments.length;u<o;u++){var a=u<0||arguments.length<=u?void 0:arguments[u],s=ve(a),f=we(a),m=typeof a,l=null;if(vn(a))this._dimensions.push(a),this._isScalar=!1;else if(s||f){var h=void 0;this._isScalar=!1,t(a)==="boolean"?(s&&(h=i(Ui(a).valueOf())),f&&(h=i(Ui(a._data).valueOf())),l=a.valueOf().length):h=i(a.valueOf()),this._dimensions.push(h)}else if(m==="number")this._dimensions.push(a);else if(m==="bigint")this._dimensions.push(Number(a));else if(m==="string")this._dimensions.push(a);else throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._sourceSize.push(l)}}n.prototype.type="Index",n.prototype.isIndex=!0;function i(u){for(var o=0,a=u.length;o<a;o++)if(!ne(u[o])||!ye(u[o]))throw new TypeError("Index parameters must be positive integer numbers");var s=new r;return s._data=u,s._size=[u.length],s}return n.prototype.clone=function(){var u=new n;return u._dimensions=De(this._dimensions),u._isScalar=this._isScalar,u._sourceSize=this._sourceSize,u},n.create=function(u){var o=new n;return n.apply(o,u),o},n.prototype.size=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Me(s)||ne(s)?1:s.size()[0]}return u},n.prototype.max=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Me(s)||ne(s)?s:s.max()}return u},n.prototype.min=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Me(s)||ne(s)?s:s.min()}return u},n.prototype.forEach=function(u){for(var o=0,a=this._dimensions.length;o<a;o++)u(this._dimensions[o],o,this)},n.prototype.dimension=function(u){var o;return ne(u)&&(o=this._dimensions[u])!==null&&o!==void 0?o:null},n.prototype.isObjectProperty=function(){return this._dimensions.length===1&&Me(this._dimensions[0])},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u.push(Me(s)||ne(s)?s:s.toArray())}return u},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];Me(s)?u.push(JSON.stringify(s)):u.push(s.toString())}return"["+u.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(u){return n.create(u.dimensions)},n},{isClass:!0});function Ui(e){var r=[];return e.forEach((t,n)=>{t&&r.push(n)}),r}function Yf(e){var r=0,t=1,n=Object.create(null),i=Object.create(null),u=0,o=function(s){var f=i[s];if(f&&(delete n[f],delete i[s],--r,t===f)){if(!r){u=0,t=1;return}for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(s){var f=i[s],m=++u;if(n[m]=s,i[s]=m,!f)return++r,r<=e?void 0:(s=n[t],o(s),s);if(delete n[f],t===f)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=u=0,t=1,n=Object.create(null),i=Object.create(null)}}}function St(e){var{hasher:r,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,r=r??JSON.stringify,function n(){typeof n.cache!="object"&&(n.cache={values:new Map,lru:Yf(t||Number.POSITIVE_INFINITY)});for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];var o=r(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var a=e.apply(e,i);return n.cache.values.set(o,a),n.cache.values.delete(n.cache.lru.hit(o)),a}}St(function(e){return new e(1).exp()},{hasher:Mt}),St(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Mt});var Ri=St(function(e){return e.acos(-1)},{hasher:Mt});St(function(e){return Ri(e).times(2)},{hasher:Mt});function Mt(e){return e[0].precision}var Li="add",Xf=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Qf=V(Li,Xf,e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:u,SparseMatrix:o,concat:a}=e,s=xs({typed:r}),f=zs({typed:r,equalScalar:i}),m=Ps({typed:r,DenseMatrix:u}),l=Or({typed:r,matrix:t,concat:a});return r(Li,{"any, any":n,"any, any, ...any":r.referToSelf(h=>(p,D,c)=>{for(var d=h(p,D),v=0;v<c.length;v++)d=h(d,c[v]);return d})},l({elop:n,DS:s,SS:f,Ss:m}))}),Hi="dot",Kf=["typed","addScalar","multiplyScalar","conj","size"],jf=V(Hi,Kf,e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:u}=e;return r(Hi,{"Array | DenseMatrix, Array | DenseMatrix":a,"SparseMatrix, SparseMatrix":s});function o(f,m){var l=u(f),h=u(m),p,D;if(l.length===1)p=l[0];else if(l.length===2&&l[1]===1)p=l[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+l.join(", ")+")");if(h.length===1)D=h[0];else if(h.length===2&&h[1]===1)D=h[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+h.join(", ")+")");if(p!==D)throw new RangeError("Vectors must have equal length ("+p+" != "+D+")");if(p===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return p}function a(f,m){var l=o(f,m),h=we(f)?f._data:f,p=we(f)?f._datatype||f.getDataType():void 0,D=we(m)?m._data:m,c=we(m)?m._datatype||m.getDataType():void 0,d=u(f).length===2,v=u(m).length===2,y=t,g=n;if(p&&c&&p===c&&typeof p=="string"&&p!=="mixed"){var A=p;y=r.find(t,[A,A]),g=r.find(n,[A,A])}if(!d&&!v){for(var F=g(i(h[0]),D[0]),w=1;w<l;w++)F=y(F,g(i(h[w]),D[w]));return F}if(!d&&v){for(var _=g(i(h[0]),D[0][0]),b=1;b<l;b++)_=y(_,g(i(h[b]),D[b][0]));return _}if(d&&!v){for(var B=g(i(h[0][0]),D[0]),S=1;S<l;S++)B=y(B,g(i(h[S][0]),D[S]));return B}if(d&&v){for(var x=g(i(h[0][0]),D[0][0]),O=1;O<l;O++)x=y(x,g(i(h[O][0]),D[O][0]));return x}}function s(f,m){o(f,m);for(var l=f._index,h=f._values,p=m._index,D=m._values,c=0,d=t,v=n,y=0,g=0;y<l.length&&g<p.length;){var A=l[y],F=p[g];if(A<F){y++;continue}if(A>F){g++;continue}A===F&&(c=d(c,v(h[y],D[g])),y++,g++)}return c}}),Zi="index",ec=["typed","Index"],rc=V(Zi,ec,e=>{var{typed:r,Index:t}=e;return r(Zi,{"...number | string | BigNumber | Range | Array | Matrix":function(i){var u=i.map(function(a){return Ee(a)?a.toNumber():ve(a)||we(a)?a.map(function(s){return Ee(s)?s.toNumber():s}):a}),o=new t;return t.apply(o,u),o}})}),Wi="det",tc=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],nc=V(Wi,tc,e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:u,isZero:o,unaryMinus:a}=e;return r(Wi,{any:function(m){return De(m)},"Array | Matrix":function(m){var l;switch(we(m)?l=m.size():Array.isArray(m)?(m=t(m),l=m.size()):l=[],l.length){case 0:return De(m);case 1:if(l[0]===1)return De(m.valueOf()[0]);if(l[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+_e(l)+")");case 2:{var h=l[0],p=l[1];if(h===p)return s(m.clone().valueOf(),h);if(p===0)return 1;throw new RangeError("Matrix must be square (size: "+_e(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+_e(l)+")")}}});function s(f,m,l){if(m===1)return De(f[0][0]);if(m===2)return n(i(f[0][0],f[1][1]),i(f[1][0],f[0][1]));for(var h=!1,p=new Array(m).fill(0).map((_,b)=>b),D=0;D<m;D++){var c=p[D];if(o(f[c][D])){var d=void 0;for(d=D+1;d<m;d++)if(!o(f[p[d]][D])){c=p[d],p[d]=p[D],p[D]=c,h=!h;break}if(d===m)return f[c][D]}for(var v=f[c][D],y=D===0?1:f[p[D-1]][D-1],g=D+1;g<m;g++)for(var A=p[g],F=D+1;F<m;F++)f[A][F]=u(n(i(f[A][F],v),i(f[A][D],f[c][F])),y)}var w=f[p[m-1]][m-1];return h?a(w):w}}),Vi="inv",ic=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],uc=V(Vi,ic,e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:u,unaryMinus:o,det:a,identity:s,abs:f}=e;return r(Vi,{"Array | Matrix":function(h){var p=we(h)?h.size():Oe(h);switch(p.length){case 1:if(p[0]===1)return we(h)?t([n(1,h.valueOf()[0])]):[n(1,h[0])];throw new RangeError("Matrix must be square (size: "+_e(p)+")");case 2:{var D=p[0],c=p[1];if(D===c)return we(h)?t(m(h.valueOf(),D,c),h.storage()):m(h,D,c);throw new RangeError("Matrix must be square (size: "+_e(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+_e(p)+")")}},any:function(h){return n(1,h)}});function m(l,h,p){var D,c,d,v,y;if(h===1){if(v=l[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,v)]]}else if(h===2){var g=a(l);if(g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(l[1][1],g),n(o(l[0][1]),g)],[n(o(l[1][0]),g),n(l[0][0],g)]]}else{var A=l.concat();for(D=0;D<h;D++)A[D]=A[D].concat();for(var F=s(h).valueOf(),w=0;w<p;w++){var _=f(A[w][w]),b=w;for(D=w+1;D<h;)f(A[D][w])>_&&(_=f(A[D][w]),b=D),D++;if(_===0)throw Error("Cannot calculate inverse, determinant is zero");D=b,D!==w&&(y=A[w],A[w]=A[D],A[D]=y,y=F[w],F[w]=F[D],F[D]=y);var B=A[w],S=F[w];for(D=0;D<h;D++){var x=A[D],O=F[D];if(D!==w){if(x[w]!==0){for(d=n(o(x[w]),B[w]),c=w;c<p;c++)x[c]=i(x[c],u(d,B[c]));for(c=0;c<p;c++)O[c]=i(O[c],u(d,S[c]))}}else{for(d=B[w],c=w;c<p;c++)x[c]=n(x[c],d);for(c=0;c<p;c++)O[c]=n(O[c],d)}}}return F}}}),oc=ac("pi",["config","?BigNumber"],e=>{var{config:r,BigNumber:t}=e;return r.number==="BigNumber"?Ri(t):Ia});function ac(e,r,t){return V(e,r,t,{recreateOnConfigChange:!0})}var Pr=jo({config:Pe}),xt=ia({}),Gi=la({}),on=Da({}),tr=Ma({Matrix:on,config:Pe}),Xr=oc({BigNumber:Pr,config:Pe}),te=ro({BigNumber:Pr,Complex:xt,DenseMatrix:tr,Fraction:Gi}),Tt=cs({typed:te}),It=hs({typed:te}),an=Xs({typed:te}),zt=rs({Complex:xt,typed:te}),sc=Ks({typed:te}),qr=La({config:Pe,typed:te}),fc=tf({typed:te}),Ji=Ls({Complex:xt,config:Pe,typed:te}),ki=Ws({typed:te}),Yi=Ya({typed:te}),cc=lf({typed:te}),Fr=Wa({Matrix:on,equalScalar:qr,typed:te}),lc=Ds({typed:te}),Ot=Ka({BigNumber:Pr,typed:te}),hc=jf({addScalar:It,conj:sc,multiplyScalar:ki,size:cc,typed:te}),Xi=qa({equalScalar:qr,typed:te}),Re=os({DenseMatrix:tr,Matrix:on,SparseMatrix:Fr,typed:te}),Cr=Gs({addScalar:It,dot:hc,equalScalar:qr,matrix:Re,multiplyScalar:ki,typed:te}),Qi=vf({BigNumber:Pr,config:Pe,matrix:Re,typed:te}),Ki=Sf({DenseMatrix:tr,SparseMatrix:Fr,equalScalar:qr,matrix:Re,typed:te}),ji=is({Fraction:Gi,typed:te}),eu=uf({BigNumber:Pr,DenseMatrix:tr,SparseMatrix:Fr,config:Pe,matrix:Re,typed:te}),pc=Ta({equal:Ki,typed:te}),Dc=Ff({bignumber:Ot,fraction:ji,number:Yi}),sn=Bf({BigNumber:Pr,DenseMatrix:tr,config:Pe,equalScalar:qr,matrix:Re,typed:te,zeros:Qi}),ru=ss({typed:te}),Qr=ef({isInteger:pc,matrix:Re,typed:te}),tu=Af({numeric:Dc,typed:te}),mc=$a({config:Pe,typed:te}),dc=qf({DenseMatrix:tr,SparseMatrix:Fr,bignumber:Ot,concat:Qr,config:Pe,matrix:Re,typed:te}),nu=Tf({DenseMatrix:tr,SparseMatrix:Fr,bignumber:Ot,concat:Qr,config:Pe,matrix:Re,typed:te}),Kr=Qf({DenseMatrix:tr,SparseMatrix:Fr,addScalar:It,concat:Qr,equalScalar:qr,matrix:Re,typed:te}),gc=nc({divideScalar:tu,isZero:Xi,matrix:Re,multiply:Cr,subtractScalar:lc,typed:te,unaryMinus:ru}),vc=Vf({DenseMatrix:tr,smaller:nu}),wc=kf({ImmutableDenseMatrix:vc,getMatrixDataType:fc}),yc=Lf({DenseMatrix:tr,SparseMatrix:Fr,concat:Qr,config:Pe,matrix:Re,typed:te}),$t=pf({add:Kr,matrix:Re,typed:te,zeros:Qi}),Pt=rc({Index:wc,typed:te}),Fc=uc({abs:Tt,addScalar:It,det:gc,divideScalar:tu,identity:eu,matrix:Re,multiply:Cr,typed:te,unaryMinus:ru}),iu=Cf({Complex:xt,config:Pe,fraction:ji,identity:eu,inv:Fc,matrix:Re,multiply:Cr,number:Yi,typed:te}),Ec=Of({DenseMatrix:tr,SparseMatrix:Fr,concat:Qr,config:Pe,matrix:Re,typed:te}),qt=ff({bignumber:Ot,matrix:Re,add:Kr,config:Pe,equal:Ki,isPositive:mc,isZero:Xi,larger:dc,largerEq:yc,smaller:nu,smallerEq:Ec,typed:te});const Ac=["Hz","kHz","MHz","GHz"],fn=299792458,cr={Hz:1,kHz:1e3,MHz:1e6,GHz:1e9,THz:1e12},cn={m:1,cm:.01,mm:.001,um:1e-6,nm:1e-9};class uu{_unit="Hz";set unit(r){if(typeof r!="string")throw new Error(`Unknown frequency unit: ${r}`);const t=this._unit;let n;switch(r.toLowerCase()){case"hz":n="Hz";break;case"khz":n="kHz";break;case"mhz":n="MHz";break;case"ghz":n="GHz";break;default:throw new Error(`Unknown frequency unit: ${r}`)}if(n!==t&&this.f_scaled&&this.f_scaled.length>0){const i=cr[t],u=cr[n];if(i&&u)this.f_scaled=this.f_scaled.map(o=>o*i/u);else throw new Error(`Could not find frequency multipliers (old: ${i}, new: ${u}) for unit conversion`)}this._unit=n}get unit(){return this._unit}_f_scaled=[];set f_scaled(r){if(!Array.isArray(r))throw new Error("Frequency value must be an array");for(const t of r){if(typeof t!="number")throw new Error(`Frequency value must be an array of numbers, but received: ${t}`);if(t<0)throw new Error(`Frequency values cannot be negative, but received: ${t}`)}this._f_scaled=r}get f_scaled(){return this._f_scaled}_getFrequencyInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=cr[this.unit];if(!t)throw new Error(`Multiplier for current unit ${this.unit} not found.`);const n=cr[r];if(!n)throw new Error(`Multiplier for target unit ${r} not found.`);return this.f_scaled.map(i=>i*t/n)}_setFrequencyFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=cr[t];if(!n)throw new Error(`Multiplier for source unit ${t} not found.`);const i=cr[this.unit];if(!i)throw new Error(`Multiplier for current internal unit ${this.unit} not found.`);const u=r.map(o=>o*n/i);this.f_scaled=u}get f_Hz(){return this._getFrequencyInTargetUnit("Hz")}set f_Hz(r){this._setFrequencyFromTargetUnit(r,"Hz")}get f_kHz(){return this._getFrequencyInTargetUnit("kHz")}set f_kHz(r){this._setFrequencyFromTargetUnit(r,"kHz")}get f_MHz(){return this._getFrequencyInTargetUnit("MHz")}set f_MHz(r){this._setFrequencyFromTargetUnit(r,"MHz")}get f_GHz(){return this._getFrequencyInTargetUnit("GHz")}set f_GHz(r){this._setFrequencyFromTargetUnit(r,"GHz")}get f_THz(){return this._getFrequencyInTargetUnit("THz")}set f_THz(r){this._setFrequencyFromTargetUnit(r,"THz")}_getWavelengthInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=cr[this.unit];if(!t)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const n=cn[r];if(!n)throw new Error(`Wavelength multiplier to meters for target wavelength unit ${r} not found.`);return this.f_scaled.map(i=>{const u=i*t;return u===0?1/0:fn/u/n})}_setWavelengthFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=cn[t];if(!n)throw new Error(`Wavelength multiplier to meters for source unit ${t} not found.`);const i=cr[this.unit];if(!i)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const u=r.map(o=>{const a=o*n;if(a===0)throw new Error("Cannot convert zero wavelength to frequency.");return fn/a/i});this.f_scaled=u}get wavelength_m(){return this._getWavelengthInTargetUnit("m")}set wavelength_m(r){this._setWavelengthFromTargetUnit(r,"m")}get wavelength_cm(){return this._getWavelengthInTargetUnit("cm")}set wavelength_cm(r){this._setWavelengthFromTargetUnit(r,"cm")}get wavelength_mm(){return this._getWavelengthInTargetUnit("mm")}set wavelength_mm(r){this._setWavelengthFromTargetUnit(r,"mm")}get wavelength_um(){return this._getWavelengthInTargetUnit("um")}set wavelength_um(r){this._setWavelengthFromTargetUnit(r,"um")}get wavelength_nm(){return this._getWavelengthInTargetUnit("nm")}set wavelength_nm(r){this._setWavelengthFromTargetUnit(r,"nm")}}const bc=["RI","MA","DB"],Cc=["S","Y","Z","G","H"];class _c{comments=[];_format;set format(r){if(r==null){this._format=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone format: ${r}`);switch(r.toLowerCase()){case"ma":this._format="MA";break;case"db":this._format="DB";break;case"ri":this._format="RI";break;default:throw new Error(`Unknown Touchstone format: ${r}`)}}get format(){return this._format}_parameter;set parameter(r){if(r==null){this._parameter=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone parameter: ${r}`);switch(r.toLowerCase()){case"s":this._parameter="S";break;case"y":this._parameter="Y";break;case"z":this._parameter="Z";break;case"g":this._parameter="G";break;case"h":this._parameter="H";break;default:throw new Error(`Unknown Touchstone parameter: ${r}`)}}get parameter(){return this._parameter}_impedance=50;set impedance(r){if(typeof r=="number"){this._impedance=r;return}if(!Array.isArray(r)||r.length===0)throw new Error(`Unknown Touchstone impedance: ${r}`);for(const t of r)if(typeof t!="number")throw new Error(`Unknown Touchstone impedance: ${r}`);this._impedance=r}get impedance(){return this._impedance}_nports;set nports(r){if(r==null){this._nports=void 0;return}if(typeof r!="number")throw new Error(`Unknown ports number: ${r}`);if(!Number.isInteger(r))throw new Error(`Unknown ports number: ${r}`);if(r<1)throw new Error(`Unknown ports number: ${r}`);this._nports=r}get nports(){return this._nports}frequency;_matrix;set matrix(r){if(r==null){this._matrix=void 0;return}this._matrix=r}get matrix(){return this._matrix}readContent(r,t){this.nports=t;const n=r.split(`
|
|
12
|
-
`).map(l=>l.trim()).filter(l=>l!=="");this.comments=n.filter(l=>l.startsWith("!")).map(l=>l.slice(1).trim()),this.frequency=new
|
|
13
|
-
`)}}const Bc=zt,Nc=qt;ge.FREQUENCY_MULTIPLIERS=cr,ge.Frequency=
|
|
11
|
+
(`+_e(b,c)+", "+_e(A,c)+") ==> "+(this._values?_e(this._values[_],c):"X")}return g},i.prototype.toString=function(){return _e(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(c){if(c){if(Ee(c)&&(c=c.toNumber()),!ne(c)||!ye(c))throw new TypeError("The parameter k must be an integer number")}else c=0;var d=c>0?c:0,v=c<0?-c:0,y=this._size[0],g=this._size[1],A=Math.min(y-v,g-d),F=[],w=[],_=[];_[0]=0;for(var b=d;b<g&&F.length<A;b++)for(var B=this._ptr[b],S=this._ptr[b+1],x=B;x<S;x++){var O=this._index[x];if(O===b-d+v){F.push(this._values[x]),w[F.length-1]=O-v;break}}return _.push(F.length),new i({values:F,index:w,ptr:_,size:[A,1]})},i.fromJSON=function(c){return new i(c)},i.diagonal=function(c,d,v,y,g){if(!ve(c))throw new TypeError("Array expected, size parameter");if(c.length!==2)throw new Error("Only two dimensions matrix are supported");if(c=c.map(function(X){if(Ee(X)&&(X=X.toNumber()),!ne(X)||!ye(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Ee(v)&&(v=v.toNumber()),!ne(v)||!ye(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var A=t,F=0;Me(g)&&(A=r.find(t,[g,g])||t,F=r.convert(0,g));var w=v>0?v:0,_=v<0?-v:0,b=c[0],B=c[1],S=Math.min(b-_,B-w),x;if(ve(d)){if(d.length!==S)throw new Error("Invalid value array length");x=function(ee){return d[ee]}}else if(we(d)){var O=d.size();if(O.length!==1||O[0]!==S)throw new Error("Invalid matrix length");x=function(ee){return d.get([ee])}}else x=function(){return d};for(var G=[],R=[],H=[],$=0;$<B;$++){H.push(G.length);var Q=$-w;if(Q>=0&&Q<S){var J=x(Q);A(J,F)||(R.push(Q+_),G.push(J))}}return H.push(G.length),new i({values:G,index:R,ptr:H,size:[b,B]})},i.prototype.swapRows=function(c,d){if(!ne(c)||!ye(c)||!ne(d)||!ye(d))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return De(c,this._size[0]),De(d,this._size[0]),i._swapRows(c,d,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(c,d,v,y,g){for(var A=y[c],F=y[c+1],w=A;w<F;w++)g(v[w],d[w])},i._swapRows=function(c,d,v,y,g,A){for(var F=0;F<v;F++){var w=A[F],_=A[F+1],b=f(c,w,_,g),B=f(d,w,_,g);if(b<_&&B<_&&g[b]===c&&g[B]===d){if(y){var S=y[b];y[b]=y[B],y[B]=S}continue}if(b<_&&g[b]===c&&(B>=_||g[B]!==d)){var x=y?y[b]:void 0;g.splice(B,0,d),y&&y.splice(B,0,x),g.splice(B<=b?b+1:b,1),y&&y.splice(B<=b?b+1:b,1);continue}if(B<_&&g[B]===d&&(b>=_||g[b]!==c)){var O=y?y[B]:void 0;g.splice(b,0,c),y&&y.splice(b,0,O),g.splice(b<=B?B+1:B,1),y&&y.splice(b<=B?B+1:B,1)}}},i},{isClass:!0}),Ga="number",Ja=["typed"];function ka(e){var r=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(r){var t={"0b":2,"0o":8,"0x":16}[r[1]],n=r[2],i=r[3];return{input:e,radix:t,integerPart:n,fractionalPart:i}}else return null}function Ya(e){for(var r=parseInt(e.integerPart,e.radix),t=0,n=0;n<e.fractionalPart.length;n++){var i=parseInt(e.fractionalPart[n],e.radix);t+=i/Math.pow(e.radix,n+1)}var u=r+t;if(isNaN(u))throw new SyntaxError('String "'+e.input+'" is not a valid number');return u}var Xa=V(Ga,Ja,e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(i){return i},string:function(i){if(i==="NaN")return NaN;var u=ka(i);if(u)return Ya(u);var o=0,a=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);a&&(o=Number(a[2]),i=a[1]);var s=Number(i);if(isNaN(s))throw new SyntaxError('String "'+i+'" is not a valid number');if(a){if(s>2**o-1)throw new SyntaxError('String "'.concat(i,'" is out of range'));s>=2**(o-1)&&(s=s-2**o)}return s},BigNumber:function(i){return i.toNumber()},bigint:function(i){return Number(i)},Fraction:function(i){return i.valueOf()},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),null:function(i){return 0},"Unit, string | Unit":function(i,u){return i.toNumber(u)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),Qa="bignumber",Ka=["typed","BigNumber"],ja=V(Qa,Ka,e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(i){return new t(i+"")},string:function(i){var u=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(u){var o=u[2],a=t(u[1]),s=new t(2).pow(Number(o));if(a.gt(s.sub(1)))throw new SyntaxError('String "'.concat(i,'" is out of range'));var f=new t(2).pow(Number(o)-1);return a.gte(f)?a.sub(s):a}return new t(i)},BigNumber:function(i){return i},bigint:function(i){return new t(i.toString())},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Fraction:function(i){return new t(String(i.n)).div(String(i.d)).times(String(i.s))},null:function(i){return new t(0)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),es="complex",rs=["typed","Complex"],ts=V(es,rs,e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(i){return new t(i,0)},"number, number":function(i,u){return new t(i,u)},"BigNumber, BigNumber":function(i,u){return new t(i.toNumber(),u.toNumber())},Fraction:function(i){return new t(i.valueOf(),0)},Complex:function(i){return i.clone()},string:function(i){return t(i)},null:function(i){return t(0)},Object:function(i){if("re"in i&&"im"in i)return new t(i.re,i.im);if("r"in i&&"phi"in i||"abs"in i&&"arg"in i)return new t(i);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),ns="fraction",is=["typed","Fraction"],us=V(ns,is,e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(i){if(!Number.isFinite(i)||isNaN(i))throw new Error(i+" cannot be represented as a fraction");return new t(i)},string:function(i){return new t(i)},"number, number":function(i,u){return new t(i,u)},"bigint, bigint":function(i,u){return new t(i,u)},null:function(i){return new t(0)},BigNumber:function(i){return new t(i.toString())},bigint:function(i){return new t(i.toString())},Fraction:function(i){return i},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Object:function(i){return new t(i)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),vi="matrix",os=["typed","Matrix","DenseMatrix","SparseMatrix"],as=V(vi,os,e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(vi,{"":function(){return u([])},string:function(a){return u([],a)},"string, string":function(a,s){return u([],a,s)},Array:function(a){return u(a)},Matrix:function(a){return u(a,a.storage())},"Array | Matrix, string":u,"Array | Matrix, string, string":u});function u(o,a,s){if(a==="dense"||a==="default"||a===void 0)return new n(o,s);if(a==="sparse")return new i(o,s);throw new TypeError("Unknown matrix type "+JSON.stringify(a)+".")}}),wi="unaryMinus",ss=["typed"],fs=V(wi,ss,e=>{var{typed:r}=e;return r(wi,{number:pi,"Complex | BigNumber | Fraction":t=>t.neg(),bigint:t=>-t,Unit:r.referToSelf(t=>n=>{var i=n.clone();return i.value=r.find(t,i.valueType())(n.value),i}),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),yi="abs",cs=["typed"],ls=V(yi,cs,e=>{var{typed:r}=e;return r(yi,{number:fi,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),Fi="addScalar",hs=["typed"],ps=V(Fi,hs,e=>{var{typed:r}=e;return r(Fi,{"number, number":ci,"Complex, Complex":function(n,i){return n.add(i)},"BigNumber, BigNumber":function(n,i){return n.plus(i)},"bigint, bigint":function(n,i){return n+i},"Fraction, Fraction":function(n,i){return n.add(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),Ei="subtractScalar",ms=["typed"],Ds=V(Ei,ms,e=>{var{typed:r}=e;return r(Ei,{"number, number":li,"Complex, Complex":function(n,i){return n.sub(i)},"BigNumber, BigNumber":function(n,i){return n.minus(i)},"bigint, bigint":function(n,i){return n-i},"Fraction, Fraction":function(n,i){return n.sub(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),ds="matAlgo11xS0s",gs=["typed","equalScalar"],Ai=V(ds,gs,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,D=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],m=l[1],c,d=t,v=0,y=o;typeof h=="string"&&(c=h,d=r.find(t,[c,c]),v=r.convert(0,c),u=r.convert(u,c),y=r.find(o,[c,c]));for(var g=[],A=[],F=[],w=0;w<m;w++){F[w]=A.length;for(var _=D[w],b=D[w+1],B=_;B<b;B++){var S=f[B],x=a?y(u,s[B]):y(s[B],u);d(x,v)||(A.push(S),g.push(x))}}return F[m]=A.length,i.createSparseMatrix({values:g,index:A,ptr:F,size:[p,m],datatype:c})}}),vs="matAlgo12xSfs",ws=["typed","DenseMatrix"],zr=V(vs,ws,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,D=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],m=l[1],c,d=o;typeof h=="string"&&(c=h,u=r.convert(u,c),d=r.find(o,[c,c]));for(var v=[],y=[],g=[],A=0;A<m;A++){for(var F=A+1,w=D[A],_=D[A+1],b=w;b<_;b++){var B=f[b];y[B]=s[b],g[B]=F}for(var S=0;S<p;S++)A===0&&(v[S]=[]),g[S]===F?v[S][A]=a?d(u,y[S]):d(y[S],u):v[S][A]=a?d(u,0):d(0,u)}return new t({data:v,size:[p,m],datatype:c})}}),ys="matAlgo14xDs",Fs=["typed"],un=V(ys,Fs,e=>{var{typed:r}=e;return function(i,u,o,a){var s=i._data,f=i._size,D=i._datatype,l,h=o;typeof D=="string"&&(l=D,u=r.convert(u,l),h=r.find(o,[l,l]));var p=f.length>0?t(h,0,f,f[0],s,u,a):[];return i.createDenseMatrix({data:p,size:me(f),datatype:l})};function t(n,i,u,o,a,s,f){var D=[];if(i===u.length-1)for(var l=0;l<o;l++)D[l]=f?n(s,a[l]):n(a[l],s);else for(var h=0;h<o;h++)D[h]=t(n,i+1,u,u[i+1],a[h],s,f);return D}}),Es="matAlgo03xDSf",As=["typed"],kr=V(Es,As,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,s=n._size,f=n._datatype||n.getDataType(),D=i._values,l=i._index,h=i._ptr,p=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ie(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!D)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var c=s[0],d=s[1],v,y=0,g=u;typeof f=="string"&&f===m&&f!=="mixed"&&(v=f,y=r.convert(0,v),g=r.find(u,[v,v]));for(var A=[],F=0;F<c;F++)A[F]=[];for(var w=[],_=[],b=0;b<d;b++){for(var B=b+1,S=h[b],x=h[b+1],O=S;O<x;O++){var G=l[O];w[G]=o?g(D[O],a[G][b]):g(a[G][b],D[O]),_[G]=B}for(var R=0;R<c;R++)_[R]===B?A[R][b]=w[R]:A[R][b]=o?g(y,a[R][b]):g(a[R][b],y)}return n.createDenseMatrix({data:A,size:[c,d],datatype:f===n._datatype&&m===i._datatype?v:void 0})}}),bs="matAlgo13xDD",Cs=["typed"],_s=V(bs,Cs,e=>{var{typed:r}=e;return function(i,u,o){var a=i._data,s=i._size,f=i._datatype,D=u._data,l=u._size,h=u._datatype,p=[];if(s.length!==l.length)throw new ie(s.length,l.length);for(var m=0;m<s.length;m++){if(s[m]!==l[m])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");p[m]=s[m]}var c,d=o;typeof f=="string"&&f===h&&(c=f,d=r.find(o,[c,c]));var v=p.length>0?t(d,0,p,p[0],a,D):[];return i.createDenseMatrix({data:v,size:p,datatype:c})};function t(n,i,u,o,a,s){var f=[];if(i===u.length-1)for(var D=0;D<o;D++)f[D]=n(a[D],s[D]);else for(var l=0;l<o;l++)f[l]=t(n,i+1,u,u[i+1],a[l],s[l]);return f}});function Te(e,r){if(mr(e.size(),r.size()))return[e,r];var t=ni(e.size(),r.size());return[e,r].map(n=>Bs(n,t))}function Bs(e,r){return mr(e.size(),r)?e:e.create(tn(e.valueOf(),r),e.datatype())}var Ns="matrixAlgorithmSuite",Ss=["typed","matrix"],Or=V(Ns,Ss,e=>{var{typed:r,matrix:t}=e,n=_s({typed:r}),i=un({typed:r});return function(o){var a=o.elop,s=o.SD||o.DS,f;a?(f={"DenseMatrix, DenseMatrix":(p,m)=>n(...Te(p,m),a),"Array, Array":(p,m)=>n(...Te(t(p),t(m)),a).valueOf(),"Array, DenseMatrix":(p,m)=>n(...Te(t(p),m),a),"DenseMatrix, Array":(p,m)=>n(...Te(p,t(m)),a)},o.SS&&(f["SparseMatrix, SparseMatrix"]=(p,m)=>o.SS(...Te(p,m),a,!1)),o.DS&&(f["DenseMatrix, SparseMatrix"]=(p,m)=>o.DS(...Te(p,m),a,!1),f["Array, SparseMatrix"]=(p,m)=>o.DS(...Te(t(p),m),a,!1)),s&&(f["SparseMatrix, DenseMatrix"]=(p,m)=>s(...Te(m,p),a,!0),f["SparseMatrix, Array"]=(p,m)=>s(...Te(t(m),p),a,!0))):(f={"DenseMatrix, DenseMatrix":r.referToSelf(p=>(m,c)=>n(...Te(m,c),p)),"Array, Array":r.referToSelf(p=>(m,c)=>n(...Te(t(m),t(c)),p).valueOf()),"Array, DenseMatrix":r.referToSelf(p=>(m,c)=>n(...Te(t(m),c),p)),"DenseMatrix, Array":r.referToSelf(p=>(m,c)=>n(...Te(m,t(c)),p))},o.SS&&(f["SparseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,c)=>o.SS(...Te(m,c),p,!1))),o.DS&&(f["DenseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,c)=>o.DS(...Te(m,c),p,!1)),f["Array, SparseMatrix"]=r.referToSelf(p=>(m,c)=>o.DS(...Te(t(m),c),p,!1))),s&&(f["SparseMatrix, DenseMatrix"]=r.referToSelf(p=>(m,c)=>s(...Te(c,m),p,!0)),f["SparseMatrix, Array"]=r.referToSelf(p=>(m,c)=>s(...Te(t(c),m),p,!0))));var D=o.scalar||"any",l=o.Ds||o.Ss;l&&(a?(f["DenseMatrix,"+D]=(p,m)=>i(p,m,a,!1),f[D+", DenseMatrix"]=(p,m)=>i(m,p,a,!0),f["Array,"+D]=(p,m)=>i(t(p),m,a,!1).valueOf(),f[D+", Array"]=(p,m)=>i(t(m),p,a,!0).valueOf()):(f["DenseMatrix,"+D]=r.referToSelf(p=>(m,c)=>i(m,c,p,!1)),f[D+", DenseMatrix"]=r.referToSelf(p=>(m,c)=>i(c,m,p,!0)),f["Array,"+D]=r.referToSelf(p=>(m,c)=>i(t(m),c,p,!1).valueOf()),f[D+", Array"]=r.referToSelf(p=>(m,c)=>i(t(c),m,p,!0).valueOf())));var h=o.sS!==void 0?o.sS:o.Ss;return a?(o.Ss&&(f["SparseMatrix,"+D]=(p,m)=>o.Ss(p,m,a,!1)),h&&(f[D+", SparseMatrix"]=(p,m)=>h(m,p,a,!0))):(o.Ss&&(f["SparseMatrix,"+D]=r.referToSelf(p=>(m,c)=>o.Ss(m,c,p,!1))),h&&(f[D+", SparseMatrix"]=r.referToSelf(p=>(m,c)=>h(c,m,p,!0)))),a&&a.signatures&&Wu(f,a.signatures),f}}),Ms="matAlgo01xDSid",xs=["typed"],Ts=V(Ms,xs,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,s=n._size,f=n._datatype||n.getDataType(),D=i._values,l=i._index,h=i._ptr,p=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ie(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!D)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var c=s[0],d=s[1],v=typeof f=="string"&&f!=="mixed"&&f===m?f:void 0,y=v?r.find(u,[v,v]):u,g,A,F=[];for(g=0;g<c;g++)F[g]=[];var w=[],_=[];for(A=0;A<d;A++){for(var b=A+1,B=h[A],S=h[A+1],x=B;x<S;x++)g=l[x],w[g]=o?y(D[x],a[g][A]):y(a[g][A],D[x]),_[g]=b;for(g=0;g<c;g++)_[g]===b?F[g][A]=w[g]:F[g][A]=a[g][A]}return n.createDenseMatrix({data:F,size:[c,d],datatype:f===n._datatype&&m===i._datatype?v:void 0})}}),Is="matAlgo04xSidSid",zs=["typed","equalScalar"],Os=V(Is,zs,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o){var a=i._values,s=i._index,f=i._ptr,D=i._size,l=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=u._values,p=u._index,m=u._ptr,c=u._size,d=u._datatype||u._data===void 0?u._datatype:u.getDataType();if(D.length!==c.length)throw new ie(D.length,c.length);if(D[0]!==c[0]||D[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+D+") must match Matrix B ("+c+")");var v=D[0],y=D[1],g,A=t,F=0,w=o;typeof l=="string"&&l===d&&l!=="mixed"&&(g=l,A=r.find(t,[g,g]),F=r.convert(0,g),w=r.find(o,[g,g]));var _=a&&h?[]:void 0,b=[],B=[],S=a&&h?[]:void 0,x=a&&h?[]:void 0,O=[],G=[],R,H,$,Q,J;for(H=0;H<y;H++){B[H]=b.length;var X=H+1;for(Q=f[H],J=f[H+1],$=Q;$<J;$++)R=s[$],b.push(R),O[R]=X,S&&(S[R]=a[$]);for(Q=m[H],J=m[H+1],$=Q;$<J;$++)if(R=p[$],O[R]===X){if(S){var ee=w(S[R],h[$]);A(ee,F)?O[R]=null:S[R]=ee}}else b.push(R),G[R]=X,x&&(x[R]=h[$]);if(S&&x)for($=B[H];$<b.length;)R=b[$],O[R]===X?(_[$]=S[R],$++):G[R]===X?(_[$]=x[R],$++):b.splice($,1)}return B[y]=b.length,i.createSparseMatrix({values:_,index:b,ptr:B,size:[v,y],datatype:l===i._datatype&&d===u._datatype?g:void 0})}}),$s="matAlgo10xSids",Ps=["typed","DenseMatrix"],qs=V($s,Ps,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,D=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],m=l[1],c,d=o;typeof h=="string"&&(c=h,u=r.convert(u,c),d=r.find(o,[c,c]));for(var v=[],y=[],g=[],A=0;A<m;A++){for(var F=A+1,w=D[A],_=D[A+1],b=w;b<_;b++){var B=f[b];y[B]=s[b],g[B]=F}for(var S=0;S<p;S++)A===0&&(v[S]=[]),g[S]===F?v[S][A]=a?d(u,y[S]):d(y[S],u):v[S][A]=u}return new t({data:v,size:[p,m],datatype:c})}});function Us(e,r,t,n){return function(i){if(i>0||t.predictable){if(i<=0)return NaN;var u=i.toString(16),o=u.substring(0,15);return e*(u.length-o.length)+r(+("0x"+o))}return n(i.toNumber())}}var bi="log10",Rs=["typed","config","Complex"],Ls=Et(16),Hs=V(bi,Rs,e=>{var{typed:r,config:t,Complex:n}=e;function i(o){return o.log().div(Math.LN10)}function u(o){return i(new n(o,0))}return r(bi,{number:function(a){return a>=0||t.predictable?Et(a):u(a)},bigint:Us(Ls,Et,t,u),Complex:i,BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():u(a.toNumber())},"Array | Matrix":r.referToSelf(o=>a=>Ve(a,o))})}),Zs="multiplyScalar",Ws=["typed"],Vs=V(Zs,Ws,e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":hi,"Complex, Complex":function(n,i){return n.mul(i)},"BigNumber, BigNumber":function(n,i){return n.times(i)},"bigint, bigint":function(n,i){return n*i},"Fraction, Fraction":function(n,i){return n.mul(i)},"number | Fraction | BigNumber | Complex, Unit":(t,n)=>n.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,n)=>t.multiply(n)})}),Ci="multiply",Gs=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Js=V(Ci,Gs,e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:u,dot:o}=e,a=Ai({typed:r,equalScalar:u}),s=un({typed:r});function f(F,w){switch(F.length){case 1:switch(w.length){case 1:if(F[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(F[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+F[0]+") must match Matrix rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;case 2:switch(w.length){case 1:if(F[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+F[1]+") must match Vector length ("+w[0]+")");break;case 2:if(F[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+F[1]+") must match Matrix B rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+F.length+" dimensions)")}}function D(F,w,_){if(_===0)throw new Error("Cannot multiply two empty vectors");return o(F,w)}function l(F,w){if(w.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return h(F,w)}function h(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._size,O=w._datatype||w.getDataType(),G=b[0],R=x[1],H,$=n,Q=i;B&&O&&B===O&&typeof B=="string"&&B!=="mixed"&&(H=B,$=r.find(n,[H,H]),Q=r.find(i,[H,H]));for(var J=[],X=0;X<R;X++){for(var ee=Q(_[0],S[0][X]),ue=1;ue<G;ue++)ee=$(ee,Q(_[ue],S[ue][X]));J[X]=ee}return F.createDenseMatrix({data:J,size:[R],datatype:B===F._datatype&&O===w._datatype?H:void 0})}var p=r("_multiplyMatrixVector",{"DenseMatrix, any":c,"SparseMatrix, any":y}),m=r("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":d,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":A});function c(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._datatype||w.getDataType(),O=b[0],G=b[1],R,H=n,$=i;B&&x&&B===x&&typeof B=="string"&&B!=="mixed"&&(R=B,H=r.find(n,[R,R]),$=r.find(i,[R,R]));for(var Q=[],J=0;J<O;J++){for(var X=_[J],ee=$(X[0],S[0]),ue=1;ue<G;ue++)ee=H(ee,$(X[ue],S[ue]));Q[J]=ee}return F.createDenseMatrix({data:Q,size:[O],datatype:B===F._datatype&&x===w._datatype?R:void 0})}function d(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._size,O=w._datatype||w.getDataType(),G=b[0],R=b[1],H=x[1],$,Q=n,J=i;B&&O&&B===O&&typeof B=="string"&&B!=="mixed"&&B!=="mixed"&&($=B,Q=r.find(n,[$,$]),J=r.find(i,[$,$]));for(var X=[],ee=0;ee<G;ee++){var ue=_[ee];X[ee]=[];for(var oe=0;oe<H;oe++){for(var le=J(ue[0],S[0][oe]),Be=1;Be<R;Be++)le=Q(le,J(ue[Be],S[Be][oe]));X[ee][oe]=le}}return F.createDenseMatrix({data:X,size:[G,H],datatype:B===F._datatype&&O===w._datatype?$:void 0})}function v(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._values,x=w._index,O=w._ptr,G=w._size,R=w._datatype||w._data===void 0?w._datatype:w.getDataType();if(!S)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var H=b[0],$=G[1],Q,J=n,X=i,ee=u,ue=0;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&(Q=B,J=r.find(n,[Q,Q]),X=r.find(i,[Q,Q]),ee=r.find(u,[Q,Q]),ue=r.convert(0,Q));for(var oe=[],le=[],Be=[],Ce=w.createSparseMatrix({values:oe,index:le,ptr:Be,size:[H,$],datatype:B===F._datatype&&R===w._datatype?Q:void 0}),be=0;be<$;be++){Be[be]=le.length;var Fe=O[be],Le=O[be+1];if(Le>Fe)for(var he=0,se=0;se<H;se++){for(var Qe=se+1,$e=void 0,pe=Fe;pe<Le;pe++){var Ie=x[pe];he!==Qe?($e=X(_[se][Ie],S[pe]),he=Qe):$e=J($e,X(_[se][Ie],S[pe]))}he===Qe&&!ee($e,ue)&&(le.push(se),oe.push($e))}}return Be[$]=le.length,Ce}function y(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!_)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var x=w._data,O=w._datatype||w.getDataType(),G=F._size[0],R=w._size[0],H=[],$=[],Q=[],J,X=n,ee=i,ue=u,oe=0;S&&O&&S===O&&typeof S=="string"&&S!=="mixed"&&(J=S,X=r.find(n,[J,J]),ee=r.find(i,[J,J]),ue=r.find(u,[J,J]),oe=r.convert(0,J));var le=[],Be=[];Q[0]=0;for(var Ce=0;Ce<R;Ce++){var be=x[Ce];if(!ue(be,oe))for(var Fe=B[Ce],Le=B[Ce+1],he=Fe;he<Le;he++){var se=b[he];Be[se]?le[se]=X(le[se],ee(be,_[he])):(Be[se]=!0,$.push(se),le[se]=ee(be,_[he]))}}for(var Qe=$.length,$e=0;$e<Qe;$e++){var pe=$[$e];H[$e]=le[pe]}return Q[1]=$.length,F.createSparseMatrix({values:H,index:$,ptr:Q,size:[G,1],datatype:S===F._datatype&&O===w._datatype?J:void 0})}function g(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!_)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var x=w._data,O=w._datatype||w.getDataType(),G=F._size[0],R=w._size[0],H=w._size[1],$,Q=n,J=i,X=u,ee=0;S&&O&&S===O&&typeof S=="string"&&S!=="mixed"&&($=S,Q=r.find(n,[$,$]),J=r.find(i,[$,$]),X=r.find(u,[$,$]),ee=r.convert(0,$));for(var ue=[],oe=[],le=[],Be=F.createSparseMatrix({values:ue,index:oe,ptr:le,size:[G,H],datatype:S===F._datatype&&O===w._datatype?$:void 0}),Ce=[],be=[],Fe=0;Fe<H;Fe++){le[Fe]=oe.length;for(var Le=Fe+1,he=0;he<R;he++){var se=x[he][Fe];if(!X(se,ee))for(var Qe=B[he],$e=B[he+1],pe=Qe;pe<$e;pe++){var Ie=b[pe];be[Ie]!==Le?(be[Ie]=Le,oe.push(Ie),Ce[Ie]=J(se,_[pe])):Ce[Ie]=Q(Ce[Ie],J(se,_[pe]))}}for(var Ke=le[Fe],lr=oe.length,hr=Ke;hr<lr;hr++){var Ur=oe[hr];ue[hr]=Ce[Ur]}}return le[H]=oe.length,Be}function A(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType(),x=w._values,O=w._index,G=w._ptr,R=w._datatype||w._data===void 0?w._datatype:w.getDataType(),H=F._size[0],$=w._size[1],Q=_&&x,J,X=n,ee=i;S&&R&&S===R&&typeof S=="string"&&S!=="mixed"&&(J=S,X=r.find(n,[J,J]),ee=r.find(i,[J,J]));for(var ue=Q?[]:void 0,oe=[],le=[],Be=F.createSparseMatrix({values:ue,index:oe,ptr:le,size:[H,$],datatype:S===F._datatype&&R===w._datatype?J:void 0}),Ce=Q?[]:void 0,be=[],Fe,Le,he,se,Qe,$e,pe,Ie,Ke=0;Ke<$;Ke++){le[Ke]=oe.length;var lr=Ke+1;for(Qe=G[Ke],$e=G[Ke+1],se=Qe;se<$e;se++)if(Ie=O[se],Q)for(Le=B[Ie],he=B[Ie+1],Fe=Le;Fe<he;Fe++)pe=b[Fe],be[pe]!==lr?(be[pe]=lr,oe.push(pe),Ce[pe]=ee(x[se],_[Fe])):Ce[pe]=X(Ce[pe],ee(x[se],_[Fe]));else for(Le=B[Ie],he=B[Ie+1],Fe=Le;Fe<he;Fe++)pe=b[Fe],be[pe]!==lr&&(be[pe]=lr,oe.push(pe));if(Q)for(var hr=le[Ke],Ur=oe.length,Rr=hr;Rr<Ur;Rr++){var hn=oe[Rr];ue[Rr]=Ce[hn]}}return le[$]=oe.length,Be}return r(Ci,i,{"Array, Array":r.referTo("Matrix, Matrix",F=>(w,_)=>{f(Oe(w),Oe(_));var b=F(t(w),t(_));return we(b)?b.valueOf():b}),"Matrix, Matrix":function(w,_){var b=w.size(),B=_.size();return f(b,B),b.length===1?B.length===1?D(w,_,b[0]):l(w,_):B.length===1?p(w,_):m(w,_)},"Matrix, Array":r.referTo("Matrix,Matrix",F=>(w,_)=>F(w,t(_))),"Array, Matrix":r.referToSelf(F=>(w,_)=>F(t(w,_.storage()),_)),"SparseMatrix, any":function(w,_){return a(w,_,i,!1)},"DenseMatrix, any":function(w,_){return s(w,_,i,!1)},"any, SparseMatrix":function(w,_){return a(_,w,i,!0)},"any, DenseMatrix":function(w,_){return s(_,w,i,!0)},"Array, any":function(w,_){return s(t(w),_,i,!1).valueOf()},"any, Array":function(w,_){return s(t(_),w,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf(F=>(w,_,b)=>{for(var B=F(w,_),S=0;S<b.length;S++)B=F(B,b[S]);return B})})}),ks="matAlgo07xSSf",Ys=["typed","SparseMatrix"],Yr=V(ks,Ys,e=>{var{typed:r,SparseMatrix:t}=e;return function(u,o,a){var s=u._size,f=u._datatype||u._data===void 0?u._datatype:u.getDataType(),D=o._size,l=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(s.length!==D.length)throw new ie(s.length,D.length);if(s[0]!==D[0]||s[1]!==D[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+D+")");var h=s[0],p=s[1],m,c=0,d=a;typeof f=="string"&&f===l&&f!=="mixed"&&(m=f,c=r.convert(0,m),d=r.find(a,[m,m]));for(var v=[],y=[],g=new Array(p+1).fill(0),A=[],F=[],w=[],_=[],b=0;b<p;b++){var B=b+1,S=0;n(u,b,w,A,B),n(o,b,_,F,B);for(var x=0;x<h;x++){var O=w[x]===B?A[x]:c,G=_[x]===B?F[x]:c,R=d(O,G);R!==0&&R!==!1&&(y.push(x),v.push(R),S++)}g[b+1]=g[b]+S}return new t({values:v,index:y,ptr:g,size:[h,p],datatype:f===u._datatype&&l===o._datatype?m:void 0})};function n(i,u,o,a,s){for(var f=i._values,D=i._index,l=i._ptr,h=l[u],p=l[u+1];h<p;h++){var m=D[h];o[m]=s,a[m]=f[h]}}}),_i="arg",Xs=["typed"],Qs=V(_i,Xs,e=>{var{typed:r}=e;return r(_i,{number:function(n){return Math.atan2(0,n)},BigNumber:function(n){return n.constructor.atan2(0,n)},Complex:function(n){return n.arg()},"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),Bi="conj",Ks=["typed"],js=V(Bi,Ks,e=>{var{typed:r}=e;return r(Bi,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),Unit:r.referToSelf(t=>n=>new n.constructor(t(n.toNumeric()),n.formatUnits())),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),Ni="concat",ef=["typed","matrix","isInteger"],rf=V(Ni,ef,e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Ni,{"...Array | Matrix | number | BigNumber":function(u){var o,a=u.length,s=-1,f,D=!1,l=[];for(o=0;o<a;o++){var h=u[o];if(we(h)&&(D=!0),ne(h)||Ee(h)){if(o!==a-1)throw new Error("Dimension must be specified as last argument");if(f=s,s=h.valueOf(),!n(s))throw new TypeError("Integer number expected for dimension");if(s<0||o>0&&s>f)throw new br(s,f+1)}else{var p=me(h).valueOf(),m=Oe(p);if(l[o]=p,f=s,s=m.length-1,o>0&&s!==f)throw new ie(f+1,s+1)}}if(l.length===0)throw new SyntaxError("At least one matrix expected");for(var c=l.shift();l.length;)c=ti(c,l.shift(),s);return D?t(c):c},"...string":function(u){return u.join("")}})}),Si="getMatrixDataType",tf=["typed"],nf=V(Si,tf,e=>{var{typed:r}=e;return r(Si,{Array:function(n){return wt(n,ur)},Matrix:function(n){return n.getDataType()}})}),Mi="identity",uf=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],of=V(Mi,uf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:u,SparseMatrix:o}=e;return r(Mi,{"":function(){return t.matrix==="Matrix"?n([]):[]},string:function(D){return n(D)},"number | BigNumber":function(D){return s(D,D,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(D,l){return s(D,D,l)},"number | BigNumber, number | BigNumber":function(D,l){return s(D,l,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(D,l,h){return s(D,l,h)},Array:function(D){return a(D)},"Array, string":function(D,l){return a(D,l)},Matrix:function(D){return a(D.valueOf(),D.storage())},"Matrix, string":function(D,l){return a(D.valueOf(),l)}});function a(f,D){switch(f.length){case 0:return D?n(D):[];case 1:return s(f[0],f[0],D);case 2:return s(f[0],f[1],D);default:throw new Error("Vector containing two values expected")}}function s(f,D,l){var h=Ee(f)||Ee(D)?i:null;if(Ee(f)&&(f=f.toNumber()),Ee(D)&&(D=D.toNumber()),!ye(f)||f<1)throw new Error("Parameters in function identity must be positive integers");if(!ye(D)||D<1)throw new Error("Parameters in function identity must be positive integers");var p=h?new i(1):1,m=h?new h(0):0,c=[f,D];if(l){if(l==="sparse")return o.diagonal(c,p,0,m);if(l==="dense")return u.diagonal(c,p,0,m);throw new TypeError('Unknown matrix type "'.concat(l,'"'))}for(var d=vt([],c,m),v=f<D?f:D,y=0;y<v;y++)d[y][y]=p;return d}});function xi(){throw new Error('No "bignumber" implementation available')}function af(){throw new Error('No "fraction" implementation available')}function sf(){throw new Error('No "matrix" implementation available')}var Ti="range",ff=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],cf=V(Ti,ff,e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:u,smallerEq:o,larger:a,largerEq:s,add:f,isZero:D,isPositive:l}=e;return r(Ti,{string:p,"string, boolean":p,number:function(v){throw new TypeError("Too few arguments to function range(): ".concat(v))},boolean:function(v){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(v,", number|bigint|BigNumber|Fraction"))},"number, number":function(v,y){return h(m(v,y,1,!1))},"number, number, number":function(v,y,g){return h(m(v,y,g,!1))},"number, number, boolean":function(v,y,g){return h(m(v,y,1,g))},"number, number, number, boolean":function(v,y,g,A){return h(m(v,y,g,A))},"bigint, bigint|number":function(v,y){return h(m(v,y,1n,!1))},"number, bigint":function(v,y){return h(m(BigInt(v),y,1n,!1))},"bigint, bigint|number, bigint|number":function(v,y,g){return h(m(v,y,BigInt(g),!1))},"number, bigint, bigint|number":function(v,y,g){return h(m(BigInt(v),y,BigInt(g),!1))},"bigint, bigint|number, boolean":function(v,y,g){return h(m(v,y,1n,g))},"number, bigint, boolean":function(v,y,g){return h(m(BigInt(v),y,1n,g))},"bigint, bigint|number, bigint|number, boolean":function(v,y,g,A){return h(m(v,y,BigInt(g),A))},"number, bigint, bigint|number, boolean":function(v,y,g,A){return h(m(BigInt(v),y,BigInt(g),A))},"BigNumber, BigNumber":function(v,y){var g=v.constructor;return h(m(v,y,new g(1),!1))},"BigNumber, BigNumber, BigNumber":function(v,y,g){return h(m(v,y,g,!1))},"BigNumber, BigNumber, boolean":function(v,y,g){var A=v.constructor;return h(m(v,y,new A(1),g))},"BigNumber, BigNumber, BigNumber, boolean":function(v,y,g,A){return h(m(v,y,g,A))},"Fraction, Fraction":function(v,y){return h(m(v,y,1,!1))},"Fraction, Fraction, Fraction":function(v,y,g){return h(m(v,y,g,!1))},"Fraction, Fraction, boolean":function(v,y,g){return h(m(v,y,1,g))},"Fraction, Fraction, Fraction, boolean":function(v,y,g,A){return h(m(v,y,g,A))},"Unit, Unit, Unit":function(v,y,g){return h(m(v,y,g,!1))},"Unit, Unit, Unit, boolean":function(v,y,g,A){return h(m(v,y,g,A))}});function h(d){return t.matrix==="Matrix"?n?n(d):sf():d}function p(d,v){var y=c(d);if(!y)throw new SyntaxError('String "'+d+'" is no valid range');return t.number==="BigNumber"?(i===void 0&&xi(),h(m(i(y.start),i(y.end),i(y.step)))):h(m(y.start,y.end,y.step,v))}function m(d,v,y,g){var A=[];if(D(y))throw new Error("Step must be non-zero");for(var F=l(y)?g?o:u:g?s:a,w=d;F(w,v);)A.push(w),w=f(w,y);return A}function c(d){var v=d.split(":"),y=v.map(function(A){return Number(A)}),g=y.some(function(A){return isNaN(A)});if(g)return null;switch(y.length){case 2:return{start:y[0],end:y[1],step:1};case 3:return{start:y[0],end:y[2],step:y[1]};default:return null}}}),Ii="size",lf=["typed"],hf=V(Ii,lf,e=>{var{typed:r}=e;return r(Ii,{Matrix:t=>t.size(),Array:Oe,string:t=>[t.length],"number | Complex | BigNumber | Unit | boolean | null":t=>[]})}),zi="subset",pf=["typed","matrix","zeros","add"],mf=V(zi,pf,e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(zi,{"Matrix, Index":function(a,s){return Ir(s)?t():(gt(a,s),a.subset(s))},"Array, Index":r.referTo("Matrix, Index",function(o){return function(a,s){var f=o(t(a),s);return s.isScalar()?f:f.valueOf()}}),"Object, Index":df,"string, Index":Df,"Matrix, Index, any, any":function(a,s,f,D){return Ir(s)?a:(gt(a,s),a.clone().subset(s,u(f,s),D))},"Array, Index, any, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f,D){var l=o(t(a),s,f,D);return l.isMatrix?l.valueOf():l}}),"Array, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f){return o(t(a),s,f,void 0).valueOf()}}),"Matrix, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f){return o(a,s,f,void 0)}}),"string, Index, string":Oi,"string, Index, string, string":Oi,"Object, Index, any":gf});function u(o,a){if(typeof o=="string")throw new Error("can't boradcast a string");if(a.isScalar())return o;var s=a.size();if(s.every(f=>f>0))try{return i(o,n(s))}catch{return o}else return o}});function Df(e,r){if(!nt(r))throw new TypeError("Index expected");if(Ir(r))return"";if(gt(Array.from(e),r),r.size().length!==1)throw new ie(r.size().length,1);var t=e.length;De(r.min()[0],t),De(r.max()[0],t);var n=r.dimension(0),i="";function u(o){i+=e.charAt(o)}return Number.isInteger(n)?u(n):n.forEach(u),i}function Oi(e,r,t,n){if(!r||r.isIndex!==!0)throw new TypeError("Index expected");if(Ir(r))return e;if(gt(Array.from(e),r),r.size().length!==1)throw new ie(r.size().length,1);if(n!==void 0){if(typeof n!="string"||n.length!==1)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=r.dimension(0),u=Number.isInteger(i)?1:i.size()[0];if(u!==t.length)throw new ie(i.size()[0],t.length);var o=e.length;De(r.min()[0]),De(r.max()[0]);for(var a=[],s=0;s<o;s++)a[s]=e.charAt(s);function f(h,p){a[h]=t.charAt(p[0])}if(Number.isInteger(i)?f(i,[0]):i.forEach(f),a.length>o)for(var D=o-1,l=a.length;D<l;D++)a[D]||(a[D]=n);return a.join("")}function df(e,r){if(!Ir(r)){if(r.size().length!==1)throw new ie(r.size(),1);var t=r.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return mn(e,t)}}function gf(e,r,t){if(Ir(r))return e;if(r.size().length!==1)throw new ie(r.size(),1);var n=r.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");var i=me(e);return Dn(i,n,t),i}var $i="zeros",vf=["typed","config","matrix","BigNumber"],wf=V($i,vf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r($i,{"":function(){return t.matrix==="Array"?u([]):u([],"default")},"...number | BigNumber | string":function(f){var D=f[f.length-1];if(typeof D=="string"){var l=f.pop();return u(f,l)}else return t.matrix==="Array"?u(f):u(f,"default")},Array:u,Matrix:function(f){var D=f.storage();return u(f.valueOf(),D)},"Array | Matrix, string":function(f,D){return u(f.valueOf(),D)}});function u(s,f){var D=o(s),l=D?new i(0):0;if(a(s),f){var h=n(f);return s.length>0?h.resize(s,l):h}else{var p=[];return s.length>0?vt(p,s,l):p}}function o(s){var f=!1;return s.forEach(function(D,l,h){Ee(D)&&(f=!0,h[l]=D.toNumber())}),f}function a(s){s.forEach(function(f){if(typeof f!="number"||!ye(f)||f<0)throw new Error("Parameters in function zeros must be positive integers")})}}),yf="numeric",Ff=["number","?bignumber","?fraction"],Ef=V(yf,Ff,e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},u={number:o=>r(o),BigNumber:t?o=>t(o):xi,bigint:o=>BigInt(o),Fraction:n?o=>n(o):af};return function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",f=arguments.length>2?arguments[2]:void 0;if(f!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var D=ur(a);if(!(D in i))throw new TypeError("Cannot convert "+a+' of type "'+D+'"; valid input types are '+Object.keys(i).join(", "));if(!(s in u))throw new TypeError("Cannot convert "+a+' to type "'+s+'"; valid output types are '+Object.keys(u).join(", "));return s===D?a:u[s](a)}}),Pi="divideScalar",Af=["typed","numeric"],bf=V(Pi,Af,e=>{var{typed:r,numeric:t}=e;return r(Pi,{"number, number":function(i,u){return i/u},"Complex, Complex":function(i,u){return i.div(u)},"BigNumber, BigNumber":function(i,u){return i.div(u)},"bigint, bigint":function(i,u){return i/u},"Fraction, Fraction":function(i,u){return i.div(u)},"Unit, number | Complex | Fraction | BigNumber | Unit":(n,i)=>n.divide(i),"number | Fraction | Complex | BigNumber, Unit":(n,i)=>i.divideInto(n)})}),qi="pow",Cf=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],_f=V(qi,Cf,e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:u,inv:o,number:a,fraction:s,Complex:f}=e;return r(qi,{"number, number":D,"Complex, Complex":function(m,c){return m.pow(c)},"BigNumber, BigNumber":function(m,c){return c.isInteger()||m>=0||t.predictable?m.pow(c):new f(m.toNumber(),0).pow(c.toNumber(),0)},"bigint, bigint":(p,m)=>p**m,"Fraction, Fraction":function(m,c){var d=m.pow(c);if(d!=null)return d;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return D(m.valueOf(),c.valueOf())},"Array, number":l,"Array, BigNumber":function(m,c){return l(m,c.toNumber())},"Matrix, number":h,"Matrix, BigNumber":function(m,c){return h(m,c.toNumber())},"Unit, number | BigNumber":function(m,c){return m.pow(c)}});function D(p,m){if(t.predictable&&!ye(m)&&p<0)try{var c=s(m),d=a(c);if((m===d||Math.abs((m-d)/m)<1e-14)&&c.d%2n===1n)return(c.n%2n===0n?1:-1)*Math.pow(-p,m)}catch{}return t.predictable&&(p<-1&&m===1/0||p>-1&&p<0&&m===-1/0)?NaN:ye(m)||p>=0||t.predictable?mi(p,m):p*p<1&&m===1/0||p*p>1&&m===-1/0?0:new f(p,0).pow(m,0)}function l(p,m){if(!ye(m))throw new TypeError("For A^b, b must be an integer (value is "+m+")");var c=Oe(p);if(c.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+c.length+" dimensions)");if(c[0]!==c[1])throw new Error("For A^b, A must be square (size is "+c[0]+"x"+c[1]+")");if(m<0)try{return l(o(p),-m)}catch(y){throw y.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 "+m+")"):y}for(var d=n(c[0]).valueOf(),v=p;m>=1;)(m&1)===1&&(d=i(v,d)),m>>=1,v=i(v,v);return d}function h(p,m){return u(l(p.valueOf(),m))}}),$r="Number of decimals in function round must be an integer",Ui="round",Bf=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],Nf=V(Ui,Bf,e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:u,BigNumber:o,DenseMatrix:a}=e,s=Ai({typed:r,equalScalar:i}),f=zr({typed:r,DenseMatrix:a}),D=un({typed:r});function l(h){return Math.abs(Zr(h).exponent)}return r(Ui,{number:function(p){var m=Gr(p,l(t.relTol)),c=je(p,m,t.relTol,t.absTol)?m:p;return Gr(c)},"number, number":function(p,m){var c=l(t.relTol);if(m>=c)return Gr(p,m);var d=Gr(p,c),v=je(p,d,t.relTol,t.absTol)?d:p;return Gr(v,m)},"number, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError($r);return new o(p).toDecimalPlaces(m.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,m){if(m%1)throw new TypeError($r);return p.round(m)},"Complex, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError($r);var c=m.toNumber();return p.round(c)},BigNumber:function(p){var m=new o(p).toDecimalPlaces(l(t.relTol)),c=yr(p,m,t.relTol,t.absTol)?m:p;return c.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError($r);var c=l(t.relTol);if(m>=c)return p.toDecimalPlaces(m.toNumber());var d=p.toDecimalPlaces(c),v=yr(p,d,t.relTol,t.absTol)?d:p;return v.toDecimalPlaces(m.toNumber())},bigint:h=>h,"bigint, number":(h,p)=>h,"bigint, BigNumber":(h,p)=>h,Fraction:function(p){return p.round()},"Fraction, number":function(p,m){if(m%1)throw new TypeError($r);return p.round(m)},"Fraction, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError($r);return p.round(m.toNumber())},"Unit, number, Unit":r.referToSelf(h=>function(p,m,c){var d=p.toNumeric(c);return c.multiply(h(d,m))}),"Unit, BigNumber, Unit":r.referToSelf(h=>(p,m,c)=>h(p,m.toNumber(),c)),"Array | Matrix, number | BigNumber, Unit":r.referToSelf(h=>(p,m,c)=>Ve(p,d=>h(d,m,c),!0)),"Array | Matrix | Unit, Unit":r.referToSelf(h=>(p,m)=>h(p,0,m)),"Array | Matrix":r.referToSelf(h=>p=>Ve(p,h,!0)),"SparseMatrix, number | BigNumber":r.referToSelf(h=>(p,m)=>s(p,m,h,!1)),"DenseMatrix, number | BigNumber":r.referToSelf(h=>(p,m)=>D(p,m,h,!1)),"Array, number | BigNumber":r.referToSelf(h=>(p,m)=>D(n(p),m,h,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf(h=>(p,m)=>i(p,0)?u(m.size(),m.storage()):f(m,p,h,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf(h=>(p,m)=>i(p,0)?u(m.size(),m.storage()):D(m,p,h,!0)),"number | Complex | BigNumber | Fraction, Array":r.referToSelf(h=>(p,m)=>D(n(m),p,h,!0).valueOf())})}),bt="equal",Sf=["typed","matrix","equalScalar","DenseMatrix","SparseMatrix"],Mf=V(bt,Sf,e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=kr({typed:r}),s=Yr({typed:r,SparseMatrix:o}),f=zr({typed:r,DenseMatrix:i}),D=Or({typed:r,matrix:t});return r(bt,xf({typed:r,equalScalar:n}),D({elop:n,SS:s,DS:a,Ss:f}))}),xf=V(bt,["typed","equalScalar"],e=>{var{typed:r,equalScalar:t}=e;return r(bt,{"any, any":function(i,u){return i===null?u===null:u===null?i===null:i===void 0?u===void 0:u===void 0?i===void 0:t(i,u)}})}),Ct="smaller",Tf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],If=V(Ct,Tf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,s=kr({typed:r}),f=Yr({typed:r,SparseMatrix:a}),D=zr({typed:r,DenseMatrix:u}),l=Or({typed:r,matrix:i,concat:o}),h=Jr({typed:r});function p(m,c){return m.lt(c)&&!yr(m,c,t.relTol,t.absTol)}return r(Ct,zf({typed:r,config:t}),{"boolean, boolean":(m,c)=>m<c,"BigNumber, BigNumber":p,"bigint, bigint":(m,c)=>m<c,"Fraction, Fraction":(m,c)=>m.compare(c)===-1,"Fraction, BigNumber":function(c,d){return p(n(c),d)},"BigNumber, Fraction":function(c,d){return p(c,n(d))},"Complex, Complex":function(c,d){throw new TypeError("No ordering relation is defined for complex numbers")}},h,l({SS:f,DS:s,Ss:D}))}),zf=V(Ct,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ct,{"number, number":function(i,u){return i<u&&!je(i,u,t.relTol,t.absTol)}})}),_t="smallerEq",Of=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],$f=V(_t,Of,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=kr({typed:r}),s=Yr({typed:r,SparseMatrix:o}),f=zr({typed:r,DenseMatrix:i}),D=Or({typed:r,matrix:n,concat:u}),l=Jr({typed:r});return r(_t,Pf({typed:r,config:t}),{"boolean, boolean":(h,p)=>h<=p,"BigNumber, BigNumber":function(p,m){return p.lte(m)||yr(p,m,t.relTol,t.absTol)},"bigint, bigint":(h,p)=>h<=p,"Fraction, Fraction":(h,p)=>h.compare(p)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,D({SS:s,DS:a,Ss:f}))}),Pf=V(_t,["typed","config"],e=>{var{typed:r,config:t}=e;return r(_t,{"number, number":function(i,u){return i<=u||je(i,u,t.relTol,t.absTol)}})}),Bt="larger",qf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],Uf=V(Bt,qf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,s=kr({typed:r}),f=Yr({typed:r,SparseMatrix:a}),D=zr({typed:r,DenseMatrix:u}),l=Or({typed:r,matrix:i,concat:o}),h=Jr({typed:r});function p(m,c){return m.gt(c)&&!yr(m,c,t.relTol,t.absTol)}return r(Bt,Rf({typed:r,config:t}),{"boolean, boolean":(m,c)=>m>c,"BigNumber, BigNumber":p,"bigint, bigint":(m,c)=>m>c,"Fraction, Fraction":(m,c)=>m.compare(c)===1,"Fraction, BigNumber":function(c,d){return p(n(c),d)},"BigNumber, Fraction":function(c,d){return p(c,n(d))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,l({SS:f,DS:s,Ss:D}))}),Rf=V(Bt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Bt,{"number, number":function(i,u){return i>u&&!je(i,u,t.relTol,t.absTol)}})}),Nt="largerEq",Lf=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],Hf=V(Nt,Lf,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=kr({typed:r}),s=Yr({typed:r,SparseMatrix:o}),f=zr({typed:r,DenseMatrix:i}),D=Or({typed:r,matrix:n,concat:u}),l=Jr({typed:r});return r(Nt,Zf({typed:r,config:t}),{"boolean, boolean":(h,p)=>h>=p,"BigNumber, BigNumber":function(p,m){return p.gte(m)||yr(p,m,t.relTol,t.absTol)},"bigint, bigint":function(p,m){return p>=m},"Fraction, Fraction":(h,p)=>h.compare(p)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,D({SS:s,DS:a,Ss:f}))}),Zf=V(Nt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Nt,{"number, number":function(i,u){return i>=u||je(i,u,t.relTol,t.absTol)}})}),Wf="ImmutableDenseMatrix",Vf=["smaller","DenseMatrix"],Gf=V(Wf,Vf,e=>{var{smaller:r,DenseMatrix:t}=e;function n(i,u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(u&&!Me(u))throw new Error("Invalid datatype: "+u);if(we(i)||ve(i)){var o=new t(i,u);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(i&&ve(i.data)&&ve(i.size))this._data=i.data,this._size=i.size,this._datatype=i.datatype,this._min=typeof i.min<"u"?i.min:null,this._max=typeof i.max<"u"?i.max:null;else{if(i)throw new TypeError("Unsupported type of data ("+ur(i)+")");this._data=[],this._size=[0],this._datatype=u,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(i){switch(arguments.length){case 1:{var u=t.prototype.subset.call(this,i);return we(u)?new n({data:u._data,size:u._size,datatype:u._datatype}):u}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:me(this._data),size:me(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(i){return new n(i)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(this._min===null){var i=null;this.forEach(function(u){(i===null||r(u,i))&&(i=u)}),this._min=i!==null?i:void 0}return this._min},n.prototype.max=function(){if(this._max===null){var i=null;this.forEach(function(u){(i===null||r(i,u))&&(i=u)}),this._max=i!==null?i:void 0}return this._max},n},{isClass:!0}),Jf="Index",kf=["ImmutableDenseMatrix","getMatrixDataType"],Yf=V(Jf,kf,e=>{var{ImmutableDenseMatrix:r,getMatrixDataType:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var u=0,o=arguments.length;u<o;u++){var a=u<0||arguments.length<=u?void 0:arguments[u],s=ve(a),f=we(a),D=typeof a,l=null;if(wn(a))this._dimensions.push(a),this._isScalar=!1;else if(s||f){var h=void 0;this._isScalar=!1,t(a)==="boolean"?(s&&(h=i(Ri(a).valueOf())),f&&(h=i(Ri(a._data).valueOf())),l=a.valueOf().length):h=i(a.valueOf()),this._dimensions.push(h)}else if(D==="number")this._dimensions.push(a);else if(D==="bigint")this._dimensions.push(Number(a));else if(D==="string")this._dimensions.push(a);else throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._sourceSize.push(l)}}n.prototype.type="Index",n.prototype.isIndex=!0;function i(u){for(var o=0,a=u.length;o<a;o++)if(!ne(u[o])||!ye(u[o]))throw new TypeError("Index parameters must be positive integer numbers");var s=new r;return s._data=u,s._size=[u.length],s}return n.prototype.clone=function(){var u=new n;return u._dimensions=me(this._dimensions),u._isScalar=this._isScalar,u._sourceSize=this._sourceSize,u},n.create=function(u){var o=new n;return n.apply(o,u),o},n.prototype.size=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Me(s)||ne(s)?1:s.size()[0]}return u},n.prototype.max=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Me(s)||ne(s)?s:s.max()}return u},n.prototype.min=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Me(s)||ne(s)?s:s.min()}return u},n.prototype.forEach=function(u){for(var o=0,a=this._dimensions.length;o<a;o++)u(this._dimensions[o],o,this)},n.prototype.dimension=function(u){var o;return ne(u)&&(o=this._dimensions[u])!==null&&o!==void 0?o:null},n.prototype.isObjectProperty=function(){return this._dimensions.length===1&&Me(this._dimensions[0])},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u.push(Me(s)||ne(s)?s:s.toArray())}return u},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];Me(s)?u.push(JSON.stringify(s)):u.push(s.toString())}return"["+u.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(u){return n.create(u.dimensions)},n},{isClass:!0});function Ri(e){var r=[];return e.forEach((t,n)=>{t&&r.push(n)}),r}function Xf(e){var r=0,t=1,n=Object.create(null),i=Object.create(null),u=0,o=function(s){var f=i[s];if(f&&(delete n[f],delete i[s],--r,t===f)){if(!r){u=0,t=1;return}for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(s){var f=i[s],D=++u;if(n[D]=s,i[s]=D,!f)return++r,r<=e?void 0:(s=n[t],o(s),s);if(delete n[f],t===f)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=u=0,t=1,n=Object.create(null),i=Object.create(null)}}}function St(e){var{hasher:r,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,r=r??JSON.stringify,function n(){typeof n.cache!="object"&&(n.cache={values:new Map,lru:Xf(t||Number.POSITIVE_INFINITY)});for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];var o=r(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var a=e.apply(e,i);return n.cache.values.set(o,a),n.cache.values.delete(n.cache.lru.hit(o)),a}}St(function(e){return new e(1).exp()},{hasher:Mt}),St(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Mt});var Li=St(function(e){return e.acos(-1)},{hasher:Mt});St(function(e){return Li(e).times(2)},{hasher:Mt});function Mt(e){return e[0].precision}var Hi="add",Qf=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Kf=V(Hi,Qf,e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:u,SparseMatrix:o,concat:a}=e,s=Ts({typed:r}),f=Os({typed:r,equalScalar:i}),D=qs({typed:r,DenseMatrix:u}),l=Or({typed:r,matrix:t,concat:a});return r(Hi,{"any, any":n,"any, any, ...any":r.referToSelf(h=>(p,m,c)=>{for(var d=h(p,m),v=0;v<c.length;v++)d=h(d,c[v]);return d})},l({elop:n,DS:s,SS:f,Ss:D}))}),Zi="dot",jf=["typed","addScalar","multiplyScalar","conj","size"],ec=V(Zi,jf,e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:u}=e;return r(Zi,{"Array | DenseMatrix, Array | DenseMatrix":a,"SparseMatrix, SparseMatrix":s});function o(f,D){var l=u(f),h=u(D),p,m;if(l.length===1)p=l[0];else if(l.length===2&&l[1]===1)p=l[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+l.join(", ")+")");if(h.length===1)m=h[0];else if(h.length===2&&h[1]===1)m=h[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+h.join(", ")+")");if(p!==m)throw new RangeError("Vectors must have equal length ("+p+" != "+m+")");if(p===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return p}function a(f,D){var l=o(f,D),h=we(f)?f._data:f,p=we(f)?f._datatype||f.getDataType():void 0,m=we(D)?D._data:D,c=we(D)?D._datatype||D.getDataType():void 0,d=u(f).length===2,v=u(D).length===2,y=t,g=n;if(p&&c&&p===c&&typeof p=="string"&&p!=="mixed"){var A=p;y=r.find(t,[A,A]),g=r.find(n,[A,A])}if(!d&&!v){for(var F=g(i(h[0]),m[0]),w=1;w<l;w++)F=y(F,g(i(h[w]),m[w]));return F}if(!d&&v){for(var _=g(i(h[0]),m[0][0]),b=1;b<l;b++)_=y(_,g(i(h[b]),m[b][0]));return _}if(d&&!v){for(var B=g(i(h[0][0]),m[0]),S=1;S<l;S++)B=y(B,g(i(h[S][0]),m[S]));return B}if(d&&v){for(var x=g(i(h[0][0]),m[0][0]),O=1;O<l;O++)x=y(x,g(i(h[O][0]),m[O][0]));return x}}function s(f,D){o(f,D);for(var l=f._index,h=f._values,p=D._index,m=D._values,c=0,d=t,v=n,y=0,g=0;y<l.length&&g<p.length;){var A=l[y],F=p[g];if(A<F){y++;continue}if(A>F){g++;continue}A===F&&(c=d(c,v(h[y],m[g])),y++,g++)}return c}}),Wi="index",rc=["typed","Index"],tc=V(Wi,rc,e=>{var{typed:r,Index:t}=e;return r(Wi,{"...number | string | BigNumber | Range | Array | Matrix":function(i){var u=i.map(function(a){return Ee(a)?a.toNumber():ve(a)||we(a)?a.map(function(s){return Ee(s)?s.toNumber():s}):a}),o=new t;return t.apply(o,u),o}})}),Vi="det",nc=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],ic=V(Vi,nc,e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:u,isZero:o,unaryMinus:a}=e;return r(Vi,{any:function(D){return me(D)},"Array | Matrix":function(D){var l;switch(we(D)?l=D.size():Array.isArray(D)?(D=t(D),l=D.size()):l=[],l.length){case 0:return me(D);case 1:if(l[0]===1)return me(D.valueOf()[0]);if(l[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+_e(l)+")");case 2:{var h=l[0],p=l[1];if(h===p)return s(D.clone().valueOf(),h);if(p===0)return 1;throw new RangeError("Matrix must be square (size: "+_e(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+_e(l)+")")}}});function s(f,D,l){if(D===1)return me(f[0][0]);if(D===2)return n(i(f[0][0],f[1][1]),i(f[1][0],f[0][1]));for(var h=!1,p=new Array(D).fill(0).map((_,b)=>b),m=0;m<D;m++){var c=p[m];if(o(f[c][m])){var d=void 0;for(d=m+1;d<D;d++)if(!o(f[p[d]][m])){c=p[d],p[d]=p[m],p[m]=c,h=!h;break}if(d===D)return f[c][m]}for(var v=f[c][m],y=m===0?1:f[p[m-1]][m-1],g=m+1;g<D;g++)for(var A=p[g],F=m+1;F<D;F++)f[A][F]=u(n(i(f[A][F],v),i(f[A][m],f[c][F])),y)}var w=f[p[D-1]][D-1];return h?a(w):w}}),Gi="inv",uc=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],oc=V(Gi,uc,e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:u,unaryMinus:o,det:a,identity:s,abs:f}=e;return r(Gi,{"Array | Matrix":function(h){var p=we(h)?h.size():Oe(h);switch(p.length){case 1:if(p[0]===1)return we(h)?t([n(1,h.valueOf()[0])]):[n(1,h[0])];throw new RangeError("Matrix must be square (size: "+_e(p)+")");case 2:{var m=p[0],c=p[1];if(m===c)return we(h)?t(D(h.valueOf(),m,c),h.storage()):D(h,m,c);throw new RangeError("Matrix must be square (size: "+_e(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+_e(p)+")")}},any:function(h){return n(1,h)}});function D(l,h,p){var m,c,d,v,y;if(h===1){if(v=l[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,v)]]}else if(h===2){var g=a(l);if(g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(l[1][1],g),n(o(l[0][1]),g)],[n(o(l[1][0]),g),n(l[0][0],g)]]}else{var A=l.concat();for(m=0;m<h;m++)A[m]=A[m].concat();for(var F=s(h).valueOf(),w=0;w<p;w++){var _=f(A[w][w]),b=w;for(m=w+1;m<h;)f(A[m][w])>_&&(_=f(A[m][w]),b=m),m++;if(_===0)throw Error("Cannot calculate inverse, determinant is zero");m=b,m!==w&&(y=A[w],A[w]=A[m],A[m]=y,y=F[w],F[w]=F[m],F[m]=y);var B=A[w],S=F[w];for(m=0;m<h;m++){var x=A[m],O=F[m];if(m!==w){if(x[w]!==0){for(d=n(o(x[w]),B[w]),c=w;c<p;c++)x[c]=i(x[c],u(d,B[c]));for(c=0;c<p;c++)O[c]=i(O[c],u(d,S[c]))}}else{for(d=B[w],c=w;c<p;c++)x[c]=n(x[c],d);for(c=0;c<p;c++)O[c]=n(O[c],d)}}}return F}}}),ac=sc("pi",["config","?BigNumber"],e=>{var{config:r,BigNumber:t}=e;return r.number==="BigNumber"?Li(t):za});function sc(e,r,t){return V(e,r,t,{recreateOnConfigChange:!0})}var Pr=ea({config:Pe}),xt=ua({}),Ji=ha({}),on=Da({}),tr=xa({Matrix:on,config:Pe}),Xr=ac({BigNumber:Pr,config:Pe}),te=to({BigNumber:Pr,Complex:xt,DenseMatrix:tr,Fraction:Ji}),Tt=ls({typed:te}),It=ps({typed:te}),an=Qs({typed:te}),zt=ts({Complex:xt,typed:te}),fc=js({typed:te}),qr=Ha({config:Pe,typed:te}),cc=nf({typed:te}),ki=Hs({Complex:xt,config:Pe,typed:te}),Yi=Vs({typed:te}),Xi=Xa({typed:te}),lc=hf({typed:te}),Fr=Va({Matrix:on,equalScalar:qr,typed:te}),hc=Ds({typed:te}),Ot=ja({BigNumber:Pr,typed:te}),pc=ec({addScalar:It,conj:fc,multiplyScalar:Yi,size:lc,typed:te}),Qi=Ua({equalScalar:qr,typed:te}),Re=as({DenseMatrix:tr,Matrix:on,SparseMatrix:Fr,typed:te}),Cr=Js({addScalar:It,dot:pc,equalScalar:qr,matrix:Re,multiplyScalar:Yi,typed:te}),Ki=wf({BigNumber:Pr,config:Pe,matrix:Re,typed:te}),ji=Mf({DenseMatrix:tr,SparseMatrix:Fr,equalScalar:qr,matrix:Re,typed:te}),eu=us({Fraction:Ji,typed:te}),ru=of({BigNumber:Pr,DenseMatrix:tr,SparseMatrix:Fr,config:Pe,matrix:Re,typed:te}),mc=Ia({equal:ji,typed:te}),Dc=Ef({bignumber:Ot,fraction:eu,number:Xi}),sn=Nf({BigNumber:Pr,DenseMatrix:tr,config:Pe,equalScalar:qr,matrix:Re,typed:te,zeros:Ki}),tu=fs({typed:te}),Qr=rf({isInteger:mc,matrix:Re,typed:te}),nu=bf({numeric:Dc,typed:te}),dc=Pa({config:Pe,typed:te}),gc=Uf({DenseMatrix:tr,SparseMatrix:Fr,bignumber:Ot,concat:Qr,config:Pe,matrix:Re,typed:te}),iu=If({DenseMatrix:tr,SparseMatrix:Fr,bignumber:Ot,concat:Qr,config:Pe,matrix:Re,typed:te}),Kr=Kf({DenseMatrix:tr,SparseMatrix:Fr,addScalar:It,concat:Qr,equalScalar:qr,matrix:Re,typed:te}),vc=ic({divideScalar:nu,isZero:Qi,matrix:Re,multiply:Cr,subtractScalar:hc,typed:te,unaryMinus:tu}),wc=Gf({DenseMatrix:tr,smaller:iu}),yc=Yf({ImmutableDenseMatrix:wc,getMatrixDataType:cc}),Fc=Hf({DenseMatrix:tr,SparseMatrix:Fr,concat:Qr,config:Pe,matrix:Re,typed:te}),$t=mf({add:Kr,matrix:Re,typed:te,zeros:Ki}),Pt=tc({Index:yc,typed:te}),Ec=oc({abs:Tt,addScalar:It,det:vc,divideScalar:nu,identity:ru,matrix:Re,multiply:Cr,typed:te,unaryMinus:tu}),uu=_f({Complex:xt,config:Pe,fraction:eu,identity:ru,inv:Ec,matrix:Re,multiply:Cr,number:Xi,typed:te}),Ac=$f({DenseMatrix:tr,SparseMatrix:Fr,concat:Qr,config:Pe,matrix:Re,typed:te}),qt=cf({bignumber:Ot,matrix:Re,add:Kr,config:Pe,equal:ji,isPositive:dc,isZero:Qi,larger:gc,largerEq:Fc,smaller:iu,smallerEq:Ac,typed:te});const bc=["Hz","kHz","MHz","GHz"],fn=299792458,cr={Hz:1,kHz:1e3,MHz:1e6,GHz:1e9,THz:1e12},cn={m:1,cm:.01,mm:.001,um:1e-6,nm:1e-9};class ou{_unit="Hz";set unit(r){if(typeof r!="string")throw new Error(`Unknown frequency unit: ${r}`);const t=this._unit;let n;switch(r.toLowerCase()){case"hz":n="Hz";break;case"khz":n="kHz";break;case"mhz":n="MHz";break;case"ghz":n="GHz";break;default:throw new Error(`Unknown frequency unit: ${r}`)}if(n!==t&&this.f_scaled&&this.f_scaled.length>0){const i=cr[t],u=cr[n];if(i&&u)this.f_scaled=this.f_scaled.map(o=>o*i/u);else throw new Error(`Could not find frequency multipliers (old: ${i}, new: ${u}) for unit conversion`)}this._unit=n}get unit(){return this._unit}_f_scaled=[];set f_scaled(r){if(!Array.isArray(r))throw new Error("Frequency value must be an array");for(const t of r){if(typeof t!="number")throw new Error(`Frequency value must be an array of numbers, but received: ${t}`);if(t<0)throw new Error(`Frequency values cannot be negative, but received: ${t}`)}this._f_scaled=r}get f_scaled(){return this._f_scaled}_getFrequencyInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=cr[this.unit];if(!t)throw new Error(`Multiplier for current unit ${this.unit} not found.`);const n=cr[r];if(!n)throw new Error(`Multiplier for target unit ${r} not found.`);return this.f_scaled.map(i=>i*t/n)}_setFrequencyFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=cr[t];if(!n)throw new Error(`Multiplier for source unit ${t} not found.`);const i=cr[this.unit];if(!i)throw new Error(`Multiplier for current internal unit ${this.unit} not found.`);const u=r.map(o=>o*n/i);this.f_scaled=u}get f_Hz(){return this._getFrequencyInTargetUnit("Hz")}set f_Hz(r){this._setFrequencyFromTargetUnit(r,"Hz")}get f_kHz(){return this._getFrequencyInTargetUnit("kHz")}set f_kHz(r){this._setFrequencyFromTargetUnit(r,"kHz")}get f_MHz(){return this._getFrequencyInTargetUnit("MHz")}set f_MHz(r){this._setFrequencyFromTargetUnit(r,"MHz")}get f_GHz(){return this._getFrequencyInTargetUnit("GHz")}set f_GHz(r){this._setFrequencyFromTargetUnit(r,"GHz")}get f_THz(){return this._getFrequencyInTargetUnit("THz")}set f_THz(r){this._setFrequencyFromTargetUnit(r,"THz")}_getWavelengthInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=cr[this.unit];if(!t)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const n=cn[r];if(!n)throw new Error(`Wavelength multiplier to meters for target wavelength unit ${r} not found.`);return this.f_scaled.map(i=>{const u=i*t;return u===0?1/0:fn/u/n})}_setWavelengthFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=cn[t];if(!n)throw new Error(`Wavelength multiplier to meters for source unit ${t} not found.`);const i=cr[this.unit];if(!i)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const u=r.map(o=>{const a=o*n;if(a===0)throw new Error("Cannot convert zero wavelength to frequency.");return fn/a/i});this.f_scaled=u}get wavelength_m(){return this._getWavelengthInTargetUnit("m")}set wavelength_m(r){this._setWavelengthFromTargetUnit(r,"m")}get wavelength_cm(){return this._getWavelengthInTargetUnit("cm")}set wavelength_cm(r){this._setWavelengthFromTargetUnit(r,"cm")}get wavelength_mm(){return this._getWavelengthInTargetUnit("mm")}set wavelength_mm(r){this._setWavelengthFromTargetUnit(r,"mm")}get wavelength_um(){return this._getWavelengthInTargetUnit("um")}set wavelength_um(r){this._setWavelengthFromTargetUnit(r,"um")}get wavelength_nm(){return this._getWavelengthInTargetUnit("nm")}set wavelength_nm(r){this._setWavelengthFromTargetUnit(r,"nm")}}const Cc=["RI","MA","DB"],_c=["S","Y","Z","G","H"];class ln{static getFilename(r){let t;try{t=new URL(r).pathname.split(/[/\\]/).pop()}catch{t=r.split(/[/\\]/).pop()}if(!t)throw new Error(`Could not determine filename from: ${r}`);return t}static parsePorts(r){const t=r.match(/\.s(\d+)p$/i);return t&&t[1]?parseInt(t[1],10):null}static fromText(r,t){const n=new ln;return n.readContent(r,t),n}static async fromUrl(r,t){const n=await fetch(r);if(!n.ok)throw new Error(`Failed to fetch file: ${n.statusText}`);const i=await n.text();let u=t??null;if(u===null){const o=this.getFilename(r);u=this.parsePorts(o)}if(u===null)throw new Error(`Could not determine number of ports from URL: ${r}. Please provide nports manually.`);return this.fromText(i,u)}static fromFile(r,t){return new Promise((n,i)=>{let u=t??null;if(u===null&&(u=this.parsePorts(r.name)),u===null)return i(new Error(`Could not determine number of ports from file name: ${r.name}`));const o=new FileReader;o.onload=a=>{try{const s=a.target?.result;if(!s){i(new Error("File content is empty"));return}n(this.fromText(s,u))}catch(s){i(s)}},o.onerror=()=>{i(new Error(`Failed to read file: ${r.name}`))},o.readAsText(r)})}comments=[];_format;set format(r){if(r==null){this._format=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone format: ${r}`);switch(r.toLowerCase()){case"ma":this._format="MA";break;case"db":this._format="DB";break;case"ri":this._format="RI";break;default:throw new Error(`Unknown Touchstone format: ${r}`)}}get format(){return this._format}_parameter;set parameter(r){if(r==null){this._parameter=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone parameter: ${r}`);switch(r.toLowerCase()){case"s":this._parameter="S";break;case"y":this._parameter="Y";break;case"z":this._parameter="Z";break;case"g":this._parameter="G";break;case"h":this._parameter="H";break;default:throw new Error(`Unknown Touchstone parameter: ${r}`)}}get parameter(){return this._parameter}_impedance=50;set impedance(r){if(typeof r=="number"){this._impedance=r;return}if(!Array.isArray(r)||r.length===0)throw new Error(`Unknown Touchstone impedance: ${r}`);for(const t of r)if(typeof t!="number")throw new Error(`Unknown Touchstone impedance: ${r}`);this._impedance=r}get impedance(){return this._impedance}_nports;set nports(r){if(r==null){this._nports=void 0;return}if(typeof r!="number")throw new Error(`Unknown ports number: ${r}`);if(!Number.isInteger(r))throw new Error(`Unknown ports number: ${r}`);if(r<1)throw new Error(`Unknown ports number: ${r}`);this._nports=r}get nports(){return this._nports}frequency;_matrix;set matrix(r){if(r==null){this._matrix=void 0;return}this._matrix=r}get matrix(){return this._matrix}readContent(r,t){this.nports=t;const n=r.split(`
|
|
12
|
+
`).map(l=>l.trim()).filter(l=>l!=="");this.comments=n.filter(l=>l.startsWith("!")).map(l=>l.slice(1).trim()),this.frequency=new ou;const i=n.filter(l=>l.startsWith("#"));if(i.length===0)throw new Error('Unable to find the option line starting with "#"');if(i.length>1)throw new Error(`Only one option line starting with "#" is supported, but found ${i.length} lines`);const u=i[0].slice(1).trim().split(/\s+/);if(this.frequency.unit=u[0],this.parameter=u[1],this.format=u[2],u.length>=4){if(u[3].toLowerCase()!=="r")throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);const l=u.slice(4).map(h=>parseFloat(h));if(l.length===0||l.some(Number.isNaN))throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);if(l.length===1)this.impedance=l[0];else if(l.length===this.nports)this.impedance=l;else throw new Error(`${this.nports}-ports network, but find ${l.length} impedances: [${l}]`)}const a=n.filter(l=>!l.startsWith("!")&&!l.startsWith("#")).map(l=>{const h=l.indexOf("!");return h!==-1?l.substring(0,h).trim():l.trim()}).join(" ").split(/\s+/).map(l=>parseFloat(l)),s=2*Math.pow(this.nports,2)+1;if(a.length%s!==0)throw new Error(`Touchstone invalid data number: ${a.length}, which should be multiple of ${s}`);const f=a.length/s,D=$t(a,Pt(Cr(qt(0,f),s)));if(Array.isArray(D))this.frequency.f_scaled=D;else if(typeof D=="number")this.frequency.f_scaled=[D];else throw new Error(`Unexpected frequency f_scaled type: ${typeof D}, and its value: ${D}`);this.matrix=new Array(t);for(let l=0;l<t;l++){this.matrix[l]=new Array(t);for(let h=0;h<t;h++)this.matrix[l][h]=new Array(f)}for(let l=0;l<t;l++)for(let h=0;h<t;h++){const p=$t(a,Pt(Kr(Cr(qt(0,f),s),(l*t+h)*2+1))),m=$t(a,Pt(Kr(Cr(qt(0,f),s),(l*t+h)*2+2)));for(let c=0;c<f;c++){let d;switch(this.format){case"RI":d=zt(p[c],m[c]);break;case"MA":d=zt({r:p[c],phi:m[c]/180*Xr});break;case"DB":d=zt({r:uu(10,p[c]/20),phi:m[c]/180*Xr});break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}t===2?this.matrix[h][l][c]=d:this.matrix[l][h][c]=d}}}validate(){if(!this.nports)throw new Error("Number of ports (nports) is not defined");if(!this.frequency)throw new Error("Frequency object is not defined");if(this.frequency.f_scaled.length===0)throw new Error("Frequency points array is empty");if(!this.parameter)throw new Error("Network parameter type is not defined");if(!this.format)throw new Error("Data format (RI/MA/DB) is not defined");if(!this.matrix)throw new Error("Network parameter matrix is not defined");const r=this.frequency.f_scaled.length;if(this.matrix.length!==this.nports)throw new Error(`Touchstone matrix has ${this.matrix.length} rows, but expected ${this.nports}`);for(let t=0;t<this.nports;t++){if(this.matrix[t].length!==this.nports)throw new Error(`Touchstone matrix at row index ${t} has ${this.matrix[t].length} columns, but expected ${this.nports}`);for(let n=0;n<this.nports;n++)if(this.matrix[t][n].length!==r)throw new Error(`Touchstone matrix at row ${t}, column ${n} has ${this.matrix[t][n].length} points, but expected ${r}`)}}writeContent(){this.validate();const r=this.frequency.f_scaled.length,t=[];this.comments.length>0&&t.push(...this.comments.map(i=>`! ${i}`));let n=`# ${this.frequency.unit} ${this.parameter} ${this.format}`;Array.isArray(this.impedance)?n+=` R ${this.impedance.join(" ")}`:n+=` R ${this.impedance}`,t.push(n);for(let i=0;i<r;i++){const u=[this.frequency.f_scaled[i].toString()];for(let o=0;o<this.nports;o++)for(let a=0;a<this.nports;a++){const s=this.nports===2?this.matrix[a][o][i]:this.matrix[o][a][i];let f,D;switch(this.format){case"RI":f=s.re,D=s.im;break;case"MA":f=Tt(s),D=an(s)/Xr*180;break;case"DB":f=20*ki(Tt(s)),D=an(s)/Xr*180;break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}u.push(sn(f,12).toString(),sn(D,12).toString())}t.push(u.join(" "))}return t.push(""),t.join(`
|
|
13
|
+
`)}}const Bc=zt,Nc=qt;ge.FREQUENCY_MULTIPLIERS=cr,ge.Frequency=ou,ge.FrequencyUnits=bc,ge.SPEED_OF_LIGHT=fn,ge.Touchstone=ln,ge.TouchstoneFormats=Cc,ge.TouchstoneParameters=_c,ge.WAVELENGTH_MULTIPLIERS_TO_M=cn,ge.abs=Tt,ge.add=Kr,ge.arg=an,ge.complex=Bc,ge.index=Pt,ge.log10=ki,ge.multiply=Cr,ge.pi=Xr,ge.pow=uu,ge.range=Nc,ge.round=sn,ge.subset=$t,Object.defineProperty(ge,Symbol.toStringTag,{value:"Module"})}));
|