mirror of
https://github.com/heyman/heynote.git
synced 2026-02-06 11:27:25 +00:00
3 lines
620 KiB
JavaScript
3 lines
620 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.math=t():e.math=t()}(this,()=>{var r={31:function(e,r,n){var o;!function(e){function i(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,e===((t.v=0)|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=0|r.charCodeAt(n),n==r.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function t(e,t){function r(){return(n.next()>>>0)/4294967296}var n=new i(e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&("object"==typeof e&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0!==(o=function(){return t}.call(r,n,r,e))&&(e.exports=o):this.xorwow=t}(e=n.nmd(e),n.amdD)},67:function(e,r,n){var o;!function(e){function i(e){var t,i=this,r=(i.next=function(){var e=i.x,t=i.i,r=e[t],n=(r^=r>>>7)^r<<24;return n=(n=(n^=(r=e[t+1&7])^r>>>10)^((r=e[t+3&7])^r>>>3))^((r=e[t+4&7])^r<<7),r=e[t+7&7],n^=(r^=r<<13)^r<<9,e[t]=n,i.i=t+1&7,n},i),n=e,a=[];if(n===(0|n))a[0]=n;else for(n=""+n,t=0;t<n.length;++t)a[7&t]=a[7&t]<<15^n.charCodeAt(t)+a[t+1&7]<<13;for(;a.length<8;)a.push(0);for(t=0;t<8&&0===a[t];++t);for(8==t?a[7]=-1:a[t],r.x=a,r.i=0,t=256;0<t;--t)r.next()}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function t(e,t){function r(){return(n.next()>>>0)/4294967296}var n=new i(e=null==e?+new Date:e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&(e.x&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0!==(o=function(){return t}.call(r,n,r,e))&&(e.exports=o):this.xorshift7=t}(e=n.nmd(e),n.amdD)},144:e=>{"use strict";function s(e,t){return u({},e,t)}var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},c={"–":"\\--","—":"\\---"," ":"~","\t":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"};e.exports=function(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=t.preserveFormatting,r=void 0!==r&&r,t=t.escapeMapFn,t=void 0===t?s:t,n=String(e),i="",a=t(u({},l),r?u({},c):{}),o=Object.keys(a);n;)!function(){var r=!1;o.forEach(function(e,t){r||n.length>=e.length&&n.slice(0,e.length)===e&&(i+=a[o[t]],n=n.slice(e.length,n.length),r=!0)}),r||(i+=n.slice(0,1),n=n.slice(1,n.length))}();return i}},180:function(e,r,n){var o;!function(e){function i(e){var n,t=this,r=(n=4022871197,function(e){e=String(e);for(var t=0;t<e.length;t++){var r=.02519603282416938*(n+=e.charCodeAt(t));n=(r=(r-=n=r>>>0)*n)>>>0,n+=4294967296*(r-=n)}return 2.3283064365386963e-10*(n>>>0)});t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=r(" "),t.s1=r(" "),t.s2=r(" "),t.s0-=r(e),t.s0<0&&(t.s0+=1),t.s1-=r(e),t.s1<0&&(t.s1+=1),t.s2-=r(e),t.s2<0&&(t.s2+=1)}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function t(e,t){var r=new i(e),e=t&&t.state,n=r.next;return n.int32=function(){return 4294967296*r.next()|0},n.double=function(){return n()+11102230246251565e-32*(2097152*n()|0)},n.quick=n,e&&("object"==typeof e&&a(e,r),n.state=function(){return a(r,{})}),n}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0!==(o=function(){return t}.call(r,n,r,e))&&(e.exports=o):this.alea=t}(e=n.nmd(e),n.amdD)},181:function(e,r,n){var o;!function(e){function i(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=0|r.charCodeAt(n),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function t(e,t){function r(){return(n.next()>>>0)/4294967296}var n=new i(e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&("object"==typeof e&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0!==(o=function(){return t}.call(r,n,r,e))&&(e.exports=o):this.xor128=t}(e=n.nmd(e),n.amdD)},234:()=>{},369:function(e){e.exports=function(){"use strict";function T(){return!0}function ce(){return!1}function fe(){}const B="Argument is not a typed-function.";return function e(){function c(e){return"object"==typeof e&&null!==e&&e.constructor===Object}const t=[{name:"number",test:function(e){return"number"==typeof e}},{name:"string",test:function(e){return"string"==typeof e}},{name:"boolean",test:function(e){return"boolean"==typeof e}},{name:"Function",test:function(e){return"function"==typeof e}},{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:c},{name:"null",test:function(e){return null===e}},{name:"undefined",test:function(e){return void 0===e}}],r={name:"any",test:T,isAny:!0};let a,o,i=0,J={createCount:0};function s(e){var t=a.get(e);if(t)return t;let r='Unknown type "'+e+'"';var n=e.toLowerCase();let i;for(i of o)if(i.toLowerCase()===n){r+='. Did you mean "'+i+'" ?';break}throw new TypeError(r)}function n(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"any";const r=e?s(e).index:o.length,n=[];for(let e=0;e<t.length;++e){if(!t[e]||"string"!=typeof t[e].name||"function"!=typeof t[e].test)throw new TypeError("Object with properties {name: string, test: function} expected");const i=t[e].name;if(a.has(i))throw new TypeError('Duplicate type name "'+i+'"');n.push(i),a.set(i,{name:i,test:t[e].test,isAny:t[e].isAny,index:r+e,conversionsTo:[]})}const i=o.slice(r);o=o.slice(0,r).concat(n).concat(i);for(let e=r+n.length;e<o.length;++e)a.get(o[e]).index=e}function u(){a=new Map,o=[],i=0,n([r],!1)}function l(r){var e=o.filter(e=>{const t=a.get(e);return!t.isAny&&t.test(r)});return e.length?e:["any"]}function f(e){return e&&"function"==typeof e&&"_typedFunctionData"in e}function p(r,n,i){if(!f(r))throw new TypeError(B);const a=i&&i.exact,o=Q(Array.isArray(n)?n.join(","):n),e=X(o);if(!a||e in r.signatures){const n=r._typedFunctionData.signatureMap.get(e);if(n)return n}var s=o.length;let u,t;if(a){let e;for(e in u=[],r.signatures)u.push(r._typedFunctionData.signatureMap.get(e))}else u=r._typedFunctionData.signatures;for(let t=0;t<s;++t){const n=o[t],i=[];let e;for(e of u){const a=h(e.params,t);if(a&&(!n.restParam||a.restParam)){if(!a.hasAny){const r=m(a);if(n.types.some(e=>!r.has(e.name)))continue}i.push(e)}}if(0===(u=i).length)break}for(t of u)if(t.params.length<=s)return t;throw new TypeError("Signature not found (signature: "+(r.name||"unnamed")+"("+X(o,", ")+"))")}function X(e,t){t=1<arguments.length&&void 0!==t?t:",";return e.map(e=>e.name).join(t)}function oe(e){const t=function(e){if(0===e.length)return[];const r=e.map(s);1<e.length&&r.sort((e,t)=>e.index-t.index);let n=r[0].conversionsTo;if(1===e.length)return n;n=n.concat([]);const i=new Set(e);for(let t=1;t<r.length;++t){let e;for(e of r[t].conversionsTo)i.has(e.from)||(n.push(e),i.add(e.from))}return n}(e.types.map(e=>e.name));let r=e.hasAny,n=e.name;var i=t.map(function(e){var t=s(e.from);return r=t.isAny||r,n+="|"+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}});return{types:e.types.concat(i),name:n,hasAny:r,hasConversion:0<i.length,restParam:e.restParam}}function m(t){return t.typeSet||(t.typeSet=new Set,t.types.forEach(e=>t.typeSet.add(e.name))),t.typeSet}function Q(e){const t=[];if("string"!=typeof e)throw new TypeError("Signatures must be strings");const r=e.trim();if(""===r)return t;const n=r.split(",");for(let e=0;e<n.length;++e){const r=function(e){const t=0===e.indexOf("..."),r=(t?3<e.length?e.slice(3):"any":e).split("|").map(e=>s(e.trim()));let n=!1,i=t?"...":"";return{types:r.map(function(e){return n=e.isAny||n,i+=e.name+"|",{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}}),name:i.slice(0,-1),hasAny:n,hasConversion:!1,restParam:t}}(n[e].trim());if(r.restParam&&e!==n.length-1)throw new SyntaxError('Unexpected rest parameter "'+n[e]+'": only allowed for the last parameter');if(0===r.types.length)return null;t.push(r)}return t}function K(e){e=ie(e);return!!e&&e.restParam}function ee(e){if(e&&0!==e.types.length){if(1===e.types.length)return s(e.types[0].name).test;if(2===e.types.length){const T=s(e.types[0].name).test,t=s(e.types[1].name).test;return function(e){return T(e)||t(e)}}{const T=e.types.map(function(e){return s(e.name).test});return function(t){for(let e=0;e<T.length;e++)if(T[e](t))return!0;return!1}}}return T}function h(e,t){return t<e.length?e[t]:K(e)?ie(e):null}function te(e,t){e=h(e,t);return e?m(e):new Set}function re(e){return null===e.conversion||void 0===e.conversion}function d(e,r){const n=new Set;return e.forEach(e=>{let t;for(t of te(e.params,r))n.add(t)}),n.has("any")?["any"]:Array.from(n)}function g(r,n,e){let t,i;var a=r||"unnamed";let o,s=e;for(o=0;o<n.length;o++){const r=[];if(s.forEach(e=>{const t=ee(h(e.params,o));(o<e.params.length||K(e.params))&&t(n[o])&&r.push(e)}),0===r.length){if(0<(i=d(s,o)).length){const r=l(n[o]);return(t=new TypeError("Unexpected type of argument in function "+a+" (expected: "+i.join(" or ")+", actual: "+r.join(" | ")+", index: "+o+")")).data={category:"wrongType",fn:a,index:o,actual:r,expected:i},t}}else s=r}r=s.map(function(e){return K(e.params)?1/0:e.params.length});if(n.length<Math.min.apply(null,r))return i=d(s,o),(t=new TypeError("Too few arguments in function "+a+" (expected: "+i.join(" or ")+", index: "+n.length+")")).data={category:"tooFewArgs",fn:a,index:n.length,expected:i},t;e=Math.max.apply(null,r);if(n.length>e)return(t=new TypeError("Too many arguments in function "+a+" (expected: "+e+", actual: "+n.length+")")).data={category:"tooManyArgs",fn:a,index:n.length,expectedLength:e},t;const u=[];for(let e=0;e<n.length;++e)u.push(l(n[e]).join("|"));return(t=new TypeError('Arguments of type "'+u.join(", ")+'" do not match any of the defined signatures of function '+a+".")).data={category:"mismatch",actual:u},t}function y(t){let r=o.length+1;for(let e=0;e<t.types.length;e++)re(t.types[e])&&(r=Math.min(r,t.types[e].typeIndex));return r}function x(t){let r=i+1;for(let e=0;e<t.types.length;e++)re(t.types[e])||(r=Math.min(r,t.types[e].conversionIndex));return r}function se(e,t){var r=e.params,n=t.params,e=ie(r),t=ie(n),i=K(r),a=K(n);if(i&&e.hasAny){if(!a||!t.hasAny)return 1}else if(a&&t.hasAny)return-1;let o,s=0,u=0;for(o of r)o.hasAny&&++s,o.hasConversion&&++u;let l=0,c=0;for(o of n)o.hasAny&&++l,o.hasConversion&&++c;if(s!==l)return s-l;if(i&&e.hasConversion){if(!a||!t.hasConversion)return 1}else if(a&&t.hasConversion)return-1;if(u!==c)return u-c;if(i){if(!a)return 1}else if(a)return-1;e=(r.length-n.length)*(i?-1:1);if(0!=e)return e;const f=[];let p,m=0;for(let e=0;e<r.length;++e){const t=function(e,t){if(e.hasAny){if(!t.hasAny)return 1}else if(t.hasAny)return-1;if(e.restParam){if(!t.restParam)return 1}else if(t.restParam)return-1;if(e.hasConversion){if(!t.hasConversion)return 1}else if(t.hasConversion)return-1;var r=y(e)-y(t);return r<0?-1:0<r?1:(r=x(e)-x(t))<0?-1:0<r?1:0}(r[e],n[e]);f.push(t),m+=t}if(0!==m)return m;for(p of f)if(0!==p)return p;return 0}function ue(e){let t,r,n,i;const a=[],o=[];switch(e.types.forEach(function(e){e.conversion&&(a.push(s(e.conversion.from).test),o.push(e.conversion.convert))}),o.length){case 0:return function(e){return e};case 1:return t=a[0],n=o[0],function(e){return t(e)?n(e):e};case 2:return t=a[0],r=a[1],n=o[0],i=o[1],function(e){return t(e)?n(e):r(e)?i(e):e};default:return function(t){for(let e=0;e<o.length;e++)if(a[e](t))return o[e](t);return t}}}function le(e,r,n){const i=e.map(e=>A(e)?w(e.referToSelf.callback):N(e)?v(e.referTo.references,e.referTo.callback):e),a=new Array(i.length).fill(!1);let o=!0;for(;o;){let t=!(o=!1);for(let e=0;e<i.length;++e)if(!a[e]){const s=i[e];if(A(s))i[e]=s.referToSelf.callback(n),i[e].referToSelf=s.referToSelf,a[e]=!0,t=!1;else if(N(s)){const n=function(e,t,r){const n=[];let i;for(i of e){var a=r[i];if("number"!=typeof a)throw new TypeError('No definition for referenced signature "'+i+'"');if("function"!=typeof(a=t[a]))return!1;n.push(a)}return n}(s.referTo.references,i,r);n?(i[e]=s.referTo.callback.apply(this,n),i[e].referTo=s.referTo,a[e]=!0,t=!1):o=!0}}if(t&&o)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return i}function M(t,r){if(J.createCount++,0===Object.keys(r).length)throw new SyntaxError("No signatures provided");if(J.warnAgainstDeprecatedThis){var n=r;const q=/\bthis(\(|\.signatures\b)/;Object.keys(n).forEach(e=>{const t=n[e];if(q.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.")})}const i=[],a=[],o={},s=[];let u;for(u in r)if(Object.prototype.hasOwnProperty.call(r,u)){const t=Q(u);if(t){i.forEach(function(e){if(function(n,i){const a=Math.max(n.length,i.length);for(let r=0;r<a;r++){const a=te(n,r),o=te(i,r);let e,t=!1;for(e of o)if(a.has(e)){t=!0;break}if(!t)return}const e=n.length,o=i.length,t=K(n),r=K(i);return t?r?e===o:o>=e:r?e>=o:e===o}(e,t))throw new TypeError('Conflicting signatures "'+X(e)+'" and "'+X(t)+'".')}),i.push(t);const ce=a.length,fe=(a.push(r[u]),t.map(oe));let e;for(e of function t(r,n,i){if(n<r.length){const o=r[n];let e=[];if(o.restParam){const t=o.types.filter(re);t.length<o.types.length&&e.push({types:t,name:"..."+t.map(e=>e.name).join("|"),hasAny:t.some(e=>e.isAny),hasConversion:!1,restParam:!0}),e.push(o)}else e=o.types.map(function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}});return a=e,Array.prototype.concat.apply([],a.map(function(e){return t(r,n+1,i.concat([e]))}))}var a;return[i]}(fe,0,[])){const t=X(e);s.push({params:e,name:t,fn:ce}),e.every(e=>!e.hasConversion)&&(o[t]=ce)}}}s.sort(se);var e=le(a,o,z);let l;for(l in o)Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=e[o[l]]);const c=[],f=new Map;for(l of s)f.has(l.name)||(l.fn=e[l.fn],c.push(l),f.set(l.name,l));var p=c[0]&&c[0].params.length<=2&&!K(c[0].params),m=c[1]&&c[1].params.length<=2&&!K(c[1].params),h=c[2]&&c[2].params.length<=2&&!K(c[2].params),d=c[3]&&c[3].params.length<=2&&!K(c[3].params),g=c[4]&&c[4].params.length<=2&&!K(c[4].params),y=c[5]&&c[5].params.length<=2&&!K(c[5].params),x=p&&m&&h&&d&&g&&y;for(let e=0;e<c.length;++e)c[e].test=function(e){let r,n,i;if(K(e)){const n=(r=ne(e).map(ee)).length,i=ee(ie(e)),a=function(t){for(let e=n;e<t.length;e++)if(!i(t[e]))return!1;return!0};return function(t){for(let e=0;e<r.length;e++)if(!r[e](t[e]))return!1;return a(t)&&t.length>=n+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(n=ee(e[0]),function(e){return n(e[0])&&1===e.length}):2===e.length?(n=ee(e[0]),i=ee(e[1]),function(e){return n(e[0])&&i(e[1])&&2===e.length}):(r=e.map(ee),function(t){for(let e=0;e<r.length;e++)if(!r[e](t[e]))return!1;return t.length===r.length})}(c[e].params);const b=p?ee(c[0].params[0]):ce,v=m?ee(c[1].params[0]):ce,w=h?ee(c[2].params[0]):ce,N=d?ee(c[3].params[0]):ce,A=g?ee(c[4].params[0]):ce,E=y?ee(c[5].params[0]):ce,S=p?ee(c[0].params[1]):ce,M=m?ee(c[1].params[1]):ce,C=h?ee(c[2].params[1]):ce,T=d?ee(c[3].params[1]):ce,B=g?ee(c[4].params[1]):ce,F=y?ee(c[5].params[1]):ce;for(let e=0;e<c.length;++e)c[e].implementation=function(e,n){let t=n;if(e.some(e=>e.hasConversion)){const i=K(e),a=e.map(ue);t=function(){const t=[],r=i?arguments.length-1:arguments.length;for(let e=0;e<r;e++)t[e]=a[e](arguments[e]);return i&&(t[r]=arguments[r].map(a[r])),n.apply(this,t)}}let i=t;if(K(e)){const n=e.length-1;i=function(){return t.apply(this,ae(arguments,0,n).concat([ae(arguments,n)]))}}return i}(c[e].params,c[e].fn);const D=p?c[0].implementation:fe,O=m?c[1].implementation:fe,_=h?c[2].implementation:fe,I=d?c[3].implementation:fe,k=g?c[4].implementation:fe,R=y?c[5].implementation:fe,P=p?c[0].params.length:-1,U=m?c[1].params.length:-1,j=h?c[2].params.length:-1,L=d?c[3].params.length:-1,$=g?c[4].params.length:-1,H=y?c[5].params.length:-1,G=x?6:0,V=c.length,Z=c.map(e=>e.test),W=c.map(e=>e.implementation),Y=function(){for(let e=G;e<V;e++)if(Z[e](arguments))return W[e].apply(this,arguments);return J.onMismatch(t,arguments,c)};function z(e,t){return(arguments.length===P&&b(e)&&S(t)?D:arguments.length===U&&v(e)&&M(t)?O:arguments.length===j&&w(e)&&C(t)?_:arguments.length===L&&N(e)&&T(t)?I:arguments.length===$&&A(e)&&B(t)?k:arguments.length===H&&E(e)&&F(t)?R:Y).apply(this,arguments)}try{Object.defineProperty(z,"name",{value:t})}catch(t){}return z.signatures=o,z._typedFunctionData={signatures:c,signatureMap:f},z}function b(e,t,r){throw g(e,t,r)}function ne(e){return ae(e,0,e.length-1)}function ie(e){return e[e.length-1]}function ae(e,t,r){return Array.prototype.slice.call(e,t,r)}function v(e,t){return{referTo:{references:e,callback:t}}}function w(e){if("function"!=typeof e)throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:e}}}function N(e){return e&&"object"==typeof e.referTo&&Array.isArray(e.referTo.references)&&"function"==typeof e.referTo.callback}function A(e){return e&&"object"==typeof e.referToSelf&&"function"==typeof e.referToSelf.callback}function E(e,t){if(!e)return t;if(t&&t!==e){const r=new Error("Function names do not match (expected: "+e+", actual: "+t+")");throw r.data={actual:t,expected:e},r}return e}u(),n(t);var C=J;function S(e){if(!e||"string"!=typeof e.from||"string"!=typeof e.to||"function"!=typeof e.convert)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(J=function(e){const n="string"==typeof e;let i=n?e:"";var a={};for(let r=n?1:0;r<arguments.length;++r){var o=arguments[r];let e,t={};if("function"==typeof o?(e=o.name,"string"==typeof o.signature?t[o.signature]=o:f(o)&&(t=o.signatures)):c(o)&&(t=o,n||(e=function(e){let t;for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(f(e[r])||"string"==typeof e[r].signature)&&(t=E(t,e[r].name));return t}(o))),0===Object.keys(t).length){const n=new TypeError("Argument to 'typed' at index "+r+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw n.data={index:r,argument:o},n}n||(i=E(i,e));{s=void 0;u=void 0;var s=a;var u=t;let e;for(e in u)if(Object.prototype.hasOwnProperty.call(u,e)){if(e in s&&u[e]!==s[e]){const l=new Error('Signature "'+e+'" is defined twice');throw l.data={signature:e,sourceFunction:u[e],destFunction:s[e]},l}s[e]=u[e]}}}return M(i||"",a)}).create=e,J.createCount=C.createCount,J.onMismatch=b,J.throwMismatchError=b,J.createError=g,J.clear=u,J.clearConversions=function(){let e;for(e of o)a.get(e).conversionsTo=[];i=0},J.addTypes=n,J._findType=s,J.referTo=function(){var e=ne(arguments).map(e=>X(Q(e))),t=ie(arguments);if("function"!=typeof t)throw new TypeError("Callback function expected as last argument");return v(e,t)},J.referToSelf=w,J.convert=function(t,e){const r=s(e);if(r.test(t))return t;const n=r.conversionsTo;if(0===n.length)throw new Error("There are no conversions to "+e+" defined.");for(let e=0;e<n.length;e++)if(s(n[e].from).test(t))return n[e].convert(t);throw new Error("Cannot convert "+t+" to "+e)},J.findSignature=p,J.find=function(e,t,r){return p(e,t,r).implementation},J.isTypedFunction=f,J.warnAgainstDeprecatedThis=!0,J.addType=function(e,t){let r="any";!1!==t&&a.has("Object")&&(r="Object"),J.addTypes([e],r)},J.addConversion=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{override:!1};S(t);const r=s(t.to),n=r.conversionsTo.find(e=>e.from===t.from);if(n){if(!e||!e.override)throw new Error('There is already a conversion from "'+t.from+'" to "'+r.name+'"');J.removeConversion({from:n.from,to:t.to,convert:n.convert})}r.conversionsTo.push({from:t.from,convert:t.convert,index:i++})},J.addConversions=function(e,t){e.forEach(e=>J.addConversion(e,t))},J.removeConversion=function(r){S(r);const e=s(r.to),t=function(t){for(let e=0;e<t.length;e++)if(t[e].from===r.from)return t[e]}(e.conversionsTo);if(!t)throw new Error("Attempt to remove nonexistent conversion from "+r.from+" to "+r.to);if(t.convert!==r.convert)throw new Error("Conversion to remove does not match existing conversion");var n=e.conversionsTo.indexOf(t);e.conversionsTo.splice(n,1)},J.resolve=function(e,t){if(!f(e))throw new TypeError(B);const r=e._typedFunctionData.signatures;for(let e=0;e<r.length;++e)if(r[e].test(t))return r[e];return null},J}()}()},391:(e,t,r)=>{var n=r(180),i=r(181),a=r(31),o=r(67),s=r(833),u=r(717),r=r(801);r.alea=n,r.xor128=i,r.xorwow=a,r.xorshift7=o,r.xor4096=s,r.tychei=u,e.exports=r},504:e=>{function t(){}t.prototype={on:function(e,t,r){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:t,ctx:r}),this},once:function(e,t,r){var n=this;function i(){n.off(e,i),t.apply(r,arguments)}return i._=t,this.on(e,i,r)},emit:function(e){for(var t=[].slice.call(arguments,1),r=((this.e||(this.e={}))[e]||[]).slice(),n=0,i=r.length;n<i;n++)r[n].fn.apply(r[n].ctx,t);return this},off:function(e,t){var r=this.e||(this.e={}),n=r[e],i=[];if(n&&t)for(var a=0,o=n.length;a<o;a++)n[a].fn!==t&&n[a].fn._!==t&&i.push(n[a]);return i.length?r[e]=i:delete r[e],this}},e.exports=t,e.exports.TinyEmitter=t},717:function(e,r,n){var o;!function(e){function i(e){var i=this,t="";i.next=function(){var e=(e=i.b)<<25^e>>>7^(t=i.c),t=t-(r=i.d)|0,r=r<<24^r>>>8^(n=i.a),n=n-e|0;return i.b=e=e<<20^e>>>12^t,i.c=t=t-r|0,i.d=r<<16^t>>>16^n,i.a=n-e|0},i.a=0,i.b=0,i.c=-1640531527,i.d=1367130551,e===Math.floor(e)?(i.a=e/4294967296|0,i.b=0|e):t+=e;for(var r=0;r<t.length+20;r++)i.b^=0|t.charCodeAt(r),i.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function t(e,t){function r(){return(n.next()>>>0)/4294967296}var n=new i(e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&("object"==typeof e&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0!==(o=function(){return t}.call(r,n,r,e))&&(e.exports=o):this.tychei=t}(e=n.nmd(e),n.amdD)},801:function(e,t,r){var o,s="undefined"!=typeof self?self:this,u=[],l=Math,c=256,f=l.pow(c,6),p=l.pow(2,52),m=2*p,h=255;function n(e,t,r){function n(){for(var e=a.g(6),t=f,r=0;e<p;)e=(e+r)*c,t*=c,r=a.g(1);for(;m<=e;)e/=2,t/=2,r>>>=1;return(e+r)/t}var i=[],e=y(function e(t,r){var n,i=[],a=typeof t;if(r&&"object"==a)for(n in t)try{i.push(e(t[n],r-1))}catch(t){}return i.length?i:"string"==a?t:t+"\0"}((t=1==t?{entropy:!0}:t||{}).entropy?[e,x(u)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(c):(e=new Uint8Array(c),(s.crypto||s.msCrypto).getRandomValues(e)),x(e)}catch(e){var t=s.navigator,t=t&&t.plugins;return[+new Date,s,t,s.screen,x(u)]}}():e,3),i),a=new d(i);return n.int32=function(){return 0|a.g(4)},n.quick=function(){return a.g(4)/4294967296},n.double=n,y(x(a.S),u),(t.pass||r||function(e,t,r,n){return n&&(n.S&&g(n,a),e.state=function(){return g(a,{})}),r?(l.random=e,t):e})(n,e,"global"in t?t.global:this==l,t.state)}function d(e){var t,r=e.length,o=this,n=0,i=o.i=o.j=0,a=o.S=[];for(r||(e=[r++]);n<c;)a[n]=n++;for(n=0;n<c;n++)a[n]=a[i=h&i+e[n%r]+(t=a[n])],a[i]=t;(o.g=function(e){for(var t,r=0,n=o.i,i=o.j,a=o.S;e--;)t=a[n=h&n+1],r=r*c+a[h&(a[n]=a[i=h&i+t])+(a[i]=t)];return o.i=n,o.j=i,r})(c)}function g(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function y(e,t){for(var r,n=e+"",i=0;i<n.length;)t[h&i]=h&(r^=19*t[h&i])+n.charCodeAt(i++);return x(t)}function x(e){return String.fromCharCode.apply(0,e)}if(y(l.random(),u),e.exports){e.exports=n;try{o=r(234)}catch(e){}}else void 0!==(r=function(){return n}.call(t,r,t,e))&&(e.exports=r)},833:function(e,r,n){var o;!function(e){function i(e){var t,r,n,i,a,o=this,s=(o.next=function(){var e,t,r=o.w,n=o.X,i=o.i;return o.w=r=r+1640531527|0,t=n[i+34&127],e=n[i=i+1&127],t=n[i]=(t^=t<<13)^t>>>15^((e^=e<<17)^e>>>12),o.i=i,t+(r^r>>>16)|0},o),u=e,l=[],c=128;for(u===(0|u)?(r=u,u=null):(u+="\0",r=0,c=Math.max(c,u.length)),n=0,i=-32;i<c;++i)u&&(r^=u.charCodeAt((i+32)%u.length)),0===i&&(a=r),r=(r=(r=(r^=r<<10)^r>>>15)^r<<4)^r>>>13,0<=i&&(n=0==(t=l[127&i]^=r+(a=a+1640531527|0))?n+1:0);for(128<=n&&(l[127&(u&&u.length||0)]=-1),n=127,i=512;0<i;--i)r=l[n+34&127],t=l[n=n+1&127],l[n]=(r=(r^=r<<13)^r>>>15)^(t=(t^=t<<17)^t>>>12);s.w=a,s.X=l,s.i=n}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function t(e,t){function r(){return(n.next()>>>0)/4294967296}var n=new i(e=null==e?+new Date:e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&(e.X&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0!==(o=function(){return t}.call(r,n,r,e))&&(e.exports=o):this.xor4096=t}(e=n.nmd(e),n.amdD)},880:e=>{e.exports=function t(e,r){"use strict";function n(e){return t.insensitive&&(""+e).toLowerCase()||""+e}var i,a,o=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,u=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,c=/^0/,e=n(e).replace(s,"")||"",r=n(r).replace(s,"")||"",f=e.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=r.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),s=parseInt(e.match(l),16)||1!==f.length&&e.match(u)&&Date.parse(e),o=parseInt(r.match(l),16)||s&&r.match(u)&&Date.parse(r)||null;if(o){if(s<o)return-1;if(o<s)return 1}for(var m=0,h=Math.max(f.length,p.length);m<h;m++){if(i=!(f[m]||"").match(c)&&parseFloat(f[m])||f[m]||0,a=!(p[m]||"").match(c)&&parseFloat(p[m])||p[m]||0,isNaN(i)!==isNaN(a))return isNaN(i)?1:-1;if(typeof i!=typeof a&&(i+="",a+=""),i<a)return-1;if(a<i)return 1}return 0}}},n={};function fd(e){var t=n[e];if(void 0!==t)return t.exports;t=n[e]={id:e,loaded:!1,exports:{}};return r[e].call(t.exports,t,t.exports,fd),t.loaded=!0,t.exports}fd.amdD=function(){throw new Error("define cannot be used indirect")},fd.amdO={},fd.d=(e,t)=>{for(var r in t)fd.o(t,r)&&!fd.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},fd.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),fd.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},fd.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var pd={};return(()=>{"use strict";fd.d(pd,{default:()=>cd});var t={},l=(fd.r(t),fd.d(t,{createAbs:()=>ha,createAccessorNode:()=>cf,createAcos:()=>jl,createAcosh:()=>ac,createAcot:()=>oc,createAcoth:()=>sc,createAcsc:()=>uc,createAcsch:()=>lc,createAdd:()=>Jc,createAddScalar:()=>ba,createAnd:()=>Lu,createAndTransform:()=>Kh,createArg:()=>Po,createArrayNode:()=>pf,createAsec:()=>cc,createAsech:()=>fc,createAsin:()=>pc,createAsinh:()=>mc,createAssignmentNode:()=>xf,createAtan:()=>hc,createAtan2:()=>dc,createAtanh:()=>gc,createAtomicMass:()=>ah,createAvogadro:()=>oh,createBellNumbers:()=>qm,createBigNumberClass:()=>Zr,createBigint:()=>Mi,createBignumber:()=>Fi,createBin:()=>nu,createBitAnd:()=>zo,createBitAndTransform:()=>rd,createBitNot:()=>qo,createBitOr:()=>Io,createBitOrTransform:()=>nd,createBitXor:()=>Ro,createBlockNode:()=>vf,createBohrMagneton:()=>P0,createBohrRadius:()=>G0,createBoltzmann:()=>sh,createBoolean:()=>Bi,createCatalan:()=>km,createCbrt:()=>Na,createCeil:()=>Ta,createChain:()=>Ep,createChainClass:()=>bp,createClassicalElectronRadius:()=>V0,createClone:()=>Qn,createColumn:()=>es,createColumnTransform:()=>Th,createCombinations:()=>tm,createCombinationsWithRep:()=>im,createCompare:()=>Hu,createCompareNatural:()=>Wu,createCompareText:()=>Ju,createCompile:()=>Xf,createComplex:()=>Di,createComplexClass:()=>en,createComposition:()=>Pm,createConcat:()=>Ko,createConcatTransform:()=>Hh,createConditionalNode:()=>Nf,createConductanceQuantum:()=>U0,createConj:()=>Uo,createConstantNode:()=>Ff,createCorr:()=>Xp,createCos:()=>xc,createCosh:()=>bc,createCot:()=>vc,createCoth:()=>wc,createCoulomb:()=>I0,createCoulombConstant:()=>k0,createCount:()=>ts,createCreateUnit:()=>Ul,createCross:()=>rs,createCsc:()=>Nc,createCsch:()=>Ac,createCtranspose:()=>js,createCube:()=>Ba,createCumSum:()=>jp,createCumSumTransform:()=>Yh,createDeepEqual:()=>dl,createDenseMatrixClass:()=>Xn,createDerivative:()=>Km,createDet:()=>Sp,createDeuteronMass:()=>Q0,createDiag:()=>ns,createDiff:()=>ys,createDiffTransform:()=>Gh,createDistance:()=>kp,createDivide:()=>qp,createDivideScalar:()=>du,createDot:()=>Kc,createDotDivide:()=>Mu,createDotMultiply:()=>yo,createDotPow:()=>Eu,createE:()=>g0,createEfimovFactor:()=>ih,createEigs:()=>Tp,createElectricConstant:()=>z0,createElectronMass:()=>Z0,createElementaryCharge:()=>R0,createEqual:()=>Qu,createEqualScalar:()=>Ai,createEqualText:()=>tl,createErf:()=>Vs,createEvaluate:()=>Kf,createExp:()=>Fa,createExpm:()=>Bp,createExpm1:()=>Da,createFactorial:()=>dm,createFalse:()=>c0,createFaraday:()=>uh,createFermiCoupling:()=>W0,createFft:()=>$s,createFibonacciHeapClass:()=>Cl,createFilter:()=>is,createFilterTransform:()=>_h,createFineStructure:()=>Y0,createFirstRadiation:()=>lh,createFix:()=>_a,createFlatten:()=>ss,createFloor:()=>ka,createForEach:()=>ls,createForEachTransform:()=>zh,createFormat:()=>ru,createFraction:()=>Oi,createFractionClass:()=>mn,createFreqz:()=>n0,createFunctionAssignmentNode:()=>Of,createFunctionNode:()=>Wf,createGamma:()=>pm,createGasConstant:()=>fh,createGcd:()=>Ya,createGetMatrixDataType:()=>ps,createGravitationConstant:()=>F0,createGravity:()=>vh,createHartreeEnergy:()=>J0,createHasNumericValue:()=>di,createHelp:()=>Ap,createHelpClass:()=>xp,createHex:()=>au,createHypot:()=>Xc,createI:()=>E0,createIdentity:()=>hs,createIfft:()=>Hs,createIm:()=>jo,createImmutableDenseMatrixClass:()=>El,createIndex:()=>tf,createIndexClass:()=>Sl,createIndexNode:()=>zf,createIndexTransform:()=>qh,createInfinity:()=>p0,createIntersect:()=>Rp,createInv:()=>Mp,createInverseConductanceQuantum:()=>j0,createInvmod:()=>mo,createIsInteger:()=>oi,createIsNaN:()=>bi,createIsNegative:()=>fi,createIsNumeric:()=>mi,createIsPositive:()=>yi,createIsPrime:()=>pu,createIsZero:()=>xi,createKldivergence:()=>ym,createKlitzing:()=>H0,createKron:()=>ds,createLN10:()=>b0,createLN2:()=>x0,createLOG10E:()=>w0,createLOG2E:()=>v0,createLarger:()=>ll,createLargerEq:()=>pl,createLcm:()=>Xa,createLeafCount:()=>jm,createLeftShift:()=>ku,createLgamma:()=>mm,createLog:()=>vu,createLog10:()=>eo,createLog1p:()=>wu,createLog2:()=>to,createLoschmidt:()=>ch,createLsolve:()=>Tu,createLsolveAll:()=>Du,createLup:()=>rp,createLusolve:()=>dp,createLyap:()=>zp,createMad:()=>Hp,createMagneticConstant:()=>_0,createMagneticFluxQuantum:()=>L0,createMap:()=>gs,createMapSlices:()=>ga,createMapSlicesTransform:()=>Ch,createMapTransform:()=>Ih,createMatrix:()=>_i,createMatrixClass:()=>dn,createMatrixFromColumns:()=>Pi,createMatrixFromFunction:()=>qi,createMatrixFromRows:()=>ki,createMax:()=>Nl,createMaxTransform:()=>Rh,createMean:()=>Lp,createMeanTransform:()=>Ph,createMedian:()=>$p,createMin:()=>Al,createMinTransform:()=>Uh,createMod:()=>$a,createMode:()=>Ks,createMolarMass:()=>xh,createMolarMassC12:()=>bh,createMolarPlanckConstant:()=>ph,createMolarVolume:()=>mh,createMultinomial:()=>bm,createMultiply:()=>io,createMultiplyScalar:()=>ro,createNaN:()=>m0,createNeutronMass:()=>K0,createNode:()=>nf,createNorm:()=>Qc,createNot:()=>Wo,createNthRoot:()=>oo,createNthRoots:()=>Au,createNuclearMagneton:()=>$0,createNull:()=>f0,createNullish:()=>Jo,createNullishTransform:()=>td,createNumber:()=>Si,createNumeric:()=>mu,createObjectNode:()=>If,createOct:()=>iu,createOnes:()=>xs,createOperatorNode:()=>Pf,createOr:()=>Xo,createOrTransform:()=>ed,createParenthesisNode:()=>jf,createParse:()=>Yf,createParser:()=>tp,createParserClass:()=>ep,createPartitionSelect:()=>vl,createPermutations:()=>wm,createPhi:()=>y0,createPi:()=>h0,createPickRandom:()=>Cm,createPinv:()=>Cp,createPlanckCharge:()=>Eh,createPlanckConstant:()=>D0,createPlanckLength:()=>wh,createPlanckMass:()=>Nh,createPlanckTemperature:()=>Sh,createPlanckTime:()=>Ah,createPolynomialRoot:()=>yp,createPow:()=>gu,createPrint:()=>su,createPrintTransform:()=>Qh,createProd:()=>tu,createProtonMass:()=>X0,createQr:()=>np,createQuantileSeq:()=>Yp,createQuantileSeqTransform:()=>Wh,createQuantumOfCirculation:()=>eh,createRandom:()=>Bm,createRandomInt:()=>Dm,createRange:()=>Ns,createRangeClass:()=>hn,createRangeNode:()=>$f,createRangeTransform:()=>jh,createRationalize:()=>t0,createRe:()=>Lo,createReducedPlanckConstant:()=>O0,createRelationalNode:()=>Gf,createReplacer:()=>a0,createReshape:()=>Es,createResize:()=>Ss,createResolve:()=>Ym,createResultSet:()=>ft,createReviver:()=>i0,createRightArithShift:()=>Pu,createRightLogShift:()=>ju,createRotate:()=>Ms,createRotationMatrix:()=>Ts,createRound:()=>xu,createRow:()=>Bs,createRowTransform:()=>Lh,createRydberg:()=>th,createSQRT1_2:()=>N0,createSQRT2:()=>A0,createSackurTetrode:()=>hh,createSchur:()=>_p,createSec:()=>Ec,createSech:()=>Sc,createSecondRadiation:()=>dh,createSetCartesian:()=>Dc,createSetDifference:()=>_c,createSetDistinct:()=>qc,createSetIntersect:()=>kc,createSetIsSubset:()=>Pc,createSetMultiplicity:()=>jc,createSetPowerset:()=>$c,createSetSize:()=>Gc,createSetSymDifference:()=>Zc,createSetUnion:()=>Yc,createSign:()=>so,createSimplify:()=>Gm,createSimplifyConstant:()=>Vm,createSimplifyCore:()=>Wm,createSin:()=>Mc,createSinh:()=>Cc,createSize:()=>Fs,createSlu:()=>pp,createSmaller:()=>nl,createSmallerEq:()=>ol,createSolveODE:()=>Gs,createSort:()=>wl,createSpaClass:()=>Tl,createSparse:()=>Rl,createSparseMatrixClass:()=>Ei,createSpeedOfLight:()=>B0,createSplitUnit:()=>ji,createSqrt:()=>uo,createSqrtm:()=>Fp,createSquare:()=>lo,createSqueeze:()=>Os,createStd:()=>Jp,createStdTransform:()=>Vh,createStefanBoltzmann:()=>gh,createStirlingS2:()=>_m,createString:()=>Ci,createSubset:()=>_s,createSubsetTransform:()=>$h,createSubtract:()=>fo,createSubtractScalar:()=>wa,createSum:()=>Pp,createSumTransform:()=>Zh,createSylvester:()=>Op,createSymbolNode:()=>Vf,createSymbolicEqual:()=>Xm,createTan:()=>Tc,createTanh:()=>Bc,createTau:()=>d0,createThomsonCrossSection:()=>rh,createTo:()=>lu,createToBest:()=>cu,createTrace:()=>ef,createTranspose:()=>Ps,createTrue:()=>l0,createTypeOf:()=>vi,createTyped:()=>st,createUnaryMinus:()=>fa,createUnaryPlus:()=>ma,createUnequal:()=>yl,createUnitClass:()=>Il,createUnitFunction:()=>kl,createUppercaseE:()=>M0,createUppercasePi:()=>S0,createUsolve:()=>Bu,createUsolveAll:()=>_u,createVacuumImpedance:()=>q0,createVariance:()=>Zp,createVarianceTransform:()=>Xh,createVersion:()=>C0,createWeakMixingAngle:()=>nh,createWienDisplacement:()=>yh,createXgcd:()=>po,createXor:()=>Qo,createZeros:()=>Ls,createZeta:()=>Qs,createZpk2tf:()=>r0}),fd(369));function h(e,t){if(n(e,t))return e[t];if("function"==typeof e[t]&&q(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function D(e,t,r){if(n(e,t))return e[t]=r;throw new Error('No access to property "'+t+'"')}function n(e,t){return!(("object"!=typeof e||!e||e.constructor!==Object)&&!Array.isArray(e)||!ue(r,t)&&(t in Object.prototype||t in Function.prototype))}function q(e,t){return!(null==e||"function"!=typeof e[t]||ue(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!ue(i,t)&&(t in Object.prototype||t in Function.prototype))}const r={length:!0,name:!0},i={toString:!0,valueOf:!0,toLocaleString:!0};class I{constructor(e){this.wrappedObject=e,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter(e=>this.has(e)).values()}get(e){return h(this.wrappedObject,e)}set(e,t){return D(this.wrappedObject,e,t),this}has(e){return n(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return a(this.keys(),e=>[e,this.get(e)])}forEach(e){for(const t of this.keys())e(this.get(t),t,this)}delete(e){n(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(const e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}}class k{constructor(e,t,r){this.a=e,this.b=t,this.bKeys=r,this[Symbol.iterator]=this.entries}get(e){return(this.bKeys.has(e)?this.b:this.a).get(e)}set(e,t){return(this.bKeys.has(e)?this.b:this.a).set(e,t),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return a(this.keys(),e=>[e,this.get(e)])}forEach(e){for(const t of this.keys())e(this.get(t),t,this)}delete(e){return(this.bKeys.has(e)?this.b:this.a).delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}}function a(t,r){return{next:()=>{var e=t.next();return e.done?e:{value:r(e.value),done:!1}}}}function P(){return new Map}function U(e){if(!e)return P();if(fe(e))return e;if(ce(e))return new I(e);throw new Error("createMap can create maps from objects or Maps")}function A(e){return"number"==typeof e}function Q(e){return!(!e||"object"!=typeof e||"function"!=typeof e.constructor)&&(!0===e.isBigNumber&&"object"==typeof e.constructor.prototype&&!0===e.constructor.prototype.isBigNumber||"function"==typeof e.constructor.isDecimal&&!0===e.constructor.isDecimal(e))}function R(e){return"bigint"==typeof e}function te(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isComplex||!1}function re(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isFraction||!1}function L(e){return e&&!0===e.constructor.prototype.isUnit||!1}function j(e){return"string"==typeof e}const b=Array.isArray;function _(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function $(e){return Array.isArray(e)||_(e)}function H(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function G(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function V(e){return e&&!0===e.constructor.prototype.isRange||!1}function Z(e){return e&&!0===e.constructor.prototype.isIndex||!1}function W(e){return"boolean"==typeof e}function Y(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function J(e){return e&&!0===e.constructor.prototype.isHelp||!1}function X(e){return"function"==typeof e}function ne(e){return e instanceof Date}function ie(e){return e instanceof RegExp}function ce(e){return!(!e||"object"!=typeof e||e.constructor!==Object||te(e)||re(e))}function fe(e){return!!e&&(e instanceof Map||e instanceof I||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function pe(e){return fe(e)&&fe(e.a)&&fe(e.b)}function me(e){return fe(e)&&ce(e.wrappedObject)}function he(e){return null===e}function de(e){return void 0===e}function ge(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function ye(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function xe(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function be(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function ve(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function ae(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function we(e){return ae(e)||oe(e)&&1===e.args.length&&ae(e.args[0])&&"-+~".includes(e.op)}function Ne(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function Ae(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function Ee(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function O(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function Se(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function oe(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function Me(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function Ce(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function Te(e){return e&&!0===e.isRelationalNode&&!0===e.constructor.prototype.isNode||!1}function se(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function Be(e){return e&&!0===e.constructor.prototype.isChain||!1}function K(e){var t=typeof e;return"object"==t?null===e?"null":Q(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":t}function ee(e){var t=typeof e;if("number"==t||"bigint"==t||"string"==t||"boolean"==t||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map(ee);if(e instanceof Date)return new Date(e.valueOf());if(Q(e))return e;if(ce(e)){var r=e,n=ee;const i={};for(const a in r)ue(r,a)&&(i[a]=n(r[a]));return i}if("function"==t)return e;throw new TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function Fe(e,t){for(const r in t)ue(t,r)&&(e[r]=t[r]);return e}function De(e,t){let r,n,i;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(n=0,i=e.length;n<i;n++)if(!De(e[n],t[n]))return!1;return!0}if("function"==typeof e)return e===t;if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(r in e)if(!(r in t&&De(e[r],t[r])))return!1;for(r in t)if(!(r in e))return!1;return!0}return e===t}function Oe(e){var t={};return function e(t,r){for(const n in t)if(ue(t,n)){const i=t[n];"object"==typeof i&&null!==i?e(i,r):r[n]=i}}(e,t),t}function _e(e,t,r){let n,i=!0;Object.defineProperty(e,t,{get:function(){return i&&(n=r(),i=!1),n},set:function(e){n=e,i=!1},configurable:!0,enumerable:!0})}function ue(e,t){return e&&Object.hasOwnProperty.call(e,t)}function s(o,s,u,e){function t(e){var t=function(t,r){const n={};for(let e=0;e<r.length;e++){var i=r[e],a=t[i];void 0!==a&&(n[i]=a)}return n}(e,s.map(qe)),r=o,n=s,i=e;if(n.filter(e=>!(e&&"?"===e[0])).every(e=>void 0!==i[e]))return u(t);{const a=n.filter(e=>void 0===i[e]);throw new Error(`Cannot create function "${r}", some dependencies are missing: ${a.map(e=>`"${e}"`).join(", ")}.`)}}return t.isFactory=!0,t.fn=o,t.dependencies=s.slice().sort(),e&&(t.meta=e),t}function ze(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function qe(e){return e&&"?"===e[0]?e.slice(1):e}function v(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}function Ie(e,t){if("bigint"===t.number)try{BigInt(e)}catch(e){return t.numberFallback}return t.number}const ke=Math.sign||function(e){return 0<e?1:e<0?-1:0},Re=Math.log2||function(e){return Math.log(e)/Math.LN2},Pe=Math.log10||function(e){return Math.log(e)/Math.LN10},Ue=Math.log1p||function(e){return Math.log(e+1)},je=Math.cbrt||function(e){if(0===e)return e;var t=e<0;let r;return t&&(e=-e),r=isFinite(e)?(e/((r=Math.exp(Math.log(e)/3))*r)+2*r)/3:e,t?-r:r},Le=Math.expm1||function(e){return 2e-4<=e||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function $e(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t];let i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!v(r))throw new Error("size must be an integer");if(2**(r-1)-1<e||e<-(2**(r-1)))throw new Error(`Value must be in range [-2^${r-1}, 2^${r-1}-1]`);if(!v(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i"+r}let a="";return e<0&&(e=-e,a="-"),""+a+n+e.toString(t)+i}function He(r,e){if("function"==typeof e)return e(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var{notation:t,precision:n,wordSize:i}=Ge(e);switch(t){case"fixed":return Ze(r,n);case"exponential":return We(r,n);case"engineering":{var a=r;var o=n;if(isNaN(a)||!isFinite(a))return String(a);const s=Ye(Ve(a),o),u=s.exponent,l=s.coefficients,c=u%3==0?u:u<0?u-3-u%3:u-u%3;if(A(o))for(;o>l.length||u-c+1>l.length;)l.push(0);else{const a=Math.abs(u-c)-(l.length-1);for(let e=0;e<a;e++)l.push(0)}let e=Math.abs(u-c),t=1;for(;0<e;)t++,e--;const f=l.slice(t).join(""),p=A(o)&&f.length||f.match(/[1-9]/)?"."+f:"",m=l.slice(0,t).join("")+p+"e"+(0<=u?"+":"")+c.toString();return s.sign+m;return}case"bin":return $e(r,2,i);case"oct":return $e(r,8,i);case"hex":return $e(r,16,i);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);const n=at(null==r?void 0:r.lowerExp,-3),i=at(null==r?void 0:r.upperExp,5),a=Ve(e),o=t?Ye(a,t):a;if(o.exponent<n||o.exponent>=i)return We(e,t);{let e=o.coefficients;const r=o.exponent,n=(e=(e=e.length<t?e.concat(Je(t-e.length)):e).concat(Je(r-e.length+1+(e.length<t?t-e.length:0))),0<r?r:0);return n<(e=Je(-r).concat(e)).length-1&&e.splice(n+1,0,"."),o.sign+e.join("")}}(r,n,e).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Ge(e){let t,r,n="auto";if(void 0!==e)if(A(e))t=e;else if(Q(e))t=e.toNumber();else{if(!ce(e))throw new Error("Unsupported type of options, number, BigNumber, or object expected");void 0!==e.precision&&(t=it(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),void 0!==e.wordSize&&(r=it(e.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),e.notation&&(n=e.notation)}return{notation:n,precision:t,wordSize:r}}function Ve(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);const r=t[1],n=t[2];let i=parseFloat(t[4]||"0");e=n.indexOf(".");i+=-1!==e?e-1:n.length-1;const a=n.replace(".","").replace(/^0*/,function(e){return i-=e.length,""}).replace(/0*$/,"").split("").map(function(e){return parseInt(e)});return 0===a.length&&(a.push(0),i++),{sign:r,coefficients:a,exponent:i}}function Ze(e,t){if(isNaN(e)||!isFinite(e))return String(e);e=Ve(e),e="number"==typeof t?Ye(e,e.exponent+1+t):e;let r=e.coefficients,n=e.exponent+1;t=n+(t||0);return r.length<t&&(r=r.concat(Je(t-r.length))),n<0&&(r=Je(1-n).concat(r),n=1),n<r.length&&r.splice(n,0,0===n?"0.":"."),e.sign+r.join("")}function We(e,t){if(isNaN(e)||!isFinite(e))return String(e);e=Ve(e),e=t?Ye(e,t):e;let r=e.coefficients;var n=e.exponent,t=(r=r.length<t?r.concat(Je(t-r.length)):r).shift();return e.sign+t+(0<r.length?"."+r.join(""):"")+"e"+(0<=n?"+":"")+n}function Ye(e,t){const r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;for(;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&5<=n.splice(t,n.length-t)[0]){let e=t-1;for(n[e]++;10===n[e];)n.pop(),0===e&&(n.unshift(0),r.exponent++,e++),e--,n[e]++}return r}function Je(t){const r=[];for(let e=0;e<t;e++)r.push(0);return r}function Xe(e,t,r,n){r=2<arguments.length&&void 0!==r?r:1e-8,n=3<arguments.length&&void 0!==n?n:0;if(r<=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(t)&&(isFinite(e)&&isFinite(t)?e===t||Math.abs(e-t)<=Math.max(r*Math.max(Math.abs(e),Math.abs(t)),n):e===t)}const Qe=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Ke=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},et=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},tt=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},rt=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},nt=Math.tanh||function(e){e=Math.exp(2*e);return(e-1)/(e+1)};function it(e,t){return A(e)?e:Q(e)?e.toNumber():void t()}function at(e,t){return A(e)?e:Q(e)?e.toNumber():t}let ot=function(){return ot=l.create,l};const st=s("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],function(e){let{BigNumber:r,Complex:n,DenseMatrix:t,Fraction:i}=e;const a=ot();return a.clear(),a.addTypes([{name:"number",test:A},{name:"Complex",test:te},{name:"BigNumber",test:Q},{name:"bigint",test:R},{name:"Fraction",test:re},{name:"Unit",test:L},{name:"identifier",test:e=>/^[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\u{10000}-\u{1000B}\u{1000D}-\u{10026}\u{10028}-\u{1003A}\u{1003C}\u{1003D}\u{1003F}-\u{1004D}\u{10050}-\u{1005D}\u{10080}-\u{100FA}\u{10280}-\u{1029C}\u{102A0}-\u{102D0}\u{10300}-\u{1031F}\u{1032D}-\u{10340}\u{10342}-\u{10349}\u{10350}-\u{10375}\u{10380}-\u{1039D}\u{103A0}-\u{103C3}\u{103C8}-\u{103CF}\u{10400}-\u{1049D}\u{104B0}-\u{104D3}\u{104D8}-\u{104FB}\u{10500}-\u{10527}\u{10530}-\u{10563}\u{10570}-\u{1057A}\u{1057C}-\u{1058A}\u{1058C}-\u{10592}\u{10594}\u{10595}\u{10597}-\u{105A1}\u{105A3}-\u{105B1}\u{105B3}-\u{105B9}\u{105BB}\u{105BC}\u{105C0}-\u{105F3}\u{10600}-\u{10736}\u{10740}-\u{10755}\u{10760}-\u{10767}\u{10780}-\u{10785}\u{10787}-\u{107B0}\u{107B2}-\u{107BA}\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10860}-\u{10876}\u{10880}-\u{1089E}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{10900}-\u{10915}\u{10920}-\u{10939}\u{10980}-\u{109B7}\u{109BE}\u{109BF}\u{10A00}\u{10A10}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A60}-\u{10A7C}\u{10A80}-\u{10A9C}\u{10AC0}-\u{10AC7}\u{10AC9}-\u{10AE4}\u{10B00}-\u{10B35}\u{10B40}-\u{10B55}\u{10B60}-\u{10B72}\u{10B80}-\u{10B91}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10D00}-\u{10D23}\u{10D4A}-\u{10D65}\u{10D6F}-\u{10D85}\u{10E80}-\u{10EA9}\u{10EB0}\u{10EB1}\u{10EC2}-\u{10EC4}\u{10F00}-\u{10F1C}\u{10F27}\u{10F30}-\u{10F45}\u{10F70}-\u{10F81}\u{10FB0}-\u{10FC4}\u{10FE0}-\u{10FF6}\u{11003}-\u{11037}\u{11071}\u{11072}\u{11075}\u{11083}-\u{110AF}\u{110D0}-\u{110E8}\u{11103}-\u{11126}\u{11144}\u{11147}\u{11150}-\u{11172}\u{11176}\u{11183}-\u{111B2}\u{111C1}-\u{111C4}\u{111DA}\u{111DC}\u{11200}-\u{11211}\u{11213}-\u{1122B}\u{1123F}\u{11240}\u{11280}-\u{11286}\u{11288}\u{1128A}-\u{1128D}\u{1128F}-\u{1129D}\u{1129F}-\u{112A8}\u{112B0}-\u{112DE}\u{11305}-\u{1130C}\u{1130F}\u{11310}\u{11313}-\u{11328}\u{1132A}-\u{11330}\u{11332}\u{11333}\u{11335}-\u{11339}\u{1133D}\u{11350}\u{1135D}-\u{11361}\u{11380}-\u{11389}\u{1138B}\u{1138E}\u{11390}-\u{113B5}\u{113B7}\u{113D1}\u{113D3}\u{11400}-\u{11434}\u{11447}-\u{1144A}\u{1145F}-\u{11461}\u{11480}-\u{114AF}\u{114C4}\u{114C5}\u{114C7}\u{11580}-\u{115AE}\u{115D8}-\u{115DB}\u{11600}-\u{1162F}\u{11644}\u{11680}-\u{116AA}\u{116B8}\u{11700}-\u{1171A}\u{11740}-\u{11746}\u{11800}-\u{1182B}\u{118A0}-\u{118DF}\u{118FF}-\u{11906}\u{11909}\u{1190C}-\u{11913}\u{11915}\u{11916}\u{11918}-\u{1192F}\u{1193F}\u{11941}\u{119A0}-\u{119A7}\u{119AA}-\u{119D0}\u{119E1}\u{119E3}\u{11A00}\u{11A0B}-\u{11A32}\u{11A3A}\u{11A50}\u{11A5C}-\u{11A89}\u{11A9D}\u{11AB0}-\u{11AF8}\u{11BC0}-\u{11BE0}\u{11C00}-\u{11C08}\u{11C0A}-\u{11C2E}\u{11C40}\u{11C72}-\u{11C8F}\u{11D00}-\u{11D06}\u{11D08}\u{11D09}\u{11D0B}-\u{11D30}\u{11D46}\u{11D60}-\u{11D65}\u{11D67}\u{11D68}\u{11D6A}-\u{11D89}\u{11D98}\u{11EE0}-\u{11EF2}\u{11F02}\u{11F04}-\u{11F10}\u{11F12}-\u{11F33}\u{11FB0}\u{12000}-\u{12399}\u{12480}-\u{12543}\u{12F90}-\u{12FF0}\u{13000}-\u{1342F}\u{13441}-\u{13446}\u{13460}-\u{143FA}\u{14400}-\u{14646}\u{16100}-\u{1611D}\u{16800}-\u{16A38}\u{16A40}-\u{16A5E}\u{16A70}-\u{16ABE}\u{16AD0}-\u{16AED}\u{16B00}-\u{16B2F}\u{16B40}-\u{16B43}\u{16B63}-\u{16B77}\u{16B7D}-\u{16B8F}\u{16D40}-\u{16D6C}\u{16E40}-\u{16E7F}\u{16F00}-\u{16F4A}\u{16F50}\u{16F93}-\u{16F9F}\u{16FE0}\u{16FE1}\u{16FE3}\u{17000}-\u{187F7}\u{18800}-\u{18CD5}\u{18CFF}-\u{18D08}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}\u{1B000}-\u{1B122}\u{1B132}\u{1B150}-\u{1B152}\u{1B155}\u{1B164}-\u{1B167}\u{1B170}-\u{1B2FB}\u{1BC00}-\u{1BC6A}\u{1BC70}-\u{1BC7C}\u{1BC80}-\u{1BC88}\u{1BC90}-\u{1BC99}\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}\u{1D6A8}-\u{1D6C0}\u{1D6C2}-\u{1D6DA}\u{1D6DC}-\u{1D6FA}\u{1D6FC}-\u{1D714}\u{1D716}-\u{1D734}\u{1D736}-\u{1D74E}\u{1D750}-\u{1D76E}\u{1D770}-\u{1D788}\u{1D78A}-\u{1D7A8}\u{1D7AA}-\u{1D7C2}\u{1D7C4}-\u{1D7CB}\u{1DF00}-\u{1DF1E}\u{1DF25}-\u{1DF2A}\u{1E030}-\u{1E06D}\u{1E100}-\u{1E12C}\u{1E137}-\u{1E13D}\u{1E14E}\u{1E290}-\u{1E2AD}\u{1E2C0}-\u{1E2EB}\u{1E4D0}-\u{1E4EB}\u{1E5D0}-\u{1E5ED}\u{1E5F0}\u{1E7E0}-\u{1E7E6}\u{1E7E8}-\u{1E7EB}\u{1E7ED}\u{1E7EE}\u{1E7F0}-\u{1E7FE}\u{1E800}-\u{1E8C4}\u{1E900}-\u{1E943}\u{1E94B}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}\u{20000}-\u{2A6DF}\u{2A700}-\u{2B739}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}\u{2EBF0}-\u{2EE5D}\u{2F800}-\u{2FA1D}\u{30000}-\u{3134A}\u{31350}-\u{323AF}][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\u{10000}-\u{1000B}\u{1000D}-\u{10026}\u{10028}-\u{1003A}\u{1003C}\u{1003D}\u{1003F}-\u{1004D}\u{10050}-\u{1005D}\u{10080}-\u{100FA}\u{10280}-\u{1029C}\u{102A0}-\u{102D0}\u{10300}-\u{1031F}\u{1032D}-\u{10340}\u{10342}-\u{10349}\u{10350}-\u{10375}\u{10380}-\u{1039D}\u{103A0}-\u{103C3}\u{103C8}-\u{103CF}\u{10400}-\u{1049D}\u{104B0}-\u{104D3}\u{104D8}-\u{104FB}\u{10500}-\u{10527}\u{10530}-\u{10563}\u{10570}-\u{1057A}\u{1057C}-\u{1058A}\u{1058C}-\u{10592}\u{10594}\u{10595}\u{10597}-\u{105A1}\u{105A3}-\u{105B1}\u{105B3}-\u{105B9}\u{105BB}\u{105BC}\u{105C0}-\u{105F3}\u{10600}-\u{10736}\u{10740}-\u{10755}\u{10760}-\u{10767}\u{10780}-\u{10785}\u{10787}-\u{107B0}\u{107B2}-\u{107BA}\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10860}-\u{10876}\u{10880}-\u{1089E}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{10900}-\u{10915}\u{10920}-\u{10939}\u{10980}-\u{109B7}\u{109BE}\u{109BF}\u{10A00}\u{10A10}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A60}-\u{10A7C}\u{10A80}-\u{10A9C}\u{10AC0}-\u{10AC7}\u{10AC9}-\u{10AE4}\u{10B00}-\u{10B35}\u{10B40}-\u{10B55}\u{10B60}-\u{10B72}\u{10B80}-\u{10B91}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10D00}-\u{10D23}\u{10D4A}-\u{10D65}\u{10D6F}-\u{10D85}\u{10E80}-\u{10EA9}\u{10EB0}\u{10EB1}\u{10EC2}-\u{10EC4}\u{10F00}-\u{10F1C}\u{10F27}\u{10F30}-\u{10F45}\u{10F70}-\u{10F81}\u{10FB0}-\u{10FC4}\u{10FE0}-\u{10FF6}\u{11003}-\u{11037}\u{11071}\u{11072}\u{11075}\u{11083}-\u{110AF}\u{110D0}-\u{110E8}\u{11103}-\u{11126}\u{11144}\u{11147}\u{11150}-\u{11172}\u{11176}\u{11183}-\u{111B2}\u{111C1}-\u{111C4}\u{111DA}\u{111DC}\u{11200}-\u{11211}\u{11213}-\u{1122B}\u{1123F}\u{11240}\u{11280}-\u{11286}\u{11288}\u{1128A}-\u{1128D}\u{1128F}-\u{1129D}\u{1129F}-\u{112A8}\u{112B0}-\u{112DE}\u{11305}-\u{1130C}\u{1130F}\u{11310}\u{11313}-\u{11328}\u{1132A}-\u{11330}\u{11332}\u{11333}\u{11335}-\u{11339}\u{1133D}\u{11350}\u{1135D}-\u{11361}\u{11380}-\u{11389}\u{1138B}\u{1138E}\u{11390}-\u{113B5}\u{113B7}\u{113D1}\u{113D3}\u{11400}-\u{11434}\u{11447}-\u{1144A}\u{1145F}-\u{11461}\u{11480}-\u{114AF}\u{114C4}\u{114C5}\u{114C7}\u{11580}-\u{115AE}\u{115D8}-\u{115DB}\u{11600}-\u{1162F}\u{11644}\u{11680}-\u{116AA}\u{116B8}\u{11700}-\u{1171A}\u{11740}-\u{11746}\u{11800}-\u{1182B}\u{118A0}-\u{118DF}\u{118FF}-\u{11906}\u{11909}\u{1190C}-\u{11913}\u{11915}\u{11916}\u{11918}-\u{1192F}\u{1193F}\u{11941}\u{119A0}-\u{119A7}\u{119AA}-\u{119D0}\u{119E1}\u{119E3}\u{11A00}\u{11A0B}-\u{11A32}\u{11A3A}\u{11A50}\u{11A5C}-\u{11A89}\u{11A9D}\u{11AB0}-\u{11AF8}\u{11BC0}-\u{11BE0}\u{11C00}-\u{11C08}\u{11C0A}-\u{11C2E}\u{11C40}\u{11C72}-\u{11C8F}\u{11D00}-\u{11D06}\u{11D08}\u{11D09}\u{11D0B}-\u{11D30}\u{11D46}\u{11D60}-\u{11D65}\u{11D67}\u{11D68}\u{11D6A}-\u{11D89}\u{11D98}\u{11EE0}-\u{11EF2}\u{11F02}\u{11F04}-\u{11F10}\u{11F12}-\u{11F33}\u{11FB0}\u{12000}-\u{12399}\u{12480}-\u{12543}\u{12F90}-\u{12FF0}\u{13000}-\u{1342F}\u{13441}-\u{13446}\u{13460}-\u{143FA}\u{14400}-\u{14646}\u{16100}-\u{1611D}\u{16800}-\u{16A38}\u{16A40}-\u{16A5E}\u{16A70}-\u{16ABE}\u{16AD0}-\u{16AED}\u{16B00}-\u{16B2F}\u{16B40}-\u{16B43}\u{16B63}-\u{16B77}\u{16B7D}-\u{16B8F}\u{16D40}-\u{16D6C}\u{16E40}-\u{16E7F}\u{16F00}-\u{16F4A}\u{16F50}\u{16F93}-\u{16F9F}\u{16FE0}\u{16FE1}\u{16FE3}\u{17000}-\u{187F7}\u{18800}-\u{18CD5}\u{18CFF}-\u{18D08}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}\u{1B000}-\u{1B122}\u{1B132}\u{1B150}-\u{1B152}\u{1B155}\u{1B164}-\u{1B167}\u{1B170}-\u{1B2FB}\u{1BC00}-\u{1BC6A}\u{1BC70}-\u{1BC7C}\u{1BC80}-\u{1BC88}\u{1BC90}-\u{1BC99}\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}\u{1D6A8}-\u{1D6C0}\u{1D6C2}-\u{1D6DA}\u{1D6DC}-\u{1D6FA}\u{1D6FC}-\u{1D714}\u{1D716}-\u{1D734}\u{1D736}-\u{1D74E}\u{1D750}-\u{1D76E}\u{1D770}-\u{1D788}\u{1D78A}-\u{1D7A8}\u{1D7AA}-\u{1D7C2}\u{1D7C4}-\u{1D7CB}\u{1DF00}-\u{1DF1E}\u{1DF25}-\u{1DF2A}\u{1E030}-\u{1E06D}\u{1E100}-\u{1E12C}\u{1E137}-\u{1E13D}\u{1E14E}\u{1E290}-\u{1E2AD}\u{1E2C0}-\u{1E2EB}\u{1E4D0}-\u{1E4EB}\u{1E5D0}-\u{1E5ED}\u{1E5F0}\u{1E7E0}-\u{1E7E6}\u{1E7E8}-\u{1E7EB}\u{1E7ED}\u{1E7EE}\u{1E7F0}-\u{1E7FE}\u{1E800}-\u{1E8C4}\u{1E900}-\u{1E943}\u{1E94B}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}\u{20000}-\u{2A6DF}\u{2A700}-\u{2B739}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}\u{2EBF0}-\u{2EE5D}\u{2F800}-\u{2FA1D}\u{30000}-\u{3134A}\u{31350}-\u{323AF}]*$/u.test(e)},{name:"string",test:j},{name:"Chain",test:Be},{name:"Array",test:b},{name:"Matrix",test:_},{name:"DenseMatrix",test:H},{name:"SparseMatrix",test:G},{name:"Range",test:V},{name:"Index",test:Z},{name:"boolean",test:W},{name:"ResultSet",test:Y},{name:"Help",test:J},{name:"function",test:X},{name:"Date",test:ne},{name:"RegExp",test:ie},{name:"null",test:he},{name:"undefined",test:de},{name:"AccessorNode",test:ge},{name:"ArrayNode",test:ye},{name:"AssignmentNode",test:xe},{name:"BlockNode",test:be},{name:"ConditionalNode",test:ve},{name:"ConstantNode",test:ae},{name:"FunctionNode",test:Ae},{name:"FunctionAssignmentNode",test:Ne},{name:"IndexNode",test:Ee},{name:"Node",test:O},{name:"ObjectNode",test:Se},{name:"OperatorNode",test:oe},{name:"ParenthesisNode",test:Me},{name:"RangeNode",test:Ce},{name:"RelationalNode",test:Te},{name:"SymbolNode",test:se},{name:"Map",test:fe},{name:"Object",test:ce}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(e){if(r||ut(e),15<e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return n||lt(e),new n(e,0)}},{from:"BigNumber",to:"Complex",convert:function(e){return n||lt(e),new n(e.toNumber(),0)}},{from:"bigint",to:"number",convert:function(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+e+")");return Number(e)}},{from:"bigint",to:"BigNumber",convert:function(e){return r||ut(e),new r(e.toString())}},{from:"bigint",to:"Fraction",convert:function(e){return i||ct(e),new i(e)}},{from:"Fraction",to:"BigNumber",convert:function(e){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(e){return n||lt(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||ct(e);const t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(t){r||ut(t);try{return new r(t)}catch(e){throw new Error('Cannot convert "'+t+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(t){try{return BigInt(t)}catch(e){throw new Error('Cannot convert "'+t+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(t){i||ct(t);try{return new i(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(t){n||lt(t);try{return new n(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return r||ut(e),new r(+e)}},{from:"boolean",to:"bigint",convert:function(e){return BigInt(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||ct(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){if(t)return new t(e);throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,r)=>{var n=a.createError(e,t,r);if(["wrongType","mismatch"].includes(n.data.category)&&1===t.length&&$(t[0])&&r.some(e=>!e.params.includes(","))){const t=new TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw t.data=n.data,t}throw n},a.onMismatch=(e,t,r)=>{var n=a.createError(e,t,r);if(["wrongType","mismatch"].includes(n.data.category)&&1===t.length&&$(t[0])&&r.some(e=>!e.params.includes(","))){const t=new TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw t.data=n.data,t}throw n},a});function ut(e){throw new Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function lt(e){throw new Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function ct(e){throw new Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}const ft=s("ResultSet",[],()=>{function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return t.prototype.type="ResultSet",t.prototype.isResultSet=!0,t.prototype.valueOf=function(){return this.entries},t.prototype.toString=function(){return"["+this.entries.map(String).join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},t.fromJSON=function(e){return new t(e.entries)},t},{isClass:!0});var pt,mt,ht=9e15,dt=1e9,gt="0123456789abcdef",yt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",xt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",bt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ht,maxE:ht,crypto:!1},w=!0,vt="[DecimalError] ",wt=vt+"Invalid argument: ",Nt=vt+"Precision limit exceeded",At=vt+"crypto unavailable",Et="[object Decimal]",St=Math.floor,d=Math.pow,Mt=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ct=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Tt=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Bt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ft=1e7,Dt=yt.length-1,Ot=xt.length-1,o={toStringTag:Et};function _t(e){var t,r,n,i=e.length-1,a="",o=e[0];if(0<i){for(a+=o,t=1;t<i;t++)(r=7-(n=e[t]+"").length)&&(a+=Gt(r)),a+=n;(r=7-(n=(o=e[t])+"").length)&&(a+=Gt(r))}else if(0===o)return"0";for(;o%10==0;)o/=10;return a+o}function zt(e,t,r){if(e!==~~e||e<t||r<e)throw Error(wt+e)}function qt(e,t,r,n){for(var i,a,o=e[0];10<=o;o/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),o=d(10,7-t),a=e[i]%o|0,null==n?t<3?(0==t?a=a/100|0:1==t&&(a=a/10|0),r<4&&99999==a||3<r&&49999==a||5e4==a||0==a):(r<4&&a+1==o||3<r&&a+1==o/2)&&(e[i+1]/o/100|0)==d(10,t-2)-1||(a==o/2||0==a)&&!(e[i+1]/o/100|0):t<4?(0==t?a=a/1e3|0:1==t?a=a/100|0:2==t&&(a=a/10|0),(n||r<4)&&9999==a||!n&&3<r&&4999==a):((n||r<4)&&a+1==o||!n&&3<r&&a+1==o/2)&&(e[i+1]/o/1e3|0)==d(10,t-3)-1}function It(e,t,r){for(var n,i,a=[0],o=0,s=e.length;o<s;){for(i=a.length;i--;)a[i]*=t;for(a[0]+=gt.indexOf(e.charAt(o++)),n=0;n<a.length;n++)a[n]>r-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}o.absoluteValue=o.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),B(e)},o.ceil=function(){return B(new this.constructor(this),this.e+1,2)},o.clampedTo=o.clamp=function(e,t){var r=this.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(wt+t);return this.cmp(e)<0?e:0<this.cmp(t)?t:new r(this)},o.comparedTo=o.cmp=function(e){var t,r,n=this,i=n.d,a=(e=new n.constructor(e)).d,o=n.s,s=e.s;if(!i||!a)return o&&s?o!==s?o:i===a?0:!i^o<0?1:-1:NaN;if(!i[0]||!a[0])return i[0]?o:a[0]?-s:0;if(o!==s)return o;if(n.e!==e.e)return n.e>e.e^o<0?1:-1;for(t=0,r=(s=i.length)<(n=a.length)?s:n;t<r;++t)if(i[t]!==a[t])return i[t]>a[t]^o<0?1:-1;return s===n?0:n<s^o<0?1:-1},o.cosine=o.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n;if(t.isZero())return t;n=(n=t.d.length)<32?(1/er(4,r=Math.ceil(n/3))).toString():(r=16,"2.3283064365386962890625e-10"),e.precision+=r,t=Kt(e,1,t.times(n),new e(1));for(var i=r;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return e.precision-=r,t}(n,tr(n,r)),n.precision=e,n.rounding=t,B(2==mt||3==mt?r.neg():r,e,t,!0)):new n(1):new n(NaN)},o.cubeRoot=o.cbrt=function(){var e,t,r,n,i,a,o,s,u,l,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(w=!1,(a=c.s*d(c.s*c,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=_t(c.d),(a=((e=c.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=d(r,1/3),e=St((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=c.s),o=(e=f.precision)+3;;)if(l=(u=(s=n).times(s).times(s)).plus(c),n=N(l.plus(c).times(s),l.plus(u),o+2,1),_t(s.d).slice(0,o)===(r=_t(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(B(n,e+1,1),t=!n.times(n).times(n).eq(c));break}if(!i&&(B(s,e+1,0),s.times(s).times(s).eq(c))){n=s;break}o+=4,i=1}return w=!0,B(n,e,f.rounding,t)},o.decimalPlaces=o.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-St(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},o.dividedBy=o.div=function(e){return N(this,new this.constructor(e))},o.dividedToIntegerBy=o.divToInt=function(e){var t=this.constructor;return B(N(this,new t(e),0,1,1),t.precision,t.rounding)},o.equals=o.eq=function(e){return 0===this.cmp(e)},o.floor=function(){return B(new this.constructor(this),this.e+1,3)},o.greaterThan=o.gt=function(e){return 0<this.cmp(e)},o.greaterThanOrEqualTo=o.gte=function(e){e=this.cmp(e);return 1==e||0===e},o.hyperbolicCosine=o.cosh=function(){var e,t,r,n=(s=this).constructor,i=new n(1);if(!s.isFinite())return new n(s.s?1/0:NaN);if(s.isZero())return i;t=n.precision,r=n.rounding,n.precision=t+Math.max(s.e,s.sd())+4,n.rounding=1;for(var a,o=(o=s.d.length)<32?(1/er(4,e=Math.ceil(o/3))).toString():(e=16,"2.3283064365386962890625e-10"),s=Kt(n,1,s.times(o),new n(1),!0),u=e,l=new n(8);u--;)a=s.times(s),s=i.minus(a.times(l.minus(a.times(l))));return B(s,n.precision=t,n.rounding=r,!0)},o.hyperbolicSine=o.sinh=function(){var e,t,r,n=(o=this).constructor;if(!o.isFinite()||o.isZero())return new n(o);if(e=n.precision,t=n.rounding,n.precision=e+Math.max(o.e,o.sd())+4,n.rounding=1,(r=o.d.length)<3)o=Kt(n,2,o,o,!0);else for(var i,a=16<(a=1.4*Math.sqrt(r))?16:0|a,o=Kt(n,2,o=o.times(1/er(5,a)),o,!0),s=new n(5),u=new n(16),l=new n(20);a--;)i=o.times(o),o=o.times(s.plus(i.times(u.times(i).plus(l))));return B(o,n.precision=e,n.rounding=t,!0)},o.hyperbolicTangent=o.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,N(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},o.inverseCosine=o.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return-1!==r?0===r?e.isNeg()?$t(t,n,i):new t(0):new t(NaN):e.isZero()?$t(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=n,t.rounding=i,e.times(2))},o.inverseHyperbolicCosine=o.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,w=!1,r=r.times(r).minus(1).sqrt().plus(r),w=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},o.inverseHyperbolicSine=o.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,w=!1,r=r.times(r).plus(1).sqrt().plus(r),w=!0,n.precision=e,n.rounding=t,r.ln())},o.inverseHyperbolicTangent=o.atanh=function(){var e,t,r,n=this,i=n.constructor;return n.isFinite()?0<=n.e?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(e=i.precision,t=i.rounding,r=n.sd(),Math.max(r,e)<2*-n.e-1?B(new i(n),e,t,!0):(i.precision=r=r-n.e,n=N(n.plus(1),new i(1).minus(n),r+e,1),i.precision=e+4,i.rounding=1,n=n.ln(),i.precision=e,i.rounding=t,n.times(.5))):new i(NaN)},o.inverseSine=o.asin=function(){var e,t,r,n=this,i=n.constructor;return n.isZero()?new i(n):(e=n.abs().cmp(1),t=i.precision,r=i.rounding,-1!==e?0===e?((e=$t(i,t+4,r).times(.5)).s=n.s,e):new i(NaN):(i.precision=t+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=r,n.times(2)))},o.inverseTangent=o.atan=function(){var e,t,r,n,i,a,o,s,u,l=this,c=l.constructor,f=c.precision,p=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&f+4<=Ot)return(o=$t(c,f+4,p).times(.25)).s=l.s,o}else{if(!l.s)return new c(NaN);if(f+4<=Ot)return(o=$t(c,f+4,p).times(.5)).s=l.s,o}for(c.precision=s=f+10,c.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(w=!1,t=Math.ceil(s/7),n=1,u=l.times(l),o=new c(l),i=l;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<<r-1)),w=!0,B(o,c.precision=f,c.rounding=p,!0)},o.isFinite=function(){return!!this.d},o.isInteger=o.isInt=function(){return!!this.d&&St(this.e/7)>this.d.length-2},o.isNaN=function(){return!this.s},o.isNegative=o.isNeg=function(){return this.s<0},o.isPositive=o.isPos=function(){return 0<this.s},o.isZero=function(){return!!this.d&&0===this.d[0]},o.lessThan=o.lt=function(e){return this.cmp(e)<0},o.lessThanOrEqualTo=o.lte=function(e){return this.cmp(e)<1},o.logarithm=o.log=function(e){var t,r,n,i,a,o,s,u,l=this,c=l.constructor,f=c.precision,p=c.rounding;if(null==e)e=new c(10),t=!0;else{if(r=(e=new c(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new c(NaN);t=e.eq(10)}if(r=l.d,l.s<0||!r||!r[0]||l.eq(1))return new c(r&&!r[0]?-1/0:1!=l.s?NaN:r?0:1/0);if(t)if(1<r.length)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(w=!1,o=Jt(l,s=f+5),n=t?Lt(c,s+10):Jt(e,s),qt((u=N(o,n,s,1)).d,i=f,p))do{if(o=Jt(l,s+=10),n=t?Lt(c,s+10):Jt(e,s),u=N(o,n,s,1),!a){+_t(u.d).slice(i+1,i+15)+1==1e14&&(u=B(u,f+1,0));break}}while(qt(u.d,i+=10,p));return w=!0,B(u,f,p)},o.minus=o.sub=function(e){var t,r,n,i,a,o,s,u,l,c,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return p.s&&e.s?p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN):e=new m(NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,u=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else{if(!l[0])return new m(3===u?-0:0);e=new m(p)}return w?B(e,s,u):e}if(r=St(e.e/7),p=St(p.e/7),l=l.slice(),a=p-r){for(o=(c=a<0)?(t=l,a=-a,f.length):(t=f,r=p,l.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((c=(n=l.length)<(o=f.length))&&(o=n),n=0;n<o;n++)if(l[n]!=f[n]){c=l[n]<f[n];break}a=0}for(c&&(t=l,l=f,f=t,e.s=-e.s),o=l.length,n=f.length-o;0<n;--n)l[o++]=0;for(n=f.length;a<n;){if(l[--n]<f[n]){for(i=n;i&&0===l[--i];)l[i]=Ft-1;--l[i],l[n]+=Ft}l[n]-=f[n]}for(;0===l[--o];)l.pop();for(;0===l[0];l.shift())--r;return l[0]?(e.d=l,e.e=jt(l,r),w?B(e,s,u):e):new m(3===u?-0:0)},o.modulo=o.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?B(new n(r),n.precision,n.rounding):(w=!1,9==n.modulo?(t=N(r,e.abs(),0,3,1)).s*=e.s:t=N(r,e,0,n.modulo,1),t=t.times(e),w=!0,r.minus(t))},o.naturalExponential=o.exp=function(){return Yt(this)},o.naturalLogarithm=o.ln=function(){return Jt(this)},o.negated=o.neg=function(){var e=new this.constructor(this);return e.s=-e.s,B(e)},o.plus=o.add=function(e){var t,r,n,i,a,o,s,u,l=this,c=l.constructor;if(e=new c(e),!l.d||!e.d)return l.s&&e.s?l.d||(e=new c(e.d||l.s===e.s?l:NaN)):e=new c(NaN),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(s=l.d,u=e.d,a=c.precision,o=c.rounding,!s[0]||!u[0])return u[0]||(e=new c(l)),w?B(e,a,o):e;if(c=St(l.e/7),l=St(e.e/7),s=s.slice(),n=c-l){for(i=n<0?(r=s,n=-n,u.length):(r=u,l=c,s.length),n>(i=(c=Math.ceil(a/7))>i?c+1:i+1)&&(n=i,r.length=1),r.reverse();n--;)r.push(0);r.reverse()}for((i=s.length)-(n=u.length)<0&&(n=i,r=u,u=s,s=r),t=0;n;)t=(s[--n]=s[n]+u[n]+t)/Ft|0,s[n]%=Ft;for(t&&(s.unshift(t),++l),i=s.length;0==s[--i];)s.pop();return e.d=s,e.e=jt(s,l),w?B(e,a,o):e},o.precision=o.sd=function(e){var t;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(wt+e);return this.d?(t=Ht(this.d),e&&this.e+1>t&&(t=this.e+1)):t=NaN,t},o.round=function(){var e=this.constructor;return B(new e(this),this.e+1,e.rounding)},o.sine=o.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:Kt(e,2,t,t);r=16<(r=1.4*Math.sqrt(n))?16:0|r,t=Kt(e,2,t=t.times(1/er(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,tr(n,r)),n.precision=e,n.rounding=t,B(2<mt?r.neg():r,e,t,!0)):new n(NaN)},o.squareRoot=o.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,l=o.s,c=o.constructor;if(1!==l||!s||!s[0])return new c(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(w=!1,n=0==(l=Math.sqrt(+o))||l==1/0?(((t=_t(s)).length+u)%2==0&&(t+="0"),l=Math.sqrt(t),u=St((u+1)/2)-(u<0||u%2),new c(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):new c(l.toString()),r=(u=c.precision)+3;;)if(n=(a=n).plus(N(o,a,r+2,1)).times(.5),_t(a.d).slice(0,r)===(t=_t(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(B(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(B(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return w=!0,B(n,u,c.rounding,e)},o.tangent=o.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=N(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,B(2==mt||4==mt?r.neg():r,e,t,!0)):new n(NaN)},o.times=o.mul=function(e){var t,r,n,i,a,o,s,u,l,c=this.constructor,f=this.d,p=(e=new c(e)).d;if(e.s*=this.s,!(f&&f[0]&&p&&p[0]))return new c(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:f&&p?0*e.s:e.s/0);for(r=St(this.e/7)+St(e.e/7),(u=f.length)<(l=p.length)&&(a=f,f=p,p=a,o=u,u=l,l=o),a=[],n=o=u+l;n--;)a.push(0);for(n=l;0<=--n;){for(t=0,i=u+n;n<i;)s=a[i]+p[n]*f[i-n-1]+t,a[i--]=s%Ft|0,t=s/Ft|0;a[i]=(a[i]+t)%Ft|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=jt(a,r),w?B(e,c.precision,c.rounding):e},o.toBinary=function(e,t){return rr(this,2,e,t)},o.toDecimalPlaces=o.toDP=function(e,t){var r=this.constructor,n=new r(this);return void 0===e?n:(zt(e,0,dt),void 0===t?t=r.rounding:zt(t,0,8),B(n,e+n.e+1,t))},o.toExponential=function(e,t){var r=this,n=r.constructor,n=void 0===e?Ut(r,!0):(zt(e,0,dt),void 0===t?t=n.rounding:zt(t,0,8),Ut(r=B(new n(r),e+1,t),!0,e+1));return r.isNeg()&&!r.isZero()?"-"+n:n},o.toFixed=function(e,t){var r=this,n=r.constructor,t=void 0===e?Ut(r):(zt(e,0,dt),void 0===t?t=n.rounding:zt(t,0,8),Ut(n=B(new n(r),e+r.e+1,t),!1,e+n.e+1));return r.isNeg()&&!r.isZero()?"-"+t:t},o.toFraction=function(e){var t,r,n,i,a,o,s,u,l,c,f=this,p=f.d,m=f.constructor;if(!p)return new m(f);if(u=r=new m(1),n=s=new m(0),l=(a=(t=new m(n)).e=Ht(p)-f.e-1)%7,t.d[0]=d(10,l<0?7+l:l),null==e)e=0<a?t:u;else{if(!(o=new m(e)).isInt()||o.lt(u))throw Error(wt+o);e=o.gt(t)?0<a?t:u:o}for(w=!1,o=new m(_t(p)),l=m.precision,m.precision=a=7*p.length*2;c=N(o,t,0,1,1),1!=(i=r.plus(c.times(n))).cmp(e);)r=n,n=i,i=u,u=s.plus(c.times(i)),s=i,i=t,t=o.minus(c.times(i)),o=i;return i=N(e.minus(r),n,0,1,1),s=s.plus(i.times(u)),r=r.plus(i.times(n)),s.s=u.s=f.s,p=N(u,n,a,1).minus(f).abs().cmp(N(s,r,a,1).minus(f).abs())<1?[u,n]:[s,r],m.precision=l,w=!0,p},o.toHexadecimal=o.toHex=function(e,t){return rr(this,16,e,t)},o.toNearest=function(e,t){var r=(n=this).constructor,n=new r(n);if(null==e){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),void 0===t?t=r.rounding:zt(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(w=!1,n=N(n,e,0,t,1).times(e),w=!0,B(n)):(e.s=n.s,n=e),n},o.toNumber=function(){return+this},o.toOctal=function(e,t){return rr(this,8,e,t)},o.toPower=o.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,l=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(d(+s,l));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return B(s,n,a);if((t=St(e.e/7))>=e.d.length-1&&(r=l<0?-l:l)<=9007199254740991)return i=Vt(u,s,r,n),e.s<0?new u(1).div(i):B(i,n,a);if((o=s.s)<0){if(t<e.d.length-1)return new u(NaN);if(1&e.d[t]||(o=1),0==s.e&&1==s.d[0]&&1==s.d.length)return s.s=o,s}return(t=0!=(r=d(+s,l))&&isFinite(r)?new u(r+"").e:St(l*(Math.log("0."+_t(s.d))/Math.LN10+s.e+1)))>u.maxE+1||t<u.minE-1?new u(0<t?o/0:0):(w=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=Yt(e.times(Jt(s,n+r)),n)).d&&qt((i=B(i,n+5,1)).d,n,a)&&(+_t((i=B(Yt(e.times(Jt(s,(t=n+10)+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=B(i,n+1,0))),i.s=o,w=!0,B(i,n,u.rounding=a))},o.toPrecision=function(e,t){var r=this,n=r.constructor,t=void 0===e?Ut(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(zt(e,1,dt),void 0===t?t=n.rounding:zt(t,0,8),Ut(r=B(new n(r),e,t),e<=r.e||r.e<=n.toExpNeg,e));return r.isNeg()&&!r.isZero()?"-"+t:t},o.toSignificantDigits=o.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(zt(e,1,dt),void 0===t?t=r.rounding:zt(t,0,8)),B(new r(this),e,t)},o.toString=function(){var e=this,t=e.constructor,t=Ut(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},o.truncated=o.trunc=function(){return B(new this.constructor(this),this.e+1,1)},o.valueOf=o.toJSON=function(){var e=this,t=e.constructor,t=Ut(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+t:t};var N=function(e,t,r,n,i,a){var o,s,u,l,c,f,p,m,h,d,g,y,x,b,v,w,N,A,E,S=e.constructor,M=e.s==t.s?1:-1,C=e.d,T=t.d;if(!(C&&C[0]&&T&&T[0]))return new S(e.s&&t.s&&(C?!T||C[0]!=T[0]:T)?C&&0==C[0]||!T?0*M:M/0:NaN);for(s=a?(c=1,e.e-t.e):(a=Ft,St(e.e/(c=7))-St(t.e/c)),A=T.length,w=C.length,h=(M=new S(M)).d=[],u=0;T[u]==(C[u]||0);u++);if(T[u]>(C[u]||0)&&s--,null==r?(x=r=S.precision,n=S.rounding):x=i?r+(e.e-t.e)+1:r,x<0)h.push(1),f=!0;else{if(x=x/c+2|0,u=0,1==A){for(T=T[l=0],x++;(u<w||l)&&x--;u++)b=l*a+(C[u]||0),h[u]=b/T|0,l=b%T|0;f=l||u<w}else{for(1<(l=a/(T[0]+1)|0)&&(T=kt(T,l,a),C=kt(C,l,a),A=T.length,w=C.length),v=A,g=(d=C.slice(0,A)).length;g<A;)d[g++]=0;for((E=T.slice()).unshift(0),N=T[0],T[1]>=a/2&&++N;l=0,(o=Rt(T,d,A,g))<0?(y=d[0],1<(l=(y=A!=g?y*a+(d[1]||0):y)/N|0)?1==(o=Rt(p=kt(T,l=a<=l?a-1:l,a),d,m=p.length,g=d.length))&&(l--,Pt(p,A<m?E:T,m,a)):(0==l&&(o=l=1),p=T.slice()),(m=p.length)<g&&p.unshift(0),Pt(d,p,g,a),-1==o&&(o=Rt(T,d,A,g=d.length))<1&&(l++,Pt(d,A<g?E:T,g,a)),g=d.length):0===o&&(l++,d=[0]),h[u++]=l,o&&d[0]?d[g++]=C[v]||0:(d=[C[v]],g=1),(v++<w||void 0!==d[0])&&x--;);f=void 0!==d[0]}h[0]||h.shift()}if(1==c)M.e=s,pt=f;else{for(u=1,l=h[0];10<=l;l/=10)u++;M.e=u+s*c-1,B(M,i?r+M.e+1:r,n,f)}return M};function kt(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function Rt(e,t,r,n){var i,a;if(r!=n)a=n<r?1:-1;else for(i=a=0;i<r;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function Pt(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&1<e.length;)e.shift()}function B(e,t,r,n){var i,a,o,s,u,l,c,f,p=e.constructor;e:if(null!=t){if(!(c=e.d))return e;for(i=1,s=c[0];10<=s;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=c[f=0])/d(10,i-o-1)%10|0;else if((f=Math.ceil((a+1)/7))>=(s=c.length)){if(!n)break e;for(;s++<=f;)c.push(0);l=u=0,o=(a%=7)-7+(i=1)}else{for(l=s=c[f],i=1;10<=s;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/d(10,i-o-1)%10|0}if(n=n||t<0||void 0!==c[f+1]||(o<0?l:l%d(10,i-o-1)),u=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):5<u||5==u&&(4==r||n||6==r&&(0<a?0<o?l/d(10,i-o):0:c[f-1])%10&1||r==(e.s<0?8:7)),t<1||!c[0])return c.length=0,u?(t-=e.e+1,c[0]=d(10,(7-t%7)%7),e.e=-t||0):c[0]=e.e=0,e;if(0==a?(c.length=f,s=1,f--):(c.length=f+1,s=d(10,7-a),c[f]=0<o?(l/d(10,i-o)%d(10,o)|0)*s:0),u)for(;;){if(0==f){for(a=1,o=c[0];10<=o;o/=10)a++;for(o=c[0]+=s,s=1;10<=o;o/=10)s++;a!=s&&(e.e++,c[0]==Ft&&(c[0]=1));break}if(c[f]+=s,c[f]!=Ft)break;c[f--]=0,s=1}for(a=c.length;0===c[--a];)c.pop()}return w&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function Ut(e,t,r){if(!e.isFinite())return Xt(e);var n,i=e.e,a=_t(e.d),o=a.length;return t?(r&&0<(n=r-o)?a=a.charAt(0)+"."+a.slice(1)+Gt(n):1<o&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+Gt(-i-1)+a,r&&0<(n=r-o)&&(a+=Gt(n))):o<=i?(a+=Gt(i+1-o),r&&0<(n=r-i-1)&&(a=a+"."+Gt(n))):((n=i+1)<o&&(a=a.slice(0,n)+"."+a.slice(n)),r&&0<(n=r-o)&&(i+1===o&&(a+="."),a+=Gt(n))),a}function jt(e,t){var r=e[0];for(t*=7;10<=r;r/=10)t++;return t}function Lt(e,t,r){if(Dt<t)throw w=!0,r&&(e.precision=r),Error(Nt);return B(new e(yt),t,1,!0)}function $t(e,t,r){if(Ot<t)throw Error(Nt);return B(new e(xt),t,r,!0)}function Ht(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];10<=t;t/=10)r++}return r}function Gt(e){for(var t="";e--;)t+="0";return t}function Vt(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(w=!1;;){if(r%2&&nr((a=a.times(t)).d,o)&&(i=!0),0===(r=St(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}nr((t=t.times(t)).d,o)}return w=!0,a}function Zt(e){return 1&e.d[e.d.length-1]}function Wt(e,t,r){for(var n,i,a=new e(t[0]),o=0;++o<t.length;){if(!(i=new e(t[o])).s){a=i;break}((n=a.cmp(i))===r||0===n&&a.s===r)&&(a=i)}return a}function Yt(e,t){var r,n,i,a,o,s,u,l=0,c=0,f=0,p=e.constructor,m=p.rounding,h=p.precision;if(!e.d||!e.d[0]||17<e.e)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(u=null==t?(w=!1,h):t,s=new p(.03125);-2<e.e;)e=e.times(s),f+=5;for(u+=n=Math.log(d(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=B(a.times(e),u,1),r=r.times(++c),_t((s=o.plus(N(a,r,u,1))).d).slice(0,u)===_t(o.d).slice(0,u)){for(i=f;i--;)o=B(o.times(o),u,1);if(null!=t)return p.precision=h,o;if(!(l<3&&qt(o.d,u-n,m,l)))return B(o,p.precision=h,m,w=!0);p.precision=u+=10,r=a=s=new p(1),c=0,l++}o=s}}function Jt(e,t){var r,n,i,a,o,s,u,l,c,f,p,m=1,h=e,d=h.d,g=h.constructor,y=g.rounding,x=g.precision;if(h.s<0||!d||!d[0]||!h.e&&1==d[0]&&1==d.length)return new g(d&&!d[0]?-1/0:1!=h.s?NaN:d?0:h);if(c=null==t?(w=!1,x):t,g.precision=c+=10,n=(r=_t(d)).charAt(0),!(Math.abs(a=h.e)<15e14))return l=Lt(g,c+2,x).times(a+""),h=Jt(new g(n+"."+r.slice(1)),c-10).plus(l),g.precision=x,null==t?B(h,x,y,w=!0):h;for(;n<7&&1!=n||1==n&&3<r.charAt(1);)n=(r=_t((h=h.times(e)).d)).charAt(0),m++;for(a=h.e,1<n?(h=new g("0."+r),a++):h=new g(n+"."+r.slice(1)),u=o=h=N((f=h).minus(1),h.plus(1),c,1),p=B(h.times(h),c,1),i=3;;){if(o=B(o.times(p),c,1),_t((l=u.plus(N(o,new g(i),c,1))).d).slice(0,c)===_t(u.d).slice(0,c)){if(u=u.times(2),0!==a&&(u=u.plus(Lt(g,c+2,x).times(a+""))),u=N(u,new g(m),c,1),null!=t)return g.precision=x,u;if(!qt(u.d,c-10,y,s))return B(u,g.precision=x,y,w=!0);g.precision=c+=10,l=o=h=N(f.minus(1),f.plus(1),c,1),p=B(h.times(h),c,1),i=s=1}u=l,i+=2}}function Xt(e){return String(e.s*e.s/0)}function Qt(e,t){var r,n,i;for(0<(n=(t=-1<(r=t.indexOf("."))?t.replace(".",""):t).search(/e/i))?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=7;n<i;)e.d.push(+t.slice(n,n+=7));n=7-(t=t.slice(n)).length}else n-=i;for(;n--;)t+="0";e.d.push(+t),w&&(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 Kt(e,t,r,n,i){var a,o,s,u,l=e.precision,c=Math.ceil(l/7);for(w=!1,u=r.times(r),s=new e(n);;){if(o=N(s.times(u),new e(t++*t++),l,1),s=i?n.plus(o):n.minus(o),n=N(o.times(u),new e(t++*t++),l,1),void 0!==(o=s.plus(n)).d[c]){for(a=c;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return w=!0,o.d.length=c+1,o}function er(e,t){for(var r=e;--t;)r*=e;return r}function tr(e,t){var r,n=t.s<0,e=$t(e,e.precision,1),i=e.times(.5);if((t=t.abs()).lte(i))return mt=n?4:1,t;if((r=t.divToInt(e)).isZero())mt=n?3:2;else{if((t=t.minus(r.times(e))).lte(i))return mt=Zt(r)?n?2:3:n?4:1,t;mt=Zt(r)?n?1:4:n?3:2}return t.minus(e).abs()}function rr(e,t,r,n){var i,a,o,s,u,l,c,f,p=e.constructor,m=void 0!==r;if(m?(zt(r,1,dt),void 0===n?n=p.rounding:zt(n,0,8)):(r=p.precision,n=p.rounding),e.isFinite()){for(m?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,0<=(o=(l=Ut(e)).indexOf("."))&&(l=l.replace(".",""),(f=new p(1)).e=l.length-o,f.d=It(Ut(f),10,i),f.e=f.d.length),a=s=(c=It(l,10,i)).length;0==c[--s];)c.pop();if(c[0]){if(o<0?a--:((e=new p(e)).d=c,e.e=a,c=(e=N(e,f,r,n,0,i)).d,a=e.e,u=pt),o=c[r],p=i/2,u=u||void 0!==c[r+1],u=n<4?(void 0!==o||u)&&(0===n||n===(e.s<0?3:2)):p<o||o===p&&(4===n||u||6===n&&1&c[r-1]||n===(e.s<0?8:7)),c.length=r,u)for(;++c[--r]>i-1;)c[r]=0,r||(++a,c.unshift(1));for(s=c.length;!c[s-1];--s);for(o=0,l="";o<s;o++)l+=gt.charAt(c[o]);if(m){if(1<s)if(16==t||8==t){for(o=16==t?4:3,--s;s%o;s++)l+="0";for(s=(c=It(l,i,t)).length;!c[s-1];--s);for(o=1,l="1.";o<s;o++)l+=gt.charAt(c[o])}else l=l.charAt(0)+"."+l.slice(1);l=l+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)l="0"+l;l="0."+l}else if(++a>s)for(a-=s;a--;)l+="0";else a<s&&(l=l.slice(0,a)+"."+l.slice(a))}else l=m?"0p+0":"0";l=(16==t?"0x":2==t?"0b":8==t?"0o":"")+l}else l=Xt(e);return e.s<0?"-"+l:l}function nr(e,t){return e.length>t&&(e.length=t,1)}function ir(e){return new this(e).abs()}function ar(e){return new this(e).acos()}function or(e){return new this(e).acosh()}function sr(e,t){return new this(e).plus(t)}function ur(e){return new this(e).asin()}function lr(e){return new this(e).asinh()}function cr(e){return new this(e).atan()}function fr(e){return new this(e).atanh()}function pr(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?$t(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=$t(this,a,1).times(.5)).s=e.s:r=t.s<0?(this.precision=a,this.rounding=1,r=this.atan(N(e,t,a,1)),t=$t(this,a,1),this.precision=n,this.rounding=i,e.s<0?r.minus(t):r.plus(t)):this.atan(N(e,t,a,1)):(r=$t(this,a,1).times(0<t.s?.25:.75)).s=e.s:r=new this(NaN),r}function mr(e){return new this(e).cbrt()}function hr(e){return B(e=new this(e),e.e+1,2)}function dr(e,t,r){return new this(e).clamp(t,r)}function gr(e){if(!e||"object"!=typeof e)throw Error(vt+"Object expected");for(var t,r,n=!0===e.defaults,i=["precision",1,dt,"rounding",0,8,"toExpNeg",-ht,0,"toExpPos",0,ht,"maxE",0,ht,"minE",-ht,0,"modulo",0,9],a=0;a<i.length;a+=3)if(t=i[a],n&&(this[t]=bt[t]),void 0!==(r=e[t])){if(!(St(r)===r&&i[a+1]<=r&&r<=i[a+2]))throw Error(wt+t+": "+r);this[t]=r}if(t="crypto",n&&(this[t]=bt[t]),void 0!==(r=e[t])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(wt+t+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(At);this[t]=!0}else this[t]=!1}return this}function yr(e){return new this(e).cos()}function xr(e){return new this(e).cosh()}function br(e,t){return new this(e).div(t)}function vr(e){return new this(e).exp()}function wr(e){return B(e=new this(e),e.e+1,3)}function Nr(){var e,t,r=new this(0);for(w=!1,e=0;e<arguments.length;)if((t=new this(arguments[e++])).d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return w=!0,new this(1/0);r=t}return w=!0,r.sqrt()}function Ar(e){return e instanceof Hr||e&&e.toStringTag===Et||!1}function Er(e){return new this(e).ln()}function Sr(e,t){return new this(e).log(t)}function Mr(e){return new this(e).log(2)}function Cr(e){return new this(e).log(10)}function Tr(){return Wt(this,arguments,-1)}function Br(){return Wt(this,arguments,1)}function Fr(e,t){return new this(e).mod(t)}function Dr(e,t){return new this(e).mul(t)}function Or(e,t){return new this(e).pow(t)}function _r(e){var t,r,n,i,a=0,o=new this(1),s=[];if(void 0===e?e=this.precision:zt(e,1,dt),n=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));a<n;)429e7<=(i=t[a])?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(At);for(t=crypto.randomBytes(n*=4);a<n;)214e7<=(i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((127&t[a+3])<<24))?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a<n;)s[a++]=1e7*Math.random()|0;for(e%=7,(n=s[--a])&&e&&(i=d(10,7-e),s[a]=(n/i|0)*i);0===s[a];a--)s.pop();if(a<0)s=[r=0];else{for(r=-1;0===s[0];r-=7)s.shift();for(n=1,i=s[0];10<=i;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function zr(e){return B(e=new this(e),e.e+1,this.rounding)}function qr(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Ir(e){return new this(e).sin()}function kr(e){return new this(e).sinh()}function Rr(e){return new this(e).sqrt()}function Pr(e,t){return new this(e).sub(t)}function Ur(){var e=0,t=arguments,r=new this(t[e]);for(w=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return w=!0,B(r,this.precision,this.rounding)}function jr(e){return new this(e).tan()}function Lr(e){return new this(e).tanh()}function $r(e){return B(e=new this(e),e.e+1,1)}o[Symbol.for("nodejs.util.inspect.custom")]=o.toString,o[Symbol.toStringTag]="Decimal";var Hr=o.constructor=function e(t){var r,n,i;function a(e){var t,r,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,Ar(e))return i.s=e.s,void(w?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e<a.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d&&e.d.slice()));if("number"==(n=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(t=0,r=e;10<=r;r/=10)t++;return void(w?a.maxE<t?(i.e=NaN,i.d=null):t<a.minE?(i.e=0,i.d=[0]):(i.e=t,i.d=[e]):(i.e=t,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):Qt(i,e.toString())}if("string"==n)return 45===(r=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===r&&(e=e.slice(1)),i.s=1),(Bt.test(e)?Qt:function(e,t){var r,n,i,a,o,s,u,l;if(-1<t.indexOf("_")){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Bt.test(t))return Qt(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ct.test(t))r=16,t=t.toLowerCase();else if(Mt.test(t))r=2;else{if(!Tt.test(t))throw Error(wt+t);r=8}for(o=0<=(a=(t=0<(a=t.search(/p/i))?(u=+t.slice(a+1),t.substring(2,a)):t.slice(2)).indexOf(".")),n=e.constructor,o&&(a=(s=(t=t.replace(".","")).length)-a,i=Vt(n,new n(r),a,2*a)),a=t=(l=It(t,r,Ft)).length-1;0===l[a];--a)l.pop();return a<0?new n(0*e.s):(e.e=jt(l,t),e.d=l,w=!1,o&&(e=N(e,i,4*s)),u&&(e=e.times(Math.abs(u)<54?d(2,u):Hr.pow(2,u))),w=!0,e)})(i,e);if("bigint"==n)return e<0?(e=-e,i.s=-1):i.s=1,Qt(i,e.toString());throw Error(wt+e)}if(a.prototype=o,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=gr,a.clone=e,a.isDecimal=Ar,a.abs=ir,a.acos=ar,a.acosh=or,a.add=sr,a.asin=ur,a.asinh=lr,a.atan=cr,a.atanh=fr,a.atan2=pr,a.cbrt=mr,a.ceil=hr,a.clamp=dr,a.cos=yr,a.cosh=xr,a.div=br,a.exp=vr,a.floor=wr,a.hypot=Nr,a.ln=Er,a.log=Sr,a.log10=Cr,a.log2=Mr,a.max=Tr,a.min=Br,a.mod=Fr,a.mul=Dr,a.pow=Or,a.random=_r,a.round=zr,a.sign=qr,a.sin=Ir,a.sinh=kr,a.sqrt=Rr,a.sub=Pr,a.sum=Ur,a.tan=jr,a.tanh=Lr,a.trunc=$r,(t=void 0===t?{}:t)&&!0!==t.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<i.length;)t.hasOwnProperty(n=i[r++])||(t[n]=this[n]);return a.config(t),a}(bt),yt=new Hr(yt),xt=new Hr(xt);function Gr(e,t){return(e=Math.abs(e))<(t=Math.abs(t))&&([e,t]=[t,e]),e<1e8?Math.sqrt(e*e+t*t):(t/=e,e*Math.sqrt(1+t*t))}const Vr=Hr,Zr=s("BigNumber",["?on","config"],e=>{let{on:t,config:r}=e;const n=Vr.clone({precision:r.precision,modulo:Vr.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(e){return new n(e.value)},t&&t("config",function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})}),n},{isClass:!0}),Wr=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},Yr=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},Jr=function(){throw SyntaxError("Invalid Param")};function Xr(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):(e*=.5,t*=.5,.5*Math.log(e*e+t*t)+Math.LN2)}function Qr(e,n){const i=Kr;if(null==e)i.re=i.im=0;else if(void 0!==n)i.re=e,i.im=n;else switch(typeof e){case"object":if("im"in e&&"re"in e)i.re=e.re,i.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return u.INFINITY;i.re=e.abs*Math.cos(e.arg),i.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return u.INFINITY;i.re=e.r*Math.cos(e.phi),i.im=e.r*Math.sin(e.phi)}else 2===e.length?(i.re=e[0],i.im=e[1]):Jr();break;case"string":i.im=i.re=0;const n=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let t=1,r=0;null===n&&Jr();for(let e=0;e<n.length;e++){var a=n[e];" "!==a&&"\t"!==a&&"\n"!==a&&("+"===a?t++:"-"===a?r++:t=r=("i"===a||"I"===a?(t+r===0&&Jr()," "===n[e+1]||isNaN(n[e+1])?i.im+=parseFloat((r%2?"-":"")+"1"):(i.im+=parseFloat((r%2?"-":"")+n[e+1]),e++)):(t+r!==0&&!isNaN(a)||Jr(),"i"===n[e+1]||"I"===n[e+1]?(i.im+=parseFloat((r%2?"-":"")+a),e++):i.re+=parseFloat((r%2?"-":"")+a)),0))}0<t+r&&Jr();break;case"number":i.im=0,i.re=e;break;default:Jr()}return isNaN(i.re)||isNaN(i.im),i}const Kr={re:0,im:0};function u(e,t){if(!(this instanceof u))return new u(e,t);e=Qr(e,t);this.re=e.re,this.im=e.im}u.prototype={re:0,im:0,sign:function(){var e=Gr(this.re,this.im);return new u(this.re/e,this.im/e)},add:function(e,t){var e=Qr(e,t),t=this.isInfinite(),r=!(isFinite(e.re)&&isFinite(e.im));return t||r?t&&r?u.NAN:u.INFINITY:new u(this.re+e.re,this.im+e.im)},sub:function(e,t){var e=Qr(e,t),t=this.isInfinite(),r=!(isFinite(e.re)&&isFinite(e.im));return t||r?t&&r?u.NAN:u.INFINITY:new u(this.re-e.re,this.im-e.im)},mul:function(e,t){var e=Qr(e,t),t=this.isInfinite(),r=!(isFinite(e.re)&&isFinite(e.im)),n=0===this.re&&0===this.im,i=0===e.re&&0===e.im;return t&&i||r&&n?u.NAN:t||r?u.INFINITY:0===e.im&&0===this.im?new u(this.re*e.re,0):new u(this.re*e.re-this.im*e.im,this.re*e.im+this.im*e.re)},div:function(e,t){var r=Qr(e,t),e=this.isInfinite(),t=!(isFinite(r.re)&&isFinite(r.im)),n=0===this.re&&0===this.im,i=0===r.re&&0===r.im;if(n&&i||e&&t)return u.NAN;if(i||e)return u.INFINITY;if(n||t)return u.ZERO;if(0===r.im)return new u(this.re/r.re,this.im/r.re);if(Math.abs(r.re)<Math.abs(r.im)){const e=r.re/r.im,t=r.re*e+r.im;return new u((this.re*e+this.im)/t,(this.im*e-this.re)/t)}{const e=r.im/r.re,t=r.im*e+r.re;return new u((this.re+this.im*e)/t,(this.im-this.re*e)/t)}},pow:function(e,t){var r=Qr(e,t),e=0===this.re&&0===this.im;if(0===r.re&&0===r.im)return u.ONE;if(0===r.im){if(0===this.im&&0<this.re)return new u(Math.pow(this.re,r.re),0);if(0===this.re)switch((r.re%4+4)%4){case 0:return new u(Math.pow(this.im,r.re),0);case 1:return new u(0,Math.pow(this.im,r.re));case 2:return new u(-Math.pow(this.im,r.re),0);case 3:return new u(0,-Math.pow(this.im,r.re))}}if(e&&0<r.re)return u.ZERO;var t=Math.atan2(this.im,this.re),e=Xr(this.re,this.im),n=Math.exp(r.re*e-r.im*t),e=r.im*e+r.re*t;return new u(n*Math.cos(e),n*Math.sin(e))},sqrt:function(){var e=this.re,t=this.im;if(0===t)return 0<=e?new u(Math.sqrt(e),0):new u(0,Math.sqrt(-e));var r=Gr(e,t),r=Math.sqrt(.5*(r+Math.abs(e))),n=Math.abs(t)/(2*r);return 0<=e?new u(r,t<0?-n:n):new u(n,t<0?-r:r)},exp:function(){var e=Math.exp(this.re);return 0===this.im?new u(e,0):new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(e<-t||t<e)return Math.cos(e)-1;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)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return 0===t&&0<e?new u(Math.log(e),0):new u(Xr(e,t),Math.atan2(t,e))},abs:function(){return Gr(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var e=this.re,t=this.im;return new u(Math.sin(e)*Wr(t),Math.cos(e)*Yr(t))},cos:function(){var e=this.re,t=this.im;return new u(Math.cos(e)*Wr(t),-Math.sin(e)*Yr(t))},tan:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)+Wr(t);return new u(Math.sin(e)/r,Yr(t)/r)},cot:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)-Wr(t);return new u(-Math.sin(e)/r,Yr(t)/r)},sec:function(){var e=this.re,t=this.im,r=.5*Wr(2*t)+.5*Math.cos(2*e);return new u(Math.cos(e)*Wr(t)/r,Math.sin(e)*Yr(t)/r)},csc:function(){var e=this.re,t=this.im,r=.5*Wr(2*t)-.5*Math.cos(2*e);return new u(Math.sin(e)*Wr(t)/r,-Math.cos(e)*Yr(t)/r)},asin:function(){var e=this.re,t=this.im,r=new u(t*t-e*e+1,-2*e*t).sqrt(),t=new u(r.re-t,r.im+e).log();return new u(t.im,-t.re)},acos:function(){var e=this.re,t=this.im,r=new u(t*t-e*e+1,-2*e*t).sqrt(),t=new u(r.re-t,r.im+e).log();return new u(Math.PI/2-t.im,t.re)},atan:function(){var e=this.re,t=this.im;if(0===e){if(1===t)return new u(0,1/0);if(-1===t)return new u(0,-1/0)}var r=e*e+(1-t)*(1-t),t=new u((1-t*t-e*e)/r,-2*e/r).log();return new u(-.5*t.im,.5*t.re)},acot:function(){var e=this.re,t=this.im;if(0===t)return new u(Math.atan2(1,e),0);var r=e*e+t*t;return(0!=r?new u(e/r,-t/r):new u(0!==e?e/0:0,0!==t?-t/0:0)).atan()},asec:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,1/0);var r=e*e+t*t;return(0!=r?new u(e/r,-t/r):new u(0!==e?e/0:0,0!==t?-t/0:0)).acos()},acsc:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(Math.PI/2,1/0);var r=e*e+t*t;return(0!=r?new u(e/r,-t/r):new u(0!==e?e/0:0,0!==t?-t/0:0)).asin()},sinh:function(){var e=this.re,t=this.im;return new u(Yr(e)*Math.cos(t),Wr(e)*Math.sin(t))},cosh:function(){var e=this.re,t=this.im;return new u(Wr(e)*Math.cos(t),Yr(e)*Math.sin(t))},tanh:function(){var e=2*this.re,t=2*this.im,r=Wr(e)+Math.cos(t);return new u(Yr(e)/r,Math.sin(t)/r)},coth:function(){var e=2*this.re,t=2*this.im,r=Wr(e)-Math.cos(t);return new u(Yr(e)/r,-Math.sin(t)/r)},csch:function(){var e=this.re,t=this.im,r=Math.cos(2*t)-Wr(2*e);return new u(-2*Yr(e)*Math.cos(t)/r,2*Wr(e)*Math.sin(t)/r)},sech:function(){var e=this.re,t=this.im,r=Math.cos(2*t)+Wr(2*e);return new u(2*Wr(e)*Math.cos(t)/r,-2*Yr(e)*Math.sin(t)/r)},asinh:function(){var e=this.im;this.im=-this.re,this.re=e;const t=this.asin();return this.re=-this.im,this.im=e,e=t.re,t.re=-t.im,t.im=e,t},acosh:function(){const e=this.acos();var t;return e.im<=0?(t=e.re,e.re=-e.im,e.im=t):(t=e.im,e.im=-e.re,e.re=t),e},atanh:function(){const e=this.re,t=this.im,r=1<e&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!=a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),s=o.re;return o.re=Xr(o.re,o.im)/2,o.im=Math.atan2(o.im,s)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return(0!=r?new u(e/r,-t/r):new u(0!==e?e/0:0,0!==t?-t/0:0)).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return(0!=r?new u(e/r,-t/r):new u(0!==e?e/0:0,0!==t?-t/0:0)).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return(0!=r?new u(e/r,-t/r):new u(0!==e?e/0:0,0!==t?-t/0:0)).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){e=Qr(e,t);return Math.abs(e.re-this.re)<=u.EPSILON&&Math.abs(e.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){let e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<u.EPSILON&&(e=0),0===(t=Math.abs(t)<u.EPSILON?0:t)?r+e:(0!==e?(r=r+e+" ",t<0?(t=-t,r+="-"):r+="+",r+=" "):t<0&&(t=-t,r+="-"),1!==t&&(r+=t),r+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},u.ZERO=new u(0,0),u.ONE=new u(1,0),u.I=new u(0,1),u.PI=new u(Math.PI,0),u.E=new u(Math.E,0),u.INFINITY=new u(1/0,1/0),u.NAN=new u(NaN,NaN),u.EPSILON=1e-15;const en=s("Complex",[],()=>(Object.defineProperty(u,"name",{value:"Complex"}),(u.prototype.constructor=u).prototype.type="Complex",u.prototype.isComplex=!0,u.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},u.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},u.prototype.format=function(e){let t=this.im,r=this.re;const n=He(this.re,e),i=He(this.im,e),a=A(e)?e:e?e.precision:null;if(null!==a){const e=Math.pow(10,-a);Math.abs(r/t)<e&&(r=0),Math.abs(t/r)<e&&(t=0)}return 0===t?n:0===r?1===t?"i":-1===t?"-i":i+"i":t<0?-1===t?n+" - i":n+" - "+i.substring(1)+"i":1===t?n+" + i":n+" + "+i+"i"},u.fromPolar=function(t){switch(arguments.length){case 1:{const t=arguments[0];if("object"==typeof t)return u(t);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{const t=arguments[0];let e=arguments[1];if(A(t)){if(A(e=L(e)&&e.hasBase("ANGLE")?e.toNumber("rad"):e))return new u({r:t,phi:e});throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},u.prototype.valueOf=u.prototype.toString,u.fromJSON=function(e){return new u(e)},u.compare=function(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0},u),{isClass:!0}),p=(BigInt="undefined"==typeof BigInt?function(e){if(isNaN(e))throw new Error("");return e}:BigInt)(0),f=BigInt(1),tn=BigInt(2),rn=BigInt(5),nn=BigInt(10),m={s:f,n:p,d:f};function an(e,t){try{e=BigInt(e)}catch(e){throw fn()}return e*t}function on(e){return"bigint"==typeof e?e:Math.floor(e)}function g(e,t){if(t===p)throw cn();const r=Object.create(ln.prototype);r.s=e<p?-f:f;var n=un(e=e<p?-e:e,t);return r.n=e/n,r.d=t/n,r}function sn(e){const t={};let r=e,n=tn,i=rn-f;for(;i<=r;){for(;r%n===p;)r/=n,t[n]=(t[n]||p)+f;i+=f+tn*n++}return r!==e?1<r&&(t[r]=(t[r]||p)+f):t[e]=(t[e]||p)+f,t}function y(s,e){let u=p,l=f,c=f;if(null!=s)if(void 0!==e){if("bigint"==typeof s)u=s;else{if(isNaN(s))throw fn();if(s%1!=0)throw pn();u=BigInt(s)}if("bigint"==typeof e)l=e;else{if(isNaN(e))throw fn();if(e%1!=0)throw pn();l=BigInt(e)}c=u*l}else if("object"==typeof s){if("d"in s&&"n"in s)u=BigInt(s.n),l=BigInt(s.d),"s"in s&&(u*=BigInt(s.s));else if(0 in s)u=BigInt(s[0]),1 in s&&(l=BigInt(s[1]));else{if("bigint"!=typeof s)throw fn();u=s}c=u*l}else if("number"==typeof s){if(isNaN(s))throw fn();if(s<0&&(c=-f,s=-s),s%1==0)u=BigInt(s);else{let e=1,t=0,r=1,n=1,i=1;for(1<=s&&(s/=e=10**Math.floor(1+Math.log10(s)));r<=1e7&&i<=1e7;){var a=(t+n)/(r+i);if(s===a){l=r+i<=1e7?(u=t+n,r+i):i>r?(u=n,i):(u=t,r);break}a<s?(t+=n,r+=i):(n+=t,i+=r),l=1e7<r?(u=n,i):(u=t,r)}u=BigInt(u)*BigInt(e),l=BigInt(l)}}else if("string"==typeof s){let e=0,t=p,r=p,n=p,i=f,a=f,o=s.replace(/_/g,"").match(/\d+|./g);if(null===o)throw fn();if("-"===o[e]?(c=-f,e++):"+"===o[e]&&e++,o.length===e+1?r=an(o[e++],c):"."===o[e+1]||"."===o[e]?("."!==o[e]&&(t=an(o[e++],c)),(++e+1===o.length||"("===o[e+1]&&")"===o[e+3]||"'"===o[e+1]&&"'"===o[e+3])&&(r=an(o[e],c),i=nn**BigInt(o[e].length),e++),("("===o[e]&&")"===o[e+2]||"'"===o[e]&&"'"===o[e+2])&&(n=an(o[e+1],c),a=nn**BigInt(o[e+1].length)-f,e+=3)):"/"===o[e+1]||":"===o[e+1]?(r=an(o[e],c),i=an(o[e+2],f),e+=3):"/"===o[e+3]&&" "===o[e+1]&&(t=an(o[e],c),r=an(o[e+2],c),i=an(o[e+4],f),e+=5),!(o.length<=e))throw fn();l=i*a,c=u=n+l*t+a*r}else{if("bigint"!=typeof s)throw fn();u=s,c=s,l=f}if(l===p)throw cn();m.s=c<p?-f:f,m.n=u<p?-u:u,m.d=l<p?-l:l}function un(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function ln(e,t){if(y(e,t),!(this instanceof ln))return g(m.s*m.n,m.d);e=un(m.d,m.n),this.s=m.s,this.n=m.n/e,this.d=m.d/e}var cn=function(){return new Error("Division by Zero")},fn=function(){return new Error("Invalid argument")},pn=function(){return new Error("Parameters must be integer")};ln.prototype={s:f,n:p,d:f,abs:function(){return g(this.n,this.d)},neg:function(){return g(-this.s*this.n,this.d)},add:function(e,t){return y(e,t),g(this.s*this.n*m.d+m.s*this.d*m.n,this.d*m.d)},sub:function(e,t){return y(e,t),g(this.s*this.n*m.d-m.s*this.d*m.n,this.d*m.d)},mul:function(e,t){return y(e,t),g(this.s*m.s*this.n*m.n,this.d*m.d)},div:function(e,t){return y(e,t),g(this.s*m.s*this.n*m.d,this.d*m.n)},clone:function(){return g(this.s*this.n,this.d)},mod:function(e,t){if(void 0===e)return g(this.s*this.n%this.d,f);if(y(e,t),p===m.n*this.d)throw cn();return g(this.s*(m.d*this.n)%(m.n*this.d),m.d*this.d)},gcd:function(e,t){return y(e,t),g(un(m.n,this.n)*un(m.d,this.d),m.d*this.d)},lcm:function(e,t){return y(e,t),m.n===p&&this.n===p?g(p,f):g(m.n*this.n,un(m.n,this.n)*un(m.d,this.d))},inverse:function(){return g(this.s*this.d,this.n)},pow:function(e,t){if(y(e,t),m.d===f)return m.s<p?g((this.s*this.d)**m.n,this.n**m.n):g((this.s*this.n)**m.n,this.d**m.n);if(this.s<p)return null;let r=sn(this.n),n=sn(this.d),i=f,a=f;for(var o in r)if("1"!==o){if("0"===o){i=p;break}if(r[o]*=m.n,r[o]%m.d!==p)return null;r[o]/=m.d,i*=BigInt(o)**r[o]}for(var s in n)if("1"!==s){if(n[s]*=m.n,n[s]%m.d!==p)return null;n[s]/=m.d,a*=BigInt(s)**n[s]}return m.s<p?g(a,i):g(i,a)},log:function(e,t){if(y(e,t),this.s<=p||m.s<=p)return null;const r={},n=sn(m.n),i=sn(m.d),a=sn(this.n),o=sn(this.d);for(const e in i)n[e]=(n[e]||p)-i[e];for(const e in o)a[e]=(a[e]||p)-o[e];for(const e in n)"1"!==e&&(r[e]=!0);for(const e in a)"1"!==e&&(r[e]=!0);let s=null,u=null;for(const e in r){const t=n[e]||p,r=a[e]||p;if(t===p){if(r!==p)return null}else{var l=r,c=t,f=un(l,c);if(l/=f,c/=f,null===s&&null===u)s=l,u=c;else if(l*u!=s*c)return null}}return null!==s&&null!==u?g(s,u):null},equals:function(e,t){return y(e,t),this.s*this.n*m.d==m.s*m.n*this.d},lt:function(e,t){return y(e,t),this.s*this.n*m.d<m.s*m.n*this.d},lte:function(e,t){return y(e,t),this.s*this.n*m.d<=m.s*m.n*this.d},gt:function(e,t){return y(e,t),this.s*this.n*m.d>m.s*m.n*this.d},gte:function(e,t){return y(e,t),this.s*this.n*m.d>=m.s*m.n*this.d},compare:function(e,t){y(e,t);e=this.s*this.n*m.d-m.s*m.n*this.d;return(p<e)-(e<p)},ceil:function(e){return e=nn**BigInt(e||0),g(on(this.s*e*this.n/this.d)+(e*this.n%this.d>p&&this.s>=p?f:p),e)},floor:function(e){return e=nn**BigInt(e||0),g(on(this.s*e*this.n/this.d)-(e*this.n%this.d>p&&this.s<p?f:p),e)},round:function(e){return e=nn**BigInt(e||0),g(on(this.s*e*this.n/this.d)+this.s*((this.s>=p?f:p)+tn*(e*this.n%this.d)>this.d?f:p),e)},roundTo:function(e,t){y(e,t);var e=this.n*m.d,t=this.d*m.n,r=e%t;let n=on(e/t);return t<=r+r&&n++,g(this.s*n*m.n,m.d)},divisible:function(e,t){return y(e,t),!(!(m.n*this.d)||this.n*m.d%(m.n*this.d))},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(t){let r=this.n,n=this.d,i=(t=t||15,function(e){for(;e%tn===p;e/=tn);for(;e%rn===p;e/=rn);if(e===f)return p;let t=nn%e,r=1;for(;t!==f;r++)if(t=t*nn%e,2e3<r)return p;return BigInt(r)}(n)),a=function(t,e){let r=f,n=function(e,t,r){let n=f;for(;t>p;e=e*e%r,t>>=f)t&f&&(n=n*e%r);return n}(nn,e,t);for(let e=0;e<300;e++){if(r===n)return BigInt(e);r=r*nn%t,n=n*nn%t}return 0}(n,i),o=this.s<p?"-":"";if(o+=on(r/n),(r=(r%=n)*nn)&&(o+="."),i){for(let e=a;e--;)o+=on(r/n),r=(r%=n)*nn;o+="(";for(let e=i;e--;)o+=on(r/n),r=(r%=n)*nn;o+=")"}else for(let e=t;r&&e--;)o+=on(r/n),r=(r%=n)*nn;return o},toFraction:function(e){let t=this.n,r=this.d,n=this.s<p?"-":"";var i;return r===f?n+=t:(i=on(t/r),e&&i>p&&(n=n+i+" ",t%=r),n=(n+=t)+"/"+r),n},toLatex:function(e){let t=this.n,r=this.d,n=this.s<p?"-":"";var i;return r===f?n+=t:(i=on(t/r),e&&i>p&&(n+=i,t%=r),n=(n=(n+="\\frac{")+t+"}{")+r+"}"),n},toContinued:function(){let e=this.n,t=this.d,r=[];do{r.push(on(e/t));var n=e%t;e=t,t=n}while(e!==f);return r},simplify:function(e){const n=BigInt(1/(e||.001)|0),i=this.abs(),a=i.toContinued();for(let r=1;r<a.length;r++){let t=g(a[r-1],f);for(let e=r-2;0<=e;e--)t=t.inverse().add(a[e]);var o=t.sub(i);if(o.n*n<o.d)return t.mul(this.s)}return this}};const mn=s("Fraction",[],()=>(Object.defineProperty(ln,"name",{value:"Fraction"}),(ln.prototype.constructor=ln).prototype.type="Fraction",ln.prototype.isFraction=!0,ln.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},ln.fromJSON=function(e){return new ln(e)},ln),{isClass:!0}),hn=s("Range",[],()=>{function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");var n=null!=e,i=null!=t,a=null!=r;if(n)if(Q(e))e=e.toNumber();else if("number"!=typeof e&&!R(e))throw new TypeError("Parameter start must be a number or bigint");if(i)if(Q(t))t=t.toNumber();else if("number"!=typeof t&&!R(t))throw new TypeError("Parameter end must be a number or bigint");if(a)if(Q(r))r=r.toNumber();else if("number"!=typeof r&&!R(r))throw new TypeError("Parameter step must be a number or bigint");this.start=n?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=a?parseFloat(r):1}return o.prototype.type="Range",o.prototype.isRange=!0,o.parse=function(e){if("string"!=typeof e)return null;const t=e.split(":").map(function(e){return parseFloat(e)});if(t.some(function(e){return isNaN(e)}))return null;switch(t.length){case 2:return new o(t[0],t[1]);case 3:return new o(t[0],t[2],t[1]);default:return null}},o.prototype.clone=function(){return new o(this.start,this.end,this.step)},o.prototype.size=function(){let e=0;var t=this.start,r=this.step,t=this.end-t;return ke(r)===ke(t)?e=Math.ceil(t/r):0==t&&(e=0),[e=isNaN(e)?0:e]},o.prototype.min=function(){var e=this.size()[0];return 0<e?0<this.step?this.start:this.start+(e-1)*this.step:void 0},o.prototype.max=function(){var e=this.size()[0];return 0<e?0<this.step?this.start+(e-1)*this.step:this.start:void 0},o.prototype.forEach=function(e){let t=this.start;var r=this.step,n=this.end;let i=0;if(0<r)for(;t<n;)e(t,[i],this),t+=r,i++;else if(r<0)for(;t>n;)e(t,[i],this),t+=r,i++},o.prototype.map=function(n){const i=[];return this.forEach(function(e,t,r){i[t[0]]=n(e,t,r)}),i},o.prototype.toArray=function(){const r=[];return this.forEach(function(e,t){r[t[0]]=e}),r},o.prototype.valueOf=function(){return this.toArray()},o.prototype.format=function(e){let t=He(this.start,e);return 1!==this.step&&(t+=":"+He(this.step,e)),t+=":"+He(this.end,e)},o.prototype.toString=function(){return this.format()},o.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},o.fromJSON=function(e){return new o(e.start,e.end,e.step)},o},{isClass:!0}),dn=s("Matrix",[],()=>{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(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,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(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){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(e){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 gn(){return(gn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)!{}.hasOwnProperty.call(n,r)||(e[r]=n[r])}return e}).apply(null,arguments)}function yn(e,t,r){const n=new e.constructor(2);let i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!v(r))throw new Error("size must be an integer");if(e.greaterThan(n.pow(r-1).sub(1))||e.lessThan(n.pow(r-1).mul(-1)))throw new Error(`Value must be in range [-2^${r-1}, 2^${r-1}-1]`);if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(n.pow(r))),i="i"+r}switch(t){case 2:return""+e.toBinary()+i;case 8:return""+e.toOctal()+i;case 16:return""+e.toHexadecimal()+i;default:throw new Error(`Base ${t} not supported `)}}function xn(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function bn(e,t){return A(e)?e:Q(e)?e.toNumber():t}function S(e,t){const r=function(t,r){{if("number"==typeof t)return He(t,r);if(!Q(t))return t&&"object"==typeof t&&"bigint"==typeof t.s&&"bigint"==typeof t.n&&"bigint"==typeof t.d?r&&"decimal"===r.fraction?t.toString():t.s*t.n+"/"+t.d:Array.isArray(t)?function r(n,i){if(Array.isArray(n)){let t="[";const a=n.length;for(let e=0;e<a;e++)0!==e&&(t+=", "),t+=r(n[e],i);return t+="]"}return S(n,i)}(t,r):j(t)?vn(t):"function"==typeof t?t.syntax?String(t.syntax):"function":t&&"object"==typeof t?"function"==typeof t.format?t.format(r):t&&t.toString(r)!=={}.toString()?t.toString(r):"{"+Object.keys(t).map(e=>vn(e)+": "+S(t[e],r)).join(", ")+"}":String(t);{var n=t,i=r;if("function"==typeof i)return i(n);if(!n.isFinite())return n.isNaN()?"NaN":n.gt(0)?"Infinity":"-Infinity";const{notation:s,precision:u,wordSize:l}=Ge(i);switch(s){case"fixed":return n.toFixed(u);case"exponential":return xn(n,u);case"engineering":{var a=n;var o=u;const c=a.e,f=c%3==0?c:c<0?c-3-c%3:c-c%3;let e=a.mul(Math.pow(10,-f)).toPrecision(o);return(e=e.includes("e")?new a.constructor(e).toFixed():e)+"e"+(0<=c?"+":"")+f.toString();return}case"bin":return yn(n,2,l);case"oct":return yn(n,8,l);case"hex":return yn(n,16,l);case"auto":{const s=bn(null==i?void 0:i.lowerExp,-3),l=bn(null==i?void 0:i.upperExp,5);if(n.isZero())return"0";let e;const p=n.toSignificantDigits(u),m=p.e;return(e=m>=s&&m<l?p.toFixed():xn(n,u)).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t})}default:throw new Error('Unknown notation "'+s+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}}}(e,t);return t&&"object"==typeof t&&"truncate"in t&&r.length>t.truncate?r.substring(0,t.truncate-3)+"...":r}function vn(e){const t=String(e);let r="",n=0;for(;n<t.length;){const e=t.charAt(n);r+=e in wn?wn[e]:e,n++}return'"'+r+'"'}const wn={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};function Nn(e){let t=String(e);return t=t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function An(e,t){if(!j(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+K(e)+", index: 0)");if(j(t))return e===t?0:t<e?1:-1;throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+K(t)+", index: 1)")}function z(e,t,r){if(!(this instanceof z))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function En(e,t,r){if(!(this instanceof En))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&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}function T(e){const t=[];for(;Array.isArray(e);)t.push(e.length),e=e[0];return t}function Sn(e,t){if(0===t.length){if(Array.isArray(e))throw new z(e.length,0)}else!function e(t,r,n){let i;var a=t.length;if(a!==r[n])throw new z(a,r[n]);if(n<r.length-1){var o=n+1;for(i=0;i<a;i++){const n=t[i];if(!Array.isArray(n))throw new z(r.length-1,r.length,"<");e(t[i],r,o)}}else for(i=0;i<a;i++)if(Array.isArray(t[i]))throw new z(r.length+1,r.length,">")}(e,t,0)}function Mn(e,t){const r=e.isMatrix?e._size:T(e);t._sourceSize.forEach((e,t)=>{if(null!==e&&e!==r[t])throw new z(e,r[t])})}function M(e,t){if(void 0!==e){if(!A(e)||!v(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&t<=e)throw new En(e,t)}}function Cn(t){for(let e=0;e<t._dimensions.length;++e){var r=t._dimensions[e];if(r._data&&b(r._data)){if(0===r._size[0])return 1}else if(r.isRange){if(r.start===r.end)return 1}else if(j(r)&&0===r.length)return 1}}function Tn(e,t,r){if(!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach(function(e){if(!A(e)||!v(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+S(t)+")")}),function e(t,r,n,i){let a,o;const s=t.length,u=r[n],l=Math.min(s,u);if(t.length=u,n<r.length-1){const s=n+1;for(a=0;a<l;a++)o=t[a],Array.isArray(o)||(o=[o],t[a]=o),e(o,r,s,i);for(a=l;a<u;a++)o=[],t[a]=o,e(o,r,s,i)}else{for(a=0;a<l;a++)for(;Array.isArray(t[a]);)t[a]=t[a][0];for(a=l;a<u;a++)t[a]=i}}(e=A(e)||Q(e)?[e]:e,t,0,void 0!==r?r:0),e}function Bn(e,n){var i=E(e,!0),t=i.length;if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(0===n.length)throw new z(0,t,"!=");var r=Dn(n=Fn(n,t));if(t!==r)throw new z(r,t,"!=");try{{var a=n;let t,r=i;for(let e=a.length-1;0<e;e--){var o=a[e],s=(t=[],r.length/o);for(let e=0;e<s;e++)t.push(r.slice(e*o,(e+1)*o));r=t}return r;return}}catch(e){if(e instanceof z)throw new z(r,t,"!=");throw e}}function Fn(e,t){const r=Dn(e),n=e.slice(),i=e.indexOf(-1);if(0<=e.indexOf(-1,i+1))throw new Error("More than one wildcard in sizes");if(0<=i){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Dn(e){return e.reduce((e,t)=>e*t,1)}function On(e,t){const r=t||T(e);for(;Array.isArray(e)&&1===e.length;)e=e[0],r.shift();let n=r.length;for(;1===r[n-1];)n--;return n<r.length&&(e=function e(t,r,n){let i,a;if(n<r){const o=n+1;for(i=0,a=t.length;i<a;i++)t[i]=e(t[i],r,o)}else for(;Array.isArray(t);)t=t[0];return t}(e,n,0),r.length=n),e}function _n(t,e,r,n){const i=n||T(t);if(r)for(let e=0;e<r;e++)t=[t],i.unshift(1);for(t=function e(t,r,n){let i,a;if(Array.isArray(t)){const o=n+1;for(i=0,a=t.length;i<a;i++)t[i]=e(t[i],r,o)}else for(let e=n;e<r;e++)t=[t];return t}(t,e,0);i.length<e;)i.push(1);return t}function E(e,t){t=1<arguments.length&&void 0!==t&&t;if(!Array.isArray(e))return e;if("boolean"!=typeof t)throw new TypeError("Boolean expected for second argument of flatten");const i=[];return(t?function t(r){if(Array.isArray(r[0]))for(let e=0;e<r.length;e++)t(r[e]);else for(let e=0;e<r.length;e++)i.push(r[e])}:function t(r){for(let e=0;e<r.length;e++){var n=r[e];Array.isArray(n)?t(n):i.push(n)}})(e),i}function zn(e,t){return Array.prototype.map.call(e,t)}function qn(e,t){Array.prototype.forEach.call(e,t)}function In(e,t){if(1!==T(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,t)}function kn(e,t){if(1!==T(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,e=>t.test(e))}function Rn(e,t){return Array.prototype.join.call(e,t)}function Pn(t){if(!Array.isArray(t))throw new TypeError("Array input expected");if(0===t.length)return t;const r=[];let n=0;r[0]={value:t[0],identifier:0};for(let e=1;e<t.length;e++)t[e]===t[e-1]?n++:n=0,r.push({value:t[e],identifier:n});return r}function Un(t){if(!Array.isArray(t))throw new TypeError("Array input expected");if(0===t.length)return t;const r=[];for(let e=0;e<t.length;e++)r.push(t[e].value);return r}function jn(t,r){let n,i=0;for(let e=0;e<t.length;e++){var a=t[e],o=Array.isArray(a);if(0===e&&o&&(i=a.length),o&&a.length!==i)return;o=o?jn(a,r):r(a);if(void 0===n)n=o;else if(n!==o)return"mixed"}return n}function Ln(){const e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(1===e.length)return e[0];if(1<e.length)return e.slice(1).reduce(function(e,t){return function t(r,n,i,a){if(a<i){if(r.length!==n.length)throw new z(r.length,n.length);const o=[];for(let e=0;e<r.length;e++)o[e]=t(r[e],n[e],i,a+1);return o}return r.concat(n)}(e,t,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function $n(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const n=t.map(e=>e.length),i=Math.max(...n),a=new Array(i).fill(null);for(let e=0;e<t.length;e++){const r=t[e],o=n[e];for(let e=0;e<o;e++){const t=i-o+e;r[e]>a[t]&&(a[t]=r[e])}}for(let e=0;e<t.length;e++)Hn(t[e],a);return a}function Hn(t,r){var n=r.length,i=t.length;for(let e=0;e<i;e++){var a=n-i+e;if(t[e]<r[a]&&1<t[e]||t[e]>r[a])throw new Error(`shape mismatch: mismatch is found in arg with shape (${t}) not possible to broadcast dimension ${i} with size ${t[e]} to size `+r[a])}}function Gn(e,t){let r=T(e);if(De(r,t))return e;Hn(r,t);var n,i,a,o=$n(r,t),s=o.length,t=[...Array(s-r.length).fill(1),...r];let u=gn([],e);r.length<s&&(u=Bn(u,t),r=T(u));for(let e=0;e<s;e++)r[e]<o[e]&&(n=u,i=o[e],a=e,u=Ln(...Array(i).fill(n),a),r=T(u));return u}function Vn(e,t){if(!Array.isArray(e))throw new Error("Array expected");var r=T(e);if(t.length!==r.length)throw new z(t.length,r.length);for(let e=0;e<t.length;e++)M(t[e],r[e]);return t.reduce((e,t)=>e[t],e)}function Zn(i,a,e){if(0===i.length)return[];if(2<arguments.length&&void 0!==e&&e)return function t(r){if(Array.isArray(r)){const a=r.length,n=Array(a);for(let e=0;e<a;e++)n[e]=t(r[e]);return n}return a(r)}(i);const o=[];return function t(r,n){if(Array.isArray(r)){const i=r.length,a=Array(i);for(let e=0;e<i;e++)o[n]=e,a[e]=t(r[e],n+1);return a}return a(r,o.slice(0,n),i)}(i,0)}function Wn(i,a,e){e=2<arguments.length&&void 0!==e&&e;if(0!==i.length){if(e)return function t(r){if(Array.isArray(r)){const a=r.length;for(let e=0;e<a;e++)t(r[e])}else a(r)}(i);const o=[];!function t(r,n){if(Array.isArray(r)){const i=r.length;for(let e=0;e<i;e++)t(r[o[n]=e],n+1)}else a(r,o.slice(0,n),i)}(i,0)}}function Yn(a,o,s,e){let t=3<arguments.length&&void 0!==e&&e;if(l.isTypedFunction(a)){let n,i;if(t)n=1;else{const s=(o.isMatrix?o.size():T(o)).map(()=>0),t=o.isMatrix?o.get(s):Vn(o,s);n=function(t,e,r){const n=[e,r,o];for(let e=3;0<e;e--){const r=n.slice(0,e);if(null!==l.resolve(t,r))return e}}(a,t,s)}if(o.isMatrix&&"mixed"!==o.dataType&&void 0!==o.dataType){const l=function(e,n){const i=[];if(Object.entries(e.signatures).forEach(e=>{let[t,r]=e;t.split(",").length===n&&i.push(r)}),1===i.length)return i[0]}(a,n);i=void 0!==l?l:a}else i=a;return 1<=n&&n<=3?{isUnary:1===n,fn:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Jn(i,t.slice(0,n),s,a.name)}}:{isUnary:!1,fn:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Jn(i,t,s,a.name)}}}return void 0===t?{isUnary:function(e){if(1!==e.length)return!1;const t=e.toString();if(/arguments/.test(t))return!1;e=t.match(/\(.*?\)/);return!/\.\.\./.test(e)}(a),fn:a}:{isUnary:t,fn:a}}function Jn(e,t,r,n){try{return e(...t)}catch(e){var i,a=e;if(a instanceof TypeError&&"wrongType"===(null==(i=a.data)?void 0:i.category)){const a=[];throw a.push("value: "+K(t[0])),2<=t.length&&a.push("index: "+K(t[1])),3<=t.length&&a.push("array: "+K(t[2])),new TypeError(`Function ${r} cannot apply callback arguments ${n}(${a.join(", ")}) at index `+JSON.stringify(t[1]))}throw new TypeError(`Function ${r} cannot apply callback arguments to function ${n}: `+a.message)}}(z.prototype=new RangeError).constructor=RangeError,z.prototype.name="DimensionError",z.prototype.isDimensionError=!0,(En.prototype=new RangeError).constructor=RangeError,En.prototype.name="IndexError";const Xn=s("DenseMatrix",["Matrix"],e=>{let t=e["Matrix"];function g(e,t){if(!(this instanceof g))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!j(t))throw new Error("Invalid datatype: "+t);if(_(e))"DenseMatrix"===e.type?(this._data=ee(e._data),this._size=ee(e._size)):(this._data=e.toArray(),this._size=e.size()),this._datatype=t||e._datatype;else if(e&&b(e.data)&&b(e.size))this._data=e.data,this._size=e.size,Sn(this._data,this._size),this._datatype=t||e.datatype;else if(b(e))this._data=r(e),this._size=T(this._data),Sn(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+K(e)+")");this._data=[],this._size=[0],this._datatype=t}}function a(t,e,r){if(0!==e.length)return t._size=e.slice(0),t._data=Tn(t._data,t._size,r),t;{let e=t._data;for(;b(e);)e=e[0];return e}}function y(e,r,t){const n=e._size.slice(0);let i=!1;for(;n.length<r.length;)n.push(0),i=!0;for(let e=0,t=r.length;e<t;e++)r[e]>n[e]&&(n[e]=r[e],i=!0);i&&a(e,n,t)}function r(e){return _(e)?r(e.valueOf()):b(e)?e.map(r):e}return(g.prototype=new t).createDenseMatrix=function(e,t){return new g(e,t)},Object.defineProperty(g,"name",{value:"DenseMatrix"}),(g.prototype.constructor=g).prototype.type="DenseMatrix",g.prototype.isDenseMatrix=!0,g.prototype.getDataType=function(){return jn(this._data,K)},g.prototype.storage=function(){return"dense"},g.prototype.datatype=function(){return this._datatype},g.prototype.create=function(e,t){return new g(e,t)},g.prototype.subset=function(e,t,n){switch(arguments.length){case 1:var r=this,i=e;if(!Z(i))throw new TypeError("Invalid index");if(i.isScalar())return r.get(i.min());{var a=i.size();if(a.length!==r._size.length)throw new z(a.length,r._size.length);var o=i.min(),s=i.max();for(let e=0,t=r._size.length;e<t;e++)M(o[e],r._size[e]),M(s[e],r._size[e]);const m=new g([]),h=function(e,i){const a=i.size().length-1,o=Array(a);return{data:function t(r){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;const e=i.dimension(n);return o[n]=e.size()[0],(n<a?e.map(e=>(M(e,r.length),t(r[e],n+1))):e.map(e=>(M(e,r.length),r[e]))).valueOf()}(e),size:o}}(r._data,i);return m._size=h.size,m._datatype=r._datatype,m._data=h.data,m}case 2:case 3:{var u=this;a=e;i=t;var l=n;if(!a||!0!==a.isIndex)throw new TypeError("Invalid index");var c=a.size(),f=a.isScalar();let r;if(_(i)?(r=i.size(),i=i.valueOf()):r=T(i),f){if(0!==r.length)throw new TypeError("Scalar expected");u.set(a.min(),i,l)}else{if(!De(r,c))try{r=T(i=0===r.length?Gn([i],c):Gn(i,c))}catch(u){}if(c.length<u._size.length)throw new z(c.length,u._size.length,"<");if(r.length<c.length){let e=0,t=0;for(;1===c[e]&&1===r[e];)e++;for(;1===c[e];)t++,e++;i=_n(i,c.length,t,r)}if(!De(c,r))throw new z(c,r,">");y(u,a.max().map(function(e){return e+1}),l);{f=u._data;var p=a;l=i;const d=p.size().length-1;!function r(n,i){let a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;const e=p.dimension(a);a<d?e.forEach((e,t)=>{M(e,n.length),r(n[e],i[t[0]],a+1)}):e.forEach((e,t)=>{M(e,n.length),n[e]=i[t[0]]})}(f,l)}}return u;return}default:throw new SyntaxError("Wrong number of arguments")}},g.prototype.get=function(e){return Vn(this._data,e)},g.prototype.set=function(e,t,r){if(!b(e))throw new TypeError("Array expected");if(e.length<this._size.length)throw new z(e.length,this._size.length,"<");let n,i,a;y(this,e.map(function(e){return e+1}),r);let o=this._data;for(n=0,i=e.length-1;n<i;n++)M(a=e[n],o.length),o=o[a];return M(a=e[e.length-1],o.length),o[a]=t,this},g.prototype.resize=function(e,t,r){if(!$(e))throw new TypeError("Array or Matrix expected");e=e.valueOf().map(e=>Array.isArray(e)&&1===e.length?e[0]:e);return a(r?this.clone():this,e,t)},g.prototype.reshape=function(e,t){const r=t?this.clone():this;r._data=Bn(r._data,e);t=r._size.reduce((e,t)=>e*t);return r._size=Fn(e,t),r},g.prototype.clone=function(){return new g({data:ee(this._data),size:ee(this._size),datatype:this._datatype})},g.prototype.size=function(){return this._size.slice(0)},g.prototype.map=function(t){let r=2<arguments.length&&void 0!==arguments[2]&&arguments[2];const a=this,e=a._size.length-1;if(e<0)return a.clone();const n=Yn(t,a,"map",r),o=n.fn,i=a.create(void 0,a._datatype);if(i._size=a._size,r||n.isUnary)return i._data=function t(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;const i=Array(r.length);if(n<e)for(let e=0;e<r.length;e++)i[e]=t(r[e],n+1);else for(let e=0;e<r.length;e++)i[e]=o(r[e]);return i}(a._data),i;if(0==e){const t=a.valueOf(),r=Array(t.length);for(let e=0;e<t.length;e++)r[e]=o(t[e],[e],a);return i._data=r,i}const s=[];return i._data=function t(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;const i=Array(r.length);if(n<e)for(let e=0;e<r.length;e++)s[n]=e,i[e]=t(r[e],n+1);else for(let e=0;e<r.length;e++)s[n]=e,i[e]=o(r[e],s.slice(),a);return i}(a._data),i},g.prototype.forEach=function(e){var t=2<arguments.length&&void 0!==arguments[2]&&arguments[2];const i=this,a=i._size.length-1;if(!(a<0)){const r=Yn(e,i,"map",t),o=r.fn;if(t||r.isUnary)!function t(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(n<a)for(let e=0;e<r.length;e++)t(r[e],n+1);else for(let e=0;e<r.length;e++)o(r[e])}(i._data);else if(0==a)for(let e=0;e<i._data.length;e++)o(i._data[e],[e],i);else{const s=[];!function t(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(n<a)for(let e=0;e<r.length;e++)t(r[s[n]=e],n+1);else for(let e=0;e<r.length;e++)s[n]=e,o(r[e],s.slice(),i)}(i._data)}}},g.prototype[Symbol.iterator]=function*(){var r=this._size.length-1;if(!(r<0))if(0==r)for(let e=0;e<this._data.length;e++)yield{value:this._data[e],index:[e]};else{const n=Array(1+r).fill(0),t=this._size.reduce((e,t)=>e*t,1);for(let e=0;e<t;e++){let t=this._data;for(let e=0;e<r;e++)t=t[n[e]];yield{value:t[n[r]],index:n.slice()};for(let e=r;0<=e&&(n[e]++,!(n[e]<this._size[e]));e--)n[e]=0}}},g.prototype.rows=function(){const e=[];if(2!==this.size().length)throw new TypeError("Rows can only be returned for a 2D matrix.");for(const t of this._data)e.push(new g([t],this._datatype));return e},g.prototype.columns=function(){const e=[],r=this.size();if(2!==r.length)throw new TypeError("Rows can only be returned for a 2D matrix.");const n=this._data;for(let t=0;t<r[1];t++){const r=n.map(e=>[e[t]]);e.push(new g(r,this._datatype))}return e},g.prototype.toArray=function(){return ee(this._data)},g.prototype.valueOf=function(){return this._data},g.prototype.format=function(e){return S(this._data,e)},g.prototype.toString=function(){return S(this._data)},g.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},g.prototype.diagonal=function(e){if(e){if(!A(e=Q(e)?e.toNumber():e)||!v(e))throw new TypeError("The parameter k must be an integer number")}else e=0;const t=0<e?e:0,r=e<0?-e:0,n=this._size[0],i=this._size[1],a=Math.min(n-r,i-t),o=[];for(let e=0;e<a;e++)o[e]=this._data[e+r][e+t];return new g({data:o,size:[a],datatype:this._datatype})},g.diagonal=function(e,t,r,n){if(!b(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw new Error("Only two dimensions matrix are supported");if(e=e.map(function(e){if(!A(e=Q(e)?e.toNumber():e)||!v(e)||e<1)throw new Error("Size values must be positive integers");return e}),r){if(!A(r=Q(r)?r.toNumber():r)||!v(r))throw new TypeError("The parameter k must be an integer number")}else r=0;var i=0<r?r:0,a=r<0?-r:0,r=e[0],o=e[1],s=Math.min(r-a,o-i);let u;if(b(t)){if(t.length!==s)throw new Error("Invalid value array length");u=function(e){return t[e]}}else if(_(t)){const e=t.size();if(1!==e.length||e[0]!==s)throw new Error("Invalid matrix length");u=function(e){return t.get([e])}}else u=function(){return t};n=n||(Q(u(0))?u(0).mul(0):0);let l=[];if(0<e.length){l=Tn(l,e,n);for(let e=0;e<s;e++)l[e+a][e+i]=u(e)}return new g({data:l,size:[r,o]})},g.fromJSON=function(e){return new g(e)},g.prototype.swapRows=function(e,t){if(!(A(e)&&v(e)&&A(t)&&v(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return M(e,this._size[0]),M(t,this._size[0]),g._swapRows(e,t,this._data),this},g._swapRows=function(e,t,r){var n=r[e];r[e]=r[t],r[t]=n},g},{isClass:En.prototype.isIndexError=!0}),Qn=s("clone",["typed"],e=>{let t=e["typed"];return t("clone",{any:ee})});function Kn(e){const t=e.length,r=e[0].length;let n,i;const a=[];for(i=0;i<r;i++){const r=[];for(n=0;n<t;n++)r.push(e[n][i]);a.push(r)}return a}function ei(t){for(let e=0;e<t.length;e++)if($(t[e]))return 1}function ti(e,t){_(e)?e.forEach(e=>t(e),!1,!0):Wn(e,t,!0)}function le(e,t,r){if(!r)return _(e)?e.map(e=>t(e),!1,!0):Zn(e,t,!0);const n=e=>0===e?e:t(e);return _(e)?e.map(e=>n(e),!1,!0):Zn(e,n,!0)}function ri(e,t,r){var n=Array.isArray(e)?T(e):e.size();if(t<0||t>=n.length)throw new En(t,n.length);return _(e)?e.create(ni(e.valueOf(),t,r),e.datatype()):ni(e,t,r)}function ni(e,t,r){let n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=Kn(e),i=[],n=0;n<o.length;n++)i[n]=ni(o[n],t-1,r);return i}for(a=e[0],n=1;n<e.length;n++)a=r(a,e[n]);return a}for(i=[],n=0;n<e.length;n++)i[n]=ni(e[n],t-1,r);return i}function ii(e,t,r,n,i,a,o,s,u,l,c){var f=e._values,p=e._index,e=e._ptr;let m,h,d,g;if(n)for(h=e[t],d=e[t+1],m=h;m<d;m++)r[g=p[m]]!==a?(r[g]=a,o.push(g),l?(n[g]=u?s(f[m],c):s(c,f[m]),i[g]=a):n[g]=f[m]):(n[g]=u?s(f[m],n[g]):s(n[g],f[m]),i[g]=a);else for(h=e[t],d=e[t+1],m=h;m<d;m++)r[g=p[m]]!==a?(r[g]=a,o.push(g)):i[g]=a}const ai="isInteger",oi=s(ai,["typed"],e=>{let t=e["typed"];return t(ai,{number:v,BigNumber:function(e){return e.isInt()},bigint:function(e){return!0},Fraction:function(e){return 1n===e.d},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),si="number";function ui(e){return Number.isNaN(e)}function li(e,t,r,n){r=2<arguments.length&&void 0!==r?r:1e-9,n=3<arguments.length&&void 0!==n?n:0;if(r<=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()&&!t.isNaN()&&(e.isFinite()&&t.isFinite()?!!e.eq(t)||e.minus(t).abs().lte(e.constructor.max(e.constructor.max(e.abs(),t.abs()).mul(r),n)):e.eq(t))}ui.signature=si;const ci="isNegative",fi=s(ci,["typed","config"],e=>{let{typed:r,config:t}=e;return r(ci,{number:e=>!Xe(e,0,t.relTol,t.absTol)&&e<0,BigNumber:e=>!li(e,new e.constructor(0),t.relTol,t.absTol)&&e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e<0n,Fraction:e=>e.s<0n,Unit:r.referToSelf(t=>e=>r.find(t,e.valueType())(e.value)),"Array | Matrix":r.referToSelf(t=>e=>le(e,t))})}),pi="isNumeric",mi=s(pi,["typed"],e=>{let t=e["typed"];return t(pi,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),hi="hasNumericValue",di=s(hi,["typed","isNumeric"],e=>{let{typed:t,isNumeric:r}=e;return t(hi,{boolean:()=>!0,string:function(e){return 0<e.trim().length&&!isNaN(Number(e))},any:function(e){return r(e)}})}),gi="isPositive",yi=s(gi,["typed","config"],e=>{let{typed:r,config:t}=e;return r(gi,{number:e=>!Xe(e,0,t.relTol,t.absTol)&&0<e,BigNumber:e=>!(li(e,new e.constructor(0),t.relTol,t.absTol)||e.isNeg()||e.isZero()||e.isNaN()),bigint:e=>0n<e,Fraction:e=>0n<e.s&&0n<e.n,Unit:r.referToSelf(t=>e=>r.find(t,e.valueType())(e.value)),"Array | Matrix":r.referToSelf(t=>e=>le(e,t))})}),xi=s("isZero",["typed","equalScalar"],e=>{let{typed:r,equalScalar:t}=e;return r("isZero",{"number | BigNumber | Complex | Fraction":e=>t(e,0),bigint:e=>0n===e,Unit:r.referToSelf(t=>e=>r.find(t,e.valueType())(e.value)),"Array | Matrix":r.referToSelf(t=>e=>le(e,t))})}),bi=s("isNaN",["typed"],e=>{let t=e["typed"];return t("isNaN",{number:ui,BigNumber:function(e){return e.isNaN()},bigint:function(e){return!1},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),vi=s("typeOf",["typed"],e=>{let t=e["typed"];return t("typeOf",{any:K})}),wi=s("compareUnits",["typed"],e=>{let n=e["typed"];return{"Unit, Unit":n.referToSelf(r=>(e,t)=>{if(e.equalBase(t))return n.find(r,[e.valueType(),t.valueType()])(e.value,t.value);throw new Error("Cannot compare units with different base")})}}),Ni="equalScalar",Ai=s(Ni,["typed","config"],e=>{let{typed:t,config:i}=e;e=wi({typed:t});return t(Ni,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Xe(e,t,i.relTol,i.absTol)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||li(e,t,i.relTol,i.absTol)},"bigint, bigint":function(e,t){return e===t},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return e=e,t=t,r=i.relTol,n=i.absTol,Xe(e.re,t.re,r,n)&&Xe(e.im,t.im,r,n);var r,n}},e)}),Ei=(s(Ni,["typed","config"],e=>{let{typed:t,config:r}=e;return t(Ni,{"number, number":function(e,t){return Xe(e,t,r.relTol,r.absTol)}})}),s("SparseMatrix",["typed","equalScalar","Matrix"],e=>{let{typed:y,equalScalar:x,Matrix:t}=e;function E(e,t){if(!(this instanceof E))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!j(t))throw new Error("Invalid datatype: "+t);if(_(e))r=this,i=t,"SparseMatrix"===(n=e).type?(r._values=n._values?ee(n._values):void 0,r._index=ee(n._index),r._ptr=ee(n._ptr),r._size=ee(n._size),r._datatype=i||n._datatype):a(r,n.valueOf(),i||n._datatype);else if(e&&b(e.index)&&b(e.ptr)&&b(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(b(e))a(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+K(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}var r,n,i}function a(r,n,i){r._values=[],r._index=[],r._ptr=[],r._datatype=i;var a=n.length;let o=0,s=x,u=0;if(j(i)&&(s=y.find(x,[i,i])||x,u=y.convert(0,i)),0<a){let t=0;do{r._ptr.push(r._index.length);for(let e=0;e<a;e++){const i=n[e];if(b(i)){if(0===t&&o<i.length&&(o=i.length),t<i.length){const n=i[t];s(n,u)||(r._values.push(n),r._index.push(e))}}else 0===t&&o<1&&(o=1),s(i,u)||(r._values.push(i),r._index.push(e))}}while(++t<o)}r._ptr.push(r._index.length),r._size=[a,o]}function m(t,r,n,i){if(n-r==0)return n;for(let e=r;e<n;e++)if(i[e]===t)return e;return r}function h(e,t,r,n,i,a,o){i.splice(e,0,n),a.splice(e,0,t);for(let e=r+1;e<o.length;e++)o[e]++}function d(r,n,t,e){let i=e||0,a=x,o=0;j(r._datatype)&&(a=y.find(x,[r._datatype,r._datatype])||x,o=y.convert(0,r._datatype),i=y.convert(i,r._datatype));var s=!a(i,o),u=r._size[0];let l,c,f,p=r._size[1];if(t>p){for(c=p;c<t;c++)if(r._ptr[c]=r._values.length,s)for(l=0;l<u;l++)r._values.push(i),r._index.push(l);r._ptr[t]=r._values.length}else t<p&&(r._ptr.splice(t+1,p-t),r._values.splice(r._ptr[t],r._values.length),r._index.splice(r._ptr[t],r._index.length));if(p=t,u<n){if(s){let t=0;for(c=0;c<p;c++){r._ptr[c]=r._ptr[c]+t,f=r._ptr[c+1]+t;let e=0;for(l=u;l<n;l++,e++)r._values.splice(f+e,0,i),r._index.splice(f+e,0,l),t++}r._ptr[p]=r._values.length}}else if(n<u){let e=0;for(c=0;c<p;c++){r._ptr[c]=r._ptr[c]-e;const x=r._ptr[c],t=r._ptr[c+1]-e;for(f=x;f<t;f++)(l=r._index[f])>n-1&&(r._values.splice(f,1),r._index.splice(f,1),e++)}r._ptr[c]=r._values.length}return r._size[0]=n,r._size[1]=t,r}function r(t,r,e,n,i){const a=n[0],o=n[1],s=[];let u,l;for(u=0;u<a;u++)for(s[u]=[],l=0;l<o;l++)s[u][l]=0;for(l=0;l<o;l++){const n=e[l],a=e[l+1];for(let e=n;e<a;e++)u=r[e],s[u][l]=t?i?ee(t[e]):t[e]:1}return s}return(E.prototype=new t).createSparseMatrix=function(e,t){return new E(e,t)},Object.defineProperty(E,"name",{value:"SparseMatrix"}),(E.prototype.constructor=E).prototype.type="SparseMatrix",E.prototype.isSparseMatrix=!0,E.prototype.getDataType=function(){return jn(this._values,K)},E.prototype.storage=function(){return"sparse"},E.prototype.datatype=function(){return this._datatype},E.prototype.create=function(e,t){return new E(e,t)},E.prototype.density=function(){var e=this._size[0],t=this._size[1];return 0!==e&&0!==t?this._index.length/(e*t):0},E.prototype.subset=function(i,e,t){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:{var a=this;var o=i;if(!Z(o))throw new TypeError("Invalid index");if(o.isScalar())return a.get(o.min());var s=o.size();if(s.length!==a._size.length)throw new z(s.length,a._size.length);let t,e,r,n;var u=o.min(),l=o.max();for(t=0,e=a._size.length;t<e;t++)M(u[t],a._size[t]),M(l[t],a._size[t]);const m=a._values,h=a._index,d=a._ptr,g=o.dimension(0),y=o.dimension(1),x=[],b=[],v=(g.forEach(function(e,t){b[e]=t[0],x[e]=!0}),m?[]:void 0),w=[],N=[];return y.forEach(function(e){for(N.push(w.length),r=d[e],n=d[e+1];r<n;r++)t=h[r],!0===x[t]&&(w.push(b[t]),v&&v.push(m[r]))}),N.push(w.length),new E({values:v,index:w,ptr:N,size:s,datatype:a._datatype});return}case 2:case 3:{var c=this;o=i;var f=e;var p=t;if(!o||!0!==o.isIndex)throw new TypeError("Invalid index");const n=o.size(),A=o.isScalar();let r;if(_(f)?(r=f.size(),f=f.toArray()):r=T(f),A){if(0!==r.length)throw new TypeError("Scalar expected");c.set(o.min(),f,p)}else{if(1!==n.length&&2!==n.length)throw new z(n.length,c._size.length,"<");if(r.length<n.length){let e=0,t=0;for(;1===n[e]&&1===r[e];)e++;for(;1===n[e];)t++,e++;f=_n(f,n.length,t,r)}if(!De(n,r))throw new z(n,r,">");if(1===n.length)o.dimension(0).forEach(function(e,t){M(e),c.set([e,0],f[t[0]],p)});else{const n=o.dimension(0),A=o.dimension(1);n.forEach(function(r,n){M(r),A.forEach(function(e,t){M(e),c.set([r,e],f[n[0]][t[0]],p)})})}}return c;return}default:throw new SyntaxError("Wrong number of arguments")}},E.prototype.get=function(e){if(!b(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new z(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var t=e[0],e=e[1],r=(M(t,this._size[0]),M(e,this._size[1]),m(t,this._ptr[e],this._ptr[e+1],this._index));return r<this._ptr[e+1]&&this._index[r]===t?this._values[r]:0},E.prototype.set=function(e,t,r){if(!b(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new z(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var n=e[0],e=e[1];let i=this._size[0],a=this._size[1],o=x,s=0;j(this._datatype)&&(o=y.find(x,[this._datatype,this._datatype])||x,s=y.convert(0,this._datatype)),(n>i-1||e>a-1)&&(d(this,Math.max(n+1,i),Math.max(e+1,a),r),i=this._size[0],a=this._size[1]),M(n,i),M(e,a);r=m(n,this._ptr[e],this._ptr[e+1],this._index);if(r<this._ptr[e+1]&&this._index[r]===n)if(o(t,s)){var u=r,l=e,c=this._values,f=this._index,p=this._ptr;c.splice(u,1),f.splice(u,1);for(let e=l+1;e<p.length;e++)p[e]--}else this._values[r]=t;else o(t,s)||h(r,n,e,t,this._values,this._index,this._ptr);return this},E.prototype.resize=function(e,t,r){if(!$(e))throw new TypeError("Array or Matrix expected");const n=e.valueOf().map(e=>Array.isArray(e)&&1===e.length?e[0]:e);if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach(function(e){if(!A(e)||!v(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+S(n)+")")}),d(r?this.clone():this,n[0],n[1],t)},E.prototype.reshape=function(t,r){if(!b(t))throw new TypeError("Array expected");if(2!==t.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");t.forEach(function(e){if(!A(e)||!v(e)||e<=-2||0===e)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+S(t)+")")});const n=this._size[0]*this._size[1];if(n!==(t=Fn(t,n))[0]*t[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");const i=r?this.clone():this;if(this._size[0]===t[0]&&this._size[1]===t[1])return i;const a=[];for(let t=0;t<i._ptr.length;t++)for(let e=0;e<i._ptr[t+1]-i._ptr[t];e++)a.push(t);const o=i._values.slice(),s=i._index.slice();for(let e=0;e<i._index.length;e++){const n=s[e],o=a[e],m=n*i._size[1]+o;a[e]=m%t[1],s[e]=Math.floor(m/t[1])}i._values.length=0,i._index.length=0,i._ptr.length=t[1]+1,i._size=t.slice();for(let e=0;e<i._ptr.length;e++)i._ptr[e]=0;for(let e=0;e<o.length;e++){const r=s[e],n=a[e],u=o[e];h(m(r,i._ptr[n],i._ptr[n+1],i._index),r,n,u,i._values,i._index,i._ptr)}return i},E.prototype.clone=function(){return new E({values:this._values?ee(this._values):void 0,index:ee(this._index),ptr:ee(this._ptr),size:ee(this._size),datatype:this._datatype})},E.prototype.size=function(){return this._size.slice(0)},E.prototype.map=function(e,t){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");const o=this,r=this._size[0],n=this._size[1],s=Yn(e,o,"map");{var u=this,l=r-1,c=n-1,f=t;const m=[],h=[],d=[];let i=x,a=0;function p(e,t,r){e=e,n=t,r=r;var n,e=s.fn(e,[n,r],o);i(e,a)||(m.push(e),h.push(t))}j(u._datatype)&&(i=y.find(x,[u._datatype,u._datatype])||x,a=y.convert(0,u._datatype));for(let t=0;t<=c;t++){d.push(m.length);const x=u._ptr[t],g=u._ptr[t+1];if(f)for(let e=x;e<g;e++){const x=u._index[e];0<=x&&x<=l&&p(u._values[e],+x,+t)}else{const E={};for(let e=x;e<g;e++)E[u._index[e]]=u._values[e];for(let e=0;e<=l;e++)p(e in E?E[e]:0,+e,+t)}}return d.push(m.length),new E({values:m,index:h,ptr:d,size:[1+l,1+c]})}},E.prototype.forEach=function(e,r){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");const n=this._size[0],i=this._size[1],a=Yn(e,this,"forEach");for(let t=0;t<i;t++){const i=this._ptr[t],o=this._ptr[t+1];if(r)for(let e=i;e<o;e++){const n=this._index[e];a.fn(this._values[e],[n,t],this)}else{const r={};for(let e=i;e<o;e++)r[this._index[e]]=this._values[e];for(let e=0;e<n;e++){const n=e in r?r[e]:0;a.fn(n,[e,t],this)}}}},E.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");const r=this._size[1];for(let t=0;t<r;t++){const r=this._ptr[t],n=this._ptr[t+1];for(let e=r;e<n;e++){const r=this._index[e];yield{value:this._values[e],index:[r,t]}}}},E.prototype.toArray=function(){return r(this._values,this._index,this._ptr,this._size,!0)},E.prototype.valueOf=function(){return r(this._values,this._index,this._ptr,this._size,!1)},E.prototype.format=function(r){const e=this._size[0],n=this._size[1],i=this.density();let a="Sparse Matrix ["+S(e,r)+" x "+S(n,r)+"] density: "+S(i,r)+"\n";for(let t=0;t<n;t++){const n=this._ptr[t],i=this._ptr[t+1];for(let e=n;e<i;e++)a+="\n ("+S(this._index[e],r)+", "+S(t,r)+") ==> "+(this._values?S(this._values[e],r):"X")}return a},E.prototype.toString=function(){return S(this.toArray())},E.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},E.prototype.diagonal=function(e){if(e){if(!A(e=Q(e)?e.toNumber():e)||!v(e))throw new TypeError("The parameter k must be an integer number")}else e=0;const r=0<e?e:0,n=e<0?-e:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-r),s=[],u=[],t=[];t[0]=0;for(let t=r;t<a&&s.length<o;t++){const i=this._ptr[t],E=this._ptr[t+1];for(let e=i;e<E;e++){const i=this._index[e];if(i===t-r+n){s.push(this._values[e]),u[s.length-1]=i-n;break}}}return t.push(s.length),new E({values:s,index:u,ptr:t,size:[o,1]})},E.fromJSON=function(e){return new E(e)},E.diagonal=function(t,r,e,n,i){if(!b(t))throw new TypeError("Array expected, size parameter");if(2!==t.length)throw new Error("Only two dimensions matrix are supported");if(t=t.map(function(e){if(!A(e=Q(e)?e.toNumber():e)||!v(e)||e<1)throw new Error("Size values must be positive integers");return e}),e){if(!A(e=Q(e)?e.toNumber():e)||!v(e))throw new TypeError("The parameter k must be an integer number")}else e=0;let a=x,o=0;j(i)&&(a=y.find(x,[i,i])||x,o=y.convert(0,i));var s=0<e?e:0,u=e<0?-e:0,i=t[0],l=t[1],c=Math.min(i-u,l-s);let f;if(b(r)){if(r.length!==c)throw new Error("Invalid value array length");f=function(e){return r[e]}}else if(_(r)){const t=r.size();if(1!==t.length||t[0]!==c)throw new Error("Invalid matrix length");f=function(e){return r.get([e])}}else f=function(){return r};const p=[],m=[],h=[];for(let e=0;e<l;e++){h.push(p.length);const y=e-s;if(0<=y&&y<c){const t=f(y);a(t,o)||(m.push(y+u),p.push(t))}}return h.push(p.length),new E({values:p,index:m,ptr:h,size:[i,l]})},E.prototype.swapRows=function(e,t){if(!(A(e)&&v(e)&&A(t)&&v(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return M(e,this._size[0]),M(t,this._size[0]),E._swapRows(e,t,this._size[1],this._values,this._index,this._ptr),this},E._forEachRow=function(e,t,r,n,i){var a=n[e],o=n[e+1];for(let e=a;e<o;e++)i(r[e],t[e])},E._swapRows=function(t,r,n,i,a,o){for(let e=0;e<n;e++){const n=o[e],s=o[e+1],u=m(t,n,s,a),l=m(r,n,s,a);if(u<s&&l<s&&a[u]===t&&a[l]===r){if(i){const t=i[u];i[u]=i[l],i[l]=t}}else if(u<s&&a[u]===t&&(s<=l||a[l]!==r)){const t=i?i[u]:void 0;a.splice(l,0,r),i&&i.splice(l,0,t),a.splice(l<=u?u+1:u,1),i&&i.splice(l<=u?u+1:u,1)}else if(l<s&&a[l]===r&&(s<=u||a[u]!==t)){const r=i?i[l]:void 0;a.splice(u,0,t),i&&i.splice(u,0,r),a.splice(u<=l?l+1:l,1),i&&i.splice(u<=l?l+1:l,1)}}},E},{isClass:!0})),Si=s("number",["typed"],e=>{let t=e["typed"];const r=t("number",{"":function(){return 0},number:function(e){return e},string:function(r){if("NaN"===r)return NaN;var n=(e=(n=r).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:n,radix:{"0b":2,"0o":8,"0x":16}[e[1]],integerPart:e[2],fractionalPart:e[3]}:null;if(n){var i=n,e=parseInt(i.integerPart,i.radix);let t=0;for(let e=0;e<i.fractionalPart.length;e++)t+=parseInt(i.fractionalPart[e],i.radix)/Math.pow(i.radix,e+1);if(e+=t,isNaN(e))throw new SyntaxError('String "'+i.input+'" is not a valid number');return e}{let e=0;n=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);n&&(e=Number(n[2]),r=n[1]);let t=Number(r);if(isNaN(t))throw new SyntaxError('String "'+r+'" is not a valid number');if(n){if(t>2**e-1)throw new SyntaxError(`String "${r}" is out of range`);t>=2**(e-1)&&(t-=2**e)}return t}},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:t.referToSelf(r=>e=>{const t=e.clone();return t.value=r(e.value),t}),null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))});return r.fromJSON=function(e){return parseFloat(e.value)},r}),Mi=s("bigint",["typed"],e=>{let t=e["typed"];const r=t("bigint",{"":function(){return 0n},bigint:function(e){return e},number:function(e){return BigInt(e.toFixed())},BigNumber:function(e){return BigInt(e.round().toString())},Fraction:function(e){return BigInt(e.valueOf().toFixed())},"string | boolean":function(e){return BigInt(e)},null:function(e){return 0n},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))});return r.fromJSON=function(e){return BigInt(e.value)},r}),Ci=s("string",["typed"],e=>{let t=e["typed"];return t("string",{"":function(){return""},number:He,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":t.referToSelf(t=>e=>le(e,t)),any:function(e){return String(e)}})}),Ti="boolean",Bi=s(Ti,["typed"],e=>{let t=e["typed"];return t(Ti,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;t=Number(e);if(""===e||isNaN(t))throw new Error('Cannot convert "'+e+'" to a boolean');return!!t},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Fi=s("bignumber",["typed","BigNumber"],e=>{let{typed:t,BigNumber:a}=e;return t("bignumber",{"":function(){return new a(0)},number:function(e){return new a(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){const r=t[2],n=a(t[1]),i=new a(2).pow(Number(r));if(n.gt(i.sub(1)))throw new SyntaxError(`String "${e}" is out of range`);t=new a(2).pow(Number(r)-1);return n.gte(t)?n.sub(i):n}return new a(e)},BigNumber:function(e){return e},bigint:function(e){return new a(e.toString())},Unit:t.referToSelf(r=>e=>{const t=e.clone();return t.value=r(e.value),t}),Fraction:function(e){return new a(String(e.n)).div(String(e.d)).times(String(e.s))},null:function(e){return new a(0)},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Di=s("complex",["typed","Complex"],e=>{let{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Oi=s("fraction",["typed","Fraction"],e=>{let{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},"bigint, bigint":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},bigint:function(e){return new r(e.toString())},Fraction:function(e){return e},Unit:t.referToSelf(r=>e=>{const t=e.clone();return t.value=r(e.value),t}),Object:function(e){return new r(e)},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),_i=s("matrix",["typed","Matrix","DenseMatrix","SparseMatrix"],e=>{let{typed:t,DenseMatrix:n,SparseMatrix:i}=e;return t("matrix",{"":function(){return r([])},string:function(e){return r([],e)},"string, string":function(e,t){return r([],e,t)},Array:function(e){return r(e)},Matrix:function(e){return r(e,e.storage())},"Array | Matrix, string":r,"Array | Matrix, string, string":r});function r(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}}),zi="matrixFromFunction",qi=s(zi,["typed","matrix","isZero"],e=>{let{typed:t,matrix:a,isZero:o}=e;return t(zi,{"Array | Matrix, function, string, string":i,"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,n,t,r){let i;return(i=void 0!==r?a(t,r):a(t)).resize(e),i.forEach(function(e,t){var r=n(t);o(r)||i.set(t,r)}),i}}),Ii="matrixFromRows",ki=s(Ii,["typed","matrix","flatten","size"],e=>{let{typed:t,matrix:r,flatten:i,size:n}=e;return t(Ii,{"...Array":a,"...Matrix":function(e){return r(a(e.map(e=>e.toArray())))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");const t=o(e[0]),r=[];for(const n of e){const e=o(n);if(e!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|e));r.push(i(n))}return r}function o(e){e=n(e);if(1===e.length)return e[0];if(2!==e.length)throw new TypeError("Only one- or two-dimensional vectors are supported.");if(1===e[0])return e[1];if(1===e[1])return e[0];throw new TypeError("At least one of the arguments is not a vector.")}}),Ri="matrixFromColumns",Pi=s(Ri,["typed","matrix","flatten","size"],e=>{let{typed:t,matrix:r,flatten:a,size:n}=e;return t(Ri,{"...Array":i,"...Matrix":function(e){return r(i(e.map(e=>e.toArray())))}});function i(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");const t=o(e[0]),r=[];for(let e=0;e<t;e++)r[e]=[];for(const i of e){const e=o(i);if(e!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|e));var n=a(i);for(let e=0;e<t;e++)r[e].push(n[e])}return r}function o(e){e=n(e);if(1===e.length)return e[0];if(2!==e.length)throw new TypeError("Only one- or two-dimensional vectors are supported.");if(1===e[0])return e[1];if(1===e[1])return e[0];throw new TypeError("At least one of the arguments is not a vector.")}}),Ui="splitUnit",ji=s(Ui,["typed"],e=>{let t=e["typed"];return t(Ui,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),Li="number",$i="number, number";function Hi(e){return Math.abs(e)}function Gi(e,t){return e+t}function Vi(e,t){return e-t}function Zi(e,t){return e*t}function Wi(e){return-e}function Yi(e){return e}function Ji(e){return je(e)}function Xi(e){return e*e*e}function Qi(e){return Math.exp(e)}function Ki(e){return Le(e)}function ea(e,t){if(!v(e)||!v(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function ta(e,t){return t?Math.log(e)/Math.log(t):Math.log(e)}function ra(e){return Pe(e)}function na(e){return Re(e)}function ia(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2;var r=t<0;if(0===(t=r?-t:t))throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;let n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function aa(e){return ke(e)}function oa(e){return e*e}function sa(e,t){let r,n,i,a=0,o=1,s=1,u=0;if(!v(e)||!v(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function ua(e,t){return e*e<1&&t===1/0||1<e*e&&t===-1/0?0:Math.pow(e,t)}function la(e,t){t=1<arguments.length&&void 0!==t?t:0;if(!v(t)||t<0||15<t)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(Ze(e,t))}Hi.signature=Li,Zi.signature=Vi.signature=Gi.signature=$i,Ki.signature=Qi.signature=Xi.signature=Ji.signature=Yi.signature=Wi.signature=Li,ea.signature=$i,oa.signature=aa.signature=na.signature=ra.signature=Li,ua.signature=sa.signature=$i;const ca="unaryMinus",fa=s(ca,["typed"],e=>{let n=e["typed"];return n(ca,{number:Wi,"Complex | BigNumber | Fraction":e=>e.neg(),bigint:e=>-e,Unit:n.referToSelf(r=>e=>{const t=e.clone();return t.value=n.find(r,t.valueType())(e.value),t}),"Array | Matrix":n.referToSelf(t=>e=>le(e,t,!0))})}),pa="unaryPlus",ma=s(pa,["typed","config","numeric"],e=>{let{typed:t,config:r,numeric:n}=e;return t(pa,{number:Yi,Complex:function(e){return e},BigNumber:function(e){return e},bigint:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":t.referToSelf(t=>e=>le(e,t,!0)),boolean:function(e){return n(e?1:0,r.number)},string:function(e){return n(e,Ie(e,r))}})}),ha=s("abs",["typed"],e=>{let t=e["typed"];return t("abs",{number:Hi,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":t.referToSelf(t=>e=>le(e,t,!0))})}),da="mapSlices",ga=s(da,["typed","isInteger"],e=>{let{typed:t,isInteger:i}=e;return t(da,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!i(t))throw new TypeError("Integer number expected for dimension");var n=Array.isArray(e)?T(e):e.size();if(t<0||t>=n.length)throw new En(t,n.length);return _(e)?e.create(ya(e.valueOf(),t,r),e.datatype()):ya(e,t,r)}})},{formerly:"apply"});function ya(e,t,r){let n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){const t=e.length,r=e[0].length;let n,i;const a=[];for(i=0;i<r;i++){const r=[];for(n=0;n<t;n++)r.push(e[n][i]);a.push(r)}return a}(e),i=[],n=0;n<a.length;n++)i[n]=ya(a[n],t-1,r);return i}return r(e)}for(i=[],n=0;n<e.length;n++)i[n]=ya(e[n],t-1,r);return i}const xa="addScalar",ba=s(xa,["typed"],e=>{let i=e["typed"];return i(xa,{"number, number":Gi,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"bigint, bigint":function(e,t){return e+t},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":i.referToSelf(n=>(e,t)=>{if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");const r=e.clone();return r.value=i.find(n,[r.valueType(),t.valueType()])(r.value,t.value),r.fixPrefix=!1,r})})}),va="subtractScalar",wa=s(va,["typed"],e=>{let i=e["typed"];return i(va,{"number, number":Vi,"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"bigint, bigint":function(e,t){return e-t},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":i.referToSelf(n=>(e,t)=>{if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");const r=e.clone();return r.value=i.find(n,[r.valueType(),t.valueType()])(r.value,t.value),r.fixPrefix=!1,r})})}),Na=s("cbrt",["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],e=>{let{config:a,typed:t,isNegative:i,unaryMinus:o,matrix:s,Complex:u,BigNumber:l,Fraction:c}=e;return t("cbrt",{number:Ji,Complex:f,"Complex, boolean":f,BigNumber:function(e){return e.cbrt()},Unit:function(t){if(t.value&&te(t.value)){let e=t.clone();return e.value=1,(e=e.pow(1/3)).value=f(t.value),e}{var e,r=i(t.value);r&&(t.value=o(t.value)),e=Q(t.value)?new l(1).div(3):re(t.value)?new c(1,3):1/3;const n=t.pow(e);return r&&(n.value=o(n.value)),n}}});function f(e,t){var r=e.arg()/3,n=e.abs(),i=new u(Ji(n),0).mul(new u(0,r).exp());if(t){const e=[i,new u(Ji(n),0).mul(new u(0,r+2*Math.PI/3).exp()),new u(Ji(n),0).mul(new u(0,r-2*Math.PI/3).exp())];return"Array"===a.matrix?e:s(e)}return i}}),Aa=s("matAlgo11xS0s",["typed","equalScalar"],e=>{let{typed:x,equalScalar:b}=e;return function(i,a,e,o){var s=i._values,u=i._index,l=i._ptr,t=i._size,r=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var n=t[0],c=t[1];let f,p=b,m=0,h=e;"string"==typeof r&&(f=r,p=x.find(b,[f,f]),m=x.convert(0,f),a=x.convert(a,f),h=x.find(e,[f,f]));const d=[],g=[],y=[];for(let n=0;n<c;n++){y[n]=g.length;for(let e=l[n],t=l[n+1],r=e;r<t;r++){const i=u[r],x=o?h(a,s[r]):h(s[r],a);p(x,m)||(g.push(i),d.push(x))}}return y[c]=g.length,i.createSparseMatrix({values:d,index:g,ptr:y,size:[n,c],datatype:f})}}),x=s("matAlgo12xSfs",["typed","DenseMatrix"],e=>{let{typed:d,DenseMatrix:g}=e;return function(i,t,e,r){var a=i._values,o=i._index,s=i._ptr,n=i._size,i=i._datatype;if(!a)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var u=n[0],l=n[1];let c,f=e;"string"==typeof i&&(c=i,t=d.convert(t,c),f=d.find(e,[c,c]));const p=[],m=[],h=[];for(let n=0;n<l;n++){const d=n+1;for(let e=s[n],t=s[n+1],r=e;r<t;r++){const i=o[r];m[i]=a[r],h[i]=d}for(let e=0;e<u;e++)0===n&&(p[e]=[]),h[e]===d?p[e][n]=r?f(t,m[e]):f(m[e],t):p[e][n]=r?f(t,0):f(0,t)}return new g({data:p,size:[u,l],datatype:c})}}),Ea=s("matAlgo14xDs",["typed"],e=>{let l=e["typed"];return function(e,t,r,n){var i=e._data,a=e._size,o=e._datatype;let s,u=r;"string"==typeof o&&(s=o,t=l.convert(t,s),u=l.find(r,[s,s]));o=0<a.length?function t(r,n,i,a,o,s,u){const l=[];if(n===i.length-1)for(let e=0;e<a;e++)l[e]=u?r(s,o[e]):r(o[e],s);else for(let e=0;e<a;e++)l[e]=t(r,n+1,i,i[n+1],o[e],s,u);return l}(u,0,a,a[0],i,t,n):[];return e.createDenseMatrix({data:o,size:ee(a),datatype:s})}}),Sa="ceil",Ma=new Vr(10),Ca=s(Sa,["typed","config","round"],e=>{let{typed:t,config:n,round:i}=e;function r(e){var t=Math.ceil(e),r=i(e);return t!==r&&Xe(e,r,n.relTol,n.absTol)&&!Xe(e,t,n.relTol,n.absTol)?r:t}return t(Sa,{number:r,"number, number":function(e,t){if(!v(t))throw new RangeError("number of decimals in function ceil must be an integer");if(t<0||15<t)throw new RangeError("number of decimals in ceil number must be in range 0-15");t=10**t;return r(e*t)/t}})}),Ta=s(Sa,["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],e=>{let{typed:t,config:i,round:a,matrix:n,equalScalar:o,zeros:s,DenseMatrix:r}=e;const u=Aa({typed:t,equalScalar:o}),l=x({typed:t,DenseMatrix:r}),c=Ea({typed:t}),f=Ca({typed:t,config:i,round:a});function p(e){const t=(e,t)=>li(e,t,i.relTol,i.absTol),r=e.ceil(),n=a(e);return!r.eq(n)&&t(e,n)&&!t(e,r)?n:r}return t("ceil",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:p,"BigNumber, BigNumber":function(e,t){t=Ma.pow(t);return p(e.mul(t)).div(t)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Unit, number, Unit":t.referToSelf(n=>function(e,t,r){e=e.toNumeric(r);return r.multiply(n(e,t))}),"Unit, BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>n(e,t.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>le(e,e=>n(e,t,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(r=>(e,t)=>r(e,0,t)),"Array | Matrix":t.referToSelf(t=>e=>le(e,t,!0)),"Array, number | BigNumber":t.referToSelf(r=>(e,t)=>le(e,e=>r(e,t),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>u(e,t,r,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>c(e,t,r,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(r=>(e,t)=>c(n(t),e,r,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(r=>(e,t)=>o(e,0)?s(t.size(),t.storage()):("dense"===t.storage()?c:l)(t,e,r,!0))})}),Ba=s("cube",["typed"],e=>{let t=e["typed"];return t("cube",{number:Xi,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},bigint:function(e){return e*e*e},Fraction:function(e){return e.pow(3)},Unit:function(e){return e.pow(3)}})}),Fa=s("exp",["typed"],e=>{let t=e["typed"];return t("exp",{number:Qi,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})}),Da=s("expm1",["typed","Complex"],e=>{let{typed:t,Complex:r}=e;return t("expm1",{number:Ki,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})}),Oa=s("fix",["typed","ceil","floor"],e=>{let{typed:t,ceil:r,floor:n}=e;return t("fix",{number:function(e){return(0<e?n:r)(e)},"number, number":function(e,t){return(0<e?n:r)(e,t)}})}),_a=s("fix",["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],e=>{let{typed:t,Complex:r,matrix:n,ceil:i,floor:a,equalScalar:o,zeros:s,DenseMatrix:u}=e;const l=x({typed:t,DenseMatrix:u}),c=Ea({typed:t}),f=Oa({typed:t,ceil:i,floor:a});return t("fix",{number:f.signatures.number,"number, number | BigNumber":f.signatures["number,number"],Complex:function(e){return new r(0<e.re?Math.floor(e.re):Math.ceil(e.re),0<e.im?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new r((0<e.re?a:i)(e.re,t),(0<e.im?a:i)(e.im,t))},"Complex, BigNumber":function(e,t){t=t.toNumber();return new r((0<e.re?a:i)(e.re,t),(0<e.im?a:i)(e.im,t))},BigNumber:function(e){return(e.isNegative()?i:a)(e)},"BigNumber, number | BigNumber":function(e,t){return(e.isNegative()?i:a)(e,t)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.s<0n?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return(e.s<0n?i:a)(e,t)},"Unit, number, Unit":t.referToSelf(n=>function(e,t,r){e=e.toNumeric(r);return r.multiply(n(e,t))}),"Unit, BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>n(e,t.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>le(e,e=>n(e,t,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(r=>(e,t)=>r(e,0,t)),"Array | Matrix":t.referToSelf(t=>e=>le(e,t,!0)),"Array | Matrix, number | BigNumber":t.referToSelf(r=>(e,t)=>le(e,e=>r(e,t),!0)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(r=>(e,t)=>c(n(t),e,r,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(r=>(e,t)=>o(e,0)?s(t.size(),t.storage()):("dense"===t.storage()?c:l)(t,e,r,!0))})}),za="floor",qa=new Vr(10),Ia=s(za,["typed","config","round"],e=>{let{typed:t,config:n,round:i}=e;function r(e){var t=Math.floor(e),r=i(e);return t!==r&&Xe(e,r,n.relTol,n.absTol)&&!Xe(e,t,n.relTol,n.absTol)?r:t}return t(za,{number:r,"number, number":function(e,t){if(!v(t))throw new RangeError("number of decimals in function floor must be an integer");if(t<0||15<t)throw new RangeError("number of decimals in floor number must be in range 0 - 15");t=10**t;return r(e*t)/t}})}),ka=s(za,["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],e=>{let{typed:t,config:i,round:a,matrix:n,equalScalar:o,zeros:s,DenseMatrix:r}=e;const u=Aa({typed:t,equalScalar:o}),l=x({typed:t,DenseMatrix:r}),c=Ea({typed:t}),f=Ia({typed:t,config:i,round:a});function p(e){const t=(e,t)=>li(e,t,i.relTol,i.absTol),r=e.floor(),n=a(e);return!r.eq(n)&&t(e,n)&&!t(e,r)?n:r}return t("floor",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:p,"BigNumber, BigNumber":function(e,t){t=qa.pow(t);return p(e.mul(t)).div(t)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Unit, number, Unit":t.referToSelf(n=>function(e,t,r){e=e.toNumeric(r);return r.multiply(n(e,t))}),"Unit, BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>n(e,t.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>le(e,e=>n(e,t,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(r=>(e,t)=>r(e,0,t)),"Array | Matrix":t.referToSelf(t=>e=>le(e,t,!0)),"Array, number | BigNumber":t.referToSelf(r=>(e,t)=>le(e,e=>r(e,t),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>u(e,t,r,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>c(e,t,r,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(r=>(e,t)=>c(n(t),e,r,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(r=>(e,t)=>o(e,0)?s(t.size(),t.storage()):("dense"===t.storage()?c:l)(t,e,r,!0))})}),Ra=s("matAlgo02xDS0",["typed","equalScalar"],e=>{let{typed:v,equalScalar:w}=e;return function(e,t,r,i){var a=e._data,n=e._size,o=e._datatype||e.getDataType(),s=t._values,u=t._index,l=t._ptr,c=t._size,f=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(n.length!==c.length)throw new z(n.length,c.length);if(n[0]!==c[0]||n[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+c+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var c=n[0],p=n[1];let m,h=w,d=0,g=r;"string"==typeof o&&o===f&&"mixed"!==o&&(m=o,h=v.find(w,[m,m]),d=v.convert(0,m),g=v.find(r,[m,m]));const y=[],x=[],b=[];for(let n=0;n<p;n++){b[n]=x.length;for(let e=l[n],t=l[n+1],r=e;r<t;r++){const v=u[r],w=i?g(s[r],a[v][n]):g(a[v][n],s[r]);h(w,d)||(x.push(v),y.push(w))}}return b[p]=x.length,t.createSparseMatrix({values:y,index:x,ptr:b,size:[c,p],datatype:o===e._datatype&&f===t._datatype?m:void 0})}}),Pa=s("matAlgo03xDSf",["typed"],e=>{let v=e["typed"];return function(e,i,t,a){var o=e._data,r=e._size,n=e._datatype||e.getDataType(),s=i._values,u=i._index,l=i._ptr,c=i._size,f=i._datatype||void 0===i._data?i._datatype:i.getDataType();if(r.length!==c.length)throw new z(r.length,c.length);if(r[0]!==c[0]||r[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+c+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var p=r[0],m=r[1];let h,d=0,g=t;"string"==typeof n&&n===f&&"mixed"!==n&&(h=n,d=v.convert(0,h),g=v.find(t,[h,h]));const y=[];for(let e=0;e<p;e++)y[e]=[];const x=[],b=[];for(let n=0;n<m;n++){const v=n+1;for(let e=l[n],t=l[n+1],r=e;r<t;r++){const i=u[r];x[i]=a?g(s[r],o[i][n]):g(o[i][n],s[r]),b[i]=v}for(let e=0;e<p;e++)b[e]===v?y[e][n]=x[e]:y[e][n]=a?g(d,o[e][n]):g(o[e][n],d)}return e.createDenseMatrix({data:y,size:[p,m],datatype:n===e._datatype&&f===i._datatype?h:void 0})}}),Ua=s("matAlgo05xSfSf",["typed","equalScalar"],e=>{let{typed:B,equalScalar:F}=e;return function(e,t,r){var n=e._values,i=e._index,a=e._ptr,o=e._size,s=e._datatype||void 0===e._data?e._datatype:e.getDataType(),u=t._values,l=t._index,c=t._ptr,f=t._size,p=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(o.length!==f.length)throw new z(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");var f=o[0],m=o[1];let h,d=F,g=0,y=r;"string"==typeof s&&s===p&&"mixed"!==s&&(h=s,d=B.find(F,[h,h]),g=B.convert(0,h),y=B.find(r,[h,h]));const x=n&&u?[]:void 0,b=[],v=[],w=x?[]:void 0,N=x?[]:void 0,A=[],E=[];let S,M,C,T;for(M=0;M<m;M++){v[M]=b.length;const e=M+1;for(C=a[M],T=a[M+1];C<T;C++)S=i[C],b.push(S),A[S]=e,w&&(w[S]=n[C]);for(C=c[M],T=c[M+1];C<T;C++)S=l[C],A[S]!==e&&b.push(S),E[S]=e,N&&(N[S]=u[C]);if(x)for(C=v[M];C<b.length;){S=b[C];const B=A[S],F=E[S];if(B===e||F===e){const t=y(B===e?w[S]:g,F===e?N[S]:g);d(t,g)?b.splice(C,1):(x.push(t),C++)}}}return v[m]=b.length,e.createSparseMatrix({values:x,index:b,ptr:v,size:[f,m],datatype:s===e._datatype&&p===t._datatype?h:void 0})}}),ja=s("matAlgo13xDD",["typed"],e=>{let p=e["typed"];return function(e,t,r){const n=e._data,i=e._size,a=e._datatype,o=t._data,s=t._size,u=t._datatype,l=[];if(i.length!==s.length)throw new z(i.length,s.length);for(let e=0;e<i.length;e++){if(i[e]!==s[e])throw new RangeError("Dimension mismatch. Matrix A ("+i+") must match Matrix B ("+s+")");l[e]=i[e]}let c,f=r;"string"==typeof a&&a===u&&(c=a,f=p.find(r,[c,c]));t=0<l.length?function t(r,n,i,a,o,s){const u=[];if(n===i.length-1)for(let e=0;e<a;e++)u[e]=r(o[e],s[e]);else for(let e=0;e<a;e++)u[e]=t(r,n+1,i,i[n+1],o[e],s[e]);return u}(f,0,l,l[0],n,o):[];return e.createDenseMatrix({data:t,size:l,datatype:c})}});function La(e,t){if(De(e.size(),t.size()))return[e,t];const r=$n(e.size(),t.size());return[e,t].map(e=>{var t=r;return De(e.size(),t)?e:e.create(Gn(e.valueOf(),t),e.datatype())})}const C=s("matrixAlgorithmSuite",["typed","matrix"],e=>{let{typed:o,matrix:s}=e;const u=ja({typed:o}),l=Ea({typed:o});return function(n){const r=n.elop,i=n.SD||n.DS;let e;r?(e={"DenseMatrix, DenseMatrix":(e,t)=>u(...La(e,t),r),"Array, Array":(e,t)=>u(...La(s(e),s(t)),r).valueOf(),"Array, DenseMatrix":(e,t)=>u(...La(s(e),t),r),"DenseMatrix, Array":(e,t)=>u(...La(e,s(t)),r)},n.SS&&(e["SparseMatrix, SparseMatrix"]=(e,t)=>n.SS(...La(e,t),r,!1)),n.DS&&(e["DenseMatrix, SparseMatrix"]=(e,t)=>n.DS(...La(e,t),r,!1),e["Array, SparseMatrix"]=(e,t)=>n.DS(...La(s(e),t),r,!1)),i&&(e["SparseMatrix, DenseMatrix"]=(e,t)=>i(...La(t,e),r,!0),e["SparseMatrix, Array"]=(e,t)=>i(...La(s(t),e),r,!0))):(e={"DenseMatrix, DenseMatrix":o.referToSelf(r=>(e,t)=>u(...La(e,t),r)),"Array, Array":o.referToSelf(r=>(e,t)=>u(...La(s(e),s(t)),r).valueOf()),"Array, DenseMatrix":o.referToSelf(r=>(e,t)=>u(...La(s(e),t),r)),"DenseMatrix, Array":o.referToSelf(r=>(e,t)=>u(...La(e,s(t)),r))},n.SS&&(e["SparseMatrix, SparseMatrix"]=o.referToSelf(r=>(e,t)=>n.SS(...La(e,t),r,!1))),n.DS&&(e["DenseMatrix, SparseMatrix"]=o.referToSelf(r=>(e,t)=>n.DS(...La(e,t),r,!1)),e["Array, SparseMatrix"]=o.referToSelf(r=>(e,t)=>n.DS(...La(s(e),t),r,!1))),i&&(e["SparseMatrix, DenseMatrix"]=o.referToSelf(r=>(e,t)=>i(...La(t,e),r,!0)),e["SparseMatrix, Array"]=o.referToSelf(r=>(e,t)=>i(...La(s(t),e),r,!0))));var t=n.scalar||"any";(n.Ds||n.Ss)&&(r?(e["DenseMatrix,"+t]=(e,t)=>l(e,t,r,!1),e[t+", DenseMatrix"]=(e,t)=>l(t,e,r,!0),e["Array,"+t]=(e,t)=>l(s(e),t,r,!1).valueOf(),e[t+", Array"]=(e,t)=>l(s(t),e,r,!0).valueOf()):(e["DenseMatrix,"+t]=o.referToSelf(r=>(e,t)=>l(e,t,r,!1)),e[t+", DenseMatrix"]=o.referToSelf(r=>(e,t)=>l(t,e,r,!0)),e["Array,"+t]=o.referToSelf(r=>(e,t)=>l(s(e),t,r,!1).valueOf()),e[t+", Array"]=o.referToSelf(r=>(e,t)=>l(s(t),e,r,!0).valueOf())));const a=void 0!==n.sS?n.sS:n.Ss;return r?(n.Ss&&(e["SparseMatrix,"+t]=(e,t)=>n.Ss(e,t,r,!1)),a&&(e[t+", SparseMatrix"]=(e,t)=>a(t,e,r,!0))):(n.Ss&&(e["SparseMatrix,"+t]=o.referToSelf(r=>(e,t)=>n.Ss(e,t,r,!1))),a&&(e[t+", SparseMatrix"]=o.referToSelf(r=>(e,t)=>a(t,e,r,!0)))),r&&r.signatures&&Fe(e,r.signatures),e}}),$a=s("mod",["typed","config","round","matrix","equalScalar","zeros","DenseMatrix","concat"],e=>{let{typed:t,config:r,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s,concat:u}=e;const l=ka({typed:t,config:r,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}),c=Ra({typed:t,equalScalar:a}),f=Pa({typed:t}),p=Ua({typed:t,equalScalar:a}),m=Aa({typed:t,equalScalar:a}),h=x({typed:t,DenseMatrix:s});return t("mod",{"number, number":function(e,t){return 0===t?e:e-t*l(e/t)},"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.sub(t.mul(l(e.div(t))))},"bigint, bigint":function(e,t){return 0n===t?e:e<0?0n===(r=e%t)?r:r+t:e%t;var r},"Fraction, Fraction":function(e,t){return t.equals(0)?e:e.sub(t.mul(l(e.div(t))))}},C({typed:t,matrix:i,concat:u})({SS:p,DS:f,SD:c,Ss:m,sS:h}))}),Ha=s("matAlgo01xDSid",["typed"],e=>{let w=e["typed"];return function(n,e,t,i){var a=n._data,r=n._size,o=n._datatype||n.getDataType(),s=e._values,u=e._index,l=e._ptr,c=e._size,f=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(r.length!==c.length)throw new z(r.length,c.length);if(r[0]!==c[0]||r[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+c+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");const p=r[0],m=r[1],h="string"==typeof o&&"mixed"!==o&&o===f?o:void 0,d=h?w.find(t,[h,h]):t;let g,y;const x=[];for(g=0;g<p;g++)x[g]=[];const b=[],v=[];for(y=0;y<m;y++){const n=y+1;for(let e=l[y],t=l[y+1],r=e;r<t;r++)g=u[r],b[g]=i?d(s[r],a[g][y]):d(a[g][y],s[r]),v[g]=n;for(g=0;g<p;g++)v[g]===n?x[g][y]=b[g]:x[g][y]=a[g][y]}return n.createDenseMatrix({data:x,size:[p,m],datatype:o===n._datatype&&f===e._datatype?h:void 0})}}),Ga=s("matAlgo04xSidSid",["typed","equalScalar"],e=>{let{typed:F,equalScalar:D}=e;return function(e,t,r){var n=e._values,i=e._index,a=e._ptr,o=e._size,s=e._datatype||void 0===e._data?e._datatype:e.getDataType(),u=t._values,l=t._index,c=t._ptr,f=t._size,p=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(o.length!==f.length)throw new z(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");var f=o[0],m=o[1];let h,d=D,g=0,y=r;"string"==typeof s&&s===p&&"mixed"!==s&&(h=s,d=F.find(D,[h,h]),g=F.convert(0,h),y=F.find(r,[h,h]));const x=n&&u?[]:void 0,b=[],v=[],w=n&&u?[]:void 0,N=n&&u?[]:void 0,A=[],E=[];let S,M,C,T,B;for(M=0;M<m;M++){v[M]=b.length;const e=M+1;for(T=a[M],B=a[M+1],C=T;C<B;C++)S=i[C],b.push(S),A[S]=e,w&&(w[S]=n[C]);for(T=c[M],B=c[M+1],C=T;C<B;C++)if(S=l[C],A[S]===e){if(w){const e=y(w[S],u[C]);d(e,g)?A[S]=null:w[S]=e}}else b.push(S),E[S]=e,N&&(N[S]=u[C]);if(w&&N)for(C=v[M];C<b.length;)S=b[C],A[S]===e?(x[C]=w[S],C++):E[S]===e?(x[C]=N[S],C++):b.splice(C,1)}return v[m]=b.length,e.createSparseMatrix({values:x,index:b,ptr:v,size:[f,m],datatype:s===e._datatype&&p===t._datatype?h:void 0})}}),Va=s("matAlgo10xSids",["typed","DenseMatrix"],e=>{let{typed:d,DenseMatrix:g}=e;return function(i,t,e,r){var a=i._values,o=i._index,s=i._ptr,n=i._size,i=i._datatype;if(!a)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var u=n[0],l=n[1];let c,f=e;"string"==typeof i&&(c=i,t=d.convert(t,c),f=d.find(e,[c,c]));const p=[],m=[],h=[];for(let n=0;n<l;n++){const d=n+1;for(let e=s[n],t=s[n+1],r=e;r<t;r++){const i=o[r];m[i]=a[r],h[i]=d}for(let e=0;e<u;e++)0===n&&(p[e]=[]),h[e]===d?p[e][n]=r?f(t,m[e]):f(m[e],t):p[e][n]=t}return new g({data:p,size:[u,l],datatype:c})}});function Za(e,t,r,n){if(!(this instanceof Za))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}(Za.prototype=new Error).constructor=Error,Za.prototype.name="ArgumentsError",Za.prototype.isArgumentsError=!0;function Wa(e){return!e.some(e=>Array.isArray(e))}const Ya=s("gcd",["typed","config","round","matrix","equalScalar","zeros","BigNumber","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,config:n,round:i,equalScalar:a,zeros:o,BigNumber:s,DenseMatrix:u,concat:l}=e;const c=$a({typed:t,config:n,round:i,matrix:r,equalScalar:a,zeros:o,DenseMatrix:u,concat:l}),f=Ha({typed:t}),p=Ga({typed:t,equalScalar:a}),m=Va({typed:t,DenseMatrix:u});return t("gcd",{"number, number":function(e,t){if(!v(e)||!v(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=c(e,t),e=t,t=r;return e<0?-e:e},"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");const r=new s(0);for(;!t.isZero();){const r=c(e,t);e=t,t=r}return e.lt(r)?e.neg():e},"Fraction, Fraction":(e,t)=>e.gcd(t)},C({typed:t,matrix:r,concat:l})({SS:p,DS:f,Ss:m}),{"number | BigNumber | Fraction | Matrix | Array, number | BigNumber | Fraction | Matrix | Array, ...number | BigNumber | Fraction | Matrix | Array":t.referToSelf(i=>(e,t,r)=>{let n=i(e,t);for(let e=0;e<r.length;e++)n=i(n,r[e]);return n}),Array:t.referToSelf(t=>e=>{if(1===e.length&&Array.isArray(e[0])&&Wa(e[0]))return t(...e[0]);if(Wa(e))return t(...e);throw new Za("gcd() supports only 1d matrices!")}),Matrix:t.referToSelf(t=>e=>t(e.toArray()))})}),Ja=s("matAlgo06xS0S0",["typed","equalScalar"],e=>{let{typed:v,equalScalar:w}=e;return function(e,r,t){var n=e._values,i=e._size,a=e._datatype||void 0===e._data?e._datatype:e.getDataType(),o=r._values,s=r._size,u=r._datatype||void 0===r._data?r._datatype:r.getDataType();if(i.length!==s.length)throw new z(i.length,s.length);if(i[0]!==s[0]||i[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+i+") must match Matrix B ("+s+")");var s=i[0],l=i[1];let c,f=w,p=0,m=t;"string"==typeof a&&a===u&&"mixed"!==a&&(c=a,f=v.find(w,[c,c]),p=v.convert(0,c),m=v.find(t,[c,c]));const h=n&&o?[]:void 0,d=[],g=[],y=h?[]:void 0,x=[],b=[];for(let t=0;t<l;t++){g[t]=d.length;const w=t+1;if(ii(e,t,x,y,b,w,d,m),ii(r,t,x,y,b,w,d,m),y){let e=g[t];for(;e<d.length;){const v=d[e];if(b[v]===w){const w=y[v];f(w,p)?d.splice(e,1):(h.push(w),e++)}else d.splice(e,1)}}else{let e=g[t];for(;e<d.length;)b[d[e]]!==w?d.splice(e,1):e++}}return g[l]=d.length,e.createSparseMatrix({values:h,index:d,ptr:g,size:[s,l],datatype:a===e._datatype&&u===r._datatype?c:void 0})}}),Xa=s("lcm",["typed","matrix","equalScalar","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,concat:i}=e;const a=Ra({typed:t,equalScalar:n}),o=Ja({typed:t,equalScalar:n}),s=Aa({typed:t,equalScalar:n}),u=C({typed:t,matrix:r,concat:i}),l="number | BigNumber | Fraction | Matrix | Array",c={};return c[l+`, ${l}, ...`+l]=t.referToSelf(i=>(e,t,r)=>{let n=i(e,t);for(let e=0;e<r.length;e++)n=i(n,r[e]);return n}),t("lcm",{"number, number":ea,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;const r=e.times(t);for(;!t.isZero();){const r=t;t=e.mod(r),e=r}return r.div(e).abs()},"Fraction, Fraction":(e,t)=>e.lcm(t)},u({SS:o,DS:a,Ss:s}),c)});function Qa(t,r,n,i){return function(e){if(0<e||n.predictable){if(e<=0)return NaN;const n=e.toString(16),i=n.substring(0,15);return t*(n.length-i.length)+r(Number("0x"+i))}return i(e.toNumber())}}const Ka=Pe(16),eo=s("log10",["typed","config","Complex"],e=>{let{typed:t,config:r,Complex:n}=e;function i(e){return e.log().div(Math.LN10)}function a(e){return i(new n(e,0))}return t("log10",{number:function(e){return(0<=e||r.predictable?ra:a)(e)},bigint:Qa(Ka,ra,r,a),Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():a(e.toNumber())},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),to=s("log2",["typed","config","Complex"],e=>{let{typed:t,config:r,Complex:n}=e;function i(e){return a(new n(e,0))}return t("log2",{number:function(e){return(0<=e||r.predictable?na:i)(e)},bigint:Qa(4,na,r,i),Complex:a,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(e.toNumber())},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}}),ro=s("multiplyScalar",["typed"],e=>{let t=e["typed"];return t("multiplyScalar",{"number, number":Zi,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"bigint, bigint":function(e,t){return e*t},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":(e,t)=>t.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,t)=>e.multiply(t)})}),no="multiply",io=s(no,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],e=>{let{typed:F,matrix:i,addScalar:D,multiplyScalar:O,equalScalar:N,dot:a}=e;const r=Aa({typed:F,equalScalar:N}),n=Ea({typed:F});function o(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}const s=F("_multiplyMatrixVector",{"DenseMatrix, any":function(e,t){var r=e._data,n=e._size,i=e._datatype||e.getDataType(),a=t._data,o=t._datatype||t.getDataType(),s=n[0],u=n[1];let l,c=D,f=O;i&&o&&i===o&&"string"==typeof i&&"mixed"!==i&&(l=i,c=F.find(D,[l,l]),f=F.find(O,[l,l]));const p=[];for(let e=0;e<s;e++){const F=r[e];let t=f(F[0],a[0]);for(let e=1;e<u;e++)t=c(t,f(F[e],a[e]));p[e]=t}return e.createDenseMatrix({data:p,size:[s],datatype:i===e._datatype&&o===t._datatype?l:void 0})},"SparseMatrix, any":function(i,e){var a=i._values,o=i._index,s=i._ptr,t=i._datatype||void 0===i._data?i._datatype:i.getDataType();if(!a)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");const r=e._data,n=e._datatype||e.getDataType(),u=i._size[0],l=e._size[0],c=[],f=[],p=[];let m,h=D,d=O,g=N,y=0;t&&n&&t===n&&"string"==typeof t&&"mixed"!==t&&(m=t,h=F.find(D,[m,m]),d=F.find(O,[m,m]),g=F.find(N,[m,m]),y=F.convert(0,m));const x=[],b=[];for(let n=p[0]=0;n<l;n++){const F=r[n];if(!g(F,y))for(let e=s[n],t=s[n+1],r=e;r<t;r++){const i=o[r];b[i]?x[i]=h(x[i],d(F,a[r])):(b[i]=!0,f.push(i),x[i]=d(F,a[r]))}}for(let e=f.length,t=0;t<e;t++){const i=f[t];c[t]=x[i]}return p[1]=f.length,i.createSparseMatrix({values:c,index:f,ptr:p,size:[u,1],datatype:t===i._datatype&&n===e._datatype?m:void 0})}}),u=F("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":function(e,t){var r=e._data,n=e._size,i=e._datatype||e.getDataType(),a=t._data,o=t._size,s=t._datatype||t.getDataType(),u=n[0],l=n[1],c=o[1];let f,p=D,m=O;i&&s&&i===s&&"string"==typeof i&&"mixed"!==i&&"mixed"!==i&&(f=i,p=F.find(D,[f,f]),m=F.find(O,[f,f]));const h=[];for(let e=0;e<u;e++){const F=r[e];h[e]=[];for(let r=0;r<c;r++){let t=m(F[0],a[0][r]);for(let e=1;e<l;e++)t=p(t,m(F[e],a[e][r]));h[e][r]=t}}return e.createDenseMatrix({data:h,size:[u,c],datatype:i===e._datatype&&s===t._datatype?f:void 0})},"DenseMatrix, SparseMatrix":function(e,i){var a=e._data,t=e._size,r=e._datatype||e.getDataType(),o=i._values,s=i._index,n=i._ptr,u=i._size,l=i._datatype||void 0===i._data?i._datatype:i.getDataType();if(!o)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var c=t[0],f=u[1];let p,m=D,h=O,d=N,g=0;r&&l&&r===l&&"string"==typeof r&&"mixed"!==r&&(p=r,m=F.find(D,[p,p]),h=F.find(O,[p,p]),d=F.find(N,[p,p]),g=F.convert(0,p));const y=[],x=[],b=[],v=i.createSparseMatrix({values:y,index:x,ptr:b,size:[c,f],datatype:r===e._datatype&&l===i._datatype?p:void 0});for(let e=0;e<f;e++){b[e]=x.length;const F=n[e],i=n[e+1];if(i>F){let n=0;for(let r=0;r<c;r++){const O=r+1;let t;for(let e=F;e<i;e++){const F=s[e];n!==O?(t=h(a[r][F],o[e]),n=O):t=m(t,h(a[r][F],o[e]))}n!==O||d(t,g)||(x.push(r),y.push(t))}}}return b[f]=x.length,v},"SparseMatrix, DenseMatrix":function(a,e){var o=a._values,s=a._index,u=a._ptr,t=a._datatype||void 0===a._data?a._datatype:a.getDataType();if(!o)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var r=e._data,n=e._datatype||e.getDataType(),i=a._size[0],l=e._size[0],c=e._size[1];let f,p=D,m=O,h=N,d=0;t&&n&&t===n&&"string"==typeof t&&"mixed"!==t&&(f=t,p=F.find(D,[f,f]),m=F.find(O,[f,f]),h=F.find(N,[f,f]),d=F.convert(0,f));const g=[],y=[],x=[],b=a.createSparseMatrix({values:g,index:y,ptr:x,size:[i,c],datatype:t===a._datatype&&n===e._datatype?f:void 0}),v=[],w=[];for(let i=0;i<c;i++){x[i]=y.length;const F=i+1;for(let n=0;n<l;n++){const D=r[n][i];if(!h(D,d))for(let e=u[n],t=u[n+1],r=e;r<t;r++){const a=s[r];w[a]!==F?(w[a]=F,y.push(a),v[a]=m(D,o[r])):v[a]=p(v[a],m(D,o[r]))}}for(let e=x[i],t=y.length,r=e;r<t;r++){const a=y[r];g[r]=v[a]}}return x[c]=y.length,b},"SparseMatrix, SparseMatrix":function(i,e){var t=i._values,r=i._index,a=i._ptr,n=i._datatype||void 0===i._data?i._datatype:i.getDataType(),o=e._values,s=e._index,u=e._ptr,l=e._datatype||void 0===e._data?e._datatype:e.getDataType(),c=i._size[0],f=e._size[1],p=t&&o;let m,h=D,d=O;n&&l&&n===l&&"string"==typeof n&&"mixed"!==n&&(m=n,h=F.find(D,[m,m]),d=F.find(O,[m,m]));const g=p?[]:void 0,y=[],x=[],b=i.createSparseMatrix({values:g,index:y,ptr:x,size:[c,f],datatype:n===i._datatype&&l===e._datatype?m:void 0}),v=p?[]:void 0,w=[];let N,A,E,S,M,C,T,B;for(let n=0;n<f;n++){x[n]=y.length;const F=n+1;for(M=u[n],C=u[n+1],S=M;S<C;S++)if(B=s[S],p)for(A=a[B],E=a[B+1],N=A;N<E;N++)T=r[N],w[T]!==F?(w[T]=F,y.push(T),v[T]=d(o[S],t[N])):v[T]=h(v[T],d(o[S],t[N]));else for(A=a[B],E=a[B+1],N=A;N<E;N++)T=r[N],w[T]!==F&&(w[T]=F,y.push(T));if(p)for(let e=x[n],t=y.length,r=e;r<t;r++){const i=y[r];g[r]=v[i]}}return x[f]=y.length,b}});return F(no,O,{"Array, Array":F.referTo("Matrix, Matrix",n=>(e,t)=>{o(T(e),T(t));const r=n(i(e),i(t));return _(r)?r.valueOf():r}),"Matrix, Matrix":function(e,t){var r=e.size(),n=t.size();return o(r,n),(1===r.length?1===n.length?function(e,t){if(0===r[0])throw new Error("Cannot multiply two empty vectors");return a(e,t)}:function(t,r){if("dense"!==r.storage())throw new Error("Support for SparseMatrix not implemented");{var a=t._data,o=t._size,s=t._datatype||t.getDataType(),u=r._data,l=r._size,c=r._datatype||r.getDataType(),f=o[0],p=l[1];let e,n=D,i=O;s&&c&&s===c&&"string"==typeof s&&"mixed"!==s&&(e=s,n=F.find(D,[e,e]),i=F.find(O,[e,e]));const m=[];for(let r=0;r<p;r++){let t=i(a[0],u[0][r]);for(let e=1;e<f;e++)t=n(t,i(a[e],u[e][r]));m[r]=t}return t.createDenseMatrix({data:m,size:[p],datatype:s===t._datatype&&c===r._datatype?e:void 0})}}:1===n.length?s:u)(e,t)},"Matrix, Array":F.referTo("Matrix,Matrix",r=>(e,t)=>r(e,i(t))),"Array, Matrix":F.referToSelf(r=>(e,t)=>r(i(e,t.storage()),t)),"SparseMatrix, any":function(e,t){return r(e,t,O,!1)},"DenseMatrix, any":function(e,t){return n(e,t,O,!1)},"any, SparseMatrix":function(e,t){return r(t,e,O,!0)},"any, DenseMatrix":function(e,t){return n(t,e,O,!0)},"Array, any":function(e,t){return n(i(e),t,O,!1).valueOf()},"any, Array":function(e,t){return n(i(t),e,O,!0).valueOf()},"any, any":O,"any, any, ...any":F.referToSelf(i=>(e,t,r)=>{let n=i(e,t);for(let e=0;e<r.length;e++)n=i(n,r[e]);return n})})}),ao="nthRoot",oo=s(ao,["typed","matrix","equalScalar","BigNumber","concat"],e=>{let{typed:t,matrix:n,equalScalar:r,BigNumber:u,concat:i}=e;const a=Ha({typed:t}),o=Ra({typed:t,equalScalar:r}),s=Ja({typed:t,equalScalar:r}),l=Aa({typed:t,equalScalar:r}),c=C({typed:t,matrix:n,concat:i});function f(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return t(ao,{number:ia,"number, number":ia,BigNumber:e=>p(e,new u(2)),"BigNumber, BigNumber":p,Complex:f,"Complex, number":f,Array:t.referTo("DenseMatrix,number",t=>e=>t(n(e),2).valueOf()),DenseMatrix:t.referTo("DenseMatrix,number",t=>e=>t(e,2)),SparseMatrix:t.referTo("SparseMatrix,number",t=>e=>t(e,2)),"SparseMatrix, SparseMatrix":t.referToSelf(r=>(e,t)=>{if(1===t.density())return s(e,t,r);throw new Error("Root must be non-zero")}),"DenseMatrix, SparseMatrix":t.referToSelf(r=>(e,t)=>{if(1===t.density())return a(e,t,r,!1);throw new Error("Root must be non-zero")}),"Array, SparseMatrix":t.referTo("DenseMatrix,SparseMatrix",r=>(e,t)=>r(n(e),t)),"number | BigNumber, SparseMatrix":t.referToSelf(r=>(e,t)=>{if(1===t.density())return l(t,e,r,!0);throw new Error("Root must be non-zero")})},c({scalar:"number | BigNumber",SD:o,Ss:l,sS:!1}));function p(e,t){const r=u.precision,n=u.clone({precision:r+2}),i=new u(0),a=new n(1),o=t.isNegative();if((t=o?t.neg():t).isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return o?new n(1/0):0;if(!e.isFinite())return o?i:e;let s=e.abs().pow(a.div(t));return s=e.isNeg()?s.neg():s,new u((o?a.div(s):s).toPrecision(r))}}),so=s("sign",["typed","BigNumber","Fraction","complex"],e=>{let{typed:r,BigNumber:t,complex:n,Fraction:i}=e;return r("sign",{number:aa,Complex:function(e){return 0===e.im?n(aa(e.re)):e.sign()},BigNumber:function(e){return new t(e.cmp(0))},bigint:function(e){return 0n<e?1n:e<0n?-1n:0n},Fraction:function(e){return 0n===e.n?new i(0):new i(e.s)},"Array | Matrix":r.referToSelf(t=>e=>le(e,t,!0)),Unit:r.referToSelf(t=>e=>{if(e._isDerived()||0===e.units[0].unit.offset)return r.find(t,e.valueType())(e.value);throw new TypeError("sign is ambiguous for units with offset")})})}),uo=s("sqrt",["config","typed","Complex"],e=>{let{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:0<=e||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}}),lo=s("square",["typed"],e=>{let t=e["typed"];return t("square",{number:oa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},bigint:function(e){return e*e},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})}),co="subtract",fo=s(co,["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,subtractScalar:i,DenseMatrix:a,concat:o}=e;const s=Ha({typed:t}),u=Pa({typed:t}),l=Ua({typed:t,equalScalar:n}),c=Va({typed:t,DenseMatrix:a}),f=x({typed:t,DenseMatrix:a}),p=C({typed:t,matrix:r,concat:o});return t(co,{"any, any":i},p({elop:i,SS:l,DS:s,SD:u,Ss:f,sS:c}))}),po=s("xgcd",["typed","config","matrix","BigNumber"],e=>{let{typed:t,config:p,matrix:m,BigNumber:h}=e;return t("xgcd",{"number, number":function(e,t){e=sa(e,t);return"Array"===p.matrix?e:m(e)},"BigNumber, BigNumber":function(e,t){let r,n,i;var a=new h(0),o=new h(1);let s,u=a,l=o,c=o,f=a;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)n=e.div(t).floor(),i=e.mod(t),r=u,u=l.minus(n.times(u)),l=r,r=c,c=f.minus(n.times(c)),f=r,e=t,t=i;return s=e.lt(a)?[e.neg(),l.neg(),f.neg()]:[e,e.isZero()?0:l,f],"Array"===p.matrix?s:m(s)}})}),mo=s("invmod",["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],e=>{let{typed:t,BigNumber:a,xgcd:o,equal:s,smaller:u,mod:l,add:c,isInteger:f}=e;return t("invmod",{"number, number":r,"BigNumber, BigNumber":r});function r(e,t){if(!f(e)||!f(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=l(e,t),s(t,0))throw new Error("Divisor must be non zero");let r=o(e,t),[n,i]=r=r.valueOf();return s(n,a(1))?(i=l(i,t),i=u(i,a(0))?c(i,t):i):NaN}}),ho=s("matAlgo09xS0Sf",["typed","equalScalar"],e=>{let{typed:T,equalScalar:B}=e;return function(e,t,r){var n=e._values,i=e._index,a=e._ptr,o=e._size,s=e._datatype||void 0===e._data?e._datatype:e.getDataType(),u=t._values,l=t._index,c=t._ptr,f=t._size,p=t._datatype||void 0===t._data?t._datatype:t.getDataType();if(o.length!==f.length)throw new z(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");var f=o[0],m=o[1];let h,d=B,g=0,y=r;"string"==typeof s&&s===p&&"mixed"!==s&&(h=s,d=T.find(B,[h,h]),g=T.convert(0,h),y=T.find(r,[h,h]));const x=n&&u?[]:void 0,b=[],v=[],w=x?[]:void 0,N=[];let A,E,S,M,C;for(E=0;E<m;E++){v[E]=b.length;const e=E+1;if(w)for(M=c[E],C=c[E+1],S=M;S<C;S++)A=l[S],N[A]=e,w[A]=u[S];for(M=a[E],C=a[E+1],S=M;S<C;S++)if(A=i[S],w){const T=N[A]===e?w[A]:g,B=y(n[S],T);d(B,g)||(b.push(A),x.push(B))}else b.push(A)}return v[m]=b.length,e.createSparseMatrix({values:x,index:b,ptr:v,size:[f,m],datatype:s===e._datatype&&p===t._datatype?h:void 0})}}),go="dotMultiply",yo=s(go,["typed","matrix","equalScalar","multiplyScalar","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,multiplyScalar:i,concat:a}=e;const o=Ra({typed:t,equalScalar:n}),s=ho({typed:t,equalScalar:n}),u=Aa({typed:t,equalScalar:n}),l=C({typed:t,matrix:r,concat:a});return t(go,l({elop:i,SS:s,DS:o,Ss:u}))});function xo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");const r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return wo(e,t,function(e,t){return e&t})}function bo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");const t=e.constructor,r=t.precision,n=(t.config({precision:1e9}),e.plus(new t(1)));return n.s=-n.s||null,t.config({precision:r}),n}function vo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");const r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?wo(e,t,function(e,t){return e|t}):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function wo(e,t,r){const n=e.constructor;let i,a;var o=+(e.s<0),s=+(t.s<0);if(o){i=No(bo(e));for(let e=0;e<i.length;++e)i[e]^=1}else i=No(e);if(s){a=No(bo(t));for(let e=0;e<a.length;++e)a[e]^=1}else a=No(t);let u,l,c,f=(c=i.length<=a.length?(u=i,l=a,o):(u=a,l=i,s),u.length),p=l.length;var m=1^r(o,s);let h=new n(1^m),d=new n(1);var g=new n(2),e=n.precision;for(n.config({precision:1e9});0<f;)r(u[--f],l[--p])===m&&(h=h.plus(d)),d=d.times(g);for(;0<p;)r(c,l[--p])===m&&(h=h.plus(d)),d=d.times(g);return n.config({precision:e}),0==m&&(h.s=-h.s),h}function No(e){var r=e.d;let n=r[0]+"";for(let e=1;e<r.length;++e){let t=r[e]+"";for(let e=7-t.length;e--;)t="0"+t;n+=t}let t=n.length;for(;"0"===n.charAt(t);)t--;let i=e.e,a=n.slice(0,t+1||1);e=a.length;if(0<i)if(++i>e)for(i-=e;i--;)a+="0";else i<e&&(a=a.slice(0,i)+"."+a.slice(i));const o=[0];for(let t=0;t<a.length;){let e=o.length;for(;e--;)o[e]*=10;o[0]+=parseInt(a.charAt(t++));for(let e=0;e<o.length;++e)1<o[e]&&(null!==o[e+1]&&void 0!==o[e+1]||(o[e+1]=0),o[e+1]+=o[e]>>1,o[e]&=1)}return o.reverse()}function Ao(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");const r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?bo(t):t.eq(n)?bo(e):e.isFinite()&&t.isFinite()?wo(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function Eo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");const r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function So(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");const r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?(t.lt(55)?e.div(Math.pow(2,t.toNumber())+""):e.div(new r(2).pow(t))).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Mo="number, number";function Co(e,t){if(v(e)&&v(t))return e&t;throw new Error("Integers expected in function bitAnd")}function To(e){if(v(e))return~e;throw new Error("Integer expected in function bitNot")}function Bo(e,t){if(v(e)&&v(t))return e|t;throw new Error("Integers expected in function bitOr")}function Fo(e,t){if(v(e)&&v(t))return e^t;throw new Error("Integers expected in function bitXor")}function Do(e,t){if(v(e)&&v(t))return e<<t;throw new Error("Integers expected in function leftShift")}function Oo(e,t){if(v(e)&&v(t))return e>>t;throw new Error("Integers expected in function rightArithShift")}function _o(e,t){if(v(e)&&v(t))return e>>>t;throw new Error("Integers expected in function rightLogShift")}Co.signature=Mo,To.signature="number",_o.signature=Oo.signature=Do.signature=Fo.signature=Bo.signature=Mo;const zo=s("bitAnd",["typed","matrix","equalScalar","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,concat:i}=e;const a=Ra({typed:t,equalScalar:n}),o=Ja({typed:t,equalScalar:n}),s=Aa({typed:t,equalScalar:n}),u=C({typed:t,matrix:r,concat:i});return t("bitAnd",{"number, number":Co,"BigNumber, BigNumber":xo,"bigint, bigint":(e,t)=>e&t},u({SS:o,DS:a,Ss:s}))}),qo=s("bitNot",["typed"],e=>{let t=e["typed"];return t("bitNot",{number:To,BigNumber:bo,bigint:e=>~e,"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Io=s("bitOr",["typed","matrix","equalScalar","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a}=e;const o=Ha({typed:t}),s=Ga({typed:t,equalScalar:n}),u=Va({typed:t,DenseMatrix:i}),l=C({typed:t,matrix:r,concat:a});return t("bitOr",{"number, number":Bo,"BigNumber, BigNumber":vo,"bigint, bigint":(e,t)=>e|t},l({SS:s,DS:o,Ss:u}))}),ko=s("matAlgo07xSSf",["typed","SparseMatrix"],e=>{let{typed:b,SparseMatrix:v}=e;return function(r,n,e){var t=r._size,i=r._datatype||void 0===r._data?r._datatype:r.getDataType(),a=n._size,o=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(t.length!==a.length)throw new z(t.length,a.length);if(t[0]!==a[0]||t[1]!==a[1])throw new RangeError("Dimension mismatch. Matrix A ("+t+") must match Matrix B ("+a+")");var s=t[0],u=t[1];let l,c=0,f=e;"string"==typeof i&&i===o&&"mixed"!==i&&(l=i,c=b.convert(0,l),f=b.find(e,[l,l]));const p=[],m=[],h=new Array(u+1).fill(0),d=[],g=[],y=[],x=[];for(let e=0;e<u;e++){const v=e+1;let t=0;w(r,e,y,d,v),w(n,e,x,g,v);for(let e=0;e<s;e++){const b=f(y[e]===v?d[e]:c,x[e]===v?g[e]:c);0!==b&&!1!==b&&(m.push(e),p.push(b),t++)}h[e+1]=h[e]+t}return new v({values:p,index:m,ptr:h,size:[s,u],datatype:i===r._datatype&&o===n._datatype?l:void 0})};function w(r,n,i,a,o){var s=r._values,u=r._index,r=r._ptr;for(let e=r[n],t=r[n+1];e<t;e++){const n=u[e];i[n]=o,a[n]=s[e]}}}),Ro=s("bitXor",["typed","matrix","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,matrix:r,DenseMatrix:n,concat:i,SparseMatrix:a}=e;const o=Pa({typed:t}),s=ko({typed:t,SparseMatrix:a}),u=x({typed:t,DenseMatrix:n}),l=C({typed:t,matrix:r,concat:i});return t("bitXor",{"number, number":Fo,"BigNumber, BigNumber":Ao,"bigint, bigint":(e,t)=>e^t},l({SS:s,DS:o,Ss:u}))}),Po=s("arg",["typed"],e=>{let t=e["typed"];return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Uo=s("conj",["typed"],e=>{let t=e["typed"];return t("conj",{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),Unit:t.referToSelf(t=>e=>new e.constructor(t(e.toNumeric()),e.formatUnits())),"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),jo=s("im",["typed"],e=>{let t=e["typed"];return t("im",{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Lo=s("re",["typed"],e=>{let t=e["typed"];return t("re",{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),$o="number, number";function Ho(e){return!e}function Go(e,t){return!(!e&&!t)}function Vo(e,t){return!!e!=!!t}function Zo(e,t){return!(!e||!t)}Ho.signature="number",Zo.signature=Vo.signature=Go.signature=$o;const Wo=s("not",["typed"],e=>{let r=e["typed"];return r("not",{"null | undefined":()=>!0,number:Ho,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},bigint:e=>!e,Unit:r.referToSelf(t=>e=>r.find(t,e.valueType())(e.value)),"Array | Matrix":r.referToSelf(t=>e=>le(e,t))})}),Yo="nullish",Jo=s(Yo,["typed","matrix","size","flatten","deepEqual"],e=>{let{typed:t,matrix:n,size:i,flatten:a,deepEqual:o}=e;const s=Pa({typed:t}),u=Ea({typed:t}),l=ja({typed:t});return t(Yo,{"number|bigint|Complex|BigNumber|Fraction|Unit|string|boolean|SparseMatrix, any":(e,t)=>e,"null, any":(e,t)=>t,"undefined, any":(e,t)=>t,"SparseMatrix, Array | Matrix":(e,t)=>{var r=a(i(e).valueOf()),t=a(i(t).valueOf());if(o(r,t))return e;throw new z(r,t)},"DenseMatrix, DenseMatrix":t.referToSelf(r=>(e,t)=>l(e,t,r)),"DenseMatrix, SparseMatrix":t.referToSelf(r=>(e,t)=>s(e,t,r,!1)),"DenseMatrix, Array":t.referToSelf(r=>(e,t)=>l(e,n(t),r)),"DenseMatrix, any":t.referToSelf(r=>(e,t)=>u(e,t,r,!1)),"Array, Array":t.referToSelf(r=>(e,t)=>l(n(e),n(t),r).valueOf()),"Array, DenseMatrix":t.referToSelf(r=>(e,t)=>l(n(e),t,r)),"Array, SparseMatrix":t.referToSelf(r=>(e,t)=>s(n(e),t,r,!1)),"Array, any":t.referToSelf(r=>(e,t)=>u(n(e),t,r,!1).valueOf())})}),Xo=s("or",["typed","matrix","equalScalar","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a}=e;const o=Pa({typed:t}),s=Ua({typed:t,equalScalar:n}),u=x({typed:t,DenseMatrix:i}),l=C({typed:t,matrix:r,concat:a});return t("or",{"number, number":Go,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"bigint, bigint":Go,"Unit, Unit":t.referToSelf(r=>(e,t)=>r(e.value||0,t.value||0))},l({SS:s,DS:o,Ss:u}))}),Qo=s("xor",["typed","matrix","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,matrix:r,DenseMatrix:n,concat:i,SparseMatrix:a}=e;const o=Pa({typed:t}),s=ko({typed:t,SparseMatrix:a}),u=x({typed:t,DenseMatrix:n}),l=C({typed:t,matrix:r,concat:i});return t("xor",{"number, number":Vo,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"bigint, bigint":Vo,"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":t.referToSelf(r=>(e,t)=>r(e.value||0,t.value||0))},l({SS:s,DS:o,Ss:u}))}),Ko=s("concat",["typed","matrix","isInteger"],e=>{let{typed:t,matrix:u,isInteger:l}=e;return t("concat",{"...Array | Matrix | number | BigNumber":function(e){let t;var r=e.length;let n,i=-1,a=!1;const o=[];for(t=0;t<r;t++){const u=e[t];if(_(u)&&(a=!0),A(u)||Q(u)){if(t!==r-1)throw new Error("Dimension must be specified as last argument");if(n=i,i=u.valueOf(),!l(i))throw new TypeError("Integer number expected for dimension");if(i<0||0<t&&i>n)throw new En(i,n+1)}else{const e=ee(u).valueOf(),l=T(e);if(o[t]=e,n=i,i=l.length-1,0<t&&i!==n)throw new z(n+1,i+1)}}if(0===o.length)throw new SyntaxError("At least one matrix expected");let s=o.shift();for(;o.length;)s=Ln(s,o.shift(),i);return a?u(s):s},"...string":function(e){return e.join("")}})}),es=s("column",["typed","Index","matrix","range"],e=>{let{typed:t,Index:n,matrix:i,range:a}=e;return t("column",{"Matrix, number":r,"Array, number":function(e,t){return r(i(ee(e)),t).valueOf()}});function r(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");M(t,e.size()[1]);var r=a(0,e.size()[0]),r=new n(r,t),t=e.subset(r);return _(t)?t:i([[t]])}}),ts=s("count",["typed","size","prod"],e=>{let{typed:t,size:r,prod:n}=e;return t("count",{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})}),rs=s("cross",["typed","matrix","subtract","multiply"],e=>{let{typed:t,matrix:r,subtract:a,multiply:o}=e;return t("cross",{"Matrix, Matrix":function(e,t){return r(n(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(n(e.toArray(),t))},"Array, Matrix":function(e,t){return r(n(e,t.toArray()))},"Array, Array":n});function n(e,t){var r=Math.max(T(e).length,T(t).length);e=On(e),t=On(t);const n=T(e),i=T(t);if(1!==n.length||1!==i.length||3!==n[0]||3!==i[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+n.join(", ")+"], B = ["+i.join(", ")+"])");e=[a(o(e[1],t[2]),o(e[2],t[1])),a(o(e[2],t[0]),o(e[0],t[2])),a(o(e[0],t[1]),o(e[1],t[0]))];return 1<r?[e]:e}}),ns=s("diag",["typed","matrix","DenseMatrix","SparseMatrix"],e=>{let{typed:t,matrix:y,DenseMatrix:x,SparseMatrix:b}=e;return t("diag",{Array:function(e){return n(e,0,T(e),null)},"Array, number":function(e,t){return n(e,t,T(e),null)},"Array, BigNumber":function(e,t){return n(e,t.toNumber(),T(e),null)},"Array, string":function(e,t){return n(e,0,T(e),t)},"Array, number, string":function(e,t,r){return n(e,t,T(e),r)},"Array, BigNumber, string":function(e,t,r){return n(e,t.toNumber(),T(e),r)},Matrix:function(e){return n(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return n(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return n(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return n(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return n(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return n(e,t.toNumber(),e.size(),r)}});function n(e,t,r,n){if(!v(t))throw new TypeError("Second parameter in function diag must be an integer");var i=0<t?t:0,a=t<0?-t:0;switch(r.length){case 1:{var o=e;var s=t;var u=n;var l=r[0];l=[l+a,l+i];if(u&&"sparse"!==u&&"dense"!==u)throw new TypeError(`Unknown matrix type ${u}"`);const h=("sparse"===u?b:x).diagonal(l,o,s);return null!==u?h:h.valueOf();return}case 2:{var c=e;l=n;var f=r;var p=a;var m=i;if(_(c)){const f=c.diagonal(t);return null!==l?l!==f.storage()?y(f,l):f:f.valueOf()}const d=Math.min(f[0]-p,f[1]-m),g=[];for(let e=0;e<d;e++)g[e]=c[e+p][e+m];return null!==l?y(g):g;return}}throw new RangeError("Matrix for function diag must be 2 dimensional")}}),is=s("filter",["typed"],e=>{let t=e["typed"];return t("filter",{"Array, function":as,"Matrix, function":function(e,t){return e.create(as(e.valueOf(),t),e.datatype())},"Array, RegExp":kn,"Matrix, RegExp":function(e,t){return e.create(kn(e.valueOf(),t),e.datatype())}})});function as(e,t){const n=Yn(t,e,"filter");return n.isUnary?In(e,n.fn):In(e,function(e,t,r){return n.fn(e,[t],r)})}const os="flatten",ss=s(os,["typed"],e=>{let t=e["typed"];return t(os,{Array:function(e){return E(e)},Matrix:function(e){return e.create(E(e.valueOf(),!0),e.datatype())}})}),us="forEach",ls=s(us,["typed"],e=>{let t=e["typed"];return t(us,{"Array, function":cs,"Matrix, function":function(e,t){e.forEach(t)}})});function cs(e,t){t=Yn(t,e,us);Wn(e,t.fn,t.isUnary)}const fs="getMatrixDataType",ps=s(fs,["typed"],e=>{let t=e["typed"];return t(fs,{Array:function(e){return jn(e,K)},Matrix:function(e){return e.getDataType()}})}),ms="identity",hs=s(ms,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],e=>{let{typed:t,config:r,matrix:n,BigNumber:l,DenseMatrix:c,SparseMatrix:f}=e;return t(ms,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return a(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return a(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return a(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":a,Array:function(e){return i(e)},"Array, string":i,Matrix:function(e){return i(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return a(e[0],e[0],t);case 2:return a(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function a(e,t,r){const n=Q(e)||Q(t)?l:null;if(Q(e)&&(e=e.toNumber()),Q(t)&&(t=t.toNumber()),!v(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!v(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var i=n?new l(1):1,a=n?new n(0):0,o=[e,t];if(r){if("sparse"===r)return f.diagonal(o,i,0,a);if("dense"===r)return c.diagonal(o,i,0,a);throw new TypeError(`Unknown matrix type "${r}"`)}const s=Tn([],o,a),u=e<t?e:t;for(let e=0;e<u;e++)s[e][e]=i;return s}}),ds=s("kron",["typed","matrix","multiplyScalar"],e=>{let{typed:t,matrix:r,multiplyScalar:a}=e;return t("kron",{"Matrix, Matrix":function(e,t){return r(n(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(n(e.toArray(),t))},"Array, Matrix":function(e,t){return r(n(e,t.toArray()))},"Array, Array":n});function n(e,r){if(1===T(e).length&&(e=[e]),1===T(r).length&&(r=[r]),2<T(e).length||2<T(r).length)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(r.length)+")");const n=[];let i=[];return e.map(function(t){return r.map(function(e){return i=[],n.push(i),t.map(function(t){return e.map(function(e){return i.push(a(t,e))})})})})&&n}}),gs=s("map",["typed"],e=>{let h=e["typed"];return h("map",{"Array, function":d,"Matrix, function":function(e,t){return e.map(t)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(e,t,n)=>{{var i=[e,t,...n.slice(0,n.length-1)],a=n[n.length-1];if("function"!=typeof a)throw new Error("Last argument must be a callback function");const c=i[0].isMatrix,f=$n(...i.map(e=>e.isMatrix?e.size():T(e))),p=c?(e,t)=>e.get(t):Vn,m=c?i.map(e=>e.isMatrix?e.create(Gn(e.toArray(),f),e.datatype()):i[0].create(Gn(e.valueOf(),f))):i.map(e=>e.isMatrix?Gn(e.toArray(),f):Gn(e,f));let r;if(h.isTypedFunction(a)){const i=f.map(()=>0),d=m.map(e=>p(e,i)),c=(u=a,e=d,o=i,s=m,null!==h.resolve(u,[...e,o,...s])?2:null!==h.resolve(u,[...e,o])?1:(h.resolve(u,e),0));r=l(c)}else{const h=i.length,d=(s=h,(o=a).length>s+1?2:o.length===s+1?1:0);r=l(d)}var o,s,u=(e,t)=>r([e,...m.slice(1).map(e=>p(e,t))],t);return c?m[0].map(u):d(m[0],u);function l(e){switch(e){case 0:return e=>a(...e);case 1:return(e,t)=>a(...e,t);case 2:return(e,t)=>a(...e,t,...m)}}}}});function d(e,t){t=Yn(t,e,"map");return Zn(e,t.fn,t.isUnary)}}),ys=s("diff",["typed","matrix","subtract","number"],e=>{let{typed:t,matrix:r,subtract:i,number:n}=e;return t("diff",{"Array | Matrix":function(e){return _(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(v(t))return _(e)?r(a(e.toArray(),t)):a(e,t);throw new RangeError("Dimension must be a whole number")},"Array, BigNumber":t.referTo("Array,number",r=>(e,t)=>r(e,n(t))),"Matrix, BigNumber":t.referTo("Matrix,number",r=>(e,t)=>r(e,n(t)))});function a(e,t){if(_(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(0<t){const r=[];return e.forEach(e=>{r.push(a(e,t-1))}),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(t){const r=[],n=t.length;for(let e=1;e<n;e++)r.push(function a(e,t){_(e)&&(e=e.toArray()),_(t)&&(t=t.toArray());const r=Array.isArray(e),n=Array.isArray(t);if(r&&n)return function(t,r){if(t.length!==r.length)throw RangeError("Not all sub-arrays have the same length");const n=[],i=t.length;for(let e=0;e<i;e++)n.push(a(t[e],r[e]));return n}(e,t);if(!r&&!n)return i(t,e);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}(t[e-1],t[e]));return r}}),xs=s("ones",["typed","config","matrix","BigNumber"],e=>{let{typed:t,config:r,matrix:i,BigNumber:a}=e;return t("ones",{"":function(){return"Array"===r.matrix?n([]):n([],"default")},"...number | BigNumber | string":function(e){var t;return"string"==typeof e[e.length-1]?(t=e.pop(),n(e,t)):"Array"===r.matrix?n(e):n(e,"default")},Array:n,Matrix:function(e){var t=e.storage();return n(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return n(e.valueOf(),t)}});function n(e,t){const r=function(){let n=!1;return e.forEach(function(e,t,r){Q(e)&&(n=!0,r[t]=e.toNumber())}),n}(),n=r?new a(1):1;if(e.forEach(function(e){if("number"!=typeof e||!v(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}),t){const r=i(t);return 0<e.length?r.resize(e,n):r}{const t=[];return 0<e.length?Tn(t,e,n):t}}});function bs(){throw new Error('No "bignumber" implementation available')}function vs(){throw new Error('No "fraction" implementation available')}function ws(){throw new Error('No "matrix" implementation available')}const Ns=s("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],e=>{let{typed:t,config:n,matrix:r,bignumber:i,smaller:s,smallerEq:u,larger:l,largerEq:c,add:f,isPositive:p}=e;return t("range",{string:o,"string, boolean":o,number:function(e){throw new TypeError("Too few arguments to function range(): "+e)},boolean:function(e){throw new TypeError(`Unexpected type of argument 1 to function range(): ${e}, number|bigint|BigNumber|Fraction`)},"number, number":function(e,t){return a(m(e,t,1,!1))},"number, number, number":function(e,t,r){return a(m(e,t,r,!1))},"number, number, boolean":function(e,t,r){return a(m(e,t,1,r))},"number, number, number, boolean":function(e,t,r,n){return a(m(e,t,r,n))},"bigint, bigint|number":function(e,t){return a(m(e,t,1n,!1))},"number, bigint":function(e,t){return a(m(BigInt(e),t,1n,!1))},"bigint, bigint|number, bigint|number":function(e,t,r){return a(m(e,t,BigInt(r),!1))},"number, bigint, bigint|number":function(e,t,r){return a(m(BigInt(e),t,BigInt(r),!1))},"bigint, bigint|number, boolean":function(e,t,r){return a(m(e,t,1n,r))},"number, bigint, boolean":function(e,t,r){return a(m(BigInt(e),t,1n,r))},"bigint, bigint|number, bigint|number, boolean":function(e,t,r,n){return a(m(e,t,BigInt(r),n))},"number, bigint, bigint|number, boolean":function(e,t,r,n){return a(m(BigInt(e),t,BigInt(r),n))},"BigNumber, BigNumber":function(e,t){return a(m(e,t,new e.constructor(1),!1))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return a(m(e,t,r,!1))},"BigNumber, BigNumber, boolean":function(e,t,r){return a(m(e,t,new e.constructor(1),r))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return a(m(e,t,r,n))},"Fraction, Fraction":function(e,t){return a(m(e,t,1,!1))},"Fraction, Fraction, Fraction":function(e,t,r){return a(m(e,t,r,!1))},"Fraction, Fraction, boolean":function(e,t,r){return a(m(e,t,1,r))},"Fraction, Fraction, Fraction, boolean":function(e,t,r,n){return a(m(e,t,r,n))},"Unit, Unit, Unit":function(e,t,r){return a(m(e,t,r,!1))},"Unit, Unit, Unit, boolean":function(e,t,r,n){return a(m(e,t,r,n))}});function a(e){return"Matrix"===n.matrix?r?r(e):ws():e}function o(t,e){var r=function(){const e=t.split(":").map(function(e){return Number(e)});if(e.some(function(e){return isNaN(e)}))return null;switch(e.length){case 2:return{start:e[0],end:e[1],step:1};case 3:return{start:e[0],end:e[2],step:e[1]};default:return null}}();if(r)return"BigNumber"===n.number?(void 0===i&&bs(),a(m(i(r.start),i(r.end),i(r.step)))):a(m(r.start,r.end,r.step,e));throw new SyntaxError('String "'+t+'" is no valid range')}function m(e,t,r,n){const i=[],a=p(r)?n?u:s:n?c:l;let o=e;for(;a(o,t);)i.push(o),o=f(o,r);return i}}),As="reshape",Es=s(As,["typed","isInteger","matrix"],e=>{let{typed:t,isInteger:r}=e;return t(As,{"Matrix, Array":function(e,t){return e.reshape(t,!0)},"Array, Array":function(e,t){return t.forEach(function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)}),Bn(e,t)}})}),Ss=s("resize",["config","matrix"],e=>{let{config:s,matrix:u}=e;return function(e,t,r){if(2!==arguments.length&&3!==arguments.length)throw new Za("resize",arguments.length,2,3);if(Q((t=_(t)?t.valueOf():t)[0])&&(t=t.map(function(e){return Q(e)?e.toNumber():e})),_(e))return e.resize(t,r,!0);if("string"==typeof e){var n=e,i=t,a=r;if(void 0!==a){if("string"!=typeof a||1!==a.length)throw new TypeError("Single character expected as defaultValue")}else a=" ";if(1!==i.length)throw new z(i.length,1);var o=i[0];if("number"!=typeof o||!v(o))throw new TypeError("Invalid size, must contain positive integers (size: "+S(i)+")");if(n.length>o)return n.substring(0,o);if(n.length<o){let r=n;for(let e=0,t=o-n.length;e<t;e++)r+=a;return r}return n}i=!Array.isArray(e)&&"Array"!==s.matrix;if(0===t.length){for(;Array.isArray(e);)e=e[0];return ee(e)}{const s=Tn(e=ee(e=Array.isArray(e)?e:[e]),t,r);return i?u(s):s}}}),Ms=s("rotate",["typed","multiply","rotationMatrix"],e=>{let{typed:t,multiply:n,rotationMatrix:i}=e;return t("rotate",{"Array , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(i(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(i(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,r){return a(e,3),n(i(t,r),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,r){return a(e,3),n(i(t,r),e)}});function a(e,t){e=Array.isArray(e)?T(e):e.size();if(2<e.length)throw new RangeError("Vector must be of dimensions 1x"+t);if(2===e.length&&1!==e[1])throw new RangeError("Vector must be of dimensions 1x"+t);if(e[0]!==t)throw new RangeError("Vector must be of dimensions 1x"+t)}}),Cs="rotationMatrix",Ts=s(Cs,["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],e=>{let{typed:t,config:n,multiplyScalar:i,addScalar:m,unaryMinus:h,norm:d,BigNumber:g,matrix:a,DenseMatrix:r,SparseMatrix:o,cos:y,sin:x}=e;return t(Cs,{"":function(){return"Matrix"===n.matrix?a([]):[]},string:function(e){return a(e)},"number | BigNumber | Complex | Unit":function(e){return s(e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":s,"number | BigNumber | Complex | Unit, Array":function(e,t){t=a(t);return u(t),l(e,t,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){u(t);var r=t.storage()||("Matrix"===n.matrix?"dense":void 0);return l(e,t,r)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){t=a(t);return u(t),l(e,t,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return u(t),l(e,t,r)}});function s(e,t){var r=Q(e)?new g(-1):-1,n=y(e),e=x(e);return v([[n,i(r,e)],[e,n]],t)}function u(e){e=e.size();if(e.length<1||3!==e[0])throw new RangeError("Vector must be of dimensions 1x3")}function b(e){return e.reduce((e,t)=>i(e,t))}function v(e,t){if(t){if("sparse"===t)return new o(e);if("dense"===t)return new r(e);throw new TypeError(`Unknown matrix type "${t}"`)}return e}function l(e,t,r){var n=d(t);if(0===n)throw new RangeError("Rotation around zero vector");const i=Q(e)?g:null,a=i?new i(1):1,o=i?new i(-1):-1,s=i?new i(t.get([0])/n):t.get([0])/n,u=i?new i(t.get([1])/n):t.get([1])/n,l=i?new i(t.get([2])/n):t.get([2])/n,c=y(e),f=m(a,h(c)),p=x(e);return v([[m(c,b([s,s,f])),m(b([s,u,f]),b([o,l,p])),m(b([s,l,f]),b([u,p]))],[m(b([s,u,f]),b([l,p])),m(c,b([u,u,f])),m(b([u,l,f]),b([o,s,p]))],[m(b([s,l,f]),b([o,u,p])),m(b([u,l,f]),b([s,p])),m(c,b([l,l,f]))]],r)}}),Bs=s("row",["typed","Index","matrix","range"],e=>{let{typed:t,Index:n,matrix:i,range:a}=e;return t("row",{"Matrix, number":r,"Array, number":function(e,t){return r(i(ee(e)),t).valueOf()}});function r(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");M(t,e.size()[0]);var r=a(0,e.size()[1]),t=new n(t,r),r=e.subset(t);return _(r)?r:i([[r]])}}),Fs=s("size",["typed","config","?matrix"],e=>{let{typed:t,config:r,matrix:n}=e;return t("size",{Matrix:function(e){return e.create(e.size(),"number")},Array:T,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length],"dense","number")},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([],"dense","number"):ws()}})}),Ds="squeeze",Os=s(Ds,["typed"],e=>{let t=e["typed"];return t(Ds,{Array:function(e){return On(ee(e))},Matrix:function(e){var t=On(e.toArray());return Array.isArray(t)?e.create(t,e.datatype()):t},any:ee})}),_s=s("subset",["typed","matrix","zeros","add"],e=>{let{typed:t,matrix:o,zeros:i,add:a}=e;return t("subset",{"Matrix, Index":function(e,t){return Cn(t)?o():(Mn(e,t),e.subset(t))},"Array, Index":t.referTo("Matrix, Index",function(n){return function(e,t){const r=n(o(e),t);return t.isScalar()?r:r.valueOf()}}),"Object, Index":Is,"string, Index":zs,"Matrix, Index, any, any":function(e,t,r,n){return Cn(t)?e:(Mn(e,t),e.clone().subset(t,function(e,t){if("string"==typeof e)throw new Error("can't boradcast a string");if(t._isScalar)return e;const r=t.size();if(!r.every(e=>0<e))return e;try{return a(e,i(r))}catch(t){return e}}(r,t),n))},"Array, Index, any, any":t.referTo("Matrix, Index, any, any",function(a){return function(e,t,r,n){const i=a(o(e),t,r,n);return i.isMatrix?i.valueOf():i}}),"Array, Index, any":t.referTo("Matrix, Index, any, any",function(n){return function(e,t,r){return n(o(e),t,r,void 0).valueOf()}}),"Matrix, Index, any":t.referTo("Matrix, Index, any, any",function(n){return function(e,t,r){return n(e,t,r,void 0)}}),"string, Index, string":qs,"string, Index, string, string":qs,"Object, Index, any":ks})});function zs(t,e){if(!Z(e))throw new TypeError("Index expected");if(Cn(e))return"";if(Mn(Array.from(t),e),1!==e.size().length)throw new z(e.size().length,1);var r=t.length;M(e.min()[0],r),M(e.max()[0],r);const n=e.dimension(0);let i="";return n.forEach(function(e){i+=t.charAt(e)}),i}function qs(t,e,r,n){if(!e||!0!==e.isIndex)throw new TypeError("Index expected");if(Cn(e))return t;if(Mn(Array.from(t),e),1!==e.size().length)throw new z(e.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";const i=e.dimension(0);if(i.size()[0]!==r.length)throw new z(i.size()[0],r.length);var a=t.length;M(e.min()[0]),M(e.max()[0]);const o=[];for(let e=0;e<a;e++)o[e]=t.charAt(e);if(i.forEach(function(e,t){o[e]=r.charAt(t[0])}),o.length>a)for(let e=a-1,t=o.length;e<t;e++)o[e]||(o[e]=n);return o.join("")}function Is(e,t){if(!Cn(t)){if(1!==t.size().length)throw new z(t.size(),1);t=t.dimension(0);if("string"!=typeof t)throw new TypeError("String expected as index to retrieve an object property");return h(e,t)}}function ks(e,t,r){if(Cn(t))return e;if(1!==t.size().length)throw new z(t.size(),1);t=t.dimension(0);if("string"!=typeof t)throw new TypeError("String expected as index to retrieve an object property");e=ee(e);return D(e,t,r),e}const Rs="transpose",Ps=s(Rs,["typed","matrix"],e=>{let{typed:t,matrix:r}=e;return t(Rs,{Array:e=>n(r(e)).valueOf(),Matrix:n,any:ee});function n(e){var t=e.size();let r;switch(t.length){case 1:r=e.clone();break;case 2:var n=t[0],i=t[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+S(t)+")");switch(e.storage()){case"dense":r=function(e,r,n){const i=e._data,a=[];let o;for(let t=0;t<n;t++){o=a[t]=[];for(let e=0;e<r;e++)o[e]=ee(i[e][t])}return e.createDenseMatrix({data:a,size:[n,r],datatype:e._datatype})}(e,n,i);break;case"sparse":r=function(n,t,e){const i=n._values,a=n._index,o=n._ptr,s=i?[]:void 0,u=[],r=[],l=[];for(let e=0;e<t;e++)l[e]=0;let c,f,p;for(c=0,f=a.length;c<f;c++)l[a[c]]++;let m=0;for(let e=0;e<t;e++)r.push(m),m+=l[e],l[e]=r[e];for(r.push(m),p=0;p<e;p++)for(let e=o[p],t=o[p+1],r=e;r<t;r++){const n=l[a[r]]++;u[n]=p,i&&(s[n]=ee(i[r]))}return n.createSparseMatrix({values:s,index:u,ptr:r,size:[e,t],datatype:n._datatype})}(e,n,i)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+S(t)+")")}return r}}),Us="ctranspose",js=s(Us,["typed","transpose","conj"],e=>{let{typed:t,transpose:r,conj:n}=e;return t(Us,{any:function(e){return n(r(e))}})}),Ls=s("zeros",["typed","config","matrix","BigNumber"],e=>{let{typed:t,config:r,matrix:i,BigNumber:a}=e;return t("zeros",{"":function(){return"Array"===r.matrix?n([]):n([],"default")},"...number | BigNumber | string":function(e){var t;return"string"==typeof e[e.length-1]?(t=e.pop(),n(e,t)):"Array"===r.matrix?n(e):n(e,"default")},Array:n,Matrix:function(e){var t=e.storage();return n(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return n(e.valueOf(),t)}});function n(e,t){const r=function(){let n=!1;return e.forEach(function(e,t,r){Q(e)&&(n=!0,r[t]=e.toNumber())}),n}(),n=r?new a(0):0;if(e.forEach(function(e){if("number"!=typeof e||!v(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}),t){const r=i(t);return 0<e.length?r.resize(e,n):r}{const t=[];return 0<e.length?Tn(t,e,n):t}}}),$s=s("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],e=>{let{typed:t,addScalar:d,multiplyScalar:g,divideScalar:y,exp:x,tau:b,i:v,dotDivide:w,conj:N,pow:A,ceil:E,log2:S}=e;return t("fft",{Array:M,Matrix:function(e){return e.create(M(e.valueOf()),e.datatype())}});function M(e){const t=T(e);return 1===t.length?C(e,t[0]):function r(n,i){const e=T(n);if(0!==i)return new Array(e[0]).fill(0).map((e,t)=>r(n[t],i-1));if(1===e.length)return C(n);function t(n){const t=T(n);return new Array(t[1]).fill(0).map((e,r)=>new Array(t[0]).fill(0).map((e,t)=>n[t][r]))}return t(r(t(n),1))}(e.map(e=>M(e,t.slice(1))),0)}function C(e){var t=e.length;if(1===t)return[e[0]];if(t%2!=0){var r=e;const n=r.length,i=x(y(g(-1,g(v,b)),n)),a=[];for(let e=1-n;e<n;e++)a.push(A(i,y(A(e,2),2)));const o=A(2,E(S(n+n-1))),s=[...new Array(n).fill(0).map((e,t)=>g(r[t],a[n-1+t])),...new Array(o-n).fill(0)],u=[...new Array(n+n-1).fill(0).map((e,t)=>y(1,a[t])),...new Array(o-(n+n-1)).fill(0)],l=C(s),c=C(u),f=new Array(o).fill(0).map((e,t)=>g(l[t],c[t])),p=w(N(M(N(f))),o),m=[];for(let e=n-1;e<n+n-1;e++)m.push(g(p[e],a[e]));return m}{const h=[...C(e.filter((e,t)=>t%2==0)),...C(e.filter((e,t)=>t%2==1))];for(let e=0;e<t/2;e++){const w=h[e],N=g(h[e+t/2],x(g(g(b,v),y(-e,t))));h[e]=d(w,N),h[e+t/2]=d(w,g(-1,N))}return h}}}),Hs=s("ifft",["typed","fft","dotDivide","conj"],e=>{let{typed:t,fft:r,dotDivide:n,conj:i}=e;return t("ifft",{"Array | Matrix":function(e){const t=_(e)?e.size():T(e);return n(i(r(i(e))),t.reduce((e,t)=>e*t,1))}})}),Gs=s("solveODE",["typed","add","subtract","multiply","divide","max","map","abs","isPositive","isNegative","larger","smaller","matrix","bignumber","unaryMinus"],e=>{let{typed:t,add:T,subtract:B,multiply:F,divide:D,max:O,map:_,abs:z,isPositive:q,isNegative:I,larger:k,smaller:R,matrix:a,bignumber:P,unaryMinus:U}=e;function i(C){return function(t,e,r,n){if(2!==e.length||!e.every(j)&&!e.every(L))throw new Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');const i=e[0],a=e[1],o=k(a,i),s=n.firstStep;if(void 0!==s&&!q(s))throw new Error('"firstStep" must be positive');const u=n.maxStep;if(void 0!==u&&!q(u))throw new Error('"maxStep" must be positive');const l=n.minStep;if(l&&I(l))throw new Error('"minStep" must be positive or zero');const c=[i,a,s,l,u].filter(e=>void 0!==e);if(!c.every(j)&&!c.every(L))throw new Error('Inconsistent type of "t" dependant variables');var f=n.tol||1e-4,p=n.minDelta||.2,m=n.maxDelta||5,h=n.maxIter||1e4,d=[i,a,...r,u,l].some(Q),[g,y,x,e]=d?[P(C.a),P(C.c),P(C.b),P(C.bp)]:[C.a,C.c,C.b,C.bp];let b=s?o?s:U(s):D(B(a,i),1);const v=[i],w=[r],N=B(x,e);let A=0,E=0;const S=o?R:k,M=function(){const i=o?k:R;return function(e,t,r){var n=T(e,r);return i(n,t)?B(t,e):r}}();for(;S(v[A],a);){const C=[];b=M(v[A],a,b),C.push(t(v[A],w[A]));for(let e=1;e<y.length;++e)C.push(t(T(v[A],F(y[e],b)),T(w[A],F(b,g[e],C))));const B=O(z(_(F(N,C),e=>L(e)?e.value:e)));B<f&&.25<f/B&&(v.push(T(v[A],b)),w.push(T(w[A],F(b,x,C))),A++);let e=.84*(f/B)**.2;if(R(e,p)?e=p:k(e,m)&&(e=m),e=d?P(e):e,b=F(b,e),u&&k(z(b),u)?b=o?u:U(u):l&&R(z(b),l)&&(b=o?l:U(l)),++E>h)throw new Error("Maximum number of iterations reached, try changing options")}return{t:v,y:w}}}function s(e,t,r,n){return i({a:[[],[.5],[0,.75],[2/9,1/3,4/9]],c:[null,.5,.75,1],b:[2/9,1/3,4/9,0],bp:[7/24,.25,1/3,1/8]})(e,t,r,n)}function u(e,t,r,n){return i({a:[[],[.2],[.075,.225],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]],c:[null,.2,.3,.8,8/9,1,1],b:[35/384,0,500/1113,125/192,-2187/6784,11/84,0],bp:[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,.025]})(e,t,r,n)}function o(e,t,r,n){const i=n.method||"RK45",a={RK23:s,RK45:u};if(i.toUpperCase()in a){const o={...n};return delete o.method,a[i.toUpperCase()](e,t,r,o)}{const e=Object.keys(a).map(e=>`"${e}"`),t=e.slice(0,-1).join(", ")+" and "+e.slice(-1);throw new Error(`Unavailable method "${i}". Available methods are `+t)}}function j(e){return Q(e)||A(e)}function n(e,t,r,n){e=o(e,t.toArray(),r.toArray(),n);return{t:a(e.t),y:a(e.y)}}return t("solveODE",{"function, Array, Array, Object":o,"function, Matrix, Matrix, Object":n,"function, Array, Array":(e,t,r)=>o(e,t,r,{}),"function, Matrix, Matrix":(e,t,r)=>n(e,t,r,{}),"function, Array, number | BigNumber | Unit":(e,t,r)=>{const n=o(e,t,[r],{});return{t:n.t,y:n.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit":(e,t,r)=>{const n=o(e,t.toArray(),[r],{});return{t:a(n.t),y:a(n.y.map(e=>e[0]))}},"function, Array, number | BigNumber | Unit, Object":(e,t,r,n)=>{const i=o(e,t,[r],n);return{t:i.t,y:i.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit, Object":(e,t,r,n)=>{const i=o(e,t.toArray(),[r],n);return{t:a(i.t),y:a(i.y.map(e=>e[0]))}}})}),Vs=s("erf",["typed"],e=>{let t=e["typed"];return t("name",{number:function(e){var t=Math.abs(e);return t>=Xs?ke(e):t<=Zs?ke(e)*function(e){var t=e*e;let r,n=Ys[0][4]*t,i=t;for(r=0;r<3;r+=1)n=(n+Ys[0][r])*t,i=(i+Js[0][r])*t;return e*(n+Ys[0][3])/(i+Js[0][3])}(t):t<=4?ke(e)*(1-function(e){let t,r=Ys[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Ys[1][t])*e,n=(n+Js[1][t])*e;var i=(r+Ys[1][7])/(n+Js[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):ke(e)*(1-function(e){let t,r=1/(e*e),n=Ys[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Ys[2][t])*r,i=(i+Js[2][t])*r;var a=r*(n+Ys[2][4])/(i+Js[2][4]),a=(Ws-a)/e,e=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-e)*a}(t))},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Zs=.46875,Ws=.5641895835477563,Ys=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Js=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],Xs=Math.pow(2,53),Qs=s("zeta",["typed","config","multiply","pow","divide","factorial","equal","smallerEq","isNegative","gamma","sin","subtract","add","?Complex","?BigNumber","pi"],e=>{let{typed:t,config:r,multiply:u,pow:l,divide:c,factorial:i,equal:n,smallerEq:f,isNegative:a,gamma:p,sin:m,subtract:h,add:d,Complex:o,BigNumber:s,pi:g}=e;return t("zeta",{number:e=>y(e,e=>e,()=>20),BigNumber:e=>y(e,e=>new s(e),()=>Math.abs(Math.log10(r.relTol))),Complex:function(e){return 0===e.re&&0===e.im?new o(-.5):1===e.re?new o(NaN,NaN):e.re===1/0&&0===e.im?new o(1):e.im===1/0||e.re===-1/0?new o(NaN,NaN):x(e,e=>e,e=>Math.round(19.5+.9*Math.abs(e.im)),e=>e.re)}});function y(e,t,r){return n(e,0)?t(-.5):n(e,1)?t(NaN):isFinite(e)?x(e,t,r,e=>e):a(e)?t(NaN):t(1)}function x(e,r,t,n){var i=t(e);{if(n(e)>-(i-1)/2){var a=e,o=r(i),i=r,s=c(1,u(b(i(0),o),h(1,l(2,h(1,a)))));let t=i(0);for(let e=i(1);f(e,o);e=d(e,1))t=d(t,c(u((-1)**(e-1),b(e,o)),l(e,a)));return u(s,t)}return i=u(l(2,e),l(r(g),h(e,1))),i=u(i,m(u(c(r(g),2),e))),i=u(i,p(h(1,e))),u(i,x(h(1,e),r,t,n))}}function b(t,r){let n=t;for(let e=t;f(e,r);e=d(e,1)){const t=c(u(i(d(r,h(e,1))),l(4,e)),u(i(h(r,e)),i(u(2,e))));n=d(n,t)}return u(r,n)}}),Ks=s("mode",["typed","isNaN","isNumeric"],e=>{let{typed:t,isNaN:o,isNumeric:s}=e;return t("mode",{"Array | Matrix":r,"...":r});function r(t){if(0===(t=E(t.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");const r={};let n=[],i=0;for(let e=0;e<t.length;e++){var a=t[e];if(s(a)&&o(a))throw new Error("Cannot calculate mode of an array containing NaN values");a in r||(r[a]=0),r[a]++,r[a]===i?n.push(a):r[a]>i&&(i=r[a],n=[a])}return n}});function eu(e,t,r){let n;return String(e).includes("Unexpected type")?(n=2<arguments.length?" (type: "+K(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):String(e).includes("complex numbers")?(n=2<arguments.length?" (type: "+K(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}const tu=s("prod",["typed","config","multiplyScalar","numeric"],e=>{let{typed:t,config:n,multiplyScalar:i,numeric:a}=e;return t("prod",{"Array | Matrix":r,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":r});function r(e){let r;if(ti(e,function(t){try{r=void 0===r?t:i(r,t)}catch(e){throw eu(e,"prod",t)}}),void 0===(r="string"==typeof r?a(r,Ie(r,n)):r))throw new Error("Cannot calculate prod of an empty array");return r}}),ru=s("format",["typed"],e=>{let t=e["typed"];return t("format",{any:S,"any, Object | function | number | BigNumber":S})}),nu=s("bin",["typed","format"],e=>{let{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number | BigNumber":function(e,t){return r(e,{notation:"bin",wordSize:t})}})}),iu=s("oct",["typed","format"],e=>{let{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number | BigNumber":function(e,t){return r(e,{notation:"oct",wordSize:t})}})}),au=s("hex",["typed","format"],e=>{let{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number | BigNumber":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}),ou=/\$([\w.]+)/g,su=s("print",["typed"],e=>{let t=e["typed"];return t("print",{"string, Object | Array":uu,"string, Object | Array, number | Object":uu})});function uu(e,i,a){return e.replace(ou,function(e,t){const r=t.split(".");let n=i[r.shift()];for(void 0!==n&&n.isMatrix&&(n=n.toArray());r.length&&void 0!==n;){const e=r.shift();n=e?n[e]:n+"."}return void 0!==n?j(n)?n:S(n,a):e})}const lu=s("to",["typed","matrix","concat"],e=>{let{typed:t,matrix:r,concat:n}=e;return t("to",{"Unit, Unit | string":(e,t)=>e.to(t)},C({typed:t,matrix:r,concat:n})({Ds:!0}))}),cu=s("toBest",["typed"],e=>{let t=e["typed"];return t("toBest",{Unit:e=>e.toBest(),"Unit, string":(e,t)=>e.toBest(t.split(",")),"Unit, string, Object":(e,t,r)=>e.toBest(t.split(","),r),"Unit, Array":(e,t)=>e.toBest(t),"Unit, Array, Object":(e,t,r)=>e.toBest(t,r)})}),fu="isPrime",pu=s(fu,["typed"],e=>{let t=e["typed"];return t(fu,{number:function(t){if(t<=3)return 1<t;if(t%2==0||t%3==0)return!1;for(let e=5;e*e<=t;e+=6)if(t%e==0||t%(e+2)==0)return!1;return!0},bigint:function(t){if(t<=3n)return 1n<t;if(t%2n===0n||t%3n===0n)return!1;for(let e=5n;e*e<=t;e+=6n)if(t%e===0n||t%(e+2n)===0n)return!1;return!0},BigNumber:function(r){if(r.lte(3))return r.gt(1);if(r.mod(2).eq(0)||r.mod(3).eq(0))return!1;if(r.lt(Math.pow(2,32))){const t=r.toNumber();for(let e=5;e*e<=t;e+=6)if(t%e==0||t%(e+2)==0)return!1;return!0}function t(e,t,r){let n=1;for(;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}const e=r.constructor.clone({precision:2*r.toFixed(0).length});let n=0,i=(r=new e(r)).sub(1);for(;i.mod(2).eq(0);)i=i.div(2),n+=1;let a=null;if(r.lt("3317044064679887385961981"))a=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(e=>e<r);else{const t=Math.min(r.toNumber()-2,Math.floor(2*Math.pow(r.toFixed(0).length*Math.log(10),2)));a=[];for(let e=2;e<=t;e+=1)a.push(t)}for(let e=0;e<a.length;e+=1){const o=a[e],s=t(r.sub(r).add(o),i,r);if(!s.eq(1))for(let e=0,t=s;!t.eq(r.sub(1));e+=1,t=t.mul(t).mod(r))if(e===n-1)return!1}return!0},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),mu=s("numeric",["number","?bignumber","?fraction"],e=>{let{number:t,bignumber:r,fraction:n}=e;const i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):bs,bigint:e=>BigInt(e),Fraction:n?e=>n(e):vs};return function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"number";if(void 0!==(2<arguments.length?arguments[2]:void 0))throw new SyntaxError("numeric() takes one or two arguments");var r=K(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(t in a)return t===r?e:a[t](e);throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "))}}),hu="divideScalar",du=s(hu,["typed","numeric"],e=>{let t=e["typed"];return t(hu,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"bigint, bigint":function(e,t){return e/t},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,t)=>e.divide(t),"number | Fraction | Complex | BigNumber, Unit":(e,t)=>t.divideInto(e)})}),gu=s("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],e=>{let{typed:t,config:n,identity:a,multiply:o,matrix:r,inv:s,number:i,fraction:u,Complex:l}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||0<=e||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"bigint, bigint":(e,t)=>e**t,"Fraction, Fraction":function(e,t){var r=e.pow(t);if(null!=r)return r;if(n.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":f,"Array, BigNumber":function(e,t){return f(e,t.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(e,t){return p(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(n.predictable&&!v(t)&&e<0)try{const n=u(t),r=i(n);if((t===r||Math.abs((t-r)/t)<1e-14)&&n.d%2n===1n)return(n.n%2n===0n?1:-1)*Math.pow(-e,t)}catch(e){}return n.predictable&&(e<-1&&t===1/0||-1<e&&e<0&&t===-1/0)?NaN:v(t)||0<=e||n.predictable?ua(e,t):e*e<1&&t===1/0||1<e*e&&t===-1/0?0:new l(e,0).pow(t,0)}function f(e,t){if(!v(t))throw new TypeError("For A^b, b must be an integer (value is "+t+")");var r=T(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");if(t<0)try{return f(s(e),-t)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+t+")");throw e}let n=a(r[0]).valueOf(),i=e;for(;1<=t;)1&~t||(n=o(i,n)),t>>=1,i=o(i,i);return n}function p(e,t){return r(f(e.valueOf(),t))}}),yu="Number of decimals in function round must be an integer",xu=s("round",["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],e=>{let{typed:t,config:i,matrix:n,equalScalar:a,zeros:o,BigNumber:r,DenseMatrix:s}=e;const u=Aa({typed:t,equalScalar:a}),l=x({typed:t,DenseMatrix:s}),c=Ea({typed:t});function f(e){return Math.abs(Ve(e).exponent)}return t("round",{number:function(e){var t=la(e,f(i.relTol));return la(Xe(e,t,i.relTol,i.absTol)?t:e)},"number, number":function(e,t){var r=f(i.relTol);if(r<=t)return la(e,t);r=la(e,r);return la(Xe(e,r,i.relTol,i.absTol)?r:e,t)},"number, BigNumber":function(e,t){if(t.isInteger())return new r(e).toDecimalPlaces(t.toNumber());throw new TypeError(yu)},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(yu);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(yu);t=t.toNumber();return e.round(t)},BigNumber:function(e){const t=new r(e).toDecimalPlaces(f(i.relTol));return(li(e,t,i.relTol,i.absTol)?t:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(yu);var r=f(i.relTol);if(r<=t)return e.toDecimalPlaces(t.toNumber());const n=e.toDecimalPlaces(r);return(li(e,n,i.relTol,i.absTol)?n:e).toDecimalPlaces(t.toNumber())},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(yu);return e.round(t)},"Fraction, BigNumber":function(e,t){if(t.isInteger())return e.round(t.toNumber());throw new TypeError(yu)},"Unit, number, Unit":t.referToSelf(n=>function(e,t,r){e=e.toNumeric(r);return r.multiply(n(e,t))}),"Unit, BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>n(e,t.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(n=>(e,t,r)=>le(e,e=>n(e,t,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(r=>(e,t)=>r(e,0,t)),"Array | Matrix":t.referToSelf(t=>e=>le(e,t,!0)),"SparseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>u(e,t,r,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>c(e,t,r,!1)),"Array, number | BigNumber":t.referToSelf(r=>(e,t)=>c(n(e),t,r,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":t.referToSelf(r=>(e,t)=>a(e,0)?o(t.size(),t.storage()):l(t,e,r,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":t.referToSelf(r=>(e,t)=>a(e,0)?o(t.size(),t.storage()):c(t,e,r,!0)),"number | Complex | BigNumber | Fraction, Array":t.referToSelf(r=>(e,t)=>c(n(t),e,r,!0).valueOf())})}),bu=Math.log(16),vu=s("log",["config","typed","typeOf","divideScalar","Complex"],e=>{let{typed:t,typeOf:n,config:r,divideScalar:i,Complex:a}=e;function o(e){return e.log()}function s(e){return o(new a(e,0))}return t("log",{number:function(e){return(0<=e||r.predictable?ta:s)(e)},bigint:Qa(bu,ta,r,s),Complex:o,BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():s(e.toNumber())},"any, any":t.referToSelf(r=>(e,t)=>{if("Fraction"===n(e)&&"Fraction"===n(t)){const r=e.log(t);if(null!==r)return r}return i(r(e),r(t))})})}),wu=s("log1p",["typed","config","divideScalar","log","Complex"],e=>{let{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t("log1p",{number:function(e){return-1<=e||r.predictable?Ue(e):o(new a(e,0))},Complex:o,BigNumber:function(e){const t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":t.referToSelf(t=>e=>le(e,t)),"any, any":t.referToSelf(r=>(e,t)=>n(r(e),i(t)))});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}),Nu="nthRoots",Au=s(Nu,["config","typed","divideScalar","Complex"],e=>{let{typed:t,Complex:u}=e;const l=[function(e){return new u(e,0)},function(e){return new u(0,e)},function(e){return new u(-e,0)},function(e){return new u(0,-e)}];function r(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new u(0,0)];const r="number"==typeof e;let n;!r&&0!==e.re&&0!==e.im||(n=r?2*(e<0):0===e.im?2*(e.re<0):2*(e.im<0)+1);const i=e.arg(),a=e.abs(),o=[],s=Math.pow(a,1/t);for(let e=0;e<t;e++){const r=(n+4*e)/t;r!==Math.round(r)?o.push(new u({r:s,phi:(i+2*Math.PI*e)/t})):o.push(l[r%4](s))}return o}return t(Nu,{Complex:function(e){return r(e,2)},"Complex, number":r})}),Eu=s("dotPow",["typed","equalScalar","matrix","pow","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e;const u=Pa({typed:t}),l=ko({typed:t,SparseMatrix:s}),c=Aa({typed:t,equalScalar:r}),f=x({typed:t,DenseMatrix:a}),p=C({typed:t,matrix:n,concat:o}),m={};for(const e in i.signatures)!Object.prototype.hasOwnProperty.call(i.signatures,e)||e.includes("Matrix")||e.includes("Array")||(m[e]=i.signatures[e]);e=t(m);return t("dotPow",p({elop:e,SS:l,DS:u,Ss:c,sS:f}))}),Su="dotDivide",Mu=s(Su,["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e;const u=Ra({typed:t,equalScalar:n}),l=Pa({typed:t}),c=ko({typed:t,SparseMatrix:s}),f=Aa({typed:t,equalScalar:n}),p=x({typed:t,DenseMatrix:a}),m=C({typed:t,matrix:r,concat:o});return t(Su,m({elop:i,SS:c,DS:l,SD:u,Ss:f,sS:p}))});function Cu(e){let s=e["DenseMatrix"];return function(r,t,n){const i=r.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+S(i)+")");var a=i[0];if(a!==i[1])throw new RangeError("Matrix must be square (size: "+S(i)+")");let o=[];if(_(t)){const r=t.size(),i=t._data;if(1===r.length){if(r[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(let e=0;e<a;e++)o[e]=[i[e]];return new s({data:o,size:[a,1],datatype:t._datatype})}if(2===r.length){if(r[0]!==a||1!==r[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(H(t)){if(n){o=[];for(let e=0;e<a;e++)o[e]=[i[e][0]];return new s({data:o,size:[a,1],datatype:t._datatype})}return t}if(G(t)){for(let e=0;e<a;e++)o[e]=[0];const r=t._values,n=t._index,i=t._ptr;for(let e=i[1],t=i[0];t<e;t++)o[n[t]][0]=r[t];return new s({data:o,size:[a,1],datatype:t._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(b(t)){const r=T(t);if(1===r.length){if(r[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(let e=0;e<a;e++)o[e]=[t[e]];return new s({data:o,size:[a,1]})}if(2!==r.length)throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");if(r[0]!==a||1!==r[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(let e=0;e<a;e++)o[e]=[t[e][0]];return new s({data:o,size:[a,1]})}}}const Tu=s("lsolve",["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],e=>{let{typed:t,matrix:r,divideScalar:m,multiplyScalar:h,subtractScalar:d,equalScalar:g,DenseMatrix:y}=e;const x=Cu({DenseMatrix:y});return t("lsolve",{"SparseMatrix, Array | Matrix":function(e,t){{var n=t;const a=(n=x(e,n,!0))._data,o=e._size[0],s=e._size[1],u=e._values,l=e._index,c=e._ptr,f=[];for(let r=0;r<s;r++){const n=a[r][0]||0;if(g(n,0))f[r]=[0];else{let t=0;const x=[],o=[],s=c[r],p=c[r+1];for(let e=s;e<p;e++){const a=l[e];a===r?t=u[e]:a>r&&(x.push(u[e]),o.push(a))}if(g(t,0))throw new Error("Linear system cannot be solved since matrix is singular");var i=m(n,t);for(let e=0,t=o.length;e<t;e++){const n=o[e];a[n]=[d(a[n][0]||0,h(i,x[e]))]}f[r]=[i]}}return new y({data:f,size:[o,1]})}},"DenseMatrix, Array | Matrix":n,"Array, Array | Matrix":function(e,t){return n(r(e),t).valueOf()}});function n(e,n){const i=(n=x(e,n,!0))._data,a=e._size[0],t=e._size[1],o=[],s=e._data;for(let r=0;r<t;r++){const n=i[r][0]||0;let t;if(g(n,0))t=0;else{const x=s[r][r];if(g(x,0))throw new Error("Linear system cannot be solved since matrix is singular");t=m(n,x);for(let e=r+1;e<a;e++)i[e]=[d(i[e][0]||0,h(t,s[e][r]))]}o[r]=[t]}return new y({data:o,size:[a,1]})}}),Bu=s("usolve",["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],e=>{let{typed:t,matrix:r,divideScalar:p,multiplyScalar:m,subtractScalar:h,equalScalar:d,DenseMatrix:g}=e;const y=Cu({DenseMatrix:g});return t("usolve",{"SparseMatrix, Array | Matrix":function(e,t){{var n=t;const a=(n=y(e,n,!0))._data,o=e._size[0],s=e._size[1],u=e._values,l=e._index,c=e._ptr,f=[];for(let r=s-1;0<=r;r--){const n=a[r][0]||0;if(d(n,0))f[r]=[0];else{let t=0;const y=[],o=[],s=c[r];for(let e=c[r+1]-1;e>=s;e--){const a=l[e];a===r?t=u[e]:a<r&&(y.push(u[e]),o.push(a))}if(d(t,0))throw new Error("Linear system cannot be solved since matrix is singular");var i=p(n,t);for(let e=0,t=o.length;e<t;e++){const n=o[e];a[n]=[h(a[n][0],m(i,y[e]))]}f[r]=[i]}}return new g({data:f,size:[o,1]})}},"DenseMatrix, Array | Matrix":n,"Array, Array | Matrix":function(e,t){return n(r(e),t).valueOf()}});function n(e,n){const i=(n=y(e,n,!0))._data,t=e._size[0],a=e._size[1],o=[],s=e._data;for(let r=a-1;0<=r;r--){const n=i[r][0]||0;let t;if(d(n,0))t=0;else{const y=s[r][r];if(d(y,0))throw new Error("Linear system cannot be solved since matrix is singular");t=p(n,y);for(let e=r-1;0<=e;e--)i[e]=[h(i[e][0]||0,m(t,s[e][r]))]}o[r]=[t]}return new g({data:o,size:[t,1]})}}),Fu="lsolveAll",Du=s(Fu,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],e=>{let{typed:t,matrix:r,divideScalar:m,multiplyScalar:h,subtractScalar:d,equalScalar:g,DenseMatrix:y}=e;const x=Cu({DenseMatrix:y});return t(Fu,{"SparseMatrix, Array | Matrix":function(e,t){{var i=t;const a=[x(e,i,!0)._data.map(e=>e[0])],o=e._size[0],s=e._size[1],u=e._values,l=e._index,c=e._ptr;for(let n=0;n<s;n++){let r=a.length;for(let e=0;e<r;e++){const x=a[e],o=[],s=[],f=c[n],p=c[n+1];let t=0;for(let e=f;e<p;e++){const a=l[e];a===n?t=u[e]:a>n&&(o.push(u[e]),s.push(a))}if(g(t,0))if(g(x[n],0)){if(0===e){const i=[...x];i[n]=1;for(let e=0,t=s.length;e<t;e++){const a=s[e];i[a]=d(i[a],o[e])}a.push(i)}}else{if(0===e)return[];a.splice(e,1),--e,--r}else{x[n]=m(x[n],t);for(let e=0,t=s.length;e<t;e++){const a=s[e];x[a]=d(x[a],h(x[n],o[e]))}}}}return a.map(e=>new y({data:e.map(e=>[e]),size:[o,1]}))}},"DenseMatrix, Array | Matrix":n,"Array, Array | Matrix":function(e,t){return n(r(e),t).map(e=>e.valueOf())}});function n(e,n){const i=[x(e,n,!0)._data.map(e=>e[0])],a=e._data,t=e._size[0],o=e._size[1];for(let r=0;r<o;r++){let t=i.length;for(let e=0;e<t;e++){const x=i[e];if(g(a[r][r],0))if(g(x[r],0)){if(0===e){const n=[...x];n[r]=1;for(let e=r+1;e<o;e++)n[e]=d(n[e],a[e][r]);i.push(n)}}else{if(0===e)return[];i.splice(e,1),--e,--t}else{x[r]=m(x[r],a[r][r]);for(let e=r+1;e<o;e++)x[e]=d(x[e],h(x[r],a[e][r]))}}}return i.map(e=>new y({data:e.map(e=>[e]),size:[t,1]}))}}),Ou="usolveAll",_u=s(Ou,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],e=>{let{typed:t,matrix:r,divideScalar:p,multiplyScalar:m,subtractScalar:h,equalScalar:d,DenseMatrix:g}=e;const y=Cu({DenseMatrix:g});return t(Ou,{"SparseMatrix, Array | Matrix":function(e,t){{var i=t;const a=[y(e,i,!0)._data.map(e=>e[0])],o=e._size[0],s=e._size[1],u=e._values,l=e._index,c=e._ptr;for(let n=s-1;0<=n;n--){let r=a.length;for(let e=0;e<r;e++){const y=a[e],o=[],s=[],f=c[n];let t=0;for(let e=c[n+1]-1;e>=f;e--){const a=l[e];a===n?t=u[e]:a<n&&(o.push(u[e]),s.push(a))}if(d(t,0))if(d(y[n],0)){if(0===e){const i=[...y];i[n]=1;for(let e=0,t=s.length;e<t;e++){const a=s[e];i[a]=h(i[a],o[e])}a.push(i)}}else{if(0===e)return[];a.splice(e,1),--e,--r}else{y[n]=p(y[n],t);for(let e=0,t=s.length;e<t;e++){const a=s[e];y[a]=h(y[a],m(y[n],o[e]))}}}}return a.map(e=>new g({data:e.map(e=>[e]),size:[o,1]}))}},"DenseMatrix, Array | Matrix":n,"Array, Array | Matrix":function(e,t){return n(r(e),t).map(e=>e.valueOf())}});function n(n,e){const i=[y(n,e,!0)._data.map(e=>e[0])],a=n._data,t=n._size[0];for(let r=n._size[1]-1;0<=r;r--){let t=i.length;for(let e=0;e<t;e++){const y=i[e];if(d(a[r][r],0))if(d(y[r],0)){if(0===e){const n=[...y];n[r]=1;for(let e=r-1;0<=e;e--)n[e]=h(n[e],a[e][r]);i.push(n)}}else{if(0===e)return[];i.splice(e,1),--e,--t}else{y[r]=p(y[r],a[r][r]);for(let e=r-1;0<=e;e--)y[e]=h(y[e],m(y[r],a[e][r]))}}}return i.map(e=>new g({data:e.map(e=>[e]),size:[t,1]}))}}),zu=s("matAlgo08xS0Sid",["typed","equalScalar"],e=>{let{typed:C,equalScalar:T}=e;return function(t,e,r){var n=t._values,i=t._index,a=t._ptr,o=t._size,s=t._datatype||void 0===t._data?t._datatype:t.getDataType(),u=e._values,l=e._index,c=e._ptr,f=e._size,p=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(o.length!==f.length)throw new z(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!n||!u)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var f=o[0],m=o[1];let h,d=T,g=0,y=r;"string"==typeof s&&s===p&&"mixed"!==s&&(h=s,d=C.find(T,[h,h]),g=C.convert(0,h),y=C.find(r,[h,h]));const x=[],b=[],v=[],w=[],N=[];let A,E,S,M;for(let e=0;e<m;e++){v[e]=b.length;const C=e+1;for(E=a[e],S=a[e+1],A=E;A<S;A++)M=i[A],N[M]=C,w[M]=n[A],b.push(M);for(E=c[e],S=c[e+1],A=E;A<S;A++)M=l[A],N[M]===C&&(w[M]=y(w[M],u[A]));for(A=v[e];A<b.length;){M=b[A];const t=w[M];d(t,g)?b.splice(A,1):(x.push(t),A++)}}return v[m]=b.length,t.createSparseMatrix({values:x,index:b,ptr:v,size:[f,m],datatype:s===t._datatype&&p===e._datatype?h:void 0})}}),qu=s("useMatrixForArrayScalar",["typed","matrix"],e=>{let{typed:t,matrix:n}=e;return{"Array, number":t.referTo("DenseMatrix, number",r=>(e,t)=>r(n(e),t).valueOf()),"Array, BigNumber":t.referTo("DenseMatrix, BigNumber",r=>(e,t)=>r(n(e),t).valueOf()),"number, Array":t.referTo("number, DenseMatrix",r=>(e,t)=>r(e,n(t)).valueOf()),"BigNumber, Array":t.referTo("BigNumber, DenseMatrix",r=>(e,t)=>r(e,n(t)).valueOf())}}),Iu="leftShift",ku=s(Iu,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e;const s=Ha({typed:t}),u=Ra({typed:t,equalScalar:n}),l=zu({typed:t,equalScalar:n}),c=Va({typed:t,DenseMatrix:a}),f=Aa({typed:t,equalScalar:n}),p=Ea({typed:t}),m=C({typed:t,matrix:r,concat:o}),h=qu({typed:t,matrix:r});return t(Iu,{"number, number":Do,"BigNumber, BigNumber":Eo,"bigint, bigint":(e,t)=>e<<t,"SparseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>n(t,0)?e.clone():f(e,t,r,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>n(t,0)?e.clone():p(e,t,r,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(r=>(e,t)=>n(e,0)?i(t.size(),t.storage()):c(t,e,r,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(r=>(e,t)=>n(e,0)?i(t.size(),t.storage()):p(t,e,r,!0))},h,m({SS:l,DS:s,SD:u}))}),Ru="rightArithShift",Pu=s(Ru,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e;const s=Ha({typed:t}),u=Ra({typed:t,equalScalar:n}),l=zu({typed:t,equalScalar:n}),c=Va({typed:t,DenseMatrix:a}),f=Aa({typed:t,equalScalar:n}),p=Ea({typed:t}),m=C({typed:t,matrix:r,concat:o}),h=qu({typed:t,matrix:r});return t(Ru,{"number, number":Oo,"BigNumber, BigNumber":So,"bigint, bigint":(e,t)=>e>>t,"SparseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>n(t,0)?e.clone():f(e,t,r,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>n(t,0)?e.clone():p(e,t,r,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(r=>(e,t)=>n(e,0)?i(t.size(),t.storage()):c(t,e,r,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(r=>(e,t)=>n(e,0)?i(t.size(),t.storage()):p(t,e,r,!0))},h,m({SS:l,DS:s,SD:u}))}),Uu="rightLogShift",ju=s(Uu,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e;const s=Ha({typed:t}),u=Ra({typed:t,equalScalar:n}),l=zu({typed:t,equalScalar:n}),c=Va({typed:t,DenseMatrix:a}),f=Aa({typed:t,equalScalar:n}),p=Ea({typed:t}),m=C({typed:t,matrix:r,concat:o}),h=qu({typed:t,matrix:r});return t(Uu,{"number, number":_o,"SparseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>n(t,0)?e.clone():f(e,t,r,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(r=>(e,t)=>n(t,0)?e.clone():p(e,t,r,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(r=>(e,t)=>n(e,0)?i(t.size(),t.storage()):c(t,e,r,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(r=>(e,t)=>n(e,0)?i(t.size(),t.storage()):p(t,e,r,!0))},h,m({SS:l,DS:s,SD:u}))}),Lu=s("and",["typed","matrix","equalScalar","zeros","not","concat"],e=>{let{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e;const s=Ra({typed:t,equalScalar:r}),u=Ja({typed:t,equalScalar:r}),l=Aa({typed:t,equalScalar:r}),c=Ea({typed:t}),f=C({typed:t,matrix:n,concat:o});return t("and",{"number, number":Zo,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"bigint, bigint":Zo,"Unit, Unit":t.referToSelf(r=>(e,t)=>r(e.value||0,t.value||0)),"SparseMatrix, any":t.referToSelf(r=>(e,t)=>a(t)?i(e.size(),e.storage()):l(e,t,r,!1)),"DenseMatrix, any":t.referToSelf(r=>(e,t)=>a(t)?i(e.size(),e.storage()):c(e,t,r,!1)),"any, SparseMatrix":t.referToSelf(r=>(e,t)=>a(e)?i(e.size(),e.storage()):l(t,e,r,!0)),"any, DenseMatrix":t.referToSelf(r=>(e,t)=>a(e)?i(e.size(),e.storage()):c(t,e,r,!0)),"Array, any":t.referToSelf(r=>(e,t)=>r(n(e),t).valueOf()),"any, Array":t.referToSelf(r=>(e,t)=>r(e,n(t)).valueOf())},f({SS:u,DS:s}))}),$u="compare",Hu=s($u,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],e=>{let{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s,concat:u}=e;const l=Pa({typed:t}),c=Ua({typed:t,equalScalar:n}),f=x({typed:t,DenseMatrix:s}),p=C({typed:t,matrix:i,concat:u}),m=wi({typed:t});return t($u,Gu({typed:t,config:r}),{"boolean, boolean":function(e,t){return e===t?0:t<e?1:-1},"BigNumber, BigNumber":function(e,t){return li(e,t,r.relTol,r.absTol)?new a(0):new a(e.cmp(t))},"bigint, bigint":function(e,t){return e===t?0n:t<e?1n:-1n},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,p({SS:c,DS:l,Ss:f}))}),Gu=s($u,["typed","config"],e=>{let{typed:t,config:r}=e;return t($u,{"number, number":function(e,t){return Xe(e,t,r.relTol,r.absTol)?0:t<e?1:-1}})});var Vu=fd(880);const Zu="compareNatural",Wu=s(Zu,["typed","compare"],e=>{let{typed:t,compare:m}=e;const h=m.signatures["boolean,boolean"];return t(Zu,{"any, any":function e(t,r){var n=K(t),i=K(r);let a;if(!("number"!==n&&"BigNumber"!==n&&"Fraction"!==n||"number"!==i&&"BigNumber"!==i&&"Fraction"!==i))return"0"!==(a=m(t,r)).toString()?0<a?1:-1:Vu(n,i);const o=["Array","DenseMatrix","SparseMatrix"];if(o.includes(n)||o.includes(i))return 0!==(a=function e(t,r,n){return G(r)&&G(n)?d(t,r.toJSON().values,n.toJSON().values):G(r)?e(t,r.toArray(),n):G(n)?e(t,r,n.toArray()):H(r)?e(t,r.toJSON().data,n):H(n)?e(t,r,n.toJSON().data):Array.isArray(r)?Array.isArray(n)?d(t,r,n):e(t,r,[n]):e(t,[r],n)}(e,t,r))?a:Vu(n,i);if(n!==i)return Vu(n,i);if("Complex"===n)return t.re>r.re?1:t.re<r.re?-1:t.im>r.im?1:t.im<r.im?-1:0;if("Unit"===n)return t.equalBase(r)?e(t.value,r.value):d(e,t.formatUnits(),r.formatUnits());if("boolean"===n)return h(t,r);if("string"===n)return Vu(t,r);if("Object"===n){var s=e,u=t,l=r;const c=Object.keys(u),f=Object.keys(l),p=(c.sort(Vu),f.sort(Vu),d(s,c,f));if(0!==p)return p;for(let e=0;e<c.length;e++){const p=s(u[c[e]],l[f[e]]);if(0!==p)return p}return 0}if("null"===n)return 0;if("undefined"===n)return 0;throw new TypeError('Unsupported type of value "'+n+'"')}});function d(r,n,i){for(let e=0,t=Math.min(n.length,i.length);e<t;e++){var a=r(n[e],i[e]);if(0!==a)return a}return n.length>i.length?1:n.length<i.length?-1:0}}),Yu="compareText",Ju=(An.signature="any, any",s(Yu,["typed","matrix","concat"],e=>{let{typed:t,matrix:r,concat:n}=e;const i=C({typed:t,matrix:r,concat:n});return t(Yu,An,i({elop:An,Ds:!0}))})),Xu="equal",Qu=s(Xu,["typed","matrix","equalScalar","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e;const s=Pa({typed:t}),u=ko({typed:t,SparseMatrix:o}),l=x({typed:t,DenseMatrix:i}),c=C({typed:t,matrix:r,concat:a});return t(Xu,Ku({typed:t,equalScalar:n}),c({elop:n,SS:u,DS:s,Ss:l}))}),Ku=s(Xu,["typed","equalScalar"],e=>{let{typed:t,equalScalar:r}=e;return t(Xu,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})}),el="equalText",tl=s(el,["typed","compareText","isZero"],e=>{let{typed:t,compareText:r,isZero:n}=e;return t(el,{"any, any":function(e,t){return n(r(e,t))}})}),rl="smaller",nl=s(rl,["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,config:r,bignumber:n,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e;const u=Pa({typed:t}),l=ko({typed:t,SparseMatrix:s}),c=x({typed:t,DenseMatrix:a}),f=C({typed:t,matrix:i,concat:o}),p=wi({typed:t});function m(e,t){return e.lt(t)&&!li(e,t,r.relTol,r.absTol)}return t(rl,il({typed:t,config:r}),{"boolean, boolean":(e,t)=>e<t,"BigNumber, BigNumber":m,"bigint, bigint":(e,t)=>e<t,"Fraction, Fraction":(e,t)=>-1===e.compare(t),"Fraction, BigNumber":function(e,t){return m(n(e),t)},"BigNumber, Fraction":function(e,t){return m(e,n(t))},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")}},p,f({SS:l,DS:u,Ss:c}))}),il=s(rl,["typed","config"],e=>{let{typed:t,config:r}=e;return t(rl,{"number, number":function(e,t){return e<t&&!Xe(e,t,r.relTol,r.absTol)}})}),al="smallerEq",ol=s(al,["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,config:r,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e;const s=Pa({typed:t}),u=ko({typed:t,SparseMatrix:o}),l=x({typed:t,DenseMatrix:i}),c=C({typed:t,matrix:n,concat:a}),f=wi({typed:t});return t(al,sl({typed:t,config:r}),{"boolean, boolean":(e,t)=>e<=t,"BigNumber, BigNumber":function(e,t){return e.lte(t)||li(e,t,r.relTol,r.absTol)},"bigint, bigint":(e,t)=>e<=t,"Fraction, Fraction":(e,t)=>1!==e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,c({SS:u,DS:s,Ss:l}))}),sl=s(al,["typed","config"],e=>{let{typed:t,config:r}=e;return t(al,{"number, number":function(e,t){return e<=t||Xe(e,t,r.relTol,r.absTol)}})}),ul="larger",ll=s(ul,["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,config:r,bignumber:n,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e;const u=Pa({typed:t}),l=ko({typed:t,SparseMatrix:s}),c=x({typed:t,DenseMatrix:a}),f=C({typed:t,matrix:i,concat:o}),p=wi({typed:t});function m(e,t){return e.gt(t)&&!li(e,t,r.relTol,r.absTol)}return t(ul,cl({typed:t,config:r}),{"boolean, boolean":(e,t)=>t<e,"BigNumber, BigNumber":m,"bigint, bigint":(e,t)=>t<e,"Fraction, Fraction":(e,t)=>1===e.compare(t),"Fraction, BigNumber":function(e,t){return m(n(e),t)},"BigNumber, Fraction":function(e,t){return m(e,n(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,f({SS:l,DS:u,Ss:c}))}),cl=s(ul,["typed","config"],e=>{let{typed:t,config:r}=e;return t(ul,{"number, number":function(e,t){return t<e&&!Xe(e,t,r.relTol,r.absTol)}})}),fl="largerEq",pl=s(fl,["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,config:r,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e;const s=Pa({typed:t}),u=ko({typed:t,SparseMatrix:o}),l=x({typed:t,DenseMatrix:i}),c=C({typed:t,matrix:n,concat:a}),f=wi({typed:t});return t(fl,ml({typed:t,config:r}),{"boolean, boolean":(e,t)=>t<=e,"BigNumber, BigNumber":function(e,t){return e.gte(t)||li(e,t,r.relTol,r.absTol)},"bigint, bigint":function(e,t){return t<=e},"Fraction, Fraction":(e,t)=>-1!==e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},f,c({SS:u,DS:s,Ss:l}))}),ml=s(fl,["typed","config"],e=>{let{typed:t,config:r}=e;return t(fl,{"number, number":function(e,t){return t<=e||Xe(e,t,r.relTol,r.absTol)}})}),hl="deepEqual",dl=s(hl,["typed","equal"],e=>{let{typed:t,equal:i}=e;return t(hl,{"any, any":function(e,t){return function t(r,n){if(Array.isArray(r)){if(Array.isArray(n)){const i=r.length;if(i!==n.length)return!1;for(let e=0;e<i;e++)if(!t(r[e],n[e]))return!1;return!0}return!1}return!Array.isArray(n)&&i(r,n)}(e.valueOf(),t.valueOf())}})}),gl="unequal",yl=s(gl,["typed","config","equalScalar","matrix","DenseMatrix","concat","SparseMatrix"],e=>{let{typed:t,equalScalar:r,matrix:n,DenseMatrix:i,concat:a,SparseMatrix:o}=e;const s=Pa({typed:t}),u=ko({typed:t,SparseMatrix:o}),l=x({typed:t,DenseMatrix:i}),c=C({typed:t,matrix:n,concat:a});return t(gl,xl({typed:t,equalScalar:r}),c({elop:function(e,t){return!r(e,t)},SS:u,DS:s,Ss:l}))}),xl=s(gl,["typed","equalScalar"],e=>{let{typed:t,equalScalar:r}=e;return t(gl,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})}),bl="partitionSelect",vl=s(bl,["typed","isNumeric","isNaN","compare"],e=>{let{typed:t,isNumeric:u,isNaN:l,compare:r}=e;const n=r,i=(e,t)=>-r(e,t);return t(bl,{"Array | Matrix, number":function(e,t){return a(e,t,n)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return a(e,t,n);if("desc"===r)return a(e,t,i);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":a});function a(e,t,r){if(!v(t)||t<0)throw new Error("k must be a non-negative integer");if(_(e)){if(1<e.size().length)throw new Error("Only one dimensional matrices supported");return o(e.valueOf(),t,r)}if(Array.isArray(e))return o(e,t,r)}function o(r,n,i){if(n>=r.length)throw new Error("k out of bounds");for(let e=0;e<r.length;e++)if(u(r[e])&&l(r[e]))return r[e];let a=0,o=r.length-1;for(;a<o;){let e=a,t=o;for(var s=r[Math.floor(Math.random()*(o-a+1))+a];e<t;)if(0<=i(r[e],s)){const n=r[t];r[t]=r[e],r[e]=n,--t}else++e;0<i(r[e],s)&&--e,n<=e?o=e:a=e+1}return r[n]}}),wl=s("sort",["typed","matrix","compare","compareNatural"],e=>{let{typed:t,matrix:r,compare:n,compareNatural:i}=e;const a=n,o=(e,t)=>-n(e,t);return t("sort",{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return l(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return l(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==T(e).length)throw new Error("One dimensional array expected")}function l(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}}),Nl=s("max",["typed","config","numeric","larger","isNaN"],e=>{let{typed:t,config:n,numeric:i,larger:a,isNaN:o}=e;return t("max",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return ri(e,t.valueOf(),r)},"...":function(e){if(ei(e))throw new TypeError("Scalar values expected in function max");return s(e)}});function r(e,t){try{return a(e,t)?e:t}catch(e){throw eu(e,"max",t)}}function s(e){let r;if(ti(e,function(t){try{(o(t)||void 0===r||a(t,r))&&(r=t)}catch(e){throw eu(e,"max",t)}}),void 0===r)throw new Error("Cannot calculate max of an empty array");return r="string"==typeof r?i(r,Ie(r,n)):r}}),Al=s("min",["typed","config","numeric","smaller","isNaN"],e=>{let{typed:t,config:n,numeric:i,smaller:a,isNaN:o}=e;return t("min",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return ri(e,t.valueOf(),r)},"...":function(e){if(ei(e))throw new TypeError("Scalar values expected in function min");return s(e)}});function r(e,t){try{return a(e,t)?e:t}catch(e){throw eu(e,"min",t)}}function s(e){let r;if(ti(e,function(t){try{(o(t)||void 0===r||a(t,r))&&(r=t)}catch(e){throw eu(e,"min",t)}}),void 0===r)throw new Error("Cannot calculate min of an empty array");return r="string"==typeof r?i(r,Ie(r,n)):r}}),El=s("ImmutableDenseMatrix",["smaller","DenseMatrix"],e=>{let{smaller:r,DenseMatrix:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!j(t))throw new Error("Invalid datatype: "+t);if(_(e)||b(e)){const i=new n(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&b(e.data)&&b(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+K(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return i.prototype=new n,i.prototype.type="ImmutableDenseMatrix",i.prototype.isImmutableDenseMatrix=!0,i.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return _(t)?new i({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},i.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},i.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},i.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},i.prototype.clone=function(){return new i({data:ee(this._data),size:ee(this._size),datatype:this._datatype})},i.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},i.fromJSON=function(e){return new i(e)},i.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},i.prototype.min=function(){if(null===this._min){let t=null;this.forEach(function(e){null!==t&&!r(e,t)||(t=e)}),this._min=null!==t?t:void 0}return this._min},i.prototype.max=function(){if(null===this._max){let t=null;this.forEach(function(e){null!==t&&!r(t,e)||(t=e)}),this._max=null!==t?t:void 0}return this._max},i},{isClass:!0}),Sl=s("Index",["ImmutableDenseMatrix","getMatrixDataType"],e=>{let{ImmutableDenseMatrix:t,getMatrixDataType:o}=e;function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(let e=0,t=arguments.length;e<t;e++){const n=arguments[e],s=b(n),i=_(n),a=typeof n;let t=null;if(V(n))this._dimensions.push(n),this._isScalar=!1;else if(s||i){let e;"boolean"===o(n)?(s&&(e=u(Ml(n).valueOf())),i&&(e=u(Ml(n._data).valueOf())),t=n.valueOf().length):e=u(n.valueOf()),this._dimensions.push(e);var r=e.size();1===r.length&&1===r[0]&&null===t||(this._isScalar=!1)}else if("number"==a)this._dimensions.push(u([n]));else if("bigint"==a)this._dimensions.push(u([Number(n)]));else{if("string"!=a)throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._dimensions.push(n)}this._sourceSize.push(t)}}function u(r){for(let e=0,t=r.length;e<t;e++)if("number"!=typeof r[e]||!v(r[e]))throw new TypeError("Index parameters must be positive integer numbers");return new t(r)}return s.prototype.type="Index",s.prototype.isIndex=!0,s.prototype.clone=function(){const e=new s;return e._dimensions=ee(this._dimensions),e._isScalar=this._isScalar,e._sourceSize=this._sourceSize,e},s.create=function(e){var t=new s;return s.apply(t,e),t},s.prototype.size=function(){const r=[];for(let e=0,t=this._dimensions.length;e<t;e++){const n=this._dimensions[e];r[e]="string"==typeof n?1:n.size()[0]}return r},s.prototype.max=function(){const r=[];for(let e=0,t=this._dimensions.length;e<t;e++){const n=this._dimensions[e];r[e]="string"==typeof n?n:n.max()}return r},s.prototype.min=function(){const r=[];for(let e=0,t=this._dimensions.length;e<t;e++){const n=this._dimensions[e];r[e]="string"==typeof n?n:n.min()}return r},s.prototype.forEach=function(r){for(let e=0,t=this._dimensions.length;e<t;e++)r(this._dimensions[e],e,this)},s.prototype.dimension=function(e){return"number"==typeof e&&this._dimensions[e]||null},s.prototype.isObjectProperty=function(){return 1===this._dimensions.length&&"string"==typeof this._dimensions[0]},s.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},s.prototype.isScalar=function(){return this._isScalar},s.prototype.toArray=function(){const r=[];for(let e=0,t=this._dimensions.length;e<t;e++){const n=this._dimensions[e];r.push("string"==typeof n?n:n.toArray())}return r},s.prototype.valueOf=s.prototype.toArray,s.prototype.toString=function(){const r=[];for(let e=0,t=this._dimensions.length;e<t;e++){const n=this._dimensions[e];"string"==typeof n?r.push(JSON.stringify(n)):r.push(n.toString())}return"["+r.join(", ")+"]"},s.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},s.fromJSON=function(e){return s.create(e.dimensions)},s},{isClass:!0});function Ml(e){const r=[];return e.forEach((e,t)=>{e&&r.push(t)}),r}const Cl=s("FibonacciHeap",["smaller","larger"],e=>{let{smaller:s,larger:u}=e;const l=1/Math.log((1+Math.sqrt(5))/2);function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,((e.right=t).right.left=t).parent=null,t.mark=!1}t.prototype.type="FibonacciHeap",t.prototype.isFibonacciHeap=!0,t.prototype.insert=function(e,t){const r={key:e,value:t,degree:0};if(this._minimum){const t=this._minimum;r.left=t,r.right=t.right,(t.right=r).right.left=r,s(e,t.key)&&(this._minimum=r)}else(r.left=r).right=r,this._minimum=r;return this._size++,r},t.prototype.size=function(){return this._size},t.prototype.clear=function(){this._minimum=null,this._size=0},t.prototype.isEmpty=function(){return 0===this._size},t.prototype.extractMinimum=function(){const e=this._minimum;if(null===e)return e;let t=this._minimum,r=e.degree,n=e.child;for(;0<r;){const e=n.right;n.left.right=n.right,n.right.left=n.left,n.left=t,n.right=t.right,((t.right=n).right.left=n).parent=null,n=e,r--}return e.left.right=e.right,e.right.left=e.left,t=e===e.right?null:function(t,e){const r=Math.floor(Math.log(e)*l)+1,n=new Array(r);let i,a=0,o=t;if(o)for(a++,o=o.right;o!==t;)a++,o=o.right;for(;0<a;){let e=o.degree;const s=o.right;for(;i=n[e];){if(u(o.key,i.key)){const t=i;i=o,o=t}c(i,o),n[e]=null,e++}n[e]=o,o=s,a--}t=null;for(let e=0;e<r;e++)(i=n[e])&&(t?(i.left.right=i.right,i.right.left=i.left,i.left=t,i.right=t.right,(t.right=i).right.left=i,s(i.key,t.key)&&(t=i)):t=i);return t}(t=e.right,this._size),this._size--,this._minimum=t,e},t.prototype.remove=function(e){var t,r;this._minimum=(t=this._minimum,(e=e).key=-1,(r=e.parent)&&s(e.key,r.key)&&(i(t,e,r),function e(t,r){var n=r.parent;n&&(r.mark?(i(t,r,n),e(n)):r.mark=!0)}(t,r)),t=s(e.key,t.key)?e:t),this.extractMinimum()};const c=function(e,t){e.left.right=e.right,e.right.left=e.left,(e.parent=t).child?(e.left=t.child,e.right=t.child.right,(t.child.right=e).right.left=e):((t.child=e).right=e).left=e,t.degree++,e.mark=!1};return t},{isClass:!0}),Tl=s("Spa",["addScalar","equalScalar","FibonacciHeap"],e=>{let{addScalar:n,equalScalar:s,FibonacciHeap:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new t}return r.prototype.type="Spa",r.prototype.isSpa=!0,r.prototype.set=function(e,t){this._values[e]?this._values[e].value=t:(t=this._heap.insert(e,t),this._values[e]=t)},r.prototype.get=function(e){e=this._values[e];return e?e.value:0},r.prototype.accumulate=function(e,t){let r=this._values[e];r?r.value=n(r.value,t):(r=this._heap.insert(e,t),this._values[e]=r)},r.prototype.forEach=function(e,t,r){const n=this._heap,i=this._values,a=[];let o=n.extractMinimum();for(o&&a.push(o);o&&o.key<=t;)o.key>=e&&(s(o.value,0)||r(o.key,o.value,this)),(o=n.extractMinimum())&&a.push(o);for(let e=0;e<a.length;e++){const t=a[e];o=n.insert(t.key,t.value),i[o.key]=o}},r.prototype.swap=function(e,t){let r=this._values[e],n=this._values[t];if(!r&&n)r=this._heap.insert(e,n.value),this._heap.remove(n),this._values[e]=r,this._values[t]=void 0;else if(r&&!n)n=this._heap.insert(t,r.value),this._heap.remove(r),this._values[t]=n,this._values[e]=void 0;else if(r&&n){const e=r.value;r.value=n.value,n.value=e}},r},{isClass:!0});function Bl(n){let i=0,a=1,o=Object.create(null),s=Object.create(null),u=0;function l(e){var t=s[e];if(t&&(delete o[t],delete s[e],--i,a===t)){if(!i)return u=0,void(a=1);for(;!Object.prototype.hasOwnProperty.call(o,++a););}}return n=Math.abs(n),{hit:function(e){var t=s[e],r=++u;if(o[r]=e,s[e]=r,!t)return++i<=n?void 0:(e=o[a],l(e),e);if(delete o[t],a===t)for(;!Object.prototype.hasOwnProperty.call(o,++a););},delete:l,clear:function(){i=u=0,a=1,o=Object.create(null),s=Object.create(null)}}}function Fl(i,e){let{hasher:a,limit:o}=1<arguments.length&&void 0!==e?e:{};return o=null==o?Number.POSITIVE_INFINITY:o,a=null==a?JSON.stringify:a,function e(){"object"!=typeof e.cache&&(e.cache={values:new Map,lru:Bl(o||Number.POSITIVE_INFINITY)});const t=[];for(let e=0;e<arguments.length;e++)t[e]=arguments[e];var r=a(t);if(e.cache.values.has(r))return e.cache.lru.hit(r),e.cache.values.get(r);var n=i.apply(i,t);return e.cache.values.set(r,n),e.cache.values.delete(e.cache.lru.hit(r)),n}}const Dl=Fl(function(e){return new e(1).exp()},{hasher:ql}),Ol=Fl(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:ql}),_l=Fl(function(e){return e.acos(-1)},{hasher:ql}),zl=Fl(function(e){return _l(e).times(2)},{hasher:ql});function ql(e){return e[0].precision}const Il=s("Unit",["?on","config","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","toBest","number","Complex","BigNumber","Fraction"],e=>{let{on:t,config:c,addScalar:l,subtractScalar:f,multiplyScalar:p,divideScalar:o,pow:s,abs:u,fix:m,round:I,equal:h,isNumeric:k,format:R,number:r,Complex:P,BigNumber:d,Fraction:g}=e;const U=r;function y(e,t){if(!(this instanceof y))throw new Error("Constructor must be called with the new operator");if(null!=e&&!k(e)&&!te(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,void 0===t)this.units=[],this.dimensions=B.map(e=>0);else if("string"==typeof t){const e=y.parse(t);this.units=e.units,this.dimensions=e.dimensions}else{if(!L(t)||null!==t.value)throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.fixPrefix=t.fixPrefix,this.skipAutomaticSimplification=t.skipAutomaticSimplification,this.dimensions=t.dimensions.slice(0),this.units=t.units.map(e=>gn({},e))}this.value=this._normalize(e)}let x,b,v;function w(){for(;" "===v||"\t"===v;)A()}function N(e){return"0"<=e&&e<="9"}function A(){b++,v=x.charAt(b)}function n(e){b=e,v=x.charAt(b)}function E(){let t="";var e=b;if("+"===v?A():"-"===v&&(t+=v,A()),!("0"<=(r=v)&&r<="9"||"."===r))return n(e),null;if("."===v){if(t+=v,A(),!N(v))return n(e),null}else{for(;N(v);)t+=v,A();"."===v&&(t+=v,A())}for(;N(v);)t+=v,A();if("E"===v||"e"===v){let e="";var r=b;if(e+=v,A(),"+"!==v&&"-"!==v||(e+=v,A()),!N(v))return n(r),t;for(t+=e;N(v);)t+=v,A()}return t}function S(e){return v===e&&(A(),e)}Object.defineProperty(y,"name",{value:"Unit"}),(y.prototype.constructor=y).prototype.type="Unit",y.prototype.isUnit=!0,y.parse=function(e,r){if(r=r||{},x=e,b=-1,v="","string"!=typeof x)throw new TypeError("Invalid argument in Unit.parse, string expected");const n=new y;let i=1,a=!(n.units=[]);A(),w();var o,t=E();let s=null;if(t){if("BigNumber"===c.number)s=new d(t);else if("Fraction"===c.number)try{s=new g(t)}catch(e){s=parseFloat(t)}else s=parseFloat(t);w(),S("*")?(i=1,a=!0):S("/")&&(i=-1,a=!0)}const u=[];let l=1;for(;;){for(w();"("===v;)u.push(i),l*=i,i=1,A(),w();if(!v)break;{const e=v;if(null===(o=function(){let e="";for(;N(v)||y.isValidAlpha(v);)e+=v,A();var t=e.charAt(0);return y.isValidAlpha(t)?e:null}()))throw new SyntaxError('Unexpected "'+e+'" in "'+x+'" at index '+b.toString())}const c=M(o);if(null===c)throw new SyntaxError('Unit "'+o+'" not found.');let t=i*l;if(w(),S("^")){w();const r=E();if(null===r)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');t*=r}n.units.push({unit:c.unit,prefix:c.prefix,power:t});for(let e=0;e<B.length;e++)n.dimensions[e]+=(c.unit.dimensions[e]||0)*t;for(w();")"===v;){if(0===u.length)throw new SyntaxError('Unmatched ")" in "'+x+'" at index '+b.toString());l/=u.pop(),A(),w()}if(a=!1,S("*")?(i=1,a=!0):S("/")?(i=-1,a=!0):i=1,c.unit.base){const e=c.unit.base.key;z.auto[e]={unit:c.unit,prefix:c.prefix}}}if(w(),v)throw new SyntaxError('Could not parse: "'+e+'"');if(a)throw new SyntaxError('Trailing characters: "'+e+'"');if(0!==u.length)throw new SyntaxError('Unmatched "(" in "'+x+'"');if(0!==n.units.length||r.allowNoUnits)return n.value=void 0!==s?n._normalize(s):null,n;throw new SyntaxError('"'+e+'" contains no units')},y.prototype.clone=function(){const t=new y;t.fixPrefix=this.fixPrefix,t.skipAutomaticSimplification=this.skipAutomaticSimplification,t.value=ee(this.value),t.dimensions=this.dimensions.slice(0),t.units=[];for(let e=0;e<this.units.length;e++){t.units[e]={};for(const r in this.units[e])ue(this.units[e],r)&&(t.units[e][r]=this.units[e][r])}return t},y.prototype.valueType=function(){return K(this.value)},y.prototype._isDerived=function(){return 0!==this.units.length&&(1<this.units.length||1e-15<Math.abs(this.units[0].power-1))},y.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;let t=e;const r=y._getNumberConverter(K(e));for(let e=0;e<this.units.length;e++){var n=r(this.units[e].unit.value),i=r(this.units[e].prefix.value),a=r(this.units[e].power);t=p(t,s(p(n,i),a))}return t},y.prototype._denormalize=function(e,t){if(null==e||0===this.units.length)return e;let r=e;const n=y._getNumberConverter(K(e));for(let e=0;e<this.units.length;e++){const t=n(this.units[e].unit.value),i=n(this.units[e].prefix.value),a=n(this.units[e].power);r=o(r,s(p(t,i),a))}return r};const M=Fl(e=>{var t;if(ue(D,e))return{unit:t=D[e],prefix:t.prefixes[""]};for(const o in D)if(ue(D,o)&&(r=e,a=o,n=void 0,i=void 0,n=r.length-a.length,i=r.length,r.substring(n,i)===a)){var r=D[o],n=e.length-o.length,i=e.substring(0,n),a=ue(r.prefixes,i)?r.prefixes[i]:void 0;if(void 0!==a)return{unit:r,prefix:a}}return null},{hasher:e=>e[0],limit:100});function a(e){return e.equalBase(F.NONE)&&null!==e.value&&!c.predictable?e.value:e}function C(e){return y._getNumberConverter(K(e))(1)}function i(e,t){t=1<arguments.length&&void 0!==t?t:{};const r=e.skipAutomaticSimplification||null===e.value?e.clone():e.simplify();{var n=r;let e=!1;void 0!==n.value&&null!==n.value&&te(n.value)&&(e=Math.abs(n.value.re)<1e-14);for(const a in n.units)ue(n.units,a)&&n.units[a].unit&&("VA"===n.units[a].unit.name&&e?n.units[a].unit=D.VAR:"VAR"!==n.units[a].unit.name||e||(n.units[a].unit=D.VA))}e=r,i=t.offset,1!==e.units.length||e.fixPrefix||Math.abs(e.units[0].power-Math.round(e.units[0].power))<1e-14&&(e.units[0].prefix=e._bestPrefix(i));var e=r._denormalize(r.value),i=null!==r.value?R(e,t||{}):"",e=r.formatUnits();return{simp:r,valueStr:i,unitStr:e}}y.isValuelessUnit=function(e){return null!==M(e)},y.prototype.hasBase=function(t){if(!(t="string"==typeof t?F[t]:t))return!1;for(let e=0;e<B.length;e++)if(1e-12<Math.abs((this.dimensions[e]||0)-(t.dimensions[e]||0)))return!1;return!0},y.prototype.equalBase=function(t){for(let e=0;e<B.length;e++)if(1e-12<Math.abs((this.dimensions[e]||0)-(t.dimensions[e]||0)))return!1;return!0},y.prototype.equals=function(e){return this.equalBase(e)&&h(this.value,e.value)},y.prototype.multiply=function(e){const t=this.clone(),r=L(e)?e:new y(e);for(let e=0;e<B.length;e++)t.dimensions[e]=(this.dimensions[e]||0)+(r.dimensions[e]||0);for(let e=0;e<r.units.length;e++){var n={...r.units[e]};t.units.push(n)}if(null!==this.value||null!==r.value){const e=null===this.value?this._normalize(C(r.value)):this.value,i=null===r.value?r._normalize(C(this.value)):r.value;t.value=p(e,i)}else t.value=null;return L(e)&&(t.skipAutomaticSimplification=!1),a(t)},y.prototype.divideInto=function(e){return new y(e).divide(this)},y.prototype.divide=function(e){const t=this.clone(),r=L(e)?e:new y(e);for(let e=0;e<B.length;e++)t.dimensions[e]=(this.dimensions[e]||0)-(r.dimensions[e]||0);for(let e=0;e<r.units.length;e++){var n={...r.units[e],power:-r.units[e].power};t.units.push(n)}if(null!==this.value||null!==r.value){const e=null===this.value?this._normalize(C(r.value)):this.value,i=null===r.value?r._normalize(C(this.value)):r.value;t.value=o(e,i)}else t.value=null;return L(e)&&(t.skipAutomaticSimplification=!1),a(t)},y.prototype.pow=function(t){const r=this.clone();for(let e=0;e<B.length;e++)r.dimensions[e]=(this.dimensions[e]||0)*t;for(let e=0;e<r.units.length;e++)r.units[e].power*=t;return null!==r.value?r.value=s(r.value,t):r.value=null,r.skipAutomaticSimplification=!1,a(r)},y.prototype.abs=function(){const e=this.clone();if(null!==e.value)if(e._isDerived()||0===e.units.length||0===e.units[0].unit.offset)e.value=u(e.value);else{const t=e._numberConverter(),r=t(e.units[0].unit.value),n=t(e.units[0].unit.offset),i=p(r,n);e.value=f(u(l(e.value,i)),i)}for(const a in e.units)"VA"!==e.units[a].unit.name&&"VAR"!==e.units[a].unit.name||(e.units[a].unit=D.W);return e},y.prototype.to=function(e){var t=null===this.value?this._normalize(1):this.value;let r;if("string"==typeof e)r=y.parse(e);else{if(!L(e))throw new Error("String or Unit expected as parameter");r=e.clone()}if(!this.equalBase(r))throw new Error(`Units do not match ('${r.toString()}' != '${this.toString()}')`);if(null!==r.value)throw new Error("Cannot convert to a unit with a value");if(null===this.value||this._isDerived()||0===this.units.length||0===r.units.length||this.units[0].unit.offset===r.units[0].unit.offset)r.value=ee(t);else{const e=y._getNumberConverter(K(t)),n=this.units[0].unit.value,i=this.units[0].unit.offset,a=p(n,i),o=r.units[0].unit.value,s=r.units[0].unit.offset,u=p(o,s);r.value=l(t,e(f(a,u)))}return r.fixPrefix=!0,r.skipAutomaticSimplification=!0,r},y.prototype.toNumber=function(e){return U(this.toNumeric(e))},y.prototype.toNumeric=function(e){let t;return(t=e?this.to(e):this.clone())._isDerived()||0===t.units.length?t._denormalize(t.value):t._denormalize(t.value,t.units[0].prefix.value)},y.prototype.toString=function(){return this.format()},y.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:0<this.units.length?this.formatUnits():null,fixPrefix:this.fixPrefix}},y.fromJSON=function(e){var t;const r=new y(e.value,null!=(t=e.unit)?t:void 0);return r.fixPrefix=e.fixPrefix||!1,r},y.prototype.valueOf=y.prototype.toString,y.prototype.simplify=function(){const r=this.clone(),n=[];let t;for(const n in q)if(ue(q,n)&&r.hasBase(F[n])){t=n;break}if("NONE"===t)r.units=[];else{let e;if(e=t&&ue(q,t)?q[t]:e)r.units=[{unit:e.unit,prefix:e.prefix,power:1}];else{let t=!1;for(let e=0;e<B.length;e++){var i=B[e];1e-12<Math.abs(r.dimensions[e]||0)&&(ue(q,i)?n.push({unit:q[i].unit,prefix:q[i].prefix,power:r.dimensions[e]||0}):t=!0)}n.length<r.units.length&&!t&&(r.units=n)}}return r},y.prototype.toSI=function(){const t=this.clone(),r=[];for(let e=0;e<B.length;e++){var n=B[e];if(1e-12<Math.abs(t.dimensions[e]||0)){if(!ue(z.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");r.push({unit:z.si[n].unit,prefix:z.si[n].prefix,power:t.dimensions[e]||0})}}return t.units=r,t.fixPrefix=!0,t.skipAutomaticSimplification=!0,null!==this.value?(t.value=null,this.to(t)):t},y.prototype.formatUnits=function(){let t="",r="",n=0,i=0;for(let e=0;e<this.units.length;e++)0<this.units[e].power?(n++,t+=" "+this.units[e].prefix.name+this.units[e].unit.name,1e-15<Math.abs(this.units[e].power-1)&&(t+="^"+this.units[e].power)):this.units[e].power<0&&i++;if(0<i)for(let e=0;e<this.units.length;e++)this.units[e].power<0&&(0<n?(r+=" "+this.units[e].prefix.name+this.units[e].unit.name,1e-15<Math.abs(this.units[e].power+1)&&(r+="^"+-this.units[e].power)):r=(r+=" "+this.units[e].prefix.name+this.units[e].unit.name)+("^"+this.units[e].power));t=t.substr(1),r=r.substr(1),1<n&&0<i&&(t="("+t+")"),1<i&&0<n&&(r="("+r+")");let e=t;return 0<n&&0<i&&(e+=" / "),e+=r},y.prototype.toBest=function(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(e&&!Array.isArray(e))throw new Error("Invalid unit type. Expected string or Unit.");var r=this.units[0].unit.prefixes;if(e&&0<e.length){const t=e.map(e=>{let t=null;if("string"==typeof e){if(!(t=y.parse(e)))throw new Error("Invalid unit type. Expected compatible string or Unit.")}else if(!L(e))throw new Error("Invalid unit type. Expected compatible string or Unit.");null===t&&(t=e.clone());try{return this.to(t.formatUnits()),t}catch(e){throw new Error("Invalid unit type. Expected compatible string or Unit.")}}).map(e=>e.units[0].prefix);this.units[0].unit.prefixes=t.reduce((e,t)=>(e[t.name]=t,e),{}),this.units[0].prefix=t[0]}const n=i(this,t).simp;return this.units[0].unit.prefixes=r,n.fixPrefix=!0,n},y.prototype.format=function(e){var{simp:e,valueStr:t,unitStr:r}=i(this,e);let n=t;return e.value&&te(e.value)&&(n="("+n+")"),0<r.length&&0<n.length&&(n+=" "),n+=r},y.prototype._bestPrefix=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1.2;if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(1e-14<=Math.abs(this.units[0].power-Math.round(this.units[0].power)))throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var t=null!==this.value?u(this.value):0,r=u(this.units[0].unit.value);let n=this.units[0].prefix;if(0===t)return n;var i=this.units[0].power;let a=Math.log(t/Math.pow(n.value*r,i))/Math.LN10-e;if(-2.200001<a&&a<1.800001)return n;a=Math.abs(a);const o=this.units[0].unit.prefixes;for(const s in o)if(ue(o,s)){const u=o[s];if(u.scientific){const o=Math.abs(Math.log(t/Math.pow(u.value*r,i))/Math.LN10-e);(o<a||o===a&&u.name.length<n.name.length)&&(n=u,a=o)}}return n};const T={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!(y.prototype.splitUnit=function(t){let r=this.clone();const n=[];for(let e=0;e<t.length&&(r=r.to(t[e]),e!==t.length-1);e++){const a=r.toNumeric(),o=I(a);var i=new y(h(o,a)?o:m(r.toNumeric()),t[e].toString());n.push(i),r=f(r,i)}let a=0;for(let e=0;e<n.length;e++)a=l(a,n[e].value);return h(a,this.value)&&(r.value=0),n.push(r),n})},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},R:{name:"R",value:1e27,scientific:!0},Q:{name:"Q",value:1e30,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0},r:{name:"r",value:1e-27,scientific:!0},q:{name:"q",value:1e-30,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},ronna:{name:"ronna",value:1e27,scientific:!0},quetta:{name:"quetta",value:1e30,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0},ronto:{name:"ronto",value:1e-27,scientific:!0},quecto:{name:"quecto",value:1e-30,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},R:{name:"R",value:1e54,scientific:!0},Q:{name:"Q",value:1e60,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0},r:{name:"r",value:1e-54,scientific:!0},q:{name:"q",value:1e-60,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},R:{name:"R",value:1e81,scientific:!0},Q:{name:"Q",value:1e90,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0},r:{name:"r",value:1e-81,scientific:!0},q:{name:"q",value:1e-90,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}},B=(T.SHORTLONG=gn({},T.SHORT,T.LONG),T.BINARY_SHORT=gn({},T.BINARY_SHORT_SI,T.BINARY_SHORT_IEC),T.BINARY_LONG=gn({},T.BINARY_LONG_SI,T.BINARY_LONG_IEC),["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"]),F={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(const e in F)ue(F,e)&&(F[e].key=e);const j={name:"",base:{},value:1,offset:0,dimensions:B.map(e=>0)},D={meter:{name:"meter",base:F.LENGTH,prefixes:T.LONG,value:1,offset:0},inch:{name:"inch",base:F.LENGTH,prefixes:T.NONE,value:.0254,offset:0},foot:{name:"foot",base:F.LENGTH,prefixes:T.NONE,value:.3048,offset:0},yard:{name:"yard",base:F.LENGTH,prefixes:T.NONE,value:.9144,offset:0},mile:{name:"mile",base:F.LENGTH,prefixes:T.NONE,value:1609.344,offset:0},link:{name:"link",base:F.LENGTH,prefixes:T.NONE,value:.201168,offset:0},rod:{name:"rod",base:F.LENGTH,prefixes:T.NONE,value:5.0292,offset:0},chain:{name:"chain",base:F.LENGTH,prefixes:T.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:F.LENGTH,prefixes:T.NONE,value:1e-10,offset:0},m:{name:"m",base:F.LENGTH,prefixes:T.SHORT,value:1,offset:0},in:{name:"in",base:F.LENGTH,prefixes:T.NONE,value:.0254,offset:0},ft:{name:"ft",base:F.LENGTH,prefixes:T.NONE,value:.3048,offset:0},yd:{name:"yd",base:F.LENGTH,prefixes:T.NONE,value:.9144,offset:0},mi:{name:"mi",base:F.LENGTH,prefixes:T.NONE,value:1609.344,offset:0},li:{name:"li",base:F.LENGTH,prefixes:T.NONE,value:.201168,offset:0},rd:{name:"rd",base:F.LENGTH,prefixes:T.NONE,value:5.02921,offset:0},ch:{name:"ch",base:F.LENGTH,prefixes:T.NONE,value:20.1168,offset:0},mil:{name:"mil",base:F.LENGTH,prefixes:T.NONE,value:254e-7,offset:0},m2:{name:"m2",base:F.SURFACE,prefixes:T.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:F.SURFACE,prefixes:T.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:F.SURFACE,prefixes:T.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:F.SURFACE,prefixes:T.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:F.SURFACE,prefixes:T.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:F.SURFACE,prefixes:T.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:F.SURFACE,prefixes:T.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:F.SURFACE,prefixes:T.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:F.SURFACE,prefixes:T.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:F.SURFACE,prefixes:T.NONE,value:1e4,offset:0},m3:{name:"m3",base:F.VOLUME,prefixes:T.CUBIC,value:1,offset:0},L:{name:"L",base:F.VOLUME,prefixes:T.SHORT,value:.001,offset:0},l:{name:"l",base:F.VOLUME,prefixes:T.SHORT,value:.001,offset:0},litre:{name:"litre",base:F.VOLUME,prefixes:T.LONG,value:.001,offset:0},cuin:{name:"cuin",base:F.VOLUME,prefixes:T.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:F.VOLUME,prefixes:T.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:F.VOLUME,prefixes:T.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:F.VOLUME,prefixes:T.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:F.VOLUME,prefixes:T.NONE,value:15e-6,offset:0},drop:{name:"drop",base:F.VOLUME,prefixes:T.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:F.VOLUME,prefixes:T.NONE,value:5e-8,offset:0},minim:{name:"minim",base:F.VOLUME,prefixes:T.NONE,value:6.1611519921875e-8,offset:0},fluiddram:{name:"fluiddram",base:F.VOLUME,prefixes:T.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:"fluidounce",base:F.VOLUME,prefixes:T.NONE,value:295735295625e-16,offset:0},gill:{name:"gill",base:F.VOLUME,prefixes:T.NONE,value:.00011829411825,offset:0},cc:{name:"cc",base:F.VOLUME,prefixes:T.NONE,value:1e-6,offset:0},cup:{name:"cup",base:F.VOLUME,prefixes:T.NONE,value:.0002365882365,offset:0},pint:{name:"pint",base:F.VOLUME,prefixes:T.NONE,value:.000473176473,offset:0},quart:{name:"quart",base:F.VOLUME,prefixes:T.NONE,value:.000946352946,offset:0},gallon:{name:"gallon",base:F.VOLUME,prefixes:T.NONE,value:.003785411784,offset:0},beerbarrel:{name:"beerbarrel",base:F.VOLUME,prefixes:T.NONE,value:.117347765304,offset:0},oilbarrel:{name:"oilbarrel",base:F.VOLUME,prefixes:T.NONE,value:.158987294928,offset:0},hogshead:{name:"hogshead",base:F.VOLUME,prefixes:T.NONE,value:.238480942392,offset:0},g:{name:"g",base:F.MASS,prefixes:T.SHORT,value:.001,offset:0},gram:{name:"gram",base:F.MASS,prefixes:T.LONG,value:.001,offset:0},ton:{name:"ton",base:F.MASS,prefixes:T.SHORT,value:907.18474,offset:0},t:{name:"t",base:F.MASS,prefixes:T.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:F.MASS,prefixes:T.LONG,value:1e3,offset:0},grain:{name:"grain",base:F.MASS,prefixes:T.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:F.MASS,prefixes:T.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:F.MASS,prefixes:T.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:F.MASS,prefixes:T.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:F.MASS,prefixes:T.NONE,value:45.359237,offset:0},stick:{name:"stick",base:F.MASS,prefixes:T.NONE,value:.115,offset:0},stone:{name:"stone",base:F.MASS,prefixes:T.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:F.MASS,prefixes:T.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:F.MASS,prefixes:T.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:F.MASS,prefixes:T.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:F.MASS,prefixes:T.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:F.MASS,prefixes:T.NONE,value:45.359237,offset:0},s:{name:"s",base:F.TIME,prefixes:T.SHORT,value:1,offset:0},min:{name:"min",base:F.TIME,prefixes:T.NONE,value:60,offset:0},h:{name:"h",base:F.TIME,prefixes:T.NONE,value:3600,offset:0},second:{name:"second",base:F.TIME,prefixes:T.LONG,value:1,offset:0},sec:{name:"sec",base:F.TIME,prefixes:T.LONG,value:1,offset:0},minute:{name:"minute",base:F.TIME,prefixes:T.NONE,value:60,offset:0},hour:{name:"hour",base:F.TIME,prefixes:T.NONE,value:3600,offset:0},day:{name:"day",base:F.TIME,prefixes:T.NONE,value:86400,offset:0},week:{name:"week",base:F.TIME,prefixes:T.NONE,value:604800,offset:0},month:{name:"month",base:F.TIME,prefixes:T.NONE,value:2629800,offset:0},year:{name:"year",base:F.TIME,prefixes:T.NONE,value:31557600,offset:0},decade:{name:"decade",base:F.TIME,prefixes:T.NONE,value:315576e3,offset:0},century:{name:"century",base:F.TIME,prefixes:T.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:F.TIME,prefixes:T.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:F.FREQUENCY,prefixes:T.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:F.FREQUENCY,prefixes:T.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:F.ANGLE,prefixes:T.SHORT,value:1,offset:0},radian:{name:"radian",base:F.ANGLE,prefixes:T.LONG,value:1,offset:0},deg:{name:"deg",base:F.ANGLE,prefixes:T.SHORT,value:null,offset:0},degree:{name:"degree",base:F.ANGLE,prefixes:T.LONG,value:null,offset:0},grad:{name:"grad",base:F.ANGLE,prefixes:T.SHORT,value:null,offset:0},gradian:{name:"gradian",base:F.ANGLE,prefixes:T.LONG,value:null,offset:0},cycle:{name:"cycle",base:F.ANGLE,prefixes:T.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:F.ANGLE,prefixes:T.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:F.ANGLE,prefixes:T.NONE,value:null,offset:0},A:{name:"A",base:F.CURRENT,prefixes:T.SHORT,value:1,offset:0},ampere:{name:"ampere",base:F.CURRENT,prefixes:T.LONG,value:1,offset:0},K:{name:"K",base:F.TEMPERATURE,prefixes:T.SHORT,value:1,offset:0},degC:{name:"degC",base:F.TEMPERATURE,prefixes:T.SHORT,value:1,offset:273.15},degF:{name:"degF",base:F.TEMPERATURE,prefixes:T.SHORT,value:new g(5,9),offset:459.67},degR:{name:"degR",base:F.TEMPERATURE,prefixes:T.SHORT,value:new g(5,9),offset:0},kelvin:{name:"kelvin",base:F.TEMPERATURE,prefixes:T.LONG,value:1,offset:0},celsius:{name:"celsius",base:F.TEMPERATURE,prefixes:T.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:F.TEMPERATURE,prefixes:T.LONG,value:new g(5,9),offset:459.67},rankine:{name:"rankine",base:F.TEMPERATURE,prefixes:T.LONG,value:new g(5,9),offset:0},mol:{name:"mol",base:F.AMOUNT_OF_SUBSTANCE,prefixes:T.SHORT,value:1,offset:0},mole:{name:"mole",base:F.AMOUNT_OF_SUBSTANCE,prefixes:T.LONG,value:1,offset:0},cd:{name:"cd",base:F.LUMINOUS_INTENSITY,prefixes:T.SHORT,value:1,offset:0},candela:{name:"candela",base:F.LUMINOUS_INTENSITY,prefixes:T.LONG,value:1,offset:0},N:{name:"N",base:F.FORCE,prefixes:T.SHORT,value:1,offset:0},newton:{name:"newton",base:F.FORCE,prefixes:T.LONG,value:1,offset:0},dyn:{name:"dyn",base:F.FORCE,prefixes:T.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:F.FORCE,prefixes:T.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:F.FORCE,prefixes:T.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:F.FORCE,prefixes:T.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:F.FORCE,prefixes:T.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:F.FORCE,prefixes:T.NONE,value:9.80665,offset:0},J:{name:"J",base:F.ENERGY,prefixes:T.SHORT,value:1,offset:0},joule:{name:"joule",base:F.ENERGY,prefixes:T.LONG,value:1,offset:0},erg:{name:"erg",base:F.ENERGY,prefixes:T.SHORTLONG,value:1e-7,offset:0},Wh:{name:"Wh",base:F.ENERGY,prefixes:T.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:F.ENERGY,prefixes:T.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:F.ENERGY,prefixes:T.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:F.ENERGY,prefixes:T.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:F.POWER,prefixes:T.SHORT,value:1,offset:0},watt:{name:"watt",base:F.POWER,prefixes:T.LONG,value:1,offset:0},hp:{name:"hp",base:F.POWER,prefixes:T.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:F.POWER,prefixes:T.SHORT,value:P.I,offset:0},VA:{name:"VA",base:F.POWER,prefixes:T.SHORT,value:1,offset:0},Pa:{name:"Pa",base:F.PRESSURE,prefixes:T.SHORT,value:1,offset:0},psi:{name:"psi",base:F.PRESSURE,prefixes:T.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:F.PRESSURE,prefixes:T.NONE,value:101325,offset:0},bar:{name:"bar",base:F.PRESSURE,prefixes:T.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:F.PRESSURE,prefixes:T.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:F.PRESSURE,prefixes:T.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:F.PRESSURE,prefixes:T.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:F.PRESSURE,prefixes:T.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:F.ELECTRIC_CHARGE,prefixes:T.LONG,value:1,offset:0},C:{name:"C",base:F.ELECTRIC_CHARGE,prefixes:T.SHORT,value:1,offset:0},farad:{name:"farad",base:F.ELECTRIC_CAPACITANCE,prefixes:T.LONG,value:1,offset:0},F:{name:"F",base:F.ELECTRIC_CAPACITANCE,prefixes:T.SHORT,value:1,offset:0},volt:{name:"volt",base:F.ELECTRIC_POTENTIAL,prefixes:T.LONG,value:1,offset:0},V:{name:"V",base:F.ELECTRIC_POTENTIAL,prefixes:T.SHORT,value:1,offset:0},ohm:{name:"ohm",base:F.ELECTRIC_RESISTANCE,prefixes:T.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:F.ELECTRIC_INDUCTANCE,prefixes:T.LONG,value:1,offset:0},H:{name:"H",base:F.ELECTRIC_INDUCTANCE,prefixes:T.SHORT,value:1,offset:0},siemens:{name:"siemens",base:F.ELECTRIC_CONDUCTANCE,prefixes:T.LONG,value:1,offset:0},S:{name:"S",base:F.ELECTRIC_CONDUCTANCE,prefixes:T.SHORT,value:1,offset:0},weber:{name:"weber",base:F.MAGNETIC_FLUX,prefixes:T.LONG,value:1,offset:0},Wb:{name:"Wb",base:F.MAGNETIC_FLUX,prefixes:T.SHORT,value:1,offset:0},tesla:{name:"tesla",base:F.MAGNETIC_FLUX_DENSITY,prefixes:T.LONG,value:1,offset:0},T:{name:"T",base:F.MAGNETIC_FLUX_DENSITY,prefixes:T.SHORT,value:1,offset:0},b:{name:"b",base:F.BIT,prefixes:T.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:F.BIT,prefixes:T.BINARY_LONG,value:1,offset:0},B:{name:"B",base:F.BIT,prefixes:T.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:F.BIT,prefixes:T.BINARY_LONG,value:8,offset:0}},O={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fldr:"fluiddram",fluiddrams:"fluiddram",floz:"fluidounce",fluidounces:"fluidounce",gi:"gill",gills:"gill",cp:"cup",cups:"cup",pt:"pint",pints:"pint",qt:"quart",quarts:"quart",gal:"gallon",gallons:"gallon",bbl:"beerbarrel",beerbarrels:"beerbarrel",obl:"oilbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",amps:"ampere",amp:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function _(e){if("BigNumber"===e.number){const e=_l(d);D.rad.value=new d(1),D.deg.value=e.div(180),D.grad.value=e.div(200),D.cycle.value=e.times(2),D.arcsec.value=e.div(648e3),D.arcmin.value=e.div(10800)}else D.rad.value=1,D.deg.value=Math.PI/180,D.grad.value=Math.PI/200,D.cycle.value=2*Math.PI,D.arcsec.value=Math.PI/648e3,D.arcmin.value=Math.PI/10800;D.radian.value=D.rad.value,D.degree.value=D.deg.value,D.gradian.value=D.grad.value}_(c),t&&t("config",function(e,t){e.number!==t.number&&_(e)});const z={si:{NONE:{unit:j,prefix:T.NONE[""]},LENGTH:{unit:D.m,prefix:T.SHORT[""]},MASS:{unit:D.g,prefix:T.SHORT.k},TIME:{unit:D.s,prefix:T.SHORT[""]},CURRENT:{unit:D.A,prefix:T.SHORT[""]},TEMPERATURE:{unit:D.K,prefix:T.SHORT[""]},LUMINOUS_INTENSITY:{unit:D.cd,prefix:T.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:D.mol,prefix:T.SHORT[""]},ANGLE:{unit:D.rad,prefix:T.SHORT[""]},BIT:{unit:D.bits,prefix:T.SHORT[""]},FORCE:{unit:D.N,prefix:T.SHORT[""]},ENERGY:{unit:D.J,prefix:T.SHORT[""]},POWER:{unit:D.W,prefix:T.SHORT[""]},PRESSURE:{unit:D.Pa,prefix:T.SHORT[""]},ELECTRIC_CHARGE:{unit:D.C,prefix:T.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:D.F,prefix:T.SHORT[""]},ELECTRIC_POTENTIAL:{unit:D.V,prefix:T.SHORT[""]},ELECTRIC_RESISTANCE:{unit:D.ohm,prefix:T.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:D.H,prefix:T.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:D.S,prefix:T.SHORT[""]},MAGNETIC_FLUX:{unit:D.Wb,prefix:T.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:D.T,prefix:T.SHORT[""]},FREQUENCY:{unit:D.Hz,prefix:T.SHORT[""]}}};z.cgs=JSON.parse(JSON.stringify(z.si)),z.cgs.LENGTH={unit:D.m,prefix:T.SHORT.c},z.cgs.MASS={unit:D.g,prefix:T.SHORT[""]},z.cgs.FORCE={unit:D.dyn,prefix:T.SHORT[""]},z.cgs.ENERGY={unit:D.erg,prefix:T.NONE[""]},z.us=JSON.parse(JSON.stringify(z.si)),z.us.LENGTH={unit:D.ft,prefix:T.NONE[""]},z.us.MASS={unit:D.lbm,prefix:T.NONE[""]},z.us.TEMPERATURE={unit:D.degF,prefix:T.NONE[""]},z.us.FORCE={unit:D.lbf,prefix:T.NONE[""]},z.us.ENERGY={unit:D.BTU,prefix:T.BTU[""]},z.us.POWER={unit:D.hp,prefix:T.NONE[""]},z.us.PRESSURE={unit:D.psi,prefix:T.NONE[""]},z.auto=JSON.parse(JSON.stringify(z.si));let q=z.auto;y.setUnitSystem=function(e){if(!ue(z,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(z).join(", "));q=z[e]},y.getUnitSystem=function(){for(const e in z)if(ue(z,e)&&z[e]===q)return e},y.typeConverters={BigNumber:function(e){return null!=e&&e.isFraction?new d(String(e.n)).div(String(e.d)).times(String(e.s)):new d(e+"")},Fraction:function(e){return new g(e)},Complex:function(e){return e},number:function(e){return null!=e&&e.isFraction?r(e):e}},y.prototype._numberConverter=function(){var e=y.typeConverters[this.valueType()];if(e)return e;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},y._getNumberConverter=function(e){if(y.typeConverters[e])return y.typeConverters[e];throw new TypeError('Unsupported type "'+e+'"')};for(const e in D)if(ue(D,e)){const t=D[e];t.dimensions=t.base.dimensions}for(const e in O)if(ue(O,e)){const t=D[O[e]],c={};for(const e in t)ue(t,e)&&(c[e]=t[e]);c.name=e,D[e]=c}return y.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},y.createUnit=function(t,r){if("object"!=typeof t)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(r&&r.override)for(const r in t)if(ue(t,r)&&y.deleteUnit(r),t[r].aliases)for(let e=0;e<t[r].aliases.length;e++)y.deleteUnit(t[r].aliases[e]);let e;for(const r in t)ue(t,r)&&(e=y.createUnitSingle(r,t[r]));return e},y.createUnitSingle=function(r,t){if(null==t&&(t={}),"string"!=typeof r)throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(ue(D,r))throw new Error('Cannot create unit "'+r+'": a unit with that name already exists');var n=r;for(let e=0;e<n.length;e++){if(v=n.charAt(e),0===e&&!y.isValidAlpha(v))throw new Error('Invalid unit name (must begin with alpha character): "'+n+'"');if(0<e&&!y.isValidAlpha(v)&&!N(v))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+n+'"')}let i,a,o,s=null,u=[],l=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(i=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+r+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');i=t.definition,a=t.prefixes,l=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(let e=0;e<u.length;e++)if(ue(D,u[e]))throw new Error('Cannot create alias "'+u[e]+'": a unit with that name already exists');if(i&&"string"==typeof i&&!s)try{s=y.parse(i,{allowNoUnits:!0})}catch(t){throw t.message='Could not create unit "'+r+'" from "'+i+'": '+t.message,t}else i&&"Unit"===i.type&&(s=i.clone());u=u||[],l=l||0,a=a&&a.toUpperCase&&T[a.toUpperCase()]||T.NONE;let c={};if(s){let e=!(c={name:r,value:s.value,dimensions:s.dimensions.slice(0),prefixes:a,offset:l});for(const r in F)if(ue(F,r)){let t=!0;for(let e=0;e<B.length;e++)if(1e-12<Math.abs((c.dimensions[e]||0)-(F[r].dimensions[e]||0))){t=!1;break}if(t){e=!0,c.base=F[r];break}}if(!e){o=o||r+"_STUFF";const t={dimensions:s.dimensions.slice(0)};t.key=o,F[o]=t,q[o]={unit:c,prefix:T.NONE[""]},c.base=F[o]}}else{if(o=o||r+"_STUFF",0<=B.indexOf(o))throw new Error('Cannot create new base unit "'+r+'": a base unit with that name already exists (and cannot be overridden)');B.push(o);for(const r in F)ue(F,r)&&(F[r].dimensions[B.length-1]=0);const t={dimensions:[]};for(let e=0;e<B.length;e++)t.dimensions[e]=0;t.dimensions[B.length-1]=1,t.key=o,F[o]=t,c={name:r,value:1,dimensions:F[o].dimensions.slice(0),prefixes:a,offset:l,base:F[o]},q[o]={unit:c,prefix:T.NONE[""]}}y.UNITS[r]=c;for(let e=0;e<u.length;e++){const t=u[e],i={};for(const r in c)ue(c,r)&&(i[r]=c[r]);i.name=t,y.UNITS[t]=i}return delete M.cache,new y(null,r)},y.deleteUnit=function(e){delete y.UNITS[e],delete M.cache},y.PREFIXES=T,y.BASE_DIMENSIONS=B,y.BASE_UNITS=F,y.UNIT_SYSTEMS=z,y.UNITS=D,y},{isClass:!0}),kl=s("unit",["typed","Unit"],e=>{let{typed:t,Unit:r}=e;return t("unit",{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,t){return new r(e,t)},"number | BigNumber | Fraction":function(e){return new r(e)},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),Rl=s("sparse",["typed","SparseMatrix"],e=>{let{typed:t,SparseMatrix:r}=e;return t("sparse",{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})}),Pl="createUnit",Ul=s(Pl,["typed","Unit"],e=>{let{typed:t,Unit:i}=e;return t(Pl,{"Object, Object":function(e,t){return i.createUnit(e,t)},Object:function(e){return i.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){const n={};return n[e]=t,i.createUnit(n,r)},"string, Unit | string | Object":function(e,t){const r={};return r[e]=t,i.createUnit(r,{})},string:function(e){const t={};return t[e]={},i.createUnit(t,{})}})}),jl=s("acos",["typed","config","Complex"],e=>{let{typed:t,config:r,Complex:n}=e;return t("acos",{number:function(e){return-1<=e&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})}),Ll="number";function $l(e){return Qe(e)}function Hl(e){return Math.atan(1/e)}function Gl(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function Vl(e){return Math.asin(1/e)}function Zl(e){e=1/e;return Math.log(e+Math.sqrt(e*e+1))}function Wl(e){return Math.acos(1/e)}function Yl(e){var e=1/e,t=Math.sqrt(e*e-1);return Math.log(t+e)}function Jl(e){return Ke(e)}function Xl(e){return et(e)}function Ql(e){return 1/Math.tan(e)}function Kl(e){e=Math.exp(2*e);return(e+1)/(e-1)}function ec(e){return 1/Math.sin(e)}function tc(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*ke(e)}function rc(e){return 1/Math.cos(e)}function nc(e){return 2/(Math.exp(e)+Math.exp(-e))}function ic(e){return rt(e)}ic.signature=nc.signature=rc.signature=tc.signature=ec.signature=Kl.signature=Ql.signature=Xl.signature=Jl.signature=Yl.signature=Wl.signature=Zl.signature=Vl.signature=Gl.signature=Hl.signature=$l.signature=Ll;const ac=s("acosh",["typed","config","Complex"],e=>{let{typed:t,config:r,Complex:n}=e;return t("acosh",{number:function(e){return 1<=e||r.predictable?$l(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})}),oc=s("acot",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("acot",{number:Hl,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()}})}),sc=s("acoth",["typed","config","Complex","BigNumber"],e=>{let{typed:t,config:r,Complex:n,BigNumber:i}=e;return t("acoth",{number:function(e){return 1<=e||e<=-1||r.predictable?Gl(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})}),uc=s("acsc",["typed","config","Complex","BigNumber"],e=>{let{typed:t,config:r,Complex:n,BigNumber:i}=e;return t("acsc",{number:function(e){return e<=-1||1<=e||r.predictable?Vl(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})}),lc=s("acsch",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("acsch",{number:Zl,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()}})}),cc=s("asec",["typed","config","Complex","BigNumber"],e=>{let{typed:t,config:r,Complex:n,BigNumber:i}=e;return t("asec",{number:function(e){return e<=-1||1<=e||r.predictable?Wl(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})}),fc=s("asech",["typed","config","Complex","BigNumber"],e=>{let{typed:t,config:n,Complex:i,BigNumber:r}=e;return t("asech",{number:function(e){if(e<=1&&-1<=e||n.predictable){var t=1/e;if(0<t||n.predictable)return Yl(e);var r=Math.sqrt(t*t-1);return new i(Math.log(r-t),Math.PI)}return new i(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new r(1).div(e).acosh()}})}),pc=s("asin",["typed","config","Complex"],e=>{let{typed:t,config:r,Complex:n}=e;return t("asin",{number:function(e){return-1<=e&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})}),mc=s("asinh",["typed"],e=>{let t=e["typed"];return t("asinh",{number:Jl,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})}),hc=s("atan",["typed"],e=>{let t=e["typed"];return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})}),dc=s("atan2",["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],e=>{let{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a,concat:o}=e;const s=Ra({typed:t,equalScalar:n}),u=Pa({typed:t}),l=ho({typed:t,equalScalar:n}),c=Aa({typed:t,equalScalar:n}),f=x({typed:t,DenseMatrix:a}),p=C({typed:t,matrix:r,concat:o});return t("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":(e,t)=>i.atan2(e,t)},p({scalar:"number | BigNumber",SS:l,DS:u,SD:s,Ss:c,sS:f}))}),gc=s("atanh",["typed","config","Complex"],e=>{let{typed:t,config:r,Complex:n}=e;return t("atanh",{number:function(e){return e<=1&&-1<=e||r.predictable?Xl(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})}),yc=s("trigUnit",["typed"],e=>{let r=e["typed"];return{Unit:r.referToSelf(t=>e=>{if(e.hasBase(e.constructor.BASE_UNITS.ANGLE))return r.find(t,e.valueType())(e.value);throw new TypeError("Unit in function cot is no angle")})}}),xc=s("cos",["typed"],e=>{let t=e["typed"];e=yc({typed:t});return t("cos",{number:Math.cos,"Complex | BigNumber":e=>e.cos()},e)}),bc=s("cosh",["typed"],e=>{let t=e["typed"];return t("cosh",{number:tt,"Complex | BigNumber":e=>e.cosh()})}),vc=s("cot",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("cot",{number:Ql,Complex:e=>e.cot(),BigNumber:e=>new r(1).div(e.tan())},yc({typed:t}))}),wc=s("coth",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("coth",{number:Kl,Complex:e=>e.coth(),BigNumber:e=>new r(1).div(e.tanh())})}),Nc=s("csc",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("csc",{number:ec,Complex:e=>e.csc(),BigNumber:e=>new r(1).div(e.sin())},yc({typed:t}))}),Ac=s("csch",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("csch",{number:tc,Complex:e=>e.csch(),BigNumber:e=>new r(1).div(e.sinh())})}),Ec=s("sec",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("sec",{number:rc,Complex:e=>e.sec(),BigNumber:e=>new r(1).div(e.cos())},yc({typed:t}))}),Sc=s("sech",["typed","BigNumber"],e=>{let{typed:t,BigNumber:r}=e;return t("sech",{number:nc,Complex:e=>e.sech(),BigNumber:e=>new r(1).div(e.cosh())})}),Mc=s("sin",["typed"],e=>{let t=e["typed"];e=yc({typed:t});return t("sin",{number:Math.sin,"Complex | BigNumber":e=>e.sin()},e)}),Cc=s("sinh",["typed"],e=>{let t=e["typed"];return t("sinh",{number:ic,"Complex | BigNumber":e=>e.sinh()})}),Tc=s("tan",["typed"],e=>{let t=e["typed"];e=yc({typed:t});return t("tan",{number:Math.tan,"Complex | BigNumber":e=>e.tan()},e)}),Bc=s("tanh",["typed"],e=>{let t=e["typed"];return t("tanh",{number:nt,"Complex | BigNumber":e=>e.tanh()})}),Fc="setCartesian",Dc=s(Fc,["typed","size","subset","compareNatural","Index","DenseMatrix"],e=>{let{typed:t,size:n,subset:i,compareNatural:a,Index:o,DenseMatrix:s}=e;return t(Fc,{"Array | Matrix, Array | Matrix":function(e,t){let r=[];if(0!==i(n(e),new o(0))&&0!==i(n(t),new o(0))){const n=E(Array.isArray(e)?e:e.toArray()).sort(a),i=E(Array.isArray(t)?t:t.toArray()).sort(a);r=[];for(let t=0;t<n.length;t++)for(let e=0;e<i.length;e++)r.push([n[t],i[e]])}return Array.isArray(e)&&Array.isArray(t)?r:new s(r)}})}),Oc="setDifference",_c=s(Oc,["typed","size","subset","compareNatural","Index","DenseMatrix"],e=>{let{typed:t,size:i,subset:a,compareNatural:o,Index:r,DenseMatrix:s}=e;return t(Oc,{"Array | Matrix, Array | Matrix":function(e,t){let n;if(0===a(i(e),new r(0)))n=[];else{if(0===a(i(t),new r(0)))return E(e.toArray());{const i=Pn(E(Array.isArray(e)?e:e.toArray()).sort(o)),a=Pn(E(Array.isArray(t)?t:t.toArray()).sort(o));let r;n=[];for(let t=0;t<i.length;t++){r=!1;for(let e=0;e<a.length;e++)if(0===o(i[t].value,a[e].value)&&i[t].identifier===a[e].identifier){r=!0;break}r||n.push(i[t])}}}return Array.isArray(e)&&Array.isArray(t)?Un(n):new s(Un(n))}})}),zc="setDistinct",qc=s(zc,["typed","size","subset","compareNatural","Index","DenseMatrix"],e=>{let{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(zc,{"Array | Matrix":function(e){let t;if(0===n(r(e),new a(0)))t=[];else{const r=E(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(r[0]);for(let e=1;e<r.length;e++)0!==i(r[e],r[e-1])&&t.push(r[e])}return Array.isArray(e)?t:new o(t)}})}),Ic="setIntersect",kc=s(Ic,["typed","size","subset","compareNatural","Index","DenseMatrix"],e=>{let{typed:t,size:n,subset:i,compareNatural:a,Index:o,DenseMatrix:s}=e;return t(Ic,{"Array | Matrix, Array | Matrix":function(e,t){let r;if(0===i(n(e),new o(0))||0===i(n(t),new o(0)))r=[];else{const n=Pn(E(Array.isArray(e)?e:e.toArray()).sort(a)),i=Pn(E(Array.isArray(t)?t:t.toArray()).sort(a));r=[];for(let t=0;t<n.length;t++)for(let e=0;e<i.length;e++)if(0===a(n[t].value,i[e].value)&&n[t].identifier===i[e].identifier){r.push(n[t]);break}}return Array.isArray(e)&&Array.isArray(t)?Un(r):new s(Un(r))}})}),Rc="setIsSubset",Pc=s(Rc,["typed","size","subset","compareNatural","Index"],e=>{let{typed:t,size:a,subset:o,compareNatural:s,Index:u}=e;return t(Rc,{"Array | Matrix, Array | Matrix":function(e,t){if(0===o(a(e),new u(0)))return!0;if(0===o(a(t),new u(0)))return!1;var r=Pn(E(Array.isArray(e)?e:e.toArray()).sort(s)),n=Pn(E(Array.isArray(t)?t:t.toArray()).sort(s));let i;for(let t=0;t<r.length;t++){i=!1;for(let e=0;e<n.length;e++)if(0===s(r[t].value,n[e].value)&&r[t].identifier===n[e].identifier){i=!0;break}if(!1===i)return!1}return!0}})}),Uc="setMultiplicity",jc=s(Uc,["typed","size","subset","compareNatural","Index"],e=>{let{typed:t,size:i,subset:a,compareNatural:o,Index:s}=e;return t(Uc,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(t,e){if(0===a(i(e),new s(0)))return 0;var r=E(Array.isArray(e)?e:e.toArray());let n=0;for(let e=0;e<r.length;e++)0===o(r[e],t)&&n++;return n}})}),Lc="setPowerset",$c=s(Lc,["typed","size","subset","compareNatural","Index"],e=>{let{typed:t,size:o,subset:s,compareNatural:u,Index:l}=e;return t(Lc,{"Array | Matrix":function(e){if(0===s(o(e),new l(0)))return[];const t=E(Array.isArray(e)?e:e.toArray()).sort(u),r=[];let n=0;for(;n.toString(2).length<=t.length;)r.push(function(t,r){const n=[];for(let e=0;e<r.length;e++)"1"===r[e]&&n.push(t[e]);return n}(t,n.toString(2).split("").reverse())),n++;var i,a=r;for(let t=a.length-1;0<t;t--)for(let e=0;e<t;e++)a[e].length>a[e+1].length&&(i=a[e],a[e]=a[e+1],a[e+1]=i);return a}})}),Hc="setSize",Gc=s(Hc,["typed","compareNatural"],e=>{let{typed:t,compareNatural:n}=e;return t(Hc,{"Array | Matrix":function(e){return(Array.isArray(e)?E(e):E(e.toArray())).length},"Array | Matrix, boolean":function(e,r){if(!1===r||0===e.length)return(Array.isArray(e)?E(e):E(e.toArray())).length;{const r=E(Array.isArray(e)?e:e.toArray()).sort(n);let t=1;for(let e=1;e<r.length;e++)0!==n(r[e],r[e-1])&&t++;return t}}})}),Vc="setSymDifference",Zc=s(Vc,["typed","size","concat","subset","setDifference","Index"],e=>{let{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Vc,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return E(t);if(0===i(r(t),new o(0)))return E(e);e=E(e),t=E(t);return n(a(e,t),a(t,e))}})}),Wc="setUnion",Yc=s(Wc,["typed","size","concat","subset","setIntersect","setSymDifference","Index"],e=>{let{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Wc,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return E(t);if(0===i(r(t),new s(0)))return E(e);e=E(e),t=E(t);return n(o(e,t),a(e,t))}})}),Jc=s("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],e=>{let{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,concat:o}=e;const s=Ha({typed:t}),u=Ga({typed:t,equalScalar:i}),l=Va({typed:t,DenseMatrix:a}),c=C({typed:t,matrix:r,concat:o});return t("add",{"any, any":n,"any, any, ...any":t.referToSelf(i=>(e,t,r)=>{let n=i(e,t);for(let e=0;e<r.length;e++)n=i(n,r[e]);return n})},c({elop:n,DS:s,SS:u,Ss:l}))}),Xc=s("hypot",["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],e=>{let{typed:t,abs:a,addScalar:o,divideScalar:s,multiplyScalar:u,sqrt:l,smaller:c,isPositive:f}=e;return t("hypot",{"... number | BigNumber":r,Array:r,Matrix:e=>r(E(e.toArray(),!0))});function r(t){let r=0,n=0;for(let e=0;e<t.length;e++){if(te(t[e]))throw new TypeError("Unexpected type of argument to hypot");var i=a(t[e]);c(n,i)?(r=u(r,u(s(n,i),s(n,i))),r=o(r,1),n=i):r=o(r,f(i)?u(s(i,n),s(i,n)):i)}return u(n,l(r))}}),Qc=s("norm",["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],e=>{let{typed:t,abs:s,add:u,pow:l,conj:c,sqrt:f,multiply:p,equalScalar:m,larger:h,smaller:d,matrix:r,ctranspose:g,eigs:y}=e;return t("norm",{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return x(r(e),2)},Matrix:function(e){return x(e,2)},"Array, number | BigNumber | string":function(e,t){return x(r(e),t)},"Matrix, number | BigNumber | string":x});function x(e,t){var r=e.size();if(1===r.length){var n=e,i=t;if(i===Number.POSITIVE_INFINITY||"inf"===i){let t=0;return n.forEach(function(e){e=s(e);h(e,t)&&(t=e)},!0),t}if(i===Number.NEGATIVE_INFINITY||"-inf"===i){let t;return n.forEach(function(e){e=s(e);t&&!d(e,t)||(t=e)},!0),t||0}if("fro"===i)return x(n,2);if("number"!=typeof i||isNaN(i))throw new Error("Unsupported parameter value");if(m(i,0))return Number.POSITIVE_INFINITY;{let t=0;return n.forEach(function(e){t=u(l(s(e),i),t)},!0),l(t,1/i)}}if(2===r.length){if(r[0]&&r[1]){n=e,r=t;if(1===r){const a=[];let r=0;return n.forEach(function(e,t){t=t[1],e=u(a[t]||0,s(e));h(e,r)&&(r=e),a[t]=e},!0),r}if(r===Number.POSITIVE_INFINITY||"inf"===r){const o=[];let r=0;return n.forEach(function(e,t){t=t[0],e=u(o[t]||0,s(e));h(e,r)&&(r=e),o[t]=e},!0),r}if("fro"===r){let r=0;return n.forEach(function(e,t){r=u(r,p(e,c(e)))}),s(f(r))}if(2!==r)throw new Error("Unsupported parameter value "+r);if((n=(r=n).size())[0]!==n[1])throw new RangeError("Invalid matrix dimensions");return n=g(r),n=p(n,r),r=y(n).values.toArray(),n=r[r.length-1],s(f(n))}throw new RangeError("Invalid matrix dimensions")}}}),Kc=s("dot",["typed","addScalar","multiplyScalar","conj","size"],e=>{let{typed:l,addScalar:f,multiplyScalar:p,conj:c,size:t}=e;return l("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,t){var r=m(e,t),n=_(e)?e._data:e,i=_(e)?e._datatype||e.getDataType():void 0,a=_(t)?t._data:t,o=_(t)?t._datatype||t.getDataType():void 0,e=2===h(e).length,t=2===h(t).length;let s=f,u=p;if(i&&o&&i===o&&"string"==typeof i&&"mixed"!==i){const e=i;s=l.find(f,[e,e]),u=l.find(p,[e,e])}if(!e&&!t){let t=u(c(n[0]),a[0]);for(let e=1;e<r;e++)t=s(t,u(c(n[e]),a[e]));return t}if(!e&&t){let t=u(c(n[0]),a[0][0]);for(let e=1;e<r;e++)t=s(t,u(c(n[e]),a[e][0]));return t}if(e&&!t){let t=u(c(n[0][0]),a[0]);for(let e=1;e<r;e++)t=s(t,u(c(n[e][0]),a[e]));return t}if(e&&t){let t=u(c(n[0][0]),a[0][0]);for(let e=1;e<r;e++)t=s(t,u(c(n[e][0]),a[e][0]));return t}},"SparseMatrix, SparseMatrix":function(e,t){m(e,t);var r=e._index,n=e._values,i=t._index,a=t._values;let o=0;const s=f,u=p;let l=0,c=0;for(;l<r.length&&c<i.length;){const e=r[l],t=i[c];e<t?l++:e>t?c++:e===t&&(o=s(o,u(n[l],a[c])),l++,c++)}return o}});function m(e,t){const r=h(e),n=h(t);let i,a;if(1===r.length)i=r[0];else{if(2!==r.length||1!==r[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+r.join(", ")+")");i=r[0]}if(1===n.length)a=n[0];else{if(2!==n.length||1!==n[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+n.join(", ")+")");a=n[0]}if(i!==a)throw new RangeError("Vectors must have equal length ("+i+" != "+a+")");if(0===i)throw new RangeError("Cannot calculate the dot product of empty vectors");return i}function h(e){return _(e)?e.size():t(e)}}),ef=s("trace",["typed","matrix","add"],e=>{let{typed:t,matrix:r,add:u}=e;return t("trace",{Array:function(e){return n(r(e))},SparseMatrix:function(e){const n=e._values,i=e._index,a=e._ptr,t=e._size,o=t[0],s=t[1];if(o!==s)throw new RangeError("Matrix must be square (size: "+S(t)+")");{let r=0;if(0<n.length)for(let t=0;t<s;t++){const o=a[t],s=a[t+1];for(let e=o;e<s;e++){const o=i[e];if(o===t){r=u(r,n[e]);break}if(o>t)break}}return r}},DenseMatrix:n,any:ee});function n(r){var e=r._size,n=r._data;switch(e.length){case 1:if(1===e[0])return ee(n[0]);throw new RangeError("Matrix must be square (size: "+S(e)+")");case 2:{const r=e[0];if(r!==e[1])throw new RangeError("Matrix must be square (size: "+S(e)+")");{let t=0;for(let e=0;e<r;e++)t=u(t,n[e][e]);return t}}default:throw new RangeError("Matrix must be two dimensional (size: "+S(e)+")")}}}),tf=s("index",["typed","Index"],e=>{let{typed:t,Index:r}=e;return t("index",{"...number | string | BigNumber | Range | Array | Matrix":function(e){var e=e.map(function(e){return Q(e)?e.toNumber():b(e)||_(e)?e.map(function(e){return Q(e)?e.toNumber():e}):e}),t=new r;return r.apply(t,e),t}})}),rf=new Set(["end"]),nf=s("Node",["mathWithTransform"],e=>{let t=e["mathWithTransform"];return class{get type(){return"Node"}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){const n=this._compile(t,{}),i={};return{evaluate:function(e){var e=U(e),t=e;for(const r of[...rf])if(t.has(r))throw new Error('Scope contains an illegal symbol, "'+r+'" is a reserved keyword');return n(e,i,null)}}}_compile(e,t){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(e){throw new Error("Cannot run forEach on a Node interface")}map(e){throw new Error("Cannot run map on a Node interface")}_ifNode(e){if(O(e))return e;throw new TypeError("Callback function must return a Node")}traverse(e){e(this,null,null),function n(e,i){e.forEach(function(e,t,r){i(e,t,r),n(e,i)})}(this,e)}transform(i){return function e(t,r,n){r=i(t,r,n);return r!==t?r:t.map(e)}(this,null,null)}filter(n){const i=[];return this.traverse(function(e,t,r){n(e,t,r)&&i.push(e)}),i}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map(function(e){return e.cloneDeep()})}equals(e){return!!e&&this.type===e.type&&De(this,e)}toString(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)}_toString(){throw new Error("_toString not implemented for "+this.type)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(e){var t=this._getCustomString(e);return void 0!==t?t:this._toHTML(e)}_toHTML(){throw new Error("_toHTML not implemented for "+this.type)}toTex(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)}_toTex(e){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}},{isClass:!0,isNode:!0});function af(e){return(af="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function of(e,t,r){var n;n=function(e){if("object"!=af(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!=af(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(t),(t="symbol"==af(n)?n:n+"")in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}function sf(e){return e&&e.isIndexError?new En(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function uf(e){let r=e["subset"];return function(e,t){try{if(Array.isArray(e))return r(e,t);if(e&&"function"==typeof e.subset)return e.subset(t);if("string"==typeof e)return r(e,t);if("object"!=typeof e)throw new TypeError("Cannot apply index: unsupported type of object");if(t.isObjectProperty())return h(e,t.getObjectProperty());throw new TypeError("Cannot apply a numeric index as object property")}catch(e){throw sf(e)}}}const lf="AccessorNode",cf=s(lf,["subset","Node"],e=>{var{subset:e,Node:t}=e;const o=uf({subset:e});function r(e){return!(ge(e)||ye(e)||ae(e)||Ae(e)||Se(e)||Me(e)||se(e))}class n extends t{constructor(e,t){if(super(),!O(e))throw new TypeError('Node expected for parameter "object"');if(!Ee(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e,this.index=t}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return lf}get isAccessorNode(){return!0}_compile(n,e){const i=this.object._compile(n,e),a=this.index._compile(n,e);if(this.index.isObjectProperty()){const n=this.index.getObjectProperty();return function(e,t,r){return h(i(e,t,r),n)}}return function(e,t,r){r=i(e,t,r),e=a(e,t,r);return o(r,e)}}forEach(e){e(this.object,"object",this),e(this.index,"index",this)}map(e){return new n(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))}clone(){return new n(this.object,this.index)}_toString(e){let t=this.object.toString(e);return(t=r(this.object)?"("+t+")":t)+this.index.toString(e)}_toHTML(e){let t=this.object.toHTML(e);return(t=r(this.object)?'<span class="math-parenthesis math-round-parenthesis">(</span>'+t+'<span class="math-parenthesis math-round-parenthesis">)</span>':t)+this.index.toHTML(e)}_toTex(e){let t=this.object.toTex(e);return(t=r(this.object)?"\\left(' + object + '\\right)":t)+this.index.toTex(e)}toJSON(){return{mathjs:lf,object:this.object,index:this.index}}static fromJSON(e){return new n(e.object,e.index)}}return of(n,"name",lf),n},{isClass:!0,isNode:!0}),ff="ArrayNode",pf=s(ff,["Node"],e=>{e=e.Node;class n extends e{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(O))throw new TypeError("Array containing Nodes expected")}get type(){return ff}get isArrayNode(){return!0}_compile(t,i){const e=zn(this.items,function(e){return e._compile(t,i)});if("Array"===t.config.matrix)return function(t,r,n){return zn(e,function(e){return e(t,r,n)})};{const i=t.matrix;return function(t,r,n){return i(zn(e,function(e){return e(t,r,n)}))}}}forEach(t){for(let e=0;e<this.items.length;e++)t(this.items[e],"items["+e+"]",this)}map(t){const r=[];for(let e=0;e<this.items.length;e++)r[e]=this._ifNode(t(this.items[e],"items["+e+"]",this));return new n(r)}clone(){return new n(this.items.slice(0))}_toString(t){return"["+this.items.map(function(e){return e.toString(t)}).join(", ")+"]"}toJSON(){return{mathjs:ff,items:this.items}}static fromJSON(e){return new n(e.items)}_toHTML(t){return'<span class="math-parenthesis math-square-parenthesis">[</span>'+this.items.map(function(e){return e.toHTML(t)}).join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(o){return function t(e,r){var n=e.some(ye)&&!e.every(ye),i=r||n,a=i?"&":"\\\\",e=e.map(function(e){return e.items?t(e.items,!r):e.toTex(o)}).join(a);return n||!i||i&&!r?"\\begin{bmatrix}"+e+"\\end{bmatrix}":e}(this.items,!1)}}return of(n,"name",ff),n},{isClass:!0,isNode:!0}),mf=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:nullish":{op:"??",associativity:"left",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function hf(e,t){if(!t||"auto"!==t)return e;let r=e;for(;Me(r);)r=r.content;return r}function F(e,t,r,n){let i=e;var a=(i="keep"!==t?e.getContent():i).getIdentifier();let o=null;for(let e=0;e<mf.length;e++)if(a in mf[e]){o=e;break}if("OperatorNode:multiply"===a&&i.implicit&&"show"!==r){const e=hf(i.args[0],t);ae(e)&&n&&"OperatorNode:divide"===n.getIdentifier()&&we(hf(n.args[0],t))||"OperatorNode:divide"===e.getIdentifier()&&we(hf(e.args[0],t))&&ae(hf(e.args[1]))||(o+=1)}return o}function df(e,t){let r=e;e=(r="keep"!==t?e.getContent():r).getIdentifier(),t=F(r,t);if(null===t)return null;t=mf[t][e];if(ue(t,"associativity")){if("left"===t.associativity)return"left";if("right"===t.associativity)return"right";throw Error("'"+e+"' has the invalid associativity '"+t.associativity+"'.")}return null}function gf(e,t,r){const n="keep"!==r?e.getContent():e,i="keep"!==r?e.getContent():t,a=n.getIdentifier(),o=i.getIdentifier(),s=F(n,r);if(null===s)return null;var u=mf[s][a];if(ue(u,"associativeWith")&&u.associativeWith instanceof Array){for(let e=0;e<u.associativeWith.length;e++)if(u.associativeWith[e]===o)return!0;return!1}return null}const yf="AssignmentNode",xf=s(yf,["subset","?matrix","Node"],e=>{var{subset:t,matrix:r,Node:e}=e;const c=uf({subset:t}),f=function(){let{subset:n,matrix:i}={subset:t,matrix:r};return function(r,e,t){try{if(Array.isArray(r))return i(r).subset(e,t).valueOf().forEach((e,t)=>{r[t]=e}),r;if(r&&"function"==typeof r.subset)return r.subset(e,t);if("string"==typeof r)return n(r,e,t);if("object"!=typeof r)throw new TypeError("Cannot apply index: unsupported type of object");if(e.isObjectProperty())return D(r,e.getObjectProperty(),t),r;throw TypeError("Cannot apply a numeric index as object property")}catch(r){throw sf(r)}}}();function i(e,t,r){var n=F(e,t=t||"keep",r),e=F(e.value,t,r);return"all"===t||null!==e&&e<=n}class n extends e{constructor(e,t,r){if(super(),this.object=e,this.index=r?t:null,this.value=r||t,!se(e)&&!ge(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(se(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!Ee(this.index))throw new TypeError('IndexNode expected as "index"');if(!O(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return yf}get isAssignmentNode(){return!0}_compile(o,e){const s=this.object._compile(o,e),u=this.index?this.index._compile(o,e):null,l=this.value._compile(o,e),i=this.object.name;if(this.index){if(this.index.isObjectProperty()){const o=this.index.getObjectProperty();return function(e,t,r){var n=s(e,t,r),e=l(e,t,r);return D(n,o,e),e}}if(se(this.object))return function(e,t,r){var n=s(e,t,r),r=l(e,t,r),t=u(e,t,n);return e.set(i,f(n,t,r)),r};{const s=this.object.object._compile(o,e);if(this.object.index.isObjectProperty()){const o=this.object.index.getObjectProperty();return function(e,t,r){var n=s(e,t,r),i=h(n,o),a=u(e,t,i),e=l(e,t,r);return D(n,o,f(i,a,e)),e}}{const h=this.object.index._compile(o,e);return function(e,t,r){var n=s(e,t,r),i=h(e,t,n),a=c(n,i),o=u(e,t,a),e=l(e,t,r);return f(n,i,f(a,o,e)),e}}}}if(se(this.object))return function(e,t,r){t=l(e,t,r);return e.set(i,t),t};throw new TypeError("SymbolNode expected as object")}forEach(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)}map(e){var t=this._ifNode(e(this.object,"object",this)),r=this.index?this._ifNode(e(this.index,"index",this)):null,e=this._ifNode(e(this.value,"value",this));return new n(t,r,e)}clone(){return new n(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"";let n=this.value.toString(e);return t+r+" = "+(n=i(this,e&&e.parenthesis,e&&e.implicit)?"("+n+")":n)}toJSON(){return{mathjs:yf,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new n(e.object,e.index,e.value)}_toHTML(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"";let n=this.value.toHTML(e);return t+r+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+(n=i(this,e&&e.parenthesis,e&&e.implicit)?'<span class="math-paranthesis math-round-parenthesis">(</span>'+n+'<span class="math-paranthesis math-round-parenthesis">)</span>':n)}_toTex(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"";let n=this.value.toTex(e);return t+r+"="+(n=i(this,e&&e.parenthesis,e&&e.implicit)?`\\left(${n}\\right)`:n)}}return of(n,"name",yf),n},{isClass:!0,isNode:!0}),bf="BlockNode",vf=s(bf,["ResultSet","Node"],e=>{let{ResultSet:o,Node:t}=e;class i extends t{constructor(e){if(super(),!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map(function(e){var t=e&&e.node,e=!e||void 0===e.visible||e.visible;if(!O(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof e)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:e}})}get type(){return bf}get isBlockNode(){return!0}_compile(t,r){const e=zn(this.blocks,function(e){return{evaluate:e.node._compile(t,r),visible:e.visible}});return function(r,n,i){const a=[];return qn(e,function(e){var t=e.evaluate(r,n,i);e.visible&&a.push(t)}),new o(a)}}forEach(t){for(let e=0;e<this.blocks.length;e++)t(this.blocks[e].node,"blocks["+e+"].node",this)}map(t){const r=[];for(let e=0;e<this.blocks.length;e++){const i=this.blocks[e],n=this._ifNode(t(i.node,"blocks["+e+"].node",this));r[e]={node:n,visible:i.visible}}return new i(r)}clone(){var e=this.blocks.map(function(e){return{node:e.node,visible:e.visible}});return new i(e)}_toString(t){return this.blocks.map(function(e){return e.node.toString(t)+(e.visible?"":";")}).join("\n")}toJSON(){return{mathjs:bf,blocks:this.blocks}}static fromJSON(e){return new i(e.blocks)}_toHTML(t){return this.blocks.map(function(e){return e.node.toHTML(t)+(e.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')}_toTex(t){return this.blocks.map(function(e){return e.node.toTex(t)+(e.visible?"":";")}).join("\\;\\;\n")}}return of(i,"name",bf),i},{isClass:!0,isNode:!0}),wf="ConditionalNode",Nf=s(wf,["Node"],e=>{e=e.Node;class t extends e{constructor(e,t,r){if(super(),!O(e))throw new TypeError("Parameter condition must be a Node");if(!O(t))throw new TypeError("Parameter trueExpr must be a Node");if(!O(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}get type(){return wf}get isConditionalNode(){return!0}_compile(e,t){const n=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,r){return(function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return e;if(e){if(Q(e))return!e.isZero();if(te(e))return e.re||e.im;if(L(e))return e.value}if(null!=e)throw new TypeError('Unsupported type of condition "'+K(e)+'"')}(n(e,t,r))?i:a)(e,t,r)}}forEach(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)}map(e){return new t(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))}clone(){return new t(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=F(this,t,e&&e.implicit);let n=this.condition.toString(e);var i=F(this.condition,t,e&&e.implicit);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");let a=this.trueExpr.toString(e);i=F(this.trueExpr,t,e&&e.implicit);("all"===t||"OperatorNode"===this.trueExpr.type||null!==i&&i<=r)&&(a="("+a+")");let o=this.falseExpr.toString(e);i=F(this.falseExpr,t,e&&e.implicit);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==i&&i<=r)&&(o="("+o+")"),n+" ? "+a+" : "+o}toJSON(){return{mathjs:wf,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new t(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=F(this,t,e&&e.implicit);let n=this.condition.toHTML(e);var i=F(this.condition,t,e&&e.implicit);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='<span class="math-parenthesis math-round-parenthesis">(</span>'+n+'<span class="math-parenthesis math-round-parenthesis">)</span>');let a=this.trueExpr.toHTML(e);i=F(this.trueExpr,t,e&&e.implicit);("all"===t||"OperatorNode"===this.trueExpr.type||null!==i&&i<=r)&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>');let o=this.falseExpr.toHTML(e);i=F(this.falseExpr,t,e&&e.implicit);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==i&&i<=r)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),n+'<span class="math-operator math-conditional-operator">?</span>'+a+'<span class="math-operator math-conditional-operator">:</span>'+o}_toTex(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return of(t,"name",wf),t},{isClass:!0,isNode:!0});var Af=fd(144);const Ef={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},c={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},Sf={abs:{1:"\\left|${args[0]}\\right|"},add:{2:`\\left(\${args[0]}${c.add}\${args[1]}\\right)`},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:`\\left(\${args[0]}${c.dotDivide}\${args[1]}\\right)`},dotMultiply:{2:`\\left(\${args[0]}${c.dotMultiply}\${args[1]}\\right)`},dotPow:{2:`\\left(\${args[0]}${c.dotPow}\${args[1]}\\right)`},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:`\\left(e${c.pow}{\${args[0]}}-1\\right)`,fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},fraction:{2:"\\frac{${args[0]}}{${args[1]}}"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:`\\left(\${args[0]}${c.mod}\${args[1]}\\right)`},multiply:{2:`\\left(\${args[0]}${c.multiply}\${args[1]}\\right)`},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : y^${args[1]} = {${args[0]}}\\}"},pow:{2:`\\left(\${args[0]}\\right)${c.pow}{\${args[1]}}`},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:`\\left(\${args[0]}${c.subtract}\${args[1]}\\right)`},unaryMinus:{1:c.unaryMinus+"\\left(${args[0]}\\right)"},unaryPlus:{1:c.unaryPlus+"\\left(${args[0]}\\right)"},bitAnd:{2:`\\left(\${args[0]}${c.bitAnd}\${args[1]}\\right)`},bitNot:{1:c.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:`\\left(\${args[0]}${c.bitOr}\${args[1]}\\right)`},bitXor:{2:`\\left(\${args[0]}${c.bitXor}\${args[1]}\\right)`},leftShift:{2:`\\left(\${args[0]}${c.leftShift}\${args[1]}\\right)`},rightArithShift:{2:`\\left(\${args[0]}${c.rightArithShift}\${args[1]}\\right)`},rightLogShift:{2:`\\left(\${args[0]}${c.rightLogShift}\${args[1]}\\right)`},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:`\\left(\${args[0]}${c.and}\${args[1]}\\right)`},not:{1:c.not+"\\left(${args[0]}\\right)"},or:{2:`\\left(\${args[0]}${c.or}\${args[1]}\\right)`},xor:{2:`\\left(\${args[0]}${c.xor}\${args[1]}\\right)`},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)"+c.ctranspose},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:`{\${args[0]}}${c.pow}{\\frac{1}{2}}`},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)"+c.transpose},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)"+c.factorial},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:`\\left(\${args[0]}${c.equal}\${args[1]}\\right)`},larger:{2:`\\left(\${args[0]}${c.larger}\${args[1]}\\right)`},largerEq:{2:`\\left(\${args[0]}${c.largerEq}\${args[1]}\\right)`},smaller:{2:`\\left(\${args[0]}${c.smaller}\${args[1]}\\right)`},smallerEq:{2:`\\left(\${args[0]}${c.smallerEq}\${args[1]}\\right)`},unequal:{2:`\\left(\${args[0]}${c.unequal}\${args[1]}\\right)`},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:`\\left(\${args[0]}${c.to}\${args[1]}\\right)`},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},bigint:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:`\\left(\\left(\${args[0]}\\right)+${Ef.i}\\cdot\\left(\${args[1]}\\right)\\right)`},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},Mf={deg:"^\\circ"};function Cf(e){return Af(e,{preserveFormatting:!0})}function Tf(e,t){return(t=void 0!==t&&t)?ue(Mf,e)?Mf[e]:"\\mathrm{"+Cf(e)+"}":ue(Ef,e)?Ef[e]:Cf(e)}const Bf="ConstantNode",Ff=s(Bf,["Node"],e=>{e=e.Node;class t extends e{constructor(e){super(),this.value=e}get type(){return Bf}get isConstantNode(){return!0}_compile(e,t){const r=this.value;return function(){return r}}forEach(e){}map(e){return this.clone()}clone(){return new t(this.value)}_toString(e){return S(this.value,e)}_toHTML(e){var t=this._toString(e);switch(K(this.value)){case"number":case"bigint":case"BigNumber":case"Fraction":return'<span class="math-number">'+t+"</span>";case"string":return'<span class="math-string">'+t+"</span>";case"boolean":return'<span class="math-boolean">'+t+"</span>";case"null":return'<span class="math-null-symbol">'+t+"</span>";case"undefined":return'<span class="math-undefined">'+t+"</span>";default:return'<span class="math-symbol">'+t+"</span>"}}toJSON(){return{mathjs:Bf,value:this.value}}static fromJSON(e){return new t(e.value)}_toTex(e){const t=this._toString(e),r=K(this.value);switch(r){case"string":return"\\mathtt{"+Cf(t)+"}";case"number":case"BigNumber":{if(!("BigNumber"===r?this.value.isFinite():isFinite(this.value)))return this.value.valueOf()<0?"-\\infty":"\\infty";const e=t.toLowerCase().indexOf("e");return-1!==e?t.substring(0,e)+"\\cdot10^{"+t.substring(e+1)+"}":t}case"bigint":return t.toString();case"Fraction":return this.value.toLatex();default:return t}}}return of(t,"name",Bf),t},{isClass:!0,isNode:!0}),Df="FunctionAssignmentNode",Of=s(Df,["typed","Node"],e=>{let{typed:f,Node:t}=e;function i(e,t,r){var n=F(e,t,r),e=F(e.expr,t,r);return"all"===t||null!==e&&e<=n}class r extends t{constructor(e,t,r){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!O(r))throw new TypeError('Node expected for parameter "expr"');if(rf.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');const n=new Set;for(const e of t){const t="string"==typeof e?e:e.name;if(n.has(t))throw new Error(`Duplicate parameter name "${t}"`);n.add(t)}this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||"any"}),this.expr=r}get type(){return Df}get isFunctionAssignmentNode(){return!0}_compile(e,t){const r=Object.create(t),a=(qn(this.params,function(e){r[e]=!0}),this.expr),o=a._compile(e,r),s=this.name,u=this.params,l=Rn(this.types,","),c=s+"("+Rn(this.params,", ")+")";return function(e,r,n){const t={},i=(t[l]=function(){const t=Object.create(r);for(let e=0;e<u.length;e++)t[u[e]]=arguments[e];return o(e,t,n)},f(s,t));return i.syntax=c,i.expr=a.toString(),e.set(s,i),i}}forEach(e){e(this.expr,"expr",this)}map(e){e=this._ifNode(e(this.expr,"expr",this));return new r(this.name,this.params.slice(0),e)}clone(){return new r(this.name,this.params.slice(0),this.expr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:"keep";let r=this.expr.toString(e);return i(this,t,e&&e.implicit)&&(r="("+r+")"),this.name+"("+this.params.join(", ")+") = "+r}toJSON(){const r=this.types;return{mathjs:Df,name:this.name,params:this.params.map(function(e,t){return{name:e,type:r[t]}}),expr:this.expr}}static fromJSON(e){return new r(e.name,e.params,e.expr)}_toHTML(e){const t=e&&e.parenthesis?e.parenthesis:"keep",r=[];for(let e=0;e<this.params.length;e++)r.push('<span class="math-symbol math-parameter">'+Nn(this.params[e])+"</span>");let n=this.expr.toHTML(e);return i(this,t,e&&e.implicit)&&(n='<span class="math-parenthesis math-round-parenthesis">(</span>'+n+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Nn(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+n}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:"keep";let r=this.expr.toTex(e);return i(this,t,e&&e.implicit)&&(r=`\\left(${r}\\right)`),"\\mathrm{"+this.name+"}\\left("+this.params.map(Tf).join(",")+"\\right)="+r}}return of(r,"name",Df),r},{isClass:!0,isNode:!0}),_f="IndexNode",zf=s(_f,["Node","size"],e=>{let{Node:t,size:s}=e;class n extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(O))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return _f}get isIndexNode(){return!0}_compile(r,n){const i=zn(this.dimensions,function(e,a){if(0<e.filter(e=>e.isSymbolNode&&"end"===e.name).length){const t=Object.create(n),o=(t.end=!0,e._compile(r,t));return function(e,t,r){if(!_(r)&&!b(r)&&!j(r))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+K(r));const n=s(r).valueOf(),i=Object.create(t);return i.end=n[a],o(e,i,r)}}return e._compile(r,n)}),a=h(r,"index");return function(t,r,n){var e=zn(i,function(e){return e(t,r,n)});return a(...e)}}forEach(t){for(let e=0;e<this.dimensions.length;e++)t(this.dimensions[e],"dimensions["+e+"]",this)}map(t){const r=[];for(let e=0;e<this.dimensions.length;e++)r[e]=this._ifNode(t(this.dimensions[e],"dimensions["+e+"]",this));return new n(r,this.dotNotation)}clone(){return new n(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return 1===this.dimensions.length&&ae(this.dimensions[0])&&"string"==typeof this.dimensions[0].value}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(e){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:_f,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(e){return new n(e.dimensions,e.dotNotation)}_toHTML(e){const t=[];for(let e=0;e<this.dimensions.length;e++)t[e]=this.dimensions[e].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Nn(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+t.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(t){const e=this.dimensions.map(function(e){return e.toTex(t)});return this.dotNotation?"."+this.getObjectProperty():"_{"+e.join(",")+"}"}}return of(n,"name",_f),n},{isClass:!0,isNode:!0}),qf="ObjectNode",If=s(qf,["Node"],e=>{e=e.Node;class r extends e{constructor(t){if(super(),this.properties=t||{},t&&("object"!=typeof t||!Object.keys(t).every(function(e){return O(t[e])})))throw new TypeError("Object containing Nodes expected")}get type(){return qf}get isObjectNode(){return!0}_compile(e,t){const a={};for(const r in this.properties)if(ue(this.properties,r)){const n=vn(r),i=JSON.parse(n),o=h(this.properties,r);a[i]=o._compile(e,t)}return function(e,t,r){const n={};for(const i in a)ue(a,i)&&(n[i]=a[i](e,t,r));return n}}forEach(e){for(const t in this.properties)ue(this.properties,t)&&e(this.properties[t],"properties["+vn(t)+"]",this)}map(e){const t={};for(const r in this.properties)ue(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],"properties["+vn(r)+"]",this)));return new r(t)}clone(){const e={};for(const t in this.properties)ue(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)}_toString(e){const t=[];for(const r in this.properties)ue(this.properties,r)&&t.push(vn(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"}toJSON(){return{mathjs:qf,properties:this.properties}}static fromJSON(e){return new r(e.properties)}_toHTML(e){const t=[];for(const r in this.properties)ue(this.properties,r)&&t.push('<span class="math-symbol math-property">'+Nn(r)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[r].toHTML(e));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+t.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(e){const t=[];for(const r in this.properties)ue(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}"+t.join("\n")+"\\end{array}\\right\\}"}}return of(r,"name",qf),r},{isClass:!0,isNode:!0});function kf(e,t){return new k(e,new I(t),new Set(Object.keys(t)))}const Rf="OperatorNode",Pf=s(Rf,["Node"],e=>{e=e.Node;function l(a,o,s,r,e){const u=F(a,o,s),l=df(a,o);if("all"===o||2<r.length&&"OperatorNode:add"!==a.getIdentifier()&&"OperatorNode:multiply"!==a.getIdentifier())return r.map(function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});let c;switch(r.length){case 0:c=[];break;case 1:{const n=F(r[0],o,s,a);if(e&&null!==n){let e,t;if(t="keep"===o?(e=r[0].getIdentifier(),a.getIdentifier()):(e=r[0].getContent().getIdentifier(),a.getContent().getIdentifier()),!1===mf[u][t].latexLeftParens){c=[!1];break}if(!1===mf[n][e].latexParens){c=[!1];break}}if(null===n){c=[!1];break}if(n<=u){c=[!0];break}c=[!1]}break;case 2:{let n;var f=F(r[0],o,s,a),p=gf(a,r[0],o);let i;n=null!==f&&(f===u&&"right"===l&&!p||f<u);var p=F(r[1],o,s,a),t=gf(a,r[1],o);if(i=null!==p&&(p===u&&"left"===l&&!t||p<u),e){let e,t,r;r="keep"===o?(e=a.getIdentifier(),t=a.args[0].getIdentifier(),a.args[1].getIdentifier()):(e=a.getContent().getIdentifier(),t=a.args[0].getContent().getIdentifier(),a.args[1].getContent().getIdentifier()),null!==f&&(!1===mf[u][e].latexLeftParens&&(n=!1),!1===mf[f][t].latexParens&&(n=!1)),null!==p&&(!1===mf[u][e].latexRightParens&&(i=!1),!1===mf[p][r].latexParens&&(i=!1))}c=[n,i]}break;default:"OperatorNode:add"!==a.getIdentifier()&&"OperatorNode:multiply"!==a.getIdentifier()||(c=r.map(function(e){var t=F(e,o,s,a),r=gf(a,e,o),e=df(e,o);return null!==t&&(u===t&&l===e&&!r||t<u)}))}if(2<=r.length&&"OperatorNode:multiply"===a.getIdentifier()&&a.implicit&&"all"!==o&&"hide"===s)for(let e=1;e<c.length;++e)!function e(t,r){let n=t;if("auto"===r)for(;Me(n);)n=n.content;return!!ae(n)||!!oe(n)&&e(n.args[0],r)}(r[e],o)||c[e-1]||"keep"===o&&Me(r[e-1])||(c[e]=!0);return c}class n extends e{constructor(e,t,r,n,i){if(super(),"string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(O))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.isPercentage=!0===i,this.op=e,this.fn=t,this.args=r||[]}get type(){return Rf}get isOperatorNode(){return!0}_compile(n,i){if("string"!=typeof this.fn||!q(n,this.fn))throw n[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');const a=h(n,this.fn),e=zn(this.args,function(e){return e._compile(n,i)});if("function"==typeof a&&!0===a.rawArgs){const i=this.args;return function(e,t,r){return a(i,n,kf(e,t))}}if(1===e.length){const n=e[0];return function(e,t,r){return a(n(e,t,r))}}if(2!==e.length)return function(t,r,n){return a.apply(null,zn(e,function(e){return e(t,r,n)}))};{const n=e[0],i=e[1];return function(e,t,r){return a(n(e,t,r),i(e,t,r))}}}forEach(t){for(let e=0;e<this.args.length;e++)t(this.args[e],"args["+e+"]",this)}map(t){const r=[];for(let e=0;e<this.args.length;e++)r[e]=this._ifNode(t(this.args[e],"args["+e+"]",this));return new n(this.op,this.fn,r,this.implicit,this.isPercentage)}clone(){return new n(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return 1===this.args.length}isBinary(){return 2===this.args.length}_toString(r){const t=r&&r.parenthesis?r.parenthesis:"keep",n=r&&r.implicit?r.implicit:"hide",i=this.args,a=l(this,t,n,i,!1);if(1===i.length){const n=df(this,t);let e=i[0].toString(r);a[0]&&(e="("+e+")");var o=/[a-zA-Z]+/.test(this.op);return"right"===n?this.op+(o?" ":"")+e:"left"===n?e+(o?" ":"")+this.op:e+this.op}if(2===i.length){let e=i[0].toString(r),t=i[1].toString(r);return a[0]&&(e="("+e+")"),a[1]&&(t="("+t+")"),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?e+" "+t:e+" "+this.op+" "+t}if(2<i.length&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){const t=i.map(function(e,t){return e=e.toString(r),e=a[t]?"("+e+")":e});return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?t.join(" "):t.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:Rf,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new n(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(r){const t=r&&r.parenthesis?r.parenthesis:"keep",n=r&&r.implicit?r.implicit:"hide",i=this.args,a=l(this,t,n,i,!1);if(1===i.length){const n=df(this,t);let e=i[0].toHTML(r);return a[0]&&(e='<span class="math-parenthesis math-round-parenthesis">(</span>'+e+'<span class="math-parenthesis math-round-parenthesis">)</span>'),"right"===n?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Nn(this.op)+"</span>"+e:e+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Nn(this.op)+"</span>"}if(2===i.length){let e=i[0].toHTML(r),t=i[1].toHTML(r);return a[0]&&(e='<span class="math-parenthesis math-round-parenthesis">(</span>'+e+'<span class="math-parenthesis math-round-parenthesis">)</span>'),a[1]&&(t='<span class="math-parenthesis math-round-parenthesis">(</span>'+t+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?e+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+t:e+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Nn(this.op)+"</span>"+t}{const t=i.map(function(e,t){return e=e.toHTML(r),e=a[t]?'<span class="math-parenthesis math-round-parenthesis">(</span>'+e+'<span class="math-parenthesis math-round-parenthesis">)</span>':e});return 2<i.length&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?t.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):t.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Nn(this.op)+"</span>"):'<span class="math-function">'+Nn(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+t.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}}_toTex(n){const i=n&&n.parenthesis?n.parenthesis:"keep",a=n&&n.implicit?n.implicit:"hide",o=this.args,s=l(this,i,a,o,!0);let u=c[this.fn];if(u=void 0===u?this.op:u,1===o.length){const a=df(this,i);let e=o[0].toTex(n);return s[0]&&(e=`\\left(${e}\\right)`),"right"===a?u+e:e+u}if(2===o.length){const l=o[0];let e=l.toTex(n);s[0]&&(e=`\\left(${e}\\right)`);let t,r=o[1].toTex(n);switch(s[1]&&(r=`\\left(${r}\\right)`),t=("keep"===i?l:l.getContent()).getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return u+"{"+e+"}{"+r+"}";case"OperatorNode:pow":switch(e="{"+e+"}",r="{"+r+"}",t){case"ConditionalNode":case"OperatorNode:divide":e=`\\left(${e}\\right)`}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===a)return e+"~"+r}return e+u+r}if(2<o.length&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){const i=o.map(function(e,t){return e=e.toTex(n),e=s[t]?`\\left(${e}\\right)`:e});return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit&&"hide"===a?i.join("~"):i.join(u)}return"\\mathrm{"+this.fn+"}\\left("+o.map(function(e){return e.toTex(n)}).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return of(n,"name",Rf),n},{isClass:!0,isNode:!0}),Uf="ParenthesisNode",jf=s(Uf,["Node"],e=>{e=e.Node;class t extends e{constructor(e){if(super(),!O(e))throw new TypeError('Node expected for parameter "content"');this.content=e}get type(){return Uf}get isParenthesisNode(){return!0}_compile(e,t){return this.content._compile(e,t)}getContent(){return this.content.getContent()}forEach(e){e(this.content,"content",this)}map(e){e=e(this.content,"content",this);return new t(e)}clone(){return new t(this.content)}_toString(e){return!e||!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)}toJSON(){return{mathjs:Uf,content:this.content}}static fromJSON(e){return new t(e.content)}_toHTML(e){return!e||!e.parenthesis||e&&"keep"===e.parenthesis?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(e)}_toTex(e){return!e||!e.parenthesis||e&&"keep"===e.parenthesis?`\\left(${this.content.toTex(e)}\\right)`:this.content.toTex(e)}}return of(t,"name",Uf),t},{isClass:!0,isNode:!0}),Lf="RangeNode",$f=s(Lf,["Node"],e=>{e=e.Node;function a(e,t,r){const n=F(e,t,r),i={},a=F(e.start,t,r);if(i.start=null!==a&&a<=n||"all"===t,e.step){const a=F(e.step,t,r);i.step=null!==a&&a<=n||"all"===t}e=F(e.end,t,r);return i.end=null!==e&&e<=n||"all"===t,i}class t extends e{constructor(e,t,r){if(super(),!O(e))throw new TypeError("Node expected");if(!O(t))throw new TypeError("Node expected");if(r&&!O(r))throw new TypeError("Node expected");if(3<arguments.length)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}get type(){return Lf}get isRangeNode(){return!0}needsEnd(){return 0<this.filter(function(e){return se(e)&&"end"===e.name}).length}_compile(e,t){const n=e.range,i=this.start._compile(e,t),a=this.end._compile(e,t);if(this.step){const o=this.step._compile(e,t);return function(e,t,r){return n(i(e,t,r),a(e,t,r),o(e,t,r))}}return function(e,t,r){return n(i(e,t,r),a(e,t,r))}}forEach(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)}map(e){return new t(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))}clone(){return new t(this.start,this.end,this.step&&this.step)}_toString(t){var r=a(this,t&&t.parenthesis?t.parenthesis:"keep",t&&t.implicit);let n,e=this.start.toString(t);if(r.start&&(e="("+e+")"),n=e,this.step){let e=this.step.toString(t);r.step&&(e="("+e+")"),n+=":"+e}let i=this.end.toString(t);return r.end&&(i="("+i+")"),n+=":"+i}toJSON(){return{mathjs:Lf,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new t(e.start,e.end,e.step)}_toHTML(t){var r=a(this,t&&t.parenthesis?t.parenthesis:"keep",t&&t.implicit);let n,e=this.start.toHTML(t);if(r.start&&(e='<span class="math-parenthesis math-round-parenthesis">(</span>'+e+'<span class="math-parenthesis math-round-parenthesis">)</span>'),n=e,this.step){let e=this.step.toHTML(t);r.step&&(e='<span class="math-parenthesis math-round-parenthesis">(</span>'+e+'<span class="math-parenthesis math-round-parenthesis">)</span>'),n+='<span class="math-operator math-range-operator">:</span>'+e}let i=this.end.toHTML(t);return r.end&&(i='<span class="math-parenthesis math-round-parenthesis">(</span>'+i+'<span class="math-parenthesis math-round-parenthesis">)</span>'),n+='<span class="math-operator math-range-operator">:</span>'+i}_toTex(t){var r=a(this,t&&t.parenthesis?t.parenthesis:"keep",t&&t.implicit);let n=this.start.toTex(t);if(r.start&&(n=`\\left(${n}\\right)`),this.step){let e=this.step.toTex(t);r.step&&(e=`\\left(${e}\\right)`),n+=":"+e}let e=this.end.toTex(t);return r.end&&(e=`\\left(${e}\\right)`),n+=":"+e}}return of(t,"name",Lf),t},{isClass:!0,isNode:!0}),Hf="RelationalNode",Gf=s(Hf,["Node"],e=>{e=e.Node;const o={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class t extends e{constructor(e,t){if(super(),!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}get type(){return Hf}get isRelationalNode(){return!0}_compile(o,t){const s=this,u=this.params.map(e=>e._compile(o,t));return function(t,r,n){let i,a=u[0](t,r,n);for(let e=0;e<s.conditionals.length;e++)if(i=a,a=u[e+1](t,r,n),!h(o,s.conditionals[e])(i,a))return!1;return!0}}forEach(r){this.params.forEach((e,t)=>r(e,"params["+t+"]",this),this)}map(r){return new t(this.conditionals.slice(),this.params.map((e,t)=>this._ifNode(r(e,"params["+t+"]",this)),this))}clone(){return new t(this.conditionals,this.params)}_toString(n){const i=n&&n.parenthesis?n.parenthesis:"keep",a=F(this,i,n&&n.implicit),t=this.params.map(function(e,t){var r=F(e,i,n&&n.implicit);return"all"===i||null!==r&&r<=a?"("+e.toString(n)+")":e.toString(n)});let r=t[0];for(let e=0;e<this.conditionals.length;e++)r=(r+=" "+o[this.conditionals[e]])+(" "+t[e+1]);return r}toJSON(){return{mathjs:Hf,conditionals:this.conditionals,params:this.params}}static fromJSON(e){return new t(e.conditionals,e.params)}_toHTML(n){const i=n&&n.parenthesis?n.parenthesis:"keep",a=F(this,i,n&&n.implicit),t=this.params.map(function(e,t){var r=F(e,i,n&&n.implicit);return"all"===i||null!==r&&r<=a?'<span class="math-parenthesis math-round-parenthesis">(</span>'+e.toHTML(n)+'<span class="math-parenthesis math-round-parenthesis">)</span>':e.toHTML(n)});let r=t[0];for(let e=0;e<this.conditionals.length;e++)r+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Nn(o[this.conditionals[e]])+"</span>"+t[e+1];return r}_toTex(n){const i=n&&n.parenthesis?n.parenthesis:"keep",a=F(this,i,n&&n.implicit),t=this.params.map(function(e,t){var r=F(e,i,n&&n.implicit);return"all"===i||null!==r&&r<=a?"\\left("+e.toTex(n)+"\right)":e.toTex(n)});let r=t[0];for(let e=0;e<this.conditionals.length;e++)r+=c[this.conditionals[e]]+t[e+1];return r}}return of(t,"name",Hf),t},{isClass:!0,isNode:!0}),Vf=s("SymbolNode",["math","?Unit","Node"],e=>{let{math:n,Unit:a,Node:t}=e;function o(e){return!!a&&a.isValuelessUnit(e)}class s extends t{constructor(e){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(n,e){const i=this.name;if(!0===e[i])return function(e,t,r){return h(t,i)};if(i in n)return function(e,t,r){return e.has(i)?e.get(i):h(n,i)};{const n=o(i);return function(e,t,r){return e.has(i)?e.get(i):n?new a(null,i):s.onUndefinedSymbol(i)}}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw new Error("Undefined symbol "+e)}clone(){return new s(this.name)}_toString(e){return this.name}_toHTML(e){var t=Nn(this.name);return"true"===t||"false"===t?'<span class="math-symbol math-boolean">'+t+"</span>":"i"===t?'<span class="math-symbol math-imaginary-symbol">'+t+"</span>":"Infinity"===t?'<span class="math-symbol math-infinity-symbol">'+t+"</span>":"NaN"===t?'<span class="math-symbol math-nan-symbol">'+t+"</span>":"null"===t?'<span class="math-symbol math-null-symbol">'+t+"</span>":"undefined"===t?'<span class="math-symbol math-undefined-symbol">'+t+"</span>":'<span class="math-symbol">'+t+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(e){return new s(e.name)}_toTex(e){let t=!1;void 0===n[this.name]&&o(this.name)&&(t=!0);var r=Tf(this.name,t);return"\\"===r[0]?r:" "+r}}return s},{isClass:!0,isNode:!0}),Zf="FunctionNode",Wf=s(Zf,["math","Node","SymbolNode"],e=>{var t;let{math:i,Node:r,SymbolNode:n}=e;const p=e=>S(e,{truncate:78});function a(e,t,r){let n="";const i=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi;let a,o=0;for(;null!==(a=i.exec(e));)if(n+=e.substring(o,a.index),o=a.index,"$$"===a[0])n+="$",o++;else{o+=a[0].length;const e=t[a[1]];if(!e)throw new ReferenceError("Template: Property "+a[1]+" does not exist.");if(void 0===a[2])switch(typeof e){case"string":n+=e;break;case"object":if(O(e))n+=e.toTex(r);else{if(!Array.isArray(e))throw new TypeError("Template: "+a[1]+" has to be a Node, String or array of Nodes");n+=e.map(function(e,t){if(O(e))return e.toTex(r);throw new TypeError("Template: "+a[1]+"["+t+"] is not a Node.")}).join(",")}break;default:throw new TypeError("Template: "+a[1]+" has to be a Node, String or array of Nodes")}else{if(!O(e[a[2]]&&e[a[2]]))throw new TypeError("Template: "+a[1]+"["+a[2]+"] is not a Node.");n+=e[a[2]].toTex(r)}}return n+=e.slice(o)}class m extends r{constructor(e,t){if(super(),!O(e="string"==typeof e?new n(e):e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(O))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[]}get name(){return this.fn.name||""}get type(){return Zf}get isFunctionNode(){return!0}_compile(a,i){const o=this.args.map(e=>e._compile(a,i));if(!se(this.fn)){if(ge(this.fn)&&Ee(this.fn.index)&&this.fn.index.isObjectProperty()){const s=this.fn.object._compile(a,i),h=this.fn.index.getObjectProperty(),u=this.args;return function(t,r,n){const e=s(t,r,n),i=function(e,t){if(q(e,t))return e[t];throw new Error('No access to method "'+t+'"')}(e,h);if(null!=i&&i.rawArgs)return i(u,a,kf(t,r));{const a=o.map(e=>e(t,r,n));return i.apply(e,a)}}}{const l=this.fn.toString(),h=this.fn._compile(a,i),c=this.args;return function(t,r,n){const e=h(t,r,n);if("function"!=typeof e)throw new TypeError(`Expression '${l}' did not evaluate to a function; value is:
|
||
`+p(e));if(e.rawArgs)return e(c,a,kf(t,r));{const a=o.map(e=>e(t,r,n));return e.apply(e,a)}}}}{const f=this.fn.name;if(i[f]){const i=this.args;return function(t,r,n){const e=h(r,f);if("function"!=typeof e)throw new TypeError(`Argument '${f}' was not a function; received: `+p(e));if(e.rawArgs)return e(i,a,kf(t,r));{const a=o.map(e=>e(t,r,n));return e.apply(e,a)}}}{const i=f in a?h(a,f):void 0,e="function"==typeof i&&!0===i.rawArgs,q=e=>{let t;if(e.has(f))t=e.get(f);else{if(!(f in a))return m.onUndefinedFunction(f);t=h(a,f)}if("function"==typeof t)return t;throw new TypeError(`'${f}' is not a function; its value is:
|
||
`+p(t))};if(e){const i=this.args;return function(t,r,n){const e=q(t);return!0===e.rawArgs?e(i,a,kf(t,r)):e(...o.map(e=>e(t,r,n)))}}switch(o.length){case 0:return function(e,t,r){return q(e)()};case 1:return function(e,t,r){return q(e)((0,o[0])(e,t,r))};case 2:return function(e,t,r){const n=q(e),i=o[0],a=o[1];return n(i(e,t,r),a(e,t,r))};default:return function(t,r,n){return q(t)(...o.map(e=>e(t,r,n)))}}}}}forEach(t){t(this.fn,"fn",this);for(let e=0;e<this.args.length;e++)t(this.args[e],"args["+e+"]",this)}map(t){const e=this._ifNode(t(this.fn,"fn",this)),r=[];for(let e=0;e<this.args.length;e++)r[e]=this._ifNode(t(this.args[e],"args["+e+"]",this));return new m(e,r)}clone(){return new m(this.fn,this.args.slice(0))}toString(e){let t;var r=this.fn.toString(e);return void 0!==(t=e&&"object"==typeof e.handler&&ue(e.handler,r)?e.handler[r](this,e):t)?t:super.toString(e)}_toString(t){const e=this.args.map(function(e){return e.toString(t)});return(Ne(this.fn)?"("+this.fn.toString(t)+")":this.fn.toString(t))+"("+e.join(", ")+")"}toJSON(){return{mathjs:Zf,fn:this.fn,args:this.args}}_toHTML(t){const e=this.args.map(function(e){return e.toHTML(t)});return'<span class="math-function">'+Nn(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+e.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(e){let t;return void 0!==(t=e&&"object"==typeof e.handler&&ue(e.handler,this.name)?e.handler[this.name](this,e):t)?t:super.toTex(e)}_toTex(t){var e=this.args.map(function(e){return e.toTex(t)});let r,n;switch(Sf[this.name]&&(r=Sf[this.name]),typeof(r=!i[this.name]||"function"!=typeof i[this.name].toTex&&"object"!=typeof i[this.name].toTex&&"string"!=typeof i[this.name].toTex?r:i[this.name].toTex)){case"function":n=r(this,t);break;case"string":n=a(r,this,t);break;case"object":switch(typeof r[e.length]){case"function":n=r[e.length](this,t);break;case"string":n=a(r[e.length],this,t)}}return void 0!==n?n:a("\\mathrm{${name}}\\left(${args}\\right)",this,t)}getIdentifier(){return this.type+":"+this.name}}return of(t=m,"name",Zf),of(m,"onUndefinedFunction",function(e){throw new Error("Undefined function "+e)}),of(m,"fromJSON",function(e){return new t(e.fn,e.args)}),m},{isClass:!0,isNode:!0}),Yf=s("parse",["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],I=>{let{typed:e,numeric:c,config:k,AccessorNode:i,ArrayNode:f,AssignmentNode:o,BlockNode:R,ConditionalNode:P,ConstantNode:p,FunctionAssignmentNode:U,FunctionNode:j,IndexNode:a,ObjectNode:L,OperatorNode:s,ParenthesisNode:$,RangeNode:n,RelationalNode:H,SymbolNode:m}=I;const u=e("parse",{string:function(e){return M(e,{})},"Array | Matrix":function(e){return t(e,{})},"string, Object":function(e,t){return M(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":t});function t(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};const r=void 0!==t.nodes?t.nodes:{};return le(e,function(e){if("string"!=typeof e)throw new TypeError("String expected");return M(e,r)})}const h={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},l={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"??":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},d={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},g={true:!0,false:!1,null:null,undefined:void 0},G=["NaN","Infinity"],V={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function y(e,t){return e.expression.substr(e.index,t)}function x(e){return y(e,1)}function b(e){e.index++}function v(e){return e.expression.charAt(e.index-1)}function w(e){return e.expression.charAt(e.index+1)}function N(e){for(e.tokenType=h.NULL,e.token="",e.comment="";;){if("#"===x(e))for(;"\n"!==x(e)&&""!==x(e);)e.comment+=x(e),b(e);if(!u.isWhitespace(x(e),e.nestingLevel))break;b(e)}if(""===x(e))return e.tokenType=h.DELIMITER;if("\n"===x(e)&&!e.nestingLevel)return e.tokenType=h.DELIMITER,e.token=x(e),b(e);const t=x(e),r=y(e,2),n=y(e,3);if(3===n.length&&l[n])return e.tokenType=h.DELIMITER,e.token=n,b(e),b(e),b(e);if(2===r.length&&l[r])return e.tokenType=h.DELIMITER,e.token=r,b(e),b(e);if(l[t])return e.tokenType=h.DELIMITER,e.token=t,b(e);if(u.isDigitDot(t)){e.tokenType=h.NUMBER;const t=y(e,2);if("0b"===t||"0o"===t||"0x"===t){for(e.token+=x(e),b(e),e.token+=x(e),b(e);u.isHexDigit(x(e));)e.token+=x(e),b(e);if("."===x(e))for(e.token+=".",b(e);u.isHexDigit(x(e));)e.token+=x(e),b(e);else if("i"===x(e))for(e.token+="i",b(e);u.isDigit(x(e));)e.token+=x(e),b(e)}else{if("."===x(e)){if(e.token+=x(e),b(e),!u.isDigit(x(e)))return e.tokenType=h.DELIMITER}else{for(;u.isDigit(x(e));)e.token+=x(e),b(e);u.isDecimalMark(x(e),w(e))&&(e.token+=x(e),b(e))}for(;u.isDigit(x(e));)e.token+=x(e),b(e);if("E"===x(e)||"e"===x(e))if(u.isDigit(w(e))||"-"===w(e)||"+"===w(e)){if(e.token+=x(e),b(e),"+"!==x(e)&&"-"!==x(e)||(e.token+=x(e),b(e)),!u.isDigit(x(e)))throw q(e,'Digit expected, got "'+x(e)+'"');for(;u.isDigit(x(e));)e.token+=x(e),b(e);if(u.isDecimalMark(x(e),w(e)))throw q(e,'Digit expected, got "'+x(e)+'"')}else if(u.isDecimalMark(w(e),e.expression.charAt(e.index+2)))throw b(e),q(e,'Digit expected, got "'+x(e)+'"')}}else{if(!u.isAlpha(x(e),v(e),w(e))){for(e.tokenType=h.UNKNOWN;""!==x(e);)e.token+=x(e),b(e);throw q(e,'Syntax error in part "'+e.token+'"')}for(;u.isAlpha(x(e),v(e),w(e))||u.isDigit(x(e));)e.token+=x(e),b(e);ue(d,e.token)?e.tokenType=h.DELIMITER:e.tokenType=h.SYMBOL}}function A(e){for(;N(e),"\n"===e.token;);}function E(e){e.nestingLevel++}function S(e){e.nestingLevel--}function M(e,t){var r={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:h.NULL,nestingLevel:0,conditionalLevel:null},e=(gn(r,{expression:e,extraNodes:t}),N(r),function(e){let t;const r=[];let n;for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&(t=C(e),e.comment&&(t.comment=e.comment));"\n"===e.token||";"===e.token;)0===r.length&&t&&(n=";"!==e.token,r.push({node:t,visible:n})),N(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&(t=C(e),e.comment&&(t.comment=e.comment),n=";"!==e.token,r.push({node:t,visible:n}));return 0<r.length?new R(r):(t||(t=new p(void 0),e.comment&&(t.comment=e.comment)),t)}(r));if(""!==r.token)throw r.tokenType===h.DELIMITER?ie(r,"Unexpected operator "+r.token):q(r,'Unexpected part "'+r.token+'"');return e}function C(e){let t,r,n,i;const a=function(e){let t=function(e){let t=T(e);for(;"or"===e.token;)A(e),t=new s("or","or",[t,T(e)]);return t}(e);for(;"?"===e.token;){var r=e.conditionalLevel,n=(e.conditionalLevel=e.nestingLevel,A(e),t),i=C(e);if(":"!==e.token)throw q(e,"False part of conditional expression expected");e.conditionalLevel=null,A(e);var a=C(e);t=new P(n,i,a),e.conditionalLevel=r}return t}(e);if("="!==e.token)return a;if(se(a))return t=a.name,A(e),n=C(e),new o(new m(t),n);if(ge(a))return A(e),n=C(e),new o(a.object,a.index,n);if(Ae(a)&&se(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach(function(e,t){se(e)?r[t]=e.name:i=!1}),i))return A(e),n=C(e),new U(t,r,n);throw q(e,"Invalid left hand side of assignment operator =")}function T(e){let t=r(e);for(;"xor"===e.token;)A(e),t=new s("xor","xor",[t,r(e)]);return t}function r(e){let t=B(e);for(;"and"===e.token;)A(e),t=new s("and","and",[t,B(e)]);return t}function B(e){let t=F(e);for(;"|"===e.token;)A(e),t=new s("|","bitOr",[t,F(e)]);return t}function F(e){let t=D(e);for(;"^|"===e.token;)A(e),t=new s("^|","bitXor",[t,D(e)]);return t}function D(e){let t=Z(e);for(;"&"===e.token;)A(e),t=new s("&","bitAnd",[t,Z(e)]);return t}function Z(e){const t=[W(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};for(;ue(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),A(e),t.push(W(e))}return 1===t.length?t[0]:2===t.length?new s(r[0].name,r[0].fn,t):new H(r.map(e=>e.fn),t)}function W(e){let t,r,n,i;t=Y(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};ue(a,e.token);)n=a[r=e.token],A(e),i=[t,Y(e)],t=new s(r,n,i);return t}function Y(e){let t,r,n,i;t=J(e);for(var a={to:"to",in:"to"};ue(a,e.token);)n=a[r=e.token],A(e),t="in"===r&&"])},;".includes(e.token)?new s("*","multiply",[t,new m("in")],!0):(i=[t,J(e)],new s(r,n,i));return t}function J(e){let t;const r=[];if(t=":"===e.token?new p(1):X(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)A(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new m("end")):r.push(X(e));t=3===r.length?new n(r[0],r[2],r[1]):new n(r[0],r[1])}return t}function X(e){let t,r,n,i;t=Q(e);for(var a={"+":"add","-":"subtract"};ue(a,e.token);){n=a[r=e.token],A(e);var o=Q(e);i=o.isPercentage?[t,new s("*","multiply",[t,o])]:[t,o],t=new s(r,n,i)}return t}function Q(e){let t,r,n,i;t=O(e),r=t;for(var a,o={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};ue(o,e.token);)n=e.token,i=o[n],A(e),t="%"===n&&e.tokenType===h.DELIMITER&&"("!==e.token?""!==e.token&&o[e.token]?(a=new s("/","divide",[t,new p(100)],!1,!0),n=e.token,i=o[n],A(e),r=O(e),new s(n,i,[a,r])):new s("/","divide",[t,new p(100)],!1,!0):(r=O(e),new s(n,i,[t,r]));return t}function O(e){let t,r;for(t=K(e),r=t;e.tokenType===h.SYMBOL||"in"===e.token&&ae(t)||"in"===e.token&&oe(t)&&"unaryMinus"===t.fn&&ae(t.args[0])||!(e.tokenType!==h.NUMBER||ae(r)||oe(r)&&"!"!==r.op)||"("===e.token;)r=K(e),t=new s("*","multiply",[t,r],!0);return t}function K(e){let t=_(e),r=t;const n=[];for(;"/"===e.token&&we(r);){if(n.push(gn({},e)),A(e),e.tokenType!==h.NUMBER){gn(e,n.pop());break}if(n.push(gn({},e)),A(e),e.tokenType!==h.SYMBOL&&"("!==e.token&&"in"!==e.token){n.pop(),gn(e,n.pop());break}gn(e,n.pop()),n.pop(),r=_(e),t=new s("/","divide",[t,r])}return t}function _(i){var e,t={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};if(ue(t,i.token))return t=t[i.token],a=i.token,A(i),e=[_(i)],new s(a,t,e);{var a=i;let e,t,r,n;return e=function(e){let t=ee(e);for(;"??"===e.token;)A(e),t=new s("??","nullish",[t,ee(e)]);return t}(a),"^"!==a.token&&".^"!==a.token||(r="^"===(t=a.token)?"pow":"dotPow",A(a),n=[e,_(a)],e=new s(t,r,n)),e}}function ee(e){let t,r,n,i;t=function(e){let t=[];if(e.tokenType===h.SYMBOL&&ue(e.extraNodes,e.token)){const c=e.extraNodes[e.token];if(N(e),"("===e.token){if(t=[],E(e),N(e),")"!==e.token)for(t.push(C(e));","===e.token;)N(e),t.push(C(e));if(")"!==e.token)throw q(e,"Parenthesis ) expected");S(e),N(e)}return new c(t)}var r=e;if(r.tokenType===h.SYMBOL||r.tokenType===h.DELIMITER&&r.token in d)return i=r.token,N(r),z(r,ue(g,i)?new p(g[i]):G.includes(i)?new p(c(i,"number")):new m(i));var i=r;if('"'===i.token||"'"===i.token)return u=te(i,i.token),z(i,new p(u));{var a=i;let e,t,r,n;if("["!==a.token){var o=a;if("{"!==o.token){var s,u=o;if(u.tokenType===h.NUMBER)return i=u.token,N(u),l=Ie(i,k),i=c(i,l),new p(i);var l=u;if("("!==l.token)throw""===(s=l).token?q(s,"Unexpected end of expression"):q(s,"Value expected");if(E(l),N(l),s=C(l),")"!==l.token)throw q(l,"Parenthesis ) expected");return S(l),N(l),z(l,new $(s))}{let e;E(o);const c={};do{if(N(o),"}"!==o.token){if('"'===o.token||"'"===o.token)e=te(o,o.token);else{if(!(o.tokenType===h.SYMBOL||o.tokenType===h.DELIMITER&&o.token in d))throw q(o,"Symbol or string expected as object key");e=o.token,N(o)}if(":"!==o.token)throw q(o,"Colon : expected after object key");N(o),c[e]=C(o)}}while(","===o.token);if("}"!==o.token)throw q(o,"Comma , or bracket } expected after object value");return S(o),N(o),z(o,new L(c))}}if(E(a),N(a),"]"!==a.token){const c=re(a);if(";"===a.token){for(r=1,t=[c];";"===a.token;)N(a),"]"!==a.token&&(t[r]=re(a),r++);if("]"!==a.token)throw q(a,"End of matrix ] expected");S(a),N(a),n=t[0].items.length;for(let e=1;e<r;e++)if(t[e].items.length!==n)throw ie(a,"Column dimensions mismatch ("+t[e].items.length+" !== "+n+")");e=new f(t)}else{if("]"!==a.token)throw q(a,"End of matrix ] expected");S(a),N(a),e=c}}else S(a),N(a),e=new f([]);return z(a,e)}}(e);for(var a={"!":"factorial","'":"ctranspose"};ue(a,e.token);)n=a[r=e.token],N(e),i=[t],t=z(e,t=new s(r,n,i));return t}function z(e,t,r){let n;for(;("("===e.token||"["===e.token||"."===e.token)&&(!r||r.includes(e.token));)if(n=[],"("===e.token){if(!se(t)&&!ge(t))return t;if(E(e),N(e),")"!==e.token)for(n.push(C(e));","===e.token;)N(e),n.push(C(e));if(")"!==e.token)throw q(e,"Parenthesis ) expected");S(e),N(e),t=new j(t,n)}else if("["===e.token){if(E(e),N(e),"]"!==e.token)for(n.push(C(e));","===e.token;)N(e),n.push(C(e));if("]"!==e.token)throw q(e,"Parenthesis ] expected");S(e),N(e),t=new i(t,new a(n))}else{if(N(e),!(e.tokenType===h.SYMBOL||e.tokenType===h.DELIMITER&&e.token in d))throw q(e,"Property name expected after dot");n.push(new p(e.token)),N(e),t=new i(t,new a(n,!0))}return t}function te(e,t){let r="";for(;""!==x(e)&&x(e)!==t;)if("\\"===x(e)){b(e);const t=x(e),n=V[t];if(void 0!==n)r+=n,e.index+=1;else{if("u"!==t)throw q(e,"Bad escape character \\"+t);{const t=e.expression.slice(e.index+1,e.index+5);if(!/^[0-9A-Fa-f]{4}$/.test(t))throw q(e,"Invalid unicode character \\u"+t);r+=String.fromCharCode(parseInt(t,16)),e.index+=5}}}else r+=x(e),b(e);if(N(e),e.token!==t)throw q(e,`End of string ${t} expected`);return N(e),r}function re(e){const t=[C(e)];let r=1;for(;","===e.token;)N(e),"]"!==e.token&&";"!==e.token&&(t[r]=C(e),r++);return new f(t)}function ne(e){return e.index-e.token.length+1}function q(e,t){const r=ne(e),n=new SyntaxError(t+" (char "+r+")");return n.char=r,n}function ie(e,t){const r=ne(e),n=new SyntaxError(t+" (char "+r+")");return n.char=r,n}return u.isAlpha=function(e,t,r){return u.isValidLatinOrGreek(e)||u.isValidMathSymbol(e,r)||u.isValidMathSymbol(t,e)},u.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},u.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(t)},u.isWhitespace=function(e,t){return" "===e||"\t"===e||" "===e||"\n"===e&&0<t},u.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},u.isDigitDot=function(e){return"0"<=e&&e<="9"||"."===e},u.isDigit=function(e){return"0"<=e&&e<="9"},u.isHexDigit=function(e){return"0"<=e&&e<="9"||"a"<=e&&e<="f"||"A"<=e&&e<="F"},e.addConversion({from:"string",to:"Node",convert:u}),u}),Jf="compile",Xf=s(Jf,["typed","parse"],e=>{let{typed:t,parse:r}=e;return t(Jf,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return le(e,function(e){return r(e).compile()})}})}),Qf="evaluate",Kf=s(Qf,["typed","parse"],e=>{let{typed:t,parse:r}=e;return t(Qf,{string:function(e){var t=P();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){const t=P();return le(e,function(e){return r(e).compile().evaluate(t)})},"Array | Matrix, Map | Object":function(e,t){return le(e,function(e){return r(e).compile().evaluate(t)})}})}),ep=s("Parser",["evaluate","parse"],e=>{let{evaluate:t,parse:a}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:P(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return t(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){var e=this.scope;if(e instanceof I)return e.wrappedObject;var t={};for(const r of e.keys())D(t,r,e.get(r));return t},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,t){if(function(t){if(0!==t.length){for(let e=0;e<t.length;e++){var r=t.charAt(e-1),n=t.charAt(e),i=t.charAt(e+1);if(!(a.isAlpha(n,r,i)||0<e&&a.isDigit(n)))return}return 1}}(e))return this.scope.set(e,t),t;throw new Error(`Invalid variable name: '${e}'. Variable names must follow the specified rules.`)},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n.prototype.toJSON=function(){const e={mathjs:"Parser",variables:{},functions:{}};for(const[r,n]of this.scope)if(X(n)){if("function"!=typeof(t=n)||"string"!=typeof t.syntax||"string"!=typeof t.expr)throw new Error("Cannot serialize external function "+r);e.functions[r]=n.syntax+" = "+n.expr}else e.variables[r]=n;var t;return e},n.fromJSON=function(e){const r=new n;return Object.entries(e.variables).forEach(e=>{var[e,t]=e;return r.set(e,t)}),Object.entries(e.functions).forEach(e=>{var[,e]=e;return r.evaluate(e)}),r},n},{isClass:!0});const tp=s("parser",["typed","Parser"],e=>{let{typed:t,Parser:r}=e;return t("parser",{"":function(){return new r}})}),rp=s("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtractScalar","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],e=>{let{typed:t,matrix:r,abs:C,addScalar:g,divideScalar:T,multiplyScalar:B,subtractScalar:y,larger:F,equalScalar:D,unaryMinus:O,DenseMatrix:x,SparseMatrix:_,Spa:z}=e;return t("lup",{DenseMatrix:n,SparseMatrix:function(n){{var o=n,s,u,l,c;const f=o._size[0],p=o._size[1],m=Math.min(f,p),h=o._values,d=o._index,g=o._ptr,y=[],x=[],b=[],v=[f,m],w=[],N=[],A=[],E=[m,p];let e,r,t;const S=[],M=[];for(e=0;e<f;e++)S[e]=e,M[e]=e;for(r=0;r<p;r++){const o=new z,p=(r<f&&(b.push(y.length),y.push(1),x.push(r)),A.push(w.length),g[r]),m=g[r+1];for(t=p;t<m;t++)e=d[t],o.set(S[e],h[t]);0<r&&o.forEach(0,r-1,function(r,n){_._forEachRow(r,y,x,b,function(e,t){r<e&&o.accumulate(e,O(B(t,n)))})});let n=r,i=o.get(r),a=C(i);o.forEach(r+1,f-1,function(e,t){var r=C(t);F(r,a)&&(n=e,a=r,i=t)}),r!==n&&(_._swapRows(r,n,v[1],y,x,b),_._swapRows(r,n,E[1],w,N,A),o.swap(r,n),s=r,u=n,c=l=void 0,l=M[s],c=M[u],S[l]=u,S[c]=s,M[s]=c,M[u]=l),o.forEach(0,f-1,function(e,t){e<=r?(w.push(t),N.push(e)):(t=T(t,i),D(t,0)||(y.push(t),x.push(e)))})}return A.push(w.length),b.push(y.length),{L:new _({values:y,index:x,ptr:b,size:v}),U:new _({values:w,index:N,ptr:A,size:E}),p:S,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}}},Array:function(e){const t=n(r(e));return{L:t.L.valueOf(),U:t.U.valueOf(),p:t.p}}});function n(n){const i=n._size[0],e=n._size[1];var t=Math.min(i,e);const a=ee(n._data),r=[],o=[i,t],s=[],u=[t,e];let l,c,f;const p=[];for(l=0;l<i;l++)p[l]=l;for(c=0;c<e;c++){if(0<c)for(l=0;l<i;l++){const n=Math.min(l,c);let e=0;for(f=0;f<n;f++)e=g(e,B(a[l][f],a[f][c]));a[l][c]=y(a[l][c],e)}let e=c,t=0,r=0;for(l=c;l<i;l++){const i=a[l][c],g=C(i);F(g,t)&&(e=l,t=g,r=i)}if(c!==e&&(p[c]=[p[e],p[e]=p[c]][0],x._swapRows(c,e,a)),c<i)for(l=c+1;l<i;l++){const n=a[l][c];D(n,0)||(a[l][c]=T(a[l][c],r))}}for(c=0;c<e;c++)for(l=0;l<i;l++)0===c&&(l<e&&(s[l]=[]),r[l]=[]),l<c?(l<e&&(s[l][c]=a[l][c]),c<i&&(r[l][c]=0)):l!==c?(l<e&&(s[l][c]=0),c<i&&(r[l][c]=a[l][c])):(l<e&&(s[l][c]=a[l][c]),c<i&&(r[l][c]=1));const m=new x({data:r,size:o}),h=new x({data:s,size:u}),d=[];for(l=0,t=p.length;l<t;l++)d[p[l]]=l;return{L:m,U:h,p:d,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}}}),np=s("qr",["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtractScalar","complex"],e=>{let{typed:t,matrix:r,zeros:f,identity:p,isZero:m,equal:h,sign:d,sqrt:g,conj:y,unaryMinus:x,addScalar:b,divideScalar:v,multiplyScalar:w,subtractScalar:N,complex:i}=e;return gn(t("qr",{DenseMatrix:n,SparseMatrix:function(e){throw new Error("qr not implemented for sparse matrices yet")},Array:function(e){const t=n(r(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:a});function a(t){const r=t._size[0],n=t._size[1],e=p([r],"dense"),i=e._data,a=t.clone(),o=a._data;let s,u,l;const c=f([r],"");for(l=0;l<Math.min(n,r);++l){const t=o[l][l],f=x(h(t,0)?1:d(t)),p=y(f);let e=0;for(s=l;s<r;s++)e=b(e,w(o[s][l],y(o[s][l])));const a=w(f,g(e));if(!m(a)){const f=N(t,a);for(c[l]=1,s=l+1;s<r;s++)c[s]=v(o[s][l],f);const m=x(y(v(f,a)));let e;for(u=l;u<n;u++){for(e=0,s=l;s<r;s++)e=b(e,w(y(c[s]),o[s][u]));for(e=w(e,m),s=l;s<r;s++)o[s][u]=w(N(o[s][u],w(c[s],e)),p)}for(s=0;s<r;s++){for(e=0,u=l;u<r;u++)e=b(e,w(i[s][u],c[u]));for(e=w(e,m),u=l;u<r;++u)i[s][u]=v(N(i[s][u],w(e,y(c[u]))),p)}}}return{Q:e,R:a,toString:function(){return"Q: "+this.Q.toString()+"\nR: "+this.R.toString()}}}function n(r){const e=a(r),n=e.R._data;if(0<r._data.length){const r="Complex"===n[0][0].type?i(0):0;for(let t=0;t<n.length;++t)for(let e=0;e<t&&e<(n[0]||[]).length;++e)n[t][e]=r}return e}});function ip(e,t,r,n,i,a,o){let s=0;for(r[o]=e;0<=s;){const e=r[o+s],u=r[n+e];-1===u?(s--,a[t++]=e):(r[n+e]=r[i+u],r[o+ ++s]=u)}return t}const ap=s("csAmd",["add","multiply","transpose"],e=>{let{add:H,multiply:G,transpose:V}=e;return function(i,e){if(!e||i<=0||3<i)return null;var t=e._size,I=t[0],a=t[1];let o=0,k=Math.max(16,10*Math.sqrt(a));t=function(n,i,e,t,a){var o=V(i);if(1===n&&t===e)return H(i,o);if(2!==n)return G(o,i);{const n=o._index,H=o._ptr;let r=0;for(let t=0;t<e;t++){let e=H[t];if(H[t]=r,!(H[t+1]-e>a))for(const i=H[t+1];e<i;e++)n[r++]=n[e]}return H[e]=r,i=V(o),G(o,i)}}(i,e,I,a,k=Math.min(a-2,k));{var R=W;const n=t._values,z=t._index,q=t._ptr,$=t._size[1];let r=0;for(let t=0;t<$;t++){let e=q[t];for(q[t]=r;e<q[t+1];e++)R(z[e],t,n?n[e]:1,null)&&(z[r]=z[e],n&&(n[r]=n[e]),r++)}q[$]=r,z.splice(r,z.length-r),n&&n.splice(r,n.length-r)}const s=t._index,u=t._ptr;let P=u[a];const r=[],l=[],c=a+1,f=2*(a+1),p=3*(a+1),m=4*(a+1),h=5*(a+1),d=6*(a+1),g=7*(a+1),y=r;let x,b,v,w,U,N,j,A,E,S,M,C,L,T,B,F,D=function(t,r,n,i,a,o,s,u,l,c,f){for(let e=0;e<t;e++)n[0+e]=r[e+1]-r[e];for(let e=n[0+t]=0;e<=t;e++)n[i+e]=-1,a[e]=-1,n[o+e]=-1,n[s+e]=-1,n[u+e]=1,n[l+e]=1,n[c+e]=0,n[f+e]=n[0+e];var e=Z(0,0,n,l,t);return n[c+t]=-2,r[t]=-1,n[l+t]=0,e}(a,u,l,p,y,f,g,c,d,m,h),O=function(t,r,n,i,a,o,s,u,l,c,f){let p=0;for(let e=0;e<t;e++){var m=n[i+e];if(0===m)n[a+e]=-2,p++,r[e]=-1,n[o+e]=0;else if(s<m)n[u+e]=0,n[a+e]=-1,p++,r[e]=-t-2,n[u+t]++;else{const t=n[l+m];-1!==t&&(c[t]=e),n[f+e]=n[l+m],n[l+m]=e}}return p}(a,u,l,h,m,d,k,c,p,y,f),_=0;for(;O<a;){for(v=-1;_<a&&-1===(v=l[p+_]);_++);-1!==l[f+v]&&(y[l[f+v]]=-1),l[p+_]=l[f+v];const i=l[m+v];let e=l[c+v],t=(O+=e,0),r=(l[c+v]=-e,u[v]);const W=0===i?r:P;let n=W;for(w=1;w<=i+1;w++){for(A=w>i?(N=v,j=r,l[0+v]-i):(N=s[r++],j=u[N],l[0+N]),U=1;U<=A;U++)x=s[j++],(E=l[c+x])<=0||(t+=E,l[c+x]=-E,s[n++]=x,-1!==l[f+x]&&(y[l[f+x]]=y[x]),-1!==y[x]?l[f+y[x]]=l[f+x]:l[p+l[h+x]]=l[f+x]);N!==v&&(u[N]=-v-2,l[d+N]=0)}for(0!==i&&(P=n),l[h+v]=t,u[v]=W,l[0+v]=n-W,l[m+v]=-2,D=Z(D,o,l,d,a),S=W;S<n;S++)if(x=s[S],!((M=l[m+x])<=0)){E=-l[c+x];const i=D-E;for(r=u[x],C=u[x]+M-1;r<=C;r++)N=s[r],l[d+N]>=D?l[d+N]-=E:0!==l[d+N]&&(l[d+N]=l[h+N]+i)}for(S=W;S<n;S++){for(x=s[S],L=(C=u[x])+l[m+x]-1,T=C,B=0,F=0,r=C;r<=L;r++)if(N=s[r],0!==l[d+N]){const i=l[d+N]-D;0<i?(F+=i,s[T++]=N,B+=N):(u[N]=-v-2,l[d+N]=0)}l[m+x]=T-C+1;const i=T,Z=C+l[0+x];for(r=1+L;r<Z;r++){b=s[r];const i=l[c+b];i<=0||(F+=i,s[T++]=b,B+=b)}0===F?(u[x]=-v-2,E=-l[c+x],t-=E,e+=E,O+=E,l[c+x]=0,l[m+x]=-1):(l[h+x]=Math.min(l[h+x],F),s[T]=s[i],s[i]=s[C],s[C]=v,l[0+x]=T-C+1,B=(B<0?-B:B)%a,l[f+x]=l[g+B],l[g+B]=x,y[x]=B)}for(l[h+v]=t,o=Math.max(o,t),D=Z(D+o,o,l,d,a),S=W;S<n;S++)if(x=s[S],!(0<=l[c+x]))for(B=y[x],x=l[g+B],l[g+B]=-1;-1!==x&&-1!==l[f+x];x=l[f+x],D++){for(A=l[0+x],M=l[m+x],r=u[x]+1;r<=u[x]+A-1;r++)l[d+s[r]]=D;let t=x;for(b=l[f+x];-1!==b;){let e=l[0+b]===A&&l[m+b]===M;for(r=u[b]+1;e&&r<=u[b]+A-1;r++)l[d+s[r]]!==D&&(e=0);e?(u[b]=-x-2,l[c+x]+=l[c+b],l[c+b]=0,l[m+b]=-1,b=l[f+b],l[f+t]=b):(t=b,b=l[f+b])}}for(r=W,S=W;S<n;S++)x=s[S],(E=-l[c+x])<=0||(l[c+x]=E,F=l[h+x]+t-E,F=Math.min(F,a-O-E),-1!==l[p+F]&&(y[l[p+F]]=x),l[f+x]=l[p+F],y[x]=-1,l[p+F]=x,_=Math.min(_,F),l[h+x]=F,s[r++]=x);l[c+v]=e,0==(l[0+v]=r-W)&&(u[v]=-1,l[d+v]=0),0!==i&&(P=r)}for(x=0;x<a;x++)u[x]=-u[x]-2;for(b=0;b<=a;b++)l[p+b]=-1;for(b=a;0<=b;b--)0<l[c+b]||(l[f+b]=l[p+u[b]],l[p+u[b]]=b);for(N=a;0<=N;N--)l[c+N]<=0||-1!==u[N]&&(l[f+N]=l[p+u[N]],l[p+u[N]]=N);for(v=0,x=0;x<=a;x++)-1===u[x]&&(v=ip(x,v,l,p,f,r,d));return r.splice(r.length-1,1),r};function Z(e,t,r,n,i){if(e<2||e+t<0){for(let e=0;e<i;e++)0!==r[n+e]&&(r[n+e]=1);e=2}return e}function W(e,t){return e!==t}});const op=s("csCounts",["transpose"],e=>{let S=e["transpose"];return function(e,t,r,n){if(!e||!t||!r)return null;var i=e._size,a=i[0],o=i[1];let s,u,l,c,f,p,m;const h=4*o+(n?o+a+1:0),d=[],g=o,y=2*o,x=3*o,b=4*o,v=5*o+1;for(l=0;l<h;l++)d[l]=-1;const w=[],N=S(e),A=N._index,E=N._ptr;for(l=0;l<o;l++)for(u=r[l],w[u]=-1===d[x+u]?1:0;-1!==u&&-1===d[x+u];u=t[u])d[x+u]=l;if(n){for(l=0;l<o;l++)d[r[l]]=l;for(s=0;s<a;s++){for(l=o,p=E[s],m=E[s+1],f=p;f<m;f++)l=Math.min(l,d[A[f]]);d[v+s]=d[b+l],d[b+l]=s}}for(s=0;s<o;s++)d[0+s]=s;for(l=0;l<o;l++){for(-1!==t[u=r[l]]&&w[t[u]]--,c=n?d[b+l]:u;-1!==c;c=n?d[v+c]:-1)for(f=E[c];f<E[c+1];f++){const e=function(e,t,r,n,i,a,o){let s,u,l,c=0;if(e<=t||r[n+t]<=r[i+e])return-1;if(r[i+e]=r[n+t],i=r[a+e],r[a+e]=t,-1===i)c=1,l=e;else{for(c=2,l=i;l!==r[o+l];l=r[o+l]);for(s=i;s!==l;s=u)u=r[o+s],r[o+s]=l}return{jleaf:c,q:l}}(s=A[f],u,d,x,g,y,0);1<=e.jleaf&&w[u]++,2===e.jleaf&&w[e.q]--}-1!==t[u]&&(d[0+u]=t[u])}for(u=0;u<o;u++)-1!==t[u]&&(w[t[u]]+=w[u]);return w}}),sp=s("csSqr",["add","multiply","transpose"],e=>{var{add:e,multiply:t,transpose:r}=e;const s=ap({add:e,multiply:t,transpose:r}),u=op({transpose:r});return function(e,t,r){const n=t._ptr,i=t._size[1];let a;const o={};if(o.q=s(e,t),e&&!o.q)return null;if(r){const r=e?function(n,t){n._values;const i=n._index,a=n._ptr,e=n._size,r=n._datatype,o=e[0],s=e[1],u=[],l=[];let c=0;for(let e=0;e<s;e++){l[e]=c;const f=t?t[e]:e;for(let e=a[f],t=a[f+1],r=e;r<t;r++){const n=i[r];u[c]=n,c++}}return l[s]=c,n.createSparseMatrix({values:null,index:u,ptr:l,size:[o,s],datatype:r})}(t,o.q):t,n=(o.parent=function(e){if(!e)return null;const i=e._index,a=e._ptr,t=e._size,r=t[0],o=t[1],s=[],u=[],l=o;let c,f;for(c=0;c<r;c++)u[l+c]=-1;for(let n=0;n<o;n++){s[n]=-1,u[0+n]=-1;for(let e=a[n],t=a[n+1],r=e;r<t;r++){const a=i[r];for(c=u[l+a];-1!==c&&c<n;c=f)f=u[0+c],u[0+c]=n,-1===f&&(s[c]=n);u[l+a]=n}}return s}(r),function(e,t){if(!e)return null;let r,n=0;const i=[],a=[],o=t,s=2*t;for(r=0;r<t;r++)a[0+r]=-1;for(r=t-1;0<=r;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r<t;r++)-1===e[r]&&(n=ip(r,n,a,0,o,i,s));return i}(o.parent,i));if(o.cp=u(r,o.parent,n,1),r&&o.parent&&o.cp&&function(e,t){var r=e._ptr,n=e._index,e=e._size,i=e[0],a=e[1];t.pinv=[],t.leftmost=[];const o=t.parent,s=t.pinv,u=t.leftmost,l=[],c=i,f=i+a,p=i+2*a;let m,h,d,g,y;for(h=0;h<a;h++)l[c+h]=-1,l[f+h]=-1,l[p+h]=0;for(m=0;m<i;m++)u[m]=-1;for(h=a-1;0<=h;h--)for(g=r[h],y=r[h+1],d=g;d<y;d++)u[n[d]]=h;for(m=i-1;0<=m;m--)(s[m]=-1)!==(h=u[m])&&(0==l[p+h]++&&(l[f+h]=m),l[0+m]=l[c+h],l[c+h]=m);for(t.lnz=0,t.m2=i,h=0;h<a;h++)if(m=l[c+h],t.lnz++,m<0&&(m=t.m2++),s[m]=h,!(--p[h]<=0)){t.lnz+=l[p+h];const e=o[h];-1!==e&&(0===l[p+e]&&(l[f+e]=l[f+h]),l[0+l[f+h]]=l[c+e],l[c+e]=l[0+m],l[p+e]+=l[p+h])}for(m=0;m<i;m++)s[m]<0&&(s[m]=h++);return 1}(r,o))for(o.unz=0,a=0;a<i;a++)o.unz+=o.cp[a]}else o.unz=4*n[i]+i,o.lnz=o.unz;return o}});function up(e,t){e[t]=-e[t]-2}function lp(e){return e<0?-e-2:e}const cp=s("csSpsolve",["divideScalar","multiply","subtract"],e=>{let{divideScalar:x,multiply:b,subtract:v}=e;return function(t,r,p,n,i,a,o){var s=t._values,u=t._index,l=t._ptr,c=t._size[1],e=r._values,f=r._index,m=r._ptr;let h,d,g,y;t=function(e,t,r,n){var i=e._ptr,a=e._size,o=t._index,t=t._ptr,s=a[1];let u,l,c,f=s;for(l=t[p],c=t[p+1],u=l;u<c;u++){const t=o[u];i[t]<0||(f=function(t,r,n,i,a){var o=r._index,s=r._ptr,u=r._size[1];let l,c,f,p=0;for(i[0]=t;0<=p;){t=i[p];const r=a?a[t]:t;s[t]<0||(up(s,t),i[u+p]=r<0?0:lp(s[r]));let e=1;for(c=i[u+p],f=r<0?0:lp(s[r+1]);c<f;c++)if(!(s[l=o[c]]<0)){i[u+p]=c,i[++p]=l,e=0;break}e&&(p--,i[--n]=t)}return n}(t,e,f,r,n))}for(u=f;u<s;u++)up(i,r[u]);return f}(t,r,n,a);for(h=t;h<c;h++)i[n[h]]=0;for(d=m[p],g=m[p+1],h=d;h<g;h++)i[f[h]]=e[h];for(let e=t;e<c;e++){const r=n[e],p=a?a[r]:r;if(!(p<0))for(d=l[p],g=l[p+1],i[r]=x(i[r],s[o?d:g-1]),h=o?d+1:d,y=o?g:g-1;h<y;h++){const t=u[h];i[t]=v(i[t],b(s[h],i[r]))}}return t}}),fp=s("csLu",["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],e=>{let{abs:A,divideScalar:E,multiply:S,subtract:t,larger:M,largerEq:C,SparseMatrix:T}=e;const B=cp({divideScalar:E,multiply:S,subtract:t});return function(n,e,i){if(!n)return null;var a=n._size[1];let o,s=100,u=100;e&&(o=e.q,s=e.lnz||s,u=e.unz||u);const l=[],c=[],f=[],p=new T({values:l,index:c,ptr:f,size:[a,a]}),m=[],h=[],d=[],g=new T({values:m,index:h,ptr:d,size:[a,a]}),y=[];let x,b;const v=[],w=[];for(x=0;x<a;x++)v[x]=0,y[x]=-1,f[x+1]=0;s=0;for(let r=u=0;r<a;r++){f[r]=s,d[r]=u;const T=o?o[r]:r,g=B(p,n,T,w,v,y,1);let e=-1,t=-1;for(b=g;b<a;b++)if(x=w[b],y[x]<0){const n=A(v[x]);M(n,t)&&(t=n,e=x)}else h[u]=y[x],m[u++]=v[x];if(-1===e||t<=0)return null;y[T]<0&&C(A(v[T]),S(t,i))&&(e=T);var N=v[e];for(h[u]=r,m[u++]=N,y[e]=r,c[s]=e,l[s++]=1,b=g;b<a;b++)x=w[b],y[x]<0&&(c[s]=x,l[s++]=E(v[x],N)),v[x]=0}for(f[a]=s,d[a]=u,b=0;b<s;b++)c[b]=y[c[b]];return l.splice(s,l.length-s),c.splice(s,c.length-s),m.splice(u,m.length-u),h.splice(u,h.length-u),{L:p,U:g,pinv:y}}}),pp=s("slu",["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],e=>{let{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:l,SparseMatrix:c}=e;const f=sp({add:n,multiply:i,transpose:a}),p=fp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:l,SparseMatrix:c});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!v(t)||t<0||3<t)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||1<r)throw new Error("Partial pivoting threshold must be a number from 0 to 1");t=f(t,e,!1),e=p(e,t,r);return{L:e.L,U:e.U,p:e.pinv,q:t.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})});function mp(e,t){let r;const n=t.length,i=[];if(e)for(r=0;r<n;r++)i[e[r]]=t[r];else for(r=0;r<n;r++)i[r]=t[r];return i}const hp="lusolve",dp=s(hp,["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],e=>{let{typed:t,matrix:r,lup:n,slu:i,usolve:s,lsolve:u,DenseMatrix:a}=e;const l=Cu({DenseMatrix:a});return t(hp,{"Array, Array | Matrix":function(e,t){e=r(e);e=n(e);return o(e.L,e.U,e.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){e=n(e);return o(e.L,e.U,e.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){e=n(e);return o(e.L,e.U,e.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){e=i(e,r,n);return o(e.L,e.U,e.p,e.q,t)},"Object, Array | Matrix":function(e,t){return o(e.L,e.U,e.p,e.q,t)}});function c(e){if(_(e))return e;if(b(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function o(e,t,r,n,i){e=c(e),t=c(t),r&&((i=l(e,i,!0))._data=mp(r,i._data));const a=u(e,i),o=s(t,a);return n&&(o._data=mp(n,o._data)),o}}),gp="polynomialRoot",yp=s(gp,["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],e=>{let{typed:t,isZero:h,equalScalar:d,add:g,subtract:y,multiply:x,divide:b,sqrt:v,unaryMinus:w,cbrt:N,typeOf:A,im:E,re:S}=e;return t(gp,{"number|Complex, ...number|Complex":(e,t)=>{const r=[e,...t];for(;0<r.length&&h(r[r.length-1]);)r.pop();if(r.length<2)throw new RangeError(`Polynomial [${e}, ${t}] must have a non-zero non-constant coefficient`);switch(r.length){case 2:return[w(b(r[0],r[1]))];case 3:{const[e,t,h]=r,g=x(2,h),N=x(t,t),A=x(4,h,e);if(d(N,A))return[b(w(t),g)];const E=v(y(N,A));return[b(y(E,t),g),b(y(w(E),t),g)]}case 4:{const[e,t,h,i]=r,a=w(x(3,i)),o=x(h,h),s=x(3,i,t),u=g(x(2,h,h,h),x(27,i,i,e)),l=x(9,i,h,t);if(d(o,s)&&d(u,l))return[b(h,a)];const c=y(o,s),f=y(u,l),p=g(x(18,i,h,t,e),x(h,h,t,t)),m=g(x(4,h,h,h,e),x(4,i,t,t,t),x(27,i,i,e,e));return d(p,m)?[b(y(x(4,i,h,t),g(x(9,i,i,e),x(h,h,h))),x(i,c)),b(y(x(9,i,e),x(h,t)),x(2,c))]:(n=d(o,s)?f:b(g(f,v(y(x(f,f),x(4,c,c,c)))),2),N(n,!0).toArray().map(e=>b(g(h,e,b(c,e)),a)).map(e=>"Complex"===A(e)&&d(S(e),S(e)+E(e))?S(e):e));var n}default:throw new RangeError("only implemented for cubic or lower-order polynomials, not "+r)}}})}),xp=s("Help",["evaluate"],e=>{let o=e["evaluate"];function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return n.prototype.type="Help",n.prototype.isHelp=!0,n.prototype.toString=function(){const r=this.doc||{};let n="\n";if(r.name&&(n+="Name: "+r.name+"\n\n"),r.category&&(n+="Category: "+r.category+"\n\n"),r.description&&(n+="Description:\n "+r.description+"\n\n"),r.syntax&&(n+="Syntax:\n "+r.syntax.join("\n ")+"\n\n"),r.examples){n+="Examples:\n";let t=!1;var e=o("config()"),i={config:e=>(t=!0,o("config(newConfig)",{newConfig:e}))};for(let t=0;t<r.examples.length;t++){var a=r.examples[t];let e;n+=" "+a+"\n";try{e=o(a,i)}catch(r){e=r}void 0===e||J(e)||(n+=" "+S(e,{precision:14})+"\n")}n+="\n",t&&o("config(originalConfig)",{originalConfig:e})}return r.mayThrow&&r.mayThrow.length&&(n+="Throws: "+r.mayThrow.join(", ")+"\n\n"),r.seealso&&r.seealso.length&&(n+="See also: "+r.seealso.join(", ")+"\n"),n},n.prototype.toJSON=function(){const e=ee(this.doc);return e.mathjs="Help",e},n.fromJSON=function(t){const r={};return Object.keys(t).filter(e=>"mathjs"!==e).forEach(e=>{r[e]=t[e]}),new n(r)},n.prototype.valueOf=n.prototype.toString,n},{isClass:!0}),bp=s("Chain",["?on","math","typed"],e=>{let{on:t,math:r,typed:n}=e;function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");Be(e)?this.value=e.value:this.value=e}function a(e,t){_e(i.prototype,e,function(){var e=t();if("function"==typeof e)return o(e)})}function o(r){return function(){if(0===arguments.length)return new i(r(this.value));const t=[this.value];for(let e=0;e<arguments.length;e++)t[e+1]=arguments[e];if(n.isTypedFunction(r)){const e=n.resolve(r,t);if(1===e.params.length)throw new Error("chain function "+r.name+" cannot match rest parameter between chain value and additional arguments.");return new i(e.implementation.apply(r,t))}return new i(r.apply(r,t))}}i.prototype.type="Chain",i.prototype.isChain=!0,i.prototype.done=function(){return this.value},i.prototype.valueOf=function(){return this.value},i.prototype.toString=function(){return S(this.value)},i.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},i.fromJSON=function(e){return new i(e.value)};const s={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return(i.createProxy=function(e,t){if("string"==typeof e)"function"==typeof t&&(i.prototype[e]=o(t));else for(const t in e)ue(e,t)&&void 0===s[t]&&a(t,()=>e[t])})(r),t&&t("import",function(e,t,r){r||a(e,t)}),i},{isClass:!0}),vp={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},wp={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},Np={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","bigint","complex","fraction","index","matrix","string","unit"]},bigint:{name:"bigint",category:"Construction",syntax:["bigint(x)"],description:"Create a bigint, an integer with an arbitrary number of digits, from a number or string.",examples:["123123123123123123 # a large number will lose digits",'bigint("123123123123123123")','bignumber(["1", "3", "5"])'],seealso:["boolean","bignumber","number","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[1:2, 1:2] = 1","B = [1, 2, 3]","B[B>1 and B<3]"],seealso:["bignumber","boolean","complex","matrix","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","bigint","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:vp,E:vp,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:wp,PI:wp,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant. Deprecated in favor of coulombConstant",examples:["coulombConstant"]},coulombConstant:{description:"Coulomb's constant",examples:["coulombConstant"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Bohr magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Bohr radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},leafCount:{name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},polynomialRoot:{name:"polynomialRoot",category:"Algebra",syntax:["x=polynomialRoot(-6, 3)","x=polynomialRoot(4, -4, 1)","x=polynomialRoot(-8, 12, -6, 1)"],description:"Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",examples:["a = polynomialRoot(-6, 11, -6, 1)"],seealso:["cbrt","sqrt"]},resolve:{name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},simplifyConstant:{name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConstant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},simplifyCore:{name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","simplifyConstant","evaluate"]},symbolicEqual:{name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)","ceil(x, n)","ceil(unit, valuelessUnit)","ceil(unit, n, valuelessUnit)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)","ceil(3.241cm, cm)","ceil(3.241cm, 2, cm)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)","fix(x, n)","fix(unit, valuelessUnit)","fix(unit, n, valuelessUnit)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)","fix(3.241cm, cm)","fix(3.241cm, 2, cm)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)","floor(x, n)","floor(unit, valuelessUnit)","floor(unit, n, valuelessUnit)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)","floor(3.241cm, cm)","floor(3.241cm, 2, cm)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenuse of a list with values.",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","pow([[1, 2], [4, 3]], 2)","pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)","round(unit, valuelessUnit)","round(unit, n, valuelessUnit)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)","round(3.241cm, 2, cm)","round([3.2, 3.8, -4.7])"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>0, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[33, 24], [48, 57]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)","invmod(7, 13)","invmod(15151, 15122)"],seealso:["gcd","xgcd"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate(expression, scope)","evaluate([expr1, expr2, expr3, ...])","evaluate([expr1, expr2, expr3, ...], scope)"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(16)")','evaluate("2 inch to cm")','evaluate("sin(x * pi)", { "x": 1/2 })','evaluate(["width=2", "height=4","width*height"])'],seealso:["parser","parse","compile"]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},parse:{name:"parse",category:"Expression",syntax:["parse(expr)","parse(expr, options)","parse([expr1, expr2, expr3, ...])","parse([expr1, expr2, expr3, ...], options)"],description:"Parse an expression. Returns a node tree, which can be evaluated by invoking node.evaluate() or transformed into a functional object via node.compile().",examples:['node1 = parse("sqrt(3^2 + 4^2)")',"node1.evaluate()","code1 = node1.compile()","code1.evaluate()","scope = {a: 3, b: 4}",'node2 = parse("a * b")',"node2.evaluate(scope)","code2 = node2.compile()","code2.evaluate(scope)"],seealso:["parser","evaluate","compile"]},parser:{name:"parser",category:"Expression",syntax:["parser()"],description:"Create a parser object that keeps a context of variables and their values, allowing the evaluation of expressions in that context.",examples:["myParser = parser()",'myParser.evaluate("sqrt(3^2 + 4^2)")','myParser.set("x", 3)','myParser.evaluate("y = x + 3")','myParser.evaluate(["y = x + 3", "y = y + 1"])','myParser.get("y")'],seealso:["evaluate","parse","compile"]},compile:{name:"compile",category:"Expression",syntax:["compile(expr) ","compile([expr1, expr2, expr3, ...])"],description:"Parse and compile an expression. Returns a an object with a function evaluate([scope]) to evaluate the compiled expression.",examples:['code1 = compile("sqrt(3^2 + 4^2)")',"code1.evaluate() ",'code2 = compile("a * b")',"code2.evaluate({a: 3, b: 4})"],seealso:["parser","parse","evaluate"]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},nullish:{name:"nullish",category:"Logical",syntax:["x ?? y","nullish(x, y)"],description:"Nullish coalescing operator. Returns the right-hand operand when the left-hand operand is null or undefined, and otherwise returns the left-hand operand.",examples:["null ?? 42","undefined ?? 42","0 ?? 42","false ?? 42","null ?? undefined ?? 42"],seealso:["and","or","not"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},mapSlices:{name:"mapSlices",category:"Matrix",syntax:["mapSlices(A, dim, callback)"],description:"Generate a matrix one dimension less than A by applying callback to each slice of A along dimension dim.",examples:["A = [[1, 2], [3, 4]]","mapSlices(A, 1, sum)","mapSlices(A, 2, prod)"],seealso:["map","forEach"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["A = [1, 2, 4, 7, 0]","diff(A)","diff(A, 1)","B = [[1, 2], [3, 4]]","diff(B)","diff(B, 1)","diff(B, 2)","diff(B, bignumber(2))","diff([[1, 2], matrix([3, 4])], 2)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and optionally eigenvectors of a square matrix",examples:["eigs([[5, 2.3], [2.3, 1]])","eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the Kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["matrixFromFunction(size, fn)","matrixFromFunction(size, fn, format)","matrixFromFunction(size, fn, format, datatype)","matrixFromFunction(size, format, fn)","matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["matrixFromRows(...arr)","matrixFromRows(row1, row2)","matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["matrixFromColumns(...arr)","matrixFromColumns(row1, row2)","matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)","map(x, y, ..., callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.",examples:["map([1, 2, 3], square)","map([1, 2], [3, 4], f(a,b) = a + b)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1, compareText)',"arr = [5, 2, 1]","partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]","arr","partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]","arr"],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"range(1m, 1m, 3m)","a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])","reshape([1, 2, 3, 4], [-1, 2])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"], "natural")',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional Fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse Fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},sylvester:{name:"sylvester",category:"Algebra",syntax:["sylvester(A,B,C)"],description:"Solves the real-valued Sylvester equation AX+XB=C for X",examples:["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])","A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]","sylvester(A, B, C)"],seealso:["schur","lyap"]},schur:{name:"schur",category:"Algebra",syntax:["schur(A)"],description:"Performs a real Schur decomposition of the real matrix A = UTU'",examples:["schur([[1, 0], [-4, 3]])","A = [[1, 0], [-4, 3]]","schur(A)"],seealso:["lyap","sylvester"]},lyap:{name:"lyap",category:"Algebra",syntax:["lyap(A,Q)"],description:"Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",examples:["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])","A = [[-2, 0], [1, -4]]","Q = [[3, 1], [1, 3]]","lyap(A,Q)"],seealso:["schur","sylvester"]},solveODE:{name:"solveODE",category:"Numeric",syntax:["solveODE(func, tspan, y0)","solveODE(func, tspan, y0, options)"],description:"Numerical Integration of Ordinary Differential Equations.",examples:["f(t,y) = y","tspan = [0, 4]","solveODE(f, tspan, 1)","solveODE(f, tspan, [1, 2])",'solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })'],seealso:["derivative","simplifyCore"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},lgamma:{name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not. Comparing a value with NaN returns false.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not. Comparing a value with NaN returns false.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},zpk2tf:{name:"zpk2tf",category:"Signal",syntax:["zpk2tf(z, p, k)"],description:"Compute the transfer function of a zero-pole-gain model.",examples:["zpk2tf([1, 2], [-1, -2], 1)","zpk2tf([1, 2], [-1, -2])","zpk2tf([1 - 3i, 2 + 2i], [-1, -2])"],seealso:[]},freqz:{name:"freqz",category:"Signal",syntax:["freqz(b, a)","freqz(b, a, w)"],description:"Calculates the frequency response of a filter given its numerator and denominator coefficients.",examples:["freqz([1, 2], [1, 2, 3])","freqz([1, 2], [1, 2, 3], [0, 1])","freqz([1, 2], [1, 2, 3], 512)"],seealso:[]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},zeta:{name:"zeta",category:"Special",syntax:["zeta(s)"],description:"Compute the Riemann Zeta Function using an infinite series and Riemann's Functional Equation for the entire complex plane",examples:["zeta(0.2)","zeta(-0.5)","zeta(4)"],seealso:[]},cumsum:{name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dimension)"],description:"Compute the maximum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dimension)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dimension)"],description:"Compute the minimum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, dimension)","std(A, normalization)","std(A, dimension, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)","sum(A, dimension)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, dimension)","variance(A, normalization)","variance(A, dimension, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},corr:{name:"corr",category:"Statistics",syntax:["corr(A,B)"],description:"Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.",examples:["corr([2, 4, 6, 8],[1, 2, 3, 6])","corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the inverse hyperbolic tangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the inverse hyperbolic cosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},toBest:{name:"toBest",category:"Units",syntax:["toBest(x)","toBest(x, unitList)","toBest(x, unitList, options)"],description:"Converts to the most appropriate display unit.",examples:['toBest(unit(5000, "m"))','toBest(unit(3500000, "W"))','toBest(unit(0.000000123, "A"))','toBest(unit(10, "m"), "cm")','toBest(unit(10, "m"), "mm,km", {offset: 1.5})'],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables, and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},print:{name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $1, $2, $3", [6, 9, 4])'],seealso:["format"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "bigint")','numeric("4", "BigNumber")','numeric("4", "Fraction")','numeric(4, "Fraction")','numeric(fraction(2, 5), "number")'],seealso:["number","bigint","fraction","bignumber","string","format"]}},Ap=s("help",["typed","mathWithTransform","Help"],e=>{let{typed:t,mathWithTransform:i,Help:a}=e;return t("help",{any:function(e){let t,r=e;if("string"!=typeof e)for(t in i)if(ue(i,t)&&e===i[t]){r=t;break}var n=h(Np,r);if(n)return new a(n);{const e="function"==typeof r?r.name:r;throw new Error('No documentation found on "'+e+'"')}}})}),Ep=s("chain",["typed","Chain"],e=>{let{typed:t,Chain:r}=e;return t("chain",{"":function(){return new r},any:function(e){return new r(e)}})}),Sp=s("det",["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],e=>{let{typed:t,matrix:l,subtractScalar:c,multiply:f,divideScalar:p,isZero:m,unaryMinus:h}=e;return t("det",{any:ee,"Array | Matrix":function(e){var t=_(e)?e.size():Array.isArray(e)?(e=l(e)).size():[];switch(t.length){case 0:return ee(e);case 1:if(1===t[0])return ee(e.valueOf()[0]);if(0===t[0])return 1;throw new RangeError("Matrix must be square (size: "+S(t)+")");case 2:{const l=t[0],n=t[1];if(l===n){var i=e.clone().valueOf();var a=l;if(1===a)return ee(i[0][0]);if(2===a)return c(f(i[0][0],i[1][1]),f(i[1][0],i[0][1]));{let n=!1;const u=new Array(a).fill(0).map((e,t)=>t);for(let r=0;r<a;r++){let t=u[r];if(m(i[t][r])){let e;for(e=r+1;e<a;e++)if(!m(i[u[e]][r])){t=u[e],u[e]=u[r],u[r]=t,n=!n;break}if(e===a)return i[t][r]}var o=i[t][r],s=0===r?1:i[u[r-1]][r-1];for(let e=r+1;e<a;e++){const m=u[e];for(let e=r+1;e<a;e++)i[m][e]=p(c(f(i[m][e],o),f(i[m][r],i[t][e])),s)}}var r=i[u[a-1]][a-1];return n?h(r):r}return}if(0===n)return 1;throw new RangeError("Matrix must be square (size: "+S(t)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+S(t)+")")}}})}),Mp=s("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],e=>{let{typed:t,matrix:n,divideScalar:p,addScalar:m,multiply:h,unaryMinus:d,det:g,identity:y,abs:x}=e;return t("inv",{"Array | Matrix":function(e){var t=_(e)?e.size():T(e);switch(t.length){case 1:if(1===t[0])return _(e)?n([p(1,e.valueOf()[0])]):[p(1,e[0])];throw new RangeError("Matrix must be square (size: "+S(t)+")");case 2:{const p=t[0],r=t[1];if(p===r)return _(e)?n(i(e.valueOf(),p,r),e.storage()):i(e,p,r);throw new RangeError("Matrix must be square (size: "+S(t)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+S(t)+")")}},any:function(e){return p(1,e)}});function i(e,n,i){let a,o,s,u,l;if(1===n){if(0===(u=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[p(1,u)]]}if(2===n){const n=g(e);if(0===n)throw Error("Cannot calculate inverse, determinant is zero");return[[p(e[1][1],n),p(d(e[0][1]),n)],[p(d(e[1][0]),n),p(e[0][0],n)]]}{const g=e.concat();for(a=0;a<n;a++)g[a]=g[a].concat();const u=y(n).valueOf();for(let r=0;r<i;r++){let e=x(g[r][r]),t=r;for(a=r+1;a<n;)x(g[a][r])>e&&(e=x(g[a][r]),t=a),a++;if(0===e)throw Error("Cannot calculate inverse, determinant is zero");(a=t)!==r&&(l=g[r],g[r]=g[a],g[a]=l,l=u[r],u[r]=u[a],u[a]=l);var c=g[r],f=u[r];for(a=0;a<n;a++){const n=g[a],y=u[a];if(a!==r){if(0!==n[r]){for(s=p(d(n[r]),c[r]),o=r;o<i;o++)n[o]=m(n[o],h(s,c[o]));for(o=0;o<i;o++)y[o]=m(y[o],h(s,f[o]))}}else{for(s=c[r],o=r;o<i;o++)n[o]=p(n[o],s);for(o=0;o<i;o++)y[o]=p(y[o],s)}}}return u}}}),Cp=s("pinv",["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],e=>{let{typed:t,matrix:i,inv:a,deepEqual:r,equal:n,dotDivide:u,dot:o,ctranspose:s,divideScalar:l,multiply:c,add:f,Complex:p}=e;return t("pinv",{"Array | Matrix":function(e){var t=_(e)?e.size():T(e);switch(t.length){case 1:return d(e)?s(e):1===t[0]?a(e):u(s(e),o(e,e));case 2:if(d(e))return s(e);var r=t[0],n=t[1];if(r===n)try{return a(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return _(e)?i(m(e.valueOf(),r,n),e.storage()):m(e,r,n);default:throw new RangeError("Matrix must be two dimensional (size: "+S(t)+")")}},any:function(e){return n(e,0)?ee(e):l(1,e)}});function m(e,t,i){var{C:e,F:t}=function(e,r){const n=function(i,a){const o=ee(e);let s=0;for(let n=0;n<i;n++){if(a<=s)return o;let e=n;for(;h(o[e][s]);)if(i===++e&&(e=n,a===++s))return o;[o[e],o[n]]=[o[n],o[e]];let r=o[n][s];for(let e=0;e<a;e++)o[n][e]=u(o[n][e],r);for(let t=0;t<i;t++)if(t!==n){r=o[t][s];for(let e=0;e<a;e++)o[t][e]=f(o[t][e],c(-1,c(r,o[n][e])))}s++}return o}(r,i);return{C:e.map((e,t)=>e.filter((e,t)=>t<r&&!h(o(n[t],n[t])))),F:n.filter((e,t)=>!h(o(n[t],n[t])))}}(e,t),e=c(a(c(s(e),e)),s(e)),t=c(s(t),a(c(t,s(t))));return c(t,e)}function h(e){return n(f(e,p(1,1)),f(0,p(1,1)))}function d(e){return r(f(e,p(1,1)),f(c(e,0),p(1,1)))}}),Tp=s("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","size","reshape","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],e=>{let{config:s,typed:t,matrix:i,addScalar:r,subtract:p,equal:n,abs:m,atan:a,cos:o,sin:u,multiplyScalar:h,divideScalar:y,inv:x,bignumber:P,multiply:U,add:l,larger:k,column:c,flatten:j,number:f,complex:L,sqrt:R,diag:$,size:H,reshape:G,qr:V,usolve:Z,usolveAll:W,im:d,re:g,smaller:Y,matrixFromColumns:J,dot:X}=e;const w=function(){let{config:E,addScalar:S,subtract:M,abs:C,atan:T,cos:B,sin:F,multiplyScalar:D,inv:O,bignumber:_,multiply:z,add:q}={config:s,addScalar:r,subtract:p,column:c,flatten:j,equal:n,abs:m,atan:a,cos:o,sin:u,multiplyScalar:h,inv:x,bignumber:P,complex:L,multiply:U,add:l};function I(r){var n=r.length;let i=0,a=[0,1];for(let t=0;t<n;t++)for(let e=t+1;e<n;e++)Math.abs(i)<Math.abs(r[t][e])&&(i=Math.abs(r[t][e]),a=[t,e]);return[a,i]}function k(r){var n=r.length;let i=0,a=[0,1];for(let t=0;t<n;t++)for(let e=t+1;e<n;e++)C(i)<C(r[t][e])&&(i=C(r[t][e]),a=[t,e]);return[a,i]}function R(i,a,e){const o=i.length,s=Array(o);let u;if(e){u=Array(o);for(let e=0;e<o;e++)u[e]=Array(o)}for(let n=0;n<o;n++){let t=0,r=i[0];for(let e=0;e<i.length;e++)C(i[e])<C(r)&&(t=e,r=i[t]);if(s[n]=i.splice(t,1)[0],e)for(let e=0;e<o;e++)u[n][e]=a[e][t],a[e].splice(t,1)}if(!e)return{values:s};var t=u.map((e,t)=>({value:s[t],vector:e}));return{values:s,eigenvectors:t}}return function(n,e){var i,a,o,s,u,l,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:E.relTol,t=3<arguments.length?arguments[3]:void 0,f=4<arguments.length?arguments[4]:void 0;if("number"===t){var p=n,m=c,h=f;const x=p.length,b=Math.abs(m/x);let e,t;if(h){t=new Array(x);for(let e=0;e<x;e++)t[e]=Array(x).fill(0),t[e][e]=1}let r=I(p);for(;Math.abs(r[1])>=Math.abs(b);){const m=r[0][0],x=r[0][1];i=p[m][m],a=p[x][x],o=p[m][x],p=function(t,e,r,n){const i=t.length,a=Math.cos(e),o=Math.sin(e),s=a*a,u=o*o,l=Array(i).fill(0),c=Array(i).fill(0),f=s*t[r][r]-2*a*o*t[r][n]+u*t[n][n],p=u*t[r][r]+2*a*o*t[r][n]+s*t[n][n];for(let e=0;e<i;e++)l[e]=a*t[r][e]-o*t[n][e],c[e]=o*t[r][e]+a*t[n][e];t[r][r]=f,t[n][n]=p,t[r][n]=0;for(let e=t[n][r]=0;e<i;e++)e!==r&&e!==n&&(t[r][e]=l[e],t[e][r]=l[e],t[n][e]=c[e],t[e][n]=c[e]);return t}(p,e=Math.abs(a-i)<=E.relTol?Math.PI/4:.5*Math.atan(2*o/(a-i)),m,x),h&&(t=function(t,e,r,n){const i=t.length,a=Math.cos(e),o=Math.sin(e),s=Array(i).fill(0),u=Array(i).fill(0);for(let e=0;e<i;e++)s[e]=a*t[e][r]-o*t[e][n],u[e]=o*t[e][r]+a*t[e][n];for(let e=0;e<i;e++)t[e][r]=s[e],t[e][n]=u[e];return t}(t,e,m,x)),r=I(p)}const v=Array(x).fill(0);for(let e=0;e<x;e++)v[e]=p[e][e];return R(ee(v),t,h)}if("BigNumber"!==t)throw TypeError("Unsupported data type: "+t);{var d=n,g=c,y=f;const w=d.length,N=C(g/w);let e,t;if(y){t=new Array(w);for(let e=0;e<w;e++)t[e]=Array(w).fill(0),t[e][e]=1}let r=k(d);for(;C(r[1])>=C(N);){const g=r[0][0],w=r[0][1];s=d[g][g],u=d[w][w],l=d[g][w],u=M(u,s),d=function(t,e,r,n){const i=t.length,a=_(B(e)),o=_(F(e)),s=D(a,a),u=D(o,o),l=Array(i).fill(_(0)),c=Array(i).fill(_(0)),f=z(_(2),a,o,t[r][n]),p=S(M(D(s,t[r][r]),f),D(u,t[n][n])),m=q(D(u,t[r][r]),f,D(s,t[n][n]));for(let e=0;e<i;e++)l[e]=M(D(a,t[r][e]),D(o,t[n][e])),c[e]=S(D(o,t[r][e]),D(a,t[n][e]));t[r][r]=p,t[n][n]=m,t[r][n]=_(0),t[n][r]=_(0);for(let e=0;e<i;e++)e!==r&&e!==n&&(t[r][e]=l[e],t[e][r]=l[e],t[n][e]=c[e],t[e][n]=c[e]);return t}(d,e=C(u)<=E.relTol?_(-1).acos().div(4):D(.5,T(z(2,l,O(u)))),g,w),y&&(t=function(t,e,r,n){const i=t.length,a=B(e),o=F(e),s=Array(i).fill(_(0)),u=Array(i).fill(_(0));for(let e=0;e<i;e++)s[e]=M(D(a,t[e][r]),D(o,t[e][n])),u[e]=S(D(o,t[e][r]),D(a,t[e][n]));for(let e=0;e<i;e++)t[e][r]=s[e],t[e][n]=u[e];return t}(t,e,g,w)),r=k(d)}const A=Array(w).fill(0);for(let e=0;e<w;e++)A[e]=d[e][e];return R(ee(A),t,y)}}}(),N=function(){let{addScalar:v,subtract:w,flatten:b,multiply:N,multiplyScalar:A,divideScalar:d,sqrt:E,abs:S,bignumber:M,diag:C,size:i,reshape:a,inv:T,qr:B,usolve:u,usolveAll:F,equal:D,complex:O,larger:g,smaller:_,dot:o}={config:s,addScalar:r,subtract:p,multiply:U,multiplyScalar:h,flatten:j,divideScalar:y,sqrt:R,abs:m,bignumber:P,diag:$,size:H,reshape:G,qr:V,inv:x,usolve:Z,usolveAll:W,equal:n,complex:L,larger:k,smaller:Y,matrixFromColumns:J,dot:X};function z(e,t,r,n,i,a,o,s){var u="BigNumber"===s,s="Complex"===s,l=u?M(0):s?O(0):0,u=u?M(1):s?O(1):1;if(_(S(r),o))return[[u,l],[l,u]];if(g(S(w(i,a)),o))return[[w(i,n),w(a,n)],[r,r]];s=w(e,i),a=w(n,i);return _(S(t),o)&&_(S(a),o)?[[s,u],[r,l]]:[[t,l],[a,u]]}function q(t,r){for(let e=0;e<t.length;e++)t[e].push(...Array(r-t[e].length).fill(0));for(let e=t.length;e<r;e++)t.push(Array(r).fill(0)),t[e][e]=1}function I(e,t,r,n,i){var a="BigNumber"===i?M(1e3):1e3;let o,s=0;for(;s<5;++s){o=function(e,t,r){var n="BigNumber"===r,i="Complex"===r;let a=Array(e).fill(0).map(e=>2*Math.random()-1);return n&&(a=a.map(e=>M(e))),f(a=l(a=i?a.map(e=>O(e)):a,t),r)}(t,r,i);try{o=u(e,o)}catch(e){continue}if(g(c(o),a))break}if(5<=s)return null;for(s=0;;){const t=u(e,o);if(_(c(l(o,[t])),n))break;if(10<=++s)return null;o=f(t)}return o}function l(e,t){var r,n=i(e);for(r of t)r=a(r,n),e=w(e,N(d(o(r,e),o(r,r)),r));return e}function c(e){return S(E(o(e,e)))}function f(e,t){var r="Complex"===t,t="BigNumber"===t?M(1):r?O(1):1;return N(d(t,c(e)),e)}return function(e,t,r,n){var i=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],a=function(a,o,s){const u="BigNumber"===n,l="Complex"===n,e=u?M(0):0,t=u?M(1):l?O(1):1,c=u?M(1):1,f=u?M(10):2,p=A(f,f);let m,h=(s&&(m=Array(o).fill(t)),!1);for(;!h;){h=!0;for(let i=0;i<o;i++){let r=e,n=e;for(let e=0;e<o;e++)i!==e&&(r=v(r,S(a[e][i])),n=v(n,S(a[i][e])));if(!D(r,0)&&!D(n,0)){let t=c,e=r;const u=d(n,f),l=A(n,f);for(;_(e,u);)e=A(e,p),t=A(t,f);for(;g(e,l);)e=d(e,p),t=d(t,f);if(_(d(v(e,n),t),A(v(r,n),.95))){h=!1;const v=d(1,t);for(let e=0;e<o;e++)i!==e&&(a[i][e]=A(a[i][e],v),a[e][i]=A(a[e][i],t));s&&(m[i]=A(m[i],v))}}}}return s?C(m):null}(e,t,i),o=e,s=t,u=r,l=i,c=a,f="BigNumber"===n,p="Complex"===n,m=f?M(0):p?O(0):0;f&&(u=M(u));for(let n=0;n<s-2;n++){let t=0,r=m;for(let e=n+1;e<s;e++){const w=o[e][n];_(S(r),S(w))&&(r=w,t=e)}if(!_(S(r),u)){if(t!==n+1){const v=o[t];o[t]=o[n+1],o[n+1]=v;for(let e=0;e<s;e++){const w=o[e][t];o[e][t]=o[e][n+1],o[e][n+1]=w}if(l){const o=c[t];c[t]=c[n+1],c[n+1]=o}}for(let t=n+2;t<s;t++){const S=d(o[t][n],r);if(0!==S){for(let e=0;e<s;e++)o[t][e]=w(o[t][e],A(S,o[n+1][e]));for(let e=0;e<s;e++)o[e][n+1]=v(o[e][n+1],A(S,o[e][t]));if(l)for(let e=0;e<s;e++)c[t][e]=w(c[t][e],A(S,c[n+1][e]))}}}}var{values:p,C:f}=function(t,e,r,n,i){const a="BigNumber"===n,o="Complex"===n,s=a?M(1):o?O(1):1;a&&(r=M(r));let u=ee(t);const l=[];let c=e;const f=[];let p=i?C(Array(e).fill(s)):void 0,m=i?C(Array(c).fill(s)):void 0,h=0;for(;h<=100;){h+=1;const t=u[c-1][c-1];for(let e=0;e<c;e++)u[e][e]=w(u[e][e],t);const{Q:M,R:a}=B(u);u=N(a,M);for(let e=0;e<c;e++)u[e][e]=v(u[e][e],t);if(i&&(m=N(m,M)),1===c||_(S(u[c-1][c-2]),r)){h=0,l.push(u[c-1][c-1]),i&&(f.unshift([[1]]),q(m,e),p=N(p,m),1<c&&(m=C(Array(c-1).fill(s)))),--c,u.pop();for(let e=0;e<c;e++)u[e].pop()}else if(2===c||_(S(u[c-2][c-3]),r)){h=0;d=u[c-2][c-2],g=u[c-2][c-1],y=u[c-1][c-2],x=u[c-1][c-1],b=void 0,b=v(d,x),d=w(A(d,x),A(g,y)),x=A(b,.5),g=A(E(w(A(b,b),A(4,d))),.5);const t=[v(x,g),w(x,g)];l.push(...t),i&&(f.unshift(z(u[c-2][c-2],u[c-2][c-1],u[c-1][c-2],u[c-1][c-1],t[0],t[1],r,n)),q(m,e),p=N(p,m),2<c&&(m=C(Array(c-2).fill(s)))),c-=2,u.pop(),u.pop();for(let e=0;e<c;e++)u[e].pop(),u[e].pop()}if(0===c)break}var d,g,y,x,b;if(l.sort((e,t)=>+w(S(e),S(t))),100<h){const t=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+l.join(", "));throw t.values=l,t.vectors=[],t}t=i?N(p,function(r,n){const i=[];for(let e=0;e<n;e++)i[e]=Array(n).fill(0);let a=0;for(const n of r){const r=n.length;for(let t=0;t<r;t++)for(let e=0;e<r;e++)i[a+t][a+e]=n[t][e];a+=r}return i}(f,e)):void 0;return{values:l,C:t}}(e,t,r,n,i);if(i){const v=function(r,n,i,a,o,s,u){const l=T(i),c=N(l,r,i),e="BigNumber"===u,t="Complex"===u,f=e?M(0):t?O(0):0,p=e?M(1):t?O(1):1,m=[],h=[];for(const r of o){const n=function(t,r,n){for(let e=0;e<t.length;e++)if(n(t[e],r))return e;return-1}(m,r,D);-1===n?(m.push(r),h.push(1)):h[n]+=1}const d=[],g=m.length,y=Array(n).fill(f),x=C(Array(n).fill(p));for(let t=0;t<g;t++){const o=m[t],M=w(c,N(o,x));let e=F(M,y);for(e.shift();e.length<h[t];){const r=I(M,n,e,s,u);if(null===r)break;e.push(r)}const l=N(T(a),i);e=e.map(e=>N(l,e)),d.push(...e.map(e=>({value:o,vector:b(e)})))}return d}(e,t,f,a,p,r,n);return{values:p,eigenvectors:v}}return{values:p}}}();return t("eigs",{Array:function(e){return b(i(e))},"Array, number|BigNumber":function(e,t){return b(i(e),{precision:t})},"Array, Object":(e,t)=>b(i(e),t),Matrix:function(e){return b(e,{matricize:!0})},"Matrix, number|BigNumber":function(e,t){return b(e,{precision:t,matricize:!0})},"Matrix, Object":function(e,t){var r={matricize:!0};return gn(r,t),b(e,r)}});function b(e,t){t=1<arguments.length&&void 0!==t?t:{};const r=!("eigenvectors"in t)||t.eigenvectors,n=function(e,t,r){const n=e.toArray(),i=e.size();if(2!==i.length||i[0]!==i[1])throw new RangeError(`Matrix must be square (size: ${S(i)})`);var a=i[0];if(function(r,n,i){for(let t=0;t<n;t++)for(let e=0;e<n;e++)if(k(P(m(d(r[t][e]))),i))return;return 1}(n,a,t)&&(function(r,n){for(let t=0;t<n;t++)for(let e=0;e<n;e++)r[t][e]=g(r[t][e])}(n,a),function(r,n,i){for(let t=0;t<n;t++)for(let e=t;e<n;e++)if(k(P(m(p(r[t][e],r[e][t]))),i))return;return 1}(n,a,t))){const i=v(e,n,a);return w(n,a,t,i,r)}e=v(e,n,a);return N(n,a,t,e,r)}(e,null!=(e=t.precision)?e:s.relTol,r);return t.matricize&&(n.values=i(n.values),r&&(n.eigenvectors=n.eigenvectors.map(e=>{var{value:e,vector:t}=e;return{value:e,vector:i(t)}}))),r&&Object.defineProperty(n,"vectors",{enumerable:!1,get:()=>{throw new Error("eigs(M).vectors replaced with eigs(M).eigenvectors")}}),n}function v(e,r,n){e=e.datatype();if("number"===e||"BigNumber"===e||"Complex"===e)return e;let i=!1,a=!1,o=!1;for(let t=0;t<n;t++)for(let e=0;e<n;e++){const n=r[t][e];if(A(n)||re(n))i=!0;else if(Q(n))a=!0;else{if(!te(n))throw TypeError("Unsupported type in Matrix: "+K(n));o=!0}}if(a&&o&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),o){for(let t=0;t<n;t++)for(let e=0;e<n;e++)r[t][e]=L(r[t][e]);return"Complex"}if(a){for(let t=0;t<n;t++)for(let e=0;e<n;e++)r[t][e]=P(r[t][e]);return"BigNumber"}if(i){for(let t=0;t<n;t++)for(let e=0;e<n;e++)r[t][e]=f(r[t][e]);return"number"}throw TypeError("Matrix contains unsupported types only.")}}),Bp=s("expm",["typed","abs","add","identity","inv","multiply"],e=>{let{typed:t,abs:p,add:m,identity:h,inv:d,multiply:g}=e;return t("expm",{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+S(t)+")");var t=t[0],r=function(r){for(let t=0;t<30;t++)for(let e=0;e<=t;e++){var n=t-e;if(function(e,t,r){let n=1;for(let e=2;e<=t;e++)n*=e;let i=n;for(let e=t+1;e<=2*t;e++)i*=e;var a=i*(2*t+1);return 8*Math.pow(e/Math.pow(2,r),2*t)*n*n/(i*a)}(r,e,n)<1e-15)return{q:e,j:n}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(function(n){var i=n.size()[0];let e=0;for(let r=0;r<i;r++){let t=0;for(let e=0;e<i;e++)t+=p(n.get([r,e]));e=Math.max(t,e)}return e}(e)),n=r.q,i=r.j,a=g(e,Math.pow(2,-i));let o=h(t),s=h(t),u=1,l=a,c=-1;for(let e=1;e<=n;e++)1<e&&(l=g(l,a),c=-c),u=u*(n-e+1)/((2*n-e+1)*e),o=m(o,g(u,l)),s=m(s,g(u*c,l));let f=g(d(s),o);for(let e=0;e<i;e++)f=g(f,f);return G(e)?e.createSparseMatrix(f):f}})}),Fp=s("sqrtm",["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],e=>{let{typed:t,abs:o,add:s,multiply:u,map:r,sqrt:n,subtract:l,inv:c,size:f,max:p,identity:m}=e;return t("sqrtm",{"Array | Matrix":function(i){var e=_(i)?i.size():T(i);switch(e.length){case 1:if(1===e[0])return r(i,n);throw new RangeError("Matrix must be square (size: "+S(e)+")");case 2:if(e[0]!==e[1])throw new RangeError("Matrix must be square (size: "+S(e)+")");{var a=i;let e,t=0,r=a,n=m(f(a));do{const a=r;if(r=u(.5,s(a,c(n))),n=u(.5,s(n,c(a))),1e-6<(e=p(o(l(r,a))))&&1e3<++t)throw new Error("computing square root of matrix: iterative method could not converge")}while(1e-6<e);return r;return}default:throw new RangeError("Matrix must be at most two dimensional (size: "+S(e)+")")}}})}),Dp="sylvester",Op=s(Dp,["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],e=>{let{typed:t,schur:g,matrixFromColumns:y,matrix:x,multiply:b,range:v,concat:w,transpose:N,index:A,subset:E,add:S,subtract:M,identity:C,lusolve:T,abs:B}=e;return t(Dp,{"Matrix, Matrix, Matrix":n,"Array, Matrix, Matrix":function(e,t,r){return n(x(e),t,r)},"Array, Array, Matrix":function(e,t,r){return n(x(e),x(t),r)},"Array, Matrix, Array":function(e,t,r){return n(x(e),t,x(r))},"Matrix, Array, Matrix":function(e,t,r){return n(e,x(t),r)},"Matrix, Array, Array":function(e,t,r){return n(e,x(t),x(r))},"Matrix, Matrix, Array":function(e,t,r){return n(e,t,x(r))},"Array, Array, Array":function(e,t,r){return n(x(e),x(t),x(r)).toArray()}});function n(e,t,r){const n=t.size()[0],i=e.size()[0],a=g(e),o=a.T,s=a.U,u=g(b(-1,t)),l=u.T,c=u.U,f=b(b(N(s),r),c),p=v(0,i),m=[],h=(e,t)=>w(e,t,1),d=(e,t)=>w(e,t,0);for(let r=0;r<n;r++)if(r<n-1&&1e-5<B(E(l,A(r+1,r)))){let t=d(E(f,A(p,r)),E(f,A(p,r+1)));for(let e=0;e<r;e++)t=S(t,d(b(m[e],E(l,A(e,r))),b(m[e],E(l,A(e,r+1)))));const g=b(C(i),b(-1,E(l,A(r,r)))),y=b(C(i),b(-1,E(l,A(r+1,r)))),x=b(C(i),b(-1,E(l,A(r,r+1)))),w=b(C(i),b(-1,E(l,A(r+1,r+1)))),N=d(h(S(o,g),y),h(x,S(o,w))),M=T(N,t);m[r]=M.subset(A(v(0,i),0)),m[r+1]=M.subset(A(v(i,2*i),0)),r++}else{let t=E(f,A(p,r));for(let e=0;e<r;e++)t=S(t,b(m[e],E(l,A(e,r))));const g=E(l,A(r,r)),y=M(o,b(g,C(i)));m[r]=T(y,t)}e=x(y(...m));return b(s,b(e,N(c)))}}),_p=s("schur",["typed","matrix","identity","multiply","qr","norm","subtract"],e=>{let{typed:t,matrix:r,identity:o,multiply:s,qr:u,norm:l,subtract:c}=e;return t("schur",{Array:function(e){const t=n(r(e));return{U:t.U.valueOf(),T:t.T.valueOf()}},Matrix:n});function n(e){const t=e.size()[0];let r,n=e,i=o(t),a=0;do{r=n;const e=u(n),t=e.Q,o=e.R;if(n=s(o,t),i=s(i,t),100<a++)break}while(1e-4<l(c(n,r)));return{U:i,T:n}}}),zp=s("lyap",["typed","matrix","sylvester","multiply","transpose"],e=>{let{typed:t,matrix:r,sylvester:n,multiply:i,transpose:a}=e;return t("lyap",{"Matrix, Matrix":function(e,t){return n(e,a(e),i(-1,t))},"Array, Matrix":function(e,t){return n(r(e),a(r(e)),i(-1,t))},"Matrix, Array":function(e,t){return n(e,a(r(e)),r(i(-1,t)))},"Array, Array":function(e,t){return n(r(e),a(r(e)),r(i(-1,t))).toArray()}})}),qp=s("divide",["typed","matrix","multiply","equalScalar","divideScalar","inv"],e=>{let{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e;const s=Aa({typed:t,equalScalar:i}),u=Ea({typed:t});return t("divide",Fe({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))}),Ip="distance",kp=s(Ip,["typed","addScalar","subtractScalar","divideScalar","multiplyScalar","deepEqual","sqrt","abs"],e=>{let{typed:t,addScalar:l,subtractScalar:c,multiplyScalar:f,divideScalar:p,deepEqual:a,sqrt:m,abs:o}=e;return t(Ip,{"Array, Array, Array":function(e,t,r){if(2!==e.length||2!==t.length||2!==r.length)throw new TypeError("Invalid Arguments: Try again");if(!s(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(a(t,r))throw new TypeError("LinePoint1 should not be same with LinePoint2");var n=c(r[1],t[1]),i=c(t[0],r[0]),t=c(f(r[0],t[1]),f(t[0],r[1]));return d(e[0],e[1],n,i,t)},"Object, Object, Object":function(e,t,r){if(2!==Object.keys(e).length||2!==Object.keys(t).length||2!==Object.keys(r).length)throw new TypeError("Invalid Arguments: Try again");if(!s(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if(a(h(t),h(r)))throw new TypeError("LinePoint1 should not be same with LinePoint2");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){const n=c(r.lineTwoPtY,t.lineOnePtY),a=c(t.lineOnePtX,r.lineTwoPtX),i=c(f(r.lineTwoPtX,t.lineOnePtY),f(t.lineOnePtX,r.lineTwoPtY));return d(e.pointX,e.pointY,n,a,i)}throw new TypeError("Key names do not match")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!s(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(n(t))return d(e[0],e[1],t[0],t[1],t[2]);throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument")}if(3===e.length&&6===t.length){if(!n(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(u(t))return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5]);throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument")}if(e.length===t.length&&0<e.length){if(!i(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(i(t))return y(e,t);throw new TypeError("All values of an array should be numbers or BigNumbers")}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!s(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!n(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return d(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!n(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!u(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!s(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return y([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3!==Object.keys(e).length||3!==Object.keys(t).length)throw new TypeError("Invalid Arguments: Try again");if(!n(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!n(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")},Array:function(e){if(function(e){if(2===e[0].length&&r(e[0][0])&&r(e[0][1])){if(e.some(e=>2!==e.length||!r(e[0])||!r(e[1])))return}else{if(!(3===e[0].length&&r(e[0][0])&&r(e[0][1])&&r(e[0][2])))return;if(e.some(e=>3!==e.length||!r(e[0])||!r(e[1])||!r(e[2])))return}return 1}(e)){var i=e;const a=[];let r=[],n=[];for(let t=0;t<i.length-1;t++)for(let e=t+1;e<i.length;e++)2===i[0].length?(r=[i[t][0],i[t][1]],n=[i[e][0],i[e][1]]):3===i[0].length&&(r=[i[t][0],i[t][1],i[t][2]],n=[i[e][0],i[e][1],i[e][2]]),a.push(y(r,n));return a}throw new TypeError("Incorrect array format entered for pairwise distance calculation")}});function r(e){return"number"==typeof e||Q(e)}function s(e){return r((e=e.constructor!==Array?h(e):e)[0])&&r(e[1])}function n(e){return r((e=e.constructor!==Array?h(e):e)[0])&&r(e[1])&&r(e[2])}function i(e){return(e=Array.isArray(e)?e:h(e)).every(r)}function u(e){return r((e=e.constructor!==Array?h(e):e)[0])&&r(e[1])&&r(e[2])&&r(e[3])&&r(e[4])&&r(e[5])}function h(t){const r=Object.keys(t),n=[];for(let e=0;e<r.length;e++)n.push(t[r[e]]);return n}function d(e,t,r,n,i){e=o(l(l(f(r,e),f(n,t)),i)),t=m(l(f(r,r),f(n,n)));return p(e,t)}function g(e,t,r,n,i,a,o,s,u){a=[c(f(c(i,t),u),f(c(a,r),s)),c(f(c(a,r),o),f(c(n,e),u)),c(f(c(n,e),s),f(c(i,t),o))],a=m(l(l(f(a[0],a[0]),f(a[1],a[1])),f(a[2],a[2]))),r=m(l(l(f(o,o),f(s,s)),f(u,u)));return p(a,r)}function y(t,r){var n=t.length;let i=0,a;for(let e=0;e<n;e++)a=c(t[e],r[e]),i=l(f(a,a),i);return m(i)}}),Rp=s("intersect",["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],e=>{let{typed:t,config:y,abs:x,add:b,addScalar:v,matrix:i,multiply:w,multiplyScalar:N,divideScalar:A,subtract:E,smaller:S,equalScalar:M,flatten:r,isZero:C,isNumeric:m}=e;return t("intersect",{"Array, Array, Array":n,"Array, Array, Array, Array":a,"Matrix, Matrix, Matrix":function(e,t,r){e=n(e.valueOf(),t.valueOf(),r.valueOf());return null===e?null:i(e)},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){e=a(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf());return null===e?null:i(e)}});function n(e,t,r){if(e=T(e),t=T(t),r=T(r),!F(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!F(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(4===(n=r).length&&m(n[0])&&m(n[1])&&m(n[2])&&m(n[3]))return n=e[0],i=e[1],e=e[2],a=t[0],o=t[1],t=t[2],s=r[0],u=r[1],l=r[2],r=r[3],c=N(n,s),s=N(a,s),f=N(i,u),u=N(o,u),p=N(e,l),l=N(t,l),r=E(E(E(r,c),f),p),s=E(E(E(v(v(s,u),l),c),f),p),u=A(r,s),[v(n,N(u,E(a,n))),v(i,N(u,E(o,i))),v(e,N(u,E(t,e)))];var n,i,a,o,s,u,l,c,f,p;throw new TypeError("Array with 4 numbers expected as third argument")}function a(e,t,r,n){if(e=T(e),t=T(t),r=T(r),n=T(n),2===e.length){if(!B(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!B(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!B(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(B(n)){var i=t;var a=n;var o=e,s=r,i=E(o,i),a=E(s,a),u=E(N(i[0],a[1]),N(a[0],i[1]));if(C(u))return null;if(S(x(u),y.relTol))return null;var l=N(a[0],o[1]),c=N(a[1],o[0]),f=N(a[0],s[1]),a=N(a[1],s[0]),s=A(v(E(E(l,c),f),a),u);return b(w(i,s),o);return}throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument")}if(3!==e.length)throw new TypeError("Arrays with two or thee dimensional points expected");if(!F(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!F(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!F(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");var p,m,h,d,g;{if(F(n))return l=e[0],c=e[1],f=e[2],a=t[0],u=t[1],i=t[2],s=r[0],o=r[1],e=r[2],t=n[0],r=n[1],n=n[2],p=D(l,s,t,s,c,o,r,o,f,e,n,e),m=D(t,s,a,l,r,o,u,c,n,e,i,f),d=D(l,s,a,l,c,o,u,c,f,e,i,f),h=D(t,s,t,s,r,o,r,o,n,e,n,e),g=D(a,l,a,l,u,c,u,c,i,f,i,f),d=E(N(p,m),N(d,h)),g=E(N(g,h),N(m,m)),C(g)?null:(d=A(d,g),g=A(v(p,N(d,m)),h),p=v(l,N(d,E(a,l))),m=v(c,N(d,E(u,c))),h=v(f,N(d,E(i,f))),a=v(s,N(g,E(t,s))),l=v(o,N(g,E(r,o))),u=v(e,N(g,E(n,e))),M(p,a)&&M(m,l)&&M(h,u)?[p,m,h]:null);throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument")}}function T(e){return 1===e.length?e[0]:1<e.length&&Array.isArray(e[0])&&e.every(e=>Array.isArray(e)&&1===e.length)?r(e):e}function B(e){return 2===e.length&&m(e[0])&&m(e[1])}function F(e){return 3===e.length&&m(e[0])&&m(e[1])&&m(e[2])}function D(e,t,r,n,i,a,o,s,u,l,c,f){e=N(E(e,t),E(r,n)),t=N(E(i,a),E(o,s)),r=N(E(u,l),E(c,f));return v(v(e,t),r)}}),Pp=s("sum",["typed","config","add","numeric"],e=>{let{typed:t,config:n,add:i,numeric:a}=e;return t("sum",{"Array | Matrix":r,"Array | Matrix, number | BigNumber":function(e,t){try{return ri(e,t,i)}catch(e){throw eu(e,"sum")}},"...":function(e){if(ei(e))throw new TypeError("Scalar values expected in function sum");return r(e)}});function r(e){let r;return ti(e,function(t){try{r=void 0===r?t:i(r,t)}catch(e){throw eu(e,"sum",t)}}),r="string"==typeof(r=void 0===r?a(0,n.number):r)?a(r,Ie(r,n)):r}}),Up="cumsum",jp=s(Up,["typed","add","unaryPlus"],e=>{let{typed:t,add:n,unaryPlus:i}=e;return t(Up,{Array:r,Matrix:function(e){return e.create(r(e.valueOf(),e.datatype()))},"Array, number | BigNumber":a,"Matrix, number | BigNumber":function(e,t){return e.create(a(e.valueOf(),t),e.datatype())},"...":function(e){if(ei(e))throw new TypeError("All values expected to be scalar in function cumsum");return r(e)}});function r(e){try{return s(e)}catch(e){throw eu(e,Up)}}function s(t){if(0===t.length)return[];const r=[i(t[0])];for(let e=1;e<t.length;++e)r.push(n(r[e-1],t[e]));return r}function a(e,t){var r=T(e);if(t<0||t>=r.length)throw new En(t,r.length);try{return function e(t,r){let n,i,a;if(r<=0){const o=t[0][0];if(Array.isArray(o)){for(a=Kn(t),i=[],n=0;n<a.length;n++)i[n]=e(a[n],r-1);return i}return s(t)}for(i=[],n=0;n<t.length;n++)i[n]=e(t[n],r-1);return i}(e,t)}catch(e){throw eu(e,Up)}}}),Lp=s("mean",["typed","add","divide"],e=>{let{typed:t,add:i,divide:a}=e;return t("mean",{"Array | Matrix":r,"Array | Matrix, number | BigNumber":function(e,t){try{var r=ri(e,t,i),n=Array.isArray(e)?T(e):e.size();return a(r,n[t])}catch(e){throw eu(e,"mean")}},"...":function(e){if(ei(e))throw new TypeError("Scalar values expected in function mean");return r(e)}});function r(e){let r,n=0;if(ti(e,function(t){try{r=void 0===r?t:i(r,t),n++}catch(e){throw eu(e,"mean",t)}}),0===n)throw new Error("Cannot calculate the mean of an empty array");return a(r,n)}}),$p=s("median",["typed","add","divide","compare","partitionSelect"],e=>{let{typed:t,add:r,divide:n,compare:a,partitionSelect:o}=e;function i(r){try{var e=(r=E(r.valueOf())).length;if(0===e)throw new Error("Cannot calculate median of an empty array");if(e%2==0){var n=e/2-1,i=o(r,1+n);let t=r[n];for(let e=0;e<n;++e)0<a(r[e],t)&&(t=r[e]);return u(t,i)}var t=o(r,(e-1)/2);return s(t)}catch(r){throw eu(r,"median")}}const s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t("median",{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(ei(e))throw new TypeError("Scalar values expected in function median");return i(e)}})}),Hp=s("mad",["typed","abs","map","median","subtract"],e=>{let{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":o});function o(e){if(0===(e=E(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{const t=i(e);return i(n(e,function(e){return r(a(e,t))}))}catch(e){throw e instanceof TypeError&&e.message.includes("median")?new TypeError(e.message.replace("median","mad")):eu(e,"mad")}}}),Gp="unbiased",Vp="variance",Zp=s(Vp,["typed","add","subtract","multiply","divide","mapSlices","isNaN"],e=>{let{typed:t,add:a,subtract:o,multiply:s,divide:u,mapSlices:n,isNaN:l}=e;return t(Vp,{"Array | Matrix":function(e){return i(e,Gp)},"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":function(e,t){return r(e,t,Gp)},"Array | Matrix, number | BigNumber, string":r,"...":function(e){return i(e,Gp)}});function i(e,t){let r,n=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(ti(e,function(t){try{r=void 0===r?t:a(r,t),n++}catch(e){throw eu(e,"variance",t)}}),0===n)throw new Error("Cannot calculate variance of an empty array");const i=u(r,n);if(r=void 0,ti(e,function(e){e=o(e,i);r=void 0===r?s(e,e):a(r,s(e,e))}),l(r))return r;switch(t){case"uncorrected":return u(r,n);case"biased":return u(r,n+1);case"unbiased":{const e=Q(r)?r.mul(0):0;return 1===n?e:u(r,n-1)}default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function r(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return n(e,t,e=>i(e,r))}catch(e){throw eu(e,"variance")}}}),Wp="quantileSeq",Yp=s(Wp,["typed","?bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],e=>{let{typed:t,bignumber:o,add:l,subtract:c,divide:s,multiply:f,partitionSelect:p,compare:m,isInteger:h,smaller:u,smallerEq:d,larger:g,mapSlices:a}=e;return t(Wp,{"Array | Matrix, number | BigNumber":(e,t)=>y(e,t,!1),"Array | Matrix, number | BigNumber, number":(e,t,r)=>i(e,t,!1,r,y),"Array | Matrix, number | BigNumber, boolean":y,"Array | Matrix, number | BigNumber, boolean, number":(e,t,r,n)=>i(e,t,r,n,y),"Array | Matrix, Array | Matrix":(e,t)=>x(e,t,!1),"Array | Matrix, Array | Matrix, number":(e,t,r)=>i(e,t,!1,r,x),"Array | Matrix, Array | Matrix, boolean":x,"Array | Matrix, Array | Matrix, boolean, number":(e,t,r,n)=>i(e,t,r,n,x)});function i(e,t,r,n,i){return a(e,n,e=>i(e,t,r))}function y(t,r,n){let i;var a=t.valueOf();if(u(r,0))throw new Error("N/prob must be non-negative");if(d(r,1))return A(r)?b(a,r,n):o(b(a,r,n));if(g(r,1)){if(!h(r))throw new Error("N must be a positive integer");if(g(r,4294967295))throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");const t=l(r,1);i=[];for(let e=0;u(e,r);e++){const r=s(e+1,t);i.push(b(a,r,n))}return A(r)?i:o(i)}}function x(e,t,r){const n=e.valueOf(),i=t.valueOf(),a=[];for(let e=0;e<i.length;++e)a.push(b(n,i[e],r));return a}function b(e,t,r){var n=E(e),e=n.length;if(0===e)throw new Error("Cannot calculate quantile of an empty sequence");const i=A(t)?t*(e-1):t.times(e-1),a=A(t)?Math.floor(i):i.floor().toNumber(),o=A(t)?i%1:i.minus(a);if(h(i))return r?n[i]:p(n,A(t)?i:i.valueOf());let s,u;if(r)s=n[a],u=n[a+1];else{u=p(n,a+1),s=n[a];for(let e=0;e<a;++e)0<m(n[e],s)&&(s=n[e])}return l(f(s,c(1,o)),f(u,o))}}),Jp=s("std",["typed","map","sqrt","variance"],e=>{let{typed:t,map:r,sqrt:n,variance:i}=e;return t("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{const e=i.apply(null,arguments);return $(e)?r(e,n):n(e)}catch(e){throw e instanceof TypeError&&e.message.includes(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}}),Xp=s("corr",["typed","matrix","mean","sqrt","sum","add","subtract","multiply","pow","divide"],e=>{let{typed:t,matrix:r,sqrt:s,sum:u,add:l,subtract:c,multiply:f,pow:p,divide:m}=e;return t("corr",{"Array, Array":n,"Matrix, Matrix":function(e,t){e=n(e.toArray(),t.toArray());return Array.isArray(e)?r(e):e}});function n(t,r){const n=[];if(Array.isArray(t[0])&&Array.isArray(r[0])){if(t.length!==r.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");for(let e=0;e<t.length;e++){if(t[e].length!==r[e].length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");n.push(i(t[e],r[e]))}return n}if(t.length!==r.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");return i(t,r)}function i(e,n){var t=e.length,r=u(e),i=u(n),a=e.reduce((e,t,r)=>l(e,f(t,n[r])),0),e=u(e.map(e=>p(e,2))),o=u(n.map(e=>p(e,2))),a=c(f(t,a),f(r,i)),e=s(f(c(f(t,e),p(r,2)),c(f(t,o),p(i,2))));return m(a,e)}});function Qp(e,t){if(t<e)return 1;if(t===e)return t;var r=t+e>>1;return Qp(e,r)*Qp(1+r,t)}function Kp(t,r){if(!v(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(!v(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(t<r)throw new TypeError("k must be less than or equal to n");var n=t-r;let i=1,a=2;var o=r<n?r:n;for(let e=r<n?1+n:r+1;e<=t;++e)for(i*=e;a<=o&&i%a==0;)i/=a,++a;return a<=o&&(i/=Qp(a,o)),i}Kp.signature="number, number";const em="combinations",tm=s(em,["typed"],e=>{let t=e["typed"];return t(em,{"number, number":Kp,"BigNumber, BigNumber":function(e,t){const r=e.constructor;let n,i;const a=e.minus(t),o=new r(1);if(!rm(e)||!rm(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(n=o,t.lt(a))for(i=o;i.lte(a);i=i.plus(o))n=n.times(t.plus(i)).dividedBy(i);else for(i=o;i.lte(t);i=i.plus(o))n=n.times(a.plus(i)).dividedBy(i);return n}})});function rm(e){return e.isInteger()&&e.gte(0)}const nm="combinationsWithRep",im=s(nm,["typed"],e=>{let t=e["typed"];return t(nm,{"number, number":function(e,t){if(!v(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!v(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t<e-1?Qp(e,e+t-1)/Qp(1,t):Qp(t+1,e+t-1)/Qp(1,e-1)},"BigNumber, BigNumber":function(e,t){let r,n;const i=new e.constructor(1),a=e.minus(i);if(!am(e)||!am(t))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e.lt(i))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(r=i,t.lt(a))for(n=i;n.lte(a);n=n.plus(i))r=r.times(t.plus(n)).dividedBy(n);else for(n=i;n.lte(t);n=n.plus(i))r=r.times(a.plus(n)).dividedBy(n);return r}})});function am(e){return e.isInteger()&&e.gte(0)}function om(t){let r;if(v(t))return t<=0?isFinite(t)?1/0:NaN:171<t?1/0:Qp(1,t-1);if(t<.5)return Math.PI/(Math.sin(Math.PI*t)*om(1-t));if(171.35<=t)return 1/0;if(85<t){const r=t*t,e=r*t,n=e*t,i=n*t;return Math.sqrt(2*Math.PI/t)*Math.pow(t/Math.E,t)*(1+1/(12*t)+1/(288*r)-139/(51840*e)-571/(2488320*n)+163879/(209018880*i)+5246819/(75246796800*i*t))}--t,r=um[0];for(let e=1;e<um.length;++e)r+=um[e]/(t+e);const e=t+sm+.5;return Math.sqrt(2*Math.PI)*Math.pow(e,t+.5)*Math.exp(-e)*r}const sm=4.7421875,um=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],lm=.9189385332046728,cm=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function fm(t){if(t<0)return NaN;if(0===t)return 1/0;if(!isFinite(t))return t;if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-fm(1-t);var e=5+--t+.5;let r=cm[0];for(let e=6;1<=e;e--)r+=cm[e]/(t+e);return lm+(t+.5)*Math.log(e)-e+Math.log(r)}fm.signature=om.signature="number";const pm=s("gamma",["typed","config","multiplyScalar","pow","BigNumber","Complex"],e=>{let{typed:t,config:s,BigNumber:u,Complex:l}=e;return t("gamma",{number:om,Complex:function e(t){if(0===t.im)return om(t.re);if(t.re<.5){const r=new l(1-t.re,-t.im),n=new l(Math.PI*t.re,Math.PI*t.im);return new l(Math.PI).div(n.sin()).div(e(r))}t=new l(t.re-1,t.im);let r=new l(um[0],0);for(let e=1;e<um.length;++e){const n=new l(um[e],0);r=r.add(n.div(t.add(e)))}const n=new l(t.re+sm+.5,t.im),i=Math.sqrt(2*Math.PI),a=n.pow(t.add(.5)),o=n.neg().exp();return r.mul(i).mul(a).mul(o)},BigNumber:function(e){if(e.isInteger())return e.isNegative()||e.isZero()?new u(1/0):function e(t){if(t<8)return new u([1,1,2,6,24,120,720,5040][t]);const r=s.precision+(0|Math.log(t.toNumber())),n=u.clone({precision:r});if(t%2==1)return t.times(e(new u(t-1)));let i=t,a=new n(t),o=t.toNumber();for(;2<i;)i-=2,o+=i,a=a.times(o);return new u(a.toPrecision(u.precision))}(e.minus(1));if(e.isFinite())throw new Error("Integer BigNumber expected");return new u(e.isNegative()?NaN:1/0)}})}),mm=s("lgamma",["Complex","typed"],e=>{let{Complex:u,typed:t}=e;const l=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t("lgamma",{number:fm,Complex:function e(t){if(t.isNaN())return new u(NaN,NaN);if(0===t.im)return new u(fm(t.re),0);if(7<=t.re||7<=Math.abs(t.im))return a(t);if(t.re<=.1){r=6.283185307179586;const a=(!0^(0<(n=t.im)||!(n<0)&&1/n==1/0)?-r:r)*Math.floor(.5*t.re+.25),o=t.mul(Math.PI).sin().log(),i=e(new u(1-t.re,-t.im));return new u(1.1447298858494002,a).sub(o).sub(i)}return 0<=t.im?o(t):o(t.conjugate()).conjugate();var r,n},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function a(e){const t=e.sub(.5).mul(e.log()).sub(e).add(lm),r=new u(1,0).div(e),n=r.div(e);let i=l[0],a=l[1];var o=2*n.re,s=n.re*n.re+n.im*n.im;for(let e=2;e<8;e++){const u=a;a=-s*i+l[e],i=o*i+u}e=r.mul(n.mul(i).add(a));return t.add(e)}function o(e){let t=0,r=0,n=e;for(e=e.add(1);e.re<=7;){const u=(n=n.mul(e)).im<0?1:0;0!=u&&0===r&&t++,r=u,e=e.add(1)}return a(e).sub(n.log()).sub(new u(0,2*t*Math.PI*1))}}),hm="factorial",dm=s(hm,["typed","gamma"],e=>{let{typed:t,gamma:r}=e;return t(hm,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":t.referToSelf(t=>e=>le(e,t))})}),gm="kldivergence",ym=s(gm,["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],e=>{let{typed:t,matrix:r,divide:i,sum:a,multiply:o,map:s,dotDivide:u,log:l,isNumeric:c}=e;return t(gm,{"Array, Array":function(e,t){return n(r(e),r(t))},"Matrix, Array":function(e,t){return n(e,r(t))},"Array, Matrix":function(e,t){return n(r(e),t)},"Matrix, Matrix":n});function n(e,t){var r=t.size().length,n=e.size().length;if(1<r)throw new Error("first object must be one dimensional");if(1<n)throw new Error("second object must be one dimensional");if(r!==n)throw new Error("Length of two vectors must be equal");if(0===a(e))throw new Error("Sum of elements in first object must be non zero");if(0===a(t))throw new Error("Sum of elements in second object must be non zero");r=i(e,a(e)),n=i(t,a(t)),e=a(o(r,s(u(r,n),e=>l(e))));return c(e)?e:Number.NaN}}),xm="multinomial",bm=s(xm,["typed","add","divide","multiply","factorial","isInteger","isPositive"],e=>{let{typed:t,add:n,divide:i,multiply:a,factorial:o,isInteger:s,isPositive:u}=e;return t(xm,{"Array | Matrix":function(e){let t=0,r=1;return ti(e,function(e){if(!s(e)||!u(e))throw new TypeError("Positive integer value expected in function multinomial");t=n(t,e),r=a(r,o(e))}),i(o(t),r)}})}),vm="permutations",wm=s(vm,["typed","factorial"],e=>{let{typed:t,factorial:r}=e;return t(vm,{"number | BigNumber":r,"number, number":function(e,t){if(!v(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!v(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(e<t)throw new TypeError("second argument k must be less than or equal to first argument n");return Qp(e-t+1,e)},"BigNumber, BigNumber":function(e,t){let r,n;if(!Nm(e)||!Nm(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})});function Nm(e){return e.isInteger()&&e.gte(0)}var Am=fd(391);const Em=Am(Date.now());function Sm(e){let t;return t=null===(e=e)?Em:Am(String(e)),function(){return t()}}const Mm="pickRandom",Cm=s(Mm,["typed","config","?on"],e=>{let{typed:t,config:r,on:n}=e,c=Sm(r.randomSeed);return n&&n("config",function(e,t){e.randomSeed!==t.randomSeed&&(c=Sm(e.randomSeed))}),t(Mm,{"Array | Matrix":function(e){return i(e,{})},"Array | Matrix, Object":i,"Array | Matrix, number":function(e,t){return i(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return i(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return i(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return i(e,{number:t,weights:r})}});function i(n,e){let{number:t,weights:i,elementWise:r=!0}=e;e=void 0===t;e&&(t=1);const a=_(n)?n.create:_(i)?i.create:null;n=n.valueOf(),i=i&&i.valueOf(),!0===r&&(n=E(n),i=E(i));let o=0;if(void 0!==i){if(i.length!==n.length)throw new Error("Weights must have the same length as possibles");for(let e=0,t=i.length;e<t;e++){if(!A(i[e])||i[e]<0)throw new Error("Weights must be an array of positive numbers");o+=i[e]}}const s=n.length,u=[];let l;for(;u.length<t;){if(void 0===i)l=n[Math.floor(c()*s)];else{let r=c()*o;for(let e=0,t=n.length;e<t;e++)if((r-=i[e])<0){l=n[e];break}}u.push(l)}return e?u[0]:a?a(u):u}});function Tm(r,n){const i=[];if(1<(r=r.slice(0)).length)for(let e=0,t=r.shift();e<t;e++)i.push(Tm(r,n));else for(let e=0,t=r.shift();e<t;e++)i.push(n());return i}const Bm=s("random",["typed","config","?on"],e=>{let{typed:t,config:r,on:n}=e,i=Sm(r.randomSeed);return n&&n("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=Sm(e.randomSeed))}),t("random",{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=Tm(e.valueOf(),()=>o(t,r));return _(e)?e.create(n,"number"):n}function o(e,t){return e+i()*(t-e)}}),Fm="randomInt",Dm=s(Fm,["typed","config","log2","?on"],e=>{let{typed:t,config:r,log2:a,on:n}=e,o=Sm(r.randomSeed);return n&&n("config",function(e,t){e.randomSeed!==t.randomSeed&&(o=Sm(e.randomSeed))}),t(Fm,{"":()=>s(0,2),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),bigint:e=>u(0n,e),"bigint, bigint":u,"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,r)=>i(e,t,r)});function i(e,t,r){var n=Tm(e.valueOf(),()=>s(t,r));return _(e)?e.create(n,"number"):n}function s(e,t){return Math.floor(e+o()*(t-e))}function u(e,t){var r=t-e;if(r<=2n**30n)return e+BigInt(s(0,Number(r)));var n=a(r);let i=r;for(;i>=r;){i=0n;for(let e=0;e<n;++e)i=2n*i+(o()<.5?0n:1n)}return e+i}}),Om="stirlingS2",_m=s(Om,["typed","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],e=>{let{typed:t,addScalar:u,multiplyScalar:l,isNegative:c,isInteger:f,number:p,bignumber:m,larger:h}=e;const d=[],g=[];return t(Om,{"number | BigNumber, number | BigNumber":function(e,r){if(!f(e)||c(e)||!f(r)||c(r))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(h(r,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");const n=!(A(e)&&A(r)),i=n?g:d,a=n?m:p,o=p(e),s=p(r);if(i[o]&&i[o].length>s)return i[o][s];for(let t=0;t<=o;++t)if(i[t]||(i[t]=[a(0===t?1:0)]),0!==t){const r=i[t],n=i[t-1];for(let e=r.length;e<=t&&e<=s;++e)r[e]=e===t?1:u(l(a(e),n[e]),n[e-1])}return i[o][s]}})}),zm="bellNumbers",qm=s(zm,["typed","addScalar","isNegative","isInteger","stirlingS2"],e=>{let{typed:t,addScalar:n,isNegative:i,isInteger:a,stirlingS2:o}=e;return t(zm,{"number | BigNumber":function(t){if(!a(t)||i(t))throw new TypeError("Non-negative integer value expected in function bellNumbers");let r=0;for(let e=0;e<=t;e++)r=n(r,o(t,e));return r}})}),Im="catalan",km=s(Im,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],e=>{let{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(Im,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})}),Rm="composition",Pm=s(Rm,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],e=>{let{typed:t,addScalar:r,combinations:n,isPositive:i,isInteger:a,larger:o}=e;return t(Rm,{"number | BigNumber, number | BigNumber":function(e,t){if(!(a(e)&&i(e)&&a(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(o(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})}),Um="leafCount",jm=s(Um,["parse","typed"],e=>{let t=e["typed"];return t(Um,{Node:function t(e){let r=0;return e.forEach(e=>{r+=t(e)}),r||1}})});function Lm(e){return ae(e)||oe(e)&&e.isUnary()&&ae(e.args[0])}function $m(e){return!!ae(e)||!(!Ae(e)&&!oe(e)||!e.args.every($m))||!(!Me(e)||!$m(e.content))}const Hm=s("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],e=>{let{FunctionNode:r,OperatorNode:n,SymbolNode:i}=e;const a="defaultF",o={add:{trivial:!0,total:!0,commutative:!0,associative:!0},unaryPlus:{trivial:!0,total:!0,commutative:!0,associative:!0},subtract:{trivial:!1,total:!0,commutative:!1,associative:!1},multiply:{trivial:!0,total:!0,commutative:!0,associative:!0},divide:{trivial:!1,total:!0,commutative:!1,associative:!1},paren:{trivial:!0,total:!0,commutative:!0,associative:!1},defaultF:{trivial:!1,total:!0,commutative:!1,associative:!1}};function t(e,t){let r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:o,n=a;if("string"==typeof e?n=e:oe(e)?n=e.fn.toString():Ae(e)?n=e.name:Me(e)&&(n="paren"),ue(r,n)){const e=r[n];if(ue(e,t))return e[t];if(ue(o,n))return o[n][t]}if(ue(r,a)){const e=r[a];return(ue(e,t)?e:o[a])[t]}if(ue(o,n)){const e=o[n];if(ue(e,t))return e[t]}return o[a][t]}function s(e){return t(e,"associative",1<arguments.length&&void 0!==arguments[1]?arguments[1]:o)}function u(e,t){let n;function i(t){for(let e=0;e<t.args.length;e++){var r=t.args[e];oe(r)&&n===r.op?i(r):a.push(r)}}const a=[];return s(e,t)?(n=e.op,i(e),a):e.args}function l(t){return oe(t)?function(e){try{return new n(t.op,t.fn,e,t.implicit)}catch(e){return console.error(e),[]}}:function(e){return new r(new i(t.name),e)}}return{createMakeNodeFunction:l,hasProperty:t,isCommutative:function(e){return t(e,"commutative",1<arguments.length&&void 0!==arguments[1]?arguments[1]:o)},isAssociative:s,mergeContext:function(e,t){const r={...e};for(const n in t)ue(e,n)?r[n]={...t[n],...e[n]}:r[n]=t[n];return r},flatten:function t(r,n){if(!r.args||0===r.args.length)return r;r.args=u(r,n);for(let e=0;e<r.args.length;e++)t(r.args[e],n)},allChildren:u,unflattenr:function t(r,n){if(r.args&&0!==r.args.length){const i=l(r),a=r.args.length;for(let e=0;e<a;e++)t(r.args[e],n);if(2<a&&s(r,n)){let e=r.args.pop();for(;0<r.args.length;)e=i([r.args.pop(),e]);r.args=e.args}}},unflattenl:function t(r,n){if(r.args&&0!==r.args.length){const i=l(r),a=r.args.length;for(let e=0;e<a;e++)t(r.args[e],n);if(2<a&&s(r,n)){let e=r.args.shift();for(;0<r.args.length;)e=i([e,r.args.shift()]);r.args=e.args}}},defaultContext:o,realContext:{divide:{total:!1},log:{total:!1}},positiveContext:{subtract:{total:!1},abs:{trivial:!0},log:{total:!0}}}}),Gm=s("simplify",["typed","parse","equal","resolve","simplifyConstant","simplifyCore","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode","replacer"],e=>{let{typed:t,parse:l,equal:o,resolve:r,simplifyConstant:n,simplifyCore:i,AccessorNode:s,ArrayNode:u,ConstantNode:c,FunctionNode:f,IndexNode:p,ObjectNode:m,OperatorNode:h,ParenthesisNode:d,SymbolNode:g,replacer:y}=e;const{hasProperty:x,isCommutative:b,isAssociative:v,mergeContext:w,flatten:N,unflattenr:A,unflattenl:E,createMakeNodeFunction:S,defaultContext:a,realContext:M,positiveContext:C}=Hm({FunctionNode:f,OperatorNode:h,SymbolNode:g}),T=(t.addConversion({from:"Object",to:"Map",convert:U}),t("simplify",{Node:O,"Node, Map":(e,t)=>O(e,!1,t),"Node, Map, Object":(e,t,r)=>O(e,!1,t,r),"Node, Array":O,"Node, Array, Map":O,"Node, Array, Map, Object":O}));function B(e){return e.transform(function(e){return Me(e)?B(e.content):e})}t.removeConversion({from:"Object",to:"Map",convert:U}),T.defaultContext=a,T.realContext=M,T.positiveContext=C;const I={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};T.rules=[i,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(cl*v) -> v * (-cl)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(cl*v) -> (-cl) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*cl) -> v * (-cl)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" vd * ( vd * n1 + n2)",r:"vd^2 * n1 + vd * n2"},{s:" vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},n,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"vd*n + vd",r:"vd*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*vd + vd -> (n+1)*vd",assuming:{multiply:{commutative:!1}}},{s:"vd + n*vd -> (1+n)*vd",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n^n1 * n -> n^(n1+1)",assuming:{divide:{total:!0},multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*cd + cd",r:"(n+1)*cd"},{s:"cd*n + cd -> cd*(n+1)",assuming:{multiply:{commutative:!1}}},{s:"cd + cd*n -> cd*(1+n)",assuming:{multiply:{commutative:!1}}},n,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"ce+ve -> ve+ce",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"vd*cd -> cd*vd",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{l:"n+-(n1)",r:"n-(n1)"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];let F=0;function D(){return new g("_p"+F++)}function O(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:P(),i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},a=i.consoleDebug;n=function(n,i){const a=[];for(let r=0;r<n.length;r++){let e,t=n[r];var o=typeof t;switch(o){case"string":t={s:t};case"object":e=function(t,r){const n={};if(t.s){const r=t.s.split("->");if(2!==r.length)throw SyntaxError("Could not parse rule: "+t.s);n.l=r[0],n.r=r[1]}else n.l=t.l,n.r=t.r;n.l=B(l(n.l)),n.r=B(l(n.r));for(const r of["imposeContext","repeat","assuming"])r in t&&(n[r]=t[r]);if(t.evaluate&&(n.evaluate=l(t.evaluate)),v(n.l,r)){const t=!b(n.l,r);let e;t&&(e=D());const i=S(n.l),a=D();n.expanded={},n.expanded.l=i([n.l,a]),N(n.expanded.l,r),A(n.expanded.l,r),n.expanded.r=i([n.r,a]),t&&(n.expandedNC1={},n.expandedNC1.l=i([e,n.l]),n.expandedNC1.r=i([e,n.r]),n.expandedNC2={},n.expandedNC2.l=i([e,n.expanded.l]),n.expandedNC2.r=i([e,n.expanded.r]))}return n}(t,i);break;case"function":e=t;break;default:throw TypeError("Unsupported type of rule: "+o)}a.push(e)}return a}(n||T.rules,i.context);let o=r(e,t);const s={};let u=(o=B(o)).toString({parenthesis:"all"});for(;!s[u];){s[u]=!0,F=0;let r=u;a&&console.log("Working on: ",u);for(let t=0;t<n.length;t++){let e="";if("function"==typeof n[t]?(o=n[t](o,i),a&&(e=n[t].name)):(N(o,i.context),o=z(o,n[t],i.context),a&&(e=n[t].l.toString()+" -> "+n[t].r.toString())),a){const n=o.toString({parenthesis:"all"});n!==r&&(console.log("Applying",e,"produced",n),r=n)}E(o,i.context)}u=o.toString({parenthesis:"all"})}return o}function _(t,r,n){let i=t;if(t)for(let e=0;e<t.length;++e){var a=z(t[e],r,n);a!==t[e]&&((i=i===t?t.slice():i)[e]=a)}return i}function z(e,r,n){if(r.assuming)for(const t in r.assuming)for(const i in r.assuming[t])if(x(t,i,n)!==r.assuming[t][i])return e;const t=w(r.imposeContext,n);let i=e;if(i instanceof h||i instanceof f){const e=_(i.args,r,n);e!==i.args&&((i=i.clone()).args=e)}else if(i instanceof d){if(i.content){const e=z(i.content,r,n);e!==i.content&&(i=new d(e))}}else if(i instanceof u){const e=_(i.items,r,n);e!==i.items&&(i=new u(e))}else if(i instanceof s){let e=i.object,t=(i.object&&(e=z(i.object,r,n)),i.index);i.index&&(t=z(i.index,r,n)),e===i.object&&t===i.index||(i=new s(e,t))}else if(i instanceof p){const e=_(i.dimensions,r,n);e!==i.dimensions&&(i=new p(e))}else if(i instanceof m){let e=!1;const t={};for(const a in i.properties)t[a]=z(i.properties[a],r,n),t[a]!==i.properties[a]&&(e=!0);e&&(i=new m(t))}let a=r.r,o=q(r.l,i,t)[0];if(!o&&r.expanded&&(a=r.expanded.r,o=q(r.expanded.l,i,t)[0]),!o&&r.expandedNC1&&(a=r.expandedNC1.r,(o=q(r.expandedNC1.l,i,t)[0])||(a=r.expandedNC2.r,o=q(r.expandedNC2.l,i,t)[0])),o){const e=i.implicit;i=a.clone(),e&&"implicit"in a&&(i.implicit=!0),i=i.transform(function(e){return e.isSymbolNode&&ue(o.placeholders,e.name)?o.placeholders[e.name].clone():e})}return i=r.repeat&&i!==e?z(i,r,n):i}function k(e,t){const r={placeholders:{}};if(!e.placeholders&&!t.placeholders)return r;if(!e.placeholders)return t;if(!t.placeholders)return e;for(const n in e.placeholders)if(ue(e.placeholders,n)&&(r.placeholders[n]=e.placeholders[n],ue(t.placeholders,n)&&!function t(r,n){if(r instanceof c&&n instanceof c){if(!o(r.value,n.value))return!1}else if(r instanceof g&&n instanceof g){if(r.name!==n.name)return!1}else{if(!(r instanceof h&&n instanceof h||r instanceof f&&n instanceof f))return!1;if(r instanceof h){if(r.op!==n.op||r.fn!==n.fn)return!1}else if(r instanceof f&&r.name!==n.name)return!1;if(r.args.length!==n.args.length)return!1;for(let e=0;e<r.args.length;e++)if(!t(r.args[e],n.args[e]))return!1}return!0}(e.placeholders[n],t.placeholders[n])))return null;for(const e in t.placeholders)ue(t.placeholders,e)&&(r.placeholders[e]=t.placeholders[e]);return r}function R(r,n){const i=[];if(0===r.length||0===n.length)return i;var a;for(let t=0;t<r.length;t++)for(let e=0;e<n.length;e++)(a=k(r[t],n[e]))&&i.push(a);return i}function q(r,n,i,e){let a=[{placeholders:{}}];if(r instanceof h&&n instanceof h||r instanceof f&&n instanceof f){if(r instanceof h){if(r.op!==n.op||r.fn!==n.fn)return[]}else if(r instanceof f&&r.name!==n.name)return[];if(!(1===n.args.length&&1===r.args.length||!v(n,i)&&n.args.length===r.args.length||e)){if(2<=n.args.length&&2===r.args.length){const o=function(r,e){const n=[];let i,a;const o=S(r);if(b(r,e))for(let e=0;e<r.args.length;e++)(a=r.args.slice(0)).splice(e,1),i=1===a.length?a[0]:o(a),n.push(o([r.args[e],i]));else for(let t=1;t<r.args.length;t++){let e=r.args[0];1<t&&(e=o(r.args.slice(0,t))),a=r.args.slice(t),i=1===a.length?a[0]:o(a),n.push(o([e,i]))}return n}(n,i);let t=[];for(let e=0;e<o.length;e++){const a=q(r,o[e],i,!0);t=t.concat(a)}return t}if(2<r.args.length)throw Error("Unexpected non-binary associative function: "+r.toString());return[]}{let t=[];for(let e=0;e<r.args.length;e++){const a=q(r.args[e],n.args[e],i);if(0===a.length)break;t.push(a)}if(t.length!==r.args.length){if(!b(n,i)||1===r.args.length)return[];if(2<r.args.length)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");const e=q(r.args[0],n.args[1],i);if(0===e.length)return[];const a=q(r.args[1],n.args[0],i);if(0===a.length)return[];t=[e,a]}a=function(e){if(0===e.length)return e;const t=e.reduce(R),r=[],n={};for(let e=0;e<t.length;e++){var i=JSON.stringify(t[e],y);n[i]||(n[i]=!0,r.push(t[e]))}return r}(t)}}else if(r instanceof g){if(0===r.name.length)throw new Error("Symbol in rule has 0 length...!?");if(I[r.name]){if(r.name!==n.name)return[]}else switch("a"<=r.name[1]&&r.name[1]<="z"?r.name.substring(0,2):r.name[0]){case"n":case"_p":a[0].placeholders[r.name]=n;break;case"c":case"cl":if(!ae(n))return[];a[0].placeholders[r.name]=n;break;case"v":if(ae(n))return[];a[0].placeholders[r.name]=n;break;case"vl":if(!se(n))return[];a[0].placeholders[r.name]=n;break;case"cd":if(!Lm(n))return[];a[0].placeholders[r.name]=n;break;case"vd":if(Lm(n))return[];a[0].placeholders[r.name]=n;break;case"ce":if(!$m(n))return[];a[0].placeholders[r.name]=n;break;case"ve":if($m(n))return[];a[0].placeholders[r.name]=n;break;default:throw new Error("Invalid symbol in rule: "+r.name)}}else{if(!(r instanceof c))return[];if(!o(r.value,n.value))return[]}return a}return T}),Vm=s("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],e=>{let{typed:t,config:n,mathWithTransform:h,matrix:d,fraction:i,bignumber:a,AccessorNode:g,ArrayNode:y,ConstantNode:x,FunctionNode:b,IndexNode:v,ObjectNode:w,OperatorNode:o,SymbolNode:r}=e;const{isCommutative:N,isAssociative:A,allChildren:E,createMakeNodeFunction:S}=Hm({FunctionNode:b,OperatorNode:o,SymbolNode:r}),M=t("simplifyConstant",{Node:e=>T(D(e,{})),"Node, Object":function(e,t){return T(D(e,t))}});function s(e){return re(e)?e.valueOf():e instanceof Array?e.map(s):_(e)?d(s(e.valueOf())):e}function C(t,r,n){try{return h[t].apply(null,r)}catch(e){return r=r.map(s),B(h[t].apply(null,r),n)}}const u=t({Fraction:function(e){var t=e=>("BigNumber"===n.number&&a?a:Number)(e),r=e.s*e.n,r=r<0n?new o("-","unaryMinus",[new x(-t(r))]):new x(t(r));return 1n===e.d?r:new o("/","divide",[r,new x(t(e.d))])},number:function(e){return e<0?c(new x(-e)):new x(e)},BigNumber:function(e){return e<0?c(new x(-e)):new x(e)},bigint:function(e){return e<0n?c(new x(-e)):new x(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new x(e)},Matrix:function(e){return new y(e.valueOf().map(e=>u(e)))}});function T(e){return O(e)?e:u(e)}function l(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){const r=i(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.n<n&&r.d<n)return r}return e}const B=t({"string, Object":function(e,t){var r=Ie(e,n);return"BigNumber"===r?(void 0===a&&bs(),a(e)):"bigint"===r?BigInt(e):"Fraction"===r?(void 0===i&&vs(),i(e)):l(parseFloat(e),t)},"Fraction, Object":function(e,t){return e},"BigNumber, Object":function(e,t){return e},"number, Object":l,"bigint, Object":function(e,t){return e},"Complex, Object":function(e,t){return 0!==e.im?e:l(e.re,t)},"Matrix, Object":function(e,t){return d(l(e.valueOf()))},"Array, Object":function(e,t){return e.map(l)}});function c(e){return new o("-","unaryMinus",[e])}function F(r,e,n,i){var t=e.shift(),e=e.reduce((t,e)=>{if(!O(e)){const n=t.pop();if(O(n))return[n,e];try{return t.push(C(r,[n,e],i)),t}catch(e){t.push(n)}}t.push(T(t.pop()));t=1===t.length?t[0]:n(t);return[n([t,T(e)])]},[t]);return 1===e.length?e[0]:n([e[0],u(e[1])])}function D(r,n){switch(r.type){case"SymbolNode":return r;case"ConstantNode":switch(typeof r.value){case"number":case"bigint":return B(r.value,n);case"string":return r.value;default:if(!isNaN(r.value))return B(r.value,n)}return r;case"FunctionNode":if(h[r.name]&&h[r.name].rawArgs)return r;if(!["add","multiply"].includes(r.name)){const o=r.args.map(e=>D(e,n));if(!o.some(O))try{return C(r.name,o,n)}catch(r){}if("size"===r.name&&1===o.length&&ye(o[0])){const r=[];let e=o[0];for(;ye(e);)r.push(e.items.length),e=e.items[0];return d(r)}return new b(r.name,o.map(T))}case"OperatorNode":{var i=r.fn.toString();let t,e;const s=S(r);if(oe(r)&&r.isUnary())t=[D(r.args[0],n)],e=O(t[0])?s(t):C(i,t,n);else if(A(r,n.context))if(t=(t=E(r,n.context)).map(e=>D(e,n)),N(i,n.context)){const r=[],u=[];for(let e=0;e<t.length;e++)(O(t[e])?u:r).push(t[e]);e=1<r.length?(e=F(i,r,s,n),u.unshift(e),F(i,u,s,n)):F(i,t,s,n)}else e=F(i,t,s,n);else t=r.args.map(e=>D(e,n)),e=F(i,t,s,n);return e}case"ParenthesisNode":return D(r.content,n);case"AccessorNode":var e=D(r.object,n),t=D(r.index,n),a=n;if(!Ee(t))return new g(T(e),T(t));if(ye(e)||_(e)){const l=Array.from(t.dimensions);for(;0<l.length;)if(ae(l[0])&&"string"!=typeof l[0].value){const t=B(l.shift().value,a);ye(e)?e=e.items[t-1]:(e=e.valueOf()[t-1])instanceof Array&&(e=d(e))}else{if(!(1<l.length&&ae(l[1])&&"string"!=typeof l[1].value))break;{const t=B(l[1].value,a),c=[],f=ye(e)?e.items:e.valueOf();for(const a of f)if(ye(a))c.push(a.items[t-1]);else{if(!_(e))break;c.push(a[t-1])}if(c.length!==f.length)break;e=ye(e)?new y(c):d(c),l.splice(1,1)}}return l.length===t.dimensions.length?new g(T(e),t):0<l.length?(t=new v(l),new g(T(e),t)):e}if(Se(e)&&1===t.dimensions.length&&ae(t.dimensions[0])){const a=t.dimensions[0].value;return a in e.properties?e.properties[a]:new x}return new g(T(e),t);case"ArrayNode":{const p=r.items.map(e=>D(e,n));return p.some(O)?new y(p.map(T)):d(p)}case"IndexNode":return new v(r.dimensions.map(e=>M(e,n)));case"ObjectNode":{const m={};for(const h in r.properties)m[h]=M(r.properties[h],n);return new w(m)}default:throw new Error("Unimplemented node type in simplifyConstant: "+r.type)}}return M}),Zm="simplifyCore",Wm=s(Zm,["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],e=>{let{typed:t,equal:a,isZero:o,AccessorNode:s,ArrayNode:u,ConstantNode:r,FunctionNode:l,IndexNode:c,ObjectNode:f,OperatorNode:p,SymbolNode:n}=e;const m=new r(0),h=new r(1),d=new r(!0),g=new r(!1);function y(e){return oe(e)&&["and","not","or"].includes(e.op)}const{hasProperty:x,isCommutative:b}=Hm({FunctionNode:l,OperatorNode:p,SymbolNode:n});function v(n){let i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};const t=i?i.context:void 0;if(x(n,"trivial",t)){if(Ae(n)&&1===n.args.length)return v(n.args[0],i);let t=!1,r=0;if(n.forEach(e=>{1===++r&&(t=v(e,i))}),1===r)return t}let r=n;if(Ae(r)){const n=function(e){var t="OperatorNode:"+e;for(const e of mf)if(t in e)return e[t].op;return null}(r.name);if(!n)return new l(v(r.fn),r.args.map(e=>v(e,i)));if(2<r.args.length&&x(r,"associative",t))for(;2<r.args.length;){const i=r.args.pop(),t=r.args.pop();r.args.push(new p(n,r.name,[i,t]))}r=new p(n,r.name,r.args)}if(oe(r)&&r.isUnary()){const n=v(r.args[0],i);if("~"===r.op&&oe(n)&&n.isUnary()&&"~"===n.op)return n.args[0];if("not"===r.op&&oe(n)&&n.isUnary()&&"not"===n.op&&y(n.args[0]))return n.args[0];let e=!0;if("-"===r.op&&oe(n)&&(n.isBinary()&&"subtract"===n.fn&&(r=new p("-","subtract",[n.args[1],n.args[0]]),e=!1),n.isUnary()&&"-"===n.op))return n.args[0];if(e)return new p(r.op,r.fn,[n])}if(oe(r)&&r.isBinary()){const n=v(r.args[0],i);let e=v(r.args[1],i);if("+"===r.op){if(ae(n)&&o(n.value))return e;if(ae(e)&&o(e.value))return n;oe(e)&&e.isUnary()&&"-"===e.op&&(e=e.args[0],r=new p("-","subtract",[n,e]))}if("-"===r.op)return oe(e)&&e.isUnary()&&"-"===e.op?v(new p("+","add",[n,e.args[0]]),i):ae(n)&&o(n.value)?v(new p("-","unaryMinus",[e])):ae(e)&&o(e.value)?n:new p(r.op,r.fn,[n,e]);if("*"===r.op){if(ae(n)){if(o(n.value))return m;if(a(n.value,1))return e}if(ae(e)){if(o(e.value))return m;if(a(e.value,1))return n;if(b(r,t))return new p(r.op,r.fn,[e,n],r.implicit)}return new p(r.op,r.fn,[n,e],r.implicit)}if("/"===r.op)return ae(n)&&o(n.value)?m:ae(e)&&a(e.value,1)?n:new p(r.op,r.fn,[n,e]);if("^"===r.op&&ae(e)){if(o(e.value))return h;if(a(e.value,1))return n}if("and"===r.op){if(ae(n)){if(!n.value)return g;if(y(e))return e;if(ae(e))return e.value?d:g}if(ae(e)){if(!e.value)return g;if(y(n))return n}}if("or"===r.op){if(ae(n)){if(n.value)return d;if(y(e))return e}if(ae(e)){if(e.value)return d;if(y(n))return n}}return new p(r.op,r.fn,[n,e])}if(oe(r))return new p(r.op,r.fn,r.args.map(e=>v(e,i)));if(ye(r))return new u(r.items.map(e=>v(e,i)));if(ge(r))return new s(v(r.object,i),v(r.index,i));if(Ee(r))return new c(r.dimensions.map(e=>v(e,i)));if(Se(r)){const n={};for(const t in r.properties)n[t]=v(r.properties[t],i);return new f(n)}return r}return t(Zm,{Node:v,"Node,Object":v})}),Ym=s("resolve",["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],e=>{let{typed:t,parse:n,ConstantNode:i,FunctionNode:a,OperatorNode:o,ParenthesisNode:s}=e;function u(e,t){let r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new Set;if(!t)return e;if(se(e)){if(r.has(e.name)){const e=Array.from(r).join(", ");throw new ReferenceError(`recursive loop of variable definitions among {${e}}`)}const a=t.get(e.name);if(O(a)){const n=new Set(r);return n.add(e.name),u(a,t,n)}return"number"==typeof a?n(String(a)):void 0!==a?new i(a):e}if(oe(e)){const n=e.args.map(function(e){return u(e,t,r)});return new o(e.op,e.fn,n,e.implicit)}if(Me(e))return new s(u(e.content,t,r));if(Ae(e)){const n=e.args.map(function(e){return u(e,t,r)});return new a(e.name,n)}return e.map(e=>u(e,t,r))}return t("resolve",{Node:u,"Node, Map | null | undefined":u,"Node, Object":(e,t)=>u(e,U(t)),"Array | Matrix":t.referToSelf(t=>e=>e.map(e=>t(e))),"Array | Matrix, null | undefined":t.referToSelf(t=>e=>e.map(e=>t(e))),"Array, Object":t.referTo("Array,Map",r=>(e,t)=>r(e,U(t))),"Matrix, Object":t.referTo("Matrix,Map",r=>(e,t)=>r(e,U(t))),"Array | Matrix, Map":t.referToSelf(r=>(e,t)=>e.map(e=>r(e,t)))})}),Jm="symbolicEqual",Xm=s(Jm,["parse","simplify","typed","OperatorNode"],e=>{let{simplify:n,typed:t,OperatorNode:i}=e;function r(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},e=new i("-","subtract",[e,t]),t=n(e,{},r);return ae(t)&&!t.value}return t(Jm,{"Node, Node":r,"Node, Node, Object":r})}),Qm="derivative",Km=s(Qm,["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],e=>{let{typed:t,config:r,parse:n,simplify:o,equal:l,isZero:c,numeric:i,ConstantNode:a,FunctionNode:f,OperatorNode:p,ParenthesisNode:s,SymbolNode:m}=e;function u(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{simplify:!0};const n=new Map,i=t.name,a=x(e,function e(t){var r=n.get(t);if(void 0!==r)return r;r=y(e,t,i);return n.set(t,r),r});return r.simplify?o(a):a}function h(e){var t=n(e);if(t.isSymbolNode)return t;throw new TypeError(`Invalid variable. Cannot parse ${JSON.stringify(e)} into a variable in function derivative`)}const d=t(Qm,{"Node, SymbolNode":u,"Node, SymbolNode, Object":u,"Node, string":(e,t)=>u(e,h(t)),"Node, string, Object":(e,t,r)=>u(e,h(t),r)}),g=(d._simplify=!0,d.toTex=function(e){return g.apply(null,e.args)},t("_derivTex",{"Node, SymbolNode":function(e,t){return ae(e)&&"string"===K(e.value)?g(n(e.value).toString(),t.toString(),1):g(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===K(t.value))return g(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return g(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+`\\left[${e}\\right]`}})),y=t("_isConst",{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(e,t,r){return t.name!==r},"function, ParenthesisNode, string":function(e,t,r){return e(t.content,r)},"function, FunctionAssignmentNode, string":function(e,t,r){return!t.params.includes(r)||e(t.expr,r)},"function, FunctionNode | OperatorNode, string":function(t,e,r){return e.args.every(e=>t(e,r))}}),x=t("_derivative",{"ConstantNode, function":function(){return b(0)},"SymbolNode, function":function(e,t){return t(e)?b(0):b(1)},"ParenthesisNode, function":function(e,t){return new s(x(e.content,t))},"FunctionAssignmentNode, function":function(e,t){return t(e)?b(0):x(e.expr,t)},"FunctionNode, function":function(e,t){if(t(e))return b(0);const r=e.args[0];let n,i,a,o,s=!1,u=!1;switch(e.name){case"cbrt":s=!0,i=new p("*","multiply",[b(3),new p("^","pow",[r,new p("/","divide",[b(2),b(3)])])]);break;case"sqrt":case"nthRoot":if(1===e.args.length)s=!0,i=new p("*","multiply",[b(2),new f("sqrt",[r])]);else if(2===e.args.length)return n=new p("/","divide",[b(1),e.args[1]]),x(new p("^","pow",[r,n]),t);break;case"log10":n=b(10);case"log":if(n||1!==e.args.length){if(1===e.args.length&&n||2===e.args.length&&t(e.args[1]))i=new p("*","multiply",[r.clone(),new f("log",[n||e.args[1]])]),s=!0;else if(2===e.args.length)return x(new p("/","divide",[new f("log",[r]),new f("log",[e.args[1]])]),t)}else i=r.clone(),s=!0;break;case"pow":if(2===e.args.length)return x(new p("^","pow",[r,e.args[1]]),t);break;case"exp":i=new f("exp",[r.clone()]);break;case"sin":i=new f("cos",[r.clone()]);break;case"cos":i=new p("-","unaryMinus",[new f("sin",[r.clone()])]);break;case"tan":i=new p("^","pow",[new f("sec",[r.clone()]),b(2)]);break;case"sec":i=new p("*","multiply",[e,new f("tan",[r.clone()])]);break;case"csc":u=!0,i=new p("*","multiply",[e,new f("cot",[r.clone()])]);break;case"cot":u=!0,i=new p("^","pow",[new f("csc",[r.clone()]),b(2)]);break;case"asin":s=!0,i=new f("sqrt",[new p("-","subtract",[b(1),new p("^","pow",[r.clone(),b(2)])])]);break;case"acos":s=!0,u=!0,i=new f("sqrt",[new p("-","subtract",[b(1),new p("^","pow",[r.clone(),b(2)])])]);break;case"atan":s=!0,i=new p("+","add",[new p("^","pow",[r.clone(),b(2)]),b(1)]);break;case"asec":s=!0,i=new p("*","multiply",[new f("abs",[r.clone()]),new f("sqrt",[new p("-","subtract",[new p("^","pow",[r.clone(),b(2)]),b(1)])])]);break;case"acsc":s=!0,u=!0,i=new p("*","multiply",[new f("abs",[r.clone()]),new f("sqrt",[new p("-","subtract",[new p("^","pow",[r.clone(),b(2)]),b(1)])])]);break;case"acot":s=!0,u=!0,i=new p("+","add",[new p("^","pow",[r.clone(),b(2)]),b(1)]);break;case"sinh":i=new f("cosh",[r.clone()]);break;case"cosh":i=new f("sinh",[r.clone()]);break;case"tanh":i=new p("^","pow",[new f("sech",[r.clone()]),b(2)]);break;case"sech":u=!0,i=new p("*","multiply",[e,new f("tanh",[r.clone()])]);break;case"csch":u=!0,i=new p("*","multiply",[e,new f("coth",[r.clone()])]);break;case"coth":u=!0,i=new p("^","pow",[new f("csch",[r.clone()]),b(2)]);break;case"asinh":s=!0,i=new f("sqrt",[new p("+","add",[new p("^","pow",[r.clone(),b(2)]),b(1)])]);break;case"acosh":s=!0,i=new f("sqrt",[new p("-","subtract",[new p("^","pow",[r.clone(),b(2)]),b(1)])]);break;case"atanh":s=!0,i=new p("-","subtract",[b(1),new p("^","pow",[r.clone(),b(2)])]);break;case"asech":s=!0,u=!0,i=new p("*","multiply",[r.clone(),new f("sqrt",[new p("-","subtract",[b(1),new p("^","pow",[r.clone(),b(2)])])])]);break;case"acsch":s=!0,u=!0,i=new p("*","multiply",[new f("abs",[r.clone()]),new f("sqrt",[new p("+","add",[new p("^","pow",[r.clone(),b(2)]),b(1)])])]);break;case"acoth":s=!0,u=!0,i=new p("-","subtract",[b(1),new p("^","pow",[r.clone(),b(2)])]);break;case"abs":i=new p("/","divide",[new f(new m("abs"),[r.clone()]),r.clone()]);break;default:throw new Error('Cannot process function "'+e.name+'" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported')}o=s?(a="/","divide"):(a="*","multiply");let l=x(r,t);return u&&(l=new p("-","unaryMinus",[l])),new p(a,o,[l,i])},"OperatorNode, function":function(e,r){if(r(e))return b(0);if("+"===e.op)return new p(e.op,e.fn,e.args.map(function(e){return x(e,r)}));if("-"===e.op){if(e.isUnary())return new p(e.op,e.fn,[x(e.args[0],r)]);if(e.isBinary())return new p(e.op,e.fn,[x(e.args[0],r),x(e.args[1],r)])}if("*"===e.op){const t=e.args.filter(function(e){return r(e)});if(0<t.length){const n=e.args.filter(function(e){return!r(e)}),i=1===n.length?n[0]:new p("*","multiply",n),l=t.concat(x(i,r));return new p("*","multiply",l)}return new p("+","add",e.args.map(function(t){return new p("*","multiply",e.args.map(function(e){return e===t?x(e,r):e.clone()}))}))}if("/"===e.op&&e.isBinary()){const a=e.args[0],o=e.args[1];return r(o)?new p("/","divide",[x(a,r),o]):r(a)?new p("*","multiply",[new p("-","unaryMinus",[a]),new p("/","divide",[x(o,r),new p("^","pow",[o.clone(),b(2)])])]):new p("/","divide",[new p("-","subtract",[new p("*","multiply",[x(a,r),o.clone()]),new p("*","multiply",[a.clone(),x(o,r)])]),new p("^","pow",[o.clone(),b(2)])])}if("^"===e.op&&e.isBinary()){const s=e.args[0],u=e.args[1];if(r(s))return ae(s)&&(c(s.value)||l(s.value,1))?b(0):new p("*","multiply",[e,new p("*","multiply",[new f("log",[s.clone()]),x(u.clone(),r)])]);if(r(u)){if(ae(u)){if(c(u.value))return b(0);if(l(u.value,1))return x(s,r)}const e=new p("^","pow",[s.clone(),new p("-","subtract",[u,b(1)])]);return new p("*","multiply",[u.clone(),new p("*","multiply",[x(s,r),e])])}return new p("*","multiply",[new p("^","pow",[s.clone(),u.clone()]),new p("+","add",[new p("*","multiply",[x(s,r),new p("/","divide",[u.clone(),s.clone()])]),new p("*","multiply",[x(u,r),new f("log",[s.clone()])])])])}throw new Error('Cannot process operator "'+e.op+'" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported')}});function b(e,t){return new a(i(e,t||Ie(String(e),r)))}return d}),e0="rationalize",t0=s(e0,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],e=>{let{typed:t,simplifyConstant:l,simplifyCore:c,simplify:f,ConstantNode:p,OperatorNode:m,SymbolNode:h}=e;function r(a){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o=function(){const e=[c,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},l,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[c,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},l,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),e=function(e,t,r){const n=[],i=f(e,r,t,{exactFractions:!1}),a="+-*/",o=(!function t(r){var e=r.type;if("FunctionNode"===e)throw new Error("There is an unsolved function call");if("OperatorNode"===e)if("^"===r.op){if("ConstantNode"!==r.args[1].type||!v(parseFloat(r.args[1].value)))throw new Error("There is a non-integer exponent");t(r.args[0])}else{if(!a.includes(r.op))throw new Error("Operator "+r.op+" invalid in polynomial expression");for(let e=0;e<r.args.length;e++)t(r.args[e])}else if("SymbolNode"===e){const t=r.name;-1===n.indexOf(t)&&n.push(t)}else if("ParenthesisNode"===e)t(r.content);else if("ConstantNode"!==e)throw new Error("type "+e+" is not allowed in polynomial expression")}(i),{});return o.expression=i,o.variables=n,o}(a,e,o.firstRules),r=e.variables.length,s={exactFractions:!1},u={exactFractions:!0};if(a=e.expression,1<=r){let e,t;a=function t(r,n,i){const e=r.type,a=1<arguments.length;if("OperatorNode"===e&&r.isBinary()){let e,t=!1;if("^"!==r.op||"ParenthesisNode"!==r.args[0].type&&"OperatorNode"!==r.args[0].type||"ConstantNode"!==r.args[1].type||(e=parseFloat(r.args[1].value),t=2<=e&&v(e)),t){if(2<e){const n=r.args[0],i=new m("^","pow",[r.args[0].cloneDeep(),new p(e-1)]);r=new m("*","multiply",[n,i])}else r=new m("*","multiply",[r.args[0],r.args[0].cloneDeep()]);a&&("content"===i?n.content=r:n.args[i]=r)}}if("ParenthesisNode"===e)t(r.content,r,"content");else if("ConstantNode"!==e&&"SymbolNode"!==e)for(let e=0;e<r.args.length;e++)t(r.args[e],r,e);if(!a)return r}(a);let r,n=!0,i=!1;for(a=f(a,o.firstRules,{},s);t=n?o.distrDivRules:o.sucDivRules,n=!n,(r=(a=f(a,t,{},u)).toString())!==e;)i=!0,e=r;i&&(a=f(a,o.firstRulesAgain,{},s)),a=f(a,o.finalRules,{},s)}const n=[],i={};return"OperatorNode"===a.type&&a.isBinary()&&"/"===a.op?(1===r&&(a.args[0]=d(a.args[0],n),a.args[1]=d(a.args[1])),t&&(i.numerator=a.args[0],i.denominator=a.args[1])):(1===r&&(a=d(a,n)),t&&(i.numerator=a,i.denominator=null)),t?(i.coefficients=n,i.variables=e.variables,i.expression=a,i):a}return t(e0,{Node:r,"Node, boolean":(e,t)=>r(e,{},t),"Node, Object":r,"Node, Object, boolean":r});function d(e,a){let o=(a=void 0===a?[]:a)[0]=0,s="";!function t(r,e,n){var i=r.type;if("FunctionNode"===i)throw new Error("There is an unsolved function call");if("OperatorNode"===i){if(!"+-*^".includes(r.op))throw new Error("Operator "+r.op+" invalid");if(null!==e){if(("unaryMinus"===r.fn||"pow"===r.fn)&&"add"!==e.fn&&"subtract"!==e.fn&&"multiply"!==e.fn)throw new Error("Invalid "+r.op+" placing");if(("subtract"===r.fn||"add"===r.fn||"multiply"===r.fn)&&"add"!==e.fn&&"subtract"!==e.fn)throw new Error("Invalid "+r.op+" placing");if(("subtract"===r.fn||"add"===r.fn||"unaryMinus"===r.fn)&&0!==n.noFil)throw new Error("Invalid "+r.op+" placing")}"^"!==r.op&&"*"!==r.op||(n.fire=r.op);for(let e=0;e<r.args.length;e++)"unaryMinus"===r.fn&&(n.oper="-"),"+"!==r.op&&"subtract"!==r.fn||(n.fire="",n.cte=1,n.oper=0===e?"+":r.op),n.noFil=e,t(r.args[e],r,n)}else if("SymbolNode"===i){if(r.name!==s&&""!==s)throw new Error("There is more than one variable");if(s=r.name,null===e)return a[1]=1,0;if("^"===e.op&&0!==n.noFil)throw new Error("In power the variable should be the first parameter");if("*"===e.op&&1!==n.noFil)throw new Error("In multiply the variable should be the second parameter");""!==n.fire&&"*"!==n.fire||(o<1&&(a[1]=0),a[1]+=n.cte*("+"===n.oper?1:-1),o=Math.max(1,o))}else{if("ConstantNode"!==i)throw new Error("Type "+i+" is not allowed");{const t=parseFloat(r.value);if(null===e)return a[0]=t,0;if("^"===e.op){if(1!==n.noFil)throw new Error("Constant cannot be powered");if(!v(t)||t<=0)throw new Error("Non-integer exponent is not allowed");for(let e=o+1;e<t;e++)a[e]=0;return t>o&&(a[t]=0),a[t]+=n.cte*("+"===n.oper?1:-1),o=Math.max(t,o),0}n.cte=t,""===n.fire&&(a[0]+=n.cte*("+"===n.oper?1:-1))}}}(e,null,{cte:1,oper:"+",fire:""});let n,i=!0;for(let r=o=a.length-1;0<=r;r--)if(0!==a[r]){let t=new p(i?a[r]:Math.abs(a[r]));var u=a[r]<0?"-":"+";if(0<r){let e=new h(s);if(1<r){const a=new p(r);e=new m("^","pow",[e,a])}t=-1===a[r]&&i?new m("-","unaryMinus",[e]):1===Math.abs(a[r])?e:new m("*","multiply",[t,e])}n=i?t:"+"==u?new m("+","add",[n,t]):new m("-","subtract",[n,t]),i=!1}return i?new p(0):n}}),r0=s("zpk2tf",["typed","add","multiply","Complex","number"],e=>{let{typed:t,add:a,multiply:o,Complex:s,number:u}=e;return t("zpk2tf",{"Array,Array,number":n,"Array,Array":function(e,t){return n(e,t,1)},"Matrix,Matrix,number":function(e,t,r){return n(e.valueOf(),t.valueOf(),r)},"Matrix,Matrix":function(e,t){return n(e.valueOf(),t.valueOf(),1)}});function n(r,n,t){r.some(e=>"BigNumber"===e.type)&&(r=r.map(e=>u(e))),n.some(e=>"BigNumber"===e.type)&&(n=n.map(e=>u(e)));let i=[s(1,0)],a=[s(1,0)];for(let t=0;t<r.length;t++){let e=r[t];"number"==typeof e&&(e=s(e,0)),i=l(i,[s(1,0),s(-e.re,-e.im)])}for(let t=0;t<n.length;t++){let e=n[t];"number"==typeof e&&(e=s(e,0)),a=l(a,[s(1,0),s(-e.re,-e.im)])}for(let e=0;e<i.length;e++)i[e]=o(i[e],t);return[i,a]}function l(r,n){const i=[];for(let t=0;t<r.length+n.length-1;t++){i[t]=s(0,0);for(let e=0;e<r.length;e++)0<=t-e&&t-e<n.length&&(i[t]=a(i[t],o(r[e],n[t-e])))}return i}}),n0=s("freqz",["typed","add","multiply","Complex","divide","matrix"],e=>{let{typed:t,add:l,multiply:c,Complex:f,divide:r,matrix:n}=e;return t("freqz",{"Array, Array":function(e,t){return i(e,t,a(512))},"Array, Array, Array":i,"Array, Array, number":function(e,t,r){if(r<0)throw new Error("w must be a positive number");return i(e,t,a(r))},"Matrix, Matrix":function(e,t){var r=a(512),{w:e,h:t}=i(e.valueOf(),t.valueOf(),r);return{w:n(e),h:n(t)}},"Matrix, Matrix, Matrix":function(e,t,r){e=i(e.valueOf(),t.valueOf(),r.valueOf()).h;return{h:n(e),w:n(r)}},"Matrix, Matrix, number":function(e,t,r){if(r<0)throw new Error("w must be a positive number");r=a(r),e=i(e.valueOf(),t.valueOf(),r).h;return{h:n(e),w:n(r)}}});function i(i,a,o){const s=[],u=[];for(let n=0;n<o.length;n++){let t=f(0,0),r=f(0,0);for(let e=0;e<i.length;e++)t=l(t,c(i[e],f(Math.cos(-e*o[n]),Math.sin(-e*o[n]))));for(let e=0;e<a.length;e++)r=l(r,c(a[e],f(Math.cos(-e*o[n]),Math.sin(-e*o[n]))));s.push(t),u.push(r)}const t=[];for(let e=0;e<s.length;e++)t.push(r(s[e],u[e]));return{h:t,w:o}}function a(t){const r=[];for(let e=0;e<t;e++)r.push(e/t*Math.PI);return r}}),i0=s("reviver",["classes"],e=>{let n=e["classes"];return function(e,t){const r=n[t&&t.mathjs];return r&&"function"==typeof r.fromJSON?r.fromJSON(t):t}}),a0=s("replacer",[],()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?"bigint"==typeof t?{mathjs:"bigint",value:String(t)}:t:{mathjs:"number",value:String(t)}}),o0=Math.PI,s0=2*Math.PI,u0=Math.E,l0=s("true",[],()=>!0),c0=s("false",[],()=>!1),f0=s("null",[],()=>null),p0=T0("Infinity",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0}),m0=T0("NaN",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN}),h0=T0("pi",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?_l(t):o0}),d0=T0("tau",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?zl(t):s0}),g0=T0("e",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?Dl(t):u0}),y0=T0("phi",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?Ol(t):1.618033988749895}),x0=T0("LN2",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2}),b0=T0("LN10",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10}),v0=T0("LOG2E",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E}),w0=T0("LOG10E",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E}),N0=T0("SQRT1_2",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2}),A0=T0("SQRT2",["config","?BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2}),E0=T0("i",["Complex"],e=>{e=e.Complex;return e.I}),S0=s("PI",["pi"],e=>{e=e.pi;return e}),M0=s("E",["e"],e=>{e=e.e;return e}),C0=s("version",[],()=>"14.8.1");function T0(e,t,r){return s(e,t,r,{recreateOnConfigChange:!0})}const B0=e("speedOfLight","299792458","m s^-1"),F0=e("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),D0=e("planckConstant","6.62607015e-34","J s"),O0=e("reducedPlanckConstant","1.0545718176461565e-34","J s"),_0=e("magneticConstant","1.25663706212e-6","N A^-2"),z0=e("electricConstant","8.8541878128e-12","F m^-1"),q0=e("vacuumImpedance","376.730313667","ohm"),I0=e("coulomb","8.987551792261171e9","N m^2 C^-2"),k0=e("coulombConstant","8.987551792261171e9","N m^2 C^-2"),R0=e("elementaryCharge","1.602176634e-19","C"),P0=e("bohrMagneton","9.2740100783e-24","J T^-1"),U0=e("conductanceQuantum","7.748091729863649e-5","S"),j0=e("inverseConductanceQuantum","12906.403729652257","ohm"),L0=e("magneticFluxQuantum","2.0678338484619295e-15","Wb"),$0=e("nuclearMagneton","5.0507837461e-27","J T^-1"),H0=e("klitzing","25812.807459304513","ohm"),G0=e("bohrRadius","5.29177210903e-11","m"),V0=e("classicalElectronRadius","2.8179403262e-15","m"),Z0=e("electronMass","9.1093837015e-31","kg"),W0=e("fermiCoupling","1.1663787e-5","GeV^-2"),Y0=Mh("fineStructure",.0072973525693),J0=e("hartreeEnergy","4.3597447222071e-18","J"),X0=e("protonMass","1.67262192369e-27","kg"),Q0=e("deuteronMass","3.3435830926e-27","kg"),K0=e("neutronMass","1.6749271613e-27","kg"),eh=e("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),th=e("rydberg","10973731.568160","m^-1"),rh=e("thomsonCrossSection","6.6524587321e-29","m^2"),nh=Mh("weakMixingAngle",.2229),ih=Mh("efimovFactor",22.7),ah=e("atomicMass","1.66053906660e-27","kg"),oh=e("avogadro","6.02214076e23","mol^-1"),sh=e("boltzmann","1.380649e-23","J K^-1"),uh=e("faraday","96485.33212331001","C mol^-1"),lh=e("firstRadiation","3.7417718521927573e-16","W m^2"),ch=e("loschmidt","2.686780111798444e25","m^-3"),fh=e("gasConstant","8.31446261815324","J K^-1 mol^-1"),ph=e("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),mh=e("molarVolume","0.022413969545014137","m^3 mol^-1"),hh=Mh("sackurTetrode",-1.16487052358),dh=e("secondRadiation","0.014387768775039337","m K"),gh=e("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),yh=e("wienDisplacement","2.897771955e-3","m K"),xh=e("molarMass","0.99999999965e-3","kg mol^-1"),bh=e("molarMassC12","11.9999999958e-3","kg mol^-1"),vh=e("gravity","9.80665","m s^-2"),wh=e("planckLength","1.616255e-35","m"),Nh=e("planckMass","2.176435e-8","kg"),Ah=e("planckTime","5.391245e-44","s"),Eh=e("planckCharge","1.87554603778e-18","C"),Sh=e("planckTemperature","1.416785e+32","K");function e(e,a,o){return s(e,["config","Unit","BigNumber"],e=>{let{config:t,Unit:r,BigNumber:n}=e;const i=new r("BigNumber"===t.number?new n(a):parseFloat(a),o);return i.fixPrefix=!0,i})}function Mh(e,n){return s(e,["config","BigNumber"],e=>{let{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(n):n})}const Ch=s("mapSlices",["typed","isInteger"],e=>{let{typed:t,isInteger:r}=e;const n=ga({typed:t,isInteger:r});return t("mapSlices",{"...any":function(e){const t=e[1];A(t)?e[1]=t-1:Q(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0,...ga.meta}),Th=s("column",["typed","Index","matrix","range"],e=>{let{typed:t,Index:r,matrix:n,range:i}=e;const a=es({typed:t,Index:r,matrix:n,range:i});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];A(r)&&(e[t]=r-1);try{return a.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0});function Bh(e,t,r){var n=e.filter(function(e){return se(e)&&!(e.name in t)&&!r.has(e.name)})[0];if(!n)throw new Error('No undefined variable found in inline expression "'+e+'"');const i=n.name,a=new Map,o=new k(r,a,new Set([i])),s=e.compile();return function(e){return a.set(i,e),s.evaluate(o)}}const Fh=s("transformCallback",["typed"],e=>{let o=e["typed"];return function(e,t){return o.isTypedFunction(e)?function i(e,a){const t=Object.fromEntries(Object.entries(e.signatures).map(e=>{let[t,r]=e;const n=t.split(",").length;return o.isTypedFunction(r)?[t,i(r,a)]:[t,Dh(r,n,a)]}));return"string"==typeof e.name?o(e.name,t):o(t)}(e,t):Dh(e,e.length,t)}});function Dh(o,e,s){return e===s?o:e===s+1?function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t.slice(0,s),i=Oh(t[s]);return o(...n,i)}:s+1<e?function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t.slice(0,s),i=Oh(t[s]),a=t.slice(s+1);return o(...n,i,...a)}:o}function Oh(e){return e.map(e=>e+1)}const _h=s("filter",["typed"],e=>{let u=e["typed"];function t(e,t,r){const n=is({typed:u}),i=Fh({typed:u});if(0===e.length)return n();let a=e[0];if(1===e.length)return n(a);var o=e.length-1;let s=e[o];return a=a&&l(a,r),s=s&&(se(s)||Ne(s)?l(s,r):Bh(s,t,r)),n(a,i(s,o))}function l(e,t){return e.compile().evaluate(t)}return t.rawArgs=!0,t},{isTransformFunction:!0}),zh=s("forEach",["typed"],e=>{e=e.typed;const o=ls({typed:e}),s=Fh({typed:e});function t(e,t,r){if(0===e.length)return o();let n=e[0];if(1===e.length)return o(n);var i=e.length-1;let a=e[i];return n=n&&u(n,r),a=a&&(se(a)||Ne(a)?u(a,r):Bh(a,t,r)),o(n,s(a,i))}function u(e,t){return e.compile().evaluate(t)}return t.rawArgs=!0,t},{isTransformFunction:!0}),qh=s("index",["Index","getMatrixDataType"],e=>{let{Index:t,getMatrixDataType:n}=e;return function(){const r=[];for(let t=0,e=arguments.length;t<e;t++){let e=arguments[t];if(V(e))e.start--,e.end-=0<e.step?0:2;else if(e&&!0===e.isSet)e=e.map(function(e){return e-1});else if(b(e)||_(e))"boolean"!==n(e)&&(e=e.map(function(e){return e-1}));else if(A(e)||R(e))e--;else if(Q(e))e=e.toNumber()-1;else if("string"!=typeof e)throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");r[t]=e}var e=new t;return t.apply(e,r),e}},{isTransformFunction:!0}),Ih=s("map",["typed"],e=>{e=e.typed;const s=gs({typed:e}),u=Fh({typed:e});function t(e,t,r){if(0===e.length)return s();if(1===e.length)return s(e[0]);var n=e.length-1;let i=e.slice(0,n),a=e[n];return i=i.map(e=>o(e,r)),a=a&&(se(a)||Ne(a)?o(a,r):Bh(a,t,r)),s(...i,u(a,n));function o(e,t){return e.compile().evaluate(t)}}return t.rawArgs=!0,t},{isTransformFunction:!0});function kh(e){var t,r;return 2===e.length&&$(e[0])&&(A(r=t=(e=e.slice())[1])||Q(r))&&(e[1]=A(r=t)?r-1:Q(r)?r.minus(1):r),e}const Rh=s("max",["typed","config","numeric","larger","isNaN"],e=>{let{typed:t,config:r,numeric:n,larger:i,isNaN:a}=e;const o=Nl({typed:t,config:r,numeric:n,larger:i,isNaN:a});return t("max",{"...any":function(e){e=kh(e);try{return o.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Ph=s("mean",["typed","add","divide"],e=>{let{typed:t,add:r,divide:n}=e;const i=Lp({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=kh(e);try{return i.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Uh=s("min",["typed","config","numeric","smaller","isNaN"],e=>{let{typed:t,config:r,numeric:n,smaller:i,isNaN:a}=e;const o=Al({typed:t,config:r,numeric:n,smaller:i,isNaN:a});return t("min",{"...any":function(e){e=kh(e);try{return o.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),jh=s("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],e=>{let{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u,add:l,isPositive:c}=e;const f=Ns({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u,add:l,isPositive:c});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),f.apply(null,e)}})},{isTransformFunction:!0}),Lh=s("row",["typed","Index","matrix","range"],e=>{let{typed:t,Index:r,matrix:n,range:i}=e;const a=Bs({typed:t,Index:r,matrix:n,range:i});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];A(r)&&(e[t]=r-1);try{return a.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),$h=s("subset",["typed","matrix","zeros","add"],e=>{let{typed:t,matrix:r,zeros:n,add:i}=e;const a=_s({typed:t,matrix:r,zeros:n,add:i});return t("subset",{"...any":function(e){try{return a.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Hh=s("concat",["typed","matrix","isInteger"],e=>{let{typed:t,matrix:r,isInteger:n}=e;const i=Ko({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){const t=e.length-1,r=e[t];A(r)?e[t]=r-1:Q(r)&&(e[t]=r.minus(1));try{return i.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Gh=s("diff",["typed","matrix","subtract","number","bignumber"],e=>{let{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e;const o=ys({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t("diff",{"...any":function(e){e=kh(e);try{return o.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Vh=s("std",["typed","map","sqrt","variance"],e=>{let{typed:t,map:r,sqrt:n,variance:i}=e;const a=Jp({typed:t,map:r,sqrt:n,variance:i});return t("std",{"...any":function(e){e=kh(e);try{return a.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Zh=s("sum",["typed","config","add","numeric"],e=>{let{typed:t,config:r,add:n,numeric:i}=e;const a=Pp({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=kh(e);try{return a.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Wh=s("quantileSeq",["typed","bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger","mapSlices"],e=>{let{typed:t,bignumber:r,add:n,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:u,isInteger:l,smaller:c,smallerEq:f,larger:p,mapSlices:m}=e;const h=Yp({typed:t,bignumber:r,add:n,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:u,isInteger:l,smaller:c,smallerEq:f,larger:p,mapSlices:m});return t("quantileSeq",{"Array | Matrix, number | BigNumber":h,"Array | Matrix, number | BigNumber, number":(e,t,r)=>h(e,t,d(r)),"Array | Matrix, number | BigNumber, boolean":h,"Array | Matrix, number | BigNumber, boolean, number":(e,t,r,n)=>h(e,t,r,d(n)),"Array | Matrix, Array | Matrix":h,"Array | Matrix, Array | Matrix, number":(e,t,r)=>h(e,t,d(r)),"Array | Matrix, Array | Matrix, boolean":h,"Array | Matrix, Array | Matrix, boolean, number":(e,t,r,n)=>h(e,t,r,d(n))});function d(e){return kh([[],e])[1]}},{isTransformFunction:!0}),Yh=s("cumsum",["typed","add","unaryPlus"],e=>{let{typed:t,add:r,unaryPlus:n}=e;const i=jp({typed:t,add:r,unaryPlus:n});return t("cumsum",{"...any":function(e){if(2===e.length&&$(e[0])){const t=e[1];A(t)?e[1]=t-1:Q(t)&&(e[1]=t.minus(1))}try{return i.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Jh="variance",Xh=s(Jh,["typed","add","subtract","multiply","divide","mapSlices","isNaN"],e=>{let{typed:t,add:r,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:s}=e;const u=Zp({typed:t,add:r,subtract:n,multiply:i,divide:a,mapSlices:o,isNaN:s});return t(Jh,{"...any":function(e){e=kh(e);try{return u.apply(null,e)}catch(e){throw sf(e)}}})},{isTransformFunction:!0}),Qh=s("print",["typed","matrix","zeros","add"],e=>{let{typed:t,matrix:r,zeros:n,add:i}=e;const a=su({typed:t,matrix:r,zeros:n,add:i});return t("print",{"string, Object | Array":function(e,t){return a(o(e),t)},"string, Object | Array, number | Object":function(e,t,r){return a(o(e),t,r)}});function o(e){return e.replace(ou,e=>"$"+e.slice(1).split(".").map(function(e){return!isNaN(e)&&0<e.length?parseInt(e)-1:e}).join("."))}},{isTransformFunction:!0}),Kh=s("and",["typed","matrix","zeros","add","equalScalar","not","concat"],e=>{var{typed:e,matrix:t,equalScalar:r,zeros:n,not:i,concat:a}=e;const o=Lu({typed:e,matrix:t,equalScalar:r,zeros:n,not:i,concat:a});function s(e,t,r){var n=e[0].compile().evaluate(r);if(!$(n)&&!o(n,!0))return!1;e=e[1].compile().evaluate(r);return o(n,e)}return s.rawArgs=!0,s},{isTransformFunction:!0}),ed=s("or",["typed","matrix","equalScalar","DenseMatrix","concat"],e=>{var{typed:e,matrix:t,equalScalar:r,DenseMatrix:n,concat:i}=e;const a=Xo({typed:e,matrix:t,equalScalar:r,DenseMatrix:n,concat:i});function o(e,t,r){var n=e[0].compile().evaluate(r);if(!$(n)&&a(n,!1))return!0;e=e[1].compile().evaluate(r);return a(n,e)}return o.rawArgs=!0,o},{isTransformFunction:!0}),td=s("nullish",["typed","matrix","size","flatten","deepEqual"],e=>{var{typed:e,matrix:t,size:r,flatten:n,deepEqual:i}=e;const a=Jo({typed:e,matrix:t,size:r,flatten:n,deepEqual:i});function o(e,t,r){var n=e[0].compile().evaluate(r);if(!$(n)&&null!=n&&void 0!==n)return n;e=e[1].compile().evaluate(r);return a(n,e)}return o.rawArgs=!0,o},{isTransformFunction:!0}),rd=s("bitAnd",["typed","matrix","zeros","add","equalScalar","not","concat"],e=>{var{typed:e,matrix:t,equalScalar:r,zeros:n,not:i,concat:a}=e;const o=zo({typed:e,matrix:t,equalScalar:r,zeros:n,not:i,concat:a});function s(e,t,r){var n=e[0].compile().evaluate(r);if(!$(n)){if(isNaN(n))return NaN;if(0===n||!1===n)return 0}e=e[1].compile().evaluate(r);return o(n,e)}return s.rawArgs=!0,s},{isTransformFunction:!0}),nd=s("bitOr",["typed","matrix","equalScalar","DenseMatrix","concat"],e=>{var{typed:e,matrix:t,equalScalar:r,DenseMatrix:n,concat:i}=e;const a=Io({typed:e,matrix:t,equalScalar:r,DenseMatrix:n,concat:i});function o(e,t,r){var n=e[0].compile().evaluate(r);if(!$(n)){if(isNaN(n))return NaN;if(-1===n)return-1;if(!0===n)return 1}e=e[1].compile().evaluate(r);return a(n,e)}return o.rawArgs=!0,o},{isTransformFunction:!0});var id=fd(504);const ad={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null},od=["Matrix","Array"],sd=["number","BigNumber","bigint","Fraction"];function ud(n,i){function a(e){if(e){if(void 0!==e.epsilon){console.warn('Warning: The configuration option "epsilon" is deprecated. Use "relTol" and "absTol" instead.');const n=ee(e);return n.relTol=e.epsilon,n.absTol=.001*e.epsilon,delete n.epsilon,a(n)}var t=ee(n),r=(ld(e,"matrix",od),ld(e,"number",sd),function e(t,r){if(Array.isArray(r))throw new TypeError("Arrays are not supported by deepExtend");for(const n in r)if(ue(r,n)&&!(n in Object.prototype)&&!(n in Function.prototype))if(r[n]&&r[n].constructor===Object)void 0===t[n]&&(t[n]={}),t[n]&&t[n].constructor===Object?e(t[n],r[n]):t[n]=r[n];else{if(Array.isArray(r[n]))throw new TypeError("Arrays are not supported by deepExtend");t[n]=r[n]}}(n,e),ee(n)),e=ee(e);return i("config",r,t,e),r}return ee(n)}return a.MATRIX_OPTIONS=od,a.NUMBER_OPTIONS=sd,Object.keys(ad).forEach(e=>{Object.defineProperty(a,e,{get:()=>n[e],enumerable:!0,configurable:!0})}),a}function ld(e,t,r){void 0===e[t]||r.includes(e[t])||console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+r.map(e=>JSON.stringify(e)).join(", ")+".")}const cd=function e(t,r){r=gn({},ad,r);if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");const n=function(e){const t=new id;return e.on=t.on.bind(t),e.off=t.off.bind(t),e.once=t.once.bind(t),e.emit=t.emit.bind(t),e}({isNumber:A,isComplex:te,isBigNumber:Q,isBigInt:R,isFraction:re,isUnit:L,isString:j,isArray:b,isMatrix:_,isCollection:$,isDenseMatrix:H,isSparseMatrix:G,isRange:V,isIndex:Z,isBoolean:W,isResultSet:Y,isHelp:J,isFunction:X,isDate:ne,isRegExp:ie,isObject:ce,isMap:fe,isPartitionedMap:pe,isObjectWrappingMap:me,isNull:he,isUndefined:de,isAccessorNode:ge,isArrayNode:ye,isAssignmentNode:xe,isBlockNode:be,isConditionalNode:ve,isConstantNode:ae,isFunctionAssignmentNode:Ne,isFunctionNode:Ae,isIndexNode:Ee,isNode:O,isObjectNode:Se,isOperatorNode:oe,isParenthesisNode:Me,isRangeNode:Ce,isRelationalNode:Te,isSymbolNode:se,isChain:Be}),i=(n.config=ud(r,n.emit),n.expression={transform:{},mathWithTransform:{config:n.config}},{});function a(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.typed.apply(n.typed,t)}a.isTypedFunction=l.isTypedFunction;const o=function(f,p,m){function a(e,t,r){var n;if(r.wrap&&"function"==typeof t&&((n=t).transform&&(i.transform=n.transform),t=i),"function"==typeof t&&"string"==typeof t.signature&&(t=f(e,{[t.signature]:t})),f.isTypedFunction(p[e])&&f.isTypedFunction(t))return t=r.override?f(e,t.signatures):f(p[e],t),p[e]=t,delete m[e],s(e,t),p.emit("import",e,function(){return t});function i(){const r=[];for(let e=0,t=arguments.length;e<t;e++){const p=arguments[e];r[e]=p&&p.valueOf()}return n.apply(p,r)}var a=void 0!==p[e],o=null==(o=p.Unit)?void 0:o.isValuelessUnit(e);if(!a&&!o||r.override)return p[e]=t,delete m[e],s(e,t),p.emit("import",e,function(){return t});if(!r.silent)throw new Error('Cannot import "'+e+'": already exists')}function s(e,t){t&&"function"==typeof t.transform?(p.expression.transform[e]=t.transform,r(e)&&(p.expression.mathWithTransform[e]=t.transform)):(delete p.expression.transform[e],r(e)&&(p.expression.mathWithTransform[e]=t))}function h(e){delete p.expression.transform[e],r(e)?p.expression.mathWithTransform[e]=p[e]:delete p.expression.mathWithTransform[e]}function o(r,n,e){let i=2<arguments.length&&void 0!==e?e:r.fn;if(i.includes("."))throw new Error("Factory name should not contain a nested path. Name: "+JSON.stringify(i));function t(){const t={};r.dependencies.map(qe).forEach(e=>{if(e.includes("."))throw new Error("Factory dependency should not contain a nested path. Name: "+JSON.stringify(e));"math"===e?t.math=p:"mathWithTransform"===e?t.mathWithTransform=p.expression.mathWithTransform:"classes"===e?t.classes=p:t[e]=p[e]});var e=r(t);if(e&&"function"==typeof e.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"');if(void 0===s||n.override)return e;if(f.isTypedFunction(s)&&f.isTypedFunction(e))return f(s,e);if(n.silent)return s;throw new Error('Cannot import "'+i+'": already exists')}const a=d(r)?p.expression.transform:p,o=i in p.expression.transform,s=ue(a,i)?a[i]:void 0,u=null!=(e=null==(e=r.meta)?void 0:e.formerly)?e:"",l=d(r)||!((e=r).fn.includes(".")||ue(g,e.fn)||e.meta&&e.meta.isClass),c=p.expression.mathWithTransform;r.meta&&!1===r.meta.lazy?(a[i]=t(),u&&(a[u]=a[i])):(_e(a,i,t),u&&_e(a,u,t)),s&&o?(h(i),u&&h(u)):l&&(_e(c,i,()=>a[i]),u&&_e(c,u,()=>a[i])),m[i]=r,p.emit("import",i,t)}function r(e){return!ue(g,e)}function d(e){return void 0!==e&&void 0!==e.meta&&!0===e.meta.isTransformFunction||!1}const g={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return function(e,i){const t=arguments.length;if(1!==t&&2!==t)throw new Za("import",t,1,2);i=i||{};var r,n={};!function t(r,e,n){if(Array.isArray(e))e.forEach(e=>t(r,e));else if(ce(e)||"object"==typeof e&&"Module"===e[Symbol.toStringTag])for(const i in e)ue(e,i)&&t(r,e[i],i);else if(ze(e)||void 0!==n){const t=ze(e)?d(e)?e.fn+".transform":e.fn:n;if(ue(r,t)&&r[t]!==e&&!i.silent)throw new Error('Cannot import "'+t+'" twice');r[t]=e}else if(!i.silent)throw new TypeError("Factory, Object, or Array expected")}(n,e);for(const e in n)if(ue(n,e)){const t=n[e];if(ze(t))o(t,i);else if("function"==typeof(r=t)||"number"==typeof r||"string"==typeof r||"boolean"==typeof r||null===r||L(r)||te(r)||Q(r)||re(r)||_(r)||Array.isArray(r))a(e,t,i);else if(!i.silent)throw new TypeError("Factory, Object, or Array expected")}}}(a,n,i);return n.import=o,n.on("config",()=>{Object.values(i).forEach(e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&o(e,{override:!0})})}),n.create=e.bind(null,t),n.factory=s,n.import(Object.values(Oe(t))),n.ArgumentsError=Za,n.DimensionError=z,n.IndexError=En,n}(t)})(),pd.default}); |