/* ------------------------------------------- Meta Bind - Release Build ------------------------------------------- By: Moritz Jung (https://www.moritzjung.dev/) Version: 1.4.15 ------------------------------------------- THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin ------------------------------------------- Copyright (C) 2026 Moritz Jung ------------------------------------------- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("@codemirror/language"),d=require("@codemirror/view"),f=require("obsidian");var p=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],m=[{index:0,name:`Sunday`,shortName:`Su`},{index:1,name:`Monday`,shortName:`Mo`},{index:2,name:`Tuesday`,shortName:`Tu`},{index:3,name:`Wednesday`,shortName:`We`},{index:4,name:`Thursday`,shortName:`Th`},{index:5,name:`Friday`,shortName:`Fr`},{index:6,name:`Saturday`,shortName:`Sa`}],h={devMode:!1,ignoreCodeBlockRestrictions:!1,preferredDateFormat:`YYYY-MM-DD`,firstWeekday:m[1],syncInterval:200,enableJs:!1,viewFieldDisplayNullAsEmpty:!1,enableSyntaxHighlighting:!0,enableEditorRightClickMenu:!0,inputFieldTemplates:[],buttonTemplates:[],excludedFolders:[`templates`]},g=1e3;function _(e,t,n){return Math.min(Math.max(e,t),n)}function v(e,t,n){return e===void 0?void 0:Math.min(Math.max(e,t),n)}function y(e,t,n,r,i){return(e-t)/(n-t)*(i-r)+r}function b(e,t){return(e%t+t)%t}function x(e,t){if(e===t||typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t))return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t)return!1;if(typeof e!=`object`)return e===t;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=Array.isArray(e),r=Array.isArray(t);if(n||r){if(!n||!r)return!1;let i=e,a=t;if(i.length!==a.length)return!1;for(let e=0;e=this.input.length}advanceTo(e){this.position=e}sliceTo(e){return this.input.slice(this.position,e)}succeedOffset(e,t){return this.succeedAt(this.position+e,t)}failOffset(e,t){return this.failAt(this.position+e,t)}succeed(e){return this.succeedAt(this.position,e)}fail(e){return this.failAt(this.position,e)}succeedAt(e,t){return this.advanceTo(e),{success:!0,value:t}}failAt(e,t){return this.advanceTo(e),this.addError(Array.isArray(t)?t:[t]),{success:!1,value:void 0}}addError(e){this.latestError===void 0||this.latestError.positiont[a](n,i)),Object.defineProperty(r,a,{get:()=>{if(n[a]!==void 0)return n[a];throw Error(`Can not access rule '${a}' in language. Rule is not yet defined. Try to access it via 'ref'.`)}});for(let e in t)n[e]=t[e](r,i);return n}static or(...e){if(e.length===0)throw Error(`or must have at least one alternative`);return new oe(function(t){let n=t.position;for(let r of e){let e=r;t.position=n;let i=e.p(t);if(i.success)return i}return{success:!1,value:void 0}})}static separateBy(t,n){return this.separateByNotEmpty(t,n).or(e.succeed([]))}static separateByNotEmpty(e,t){return this.sequenceMap(function(e,t){return t.unshift(e),t},e,t.then(e).many())}static string(e){let t=`'`+e+`'`;return new oe(function(n){for(let r=0;r=0&&e<=a.length){let t=a[0],n=a[e];return r.succeedOffset(t.length,n)}let i=`expected valid match group (0 to `+a.length+`) in `+n;return r.fail(i)}else return r.fail(n)})}static succeed(e){return new oe(function(t){return t.succeed(e)})}static fail(e){return new oe(function(t){return t.fail(e)})}static oneOf(e){return ue.test(function(t){return e.includes(t)},`one character of '${e}'`)}static noneOf(e){return ue.test(function(t){return!e.includes(t)},`no character of '${e}'`)}static oneStringOf(e){return this.or(...e.map(e=>this.string(e))).describe(e.map(e=>`'${e}'`).join(` or `))}static manyOf(e){return new oe(function(t){let n=t.position;for(;ne.succeed(e.position))}static any(){return new oe(e=>e.atEOF()?e.fail(`any character`):e.succeedOffset(1,e.input[e.position]))}static remaining(){return new oe(e=>e.succeedAt(e.input.length,e.input.slice(e.position)))}static eof(){return new oe(e=>e.atEOF()?e.succeed(void 0):e.fail(`eof`))}static digit(){return ue.testCharCode(e=>e>=F&&e<=I,`a digit`)}static digits(){return ue.testCharCodes(e=>e>=F&&e<=I,`multiple digits`)}static letter(){return ue.testCharCode(e=>e>=L&&e<=ie||e>=ae&&e<=R,`a letter`)}static letters(){return ue.testCharCodes(e=>e>=L&&e<=ie||e>=ae&&e<=R,`multiple letters`)}static unicodeLetter(){return P.regexp(/^\p{L}/iu).describe(`a unicode letter`)}static unicodeLetters(){return P.regexp(/^\p{L}+/iu).describe(`multiple unicode letters`)}static unicodeAlphanumeric(){return P.regexp(/^[\p{L}\p{N}]/iu).describe(`a unicode alphanumeric character`)}static unicodeAlphanumerics(){return P.regexp(/^[\p{L}\p{N}]+/iu).describe(`multiple unicode alphanumeric characters`)}static optionalWhitespace(){return new oe(function(e){let t=e.position;for(;t=e.input.length)return e.fail(`\\r\\n`);let t=e.input[e.position],n=e.input[e.position+1];return t===`\r`&&n===` `?e.succeedOffset(2,void 0):e.fail(`\\r\\n`)})}static newline(){let e=`newline`;return new oe(function(t){if(t.position>=t.input.length)return t.fail(e);let n=t.input[t.position];return n===` `?t.succeedOffset(1,void 0):n===`\r`?t.position+1e.reduce((e,t)=>n(t,e),t),e.many(),t)}static postfix(e,t,n){return P.sequenceMap((e,t)=>t.reduce((e,t)=>n(t,e),e),t,e.many())}static binaryRight(e,t,n){return P.sequenceMap((e,t)=>e.reverse().reduce((e,t)=>{let[r,i]=t;return n(r,i,e)},t),P.sequence(t,e.trim(this.optionalWhitespace())).many(),t)}static binaryLeft(e,t,n){return P.sequenceMap((e,t)=>t.reduce((e,t)=>{let[r,i]=t;return n(e,r,i)},e),t,P.sequence(e.trim(this.optionalWhitespace()),t).many())}static binaryRightRange(t,n,r){return P.sequenceMap((e,t,n)=>e.reverse().reduce((e,t)=>{let[i,a,o]=t;return r({from:i,to:n},a,o,e)},t),P.sequence(e.position(),n,t.trim(this.optionalWhitespace())).many(),n,e.position())}static binaryLeftRange(t,n,r){return P.sequenceMap((e,t,n)=>n.reduce((t,n)=>{let[i,a,o]=n;return r({from:e,to:o},t,i,a)},t),e.position(),n,P.sequence(t.trim(this.optionalWhitespace()),n,e.position()).many())}static func(e,t,n){let r=typeof e==`string`?P.string(e):e;return P.sequenceMap((e,t,r,i,a,o)=>n(e,i),r,P.string(`(`),this.optionalWhitespace(),t,this.optionalWhitespace(),P.string(`)`))}},oe=class e{p;constructor(e){this.p=e}tryParse(e){let t=new ee(e,0),n=this.p(t);return n.success?n:{success:!1,value:void 0,furthest:t.latestError.position,expected:t.latestError.expected}}parse(e){let t=this.tryParse(e);if(t.success)return t.value;throw new ne(e,t)}or(e){let t=this;return P.or(t,e)}trim(e){return this.wrap(e,e)}trimString(e){return this.trim(P.string(e))}wrap(t,n){let r=this;return new e(function(e){let i=t.p(e);if(!i.success)return i;let a=r.p(e);if(!a.success)return a;let o=n.p(e);return o.success?a:o})}wrapString(e,t){return this.wrap(P.string(e),P.string(t))}then(t){let n=this;return new e(function(e){let r=n.p(e);if(!r.success)return r;let i=t.p(e);return i.success,i})}skip(t){let n=this;return new e(function(e){let r=n.p(e);if(!r.success)return r;let i=t.p(e);return i.success?r:i})}and(e){let t=this;return P.sequence(t,e)}many(){let t=this;return new e(function(e){let n=[];for(;;){let r=e.position,i=t.p(e);if(i.success){if(e.position===r)throw Error(`infinite loop in many() parser detected`);n.push(i.value)}else return e.position=r,{success:!0,value:n}}})}repeat(t,n){ce(t,n);let r=this;return new e(function(e){let i=[],a=0;for(;a=t?{success:!0,value:i}:{success:!1,value:void 0}}return{success:!0,value:i}})}atMost(e){return this.repeat(0,e)}atLeast(e){return P.sequenceMap((e,t)=>e.concat(t),this.repeat(e,e),this.many())}separateBy(e){return P.separateBy(this,e)}separateByNotEmpty(e){return P.separateByNotEmpty(this,e)}result(e){return this.map(()=>e)}map(t){let n=this;return new e(function(e){let r=n.p(e);return r.success?{success:!0,value:t(r.value)}:r})}marker(){let e=this;return P.sequenceMap(function(e,t,n){return{value:t,range:{from:e,to:n}}},z.position(),e,z.position())}namedMarker(e){let t=this;return P.sequenceMap(function(t,n,r){return{value:n,name:e,range:{from:t,to:r}}},z.position(),t,z.position())}node(e){let t=this;return P.sequenceMap(function(t,n,r){return e(n,{from:t,to:r})},z.position(),t,z.position())}followedBy(e){return this.skip(ue.followedBy(e))}notFollowedBy(e){return this.skip(ue.notFollowedBy(e))}describe(t){typeof t==`string`&&(t=[t]);let n=this;return new e(function(e){let r=e.getAndClearLatestError(),i=n.p(e);return e.latestError!==void 0&&(e.latestError.expected=t),e.mergeLatestError(r),i})}box(t){let n=this;return new e(function(e){let r=e.getAndClearLatestError(),i=n.p(e);return e.latestError!==void 0&&(e.latestError.expected=[`(${e.latestError.expected.join(` or `)} as part of ${t})`]),e.mergeLatestError(r),i})}optional(e){return this.or(P.succeed(e))}chain(t){let n=this;return new e(function(e){let r=n.p(e);return r.success?t(r.value).p(e):r})}thenEof(){let t=this;return new e(function(e){let n=t.p(e);return n.success?e.atEOF()?n:e.fail(`eof`):n})}};function se(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function ce(e,t){if(tn.position){let e=n.input.slice(n.position,r);return n.succeedAt(r,e)}else return n.fail(t)})}},de=function(e){return e.INLINE=`inline`,e.BLOCK=`block`,e}({}),fe=function(e){return e.INPUT=`INPUT`,e.VIEW=`VIEW`,e.JS_VIEW=`JS_VIEW`,e.TABLE=`TABLE`,e.BUTTON_GROUP=`BUTTON_GROUP`,e.BUTTON=`BUTTON`,e.EMBED=`EMBED`,e.EXCLUDED=`EXCLUDED`,e}({}),pe=class{linePosition;constructor(e){this.linePosition=e}getPosition(){return this.linePosition}};function me(e){return e===`INPUT`||e===`VIEW`||e===`BUTTON_GROUP`}var B=function(e){return e.CRITICAL=`CRITICAL`,e.ERROR=`ERROR`,e.WARNING=`WARNING`,e}({}),he=function(e){return e.INTERNAL=`MB_INTERNAL`,e.PARSING=`MB_PARSING`,e.BIND_TARGET=`MB_BIND_TARGET`,e.VALUE=`MB_VALUE`,e.ARGUMENT=`MB_ARGUMENT`,e.JS=`MB_JS`,e.EXPRESSION=`MB_EXPRESSION`,e.PUBLISH=`MB_PUBLISH`,e.VALIDATION=`MB_VALIDATION`,e.PARSINOM=`MB_PARSINOM`,e.EXAMPLE=`MB_EXAMPLE`,e.EMBED=`MB_EMBED`,e.BUTTON=`MB_BUTTON`,e.DEPENDENCY=`MB_DEPENDENCY`,e.OTHER=`OTHER`,e}({}),ge=class extends Error{errorLevel;effect;cause;tip;docs;context;positionContext;constructor(e){super(``),this.errorLevel=e.errorLevel,this.effect=e.effect,this.cause=e.cause,this.tip=e.tip,this.docs=e.docs,this.context=e.context,this.positionContext=e.positionContext,this.updateMessage()}updateMessage(){this.cause instanceof Error?this.message=`[${this.getErrorType()}] "${this.effect}" caused by error "${this.cause.message}"`:this.message=`[${this.getErrorType()}] "${this.effect}" caused by "${this.cause}"`}log(){console.log(this.message,this.stack,this.context)}},_e=class extends ge{getErrorType(){return`MB_INTERNAL`}},ve=class extends ge{getErrorType(){return`MB_PARSING`}},ye=class extends ge{getErrorType(){return`MB_VALIDATION`}},be=class extends ge{getErrorType(){return`MB_BIND_TARGET`}},xe=class extends ge{getErrorType(){return`MB_ARGUMENT`}},Se=class extends ge{getErrorType(){return`MB_JS`}},Ce=class extends ge{getErrorType(){return`MB_EXPRESSION`}},we=class extends ge{getErrorType(){return`MB_EXAMPLE`}},Te=class extends ge{getErrorType(){return`MB_BUTTON`}},Ee=class extends ge{getErrorType(){return`MB_DEPENDENCY`}};function De(e,t){let n=e.thenEof().tryParse(t);if(n.success)return n.value;throw new Oe(B.ERROR,`parsiNOM parser`,t,n)}var Oe=class extends ge{str;parseFailure;source;constructor(e,t,n,r){super({errorLevel:e,effect:`Failed to parse. Check that your syntax is correct.`,cause:`expected ${r.expected.sort().join(` or `)}`}),this.str=n,this.parseFailure=r,this.source=t,this.updateMessage2()}getErrorType(){return he.PARSINOM}updateMessage2(){this.cause instanceof Error?this.message=`[${this.getErrorType()}] "${this.effect}" caused by error "${this.cause.message}"\n`:this.message=`[${this.getErrorType()}] "${this.effect}" caused by "${this.cause}"\n`;let e=re(this.str,this.parseFailure.furthest),t=this.str.split(` `)[e.line-1]??``,n=`${e.line} | `;this.positionContext=`${n}${t}`,this.positionContext+=`\n${this.getUnderline(n.length,e.column)}\n`,this.message+=` `+this.positionContext}getUnderline(e,t){return` `.repeat(t+e-1)+`^ (${this.cause})`}},ke=class extends ge{str;position;source;constructor(e,t,n,r,i,a){super({errorLevel:e,effect:`Failed to validate the result of the parser.`,cause:n,docs:a}),this.str=r,this.position=i,this.source=t,this.updateMessage2()}getErrorType(){return he.VALIDATION}updateMessage2(){if(this.cause instanceof Error?this.message=`[${this.getErrorType()}] "${this.effect}" caused by error "${this.cause.message}"\n`:this.message=`[${this.getErrorType()}] "${this.effect}" caused by "${this.cause}"\n`,this.str&&this.position){let e=re(this.str,this.position.from),t=re(this.str,this.position.to),n=this.str.split(` `)[e.line-1]??``,r=`${e.line} | `;this.positionContext=`${r}${n}`,this.positionContext+=`\n${this.getUnderline(r.length,n.length,e,t)}\n`,this.message+=` `+this.positionContext}}getUnderline(e,t,n,r){if(this.position===void 0)return``;let i=` `.repeat(n.column+e-1),a=r.line===n.line?r.column:t+1;return i+`^`.repeat(Math.max(1,a-n.column))}},Ae=P.sequence(P.or(z.unicodeLetter(),P.oneOf(`_$`)),P.or(z.unicodeAlphanumeric(),P.oneOf(`-_$`)).many()).map(e=>e[0]+e[1].join(``)).describe(`identifier`),je=P.sequenceMap((e,t)=>e+t.map(e=>e[0]+e[1]).join(``),Ae,P.sequence(z.optionalWhitespace(),Ae).many()).describe(`identifier with spaces`),Me=P.string(`\\`).then(z.any()).map(e=>e===`'`?`'`:e===`\\`?`\\`:`\\`+e);function Ne(e){return P.or(Me,P.noneOf(e+`\\`)).many().map(e=>e.join(``)).trim(P.string(e))}var Pe=Ne(`'`),Fe=Ne(`"`),Ie=P.manyNotOf(`{}[]#^|:?`).box(`file path`);function Le(e,t){return{value:e,position:t}}function Re(e){if(e!==void 0)return typeof e==`string`?{value:e}:e}var ze=function(e){return e.OBJECT=`object`,e.ARRAY=`array`,e}({}),Be=class{parent;access;child;constructor(e,t,n){this.parent=e,this.access=t,this.child=n}};function Ve(e,t){return e[t]}function He(e,t,n){e[t]=n}var Ue=class{type;prop;index;constructor(e,t){if(this.type=e,this.prop=e===`object`?t:``,this.index=e===`array`?Number(t):0,Number.isNaN(this.index))throw Error(`can not access array with non number index`)}get(e){if(this.type===`object`){if(typeof e!=`object`||!e)throw Error(`can not access property of non-object`);return new Be(e,this,Ve(e,this.prop))}else{if(typeof e!=`object`||!e||!Array.isArray(e))throw Error(`can not access property of non-array`);return new Be(e,this,e[this.index])}}set(e,t){if(this.type===`object`){if(typeof e!=`object`||!e)throw Error(`can not access property of non-object`);He(e,this.prop,t)}else{if(typeof e!=`object`||!e||!Array.isArray(e))throw Error(`can not access property of non-array`);e[this.index]=t}}create(e){if(this.type===`object`){if(typeof e!=`object`||!e)throw Error(`can not access property of non-object`);He(e,this.prop,void 0)}else{if(typeof e!=`object`||!e||!Array.isArray(e))throw Error(`can not access property of non-array`);e[this.index]=void 0}}toUnvalidatedPropAccess(){return this.type===`object`?{type:this.type,prop:{value:this.prop}}:{type:this.type,prop:{value:this.index.toString()}}}},We=Ae.node((e,t)=>({type:ze.OBJECT,prop:Le(e,t)})),Ge=P.or(z.digits().wrap(P.string(`[`),P.string(`]`)).node((e,t)=>({type:ze.ARRAY,prop:Le(e,t)})),Fe.wrap(P.string(`[`),P.string(`]`)).node((e,t)=>({type:ze.OBJECT,prop:Le(e,t)}))),Ke=P.or(P.sequenceMap(e=>({storagePath:void 0,listenToChildren:!0,storageProp:e}),Ge.atLeast(1)),P.sequenceMap((e,t)=>({storagePath:void 0,listenToChildren:!0,storageProp:[e,...t]}),We,Ge.many())),qe=P.sequenceMap((e,t)=>[e,...t],We,Ge.many()),Je=P.sequenceMap((e,t)=>(e.storageProp=e.storageProp.concat(t.flat()),e),Ke,P.string(`.`).then(qe).many()),Ye=P.sequenceMap((e,t,n)=>(n.storageType=e,n.storagePath=t,n),Ae.describe(`storage type`).node(Le).skip(P.string(`^`).describe(`storage type separator "^"`)).optional(),Ie.describe(`storage path`).node(Le).skip(P.string(`#`).describe(`storage/file path separator "#"`)).optional(),Je.describe(`property path`)).box(`bind target`),Xe=P.regexp(/^[^()',]+/).describe(`any character except parentheses, single quotation marks and commas`),Ze=P.or(Pe,Xe).node(Le),Qe=P.separateBy(Ze,P.string(`,`).describe(`argument value separator ","`).trim(z.optionalWhitespace())),$e=P.sequenceMap((e,t)=>({name:e,value:t}),Ae.node(Le),Qe.trim(z.optionalWhitespace()).wrap(P.string(`(`).describe(`argument value paren "("`),P.string(`)`).describe(`argument value paren ")"`)).optional([])),et=P.separateBy($e,P.string(`,`).describe(`argument separator ","`).trim(z.optionalWhitespace())),tt=P.string(`\\`).then(z.any()).map(e=>e===`[`?`[`:e===`]`?`]`:e===`{`?`{`:e===`}`?`}`:e===`\\`?`\\`:`\\`+e),nt=P.sequenceMap((e,t)=>e+t.flat().join(``),P.manyNotOf(`{}[]\\`),P.sequence(tt,P.manyNotOf(`{}[]\\`)).many()).box(`View Field Content`),rt=P.sequenceMap((e,t)=>[e,...t.flat()],nt,P.sequence(Ye.wrapString(`{`,`}`),nt).many()),it=P.sequenceMap((e,t,n)=>({viewFieldType:e,writeToBindTarget:n===void 0?void 0:n[1],arguments:t,templateDeclaration:void 0}),Ae.node(Le).trim(z.optionalWhitespace()).optional().describe(`input field type`),et.trim(z.optionalWhitespace()).wrapString(`(`,`)`).trim(z.optionalWhitespace()).optional([]),P.sequence(P.string(`:`).trim(z.optionalWhitespace()),Ye).trim(z.optionalWhitespace()).optional()),at=P.sequenceMap((e,t,n,r)=>r===void 0?{viewFieldType:void 0,writeToBindTarget:void 0,arguments:[],templateDeclaration:t}:(r.templateDeclaration=t,r),P.string(`VIEW`),rt.wrapString(`[`,`]`),z.optionalWhitespace(),it.wrapString(`[`,`]`).optional(),z.eof()),ot=P.sequenceMap((e,t,n,r)=>(t!==void 0&&(e.listenToChildren=!0),{bindTarget:e,name:r}),Ye.wrapString(`{`,`}`),P.string(` and children`).optional(),P.string(` as `),Ae),st=P.sequenceMap((e,t,n,r)=>({bindTargetMappings:e,writeToBindTarget:t,hidden:n!==void 0,code:r}),ot.separateBy(z.whitespace()).skip(z.whitespace()),P.string(`save to `).then(Ye.wrapString(`{`,`}`)).skip(z.whitespace()).optional(),P.string(`hidden`).skip(z.whitespace()).optional(),P.string(`---`).then(z.remaining())),ct=class{range;tokenClass;constructor(e,t){this.range=e,this.tokenClass=t}},lt=function(e){return e.IDENT=`ident`,e.CONTROL=`control`,e.STRING=`string`,e.KEYWORD=`keyword`,e.ERROR=`error`,e}({}),ut=class e{static sequence(...e){return P.sequenceMap((...e)=>e.flat(2).filter(e=>e!==void 0),...e)}static separateBy(t,n){return e.sequence(t,e.sequence(n,t).many()).optional([])}static highlight(e,t){return e.node((e,n)=>[new ct(n,t)])}static highlightStr(t,n){return e.highlight(P.string(t),n)}},dt=ut.highlight(Ae,lt.IDENT),ft=ut.highlight(Ae,lt.KEYWORD),pt=ut.highlightStr(`,`,lt.CONTROL),mt=ut.highlightStr(`(`,lt.CONTROL),ht=ut.highlightStr(`)`,lt.CONTROL),gt=ut.highlightStr(`[`,lt.CONTROL),_t=ut.highlightStr(`]`,lt.CONTROL),vt=ut.highlight(Pe,lt.STRING),yt=ut.highlight(Xe,lt.IDENT),bt=P.or(yt,vt),xt=ut.separateBy(bt,pt.trim(z.optionalWhitespace())),St=ut.sequence(ft,ut.sequence(mt,xt.trim(z.optionalWhitespace()),ht).optional()),Ct=ut.separateBy(St,pt.trim(z.optionalWhitespace())),wt=ut.sequence(ut.sequence(dt,ut.highlightStr(`^`,lt.CONTROL)).optional(),ut.sequence(ut.highlight(Ie,lt.IDENT),ut.highlightStr(`#`,lt.CONTROL)).optional(),ut.highlight(Je,lt.IDENT)),Tt=ut.sequence(ft.trim(z.optionalWhitespace()),ut.sequence(mt,Ct.trim(z.optionalWhitespace()),ht).trim(z.optionalWhitespace()).optional(),ut.sequence(ut.highlightStr(`:`,lt.CONTROL).trim(z.optionalWhitespace()),wt).trim(z.optionalWhitespace()).optional()),Et=ut.sequence(ft.trim(z.optionalWhitespace()).optional(),ut.sequence(mt,Ct.trim(z.optionalWhitespace()),ht).trim(z.optionalWhitespace()).optional(),ut.sequence(ut.highlightStr(`:`,lt.CONTROL).trim(z.optionalWhitespace()),wt).trim(z.optionalWhitespace()).optional()),Dt=P.or(ut.sequence(ut.highlightStr(`INPUT`,lt.CONTROL),gt,dt.trim(z.optionalWhitespace()),_t.skip(z.optionalWhitespace()),gt,Et,_t),ut.sequence(ut.highlightStr(`INPUT`,lt.CONTROL),gt,Tt,_t)),Ot=ut.highlight(nt,lt.IDENT),kt=ut.sequence(ut.highlightStr(`{`,lt.STRING),wt,ut.highlightStr(`}`,lt.STRING)),At=ut.sequence(Ot,ut.sequence(kt,Ot).many()),jt=ut.sequence(ft.trim(z.optionalWhitespace()).optional(),ut.sequence(mt,Ct.trim(z.optionalWhitespace()).optional(),ht).trim(z.optionalWhitespace()).optional(),ut.sequence(ut.highlightStr(`:`,lt.CONTROL).trim(z.optionalWhitespace()),wt).trim(z.optionalWhitespace()).optional()),Mt=ut.sequence(ut.highlightStr(`VIEW`,lt.CONTROL),gt,At,_t,ut.sequence(gt.skip(z.optionalWhitespace()),jt,_t).optional()),Nt=ut.sequence(ut.highlightStr(`BUTTON`,lt.CONTROL),gt,ut.separateBy(dt,pt.trim(z.optionalWhitespace())),_t),Pt=class{str;highlights;parsingError;constructor(e,t,n){this.str=e,this.highlights=t.filter(e=>e.range.from!==e.range.to),this.parsingError=n}getHighlights(){if(this.parsingError===void 0)return this.highlights;let e=this.parsingError.parseFailure.furthest;return[new ct({from:e,to:e+1},lt.ERROR)]}},Ft=class{mb;constructor(e){this.mb=e}highlightInputFieldDeclaration(e,t){return this.highlightWithParser(e,t,Dt)}highlightViewFieldDeclaration(e,t){return this.highlightWithParser(e,t,Mt)}highlightInlineButtonDeclaration(e,t){return this.highlightWithParser(e,t,Nt)}highlight(e,t,n){if(t===fe.INPUT)return this.highlightInputFieldDeclaration(e,n);if(t===fe.VIEW)return this.highlightViewFieldDeclaration(e,n);if(t===fe.BUTTON_GROUP)return this.highlightInlineButtonDeclaration(e,n);throw Error(`Unknown MDRCType ${t}`)}highlightBindTarget(e,t){return this.highlightWithParser(e,t,wt)}highlightWithParser(e,t,n){try{return t?new Pt(e,De(n.trim(z.optionalWhitespace()).thenEof(),e)):new Pt(e,De(n.thenEof(),e))}catch(t){return t instanceof Oe?new Pt(e,[],t):(console.error(t),new Pt(e,[]))}}},It=function(e){return e.DEFAULT=`default`,e.PRIMARY=`primary`,e.DESTRUCTIVE=`destructive`,e.PLAIN=`plain`,e}({}),Lt=function(e){return e.COMMAND=`command`,e.JS=`js`,e.OPEN=`open`,e.INPUT=`input`,e.SLEEP=`sleep`,e.TEMPLATER_CREATE_NOTE=`templaterCreateNote`,e.RUN_TEMPLATER_FILE=`runTemplaterFile`,e.UPDATE_METADATA=`updateMetadata`,e.CREATE_NOTE=`createNote`,e.REPLACE_IN_NOTE=`replaceInNote`,e.REGEXP_REPLACE_IN_NOTE=`regexpReplaceInNote`,e.REPLACE_SELF=`replaceSelf`,e.INSERT_INTO_NOTE=`insertIntoNote`,e.INLINE_JS=`inlineJS`,e}({}),Rt=class e{type;shiftKey;ctrlKey;altKey;constructor(e,t,n,r){this.type=e,this.shiftKey=t,this.ctrlKey=n,this.altKey=r}static fromMouseEvent(t,n){return new e(n,t.shiftKey,t.ctrlKey,t.altKey)}openInNewTab(){return this.type===`middle`||this.ctrlKey}},zt=function(e){return e.LEFT=`left`,e.MIDDLE=`middle`,e}({}),Bt=class{actionType;mb;constructor(e,t){this.actionType=e,this.mb=t}},Vt=class extends Bt{constructor(e){super(Lt.COMMAND,e)}async run(e,t,n,r,i){this.mb.internal.executeCommandById(t.command)}create(){return{type:Lt.COMMAND,command:``}}getActionLabel(){return`Run a command`}},Ht=class extends Bt{constructor(e){super(Lt.CREATE_NOTE,e)}async run(e,t,n,r,i){if(t.openIfAlreadyExists){let e=M(A(t.folderPath??``,t.fileName),`md`);if(await this.mb.file.exists(e)){await this.mb.file.open(e,``,!1);return}}await this.mb.file.create(t.folderPath??``,t.fileName,`md`,t.openNote??!1,i.openInNewTab())}create(){return{type:Lt.CREATE_NOTE,folderPath:`/`,fileName:`Untitled`,openNote:!0,openIfAlreadyExists:!1}}getActionLabel(){return`Create a new note`}},Ut=class extends Bt{constructor(e){super(Lt.INLINE_JS,e)}async run(e,t,n,r,i){if(!this.mb.getSettings().enableJs)throw new Se({errorLevel:B.CRITICAL,effect:`Can't run button action that requires JS evaluation.`,cause:`JS evaluation is disabled in the plugin settings.`});let a={buttonConfig:structuredClone(e),args:structuredClone(t.args),buttonContext:structuredClone(r),click:structuredClone(i)};(await this.mb.internal.jsEngineRunCode(t.code,n,a))()}create(){return{type:Lt.INLINE_JS,code:`console.log("Hello world")`,args:{}}}getActionLabel(){return`Run JavaScript code`}},Wt=class extends Bt{constructor(e){super(Lt.INPUT,e)}async run(e,t,n,r,i){let a=document.activeElement;a&&a instanceof HTMLInputElement&&(a.setRangeText(t.str,a.selectionStart,a.selectionEnd,`end`),a.dispatchEvent(new Event(`input`,{bubbles:!0})))}create(){return{type:Lt.INPUT,str:``}}getActionLabel(){return`Insert text at cursor`}};function Gt(e){if(e===`+`)return`+`;if(e===`-`)return`-`;throw Error(`Invalid LineNumberOp: ${e}`)}function Kt(e){if(e===void 0||e===`+`)return 1;if(e===`-`)return-1;throw Error(`Invalid LineNumberOp: ${e}`)}var qt=class{literal;op;number;constructor(e,t,n){this.literal=e,this.op=t,this.number=n}evaluate(e){let t=this.resolveLiteral(e),n=Kt(this.op);return t!==void 0&&this.number!==void 0?t+this.number*n:this.number===void 0?t===void 0?0:t:this.number*n}resolveLiteral(e){if(this.literal!==void 0){if(this.literal in e)return e[this.literal];throw Error(`Error while evaluating line number expression: Literal "${this.literal}" not available.`)}}},Jt=P.sequenceMap((e,t)=>e===void 0?t:-t,P.string(`-`).optional(),P.or(P.sequenceMap((e,t,n)=>Number(e+t+n),z.digits(),P.string(`.`),z.digits()),z.digits().map(e=>Number(e)))).thenEof(),Yt=P.sequenceMap((e,t)=>e===void 0?t:-t,P.string(`-`).optional(),z.digits().map(e=>Number(e))).thenEof(),Xt=P.or(P.sequenceMap((e,t,n)=>new qt(e,Gt(t),n),Ae,P.or(P.string(`+`),P.string(`-`)).trim(z.optionalWhitespace()),Yt),Ae.map(e=>new qt(e,void 0,void 0)),Yt.map(e=>new qt(void 0,void 0,e))),Zt=class extends Bt{constructor(e){super(Lt.INSERT_INTO_NOTE,e)}async run(e,t,n,r,i){let a=t.templater?await this.mb.internal.evaluateTemplaterTemplate(this.mb.file.resolveFilePathLike(t.value),n):t.value,o=De(Xt,t.line.toString());await this.mb.file.atomicModify(n,e=>{let t=e.split(` `),n=this.mb.file.createLineNumberContext(e,r.position),i=o.evaluate(n);if(i<1||i>t.length)throw Error(`Line number out of bounds`);return t=[...t.slice(0,i-1),a,...t.slice(i-1)],t.join(` `)})}create(){return{type:Lt.INSERT_INTO_NOTE,line:0,value:`Some text`,templater:!1}}getActionLabel(){return`Insert text into the note`}},Qt=class extends Bt{constructor(e){super(Lt.JS,e)}async run(e,t,n,r,i){if(!this.mb.getSettings().enableJs)throw new Se({errorLevel:B.CRITICAL,effect:`Can't run button action that requires JS evaluation.`,cause:`JS evaluation is disabled in the plugin settings.`});let a={buttonConfig:structuredClone(e),args:structuredClone(t.args),buttonContext:structuredClone(r),click:structuredClone(i)};(await this.mb.internal.jsEngineRunFile(t.file,n,a))()}create(){return{type:Lt.JS,file:``,args:{}}}getActionLabel(){return`Run a JavaScript file`}},$t=P.sequence(Ie,P.or(P.string(`#`).then(P.manyNotOf(`[]#|:`)),P.string(`#`).result(void 0),P.succeed(void 0)),P.string(`|`).then(P.manyNotOf(`[]`)).optional()),en=P.or(P.sequenceMap((e,t)=>new nn(e!==void 0,t[0],t[1],t[2],!0),P.string(`!`).optional(),$t.wrapString(`[[`,`]]`)),P.sequenceMap((e,t,n)=>{let r=!T(n);return new nn(e!==void 0,n,void 0,t,r)},P.string(`!`).optional(),P.manyNotOf(`[]`).wrapString(`[`,`]`),P.manyNotOf(`()`).wrapString(`(`,`)`))),tn=P.separateBy(en,P.string(`,`).trim(z.optionalWhitespace())),nn=class e{isEmbed;target;block;alias;internal;constructor(e,t,n,r,i){this.isEmbed=e,this.target=t,this.block=n,this.alias=r,this.internal=i??!0}static fromUrl(t){return new e(!1,t.href,void 0,t.hostname,!1)}fullTarget(){return this.block?`${this.target}#${this.block}`:this.target}open(e,t,n){this.internal?e.file.open(this.fullTarget(),t,n):E(this.target)}toString(){let e=this.isEmbed?`!`:``;if(this.internal){let t=this.alias?`|${this.alias}`:``;return`${e}[[${this.fullTarget()}${t}]]`}else return`${e}[${this.alias??this.fullTarget()}](${this.fullTarget()})`}},rn=class e{static parseLink(e){return De(en.thenEof(),e)}static parseLinkList(e){return De(tn.thenEof(),e)}static isLink(e){return en.thenEof().tryParse(e).success}static urlToLink(e){return nn.fromUrl(e)}static parseLinkOrUrl(t){return T(t)?e.urlToLink(new URL(t)):e.parseLink(t)}static interpretAsLink(e){let t=en.thenEof().tryParse(e);if(t.success)return t.value;let n=$t.thenEof().tryParse(e);if(n.success)return new nn(!1,n.value[0],n.value[1],n.value[2],!0);if(T(e)){let t=new URL(e);return nn.fromUrl(t)}}},an=class extends Bt{constructor(e){super(Lt.OPEN,e)}async run(e,t,n,r,i){let a=i.openInNewTab()||(t.newTab??!1),o=rn.interpretAsLink(t.link);if(!o)throw Error(`Invalid link`);o.open(this.mb,n,a)}create(){return{type:Lt.OPEN,link:``,newTab:!0}}getActionLabel(){return`Open a link`}},on=class extends Bt{constructor(e){super(Lt.REGEXP_REPLACE_IN_NOTE,e)}async run(e,t,n,r,i){if(t.regexp===``)throw Error(`Regexp cannot be empty`);await this.mb.file.atomicModify(n,e=>e.replace(new RegExp(t.regexp,t.regexpFlags??`g`),t.replacement))}create(){return{type:Lt.REGEXP_REPLACE_IN_NOTE,regexp:`([A-Z])\\w+`,replacement:`Replacement text`,regexpFlags:`g`}}getActionLabel(){return`Replace text in note using regexp`}},sn=class extends Bt{constructor(e){super(Lt.REPLACE_IN_NOTE,e)}async run(e,t,n,r,i){let a=t.templater?await this.mb.internal.evaluateTemplaterTemplate(this.mb.file.resolveFilePathLike(t.replacement),n):t.replacement,o=De(Xt,t.fromLine.toString()),s=De(Xt,t.toLine.toString());await this.mb.file.atomicModify(n,e=>{let t=e.split(` `),n=this.mb.file.createLineNumberContext(e,r.position),i=o.evaluate(n),c=s.evaluate(n);if(i>c)throw Error(`From line (${i}) can't be greater than to line (${c})`);if(i<1)throw Error(`From line (${i}) can't smaller than 1.`);if(c>t.length)throw Error(`To line (${c}) can't greater than the file length ${t.length}.`);return t=[...t.slice(0,i-1),a,...t.slice(c)],t.join(` `)})}create(){return{type:Lt.REPLACE_IN_NOTE,fromLine:0,toLine:0,replacement:`Replacement text`,templater:!1}}getActionLabel(){return`Replace text in note`}},cn=class extends Bt{constructor(e){super(Lt.REPLACE_SELF,e)}async run(e,t,n,r,i){if(r.isInline)throw Error(`Replace self action not supported for inline buttons`);if(r.position===void 0)throw Error(`Position of the button in the note is unknown`);if(r.position.lineStart>r.position.lineEnd)throw Error(`Position of the button in the note is invalid`);let a=r.position,o=t.templater?await this.mb.internal.evaluateTemplaterTemplate(this.mb.file.resolveFilePathLike(t.replacement),n):t.replacement;await this.mb.file.atomicModify(n,e=>{let t=e.split(` `);if(a.lineStart<0||a.lineEnd>t.length)throw Error(`Position of the button in the note is out of bounds`);return t=[...t.slice(0,a.lineStart),o,...t.slice(a.lineEnd+1)],t.join(` `)})}create(){return{type:Lt.REPLACE_SELF,replacement:`Replacement text`,templater:!1}}getActionLabel(){return`Replace button with text`}},ln=class extends Bt{constructor(e){super(Lt.RUN_TEMPLATER_FILE,e)}async run(e,t,n,r,i){let a=this.mb.file.resolveFilePathLike(t.templateFile);await this.mb.internal.evaluateTemplaterTemplate(a,n)}create(){return{type:Lt.RUN_TEMPLATER_FILE,templateFile:``}}getActionLabel(){return`Run a templater file`}},un=class extends Bt{constructor(e){super(Lt.SLEEP,e)}async run(e,t,n,r,i){await new Promise(e=>window.setTimeout(e,t.ms))}create(){return{type:Lt.SLEEP,ms:0}}getActionLabel(){return`Sleep for some time`}},dn=class extends Bt{constructor(e){super(Lt.TEMPLATER_CREATE_NOTE,e)}async run(e,t,n,r,i){if(t.openIfAlreadyExists&&t.fileName){let e=M(A(t.folderPath??``,t.fileName),`md`);if(await this.mb.file.exists(e)){await this.mb.file.open(e,``,!1);return}}await this.mb.internal.createNoteWithTemplater(t.templateFile,t.folderPath,t.fileName,t.openNote,i.openInNewTab())}create(){return{type:Lt.TEMPLATER_CREATE_NOTE,templateFile:``,folderPath:`/`,fileName:``,openNote:!0,openIfAlreadyExists:!1}}getActionLabel(){return`Create a new note using Templater`}};function fn(e){if(e.toLowerCase()===`null`)return null;if(e===`true`)return!0;if(e===`false`)return!1;{let t=Jt.tryParse(e);return t.success?t.value:e}}function pn(e){return e==null?``:typeof e==`string`?e:typeof e==`boolean`?e?`true`:`false`:e.toString()}function mn(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`}function hn(e){if(e!=null){if(mn(e))return[e];if(typeof e==`object`&&Array.isArray(e))return e.filter(e=>mn(e))}}function gn(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=Jt.tryParse(e);if(t.success)return t.value}}function _n(e){return mn(e)?pn(e):void 0}function vn(e){return mn(e)?e:void 0}function yn(e,t){return Array.isArray(e)?e.map(e=>bn(e,t)).filter(e=>e!==``).join(`, `):bn(e,t)}function bn(e,t){return e==null?t?``:`null`:typeof e==`function`?``:typeof e==`object`||Array.isArray(e)?JSON.stringify(e):e.toString()}function xn(e,t){return Array.isArray(e)?e.map(e=>Sn(e,t)).filter(e=>e!==``):Sn(e,t)}function Sn(e,t){return typeof e==`string`?rn.isLink(e)?rn.parseLink(e):T(e)?rn.urlToLink(new URL(e)):e:bn(e,t)}var Cn=class extends Bt{constructor(e){super(Lt.UPDATE_METADATA,e)}async run(e,t,n,r,i){let a=this.mb.bindTargetParser.fromStringAndValidate(t.bindTarget,n);if(t.evaluate){if(!this.mb.getSettings().enableJs)throw new Se({errorLevel:B.CRITICAL,effect:`Can't run button action that requires JS evaluation.`,cause:`JS evaluation is disabled in the plugin settings.`});let e=this.mb.api.getMetadata(a),r=await this.mb.internal.jsEngineExecuteCustom(t.value,{x:e,getMetadata:e=>this.mb.api.getMetadata(this.mb.api.parseBindTarget(e,n))},!0);this.mb.api.setMetadata(a,r)}else this.mb.api.setMetadata(a,fn(t.value))}create(){return{type:Lt.UPDATE_METADATA,bindTarget:``,evaluate:!1,value:``}}getActionLabel(){return`Update metadata`}},wn=class{mb;actionContexts;constructor(e){this.mb=e,this.actionContexts={[Lt.COMMAND]:new Vt(e),[Lt.OPEN]:new an(e),[Lt.JS]:new Qt(e),[Lt.INPUT]:new Wt(e),[Lt.SLEEP]:new un(e),[Lt.TEMPLATER_CREATE_NOTE]:new dn(e),[Lt.UPDATE_METADATA]:new Cn(e),[Lt.CREATE_NOTE]:new Ht(e),[Lt.REPLACE_IN_NOTE]:new sn(e),[Lt.REPLACE_SELF]:new cn(e),[Lt.REGEXP_REPLACE_IN_NOTE]:new on(e),[Lt.INSERT_INTO_NOTE]:new Zt(e),[Lt.INLINE_JS]:new Ut(e),[Lt.RUN_TEMPLATER_FILE]:new ln(e)}}createDefaultButtonConfig(){return{label:`This is a button`,icon:``,style:It.DEFAULT,class:``,cssStyle:``,backgroundImage:``,tooltip:``,id:``,hidden:!1,actions:[]}}async runButtonActions(e,t,n,r){try{if(e.action)await this.runAction(e,e.action,t,n,r);else if(e.actions)for(let i of e.actions)await this.runAction(e,i,t,n,r);else console.warn(`meta-bind | ButtonMDRC >> no action defined`)}catch(e){console.warn(`meta-bind | ButtonMDRC >> error while running action`,e),this.mb.internal.showNotice(`meta-bind | Error while running button action. Check the console for details.`)}}createDefaultAction(e){return this.actionContexts[e].create()}async runAction(e,t,n,r,i){let a=t.type;await this.actionContexts[a].run(e,t,n,r,i)}getActionLabel(e){return this.actionContexts[e].getActionLabel()}},Tn=class{errors;otherError;subject;constructor(e){this.subject=e,this.errors=[]}add(e){e instanceof Error?(e instanceof ge?this.errors.push(e):this.otherError=e,console.warn(e)):(console.trace(``),console.warn(`[MB_ERROR_CONTAINER] received invalid error type`,e))}merge(e){return this.errors=this.errors.concat(e.errors),e.otherError&&(this.otherError=e.otherError),this}hasErrors(){if(this.otherError)return!0;for(let e of this.errors)if(e.errorLevel===B.ERROR||e.errorLevel===B.CRITICAL)return!0;return!1}hasCriticalErrors(){if(this.otherError)return!0;for(let e of this.errors)if(e.errorLevel===B.CRITICAL)return!0;return!1}hasWarnings(){for(let e of this.errors)if(e.errorLevel===B.WARNING)return!0;return!1}isEmpty(){return this.errors.length===0&&!this.otherError}getErrors(){let e=this.errors.filter(e=>e.errorLevel===B.ERROR||e.errorLevel===B.CRITICAL);return this.otherError?e.concat([this.otherError]):e}getWarnings(){return this.errors.filter(e=>e.errorLevel===B.WARNING)}},En=class{value;count;constructor(e){this.value=e,this.count=1}getValue(){return this.value}increment(){return this.count+=1,this.count}decrement(){return--this.count,this.count}getCount(){return this.count}isEmpty(){return this.count===0}},Dn=class{mb;buttons;buttonLoadListeners;buttonTemplates;constructor(e){this.mb=e,this.buttons=new Map,this.buttonLoadListeners=new Map,this.buttonTemplates=new Map}setButtonTemplates(e){let t=new Set,n=new Tn(`ButtonManager`);this.buttonTemplates.clear();for(let r of e){let e;try{e=this.mb.buttonParser.validateConfig(r),Object.assign(r,e)}catch(e){n.add(e);continue}e.id===void 0||e.id===``?n.add(new Te({errorLevel:B.ERROR,cause:`Button with label "${e.label}" has no id, but button templates must have an id.`,effect:`Button templates could not be saved.`})):t.has(e.id)?n.add(new Te({errorLevel:B.ERROR,cause:`Button id "${e.id}" is not unique. The same id is used by multiple buttons.`,effect:`Button templates could not be saved.`})):(t.add(e.id),this.buttonTemplates.set(e.id,e))}return n.hasErrors()&&this.buttonTemplates.clear(),n}registerButtonLoadListener(e,t,n){let r=this.getButton(e,t);r&&n(r),this.buttonLoadListeners.has(e)||this.buttonLoadListeners.set(e,new Map);let i=this.buttonLoadListeners.get(e);i.has(t)||i.set(t,new Map);let a=i.get(t),o=w();return a.set(o,n),()=>this.removeButtonLoadListener(e,t,o)}notifyButtonLoadListeners(e,t){let n=this.getButton(e,t);if(!n)throw Error(`ButtonManager | button with id ${t} does not exist`);let r=this.buttonLoadListeners.get(e);if(!r)return;let i=r.get(t);if(i)for(let[e,t]of i)t(n)}removeButtonLoadListener(e,t,n){let r=this.buttonLoadListeners.get(e);if(!r)return;let i=r.get(t);i&&(i.delete(n),i.size===0&&r.delete(t),r.size===0&&this.buttonLoadListeners.delete(e))}addButton(e,t){if(t.id===void 0||t.id===``)throw Error(`ButtonManager | button id is undefined`);if(this.buttonTemplates.has(t.id))throw Error(`ButtonManager | button with id "${t.id}" already exists in the button templates`);this.buttons.has(e)||this.buttons.set(e,new Map),this.buttons.get(e).set(t.id,new En(t)),this.notifyButtonLoadListeners(e,t.id)}getButton(e,t){if(this.buttonTemplates.has(t))return this.buttonTemplates.get(t);let n=this.buttons.get(e);if(n)return n.get(t)?.getValue()}removeButton(e,t){let n=this.buttons.get(e);n&&(n.get(t)?.decrement(),n.get(t)?.isEmpty()&&n.delete(t),n.size===0&&this.buttons.delete(e))}},On=function(e){return e.TOGGLE=`toggle`,e.SLIDER=`slider`,e.TEXT=`text`,e.TEXT_AREA=`textArea`,e.SELECT=`select`,e.MULTI_SELECT=`multiSelect`,e.DATE=`date`,e.TIME=`time`,e.DATE_PICKER=`datePicker`,e.NUMBER=`number`,e.SUGGESTER=`suggester`,e.EDITOR=`editor`,e.IMAGE_SUGGESTER=`imageSuggester`,e.PROGRESS_BAR=`progressBar`,e.INLINE_SELECT=`inlineSelect`,e.LIST=`list`,e.LIST_SUGGESTER=`listSuggester`,e.INLINE_LIST_SUGGESTER=`inlineListSuggester`,e.INLINE_LIST=`inlineList`,e.IMAGE_LIST_SUGGESTER=`imageListSuggester`,e.DATE_TIME=`dateTime`,e.INVALID=`invalid`,e}({}),kn=function(e){return e.CLASS=`class`,e.ADD_LABELS=`addLabels`,e.MIN_VALUE=`minValue`,e.MAX_VALUE=`maxValue`,e.STEP_SIZE=`stepSize`,e.OPTION=`option`,e.TITLE=`title`,e.OPTION_QUERY=`optionQuery`,e.SHOWCASE=`showcase`,e.ON_VALUE=`onValue`,e.OFF_VALUE=`offValue`,e.DEFAULT_VALUE=`defaultValue`,e.PLACEHOLDER=`placeholder`,e.USE_LINKS=`useLinks`,e.LIMIT=`limit`,e.MULTI_LINE=`multiLine`,e.ALLOW_OTHER=`allowOther`,e.INVALID=`invalid`,e}({}),An={toggle:{type:`toggle`,allowInBlock:!0,allowInline:!0},slider:{type:`slider`,allowInBlock:!0,allowInline:!0},text:{type:`text`,allowInBlock:!0,allowInline:!0},textArea:{type:`textArea`,allowInBlock:!0,allowInline:!0},select:{type:`select`,allowInBlock:!0,allowInline:!1},multiSelect:{type:`multiSelect`,allowInBlock:!0,allowInline:!1},date:{type:`date`,allowInBlock:!0,allowInline:!0},time:{type:`time`,allowInBlock:!0,allowInline:!0},datePicker:{type:`datePicker`,allowInBlock:!0,allowInline:!0},number:{type:`number`,allowInBlock:!0,allowInline:!0},suggester:{type:`suggester`,allowInBlock:!0,allowInline:!0},editor:{type:`editor`,allowInBlock:!0,allowInline:!1},imageSuggester:{type:`imageSuggester`,allowInBlock:!0,allowInline:!0},progressBar:{type:`progressBar`,allowInBlock:!0,allowInline:!1},inlineSelect:{type:`inlineSelect`,allowInBlock:!0,allowInline:!0},list:{type:`list`,allowInBlock:!0,allowInline:!1},listSuggester:{type:`listSuggester`,allowInBlock:!0,allowInline:!1},inlineListSuggester:{type:`inlineListSuggester`,allowInBlock:!0,allowInline:!0},inlineList:{type:`inlineList`,allowInBlock:!0,allowInline:!0},imageListSuggester:{type:`imageListSuggester`,allowInBlock:!0,allowInline:!1},dateTime:{type:`dateTime`,allowInBlock:!0,allowInline:!0},invalid:{type:`invalid`,allowInBlock:!1,allowInline:!1}},jn=function(e){return e.TRUE=`true`,e.PARTIAL=`partial`,e.FALSE=`false`,e}({}),Mn={addLabels:{type:`addLabels`,allowedFieldTypes:[`slider`,`progressBar`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},class:{type:`class`,allowedFieldTypes:[],values:[[{name:`className`,allowed:[],description:`the name of the css class to add`}]],allowMultiple:!0},defaultValue:{type:`defaultValue`,allowedFieldTypes:[],values:[[{name:`value`,allowed:[],description:``}]],allowMultiple:!1},maxValue:{type:`maxValue`,allowedFieldTypes:[`slider`,`progressBar`],values:[[{name:`value`,allowed:[`number`],description:`the maximally allowed value`}]],allowMultiple:!1},minValue:{type:`minValue`,allowedFieldTypes:[`slider`,`progressBar`],values:[[{name:`value`,allowed:[`number`],description:`the minimally allowed value`}]],allowMultiple:!1},stepSize:{type:`stepSize`,allowedFieldTypes:[`slider`,`progressBar`],values:[[{name:`value`,allowed:[`number`],description:`the step size for sliders`}]],allowMultiple:!1},offValue:{type:`offValue`,allowedFieldTypes:[`toggle`],values:[[{name:`value`,allowed:[],description:`the value for the off state`}]],allowMultiple:!1},onValue:{type:`onValue`,allowedFieldTypes:[`toggle`],values:[[{name:`value`,allowed:[],description:`the value for the off state`}]],allowMultiple:!1},option:{type:`option`,allowedFieldTypes:[`select`,`multiSelect`,`suggester`,`imageSuggester`,`inlineSelect`,`listSuggester`,`inlineListSuggester`,`imageListSuggester`],values:[[{name:`value`,allowed:[],description:`the value and display name of the option`}],[{name:`value`,allowed:[],description:`the value of the option`},{name:`name`,allowed:[],description:`the display name of the option`}]],allowMultiple:!0},optionQuery:{type:`optionQuery`,allowedFieldTypes:[`suggester`,`imageSuggester`,`listSuggester`,`inlineListSuggester`,`imageListSuggester`],values:[[{name:`value`,allowed:[],description:`the query for options`}]],allowMultiple:!0},placeholder:{type:`placeholder`,allowedFieldTypes:[`text`,`textArea`,`number`,`list`,`inlineList`],values:[[{name:`value`,allowed:[],description:``}]],allowMultiple:!1},showcase:{type:`showcase`,allowedFieldTypes:[],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},title:{type:`title`,allowedFieldTypes:[],values:[[{name:`value`,allowed:[],description:``}]],allowMultiple:!1},useLinks:{type:`useLinks`,allowedFieldTypes:[`suggester`,`listSuggester`,`inlineListSuggester`],values:[[],[{name:`value`,allowed:[`true`,`partial`,`false`],description:``}]],allowMultiple:!1},limit:{type:`limit`,allowedFieldTypes:[`text`,`textArea`,`list`,`inlineList`],values:[[{name:`value`,allowed:[`number`],description:`a character limit for text fields`}]],allowMultiple:!1},multiLine:{type:`multiLine`,allowedFieldTypes:[`list`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},allowOther:{type:`allowOther`,allowedFieldTypes:[`suggester`,`listSuggester`,`inlineListSuggester`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},invalid:{type:`invalid`,allowedFieldTypes:[],values:[[]],allowMultiple:!0}},Nn=function(e){return e.MATH=`math`,e.TEXT=`text`,e.LINK=`link`,e.IMAGE=`image`,e.INVALID=`invalid`,e}({}),Pn=function(e){return e.RENDER_MARKDOWN=`renderMarkdown`,e.HIDDEN=`hidden`,e.CLASS=`class`,e.INVALID=`invalid`,e}({}),Fn={renderMarkdown:{type:`renderMarkdown`,allowedFieldTypes:[`text`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},hidden:{type:`hidden`,allowedFieldTypes:[],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},class:{type:`class`,allowedFieldTypes:[],values:[[{name:`className`,allowed:[],description:`the name of the css class to add`}]],allowMultiple:!0},invalid:{type:`invalid`,allowedFieldTypes:[],values:[[]],allowMultiple:!0}},In=Array.isArray,Ln=Array.prototype.indexOf,Rn=Array.prototype.includes,zn=Array.from,Bn=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,Hn=Object.getOwnPropertyDescriptors,Un=Object.prototype,Wn=Array.prototype,Gn=Object.getPrototypeOf,Kn=Object.isExtensible,qn=()=>{};function Jn(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}var Xn=1024,Zn=2048,Qn=4096,$n=8192,er=16384,tr=32768,nr=1<<25,rr=65536,ir=1<<19,ar=1<<20,or=1<<25,sr=65536,cr=1<<21,lr=1<<22,ur=1<<23,dr=Symbol(`$state`),fr=Symbol(`legacy props`),pr=Symbol(``),mr=Symbol(`attributes`),hr=Symbol(`class`),gr=Symbol(`style`),_r=Symbol(`text`),vr=Symbol(`form reset`),yr=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},br=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function xr(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Sr(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Cr(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function wr(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Tr(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Er(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Dr(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Or(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function kr(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ar(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function jr(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Mr(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Nr={},Pr=Symbol(`uninitialized`),Fr=`http://www.w3.org/1999/xhtml`;function Ir(){console.warn(`https://svelte.dev/e/derived_inert`)}function Lr(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Rr(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function zr(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Br=!1;function Vr(e){Br=e}var Hr;function Ur(e){if(e===null)throw Lr(),Nr;return Hr=e}function Wr(){return Ur(Da(Hr))}function V(e){if(Br){if(Da(Hr)!==null)throw Lr(),Nr;Hr=e}}function Gr(e=1){if(Br){for(var t=e,n=Hr;t--;)n=Da(n);Hr=n}}function Kr(e=!0){for(var t=0,n=Hr;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=Da(n);e&&n.remove(),n=i}}function qr(e){if(!e||e.nodeType!==8)throw Lr(),Nr;return e.data}function Jr(e){return e===this.v}function Yr(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Xr(e){return!Yr(e,this.v)}var Zr=!1,Qr=!1,$r=[];function ei(e,t=!1,n=!1){return ti(e,new Map,``,$r,null,n)}function ti(e,t,n,r,i=null,a=!1){if(typeof e==`object`&&e){var o=t.get(e);if(o!==void 0)return o;if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);if(In(e)){var s=Array(e.length);t.set(e,s),i!==null&&t.set(i,s);for(var c=0;c{t===si&&ci()})}si.push(e)}function ui(){for(;si.length>0;)ci()}function di(e){var t=_o;if(t===null)return mo.f|=ur,e;if(!(t.f&32768)&&!(t.f&4))throw e;fi(e,t)}function fi(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var pi=~(Zn|Qn|Xn);function mi(e,t){e.f=e.f&pi|t}function hi(e){e.f&512||e.deps===null?mi(e,Xn):mi(e,Qn)}function gi(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=sr,gi(t.deps))}function _i(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),gi(e.deps),mi(e,Xn)}var vi=!1,yi=!1;function bi(e){var t=yi;try{return yi=!1,[e(),yi]}finally{yi=t}}var xi=null,Si=null,Ci=null,wi=null,Ti=null,Ei=null,Di=!1,Oi=!1,ki=null,Ai=null,ji=0,Mi=1,Ni=class e{id=Mi++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){Si===null?xi=Si=this:(Si.#n=this,this.#t=Si),Si=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)mi(r,Zn),t(r);for(r of n.m)mi(r,Qn),t(r)}this.#p.add(e)}#g(){this.#e=!0,ji++>1e3&&(this.#S(),Fi());for(let e of this.#u)this.#d.delete(e),mi(e,Zn),this.schedule(e);for(let e of this.#d)mi(e,Qn),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=ki=[],r=[],i=Ai=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw Hi(e),this.#h()||this.discard(),t}if(Ci=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(ki=null,Ai=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)Vi(e,t);i.length>0&&Ci.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),wi=this,Li(r),Li(n),wi=null,this.#s?.resolve();var s=Ci;if(this.#a===0&&(this.#c.length===0||s!==null)&&(this.#S(),Zr&&(this.#x(),Ci=s)),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=Xn;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=Xn:i&4?t.push(r):Zr&&i&16777224?n.push(r):Ao(r)&&(i&16&&this.#d.add(r),Fo(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),mi(i,Zn),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),Ci=this,this.#g()}#b(e){for(var t=0;t!l.current.get(e)[1]&&!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#p)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#b([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Ri(o,r,i,a);a=new Map;var s=[...l.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(s.length>0)for(let e of this.#l)!(e.f&155648)&&zi(e,s,a)&&(e.f&4194320?(mi(e,Zn),l.schedule(e)):l.#u.add(e));if(l.#c.length>0&&!l.#m){l.apply();for(var c of l.#c)l.#_(c,[],[]);l.#c=[]}l.deactivate()}}}}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,li(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=Yn()).promise}static ensure(){if(Ci===null){let t=Ci=new e;!Oi&&!Di&&li(()=>{t.#e||t.flush()})}return Ci}apply(){if(!Zr||!this.is_fork&&this.#t===null&&this.#n===null){Ti=null;return}Ti=new Map;for(let[e,[t]]of this.current)Ti.set(e,t);for(let t=xi;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id0)){ca.clear();for(let e of Ii){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Ii.has(n)&&(Ii.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Fo(n)}}Ii.clear()}}Ii=null}}function Ri(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Ri(i,t,n,r):e&4194320&&!(e&2048)&&zi(i,t,r)&&(mi(i,Zn),Bi(i))}}function zi(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(Rn.call(t,r))return!0;if(r.f&2&&zi(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Bi(e){Ci.schedule(e)}function Vi(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),mi(e,Xn);for(var n=e.first;n!==null;)Vi(n,t),n=n.next}}function Hi(e){mi(e,Xn);for(var t=e.first;t!==null;)Hi(t),t=t.next}function Ui(e){let t=0,n=ua(0),r;return()=>{Va()&&(G(n),Ja(()=>(t===0&&(r=zo(()=>e(()=>ga(n)))),t+=1,()=>{li(()=>{--t,t===0&&(r?.(),r=void 0,ga(n))})})))}}var Wi=rr|ir;function Gi(e,t,n,r){new Ki(e,t,n,r)}var Ki=class{parent;is_pending=!1;transform_error;#e;#t=Br?Hr:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Ui(()=>(this.#m=ua(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=_o;t.b=this,t.f|=128,n(e)},this.parent=_o.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Xa(()=>{if(Br){let e=this.#t;Wr();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},Wi),Br&&(this.#e=Hr)}#g(){try{this.#a=Za(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Za(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Za(()=>e(this.#e)),li(()=>{var e=this.#c=document.createDocumentFragment(),t=Ta();e.append(t),this.#a=this.#x(()=>Za(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,io(this.#o,()=>{this.#o=null}),this.#b(Ci))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Za(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();co(this.#a,e);let t=this.#n.pending;this.#o=Za(()=>t(this.#e))}else this.#b(Ci)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){_i(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=_o,n=mo,r=ni;vo(this.#i),go(this.#i),ri(this.#i.ctx);try{return Ni.ensure(),e()}catch(e){return di(e),null}finally{vo(t),go(n),ri(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&io(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,li(()=>{this.#d=!1,this.#m&&ma(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),G(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Ci?.is_fork?(this.#a&&Ci.skip_effect(this.#a),this.#o&&Ci.skip_effect(this.#o),this.#s&&Ci.skip_effect(this.#s),Ci.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(to(this.#a),null),this.#o&&=(to(this.#o),null),this.#s&&=(to(this.#s),null),Br&&(Ur(this.#t),Gr(),Ur(Kr()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){zr();return}r=!0,i&&Mr(),this.#s!==null&&io(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){fi(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Za(()=>{var t=_o;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return fi(e,this.#i.parent),null}}))};li(()=>{var t;try{t=this.transform_error(e)}catch(e){fi(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>fi(e,this.#i&&this.#i.parent)):o(t)})}};function qi(e,t,n,r){let i=oi()?Zi:ta;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=_o,s=Ji(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){if(!(o.f&16384)){s();try{r(e)}catch(e){fi(e,o)}Yi()}}var u=Xi();if(n.length===0){c.then(()=>l(t.map(i))).finally(u);return}function d(){Promise.all(n.map(e=>$i(e))).then(e=>l([...t.map(i),...e])).catch(e=>fi(e,o)).finally(u)}c?c.then(()=>{s(),d(),Yi()}):d()}function Ji(){var e=_o,t=mo,n=ni,r=Ci;return function(i=!0){vo(e),go(t),ri(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Yi(e=!0){vo(null),go(null),ri(null),e&&Ci?.deactivate()}function Xi(){var e=_o,t=e.b,n=Ci,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function Zi(e){var t=2|Zn;return _o!==null&&(_o.f|=ir),{ctx:ni,deps:null,effects:null,equals:Jr,f:t,fn:e,reactions:null,rv:0,v:Pr,wv:0,parent:_o,ac:null}}var Qi=Symbol(`obsolete`);function $i(e,t,n){let r=_o;r===null&&Sr();var i=void 0,a=ua(Pr),o=!mo,s=new Set;return qa(()=>{var t=_o,n=Yn();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==yr&&n.reject(e)}).finally(Yi)}catch(e){n.reject(e),Yi()}var c=Ci;if(o){if(t.f&32768)var l=Xi();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Qi);else for(let e of s.values())e.reject(Qi);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Qi&&(c.activate(),t?(a.f|=ur,ma(a,t)):(a.f&8388608&&(a.f^=ur),ma(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Ha(()=>{for(let e of s)e.reject(Qi)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function ea(e){let t=Zi(e);return Zr||bo(t),t}function ta(e){let t=Zi(e);return t.equals=Xr,t}function na(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n0&&!la&&ha()}return t}function ha(){la=!1;for(let e of sa){e.f&1024&&mi(e,Qn);let t;try{t=Ao(e)}catch{t=!0}t&&Fo(e)}sa.clear()}function ga(e){pa(e,e.v+1)}function _a(e,t,n){var r=e.reactions;if(r!==null)for(var i=oi(),a=r.length,o=0;o{if(Do===o)return e();var t=mo,n=Do;go(null),Oo(o);var r=e();return go(t),Oo(n),r};return r&&n.set(`length`,da(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&kr();var i=n.get(t);return i===void 0?s(()=>{var e=da(r.value,a);return n.set(t,e),e}):pa(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>da(Pr,a));n.set(t,e),ga(i)}}else pa(r,Pr),ga(i);return!0},get(t,r,i){if(r===dr)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||Vn(t,r)?.writable)&&(o=s(()=>da(va(c?t[r]:Pr),a)),n.set(r,o)),o!==void 0){var l=G(o);return l===Pr?void 0:l}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=G(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==Pr)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===dr)return!0;var r=n.get(t),i=r!==void 0&&r.v!==Pr||Reflect.has(e,t);return(r!==void 0||_o!==null&&(!i||Vn(e,t)?.writable))&&(r===void 0&&(r=s(()=>da(i?va(e[t]):Pr,a)),n.set(t,r)),G(r)===Pr)?!1:i},set(e,t,o,c){var l=n.get(t),u=t in e;if(r&&t===`length`)for(var d=o;dda(Pr,a)),n.set(d+``,f)):pa(f,Pr)}if(l===void 0)(!u||Vn(e,t)?.writable)&&(l=s(()=>da(void 0,a)),pa(l,va(o)),n.set(t,l));else{u=l.v!==Pr;var p=s(()=>va(o));pa(l,p)}var m=Reflect.getOwnPropertyDescriptor(e,t);if(m?.set&&m.set.call(c,o),!u){if(r&&typeof t==`string`){var h=n.get(`length`),g=Number(t);Number.isInteger(g)&&g>=h.v&&pa(h,g+1)}ga(i)}return!0},ownKeys(e){G(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==Pr});for(var[r,a]of n)a.v!==Pr&&!(r in e)&&t.push(r);return t},setPrototypeOf(){Ar()}})}function ya(e){try{if(typeof e==`object`&&e&&dr in e)return e[dr]}catch{}return e}function H(e,t){return Object.is(ya(e),ya(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var ba,xa,Sa,Ca;function wa(){if(ba===void 0){ba=window,xa=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Sa=Vn(t,`firstChild`).get,Ca=Vn(t,`nextSibling`).get,Kn(e)&&(e[hr]=void 0,e[mr]=null,e[gr]=void 0,e.__e=void 0),Kn(n)&&(n[_r]=void 0)}}function Ta(e=``){return document.createTextNode(e)}function Ea(e){return Sa.call(e)}function Da(e){return Ca.call(e)}function U(e,t){if(!Br)return Ea(e);var n=Ea(Hr);if(n===null)n=Hr.appendChild(Ta());else if(t&&n.nodeType!==3){var r=Ta();return n?.before(r),Ur(r),r}return t&&Ma(n),Ur(n),n}function Oa(e,t=!1){if(!Br){var n=Ea(e);return n instanceof Comment&&n.data===``?Da(n):n}if(t){if(Hr?.nodeType!==3){var r=Ta();return Hr?.before(r),Ur(r),r}Ma(Hr)}return Hr}function W(e,t=1,n=!1){let r=Br?Hr:e;for(var i;t--;)i=r,r=Da(r);if(!Br)return r;if(n){if(r?.nodeType!==3){var a=Ta();return r===null?i?.after(a):r.before(a),Ur(a),a}Ma(r)}return Ur(r),r}function ka(e){e.textContent=``}function Aa(){return!Zr||Ii!==null?!1:(_o.f&tr)!==0}function ja(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function Ma(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Na(e){Br&&Ea(e)!==null&&ka(e)}var Pa=!1;function Fa(){Pa||(Pa=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[vr]?.()})},{capture:!0}))}function Ia(e){var t=mo,n=_o;go(null),vo(null);try{return e()}finally{go(t),vo(n)}}function La(e,t,n,r=n){e.addEventListener(t,()=>Ia(n));let i=e[vr];i?e[vr]=()=>{i(),r(!0)}:e[vr]=()=>r(!0),Fa()}function Ra(e){_o===null&&(mo===null&&Er(e),Tr()),fo&&wr(e)}function za(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Ba(e,t){var n=_o;n!==null&&n.f&8192&&(e|=$n);var r={ctx:ni,deps:null,nodes:null,f:e|Zn|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};Ci?.register_created_effect(r);var i=r;if(e&4)ki===null?Ni.ensure().schedule(r):ki.push(r);else if(t!==null){try{Fo(r)}catch(e){throw to(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=rr))}if(i!==null&&(i.parent=n,n!==null&&za(i,n),mo!==null&&mo.f&2&&!(e&64))){var a=mo;(a.effects??=[]).push(i)}return r}function Va(){return mo!==null&&!ho}function Ha(e){let t=Ba(8,null);return mi(t,Xn),t.teardown=e,t}function Ua(e){Ra(`$effect`);var t=_o.f;if(!mo&&t&32&&ni!==null&&!ni.i){var n=ni;(n.e??=[]).push(e)}else return Wa(e)}function Wa(e){return Ba(4|ar,e)}function Ga(e){Ni.ensure();let t=Ba(64|ir,e);return(e={})=>new Promise(n=>{e.outro?io(t,()=>{to(t),n(void 0)}):(to(t),n(void 0))})}function Ka(e){return Ba(4,e)}function qa(e){return Ba(lr|ir,e)}function Ja(e,t=0){return Ba(8|t,e)}function Ya(e,t=[],n=[],r=[]){qi(r,t,n,t=>{Ba(8,()=>e(...t.map(G)))})}function Xa(e,t=0){return Ba(16|t,e)}function Za(e){return Ba(32|ir,e)}function Qa(e){var t=e.teardown;if(t!==null){let e=fo,n=mo;po(!0),go(null);try{t.call(null)}finally{po(e),go(n)}}}function $a(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Ia(()=>{e.abort(yr)});var r=n.next;n.f&64?n.parent=null:to(n,t),n=r}}function eo(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||to(t),t=n}}function to(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(no(e.nodes.start,e.nodes.end),n=!0),mi(e,nr),$a(e,t&&!n),Po(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Qa(e),e.f^=nr,e.f|=er;var i=e.parent;i!==null&&i.first!==null&&ro(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function no(e,t){for(;e!==null;){var n=e===t?null:Da(e);e.remove(),e=n}}function ro(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function io(e,t,n=!0){var r=[];ao(e,r,!0);var i=()=>{n&&to(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function ao(e,t,n){if(!(e.f&8192)){e.f^=$n;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;ao(i,t,o?n:!1)}i=a}}}function oo(e){so(e,!0)}function so(e,t){if(e.f&8192){e.f^=$n,e.f&1024||(mi(e,Zn),Ni.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;so(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function co(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:Da(n);t.append(n),n=i}}var lo=null,uo=!1,fo=!1;function po(e){fo=e}var mo=null,ho=!1;function go(e){mo=e}var _o=null;function vo(e){_o=e}var yo=null;function bo(e){mo!==null&&(!Zr||mo.f&2)&&(yo??=new Set).add(e)}var xo=null,So=0,Co=null;function wo(e){Co=e}var To=1,Eo=0,Do=Eo;function Oo(e){Do=e}function ko(){return++To}function Ao(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~sr),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Ti===null&&mi(e,Xn)}return!1}function jo(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Zr&&yo!==null&&yo.has(e)))for(var i=0;i{e.ac.abort(yr)}),e.ac=null);try{e.f|=cr;var u=e.fn,d=u();e.f|=tr;var f=e.deps,p=Ci?.is_fork;if(xo!==null){var m;if(p||Po(e,So),f!==null&&So>0)for(f.length=So+xo.length,m=0;m{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Pi()}function G(e){var t=(e.f&2)!=0;if(lo?.add(e),mo!==null&&!ho&&!(_o!==null&&_o.f&16384)&&(yo===null||!yo.has(e))){var n=mo.deps;if(mo.f&2097152)e.rvn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?li(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Ko(e,t,n,r,i){var a={capture:r,passive:i},o=Go(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Ha(()=>{t.removeEventListener(e,o,a)})}function qo(e,t,n){(t[Ho]??={})[e]=n}function Jo(e){for(var t=0;t{throw e});throw f}}finally{e[Ho]=t,delete e.currentTarget,go(u),vo(d)}}}var Zo=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Qo(e){return Zo?.createHTML(e)??e}function $o(e){var t=ja(`template`);return t.innerHTML=Qo(e.replaceAll(``,``)),t.content}function es(e,t){var n=_o;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function K(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Br)return es(Hr,null),Hr;i===void 0&&(i=$o(a?e:``+e),n||(i=Ea(i)));var t=r||xa?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=Ea(t),s=t.lastChild;es(o,s)}else es(t,t);return t}}function ts(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Br)return es(Hr,null),Hr;if(!o){var e=Ea($o(a));if(i)for(o=document.createDocumentFragment();Ea(e);)o.appendChild(Ea(e));else o=Ea(e)}var t=o.cloneNode(!0);if(i){var n=Ea(t),r=t.lastChild;es(n,r)}else es(t,t);return t}}function ns(e,t){return ts(e,t,`svg`)}function rs(e=``){if(!Br){var t=Ta(e+``);return es(t,t),t}var n=Hr;return n.nodeType===3?Ma(n):(n.before(n=Ta()),Ur(n)),es(n,n),n}function is(){if(Br)return es(Hr,null),Hr;var e=document.createDocumentFragment(),t=document.createComment(``),n=Ta();return e.append(t,n),es(t,n),e}function q(e,t){if(Br){var n=_o;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Hr),Wr();return}e!==null&&e.before(t)}function as(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[_r]??=e.nodeValue)&&(e[_r]=n,e.nodeValue=`${n}`)}function os(e,t){return cs(e,t)}var ss=new Map;function cs(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s}){wa();var c=void 0,l=Ga(()=>{var o=n??t.appendChild(Ta());Gi(o,{pending:()=>{}},t=>{ii({});var n=ni;if(a&&(n.c=a),i&&(r.$$events=i),Br&&es(t,null),c=e(t,r)||{},Br&&(_o.nodes.end=Hr,Hr===null||Hr.nodeType!==8||Hr.data!==`]`))throw Lr(),Nr;ai()},s);var l=new Set,u=e=>{for(var n=0;n{for(var e of l)for(let n of[t,document]){var r=ss.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Xo),r.delete(e),r.size===0&&ss.delete(n)):r.set(e,i)}Wo.delete(u),o!==n&&o.parentNode?.removeChild(o)}});return ls.set(c,l),c}var ls=new WeakMap;function us(e,t){let n=ls.get(e);return n?(ls.delete(e),n(t)):Promise.resolve()}var ds=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)oo(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(oo(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(to(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();co(r,t),t.append(Ta()),this.#n.set(e,{effect:r,fragment:t})}else to(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),io(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(to(n.effect),this.#n.delete(e))};ensure(e,t){var n=Ci,r=Aa();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=Ta();i.append(a),this.#n.set(e,{effect:Za(()=>t(a)),fragment:i})}else this.#t.set(e,Za(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else Br&&(this.anchor=Hr),this.#a(n)}};function fs(e,t,n=!1){var r;Br&&(r=Hr,Wr());var i=new ds(e),a=n?rr:0;function o(e,t){if(Br){var n=qr(r);if(e!==parseInt(n.substring(1))){var a=Kr();Ur(a),i.anchor=a,Vr(!1),i.ensure(e,t),Vr(!0);return}}i.ensure(e,t)}Xa(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function ps(e,t){return t}function ms(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;hs(e,zn(a.done)),t.delete(a),t.size===0&&(e.outrogroups=null)}}else --o},!1)}if(o===0){var c=r.length===0&&n!==null;if(c){var l=n,u=l.parentNode;ka(u),u.append(l),e.items.clear()}hs(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function hs(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var e=n();return In(e)?e:e==null?[]:zn(e)}),d,f=new Map,p=!0;function m(e){g.effect.f&16384||(g.pending.delete(e),g.fallback=l,ys(g,d,o,t,r),l!==null&&(d.length===0?l.f&33554432?(l.f^=or,xs(l,null,o)):oo(l):io(l,()=>{l=null})))}function h(e){g.pending.delete(e)}var g={effect:Xa(()=>{d=G(u);var e=d.length;let c=!1;Br&&qr(o)===`[!`!=(e===0)&&(o=Kr(),Ur(o),Vr(!1),c=!0);for(var g=new Set,_=Ci,v=Aa(),y=0;ya(o)):(l=Za(()=>a(gs??=Ta())),l.f|=or)),e>g.size&&Cr(``,``,``),Br&&e>0&&Ur(Kr()),!p)if(f.set(_,g),v){for(let[e,t]of s)g.has(e)||_.skip_effect(t.e);_.oncommit(m),_.ondiscard(h)}else m(_);c&&Vr(!0),G(u)}),flags:t,items:s,pending:f,outrogroups:null,fallback:l};p=!1,Br&&(o=Hr)}function vs(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function ys(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=vs(e.effect.first),l,u=null,d,f=[],p=[],m,h,g,_;if(a)for(_=0;_0){var T=r&4&&o===0?n:null;if(a){for(_=0;_{if(d!==void 0)for(g of d)g.nodes?.a?.apply()})}function bs(e,t,n,r,i,a,o,s){var c=o&1?o&16?ua(n):fa(n,!1,!1):null,l=o&2?ua(i):null;return{v:c,i:l,e:Za(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function xs(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=Da(r);if(a.before(r),r===i)return;r=o}}function Ss(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Cs(e,t,...n){var r=new ds(e);Xa(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},rr)}function ws(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Ds.includes(r[o-1]))&&(s===r.length||Ds.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ks(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function As(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function js(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(As)),i&&c.push(...Object.keys(i).map(As));var l=0,u=-1;let t=e.length;for(var d=0;d{Fs(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),Ha(()=>{t.disconnect()})}function Ls(e,t,n=t){var r=new WeakSet,i=!0;La(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Rs);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Rs(o)}n(a),e.__value=a,Ci!==null&&r.add(Ci)}),Ka(()=>{var a=t();if(e===document.activeElement){var o=Zr?wi:Ci;if(r.has(o))return}if(Fs(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Rs(s),n(a))}e.__value=a,i=!1}),Is(e)}function Rs(e){return`__value`in e?e.__value:e.value}var zs=Symbol(`is custom element`),Bs=Symbol(`is html`),Vs=br?`link`:`LINK`,Hs=br?`progress`:`PROGRESS`;function Us(e){if(Br){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Ks(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Ks(e,`checked`,null),e.checked=r}}};e[vr]=n,li(n),Fa()}}function Ws(e,t){var n=qs(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Hs)||(e.value=t??``)}function Gs(e,t){var n=qs(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Ks(e,t,n,r){var i=qs(e);Br&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Vs)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[pr]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ys(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function qs(e){return e[mr]??={[zs]:e.nodeName.includes(`-`),[Bs]:e.namespaceURI===Fr}}var Js=new Map;function Ys(e){var t=e.getAttribute(`is`)||e.nodeName,n=Js.get(t);if(n)return n;Js.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=Hn(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=Gn(i)}return n}function Xs(e,t,n=t){var r=new WeakSet;La(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Zs(e)?Qs(a):a,n(a),Ci!==null&&r.add(Ci),await Io(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(Br&&e.defaultValue!==e.value||zo(t)==null&&e.value)&&(n(Zs(e)?Qs(e.value):e.value),Ci!==null&&r.add(Ci)),Ja(()=>{var n=t();if(e===document.activeElement){var i=Zr?wi:Ci;if(r.has(i))return}Zs(e)&&n===Qs(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function Zs(e){var t=e.type;return t===`number`||t===`range`}function Qs(e){return e===``?null:+e}function $s(e,t){return e===t||e?.[dr]===t}function ec(e={},t,n,r){var i=ni.r,a=_o;return Ka(()=>{var o,s;return Ja(()=>{o=s,s=r?.()||[],zo(()=>{$s(n(...s),e)||(t(e,...s),o&&$s(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&$s(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function tc(e,t,n,r){var i=!Qr||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=void 0,u=()=>o&&i?(l??=Zi(r),G(l)):(c&&(c=!1,s=o?zo(r):r),s);let d;if(a){var f=dr in e||fr in e;d=Vn(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var p,m=!1;a?[p,m]=bi(()=>e[t]):p=e[t],p===void 0&&r!==void 0&&(p=u(),d&&(i&&Or(t),d(p)));var h=i?()=>{var n=e[t];return n===void 0?u():(c=!0,n)}:()=>{var n=e[t];return n!==void 0&&(s=void 0),n===void 0?s:n};if(i&&!(n&4))return h;if(d){var g=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||g||m)&&d(t?h():e),e):h()})}var _=!1,v=(n&1?Zi:ta)(()=>(_=!1,h()));a&&G(v);var y=_o;return(function(e,t){if(arguments.length>0){let n=t?G(v):i&&a?va(e):e;return pa(v,n),_=!0,s!==void 0&&(s=n),e}return fo&&_||y.f&16384?v.v:G(v)})}function nc(e){ni===null&&xr(`onMount`),Qr&&ni.l!==null?ic(ni).m.push(e):Ua(()=>{let t=zo(e);if(typeof t==`function`)return t})}function rc(e){ni===null&&xr(`onDestroy`),nc(()=>()=>zo(e))}function ic(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}var ac=class{mb;svelteComponent;svelteComponentInstance;mounted;onValueChange;constructor(e,t,n){this.mb=e,this.mounted=!1,this.svelteComponent=t,this.onValueChange=n}setValue(e){this.svelteComponentInstance?.setValue(e)}getInstance(){return this.svelteComponentInstance}mount(e,t,n={}){let r=Object.assign({mb:this.mb,value:t,onValueChange:this.onValueChange},n);this.svelteComponentInstance=os(this.svelteComponent,{target:e,props:r}),this.mounted=!0}unmount(){this.svelteComponentInstance&&us(this.svelteComponentInstance),this.mounted=!1}isMounted(){return this.mounted}},oc=class{mounted;targetEl;onUnmountCbs;constructor(){this.mounted=!1,this.targetEl=void 0,this.onUnmountCbs=[]}isMounted(){return this.mounted}getTargetEl(){return this.targetEl}mount(e){if(this.mounted||this.targetEl){console.warn(`Mountable is already mounted`,this);return}if(e===void 0){console.error(`Mountable target element is undefined`,this);return}this.mounted=!0,this.targetEl=e,this.onMount(e)}unmount(){if(!this.mounted||!this.targetEl){console.warn(`Mountable is not mounted`,this);return}this.mounted=!1,this.onUnmount(this.targetEl);for(let e of this.onUnmountCbs)e();this.targetEl=void 0}registerUnmountCb(e){this.onUnmountCbs.push(e)}},sc=class{listeners;constructor(){this.listeners=[]}registerListener(e){let t=e;return t.uuid=w(),this.listeners.push(t),t}unregisterListener(e){this.unregisterListenerById(e.uuid)}unregisterListenerById(e){this.listeners=this.listeners.filter(t=>t.uuid!==e)}unregisterAllListeners(){this.listeners=[]}notifyListeners(e){for(let t of this.listeners)try{t.callback(e)}catch(e){let t=e instanceof Error?e:String(e);console.error(new _e({errorLevel:B.ERROR,effect:`error while calling listener callback`,cause:t}))}}},cc=class extends sc{value;constructor(e){super(),this.value=e}get(){return this.value}set(e){this.value=e,this.notifyListeners(e)}},lc=class extends sc{value;mapFn;constructor(e,t){super(),this.value=t(e),this.mapFn=t}get(){return this.value}set(e){this.value=this.mapFn(e),this.notifyListeners(this.value)}setDirect(e){this.value=e,this.notifyListeners(e)}},uc=class extends oc{mb;mountable;svelteWrapper;inputSignal;metadataSubscription;mountTarget;constructor(e){super(),this.mountable=e,this.mb=e.mb}reverseMapValue(e){let t=this.rawReverseMapValue(e);if(t!==void 0)return t;let n=this.rawReverseMapValue(this.getDefaultValue());return n===void 0?this.getFallbackDefaultValue():n}mapValue(e){return this.rawMapValue(e)}getValue(){return this.inputSignal?this.inputSignal.get():this.getDefaultValue()}getInternalValue(){return this.reverseMapValue(this.getValue())}setValue(e){this.inputSignal?.setDirect(e),this.notifySubscription(e)}setInternalValue(e){this.setValue(this.mapValue(e))}notifySubscription(e){this.metadataSubscription?.write(e)}getDefaultValue(){let e=this.mountable.getArgument(kn.DEFAULT_VALUE);if(e===void 0)return this.mapValue(this.getFallbackDefaultValue());let t=this.filterValue(e.value);return t===void 0?this.mapValue(this.getFallbackDefaultValue()):t}updateDataAttributes(e){this.mountTarget&&(this.mountTarget.dataset.internalValue=JSON.stringify(e))}getMountArgs(){return{}}onMount(e){this.mountTarget=e,this.svelteWrapper=new ac(this.mb,this.getSvelteComponent(),e=>{this.updateDataAttributes(e),this.notifySubscription(this.mapValue(e))}),this.inputSignal=new lc(void 0,e=>{let t=this.filterValue(e);return t===void 0?this.getDefaultValue():t}),this.inputSignal.registerListener({callback:e=>this.svelteWrapper?.setValue(this.reverseMapValue(e))}),this.inputSignal.registerListener({callback:e=>{this.updateDataAttributes(this.reverseMapValue(e))}}),this.updateDataAttributes(this.getInternalValue());let t=this.mountable.getBindTarget();t&&(this.metadataSubscription=this.mountable.mb.metadataManager.subscribe(this.mountable.getUuid(),this.inputSignal,t,()=>this.mountable.unmount())),this.svelteWrapper.mount(e,this.reverseMapValue(this.getValue()),this.getMountArgs())}onUnmount(){this.mountTarget=void 0,this.inputSignal?.unregisterAllListeners(),this.metadataSubscription?.unsubscribe(),this.svelteWrapper?.unmount()}},dc;function J(){return dc.apply(null,arguments)}function fc(e){dc=e}function pc(e){return e instanceof Array||Object.prototype.toString.call(e)===`[object Array]`}function mc(e){return e!=null&&Object.prototype.toString.call(e)===`[object Object]`}function hc(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function gc(e){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(e).length===0;for(var t in e)if(hc(e,t))return!1;return!0}function _c(e){return e===void 0}function vc(e){return typeof e==`number`||Object.prototype.toString.call(e)===`[object Number]`}function yc(e){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`}function bc(e,t){var n=[],r,i=e.length;for(r=0;r>>0,r;for(r=0;r0)for(n=0;n=0?n?`+`:``:`-`)+(10**Math.max(0,i)).toString().substr(1)+r}var Gc=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Kc=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,qc={},Jc={};function Yc(e,t,n,r){var i=r;typeof r==`string`&&(i=function(){return this[r]()}),e&&(Jc[e]=i),t&&(Jc[t[0]]=function(){return Wc(i.apply(this,arguments),t[1],t[2])}),n&&(Jc[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),e)})}function Xc(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,``):e.replace(/\\/g,``)}function Zc(e){var t=e.match(Gc),n,r;for(n=0,r=t.length;n=0&&Kc.test(e);)e=e.replace(Kc,r),Kc.lastIndex=0,--n;return e}var el={LTS:`h:mm:ss A`,LT:`h:mm A`,L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`};function tl(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(Gc).map(function(e){return e===`MMMM`||e===`MM`||e===`DD`||e===`dddd`?e.slice(1):e}).join(``),this._longDateFormat[e])}var nl=`Invalid date`;function rl(){return this._invalidDate}var il=`%d`,al=/\d{1,2}/;function ol(e){return this._ordinal.replace(`%d`,e)}var sl={future:`in %s`,past:`%s ago`,s:`a few seconds`,ss:`%d seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,w:`a week`,ww:`%d weeks`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function cl(e,t,n,r){var i=this._relativeTime[n];return Lc(i)?i(e,t,n,r):i.replace(/%d/i,e)}function ll(e,t){var n=this._relativeTime[e>0?`future`:`past`];return Lc(n)?n(t):n.replace(/%s/i,t)}var ul={D:`date`,dates:`date`,date:`date`,d:`day`,days:`day`,day:`day`,e:`weekday`,weekdays:`weekday`,weekday:`weekday`,E:`isoWeekday`,isoweekdays:`isoWeekday`,isoweekday:`isoWeekday`,DDD:`dayOfYear`,dayofyears:`dayOfYear`,dayofyear:`dayOfYear`,h:`hour`,hours:`hour`,hour:`hour`,ms:`millisecond`,milliseconds:`millisecond`,millisecond:`millisecond`,m:`minute`,minutes:`minute`,minute:`minute`,M:`month`,months:`month`,month:`month`,Q:`quarter`,quarters:`quarter`,quarter:`quarter`,s:`second`,seconds:`second`,second:`second`,gg:`weekYear`,weekyears:`weekYear`,weekyear:`weekYear`,GG:`isoWeekYear`,isoweekyears:`isoWeekYear`,isoweekyear:`isoWeekYear`,w:`week`,weeks:`week`,week:`week`,W:`isoWeek`,isoweeks:`isoWeek`,isoweek:`isoWeek`,y:`year`,years:`year`,year:`year`};function dl(e){return typeof e==`string`?ul[e]||ul[e.toLowerCase()]:void 0}function fl(e){var t={},n,r;for(r in e)hc(e,r)&&(n=dl(r),n&&(t[n]=e[r]));return t}var pl={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function ml(e){var t=[],n;for(n in e)hc(e,n)&&t.push({unit:n,priority:pl[n]});return t.sort(function(e,t){return e.priority-t.priority}),t}var hl=/\d/,gl=/\d\d/,_l=/\d{3}/,vl=/\d{4}/,yl=/[+-]?\d{6}/,bl=/\d\d?/,xl=/\d\d\d\d?/,Sl=/\d\d\d\d\d\d?/,Cl=/\d{1,3}/,wl=/\d{1,4}/,Tl=/[+-]?\d{1,6}/,El=/\d+/,Dl=/[+-]?\d+/,Ol=/Z|[+-]\d\d:?\d\d/gi,kl=/Z|[+-]\d\d(?::?\d\d)?/gi,Al=/[+-]?\d+(\.\d{1,3})?/,jl=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,Ml=/^[1-9]\d?/,Nl=/^([1-9]\d|\d)/,Pl={};function Fl(e,t,n){Pl[e]=Lc(t)?t:function(e,r){return e&&n?n:t}}function Il(e,t){return hc(Pl,e)?Pl[e](t._strict,t._locale):new RegExp(Ll(e))}function Ll(e){return Rl(e.replace(`\\`,``).replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,r,i){return t||n||r||i}))}function Rl(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)}function zl(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function Bl(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=zl(t)),n}var Vl={};function Hl(e,t){var n,r=t,i;for(typeof e==`string`&&(e=[e]),vc(t)&&(r=function(e,n){n[t]=Bl(e)}),i=e.length,n=0;n68?1900:2e3)};var nu=iu(`FullYear`,!0);function ru(){return Gl(this.year())}function iu(e,t){return function(n){return n==null?au(this,e):(ou(this,e,n),J.updateOffset(this,t),this)}}function au(e,t){if(!e.isValid())return NaN;var n=e._d,r=e._isUTC;switch(t){case`Milliseconds`:return r?n.getUTCMilliseconds():n.getMilliseconds();case`Seconds`:return r?n.getUTCSeconds():n.getSeconds();case`Minutes`:return r?n.getUTCMinutes():n.getMinutes();case`Hours`:return r?n.getUTCHours():n.getHours();case`Date`:return r?n.getUTCDate():n.getDate();case`Day`:return r?n.getUTCDay():n.getDay();case`Month`:return r?n.getUTCMonth():n.getMonth();case`FullYear`:return r?n.getUTCFullYear():n.getFullYear();default:return NaN}}function ou(e,t,n){var r,i,a,o,s;if(!(!e.isValid()||isNaN(n))){switch(r=e._d,i=e._isUTC,t){case`Milliseconds`:i?r.setUTCMilliseconds(n):r.setMilliseconds(n);return;case`Seconds`:i?r.setUTCSeconds(n):r.setSeconds(n);return;case`Minutes`:i?r.setUTCMinutes(n):r.setMinutes(n);return;case`Hours`:i?r.setUTCHours(n):r.setHours(n);return;case`Date`:i?r.setUTCDate(n):r.setDate(n);return;case`FullYear`:break;default:return}a=n,o=e.month(),s=e.date(),s=s===29&&o===1&&!Gl(a)?28:s,i?r.setUTCFullYear(a,o,s):r.setFullYear(a,o,s)}}function su(e){return e=dl(e),Lc(this[e])?this[e]():this}function cu(e,t){if(typeof e==`object`){e=fl(e);var n=ml(e),r,i=n.length;for(r=0;r=0?(s=new Date(e+400,t,n,r,i,a,o),isFinite(s.getFullYear())&&s.setFullYear(e)):s=new Date(e,t,n,r,i,a,o),s}function Ou(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function ku(e,t,n){var r=7+t-n;return-((7+Ou(e,0,r).getUTCDay()-t)%7)+r-1}function Au(e,t,n,r,i){var a=(7+n-r)%7,o=ku(e,r,i),s=1+7*(t-1)+a+o,c,l;return s<=0?(c=e-1,l=tu(c)+s):s>tu(e)?(c=e+1,l=s-tu(e)):(c=e,l=s),{year:c,dayOfYear:l}}function ju(e,t,n){var r=ku(e.year(),t,n),i=Math.floor((e.dayOfYear()-r-1)/7)+1,a,o;return i<1?(o=e.year()-1,a=i+Mu(o,t,n)):i>Mu(e.year(),t,n)?(a=i-Mu(e.year(),t,n),o=e.year()+1):(o=e.year(),a=i),{week:a,year:o}}function Mu(e,t,n){var r=ku(e,t,n),i=ku(e+1,t,n);return(tu(e)-r+i)/7}Yc(`w`,[`ww`,2],`wo`,`week`),Yc(`W`,[`WW`,2],`Wo`,`isoWeek`),Fl(`w`,bl,Ml),Fl(`ww`,bl,gl),Fl(`W`,bl,Ml),Fl(`WW`,bl,gl),Ul([`w`,`ww`,`W`,`WW`],function(e,t,n,r){t[r.substr(0,1)]=Bl(e)});function Nu(e){return ju(e,this._week.dow,this._week.doy).week}var Pu={dow:0,doy:6};function Fu(){return this._week.dow}function Iu(){return this._week.doy}function Lu(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,`d`)}function Ru(e){var t=ju(this,1,4).week;return e==null?t:this.add((e-t)*7,`d`)}Yc(`d`,0,`do`,`day`),Yc(`dd`,0,0,function(e){return this.localeData().weekdaysMin(this,e)}),Yc(`ddd`,0,0,function(e){return this.localeData().weekdaysShort(this,e)}),Yc(`dddd`,0,0,function(e){return this.localeData().weekdays(this,e)}),Yc(`e`,0,0,`weekday`),Yc(`E`,0,0,`isoWeekday`),Fl(`d`,bl),Fl(`e`,bl),Fl(`E`,bl),Fl(`dd`,function(e,t){return t.weekdaysMinRegex(e)}),Fl(`ddd`,function(e,t){return t.weekdaysShortRegex(e)}),Fl(`dddd`,function(e,t){return t.weekdaysRegex(e)}),Ul([`dd`,`ddd`,`dddd`],function(e,t,n,r){var i=n._locale.weekdaysParse(e,r,n._strict);i==null?wc(n).invalidWeekday=e:t.d=i}),Ul([`d`,`e`,`E`],function(e,t,n,r){t[r]=Bl(e)});function zu(e,t){return typeof e==`string`?isNaN(e)?(e=t.weekdaysParse(e),typeof e==`number`?e:null):parseInt(e,10):e}function Bu(e,t){return typeof e==`string`?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function Vu(e,t){return e.slice(t,7).concat(e.slice(0,t))}var Hu=`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),Uu=`Sun_Mon_Tue_Wed_Thu_Fri_Sat`.split(`_`),Wu=`Su_Mo_Tu_We_Th_Fr_Sa`.split(`_`),Gu=jl,Ku=jl,qu=jl;function Ju(e,t){var n=pc(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?`format`:`standalone`];return e===!0?Vu(n,this._week.dow):e?n[e.day()]:n}function Yu(e){return e===!0?Vu(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function Xu(e){return e===!0?Vu(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function Zu(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],r=0;r<7;++r)a=Sc([2e3,1]).day(r),this._minWeekdaysParse[r]=this.weekdaysMin(a,``).toLocaleLowerCase(),this._shortWeekdaysParse[r]=this.weekdaysShort(a,``).toLocaleLowerCase(),this._weekdaysParse[r]=this.weekdays(a,``).toLocaleLowerCase();return n?t===`dddd`?(i=uu.call(this._weekdaysParse,o),i===-1?null:i):t===`ddd`?(i=uu.call(this._shortWeekdaysParse,o),i===-1?null:i):(i=uu.call(this._minWeekdaysParse,o),i===-1?null:i):t===`dddd`?(i=uu.call(this._weekdaysParse,o),i!==-1||(i=uu.call(this._shortWeekdaysParse,o),i!==-1)?i:(i=uu.call(this._minWeekdaysParse,o),i===-1?null:i)):t===`ddd`?(i=uu.call(this._shortWeekdaysParse,o),i!==-1||(i=uu.call(this._weekdaysParse,o),i!==-1)?i:(i=uu.call(this._minWeekdaysParse,o),i===-1?null:i)):(i=uu.call(this._minWeekdaysParse,o),i!==-1||(i=uu.call(this._weekdaysParse,o),i!==-1)?i:(i=uu.call(this._shortWeekdaysParse,o),i===-1?null:i))}function Qu(e,t,n){var r,i,a;if(this._weekdaysParseExact)return Zu.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),r=0;r<7;r++)if(i=Sc([2e3,1]).day(r),n&&!this._fullWeekdaysParse[r]&&(this._fullWeekdaysParse[r]=RegExp(`^`+this.weekdays(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._shortWeekdaysParse[r]=RegExp(`^`+this.weekdaysShort(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._minWeekdaysParse[r]=RegExp(`^`+this.weekdaysMin(i,``).replace(`.`,`\\.?`)+`$`,`i`)),this._weekdaysParse[r]||(a=`^`+this.weekdays(i,``)+`|^`+this.weekdaysShort(i,``)+`|^`+this.weekdaysMin(i,``),this._weekdaysParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`dddd`&&this._fullWeekdaysParse[r].test(e)||n&&t===`ddd`&&this._shortWeekdaysParse[r].test(e)||n&&t===`dd`&&this._minWeekdaysParse[r].test(e)||!n&&this._weekdaysParse[r].test(e))return r}function $u(e){if(!this.isValid())return e==null?NaN:this;var t=au(this,`Day`);return e==null?t:(e=zu(e,this.localeData()),this.add(e-t,`d`))}function ed(e){if(!this.isValid())return e==null?NaN:this;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,`d`)}function td(e){if(!this.isValid())return e==null?NaN:this;if(e!=null){var t=Bu(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function nd(e){return this._weekdaysParseExact?(hc(this,`_weekdaysRegex`)||ad.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(hc(this,`_weekdaysRegex`)||(this._weekdaysRegex=Gu),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function rd(e){return this._weekdaysParseExact?(hc(this,`_weekdaysRegex`)||ad.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(hc(this,`_weekdaysShortRegex`)||(this._weekdaysShortRegex=Ku),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function id(e){return this._weekdaysParseExact?(hc(this,`_weekdaysRegex`)||ad.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(hc(this,`_weekdaysMinRegex`)||(this._weekdaysMinRegex=qu),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function ad(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i=[],a,o,s,c,l;for(a=0;a<7;a++)o=Sc([2e3,1]).day(a),s=Rl(this.weekdaysMin(o,``)),c=Rl(this.weekdaysShort(o,``)),l=Rl(this.weekdays(o,``)),t.push(s),n.push(c),r.push(l),i.push(s),i.push(c),i.push(l);t.sort(e),n.sort(e),r.sort(e),i.sort(e),this._weekdaysRegex=RegExp(`^(`+i.join(`|`)+`)`,`i`),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._weekdaysShortStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._weekdaysMinStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function od(){return this.hours()%12||12}function sd(){return this.hours()||24}Yc(`H`,[`HH`,2],0,`hour`),Yc(`h`,[`hh`,2],0,od),Yc(`k`,[`kk`,2],0,sd),Yc(`hmm`,0,0,function(){return``+od.apply(this)+Wc(this.minutes(),2)}),Yc(`hmmss`,0,0,function(){return``+od.apply(this)+Wc(this.minutes(),2)+Wc(this.seconds(),2)}),Yc(`Hmm`,0,0,function(){return``+this.hours()+Wc(this.minutes(),2)}),Yc(`Hmmss`,0,0,function(){return``+this.hours()+Wc(this.minutes(),2)+Wc(this.seconds(),2)});function cd(e,t){Yc(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}cd(`a`,!0),cd(`A`,!1);function ld(e,t){return t._meridiemParse}Fl(`a`,ld),Fl(`A`,ld),Fl(`H`,bl,Nl),Fl(`h`,bl,Ml),Fl(`k`,bl,Ml),Fl(`HH`,bl,gl),Fl(`hh`,bl,gl),Fl(`kk`,bl,gl),Fl(`hmm`,xl),Fl(`hmmss`,Sl),Fl(`Hmm`,xl),Fl(`Hmmss`,Sl),Hl([`H`,`HH`],Yl),Hl([`k`,`kk`],function(e,t,n){var r=Bl(e);t[Yl]=r===24?0:r}),Hl([`a`,`A`],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),Hl([`h`,`hh`],function(e,t,n){t[Yl]=Bl(e),wc(n).bigHour=!0}),Hl(`hmm`,function(e,t,n){var r=e.length-2;t[Yl]=Bl(e.substr(0,r)),t[Xl]=Bl(e.substr(r)),wc(n).bigHour=!0}),Hl(`hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[Yl]=Bl(e.substr(0,r)),t[Xl]=Bl(e.substr(r,2)),t[Zl]=Bl(e.substr(i)),wc(n).bigHour=!0}),Hl(`Hmm`,function(e,t,n){var r=e.length-2;t[Yl]=Bl(e.substr(0,r)),t[Xl]=Bl(e.substr(r))}),Hl(`Hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[Yl]=Bl(e.substr(0,r)),t[Xl]=Bl(e.substr(r,2)),t[Zl]=Bl(e.substr(i))});function ud(e){return(e+``).toLowerCase().charAt(0)===`p`}var dd=/[ap]\.?m?\.?/i,fd=iu(`Hours`,!0);function pd(e,t,n){return e>11?n?`pm`:`PM`:n?`am`:`AM`}var md={calendar:Hc,longDateFormat:el,invalidDate:nl,ordinal:il,dayOfMonthOrdinalParse:al,relativeTime:sl,months:fu,monthsShort:pu,week:Pu,weekdays:Hu,weekdaysMin:Wu,weekdaysShort:Uu,meridiemParse:dd},hd={},gd={},_d;function vd(e,t){var n,r=Math.min(e.length,t.length);for(n=0;n0;){if(i=Sd(a.slice(0,n).join(`-`)),i)return i;if(r&&r.length>=n&&vd(a,r)>=n-1)break;n--}t++}return _d}function xd(e){return!!(e&&e.match(`^[^/\\\\]*$`))}function Sd(e){var t=null,n;if(hd[e]===void 0&&typeof module<`u`&&module&&module.exports&&xd(e))try{t=_d._abbr,n=require,n(`./locale/`+e),Cd(t)}catch{hd[e]=null}return hd[e]}function Cd(e,t){var n;return e&&(n=_c(t)?Ed(e):wd(e,t),n?_d=n:typeof console<`u`&&console.warn&&console.warn(`Locale `+e+` not found. Did you forget to load it?`)),_d._abbr}function wd(e,t){if(t!==null){var n,r=md;if(t.abbr=e,hd[e]!=null)Ic(`defineLocaleOverride`,`use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.`),r=hd[e]._config;else if(t.parentLocale!=null)if(hd[t.parentLocale]!=null)r=hd[t.parentLocale]._config;else if(n=Sd(t.parentLocale),n!=null)r=n._config;else return gd[t.parentLocale]||(gd[t.parentLocale]=[]),gd[t.parentLocale].push({name:e,config:t}),null;return hd[e]=new Bc(zc(r,t)),gd[e]&&gd[e].forEach(function(e){wd(e.name,e.config)}),Cd(e),hd[e]}else return delete hd[e],null}function Td(e,t){if(t!=null){var n,r,i=md;hd[e]!=null&&hd[e].parentLocale!=null?hd[e].set(zc(hd[e]._config,t)):(r=Sd(e),r!=null&&(i=r._config),t=zc(i,t),r??(t.abbr=e),n=new Bc(t),n.parentLocale=hd[e],hd[e]=n),Cd(e)}else hd[e]!=null&&(hd[e].parentLocale==null?hd[e]!=null&&delete hd[e]:(hd[e]=hd[e].parentLocale,e===Cd()&&Cd(e)));return hd[e]}function Ed(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return _d;if(!pc(e)){if(t=Sd(e),t)return t;e=[e]}return bd(e)}function Dd(){return Vc(hd)}function Od(e){var t,n=e._a;return n&&wc(e).overflow===-2&&(t=n[ql]<0||n[ql]>11?ql:n[Jl]<1||n[Jl]>du(n[Kl],n[ql])?Jl:n[Yl]<0||n[Yl]>24||n[Yl]===24&&(n[Xl]!==0||n[Zl]!==0||n[Ql]!==0)?Yl:n[Xl]<0||n[Xl]>59?Xl:n[Zl]<0||n[Zl]>59?Zl:n[Ql]<0||n[Ql]>999?Ql:-1,wc(e)._overflowDayOfYear&&(tJl)&&(t=Jl),wc(e)._overflowWeeks&&t===-1&&(t=$l),wc(e)._overflowWeekday&&t===-1&&(t=eu),wc(e).overflow=t),e}var kd=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ad=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,jd=/Z|[+-]\d\d(?::?\d\d)?/,Md=[[`YYYYYY-MM-DD`,/[+-]\d{6}-\d\d-\d\d/],[`YYYY-MM-DD`,/\d{4}-\d\d-\d\d/],[`GGGG-[W]WW-E`,/\d{4}-W\d\d-\d/],[`GGGG-[W]WW`,/\d{4}-W\d\d/,!1],[`YYYY-DDD`,/\d{4}-\d{3}/],[`YYYY-MM`,/\d{4}-\d\d/,!1],[`YYYYYYMMDD`,/[+-]\d{10}/],[`YYYYMMDD`,/\d{8}/],[`GGGG[W]WWE`,/\d{4}W\d{3}/],[`GGGG[W]WW`,/\d{4}W\d{2}/,!1],[`YYYYDDD`,/\d{7}/],[`YYYYMM`,/\d{6}/,!1],[`YYYY`,/\d{4}/,!1]],Nd=[[`HH:mm:ss.SSSS`,/\d\d:\d\d:\d\d\.\d+/],[`HH:mm:ss,SSSS`,/\d\d:\d\d:\d\d,\d+/],[`HH:mm:ss`,/\d\d:\d\d:\d\d/],[`HH:mm`,/\d\d:\d\d/],[`HHmmss.SSSS`,/\d\d\d\d\d\d\.\d+/],[`HHmmss,SSSS`,/\d\d\d\d\d\d,\d+/],[`HHmmss`,/\d\d\d\d\d\d/],[`HHmm`,/\d\d\d\d/],[`HH`,/\d\d/]],Pd=/^\/?Date\((-?\d+)/i,Fd=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Id={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Ld(e){var t,n,r=e._i,i=kd.exec(r)||Ad.exec(r),a,o,s,c,l=Md.length,u=Nd.length;if(i){for(wc(e).iso=!0,t=0,n=l;ttu(o)||e._dayOfYear===0)&&(wc(e)._overflowDayOfYear=!0),n=Ou(o,0,e._dayOfYear),e._a[ql]=n.getUTCMonth(),e._a[Jl]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=r[t]=i[t];for(;t<7;t++)e._a[t]=r[t]=e._a[t]==null?+(t===2):e._a[t];e._a[Yl]===24&&e._a[Xl]===0&&e._a[Zl]===0&&e._a[Ql]===0&&(e._nextDay=!0,e._a[Yl]=0),e._d=(e._useUTC?Ou:Du).apply(null,r),a=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[Yl]=24),e._w&&e._w.d!==void 0&&e._w.d!==a&&(wc(e).weekdayMismatch=!0)}}function Jd(e){var t=e._w,n,r,i,a,o,s,c,l;t.GG!=null||t.W!=null||t.E!=null?(a=1,o=4,n=Gd(t.GG,e._a[Kl],ju(rf(),1,4).year),r=Gd(t.W,1),i=Gd(t.E,1),(i<1||i>7)&&(c=!0)):(a=e._locale._week.dow,o=e._locale._week.doy,l=ju(rf(),a,o),n=Gd(t.gg,e._a[Kl],l.year),r=Gd(t.w,l.week),t.d==null?t.e==null?i=a:(i=t.e+a,(t.e<0||t.e>6)&&(c=!0)):(i=t.d,(i<0||i>6)&&(c=!0))),r<1||r>Mu(n,a,o)?wc(e)._overflowWeeks=!0:c==null?(s=Au(n,r,i,a,o),e._a[Kl]=s.year,e._dayOfYear=s.dayOfYear):wc(e)._overflowWeekday=!0}J.ISO_8601=function(){},J.RFC_2822=function(){};function Yd(e){if(e._f===J.ISO_8601){Ld(e);return}if(e._f===J.RFC_2822){Ud(e);return}e._a=[],wc(e).empty=!0;var t=``+e._i,n,r,i,a,o,s=t.length,c=0,l,u;for(i=$c(e._f,e._locale).match(Gc)||[],u=i.length,n=0;n0&&wc(e).unusedInput.push(o),t=t.slice(t.indexOf(r)+r.length),c+=r.length),Jc[a]?(r?wc(e).empty=!1:wc(e).unusedTokens.push(a),Wl(a,r,e)):e._strict&&!r&&wc(e).unusedTokens.push(a);wc(e).charsLeftOver=s-c,t.length>0&&wc(e).unusedInput.push(t),e._a[Yl]<=12&&wc(e).bigHour===!0&&e._a[Yl]>0&&(wc(e).bigHour=void 0),wc(e).parsedDateParts=e._a.slice(0),wc(e).meridiem=e._meridiem,e._a[Yl]=Xd(e._locale,e._a[Yl],e._meridiem),l=wc(e).era,l!==null&&(e._a[Kl]=e._locale.erasConvertYear(l,e._a[Kl])),qd(e),Od(e)}function Xd(e,t,n){var r;return n==null?t:e.meridiemHour==null?e.isPM==null?t:(r=e.isPM(n),r&&t<12&&(t+=12),!r&&t===12&&(t=0),t):e.meridiemHour(t,n)}function Zd(e){var t,n,r,i,a,o,s=!1,c=e._f.length;if(c===0){wc(e).invalidFormat=!0,e._d=new Date(NaN);return}for(i=0;ithis?this:e:Dc()});function sf(e,t){var n,r;if(t.length===1&&pc(t[0])&&(t=t[0]),!t.length)return rf();for(n=t[0],r=1;rthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function jf(){if(!_c(this._isDSTShifted))return this._isDSTShifted;var e={},t;return Ac(e,this),e=ef(e),e._a?(t=e._isUTC?Sc(e._a):rf(e._a),this._isDSTShifted=this.isValid()&&vf(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Mf(){return this.isValid()?!this._isUTC:!1}function Nf(){return this.isValid()?this._isUTC:!1}function Pf(){return this.isValid()?this._isUTC&&this._offset===0:!1}var Ff=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,If=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Lf(e,t){var n=e,r=null,i,a,o;return gf(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:vc(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(r=Ff.exec(e))?(i=r[1]===`-`?-1:1,n={y:0,d:Bl(r[Jl])*i,h:Bl(r[Yl])*i,m:Bl(r[Xl])*i,s:Bl(r[Zl])*i,ms:Bl(_f(r[Ql]*1e3))*i}):(r=If.exec(e))?(i=r[1]===`-`?-1:1,n={y:Rf(r[2],i),M:Rf(r[3],i),w:Rf(r[4],i),d:Rf(r[5],i),h:Rf(r[6],i),m:Rf(r[7],i),s:Rf(r[8],i)}):n==null?n={}:typeof n==`object`&&(`from`in n||`to`in n)&&(o=Bf(rf(n.from),rf(n.to)),n={},n.ms=o.milliseconds,n.M=o.months),a=new hf(n),gf(e)&&hc(e,`_locale`)&&(a._locale=e._locale),gf(e)&&hc(e,`_isValid`)&&(a._isValid=e._isValid),a}Lf.fn=hf.prototype,Lf.invalid=mf;function Rf(e,t){var n=e&&parseFloat(e.replace(`,`,`.`));return(isNaN(n)?0:n)*t}function zf(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,`M`).isAfter(t)&&--n.months,n.milliseconds=t-+e.clone().add(n.months,`M`),n}function Bf(e,t){var n;return e.isValid()&&t.isValid()?(t=Sf(t,e),e.isBefore(t)?n=zf(e,t):(n=zf(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function Vf(e,t){return function(n,r){var i,a;return r!==null&&!isNaN(+r)&&(Ic(t,`moment().`+t+`(period, number) is deprecated. Please use moment().`+t+`(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.`),a=n,n=r,r=a),i=Lf(n,r),Hf(this,i,e),this}}function Hf(e,t,n,r){var i=t._milliseconds,a=_f(t._days),o=_f(t._months);e.isValid()&&(r??=!0,o&&xu(e,au(e,`Month`)+o*n),a&&ou(e,`Date`,au(e,`Date`)+a*n),i&&e._d.setTime(e._d.valueOf()+i*n),r&&J.updateOffset(e,a||o))}var Uf=Vf(1,`add`),Wf=Vf(-1,`subtract`);function Gf(e){return typeof e==`string`||e instanceof String}function Kf(e){return Mc(e)||yc(e)||Gf(e)||vc(e)||Jf(e)||qf(e)||e==null}function qf(e){var t=mc(e)&&!gc(e),n=!1,r=[`years`,`year`,`y`,`months`,`month`,`M`,`days`,`day`,`d`,`dates`,`date`,`D`,`hours`,`hour`,`h`,`minutes`,`minute`,`m`,`seconds`,`second`,`s`,`milliseconds`,`millisecond`,`ms`],i,a,o=r.length;for(i=0;in.valueOf():n.valueOf()9999?Qc(n,t?`YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYYYY-MM-DD[T]HH:mm:ss.SSSZ`):Lc(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace(`Z`,Qc(n,`Z`)):Qc(n,t?`YYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYY-MM-DD[T]HH:mm:ss.SSSZ`)}function lp(){if(!this.isValid())return`moment.invalid(/* `+this._i+` */)`;var e=`moment`,t=``,n,r,i,a;return this.isLocal()||(e=this.utcOffset()===0?`moment.utc`:`moment.parseZone`,t=`Z`),n=`[`+e+`("]`,r=0<=this.year()&&this.year()<=9999?`YYYY`:`YYYYYY`,i=`-MM-DD[T]HH:mm:ss.SSS`,a=t+`[")]`,this.format(n+r+i+a)}function up(e){e||=this.isUtc()?J.defaultFormatUtc:J.defaultFormat;var t=Qc(this,e);return this.localeData().postformat(t)}function dp(e,t){return this.isValid()&&(Mc(e)&&e.isValid()||rf(e).isValid())?Lf({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function fp(e){return this.from(rf(),e)}function pp(e,t){return this.isValid()&&(Mc(e)&&e.isValid()||rf(e).isValid())?Lf({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function mp(e){return this.to(rf(),e)}function hp(e){var t;return e===void 0?this._locale._abbr:(t=Ed(e),t!=null&&(this._locale=t),this)}var gp=Pc(`moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.`,function(e){return e===void 0?this.localeData():this.locale(e)});function _p(){return this._locale}var vp=1e3,yp=60*vp,bp=60*yp,xp=146097*24*bp;function Sp(e,t){return(e%t+t)%t}function Cp(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-xp:new Date(e,t,n).valueOf()}function wp(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-xp:Date.UTC(e,t,n)}function Tp(e){var t,n;if(e=dl(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(n=this._isUTC?wp:Cp,e){case`year`:t=n(this.year(),0,1);break;case`quarter`:t=n(this.year(),this.month()-this.month()%3,1);break;case`month`:t=n(this.year(),this.month(),1);break;case`week`:t=n(this.year(),this.month(),this.date()-this.weekday());break;case`isoWeek`:t=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case`day`:case`date`:t=n(this.year(),this.month(),this.date());break;case`hour`:t=this._d.valueOf(),t-=Sp(t+(this._isUTC?0:this.utcOffset()*yp),bp);break;case`minute`:t=this._d.valueOf(),t-=Sp(t,yp);break;case`second`:t=this._d.valueOf(),t-=Sp(t,vp);break}return this._d.setTime(t),J.updateOffset(this,!0),this}function Ep(e){var t,n;if(e=dl(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(n=this._isUTC?wp:Cp,e){case`year`:t=n(this.year()+1,0,1)-1;break;case`quarter`:t=n(this.year(),this.month()-this.month()%3+3,1)-1;break;case`month`:t=n(this.year(),this.month()+1,1)-1;break;case`week`:t=n(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case`isoWeek`:t=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case`day`:case`date`:t=n(this.year(),this.month(),this.date()+1)-1;break;case`hour`:t=this._d.valueOf(),t+=bp-Sp(t+(this._isUTC?0:this.utcOffset()*yp),bp)-1;break;case`minute`:t=this._d.valueOf(),t+=yp-Sp(t,yp)-1;break;case`second`:t=this._d.valueOf(),t+=vp-Sp(t,vp)-1;break}return this._d.setTime(t),J.updateOffset(this,!0),this}function Dp(){return this._d.valueOf()-(this._offset||0)*6e4}function Op(){return Math.floor(this.valueOf()/1e3)}function kp(){return new Date(this.valueOf())}function Ap(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function jp(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Mp(){return this.isValid()?this.toISOString():null}function Np(){return Ec(this)}function Pp(){return xc({},wc(this))}function Fp(){return wc(this).overflow}function Ip(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}Yc(`N`,0,0,`eraAbbr`),Yc(`NN`,0,0,`eraAbbr`),Yc(`NNN`,0,0,`eraAbbr`),Yc(`NNNN`,0,0,`eraName`),Yc(`NNNNN`,0,0,`eraNarrow`),Yc(`y`,[`y`,1],`yo`,`eraYear`),Yc(`y`,[`yy`,2],0,`eraYear`),Yc(`y`,[`yyy`,3],0,`eraYear`),Yc(`y`,[`yyyy`,4],0,`eraYear`),Fl(`N`,qp),Fl(`NN`,qp),Fl(`NNN`,qp),Fl(`NNNN`,Jp),Fl(`NNNNN`,Yp),Hl([`N`,`NN`,`NNN`,`NNNN`,`NNNNN`],function(e,t,n,r){var i=n._locale.erasParse(e,r,n._strict);i?wc(n).era=i:wc(n).invalidEra=e}),Fl(`y`,El),Fl(`yy`,El),Fl(`yyy`,El),Fl(`yyyy`,El),Fl(`yo`,Xp),Hl([`y`,`yy`,`yyy`,`yyyy`],Kl),Hl([`yo`],function(e,t,n,r){var i;n._locale._eraYearOrdinalRegex&&(i=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[Kl]=n._locale.eraYearOrdinalParse(e,i):t[Kl]=parseInt(e,10)});function Lp(e,t){var n,r,i,a=this._eras||Ed(`en`)._eras;for(n=0,r=a.length;n=0)return a[r]}function zp(e,t){var n=e.since<=e.until?1:-1;return t===void 0?J(e.since).year():J(e.since).year()+(t-e.offset)*n}function Bp(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;ea&&(t=a),om.call(this,e,t,n,r,i))}function om(e,t,n,r,i){var a=Au(e,t,n,r,i),o=Ou(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}Yc(`Q`,0,`Qo`,`quarter`),Fl(`Q`,hl),Hl(`Q`,function(e,t){t[ql]=(Bl(e)-1)*3});function sm(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}Yc(`D`,[`DD`,2],`Do`,`date`),Fl(`D`,bl,Ml),Fl(`DD`,bl,gl),Fl(`Do`,function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Hl([`D`,`DD`],Jl),Hl(`Do`,function(e,t){t[Jl]=Bl(e.match(bl)[0])});var cm=iu(`Date`,!0);Yc(`DDD`,[`DDDD`,3],`DDDo`,`dayOfYear`),Fl(`DDD`,Cl),Fl(`DDDD`,_l),Hl([`DDD`,`DDDD`],function(e,t,n){n._dayOfYear=Bl(e)});function lm(e){var t=Math.round((this.clone().startOf(`day`)-this.clone().startOf(`year`))/864e5)+1;return e==null?t:this.add(e-t,`d`)}Yc(`m`,[`mm`,2],0,`minute`),Fl(`m`,bl,Nl),Fl(`mm`,bl,gl),Hl([`m`,`mm`],Xl);var um=iu(`Minutes`,!1);Yc(`s`,[`ss`,2],0,`second`),Fl(`s`,bl,Nl),Fl(`ss`,bl,gl),Hl([`s`,`ss`],Zl);var dm=iu(`Seconds`,!1);Yc(`S`,0,0,function(){return~~(this.millisecond()/100)}),Yc(0,[`SS`,2],0,function(){return~~(this.millisecond()/10)}),Yc(0,[`SSS`,3],0,`millisecond`),Yc(0,[`SSSS`,4],0,function(){return this.millisecond()*10}),Yc(0,[`SSSSS`,5],0,function(){return this.millisecond()*100}),Yc(0,[`SSSSSS`,6],0,function(){return this.millisecond()*1e3}),Yc(0,[`SSSSSSS`,7],0,function(){return this.millisecond()*1e4}),Yc(0,[`SSSSSSSS`,8],0,function(){return this.millisecond()*1e5}),Yc(0,[`SSSSSSSSS`,9],0,function(){return this.millisecond()*1e6}),Fl(`S`,Cl,hl),Fl(`SS`,Cl,gl),Fl(`SSS`,Cl,_l);var fm,pm;for(fm=`SSSS`;fm.length<=9;fm+=`S`)Fl(fm,El);function mm(e,t){t[Ql]=Bl((`0.`+e)*1e3)}for(fm=`S`;fm.length<=9;fm+=`S`)Hl(fm,mm);pm=iu(`Milliseconds`,!1),Yc(`z`,0,0,`zoneAbbr`),Yc(`zz`,0,0,`zoneName`);function hm(){return this._isUTC?`UTC`:``}function gm(){return this._isUTC?`Coordinated Universal Time`:``}var Y=jc.prototype;Y.add=Uf,Y.calendar=Zf,Y.clone=Qf,Y.diff=ap,Y.endOf=Ep,Y.format=up,Y.from=dp,Y.fromNow=fp,Y.to=pp,Y.toNow=mp,Y.get=su,Y.invalidAt=Fp,Y.isAfter=$f,Y.isBefore=ep,Y.isBetween=tp,Y.isSame=np,Y.isSameOrAfter=rp,Y.isSameOrBefore=ip,Y.isValid=Np,Y.lang=gp,Y.locale=hp,Y.localeData=_p,Y.max=of,Y.min=af,Y.parsingFlags=Pp,Y.set=cu,Y.startOf=Tp,Y.subtract=Wf,Y.toArray=Ap,Y.toObject=jp,Y.toDate=kp,Y.toISOString=cp,Y.inspect=lp,typeof Symbol<`u`&&Symbol.for!=null&&(Y[Symbol.for(`nodejs.util.inspect.custom`)]=function(){return`Moment<`+this.format()+`>`}),Y.toJSON=Mp,Y.toString=sp,Y.unix=Op,Y.valueOf=Dp,Y.creationData=Ip,Y.eraName=Bp,Y.eraNarrow=Vp,Y.eraAbbr=Hp,Y.eraYear=Up,Y.year=nu,Y.isLeapYear=ru,Y.weekYear=$p,Y.isoWeekYear=em,Y.quarter=Y.quarters=sm,Y.month=Su,Y.daysInMonth=Cu,Y.week=Y.weeks=Lu,Y.isoWeek=Y.isoWeeks=Ru,Y.weeksInYear=rm,Y.weeksInWeekYear=im,Y.isoWeeksInYear=tm,Y.isoWeeksInISOWeekYear=nm,Y.date=cm,Y.day=Y.days=$u,Y.weekday=ed,Y.isoWeekday=td,Y.dayOfYear=lm,Y.hour=Y.hours=fd,Y.minute=Y.minutes=um,Y.second=Y.seconds=dm,Y.millisecond=Y.milliseconds=pm,Y.utcOffset=wf,Y.utc=Ef,Y.local=Df,Y.parseZone=Of,Y.hasAlignedHourOffset=kf,Y.isDST=Af,Y.isLocal=Mf,Y.isUtcOffset=Nf,Y.isUtc=Pf,Y.isUTC=Pf,Y.zoneAbbr=hm,Y.zoneName=gm,Y.dates=Pc(`dates accessor is deprecated. Use date instead.`,cm),Y.months=Pc(`months accessor is deprecated. Use month instead`,Su),Y.years=Pc(`years accessor is deprecated. Use year instead`,nu),Y.zone=Pc(`moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/`,Tf),Y.isDSTShifted=Pc(`isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information`,jf);function _m(e){return rf(e*1e3)}function vm(){return rf.apply(null,arguments).parseZone()}function ym(e){return e}var bm=Bc.prototype;bm.calendar=Uc,bm.longDateFormat=tl,bm.invalidDate=rl,bm.ordinal=ol,bm.preparse=ym,bm.postformat=ym,bm.relativeTime=cl,bm.pastFuture=ll,bm.set=Rc,bm.eras=Lp,bm.erasParse=Rp,bm.erasConvertYear=zp,bm.erasAbbrRegex=Gp,bm.erasNameRegex=Wp,bm.erasNarrowRegex=Kp,bm.months=_u,bm.monthsShort=vu,bm.monthsParse=bu,bm.monthsRegex=Tu,bm.monthsShortRegex=wu,bm.week=Nu,bm.firstDayOfYear=Iu,bm.firstDayOfWeek=Fu,bm.weekdays=Ju,bm.weekdaysMin=Xu,bm.weekdaysShort=Yu,bm.weekdaysParse=Qu,bm.weekdaysRegex=nd,bm.weekdaysShortRegex=rd,bm.weekdaysMinRegex=id,bm.isPM=ud,bm.meridiem=pd;function xm(e,t,n,r){var i=Ed(),a=Sc().set(r,t);return i[n](a,e)}function Sm(e,t,n){if(vc(e)&&(t=e,e=void 0),e||=``,t!=null)return xm(e,t,n,`month`);var r,i=[];for(r=0;r<12;r++)i[r]=xm(e,r,n,`month`);return i}function Cm(e,t,n,r){typeof e==`boolean`?(vc(t)&&(n=t,t=void 0),t||=``):(t=e,n=t,e=!1,vc(t)&&(n=t,t=void 0),t||=``);var i=Ed(),a=e?i._week.dow:0,o,s=[];if(n!=null)return xm(t,(n+a)%7,r,`day`);for(o=0;o<7;o++)s[o]=xm(t,(o+a)%7,r,`day`);return s}function wm(e,t){return Sm(e,t,`months`)}function Tm(e,t){return Sm(e,t,`monthsShort`)}function Em(e,t,n){return Cm(e,t,n,`weekdays`)}function Dm(e,t,n){return Cm(e,t,n,`weekdaysShort`)}function Om(e,t,n){return Cm(e,t,n,`weekdaysMin`)}Cd(`en`,{eras:[{since:`0001-01-01`,until:1/0,offset:1,name:`Anno Domini`,narrow:`AD`,abbr:`AD`},{since:`0000-12-31`,until:-1/0,offset:1,name:`Before Christ`,narrow:`BC`,abbr:`BC`}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(Bl(e%100/10)===1?`th`:t===1?`st`:t===2?`nd`:t===3?`rd`:`th`)}}),J.lang=Pc(`moment.lang is deprecated. Use moment.locale instead.`,Cd),J.langData=Pc(`moment.langData is deprecated. Use moment.localeData instead.`,Ed);var km=Math.abs;function Am(){var e=this._data;return this._milliseconds=km(this._milliseconds),this._days=km(this._days),this._months=km(this._months),e.milliseconds=km(e.milliseconds),e.seconds=km(e.seconds),e.minutes=km(e.minutes),e.hours=km(e.hours),e.months=km(e.months),e.years=km(e.years),this}function jm(e,t,n,r){var i=Lf(t,n);return e._milliseconds+=r*i._milliseconds,e._days+=r*i._days,e._months+=r*i._months,e._bubble()}function Mm(e,t){return jm(this,e,t,1)}function Nm(e,t){return jm(this,e,t,-1)}function Pm(e){return e<0?Math.floor(e):Math.ceil(e)}function Fm(){var e=this._milliseconds,t=this._days,n=this._months,r=this._data,i,a,o,s,c;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=Pm(Lm(n)+t)*864e5,t=0,n=0),r.milliseconds=e%1e3,i=zl(e/1e3),r.seconds=i%60,a=zl(i/60),r.minutes=a%60,o=zl(a/60),r.hours=o%24,t+=zl(o/24),c=zl(Im(t)),n+=c,t-=Pm(Lm(c)),s=zl(n/12),n%=12,r.days=t,r.months=n,r.years=s,this}function Im(e){return e*4800/146097}function Lm(e){return e*146097/4800}function Rm(e){if(!this.isValid())return NaN;var t,n,r=this._milliseconds;if(e=dl(e),e===`month`||e===`quarter`||e===`year`)switch(t=this._days+r/864e5,n=this._months+Im(t),e){case`month`:return n;case`quarter`:return n/3;case`year`:return n/12}else switch(t=this._days+Math.round(Lm(this._months)),e){case`week`:return t/7+r/6048e5;case`day`:return t+r/864e5;case`hour`:return t*24+r/36e5;case`minute`:return t*1440+r/6e4;case`second`:return t*86400+r/1e3;case`millisecond`:return Math.floor(t*864e5)+r;default:throw Error(`Unknown unit `+e)}}function zm(e){return function(){return this.as(e)}}var Bm=zm(`ms`),Vm=zm(`s`),Hm=zm(`m`),Um=zm(`h`),Wm=zm(`d`),Gm=zm(`w`),Km=zm(`M`),qm=zm(`Q`),Jm=zm(`y`),Ym=Bm;function Xm(){return Lf(this)}function Zm(e){return e=dl(e),this.isValid()?this[e+`s`]():NaN}function Qm(e){return function(){return this.isValid()?this._data[e]:NaN}}var $m=Qm(`milliseconds`),eh=Qm(`seconds`),th=Qm(`minutes`),nh=Qm(`hours`),rh=Qm(`days`),ih=Qm(`months`),ah=Qm(`years`);function oh(){return zl(this.days()/7)}var sh=Math.round,ch={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function lh(e,t,n,r,i){return i.relativeTime(t||1,!!n,e,r)}function uh(e,t,n,r){var i=Lf(e).abs(),a=sh(i.as(`s`)),o=sh(i.as(`m`)),s=sh(i.as(`h`)),c=sh(i.as(`d`)),l=sh(i.as(`M`)),u=sh(i.as(`w`)),d=sh(i.as(`y`)),f=a<=n.ss&&[`s`,a]||a0,f[4]=r,lh.apply(null,f)}function dh(e){return e===void 0?sh:typeof e==`function`?(sh=e,!0):!1}function fh(e,t){return ch[e]===void 0?!1:t===void 0?ch[e]:(ch[e]=t,e===`s`&&(ch.ss=t-1),!0)}function ph(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,r=ch,i,a;return typeof e==`object`&&(t=e,e=!1),typeof e==`boolean`&&(n=e),typeof t==`object`&&(r=Object.assign({},ch,t),t.s!=null&&t.ss==null&&(r.ss=t.s-1)),i=this.localeData(),a=uh(this,!n,r,i),n&&(a=i.pastFuture(+this,a)),i.postformat(a)}var mh=Math.abs;function hh(e){return(e>0)-(e<0)||+e}function gh(){if(!this.isValid())return this.localeData().invalidDate();var e=mh(this._milliseconds)/1e3,t=mh(this._days),n=mh(this._months),r,i,a,o,s=this.asSeconds(),c,l,u,d;return s?(r=zl(e/60),i=zl(r/60),e%=60,r%=60,a=zl(n/12),n%=12,o=e?e.toFixed(3).replace(/\.?0+$/,``):``,c=s<0?`-`:``,l=hh(this._months)===hh(s)?``:`-`,u=hh(this._days)===hh(s)?``:`-`,d=hh(this._milliseconds)===hh(s)?``:`-`,c+`P`+(a?l+a+`Y`:``)+(n?l+n+`M`:``)+(t?u+t+`D`:``)+(i||r||e?`T`:``)+(i?d+i+`H`:``)+(r?d+r+`M`:``)+(e?d+o+`S`:``)):`P0D`}var _h=hf.prototype;_h.isValid=pf,_h.abs=Am,_h.add=Mm,_h.subtract=Nm,_h.as=Rm,_h.asMilliseconds=Bm,_h.asSeconds=Vm,_h.asMinutes=Hm,_h.asHours=Um,_h.asDays=Wm,_h.asWeeks=Gm,_h.asMonths=Km,_h.asQuarters=qm,_h.asYears=Jm,_h.valueOf=Ym,_h._bubble=Fm,_h.clone=Xm,_h.get=Zm,_h.milliseconds=$m,_h.seconds=eh,_h.minutes=th,_h.hours=nh,_h.days=rh,_h.weeks=oh,_h.months=ih,_h.years=ah,_h.humanize=ph,_h.toISOString=gh,_h.toString=gh,_h.toJSON=gh,_h.locale=hp,_h.localeData=_p,_h.toIsoString=Pc(`toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)`,gh),_h.lang=gp,Yc(`X`,0,0,`unix`),Yc(`x`,0,0,`valueOf`),Fl(`x`,Dl),Fl(`X`,Al),Hl(`X`,function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),Hl(`x`,function(e,t,n){n._d=new Date(Bl(e))}),J.version=`2.30.1`,fc(rf),J.fn=Y,J.min=cf,J.max=lf,J.now=uf,J.utc=Sc,J.unix=_m,J.months=wm,J.isDate=yc,J.locale=Cd,J.invalid=Dc,J.duration=Lf,J.isMoment=Mc,J.weekdays=Em,J.parseZone=vm,J.localeData=Ed,J.isDuration=gf,J.monthsShort=Tm,J.weekdaysMin=Om,J.defineLocale=wd,J.updateLocale=Td,J.locales=Dd,J.weekdaysShort=Dm,J.normalizeUnits=dl,J.relativeTimeRounding=dh,J.relativeTimeThreshold=fh,J.calendarFormat=Xf,J.prototype=Y,J.HTML5_FMT={DATETIME_LOCAL:`YYYY-MM-DDTHH:mm`,DATETIME_LOCAL_SECONDS:`YYYY-MM-DDTHH:mm:ss`,DATETIME_LOCAL_MS:`YYYY-MM-DDTHH:mm:ss.SSS`,DATE:`YYYY-MM-DD`,TIME:`HH:mm`,TIME_SECONDS:`HH:mm:ss`,TIME_MS:`HH:mm:ss.SSS`,WEEK:`GGGG-[W]WW`,MONTH:`YYYY-MM`};var vh=class e{static dateFormat;static stringify(e){return e.format(this.dateFormat)}static parse(t){return J(t,e.dateFormat)}static getDefaultDate(){return J(new Date)}static getDefaultDay(){return new Date().getDate()}static getDefaultMonth(){return 1}static getDefaultYear(){return new Date().getFullYear()}};typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),new Set([`$$slots`,`$$events`,`$$legacy`]);var yh=K(``);function bh(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=yh();return Us(a),qo(`input`,a,()=>t.onValueChange(ei(G(n)))),Xs(a,()=>G(n),e=>pa(n,e)),q(e,a),ai(i)}Jo([`input`]);var xh=class extends uc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return vh.stringify(vh.getDefaultDate())}getSvelteComponent(){return bh}rawMapValue(e){return e}rawReverseMapValue(e){return e}},Sh=K(`
`);function Ch(e,t){ii(t,!0);let n=tc(t,`iconName`,3,``),r=da(void 0);Ua(()=>G(r)?t.mb.internal.setIcon(G(r),n()):void 0);var i=is(),a=Oa(i),o=e=>{var t=Sh();ec(t,e=>pa(r,e),()=>G(r)),q(e,t)};fs(a,e=>{n().length>0&&e(o)}),q(e,i),ai()}new Set([`$$slots`,`$$events`,`$$legacy`]);var wh=K(`
`);function Th(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(){t.showDatePicker()}function a(e){e.key===` `&&t.showDatePicker()}var o={setValue:r},s=wh(),c=U(s),l=U(c,!0);return V(c),Ch(W(c,2),{get mb(){return t.mb},iconName:`calendar`}),V(s),Ya(e=>as(l,e),[()=>G(n)?G(n).format(t.dateFormat):`none`]),qo(`click`,s,i),qo(`keydown`,s,a),q(e,s),ai(o)}Jo([`click`,`keydown`]);var Eh=class extends uc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){if(e===null)return null;if(e===void 0||typeof e!=`string`)return;let t=vh.parse(e);if(t.isValid())return vh.stringify(t)}getFallbackDefaultValue(){return vh.getDefaultDate()}getSvelteComponent(){return Th}rawMapValue(e){return e===null?null:vh.stringify(e)}rawReverseMapValue(e){if(e===null)return null;let t=vh.parse(e);if(t.isValid())return t}getMountArgs(){return{dateFormat:this.mountable.mb.getSettings().preferredDateFormat,showDatePicker:()=>{this.mountable.mb.internal.openDatePickerModal(this.getInternalValue(),e=>this.setInternalValue(e))}}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Dh=K(``);function Oh(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=Dh();return Us(a),qo(`input`,a,()=>t.onValueChange(ei(G(n)))),Xs(a,()=>G(n),e=>pa(n,e)),q(e,a),ai(i)}Jo([`input`]);var kh=class extends uc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return vh.stringify(vh.getDefaultDate())}getSvelteComponent(){return Oh}rawMapValue(e){return e}rawReverseMapValue(e){return e}},Ah=K(`
`);function jh(e,t){ii(t,!0);let n,r;rc(()=>{r?.()});async function i(e){r?.(),k.empty(n),r=await t.mb.internal.renderMarkdown(e,n,t.filePath)}Ua(()=>void i(t.value));var a=Ah();ec(a,e=>n=e,()=>n),q(e,a),ai()}new Set([`$$slots`,`$$events`,`$$legacy`]);var Mh=K(``),Nh=K(`
`);function Ph(e,t){ii(t,!0);let n=da(va(t.value)),r=da(!1);function i(e){pa(n,e,!0)}function a(){pa(r,!1)}function o(){pa(r,!0)}function s(e){e.key===` `&&o()}var c={setValue:i},l=Nh(),u=U(l),d=e=>{var r=Mh();Na(r),qo(`focusout`,r,()=>a()),qo(`input`,r,()=>t.onValueChange(ei(G(n)))),Xs(r,()=>G(n),e=>pa(n,e)),q(e,r)},f=e=>{jh(e,{get value(){return G(n)},get mb(){return t.mb},get filePath(){return t.filePath}})};return fs(u,e=>{G(r)?e(d):e(f,-1)}),V(l),qo(`click`,l,()=>o()),Ko(`keypress`,l,e=>s(e)),q(e,l),ai(c)}Jo([`click`,`focusout`,`input`]);var Fh=class extends uc{mdUnloadCallback;filterValue(e){return mn(e)?e?.toString():void 0}getFallbackDefaultValue(){return``}getSvelteComponent(){return Ph}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{render:(e,t)=>void this.renderInElement(e,t),filePath:this.mountable.getFilePath()}}async renderInElement(e,t){this.mdUnloadCallback?.(),e.innerHTML=``,this.mdUnloadCallback=await this.mountable.mb.internal.renderMarkdown(t,e,this.mountable.getFilePath())}onUnmount(){super.onUnmount(),this.mdUnloadCallback?.()}},Ih=K(``);function Lh(e,t){ii(t,!0);let n=tc(t,`variant`,19,()=>It.DEFAULT),r=tc(t,`disabled`,3,!1),i=tc(t,`tooltip`,3,``),a=tc(t,`classes`,3,``),o=tc(t,`onclick`,3,()=>{});var s=Ih();let c;Cs(U(s),()=>t.children),V(s),Ya(()=>{c=Ms(s,1,`mb-button-inner ${a()??``}`,null,c,{"mod-cta":n()===It.PRIMARY,"mod-warning":n()===It.DESTRUCTIVE,"mod-plain":n()===It.PLAIN,disabled:r()}),Ks(s,`aria-label`,i()),s.disabled=r()}),qo(`click`,s,function(...e){o()?.apply(this,e)}),q(e,s),ai()}Jo([`click`]),new Set([`$$slots`,`$$events`,`$$legacy`]);var Rh=K(`
`),zh=K(`
`,1);function Bh(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){G(n).push(e),t.onValueChange(ei(G(n)))}function a(e){G(n).splice(e,1),t.onValueChange(ei(G(n)))}function o(e,r){let i=[];r>0&&i.push({name:`Move left`,icon:`arrow-left`,onclick:()=>{let e=G(n)[r-1];G(n)[r-1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),r{let e=G(n)[r+1];G(n)[r+1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),i.push({name:`Copy image path`,icon:`copy`,onclick:()=>{let e=G(n)[r];navigator.clipboard.writeText(e).then(()=>{t.mb.internal.showNotice(`Image path copied to clipboard`)}).catch(()=>{t.mb.internal.showNotice(`Failed to copy image path to clipboard`)})}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var s={setValue:r,pushValue:i},c=zh(),l=Oa(c);_s(l,21,()=>G(n),ps,(e,n,r)=>{var i=Rh(),a=U(i);V(i),Ya((e,t)=>{Ks(i,`data-value`,e),Ks(a,`src`,t),Ks(a,`alt`,G(n)),Ks(a,`aria-label`,G(n))},[()=>pn(G(n)),()=>t.mb.internal.imagePathToUri(G(n))]),qo(`contextmenu`,i,e=>o(e,r)),q(e,i)}),V(l);var u=W(l,2);return Lh(U(u),{get variant(){return It.DEFAULT},onclick:()=>t.showSuggester(),children:(e,t)=>{Gr(),q(e,rs(`Add new image`))},$$slots:{default:!0}}),V(u),q(e,c),ai(s)}Jo([`contextmenu`]);var Vh=class extends uc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return Bh}rawMapValue(e){return e}rawReverseMapValue(e){return e.map(e=>pn(e)).filter(e=>e!==void 0)}getMountArgs(){return{showSuggester:()=>this.openModal()}}openModal(){this.mountable.mb.internal.openImageSuggesterModal(this,!1,e=>{e!==void 0&&this.svelteWrapper?.getInstance()?.pushValue(e)})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Hh=K(`
`),Uh=K(`
`);function Wh(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){let n=[];n.push({name:`Edit`,icon:`pencil`,onclick:()=>{t.showSuggester()}}),n.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>t.clear()}),t.mb.internal.createContextMenu(n).showWithEvent(e)}var a={setValue:r},o=is(),s=Oa(o),c=e=>{var r=Hh(),a=U(r);Lh(W(a,2),{get variant(){return It.PLAIN},onclick:e=>i(e),classes:`mb-image-card-button`,children:(e,n)=>{Ch(e,{iconName:`ellipsis-vertical`,get mb(){return t.mb}})},$$slots:{default:!0}}),V(r),Ya(e=>{Ks(a,`src`,e),Ks(a,`alt`,G(n)),Ks(a,`aria-label`,G(n))},[()=>t.mb.internal.imagePathToUri(G(n))]),qo(`contextmenu`,r,e=>i(e)),q(e,r)},l=e=>{var n=Uh();Lh(U(n),{get variant(){return It.PLAIN},onclick:()=>t.showSuggester(),tooltip:`Select image`,children:(e,t)=>{Gr(),q(e,rs(`No image selected. Click to select.`))},$$slots:{default:!0}}),V(n),q(e,n)};return fs(s,e=>{G(n)?e(c):e(l,-1)}),q(e,o),ai(a)}Jo([`contextmenu`]);var Gh=class extends uc{filterValue(e){return mn(e)?e:void 0}getFallbackDefaultValue(){}getSvelteComponent(){return Wh}rawMapValue(e){return e}rawReverseMapValue(e){return pn(e)}getMountArgs(){return{showSuggester:()=>this.openModal(),clear:()=>this.setInternalValue(void 0)}}openModal(){this.mountable.mb.internal.openImageSuggesterModal(this,!0,e=>this.setInternalValue(e))}},Kh=K(` `);function qh(e,t){ii(t,!0);let n=ea(()=>t.mdLink.block?`${t.mdLink.target}#${t.mdLink.block}`:t.mdLink.target),r=ea(()=>t.mdLink.internal?`internal-link`:`external-link`),i=ea(()=>t.mdLink.alias?G(n):void 0),a=ea(()=>t.mdLink.alias?t.mdLink.alias:t.mdLink.block?`${t.mdLink.target} > ${t.mdLink.block}`:t.mdLink.target);var o=Kh(),s=U(o,!0);V(o),Ya(()=>{Ks(o,`data-href`,G(n)),Ks(o,`href`,G(n)),Ms(o,1,Es(G(r))),Ks(o,`aria-label`,G(i)),as(s,G(a))}),q(e,o),ai()}var Jh=K(`, `,1),Yh=K(` `,1);function Xh(e,t){ii(t,!0);let n=tc(t,`elements`,19,()=>[]);var r=Yh(),i=Oa(r);_s(i,17,()=>n().slice(0,n().length-1),ps,(e,n)=>{var r=Jh();Cs(Oa(r),()=>t.children,()=>G(n)),Gr(3),q(e,r)}),Cs(W(i,2),()=>t.children,()=>n()[n().length-1]),q(e,r),ai()}var Zh=K(` `),Qh=K(` `),$h=K(``);function eg(e,t){ii(t,!0);let n=tc(t,`value`,3,void 0),r=ea(()=>xn(n(),!1));var i=is(),a=Oa(i),o=e=>{var t=Zh(),n=U(t,!0);V(t),Ya(()=>as(n,G(r))),q(e,t)},s=e=>{var t=$h();Xh(U(t),{get elements(){return G(r)},children:(e,t=qn)=>{var n=is(),r=Oa(n),i=e=>{var n=Qh(),r=U(n,!0);V(n),Ya(()=>as(r,t())),q(e,n)},a=e=>{qh(e,{get mdLink(){return t()}})};fs(r,e=>{typeof t()==`string`?e(i):e(a,-1)}),q(e,n)},$$slots:{default:!0}}),V(t),q(e,t)},c=ea(()=>Array.isArray(G(r))),l=e=>{var t=$h();qh(U(t),{get mdLink(){return G(r)}}),V(t),q(e,t)};fs(a,e=>{typeof G(r)==`string`?e(o):G(c)?e(s,1):e(l,-1)}),q(e,i),ai()}new Set([`$$slots`,`$$events`,`$$legacy`]);var tg=K(`
`),ng=K(`
`);function rg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){G(n).push(e),t.onValueChange(ei(G(n)))}function a(e){G(n).splice(e,1),t.onValueChange(ei(G(n)))}function o(e){e.key===` `&&t.showInput()}function s(e,r){let i=[];r>0&&i.push({name:`Move left`,icon:`arrow-left`,onclick:()=>{let e=G(n)[r-1];G(n)[r-1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),r{let e=G(n)[r+1];G(n)[r+1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),i.push({name:`Edit`,icon:`pencil`,onclick:()=>{t.mb.internal.openTextPromptModal({title:`Meta Bind List`,subTitle:`Edit the value of a list item.`,value:pn(G(n)[r]),multiline:!1,onSubmit:e=>{G(n)[r]=e,t.onValueChange(ei(G(n)))},onCancel:()=>{}})}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var c={setValue:r,pushValue:i},l=ng(),u=U(l);_s(u,17,()=>G(n),ps,(e,t,n)=>{var r=tg();eg(U(r),{get value(){return G(t)}}),V(r),Ya(e=>Ks(r,`data-value`,e),[()=>pn(G(t))]),qo(`contextmenu`,r,e=>s(e,n)),q(e,r)});var d=W(u,2);return Ch(W(U(d),2),{get mb(){return t.mb},iconName:`plus`}),V(d),V(l),qo(`click`,d,()=>t.showInput()),qo(`keydown`,d,o),q(e,l),ai(c)}Jo([`contextmenu`,`click`,`keydown`]);var ig=class extends uc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return rg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showInput:()=>this.openModal()}}openModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind List`,subTitle:`Create a new List Element.`,value:``,multiline:!1,onSubmit:e=>{this.svelteWrapper?.getInstance()?.pushValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var ag=K(`
`),og=K(`
`);function sg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){G(n).push(e),t.onValueChange(ei(G(n)))}function a(e){G(n).splice(e,1),t.onValueChange(ei(G(n)))}function o(e){if(!t.allowOther){t.showSuggester();return}t.mb.internal.createContextMenu([{name:`From Options`,onclick:()=>t.showSuggester()},{name:`From Text`,onclick:()=>t.showTextPrompt()}]).showWithEvent(e)}function s(e){e.key===` `&&t.showSuggester()}function c(e,r){let i=[];r>0&&i.push({name:`Move left`,icon:`arrow-left`,onclick:()=>{let e=G(n)[r-1];G(n)[r-1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),r{let e=G(n)[r+1];G(n)[r+1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var l={setValue:r,pushValue:i},u=og(),d=U(u);_s(d,17,()=>G(n),ps,(e,t,n)=>{var r=ag();eg(U(r),{get value(){return G(t)}}),V(r),Ya(e=>Ks(r,`data-value`,e),[()=>pn(G(t))]),qo(`contextmenu`,r,e=>c(e,n)),q(e,r)});var f=W(d,2);return Ch(W(U(f),2),{get mb(){return t.mb},iconName:`plus`}),V(f),V(u),qo(`click`,f,o),qo(`keydown`,f,s),q(e,u),ai(l)}Jo([`contextmenu`,`click`,`keydown`]);var cg=class extends uc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return sg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showSuggester:()=>this.openModal(),showTextPrompt:()=>this.openTextModal(),allowOther:this.mountable.getArgument(kn.ALLOW_OTHER)?.value===!0}}openModal(){this.mountable.mb.internal.openSuggesterModal(this,e=>{this.svelteWrapper?.getInstance()?.pushValue(e.value)})}openTextModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind List Suggester`,subTitle:`Create a new List Element.`,value:``,multiline:!1,onSubmit:e=>{this.svelteWrapper?.getInstance()?.pushValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var lg=K(``),ug=K(``);function dg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(){t.onValueChange(ei(G(n)))}var a={setValue:r},o=ug();return _s(o,21,()=>t.options,ps,(e,t)=>{var n=lg(),r=U(n,!0);V(n);var i={};Ya(()=>{as(r,G(t).name),i!==(i=G(t).value)&&(n.value=(n.__value=G(t).value)??``)}),q(e,n)}),V(o),qo(`change`,o,()=>i()),Ls(o,()=>G(n),e=>pa(n,e)),q(e,o),ai(a)}Jo([`change`]);var fg=class extends uc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){return vn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return dg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{options:this.options}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var pg=K(`
`),mg=K(`Empty`),hg=K(``),gg=K(``),_g=K(` `),vg=K(`
`,1);function yg(e,t){ii(t,!0);let n=da(va(t.value)),r=da(``);function i(e){pa(n,e,!0)}function a(){G(n).push(G(r)),t.onValueChange(ei(G(n))),pa(r,``)}function o(e){G(n).splice(e,1),t.onValueChange(ei(G(n)))}function s(e,t){let n=t.toString();return`${e.toString().padStart(n.length,`0`)}/${n}`}function c(e,r){let i=[];r>0&&i.push({name:`Move up`,icon:`arrow-up`,onclick:()=>{let e=G(n)[r-1];G(n)[r-1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),r{let e=G(n)[r+1];G(n)[r+1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),i.push({name:`Edit`,icon:`pencil`,onclick:()=>{t.mb.internal.openTextPromptModal({title:`Meta Bind List`,subTitle:`Edit the value of a list item.`,value:pn(G(n)[r]),multiline:t.multiLine,onSubmit:e=>{G(n)[r]=e,t.onValueChange(ei(G(n)))},onCancel:()=>{}})}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>o(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var l={setValue:i},u=vg(),d=Oa(u);_s(d,21,()=>G(n),ps,(e,t,n)=>{var r=pg();eg(U(r),{get value(){return G(t)}}),V(r),Ya(e=>Ks(r,`data-value`,e),[()=>pn(G(t))]),qo(`contextmenu`,r,e=>c(e,n)),q(e,r)},e=>{q(e,mg())}),V(d);var f=W(d,2),p=U(f),m=e=>{var n=hg();Na(n),Ya(()=>{Ks(n,`placeholder`,t.placeholder),Ks(n,`maxlength`,t.limit)}),Xs(n,()=>G(r),e=>pa(r,e)),q(e,n)},h=e=>{var n=gg();Us(n),Ya(()=>{Ks(n,`placeholder`,t.placeholder),Ks(n,`maxlength`,t.limit)}),qo(`keyup`,n,e=>{e.key===`Enter`&&G(r).length>0&&a()}),Xs(n,()=>G(r),e=>pa(r,e)),q(e,n)};fs(p,e=>{t.multiLine?e(m):e(h,-1)});var g=W(p,2),_=e=>{var r=_g(),i=U(r,!0);V(r),Ya(e=>{Ms(r,1,`mb-content-limit-indicator ${G(n).length>t.limit?`mb-content-limit-indicator-overflow`:``}`),as(i,e)},[()=>s(G(n).length,t.limit)]),q(e,r)};fs(g,e=>{t.limit!==void 0&&e(_)});var v=W(g,2);{let e=ea(()=>!G(r));Lh(v,{onclick:()=>a(),get disabled(){return G(e)},children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`plus`})},$$slots:{default:!0}})}return V(f),q(e,u),ai(l)}Jo([`contextmenu`,`keyup`]);var bg=class extends uc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return yg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`New Entry...`,limit:this.mountable.getArgument(kn.LIMIT)?.value,multiLine:this.mountable.getArgument(kn.MULTI_LINE)?.value===!0}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var xg=K(`
`),Sg=K(`Empty`),Cg=K(`
`,1);function wg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){G(n).push(e),t.onValueChange(ei(G(n)))}function a(e){G(n).splice(e,1),t.onValueChange(ei(G(n)))}function o(e,r){let i=[];r>0&&i.push({name:`Move up`,icon:`arrow-up`,onclick:()=>{let e=G(n)[r-1];G(n)[r-1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),r{let e=G(n)[r+1];G(n)[r+1]=G(n)[r],G(n)[r]=e,t.onValueChange(ei(G(n)))}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var s={setValue:r,pushValue:i},c=Cg(),l=Oa(c);_s(l,21,()=>G(n),ps,(e,t,n)=>{var r=xg();eg(U(r),{get value(){return G(t)}}),V(r),Ya(e=>Ks(r,`data-value`,e),[()=>pn(G(t))]),qo(`contextmenu`,r,e=>o(e,n)),q(e,r)},e=>{q(e,Sg())}),V(l);var u=W(l,2),d=U(u);Lh(d,{get variant(){return It.DEFAULT},onclick:()=>t.showSuggester(),children:(e,t)=>{Gr(),q(e,rs(`Add new item`))},$$slots:{default:!0}});var f=W(d,2),p=e=>{Lh(e,{get variant(){return It.DEFAULT},onclick:()=>t.showTextPrompt(),children:(e,t)=>{Gr(),q(e,rs(`Add other item`))},$$slots:{default:!0}})};return fs(f,e=>{t.allowOther&&e(p)}),V(u),q(e,c),ai(s)}Jo([`contextmenu`]);var Tg=class extends uc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return wg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showSuggester:()=>this.openModal(),showTextPrompt:()=>this.openTextModal(),allowOther:this.mountable.getArgument(kn.ALLOW_OTHER)?.value===!0}}openModal(){this.mountable.mb.internal.openSuggesterModal(this,e=>{this.svelteWrapper?.getInstance()?.pushValue(e.value)})}openTextModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind List Suggester`,subTitle:`Create a new List Element.`,value:``,multiline:!1,onSubmit:e=>{this.svelteWrapper?.getInstance()?.pushValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Eg=K(`
`);function Dg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){G(n).includes(e)?pa(n,G(n).filter(t=>t!==e),!0):G(n).push(e),t.onValueChange(ei(G(n)))}function a(e,t){e.key===` `&&i(t)}var o={setValue:r},s=is();return _s(Oa(s),17,()=>t.options,ps,(e,t)=>{var r=Eg();let o;var s=U(r);Us(s),eg(W(s,2),{get value(){return G(t).name}}),V(r),Ya((e,t,n)=>{o=Ms(r,1,`mb-select-input-element mb-mod-multi`,null,o,e),Ks(r,`data-value`,t),Gs(s,n)},[()=>({"is-selected":G(n).includes(G(t).value)}),()=>pn(G(t).value),()=>G(n).includes(G(t).value)]),qo(`click`,r,e=>{e.target instanceof HTMLInputElement||i(G(t).value)}),Ko(`keypress`,r,e=>a(e,G(t).value)),qo(`input`,s,()=>i(G(t).value)),q(e,r)}),q(e,s),ai(o)}Jo([`click`,`input`]);var Og=class extends uc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return Dg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{options:this.options}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var kg=K(``);function Ag(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=kg();return Us(a),Ya(()=>Ks(a,`placeholder`,t.placeholder)),qo(`input`,a,()=>t.onValueChange(ei(G(n)))),Xs(a,()=>G(n),e=>pa(n,e)),q(e,a),ai(i)}Jo([`input`]);var jg=class extends uc{filterValue(e){return gn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return Ag}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`Number`}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Mg=K(` `,1),Ng=K(`
`);function Pg(e,t){ii(t,!0);let n=da(va(t.value)),r=!1,i,a=0,o;function s(e){pa(n,e,!0)}function c(e){pa(n,e,!0),t.onValueChange(e)}function l(e){return e=_(e,t.minValue,t.maxValue),y(e,t.minValue,t.maxValue,0,100)}function u(){r=!0}function d(){r=!1}function f(e){u(),p(e)}function p(e){r&&(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),m(e instanceof TouchEvent?e.touches[0].clientX:e.clientX))}function m(e){let n=i.getBoundingClientRect();e=_(e,n.left,n.right);let r=y(e,n.left,n.right,t.minValue,t.maxValue);r=h(r,t.stepSize),c(r)}function h(e,t){return Number.parseFloat((Math.round(e/t)*t).toFixed(10))}function g(e){a<50&&(a+=1);let r=Math.ceil(a/5);(e.key===`ArrowUp`||e.key===`ArrowRight`)&&c(_(G(n)+r,t.minValue,t.maxValue)),(e.key===`ArrowDown`||e.key===`ArrowLeft`)&&c(_(G(n)-r,t.minValue,t.maxValue)),window.clearTimeout(o),o=window.setTimeout(()=>a=1,100)}var v={setValue:s},b=Ng();Ko(`touchmove`,ba,p,void 0,!1),Ko(`touchcancel`,ba,d),Ko(`touchend`,ba,d),Ko(`mousemove`,ba,p),Ko(`mouseup`,ba,d);var x=U(b),S=W(x,2),C=e=>{var r=Mg(),i=Oa(r),a=U(i,!0);V(i);var o=W(i,2),s=U(o,!0);V(o);var c=W(o,2),l=U(c,!0);V(c),Ya(()=>{as(a,G(n)),as(s,t.minValue),as(l,t.maxValue)}),q(e,r)};return fs(S,e=>{t.addLabels&&e(C)}),V(b),ec(b,e=>i=e,()=>i),Ya((e,r)=>{Ks(b,`aria-label`,e),Ps(x,r),Ks(x,`aria-valuemin`,t.minValue),Ks(x,`aria-valuemax`,t.maxValue),Ks(x,`aria-valuenow`,G(n))},[()=>G(n).toString(),()=>`width: ${l(G(n))}%`]),qo(`keydown`,b,g),qo(`mousedown`,b,f),qo(`touchstart`,b,f,void 0,!0),Ko(`dragstart`,x,()=>r=!0),q(e,b),ai(v)}Jo([`keydown`,`mousedown`,`touchstart`]);var Fg=class extends uc{minValue;maxValue;stepSize;constructor(e){if(super(e),this.minValue=this.mountable.getArgument(kn.MIN_VALUE)?.value??0,this.maxValue=this.mountable.getArgument(kn.MAX_VALUE)?.value??100,this.stepSize=this.mountable.getArgument(kn.STEP_SIZE)?.value??1,this.minValue>=this.maxValue)throw new xe({errorLevel:B.ERROR,effect:`can not create progress bar input field`,cause:`minValue (${this.maxValue}) must be less than maxValue (${this.maxValue})`})}filterValue(e){return v(gn(e),this.minValue,this.maxValue)}getFallbackDefaultValue(){return this.minValue}getSvelteComponent(){return Pg}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{minValue:this.minValue,maxValue:this.maxValue,stepSize:this.stepSize,addLabels:(this.mountable.getArgument(kn.ADD_LABELS)?.value??!0)===!0}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Ig=K(`
`);function Lg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){G(n)===e?pa(n,null):pa(n,e,!0),t.onValueChange(ei(G(n)))}function a(e,t){e.key===` `&&i(t)}var o={setValue:r},s=is();return _s(Oa(s),17,()=>t.options,ps,(e,t)=>{var r=Ig();let o;var s=U(r);Us(s),eg(W(s,2),{get value(){return G(t).name}}),V(r),Ya(e=>{o=Ms(r,1,`mb-select-input-element`,null,o,{"is-selected":G(t).value===G(n)}),Ks(r,`data-value`,e),Gs(s,G(t).value===G(n))},[()=>pn(G(t).value)]),qo(`click`,r,e=>{e.target instanceof HTMLInputElement||i(G(t).value)}),Ko(`keypress`,r,e=>a(e,G(t).value)),qo(`input`,s,()=>i(G(t).value)),q(e,r)}),q(e,s),ai(o)}Jo([`click`,`input`]);var Rg=class extends uc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){return vn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return Lg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{options:this.options}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var zg=K(` `),Bg=K(` `,1);function Vg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=Bg(),o=Oa(a),s=e=>{var n=zg(),r=U(n,!0);V(n),Ya(()=>as(r,t.minValue)),q(e,n)};fs(o,e=>{t.addLabels&&e(s)});var c=W(o,2);Us(c);var l=W(c,2),u=e=>{var n=zg(),r=U(n,!0);V(n),Ya(()=>as(r,t.maxValue)),q(e,n)};return fs(l,e=>{t.addLabels&&e(u)}),Ya(e=>{Ks(c,`aria-label`,e),Ks(c,`min`,t.minValue),Ks(c,`max`,t.maxValue),Ks(c,`step`,t.stepSize)},[()=>G(n).toString()]),qo(`input`,c,()=>t.onValueChange(ei(G(n)))),Xs(c,()=>G(n),e=>pa(n,e)),q(e,a),ai(i)}Jo([`input`]);var Hg=class extends uc{minValue;maxValue;stepSize;constructor(e){if(super(e),this.minValue=this.mountable.getArgument(kn.MIN_VALUE)?.value??0,this.maxValue=this.mountable.getArgument(kn.MAX_VALUE)?.value??100,this.stepSize=this.mountable.getArgument(kn.STEP_SIZE)?.value??1,this.minValue>=this.maxValue)throw new xe({errorLevel:B.ERROR,effect:`can not create slider input field`,cause:`minValue (${this.maxValue}) must be less than maxValue (${this.maxValue})`})}filterValue(e){return v(gn(e),this.minValue,this.maxValue)}getFallbackDefaultValue(){return this.minValue}getSvelteComponent(){return Vg}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{minValue:this.minValue,maxValue:this.maxValue,stepSize:this.stepSize,addLabels:this.mountable.getArgument(kn.ADD_LABELS)?.value===!0}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Ug=K(` `),Wg=K(`
`);function Gg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}let i=ea(()=>G(n)?.toString()??`null`),a=ea(()=>{if(rn.isLink(G(i)))try{return rn.parseLink(G(i))}catch(e){console.warn(e)}});var o={setValue:r},s=Wg(),c=U(s),l=U(c),u=e=>{qh(e,{get mdLink(){return G(a)}})},d=e=>{var t=Ug(),n=U(t,!0);V(t),Ya(()=>as(n,G(i))),q(e,t)};fs(l,e=>{G(a)===void 0?e(d,-1):e(u)}),V(c);var f=W(c,2);Lh(f,{get variant(){return It.PLAIN},get onclick(){return t.showSuggester},children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`list`})},$$slots:{default:!0}});var p=W(f,2),m=e=>{Lh(e,{get variant(){return It.PLAIN},get onclick(){return t.showTextPrompt},children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`pencil`})},$$slots:{default:!0}})};return fs(p,e=>{t.allowOther&&e(m)}),V(s),q(e,s),ai(o)}var Kg=class extends uc{filterValue(e){return vn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return Gg}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showSuggester:()=>this.openModal(),showTextPrompt:()=>this.openTextModal(),allowOther:this.mountable.getArgument(kn.ALLOW_OTHER)?.value===!0}}openModal(){this.mountable.mb.internal.openSuggesterModal(this,e=>this.setInternalValue(e.value))}openTextModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind Suggester`,subTitle:`Set the suggester value.`,value:``,multiline:!1,onSubmit:e=>{this.setInternalValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var qg=K(` `),Jg=K(` `,1);function Yg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e,t){let n=t.toString();return`${e.toString().padStart(n.length,`0`)}/${n}`}var a={setValue:r},o=Jg(),s=Oa(o);Us(s);var c=W(s,2),l=e=>{var r=qg(),a=U(r,!0);V(r),Ya(e=>{Ms(r,1,`mb-content-limit-indicator ${G(n).length>t.limit?`mb-content-limit-indicator-overflow`:``}`),as(a,e)},[()=>i(G(n).length,t.limit)]),q(e,r)};return fs(c,e=>{t.limit!==void 0&&e(l)}),Ya(()=>{Ks(s,`placeholder`,t.placeholder),Ks(s,`maxlength`,t.limit)}),qo(`input`,s,()=>t.onValueChange(ei(G(n)))),Xs(s,()=>G(n),e=>pa(n,e)),q(e,o),ai(a)}Jo([`input`]);var Xg=class extends uc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return``}getSvelteComponent(){return Yg}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`Text`,limit:this.mountable.getArgument(kn.LIMIT)?.value}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Zg=K(``);function Qg(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=Zg();return Na(a),Ya(()=>{Ks(a,`placeholder`,t.placeholder),Ks(a,`maxlength`,t.limit)}),qo(`input`,a,()=>t.onValueChange(ei(G(n)))),Xs(a,()=>G(n),e=>pa(n,e)),q(e,a),ai(i)}Jo([`input`]);var $g=class extends uc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return``}getSvelteComponent(){return Qg}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`Text`,limit:this.mountable.getArgument(kn.LIMIT)?.value}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var e_=K(``);function t_(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=e_();return Us(a),qo(`input`,a,()=>t.onValueChange(ei(G(n)))),Xs(a,()=>G(n),e=>pa(n,e)),q(e,a),ai(i)}Jo([`input`]);var n_=class extends uc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return`00:00`}getSvelteComponent(){return t_}rawMapValue(e){return e}rawReverseMapValue(e){return e}};new Set([`$$slots`,`$$events`,`$$legacy`]);var r_=K(`
`);function i_(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(){pa(n,!G(n)),t.onValueChange(ei(G(n)))}function a(e){e.key===` `&&i()}var o={setValue:r},s=r_();let c;var l=U(s);return Us(l),V(s),Ya(()=>{c=Ms(s,1,`checkbox-container`,null,c,{"is-enabled":G(n)}),Ks(s,`aria-checked`,G(n)),Gs(l,G(n))}),qo(`click`,s,()=>i()),qo(`keydown`,s,e=>a(e)),q(e,s),ai(o)}Jo([`click`,`keydown`]);var a_=class extends uc{onValue;offValue;constructor(e){super(e),this.onValue=this.mountable.getArgument(kn.ON_VALUE)?.value??!0,this.offValue=this.mountable.getArgument(kn.OFF_VALUE)?.value??!1}filterValue(e){return e===this.onValue||e===this.offValue?vn(e):void 0}getFallbackDefaultValue(){return!1}getSvelteComponent(){return i_}rawReverseMapValue(e){return e===this.onValue?!0:(this.offValue,!1)}rawMapValue(e){return e?this.onValue:this.offValue}},o_=class{static linkToInputField(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/inputfields/${e.toLowerCase()}/`}static linkToInputFieldArgument(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/inputfieldarguments/${e.toLowerCase()}/`}static linkToViewField(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/viewfields/${e.toLowerCase()}/`}static linkToViewFieldArgument(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/viewfieldarguments/${e.toLowerCase()}/`}static linkToInputFields(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/inputfields/`}static linkToViewFields(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/viewfields/`}static linkToButtons(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/buttons/#button-configuration`}static linkToButtonConfig(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/buttons/#button-configuration`}static linkToSearch(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/?s=${encodeURIComponent(e)}`}static linkToHome(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/`}static linkToGithub(){return`https://github.com/mProjectsCode/obsidian-meta-bind-plugin`}static linkToIssues(){return`https://github.com/mProjectsCode/obsidian-meta-bind-plugin/issues`}static linkToCanaryBuilds(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/installation/#canary-builds`}static open(e){E(e)}},s_=class{mb;constructor(e){this.mb=e}createInputField(e){let t=e.declaration.inputFieldType,n=e.renderChildType;if(t!==On.INVALID&&this.checkRenderChildTypeAllowed(t,n),t===On.TOGGLE)return new a_(e);if(t===On.SLIDER)return new Hg(e);if(t===On.TEXT)return new Xg(e);if(t===On.TEXT_AREA)return new $g(e);if(t===On.SELECT)return new Rg(e);if(t===On.MULTI_SELECT)return new Og(e);if(t===On.DATE_PICKER)return new Eh(e);if(t===On.NUMBER)return new jg(e);if(t===On.SUGGESTER)return new Kg(e);if(t===On.EDITOR)return new Fh(e);if(t===On.PROGRESS_BAR)return new Fg(e);if(t===On.INLINE_SELECT)return new fg(e);if(t===On.IMAGE_SUGGESTER)return new Gh(e);if(t===On.LIST)return new bg(e);if(t===On.LIST_SUGGESTER)return new Tg(e);if(t===On.DATE)return new xh(e);if(t===On.TIME)return new n_(e);if(t===On.INLINE_LIST_SUGGESTER)return new cg(e);if(t===On.INLINE_LIST)return new ig(e);if(t===On.IMAGE_LIST_SUGGESTER)return new Vh(e);if(t===On.DATE_TIME)return new kh(e)}checkRenderChildTypeAllowed(e,t){if(this.mb.getSettings().ignoreCodeBlockRestrictions)return;let n=An[e];if(t===de.BLOCK&&!n.allowInBlock)throw new ve({errorLevel:B.ERROR,effect:`can not create input field`,cause:`input fields of type '${e}' are not allowed inside of code blocks`,docs:[o_.linkToInputField(e)]});if(t===de.INLINE&&!n.allowInline)throw new ve({errorLevel:B.ERROR,effect:`can not create input field`,cause:`input fields of type '${e}' are not allowed inside of inline code blocks`,docs:[o_.linkToInputField(e)]})}},c_=class extends oc{mb;mountable;metadataSubscription;variables;hidden;constructor(e){super(),this.mountable=e,this.mb=e.mb,this.variables=[],this.hidden=!1}async initialRender(e){k.addClass(e,`mb-view-text`),this.hidden=this.mountable.getArgument(Pn.HIDDEN)?.value??!1,this.hidden&&k.addClass(e,`mb-view-hidden`),await this.onInitialRender(e)}async rerender(e,t){this.hidden||await this.onRerender(e,t)}onMount(e){this.buildVariables(),this.initialRender(e),this.metadataSubscription=this.mountable.mb.metadataManager.subscribeDerived(this.mountable.getUuid(),this.mountable.getDeclaration().writeToBindTarget,this.variables.map(e=>e.bindTargetDeclaration),this.variables.map(e=>e.metadataSignal),async()=>{let t=await this.computeValue();return this.rerender(e,t),this.mapValue(t)},()=>this.mountable.unmount())}onUnmount(){this.metadataSubscription?.unsubscribe()}},l_=K(`
`);function u_(e,t){ii(t,!0);let n=tc(t,`internal`,3,!0),r=ea(()=>n()?t.mb.internal.imagePathToUri(t.image):t.image);var i=l_(),a=U(i);V(i),Ya(()=>{Ks(a,`src`,G(r)),Ks(a,`alt`,t.image)}),q(e,i),ai()}var d_=K(`No images`),f_=K(`
`);function p_(e,t){ii(t,!0);let n=tc(t,`images`,23,()=>[]);function r(e){n(e)}var i={updateImages:r},a=f_();return _s(a,21,n,ps,(e,n)=>{u_(e,{get mb(){return t.mb},get image(){return G(n).link},get internal(){return G(n).internal}})},e=>{q(e,d_())}),V(a),q(e,a),ai(i)}var m_=class extends c_{component;linkVariable;constructor(e){super(e)}buildVariables(){let e=this.mountable.getDeclaration().templateDeclaration.filter(e=>typeof e==`string`?e:!0);if(e.length!==1)throw new ye({errorLevel:B.ERROR,effect:`can not create view field`,cause:`image view filed only supports exactly a single bind target and not text content`});let t=e[0];if(typeof t==`string`)throw new ye({errorLevel:B.ERROR,effect:`can not create view field`,cause:`image view filed only supports exactly a single bind target and not text content`});t.listenToChildren=!0,this.linkVariable={bindTargetDeclaration:t,metadataSignal:new cc(void 0),uuid:w(),contextName:`MB_VAR_0`},this.variables.push(this.linkVariable)}computeValue(){let e=this.linkVariable.metadataSignal.get();if(typeof e==`string`){let t=rn.interpretAsLink(e);return t===void 0?void 0:[t]}else if(Array.isArray(e))return e.filter(e=>typeof e==`string`).map(e=>rn.interpretAsLink(e)).filter(e=>e!==void 0);else return}mapValue(e){return e===void 0?``:Array.isArray(e)?e.map(e=>e.toString()):e.toString()}onInitialRender(e){this.component=os(p_,{target:e,props:{images:[],mb:this.mountable.mb}})}async onRerender(e,t){this.component?.updateImages(N(t).map(e=>({link:e.target,internal:e.internal})))}onUnmount(){super.onUnmount(),this.component&&us(this.component)}},h_=K(``);function g_(e,t){ii(t,!0);let n=tc(t,`mdLinkList`,7);function r(e){n(e)}var i={updateList:r},a=is(),o=Oa(a),s=e=>{q(e,h_())},c=e=>{qh(e,{get mdLink(){return n()[0]}})},l=e=>{Xh(e,{get elements(){return n()},children:(e,t=qn)=>{qh(e,{get mdLink(){return t()}})},$$slots:{default:!0}})};return fs(o,e=>{n().length===0?e(s):n().length===1?e(c,1):e(l,-1)}),q(e,a),ai(i)}var __=class extends c_{component;linkVariable;aliasVariable;constructor(e){super(e)}buildVariables(){let e=this.mountable.getDeclaration().templateDeclaration.filter(e=>typeof e==`string`?e:!0);if(e.length!==1&&e.length!==2&&e.length!==3)throw new ye({errorLevel:B.ERROR,effect:`can not create view field`,cause:`link view field must be of form "{bindTarget}" or "{bindTarget}|{bindTarget}"`});let t=e[0],n=e[1],r=e[2];if(this.variables=[],e.length===1){if(typeof t==`string`)throw new ye({errorLevel:B.ERROR,effect:`can not create view field`,cause:`link view field must be of form "{bindTarget}" or "{bindTarget}|{bindTarget}"`});t.listenToChildren=!0,this.linkVariable={bindTargetDeclaration:t,metadataSignal:new cc(void 0),uuid:w(),contextName:`MB_VAR_0`},this.variables.push(this.linkVariable)}else if(e.length===2||e.length===3){if(typeof t==`string`||typeof n!=`string`)throw new ye({errorLevel:B.ERROR,effect:`can not create view field`,cause:`link view field must be of form "{bindTarget}", "{bindTarget}|alias", or "{bindTarget}|{bindTarget}"`});t.listenToChildren=!0,this.linkVariable={bindTargetDeclaration:t,metadataSignal:new cc(void 0),uuid:w(),contextName:`MB_VAR_0`},this.variables.push(this.linkVariable),e.length===2?this.aliasVariable=n.slice(1):typeof r==`string`?this.aliasVariable=r:(r.listenToChildren=!0,this.aliasVariable={bindTargetDeclaration:r,metadataSignal:new cc(void 0),uuid:w(),contextName:`MB_VAR_1`},this.variables.push(this.aliasVariable))}else throw Error(`unreachable`)}getAlias(){if(this.aliasVariable)return typeof this.aliasVariable==`string`?this.aliasVariable:yn(this.aliasVariable.metadataSignal.get(),this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)}computeValue(){let e=this.linkVariable.metadataSignal.get(),t=this.getAlias();if(typeof e==`string`){let n=rn.interpretAsLink(e);return n===void 0?void 0:(t&&(n.alias=t),[n])}else if(Array.isArray(e))return e.filter(e=>typeof e==`string`).map(e=>rn.interpretAsLink(e)).filter(e=>e!==void 0);else return}mapValue(e){return e===void 0?``:Array.isArray(e)?e.map(e=>e.toString()):e.toString()}onInitialRender(e){this.component=os(g_,{target:e,props:{mdLinkList:[]}})}async onRerender(e,t){this.component?.updateList(N(t))}onUnmount(){super.onUnmount(),this.component&&us(this.component)}},v_=class extends c_{container;expression;expressionStr;hidden;constructor(e){super(e),this.hidden=!1}buildVariables(){let e=0;this.expressionStr=``,this.variables=[];for(let t of this.mountable.getDeclaration().templateDeclaration??[])if(typeof t!=`string`){let n={bindTargetDeclaration:t,metadataSignal:new cc(void 0),uuid:w(),contextName:`MB_VAR_${e}`};this.variables.push(n),this.expressionStr+=n.contextName,e+=1}else this.expressionStr+=t;this.expression=this.mb.math.compile(this.expressionStr)}buildMathJSContext(){let e={};for(let t of this.variables??[])!t.contextName||!t.metadataSignal||(e[t.contextName]=t.metadataSignal.get()??``);return e}computeValue(){if(!this.expression)return this.handleComputeError(new Ce({errorLevel:B.ERROR,effect:`failed to evaluate expression`,cause:`expression is undefined`}));let e=this.buildMathJSContext();try{return{value:fn(`${this.expression.evaluate(e)}`),error:!1}}catch(t){return t instanceof Error?this.handleComputeError(new Ce({errorLevel:B.ERROR,effect:`failed to evaluate expression`,cause:t,context:{expression:this.expressionStr,context:e}})):this.handleComputeError(Error(`failed to evaluate js expression because of unexpected thrown value`))}}mapValue(e){return e.value}onInitialRender(e){}onRerender(e,t){let n=yn(t?.value,this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)??``;t?.error?k.addClass(e,`mb-error`):k.removeClass(e,`mb-error`),e.innerText=n}handleComputeError(e){return console.warn(e),{error:!0,value:e.message}}},y_=class extends c_{textParts;renderMarkdown;markdownUnloadCallback;constructor(e){super(e),this.renderMarkdown=!1}buildVariables(){this.textParts=[];let e=0;this.variables=[];for(let t of this.mountable.getDeclaration().templateDeclaration??[])if(typeof t!=`string`){let n={bindTargetDeclaration:t,metadataSignal:new cc(void 0),uuid:w(),contextName:`MB_VAR_${e}`};this.variables.push(n),this.textParts.push(n),e+=1}else this.textParts.push(t)}computeValue(){if(!this.textParts)throw new Ce({errorLevel:B.CRITICAL,effect:`failed to evaluate text view field`,cause:`content parts is undefined`});return this.textParts.map(e=>typeof e==`string`?e:yn(e.metadataSignal.get(),this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)).join(``)}mapValue(e){return e}onInitialRender(e){this.renderMarkdown=this.mountable.getArgument(Pn.RENDER_MARKDOWN)?.value??!1,this.renderMarkdown&&k.addClass(e,`mb-view-markdown`)}async onRerender(e,t){let n=yn(t,this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)??``;this.renderMarkdown?(this.markdownUnloadCallback?.(),k.empty(e),this.markdownUnloadCallback=await this.mountable.mb.internal.renderMarkdown(n,e,this.mountable.getFilePath())):e.innerText=n}onUnmount(){super.onUnmount(),this.markdownUnloadCallback?.()}},b_=class{mb;constructor(e){this.mb=e}createViewField(e){let t=e.declaration.viewFieldType;if(t===Nn.MATH)return new v_(e);if(t===Nn.TEXT)return new y_(e);if(t===Nn.LINK)return new __(e);if(t===Nn.IMAGE)return new m_(e)}},x_=class extends Error{},S_=class extends Error{},C_=function(e){return this instanceof C_?(this.v=e,this):new C_(e)},w_;(function(e){e[e.SHORTEST=0]=`SHORTEST`,e[e.LONGEST=1]=`LONGEST`,e[e.STRICT_EQUAL=2]=`STRICT_EQUAL`})(w_||={});function*T_(e,t,...n){if(n.length===0)return;let r=[];for(let e of n)r.push(N_(e));iterate:for(;;){let n=D_(r,e=>e.next()),i=[],a=!0,o=!1;for(let e of n){let n;e.done?(a=!1,n=t):(o=!0,n=e.value),i.push(n)}if(!a&&o)switch(e){case w_.SHORTEST:break iterate;case w_.STRICT_EQUAL:throw new S_(`Iterators must have equal lengths`)}if(!o)break;yield i}}var E_=function(e){return this instanceof E_?(this.v=e,this):new E_(e)};function*D_(e,t){for(let n of M_(e))yield t(n)}function O_(e,t){for(let n of M_(e))if(t(n))return!0;return!1}function k_(e){return e==null?!1:typeof e[Symbol.iterator]==`function`}function A_(e){return e==null?!1:e.next!==void 0&&typeof e.next==`function`}var j_=function(e){return this instanceof j_?(this.v=e,this):new j_(e)};function M_(e){if(k_(e))return e;if(A_(e))return{[Symbol.iterator](){return e}};if(typeof e==`object`&&e)return(function*(){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(yield[t,e[t]])})();throw new x_(`Given collection is not iterable or iterator.`)}function N_(e){if(A_(e))return e;if(k_(e))return(function*(){for(let t of e)yield t})();throw new x_(`Given collection is not iterable or iterator.`)}var P_=function(e){return this instanceof P_?(this.v=e,this):new P_(e)};function*F_(...e){for(let t of T_(w_.SHORTEST,void 0,...e))yield t}var I_=class{uuid;metadataManager;bindTarget;dependencies;dependencySignals;dependencySubscriptions;computeFunction;deleted;onDelete;constructor(e,t,n,r,i,a,o){this.uuid=e,this.metadataManager=t,this.bindTarget=n,this.dependencies=r,this.dependencySignals=i,this.dependencySubscriptions=[],this.computeFunction=a,this.onDelete=o,this.deleted=!1}init(){for(let[e,t]of F_(this.dependencies,this.dependencySignals)){let n=this.uuid+`/`+w();this.dependencySubscriptions.push(this.metadataManager.subscribe(n,t,e,()=>this.delete())),t.registerListener({callback:()=>void this.computeValue()})}this.computeValue()}async computeValue(){try{let e=await this.computeFunction();this.bindTarget&&(x(this.metadataManager.readShortLived(this.bindTarget),e)||this.metadataManager.write(e,this.bindTarget,this.uuid))}catch(e){let t=e instanceof Error?e:String(e);console.warn(new _e({errorLevel:B.ERROR,effect:`Failed to run derived metadata computation`,cause:t}))}}unsubscribe(){for(let e of this.dependencySubscriptions)e.unsubscribe();this.metadataManager.unsubscribe(this)}onUpdate(e){return!1}updatable(){return!1}getDependencies(){return this.dependencies}delete(){this.deleted=!0;for(let e of this.dependencySubscriptions)e.deleted||e.delete();this.onDelete(),this.unsubscribe()}},L_=class{uuid;metadataManager;bindTarget;dependencies;dependencySignals;dependencySubscriptions;effectFunction;deleted;onDelete;constructor(e,t,n,r,i,a){this.uuid=e,this.metadataManager=t,this.bindTarget=void 0,this.dependencies=n,this.dependencySignals=r,this.dependencySubscriptions=[],this.effectFunction=i,this.deleted=!1,this.onDelete=a}init(){for(let[e,t]of F_(this.dependencies,this.dependencySignals)){let n=this.uuid+`/`+w();this.dependencySubscriptions.push(this.metadataManager.subscribe(n,t,e,()=>this.delete())),t.registerListener({callback:()=>void this.runEffect()})}this.runEffect()}async runEffect(){try{await this.effectFunction()}catch(e){let t=e instanceof Error?e:String(e);console.warn(new _e({errorLevel:B.ERROR,effect:`Failed to run metadata effect`,cause:t}))}}unsubscribe(){for(let e of this.dependencySubscriptions)e.unsubscribe();this.metadataManager.unsubscribe(this)}onUpdate(e){return!1}updatable(){return!1}getDependencies(){return this.dependencies}delete(){this.deleted=!0;for(let e of this.dependencySubscriptions)e.deleted||e.delete();this.onDelete(),this.unsubscribe()}},R_=class{uuid;callbackSignal;value;metadataManager;bindTarget;deleted;onDelete;constructor(e,t,n,r,i){this.uuid=e,this.callbackSignal=t,this.metadataManager=n,this.bindTarget=r,this.onDelete=i,this.deleted=!1,this.value=void 0}unsubscribe(){this.metadataManager.unsubscribe(this)}write(e){x(this.metadataManager.readShortLived(this.bindTarget),e)||(this.value=e,this.metadataManager.write(e,this.bindTarget,this.uuid))}read(){return this.metadataManager.read(this.bindTarget)}onUpdate(e){try{if(!x(this.value,e)){let t=structuredClone(e);return this.value=t,this.callbackSignal.set(t),!0}}catch(e){let t=e instanceof Error?e:String(e);console.warn(new _e({errorLevel:B.ERROR,effect:`Failed to notify subscription of updated value in the cache`,cause:t}))}return!1}updatable(){return!0}getDependencies(){return[]}delete(){this.deleted=!0,this.onDelete()}},z_=class{static get(e,t){return t.get(e).child}static tryGet(e,t){return t.tryGet(e)?.child}static fullGet(e,t){return t.get(e)}static set(e,t,n){t.set(e,n)}static setAndCreate(e,t,n){t.setAndCreate(e,n)}};function B_(e,t){return e===void 0||t===void 0||e.storageType!==t.storageType||e.storagePath!==t.storagePath?!1:V_(e.storageProp,t.storageProp,t.listenToChildren)}function V_(e,t,n){let r=e.path,i=t.path;for(let e=0;ei.length?n:!0}function H_(e){return e===void 0?`undefined`:`${e.storagePath}#${e.storageProp.toString()}`}var U_=class{sources;defaultSource;constructor(){this.sources=new Map,this.defaultSource=`CHANGE_THE_DEFAULT_SOURCE`}registerSource(e){this.sources.set(e.id,e)}setDefaultSource(e){if(this.sources.has(e))this.defaultSource=e;else throw new _e({errorLevel:B.CRITICAL,effect:`can not set default source`,cause:`Source "${e}" does not exist`})}unregisterSource(e){this.sources.delete(e.id)}getSource(e){return this.sources.get(e)}iterateSources(){return this.sources.keys()}subscribe(e,t,n,r){let i=new R_(e,t,this,n,r);return this.subscribeSubscription(i),i}subscribeDerived(e,t,n,r,i,a){let o=new I_(e,this,t,n,r,i,a);return this.checkForLoops(o),o.init(),this.subscribeSubscription(o),o}subscribeEffect(e,t,n,r,i){let a=new L_(e,this,t,n,r,i);return a.init(),this.subscribeSubscription(a),a}unsubscribe(e){if(e.bindTarget===void 0)return;let t=this.getSource(e.bindTarget.storageType);if(t===void 0)throw new _e({errorLevel:B.ERROR,effect:`can not unsubscribe subscription`,cause:`Source "${e.bindTarget.storageType}" does not exist`});let n=t.unsubscribe(e);n.subscriptions.length===0&&(n.cyclesWithoutListeners=0)}subscribeSubscription(e){if(e.bindTarget===void 0)return;let t=this.getSource(e.bindTarget.storageType);if(t===void 0)throw new _e({errorLevel:B.ERROR,effect:`can not subscribe subscription`,cause:`Source "${e.bindTarget.storageType}" does not exist`});let n=t.subscribe(e);n.cyclesWithoutListeners=0;let r=t.readCacheItem(n,e.bindTarget.storageProp);e.onUpdate(r)}checkForLoops(e){for(let t of this.getAllSubscriptionsToDependencies(e))this.recCheckForLoops([e,t])}recCheckForLoops(e){let t=e.at(0),n=e.at(-1);if(!(n===void 0||t===void 0)){if(B_(t.bindTarget,n.bindTarget))throw new be({errorLevel:B.ERROR,effect:`bind target dependency loop detected`,cause:`the loop is as follows: ${e.map(e=>`"${H_(e.bindTarget)}"`).join(` -> `)}`,docs:[`https://mprojectscode.github.io/obsidian-meta-bind-plugin-docs/guides/viewfields/#circular-dependencies`]});for(let t of this.getAllSubscriptionsToDependencies(n))this.recCheckForLoops([...e,t])}}getAllSubscriptionsToDependencies(e){return e.getDependencies().map(e=>this.getAllSubscriptionsToBindTarget(e)).flat()}getAllSubscriptionsToBindTarget(e){if(e===void 0)return[];let t=this.getCacheItemForBindTarget(e);return t?t.subscriptions.filter(t=>B_(t.bindTarget,e)):[]}getCacheItemForBindTarget(e){return this.getSource(e.storageType)?.getCacheItemForStoragePath(e.storagePath)}async cycle(){let e=[];for(let t of this.sources.values())e.push(this.cycleSource(t));for(let t of await Promise.allSettled(e))t.status===`rejected`&&console.warn(`meta-bind | MetadataManager >> failed to cycle source`,t.reason)}async cycleSource(e){let t=[],n=await Promise.allSettled(e.getCacheItems().map(async n=>{if(e.onCycle(n),n.dirty)try{await e.syncExternal(n),n.dirty=!1}catch(t){console.warn(`failed to sync changes to external source for ${e.id}`,t)}n.externalWriteLock>0&&--n.externalWriteLock,n.subscriptions.length===0&&(n.cyclesWithoutListeners+=1),n.cyclesWithoutListeners>300&&e.shouldDelete(n)&&t.push(n)}));for(let t of n)t.status===`rejected`&&console.warn(`meta-bind | MetadataManager >> failed to cycle cache item in source ${e.id}`,t.reason);for(let n of t)n.subscriptions.length===0&&n.cyclesWithoutListeners>300&&e.shouldDelete(n)&&e.deleteCache(n)}write(e,t,n){let r=this.getSource(t.storageType);if(r===void 0)throw new _e({errorLevel:B.ERROR,effect:`can not write to cache`,cause:`Source "${t.storageType}" does not exist`});let i=r.writeCache(structuredClone(e),t);i.dirty=!0,i.externalWriteLock=5,this.notifyListeners(t,n)}read(e){let t=this.getSource(e.storageType);if(t===void 0)throw new _e({errorLevel:B.ERROR,effect:`can not read metadata`,cause:`Source "${e.storageType}" does not exist`});return structuredClone(t.readCache(e))}readShortLived(e){let t=this.getSource(e.storageType);if(t===void 0)throw new _e({errorLevel:B.ERROR,effect:`can not read metadata`,cause:`Source "${e.storageType}" does not exist`});return t.readCache(e)}isCacheExternalWriteLocked(e){return e.externalWriteLock>0}notifyListeners(e,t){let n=this.getSource(e.storageType);if(n===void 0)throw new _e({errorLevel:B.ERROR,effect:`can notify listeners metadata`,cause:`Source "${e.storageType}" does not exist`});let r=n.getCacheItemForStoragePath(e.storagePath);if(r!==void 0){for(let i of r.subscriptions)if(!(t!==void 0&&t===i.uuid||i.bindTarget===void 0||!i.updatable())&&V_(e.storageProp,i.bindTarget.storageProp,i.bindTarget.listenToChildren)){let e=n.readCache(i.bindTarget);i.onUpdate(e)}}}notifyAllListeners(e,t){for(let n of t.subscriptions){if(n.bindTarget===void 0)continue;let t=e.readCache(n.bindTarget);n.onUpdate(t)}}deleteCachesForStoragePath(e){for(let t of this.sources.values()){if(!t.usesStoragePath())continue;let n=t.getCacheItemForStoragePath(e);if(n!==void 0){for(let e of[...n.subscriptions])e.delete();t.deleteCache(n)}}}constructDefaultCacheItem(){return{subscriptions:[],externalWriteLock:0,dirty:!1,cyclesWithoutListeners:0}}onExternalUpdate(e,t,n){let r=e.getCacheItemForStoragePath(t);if(r===void 0||this.isCacheExternalWriteLocked(r))return;e.writeEntireCache(n,r);let i=0;for(let e of r.subscriptions){if(e.bindTarget===void 0||!e.updatable())continue;let t=z_.tryGet(n,e.bindTarget.storageProp);e.onUpdate(t)&&(i+=1)}}onStoragePathDeleted(e){this.deleteCachesForStoragePath(e)}onStoragePathRenamed(e,t){this.deleteCachesForStoragePath(e)}},W_=class{activeMountables;constructor(){this.activeMountables=new Map}unloadFile(e){for(let t of this.activeMountables.values())t.getFilePath()===e&&t.unmount()}unload(){for(let e of this.activeMountables.values())e.unmount()}registerMountable(e){this.activeMountables.set(e.getUuid(),e)}unregisterMountable(e){this.activeMountables.delete(e.getUuid())}},G_=function(e){return e.FRONTMATTER=`frontmatter`,e.MEMORY=`memory`,e.GLOBAL_MEMORY=`globalMemory`,e.SCOPE=`scope`,e}({}),K_=class e{path;constructor(e){this.path=e}get(e){if(this.path.length===0)throw Error(`can not use empty path to access object`);let t=this.path[0].get(e);for(let e of this.path.slice(1))t=e.get(t.child);return t}tryGet(e){try{return this.get(e)}catch{return}}set(e,t){if(this.path.length===0)throw Error(`can not use empty path to access object`);let n=this.path[0].get(e);for(let e of this.path.slice(1))n=e.get(n.child);n.access.set(n.parent,t)}setAndCreate(e,t){if(this.path.length===0)throw Error(`can not use empty path to access object`);let n=this.path[0].get(e);n.child===void 0&&(n.access.set(n.parent,this.getNextPathElementValue(0,t)),n=n.access.get(n.parent));for(let e=1;ee.prop)}toString(){return this.toStringArray().join(`.`)}concat(t){return new e(this.path.concat(t.path))}compareDiffArray(e){let t=Math.min(this.path.length,e.length);for(let n=0;ne.toUnvalidatedPropAccess()),listenToChildren:e.listenToChildren}}validate(e,t,n,r){let i=new K_(t.storageProp.map(e=>new Ue(e.type,e.prop.value))),a;a=t.storageType===void 0?this.mb.metadataManager.defaultSource:this.validateStorageType(t.storageType,e);let o=t.storagePath!==void 0,s=t.storagePath??{value:n},c=this.mb.metadataManager.getSource(a);if(c===void 0)throw new _e({errorLevel:B.CRITICAL,effect:`can not validate bind target`,cause:`Source '${a}' not found. But validation was successful. This should not happen.`,context:{fullDeclaration:e,sources:[...this.mb.metadataManager.sources.keys()]}});let l=c.validateStoragePath(s,o,e,this),u={storageType:a,storagePath:l,storageProp:i,listenToChildren:t.listenToChildren};return c.id===G_.SCOPE?this.resolveScope(u,r):u}resolveScope(e,t){if(t===void 0)throw new ke(B.ERROR,`Bind Target Scope Validator`,`Failed to resolve bind target scope, no scope provided`);return e.storageType=t.scope.storageType,e.storagePath=t.scope.storagePath,e.storageProp=t.scope.storageProp.concat(e.storageProp),e}validateStorageType(e,t){for(let t of this.mb.metadataManager.iterateSources())if(t===e.value)return t;throw new ke(B.ERROR,`Bind Target Validator`,`Encountered invalid identifier. Expected token to be a storage type but received '${e?.value}'.`,t,e?.position)}validateStoragePathAsFilePath(e,t){let n=e?.value;if(n===void 0)throw new ke(B.ERROR,`Bind Target Validator`,`Failed to parse bind target. Bind target storage path is undefined.`,t,e?.position);let r=this.mb.file.getPathByName(n);if(r===void 0)throw new ke(B.ERROR,`Bind Target Validator`,`Failed to parse bind target. Bind target file path '${n}' not found.`,t,e?.position);return r}},J_;function X(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;en?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Y_=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},X_=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(J_=globalThis).__zod_globalConfig??(J_.__zod_globalConfig={});var Z_=globalThis.__zod_globalConfig;function Q_(e){return e&&Object.assign(Z_,e),Z_}function $_(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ev(e,t){return typeof t==`bigint`?t.toString():t}function tv(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function nv(e){return e==null}function rv(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function iv(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r){};function fv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var pv=tv(()=>{if(Z_.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function mv(e){if(fv(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(fv(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function hv(e){return mv(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var gv=new Set([`string`,`number`,`symbol`]);function _v(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function vv(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function yv(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function bv(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var xv={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Sv(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return vv(e,cv(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return sv(this,`shape`,e),e},checks:[]}))}function Cv(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return vv(e,cv(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return sv(this,`shape`,r),r},checks:[]}))}function wv(e,t){if(!mv(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return vv(e,cv(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return sv(this,`shape`,n),n}}))}function Tv(e,t){if(!mv(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return vv(e,cv(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return sv(this,`shape`,n),n}}))}function Ev(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return vv(e,cv(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return sv(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Dv(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return vv(t,cv(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return sv(this,`shape`,i),i},checks:[]}))}function Ov(e,t,n){return vv(t,cv(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return sv(this,`shape`,i),i}}))}function kv(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Mv(e){return typeof e==`string`?e:e?.message}function Nv(e,t,n){let r=e.message?e.message:Mv(e.inst?._zod.def?.error?.(e))??Mv(t?.error?.(e))??Mv(n.customError?.(e))??Mv(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Pv(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Fv(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Iv=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ev,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lv=X(`$ZodError`,Iv),Rv=X(`$ZodError`,Iv,{Parent:Error});function zv(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Bv(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Y_;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Nv(e,a,Q_())));throw dv(t,i?.callee),t}return o.value},Hv=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Nv(e,a,Q_())));throw dv(t,i?.callee),t}return o.value},Uv=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Y_;return a.issues.length?{success:!1,error:new(e??Lv)(a.issues.map(e=>Nv(e,i,Q_())))}:{success:!0,data:a.value}},Wv=Uv(Rv),Gv=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Nv(e,i,Q_())))}:{success:!0,data:a.value}},Kv=Gv(Rv),qv=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Vv(e)(t,n,i)},Jv=e=>(t,n,r)=>Vv(e)(t,n,r),Yv=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Hv(e)(t,n,i)},Xv=e=>async(t,n,r)=>Hv(e)(t,n,r),Zv=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Uv(e)(t,n,i)},Qv=e=>(t,n,r)=>Uv(e)(t,n,r),$v=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Gv(e)(t,n,i)},ey=e=>async(t,n,r)=>Gv(e)(t,n,r),ty=/^[cC][0-9a-z]{6,}$/,ny=/^[0-9a-z]+$/,ry=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,iy=/^[0-9a-vA-V]{20}$/,ay=/^[A-Za-z0-9]{27}$/,oy=/^[a-zA-Z0-9_-]{21}$/,sy=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,cy=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ly=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,uy=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,dy=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function fy(){return new RegExp(dy,`u`)}var py=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,my=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,hy=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,gy=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_y=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,vy=/^[A-Za-z0-9_-]*$/,yy=/^https?$/,by=/^\+[1-9]\d{6,14}$/,xy=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Sy=RegExp(`^${xy}$`);function Cy(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function wy(e){return RegExp(`^${Cy(e)}$`)}function Ty(e){let t=Cy({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${xy}T(?:${r})$`)}var Ey=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Dy=/^-?\d+$/,Oy=/^-?\d+(?:\.\d+)?$/,ky=/^(?:true|false)$/i,Ay=/^[^A-Z]*$/,jy=/^[^a-z]*$/,My=X(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ny={number:`number`,bigint:`bigint`,object:`date`},Py=X(`$ZodCheckLessThan`,(e,t)=>{My.init(e,t);let n=Ny[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value{(t.inclusive?r.value<=t.value:r.value{My.init(e,t);let n=Ny[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Iy=X(`$ZodCheckMultipleOf`,(e,t)=>{My.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):iv(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ly=X(`$ZodCheckNumberFormat`,(e,t)=>{My.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=xv[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Dy)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}sa&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Ry=X(`$ZodCheckMaxLength`,(e,t)=>{var n;My.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nv(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum{let r=n.value;if(r.length<=t.maximum)return;let i=Pv(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),zy=X(`$ZodCheckMinLength`,(e,t)=>{var n;My.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nv(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Pv(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),By=X(`$ZodCheckLengthEquals`,(e,t)=>{var n;My.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nv(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Pv(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Vy=X(`$ZodCheckStringFormat`,(e,t)=>{var n,r;My.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Hy=X(`$ZodCheckRegex`,(e,t)=>{Vy.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Uy=X(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ay,Vy.init(e,t)}),Wy=X(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=jy,Vy.init(e,t)}),Gy=X(`$ZodCheckIncludes`,(e,t)=>{My.init(e,t);let n=_v(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ky=X(`$ZodCheckStartsWith`,(e,t)=>{My.init(e,t);let n=RegExp(`^${_v(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),qy=X(`$ZodCheckEndsWith`,(e,t)=>{My.init(e,t);let n=RegExp(`.*${_v(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Jy=X(`$ZodCheckOverwrite`,(e,t)=>{My.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Yy=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(` `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(` `))}},Xy={major:4,minor:4,patch:3},Zy=X(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xy;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=kv(e),i;for(let a of t){if(a._zod.def.when){if(Av(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Y_;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=kv(e,t))});else{if(e.issues.length===t)continue;r||=kv(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(kv(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Y_;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Y_;return o.then(e=>t(e,r,a))}return t(o,r,a)}}ov(e,`~standard`,()=>({validate:t=>{try{let n=Wv(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Kv(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Qy=X(`$ZodString`,(e,t)=>{Zy.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ey(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),$y=X(`$ZodStringFormat`,(e,t)=>{Vy.init(e,t),Qy.init(e,t)}),eb=X(`$ZodGUID`,(e,t)=>{t.pattern??=cy,$y.init(e,t)}),tb=X(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=ly(e)}else t.pattern??=ly();$y.init(e,t)}),nb=X(`$ZodEmail`,(e,t)=>{t.pattern??=uy,$y.init(e,t)}),rb=X(`$ZodURL`,(e,t)=>{$y.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===yy.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ib=X(`$ZodEmoji`,(e,t)=>{t.pattern??=fy(),$y.init(e,t)}),ab=X(`$ZodNanoID`,(e,t)=>{t.pattern??=oy,$y.init(e,t)}),ob=X(`$ZodCUID`,(e,t)=>{t.pattern??=ty,$y.init(e,t)}),sb=X(`$ZodCUID2`,(e,t)=>{t.pattern??=ny,$y.init(e,t)}),cb=X(`$ZodULID`,(e,t)=>{t.pattern??=ry,$y.init(e,t)}),lb=X(`$ZodXID`,(e,t)=>{t.pattern??=iy,$y.init(e,t)}),ub=X(`$ZodKSUID`,(e,t)=>{t.pattern??=ay,$y.init(e,t)}),db=X(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ty(t),$y.init(e,t)}),fb=X(`$ZodISODate`,(e,t)=>{t.pattern??=Sy,$y.init(e,t)}),pb=X(`$ZodISOTime`,(e,t)=>{t.pattern??=wy(t),$y.init(e,t)}),mb=X(`$ZodISODuration`,(e,t)=>{t.pattern??=sy,$y.init(e,t)}),hb=X(`$ZodIPv4`,(e,t)=>{t.pattern??=py,$y.init(e,t),e._zod.bag.format=`ipv4`}),gb=X(`$ZodIPv6`,(e,t)=>{t.pattern??=my,$y.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),_b=X(`$ZodCIDRv4`,(e,t)=>{t.pattern??=hy,$y.init(e,t)}),vb=X(`$ZodCIDRv6`,(e,t)=>{t.pattern??=gy,$y.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function yb(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var bb=X(`$ZodBase64`,(e,t)=>{t.pattern??=_y,$y.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{yb(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function xb(e){if(!vy.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return yb(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Sb=X(`$ZodBase64URL`,(e,t)=>{t.pattern??=vy,$y.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{xb(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Cb=X(`$ZodE164`,(e,t)=>{t.pattern??=by,$y.init(e,t)});function wb(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Tb=X(`$ZodJWT`,(e,t)=>{$y.init(e,t),e._zod.check=n=>{wb(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Eb=X(`$ZodNumber`,(e,t)=>{Zy.init(e,t),e._zod.pattern=e._zod.bag.pattern??Oy,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Db=X(`$ZodNumberFormat`,(e,t)=>{Ly.init(e,t),Eb.init(e,t)}),Ob=X(`$ZodBoolean`,(e,t)=>{Zy.init(e,t),e._zod.pattern=ky,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),kb=X(`$ZodAny`,(e,t)=>{Zy.init(e,t),e._zod.parse=e=>e}),Ab=X(`$ZodUnknown`,(e,t)=>{Zy.init(e,t),e._zod.parse=e=>e}),jb=X(`$ZodNever`,(e,t)=>{Zy.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Mb(e,t,n){e.issues.length&&t.issues.push(...jv(n,e.issues)),t.value[n]=e.value}var Nb=X(`$ZodArray`,(e,t)=>{Zy.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;eMb(t,n,e))):Mb(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Pb(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...jv(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Fb(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=bv(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ib(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Pb(e,n,i,t,u,d))):Pb(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Lb=X(`$ZodObject`,(e,t)=>{if(Zy.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=tv(()=>Fb(t));ov(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=fv,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Pb(n,t,e,s,r,i))):Pb(a,t,e,s,r,i)}return i?Ib(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Rb=X(`$ZodObjectJIT`,(e,t)=>{Lb.init(e,t);let n=e._zod.parse,r=tv(()=>Fb(t)),i=e=>{let t=new Yy([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=lv(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=lv(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(` if (${n}.issues.length) { if (${o} in input) { payload.issues = payload.issues.concat(${n}.issues.map(iss => ({ ...iss, path: iss.path ? [${o}, ...iss.path] : [${o}] }))); } } if (${n}.value === undefined) { if (${o} in input) { newResult[${o}] = undefined; } } else { newResult[${o}] = ${n}.value; } `):c?t.write(` if (${n}.issues.length) { payload.issues = payload.issues.concat(${n}.issues.map(iss => ({ ...iss, path: iss.path ? [${o}, ...iss.path] : [${o}] }))); } if (${n}.value === undefined) { if (${o} in input) { newResult[${o}] = undefined; } } else { newResult[${o}] = ${n}.value; } `):t.write(` const ${n}_present = ${o} in input; if (${n}.issues.length) { payload.issues = payload.issues.concat(${n}.issues.map(iss => ({ ...iss, path: iss.path ? [${o}, ...iss.path] : [${o}] }))); } if (!${n}_present && !${n}.issues.length) { payload.issues.push({ code: "invalid_type", expected: "nonoptional", input: undefined, path: [${o}] }); } if (${n}_present) { if (${n}.value === undefined) { newResult[${o}] = undefined; } else { newResult[${o}] = ${n}.value; } } `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=fv,s=!Z_.jitless,c=s&&pv.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Ib([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function zb(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!kv(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Nv(e,r,Q_())))}),t)}var Bb=X(`$ZodUnion`,(e,t)=>{Zy.init(e,t),ov(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),ov(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),ov(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),ov(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>rv(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>zb(t,r,e,i)):zb(o,r,e,i)}}),Vb=X(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Bb.init(e,t);let n=e._zod.parse;ov(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=tv(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!fv(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Hb=X(`$ZodIntersection`,(e,t)=>{Zy.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Wb(e,t,n)):Wb(e,i,a)}});function Ub(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(mv(e)&&mv(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ub(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;re.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),kv(e))return e;let o=Ub(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Gb=X(`$ZodRecord`,(e,t)=>{Zy.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!mv(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Nv(e,r,Q_())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...jv(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...jv(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Oy.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Nv(e,r,Q_())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...jv(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...jv(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Kb=X(`$ZodEnum`,(e,t)=>{Zy.init(e,t);let n=$_(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>gv.has(typeof e)).map(e=>typeof e==`string`?_v(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),qb=X(`$ZodLiteral`,(e,t)=>{if(Zy.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?_v(e):e?_v(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Jb=X(`$ZodTransform`,(e,t)=>{Zy.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new X_(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Y_;return n.value=i,n.fallback=!0,n}});function Yb(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Xb=X(`$ZodOptional`,(e,t)=>{Zy.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,ov(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ov(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${rv(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Yb(e,r)):Yb(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Zb=X(`$ZodExactOptional`,(e,t)=>{Xb.init(e,t),ov(e._zod,`values`,()=>t.innerType._zod.values),ov(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Qb=X(`$ZodNullable`,(e,t)=>{Zy.init(e,t),ov(e._zod,`optin`,()=>t.innerType._zod.optin),ov(e._zod,`optout`,()=>t.innerType._zod.optout),ov(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${rv(e.source)}|null)$`):void 0}),ov(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),$b=X(`$ZodDefault`,(e,t)=>{Zy.init(e,t),e._zod.optin=`optional`,ov(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ex(e,t)):ex(r,t)}});function ex(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var tx=X(`$ZodPrefault`,(e,t)=>{Zy.init(e,t),e._zod.optin=`optional`,ov(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),nx=X(`$ZodNonOptional`,(e,t)=>{Zy.init(e,t),ov(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>rx(t,e)):rx(i,e)}});function rx(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var ix=X(`$ZodCatch`,(e,t)=>{Zy.init(e,t),e._zod.optin=`optional`,ov(e._zod,`optout`,()=>t.innerType._zod.optout),ov(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Nv(e,n,Q_()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Nv(e,n,Q_()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ax=X(`$ZodPipe`,(e,t)=>{Zy.init(e,t),ov(e._zod,`values`,()=>t.in._zod.values),ov(e._zod,`optin`,()=>t.in._zod.optin),ov(e._zod,`optout`,()=>t.out._zod.optout),ov(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ox(e,t.in,n)):ox(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ox(e,t.out,n)):ox(r,t.out,n)}});function ox(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var sx=X(`$ZodReadonly`,(e,t)=>{Zy.init(e,t),ov(e._zod,`propValues`,()=>t.innerType._zod.propValues),ov(e._zod,`values`,()=>t.innerType._zod.values),ov(e._zod,`optin`,()=>t.innerType?._zod?.optin),ov(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(cx):cx(r)}});function cx(e){return e.value=Object.freeze(e.value),e}var lx=X(`$ZodCustom`,(e,t)=>{My.init(e,t),Zy.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ux(t,n,r,e));ux(i,n,r,e)}});function ux(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Fv(e))}}var dx,fx=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function px(){return new fx}(dx=globalThis).__zod_globalRegistry??(dx.__zod_globalRegistry=px());var mx=globalThis.__zod_globalRegistry;function hx(e,t){return new e({type:`string`,...yv(t)})}function gx(e,t){return new e({type:`string`,coerce:!0,...yv(t)})}function _x(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...yv(t)})}function vx(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...yv(t)})}function yx(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...yv(t)})}function bx(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...yv(t)})}function xx(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...yv(t)})}function Sx(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...yv(t)})}function Cx(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...yv(t)})}function wx(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...yv(t)})}function Tx(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...yv(t)})}function Ex(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...yv(t)})}function Dx(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...yv(t)})}function Ox(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...yv(t)})}function kx(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...yv(t)})}function Ax(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...yv(t)})}function jx(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...yv(t)})}function Mx(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...yv(t)})}function Nx(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...yv(t)})}function Px(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...yv(t)})}function Fx(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...yv(t)})}function Ix(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...yv(t)})}function Lx(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...yv(t)})}function Rx(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...yv(t)})}function zx(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...yv(t)})}function Bx(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...yv(t)})}function Vx(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...yv(t)})}function Hx(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...yv(t)})}function Ux(e,t){return new e({type:`number`,checks:[],...yv(t)})}function Wx(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...yv(t)})}function Gx(e,t){return new e({type:`boolean`,...yv(t)})}function Kx(e){return new e({type:`any`})}function qx(e){return new e({type:`unknown`})}function Jx(e,t){return new e({type:`never`,...yv(t)})}function Yx(e,t){return new Py({check:`less_than`,...yv(t),value:e,inclusive:!1})}function Xx(e,t){return new Py({check:`less_than`,...yv(t),value:e,inclusive:!0})}function Zx(e,t){return new Fy({check:`greater_than`,...yv(t),value:e,inclusive:!1})}function Qx(e,t){return new Fy({check:`greater_than`,...yv(t),value:e,inclusive:!0})}function $x(e,t){return new Iy({check:`multiple_of`,...yv(t),value:e})}function eS(e,t){return new Ry({check:`max_length`,...yv(t),maximum:e})}function tS(e,t){return new zy({check:`min_length`,...yv(t),minimum:e})}function nS(e,t){return new By({check:`length_equals`,...yv(t),length:e})}function rS(e,t){return new Hy({check:`string_format`,format:`regex`,...yv(t),pattern:e})}function iS(e){return new Uy({check:`string_format`,format:`lowercase`,...yv(e)})}function aS(e){return new Wy({check:`string_format`,format:`uppercase`,...yv(e)})}function oS(e,t){return new Gy({check:`string_format`,format:`includes`,...yv(t),includes:e})}function sS(e,t){return new Ky({check:`string_format`,format:`starts_with`,...yv(t),prefix:e})}function cS(e,t){return new qy({check:`string_format`,format:`ends_with`,...yv(t),suffix:e})}function lS(e){return new Jy({check:`overwrite`,tx:e})}function uS(e){return lS(t=>t.normalize(e))}function dS(){return lS(e=>e.trim())}function fS(){return lS(e=>e.toLowerCase())}function pS(){return lS(e=>e.toUpperCase())}function mS(){return lS(e=>uv(e))}function hS(e,t,n){return new e({type:`array`,element:t,...yv(n)})}function gS(e,t,n){let r=yv(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function _S(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...yv(n)})}function vS(e,t){let n=yS(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Fv(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Fv(r))}},e(t.value,t)),t);return n}function yS(e,t){let n=new My({check:`custom`,...yv(t)});return n._zod.check=e,n}function bS(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??mx,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function xS(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,xS(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&wS(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function SS(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function CS(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ES(t,`input`,e.processors),output:ES(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function wS(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return wS(r.element,n);if(r.type===`set`)return wS(r.valueType,n);if(r.type===`lazy`)return wS(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return wS(r.innerType,n);if(r.type===`intersection`)return wS(r.left,n)||wS(r.right,n);if(r.type===`record`||r.type===`map`)return wS(r.keyType,n)||wS(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:wS(r.in,n)||wS(r.out,n);if(r.type===`object`){for(let e in r.shape)if(wS(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(wS(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(wS(e,n))return!0;return!!(r.rest&&wS(r.rest,n))}return!1}var TS=(e,t={})=>n=>{let r=bS({...n,processors:t});return xS(e,r),SS(r,e),CS(r,e)},ES=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=bS({...i??{},target:a,io:t,processors:n});return xS(e,o),SS(o,e),CS(o,e)},DS={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},OS=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=DS[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},kS=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},AS=(e,t,n,r)=>{n.type=`boolean`},jS=(e,t,n,r)=>{n.not={}},MS=(e,t,n,r)=>{let i=e._zod.def,a=$_(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},NS=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},PS=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},FS=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},IS=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=xS(a.element,t,{...r,path:[...r.path,`items`]})},LS=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=xS(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=xS(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},RS=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>xS(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zS=(e,t,n,r)=>{let i=e._zod.def,a=xS(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=xS(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},BS=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=xS(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=xS(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=xS(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},VS=(e,t,n,r)=>{let i=e._zod.def,a=xS(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},HS=(e,t,n,r)=>{let i=e._zod.def;xS(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},US=(e,t,n,r)=>{let i=e._zod.def;xS(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},WS=(e,t,n,r)=>{let i=e._zod.def;xS(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},GS=(e,t,n,r)=>{let i=e._zod.def;xS(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},KS=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;xS(o,t,r);let s=t.seen.get(e);s.ref=o},qS=(e,t,n,r)=>{let i=e._zod.def;xS(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},JS=(e,t,n,r)=>{let i=e._zod.def;xS(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},YS=X(`ZodISODateTime`,(e,t)=>{db.init(e,t),SC.init(e,t)});function XS(e){return zx(YS,e)}var ZS=X(`ZodISODate`,(e,t)=>{fb.init(e,t),SC.init(e,t)});function QS(e){return Bx(ZS,e)}var $S=X(`ZodISOTime`,(e,t)=>{pb.init(e,t),SC.init(e,t)});function eC(e){return Vx($S,e)}var tC=X(`ZodISODuration`,(e,t)=>{mb.init(e,t),SC.init(e,t)});function nC(e){return Hx(tC,e)}var rC=X(`ZodError`,(e,t)=>{Lv.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Bv(e,t)},flatten:{value:t=>zv(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ev,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ev,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),iC=Vv(rC),aC=Hv(rC),oC=Uv(rC),sC=Gv(rC),cC=qv(rC),lC=Jv(rC),uC=Yv(rC),dC=Xv(rC),fC=Zv(rC),pC=Qv(rC),mC=$v(rC),hC=ey(rC),gC=new WeakMap;function _C(e,t,n){let r=Object.getPrototypeOf(e),i=gC.get(r);if(i||(i=new Set,gC.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var vC=X(`ZodType`,(e,t)=>(Zy.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ES(e,`input`),output:ES(e,`output`)}}),e.toJSONSchema=TS(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>iC(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>oC(e,t,n),e.parseAsync=async(t,n)=>aC(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>sC(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>cC(e,t,n),e.decode=(t,n)=>lC(e,t,n),e.encodeAsync=async(t,n)=>uC(e,t,n),e.decodeAsync=async(t,n)=>dC(e,t,n),e.safeEncode=(t,n)=>fC(e,t,n),e.safeDecode=(t,n)=>pC(e,t,n),e.safeEncodeAsync=async(t,n)=>mC(e,t,n),e.safeDecodeAsync=async(t,n)=>hC(e,t,n),_C(e,`ZodType`,{check(...e){let t=this.def;return this.clone(cv(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return vv(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Rw(e,t))},superRefine(e,t){return this.check(zw(e,t))},overwrite(e){return this.check(lS(e))},optional(){return yw(this)},exactOptional(){return xw(this)},nullable(){return Cw(this)},nullish(){return yw(Cw(this))},nonoptional(e){return kw(this,e)},array(){return tw(this)},or(e){return aw([this,e])},and(e){return lw(this,e)},transform(e){return Nw(this,_w(e))},default(e){return Tw(this,e)},prefault(e){return Dw(this,e)},catch(e){return jw(this,e)},pipe(e){return Nw(this,e)},readonly(){return Fw(this)},describe(e){let t=this.clone();return mx.add(t,{description:e}),t},meta(...e){if(e.length===0)return mx.get(this);let t=this.clone();return mx.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return mx.get(e)?.description},configurable:!0}),e)),yC=X(`_ZodString`,(e,t)=>{Qy.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>OS(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,_C(e,`_ZodString`,{regex(...e){return this.check(rS(...e))},includes(...e){return this.check(oS(...e))},startsWith(...e){return this.check(sS(...e))},endsWith(...e){return this.check(cS(...e))},min(...e){return this.check(tS(...e))},max(...e){return this.check(eS(...e))},length(...e){return this.check(nS(...e))},nonempty(...e){return this.check(tS(1,...e))},lowercase(e){return this.check(iS(e))},uppercase(e){return this.check(aS(e))},trim(){return this.check(dS())},normalize(...e){return this.check(uS(...e))},toLowerCase(){return this.check(fS())},toUpperCase(){return this.check(pS())},slugify(){return this.check(mS())}})}),bC=X(`ZodString`,(e,t)=>{Qy.init(e,t),yC.init(e,t),e.email=t=>e.check(_x(CC,t)),e.url=t=>e.check(Cx(EC,t)),e.jwt=t=>e.check(Rx(VC,t)),e.emoji=t=>e.check(wx(DC,t)),e.guid=t=>e.check(vx(wC,t)),e.uuid=t=>e.check(yx(TC,t)),e.uuidv4=t=>e.check(bx(TC,t)),e.uuidv6=t=>e.check(xx(TC,t)),e.uuidv7=t=>e.check(Sx(TC,t)),e.nanoid=t=>e.check(Tx(OC,t)),e.guid=t=>e.check(vx(wC,t)),e.cuid=t=>e.check(Ex(kC,t)),e.cuid2=t=>e.check(Dx(AC,t)),e.ulid=t=>e.check(Ox(jC,t)),e.base64=t=>e.check(Fx(RC,t)),e.base64url=t=>e.check(Ix(zC,t)),e.xid=t=>e.check(kx(MC,t)),e.ksuid=t=>e.check(Ax(NC,t)),e.ipv4=t=>e.check(jx(PC,t)),e.ipv6=t=>e.check(Mx(FC,t)),e.cidrv4=t=>e.check(Nx(IC,t)),e.cidrv6=t=>e.check(Px(LC,t)),e.e164=t=>e.check(Lx(BC,t)),e.datetime=t=>e.check(XS(t)),e.date=t=>e.check(QS(t)),e.time=t=>e.check(eC(t)),e.duration=t=>e.check(nC(t))});function xC(e){return hx(bC,e)}var SC=X(`ZodStringFormat`,(e,t)=>{$y.init(e,t),yC.init(e,t)}),CC=X(`ZodEmail`,(e,t)=>{nb.init(e,t),SC.init(e,t)}),wC=X(`ZodGUID`,(e,t)=>{eb.init(e,t),SC.init(e,t)}),TC=X(`ZodUUID`,(e,t)=>{tb.init(e,t),SC.init(e,t)}),EC=X(`ZodURL`,(e,t)=>{rb.init(e,t),SC.init(e,t)}),DC=X(`ZodEmoji`,(e,t)=>{ib.init(e,t),SC.init(e,t)}),OC=X(`ZodNanoID`,(e,t)=>{ab.init(e,t),SC.init(e,t)}),kC=X(`ZodCUID`,(e,t)=>{ob.init(e,t),SC.init(e,t)}),AC=X(`ZodCUID2`,(e,t)=>{sb.init(e,t),SC.init(e,t)}),jC=X(`ZodULID`,(e,t)=>{cb.init(e,t),SC.init(e,t)}),MC=X(`ZodXID`,(e,t)=>{lb.init(e,t),SC.init(e,t)}),NC=X(`ZodKSUID`,(e,t)=>{ub.init(e,t),SC.init(e,t)}),PC=X(`ZodIPv4`,(e,t)=>{hb.init(e,t),SC.init(e,t)}),FC=X(`ZodIPv6`,(e,t)=>{gb.init(e,t),SC.init(e,t)}),IC=X(`ZodCIDRv4`,(e,t)=>{_b.init(e,t),SC.init(e,t)}),LC=X(`ZodCIDRv6`,(e,t)=>{vb.init(e,t),SC.init(e,t)}),RC=X(`ZodBase64`,(e,t)=>{bb.init(e,t),SC.init(e,t)}),zC=X(`ZodBase64URL`,(e,t)=>{Sb.init(e,t),SC.init(e,t)}),BC=X(`ZodE164`,(e,t)=>{Cb.init(e,t),SC.init(e,t)}),VC=X(`ZodJWT`,(e,t)=>{Tb.init(e,t),SC.init(e,t)}),HC=X(`ZodNumber`,(e,t)=>{Eb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kS(e,t,n,r),_C(e,`ZodNumber`,{gt(e,t){return this.check(Zx(e,t))},gte(e,t){return this.check(Qx(e,t))},min(e,t){return this.check(Qx(e,t))},lt(e,t){return this.check(Yx(e,t))},lte(e,t){return this.check(Xx(e,t))},max(e,t){return this.check(Xx(e,t))},int(e){return this.check(GC(e))},safe(e){return this.check(GC(e))},positive(e){return this.check(Zx(0,e))},nonnegative(e){return this.check(Qx(0,e))},negative(e){return this.check(Yx(0,e))},nonpositive(e){return this.check(Xx(0,e))},multipleOf(e,t){return this.check($x(e,t))},step(e,t){return this.check($x(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function UC(e){return Ux(HC,e)}var WC=X(`ZodNumberFormat`,(e,t)=>{Db.init(e,t),HC.init(e,t)});function GC(e){return Wx(WC,e)}var KC=X(`ZodBoolean`,(e,t)=>{Ob.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AS(e,t,n,r)});function qC(e){return Gx(KC,e)}var JC=X(`ZodAny`,(e,t)=>{kb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function YC(){return Kx(JC)}var XC=X(`ZodUnknown`,(e,t)=>{Ab.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ZC(){return qx(XC)}var QC=X(`ZodNever`,(e,t)=>{jb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jS(e,t,n,r)});function $C(e){return Jx(QC,e)}var ew=X(`ZodArray`,(e,t)=>{Nb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>IS(e,t,n,r),e.element=t.element,_C(e,`ZodArray`,{min(e,t){return this.check(tS(e,t))},nonempty(e){return this.check(tS(1,e))},max(e,t){return this.check(eS(e,t))},length(e,t){return this.check(nS(e,t))},unwrap(){return this.element}})});function tw(e,t){return hS(ew,e,t)}var nw=X(`ZodObject`,(e,t)=>{Rb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>LS(e,t,n,r),ov(e,`shape`,()=>t.shape),_C(e,`ZodObject`,{keyof(){return pw(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:ZC()})},loose(){return this.clone({...this._zod.def,catchall:ZC()})},strict(){return this.clone({...this._zod.def,catchall:$C()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return wv(this,e)},safeExtend(e){return Tv(this,e)},merge(e){return Ev(this,e)},pick(e){return Sv(this,e)},omit(e){return Cv(this,e)},partial(...e){return Dv(vw,this,e[0])},required(...e){return Ov(Ow,this,e[0])}})});function rw(e,t){return new nw({type:`object`,shape:e??{},...yv(t)})}var iw=X(`ZodUnion`,(e,t)=>{Bb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>RS(e,t,n,r),e.options=t.options});function aw(e,t){return new iw({type:`union`,options:e,...yv(t)})}var ow=X(`ZodDiscriminatedUnion`,(e,t)=>{iw.init(e,t),Vb.init(e,t)});function sw(e,t,n){return new ow({type:`union`,options:t,discriminator:e,...yv(n)})}var cw=X(`ZodIntersection`,(e,t)=>{Hb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zS(e,t,n,r)});function lw(e,t){return new cw({type:`intersection`,left:e,right:t})}var uw=X(`ZodRecord`,(e,t)=>{Gb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>BS(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function dw(e,t,n){return!t||!t._zod?new uw({type:`record`,keyType:xC(),valueType:e,...yv(t)}):new uw({type:`record`,keyType:e,valueType:t,...yv(n)})}var fw=X(`ZodEnum`,(e,t)=>{Kb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>MS(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new fw({...t,checks:[],...yv(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new fw({...t,checks:[],...yv(r),entries:i})}});function pw(e,t){return new fw({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...yv(t)})}var mw=X(`ZodLiteral`,(e,t)=>{qb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>NS(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function hw(e,t){return new mw({type:`literal`,values:Array.isArray(e)?e:[e],...yv(t)})}var gw=X(`ZodTransform`,(e,t)=>{Jb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>FS(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new X_(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Fv(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Fv(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function _w(e){return new gw({type:`transform`,transform:e})}var vw=X(`ZodOptional`,(e,t)=>{Xb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JS(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yw(e){return new vw({type:`optional`,innerType:e})}var bw=X(`ZodExactOptional`,(e,t)=>{Zb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JS(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xw(e){return new bw({type:`optional`,innerType:e})}var Sw=X(`ZodNullable`,(e,t)=>{Qb.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>VS(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cw(e){return new Sw({type:`nullable`,innerType:e})}var ww=X(`ZodDefault`,(e,t)=>{$b.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>US(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Tw(e,t){return new ww({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():hv(t)}})}var Ew=X(`ZodPrefault`,(e,t)=>{tx.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>WS(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dw(e,t){return new Ew({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():hv(t)}})}var Ow=X(`ZodNonOptional`,(e,t)=>{nx.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>HS(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kw(e,t){return new Ow({type:`nonoptional`,innerType:e,...yv(t)})}var Aw=X(`ZodCatch`,(e,t)=>{ix.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GS(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jw(e,t){return new Aw({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Mw=X(`ZodPipe`,(e,t)=>{ax.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KS(e,t,n,r),e.in=t.in,e.out=t.out});function Nw(e,t){return new Mw({type:`pipe`,in:e,out:t})}var Pw=X(`ZodReadonly`,(e,t)=>{sx.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qS(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fw(e){return new Pw({type:`readonly`,innerType:e})}var Iw=X(`ZodCustom`,(e,t)=>{lx.init(e,t),vC.init(e,t),e._zod.processJSONSchema=(t,n,r)=>PS(e,t,n,r)});function Lw(e,t){return gS(Iw,e??(()=>!0),t)}function Rw(e,t={}){return _S(Iw,e,t)}function zw(e,t){return vS(e,t)}function Bw(e,t={}){let n=new Iw({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...yv(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function Vw(e){return gx(bC,e)}function Hw(){return Lw(e=>typeof e==`function`)}function Uw(e,t){return function(n){return n.refine(n=>{let r=n;return r[e]===void 0!=(r[t]===void 0)},{message:`Either ${e} or ${t} must be used, but not both.`,path:[t]})}}function Ww(){return function(e){return e}}function Gw(e,t){let n=e.safeParse(t);if(!n.success)throw new _e({errorLevel:B.CRITICAL,effect:`Failed to run function due to invalid arguments. Check that the arguments that you are passing to the function match the type definition of the function.`,cause:n.error})}function Kw(e,t){return e.safeParse(t)}var qw=[`zeroth`,`first`,`second`,`third`,`fourth`,`fifth`,`sixth`,`seventh`,`eighth`,`ninth`,`tenth`,`eleventh`,`twelfth`,`thirteenth`,`fourteenth`,`fifteenth`,`sixteenth`,`seventeenth`,`eighteenth`,`nineteenth`],Jw=[`twent`,`thirt`,`fort`,`fift`,`sixt`,`sevent`,`eight`,`ninet`];function Yw(e){return e<20?qw[e]:e%10==0?Jw[Math.floor(e/10)-2]+`ieth`:Jw[Math.floor(e/10)-2]+`y-`+qw[e%10]}function Xw(e){let t=``;for(let n of e.issues){let e=Zw(n.path);t+=`✖ ${n.message??n.code} \n → at '${e}'\n`}return t.trim()}function Zw(e){return!e||e.length===0?`unknown location`:e.map(e=>typeof e==`string`?e:typeof e==`symbol`?e.toString():Yw(e+1)+` element`).join(` > `)}function Qw(e,t,n){return UC({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' fields to be a number, but got ${typeof r.input}.`})}function $w(e,t,n){return xC({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' fields to be a string, but got ${typeof r.input}.`})}function eT(e,t,n){return Vw({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' fields to be a string, but got ${typeof r.input}.`})}function tT(e,t,n){return qC({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' fields to be a boolean, but got ${typeof r.input}.`})}var nT=Ww()(rw({type:hw(Lt.COMMAND),command:$w(`command`,`command`,`command to run`)})),rT=Ww()(rw({type:hw(Lt.JS),file:$w(`js`,`file`,`file path to the file to run`),args:dw(xC(),ZC()).optional()})),iT=Ww()(rw({type:hw(Lt.OPEN),link:$w(`open`,`link`,`link to open`),newTab:tT(`open`,`newTab`,``).optional()})),aT=Ww()(rw({type:hw(Lt.INPUT),str:$w(`input`,`str`,`value to input`)})),oT=Ww()(rw({type:hw(Lt.SLEEP),ms:Qw(`sleep`,`ms`,`duration`)})),sT=Ww()(rw({type:hw(Lt.TEMPLATER_CREATE_NOTE),templateFile:$w(`templaterCreateNote`,`templateFile`,`template file path`),folderPath:$w(`templaterCreateNote`,`folderPath`,`folder path`).optional(),fileName:$w(`templaterCreateNote`,`fileName`,`file name`).optional(),openNote:tT(`templaterCreateNote`,`openNote`,`value for whether to open the note`).optional(),openIfAlreadyExists:tT(`templaterCreateNote`,`openIfAlreadyExists`,`value for whether to open the note if it already exists`).optional()})),cT=Ww()(rw({type:hw(Lt.RUN_TEMPLATER_FILE),templateFile:$w(`runTemplaterFile`,`templateFile`,`template file path`)})),lT=Ww()(rw({type:hw(Lt.UPDATE_METADATA),bindTarget:$w(`updateMetadata`,`bindTarget`,`bind target to the metadata to update`),evaluate:tT(`updateMetadata`,`evaluate`,`value for whether to evaluate the value as a JavaScript expression`),value:eT(`updateMetadata`,`value for the update`,`value`)})),uT=Ww()(rw({type:hw(Lt.CREATE_NOTE),folderPath:$w(`createNote`,`folderPath`,`folder path`).optional(),fileName:$w(`createNote`,`fileName`,`file name`),openNote:tT(`createNote`,`openNote`,`value for whether to open the note`).optional(),openIfAlreadyExists:tT(`createNote`,`openIfAlreadyExists`,`value for whether to open the note if it already exists`).optional()})),dT=Ww()(rw({type:hw(Lt.REPLACE_IN_NOTE),fromLine:eT(`replaceInNote`,`fromLine`,`line to replace from`),toLine:eT(`replaceInNote`,`toLine`,`line to replace to`),replacement:$w(`replaceInNote`,`replacement`,`replacement string`),templater:tT(`replaceInNote`,`templater`,`value for whether to use Templater`).optional()})),fT=Ww()(rw({type:hw(Lt.REPLACE_SELF),replacement:$w(`replaceSelf`,`replacement`,`replacement string`),templater:tT(`replaceSelf`,`templater`,`value for whether to use Templater`).optional()})),pT=Ww()(rw({type:hw(Lt.REGEXP_REPLACE_IN_NOTE),regexp:$w(`regexpReplaceInNote`,`regexp`,`search regular expression`),regexpFlags:$w(`regexpReplaceInNote`,`regexpFlags`,`regular expression flags string`).optional(),replacement:$w(`regexpReplaceInNote`,`replacement`,`replacement string`)})),mT=Ww()(rw({type:hw(Lt.INSERT_INTO_NOTE),line:eT(`insertIntoNote`,`line`,`line to insert at`),value:$w(`insertIntoNote`,`value`,`string to insert`),templater:tT(`insertIntoNote`,`templater`,`value for whether to use Templater`).optional()})),hT=Ww()(rw({type:hw(Lt.INLINE_JS),code:$w(`inlineJS`,`code`,`code string to run`),args:dw(xC(),ZC()).optional()})),gT=Ww()(sw(`type`,[nT,rT,iT,aT,oT,sT,lT,uT,dT,fT,pT,mT,hT,cT])),_T=pw(It),vT=Ww()(Uw(`action`,`actions`)(rw({label:xC(),icon:xC().optional(),style:_T,class:xC().optional(),cssStyle:xC().optional(),backgroundImage:xC().optional(),tooltip:xC().optional(),id:xC().optional(),hidden:qC().optional(),action:gT.optional(),actions:gT.array().optional()}))),yT=P.sequenceMap((e,t)=>t,P.string(`BUTTON`),P.manyNotOf(`[],^`).separateBy(P.string(`,`).trim(z.optionalWhitespace())).wrapString(`[`,`]`)),bT=class{mb;constructor(e){this.mb=e}fromGroupString(e){let t=new Tn(`ButtonGroup`),n=[];try{n=De(yT,e)}catch(e){t.add(e)}return{declarationString:e,referencedButtonIds:n,errorCollection:t}}validateGroup(e){return{declarationString:void 0,referencedButtonIds:e.referencedButtonIds,errorCollection:new Tn(`ButtonGroup`)}}fromString(e){let t=new Tn(`Button`),n;try{let t=this.mb.internal.parseYaml(e);n=this.validateConfig(t)}catch(e){t.add(e)}return{declarationString:e,config:n,errorCollection:t}}validateConfig(e){let t=Kw(vT,e);if(!t.success){let e=Xw(t.error);throw new Te({errorLevel:B.ERROR,effect:`The validation for the button config failed.`,cause:`Your button syntax seems to be invalid. Check that your button config follows what is described in the docs.`,positionContext:e,docs:[o_.linkToButtonConfig()]})}return t.data}validate(e){let t=new Tn(`Button`),n;try{n=this.validateConfig(e)}catch(e){t.add(e)}return{declarationString:void 0,config:n,errorCollection:t}}},xT=class{arguments=[];add(e){this.arguments.push(e)}validate(){let e={};for(let t of Object.values(kn))e[t]=0;for(let t of this.arguments){let n=t.getConfig();if(e[n.type]+=1,e[n.type]>1&&!n.allowMultiple)throw new xe({errorLevel:B.ERROR,effect:`failed to validate argument container`,cause:`argument '${n.type}' does not allow duplicates`,docs:[o_.linkToSearch(n.type)]})}}mergeByOverride(e){for(let t of e.arguments){let e=t.getConfig();e.allowMultiple||(this.arguments=this.arguments.filter(t=>t.getConfig().type!==e.type)),this.arguments.push(t)}return this.validate(),this}mergeByThrow(e){for(let t of e.arguments){let e=t.getConfig();if(!e.allowMultiple&&this.arguments.filter(t=>t.getConfig().type===e.type).length>0)throw new xe({errorLevel:B.ERROR,effect:`failed to merge argument container`,cause:`can not merge FieldArgumentContainers, since arguments overlap`});this.arguments.push(t)}return this.validate(),this}getAll(e){return this.arguments.filter(t=>t.getConfig().type===e)}get(e){return this.getAll(e).at(0)}},ST=class extends xT{getAll(e){return super.getAll(e)}get(e){return this.getAll(e).at(0)}},CT=class{value;parseValue(e){this.validateValues(e,this.getConfig().values),this._parseValue(e)}validateValues(e,t){if(t.find(t=>t.length===e.length)===void 0)throw new xe({errorLevel:B.WARNING,effect:`Failed to parse argument value for argument '${this.getConfig().type}'.`,cause:`Expected argument values to follow the form ${t.map(e=>e.length===0?`none`:e.map(e=>`'${e.name}'`).join(`, `)).join(` or `)}. Received arguments of length ${e.length}.`,docs:[o_.linkToSearch(this.getConfig().type)]})}isAllowed(e){return this.getConfig().allowedFieldTypes.length===0?!0:this.getConfig().allowedFieldTypes.includes(e)}getAllowedFieldsAsString(){return this.getConfig().allowedFieldTypes.length===0?`all`:this.getConfig().allowedFieldTypes.join(`, `)}},wT=class extends CT{},TT=class extends wT{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.addLabels}},ET=class extends wT{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.allowOther}},DT=class extends wT{value=[];_parseValue(e){this.value=e[0].value.split(` `)}getConfig(){return Mn.class}},OT=class extends wT{value=``;_parseValue(e){this.value=fn(e[0].value)}getConfig(){return Mn.defaultValue}},kT=class extends wT{value=void 0;_parseValue(e){if(this.value=Number.parseInt(e[0].value),Number.isNaN(this.value))throw new xe({errorLevel:B.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'limit' must be of type number`,docs:[o_.linkToInputFieldArgument(this.getConfig().type)]});if(this.value<=0)throw new xe({errorLevel:B.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'limit' must be a positive number`,docs:[o_.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.limit}},AT=class extends wT{value=100;_parseValue(e){if(this.value=Number.parseFloat(e[0].value),Number.isNaN(this.value))throw new xe({errorLevel:B.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'maxValue' must be of type number`,docs:[o_.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.maxValue}},jT=class extends wT{value=0;_parseValue(e){if(this.value=Number.parseFloat(e[0].value),Number.isNaN(this.value))throw new xe({errorLevel:B.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'minValue' must be of type number`,docs:[o_.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.minValue}},MT=class extends wT{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.multiLine}},NT=class extends wT{value=!1;_parseValue(e){this.value=fn(e[0].value)}getConfig(){return Mn.offValue}},PT=class extends wT{value=!0;_parseValue(e){this.value=fn(e[0].value)}getConfig(){return Mn.onValue}},FT=class extends wT{value=``;name=``;_parseValue(e){e.length===1?(this.value=fn(e[0].value),this.name=e[0].value):e.length===2&&(this.value=fn(e[0].value),this.name=e[1].value)}getConfig(){return Mn.option}},IT=class extends wT{value=``;_parseValue(e){this.value=e[0].value}getConfig(){return Mn.optionQuery}},LT=class extends wT{value=``;_parseValue(e){this.value=e[0].value}getConfig(){return Mn.placeholder}},RT=class extends wT{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.showcase}},zT=class extends wT{value=0;_parseValue(e){if(this.value=Number.parseFloat(e[0].value),Number.isNaN(this.value))throw new xe({errorLevel:B.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'stepSize' must be of type number`,docs:[o_.linkToInputFieldArgument(this.getConfig().type)]});if(this.value<=0)throw new xe({errorLevel:B.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'stepSize' must be a positive number`,docs:[o_.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.stepSize}},BT=class extends wT{value=``;_parseValue(e){this.value=e[0].value}getConfig(){return Mn.title}};function VT(e,t,n){return n===jn.TRUE?`[[${e}|${t}]]`:n===jn.PARTIAL?`[[${t}]]`:`${t}`}var HT=class extends wT{value=jn.TRUE;_parseValue(e){let t=e[0]?.value.toLowerCase();if(t===void 0){this.value=jn.TRUE;return}if(t===jn.TRUE||t===jn.PARTIAL||t===jn.FALSE){this.value=t;return}throw new xe({errorLevel:B.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'useLinks' must be one of ${D([jn.TRUE,jn.PARTIAL,jn.FALSE],e=>`'${e}'`,`, `,`or`)}`,docs:[o_.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.useLinks}},UT={[kn.CLASS]:DT,[kn.ADD_LABELS]:TT,[kn.MIN_VALUE]:jT,[kn.MAX_VALUE]:AT,[kn.STEP_SIZE]:zT,[kn.OPTION]:FT,[kn.TITLE]:BT,[kn.OPTION_QUERY]:IT,[kn.SHOWCASE]:RT,[kn.OFF_VALUE]:NT,[kn.ON_VALUE]:PT,[kn.DEFAULT_VALUE]:OT,[kn.PLACEHOLDER]:LT,[kn.USE_LINKS]:HT,[kn.LIMIT]:kT,[kn.ALLOW_OTHER]:ET,[kn.MULTI_LINE]:MT},WT=class{static createInputFieldArgument(e){if(e in UT){let t=UT[e];if(t)return new t}throw new ve({errorLevel:B.WARNING,effect:`can not crate input field argument`,cause:`unknown argument '${e}'`})}},GT=class{unvalidatedDeclaration;errorCollection;filePath;mb;constructor(e,t,n){this.mb=e,this.unvalidatedDeclaration=t,this.filePath=n,this.errorCollection=new Tn(`input field declaration`)}validate(e){let t=this.validateInputFieldType(),n=this.validateBindTarget(e),r=this.validateArguments(t),i={declarationString:this.unvalidatedDeclaration.declarationString,inputFieldType:t,bindTarget:n,argumentContainer:r,errorCollection:this.errorCollection.merge(this.unvalidatedDeclaration.errorCollection)};return this.checkForDeprecation(i),i}validateInputFieldType(){let e=this.unvalidatedDeclaration.inputFieldType;for(let t of Object.entries(On))if(t[1]===e?.value)return t[1];return this.errorCollection.add(new ke(B.ERROR,`Declaration Validator`,`Encountered invalid identifier. Expected an input field type but received '${e?.value}'.`,this.unvalidatedDeclaration.declarationString,e?.position)),On.INVALID}checkForDeprecation(e){}validateBindTarget(e){if(this.unvalidatedDeclaration.bindTarget!==void 0)try{return this.mb.bindTargetParser.validate(this.unvalidatedDeclaration.declarationString,this.unvalidatedDeclaration.bindTarget,this.filePath,e)}catch(e){this.errorCollection.add(e)}}validateArguments(e){let t=new ST;for(let n of this.unvalidatedDeclaration.arguments){let r=this.validateArgumentType(n.name);if(r===kn.INVALID)continue;let i=WT.createInputFieldArgument(r);if(!i.isAllowed(e)){this.errorCollection.add(new ke(B.WARNING,`Declaration Validator`,`Failed to parse input field arguments. Argument "${n.name.value}" is only applicable to "${i.getAllowedFieldsAsString()}" input fields.`,this.unvalidatedDeclaration.declarationString,n.name.position));continue}try{i.parseValue(n.value)}catch(e){this.errorCollection.add(e);continue}t.add(i)}try{t.validate()}catch(e){this.errorCollection.add(e)}return t}validateArgumentType(e){for(let t of Object.entries(kn))if(t[1]===e.value)return t[1];return this.errorCollection.add(new ke(B.WARNING,`Declaration Validator`,`Encountered invalid identifier. Expected an input field argument type but received '${e.value}'.`,this.unvalidatedDeclaration.declarationString,e.position)),kn.INVALID}},KT=P.sequenceMap((e,t,n)=>({inputFieldType:e,arguments:t,bindTarget:n===void 0?void 0:n[1]}),Ae.node(Le).trim(z.optionalWhitespace()).describe(`input field type`),et.trim(z.optionalWhitespace()).wrap(P.string(`(`).describe(`arguments paren "("`),P.string(`)`).describe(`arguments paren ")"`)).trim(z.optionalWhitespace()).optional([]),P.sequence(P.string(`:`).trim(z.optionalWhitespace()).describe(`bind target separator ":"`),Ye).trim(z.optionalWhitespace()).optional()),qT=P.sequenceMap((e,t,n)=>({inputFieldType:e,arguments:t,bindTarget:n===void 0?void 0:n[1]}),Ae.node(Le).trim(z.optionalWhitespace()).optional().describe(`input field type`),et.trim(z.optionalWhitespace()).wrap(P.string(`(`).describe(`arguments paren "("`),P.string(`)`).describe(`arguments paren ")"`)).trim(z.optionalWhitespace()).optional([]),P.sequence(P.string(`:`).trim(z.optionalWhitespace()).describe(`bind target separator ":"`),Ye).trim(z.optionalWhitespace()).optional()),JT=P.or(P.sequenceMap((e,t,n)=>(n.templateName=t,n),P.string(`INPUT`),P.sequenceMap((e,t,n)=>t,P.string(`[`),je.node(Le).trim(z.optionalWhitespace()).describe(`template name`),P.string(`]`).skip(z.optionalWhitespace())),qT.wrap(P.string(`[`),P.string(`]`)),z.eof()),P.sequenceMap((e,t)=>t,P.string(`INPUT`),KT.wrap(P.string(`[`),P.string(`]`)),z.eof())),YT=P.sequenceMap((e,t)=>t,P.string(`INPUT`),qT.wrap(P.string(`[`),P.string(`]`)),z.eof()),XT=class{mb;templates;constructor(e){this.mb=e,this.templates=[]}fromString(e){let t=new Tn(`InputField`);try{let n=De(JT,e),r=this.partialToFullDeclaration(n,e,t);return r=this.applyTemplate(r),r}catch(e){t.add(e)}return{declarationString:e,inputFieldType:{value:On.INVALID},bindTarget:void 0,arguments:[],errorCollection:t}}fromStringAndValidate(e,t,n){return this.validate(this.fromString(e),t,n)}fromSimpleDeclaration(e){return{declarationString:void 0,inputFieldType:Re(e.inputFieldType),bindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.bindTarget),arguments:(e.arguments??[]).map(e=>({name:Re(e.name),value:e.value.map(e=>Re(e))})),errorCollection:new Tn(`InputField`)}}fromSimpleDeclarationAndValidate(e,t,n){return this.validate(this.fromSimpleDeclaration(e),t,n)}partialToFullDeclaration(e,t,n){return{...structuredClone(e),declarationString:t,errorCollection:n}}validate(e,t,n){return new GT(this.mb,e,t).validate(n)}merge(e,t){let n;return e.bindTarget===void 0?n=t.bindTarget:(n=e.bindTarget,t.bindTarget?.storagePath!==void 0&&(n.storagePath=t.bindTarget.storagePath),t.bindTarget?.storageProp!==void 0&&(n.storageProp=t.bindTarget.storageProp)),{declarationString:t.declarationString,inputFieldType:t.inputFieldType??e.inputFieldType,bindTarget:n,arguments:t.arguments.concat(e.arguments).reduce((e,t)=>(e.find(e=>e.name===t.name)===void 0&&e.push(t),e),[]),errorCollection:new Tn(`input field declaration`).merge(e.errorCollection).merge(t.errorCollection)}}parseTemplateString(e){let t=new Tn(`InputFieldParser`);try{let n=De(YT,e);return this.partialToFullDeclaration(n,e,t)}catch(e){t.add(e)}return{declarationString:e,inputFieldType:{value:On.INVALID},bindTarget:void 0,arguments:[],errorCollection:t}}parseTemplates(e){this.templates=[];let t=new Tn(`input field template parser`);for(let n of e){let e=this.parseTemplateString(n.declaration);t.merge(e.errorCollection);let r={name:n.name,template:e};this.templates.push(C(r))}return t}getTemplate(e){return this.templates.find(t=>t.name===e)?.template}applyTemplate(e){if(e.templateName===void 0)return e;let t=this.getTemplate(e.templateName.value);return t===void 0?(e.errorCollection.add(new ke(B.WARNING,`Input Field Parser`,`Invalid template name. Could not find a template with the name '${e.templateName.value}'.`,e.declarationString,e.templateName.position,[`https://mprojectscode.github.io/obsidian-meta-bind-plugin-docs/guides/templates/`])),e):this.merge(t,e)}},ZT=class{mb;constructor(e){this.mb=e}fromString(e){let t=new Tn(`JsViewFieldDeclaration`);try{let n=De(st,e);return this.partialToFullDeclaration(n,e,t)}catch(e){t.add(e)}return{declarationString:e,errorCollection:t,bindTargetMappings:[],writeToBindTarget:void 0,hidden:!1,code:``}}fromStringAndValidate(e,t){return this.validate(this.fromString(e),t)}fromSimpleDeclaration(e){let t=new Tn(`JsViewFieldDeclaration`);return{declarationString:void 0,code:e.code,bindTargetMappings:e.bindTargetMappings.map(e=>({bindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.bindTarget),name:e.name})),writeToBindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.writeToBindTarget),hidden:e.hidden??!1,errorCollection:t}}fromSimpleDeclarationAndValidate(e,t){return this.validate(this.fromSimpleDeclaration(e),t)}partialToFullDeclaration(e,t,n){let r=e;return r.declarationString=t,r.errorCollection=n,r.bindTargetMappings=[...r.bindTargetMappings],r}validate(e,t){let n={};n.declarationString=e.declarationString,n.errorCollection=e.errorCollection;try{return n.bindTargetMappings=e.bindTargetMappings.map(n=>({bindTarget:this.mb.bindTargetParser.validate(e.declarationString,n.bindTarget,t),name:n.name})),e.writeToBindTarget!==void 0&&(n.writeToBindTarget=this.mb.bindTargetParser.validate(e.declarationString,e.writeToBindTarget,t)),n.code=e.code,n.hidden=e.hidden,n}catch(e){n.errorCollection.add(e)}return{declarationString:e.declarationString,errorCollection:n.errorCollection,bindTargetMappings:[],writeToBindTarget:void 0,hidden:!1,code:``}}},QT=class extends xT{getAll(e){return super.getAll(e)}get(e){return this.getAll(e).at(0)}},$T=class extends CT{},eE=class extends $T{value=[];_parseValue(e){this.value=e[0].value.split(` `)}getConfig(){return Fn.class}},tE=class extends $T{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Fn.hidden}},nE=class extends $T{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Fn.renderMarkdown}},rE={[Pn.RENDER_MARKDOWN]:nE,[Pn.HIDDEN]:tE,[Pn.CLASS]:eE},iE=class{static createViewFieldArgument(e){if(e in rE){let t=rE[e];if(t)return new t}throw new ve({errorLevel:B.WARNING,effect:`can not crate view field argument`,cause:`unknown argument '${e}'`})}},aE=class{unvalidatedDeclaration;errorCollection;filePath;mb;constructor(e,t,n){this.unvalidatedDeclaration=e,this.mb=n,this.filePath=t,this.errorCollection=new Tn(`view field declaration`)}validate(e){let t=this.validateInputFieldType(),n=this.validateBindTarget(e),r=this.validateArguments(t),i=this.validateTemplateDeclaration(e),a={declarationString:this.unvalidatedDeclaration.declarationString,viewFieldType:t,writeToBindTarget:n,argumentContainer:r,templateDeclaration:i,errorCollection:this.errorCollection.merge(this.unvalidatedDeclaration.errorCollection)};return this.checkForDeprecation(a),a}validateInputFieldType(){let e=this.unvalidatedDeclaration.viewFieldType;if(e===void 0)return Nn.MATH;for(let t of Object.entries(Nn))if(t[1]===e?.value)return t[1];return this.errorCollection.add(new ke(B.ERROR,`Declaration Validator`,`Encountered invalid identifier. Expected a view field type but received '${e.value}'.`,this.unvalidatedDeclaration.declarationString,e.position)),Nn.INVALID}checkForDeprecation(e){}validateBindTarget(e){if(this.unvalidatedDeclaration.writeToBindTarget!==void 0)return this.mb.bindTargetParser.validate(this.unvalidatedDeclaration.declarationString,this.unvalidatedDeclaration.writeToBindTarget,this.filePath,e)}validateArguments(e){let t=new QT;for(let n of this.unvalidatedDeclaration.arguments){let r=this.validateArgumentType(n.name);if(r===Pn.INVALID)continue;let i=iE.createViewFieldArgument(r);if(!i.isAllowed(e)){this.errorCollection.add(new ke(B.WARNING,`Declaration Validator`,`Failed to parse view field arguments. Argument "${n.name.value}" is only applicable to "${i.getAllowedFieldsAsString()}" view fields.`,this.unvalidatedDeclaration.declarationString,n.name.position));continue}try{i.parseValue(n.value)}catch(e){this.errorCollection.add(e);continue}t.add(i)}try{t.validate()}catch(e){this.errorCollection.add(e)}return t}validateArgumentType(e){for(let t of Object.entries(Pn))if(t[1]===e.value)return t[1];return this.errorCollection.add(new ke(B.WARNING,`Declaration Validator`,`Encountered invalid identifier. Expected a view field argument type but received '${e.value}'.`,this.unvalidatedDeclaration.declarationString,e.position)),Pn.INVALID}validateTemplateDeclaration(e){try{return this.unvalidatedDeclaration.templateDeclaration?.map(t=>typeof t==`string`?t:this.mb.bindTargetParser.validate(this.unvalidatedDeclaration.declarationString,t,this.filePath,e))??[]}catch(e){return this.errorCollection.add(e),[]}}},oE=class{mb;constructor(e){this.mb=e}fromString(e){let t=new Tn(`ViewFieldDeclaration`);try{let n=De(at,e);return this.partialToFullDeclaration(n,e,t)}catch(e){t.add(e)}return{declarationString:e,errorCollection:t,viewFieldType:{value:Nn.INVALID},writeToBindTarget:void 0,arguments:[],templateDeclaration:[]}}fromStringAndValidate(e,t,n){return this.validate(this.fromString(e),t,n)}fromSimpleDeclaration(e){let t=new Tn(`ViewFieldDeclaration`);return{declarationString:void 0,templateDeclaration:(e.templateDeclaration??[]).map(e=>typeof e==`string`?e:this.mb.bindTargetParser.fromExistingDeclaration(e)),viewFieldType:Re(e.viewFieldType),arguments:(e.arguments??[]).map(e=>({name:Re(e.name),value:e.value.map(e=>Re(e))})),writeToBindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.writeToBindTarget),errorCollection:t}}fromSimpleDeclarationAndValidate(e,t,n){return this.validate(this.fromSimpleDeclaration(e),t,n)}partialToFullDeclaration(e,t,n){return{...structuredClone(e),declarationString:t,errorCollection:n}}validate(e,t,n){return new aE(e,t,this.mb).validate(n)}},sE=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):n.moment=r()})(e,(function(){"use strict";var e;function n(){return e.apply(null,arguments)}function r(t){e=t}function i(e){return e instanceof Array||Object.prototype.toString.call(e)===`[object Array]`}function a(e){return e!=null&&Object.prototype.toString.call(e)===`[object Object]`}function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(e).length===0;for(var t in e)if(o(e,t))return!1;return!0}function c(e){return e===void 0}function l(e){return typeof e==`number`||Object.prototype.toString.call(e)===`[object Number]`}function u(e){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`}function d(e,t){var n=[],r,i=e.length;for(r=0;r>>0,r;for(r=0;r0)for(n=0;n=0?n?`+`:``:`-`)+(10**Math.max(0,i)).toString().substr(1)+r}var ne=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,re=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,P={},F={};function I(e,t,n,r){var i=r;typeof r==`string`&&(i=function(){return this[r]()}),e&&(F[e]=i),t&&(F[t[0]]=function(){return te(i.apply(this,arguments),t[1],t[2])}),n&&(F[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),e)})}function L(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,``):e.replace(/\\/g,``)}function ie(e){var t=e.match(ne),n,r;for(n=0,r=t.length;n=0&&re.test(e);)e=e.replace(re,r),re.lastIndex=0,--n;return e}var z={LTS:`h:mm:ss A`,LT:`h:mm A`,L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`};function oe(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(ne).map(function(e){return e===`MMMM`||e===`MM`||e===`DD`||e===`dddd`?e.slice(1):e}).join(``),this._longDateFormat[e])}var se=`Invalid date`;function ce(){return this._invalidDate}var le=`%d`,ue=/\d{1,2}/;function de(e){return this._ordinal.replace(`%d`,e)}var fe={future:`in %s`,past:`%s ago`,s:`a few seconds`,ss:`%d seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,w:`a week`,ww:`%d weeks`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function pe(e,t,n,r){var i=this._relativeTime[n];return O(i)?i(e,t,n,r):i.replace(/%d/i,e)}function me(e,t){var n=this._relativeTime[e>0?`future`:`past`];return O(n)?n(t):n.replace(/%s/i,t)}var B={D:`date`,dates:`date`,date:`date`,d:`day`,days:`day`,day:`day`,e:`weekday`,weekdays:`weekday`,weekday:`weekday`,E:`isoWeekday`,isoweekdays:`isoWeekday`,isoweekday:`isoWeekday`,DDD:`dayOfYear`,dayofyears:`dayOfYear`,dayofyear:`dayOfYear`,h:`hour`,hours:`hour`,hour:`hour`,ms:`millisecond`,milliseconds:`millisecond`,millisecond:`millisecond`,m:`minute`,minutes:`minute`,minute:`minute`,M:`month`,months:`month`,month:`month`,Q:`quarter`,quarters:`quarter`,quarter:`quarter`,s:`second`,seconds:`second`,second:`second`,gg:`weekYear`,weekyears:`weekYear`,weekyear:`weekYear`,GG:`isoWeekYear`,isoweekyears:`isoWeekYear`,isoweekyear:`isoWeekYear`,w:`week`,weeks:`week`,week:`week`,W:`isoWeek`,isoweeks:`isoWeek`,isoweek:`isoWeek`,y:`year`,years:`year`,year:`year`};function he(e){return typeof e==`string`?B[e]||B[e.toLowerCase()]:void 0}function ge(e){var t={},n,r;for(r in e)o(e,r)&&(n=he(r),n&&(t[n]=e[r]));return t}var _e={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function ve(e){var t=[],n;for(n in e)o(e,n)&&t.push({unit:n,priority:_e[n]});return t.sort(function(e,t){return e.priority-t.priority}),t}var ye=/\d/,be=/\d\d/,xe=/\d{3}/,Se=/\d{4}/,Ce=/[+-]?\d{6}/,we=/\d\d?/,Te=/\d\d\d\d?/,Ee=/\d\d\d\d\d\d?/,De=/\d{1,3}/,Oe=/\d{1,4}/,ke=/[+-]?\d{1,6}/,Ae=/\d+/,je=/[+-]?\d+/,Me=/Z|[+-]\d\d:?\d\d/gi,Ne=/Z|[+-]\d\d(?::?\d\d)?/gi,Pe=/[+-]?\d+(\.\d{1,3})?/,Fe=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,Ie=/^[1-9]\d?/,Le=/^([1-9]\d|\d)/,Re={};function ze(e,t,n){Re[e]=O(t)?t:function(e,r){return e&&n?n:t}}function Be(e,t){return o(Re,e)?Re[e](t._strict,t._locale):new RegExp(Ve(e))}function Ve(e){return He(e.replace(`\\`,``).replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,r,i){return t||n||r||i}))}function He(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)}function Ue(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function We(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=Ue(t)),n}var Ge={};function Ke(e,t){var n,r=t,i;for(typeof e==`string`&&(e=[e]),l(t)&&(r=function(e,n){n[t]=We(e)}),i=e.length,n=0;n68?1900:2e3)};var ot=ct(`FullYear`,!0);function st(){return Ye(this.year())}function ct(e,t){return function(r){return r==null?lt(this,e):(ut(this,e,r),n.updateOffset(this,t),this)}}function lt(e,t){if(!e.isValid())return NaN;var n=e._d,r=e._isUTC;switch(t){case`Milliseconds`:return r?n.getUTCMilliseconds():n.getMilliseconds();case`Seconds`:return r?n.getUTCSeconds():n.getSeconds();case`Minutes`:return r?n.getUTCMinutes():n.getMinutes();case`Hours`:return r?n.getUTCHours():n.getHours();case`Date`:return r?n.getUTCDate():n.getDate();case`Day`:return r?n.getUTCDay():n.getDay();case`Month`:return r?n.getUTCMonth():n.getMonth();case`FullYear`:return r?n.getUTCFullYear():n.getFullYear();default:return NaN}}function ut(e,t,n){var r,i,a,o,s;if(!(!e.isValid()||isNaN(n))){switch(r=e._d,i=e._isUTC,t){case`Milliseconds`:i?r.setUTCMilliseconds(n):r.setMilliseconds(n);return;case`Seconds`:i?r.setUTCSeconds(n):r.setSeconds(n);return;case`Minutes`:i?r.setUTCMinutes(n):r.setMinutes(n);return;case`Hours`:i?r.setUTCHours(n):r.setHours(n);return;case`Date`:i?r.setUTCDate(n):r.setDate(n);return;case`FullYear`:break;default:return}a=n,o=e.month(),s=e.date(),s=s===29&&o===1&&!Ye(a)?28:s,i?r.setUTCFullYear(a,o,s):r.setFullYear(a,o,s)}}function dt(e){return e=he(e),O(this[e])?this[e]():this}function ft(e,t){if(typeof e==`object`){e=ge(e);var n=ve(e),r,i=n.length;for(r=0;r=0?(s=new Date(e+400,t,n,r,i,a,o),isFinite(s.getFullYear())&&s.setFullYear(e)):s=new Date(e,t,n,r,i,a,o),s}function Mt(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Nt(e,t,n){var r=7+t-n;return-((7+Mt(e,0,r).getUTCDay()-t)%7)+r-1}function Pt(e,t,n,r,i){var a=(7+n-r)%7,o=Nt(e,r,i),s=1+7*(t-1)+a+o,c,l;return s<=0?(c=e-1,l=at(c)+s):s>at(e)?(c=e+1,l=s-at(e)):(c=e,l=s),{year:c,dayOfYear:l}}function Ft(e,t,n){var r=Nt(e.year(),t,n),i=Math.floor((e.dayOfYear()-r-1)/7)+1,a,o;return i<1?(o=e.year()-1,a=i+It(o,t,n)):i>It(e.year(),t,n)?(a=i-It(e.year(),t,n),o=e.year()+1):(o=e.year(),a=i),{week:a,year:o}}function It(e,t,n){var r=Nt(e,t,n),i=Nt(e+1,t,n);return(at(e)-r+i)/7}I(`w`,[`ww`,2],`wo`,`week`),I(`W`,[`WW`,2],`Wo`,`isoWeek`),ze(`w`,we,Ie),ze(`ww`,we,be),ze(`W`,we,Ie),ze(`WW`,we,be),qe([`w`,`ww`,`W`,`WW`],function(e,t,n,r){t[r.substr(0,1)]=We(e)});function Lt(e){return Ft(e,this._week.dow,this._week.doy).week}var Rt={dow:0,doy:6};function zt(){return this._week.dow}function Bt(){return this._week.doy}function Vt(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,`d`)}function Ht(e){var t=Ft(this,1,4).week;return e==null?t:this.add((e-t)*7,`d`)}I(`d`,0,`do`,`day`),I(`dd`,0,0,function(e){return this.localeData().weekdaysMin(this,e)}),I(`ddd`,0,0,function(e){return this.localeData().weekdaysShort(this,e)}),I(`dddd`,0,0,function(e){return this.localeData().weekdays(this,e)}),I(`e`,0,0,`weekday`),I(`E`,0,0,`isoWeekday`),ze(`d`,we),ze(`e`,we),ze(`E`,we),ze(`dd`,function(e,t){return t.weekdaysMinRegex(e)}),ze(`ddd`,function(e,t){return t.weekdaysShortRegex(e)}),ze(`dddd`,function(e,t){return t.weekdaysRegex(e)}),qe([`dd`,`ddd`,`dddd`],function(e,t,n,r){var i=n._locale.weekdaysParse(e,r,n._strict);i==null?h(n).invalidWeekday=e:t.d=i}),qe([`d`,`e`,`E`],function(e,t,n,r){t[r]=We(e)});function Ut(e,t){return typeof e==`string`?isNaN(e)?(e=t.weekdaysParse(e),typeof e==`number`?e:null):parseInt(e,10):e}function Wt(e,t){return typeof e==`string`?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function Gt(e,t){return e.slice(t,7).concat(e.slice(0,t))}var Kt=`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),qt=`Sun_Mon_Tue_Wed_Thu_Fri_Sat`.split(`_`),Jt=`Su_Mo_Tu_We_Th_Fr_Sa`.split(`_`),Yt=Fe,Xt=Fe,Zt=Fe;function Qt(e,t){var n=i(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?`format`:`standalone`];return e===!0?Gt(n,this._week.dow):e?n[e.day()]:n}function $t(e){return e===!0?Gt(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function en(e){return e===!0?Gt(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function tn(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],r=0;r<7;++r)a=p([2e3,1]).day(r),this._minWeekdaysParse[r]=this.weekdaysMin(a,``).toLocaleLowerCase(),this._shortWeekdaysParse[r]=this.weekdaysShort(a,``).toLocaleLowerCase(),this._weekdaysParse[r]=this.weekdays(a,``).toLocaleLowerCase();return n?t===`dddd`?(i=mt.call(this._weekdaysParse,o),i===-1?null:i):t===`ddd`?(i=mt.call(this._shortWeekdaysParse,o),i===-1?null:i):(i=mt.call(this._minWeekdaysParse,o),i===-1?null:i):t===`dddd`?(i=mt.call(this._weekdaysParse,o),i!==-1||(i=mt.call(this._shortWeekdaysParse,o),i!==-1)?i:(i=mt.call(this._minWeekdaysParse,o),i===-1?null:i)):t===`ddd`?(i=mt.call(this._shortWeekdaysParse,o),i!==-1||(i=mt.call(this._weekdaysParse,o),i!==-1)?i:(i=mt.call(this._minWeekdaysParse,o),i===-1?null:i)):(i=mt.call(this._minWeekdaysParse,o),i!==-1||(i=mt.call(this._weekdaysParse,o),i!==-1)?i:(i=mt.call(this._shortWeekdaysParse,o),i===-1?null:i))}function nn(e,t,n){var r,i,a;if(this._weekdaysParseExact)return tn.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),r=0;r<7;r++)if(i=p([2e3,1]).day(r),n&&!this._fullWeekdaysParse[r]&&(this._fullWeekdaysParse[r]=RegExp(`^`+this.weekdays(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._shortWeekdaysParse[r]=RegExp(`^`+this.weekdaysShort(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._minWeekdaysParse[r]=RegExp(`^`+this.weekdaysMin(i,``).replace(`.`,`\\.?`)+`$`,`i`)),this._weekdaysParse[r]||(a=`^`+this.weekdays(i,``)+`|^`+this.weekdaysShort(i,``)+`|^`+this.weekdaysMin(i,``),this._weekdaysParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`dddd`&&this._fullWeekdaysParse[r].test(e)||n&&t===`ddd`&&this._shortWeekdaysParse[r].test(e)||n&&t===`dd`&&this._minWeekdaysParse[r].test(e)||!n&&this._weekdaysParse[r].test(e))return r}function rn(e){if(!this.isValid())return e==null?NaN:this;var t=lt(this,`Day`);return e==null?t:(e=Ut(e,this.localeData()),this.add(e-t,`d`))}function an(e){if(!this.isValid())return e==null?NaN:this;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,`d`)}function on(e){if(!this.isValid())return e==null?NaN:this;if(e!=null){var t=Wt(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function sn(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||un.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(o(this,`_weekdaysRegex`)||(this._weekdaysRegex=Yt),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function cn(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||un.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(o(this,`_weekdaysShortRegex`)||(this._weekdaysShortRegex=Xt),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function ln(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||un.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(o(this,`_weekdaysMinRegex`)||(this._weekdaysMinRegex=Zt),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function un(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i=[],a,o,s,c,l;for(a=0;a<7;a++)o=p([2e3,1]).day(a),s=He(this.weekdaysMin(o,``)),c=He(this.weekdaysShort(o,``)),l=He(this.weekdays(o,``)),t.push(s),n.push(c),r.push(l),i.push(s),i.push(c),i.push(l);t.sort(e),n.sort(e),r.sort(e),i.sort(e),this._weekdaysRegex=RegExp(`^(`+i.join(`|`)+`)`,`i`),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._weekdaysShortStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._weekdaysMinStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function dn(){return this.hours()%12||12}function fn(){return this.hours()||24}I(`H`,[`HH`,2],0,`hour`),I(`h`,[`hh`,2],0,dn),I(`k`,[`kk`,2],0,fn),I(`hmm`,0,0,function(){return``+dn.apply(this)+te(this.minutes(),2)}),I(`hmmss`,0,0,function(){return``+dn.apply(this)+te(this.minutes(),2)+te(this.seconds(),2)}),I(`Hmm`,0,0,function(){return``+this.hours()+te(this.minutes(),2)}),I(`Hmmss`,0,0,function(){return``+this.hours()+te(this.minutes(),2)+te(this.seconds(),2)});function pn(e,t){I(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}pn(`a`,!0),pn(`A`,!1);function mn(e,t){return t._meridiemParse}ze(`a`,mn),ze(`A`,mn),ze(`H`,we,Le),ze(`h`,we,Ie),ze(`k`,we,Ie),ze(`HH`,we,be),ze(`hh`,we,be),ze(`kk`,we,be),ze(`hmm`,Te),ze(`hmmss`,Ee),ze(`Hmm`,Te),ze(`Hmmss`,Ee),Ke([`H`,`HH`],$e),Ke([`k`,`kk`],function(e,t,n){var r=We(e);t[$e]=r===24?0:r}),Ke([`a`,`A`],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),Ke([`h`,`hh`],function(e,t,n){t[$e]=We(e),h(n).bigHour=!0}),Ke(`hmm`,function(e,t,n){var r=e.length-2;t[$e]=We(e.substr(0,r)),t[et]=We(e.substr(r)),h(n).bigHour=!0}),Ke(`hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[$e]=We(e.substr(0,r)),t[et]=We(e.substr(r,2)),t[tt]=We(e.substr(i)),h(n).bigHour=!0}),Ke(`Hmm`,function(e,t,n){var r=e.length-2;t[$e]=We(e.substr(0,r)),t[et]=We(e.substr(r))}),Ke(`Hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[$e]=We(e.substr(0,r)),t[et]=We(e.substr(r,2)),t[tt]=We(e.substr(i))});function hn(e){return(e+``).toLowerCase().charAt(0)===`p`}var gn=/[ap]\.?m?\.?/i,_n=ct(`Hours`,!0);function vn(e,t,n){return e>11?n?`pm`:`PM`:n?`am`:`AM`}var yn={calendar:N,longDateFormat:z,invalidDate:se,ordinal:le,dayOfMonthOrdinalParse:ue,relativeTime:fe,months:gt,monthsShort:_t,week:Rt,weekdays:Kt,weekdaysMin:Jt,weekdaysShort:qt,meridiemParse:gn},bn={},xn={},Sn;function Cn(e,t){var n,r=Math.min(e.length,t.length);for(n=0;n0;){if(i=Dn(a.slice(0,n).join(`-`)),i)return i;if(r&&r.length>=n&&Cn(a,r)>=n-1)break;n--}t++}return Sn}function En(e){return!!(e&&e.match(`^[^/\\\\]*$`))}function Dn(e){var n=null,r;if(bn[e]===void 0&&t!==void 0&&t&&t.exports&&En(e))try{n=Sn._abbr,r=require,r(`./locale/`+e),On(n)}catch{bn[e]=null}return bn[e]}function On(e,t){var n;return e&&(n=c(t)?jn(e):kn(e,t),n?Sn=n:typeof console<`u`&&console.warn&&console.warn(`Locale `+e+` not found. Did you forget to load it?`)),Sn._abbr}function kn(e,t){if(t!==null){var n,r=yn;if(t.abbr=e,bn[e]!=null)D(`defineLocaleOverride`,`use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.`),r=bn[e]._config;else if(t.parentLocale!=null)if(bn[t.parentLocale]!=null)r=bn[t.parentLocale]._config;else if(n=Dn(t.parentLocale),n!=null)r=n._config;else return xn[t.parentLocale]||(xn[t.parentLocale]=[]),xn[t.parentLocale].push({name:e,config:t}),null;return bn[e]=new j(A(r,t)),xn[e]&&xn[e].forEach(function(e){kn(e.name,e.config)}),On(e),bn[e]}else return delete bn[e],null}function An(e,t){if(t!=null){var n,r,i=yn;bn[e]!=null&&bn[e].parentLocale!=null?bn[e].set(A(bn[e]._config,t)):(r=Dn(e),r!=null&&(i=r._config),t=A(i,t),r??(t.abbr=e),n=new j(t),n.parentLocale=bn[e],bn[e]=n),On(e)}else bn[e]!=null&&(bn[e].parentLocale==null?bn[e]!=null&&delete bn[e]:(bn[e]=bn[e].parentLocale,e===On()&&On(e)));return bn[e]}function jn(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return Sn;if(!i(e)){if(t=Dn(e),t)return t;e=[e]}return Tn(e)}function Mn(){return M(bn)}function Nn(e){var t,n=e._a;return n&&h(e).overflow===-2&&(t=n[Ze]<0||n[Ze]>11?Ze:n[Qe]<1||n[Qe]>ht(n[Xe],n[Ze])?Qe:n[$e]<0||n[$e]>24||n[$e]===24&&(n[et]!==0||n[tt]!==0||n[nt]!==0)?$e:n[et]<0||n[et]>59?et:n[tt]<0||n[tt]>59?tt:n[nt]<0||n[nt]>999?nt:-1,h(e)._overflowDayOfYear&&(tQe)&&(t=Qe),h(e)._overflowWeeks&&t===-1&&(t=rt),h(e)._overflowWeekday&&t===-1&&(t=it),h(e).overflow=t),e}var Pn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Fn=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,In=/Z|[+-]\d\d(?::?\d\d)?/,Ln=[[`YYYYYY-MM-DD`,/[+-]\d{6}-\d\d-\d\d/],[`YYYY-MM-DD`,/\d{4}-\d\d-\d\d/],[`GGGG-[W]WW-E`,/\d{4}-W\d\d-\d/],[`GGGG-[W]WW`,/\d{4}-W\d\d/,!1],[`YYYY-DDD`,/\d{4}-\d{3}/],[`YYYY-MM`,/\d{4}-\d\d/,!1],[`YYYYYYMMDD`,/[+-]\d{10}/],[`YYYYMMDD`,/\d{8}/],[`GGGG[W]WWE`,/\d{4}W\d{3}/],[`GGGG[W]WW`,/\d{4}W\d{2}/,!1],[`YYYYDDD`,/\d{7}/],[`YYYYMM`,/\d{6}/,!1],[`YYYY`,/\d{4}/,!1]],Rn=[[`HH:mm:ss.SSSS`,/\d\d:\d\d:\d\d\.\d+/],[`HH:mm:ss,SSSS`,/\d\d:\d\d:\d\d,\d+/],[`HH:mm:ss`,/\d\d:\d\d:\d\d/],[`HH:mm`,/\d\d:\d\d/],[`HHmmss.SSSS`,/\d\d\d\d\d\d\.\d+/],[`HHmmss,SSSS`,/\d\d\d\d\d\d,\d+/],[`HHmmss`,/\d\d\d\d\d\d/],[`HHmm`,/\d\d\d\d/],[`HH`,/\d\d/]],zn=/^\/?Date\((-?\d+)/i,Bn=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Vn={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Hn(e){var t,n,r=e._i,i=Pn.exec(r)||Fn.exec(r),a,o,s,c,l=Ln.length,u=Rn.length;if(i){for(h(e).iso=!0,t=0,n=l;tat(o)||e._dayOfYear===0)&&(h(e)._overflowDayOfYear=!0),n=Mt(o,0,e._dayOfYear),e._a[Ze]=n.getUTCMonth(),e._a[Qe]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=r[t]=i[t];for(;t<7;t++)e._a[t]=r[t]=e._a[t]==null?+(t===2):e._a[t];e._a[$e]===24&&e._a[et]===0&&e._a[tt]===0&&e._a[nt]===0&&(e._nextDay=!0,e._a[$e]=0),e._d=(e._useUTC?Mt:jt).apply(null,r),a=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[$e]=24),e._w&&e._w.d!==void 0&&e._w.d!==a&&(h(e).weekdayMismatch=!0)}}function $n(e){var t=e._w,n,r,i,a,o,s,c,l;t.GG!=null||t.W!=null||t.E!=null?(a=1,o=4,n=Xn(t.GG,e._a[Xe],Ft(cr(),1,4).year),r=Xn(t.W,1),i=Xn(t.E,1),(i<1||i>7)&&(c=!0)):(a=e._locale._week.dow,o=e._locale._week.doy,l=Ft(cr(),a,o),n=Xn(t.gg,e._a[Xe],l.year),r=Xn(t.w,l.week),t.d==null?t.e==null?i=a:(i=t.e+a,(t.e<0||t.e>6)&&(c=!0)):(i=t.d,(i<0||i>6)&&(c=!0))),r<1||r>It(n,a,o)?h(e)._overflowWeeks=!0:c==null?(s=Pt(n,r,i,a,o),e._a[Xe]=s.year,e._dayOfYear=s.dayOfYear):h(e)._overflowWeekday=!0}n.ISO_8601=function(){},n.RFC_2822=function(){};function er(e){if(e._f===n.ISO_8601){Hn(e);return}if(e._f===n.RFC_2822){Jn(e);return}e._a=[],h(e).empty=!0;var t=``+e._i,r,i,a,o,s,c=t.length,l=0,u,d;for(a=R(e._f,e._locale).match(ne)||[],d=a.length,r=0;r0&&h(e).unusedInput.push(s),t=t.slice(t.indexOf(i)+i.length),l+=i.length),F[o]?(i?h(e).empty=!1:h(e).unusedTokens.push(o),Je(o,i,e)):e._strict&&!i&&h(e).unusedTokens.push(o);h(e).charsLeftOver=c-l,t.length>0&&h(e).unusedInput.push(t),e._a[$e]<=12&&h(e).bigHour===!0&&e._a[$e]>0&&(h(e).bigHour=void 0),h(e).parsedDateParts=e._a.slice(0),h(e).meridiem=e._meridiem,e._a[$e]=tr(e._locale,e._a[$e],e._meridiem),u=h(e).era,u!==null&&(e._a[Xe]=e._locale.erasConvertYear(u,e._a[Xe])),Qn(e),Nn(e)}function tr(e,t,n){var r;return n==null?t:e.meridiemHour==null?e.isPM==null?t:(r=e.isPM(n),r&&t<12&&(t+=12),!r&&t===12&&(t=0),t):e.meridiemHour(t,n)}function nr(e){var t,n,r,i,a,o,s=!1,c=e._f.length;if(c===0){h(e).invalidFormat=!0,e._d=new Date(NaN);return}for(i=0;ithis?this:e:v()});function dr(e,t){var n,r;if(t.length===1&&i(t[0])&&(t=t[0]),!t.length)return cr();for(n=t[0],r=1;rthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Fr(){if(!c(this._isDSTShifted))return this._isDSTShifted;var e={},t;return x(e,this),e=ar(e),e._a?(t=e._isUTC?p(e._a):cr(e._a),this._isDSTShifted=this.isValid()&&Sr(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Ir(){return this.isValid()?!this._isUTC:!1}function Lr(){return this.isValid()?this._isUTC:!1}function Rr(){return this.isValid()?this._isUTC&&this._offset===0:!1}var zr=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,Br=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Vr(e,t){var n=e,r=null,i,a,s;return br(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:l(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(r=zr.exec(e))?(i=r[1]===`-`?-1:1,n={y:0,d:We(r[Qe])*i,h:We(r[$e])*i,m:We(r[et])*i,s:We(r[tt])*i,ms:We(xr(r[nt]*1e3))*i}):(r=Br.exec(e))?(i=r[1]===`-`?-1:1,n={y:Hr(r[2],i),M:Hr(r[3],i),w:Hr(r[4],i),d:Hr(r[5],i),h:Hr(r[6],i),m:Hr(r[7],i),s:Hr(r[8],i)}):n==null?n={}:typeof n==`object`&&(`from`in n||`to`in n)&&(s=Wr(cr(n.from),cr(n.to)),n={},n.ms=s.milliseconds,n.M=s.months),a=new yr(n),br(e)&&o(e,`_locale`)&&(a._locale=e._locale),br(e)&&o(e,`_isValid`)&&(a._isValid=e._isValid),a}Vr.fn=yr.prototype,Vr.invalid=vr;function Hr(e,t){var n=e&&parseFloat(e.replace(`,`,`.`));return(isNaN(n)?0:n)*t}function Ur(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,`M`).isAfter(t)&&--n.months,n.milliseconds=t-+e.clone().add(n.months,`M`),n}function Wr(e,t){var n;return e.isValid()&&t.isValid()?(t=Er(t,e),e.isBefore(t)?n=Ur(e,t):(n=Ur(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function V(e,t){return function(n,r){var i,a;return r!==null&&!isNaN(+r)&&(D(t,`moment().`+t+`(period, number) is deprecated. Please use moment().`+t+`(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.`),a=n,n=r,r=a),i=Vr(n,r),Gr(this,i,e),this}}function Gr(e,t,r,i){var a=t._milliseconds,o=xr(t._days),s=xr(t._months);e.isValid()&&(i??=!0,s&&Tt(e,lt(e,`Month`)+s*r),o&&ut(e,`Date`,lt(e,`Date`)+o*r),a&&e._d.setTime(e._d.valueOf()+a*r),i&&n.updateOffset(e,o||s))}var Kr=V(1,`add`),qr=V(-1,`subtract`);function Jr(e){return typeof e==`string`||e instanceof String}function Yr(e){return C(e)||u(e)||Jr(e)||l(e)||Zr(e)||Xr(e)||e==null}function Xr(e){var t=a(e)&&!s(e),n=!1,r=[`years`,`year`,`y`,`months`,`month`,`M`,`days`,`day`,`d`,`dates`,`date`,`D`,`hours`,`hour`,`h`,`minutes`,`minute`,`m`,`seconds`,`second`,`s`,`milliseconds`,`millisecond`,`ms`],i,c,l=r.length;for(i=0;in.valueOf():n.valueOf()9999?ae(n,t?`YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYYYY-MM-DD[T]HH:mm:ss.SSSZ`):O(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace(`Z`,ae(n,`Z`)):ae(n,t?`YYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYY-MM-DD[T]HH:mm:ss.SSSZ`)}function fi(){if(!this.isValid())return`moment.invalid(/* `+this._i+` */)`;var e=`moment`,t=``,n,r,i,a;return this.isLocal()||(e=this.utcOffset()===0?`moment.utc`:`moment.parseZone`,t=`Z`),n=`[`+e+`("]`,r=0<=this.year()&&this.year()<=9999?`YYYY`:`YYYYYY`,i=`-MM-DD[T]HH:mm:ss.SSS`,a=t+`[")]`,this.format(n+r+i+a)}function pi(e){e||=this.isUtc()?n.defaultFormatUtc:n.defaultFormat;var t=ae(this,e);return this.localeData().postformat(t)}function mi(e,t){return this.isValid()&&(C(e)&&e.isValid()||cr(e).isValid())?Vr({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function hi(e){return this.from(cr(),e)}function gi(e,t){return this.isValid()&&(C(e)&&e.isValid()||cr(e).isValid())?Vr({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function _i(e){return this.to(cr(),e)}function vi(e){var t;return e===void 0?this._locale._abbr:(t=jn(e),t!=null&&(this._locale=t),this)}var yi=T(`moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.`,function(e){return e===void 0?this.localeData():this.locale(e)});function bi(){return this._locale}var xi=1e3,Si=60*xi,Ci=60*Si,wi=146097*24*Ci;function Ti(e,t){return(e%t+t)%t}function Ei(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-wi:new Date(e,t,n).valueOf()}function Di(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-wi:Date.UTC(e,t,n)}function Oi(e){var t,r;if(e=he(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Di:Ei,e){case`year`:t=r(this.year(),0,1);break;case`quarter`:t=r(this.year(),this.month()-this.month()%3,1);break;case`month`:t=r(this.year(),this.month(),1);break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday());break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case`day`:case`date`:t=r(this.year(),this.month(),this.date());break;case`hour`:t=this._d.valueOf(),t-=Ti(t+(this._isUTC?0:this.utcOffset()*Si),Ci);break;case`minute`:t=this._d.valueOf(),t-=Ti(t,Si);break;case`second`:t=this._d.valueOf(),t-=Ti(t,xi);break}return this._d.setTime(t),n.updateOffset(this,!0),this}function ki(e){var t,r;if(e=he(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Di:Ei,e){case`year`:t=r(this.year()+1,0,1)-1;break;case`quarter`:t=r(this.year(),this.month()-this.month()%3+3,1)-1;break;case`month`:t=r(this.year(),this.month()+1,1)-1;break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case`day`:case`date`:t=r(this.year(),this.month(),this.date()+1)-1;break;case`hour`:t=this._d.valueOf(),t+=Ci-Ti(t+(this._isUTC?0:this.utcOffset()*Si),Ci)-1;break;case`minute`:t=this._d.valueOf(),t+=Si-Ti(t,Si)-1;break;case`second`:t=this._d.valueOf(),t+=xi-Ti(t,xi)-1;break}return this._d.setTime(t),n.updateOffset(this,!0),this}function Ai(){return this._d.valueOf()-(this._offset||0)*6e4}function ji(){return Math.floor(this.valueOf()/1e3)}function Mi(){return new Date(this.valueOf())}function Ni(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function Pi(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Fi(){return this.isValid()?this.toISOString():null}function Ii(){return _(this)}function Li(){return f({},h(this))}function Ri(){return h(this).overflow}function zi(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}I(`N`,0,0,`eraAbbr`),I(`NN`,0,0,`eraAbbr`),I(`NNN`,0,0,`eraAbbr`),I(`NNNN`,0,0,`eraName`),I(`NNNNN`,0,0,`eraNarrow`),I(`y`,[`y`,1],`yo`,`eraYear`),I(`y`,[`yy`,2],0,`eraYear`),I(`y`,[`yyy`,3],0,`eraYear`),I(`y`,[`yyyy`,4],0,`eraYear`),ze(`N`,Xi),ze(`NN`,Xi),ze(`NNN`,Xi),ze(`NNNN`,Zi),ze(`NNNNN`,Qi),Ke([`N`,`NN`,`NNN`,`NNNN`,`NNNNN`],function(e,t,n,r){var i=n._locale.erasParse(e,r,n._strict);i?h(n).era=i:h(n).invalidEra=e}),ze(`y`,Ae),ze(`yy`,Ae),ze(`yyy`,Ae),ze(`yyyy`,Ae),ze(`yo`,$i),Ke([`y`,`yy`,`yyy`,`yyyy`],Xe),Ke([`yo`],function(e,t,n,r){var i;n._locale._eraYearOrdinalRegex&&(i=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[Xe]=n._locale.eraYearOrdinalParse(e,i):t[Xe]=parseInt(e,10)});function Bi(e,t){var r,i,a,o=this._eras||jn(`en`)._eras;for(r=0,i=o.length;r=0)return a[r]}function Hi(e,t){var r=e.since<=e.until?1:-1;return t===void 0?n(e.since).year():n(e.since).year()+(t-e.offset)*r}function Ui(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;ea&&(t=a),la.call(this,e,t,n,r,i))}function la(e,t,n,r,i){var a=Pt(e,t,n,r,i),o=Mt(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}I(`Q`,0,`Qo`,`quarter`),ze(`Q`,ye),Ke(`Q`,function(e,t){t[Ze]=(We(e)-1)*3});function ua(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}I(`D`,[`DD`,2],`Do`,`date`),ze(`D`,we,Ie),ze(`DD`,we,be),ze(`Do`,function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Ke([`D`,`DD`],Qe),Ke(`Do`,function(e,t){t[Qe]=We(e.match(we)[0])});var da=ct(`Date`,!0);I(`DDD`,[`DDDD`,3],`DDDo`,`dayOfYear`),ze(`DDD`,De),ze(`DDDD`,xe),Ke([`DDD`,`DDDD`],function(e,t,n){n._dayOfYear=We(e)});function fa(e){var t=Math.round((this.clone().startOf(`day`)-this.clone().startOf(`year`))/864e5)+1;return e==null?t:this.add(e-t,`d`)}I(`m`,[`mm`,2],0,`minute`),ze(`m`,we,Le),ze(`mm`,we,be),Ke([`m`,`mm`],et);var pa=ct(`Minutes`,!1);I(`s`,[`ss`,2],0,`second`),ze(`s`,we,Le),ze(`ss`,we,be),Ke([`s`,`ss`],tt);var ma=ct(`Seconds`,!1);I(`S`,0,0,function(){return~~(this.millisecond()/100)}),I(0,[`SS`,2],0,function(){return~~(this.millisecond()/10)}),I(0,[`SSS`,3],0,`millisecond`),I(0,[`SSSS`,4],0,function(){return this.millisecond()*10}),I(0,[`SSSSS`,5],0,function(){return this.millisecond()*100}),I(0,[`SSSSSS`,6],0,function(){return this.millisecond()*1e3}),I(0,[`SSSSSSS`,7],0,function(){return this.millisecond()*1e4}),I(0,[`SSSSSSSS`,8],0,function(){return this.millisecond()*1e5}),I(0,[`SSSSSSSSS`,9],0,function(){return this.millisecond()*1e6}),ze(`S`,De,ye),ze(`SS`,De,be),ze(`SSS`,De,xe);var ha,ga;for(ha=`SSSS`;ha.length<=9;ha+=`S`)ze(ha,Ae);function _a(e,t){t[nt]=We((`0.`+e)*1e3)}for(ha=`S`;ha.length<=9;ha+=`S`)Ke(ha,_a);ga=ct(`Milliseconds`,!1),I(`z`,0,0,`zoneAbbr`),I(`zz`,0,0,`zoneName`);function va(){return this._isUTC?`UTC`:``}function ya(){return this._isUTC?`Coordinated Universal Time`:``}var H=S.prototype;H.add=Kr,H.calendar=ei,H.clone=ti,H.diff=ci,H.endOf=ki,H.format=pi,H.from=mi,H.fromNow=hi,H.to=gi,H.toNow=_i,H.get=dt,H.invalidAt=Ri,H.isAfter=ni,H.isBefore=ri,H.isBetween=ii,H.isSame=ai,H.isSameOrAfter=oi,H.isSameOrBefore=si,H.isValid=Ii,H.lang=yi,H.locale=vi,H.localeData=bi,H.max=ur,H.min=lr,H.parsingFlags=Li,H.set=ft,H.startOf=Oi,H.subtract=qr,H.toArray=Ni,H.toObject=Pi,H.toDate=Mi,H.toISOString=di,H.inspect=fi,typeof Symbol<`u`&&Symbol.for!=null&&(H[Symbol.for(`nodejs.util.inspect.custom`)]=function(){return`Moment<`+this.format()+`>`}),H.toJSON=Fi,H.toString=ui,H.unix=ji,H.valueOf=Ai,H.creationData=zi,H.eraName=Ui,H.eraNarrow=Wi,H.eraAbbr=Gi,H.eraYear=Ki,H.year=ot,H.isLeapYear=st,H.weekYear=na,H.isoWeekYear=ra,H.quarter=H.quarters=ua,H.month=Et,H.daysInMonth=Dt,H.week=H.weeks=Vt,H.isoWeek=H.isoWeeks=Ht,H.weeksInYear=oa,H.weeksInWeekYear=sa,H.isoWeeksInYear=ia,H.isoWeeksInISOWeekYear=aa,H.date=da,H.day=H.days=rn,H.weekday=an,H.isoWeekday=on,H.dayOfYear=fa,H.hour=H.hours=_n,H.minute=H.minutes=pa,H.second=H.seconds=ma,H.millisecond=H.milliseconds=ga,H.utcOffset=Or,H.utc=Ar,H.local=jr,H.parseZone=Mr,H.hasAlignedHourOffset=Nr,H.isDST=Pr,H.isLocal=Ir,H.isUtcOffset=Lr,H.isUtc=Rr,H.isUTC=Rr,H.zoneAbbr=va,H.zoneName=ya,H.dates=T(`dates accessor is deprecated. Use date instead.`,da),H.months=T(`months accessor is deprecated. Use month instead`,Et),H.years=T(`years accessor is deprecated. Use year instead`,ot),H.zone=T(`moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/`,kr),H.isDSTShifted=T(`isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information`,Fr);function ba(e){return cr(e*1e3)}function xa(){return cr.apply(null,arguments).parseZone()}function Sa(e){return e}var Ca=j.prototype;Ca.calendar=ee,Ca.longDateFormat=oe,Ca.invalidDate=ce,Ca.ordinal=de,Ca.preparse=Sa,Ca.postformat=Sa,Ca.relativeTime=pe,Ca.pastFuture=me,Ca.set=k,Ca.eras=Bi,Ca.erasParse=Vi,Ca.erasConvertYear=Hi,Ca.erasAbbrRegex=Ji,Ca.erasNameRegex=qi,Ca.erasNarrowRegex=Yi,Ca.months=xt,Ca.monthsShort=St,Ca.monthsParse=wt,Ca.monthsRegex=kt,Ca.monthsShortRegex=Ot,Ca.week=Lt,Ca.firstDayOfYear=Bt,Ca.firstDayOfWeek=zt,Ca.weekdays=Qt,Ca.weekdaysMin=en,Ca.weekdaysShort=$t,Ca.weekdaysParse=nn,Ca.weekdaysRegex=sn,Ca.weekdaysShortRegex=cn,Ca.weekdaysMinRegex=ln,Ca.isPM=hn,Ca.meridiem=vn;function wa(e,t,n,r){var i=jn(),a=p().set(r,t);return i[n](a,e)}function Ta(e,t,n){if(l(e)&&(t=e,e=void 0),e||=``,t!=null)return wa(e,t,n,`month`);var r,i=[];for(r=0;r<12;r++)i[r]=wa(e,r,n,`month`);return i}function Ea(e,t,n,r){typeof e==`boolean`?(l(t)&&(n=t,t=void 0),t||=``):(t=e,n=t,e=!1,l(t)&&(n=t,t=void 0),t||=``);var i=jn(),a=e?i._week.dow:0,o,s=[];if(n!=null)return wa(t,(n+a)%7,r,`day`);for(o=0;o<7;o++)s[o]=wa(t,(o+a)%7,r,`day`);return s}function Da(e,t){return Ta(e,t,`months`)}function U(e,t){return Ta(e,t,`monthsShort`)}function Oa(e,t,n){return Ea(e,t,n,`weekdays`)}function W(e,t,n){return Ea(e,t,n,`weekdaysShort`)}function ka(e,t,n){return Ea(e,t,n,`weekdaysMin`)}On(`en`,{eras:[{since:`0001-01-01`,until:1/0,offset:1,name:`Anno Domini`,narrow:`AD`,abbr:`AD`},{since:`0000-12-31`,until:-1/0,offset:1,name:`Before Christ`,narrow:`BC`,abbr:`BC`}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(We(e%100/10)===1?`th`:t===1?`st`:t===2?`nd`:t===3?`rd`:`th`)}}),n.lang=T(`moment.lang is deprecated. Use moment.locale instead.`,On),n.langData=T(`moment.langData is deprecated. Use moment.localeData instead.`,jn);var Aa=Math.abs;function ja(){var e=this._data;return this._milliseconds=Aa(this._milliseconds),this._days=Aa(this._days),this._months=Aa(this._months),e.milliseconds=Aa(e.milliseconds),e.seconds=Aa(e.seconds),e.minutes=Aa(e.minutes),e.hours=Aa(e.hours),e.months=Aa(e.months),e.years=Aa(e.years),this}function Ma(e,t,n,r){var i=Vr(t,n);return e._milliseconds+=r*i._milliseconds,e._days+=r*i._days,e._months+=r*i._months,e._bubble()}function Na(e,t){return Ma(this,e,t,1)}function Pa(e,t){return Ma(this,e,t,-1)}function Fa(e){return e<0?Math.floor(e):Math.ceil(e)}function Ia(){var e=this._milliseconds,t=this._days,n=this._months,r=this._data,i,a,o,s,c;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=Fa(Ra(n)+t)*864e5,t=0,n=0),r.milliseconds=e%1e3,i=Ue(e/1e3),r.seconds=i%60,a=Ue(i/60),r.minutes=a%60,o=Ue(a/60),r.hours=o%24,t+=Ue(o/24),c=Ue(La(t)),n+=c,t-=Fa(Ra(c)),s=Ue(n/12),n%=12,r.days=t,r.months=n,r.years=s,this}function La(e){return e*4800/146097}function Ra(e){return e*146097/4800}function za(e){if(!this.isValid())return NaN;var t,n,r=this._milliseconds;if(e=he(e),e===`month`||e===`quarter`||e===`year`)switch(t=this._days+r/864e5,n=this._months+La(t),e){case`month`:return n;case`quarter`:return n/3;case`year`:return n/12}else switch(t=this._days+Math.round(Ra(this._months)),e){case`week`:return t/7+r/6048e5;case`day`:return t+r/864e5;case`hour`:return t*24+r/36e5;case`minute`:return t*1440+r/6e4;case`second`:return t*86400+r/1e3;case`millisecond`:return Math.floor(t*864e5)+r;default:throw Error(`Unknown unit `+e)}}function Ba(e){return function(){return this.as(e)}}var Va=Ba(`ms`),Ha=Ba(`s`),Ua=Ba(`m`),Wa=Ba(`h`),Ga=Ba(`d`),Ka=Ba(`w`),qa=Ba(`M`),Ja=Ba(`Q`),Ya=Ba(`y`),Xa=Va;function Za(){return Vr(this)}function Qa(e){return e=he(e),this.isValid()?this[e+`s`]():NaN}function $a(e){return function(){return this.isValid()?this._data[e]:NaN}}var eo=$a(`milliseconds`),to=$a(`seconds`),no=$a(`minutes`),ro=$a(`hours`),io=$a(`days`),ao=$a(`months`),oo=$a(`years`);function so(){return Ue(this.days()/7)}var co=Math.round,lo={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function uo(e,t,n,r,i){return i.relativeTime(t||1,!!n,e,r)}function fo(e,t,n,r){var i=Vr(e).abs(),a=co(i.as(`s`)),o=co(i.as(`m`)),s=co(i.as(`h`)),c=co(i.as(`d`)),l=co(i.as(`M`)),u=co(i.as(`w`)),d=co(i.as(`y`)),f=a<=n.ss&&[`s`,a]||a0,f[4]=r,uo.apply(null,f)}function po(e){return e===void 0?co:typeof e==`function`?(co=e,!0):!1}function mo(e,t){return lo[e]===void 0?!1:t===void 0?lo[e]:(lo[e]=t,e===`s`&&(lo.ss=t-1),!0)}function ho(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,r=lo,i,a;return typeof e==`object`&&(t=e,e=!1),typeof e==`boolean`&&(n=e),typeof t==`object`&&(r=Object.assign({},lo,t),t.s!=null&&t.ss==null&&(r.ss=t.s-1)),i=this.localeData(),a=fo(this,!n,r,i),n&&(a=i.pastFuture(+this,a)),i.postformat(a)}var go=Math.abs;function _o(e){return(e>0)-(e<0)||+e}function vo(){if(!this.isValid())return this.localeData().invalidDate();var e=go(this._milliseconds)/1e3,t=go(this._days),n=go(this._months),r,i,a,o,s=this.asSeconds(),c,l,u,d;return s?(r=Ue(e/60),i=Ue(r/60),e%=60,r%=60,a=Ue(n/12),n%=12,o=e?e.toFixed(3).replace(/\.?0+$/,``):``,c=s<0?`-`:``,l=_o(this._months)===_o(s)?``:`-`,u=_o(this._days)===_o(s)?``:`-`,d=_o(this._milliseconds)===_o(s)?``:`-`,c+`P`+(a?l+a+`Y`:``)+(n?l+n+`M`:``)+(t?u+t+`D`:``)+(i||r||e?`T`:``)+(i?d+i+`H`:``)+(r?d+r+`M`:``)+(e?d+o+`S`:``)):`P0D`}var yo=yr.prototype;return yo.isValid=_r,yo.abs=ja,yo.add=Na,yo.subtract=Pa,yo.as=za,yo.asMilliseconds=Va,yo.asSeconds=Ha,yo.asMinutes=Ua,yo.asHours=Wa,yo.asDays=Ga,yo.asWeeks=Ka,yo.asMonths=qa,yo.asQuarters=Ja,yo.asYears=Ya,yo.valueOf=Xa,yo._bubble=Ia,yo.clone=Za,yo.get=Qa,yo.milliseconds=eo,yo.seconds=to,yo.minutes=no,yo.hours=ro,yo.days=io,yo.weeks=so,yo.months=ao,yo.years=oo,yo.humanize=ho,yo.toISOString=vo,yo.toString=vo,yo.toJSON=vo,yo.locale=vi,yo.localeData=bi,yo.toIsoString=T(`toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)`,vo),yo.lang=yi,I(`X`,0,0,`unix`),I(`x`,0,0,`valueOf`),ze(`x`,je),ze(`X`,Pe),Ke(`X`,function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),Ke(`x`,function(e,t,n){n._d=new Date(We(e))}),n.version=`2.30.1`,r(cr),n.fn=H,n.min=fr,n.max=pr,n.now=mr,n.utc=p,n.unix=ba,n.months=Da,n.isDate=u,n.locale=On,n.invalid=v,n.duration=Vr,n.isMoment=C,n.weekdays=Oa,n.parseZone=xa,n.localeData=jn,n.isDuration=br,n.monthsShort=U,n.weekdaysMin=ka,n.defineLocale=kn,n.updateLocale=An,n.locales=Mn,n.weekdaysShort=W,n.normalizeUnits=he,n.relativeTimeRounding=po,n.relativeTimeThreshold=mo,n.calendarFormat=$r,n.prototype=H,n.HTML5_FMT={DATETIME_LOCAL:`YYYY-MM-DDTHH:mm`,DATETIME_LOCAL_SECONDS:`YYYY-MM-DDTHH:mm:ss`,DATETIME_LOCAL_MS:`YYYY-MM-DDTHH:mm:ss.SSS`,DATE:`YYYY-MM-DD`,TIME:`HH:mm`,TIME_SECONDS:`HH:mm:ss`,TIME_MS:`HH:mm:ss.SSS`,WEEK:`GGGG-[W]WW`,MONTH:`YYYY-MM`},n}))}))()),cE=m[1];function lE(e){cE=e}function uE(e){return p[e]}function dE(e,t){let n=(0,sE.default)(new Date(t,e)).daysInMonth(),r=Array(42).fill(0),i=fE(new Date(t,e,1));for(let e=0;e({index:b(e.index-cE.index,7),name:e.name,shortName:e.shortName})).sort((e,t)=>e.index-t.index).map(e=>e.shortName)}function mE(){return mE=Object.assign?Object.assign.bind():function(e){for(var t=1;tthis.has(e)).values()}get(e){return gE(this.wrappedObject,e)}set(e,t){return _E(this.wrappedObject,e,t),this}has(e){return vE(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return DE(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){vE(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}},EE=class{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):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 DE(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}};function DE(e,t){return{next:()=>{var n=e.next();return n.done?n:{value:t(n.value),done:!1}}}}function OE(){return new Map}function kE(e){if(!e)return OE();if(QE(e))return e;if(ZE(e))return new TE(e);throw Error(`createMap can create maps from objects or Maps`)}function AE(e){if(e instanceof TE)return e.wrappedObject;var t={};for(var n of e.keys())_E(t,n,e.get(n));return t}function jE(e){return typeof e==`number`}function ME(e){return!e||typeof e!=`object`||typeof e.constructor!=`function`?!1:e.isBigNumber===!0&&typeof e.constructor.prototype==`object`&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal==`function`&&e.constructor.isDecimal(e)===!0}function NE(e){return typeof e==`bigint`}function PE(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isComplex===!0||!1}function FE(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isFraction===!0||!1}function IE(e){return e&&e.constructor.prototype.isUnit===!0||!1}function LE(e){return typeof e==`string`}var RE=Array.isArray;function zE(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function BE(e){return Array.isArray(e)||zE(e)}function VE(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function HE(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function UE(e){return e&&e.constructor.prototype.isRange===!0||!1}function WE(e){return e&&e.constructor.prototype.isIndex===!0||!1}function GE(e){return typeof e==`boolean`}function KE(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function qE(e){return e&&e.constructor.prototype.isHelp===!0||!1}function JE(e){return typeof e==`function`}function YE(e){return e instanceof Date}function XE(e){return e instanceof RegExp}function ZE(e){return!!(e&&typeof e==`object`&&e.constructor===Object&&!PE(e)&&!FE(e))}function QE(e){return e?e instanceof Map||e instanceof TE||typeof e.set==`function`&&typeof e.get==`function`&&typeof e.keys==`function`&&typeof e.has==`function`:!1}function $E(e){return QE(e)&&QE(e.a)&&QE(e.b)}function eD(e){return QE(e)&&ZE(e.wrappedObject)}function tD(e){return e===null}function nD(e){return e===void 0}function rD(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function iD(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function aD(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function oD(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function sD(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function cD(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function lD(e){return cD(e)||hD(e)&&e.args.length===1&&cD(e.args[0])&&`-+~`.includes(e.op)}function uD(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function dD(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function fD(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function pD(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function mD(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function hD(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function gD(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function _D(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function vD(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function yD(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function bD(e){return e&&e.constructor.prototype.isChain===!0||!1}function xD(e){var t=typeof e;return t===`object`?e===null?`null`:ME(e)?`BigNumber`:e.constructor&&e.constructor.name?e.constructor.name:`Object`:t}function SD(e){var t=typeof e;if(t===`number`||t===`bigint`||t===`string`||t===`boolean`||e==null)return e;if(typeof e.clone==`function`)return e.clone();if(Array.isArray(e))return e.map(function(e){return SD(e)});if(e instanceof Date)return new Date(e.valueOf());if(ME(e))return e;if(ZE(e))return CD(e,SD);if(t===`function`)return e;throw TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function CD(e,t){var n={};for(var r in e)AD(e,r)&&(n[r]=t(e[r]));return n}function wD(e,t){for(var n in t)AD(t,n)&&(e[n]=t[n]);return e}function TD(e,t){if(Array.isArray(t))throw TypeError(`Arrays are not supported by deepExtend`);for(var n in t)if(AD(t,n)&&!(n in Object.prototype)&&!(n in Function.prototype))if(t[n]&&t[n].constructor===Object)e[n]===void 0&&(e[n]={}),e[n]&&e[n].constructor===Object?TD(e[n],t[n]):e[n]=t[n];else if(Array.isArray(t[n]))throw TypeError(`Arrays are not supported by deepExtend`);else e[n]=t[n];return e}function ED(e,t){var n,r,i;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(r=0,i=e.length;r{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})}),n}function ID(e,t,n){e[t]!==void 0&&!n.includes(e[t])&&console.warn(`Warning: Unknown value "`+e[t]+`" for configuration option "`+t+`". Available options: `+n.map(e=>JSON.stringify(e)).join(`, `)+`.`)}var LD=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.typed=r())})(e,(function(){"use strict";function e(){return!0}function t(){return!1}function n(){}let r=`Argument is not a typed-function.`;function i(){function a(e){return typeof e==`object`&&!!e&&e.constructor===Object}let o=[{name:`number`,test:function(e){return typeof e==`number`}},{name:`string`,test:function(e){return typeof e==`string`}},{name:`boolean`,test:function(e){return typeof e==`boolean`}},{name:`Function`,test:function(e){return typeof e==`function`}},{name:`Array`,test:Array.isArray},{name:`Date`,test:function(e){return e instanceof Date}},{name:`RegExp`,test:function(e){return e instanceof RegExp}},{name:`Object`,test:a},{name:`null`,test:function(e){return e===null}},{name:`undefined`,test:function(e){return e===void 0}}],s={name:`any`,test:e,isAny:!0},c,l,u=0,d={createCount:0};function f(e){let t=c.get(e);if(t)return t;let n=`Unknown type "`+e+`"`,r=e.toLowerCase(),i;for(i of l)if(i.toLowerCase()===r){n+=`. Did you mean "`+i+`" ?`;break}throw TypeError(n)}function p(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`any`,n=t?f(t).index:l.length,r=[];for(let t=0;t{let n=c.get(t);return!n.isAny&&n.test(e)});return t.length?t:[`any`]}function _(e){return e&&typeof e==`function`&&`_typedFunctionData`in e}function v(e,t,n){if(!_(e))throw TypeError(r);let i=n&&n.exact,a=T(Array.isArray(t)?t.join(`,`):t),o=x(a);if(!i||o in e.signatures){let t=e._typedFunctionData.signatureMap.get(o);if(t)return t}let s=a.length,c;if(i){c=[];let t;for(t in e.signatures)c.push(e._typedFunctionData.signatureMap.get(t))}else c=e._typedFunctionData.signatures;for(let e=0;e!e.has(t.name)))continue}n.push(r)}}if(c=n,c.length===0)break}let l;for(l of c)if(l.params.length<=s)return l;throw TypeError(`Signature not found (signature: `+(e.name||`unnamed`)+`(`+x(a,`, `)+`))`)}function y(e,t,n){return v(e,t,n).implementation}function b(e,t){let n=f(t);if(n.test(e))return e;let r=n.conversionsTo;if(r.length===0)throw Error(`There are no conversions to `+t+` defined.`);for(let t=0;t1&&arguments[1]!==void 0?arguments[1]:`,`;return e.map(e=>e.name).join(t)}function S(e){let t=e.indexOf(`...`)===0,n=(t?e.length>3?e.slice(3):`any`:e).split(`|`).map(e=>f(e.trim())),r=!1,i=t?`...`:``;return{types:n.map(function(e){return r=e.isAny||r,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:r,hasConversion:!1,restParam:t}}function C(e){let t=P(e.types.map(e=>e.name)),n=e.hasAny,r=e.name,i=t.map(function(e){let t=f(e.from);return n=t.isAny||n,r+=`|`+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:r,hasAny:n,hasConversion:i.length>0,restParam:e.restParam}}function w(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach(t=>e.typeSet.add(t.name))),e.typeSet}function T(e){let t=[];if(typeof e!=`string`)throw TypeError(`Signatures must be strings`);let n=e.trim();if(n===``)return t;let r=n.split(`,`);for(let e=0;e=n+1}}else if(e.length===0)return function(e){return e.length===0};else if(e.length===1)return n=D(e[0]),function(e){return n(e[0])&&e.length===1};else if(e.length===2)return n=D(e[0]),r=D(e[1]),function(e){return n(e[0])&&r(e[1])&&e.length===2};else return t=e.map(D),function(e){for(let n=0;n{let r=A(e.params,t),i;for(i of r)n.add(i)}),n.has(`any`)?[`any`]:Array.from(n)}function N(e,t,n){let r,i,a=e||`unnamed`,o=n,s;for(s=0;s{let r=D(k(n.params,s));(s0){let e=g(t[s]);return r=TypeError(`Unexpected type of argument in function `+a+` (expected: `+i.join(` or `)+`, actual: `+e.join(` | `)+`, index: `+s+`)`),r.data={category:`wrongType`,fn:a,index:s,actual:e,expected:i},r}}else o=e}let c=o.map(function(e){return E(e.params)?1/0:e.params.length});if(t.lengthl)return r=TypeError(`Too many arguments in function `+a+` (expected: `+l+`, actual: `+t.length+`)`),r.data={category:`tooManyArgs`,fn:a,index:t.length,expectedLength:l},r;let u=[];for(let e=0;e0)return .001;let r=te(e),i=te(t);if(e.hasConversion){if(!t.hasConversion)return(1+r)*1e-6}else if(t.hasConversion)return-(1+i)*1e-6;let a=r-i;return a<0?-1e-7:a>0?1e-7:0}function re(e,t){let n=e.params,r=t.params,i=ue(n),a=ue(r),o=E(n),s=E(r);if(o&&i.hasAny){if(!s||!a.hasAny)return 1e7}else if(s&&a.hasAny)return-1e7;let c=0,l=0,u;for(u of n)u.hasAny&&++c,u.hasConversion&&++l;let d=0,f=0;for(u of r)u.hasAny&&++d,u.hasConversion&&++f;if(c!==d)return(c-d)*1e6;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1e5}else if(s&&a.hasConversion)return-1e5;if(l!==f)return(l-f)*1e4;if(o){if(!s)return 1e3}else if(s)return-1e3;let p=(n.length-r.length)*(o?-100:100);if(p!==0)return p;let m=[],h=0;for(let e=0;ee.hasConversion)){let i=E(e),a=e.map(I);r=a.map(e=>e.name).join(`;`),n=function(){let e=[],n=i?arguments.length-1:arguments.length;for(let t=0;t`+e.conversion.to+`,`,a.push(f(e.conversion.from).test),o.push(e.conversion.convert))}),s=s?s.slice(0,-1):`pass`;let c=e=>e;switch(o.length){case 0:break;case 1:t=a[0],r=o[0],c=function(e){return t(e)?r(e):e};break;case 2:t=a[0],n=a[1],r=o[0],i=o[1],c=function(e){return t(e)?r(e):n(e)?i(e):e};break;default:c=function(e){for(let t=0;te.name).join(`|`),hasAny:e.some(e=>e.isAny),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map(function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}});return pe(a,function(i){return t(e,n+1,r.concat([i]))})}else return[r]}return t(e,0,[])}function ie(e,t){let n=Math.max(e.length,t.length);for(let r=0;r=r:o?r>=i:r===i}function ae(e){return e.map(e=>_e(e)?he(e.referToSelf.callback):ge(e)?B(e.referTo.references,e.referTo.callback):e)}function R(e,t,n){let r=[],i;for(i of e){let e=n[i];if(typeof e!=`number`)throw TypeError(`No definition for referenced signature "`+i+`"`);if(e=t[e],typeof e!=`function`)return!1;r.push(e)}return r}function z(e,t,n){let r=ae(e),i=Array(r.length).fill(!1),a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o{let r=e[n];if(t.test(r.toString()))throw SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function se(e,r){if(d.createCount++,Object.keys(r).length===0)throw SyntaxError(`No signatures provided`);d.warnAgainstDeprecatedThis&&oe(r);let i=[],a=[],o={},s=[],c;for(c in r){if(!Object.prototype.hasOwnProperty.call(r,c))continue;let e=T(c);if(!e)continue;i.forEach(function(t){if(ie(t,e))throw TypeError(`Conflicting signatures "`+x(t)+`" and "`+x(e)+`".`)}),i.push(e);let t=a.length;a.push(r[c]);let n=e.map(C),l;for(l of L(n)){let e=x(l);s.push({params:l,name:e,fn:t}),l.every(e=>!e.hasConversion)&&(o[e]=t)}}s.sort(re);let l=z(a,o,xe),u;for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&(o[u]=l[o[u]]);let f=[],p=new Map;for(u of s)p.has(u.name)||(u.fn=l[u.fn],f.push(u),p.set(u.name,u));let m=f[0]&&f[0].params.length<=2&&!E(f[0].params),h=f[1]&&f[1].params.length<=2&&!E(f[1].params),g=f[2]&&f[2].params.length<=2&&!E(f[2].params),_=f[3]&&f[3].params.length<=2&&!E(f[3].params),v=f[4]&&f[4].params.length<=2&&!E(f[4].params),y=f[5]&&f[5].params.length<=2&&!E(f[5].params),b=m&&h&&g&&_&&v&&y;for(let e=0;ee.test),ye=f.map(e=>e.implementation),be=function(){for(let e=ge;e<_e;e++)if(ve[e](arguments))return ye[e].apply(this,arguments);return d.onMismatch(e,arguments,f)};function xe(e,t){return arguments.length===de&&S(e)&&N(t)?ae.apply(this,arguments):arguments.length===fe&&w(e)&&ee(t)?R.apply(this,arguments):arguments.length===pe&&k(e)&&te(t)?se.apply(this,arguments):arguments.length===me&&A(e)&&ne(t)?ce.apply(this,arguments):arguments.length===B&&j(e)&&P(t)?le.apply(this,arguments):arguments.length===he&&M(e)&&I(t)?ue.apply(this,arguments):be.apply(this,arguments)}try{Object.defineProperty(xe,"name",{value:e})}catch{}return xe.signatures=o,xe._typedFunctionData={signatures:f,signatureMap:p},xe}function ce(e,t,n){throw N(e,t,n)}function le(e){return de(e,0,e.length-1)}function ue(e){return e[e.length-1]}function de(e,t,n){return Array.prototype.slice.call(e,t,n)}function fe(e,t){for(let n=0;nx(T(e))),t=ue(arguments);if(typeof t!=`function`)throw TypeError(`Callback function expected as last argument`);return B(e,t)}function B(e,t){return{referTo:{references:e,callback:t}}}function he(e){if(typeof e!=`function`)throw TypeError(`Callback function expected as first argument`);return{referToSelf:{callback:e}}}function ge(e){return e&&typeof e.referTo==`object`&&Array.isArray(e.referTo.references)&&typeof e.referTo.callback==`function`}function _e(e){return e&&typeof e.referToSelf==`object`&&typeof e.referToSelf.callback==`function`}function ve(e,t){if(!e)return t;if(t&&t!==e){let n=Error(`Function names do not match (expected: `+e+`, actual: `+t+`)`);throw n.data={actual:t,expected:e},n}return e}function ye(e){let t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(e[n])||typeof e[n].signature==`string`)&&(t=ve(t,e[n].name));return t}function be(e,t){let n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(n in e&&t[n]!==e[n]){let r=Error(`Signature "`+n+`" is defined twice`);throw r.data={signature:n,sourceFunction:t[n],destFunction:e[n]},r}e[n]=t[n]}}let xe=d;d=function(e){let t=typeof e==`string`,n=+!!t,r=t?e:``,i={};for(let e=n;e1&&arguments[1]!==void 0?arguments[1]:{override:!1};Se(e);let n=f(e.to),r=n.conversionsTo.find(t=>t.from===e.from);if(r)if(t&&t.override)d.removeConversion({from:r.from,to:e.to,convert:r.convert});else throw Error(`There is already a conversion from "`+e.from+`" to "`+n.name+`"`);n.conversionsTo.push({from:e.from,to:n.name,convert:e.convert,index:u++})},d.addConversions=function(e,t){e.forEach(e=>d.addConversion(e,t))},d.removeConversion=function(e){Se(e);let t=f(e.to),n=fe(t.conversionsTo,t=>t.from===e.from);if(!n)throw Error(`Attempt to remove nonexistent conversion from `+e.from+` to `+e.to);if(n.convert!==e.convert)throw Error(`Conversion to remove does not match existing conversion`);let r=t.conversionsTo.indexOf(n);t.conversionsTo.splice(r,1)},d.resolve=function(e,t){if(!_(e))throw TypeError(r);let n=e._typedFunctionData.signatures;for(let e=0;e!BD(e)).every(e=>n[e]!==void 0)){var r=t.filter(e=>n[e]===void 0);throw Error(`Cannot create function "${e}", some dependencies are missing: ${r.map(e=>`"${e}"`).join(`, `)}.`)}}function BD(e){return e&&e[0]===`?`}function VD(e){return e&&e[0]===`?`?e.slice(1):e}function HD(e){return typeof e==`boolean`?!0:Number.isFinite(e)?e===Math.round(e):!1}function UD(e,t){if(t.number===`bigint`)try{BigInt(e)}catch{return t.numberFallback}return t.number}var WD=Math.sign||function(e){return e>0?1:e<0?-1:0},GD=Math.log2||function(e){return Math.log(e)/Math.LN2},KD=Math.log10||function(e){return Math.log(e)/Math.LN10},qD=Math.log1p||function(e){return Math.log(e+1)},JD=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},YD=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function XD(e,t,n){var r={2:`0b`,8:`0o`,16:`0x`}[t],i=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!HD(n))throw Error(`size must be an integer`);if(e>2**(n-1)-1||e<-(2**(n-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!HD(e))throw Error(`Value must be an integer`);e<0&&(e+=2**n),i=`i${n}`}var a=``;return e<0&&(e=-e,a=`-`),`${a}${r}${e.toString(t)}${i}`}function ZD(e,t){if(typeof t==`function`)return t(e);if(e===1/0)return`Infinity`;if(e===-1/0)return`-Infinity`;if(isNaN(e))return`NaN`;var{notation:n,precision:r,wordSize:i}=QD(t);switch(n){case`fixed`:return tO(e,r);case`exponential`:return nO(e,r);case`engineering`:return eO(e,r);case`bin`:return XD(e,2,i);case`oct`:return XD(e,8,i);case`hex`:return XD(e,16,i);case`auto`:return rO(e,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return e===`.`?t:e+t});default:throw Error(`Unknown notation "`+n+`". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.`)}}function QD(e){var t=`auto`,n,r;if(e!==void 0)if(jE(e))n=e;else if(ME(e))n=e.toNumber();else if(ZE(e))e.precision!==void 0&&(n=hO(e.precision,()=>{throw Error(`Option "precision" must be a number or BigNumber`)})),e.wordSize!==void 0&&(r=hO(e.wordSize,()=>{throw Error(`Option "wordSize" must be a number or BigNumber`)})),e.notation&&(t=e.notation);else throw Error(`Unsupported type of options, number, BigNumber, or object expected`);return{notation:t,precision:n,wordSize:r}}function $D(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw SyntaxError(`Invalid number `+e);var n=t[1],r=t[2],i=parseFloat(t[4]||`0`),a=r.indexOf(`.`);i+=a===-1?r.length-1:a-1;var o=r.replace(`.`,``).replace(/^0*/,function(e){return i-=e.length,``}).replace(/0*$/,``).split(``).map(function(e){return parseInt(e)});return o.length===0&&(o.push(0),i++),{sign:n,coefficients:o,exponent:i}}function eO(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=iO($D(e),t),r=n.exponent,i=n.coefficients,a=r%3==0?r:r<0?r-3-r%3:r-r%3;if(jE(t))for(;t>i.length||r-a+1>i.length;)i.push(0);else for(var o=Math.abs(r-a)-(i.length-1),s=0;s0;)l++,c--;var u=i.slice(l).join(``),d=jE(t)&&u.length||u.match(/[1-9]/)?`.`+u:``,f=i.slice(0,l).join(``)+d+`e`+(r>=0?`+`:``)+a.toString();return n.sign+f}function tO(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=$D(e),r=typeof t==`number`?iO(n,n.exponent+1+t):n,i=r.coefficients,a=r.exponent+1,o=a+(t||0);return i.length0?`.`+i.join(``):``)+`e`+(a>=0?`+`:``)+a}function rO(e,t,n){if(isNaN(e)||!Number.isFinite(e))return String(e);var r=gO(n?.lowerExp,-3),i=gO(n?.upperExp,5),a=$D(e),o=t?iO(a,t):a;if(o.exponent=i)return nO(e,t);var s=o.coefficients,c=o.exponent;s.length0?c:0;return lt&&r.splice(t,r.length-t)[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),n.exponent++,i++),i--,r[i]++}return n}function aO(e){for(var t=[],n=0;n2&&arguments[2]!==void 0?arguments[2]:1e-8,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(n<=0)throw Error(`Relative tolerance must be greater than 0`);if(r<0)throw Error(`Absolute tolerance must be at least 0`);return isNaN(e)||isNaN(t)?!1:!Number.isFinite(e)||!Number.isFinite(t)?e===t:e===t?!0:Math.abs(e-t)<=Math.max(n*Math.max(Math.abs(e),Math.abs(t)),r)}var cO=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},lO=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},uO=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},dO=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},fO=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},pO=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function mO(e,t){return(e>0?!0:e<0?!1:1/e==1/0)^(t>0?!0:t<0?!1:1/t==1/0)?-e:e}function hO(e,t){if(jE(e))return e;if(ME(e))return e.toNumber();t()}function gO(e,t){return jE(e)?e:ME(e)?e.toNumber():t}var _O=l(LD(),1),vO=function(){return vO=_O.default.create,_O.default},yO=Z(`typed`,[`?BigNumber`,`?Complex`,`?DenseMatrix`,`?Fraction`],function(e){var{BigNumber:t,Complex:n,DenseMatrix:r,Fraction:i}=e,a=vO();return a.clear(),a.addTypes([{name:`number`,test:jE},{name:`Complex`,test:PE},{name:`BigNumber`,test:ME},{name:`bigint`,test:NE},{name:`Fraction`,test:FE},{name:`Unit`,test:IE},{name:`identifier`,test:e=>LE&&/^(?:[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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(e)},{name:`string`,test:LE},{name:`Chain`,test:bD},{name:`Array`,test:RE},{name:`Matrix`,test:zE},{name:`DenseMatrix`,test:VE},{name:`SparseMatrix`,test:HE},{name:`Range`,test:UE},{name:`Index`,test:WE},{name:`boolean`,test:GE},{name:`ResultSet`,test:KE},{name:`Help`,test:qE},{name:`function`,test:JE},{name:`Date`,test:YE},{name:`RegExp`,test:XE},{name:`null`,test:tD},{name:`undefined`,test:nD},{name:`AccessorNode`,test:rD},{name:`ArrayNode`,test:iD},{name:`AssignmentNode`,test:aD},{name:`BlockNode`,test:oD},{name:`ConditionalNode`,test:sD},{name:`ConstantNode`,test:cD},{name:`FunctionNode`,test:dD},{name:`FunctionAssignmentNode`,test:uD},{name:`IndexNode`,test:fD},{name:`Node`,test:pD},{name:`ObjectNode`,test:mD},{name:`OperatorNode`,test:hD},{name:`ParenthesisNode`,test:gD},{name:`RangeNode`,test:_D},{name:`RelationalNode`,test:vD},{name:`SymbolNode`,test:yD},{name:`Map`,test:QE},{name:`Object`,test:ZE}]),a.addConversions([{from:`number`,to:`BigNumber`,convert:function(e){if(t||bO(e),oO(e)>15)throw TypeError(`Cannot implicitly convert a number with >15 significant digits to BigNumber (value: `+e+`). Use function bignumber(x) to convert to BigNumber.`);return new t(e)}},{from:`number`,to:`Complex`,convert:function(e){return n||xO(e),new n(e,0)}},{from:`BigNumber`,to:`Complex`,convert:function(e){return n||xO(e),new n(e.toNumber(),0)}},{from:`bigint`,to:`number`,convert:function(e){if(e>2**53-1)throw 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 t||bO(e),new t(e.toString())}},{from:`bigint`,to:`Fraction`,convert:function(e){return i||CO(e),new i(e)}},{from:`Fraction`,to:`BigNumber`,convert:function(e){throw 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||xO(e),new n(e.valueOf(),0)}},{from:`number`,to:`Fraction`,convert:function(e){i||CO(e);var t=new i(e);if(t.valueOf()!==e)throw 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 Error(`Cannot convert "`+e+`" to a number`);return t}},{from:`string`,to:`BigNumber`,convert:function(e){t||bO(e);try{return new t(e)}catch{throw Error(`Cannot convert "`+e+`" to BigNumber`)}}},{from:`string`,to:`bigint`,convert:function(e){try{return BigInt(e)}catch{throw Error(`Cannot convert "`+e+`" to BigInt`)}}},{from:`string`,to:`Fraction`,convert:function(e){i||CO(e);try{return new i(e)}catch{throw Error(`Cannot convert "`+e+`" to Fraction`)}}},{from:`string`,to:`Complex`,convert:function(e){n||xO(e);try{return new n(e)}catch{throw Error(`Cannot convert "`+e+`" to Complex`)}}},{from:`boolean`,to:`number`,convert:function(e){return+e}},{from:`boolean`,to:`BigNumber`,convert:function(e){return t||bO(e),new t(+e)}},{from:`boolean`,to:`bigint`,convert:function(e){return BigInt(+e)}},{from:`boolean`,to:`Fraction`,convert:function(e){return i||CO(e),new i(+e)}},{from:`boolean`,to:`string`,convert:function(e){return String(e)}},{from:`Array`,to:`Matrix`,convert:function(e){return r||SO(),new r(e)}},{from:`Matrix`,to:`Array`,convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&BE(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&BE(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a});function bO(e){throw Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function xO(e){throw Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function SO(){throw Error(`Cannot convert array into a Matrix: no class 'DenseMatrix' provided`)}function CO(e){throw Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}var wO=Z(`ResultSet`,[],()=>{function e(t){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);this.entries=t||[]}return e.prototype.type=`ResultSet`,e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return`[`+this.entries.map(String).join(`, `)+`]`},e.prototype.toJSON=function(){return{mathjs:`ResultSet`,entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e},{isClass:!0}),TO=9e15,EO=1e9,DO=`0123456789abcdef`,OO=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,kO=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,AO={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-TO,maxE:TO,crypto:!1},jO,MO,NO=!0,PO=`[DecimalError] `,FO=PO+`Invalid argument: `,IO=PO+`Precision limit exceeded`,LO=PO+`crypto unavailable`,RO=`[object Decimal]`,zO=Math.floor,BO=Math.pow,VO=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,HO=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,UO=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,WO=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,GO=1e7,KO=7,qO=9007199254740991,JO=OO.length-1,YO=kO.length-1,Q={toStringTag:RO};Q.absoluteValue=Q.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),nk(e)},Q.ceil=function(){return nk(new this.constructor(this),this.e+1,2)},Q.clampedTo=Q.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(FO+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},Q.comparedTo=Q.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=rs[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},Q.cosine=Q.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+KO,r.rounding=1,n=ek(r,bk(r,n)),r.precision=e,r.rounding=t,nk(MO==2||MO==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},Q.cubeRoot=Q.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(NO=!1,a=u.s*BO(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=XO(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=BO(n,1/3),e=zO((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=tk(l.plus(u).times(s),l.plus(c),o+2,1),XO(s.d).slice(0,o)===(n=XO(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(nk(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(nk(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return NO=!0,nk(r,e,d.rounding,t)},Q.decimalPlaces=Q.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-zO(this.e/KO))*KO,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},Q.dividedBy=Q.div=function(e){return tk(this,new this.constructor(e))},Q.dividedToIntegerBy=Q.divToInt=function(e){var t=this,n=t.constructor;return nk(tk(t,new n(e),0,1,1),n.precision,n.rounding)},Q.equals=Q.eq=function(e){return this.cmp(e)===0},Q.floor=function(){return nk(new this.constructor(this),this.e+1,3)},Q.greaterThan=Q.gt=function(e){return this.cmp(e)>0},Q.greaterThanOrEqualTo=Q.gte=function(e){var t=this.cmp(e);return t==1||t===0},Q.hyperbolicCosine=Q.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/yk(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=vk(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return nk(a,o.precision=n,o.rounding=r,!0)},Q.hyperbolicSine=Q.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=vk(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/yk(5,e)),i=vk(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,nk(i,t,n,!0)},Q.hyperbolicTangent=Q.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,tk(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},Q.inverseCosine=Q.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?ok(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?ok(t,r,i):new t(0):new t(NaN)},Q.inverseHyperbolicCosine=Q.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,NO=!1,n=n.times(n).minus(1).sqrt().plus(n),NO=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},Q.inverseHyperbolicSine=Q.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,NO=!1,n=n.times(n).plus(1).sqrt().plus(n),NO=!0,r.precision=e,r.rounding=t,n.ln())},Q.inverseHyperbolicTangent=Q.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?nk(new a(i),e,t,!0):(a.precision=n=r-i.e,i=tk(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},Q.inverseSine=Q.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=ok(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},Q.inverseTangent=Q.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=YO)return o=ok(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=YO)return o=ok(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/KO+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(NO=!1,t=Math.ceil(s/KO),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<this.d.length-2},Q.isNaN=function(){return!this.s},Q.isNegative=Q.isNeg=function(){return this.s<0},Q.isPositive=Q.isPos=function(){return this.s>0},Q.isZero=function(){return!!this.d&&this.d[0]===0},Q.lessThan=Q.lt=function(e){return this.cmp(e)<0},Q.lessThanOrEqualTo=Q.lte=function(e){return this.cmp(e)<1},Q.logarithm=Q.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(NO=!1,s=d+p,o=pk(l,s),r=t?ak(u,s+10):pk(e,s),c=tk(o,r,s,1),QO(c.d,i=d,f))do if(s+=10,o=pk(l,s),r=t?ak(u,s+10):pk(e,s),c=tk(o,r,s,1),!a){+XO(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=nk(c,d+1,0));break}while(QO(c.d,i+=10,f));return NO=!0,nk(c,d,f)},Q.minus=Q.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return NO?nk(e,s,c):e}if(n=zO(e.e/KO),u=zO(p.e/KO),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/KO),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/GO|0,l[i]%=GO;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=ik(l,r),NO?nk(e,s,c):e},Q.precision=Q.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(FO+e);return n.d?(t=sk(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},Q.round=function(){var e=this,t=e.constructor;return nk(new t(e),e.e+1,t.rounding)},Q.sine=Q.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+KO,r.rounding=1,n=_k(r,bk(r,n)),r.precision=e,r.rounding=t,nk(MO>2?n.neg():n,e,t,!0)):new r(NaN)},Q.squareRoot=Q.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(NO=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=XO(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=zO((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(tk(o,a,n+2,1)).times(.5),XO(a.d).slice(0,n)===(t=XO(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(nk(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(nk(r,c+1,1),e=!r.times(r).eq(o));break}return NO=!0,nk(r,c,u.rounding,e)},Q.tangent=Q.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=tk(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,nk(MO==2||MO==4?n.neg():n,e,t,!0)):new r(NaN)},Q.times=Q.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=zO(u.e/KO)+zO(e.e/KO),c=f.length,l=p.length,c=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%GO|0,t=s/GO|0;a[i]=(a[i]+t)%GO|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=ik(a,n),NO?nk(e,d.precision,d.rounding):e},Q.toBinary=function(e,t){return xk(this,2,e,t)},Q.toDecimalPlaces=Q.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(ZO(e,0,EO),t===void 0?t=r.rounding:ZO(t,0,8),nk(n,e+n.e+1,t))},Q.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=rk(r,!0):(ZO(e,0,EO),t===void 0?t=i.rounding:ZO(t,0,8),r=nk(new i(r),e+1,t),n=rk(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},Q.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=rk(i):(ZO(e,0,EO),t===void 0?t=a.rounding:ZO(t,0,8),r=nk(new a(i),e+i.e+1,t),n=rk(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},Q.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=sk(m)-p.e-1,o=a%KO,t.d[0]=BO(10,o<0?KO+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(FO+s);e=s.gt(t)?a>0?t:l:s}for(NO=!1,s=new h(XO(m)),u=h.precision,h.precision=a=m.length*KO*2;d=tk(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=tk(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=tk(l,r,a,1).minus(p).abs().cmp(tk(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,NO=!0,f},Q.toHexadecimal=Q.toHex=function(e,t){return xk(this,16,e,t)},Q.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:ZO(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(NO=!1,n=tk(n,e,0,t,1).times(e),NO=!0,nk(n)):(e.s=n.s,n=e),n},Q.toNumber=function(){return+this},Q.toOctal=function(e,t){return xk(this,8,e,t)},Q.toPower=Q.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(BO(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return nk(s,r,a);if(t=zO(e.e/KO),t>=e.d.length-1&&(n=l<0?-l:l)<=qO)return i=lk(c,s,n,r),e.s<0?new c(1).div(i):nk(i,r,a);if(o=s.s,o<0){if(tc.maxE+1||t0?o/0:0):(NO=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=fk(e.times(pk(s,r+n)),r),i.d&&(i=nk(i,r+5,1),QO(i.d,r,a)&&(t=r+10,i=nk(fk(e.times(pk(s,t+n)),t),t+5,1),+XO(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=nk(i,r+1,0)))),i.s=o,NO=!0,c.rounding=a,nk(i,r,a))},Q.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=rk(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(ZO(e,1,EO),t===void 0?t=i.rounding:ZO(t,0,8),r=nk(new i(r),e,t),n=rk(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},Q.toSignificantDigits=Q.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(ZO(e,1,EO),t===void 0?t=r.rounding:ZO(t,0,8)),nk(new r(n),e,t)},Q.toString=function(){var e=this,t=e.constructor,n=rk(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},Q.truncated=Q.trunc=function(){return nk(new this.constructor(this),this.e+1,1)},Q.valueOf=Q.toJSON=function(){var e=this,t=e.constructor,n=rk(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function XO(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;tn)throw Error(FO+e)}function QO(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=KO,i=0):(i=Math.ceil((t+1)/KO),t%=KO),a=BO(10,KO-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==BO(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==BO(10,t-3)-1,o}function $O(e,t,n){for(var r,i=[0],a,o=0,s=e.length;on-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function ek(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/yk(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=vk(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var tk=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k=r.constructor,A=r.s==i.s?1:-1,j=r.d,M=i.d;if(!j||!j[0]||!M||!M[0])return new k(!r.s||!i.s||(j?M&&j[0]==M[0]:!M)?NaN:j&&j[0]==0||!M?A*0:A/0);for(c?(p=1,u=r.e-i.e):(c=GO,p=KO,u=zO(r.e/p)-zO(i.e/p)),D=M.length,T=j.length,_=new k(A),v=_.d=[],d=0;M[d]==(j[d]||0);d++);if(M[d]>(j[d]||0)&&u--,a==null?(S=a=k.precision,o=k.rounding):S=s?a+(r.e-i.e)+1:a,S<0)v.push(1),m=!0;else{if(S=S/p+2|0,d=0,D==1){for(f=0,M=M[0],S++;(d1&&(M=e(M,f,c),j=e(j,f,c),D=M.length,T=j.length),w=D,y=j.slice(0,D),b=y.length;b=c/2&&++E;do f=0,l=t(M,y,D,b),l<0?(x=y[0],D!=b&&(x=x*c+(y[1]||0)),f=x/E|0,f>1?(f>=c&&(f=c-1),h=e(M,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,D=10;f/=10)d++;_.e=d+u*p-1,nk(_,s?a+_.e+1:a,o,m)}return _}})();function nk(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=KO,o=t,u=d[f=0],c=u/BO(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/KO),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=KO,o=a-KO+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=KO,o=a-KO+i,c=o<0?0:u/BO(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%BO(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/BO(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=BO(10,(KO-t%KO)%KO),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=BO(10,KO-a),d[f]=o>0?(u/BO(10,i-o)%BO(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==GO&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=GO)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return NO&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+`.`+a.slice(1)+ck(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+ck(-i-1)+a,n&&(r=n-o)>0&&(a+=ck(r))):i>=o?(a+=ck(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+ck(r))):((r=i+1)0&&(i+1===o&&(a+=`.`),a+=ck(r))),a}function ik(e,t){var n=e[0];for(t*=KO;n>=10;n/=10)t++;return t}function ak(e,t,n){if(t>JO)throw NO=!0,n&&(e.precision=n),Error(IO);return nk(new e(OO),t,1,!0)}function ok(e,t,n){if(t>YO)throw Error(IO);return nk(new e(kO),t,n,!0)}function sk(e){var t=e.length-1,n=t*KO+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ck(e){for(var t=``;e--;)t+=`0`;return t}function lk(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/KO+4);for(NO=!1;;){if(n%2&&(a=a.times(t),Sk(a.d,o)&&(i=!0)),n=zO(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),Sk(t.d,o)}return NO=!0,a}function uk(e){return e.d[e.d.length-1]&1}function dk(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(NO=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(BO(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=nk(a.times(e),c,1),n=n.times(++u),s=o.plus(tk(a,n,c,1)),XO(s.d).slice(0,c)===XO(o.d).slice(0,c)){for(i=d;i--;)o=nk(o.times(o),c,1);if(t==null)if(l<3&&QO(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return nk(o,f.precision=m,p,NO=!0);else return f.precision=m,o}o=s}}function pk(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(NO=!1,u=y):u=t,_.precision=u+=m,n=XO(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=XO(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=ak(_,u+2,y).times(a+``),h=pk(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?nk(h,y,v,NO=!0):h;for(d=h,c=o=h=tk(h.minus(1),h.plus(1),u,1),f=nk(h.times(h),u,1),i=3;;){if(o=nk(o.times(f),u,1),l=c.plus(tk(o,new _(i),u,1)),XO(l.d).slice(0,u)===XO(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(ak(_,u+2,y).times(a+``))),c=tk(c,new _(p),u,1),t==null)if(QO(c.d,u-m,v,s))_.precision=u+=m,l=o=h=tk(d.minus(1),d.plus(1),u,1),f=nk(h.times(h),u,1),i=s=1;else return nk(c,_.precision=y,v,NO=!0);else return _.precision=y,c;c=l,i+=2}}function mk(e){return String(e.s*e.s/0)}function hk(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%KO,n<0&&(r+=KO),re.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),WO.test(t))return hk(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(HO.test(t))n=16,t=t.toLowerCase();else if(VO.test(t))n=2;else if(UO.test(t))n=8;else throw Error(FO+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=lk(r,new r(n),a,a*2)),l=$O(t,n,GO),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=ik(l,u),e.d=l,NO=!1,o&&(e=tk(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?BO(2,c):uA.pow(2,c))),NO=!0,e)}function _k(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:vk(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/yk(5,n)),t=vk(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function vk(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/KO);for(NO=!1,c=n.times(n),s=new e(r);;){if(o=tk(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=tk(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return NO=!0,o.d.length=d+1,o}function yk(e,t){for(var n=e;--t;)n*=e;return n}function bk(e,t){var n,r=t.s<0,i=ok(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return MO=r?4:1,t;if(n=t.divToInt(i),n.isZero())MO=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return MO=uk(n)?r?2:3:r?4:1,t;MO=uk(n)?r?1:4:r?3:2}return t.minus(i).abs()}function xk(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?(ZO(n,1,EO),r===void 0?r=p.rounding:ZO(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=mk(e);else{for(u=rk(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=$O(rk(f),10,i),f.e=f.d.length),d=$O(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=tk(e,f,n,r,0,i),d=e.d,a=e.e,l=jO),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=$O(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;oc)for(a-=c;a--;)u+=`0`;else at)return e.length=t,!0}function Ck(e){return new this(e).abs()}function wk(e){return new this(e).acos()}function Tk(e){return new this(e).acosh()}function Ek(e,t){return new this(e).plus(t)}function Dk(e){return new this(e).asin()}function Ok(e){return new this(e).asinh()}function kk(e){return new this(e).atan()}function Ak(e){return new this(e).atanh()}function jk(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=ok(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?ok(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=ok(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(tk(e,t,a,1)),t=ok(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(tk(e,t,a,1)),n}function Mk(e){return new this(e).cbrt()}function Nk(e){return nk(e=new this(e),e.e+1,2)}function Pk(e,t,n){return new this(e).clamp(t,n)}function Fk(e){if(!e||typeof e!=`object`)throw Error(PO+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,EO,`rounding`,0,8,`toExpNeg`,-TO,0,`toExpPos`,0,TO,`maxE`,0,TO,`minE`,-TO,0,`modulo`,0,9];for(t=0;t=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(FO+n+`: `+r);if(n=`crypto`,i&&(this[n]=AO[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(LO);else this[n]=!1;else throw Error(FO+n+`: `+r);return this}function Ik(e){return new this(e).cos()}function Lk(e){return new this(e).cosh()}function Rk(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,Uk(e)){a.s=e.s,NO?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e=10;n/=10)t++;NO?t>i.maxE?(a.e=NaN,a.d=null):t=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(LO);for(r=s[--a],e%=KO,r&&e&&(i=BO(10,KO-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=KO)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r{var{on:t,config:n}=e,r=uA.clone({precision:n.precision,modulo:uA.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type=`BigNumber`,r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:`BigNumber`,value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t(`config`,function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})}),r},{isClass:!0}),fA=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},pA=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},mA=e=>{let t=Math.sin(.5*e);return-2*t*t},hA=function(e,t){return e=Math.abs(e),t=Math.abs(t),e0&&gA();break;case`number`:n.im=0,n.re=e;break;default:gA()}return isNaN(n.re)||isNaN(n.im),n};function $(e,t){if(!(this instanceof $))return new $(e,t);let n=yA(e,t);this.re=n.re,this.im=n.im}$.prototype={re:0,im:0,sign:function(){let e=hA(this.re,this.im);return new $(this.re/e,this.im/e)},add:function(e,t){let n=yA(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?$.NAN:$.INFINITY:new $(this.re+n.re,this.im+n.im)},sub:function(e,t){let n=yA(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?$.NAN:$.INFINITY:new $(this.re-n.re,this.im-n.im)},mul:function(e,t){let n=yA(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),a=this.re===0&&this.im===0,o=n.re===0&&n.im===0;return r&&o||i&&a?$.NAN:r||i?$.INFINITY:n.im===0&&this.im===0?new $(this.re*n.re,0):new $(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){let n=yA(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),a=this.re===0&&this.im===0,o=n.re===0&&n.im===0;if(a&&o||r&&i)return $.NAN;if(o||r)return $.INFINITY;if(a||i)return $.ZERO;if(n.im===0)return new $(this.re/n.re,this.im/n.re);if(Math.abs(n.re)0)return new $(this.re**+n.re,0);if(this.re===0)switch((n.re%4+4)%4){case 0:return new $(this.im**+n.re,0);case 1:return new $(0,this.im**+n.re);case 2:return new $(-(this.im**+n.re),0);case 3:return new $(0,-(this.im**+n.re))}}if(r&&n.re>0)return $.ZERO;let i=Math.atan2(this.im,this.re),a=_A(this.re,this.im),o=Math.exp(n.re*a-n.im*i),s=n.im*a+n.re*i;return new $(o*Math.cos(s),o*Math.sin(s))},sqrt:function(){let e=this.re,t=this.im;if(t===0)return e>=0?new $(Math.sqrt(e),0):new $(0,Math.sqrt(-e));let n=hA(e,t),r=Math.sqrt(.5*(n+Math.abs(e))),i=Math.abs(t)/(2*r);return e>=0?new $(r,t<0?-i:i):new $(i,t<0?-r:r)},exp:function(){let e=Math.exp(this.re);return this.im===0?new $(e,0):new $(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){let e=this.re,t=this.im;return new $(Math.expm1(e)*Math.cos(t)+mA(t),Math.exp(e)*Math.sin(t))},log:function(){let e=this.re,t=this.im;return t===0&&e>0?new $(Math.log(e),0):new $(_A(e,t),Math.atan2(t,e))},abs:function(){return hA(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){let e=this.re,t=this.im;return new $(Math.sin(e)*fA(t),Math.cos(e)*pA(t))},cos:function(){let e=this.re,t=this.im;return new $(Math.cos(e)*fA(t),-Math.sin(e)*pA(t))},tan:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)+fA(t);return new $(Math.sin(e)/n,pA(t)/n)},cot:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)-fA(t);return new $(-Math.sin(e)/n,pA(t)/n)},sec:function(){let e=this.re,t=this.im,n=.5*fA(2*t)+.5*Math.cos(2*e);return new $(Math.cos(e)*fA(t)/n,Math.sin(e)*pA(t)/n)},csc:function(){let e=this.re,t=this.im,n=.5*fA(2*t)-.5*Math.cos(2*e);return new $(Math.sin(e)*fA(t)/n,-Math.cos(e)*pA(t)/n)},asin:function(){let e=this.re,t=this.im,n=new $(t*t-e*e+1,-2*e*t).sqrt(),r=new $(n.re-t,n.im+e).log();return new $(r.im,-r.re)},acos:function(){let e=this.re,t=this.im,n=new $(t*t-e*e+1,-2*e*t).sqrt(),r=new $(n.re-t,n.im+e).log();return new $(Math.PI/2-r.im,r.re)},atan:function(){let e=this.re,t=this.im;if(e===0){if(t===1)return new $(0,1/0);if(t===-1)return new $(0,-1/0)}let n=e*e+(1-t)*(1-t),r=new $((1-t*t-e*e)/n,-2*e/n).log();return new $(-.5*r.im,.5*r.re)},acot:function(){let e=this.re,t=this.im;if(t===0)return new $(Math.atan2(1,e),0);let n=e*e+t*t;return n===0?new $(e===0?0:e/0,t===0?0:-t/0).atan():new $(e/n,-t/n).atan()},asec:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new $(0,1/0);let n=e*e+t*t;return n===0?new $(e===0?0:e/0,t===0?0:-t/0).acos():new $(e/n,-t/n).acos()},acsc:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new $(Math.PI/2,1/0);let n=e*e+t*t;return n===0?new $(e===0?0:e/0,t===0?0:-t/0).asin():new $(e/n,-t/n).asin()},sinh:function(){let e=this.re,t=this.im;return new $(pA(e)*Math.cos(t),fA(e)*Math.sin(t))},cosh:function(){let e=this.re,t=this.im;return new $(fA(e)*Math.cos(t),pA(e)*Math.sin(t))},tanh:function(){let e=2*this.re,t=2*this.im,n=fA(e)+Math.cos(t);return new $(pA(e)/n,Math.sin(t)/n)},coth:function(){let e=2*this.re,t=2*this.im,n=fA(e)-Math.cos(t);return new $(pA(e)/n,-Math.sin(t)/n)},csch:function(){let e=this.re,t=this.im,n=Math.cos(2*t)-fA(2*e);return new $(-2*pA(e)*Math.cos(t)/n,2*fA(e)*Math.sin(t)/n)},sech:function(){let e=this.re,t=this.im,n=Math.cos(2*t)+fA(2*e);return new $(2*fA(e)*Math.cos(t)/n,-2*pA(e)*Math.sin(t)/n)},asinh:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new $(0,0);let t=Math.abs(e),n=Math.log(t+Math.sqrt(t*t+1));return new $(e<0?-n:n,0)}let n=new $(e*e-t*t+1,2*e*t).sqrt();return new $(e+n.re,t+n.im).log()},acosh:function(){let e=this.re,t=this.im;if(t===0){if(e>1)return new $(Math.log(e+Math.sqrt(e-1)*Math.sqrt(e+1)),0);if(e<-1){let t=Math.sqrt(e*e-1);return new $(Math.log(-e+t),Math.PI)}return new $(0,Math.acos(e))}let n=new $(e-1,t).sqrt(),r=new $(e+1,t).sqrt();return new $(e+n.re*r.re-n.im*r.im,t+n.re*r.im+n.im*r.re).log()},atanh:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new $(0,0);if(e===1)return new $(1/0,0);if(e===-1)return new $(-1/0,0);if(-11){let t=(e+1)/(e-1);return new $(.5*Math.log(t),-Math.PI/2)}let t=(1+e)/(1-e);return new $(.5*Math.log(-t),Math.PI/2)}let n=1-e,r=1+e,i=n*n+t*t;if(i===0)return new $(e===-1?0:e/0,t===0?0:t/0);let a=(r*n-t*t)/i,o=(t*n+r*t)/i;return new $(_A(a,o)/2,Math.atan2(o,a)/2)},acoth:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new $(0,Math.PI/2);let n=e*e+t*t;return n===0?new $(e===0?0:e/0,t===0?0:-t/0).atanh():new $(e/n,-t/n).atanh()},acsch:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new $(1/0,0);let t=1/e;return new $(Math.log(t+Math.sqrt(t*t+1)),0)}let n=e*e+t*t;return n===0?new $(e===0?0:e/0,t===0?0:-t/0).asinh():new $(e/n,-t/n).asinh()},asech:function(){let e=this.re,t=this.im;if(this.isZero())return $.INFINITY;let n=e*e+t*t;return n===0?new $(e===0?0:e/0,t===0?0:-t/0).acosh():new $(e/n,-t/n).acosh()},inverse:function(){if(this.isZero())return $.INFINITY;if(this.isInfinite())return $.ZERO;let e=this.re,t=this.im,n=e*e+t*t;return new $(e/n,-t/n)},conjugate:function(){return new $(this.re,-this.im)},neg:function(){return new $(-this.re,-this.im)},ceil:function(e){return e=10**(e||0),new $(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=10**(e||0),new $(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=10**(e||0),new $(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){let n=yA(e,t);return Math.abs(n.re-this.re)<=$.EPSILON&&Math.abs(n.im-this.im)<=$.EPSILON},clone:function(){return new $(this.re,this.im)},toString:function(){let e=this.re,t=this.im,n=``;return this.isNaN()?`NaN`:this.isInfinite()?`Infinity`:(Math.abs(e)<$.EPSILON&&(e=0),Math.abs(t)<$.EPSILON&&(t=0),t===0?n+e:(e===0?t<0&&(t=-t,n+=`-`):(n+=e,n+=` `,t<0?(t=-t,n+=`-`):n+=`+`,n+=` `),t!==1&&(n+=t),n+`i`))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},$.ZERO=new $(0,0),$.ONE=new $(1,0),$.I=new $(0,1),$.PI=new $(Math.PI,0),$.E=new $(Math.E,0),$.INFINITY=new $(1/0,1/0),$.NAN=new $(NaN,NaN),$.EPSILON=1e-15;var bA=Z(`Complex`,[],()=>(Object.defineProperty($,"name",{value:`Complex`}),$.prototype.constructor=$,$.prototype.type=`Complex`,$.prototype.isComplex=!0,$.prototype.toJSON=function(){return{mathjs:`Complex`,re:this.re,im:this.im}},$.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},$.prototype.format=function(e){var t=``,n=this.im,r=this.re,i=ZD(this.re,e),a=ZD(this.im,e),o=jE(e)?e:e?e.precision:null;if(o!==null){var s=10**-o;Math.abs(r/n)t.re?1:e.ret.im?1:e.im`u`&&(BigInt=function(e){if(isNaN(e))throw Error(``);return e});var xA=BigInt(0),SA=BigInt(1),CA=BigInt(2),wA=BigInt(3),TA=BigInt(5),EA=BigInt(10);BigInt(2**53-1);var DA=2e3,OA={s:SA,n:xA,d:SA};function kA(e,t){try{e=BigInt(e)}catch{throw VA()}return e*t}function AA(e){return typeof e==`bigint`?e:Math.floor(e)}function jA(e,t){if(t===xA)throw BA();let n=Object.create(zA.prototype);n.s=e{t[e]=(t[e]||xA)+SA};for(;e%CA===xA;)n(CA),e/=CA;for(;e%wA===xA;)n(wA),e/=wA;for(;e%TA===xA;)n(TA),e/=TA;for(let t=0,r=CA+TA;r*r<=e;){for(;e%r===xA;)n(r),e/=r;r+=MA[t],t=t+1&7}return e>SA&&n(e),t}var PA=function(e,t){let n=xA,r=SA,i=SA;if(e!=null)if(t!==void 0){if(typeof e==`bigint`)n=e;else if(isNaN(e))throw VA();else if(e%1!=0)throw HA();else n=BigInt(e);if(typeof t==`bigint`)r=t;else if(isNaN(t))throw VA();else if(t%1!=0)throw HA();else r=BigInt(t);i=n*r}else if(typeof e==`object`){if(`d`in e&&`n`in e)n=BigInt(e.n),r=BigInt(e.d),`s`in e&&(n*=BigInt(e.s));else if(0 in e)n=BigInt(e[0]),1 in e&&(r=BigInt(e[1]));else if(typeof e==`bigint`)n=e;else throw VA();i=n*r}else if(typeof e==`number`){if(isNaN(e))throw VA();if(e<0&&(i=-SA,e=-e),e%1==0)n=BigInt(e);else{let t=1,i=0,a=1,o=1,s=1,c=1e7;for(e>=1&&(t=10**Math.floor(1+Math.log10(e)),e/=t);a<=c&&s<=c;){let t=(i+o)/(a+s);if(e===t){a+s<=c?(n=i+o,r=a+s):s>a?(n=o,r=s):(n=i,r=a);break}else e>t?(i+=o,a+=s):(o+=i,s+=a),a>c?(n=o,r=s):(n=i,r=a)}n=BigInt(n)*BigInt(t),r=BigInt(r)}}else if(typeof e==`string`){let t=0,a=xA,o=xA,s=xA,c=SA,l=SA,u=e.replace(/_/g,``).match(/\d+|./g);if(u===null)throw VA();if(u[t]===`-`?(i=-SA,t++):u[t]===`+`&&t++,u.length===t+1?o=kA(u[t++],i):u[t+1]===`.`||u[t]===`.`?(u[t]!==`.`&&(a=kA(u[t++],i)),t++,(t+1===u.length||u[t+1]===`(`&&u[t+3]===`)`||u[t+1]===`'`&&u[t+3]===`'`)&&(o=kA(u[t],i),c=EA**BigInt(u[t].length),t++),(u[t]===`(`&&u[t+2]===`)`||u[t]===`'`&&u[t+2]===`'`)&&(s=kA(u[t+1],i),l=EA**BigInt(u[t+1].length)-SA,t+=3)):u[t+1]===`/`||u[t+1]===`:`?(o=kA(u[t],i),c=kA(u[t+2],SA),t+=3):u[t+3]===`/`&&u[t+1]===` `&&(a=kA(u[t],i),o=kA(u[t+2],i),c=kA(u[t+4],SA),t+=5),u.length<=t)r=c*l,i=n=s+r*a+l*o;else throw VA()}else if(typeof e==`bigint`)n=e,i=e,r=SA;else throw VA();if(r===xA)throw BA();OA.s=ixA;e=e*e%n,t>>=SA)t&SA&&(r=r*e%n);return r}function IA(e,t){for(;t%CA===xA;t/=CA);for(;t%TA===xA;t/=TA);if(t===SA)return xA;let n=EA%t,r=1;for(;n!==SA;r++)if(n=n*EA%t,r>DA)return xA;return BigInt(r)}function LA(e,t,n){let r=SA,i=FA(EA,n,t);for(let e=0;e<300;e++){if(r===i)return BigInt(e);r=r*EA%t,i=i*EA%t}return 0}function RA(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}}function zA(e,t){if(PA(e,t),this instanceof zA)e=RA(OA.d,OA.n),this.s=OA.s,this.n=OA.n/e,this.d=OA.d/e;else return jA(OA.s*OA.n,OA.d)}var BA=function(){return Error(`Division by Zero`)},VA=function(){return Error(`Invalid argument`)},HA=function(){return Error(`Parameters must be integer`)};zA.prototype={s:SA,n:xA,d:SA,abs:function(){return jA(this.n,this.d)},neg:function(){return jA(-this.s*this.n,this.d)},add:function(e,t){return PA(e,t),jA(this.s*this.n*OA.d+OA.s*this.d*OA.n,this.d*OA.d)},sub:function(e,t){return PA(e,t),jA(this.s*this.n*OA.d-OA.s*this.d*OA.n,this.d*OA.d)},mul:function(e,t){return PA(e,t),jA(this.s*OA.s*this.n*OA.n,this.d*OA.d)},div:function(e,t){return PA(e,t),jA(this.s*OA.s*this.n*OA.d,this.d*OA.n)},clone:function(){return jA(this.s*this.n,this.d)},mod:function(e,t){if(e===void 0)return jA(this.s*this.n%this.d,SA);if(PA(e,t),xA===OA.n*this.d)throw BA();return jA(this.s*(OA.d*this.n)%(OA.n*this.d),OA.d*this.d)},gcd:function(e,t){return PA(e,t),jA(RA(OA.n,this.n)*RA(OA.d,this.d),OA.d*this.d)},lcm:function(e,t){return PA(e,t),OA.n===xA&&this.n===xA?jA(xA,SA):jA(OA.n*this.n,RA(OA.n,this.n)*RA(OA.d,this.d))},inverse:function(){return jA(this.s*this.d,this.n)},pow:function(e,t){if(PA(e,t),OA.d===SA)return OA.sOA.s*OA.n*this.d},gte:function(e,t){return PA(e,t),this.s*this.n*OA.d>=OA.s*OA.n*this.d},compare:function(e,t){PA(e,t);let n=this.s*this.n*OA.d-OA.s*OA.n*this.d;return(xAxA&&this.s>=xA?SA:xA),e)},floor:function(e){return e=EA**BigInt(e||0),jA(AA(this.s*e*this.n/this.d)-(e*this.n%this.d>xA&&this.s=xA?SA:xA)+CA*(e*this.n%this.d)>this.d?SA:xA),e)},roundTo:function(e,t){PA(e,t);let n=this.n*OA.d,r=this.d*OA.n,i=n%r,a=AA(n/r);return i+i>=r&&a++,jA(this.s*a*OA.n,OA.d)},divisible:function(e,t){return PA(e,t),OA.n===xA?!1:this.n*OA.d%(OA.n*this.d)===xA},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e=15){let t=this.n,n=this.d,r=IA(t,n),i=LA(t,n,r),a=this.sxA&&(r+=i,r+=` `,t%=n),r+=t,r+=`/`,r+=n}return r},toLatex:function(e=!1){let t=this.n,n=this.d,r=this.sxA&&(r+=i,t%=n),r+=`\\frac{`,r+=t,r+=`}{`,r+=n,r+=`}`}return r},toContinued:function(){let e=this.n,t=this.d,n=[];for(;t;){n.push(AA(e/t));let r=e%t;e=t,t=r}return n},simplify:function(e=.001){let t=BigInt(Math.ceil(1/e)),n=this.abs(),r=n.toContinued();for(let e=1;e=0;t--)i=i.inverse().add(r[t]);let a=i.sub(n);if(a.n*t(Object.defineProperty(zA,"name",{value:`Fraction`}),zA.prototype.constructor=zA,zA.prototype.type=`Fraction`,zA.prototype.isFraction=!0,zA.prototype.toJSON=function(){return{mathjs:`Fraction`,n:String(this.s*this.n),d:String(this.d)}},zA.fromJSON=function(e){return new zA(e)},zA),{isClass:!0}),WA=Z(`Range`,[],()=>{function e(t,n,r){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);var i=t!=null,a=n!=null,o=r!=null;if(i){if(ME(t))t=t.toNumber();else if(typeof t!=`number`&&!NE(t))throw TypeError(`Parameter start must be a number or bigint`)}if(a){if(ME(n))n=n.toNumber();else if(typeof n!=`number`&&!NE(n))throw TypeError(`Parameter end must be a number or bigint`)}if(o){if(ME(r))r=r.toNumber();else if(typeof r!=`number`&&!NE(r))throw TypeError(`Parameter step must be a number or bigint`)}if(this.start=i?parseFloat(t):0,this.end=a?parseFloat(n):0,this.step=o?parseFloat(r):1,o&&sO(this.step,0))throw Error(`Step must not be zero`)}return e.prototype.type=`Range`,e.prototype.isRange=!0,e.parse=function(t){if(typeof t!=`string`)return null;var n=t.split(`:`).map(function(e){return parseFloat(e)});if(n.some(function(e){return isNaN(e)}))return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return WD(n)===WD(r)?e=Math.ceil(r/n):r===0&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},e.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,i=0;if(n>0)for(;tr;)e(t,[i],this),t+=n,i++},e.prototype.map=function(e){var t=[];return this.forEach(function(n,r,i){t[r[0]]=e(n,r,i)}),t},e.prototype.toArray=function(){var e=[];return this.forEach(function(t,n){e[n[0]]=t}),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ZD(this.start,e);return this.step!==1&&(t+=`:`+ZD(this.step,e)),t+=`:`+ZD(this.end,e),t},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:`Range`,start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e},{isClass:!0}),GA=Z(`Matrix`,[],()=>{function e(){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`)}return e.prototype.type=`Matrix`,e.prototype.isMatrix=!0,e.prototype.storage=function(){throw Error(`Cannot invoke storage on a Matrix interface`)},e.prototype.datatype=function(){throw Error(`Cannot invoke datatype on a Matrix interface`)},e.prototype.create=function(e,t){throw Error(`Cannot invoke create on a Matrix interface`)},e.prototype.subset=function(e,t,n){throw Error(`Cannot invoke subset on a Matrix interface`)},e.prototype.get=function(e){throw Error(`Cannot invoke get on a Matrix interface`)},e.prototype.set=function(e,t,n){throw Error(`Cannot invoke set on a Matrix interface`)},e.prototype.resize=function(e,t){throw Error(`Cannot invoke resize on a Matrix interface`)},e.prototype.reshape=function(e,t){throw Error(`Cannot invoke reshape on a Matrix interface`)},e.prototype.clone=function(){throw Error(`Cannot invoke clone on a Matrix interface`)},e.prototype.size=function(){throw Error(`Cannot invoke size on a Matrix interface`)},e.prototype.map=function(e,t){throw Error(`Cannot invoke map on a Matrix interface`)},e.prototype.forEach=function(e){throw Error(`Cannot invoke forEach on a Matrix interface`)},e.prototype[Symbol.iterator]=function(){throw Error(`Cannot iterate a Matrix interface`)},e.prototype.toArray=function(){throw Error(`Cannot invoke toArray on a Matrix interface`)},e.prototype.valueOf=function(){throw Error(`Cannot invoke valueOf on a Matrix interface`)},e.prototype.format=function(e){throw Error(`Cannot invoke format on a Matrix interface`)},e.prototype.toString=function(){throw Error(`Cannot invoke toString on a Matrix interface`)},e},{isClass:!0});function KA(e,t,n){var r=e.constructor,i=new r(2),a=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!HD(n))throw Error(`size must be an integer`);if(e.greaterThan(i.pow(n-1).sub(1))||e.lessThan(i.pow(n-1).mul(-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!e.isInteger())throw Error(`Value must be an integer`);e.lessThan(0)&&(e=e.add(i.pow(n))),a=`i${n}`}switch(t){case 2:return`${e.toBinary()}${a}`;case 8:return`${e.toOctal()}${a}`;case 16:return`${e.toHexadecimal()}${a}`;default:throw Error(`Base ${t} not supported `)}}function qA(e,t){if(typeof t==`function`)return t(e);if(!e.isFinite())return e.isNaN()?`NaN`:e.gt(0)?`Infinity`:`-Infinity`;var{notation:n,precision:r,wordSize:i}=QD(t);switch(n){case`fixed`:return XA(e,r);case`exponential`:return YA(e,r);case`engineering`:return JA(e,r);case`bin`:return KA(e,2,i);case`oct`:return KA(e,8,i);case`hex`:return KA(e,16,i);case`auto`:var a=ZA(t?.lowerExp,-3),o=ZA(t?.upperExp,5);if(e.isZero())return`0`;var s,c=e.toSignificantDigits(r),l=c.e;return s=l>=a&&l=0?`+`:``)+r.toString()}function YA(e,t){return t===void 0?e.toExponential():e.toExponential(t-1)}function XA(e,t){return e.toFixed(t)}function ZA(e,t){return jE(e)?e:ME(e)?e.toNumber():t}function QA(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function $A(e,t){var n=ej(e,t);return t&&typeof t==`object`&&`truncate`in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+`...`:n}function ej(e,t){return typeof e==`number`?ZD(e,t):ME(e)?qA(e,t):aj(e)?!t||t.fraction!==`decimal`?`${e.s*e.n}/${e.d}`:e.toString():Array.isArray(e)?ij(e,t):LE(e)?tj(e):typeof e==`function`?e.syntax?String(e.syntax):`function`:e&&typeof e==`object`?typeof e.format==`function`?e.format(t):e&&e.toString(t)!=={}.toString()?e.toString(t):`{`+Object.keys(e).map(n=>tj(n)+`: `+$A(e[n],t)).join(`, `)+`}`:String(e)}function tj(e){for(var t=String(e),n=``,r=0;r/g,`>`),t}function ij(e,t){if(Array.isArray(e)){for(var n=`[`,r=e.length,i=0;it?1:-1}function sj(e,t,n){if(!(this instanceof sj))throw SyntaxError(`Constructor must be called with the new operator`);this.actual=e,this.expected=t,this.relation=n,this.message=`Dimension mismatch (`+(Array.isArray(e)?`[`+e.join(`, `)+`]`:e)+` `+(this.relation||`!=`)+` `+(Array.isArray(t)?`[`+t.join(`, `)+`]`:t)+`)`,this.stack=Error().stack}sj.prototype=RangeError(),sj.prototype.constructor=RangeError,sj.prototype.name=`DimensionError`,sj.prototype.isDimensionError=!0;function cj(e,t,n){if(!(this instanceof cj))throw 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=n),this.min!==void 0&&this.index=this.max?this.message=`Index out of range (`+this.index+` > `+(this.max-1)+`)`:this.message=`Index out of range (`+this.index+`)`,this.stack=Error().stack}cj.prototype=RangeError(),cj.prototype.constructor=RangeError,cj.prototype.name=`IndexError`,cj.prototype.isIndexError=!0;function lj(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function uj(e,t,n){var r,i=e.length;if(i!==t[n])throw new sj(i,t[n]);if(n`)}function dj(e,t){if(t.length===0){if(Array.isArray(e))throw new sj(e.length,0)}else uj(e,t,0)}function fj(e,t){var n=e.isMatrix?e._size:lj(e);t._sourceSize.forEach((e,t)=>{if(e!==null&&e!==n[t])throw new sj(e,n[t])})}function pj(e,t){if(e!==void 0){if(!jE(e)||!HD(e))throw TypeError(`Index must be an integer (value: `+e+`)`);if(e<0||typeof t==`number`&&e>=t)throw new cj(e,t)}}function mj(e){for(var t=0;t=0)throw Error(`More than one wildcard in sizes`);var o=a>=0,s=t%n===0;if(o)if(s)r[a]=-t/n;else throw Error(`Could not replace wildcard, since `+t+` is no multiple of `+-n);return r}function yj(e){return e.reduce((e,t)=>e*t,1)}function bj(e,t){for(var n=e,r,i=t.length-1;i>0;i--){var a=t[i];r=[];for(var o=n.length/a,s=0;s1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof t!=`boolean`)throw TypeError(`Boolean expected for second argument of flatten`);var n=[];return t?i(e):r(e),n;function r(e){for(var t=0;tt.test(e))}function Aj(e,t){return Array.prototype.join.call(e,t)}function jj(e){if(!Array.isArray(e))throw TypeError(`Array input expected`);if(e.length===0)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r1)return e.slice(1).reduce(function(e,n){return Pj(e,n,t,0)},e[0]);throw Error(`Wrong number of arguments in function concat`)}function Ij(){for(var e=arguments.length,t=Array(e),n=0;ne.length),i=Math.max(...r),a=Array(i).fill(null),o=0;oa[u]&&(a[u]=s[l])}for(var d=0;d1||e[i]>t[a])throw Error(`shape mismatch: mismatch is found in arg with shape (${e}) not possible to broadcast dimension ${r} with size ${e[i]} to size ${t[a]}`)}}function Rj(e,t){var n=lj(e);if(ED(n,t))return e;Lj(n,t);var r=Ij(n,t),i=r.length,a=[...Array(i-n.length).fill(1),...n],o=Uj(e);n.lengthe[t],e)}function Vj(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(n)return a(e);var r=[];return i(e,0);function i(n,a){if(Array.isArray(n)){for(var o=n.length,s=Array(o),c=0;c2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return;if(n){a(e);return}var r=[];i(e,0);function i(n,a){if(Array.isArray(n))for(var o=n.length,s=0;s0);i=qj(e,t.isMatrix?t.get(o):Bj(t,o),o,t)}var s;if(t.isMatrix&&t.dataType!==`mixed`&&t.dataType!==void 0){var c=Gj(e,i);s=c===void 0?e:c}else s=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){for(var t=arguments.length,r=Array(t),a=0;a{var[r,i]=e;r.split(`,`).length===t&&n.push(i)}),n.length===1)return n[0]}function Kj(e){if(e.length!==1)return!1;var t=e.toString();if(/arguments/.test(t))return!1;var n=t.match(/\(.*?\)/);return!/\.\.\./.test(n)}function qj(e,t,n,r){for(var i=[t,n,r],a=3;a>0;a--){var o=i.slice(0,a);if(_O.default.resolve(e,o)!==null)return a}}function Jj(e,t,n,r){try{return e(...t)}catch(e){Yj(e,t,n,r)}}function Yj(e,t,n,r){if(e instanceof TypeError&&e.data?.category===`wrongType`){var i=[];throw i.push(`value: ${xD(t[0])}`),t.length>=2&&i.push(`index: ${xD(t[1])}`),t.length>=3&&i.push(`array: ${xD(t[2])}`),TypeError(`Function ${n} cannot apply callback arguments ${r}(${i.join(`, `)}) at index ${JSON.stringify(t[1])}`)}else throw TypeError(`Function ${n} cannot apply callback arguments to function ${r}: ${e.message}`)}var Xj=Z(`DenseMatrix`,[`Matrix`,`config`],e=>{var{Matrix:t,config:n}=e;function r(e,t){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!LE(t))throw Error(`Invalid datatype: `+t);if(zE(e))e.type===`DenseMatrix`?(this._data=SD(e._data),this._size=SD(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&RE(e.data)&&RE(e.size))this._data=e.data,this._size=e.size,dj(this._data,this._size),this._datatype=t||e.datatype;else if(RE(e))this._data=u(e),this._size=lj(this._data),dj(this._data,this._size),this._datatype=t;else if(e)throw TypeError(`Unsupported type of data (`+xD(e)+`)`);else this._data=[],this._size=[0],this._datatype=t}r.prototype=new t,r.prototype.createDenseMatrix=function(e,t){return new r(e,t)},Object.defineProperty(r,"name",{value:`DenseMatrix`}),r.prototype.constructor=r,r.prototype.type=`DenseMatrix`,r.prototype.isDenseMatrix=!0,r.prototype.getDataType=function(){return Nj(this._data,xD)},r.prototype.storage=function(){return`dense`},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(e,t){return new r(e,t)},r.prototype.subset=function(e,t,n){switch(arguments.length){case 1:return i(this,e);case 2:case 3:return o(this,e,t,n);default:throw SyntaxError(`Wrong number of arguments`)}},r.prototype.get=function(e){return Bj(this._data,e)},r.prototype.set=function(e,t,n){if(!RE(e))throw TypeError(`Array expected`);if(e.lengthe===1):t.isScalar())return e.get(t.min());var i=t.size();if(i.length!==e._size.length)throw new sj(i.length,e._size.length);for(var o=t.min(),s=t.max(),c=0,l=e._size.length;ce!==null)};function i(e){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=t.dimension(a);function s(e,t){return jE(e)?t(e):e.map(t).valueOf()}return jE(o)?r[a]=null:r[a]=o.size()[0],a(pj(t,e.length),i(e[t],a+1))):s(o,t=>(pj(t,e.length),e[t]))}}function o(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Invalid index`);var i=t.size(),a=t.isScalar(),o;if(zE(n)?(o=n.size(),n=n.valueOf()):o=lj(n),a){if(o.length!==0)throw TypeError(`Scalar expected`);e.set(t.min(),n,r)}else{if(!ED(o,i)){if(o.length===0)n=Rj([n],i);else try{n=Rj(n,i)}catch{}o=lj(n)}if(i.length`);l(e,t.max().map(function(e){return e+1}),r),s(e._data,t,n)}return e}function s(e,t,n){var r=t.size().length-1;i(e,n);function i(e,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=t.dimension(a),s=(t,r)=>{pj(t,e.length),i(e[t],n[r[0]],a+1)},c=(t,r)=>{pj(t,e.length),e[t]=n[r[0]]};aArray.isArray(e)&&e.length===1?e[0]:e);return c(n?this.clone():this,r,t)};function c(e,t,n){if(t.length===0){for(var r=e._data;RE(r);)r=r[0];return r}return e._size=t.slice(0),e._data=hj(e._data,e._size,n),e}r.prototype.reshape=function(e,t){var n=t?this.clone():this;return n._data=_j(n._data,e),n._size=vj(e,n._size.reduce((e,t)=>e*t)),n};function l(e,t,n){for(var r=e._size.slice(0),i=!1;r.lengthr[a]&&(r[a]=t[a],i=!0);i&&c(e,r,n)}r.prototype.clone=function(){return new r({data:SD(this._data),size:SD(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){arguments.length>1&&arguments[1]!==void 0&&arguments[1];var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=this,r=n._size.length-1;if(r<0)return n.clone();var i=Wj(e,n,`map`,t),a=i.fn,o=n.create(void 0,n._datatype);if(o._size=n._size,t||i.isUnary)return o._data=f(n._data),o;if(r===0){for(var s=n.valueOf(),c=Array(s.length),l=0;l1&&arguments[1]!==void 0?arguments[1]:0,i=Array(e.length);if(t1&&arguments[1]!==void 0?arguments[1]:0,n=Array(e.length);if(t1&&arguments[1]!==void 0&&arguments[1];var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=this,r=n._size.length-1;if(r<0)return;var i=Wj(e,n,`map`,t),a=i.fn;if(t||i.isUnary){l(n._data);return}if(r===0){for(var o=0;o1&&arguments[1]!==void 0?arguments[1]:0;if(t1&&arguments[1]!==void 0?arguments[1]:0;if(te*t,1),i=0;i=0&&(n[s]++,!(n[s][e[n]]);t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-t),s=[],c=0;c0?n:0,o=n<0?-n:0,s=e[0],c=e[1],l=Math.min(s-o,c-a),u;if(RE(t)){if(t.length!==l)throw Error(`Invalid value array length`);u=function(e){return t[e]}}else if(zE(t)){var d=t.size();if(d.length!==1||d[0]!==l)throw Error(`Invalid matrix length`);u=function(e){return t.get([e])}}else u=function(){return t};i||=ME(u(0))?u(0).mul(0):0;var f=[];if(e.length>0){f=hj(f,e,i);for(var p=0;p{var{typed:t}=e;return t(Zj,{any:SD})});function $j(e){var t=e.length,n=e[0].length,r,i,a=[];for(i=0;it(e),!1,!0):Hj(e,t,!0)}function nM(e,t,n){if(!n)return zE(e)?e.map(e=>t(e),!1,!0):Vj(e,t,!0);var r=e=>e===0?e:t(e);return zE(e)?e.map(e=>r(e),!1,!0):Vj(e,r,!0)}function rM(e,t,n){var r=Array.isArray(e)?lj(e):e.size();if(t<0||t>=r.length)throw new cj(t,r.length);return zE(e)?e.create(iM(e.valueOf(),t,n),e.datatype()):iM(e,t,n)}function iM(e,t,n){var r,i,a,o;if(t<=0)if(Array.isArray(e[0])){for(o=$j(e),i=[],r=0;r{var{typed:t,equal:n}=e;return t(oM,{number:e=>Number.isFinite(e)?n(e,Math.round(e)):!1,BigNumber:e=>e.isFinite()?n(e.round(),e):!1,bigint:e=>!0,Fraction:e=>e.d===1n,"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),cM=`number`,lM=`number, number`;function uM(e){return Math.abs(e)}uM.signature=cM;function dM(e,t){return e+t}dM.signature=lM;function fM(e,t){return e-t}fM.signature=lM;function pM(e,t){return e*t}pM.signature=lM;function mM(e,t){return e/t}mM.signature=lM;function hM(e){return-e}hM.signature=cM;function gM(e){return e}gM.signature=cM;function _M(e){return JD(e)}_M.signature=cM;function vM(e){return e*e*e}vM.signature=cM;function yM(e){return Math.exp(e)}yM.signature=cM;function bM(e){return YD(e)}bM.signature=cM;function xM(e,t){if(!HD(e)||!HD(t))throw Error(`Parameters in function gcd must be integer numbers`);for(var n;t!==0;)n=e%t,e=t,t=n;return e<0?-e:e}xM.signature=lM;function SM(e,t){if(!HD(e)||!HD(t))throw Error(`Parameters in function lcm must be integer numbers`);if(e===0||t===0)return 0;for(var n,r=e*t;t!==0;)n=t,t=e%n,e=n;return Math.abs(r/e)}SM.signature=lM;function CM(e,t){return t?Math.log(e)/Math.log(t):Math.log(e)}function wM(e){return KD(e)}wM.signature=cM;function TM(e){return GD(e)}TM.signature=cM;function EM(e){return qD(e)}EM.signature=cM;function DM(e,t){return t===0?e:e-t*Math.floor(e/t)}DM.signature=lM;function OM(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,n=t<0;if(n&&(t=-t),t===0)throw Error(`Root must be non-zero`);if(e<0&&Math.abs(t)%2!=1)throw Error(`Root must be odd when a is negative.`);if(e===0)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.abs(e)**(1/t);return r=e<0?-r:r,n?1/r:r}function kM(e){return WD(e)}kM.signature=cM;function AM(e){return Math.sqrt(e)}AM.signature=cM;function jM(e){return e*e}jM.signature=cM;function MM(e,t){var n,r,i,a=0,o=1,s=1,c=0;if(!HD(e)||!HD(t))throw Error(`Parameters in function xgcd must be integer numbers`);for(;t;)r=Math.floor(e/t),i=e-r*t,n=a,a=o-r*a,o=n,n=s,s=c-r*s,c=n,e=t,t=i;return e<0?[-e,-o,-c]:[e,e?o:0,c]}MM.signature=lM;function NM(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:e**+t}NM.signature=lM;function PM(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!HD(t)||t<0||t>15)throw Error(`Number of decimals in function round must be an integer from 0 to 15 inclusive`);return parseFloat(tO(e,t))}function FM(e){return Math.abs(e)}FM.signature=cM;var IM=`number`,LM=`number, number`;function RM(e,t){if(!HD(e)||!HD(t))throw Error(`Integers expected in function bitAnd`);return e&t}RM.signature=LM;function zM(e){if(!HD(e))throw Error(`Integer expected in function bitNot`);return~e}zM.signature=IM;function BM(e,t){if(!HD(e)||!HD(t))throw Error(`Integers expected in function bitOr`);return e|t}BM.signature=LM;function VM(e,t){if(!HD(e)||!HD(t))throw Error(`Integers expected in function bitXor`);return e^t}VM.signature=LM;function HM(e,t){if(!HD(e)||!HD(t))throw Error(`Integers expected in function leftShift`);return e<>t}UM.signature=LM;function WM(e,t){if(!HD(e)||!HD(t))throw Error(`Integers expected in function rightLogShift`);return e>>>t}WM.signature=LM;function GM(e,t){if(t>1;return GM(e,n)*GM(n+1,t)}function KM(e,t){if(!HD(e)||e<0||!HD(t)||t<0)throw TypeError(`Positive integer value expected in function combinations`);if(t>e)throw TypeError(`k must be less than or equal to n`);for(var n=e-t,r=1,i=t171?1/0:GM(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*rN(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,i=r*e,a=i*e;return Math.sqrt(2*Math.PI/e)*(e/Math.E)**+e*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=aN[0];for(var o=1;o=1;r--)n+=sN[r]/(e+r);return oN+(e+.5)*Math.log(t)-t+Math.log(n)}cN.signature=`number`;var lN=`number`,uN=`number, number`;function dN(e){return Math.acos(e)}dN.signature=lN;function fN(e){return cO(e)}fN.signature=lN;function pN(e){return Math.atan(1/e)}pN.signature=lN;function mN(e){return Number.isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}mN.signature=lN;function hN(e){return Math.asin(1/e)}hN.signature=lN;function gN(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}gN.signature=lN;function _N(e){return Math.acos(1/e)}_N.signature=lN;function vN(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}vN.signature=lN;function yN(e){return Math.asin(e)}yN.signature=lN;function bN(e){return lO(e)}bN.signature=lN;function xN(e){return Math.atan(e)}xN.signature=lN;function SN(e,t){return Math.atan2(e,t)}SN.signature=uN;function CN(e){return uO(e)}CN.signature=lN;function wN(e){return Math.cos(e)}wN.signature=lN;function TN(e){return dO(e)}TN.signature=lN;function EN(e){return 1/Math.tan(e)}EN.signature=lN;function DN(e){var t=Math.exp(2*e);return(t+1)/(t-1)}DN.signature=lN;function ON(e){return 1/Math.sin(e)}ON.signature=lN;function kN(e){return e===0?1/0:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*WD(e)}kN.signature=lN;function AN(e){return 1/Math.cos(e)}AN.signature=lN;function jN(e){return 2/(Math.exp(e)+Math.exp(-e))}jN.signature=lN;function MN(e){return Math.sin(e)}MN.signature=lN;function NN(e){return fO(e)}NN.signature=lN;function PN(e){return Math.tan(e)}PN.signature=lN;function FN(e){return pO(e)}FN.signature=lN;var IN=`number`;function LN(e){return HD(e)}LN.signature=IN;function RN(e){return e<0}RN.signature=IN;function zN(e){return e>0}zN.signature=IN;function BN(e){return e===0}BN.signature=IN;function VN(e){return Number.isNaN(e)}VN.signature=IN;function HN(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(n<=0)throw Error(`Relative tolerance must be greater than 0`);if(r<0)throw Error(`Absolute tolerance must be at least 0`);return e.isNaN()||t.isNaN()?!1:!e.isFinite()||!t.isFinite()?e.eq(t):e.eq(t)?!0:e.minus(t).abs().lte(e.constructor.max(e.constructor.max(e.abs(),t.abs()).mul(n),r))}var UN=`isNegative`,WN=Z(UN,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(UN,{number:e=>sO(e,0,n.relTol,n.absTol)?!1:RN(e),BigNumber:e=>HN(e,new e.constructor(0),n.relTol,n.absTol)?!1:e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e<0n,Fraction:e=>e.s<0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),GN=`isNumeric`,KN=Z(GN,[`typed`],e=>{var{typed:t}=e;return t(GN,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),qN=`hasNumericValue`,JN=Z(qN,[`typed`,`isNumeric`],e=>{var{typed:t,isNumeric:n}=e;return t(qN,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})}),YN=`isPositive`,XN=Z(YN,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(YN,{number:e=>sO(e,0,n.relTol,n.absTol)?!1:zN(e),BigNumber:e=>HN(e,new e.constructor(0),n.relTol,n.absTol)?!1:!e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e>0n,Fraction:e=>e.s>0n&&e.n>0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),ZN=`isZero`,QN=Z(ZN,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(ZN,{"number | BigNumber | Complex | Fraction":e=>n(e,0),bigint:e=>e===0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),$N=`isNaN`,eP=Z($N,[`typed`],e=>{var{typed:t}=e;return t($N,{number:VN,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(e=>t=>nM(t,e))})}),tP=`isBounded`,nP=Z(tP,[`typed`],e=>{var{typed:t}=e;return t(tP,{number:e=>Number.isFinite(e),"BigNumber | Complex":e=>e.isFinite(),"bigint | Fraction":()=>!0,"null | undefined":()=>!1,Unit:t.referToSelf(e=>t=>e(t.value)),"Array | Matrix":t.referToSelf(e=>t=>(Array.isArray(t)||(t=t.valueOf()),t.every(t=>e(t))))})}),rP=`isFinite`,iP=Z(rP,[`typed`,`isBounded`,`map`],e=>{var{typed:t,isBounded:n,map:r}=e;return t(rP,{"Array | Matrix":e=>r(e,n),any:e=>n(e)})}),aP=`typeOf`,oP=Z(aP,[`typed`],e=>{var{typed:t}=e;return t(aP,{any:xD})});function sP(e,t,n,r){return sO(e.re,t.re,n,r)&&sO(e.im,t.im,n,r)}var cP=Z(`compareUnits`,[`typed`],e=>{var{typed:t}=e;return{"Unit, Unit":t.referToSelf(e=>(n,r)=>{if(!n.equalBase(r))throw Error(`Cannot compare units with different base`);return t.find(e,[n.valueType(),r.valueType()])(n.value,r.value)})}}),lP=`equalScalar`,uP=Z(lP,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(lP,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return sO(e,t,n.relTol,n.absTol)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||HN(e,t,n.relTol,n.absTol)},"bigint, bigint":function(e,t){return e===t},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return sP(e,t,n.relTol,n.absTol)}},cP({typed:t}))});Z(lP,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(lP,{"number, number":function(e,t){return sO(e,t,n.relTol,n.absTol)}})});var dP=Z(`SparseMatrix`,[`typed`,`equalScalar`,`Matrix`],e=>{var{typed:t,equalScalar:n,Matrix:r}=e;function i(e,t){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!LE(t))throw Error(`Invalid datatype: `+t);if(zE(e))a(this,e,t);else if(e&&RE(e.index)&&RE(e.ptr)&&RE(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(RE(e))o(this,e,t);else if(e)throw TypeError(`Unsupported type of data (`+xD(e)+`)`);else this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}function a(e,t,n){t.type===`SparseMatrix`?(e._values=t._values?SD(t._values):void 0,e._index=SD(t._index),e._ptr=SD(t._ptr),e._size=SD(t._size),e._datatype=n||t._datatype):o(e,t.valueOf(),n||t._datatype)}function o(e,r,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=r.length,o=0,s=n,c=0;if(LE(i)&&(s=t.find(n,[i,i])||n,c=t.convert(0,i)),a>0){var l=0;do{e._ptr.push(e._index.length);for(var u=0;u`);if(i.length===1)d(t.dimension(0),(t,i)=>{pj(t),e.set([t,0],n[i[0]],r)});else{var l=t.dimension(0),u=t.dimension(1);d(l,(t,i)=>{pj(t),d(u,(a,o)=>{pj(a),e.set([t,a],n[i[0]][o[0]],r)})})}}return e;function d(e,t){jE(e)?t(e,[0]):e.forEach(t)}}i.prototype.get=function(e){if(!RE(e))throw TypeError(`Array expected`);if(e.length!==this._size.length)throw new sj(e.length,this._size.length);if(!this._values)throw Error(`Cannot invoke get on a Pattern only matrix`);var t=e[0],n=e[1];pj(t,this._size[0]),pj(n,this._size[1]);var r=l(t,this._ptr[n],this._ptr[n+1],this._index);return rs-1||o>c-1)&&(f(this,Math.max(a+1,s),Math.max(o+1,c),i),s=this._size[0],c=this._size[1]),pj(a,s),pj(o,c);var h=l(a,this._ptr[o],this._ptr[o+1],this._index);return hArray.isArray(e)&&e.length===1?e[0]:e);if(r.length!==2)throw Error(`Only two dimensions matrix are supported`);return r.forEach(function(e){if(!jE(e)||!HD(e)||e<0)throw TypeError(`Invalid size, must contain positive integers (size: `+$A(r)+`)`)}),f(n?this.clone():this,r[0],r[1],t)};function f(e,r,i,a){var o=a||0,s=n,c=0;LE(e._datatype)&&(s=t.find(n,[e._datatype,e._datatype])||n,c=t.convert(0,e._datatype),o=t.convert(o,e._datatype));var l=!s(o,c),u=e._size[0],d=e._size[1],f,p,m;if(i>d){for(p=d;pu){if(l){var h=0;for(p=0;pr-1&&(e._values.splice(m,1),e._index.splice(m,1),_++)}e._ptr[p]=e._values.length}return e._size[0]=r,e._size[1]=i,e}i.prototype.reshape=function(e,t){if(!RE(e))throw TypeError(`Array expected`);if(e.length!==2)throw Error(`Sparse matrices can only be reshaped in two dimensions`);e.forEach(function(t){if(!jE(t)||!HD(t)||t<=-2||t===0)throw TypeError(`Invalid size, must contain positive integers or -1 (size: `+$A(e)+`)`)});var n=this._size[0]*this._size[1];if(e=vj(e,n),n!==e[0]*e[1])throw Error(`Reshaping sparse matrix will result in the wrong number of elements`);var r=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return r;for(var i=[],a=0;a=r&&b<=a&&h(e._values[y],b-r,g-o)}else{for(var x={},S=_;S `+(this._values?$A(this._values[c],e):`X`)}return i},i.prototype.toString=function(){return $A(this.toArray())},i.prototype.toJSON=function(){return{mathjs:`SparseMatrix`,values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(ME(e)&&(e=e.toNumber()),!jE(e)||!HD(e))throw TypeError(`The parameter k must be an integer number`)}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],a=this._size[1],o=Math.min(r-n,a-t),s=[],c=[],l=[];l[0]=0;for(var u=t;u0?a:0,d=a<0?-a:0,f=e[0],p=e[1],m=Math.min(f-d,p-u),h;if(RE(r)){if(r.length!==m)throw Error(`Invalid value array length`);h=function(e){return r[e]}}else if(zE(r)){var g=r.size();if(g.length!==1||g[0]!==m)throw Error(`Invalid matrix length`);h=function(e){return r.get([e])}}else h=function(){return r};for(var _=[],v=[],y=[],b=0;b=0&&x=c||i[d]!==t)){var p=r?r[u]:void 0;i.splice(d,0,t),r&&r.splice(d,0,p),i.splice(d<=u?u+1:u,1),r&&r.splice(d<=u?u+1:u,1);continue}if(d=c||i[u]!==e)){var m=r?r[d]:void 0;i.splice(u,0,e),r&&r.splice(u,0,m),i.splice(u<=d?d+1:d,1),r&&r.splice(u<=d?d+1:d,1)}}},i},{isClass:!0}),fP=`number`,pP=[`typed`];function mP(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}function hP(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r{var{typed:t}=e,n=t(`number`,{"":function(){return 0},number:function(e){return e},string:function(e){if(e===`NaN`)return NaN;var t=mP(e);if(t)return hP(t);var n=0,r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);r&&(n=Number(r[2]),e=r[1]);var i=Number(e);if(isNaN(i))throw SyntaxError(`String "`+e+`" is not a valid number`);if(r){if(i>2**n-1)throw SyntaxError(`String "${e}" is out of range`);i>=2**(n-1)&&(i-=2**n)}return i},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))});return n.fromJSON=function(e){return parseFloat(e.value)},n}),_P=Z(`bigint`,[`typed`],e=>{var{typed:t}=e,n=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(e=>t=>nM(t,e))});return n.fromJSON=function(e){return BigInt(e.value)},n}),vP=`string`,yP=Z(vP,[`typed`],e=>{var{typed:t}=e;return t(vP,{"":function(){return``},number:ZD,null:function(e){return`null`},boolean:function(e){return e+``},string:function(e){return e},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e)),any:function(e){return String(e)}})}),bP=`boolean`,xP=Z(bP,[`typed`],e=>{var{typed:t}=e;return t(bP,{"":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(t===`true`)return!0;if(t===`false`)return!1;var n=Number(e);if(e!==``&&!isNaN(n))return!!n;throw Error(`Cannot convert "`+e+`" to a boolean`)},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),SP=Z(`bignumber`,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(`bignumber`,{"":function(){return new n(0)},number:function(e){return new n(e+``)},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],i=n(t[1]),a=new n(2).pow(Number(r));if(i.gt(a.sub(1)))throw SyntaxError(`String "${e}" is out of range`);var o=new n(2).pow(Number(r)-1);return i.gte(o)?i.sub(a):i}return new n(e)},BigNumber:function(e){return e},bigint:function(e){return new n(e.toString())},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),Fraction:function(e){return new n(String(e.n)).div(String(e.d)).times(String(e.s))},null:function(e){return new n(0)},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),CP=Z(`complex`,[`typed`,`Complex`],e=>{var{typed:t,Complex:n}=e;return t(`complex`,{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if(`re`in e&&`im`in e)return new n(e.re,e.im);if(`r`in e&&`phi`in e||`abs`in e&&`arg`in e)return new n(e);throw Error(`Expected object with properties (re and im) or (r and phi) or (abs and arg)`)},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),wP=Z(`fraction`,[`typed`,`Fraction`],e=>{var{typed:t,Fraction:n}=e;return t(`fraction`,{number:function(e){if(!Number.isFinite(e)||isNaN(e))throw Error(e+` cannot be represented as a fraction`);return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},"bigint, bigint":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},bigint:function(e){return new n(e.toString())},Fraction:function(e){return e},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),Object:function(e){return new n(e)},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),TP=`matrix`,EP=Z(TP,[`typed`,`Matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(TP,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,n){if(t===`dense`||t===`default`||t===void 0)return new r(e,n);if(t===`sparse`)return new i(e,n);throw TypeError(`Unknown matrix type `+JSON.stringify(t)+`.`)}}),DP=`matrixFromFunction`,OP=Z(DP,[`typed`,`matrix`,`isZero`],e=>{var{typed:t,matrix:n,isZero:r}=e;return t(DP,{"Array | Matrix, function, string, string":function(e,t,n,r){return i(e,t,n,r)},"Array | Matrix, function, string":function(e,t,n){return i(e,t,n)},"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,n){return i(e,n,t)},"Array | Matrix, string, string, function":function(e,t,n,r){return i(e,r,t,n)}});function i(e,t,i,a){var o=a===void 0?n(i):n(i,a);return o.resize(e),o.forEach(function(e,n){var i=t(n);r(i)||o.set(n,i)}),o}}),kP=`matrixFromRows`,AP=Z(kP,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(kP,{"...Array":function(e){return a(e)},"...Matrix":function(e){return n(a(e.map(e=>e.toArray())))}});function a(e){if(e.length===0)throw TypeError(`At least one row is needed to construct a matrix.`);var t=o(e[0]),n=[];for(var i of e){var a=o(i);if(a!==t)throw TypeError(`The vectors had different length: `+(t|0)+` ≠ `+(a|0));n.push(r(i))}return n}function o(e){var t=i(e);if(t.length===1)return t[0];if(t.length===2){if(t[0]===1)return t[1];if(t[1]===1)return t[0];throw TypeError(`At least one of the arguments is not a vector.`)}else throw TypeError(`Only one- or two-dimensional vectors are supported.`)}}),jP=`matrixFromColumns`,MP=Z(jP,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(jP,{"...Array":function(e){return a(e)},"...Matrix":function(e){return n(a(e.map(e=>e.toArray())))}});function a(e){if(e.length===0)throw TypeError(`At least one column is needed to construct a matrix.`);for(var t=o(e[0]),n=[],i=0;i{var{typed:t}=e;return t(NP,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),FP=`unaryMinus`,IP=Z(FP,[`typed`],e=>{var{typed:t}=e;return t(FP,{number:hM,"Complex | BigNumber | Fraction":e=>e.neg(),bigint:e=>-e,Unit:t.referToSelf(e=>n=>{var r=n.clone();return r.value=t.find(e,r.valueType())(n.value),r}),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e,!0))})}),LP=`unaryPlus`,RP=Z(LP,[`typed`,`config`,`numeric`],e=>{var{typed:t,config:n,numeric:r}=e;return t(LP,{number:gM,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(e=>t=>nM(t,e,!0)),boolean:function(e){return r(+!!e,n.number)},string:function(e){return r(e,UD(e,n))}})}),zP=`abs`,BP=Z(zP,[`typed`],e=>{var{typed:t}=e;return t(zP,{number:uM,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":t.referToSelf(e=>t=>nM(t,e,!0))})}),VP=`mapSlices`,HP=Z(VP,[`typed`,`isInteger`],e=>{var{typed:t,isInteger:n}=e;return t(VP,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw TypeError(`Integer number expected for dimension`);var i=Array.isArray(e)?lj(e):e.size();if(t<0||t>=i.length)throw new cj(t,i.length);return zE(e)?e.create(UP(e.valueOf(),t,r),e.datatype()):UP(e,t,r)}})},{formerly:`apply`});function UP(e,t,n){var r,i,a;if(t<=0)if(Array.isArray(e[0])){for(a=WP(e),i=[],r=0;r{var{typed:t}=e;return t(GP,{"number, number":dM,"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":t.referToSelf(e=>(n,r)=>{if(n.value===null||n.value===void 0)throw Error(`Parameter x contains a unit with undefined value`);if(r.value===null||r.value===void 0)throw Error(`Parameter y contains a unit with undefined value`);if(!n.equalBase(r))throw Error(`Units do not match`);var i=n.clone();return i.value=t.find(e,[i.valueType(),r.valueType()])(i.value,r.value),i.fixPrefix=!1,i})})}),qP=`subtractScalar`,JP=Z(qP,[`typed`],e=>{var{typed:t}=e;return t(qP,{"number, number":fM,"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":t.referToSelf(e=>(n,r)=>{if(n.value===null||n.value===void 0)throw Error(`Parameter x contains a unit with undefined value`);if(r.value===null||r.value===void 0)throw Error(`Parameter y contains a unit with undefined value`);if(!n.equalBase(r))throw Error(`Units do not match`);var i=n.clone();return i.value=t.find(e,[i.valueType(),r.valueType()])(i.value,r.value),i.fixPrefix=!1,i})})}),YP=`cbrt`,XP=Z(YP,[`config`,`typed`,`isNegative`,`unaryMinus`,`matrix`,`Complex`,`BigNumber`,`Fraction`],e=>{var{config:t,typed:n,isNegative:r,unaryMinus:i,matrix:a,Complex:o,BigNumber:s,Fraction:c}=e;return n(YP,{number:_M,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:u});function l(e,n){var r=e.arg()/3,i=e.abs(),s=new o(_M(i),0).mul(new o(0,r).exp());if(n){var c=[s,new o(_M(i),0).mul(new o(0,r+Math.PI*2/3).exp()),new o(_M(i),0).mul(new o(0,r-Math.PI*2/3).exp())];return t.matrix===`Array`?c:a(c)}else return s}function u(e){if(e.value&&PE(e.value)){var t=e.clone();return t.value=1,t=t.pow(1/3),t.value=l(e.value),t}else{var n=r(e.value);n&&(e.value=i(e.value));var a=ME(e.value)?new s(1).div(3):FE(e.value)?new c(1,3):1/3,o=e.pow(a);return n&&(o.value=i(o.value)),o}}}),ZP=Z(`matAlgo11xS0s`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=n,h=0,g=i;typeof u==`string`&&(p=u,m=t.find(n,[p,p]),h=t.convert(0,p),r=t.convert(r,p),g=t.find(i,[p,p]));for(var _=[],v=[],y=[],b=0;b{var{typed:t,DenseMatrix:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=i;typeof u==`string`&&(p=u,r=t.convert(r,p),m=t.find(i,[p,p]));for(var h=[],g=[],_=[],v=0;v{var{typed:t}=e;return function(e,r,i,a){var o=e._data,s=e._size,c=e._datatype,l,u=i;typeof c==`string`&&(l=c,r=t.convert(r,l),u=t.find(i,[l,l]));var d=s.length>0?n(u,0,s,s[0],o,r,a):[];return e.createDenseMatrix({data:d,size:SD(s),datatype:l})};function n(e,t,r,i,a,o,s){var c=[];if(t===r.length-1)for(var l=0;l{var{typed:t,config:n,round:r}=e;function i(e){var t=Math.ceil(e),i=r(e);return t===i?t:sO(e,i,n.relTol,n.absTol)&&!sO(e,t,n.relTol,n.absTol)?i:t}return t(eF,{number:i,"number, number":function(e,t){if(!HD(t))throw RangeError(`number of decimals in function ceil must be an integer`);if(t<0||t>15)throw RangeError(`number of decimals in ceil number must be in range 0-15`);var n=10**t;return i(e*n)/n}})}),iF=Z(eF,tF,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=ZP({typed:t,equalScalar:a}),l=QP({typed:t,DenseMatrix:s}),u=$P({typed:t}),d=rF({typed:t,config:n,round:r});function f(e){var t=(e,t)=>HN(e,t,n.relTol,n.absTol),i=e.ceil(),a=r(e);return i.eq(a)?i:t(e,a)&&!t(e,i)?a:i}return t(`ceil`,{number:d.signatures.number,"number,number":d.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:f,"BigNumber, BigNumber":function(e,t){var n=nF.pow(t);return f(e.mul(n)).div(n)},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(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>nM(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>nM(t,t=>e(t,n),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(i(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>a(t,0)?o(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),aF=`cube`,oF=Z(aF,[`typed`],e=>{var{typed:t}=e;return t(aF,{number:vM,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)}})}),sF=`exp`,cF=Z(sF,[`typed`],e=>{var{typed:t}=e;return t(sF,{number:yM,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})}),lF=`expm1`,uF=Z(lF,[`typed`,`Complex`],e=>{var{typed:t,Complex:n}=e;return t(lF,{number:bM,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})}),dF=`fix`,fF=[`typed`,`Complex`,`matrix`,`ceil`,`floor`,`equalScalar`,`zeros`,`DenseMatrix`],pF=Z(dF,[`typed`,`ceil`,`floor`],e=>{var{typed:t,ceil:n,floor:r}=e;return t(dF,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})}),mF=Z(dF,fF,e=>{var{typed:t,Complex:n,matrix:r,ceil:i,floor:a,equalScalar:o,zeros:s,DenseMatrix:c}=e,l=QP({typed:t,DenseMatrix:c}),u=$P({typed:t}),d=pF({typed:t,ceil:i,floor:a});return t(`fix`,{number:d.signatures.number,"number, number | BigNumber":d.signatures[`number,number`],Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new n(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},"Complex, BigNumber":function(e,t){var r=t.toNumber();return new n(e.re>0?a(e.re,r):i(e.re,r),e.im>0?a(e.im,r):i(e.im,r))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):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(e,t):a(e,t)},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>nM(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e,!0)),"Array | Matrix, number | BigNumber":t.referToSelf(e=>(t,n)=>nM(t,t=>e(t,n),!0)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(r(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>o(t,0)?s(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),hF=`floor`,gF=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`],_F=new uA(10),vF=Z(hF,[`typed`,`config`,`round`],e=>{var{typed:t,config:n,round:r}=e;function i(e){var t=Math.floor(e),i=r(e);return t===i?t:sO(e,i,n.relTol,n.absTol)&&!sO(e,t,n.relTol,n.absTol)?i:t}return t(hF,{number:i,"number, number":function(e,t){if(!HD(t))throw RangeError(`number of decimals in function floor must be an integer`);if(t<0||t>15)throw RangeError(`number of decimals in floor number must be in range 0 - 15`);var n=10**t;return i(e*n)/n}})}),yF=Z(hF,gF,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=ZP({typed:t,equalScalar:a}),l=QP({typed:t,DenseMatrix:s}),u=$P({typed:t}),d=vF({typed:t,config:n,round:r});function f(e){var t=(e,t)=>HN(e,t,n.relTol,n.absTol),i=e.floor(),a=r(e);return i.eq(a)?i:t(e,a)&&!t(e,i)?a:i}return t(`floor`,{number:d.signatures.number,"number,number":d.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:f,"BigNumber, BigNumber":function(e,t){var n=_F.pow(t);return f(e.mul(n)).div(n)},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(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>nM(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>nM(t,t=>e(t,n),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(i(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>a(t,0)?o(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),bF=Z(`matAlgo02xDS0`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i,a){var o=e._data,s=e._size,c=e._datatype||e.getDataType(),l=r._values,u=r._index,d=r._ptr,f=r._size,p=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(s.length!==f.length)throw new sj(s.length,f.length);if(s[0]!==f[0]||s[1]!==f[1])throw RangeError(`Dimension mismatch. Matrix A (`+s+`) must match Matrix B (`+f+`)`);if(!l)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var m=s[0],h=s[1],g,_=n,v=0,y=i;typeof c==`string`&&c===p&&c!==`mixed`&&(g=c,_=t.find(n,[g,g]),v=t.convert(0,g),y=t.find(i,[g,g]));for(var b=[],x=[],S=[],C=0;C{var{typed:t}=e;return function(e,n,r,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,u=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(o.length!==d.length)throw new sj(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+d+`)`);if(!c)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var p=o[0],m=o[1],h,g=0,_=r;typeof s==`string`&&s===f&&s!==`mixed`&&(h=s,g=t.convert(0,h),_=t.find(r,[h,h]));for(var v=[],y=0;y{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new sj(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=x?[]:void 0,T=x?[]:void 0,E=[],D=[],O,k,A,j;for(k=0;k{var{typed:t}=e;return function(e,r,i){var a=e._data,o=e._size,s=e._datatype,c=r._data,l=r._size,u=r._datatype,d=[];if(o.length!==l.length)throw new sj(o.length,l.length);for(var f=0;f0?n(m,0,d,d[0],a,c):[];return e.createDenseMatrix({data:h,size:d,datatype:p})};function n(e,t,r,i,a,o){var s=[];if(t===r.length-1)for(var c=0;cTF(e,n))}function TF(e,t){return ED(e.size(),t)?e:e.create(Rj(e.valueOf(),t),e.datatype())}var EF=Z(`matrixAlgorithmSuite`,[`typed`,`matrix`],e=>{var{typed:t,matrix:n}=e,r=CF({typed:t}),i=$P({typed:t});return function(e){var a=e.elop,o=e.SD||e.DS,s;a?(s={"DenseMatrix, DenseMatrix":(e,t)=>r(...wF(e,t),a),"Array, Array":(e,t)=>r(...wF(n(e),n(t)),a).valueOf(),"Array, DenseMatrix":(e,t)=>r(...wF(n(e),t),a),"DenseMatrix, Array":(e,t)=>r(...wF(e,n(t)),a)},e.SS&&(s[`SparseMatrix, SparseMatrix`]=(t,n)=>e.SS(...wF(t,n),a,!1)),e.DS&&(s[`DenseMatrix, SparseMatrix`]=(t,n)=>e.DS(...wF(t,n),a,!1),s[`Array, SparseMatrix`]=(t,r)=>e.DS(...wF(n(t),r),a,!1)),o&&(s[`SparseMatrix, DenseMatrix`]=(e,t)=>o(...wF(t,e),a,!0),s[`SparseMatrix, Array`]=(e,t)=>o(...wF(n(t),e),a,!0))):(s={"DenseMatrix, DenseMatrix":t.referToSelf(e=>(t,n)=>r(...wF(t,n),e)),"Array, Array":t.referToSelf(e=>(t,i)=>r(...wF(n(t),n(i)),e).valueOf()),"Array, DenseMatrix":t.referToSelf(e=>(t,i)=>r(...wF(n(t),i),e)),"DenseMatrix, Array":t.referToSelf(e=>(t,i)=>r(...wF(t,n(i)),e))},e.SS&&(s[`SparseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.SS(...wF(n,r),t,!1))),e.DS&&(s[`DenseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.DS(...wF(n,r),t,!1)),s[`Array, SparseMatrix`]=t.referToSelf(t=>(r,i)=>e.DS(...wF(n(r),i),t,!1))),o&&(s[`SparseMatrix, DenseMatrix`]=t.referToSelf(e=>(t,n)=>o(...wF(n,t),e,!0)),s[`SparseMatrix, Array`]=t.referToSelf(e=>(t,r)=>o(...wF(n(r),t),e,!0))));var c=e.scalar||`any`;(e.Ds||e.Ss)&&(a?(s[`DenseMatrix,`+c]=(e,t)=>i(e,t,a,!1),s[c+`, DenseMatrix`]=(e,t)=>i(t,e,a,!0),s[`Array,`+c]=(e,t)=>i(n(e),t,a,!1).valueOf(),s[c+`, Array`]=(e,t)=>i(n(t),e,a,!0).valueOf()):(s[`DenseMatrix,`+c]=t.referToSelf(e=>(t,n)=>i(t,n,e,!1)),s[c+`, DenseMatrix`]=t.referToSelf(e=>(t,n)=>i(n,t,e,!0)),s[`Array,`+c]=t.referToSelf(e=>(t,r)=>i(n(t),r,e,!1).valueOf()),s[c+`, Array`]=t.referToSelf(e=>(t,r)=>i(n(r),t,e,!0).valueOf())));var l=e.sS===void 0?e.Ss:e.sS;return a?(e.Ss&&(s[`SparseMatrix,`+c]=(t,n)=>e.Ss(t,n,a,!1)),l&&(s[c+`, SparseMatrix`]=(e,t)=>l(t,e,a,!0))):(e.Ss&&(s[`SparseMatrix,`+c]=t.referToSelf(t=>(n,r)=>e.Ss(n,r,t,!1))),l&&(s[c+`, SparseMatrix`]=t.referToSelf(e=>(t,n)=>l(n,t,e,!0)))),a&&a.signatures&&wD(s,a.signatures),s}}),DF=`mod`,OF=Z(DF,[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s,concat:c}=e,l=yF({typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}),u=bF({typed:t,equalScalar:a}),d=xF({typed:t}),f=SF({typed:t,equalScalar:a}),p=ZP({typed:t,equalScalar:a}),m=QP({typed:t,DenseMatrix:s}),h=EF({typed:t,matrix:i,concat:c});return t(DF,{"number, number":g,"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.sub(t.mul(l(e.div(t))))},"bigint, bigint":function(e,t){if(t===0n)return e;if(e<0){var n=e%t;return n===0n?n:n+t}return e%t},"Fraction, Fraction":function(e,t){return t.equals(0)?e:e.sub(t.mul(l(e.div(t))))}},h({SS:f,DS:d,SD:u,Ss:p,sS:m}));function g(e,t){return t===0?e:e-t*l(e/t)}}),kF=Z(`matAlgo01xDSid`,[`typed`],e=>{var{typed:t}=e;return function(e,n,r,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,u=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(o.length!==d.length)throw new sj(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+d+`)`);if(!c)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var p=o[0],m=o[1],h=typeof s==`string`&&s!==`mixed`&&s===f?s:void 0,g=h?t.find(r,[h,h]):r,_,v,y=[];for(_=0;_{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new sj(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=a&&u?[]:void 0,T=a&&u?[]:void 0,E=[],D=[],O,k,A,j,M;for(k=0;k{var{typed:t,DenseMatrix:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=i;typeof u==`string`&&(p=u,r=t.convert(r,p),m=t.find(i,[p,p]));for(var h=[],g=[],_=[],v=0;vArray.isArray(e))}var RF=Z(NF,PF,e=>{var{typed:t,matrix:n,config:r,round:i,equalScalar:a,zeros:o,BigNumber:s,DenseMatrix:c,concat:l}=e,u=OF({typed:t,config:r,round:i,matrix:n,equalScalar:a,zeros:o,DenseMatrix:c,concat:l}),d=kF({typed:t}),f=AF({typed:t,equalScalar:a}),p=jF({typed:t,DenseMatrix:c}),m=EF({typed:t,matrix:n,concat:l});return t(NF,{"number, number":h,"BigNumber, BigNumber":g,"Fraction, Fraction":(e,t)=>e.gcd(t)},m({SS:f,DS:d,Ss:p}),{[IF]:t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;at=>{if(t.length===1&&Array.isArray(t[0])&&LF(t[0]))return e(...t[0]);if(LF(t))return e(...t);throw new MF(`gcd() supports only 1d matrices!`)}),Matrix:t.referToSelf(e=>t=>e(t.toArray()))});function h(e,t){if(!HD(e)||!HD(t))throw Error(`Parameters in function gcd must be integer numbers`);for(var n;t!==0;)n=u(e,t),e=t,t=n;return e<0?-e:e}function g(e,t){if(!e.isInt()||!t.isInt())throw Error(`Parameters in function gcd must be integer numbers`);for(var n=new s(0);!t.isZero();){var r=u(e,t);e=t,t=r}return e.lt(n)?e.neg():e}}),zF=Z(`matAlgo06xS0S0`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._size,s=e._datatype||e._data===void 0?e._datatype:e.getDataType(),c=r._values,l=r._size,u=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(o.length!==l.length)throw new sj(o.length,l.length);if(o[0]!==l[0]||o[1]!==l[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+l+`)`);var d=o[0],f=o[1],p,m=n,h=0,g=i;typeof s==`string`&&s===u&&s!==`mixed`&&(p=s,m=t.find(n,[p,p]),h=t.convert(0,p),g=t.find(i,[p,p]));for(var _=a&&c?[]:void 0,v=[],y=[],b=_?[]:void 0,x=[],S=[],C=0;C{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=bF({typed:t,equalScalar:r}),o=zF({typed:t,equalScalar:r}),s=ZP({typed:t,equalScalar:r}),c=EF({typed:t,matrix:n,concat:i}),l=`number | BigNumber | Fraction | Matrix | Array`,u={};return u[`${l}, ${l}, ...${l}`]=t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;ae.lcm(t)},c({SS:o,DS:a,Ss:s}),u);function d(e,t){if(!e.isInt()||!t.isInt())throw Error(`Parameters in function lcm must be integer numbers`);if(e.isZero())return e;if(t.isZero())return t;for(var n=e.times(t);!t.isZero();){var r=t;t=e.mod(r),e=r}return n.div(e).abs()}});function HF(e,t,n,r){return function(i){if(i>0||n.predictable){if(i<=0)return NaN;var a=i.toString(16),o=a.substring(0,15);return e*(a.length-o.length)+t(Number(`0x`+o))}return r(i.toNumber())}}var UF=`log10`,WF=[`typed`,`config`,`Complex`],GF=wM(16),KF=Z(UF,WF,e=>{var{typed:t,config:n,Complex:r}=e;function i(e){return e.log().div(Math.LN10)}function a(e){return i(new r(e,0))}return t(UF,{number:function(e){return e>=0||n.predictable?wM(e):a(e)},bigint:HF(GF,wM,n,a),Complex:i,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():a(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),qF=`log2`,JF=Z(qF,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;function i(e){return a(new r(e,0))}return t(qF,{number:function(e){return e>=0||n.predictable?TM(e):i(e)},bigint:HF(4,TM,n,i),Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):i(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}}),YF=Z(`multiplyScalar`,[`typed`],e=>{var{typed:t}=e;return t(`multiplyScalar`,{"number, number":pM,"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)})}),XF=`multiply`,ZF=Z(XF,[`typed`,`matrix`,`addScalar`,`multiplyScalar`,`equalScalar`,`dot`],e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:i,equalScalar:a,dot:o}=e,s=ZP({typed:t,equalScalar:a}),c=$P({typed:t});function l(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Vectors must have the same length`);break;case 2:if(e[0]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Vector length (`+e[0]+`) must match Matrix rows (`+t[0]+`)`);break;default:throw 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 RangeError(`Dimension mismatch in multiplication. Matrix columns (`+e[1]+`) must match Vector length (`+t[0]+`)`);break;case 2:if(e[1]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Matrix A columns (`+e[1]+`) must match Matrix B rows (`+t[0]+`)`);break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix B has `+t.length+` dimensions)`)}break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix A has `+e.length+` dimensions)`)}}function u(e,t,n){if(n===0)throw Error(`Cannot multiply two empty vectors`);return o(e,t)}function d(e,t){if(t.storage()!==`dense`)throw Error(`Support for SparseMatrix not implemented`);return f(e,t)}function f(e,n){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._data,l=n._size,u=n._datatype||n.getDataType(),d=o[0],f=l[1],p,m=r,h=i;s&&u&&s===u&&typeof s==`string`&&s!==`mixed`&&(p=s,m=t.find(r,[p,p]),h=t.find(i,[p,p]));for(var g=[],_=0;_E)for(var O=0,k=0;k(t,r)=>{l(lj(t),lj(r));var i=e(n(t),n(r));return zE(i)?i.valueOf():i}),"Matrix, Matrix":function(e,t){var n=e.size(),r=t.size();return l(n,r),n.length===1?r.length===1?u(e,t,n[0]):d(e,t):r.length===1?p(e,t):m(e,t)},"Matrix, Array":t.referTo(`Matrix,Matrix`,e=>(t,r)=>e(t,n(r))),"Array, Matrix":t.referToSelf(e=>(t,r)=>e(n(t,r.storage()),r)),"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(n(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,concat:a}=e,o=kF({typed:t}),s=bF({typed:t,equalScalar:r}),c=zF({typed:t,equalScalar:r}),l=ZP({typed:t,equalScalar:r}),u=EF({typed:t,matrix:n,concat:a});function d(){throw Error(`Complex number not supported in function nthRoot. Use nthRoots instead.`)}return t(QF,{number:OM,"number, number":OM,BigNumber:e=>f(e,new i(2)),"BigNumber, BigNumber":f,Complex:d,"Complex, number":d,Array:t.referTo(`DenseMatrix,number`,e=>t=>e(n(t),2).valueOf()),DenseMatrix:t.referTo(`DenseMatrix,number`,e=>t=>e(t,2)),SparseMatrix:t.referTo(`SparseMatrix,number`,e=>t=>e(t,2)),"SparseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return c(t,n,e);throw Error(`Root must be non-zero`)}),"DenseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return o(t,n,e,!1);throw Error(`Root must be non-zero`)}),"Array, SparseMatrix":t.referTo(`DenseMatrix,SparseMatrix`,e=>(t,r)=>e(n(t),r)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return l(n,t,e,!0);throw Error(`Root must be non-zero`)})},u({scalar:`number | BigNumber`,SD:s,Ss:l,sS:!1}));function f(e,t){var n=i.precision,r=i.clone({precision:n+2}),a=new i(0),o=new r(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw Error(`Root must be non-zero`);if(e.isNegative()&&!t.abs().mod(2).equals(1))throw Error(`Root must be odd when a is negative.`);if(e.isZero())return s?new r(1/0):0;if(!e.isFinite())return s?a:e;var c=e.abs().pow(o.div(t));return c=e.isNeg()?c.neg():c,new i((s?o.div(c):c).toPrecision(n))}}),eI=`sign`,tI=Z(eI,[`typed`,`BigNumber`,`Fraction`,`complex`],e=>{var{typed:t,BigNumber:n,complex:r,Fraction:i}=e;return t(eI,{number:kM,Complex:function(e){return e.im===0?r(kM(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},bigint:function(e){return e>0n?1n:e<0n?-1n:0n},Fraction:function(e){return e.n===0n?new i(0):new i(e.s)},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e,!0)),Unit:t.referToSelf(e=>n=>{if(!n._isDerived()&&n.units[0].unit.offset!==0)throw TypeError(`sign is ambiguous for units with offset`);return t.find(e,n.valueType())(n.value)})})}),nI=Z(`sqrt`,[`config`,`typed`,`Complex`],e=>{var{config:t,typed:n,Complex:r}=e;return n(`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:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}}),rI=`square`,iI=Z(rI,[`typed`],e=>{var{typed:t}=e;return t(rI,{number:jM,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)}})}),aI=`subtract`,oI=Z(aI,[`typed`,`matrix`,`equalScalar`,`subtractScalar`,`unaryMinus`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,subtractScalar:i,unaryMinus:a,DenseMatrix:o,concat:s}=e,c=kF({typed:t}),l=xF({typed:t}),u=SF({typed:t,equalScalar:r}),d=jF({typed:t,DenseMatrix:o}),f=QP({typed:t,DenseMatrix:o}),p=EF({typed:t,matrix:n,concat:s});return t(aI,{"any, any":i},p({elop:i,SS:u,DS:c,SD:l,Ss:f,sS:d}))}),sI=`xgcd`,cI=Z(sI,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(sI,{"number, number":function(e,t){var i=MM(e,t);return n.matrix===`Array`?i:r(i)},"BigNumber, BigNumber":a});function a(e,t){var a,o,s,c=new i(0),l=new i(1),u=c,d=l,f=l,p=c;if(!e.isInt()||!t.isInt())throw Error(`Parameters in function xgcd must be integer numbers`);for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=u,u=d.minus(o.times(u)),d=a,a=f,f=p.minus(o.times(f)),p=a,e=t,t=s;var m=e.lt(c)?[e.neg(),d.neg(),p.neg()]:[e,e.isZero()?0:d,p];return n.matrix===`Array`?m:r(m)}}),lI=`invmod`,uI=Z(lI,[`typed`,`config`,`BigNumber`,`xgcd`,`equal`,`smaller`,`mod`,`add`,`isInteger`],e=>{var{typed:t,config:n,BigNumber:r,xgcd:i,equal:a,smaller:o,mod:s,add:c,isInteger:l}=e;return t(lI,{"number, number":u,"BigNumber, BigNumber":u});function u(e,t){if(!l(e)||!l(t))throw Error(`Parameters in function invmod must be integer numbers`);if(e=s(e,t),a(t,0))throw Error(`Divisor must be non zero`);var n=i(e,t);n=n.valueOf();var[u,d]=n;return a(u,r(1))?(d=s(d,t),o(d,r(0))&&(d=c(d,t)),d):NaN}}),dI=Z(`matAlgo09xS0Sf`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new sj(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=x?[]:void 0,T=[],E,D,O,k,A;for(D=0;D{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:i,concat:a}=e,o=bF({typed:t,equalScalar:r}),s=dI({typed:t,equalScalar:r}),c=ZP({typed:t,equalScalar:r});return t(fI,EF({typed:t,matrix:n,concat:a})({elop:i,SS:s,DS:o,Ss:c}))});function mI(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitAnd`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(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 n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return _I(e,t,function(e,t){return e&t})}function hI(e){if(e.isFinite()&&!e.isInteger())throw Error(`Integer expected in function bitNot`);var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function gI(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitOr`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:!e.isFinite()||!t.isFinite()?!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e:_I(e,t,function(e,t){return e|t})}function _I(e,t,n){var r=e.constructor,i,a,o=+(e.s<0),s=+(t.s<0);if(o){i=vI(hI(e));for(var c=0;c0;)n(u[--p],d[--m])===h&&(g=g.plus(_)),_=_.times(v);for(;m>0;)n(f,d[--m])===h&&(g=g.plus(_)),_=_.times(v);return r.config({precision:y}),h===0&&(g.s=-g.s),g}function vI(e){for(var t=e.d,n=t[0]+``,r=1;r0)if(++s>l)for(s-=l;s--;)c+=`0`;else s1&&((u[p+1]===null||u[p+1]===void 0)&&(u[p+1]=0),u[p+1]+=u[p]>>1,u[p]&=1)}return u.reverse()}function yI(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitXor`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?hI(t):t.eq(r)?hI(e):!e.isFinite()||!t.isFinite()?!e.isFinite()&&!t.isFinite()?r:new n(e.isNegative()===t.isNegative()?1/0:-1/0):_I(e,t,function(e,t){return e^t})}function bI(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function leftShift`);var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:!e.isFinite()&&!t.isFinite()?new n(NaN):t.lt(55)?e.times(2**t.toNumber()+``):e.times(new n(2).pow(t))}function xI(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function rightArithShift`);var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(2**t.toNumber()+``).floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var SI=`bitAnd`,CI=Z(SI,[`typed`,`matrix`,`equalScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=bF({typed:t,equalScalar:r}),o=zF({typed:t,equalScalar:r}),s=ZP({typed:t,equalScalar:r}),c=EF({typed:t,matrix:n,concat:i});return t(SI,{"number, number":RM,"BigNumber, BigNumber":mI,"bigint, bigint":(e,t)=>e&t},c({SS:o,DS:a,Ss:s}))}),wI=`bitNot`,TI=Z(wI,[`typed`],e=>{var{typed:t}=e;return t(wI,{number:zM,BigNumber:hI,bigint:e=>~e,"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),EI=`bitOr`,DI=Z(EI,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=kF({typed:t}),s=AF({typed:t,equalScalar:r}),c=jF({typed:t,DenseMatrix:i}),l=EF({typed:t,matrix:n,concat:a});return t(EI,{"number, number":BM,"BigNumber, BigNumber":gI,"bigint, bigint":(e,t)=>e|t},l({SS:s,DS:o,Ss:c}))}),OI=Z(`matAlgo07xSSf`,[`typed`,`SparseMatrix`],e=>{var{typed:t,SparseMatrix:n}=e;return function(e,i,a){var o=e._size,s=e._datatype||e._data===void 0?e._datatype:e.getDataType(),c=i._size,l=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(o.length!==c.length)throw new sj(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+c+`)`);var u=o[0],d=o[1],f,p=0,m=a;typeof s==`string`&&s===l&&s!==`mixed`&&(f=s,p=t.convert(0,f),m=t.find(a,[f,f]));for(var h=[],g=[],_=Array(d+1).fill(0),v=[],y=[],b=[],x=[],S=0;S{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=xF({typed:t}),s=OI({typed:t,SparseMatrix:a}),c=QP({typed:t,DenseMatrix:r}),l=EF({typed:t,matrix:n,concat:i});return t(kI,{"number, number":VM,"BigNumber, BigNumber":yI,"bigint, bigint":(e,t)=>e^t},l({SS:s,DS:o,Ss:c}))}),jI=`arg`,MI=Z(jI,[`typed`],e=>{var{typed:t}=e;return t(jI,{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(e=>t=>nM(t,e))})}),NI=`conj`,PI=Z(NI,[`typed`],e=>{var{typed:t}=e;return t(NI,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),Unit:t.referToSelf(e=>t=>new t.constructor(e(t.toNumeric()),t.formatUnits())),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),FI=`im`,II=Z(FI,[`typed`],e=>{var{typed:t}=e;return t(FI,{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),LI=`re`,RI=Z(LI,[`typed`],e=>{var{typed:t}=e;return t(LI,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),zI=`not`,BI=Z(zI,[`typed`],e=>{var{typed:t}=e;return t(zI,{"null | undefined":()=>!0,number:$M,Complex:function(e){return e.re===0&&e.im===0},BigNumber:function(e){return e.isZero()||e.isNaN()},bigint:e=>!e,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),VI=`nullish`,HI=Z(VI,[`typed`,`matrix`,`size`,`flatten`,`deepEqual`],e=>{var{typed:t,matrix:n,size:r,flatten:i,deepEqual:a}=e,o=xF({typed:t}),s=$P({typed:t}),c=CF({typed:t});return t(VI,{"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 n=r(e),i=r(t);if(a(n,i))return e;throw new sj(n,i)},"DenseMatrix, DenseMatrix":t.referToSelf(e=>(t,n)=>c(t,n,e)),"DenseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>o(t,n,e,!1)),"DenseMatrix, Array":t.referToSelf(e=>(t,r)=>c(t,n(r),e)),"DenseMatrix, any":t.referToSelf(e=>(t,n)=>s(t,n,e,!1)),"Array, Array":t.referToSelf(e=>(t,r)=>c(n(t),n(r),e).valueOf()),"Array, DenseMatrix":t.referToSelf(e=>(t,r)=>c(n(t),r,e)),"Array, SparseMatrix":t.referToSelf(e=>(t,r)=>o(n(t),r,e,!1)),"Array, any":t.referToSelf(e=>(t,r)=>s(n(t),r,e,!1).valueOf())})}),UI=`or`,WI=Z(UI,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=xF({typed:t}),s=SF({typed:t,equalScalar:r}),c=QP({typed:t,DenseMatrix:i}),l=EF({typed:t,matrix:n,concat:a});return t(UI,{"number, number":eN,"Complex, Complex":function(e,t){return e.re!==0||e.im!==0||t.re!==0||t.im!==0},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"bigint, bigint":eN,"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0))},l({SS:s,DS:o,Ss:c}))}),GI=`xor`,KI=Z(GI,[`typed`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=xF({typed:t}),s=OI({typed:t,SparseMatrix:a}),c=QP({typed:t,DenseMatrix:r}),l=EF({typed:t,matrix:n,concat:i});return t(GI,{"number, number":tN,"Complex, Complex":function(e,t){return(e.re!==0||e.im!==0)!=(t.re!==0||t.im!==0)},"bigint, bigint":tN,"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0))},l({SS:s,DS:o,Ss:c}))}),qI=`concat`,JI=Z(qI,[`typed`,`matrix`,`isInteger`],e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(qI,{"...Array | Matrix | number | BigNumber":function(e){var t,i=e.length,a=-1,o,s=!1,c=[];for(t=0;t0&&a>o)throw new cj(a,o+1)}else{var u=SD(l).valueOf(),d=lj(u);if(c[t]=u,o=a,a=d.length-1,t>0&&a!==o)throw new sj(o+1,a+1)}}if(c.length===0)throw SyntaxError(`At least one matrix expected`);for(var f=c.shift();c.length;)f=Fj(f,c.shift(),a);return s?n(f):f},"...string":function(e){return e.join(``)}})}),YI=`column`,XI=Z(YI,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e;return t(YI,{"Matrix, number":a,"Array, number":function(e,t){return a(r(SD(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);pj(t,e.size()[1]);var a=new n(i(0,e.size()[0]),[t]),o=e.subset(a);return zE(o)?o:r([[o]])}}),ZI=`count`,QI=Z(ZI,[`typed`,`size`,`prod`],e=>{var{typed:t,size:n,prod:r}=e;return t(ZI,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})}),$I=`cross`,eL=Z($I,[`typed`,`matrix`,`subtract`,`multiply`],e=>{var{typed:t,matrix:n,subtract:r,multiply:i}=e;return t($I,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var n=Math.max(lj(e).length,lj(t).length);e=xj(e),t=xj(t);var a=lj(e),o=lj(t);if(a.length!==1||o.length!==1||a[0]!==3||o[0]!==3)throw RangeError(`Vectors with length 3 expected (Size A = [`+a.join(`, `)+`], B = [`+o.join(`, `)+`])`);var s=[r(i(e[1],t[2]),i(e[2],t[1])),r(i(e[2],t[0]),i(e[0],t[2])),r(i(e[0],t[1]),i(e[1],t[0]))];return n>1?[s]:s}}),tL=`diag`,nL=Z(tL,[`typed`,`matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(tL,{Array:function(e){return a(e,0,lj(e),null)},"Array, number":function(e,t){return a(e,t,lj(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),lj(e),null)},"Array, string":function(e,t){return a(e,0,lj(e),t)},"Array, number, string":function(e,t,n){return a(e,t,lj(e),n)},"Array, BigNumber, string":function(e,t,n){return a(e,t.toNumber(),lj(e),n)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return a(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return a(e,t.toNumber(),e.size(),n)}});function a(e,t,n,r){if(!HD(t))throw TypeError(`Second parameter in function diag must be an integer`);var i=t>0?t:0,a=t<0?-t:0;switch(n.length){case 1:return o(e,t,r,n[0],a,i);case 2:return s(e,t,r,n,a,i)}throw RangeError(`Matrix for function diag must be 2 dimensional`)}function o(e,t,n,a,o,s){var c=[a+o,a+s];if(n&&n!==`sparse`&&n!==`dense`)throw TypeError(`Unknown matrix type ${n}"`);var l=n===`sparse`?i.diagonal(c,e,t):r.diagonal(c,e,t);return n===null?l.valueOf():l}function s(e,t,r,i,a,o){if(zE(e)){var s=e.diagonal(t);return r===null?s.valueOf():r===s.storage()?s:n(s,r)}for(var c=Math.min(i[0]-a,i[1]-o),l=[],u=0;u{var{typed:t}=e;return t(`filter`,{"Array, function":iL,"Matrix, function":function(e,t){return e.create(iL(e.valueOf(),t),e.datatype())},"Array, RegExp":kj,"Matrix, RegExp":function(e,t){return e.create(kj(e.valueOf(),t),e.datatype())}})});function iL(e,t){var n=Wj(t,e,`filter`);return n.isUnary?Oj(e,n.fn):Oj(e,function(e,t,r){return n.fn(e,[t],r)})}var aL=`flatten`,oL=Z(aL,[`typed`],e=>{var{typed:t}=e;return t(aL,{Array:function(e){return Tj(e)},DenseMatrix:function(e){return e.create(Tj(e.valueOf(),!0),e.datatype())},SparseMatrix:function(e){throw TypeError(`SparseMatrix is not supported by function flatten because it does not support 1D vectors. Convert to a DenseMatrix or Array first. Example: flatten(x.toArray())`)}})}),sL=`forEach`,cL=Z(sL,[`typed`],e=>{var{typed:t}=e;return t(sL,{"Array, function":lL,"Matrix, function":function(e,t){e.forEach(t)}})});function lL(e,t){var n=Wj(t,e,sL);Hj(e,n.fn,n.isUnary)}var uL=`getMatrixDataType`,dL=Z(uL,[`typed`],e=>{var{typed:t}=e;return t(uL,{Array:function(e){return Nj(e,xD)},Matrix:function(e){return e.getDataType()}})}),fL=`identity`,pL=Z(fL,[`typed`,`config`,`matrix`,`BigNumber`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return t(fL,{"":function(){return n.matrix===`Matrix`?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return c(e,e,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return c(e,t,n)},Array:function(e){return s(e)},"Array, string":function(e,t){return s(e,t)},Matrix:function(e){return s(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return s(e.valueOf(),t)}});function s(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw Error(`Vector containing two values expected`)}}function c(e,t,n){var r=ME(e)||ME(t)?i:null;if(ME(e)&&(e=e.toNumber()),ME(t)&&(t=t.toNumber()),!HD(e)||e<1||!HD(t)||t<1)throw Error(`Parameters in function identity must be positive integers`);var s=r?new i(1):1,c=r?new r(0):0,l=[e,t];if(n){if(n===`sparse`)return o.diagonal(l,s,0,c);if(n===`dense`)return a.diagonal(l,s,0,c);throw TypeError(`Unknown matrix type "${n}"`)}for(var u=hj([],l,c),d=e{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(mL,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function i(e,t){return e.flatMap(e=>t.map(t=>r(e,t)))}function a(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1;if(n<0){var r=lj(e).length,o=lj(t).length;for(n=Math.max(r,o);r++t.map(t=>a(e,t,n-1)))}}),gL=`map`,_L=Z(gL,[`typed`],e=>{var{typed:t}=e;return t(gL,{"Array, function":s,"Matrix, function":function(e,t){return e.map(t)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(e,t,r)=>n([e,t,...r.slice(0,r.length-1)],r[r.length-1])});function n(e,n){if(typeof n!=`function`)throw Error(`Last argument must be a callback function`);var c=e[0].isMatrix,l=e.map(e=>e.isMatrix?e.size():lj(e)),u=Ij(...l),d=e.length,f=c?(e,t)=>e.get(t):Bj,p=e.map((e,t)=>{var n=l[t].map(()=>0);return e.isMatrix?e.get(n):Bj(e,n)}),m=t.isTypedFunction(n)?o(n,p,u.map(()=>0),e):a(n,d);if(m<2)return r(e,i(m,n,null));var h=c?e.map(t=>t.isMatrix?t.create(Rj(t.toArray(),u),t.datatype()):e[0].create(Rj(t.valueOf(),u))):e.map(e=>e.isMatrix?Rj(e.toArray(),u):Rj(e,u)),g=i(m,n,h),_=(e,t)=>g([e,...h.slice(1).map(e=>f(e,t))],t);return c?h[0].map(_):s(h[0],_)}function r(e,t){var n=e[0],r=e.map(e=>e.isMatrix?e.valueOf():e),i=e.map(e=>e.isMatrix?e.size():lj(e)),a=Ij(...i),o=i.map(e=>a.length-e.length),s=a.length-1,c=t.length>1?[]:null,l=d(r,0);if(n.isMatrix){var u=n.create();return u._data=l,u._size=a,u}else return l;function d(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=a[n],i=Array(r);if(no[r]>n?e:e.length===1?e[0]:e[t]),n+1)},u=0;ue.length===1?e[0]:e[r]),c?c.slice():void 0)},p=0;pt(...e);case 1:return(e,n)=>t(...e,n);case 2:return(e,r)=>t(...e,r,...n)}}function a(e,t){var n=e.toString();if(/arguments/.test(n))return 2;var r=n.match(/\(.*?\)/);return/\.\.\./.test(r)||e.length>t+1?2:+(e.length===t+1)}function o(e,n,r,i){return t.resolve(e,[...n,r,...i])===null?t.resolve(e,[...n,r])===null?(t.resolve(e,n),0):1:2}function s(e,t){var n=Wj(t,e,gL);return Vj(e,n.fn,n.isUnary)}}),vL=`diff`,yL=Z(vL,[`typed`,`matrix`,`subtract`,`number`],e=>{var{typed:t,matrix:n,subtract:r,number:i}=e;return t(vL,{"Array | Matrix":function(e){return zE(e)?n(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!HD(t))throw RangeError(`Dimension must be a whole number`);return zE(e)?n(a(e.toArray(),t)):a(e,t)},"Array, BigNumber":t.referTo(`Array,number`,e=>(t,n)=>e(t,i(n))),"Matrix, BigNumber":t.referTo(`Matrix,number`,e=>(t,n)=>e(t,i(n)))});function a(e,t){if(zE(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError(`Array/Matrix does not have that many dimensions`);if(t>0){var n=[];return e.forEach(e=>{n.push(a(e,t-1))}),n}else if(t===0)return o(e);else throw RangeError(`Cannot have negative dimension`)}function o(e){for(var t=[],n=e.length,r=1;r{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(`ones`,{"":function(){return n.matrix===`Array`?a([]):a([],`default`)},"...number | BigNumber | string":function(e){return typeof e[e.length-1]==`string`?a(e,e.pop()):n.matrix===`Array`?a(e):a(e,`default`)},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var n=o(e)?new i(1):1;if(s(e),t){var a=r(t);return e.length>0?a.resize(e,n):a}else{var c=[];return e.length>0?hj(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){ME(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!HD(e)||e<0)throw Error(`Parameters in function ones must be positive integers`)})}});function xL(){throw Error(`No "bignumber" implementation available`)}function SL(){throw Error(`No "fraction" implementation available`)}function CL(){throw Error(`No "matrix" implementation available`)}var wL=`range`,TL=Z(wL,[`typed`,`config`,`?matrix`,`?bignumber`,`equal`,`smaller`,`smallerEq`,`larger`,`largerEq`,`add`,`isZero`,`isPositive`],e=>{var{typed:t,config:n,matrix:r,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:c,add:l,isZero:u,isPositive:d}=e;return t(wL,{string:p,"string, boolean":p,number:function(e){throw TypeError(`Too few arguments to function range(): ${e}`)},boolean:function(e){throw TypeError(`Unexpected type of argument 1 to function range(): ${e}, number|bigint|BigNumber|Fraction`)},"number, number":function(e,t){return f(m(e,t,1,!1))},"number, number, number":function(e,t,n){return f(m(e,t,n,!1))},"number, number, boolean":function(e,t,n){return f(m(e,t,1,n))},"number, number, number, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"bigint, bigint|number":function(e,t){return f(m(e,t,1n,!1))},"number, bigint":function(e,t){return f(m(BigInt(e),t,1n,!1))},"bigint, bigint|number, bigint|number":function(e,t,n){return f(m(e,t,BigInt(n),!1))},"number, bigint, bigint|number":function(e,t,n){return f(m(BigInt(e),t,BigInt(n),!1))},"bigint, bigint|number, boolean":function(e,t,n){return f(m(e,t,1n,n))},"number, bigint, boolean":function(e,t,n){return f(m(BigInt(e),t,1n,n))},"bigint, bigint|number, bigint|number, boolean":function(e,t,n,r){return f(m(e,t,BigInt(n),r))},"number, bigint, bigint|number, boolean":function(e,t,n,r){return f(m(BigInt(e),t,BigInt(n),r))},"BigNumber, BigNumber":function(e,t){var n=e.constructor;return f(m(e,t,new n(1),!1))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return f(m(e,t,n,!1))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return f(m(e,t,new r(1),n))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"Fraction, Fraction":function(e,t){return f(m(e,t,1,!1))},"Fraction, Fraction, Fraction":function(e,t,n){return f(m(e,t,n,!1))},"Fraction, Fraction, boolean":function(e,t,n){return f(m(e,t,1,n))},"Fraction, Fraction, Fraction, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"Unit, Unit, Unit":function(e,t,n){return f(m(e,t,n,!1))},"Unit, Unit, Unit, boolean":function(e,t,n,r){return f(m(e,t,n,r))}});function f(e){return n.matrix===`Matrix`?r?r(e):CL():e}function p(e,t){var r=h(e);if(!r)throw SyntaxError(`String "`+e+`" is no valid range`);return n.number===`BigNumber`?(i===void 0&&xL(),f(m(i(r.start),i(r.end),i(r.step)),t)):f(m(r.start,r.end,r.step,t))}function m(e,t,n,r){var i=[];if(u(n))throw Error(`Step must be non-zero`);for(var f=d(n)?r?o:a:r?c:s,p=e;f(p,t);)i.push(p),p=l(p,n);return i}function h(e){var t=e.split(`:`).map(function(e){return Number(e)});if(t.some(function(e){return isNaN(e)}))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}}),EL=`reshape`,DL=Z(EL,[`typed`,`isInteger`,`matrix`],e=>{var{typed:t,isInteger:n}=e;return t(EL,{"Matrix, Array":function(e,t){return e.reshape(t,!0)},"Array, Array":function(e,t){return t.forEach(function(e){if(!n(e))throw TypeError(`Invalid size for dimension: `+e)}),_j(e,t)}})}),OL=Z(`resize`,[`config`,`matrix`],e=>{var{config:t,matrix:n}=e;return function(e,i,a){if(arguments.length!==2&&arguments.length!==3)throw new MF(`resize`,arguments.length,2,3);if(zE(i)&&(i=i.valueOf()),ME(i[0])&&(i=i.map(function(e){return ME(e)?e.toNumber():e})),zE(e))return e.resize(i,a,!0);if(typeof e==`string`)return r(e,i,a);var o=Array.isArray(e)?!1:t.matrix!==`Array`;if(i.length===0){for(;Array.isArray(e);)e=e[0];return SD(e)}else{Array.isArray(e)||(e=[e]),e=SD(e);var s=hj(e,i,a);return o?n(s):s}};function r(e,t,n){if(n!==void 0){if(typeof n!=`string`||n.length!==1)throw TypeError(`Single character expected as defaultValue`)}else n=` `;if(t.length!==1)throw new sj(t.length,1);var r=t[0];if(typeof r!=`number`||!HD(r))throw TypeError(`Invalid size, must contain positive integers (size: `+$A(t)+`)`);if(e.length>r)return e.substring(0,r);if(e.length{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(kL,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),n(r(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),n(r(t,a),e)}});function i(e,t){var n=Array.isArray(e)?lj(e):e.size();if(n.length>2||n.length===2&&n[1]!==1||n[0]!==t)throw RangeError(`Vector must be of dimensions 1x${t}`)}}),jL=`rotationMatrix`,ML=Z(jL,[`typed`,`config`,`multiplyScalar`,`addScalar`,`unaryMinus`,`norm`,`matrix`,`BigNumber`,`DenseMatrix`,`SparseMatrix`,`cos`,`sin`],e=>{var{typed:t,config:n,multiplyScalar:r,addScalar:i,unaryMinus:a,norm:o,BigNumber:s,matrix:c,DenseMatrix:l,SparseMatrix:u,cos:d,sin:f}=e;return t(jL,{"":function(){return n.matrix===`Matrix`?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return p(e,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return p(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=c(t);return m(n),_(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){return m(t),_(e,t,t.storage()||(n.matrix===`Matrix`?`dense`:void 0))},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=c(t);return m(r),_(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return m(t),_(e,t,n)}});function p(e,t){var n=ME(e)?new s(-1):-1,i=d(e),a=f(e);return g([[i,r(n,a)],[a,i]],t)}function m(e){var t=e.size();if(t.length<1||t[0]!==3)throw RangeError(`Vector must be of dimensions 1x3`)}function h(e){return e.reduce((e,t)=>r(e,t))}function g(e,t){if(t){if(t===`sparse`)return new u(e);if(t===`dense`)return new l(e);throw TypeError(`Unknown matrix type "${t}"`)}return e}function _(e,t,n){var r=o(t);if(r===0)throw RangeError(`Rotation around zero vector`);var c=ME(e)?s:null,l=c?new c(1):1,u=c?new c(-1):-1,p=c?new c(t.get([0])/r):t.get([0])/r,m=c?new c(t.get([1])/r):t.get([1])/r,_=c?new c(t.get([2])/r):t.get([2])/r,v=d(e),y=i(l,a(v)),b=f(e),x=i(v,h([p,p,y])),S=i(h([p,m,y]),h([u,_,b])),C=i(h([p,_,y]),h([m,b])),w=i(h([p,m,y]),h([_,b])),T=i(v,h([m,m,y])),E=i(h([m,_,y]),h([u,p,b])),D=i(h([p,_,y]),h([u,m,b])),O=i(h([m,_,y]),h([p,b])),k=i(v,h([_,_,y]));return g([[x,S,C],[w,T,E],[D,O,k]],n)}}),NL=`row`,PL=Z(NL,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e;return t(NL,{"Matrix, number":a,"Array, number":function(e,t){return a(r(SD(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);pj(t,e.size()[0]);var a=i(0,e.size()[1]),o=new n([t],a),s=e.subset(o);return zE(s)?s:r([[s]])}}),FL=`size`,IL=Z(FL,[`typed`],e=>{var{typed:t}=e;return t(FL,{Matrix:e=>e.size(),Array:lj,string:e=>[e.length],"number | Complex | BigNumber | Unit | boolean | null":e=>[]})}),LL=`squeeze`,RL=Z(LL,[`typed`],e=>{var{typed:t}=e;return t(LL,{Array:function(e){return xj(SD(e))},Matrix:function(e){var t=xj(e.toArray());return Array.isArray(t)?e.create(t,e.datatype()):t},any:function(e){return SD(e)}})}),zL=`subset`,BL=Z(zL,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e;return t(zL,{"Matrix, Index":function(e,t){return mj(t)?n():(fj(e,t),e.subset(t))},"Array, Index":t.referTo(`Matrix, Index`,function(e){return function(t,r){var i=e(n(t),r);return r.isScalar()?i:i.valueOf()}}),"Object, Index":UL,"string, Index":VL,"Matrix, Index, any, any":function(e,t,n,r){return mj(t)?e:(fj(e,t),e.clone().subset(t,a(n,t),r))},"Array, Index, any, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,r,i,a){var o=e(n(t),r,i,a);return o.isMatrix?o.valueOf():o}}),"Array, Index, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,r,i){return e(n(t),r,i,void 0).valueOf()}}),"Matrix, Index, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,n,r){return e(t,n,r,void 0)}}),"string, Index, string":HL,"string, Index, string, string":HL,"Object, Index, any":WL});function a(e,t){if(typeof e==`string`)throw Error(`can't boradcast a string`);if(t.isScalar())return e;var n=t.size();if(n.every(e=>e>0))try{return i(e,r(n))}catch{return e}else return e}});function VL(e,t){if(!WE(t))throw TypeError(`Index expected`);if(mj(t))return``;if(fj(Array.from(e),t),t.size().length!==1)throw new sj(t.size().length,1);var n=e.length;pj(t.min()[0],n),pj(t.max()[0],n);var r=t.dimension(0),i=``;function a(t){i+=e.charAt(t)}return Number.isInteger(r)?a(r):r.forEach(a),i}function HL(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Index expected`);if(mj(t))return e;if(fj(Array.from(e),t),t.size().length!==1)throw new sj(t.size().length,1);if(r!==void 0){if(typeof r!=`string`||r.length!==1)throw TypeError(`Single character expected as defaultValue`)}else r=` `;var i=t.dimension(0);if((Number.isInteger(i)?1:i.size()[0])!==n.length)throw new sj(i.size()[0],n.length);var a=e.length;pj(t.min()[0]),pj(t.max()[0]);for(var o=[],s=0;sa)for(var l=a-1,u=o.length;l{var{typed:t,matrix:n}=e;return t(GL,{Array:e=>r(n(e)).valueOf(),Matrix:r,any:SD});function r(e){var t=e.size(),n;switch(t.length){case 1:n=e.clone();break;case 2:var r=t[0],o=t[1];if(o===0)throw RangeError(`Cannot transpose a 2D matrix with no columns (size: `+$A(t)+`)`);switch(e.storage()){case`dense`:n=i(e,r,o);break;case`sparse`:n=a(e,r,o);break}break;default:throw RangeError(`Matrix must be a vector or two dimensional (size: `+$A(t)+`)`)}return n}function i(e,t,n){for(var r=e._data,i=[],a,o=0;o{var{typed:t,transpose:n,conj:r}=e;return t(qL,{any:function(e){return r(n(e))}})}),YL=`zeros`,XL=Z(YL,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(YL,{"":function(){return n.matrix===`Array`?a([]):a([],`default`)},"...number | BigNumber | string":function(e){return typeof e[e.length-1]==`string`?a(e,e.pop()):n.matrix===`Array`?a(e):a(e,`default`)},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var n=o(e)?new i(0):0;if(s(e),t){var a=r(t);return e.length>0?a.resize(e,n):a}else{var c=[];return e.length>0?hj(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){ME(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!HD(e)||e<0)throw Error(`Parameters in function zeros must be positive integers`)})}}),ZL=`fft`,QL=Z(ZL,[`typed`,`matrix`,`addScalar`,`multiplyScalar`,`divideScalar`,`exp`,`tau`,`i`,`dotDivide`,`conj`,`pow`,`ceil`,`log2`],e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:i,divideScalar:a,exp:o,tau:s,i:c,dotDivide:l,conj:u,pow:d,ceil:f,log2:p}=e;return t(ZL,{Array:m,Matrix:function(e){return e.create(m(e.valueOf()),e.datatype())}});function m(e){var t=lj(e);return t.length===1?_(e,t[0]):h(e.map(e=>m(e,t.slice(1))),0)}function h(e,t){var n=lj(e);if(t!==0)return Array(n[0]).fill(0).map((n,r)=>h(e[r],t-1));if(n.length===1)return _(e);function r(e){var t=lj(e);return Array(t[1]).fill(0).map((n,r)=>Array(t[0]).fill(0).map((t,n)=>e[n][r]))}return r(h(r(e),1))}function g(e){for(var t=e.length,n=o(a(i(-1,i(c,s)),t)),r=[],h=1-t;hi(e[a],r[t-1+a])),...Array(g-t).fill(0)],y=[...Array(t+t-1).fill(0).map((e,t)=>a(1,r[t])),...Array(g-(t+t-1)).fill(0)],b=_(v),x=_(y),S=l(u(m(u(Array(g).fill(0).map((e,t)=>i(b[t],x[t]))))),g),C=[],w=t-1;wt%2==0),t/2),..._(e.filter((e,t)=>t%2==1),t/2)],l=0;l{var{typed:t,fft:n,dotDivide:r,conj:i}=e;return t($L,{"Array | Matrix":function(e){var t=zE(e)?e.size():lj(e);return r(i(n(i(e))),t.reduce((e,t)=>e*t,1))}})});function tR(e){"@babel/helpers - typeof";return tR=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},tR(e)}function nR(e,t){if(tR(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(tR(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function rR(e){var t=nR(e,`string`);return tR(t)==`symbol`?t:t+``}function iR(e,t,n){return(t=rR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oR(e){for(var t=1;t{var{typed:t,add:n,subtract:r,multiply:i,divide:a,max:o,map:s,abs:c,isPositive:l,isNegative:u,larger:d,smaller:f,matrix:p,bignumber:m,unaryMinus:h}=e;function g(e){return function(t,p,g,_){if(!(p.length===2&&(p.every(S)||p.every(IE))))throw Error(`"tspan" must be an Array of two numeric values or two units [tStart, tEnd]`);var v=p[0],y=p[1],C=d(y,v),w=_.firstStep;if(w!==void 0&&!l(w))throw Error(`"firstStep" must be positive`);var T=_.maxStep;if(T!==void 0&&!l(T))throw Error(`"maxStep" must be positive`);var E=_.minStep;if(E&&u(E))throw Error(`"minStep" must be positive or zero`);var D=[v,y,w,E,T].filter(e=>e!==void 0);if(!(D.every(S)||D.every(IE)))throw Error(`Inconsistent type of "t" dependant variables`);for(var O=1,k=_.tol?_.tol:1e-4,A=_.minDelta?_.minDelta:.2,j=_.maxDelta?_.maxDelta:5,M=_.maxIter?_.maxIter:1e4,N=[v,y,...g,T,E].some(ME),[ee,te,ne,re]=N?[m(e.a),m(e.c),m(e.b),m(e.bp)]:[e.a,e.c,e.b,e.bp],P=w?C?w:h(w):a(r(y,v),O),F=[v],I=[g],L=r(ne,re),ie=0,ae=0,R=b(C),z=x(C);R(F[ie],y);){var oe=[];P=z(F[ie],y,P),oe.push(t(F[ie],I[ie]));for(var se=1;seIE(e)?e.value:e)));ce1/4&&(F.push(n(F[ie],P)),I.push(n(I[ie],i(P,ne,oe))),ie++);var le=.84*(k/ce)**(1/5);if(f(le,A)?le=A:d(le,j)&&(le=j),le=N?m(le):le,P=i(P,le),T&&d(c(P),T)?P=C?T:h(T):E&&f(c(P),E)&&(P=C?E:h(E)),ae++,ae>M)throw Error(`Maximum number of iterations reached, try changing options`)}return{t:F,y:I}}}function _(e,t,n,r){return g({a:[[],[1/2],[0,3/4],[2/9,1/3,4/9]],c:[null,1/2,3/4,1],b:[2/9,1/3,4/9,0],bp:[7/24,1/4,1/3,1/8]})(e,t,n,r)}function v(e,t,n,r){return g({a:[[],[1/5],[3/40,9/40],[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,1/5,3/10,4/5,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,1/40]})(e,t,n,r)}function y(e,t,n,r){var i=r.method?r.method:`RK45`,a={RK23:_,RK45:v};if(i.toUpperCase()in a){var o=oR({},r);return delete o.method,a[i.toUpperCase()](e,t,n,o)}else{var s=Object.keys(a).map(e=>`"${e}"`),c=`${s.slice(0,-1).join(`, `)} and ${s.slice(-1)}`;throw Error(`Unavailable method "${i}". Available methods are ${c}`)}}function b(e){return e?f:d}function x(e){var t=e?d:f;return function(e,i,a){return t(n(e,a),i)?r(i,e):a}}function S(e){return ME(e)||jE(e)}function C(e,t,n,r){var i=y(e,t.toArray(),n.toArray(),r);return{t:p(i.t),y:p(i.y)}}return t(`solveODE`,{"function, Array, Array, Object":y,"function, Matrix, Matrix, Object":C,"function, Array, Array":(e,t,n)=>y(e,t,n,{}),"function, Matrix, Matrix":(e,t,n)=>C(e,t,n,{}),"function, Array, number | BigNumber | Unit":(e,t,n)=>{var r=y(e,t,[n],{});return{t:r.t,y:r.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit":(e,t,n)=>{var r=y(e,t.toArray(),[n],{});return{t:p(r.t),y:p(r.y.map(e=>e[0]))}},"function, Array, number | BigNumber | Unit, Object":(e,t,n,r)=>{var i=y(e,t,[n],r);return{t:i.t,y:i.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit, Object":(e,t,n,r)=>{var i=y(e,t.toArray(),[n],r);return{t:p(i.t),y:p(i.y.map(e=>e[0]))}}})}),cR=Z(`erf`,[`typed`],e=>{var{typed:t}=e;return t(`name`,{number:function(e){var t=Math.abs(e);return t>=pR?WD(e):t<=lR?WD(e)*n(t):t<=4?WD(e)*(1-r(t)):WD(e)*(1-i(t))},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))});function n(e){var t=e*e,n=dR[0][4]*t,r=t,i;for(i=0;i<3;i+=1)n=(n+dR[0][i])*t,r=(r+fR[0][i])*t;return e*(n+dR[0][3])/(r+fR[0][3])}function r(e){var t=dR[1][8]*e,n=e,r;for(r=0;r<7;r+=1)t=(t+dR[1][r])*e,n=(n+fR[1][r])*e;var i=(t+dR[1][7])/(n+fR[1][7]),a=parseInt(e*16)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}function i(e){var t=1/(e*e),n=dR[2][5]*t,r=t,i;for(i=0;i<4;i+=1)n=(n+dR[2][i])*t,r=(r+fR[2][i])*t;var a=t*(n+dR[2][4])/(r+fR[2][4]);a=(uR-a)/e,t=parseInt(e*16)/16;var o=(e-t)*(e+t);return Math.exp(-t*t)*Math.exp(-o)*a}}),lR=.46875,uR=.5641895835477563,dR=[[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]],fR=[[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]],pR=2**53,mR=`zeta`,hR=Z(mR,[`typed`,`config`,`multiply`,`pow`,`divide`,`factorial`,`equal`,`smallerEq`,`isBounded`,`isNegative`,`gamma`,`sin`,`subtract`,`add`,`?Complex`,`?BigNumber`,`pi`],e=>{var{typed:t,config:n,multiply:r,pow:i,divide:a,factorial:o,equal:s,smallerEq:c,isBounded:l,isNegative:u,gamma:d,sin:f,subtract:p,add:m,Complex:h,BigNumber:g,pi:_}=e;return t(mR,{number:e=>v(e,e=>e,()=>20),BigNumber:e=>v(e,e=>new g(e),()=>Math.abs(Math.log10(n.relTol))),Complex:y});function v(e,t,n){return s(e,0)?t(-.5):s(e,1)?t(NaN):l(e)?b(e,t,n,e=>e):u(e)?t(NaN):t(1)}function y(e){return e.re===0&&e.im===0?new h(-.5):e.re===1?new h(NaN,NaN):e.re===1/0&&e.im===0?new h(1):e.im===1/0||e.re===-1/0?new h(NaN,NaN):b(e,e=>e,e=>Math.round(1.3*15+.9*Math.abs(e.im)),e=>e.re)}function b(e,t,n,o){var s=n(e);if(o(e)>-(s-1)/2)return S(e,t(s),t);var c=r(i(2,e),i(t(_),p(e,1)));return c=r(c,f(r(a(t(_),2),e))),c=r(c,d(p(1,e))),r(c,b(p(1,e),t,n,o))}function x(e,t){for(var n=e,s=e;c(s,t);s=m(s,1)){var l=a(r(o(m(t,p(s,1))),i(4,s)),r(o(p(t,s)),o(r(2,s))));n=m(n,l)}return r(t,n)}function S(e,t,n){for(var o=a(1,r(x(n(0),t),p(1,i(2,p(1,e))))),s=n(0),l=n(1);c(l,t);l=m(l,1))s=m(s,a(r((-1)**(l-1),x(l,t)),i(l,e)));return r(o,s)}}),gR=`mode`,_R=Z(gR,[`typed`,`isNaN`,`isNumeric`],e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(gR,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(e=Tj(e.valueOf()),e.length===0)throw Error(`Cannot calculate mode of an empty array`);for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}});function vR(e,t,n){var r;return String(e).includes(`Unexpected type`)?(r=arguments.length>2?` (type: `+xD(n)+`, value: `+JSON.stringify(n)+`)`:` (type: `+e.data.actual+`)`,TypeError(`Cannot calculate `+t+`, unexpected type of argument`+r)):String(e).includes(`complex numbers`)?(r=arguments.length>2?` (type: `+xD(n)+`, value: `+JSON.stringify(n)+`)`:``,TypeError(`Cannot calculate `+t+`, no ordering relation is defined for complex numbers`+r)):e}var yR=`prod`,bR=Z(yR,[`typed`,`config`,`multiplyScalar`,`numeric`],e=>{var{typed:t,config:n,multiplyScalar:r,numeric:i}=e;return t(yR,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw Error(`prod(A, dim) is not yet supported`)},"...":function(e){return a(e)}});function a(e){var t;if(tM(e,function(e){try{t=t===void 0?e:r(t,e)}catch(t){throw vR(t,`prod`,e)}}),typeof t==`string`&&(t=i(t,UD(t,n))),t===void 0)throw Error(`Cannot calculate prod of an empty array`);return t}}),xR=`format`,SR=Z(xR,[`typed`],e=>{var{typed:t}=e;return t(xR,{any:$A,"any, Object | function | number | BigNumber":$A})}),CR=`bin`,wR=Z(CR,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(CR,{"number | BigNumber":function(e){return n(e,{notation:`bin`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`bin`,wordSize:t})}})}),TR=`oct`,ER=Z(TR,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(TR,{"number | BigNumber":function(e){return n(e,{notation:`oct`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`oct`,wordSize:t})}})}),DR=`hex`,OR=Z(DR,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(DR,{"number | BigNumber":function(e){return n(e,{notation:`hex`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`hex`,wordSize:t})}})}),kR=/\$([\w.]+)/g,AR=`print`,jR=Z(AR,[`typed`],e=>{var{typed:t}=e;return t(AR,{"string, Object | Array":MR,"string, Object | Array, number | Object":MR})});function MR(e,t,n){return e.replace(kR,function(e,r){var i=r.split(`.`),a=t[i.shift()];for(a!==void 0&&a.isMatrix&&(a=a.toArray());i.length&&a!==void 0;){var o=i.shift();a=o?a[o]:a+`.`}return a===void 0?e:LE(a)?a:$A(a,n)})}var NR=`to`,PR=Z(NR,[`typed`,`matrix`,`concat`],e=>{var{typed:t,matrix:n,concat:r}=e;return t(NR,{"Unit, Unit | string":(e,t)=>e.to(t)},EF({typed:t,matrix:n,concat:r})({Ds:!0}))}),FR=`toBest`,IR=Z(FR,[`typed`],e=>{var{typed:t}=e;return t(FR,{Unit:e=>e.toBest(),"Unit, string":(e,t)=>e.toBest(t.split(`,`)),"Unit, string, Object":(e,t,n)=>e.toBest(t.split(`,`),n),"Unit, Array":(e,t)=>e.toBest(t),"Unit, Array, Object":(e,t,n)=>e.toBest(t,n)})}),LR=`isPrime`,RR=Z(LR,[`typed`],e=>{var{typed:t}=e;return t(LR,{number:function(e){if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t===0||e%(t+2)===0)return!1;return!0},bigint:function(e){if(e<=3n)return e>1n;if(e%2n==0n||e%3n==0n)return!1;for(var t=5n;t*t<=e;t+=6n)if(e%t===0n||e%(t+2n)===0n)return!1;return!0},BigNumber:function(e){if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(2**32)){for(var t=e.toNumber(),n=5;n*n<=t;n+=6)if(t%n===0||t%(n+2)===0)return!1;return!0}function r(e,t,n){for(var r=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(n)):(t=t.sub(1),r=e.mul(r).mod(n));return r}e=new(e.constructor.clone({precision:e.toFixed(0).length*2}))(e);for(var i=0,a=e.sub(1);a.mod(2).eq(0);)a=a.div(2),i+=1;var o=null;if(e.lt(`3317044064679887385961981`))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(t=>tt=>nM(t,e))})}),zR=Z(`numeric`,[`number`,`?bignumber`,`?fraction`],e=>{var{number:t,bignumber:n,fraction:r}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:n?e=>n(e):xL,bigint:e=>BigInt(e),Fraction:r?e=>r(e):SL};return function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`number`;if((arguments.length>2?arguments[2]:void 0)!==void 0)throw SyntaxError(`numeric() takes one or two arguments`);var n=xD(e);if(!(n in i))throw TypeError(`Cannot convert `+e+` of type "`+n+`"; valid input types are `+Object.keys(i).join(`, `));if(!(t in a))throw TypeError(`Cannot convert `+e+` to type "`+t+`"; valid output types are `+Object.keys(a).join(`, `));return t===n?e:a[t](e)}}),BR=`divideScalar`,VR=Z(BR,[`typed`,`numeric`],e=>{var{typed:t,numeric:n}=e;return t(BR,{"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)})}),HR=`pow`,UR=Z(HR,[`typed`,`config`,`identity`,`multiply`,`matrix`,`inv`,`fraction`,`number`,`Complex`],e=>{var{typed:t,config:n,identity:r,multiply:i,matrix:a,inv:o,number:s,fraction:c,Complex:l}=e;return t(HR,{"number, number":u,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||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(r!=null)return r;if(n.predictable)throw Error(`Result of pow is non-rational and cannot be expressed as a fraction`);return u(e.valueOf(),t.valueOf())},"Array, number":d,"Array, BigNumber":function(e,t){return d(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function u(e,t){if(n.predictable&&!HD(t)&&e<0)try{var r=c(t),i=s(r);if((t===i||Math.abs((t-i)/t)<1e-14)&&r.d%2n==1n)return(r.n%2n==0n?1:-1)*(-e)**+t}catch{}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:HD(t)||e>=0||n.predictable?NM(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function d(e,t){if(!HD(t))throw TypeError(`For A^b, b must be an integer (value is `+t+`)`);var n=lj(e);if(n.length!==2)throw Error(`For A^b, A must be 2 dimensional (A has `+n.length+` dimensions)`);if(n[0]!==n[1])throw Error(`For A^b, A must be square (size is `+n[0]+`x`+n[1]+`)`);if(t<0)try{return d(o(e),-t)}catch(e){throw e.message===`Cannot calculate inverse, determinant is zero`?TypeError(`For A^b, when A is not invertible, b must be a positive integer (value is `+t+`)`):e}for(var a=r(n[0]).valueOf(),s=e;t>=1;)(t&1)==1&&(a=i(s,a)),t>>=1,s=i(s,s);return a}function f(e,t){return a(d(e.valueOf(),t))}}),WR=`Number of decimals in function round must be an integer`,GR=`round`,KR=Z(GR,[`typed`,`config`,`matrix`,`equalScalar`,`zeros`,`BigNumber`,`DenseMatrix`],e=>{var{typed:t,config:n,matrix:r,equalScalar:i,zeros:a,BigNumber:o,DenseMatrix:s}=e,c=ZP({typed:t,equalScalar:i}),l=QP({typed:t,DenseMatrix:s}),u=$P({typed:t});function d(e){return Math.abs($D(e).exponent)}return t(GR,{number:function(e){var t=PM(e,d(n.relTol));return PM(sO(e,t,n.relTol,n.absTol)?t:e)},"number, number":function(e,t){var r=d(n.relTol);if(t>=r)return PM(e,t);var i=PM(e,r);return PM(sO(e,i,n.relTol,n.absTol)?i:e,t)},"number, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(WR);return new o(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw TypeError(WR);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(WR);var n=t.toNumber();return e.round(n)},BigNumber:function(e){var t=new o(e).toDecimalPlaces(d(n.relTol));return(HN(e,t,n.relTol,n.absTol)?t:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(WR);var r=d(n.relTol);if(t>=r)return e.toDecimalPlaces(t.toNumber());var i=e.toDecimalPlaces(r);return(HN(e,i,n.relTol,n.absTol)?i: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 TypeError(WR);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(WR);return e.round(t.toNumber())},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>nM(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>nM(t,e,!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>u(r(t),n,e,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":t.referToSelf(e=>(t,n)=>i(t,0)?a(n.size(),n.storage()):l(n,t,e,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":t.referToSelf(e=>(t,n)=>i(t,0)?a(n.size(),n.storage()):u(n,t,e,!0)),"number | Complex | BigNumber | Fraction, Array":t.referToSelf(e=>(t,n)=>u(r(n),t,e,!0).valueOf())})}),qR=`log`,JR=[`config`,`typed`,`typeOf`,`divideScalar`,`Complex`],YR=Math.log(16),XR=Z(qR,JR,e=>{var{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(qR,{number:function(e){return e>=0||r.predictable?CM(e):s(e)},bigint:HF(YR,CM,r,s),Complex:o,BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():s(e.toNumber())},"any, any":t.referToSelf(e=>(t,r)=>{if(n(t)===`Fraction`&&n(r)===`Fraction`){var a=t.log(r);if(a!==null)return a}return i(e(t),e(r))})})}),ZR=`log1p`,QR=Z(ZR,[`typed`,`config`,`divideScalar`,`log`,`Complex`],e=>{var{typed:t,config:n,divideScalar:r,log:i,Complex:a}=e;return t(ZR,{number:function(e){return e>=-1||n.predictable?qD(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e)),"any, any":t.referToSelf(e=>(t,n)=>r(e(t),i(n)))});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))}}),$R=`nthRoots`,ez=Z($R,[`config`,`typed`,`divideScalar`,`Complex`],e=>{var{typed:t,config:n,divideScalar:r,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw Error(`Root must be greater than zero`);if(t===0)throw Error(`Root must be non-zero`);if(t%1!=0)throw Error(`Root must be an integer`);if(e===0||e.abs()===0)return[new i(0,0)];var n=typeof e==`number`,r;(n||e.re===0||e.im===0)&&(r=n?2*(e<0):e.im===0?2*(e.re<0):2*(e.im<0)+1);for(var o=e.arg(),s=e.abs(),c=[],l=s**(1/t),u=0;u{var{typed:t,equalScalar:n,matrix:r,pow:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=xF({typed:t}),l=OI({typed:t,SparseMatrix:s}),u=ZP({typed:t,equalScalar:n}),d=QP({typed:t,DenseMatrix:a}),f=EF({typed:t,matrix:r,concat:o}),p={};for(var m in i.signatures)Object.prototype.hasOwnProperty.call(i.signatures,m)&&!m.includes(`Matrix`)&&!m.includes(`Array`)&&(p[m]=i.signatures[m]);return t(tz,f({elop:t(p),SS:l,DS:c,Ss:u,sS:d}))}),rz=`dotDivide`,iz=Z(rz,[`typed`,`matrix`,`equalScalar`,`divideScalar`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,equalScalar:r,divideScalar:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=bF({typed:t,equalScalar:r}),l=xF({typed:t}),u=OI({typed:t,SparseMatrix:s}),d=ZP({typed:t,equalScalar:r}),f=QP({typed:t,DenseMatrix:a});return t(rz,EF({typed:t,matrix:n,concat:o})({elop:i,SS:u,DS:l,SD:c,Ss:d,sS:f}))});function az(e){var{DenseMatrix:t}=e;return function(e,n,r){var i=e.size();if(i.length!==2)throw RangeError(`Matrix must be two dimensional (size: `+$A(i)+`)`);var a=i[0];if(a!==i[1])throw RangeError(`Matrix must be square (size: `+$A(i)+`)`);var o=[];if(zE(n)){var s=n.size(),c=n._data;if(s.length===1){if(s[0]!==a)throw RangeError(`Dimension mismatch. Matrix columns must match vector length.`);for(var l=0;l{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=az({DenseMatrix:s});return t(oz,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).valueOf()}});function l(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=[],f=e._data,p=0;ph&&(v.push(d[S]),y.push(C))}if(o(_,0))throw Error(`Linear system cannot be solved since matrix is singular`);for(var w=r(g,_),T=0,E=y.length;T{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=az({DenseMatrix:s});return t(cz,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).valueOf()}});function l(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=[],f=e._data,p=u-1;p>=0;p--){var m=n[p][0]||0,h=void 0;if(o(m,0))h=0;else{var g=f[p][p];if(o(g,0))throw Error(`Linear system cannot be solved since matrix is singular`);h=r(m,g);for(var _=p-1;_>=0;_--)n[_]=[a(n[_][0]||0,i(h,f[_][p]))]}d[p]=[h]}return new s({data:d,size:[l,1]})}function u(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=[],h=u-1;h>=0;h--){var g=n[h][0]||0;if(o(g,0))m[h]=[0];else{for(var _=0,v=[],y=[],b=p[h],x=p[h+1]-1;x>=b;x--){var S=f[x];S===h?_=d[x]:S{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=az({DenseMatrix:s});return t(uz,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map(e=>e.valueOf())}});function l(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._data,u=e._size[0],d=e._size[1],f=0;fnew s({data:e.map(e=>[e]),size:[u,1]}))}function u(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=0;mm&&(v.push(d[C]),y.push(w))}if(!o(S,0)){_[m]=r(_[m],S);for(var T=0,E=y.length;Tnew s({data:e.map(e=>[e]),size:[l,1]}))}}),fz=`usolveAll`,pz=Z(fz,[`typed`,`matrix`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`equalScalar`,`DenseMatrix`],e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=az({DenseMatrix:s});return t(fz,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map(e=>e.valueOf())}});function l(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._data,u=e._size[0],d=e._size[1]-1;d>=0;d--)for(var f=n.length,p=0;p=0;h--)m[h]=a(m[h],i(m[d],l[h][d]))}else if(!o(m[d],0)){if(p===0)return[];n.splice(p,1),--p,--f}else if(p===0){var g=[...m];g[d]=1;for(var _=d-1;_>=0;_--)g[_]=a(g[_],l[_][d]);n.push(g)}}return n.map(e=>new s({data:e.map(e=>[e]),size:[u,1]}))}function u(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=u-1;m>=0;m--)for(var h=n.length,g=0;g=b;C--){var w=f[C];w===m?S=d[C]:wnew s({data:e.map(e=>[e]),size:[l,1]}))}}),mz=Z(`matAlgo08xS0Sid`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new sj(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);if(!a||!u)throw Error(`Cannot perform operation on Pattern Sparse Matrices`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));for(var x=[],S=[],C=[],w=[],T=[],E,D,O,k,A=0;A{var{typed:t,matrix:n}=e;return{"Array, number":t.referTo(`DenseMatrix, number`,e=>(t,r)=>e(n(t),r).valueOf()),"Array, BigNumber":t.referTo(`DenseMatrix, BigNumber`,e=>(t,r)=>e(n(t),r).valueOf()),"number, Array":t.referTo(`number, DenseMatrix`,e=>(t,r)=>e(t,n(r)).valueOf()),"BigNumber, Array":t.referTo(`BigNumber, DenseMatrix`,e=>(t,r)=>e(t,n(r)).valueOf())}}),gz=`leftShift`,_z=Z(gz,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=kF({typed:t}),c=bF({typed:t,equalScalar:r}),l=mz({typed:t,equalScalar:r}),u=jF({typed:t,DenseMatrix:a}),d=ZP({typed:t,equalScalar:r}),f=$P({typed:t}),p=EF({typed:t,matrix:n,concat:o}),m=hz({typed:t,matrix:n});return t(gz,{"number, number":HM,"BigNumber, BigNumber":bI,"bigint, bigint":(e,t)=>e<(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),vz=`rightArithShift`,yz=Z(vz,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=kF({typed:t}),c=bF({typed:t,equalScalar:r}),l=mz({typed:t,equalScalar:r}),u=jF({typed:t,DenseMatrix:a}),d=ZP({typed:t,equalScalar:r}),f=$P({typed:t}),p=EF({typed:t,matrix:n,concat:o}),m=hz({typed:t,matrix:n});return t(vz,{"number, number":UM,"BigNumber, BigNumber":xI,"bigint, bigint":(e,t)=>e>>t,"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),bz=`rightLogShift`,xz=Z(bz,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=kF({typed:t}),c=bF({typed:t,equalScalar:r}),l=mz({typed:t,equalScalar:r}),u=jF({typed:t,DenseMatrix:a}),d=ZP({typed:t,equalScalar:r}),f=$P({typed:t}),p=EF({typed:t,matrix:n,concat:o}),m=hz({typed:t,matrix:n});return t(bz,{"number, number":WM,"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),Sz=`and`,Cz=Z(Sz,[`typed`,`matrix`,`equalScalar`,`zeros`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=bF({typed:t,equalScalar:r}),c=zF({typed:t,equalScalar:r}),l=ZP({typed:t,equalScalar:r}),u=$P({typed:t}),d=EF({typed:t,matrix:n,concat:o});return t(Sz,{"number, number":nN,"Complex, Complex":function(e,t){return(e.re!==0||e.im!==0)&&(t.re!==0||t.im!==0)},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!t.isZero()&&!e.isNaN()&&!t.isNaN()},"bigint, bigint":nN,"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0)),"SparseMatrix, any":t.referToSelf(e=>(t,n)=>a(n)?i(t.size(),t.storage()):l(t,n,e,!1)),"DenseMatrix, any":t.referToSelf(e=>(t,n)=>a(n)?i(t.size(),t.storage()):u(t,n,e,!1)),"any, SparseMatrix":t.referToSelf(e=>(t,n)=>a(t)?i(t.size(),t.storage()):l(n,t,e,!0)),"any, DenseMatrix":t.referToSelf(e=>(t,n)=>a(t)?i(t.size(),t.storage()):u(n,t,e,!0)),"Array, any":t.referToSelf(e=>(t,r)=>e(n(t),r).valueOf()),"any, Array":t.referToSelf(e=>(t,r)=>e(t,n(r)).valueOf())},d({SS:c,DS:s}))}),wz=`compare`,Tz=Z(wz,[`typed`,`config`,`matrix`,`equalScalar`,`BigNumber`,`Fraction`,`DenseMatrix`,`concat`],e=>{var{typed:t,config:n,equalScalar:r,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s,concat:c}=e,l=xF({typed:t}),u=SF({typed:t,equalScalar:r}),d=QP({typed:t,DenseMatrix:s}),f=EF({typed:t,matrix:i,concat:c}),p=cP({typed:t});return t(wz,Ez({typed:t,config:n}),{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return HN(e,t,n.relTol,n.absTol)?new a(0):new a(e.cmp(t))},"bigint, bigint":function(e,t){return e===t?0n:e>t?1n:-1n},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},p,f({SS:u,DS:l,Ss:d}))}),Ez=Z(wz,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(wz,{"number, number":function(e,t){return sO(e,t,n.relTol,n.absTol)?0:e>t?1:-1}})}),Dz=l(o(((e,t)=>{t.exports=function e(t,n){"use strict";var r=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,i=/(^[ ]*|[ ]*$)/g,a=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,s=/^0/,c=function(t){return e.insensitive&&(``+t).toLowerCase()||``+t},l=c(t).replace(i,``)||``,u=c(n).replace(i,``)||``,d=l.replace(r,`\0$1\0`).replace(/\0$/,``).replace(/^\0/,``).split(`\0`),f=u.replace(r,`\0$1\0`).replace(/\0$/,``).replace(/^\0/,``).split(`\0`),p=parseInt(l.match(o),16)||d.length!==1&&l.match(a)&&Date.parse(l),m=parseInt(u.match(o),16)||p&&u.match(a)&&Date.parse(u)||null,h,g;if(m){if(pm)return 1}for(var _=0,v=Math.max(d.length,f.length);_g)return 1}return 0}}))(),1),Oz=`compareNatural`,kz=Z(Oz,[`typed`,`compare`],e=>{var{typed:t,compare:n}=e,r=n.signatures[`boolean,boolean`];return t(Oz,{"any, any":i});function i(e,t){var c=xD(e),l=xD(t),u;if((c===`number`||c===`BigNumber`||c===`Fraction`||c===`bigint`)&&(l===`number`||l===`BigNumber`||l===`Fraction`||l===`bigint`))return u=n(e,t),u.toString()===`0`?(0,Dz.default)(c,l):u>0?1:-1;var d=[`Array`,`DenseMatrix`,`SparseMatrix`];if(d.includes(c)||d.includes(l))return u=a(i,e,t),u===0?(0,Dz.default)(c,l):u;if(c!==l)return(0,Dz.default)(c,l);if(c===`Complex`)return Az(e,t);if(c===`Unit`)return e.equalBase(t)?i(e.value,t.value):o(i,e.formatUnits(),t.formatUnits());if(c===`boolean`)return r(e,t);if(c===`string`)return(0,Dz.default)(e,t);if(c===`Object`)return s(i,e,t);if(c===`null`||c===`undefined`)return 0;throw TypeError(`Unsupported type of value "`+c+`"`)}function a(e,t,n){return HE(t)&&HE(n)?o(e,t.toJSON().values,n.toJSON().values):HE(t)?a(e,t.toArray(),n):HE(n)?a(e,t,n.toArray()):VE(t)?a(e,t.toJSON().data,n):VE(n)?a(e,t,n.toJSON().data):Array.isArray(t)?Array.isArray(n)?o(e,t,n):a(e,t,[n]):a(e,[t],n)}function o(e,t,n){for(var r=0,i=Math.min(t.length,n.length);rn.length?1:t.lengtht.re?1:e.ret.im?1:e.im{var{typed:t,matrix:n,concat:r}=e;return t(jz,oj,EF({typed:t,matrix:n,concat:r})({elop:oj,Ds:!0}))}),Pz=`equal`,Fz=Z(Pz,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=xF({typed:t}),c=OI({typed:t,SparseMatrix:o}),l=QP({typed:t,DenseMatrix:i}),u=EF({typed:t,matrix:n});return t(Pz,Iz({typed:t,equalScalar:r}),u({elop:r,SS:c,DS:s,Ss:l}))}),Iz=Z(Pz,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(Pz,{"any, any":function(e,t){return e===null?t===null:t===null?e===null:e===void 0?t===void 0:t===void 0?e===void 0:n(e,t)}})}),Lz=`equalText`,Rz=Z(Lz,[`typed`,`compareText`,`isZero`],e=>{var{typed:t,compareText:n,isZero:r}=e;return t(Lz,{"any, any":function(e,t){return r(n(e,t))}})}),zz=`smaller`,Bz=Z(zz,[`typed`,`config`,`bignumber`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,bignumber:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=xF({typed:t}),l=OI({typed:t,SparseMatrix:s}),u=QP({typed:t,DenseMatrix:a}),d=EF({typed:t,matrix:i,concat:o}),f=cP({typed:t});function p(e,t){return e.lt(t)&&!HN(e,t,n.relTol,n.absTol)}return t(zz,Vz({typed:t,config:n}),{"boolean, boolean":(e,t)=>eee.compare(t)===-1,"Fraction, BigNumber":function(e,t){return p(r(e),t)},"BigNumber, Fraction":function(e,t){return p(e,r(t))},"Complex, Complex":function(e,t){throw TypeError(`No ordering relation is defined for complex numbers`)}},f,d({SS:l,DS:c,Ss:u}))}),Vz=Z(zz,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(zz,{"number, number":function(e,t){return e{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=xF({typed:t}),c=OI({typed:t,SparseMatrix:o}),l=QP({typed:t,DenseMatrix:i}),u=EF({typed:t,matrix:r,concat:a}),d=cP({typed:t});return t(Hz,Wz({typed:t,config:n}),{"boolean, boolean":(e,t)=>e<=t,"BigNumber, BigNumber":function(e,t){return e.lte(t)||HN(e,t,n.relTol,n.absTol)},"bigint, bigint":(e,t)=>e<=t,"Fraction, Fraction":(e,t)=>e.compare(t)!==1,"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},d,u({SS:c,DS:s,Ss:l}))}),Wz=Z(Hz,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Hz,{"number, number":function(e,t){return e<=t||sO(e,t,n.relTol,n.absTol)}})}),Gz=`larger`,Kz=Z(Gz,[`typed`,`config`,`bignumber`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,bignumber:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=xF({typed:t}),l=OI({typed:t,SparseMatrix:s}),u=QP({typed:t,DenseMatrix:a}),d=EF({typed:t,matrix:i,concat:o}),f=cP({typed:t});function p(e,t){return e.gt(t)&&!HN(e,t,n.relTol,n.absTol)}return t(Gz,qz({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>t,"BigNumber, BigNumber":p,"bigint, bigint":(e,t)=>e>t,"Fraction, Fraction":(e,t)=>e.compare(t)===1,"Fraction, BigNumber":function(e,t){return p(r(e),t)},"BigNumber, Fraction":function(e,t){return p(e,r(t))},"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},f,d({SS:l,DS:c,Ss:u}))}),qz=Z(Gz,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Gz,{"number, number":function(e,t){return e>t&&!sO(e,t,n.relTol,n.absTol)}})}),Jz=`largerEq`,Yz=Z(Jz,[`typed`,`config`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=xF({typed:t}),c=OI({typed:t,SparseMatrix:o}),l=QP({typed:t,DenseMatrix:i}),u=EF({typed:t,matrix:r,concat:a}),d=cP({typed:t});return t(Jz,Xz({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>=t,"BigNumber, BigNumber":function(e,t){return e.gte(t)||HN(e,t,n.relTol,n.absTol)},"bigint, bigint":function(e,t){return e>=t},"Fraction, Fraction":(e,t)=>e.compare(t)!==-1,"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},d,u({SS:c,DS:s,Ss:l}))}),Xz=Z(Jz,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Jz,{"number, number":function(e,t){return e>=t||sO(e,t,n.relTol,n.absTol)}})}),Zz=`deepEqual`,Qz=Z(Zz,[`typed`,`equal`],e=>{var{typed:t,equal:n}=e;return t(Zz,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e))if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,config:n,equalScalar:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=xF({typed:t}),l=OI({typed:t,SparseMatrix:s}),u=QP({typed:t,DenseMatrix:a}),d=EF({typed:t,matrix:i,concat:o});return t($z,tB({typed:t,equalScalar:r}),d({elop:f,SS:l,DS:c,Ss:u}));function f(e,t){return!r(e,t)}}),tB=Z($z,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t($z,{"any, any":function(e,t){return e===null?t!==null:t===null?e!==null:e===void 0?t!==void 0:t===void 0?e!==void 0:!n(e,t)}})}),nB=`partitionSelect`,rB=Z(nB,[`typed`,`isNumeric`,`isNaN`,`compare`],e=>{var{typed:t,isNumeric:n,isNaN:r,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(nB,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,n){if(n===`asc`)return s(e,t,a);if(n===`desc`)return s(e,t,o);throw Error(`Compare string must be "asc" or "desc"`)},"Array | Matrix, number, function":s});function s(e,t,n){if(!HD(t)||t<0)throw Error(`k must be a non-negative integer`);if(zE(e)){if(e.size().length>1)throw Error(`Only one dimensional matrices supported`);return c(e.valueOf(),t,n)}if(Array.isArray(e))return c(e,t,n)}function c(e,t,i){if(t>=e.length)throw Error(`k out of bounds`);for(var a=0;a=0){var d=e[l];e[l]=e[c],e[c]=d,--l}else ++c;i(e[c],u)>0&&--c,t<=c?s=c:o=c+1}return e[t]}}),iB=`sort`,aB=Z(iB,[`typed`,`matrix`,`compare`,`compareNatural`],e=>{var{typed:t,matrix:n,compare:r,compareNatural:i}=e,a=r,o=(e,t)=>-r(e,t);return t(iB,{Array:function(e){return c(e),e.sort(a)},Matrix:function(e){return l(e),n(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return c(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return c(e),e.sort(s(t))},"Matrix, string":function(e,t){return l(e),n(e.toArray().sort(s(t)),e.storage())}});function s(e){if(e===`asc`)return a;if(e===`desc`)return o;if(e===`natural`)return i;throw Error(`String "asc", "desc", or "natural" expected`)}function c(e){if(lj(e).length!==1)throw Error(`One dimensional array expected`)}function l(e){if(e.size().length!==1)throw Error(`One dimensional matrix expected`)}}),oB=`max`,sB=Z(oB,[`typed`,`config`,`numeric`,`larger`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,larger:i,isNaN:a}=e;return t(oB,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return rM(e,t.valueOf(),o)},"...":function(e){if(eM(e))throw TypeError(`Scalar values expected in function max`);return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw vR(e,`max`,t)}}function s(e){var t;if(tM(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw vR(t,`max`,e)}}),t===void 0)throw Error(`Cannot calculate max of an empty array`);return typeof t==`string`&&(t=r(t,UD(t,n))),t}}),cB=`min`,lB=Z(cB,[`typed`,`config`,`numeric`,`smaller`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,smaller:i,isNaN:a}=e;return t(cB,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return rM(e,t.valueOf(),o)},"...":function(e){if(eM(e))throw TypeError(`Scalar values expected in function min`);return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw vR(e,`min`,t)}}function s(e){var t;if(tM(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw vR(t,`min`,e)}}),t===void 0)throw Error(`Cannot calculate min of an empty array`);return typeof t==`string`&&(t=r(t,UD(t,n))),t}}),uB=Z(`ImmutableDenseMatrix`,[`smaller`,`DenseMatrix`],e=>{var{smaller:t,DenseMatrix:n}=e;function r(e,t){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!LE(t))throw Error(`Invalid datatype: `+t);if(zE(e)||RE(e)){var 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&&RE(e.data)&&RE(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=e.min===void 0?null:e.min,this._max=e.max===void 0?null:e.max;else if(e)throw TypeError(`Unsupported type of data (`+xD(e)+`)`);else this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}return r.prototype=new n,r.prototype.type=`ImmutableDenseMatrix`,r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return zE(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw Error(`Cannot invoke set subset on an Immutable Matrix instance`);default:throw SyntaxError(`Wrong number of arguments`)}},r.prototype.set=function(){throw Error(`Cannot invoke set on an Immutable Matrix instance`)},r.prototype.resize=function(){throw Error(`Cannot invoke resize on an Immutable Matrix instance`)},r.prototype.reshape=function(){throw Error(`Cannot invoke reshape on an Immutable Matrix instance`)},r.prototype.clone=function(){return new r({data:SD(this._data),size:SD(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:`ImmutableDenseMatrix`,data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw Error(`Cannot invoke swapRows on an Immutable Matrix instance`)},r.prototype.min=function(){if(this._min===null){var e=null;this.forEach(function(n){(e===null||t(n,e))&&(e=n)}),this._min=e===null?void 0:e}return this._min},r.prototype.max=function(){if(this._max===null){var e=null;this.forEach(function(n){(e===null||t(e,n))&&(e=n)}),this._max=e===null?void 0:e}return this._max},r},{isClass:!0}),dB=Z(`Index`,[`ImmutableDenseMatrix`,`getMatrixDataType`],e=>{var{ImmutableDenseMatrix:t,getMatrixDataType:n}=e;function r(){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var e=0,t=arguments.length;e{e&&t.push(n)}),t}var pB=Z(`FibonacciHeap`,[`smaller`,`larger`],e=>{var{smaller:t,larger:n}=e,r=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);this._minimum=null,this._size=0}i.prototype.type=`FibonacciHeap`,i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var i=this._minimum;r.left=i,r.right=i.right,i.right=r,r.right.left=r,t(e,i.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return this._size===0},i.prototype.extractMinimum=function(){var e=this._minimum;if(e===null)return e;for(var t=this._minimum,n=e.degree,r=e.child;n>0;){var i=r.right;r.left.right=r.right,r.right.left=r.left,r.left=t,r.right=t.right,t.right=r,r.right.left=r,r.parent=null,r=i,n--}return e.left.right=e.right,e.right.left=e.left,e===e.right?t=null:(t=e.right,t=l(t,this._size)),this._size--,this._minimum=t,e},i.prototype.remove=function(e){this._minimum=a(this._minimum,e,-1),this.extractMinimum()};function a(e,n,r){n.key=r;var i=n.parent;return i&&t(n.key,i.key)&&(o(e,n,i),s(e,i)),t(n.key,e.key)&&(e=n),e}function o(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),n.degree===0&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(o(e,t,n),s(n)):t.mark=!0)}var c=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1};function l(e,i){var a=Math.floor(Math.log(i)*r)+1,o=Array(a),s=0,l=e;if(l)for(s++,l=l.right;l!==e;)s++,l=l.right;for(var u;s>0;){for(var d=l.degree,f=l.right;u=o[d],u;){if(n(l.key,u.key)){var p=u;u=l,l=p}c(u,l),o[d]=null,d++}o[d]=l,l=f,s--}e=null;for(var m=0;m{var{addScalar:t,equalScalar:n,FibonacciHeap:r}=e;function i(){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);this._values=[],this._heap=new r}return i.prototype.type=`Spa`,i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},i.prototype.forEach=function(e,t,r){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(n(s.value,0)||r(s.key,s.value,this)),s=i.extractMinimum(),s&&o.push(s);for(var c=0;c1&&arguments[1]!==void 0?arguments[1]:{};return n??=1/0,t??=JSON.stringify,function r(){typeof r.cache!=`object`&&(r.cache={values:new Map,lru:hB(n||1/0)});for(var i=[],a=0;a{var{on:t,config:n,addScalar:r,subtractScalar:i,multiplyScalar:a,divideScalar:o,pow:s,abs:c,fix:l,round:u,equal:d,isNumeric:f,format:p,number:m,Complex:h,BigNumber:g,Fraction:_}=e,v=m,y=!1,b=!0;function x(e,t){if(!(this instanceof x))throw Error(`Constructor must be called with the new operator`);if(!(e==null||f(e)||PE(e)))throw TypeError(`First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined`);if(this.fixPrefix=y,this.skipAutomaticSimplification=b,t===void 0)this.units=[],this.dimensions=I.map(e=>0);else if(typeof t==`string`){var n=x.parse(t);this.units=n.units,this.dimensions=n.dimensions}else if(IE(t)&&t.value===null)this.fixPrefix=t.fixPrefix,this.skipAutomaticSimplification=t.skipAutomaticSimplification,this.dimensions=t.dimensions.slice(0),this.units=t.units.map(e=>mE({},e));else throw TypeError(`Second parameter in Unit constructor must be a string or valueless Unit`);this.value=this._normalize(e)}Object.defineProperty(x,"name",{value:`Unit`}),x.prototype.constructor=x,x.prototype.type=`Unit`,x.prototype.isUnit=!0;var S,C,w;function T(){for(;w===` `||w===` `;)O()}function E(e){return e>=`0`&&e<=`9`||e===`.`}function D(e){return e>=`0`&&e<=`9`}function O(){C++,w=S.charAt(C)}function k(e){C=e,w=S.charAt(C)}function A(){var e=``,t=C;if(w===`+`?O():w===`-`&&(e+=w,O()),!E(w))return k(t),null;if(w===`.`){if(e+=w,O(),!D(w))return k(t),null}else{for(;D(w);)e+=w,O();w===`.`&&(e+=w,O())}for(;D(w);)e+=w,O();if(w===`E`||w===`e`){var n=``,r=C;if(n+=w,O(),(w===`+`||w===`-`)&&(n+=w,O()),!D(w))return k(r),e;for(e+=n;D(w);)e+=w,O()}return e}function j(){for(var e=``;D(w)||x.isValidAlpha(w);)e+=w,O();var t=e.charAt(0);return x.isValidAlpha(t)?e:null}function M(e){return w===e?(O(),e):null}x.parse=function(e,t){if(t||={},S=e,C=-1,w=``,typeof S!=`string`)throw TypeError(`Invalid argument in Unit.parse, string expected`);var r=new x;r.units=[];var i=1,a=!1;O(),T();var o=A(),s=null;if(o){if(n.number===`BigNumber`)s=new g(o);else if(n.number===`Fraction`)try{s=new _(o)}catch{s=parseFloat(o)}else s=parseFloat(o);T(),M(`*`)?(i=1,a=!0):M(`/`)&&(i=-1,a=!0)}for(var c=[],l=1;;){for(T();w===`(`;)c.push(i),l*=i,i=1,O(),T();var u=void 0;if(w){var d=w;if(u=j(),u===null)throw SyntaxError(`Unexpected "`+d+`" in "`+S+`" at index `+C.toString())}else break;var f=N(u);if(f===null)throw SyntaxError(`Unit "`+u+`" not found.`);var p=i*l;if(T(),M(`^`)){T();var m=A();if(m===null)throw SyntaxError(`In "`+e+`", "^" must be followed by a floating-point number`);p*=m}r.units.push({unit:f.unit,prefix:f.prefix,power:p});for(var h=0;h1||Math.abs(this.units[0].power-1)>1e-15},x.prototype._normalize=function(e){if(e==null||this.units.length===0)return e;for(var t=e,n=x._getNumberConverter(xD(e)),r=0;r{if(AD(R,e)){var t=R[e];return{unit:t,prefix:t.prefixes[``]}}for(var n in R)if(AD(R,n)&&QA(e,n)){var r=R[n],i=e.length-n.length,a=e.substring(0,i),o=AD(r.prefixes,a)?r.prefixes[a]:void 0;if(o!==void 0)return{unit:r,prefix:o}}return null},{hasher:e=>e[0],limit:100});x.isValuelessUnit=function(e){return N(e)!==null},x.prototype.hasBase=function(e){if(typeof e==`string`&&(e=L[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},x.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},x.prototype.equals=function(e){return this.equalBase(e)&&d(this.value,e.value)},x.prototype.multiply=function(e){for(var t=this.clone(),n=IE(e)?e:new x(e),r=0;r0?this.formatUnits():null,fixPrefix:this.fixPrefix,skipSimp:this.skipAutomaticSimplification}},x.fromJSON=function(e){var t=new x(e.value,e.unit??void 0);return t.fixPrefix=e.fixPrefix??y,t.skipAutomaticSimplification=e.skipSimp??b,t},x.prototype.valueOf=x.prototype.toString,x.prototype.simplify=function(){var e=this.clone(),t=[],n;for(var r in ce)if(AD(ce,r)&&e.hasBase(L[r])){n=r;break}if(n===`NONE`)e.units=[];else{var i;if(n&&AD(ce,n)&&(i=ce[n]),i)e.units=[{unit:i.unit,prefix:i.prefix,power:1}];else{for(var a=!1,o=0;o1e-12&&(AD(ce,s)?t.push({unit:ce[s].unit,prefix:ce[s].prefix,power:e.dimensions[o]||0}):a=!0)}t.length1e-12)if(AD(se.si,r))t.push({unit:se.si[r].unit,prefix:se.si[r].prefix,power:e.dimensions[n]||0});else throw Error(`Cannot express custom unit `+r+` in SI units`)}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,this.value===null?e:(e.value=null,this.to(e))},x.prototype.formatUnits=function(){for(var e=``,t=``,n=0,r=0,i=0;i0?(n++,e+=` `+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+=`^`+this.units[i].power)):this.units[i].power<0&&r++;if(r>0)for(var a=0;a0?(t+=` `+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+=`^`+-this.units[a].power)):(t+=` `+this.units[a].prefix.name+this.units[a].unit.name,t+=`^`+this.units[a].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e=`(`+e+`)`),r>1&&n>0&&(t=`(`+t+`)`);var o=e;return n>0&&r>0&&(o+=` / `),o+=t,o},x.prototype.toBest=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e&&!Array.isArray(e))throw Error(`Invalid unit type. Expected string or Unit.`);var n=this.units[0].unit.prefixes;if(e&&e.length>0){var r=e.map(e=>{var t=null;if(typeof e==`string`){if(t=x.parse(e),!t)throw Error(`Invalid unit type. Expected compatible string or Unit.`)}else if(!IE(e))throw Error(`Invalid unit type. Expected compatible string or Unit.`);t===null&&(t=e.clone());try{return this.to(t.formatUnits()),t}catch{throw Error(`Invalid unit type. Expected compatible string or Unit.`)}}).map(e=>e.units[0].prefix);this.units[0].unit.prefixes=r.reduce((e,t)=>(e[t.name]=t,e),{}),this.units[0].prefix=r[0]}var i=ne(this,t).simp;return this.units[0].unit.prefixes=n,i.fixPrefix=!0,i},x.prototype.format=function(e){var{simp:t,valueStr:n,unitStr:r}=ne(this,e),i=n;return t.value&&PE(t.value)&&(i=`(`+i+`)`),r.length>0&&i.length>0&&(i+=` `),i+=r,i};function ne(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=e.skipAutomaticSimplification||e.value===null?e.clone():e.simplify();re(n),P(n,t.offset);var r=n._denormalize(n.value);return{simp:n,valueStr:n.value===null?``:p(r,t||{}),unitStr:n.formatUnits()}}function re(e){var t=!1;for(var n in e.value!==void 0&&e.value!==null&&PE(e.value)&&(t=Math.abs(e.value.re)<1e-14),e.units)AD(e.units,n)&&e.units[n].unit&&(e.units[n].unit.name===`VA`&&t?e.units[n].unit=R.VAR:e.units[n].unit.name===`VAR`&&!t&&(e.units[n].unit=R.VA))}function P(e,t){e.units.length===1&&!e.fixPrefix&&Math.abs(e.units[0].power-Math.round(e.units[0].power))<1e-14&&(e.units[0].prefix=e._bestPrefix(t))}x.prototype._bestPrefix=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1.2;if(this.units.length!==1||Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw Error(`Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!`);var t=this.value===null?0:c(this.value),n=c(this.units[0].unit.value),r=this.units[0].prefix;if(t===0)return r;var i=this.units[0].power,a=Math.log(t/(r.value*n)**+i)/Math.LN10-e;if(a>-2.200001&&a<1.800001)return r;a=Math.abs(a);var o=this.units[0].unit.prefixes;for(var s in o)if(AD(o,s)){var l=o[s];if(l.scientific){var u=Math.abs(Math.log(t/(l.value*n)**+i)/Math.LN10-e);(u0)},R={meter:{name:`meter`,base:L.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:`inch`,base:L.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:`foot`,base:L.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:`yard`,base:L.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:`mile`,base:L.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:`link`,base:L.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:`rod`,base:L.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:`chain`,base:L.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:`angstrom`,base:L.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:`m`,base:L.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:`in`,base:L.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:`ft`,base:L.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:`yd`,base:L.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:`mi`,base:L.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:`li`,base:L.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:`rd`,base:L.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:`ch`,base:L.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:`mil`,base:L.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:`m2`,base:L.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:`sqin`,base:L.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:`sqft`,base:L.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:`sqyd`,base:L.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:`sqmi`,base:L.SURFACE,prefixes:F.NONE,value:2589988.110336,offset:0},sqrd:{name:`sqrd`,base:L.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:`sqch`,base:L.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:`sqmil`,base:L.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:`acre`,base:L.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:`hectare`,base:L.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:`m3`,base:L.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:`L`,base:L.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:`l`,base:L.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:`litre`,base:L.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:`cuin`,base:L.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:`cuft`,base:L.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:`cuyd`,base:L.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:`teaspoon`,base:L.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:`tablespoon`,base:L.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:`drop`,base:L.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:`gtt`,base:L.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:`minim`,base:L.VOLUME,prefixes:F.NONE,value:6.1611519921875e-8,offset:0},fluiddram:{name:`fluiddram`,base:L.VOLUME,prefixes:F.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:`fluidounce`,base:L.VOLUME,prefixes:F.NONE,value:295735295625e-16,offset:0},gill:{name:`gill`,base:L.VOLUME,prefixes:F.NONE,value:.00011829411825,offset:0},cc:{name:`cc`,base:L.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:`cup`,base:L.VOLUME,prefixes:F.NONE,value:.0002365882365,offset:0},pint:{name:`pint`,base:L.VOLUME,prefixes:F.NONE,value:.000473176473,offset:0},quart:{name:`quart`,base:L.VOLUME,prefixes:F.NONE,value:.000946352946,offset:0},gallon:{name:`gallon`,base:L.VOLUME,prefixes:F.NONE,value:.003785411784,offset:0},beerbarrel:{name:`beerbarrel`,base:L.VOLUME,prefixes:F.NONE,value:.117347765304,offset:0},oilbarrel:{name:`oilbarrel`,base:L.VOLUME,prefixes:F.NONE,value:.158987294928,offset:0},hogshead:{name:`hogshead`,base:L.VOLUME,prefixes:F.NONE,value:.238480942392,offset:0},g:{name:`g`,base:L.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:`gram`,base:L.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:`ton`,base:L.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:`t`,base:L.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:`tonne`,base:L.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:`grain`,base:L.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:`dram`,base:L.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:`ounce`,base:L.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:`poundmass`,base:L.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:`hundredweight`,base:L.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:`stick`,base:L.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:`stone`,base:L.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:`gr`,base:L.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:`dr`,base:L.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:`oz`,base:L.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:`lbm`,base:L.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:`cwt`,base:L.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:`s`,base:L.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:`min`,base:L.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:`h`,base:L.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:`second`,base:L.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:`sec`,base:L.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:`minute`,base:L.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:`hour`,base:L.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:`day`,base:L.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:`week`,base:L.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:`month`,base:L.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:`year`,base:L.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:`decade`,base:L.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:`century`,base:L.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:`millennium`,base:L.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:`Hertz`,base:L.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:`Hz`,base:L.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:`rad`,base:L.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:`radian`,base:L.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:`deg`,base:L.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:`degree`,base:L.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:`grad`,base:L.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:`gradian`,base:L.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:`cycle`,base:L.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:`arcsec`,base:L.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:`arcmin`,base:L.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:`A`,base:L.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:`ampere`,base:L.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:`K`,base:L.TEMPERATURE,prefixes:F.SHORT,value:1,offset:0},degC:{name:`degC`,base:L.TEMPERATURE,prefixes:F.SHORT,value:1,offset:273.15},degF:{name:`degF`,base:L.TEMPERATURE,prefixes:F.SHORT,value:new _(5,9),offset:459.67},degR:{name:`degR`,base:L.TEMPERATURE,prefixes:F.SHORT,value:new _(5,9),offset:0},kelvin:{name:`kelvin`,base:L.TEMPERATURE,prefixes:F.LONG,value:1,offset:0},celsius:{name:`celsius`,base:L.TEMPERATURE,prefixes:F.LONG,value:1,offset:273.15},fahrenheit:{name:`fahrenheit`,base:L.TEMPERATURE,prefixes:F.LONG,value:new _(5,9),offset:459.67},rankine:{name:`rankine`,base:L.TEMPERATURE,prefixes:F.LONG,value:new _(5,9),offset:0},mol:{name:`mol`,base:L.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:`mole`,base:L.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:`cd`,base:L.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:`candela`,base:L.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:`N`,base:L.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:`newton`,base:L.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:`dyn`,base:L.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:`dyne`,base:L.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:`lbf`,base:L.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:`poundforce`,base:L.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:`kip`,base:L.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:`kilogramforce`,base:L.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:`J`,base:L.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:`joule`,base:L.ENERGY,prefixes:F.LONG,value:1,offset:0},erg:{name:`erg`,base:L.ENERGY,prefixes:F.SHORTLONG,value:1e-7,offset:0},Wh:{name:`Wh`,base:L.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:`BTU`,base:L.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:`eV`,base:L.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:`electronvolt`,base:L.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:`W`,base:L.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:`watt`,base:L.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:`hp`,base:L.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:`VAR`,base:L.POWER,prefixes:F.SHORT,value:h.I,offset:0},VA:{name:`VA`,base:L.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:`Pa`,base:L.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:`psi`,base:L.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:`atm`,base:L.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:`bar`,base:L.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:`torr`,base:L.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:`mmHg`,base:L.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:`mmH2O`,base:L.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:`cmH2O`,base:L.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:`coulomb`,base:L.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:`C`,base:L.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},Ah:{name:`Ah`,base:L.ELECTRIC_CHARGE,prefixes:F.SHORT,value:3600,offset:0},farad:{name:`farad`,base:L.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:`F`,base:L.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:`volt`,base:L.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:`V`,base:L.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:`ohm`,base:L.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:`henry`,base:L.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:`H`,base:L.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:`siemens`,base:L.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:`S`,base:L.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:`weber`,base:L.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:`Wb`,base:L.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:`tesla`,base:L.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:`T`,base:L.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:`b`,base:L.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:`bits`,base:L.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:`B`,base:L.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:`bytes`,base:L.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},z={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 oe(e){if(e.number===`BigNumber`){var t=yB(g);R.rad.value=new g(1),R.deg.value=t.div(180),R.grad.value=t.div(200),R.cycle.value=t.times(2),R.arcsec.value=t.div(648e3),R.arcmin.value=t.div(10800)}else R.rad.value=1,R.deg.value=Math.PI/180,R.grad.value=Math.PI/200,R.cycle.value=Math.PI*2,R.arcsec.value=Math.PI/648e3,R.arcmin.value=Math.PI/10800;R.radian.value=R.rad.value,R.degree.value=R.deg.value,R.gradian.value=R.grad.value}oe(n),t&&t(`config`,function(e,t){e.number!==t.number&&oe(e)});var se={si:{NONE:{unit:ae,prefix:F.NONE[``]},LENGTH:{unit:R.m,prefix:F.SHORT[``]},MASS:{unit:R.g,prefix:F.SHORT.k},TIME:{unit:R.s,prefix:F.SHORT[``]},CURRENT:{unit:R.A,prefix:F.SHORT[``]},TEMPERATURE:{unit:R.K,prefix:F.SHORT[``]},LUMINOUS_INTENSITY:{unit:R.cd,prefix:F.SHORT[``]},AMOUNT_OF_SUBSTANCE:{unit:R.mol,prefix:F.SHORT[``]},ANGLE:{unit:R.rad,prefix:F.SHORT[``]},BIT:{unit:R.bits,prefix:F.SHORT[``]},FORCE:{unit:R.N,prefix:F.SHORT[``]},ENERGY:{unit:R.J,prefix:F.SHORT[``]},POWER:{unit:R.W,prefix:F.SHORT[``]},PRESSURE:{unit:R.Pa,prefix:F.SHORT[``]},ELECTRIC_CHARGE:{unit:R.C,prefix:F.SHORT[``]},ELECTRIC_CAPACITANCE:{unit:R.F,prefix:F.SHORT[``]},ELECTRIC_POTENTIAL:{unit:R.V,prefix:F.SHORT[``]},ELECTRIC_RESISTANCE:{unit:R.ohm,prefix:F.SHORT[``]},ELECTRIC_INDUCTANCE:{unit:R.H,prefix:F.SHORT[``]},ELECTRIC_CONDUCTANCE:{unit:R.S,prefix:F.SHORT[``]},MAGNETIC_FLUX:{unit:R.Wb,prefix:F.SHORT[``]},MAGNETIC_FLUX_DENSITY:{unit:R.T,prefix:F.SHORT[``]},FREQUENCY:{unit:R.Hz,prefix:F.SHORT[``]}}};se.cgs=JSON.parse(JSON.stringify(se.si)),se.cgs.LENGTH={unit:R.m,prefix:F.SHORT.c},se.cgs.MASS={unit:R.g,prefix:F.SHORT[``]},se.cgs.FORCE={unit:R.dyn,prefix:F.SHORT[``]},se.cgs.ENERGY={unit:R.erg,prefix:F.NONE[``]},se.us=JSON.parse(JSON.stringify(se.si)),se.us.LENGTH={unit:R.ft,prefix:F.NONE[``]},se.us.MASS={unit:R.lbm,prefix:F.NONE[``]},se.us.TEMPERATURE={unit:R.degF,prefix:F.NONE[``]},se.us.FORCE={unit:R.lbf,prefix:F.NONE[``]},se.us.ENERGY={unit:R.BTU,prefix:F.BTU[``]},se.us.POWER={unit:R.hp,prefix:F.NONE[``]},se.us.PRESSURE={unit:R.psi,prefix:F.NONE[``]},se.auto=JSON.parse(JSON.stringify(se.si));var ce=se.auto;for(var le in x.setUnitSystem=function(e){if(AD(se,e))ce=se[e];else throw Error(`Unit system `+e+` does not exist. Choices are: `+Object.keys(se).join(`, `))},x.getUnitSystem=function(){for(var e in se)if(AD(se,e)&&se[e]===ce)return e},x.typeConverters={BigNumber:function(e){return e!=null&&e.isFraction?new g(String(e.n)).div(String(e.d)).times(String(e.s)):new g(e+``)},Fraction:function(e){return new _(e)},Complex:function(e){return e},number:function(e){return e!=null&&e.isFraction?m(e):e}},x.prototype._numberConverter=function(){var e=x.typeConverters[this.valueType()];if(e)return e;throw TypeError(`Unsupported Unit value type "`+this.valueType()+`"`)},x._getNumberConverter=function(e){if(!x.typeConverters[e])throw TypeError(`Unsupported type "`+e+`"`);return x.typeConverters[e]},R)if(AD(R,le)){var ue=R[le];ue.dimensions=ue.base.dimensions}for(var de in z)if(AD(z,de)){var fe=R[z[de]],pe={};for(var me in fe)AD(fe,me)&&(pe[me]=fe[me]);pe.name=de,R[de]=pe}x.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)};function B(e){for(var t=0;t0&&!(x.isValidAlpha(w)||D(w)))throw Error(`Invalid unit name (only alphanumeric characters are allowed): "`+e+`"`)}}return x.createUnit=function(e,t){if(typeof e!=`object`)throw TypeError(`createUnit expects first parameter to be of type 'Object'`);if(t&&t.override){for(var n in e)if(AD(e,n)&&x.deleteUnit(n),e[n].aliases)for(var r=0;r1e-12){f=!1;break}if(f){u=!0,l.base=L[d];break}}if(!u){s||=e+`_STUFF`;var m={dimensions:n.dimensions.slice(0)};m.key=s,L[s]=m,ce[s]={unit:l,prefix:F.NONE[``]},l.base=L[s]}}else{if(s||=e+`_STUFF`,I.indexOf(s)>=0)throw Error(`Cannot create new base unit "`+e+`": a base unit with that name already exists (and cannot be overridden)`);for(var h in I.push(s),L)AD(L,h)&&(L[h].dimensions[I.length-1]=0);for(var g={dimensions:[]},_=0;_{var{typed:t,Unit:n}=e;return t(TB,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,t){return new n(e,t)},"number | BigNumber | Fraction":function(e){return new n(e)},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),DB=`sparse`,OB=Z(DB,[`typed`,`SparseMatrix`],e=>{var{typed:t,SparseMatrix:n}=e;return t(DB,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})}),kB=`createUnit`,AB=Z(kB,[`typed`,`Unit`],e=>{var{typed:t,Unit:n}=e;return t(kB,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var i={};return i[e]=t,n.createUnit(i,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})}),jB=`acos`,MB=Z(jB,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(jB,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})}),NB=`acosh`,PB=Z(NB,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(NB,{number:function(e){return e>=1||n.predictable?fN(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})}),FB=`acot`,IB=Z(FB,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(FB,{number:pN,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()}})}),LB=`acoth`,RB=Z(LB,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(LB,{number:function(e){return e>=1||e<=-1||n.predictable?mN(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})}),zB=`acsc`,BB=Z(zB,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(zB,{number:function(e){return e<=-1||e>=1||n.predictable?hN(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})}),VB=`acsch`,HB=Z(VB,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(VB,{number:gN,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()}})}),UB=`asec`,WB=Z(UB,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(UB,{number:function(e){return e<=-1||e>=1||n.predictable?_N(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})}),GB=`asech`,KB=Z(GB,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(GB,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return vN(e);var i=Math.sqrt(t*t-1);return new r(Math.log(i-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()}})}),qB=`asin`,JB=Z(qB,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(qB,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})}),YB=Z(`asinh`,[`typed`],e=>{var{typed:t}=e;return t(`asinh`,{number:bN,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})}),XB=Z(`atan`,[`typed`],e=>{var{typed:t}=e;return t(`atan`,{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})}),ZB=`atan2`,QB=Z(ZB,[`typed`,`matrix`,`equalScalar`,`BigNumber`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,DenseMatrix:a,concat:o}=e,s=bF({typed:t,equalScalar:r}),c=xF({typed:t}),l=dI({typed:t,equalScalar:r}),u=ZP({typed:t,equalScalar:r}),d=QP({typed:t,DenseMatrix:a}),f=EF({typed:t,matrix:n,concat:o});return t(ZB,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,t)=>i.atan2(e,t)},f({scalar:`number | BigNumber`,SS:l,DS:c,SD:s,Ss:u,sS:d}))}),$B=`atanh`,eV=Z($B,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t($B,{number:function(e){return e<=1&&e>=-1||n.predictable?CN(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})}),tV=Z(`trigUnit`,[`typed`],e=>{var{typed:t}=e;return{Unit:t.referToSelf(e=>n=>{if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw TypeError(`Unit in function cot is no angle`);return t.find(e,n.valueType())(n.value)})}}),nV=`cos`,rV=Z(nV,[`typed`],e=>{var{typed:t}=e,n=tV({typed:t});return t(nV,{number:Math.cos,"Complex | BigNumber":e=>e.cos()},n)}),iV=`cosh`,aV=Z(iV,[`typed`],e=>{var{typed:t}=e;return t(iV,{number:dO,"Complex | BigNumber":e=>e.cosh()})}),oV=`cot`,sV=Z(oV,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=tV({typed:t});return t(oV,{number:EN,Complex:e=>e.cot(),BigNumber:e=>new n(1).div(e.tan())},r)}),cV=`coth`,lV=Z(cV,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(cV,{number:DN,Complex:e=>e.coth(),BigNumber:e=>new n(1).div(e.tanh())})}),uV=`csc`,dV=Z(uV,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=tV({typed:t});return t(uV,{number:ON,Complex:e=>e.csc(),BigNumber:e=>new n(1).div(e.sin())},r)}),fV=`csch`,pV=Z(fV,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(fV,{number:kN,Complex:e=>e.csch(),BigNumber:e=>new n(1).div(e.sinh())})}),mV=`sec`,hV=Z(mV,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=tV({typed:t});return t(mV,{number:AN,Complex:e=>e.sec(),BigNumber:e=>new n(1).div(e.cos())},r)}),gV=`sech`,_V=Z(gV,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(gV,{number:jN,Complex:e=>e.sech(),BigNumber:e=>new n(1).div(e.cosh())})}),vV=`sin`,yV=Z(vV,[`typed`],e=>{var{typed:t}=e,n=tV({typed:t});return t(vV,{number:Math.sin,"Complex | BigNumber":e=>e.sin()},n)}),bV=`sinh`,xV=Z(bV,[`typed`],e=>{var{typed:t}=e;return t(bV,{number:NN,"Complex | BigNumber":e=>e.sinh()})}),SV=`tan`,CV=Z(SV,[`typed`],e=>{var{typed:t}=e,n=tV({typed:t});return t(SV,{number:Math.tan,"Complex | BigNumber":e=>e.tan()},n)}),wV=Z(`tanh`,[`typed`],e=>{var{typed:t}=e;return t(`tanh`,{number:pO,"Complex | BigNumber":e=>e.tanh()})}),TV=`setCartesian`,EV=Z(TV,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(TV,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(r(n(e),new a(0))!==0&&r(n(t),new a(0))!==0){var c=Tj(Array.isArray(e)?e:e.toArray()).sort(i),l=Tj(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var u=0;u{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(DV,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(r(n(e),new a(0))===0)s=[];else if(r(n(t),new a(0))===0)return Tj(e.toArray());else{var c=jj(Tj(Array.isArray(e)?e:e.toArray()).sort(i)),l=jj(Tj(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var u,d=0;d{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(kV,{"Array | Matrix":function(e){var t;if(r(n(e),new a(0))===0)t=[];else{var s=Tj(Array.isArray(e)?e:e.toArray()).sort(i);t=[],t.push(s[0]);for(var c=1;c{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(jV,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(r(n(e),new a(0))===0||r(n(t),new a(0))===0)s=[];else{var c=jj(Tj(Array.isArray(e)?e:e.toArray()).sort(i)),l=jj(Tj(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var u=0;u{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(NV,{"Array | Matrix, Array | Matrix":function(e,t){if(r(n(e),new a(0))===0)return!0;if(r(n(t),new a(0))===0)return!1;for(var o=jj(Tj(Array.isArray(e)?e:e.toArray()).sort(i)),s=jj(Tj(Array.isArray(t)?t:t.toArray()).sort(i)),c,l=0;l{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(FV,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(r(n(t),new a(0))===0)return 0;for(var o=Tj(Array.isArray(t)?t:t.toArray()),s=0,c=0;c{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(LV,{"Array | Matrix":function(e){if(r(n(e),new a(0))===0)return[];for(var t=Tj(Array.isArray(e)?e:e.toArray()).sort(i),c=[],l=0;l.toString(2).length<=t.length;)c.push(o(t,l.toString(2).split(``).reverse())),l++;return s(c)}});function o(e,t){for(var n=[],r=0;r0;n--)for(var r=0;re[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}}),zV=`setSize`,BV=Z(zV,[`typed`,`compareNatural`],e=>{var{typed:t,compareNatural:n}=e;return t(zV,{"Array | Matrix":function(e){return Array.isArray(e)?Tj(e).length:Tj(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(t===!1||e.length===0)return Array.isArray(e)?Tj(e).length:Tj(e.toArray()).length;for(var r=Tj(Array.isArray(e)?e:e.toArray()).sort(n),i=1,a=1;a{var{typed:t,size:n,concat:r,subset:i,setDifference:a,Index:o}=e;return t(VV,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new o(0))===0)return Tj(t);if(i(n(t),new o(0))===0)return Tj(e);var s=Tj(e),c=Tj(t);return r(a(s,c),a(c,s))}})}),UV=`setUnion`,WV=Z(UV,[`typed`,`size`,`concat`,`subset`,`setIntersect`,`setSymDifference`,`Index`],e=>{var{typed:t,size:n,concat:r,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(UV,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new s(0))===0)return Tj(t);if(i(n(t),new s(0))===0)return Tj(e);var c=Tj(e),l=Tj(t);return r(o(c,l),a(c,l))}})}),GV=`add`,KV=Z(GV,[`typed`,`matrix`,`addScalar`,`equalScalar`,`DenseMatrix`,`SparseMatrix`,`concat`],e=>{var{typed:t,matrix:n,addScalar:r,equalScalar:i,DenseMatrix:a,SparseMatrix:o,concat:s}=e,c=kF({typed:t}),l=AF({typed:t,equalScalar:i}),u=jF({typed:t,DenseMatrix:a}),d=EF({typed:t,matrix:n,concat:s});return t(GV,{"any, any":r,"any, any, ...any":t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a{var{typed:t,abs:n,addScalar:r,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:c}=e;return t(qV,{"... number | BigNumber":l,Array:l,Matrix:e=>l(Tj(e.toArray(),!0))});function l(e){for(var t=0,l=0,u=0;u{var{typed:t,abs:n,add:r,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:c,larger:l,smaller:u,matrix:d,ctranspose:f,eigs:p}=e;return t(YV,{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 S(d(e),2)},Matrix:function(e){return S(e,2)},"Array, number | BigNumber | string":function(e,t){return S(d(e),t)},"Matrix, number | BigNumber | string":function(e,t){return S(e,t)}});function m(e){var t=0;return e.forEach(function(e){var r=n(e);l(r,t)&&(t=r)},!0),t}function h(e){var t;return e.forEach(function(e){var r=n(e);(!t||u(r,t))&&(t=r)},!0),t||0}function g(e,t){if(t===1/0||t===`inf`)return m(e);if(t===-1/0||t===`-inf`)return h(e);if(t===`fro`)return S(e,2);if(typeof t==`number`&&!isNaN(t)){if(!c(t,0)){var a=0;return e.forEach(function(e){a=r(i(n(e),t),a)},!0),i(a,1/t)}return 1/0}throw Error(`Unsupported parameter value`)}function _(e){var t=0;return e.forEach(function(e,n){t=r(t,s(e,a(e)))}),n(o(t))}function v(e){var t=[],i=0;return e.forEach(function(e,a){var o=a[1],s=r(t[o]||0,n(e));l(s,i)&&(i=s),t[o]=s},!0),i}function y(e){var t=e.size();if(t[0]!==t[1])throw RangeError(`Invalid matrix dimensions`);var r=p(s(f(e),e)).values.toArray(),i=r[r.length-1];return n(o(i))}function b(e){var t=[],i=0;return e.forEach(function(e,a){var o=a[0],s=r(t[o]||0,n(e));l(s,i)&&(i=s),t[o]=s},!0),i}function x(e,t){if(t===1)return v(e);if(t===1/0||t===`inf`)return b(e);if(t===`fro`)return _(e);if(t===2)return y(e);throw Error(`Unsupported parameter value `+t)}function S(e,t){var n=e.size();if(n.length===1)return g(e,t);if(n.length===2){if(n[0]&&n[1])return x(e,t);throw RangeError(`Invalid matrix dimensions`)}}}),ZV=`dot`,QV=Z(ZV,[`typed`,`addScalar`,`multiplyScalar`,`conj`,`size`],e=>{var{typed:t,addScalar:n,multiplyScalar:r,conj:i,size:a}=e;return t(ZV,{"Array | DenseMatrix, Array | DenseMatrix":s,"SparseMatrix, SparseMatrix":c});function o(e,t){var n=a(e),r=a(t),i,o;if(n.length===1)i=n[0];else if(n.length===2&&n[1]===1)i=n[0];else throw RangeError(`Expected a column vector, instead got a matrix of size (`+n.join(`, `)+`)`);if(r.length===1)o=r[0];else if(r.length===2&&r[1]===1)o=r[0];else throw RangeError(`Expected a column vector, instead got a matrix of size (`+r.join(`, `)+`)`);if(i!==o)throw RangeError(`Vectors must have equal length (`+i+` != `+o+`)`);if(i===0)throw RangeError(`Cannot calculate the dot product of empty vectors`);return i}function s(e,s){var c=o(e,s),l=zE(e)?e._data:e,u=zE(e)?e._datatype||e.getDataType():void 0,d=zE(s)?s._data:s,f=zE(s)?s._datatype||s.getDataType():void 0,p=a(e).length===2,m=a(s).length===2,h=n,g=r;if(u&&f&&u===f&&typeof u==`string`&&u!==`mixed`){var _=u;h=t.find(n,[_,_]),g=t.find(r,[_,_])}if(!p&&!m){for(var v=g(i(l[0]),d[0]),y=1;yh){p++;continue}m===h&&(l=u(l,d(a[f],c[p])),f++,p++)}return l}}),$V=Z(`trace`,[`typed`,`matrix`,`add`],e=>{var{typed:t,matrix:n,add:r}=e;return t(`trace`,{Array:function(e){return i(n(e))},SparseMatrix:a,DenseMatrix:i,any:SD});function i(e){var t=e._size,n=e._data;switch(t.length){case 1:if(t[0]===1)return SD(n[0]);throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o0)for(var l=0;ll)break}return c}throw RangeError(`Matrix must be square (size: `+$A(a)+`)`)}}),eH=`index`,tH=Z(eH,[`typed`,`Index`],e=>{var{typed:t,Index:n}=e;return t(eH,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map(function(e){return ME(e)?e.toNumber():RE(e)||zE(e)?e.map(function(e){return ME(e)?e.toNumber():e}):e}),r=new n;return n.apply(r,t),r}})}),nH=new Set([`end`]),rH=Z(`Node`,[`mathWithTransform`],e=>{var{mathWithTransform:t}=e;function n(e){for(var t of[...nH])if(e.has(t))throw Error(`Scope contains an illegal symbol, "`+t+`" is a reserved keyword`)}class r{get type(){return`Node`}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(t,{}),r={},i=null;function a(t){var a=kE(t);return n(a),e(a,r,i)}return{evaluate:a}}_compile(e,t){throw Error(`Method _compile must be implemented by type `+this.type)}forEach(e){throw Error(`Cannot run forEach on a Node interface`)}map(e){throw Error(`Cannot run map on a Node interface`)}_ifNode(e){if(!pD(e))throw TypeError(`Callback function must return a Node`);return e}traverse(e){e(this,null,null);function t(e,n){e.forEach(function(e,r,i){n(e,r,i),t(e,n)})}t(this,e)}transform(e){function t(n,r,i){var a=e(n,r,i);return a===n?n.map(t):a}return t(this,null,null)}filter(e){var t=[];return this.traverse(function(n,r,i){e(n,r,i)&&t.push(n)}),t}clone(){throw Error(`Cannot clone a Node interface`)}cloneDeep(){return this.map(function(e){return e.cloneDeep()})}equals(e){return e?this.type===e.type&&ED(this,e):!1}toString(e){var t=this._getCustomString(e);return t===void 0?this._toString(e):t}_toString(){throw Error(`_toString not implemented for `+this.type)}toJSON(){throw Error(`Cannot serialize object: toJSON not implemented by `+this.type)}toHTML(e){var t=this._getCustomString(e);return t===void 0?this._toHTML(e):t}_toHTML(){throw Error(`_toHTML not implemented for `+this.type)}toTex(e){var t=this._getCustomString(e);return t===void 0?this._toTex(e):t}_toTex(e){throw Error(`_toTex not implemented for `+this.type)}_getCustomString(e){if(e&&typeof e==`object`)switch(typeof e.handler){case`object`:case`undefined`:return;case`function`:return e.handler(this,e);default:throw TypeError(`Object or function expected as callback`)}}getIdentifier(){return this.type}getContent(){return this}}return r},{isClass:!0,isNode:!0});function iH(e){return e&&e.isIndexError?new cj(e.index+1,e.min+1,e.max===void 0?void 0:e.max+1):e}function aH(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&typeof e.subset==`function`)return e.subset(n);if(typeof e==`string`)return t(e,n);if(typeof e==`object`){if(!n.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return gE(e,n.getObjectProperty())}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw iH(e)}}}var oH=`AccessorNode`,sH=Z(oH,[`subset`,`Node`],e=>{var{subset:t,Node:n}=e,r=aH({subset:t});function i(e){return!(rD(e)||iD(e)||cD(e)||dD(e)||mD(e)||gD(e)||yD(e))}class a extends n{constructor(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!pD(e))throw TypeError(`Node expected for parameter "object"`);if(!fD(t))throw TypeError(`IndexNode expected for parameter "index"`);this.object=e,this.index=t,this.optionalChaining=n}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return oH}get isAccessorNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),i=this.index._compile(e,t),a=this.optionalChaining,o=rD(this.object)&&this.object.optionalChaining;if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(e,t,r){var i=r||{},c=n(e,t,i);if(a&&c==null){i.optionalShortCircuit=!0;return}if(!(o&&i!=null&&i.optionalShortCircuit))return gE(c,s)}}else return function(e,t,s){var c=s||{},l=n(e,t,c);if(a&&l==null){c.optionalShortCircuit=!0;return}if(!(o&&c!=null&&c.optionalShortCircuit))return r(l,i(e,t,l))}}forEach(e){e(this.object,`object`,this),e(this.index,`index`,this)}map(e){return new a(this._ifNode(e(this.object,`object`,this)),this._ifNode(e(this.index,`index`,this)),this.optionalChaining)}clone(){return new a(this.object,this.index,this.optionalChaining)}_toString(e){var t=this.object.toString(e);i(this.object)&&(t=`(`+t+`)`);var n=this.optionalChaining?this.index.dotNotation?`?`:`?.`:``;return t+n+this.index.toString(e)}_toHTML(e){var t=this.object.toHTML(e);return i(this.object)&&(t=`(`+t+`)`),t+this.index.toHTML(e)}_toTex(e){var t=this.object.toTex(e);return i(this.object)&&(t=`\\left(' + object + '\\right)`),t+this.index.toTex(e)}toJSON(){return{mathjs:oH,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(e){return new a(e.object,e.index,e.optionalChaining)}}return iR(a,`name`,oH),a},{isClass:!0,isNode:!0}),cH=`ArrayNode`,lH=Z(cH,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(pD))throw TypeError(`Array containing Nodes expected`)}get type(){return cH}get isArrayNode(){return!0}_compile(e,t){var n=Ej(this.items,function(n){return n._compile(e,t)});if(e.config.matrix!==`Array`){var r=e.matrix;return function(e,t,i){return r(Ej(n,function(n){return n(e,t,i)}))}}else return function(e,t,r){return Ej(n,function(n){return n(e,t,r)})}}forEach(e){for(var t=0;t[`+this.items.map(function(t){return t.toHTML(e)}).join(`,`)+`]`}_toTex(e){function t(n,r){var i=n.some(iD)&&!n.every(iD),a=r||i,o=a?`&`:`\\\\`,s=n.map(function(n){return n.items?t(n.items,!r):n.toTex(e)}).join(o);return i||!a||a&&!r?`\\begin{bmatrix}`+s+`\\end{bmatrix}`:s}return t(this.items,!1)}}return iR(n,`name`,cH),n},{isClass:!0,isNode:!0});function uH(e){var{subset:t,matrix:n}=e;return function(e,r,i){try{if(Array.isArray(e))return n(e).subset(r,i).valueOf().forEach((t,n)=>{e[n]=t}),e;if(e&&typeof e.subset==`function`)return e.subset(r,i);if(typeof e==`string`)return t(e,r,i);if(typeof e==`object`){if(!r.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return _E(e,r.getObjectProperty(),i),e}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw iH(e)}}}var dH=[{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 fH(e,t){if(!t||t!==`auto`)return e;for(var n=e;gD(n);)n=n.content;return n}function pH(e,t,n,r){var i=e;t!==`keep`&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s{var{subset:t,matrix:n,Node:r}=e,i=aH({subset:t}),a=uH({subset:t,matrix:n});function o(e,t,n){t||=`keep`;var r=pH(e,t,n),i=pH(e.value,t,n);return t===`all`||i!==null&&i<=r}class s extends r{constructor(e,t,n){if(super(),this.object=e,this.index=n?t:null,this.value=n||t,!yD(e)&&!rD(e))throw TypeError(`SymbolNode or AccessorNode expected as "object"`);if(yD(e)&&e.name===`end`)throw Error(`Cannot assign to symbol "end"`);if(this.index&&!fD(this.index))throw TypeError(`IndexNode expected as "index"`);if(!pD(this.value))throw TypeError(`Node expected as "value"`)}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return _H}get isAssignmentNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(!this.index){if(!yD(this.object))throw TypeError(`SymbolNode expected as object`);return function(e,t,n){var r=o(e,t,n);return e.set(s,r),r}}else if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(e,t,r){var i=n(e,t,r),a=o(e,t,r);return _E(i,c,a),a}}else if(yD(this.object))return function(e,t,i){var c=n(e,t,i),l=o(e,t,i),u=r(e,t,c);return e.set(s,a(c,u,l)),l};else{var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var u=this.object.index.getObjectProperty();return function(e,t,n){var i=l(e,t,n),s=gE(i,u),c=r(e,t,s),d=o(e,t,n);return _E(i,u,a(s,c,d)),d}}else{var d=this.object.index._compile(e,t);return function(e,t,n){var s=l(e,t,n),c=d(e,t,s),u=i(s,c),f=r(e,t,u),p=o(e,t,n);return a(s,c,a(u,f,p)),p}}}}forEach(e){e(this.object,`object`,this),this.index&&e(this.index,`index`,this),e(this.value,`value`,this)}map(e){return new s(this._ifNode(e(this.object,`object`,this)),this.index?this._ifNode(e(this.index,`index`,this)):null,this._ifNode(e(this.value,`value`,this)))}clone(){return new s(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):``,r=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+` = `+r}toJSON(){return{mathjs:_H,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new s(e.object,e.index,e.value)}_toHTML(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):``,r=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+`=`+r}_toTex(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):``,r=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`\\left(${r}\\right)`),t+n+`=`+r}}return iR(s,`name`,_H),s},{isClass:!0,isNode:!0}),yH=`BlockNode`,bH=Z(yH,[`ResultSet`,`Node`],e=>{var{ResultSet:t,Node:n}=e;class r extends n{constructor(e){if(super(),!Array.isArray(e))throw Error(`Array expected`);this.blocks=e.map(function(e){var t=e&&e.node,n=e&&e.visible!==void 0?e.visible:!0;if(!pD(t))throw TypeError(`Property "node" must be a Node`);if(typeof n!=`boolean`)throw TypeError(`Property "visible" must be a boolean`);return{node:t,visible:n}})}get type(){return yH}get isBlockNode(){return!0}_compile(e,n){var r=Ej(this.blocks,function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}});return function(e,n,i){var a=[];return Dj(r,function(t){var r=t.evaluate(e,n,i);t.visible&&a.push(r)}),new t(a)}}forEach(e){for(var t=0;t;`)}).join(`
`)}_toTex(e){return this.blocks.map(function(t){return t.node.toTex(e)+(t.visible?``:`;`)}).join(`\\;\\; `)}}return iR(r,`name`,yH),r},{isClass:!0,isNode:!0}),xH=`ConditionalNode`,SH=Z(xH,[`Node`],e=>{var{Node:t}=e;function n(e){if(typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return!!e;if(e){if(ME(e))return!e.isZero();if(PE(e))return!!(e.re||e.im);if(IE(e))return!!e.value}if(e==null)return!1;throw TypeError(`Unsupported type of condition "`+xD(e)+`"`)}class r extends t{constructor(e,t,n){if(super(),!pD(e))throw TypeError(`Parameter condition must be a Node`);if(!pD(t))throw TypeError(`Parameter trueExpr must be a Node`);if(!pD(n))throw TypeError(`Parameter falseExpr must be a Node`);this.condition=e,this.trueExpr=t,this.falseExpr=n}get type(){return xH}get isConditionalNode(){return!0}_compile(e,t){var r=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,o){return n(r(e,t,o))?i(e,t,o):a(e,t,o)}}forEach(e){e(this.condition,`condition`,this),e(this.trueExpr,`trueExpr`,this),e(this.falseExpr,`falseExpr`,this)}map(e){return new r(this._ifNode(e(this.condition,`condition`,this)),this._ifNode(e(this.trueExpr,`trueExpr`,this)),this._ifNode(e(this.falseExpr,`falseExpr`,this)))}clone(){return new r(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=pH(this,t,e&&e.implicit),r=this.condition.toString(e),i=pH(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toString(e),o=pH(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toString(e),c=pH(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+` ? `+a+` : `+s}toJSON(){return{mathjs:xH,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new r(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=pH(this,t,e&&e.implicit),r=this.condition.toHTML(e),i=pH(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toHTML(e),o=pH(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toHTML(e),c=pH(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+`?`+a+`:`+s}_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 iR(r,`name`,xH),r},{isClass:!0,isNode:!0}),CH=l(o(((e,t)=>{var n=Object.assign||function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{},o=t.preserveFormatting,s=o===void 0?!1:o,c=t.escapeMapFn,l=c===void 0?a:c,u=String(e),d=``,f=l(n({},r),s?n({},i):{}),p=Object.keys(f),m=function(){var e=!1;p.forEach(function(t,n){e||u.length>=t.length&&u.slice(0,t.length)===t&&(d+=f[p[n]],u=u.slice(t.length,u.length),e=!0)}),e||(d+=u.slice(0,1),u=u.slice(1,u.length))};u;)m();return d}}))(),1),wH={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{?}`},TH={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`},EH={abs:{1:"\\left|${args[0]}\\right|"},add:{2:`\\left(\${args[0]}${TH.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]}${TH.dotDivide}\${args[1]}\\right)`},dotMultiply:{2:`\\left(\${args[0]}${TH.dotMultiply}\${args[1]}\\right)`},dotPow:{2:`\\left(\${args[0]}${TH.dotPow}\${args[1]}\\right)`},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:`\\left(e${TH.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]}${TH.mod}\${args[1]}\\right)`},multiply:{2:`\\left(\${args[0]}${TH.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)${TH.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]}${TH.subtract}\${args[1]}\\right)`},unaryMinus:{1:`${TH.unaryMinus}\\left(\${args[0]}\\right)`},unaryPlus:{1:`${TH.unaryPlus}\\left(\${args[0]}\\right)`},bitAnd:{2:`\\left(\${args[0]}${TH.bitAnd}\${args[1]}\\right)`},bitNot:{1:TH.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:`\\left(\${args[0]}${TH.bitOr}\${args[1]}\\right)`},bitXor:{2:`\\left(\${args[0]}${TH.bitXor}\${args[1]}\\right)`},leftShift:{2:`\\left(\${args[0]}${TH.leftShift}\${args[1]}\\right)`},rightArithShift:{2:`\\left(\${args[0]}${TH.rightArithShift}\${args[1]}\\right)`},rightLogShift:{2:`\\left(\${args[0]}${TH.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]}${TH.and}\${args[1]}\\right)`},not:{1:TH.not+"\\left(${args[0]}\\right)"},or:{2:`\\left(\${args[0]}${TH.or}\${args[1]}\\right)`},xor:{2:`\\left(\${args[0]}${TH.xor}\${args[1]}\\right)`},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:`\\left(\${args[0]}\\right)${TH.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]}}${TH.pow}{\\frac{1}{2}}`},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:`\\left(\${args[0]}\\right)${TH.transpose}`},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:`\\left(\${args[0]}\\right)${TH.factorial}`},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:`\\left(\${args[0]}${TH.equal}\${args[1]}\\right)`},larger:{2:`\\left(\${args[0]}${TH.larger}\${args[1]}\\right)`},largerEq:{2:`\\left(\${args[0]}${TH.largerEq}\${args[1]}\\right)`},smaller:{2:`\\left(\${args[0]}${TH.smaller}\${args[1]}\\right)`},smallerEq:{2:`\\left(\${args[0]}${TH.smallerEq}\${args[1]}\\right)`},unequal:{2:`\\left(\${args[0]}${TH.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]}${TH.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)+${wH.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)"}},DH="\\mathrm{${name}}\\left(${args}\\right)",OH={deg:`^\\circ`};function kH(e){return(0,CH.default)(e,{preserveFormatting:!0})}function AH(e,t){return t=t===void 0?!1:t,t?AD(OH,e)?OH[e]:`\\mathrm{`+kH(e)+`}`:AD(wH,e)?wH[e]:kH(e)}var jH=`ConstantNode`,MH=Z(jH,[`Node`,`isBounded`],e=>{var{Node:t,isBounded:n}=e;class r extends t{constructor(e){super(),this.value=e}get type(){return jH}get isConstantNode(){return!0}_compile(e,t){var n=this.value;return function(){return n}}forEach(e){}map(e){return this.clone()}clone(){return new r(this.value)}_toString(e){return $A(this.value,e)}_toHTML(e){var t=this._toString(e);switch(xD(this.value)){case`number`:case`bigint`:case`BigNumber`:case`Fraction`:return``+t+``;case`string`:return``+t+``;case`boolean`:return``+t+``;case`null`:return``+t+``;case`undefined`:return``+t+``;default:return``+t+``}}toJSON(){return{mathjs:jH,value:this.value}}static fromJSON(e){return new r(e.value)}_toTex(e){var t=this._toString(e);switch(xD(this.value)){case`string`:return`\\mathtt{`+kH(t)+`}`;case`number`:case`BigNumber`:if(!n(this.value))return this.value.valueOf()<0?`-\\infty`:`\\infty`;var r=t.toLowerCase().indexOf(`e`);return r===-1?t:t.substring(0,r)+`\\cdot10^{`+t.substring(r+1)+`}`;case`bigint`:return t.toString();case`Fraction`:return this.value.toLatex();default:return t}}}return iR(r,`name`,jH),r},{isClass:!0,isNode:!0}),NH=`FunctionAssignmentNode`,PH=Z(NH,[`typed`,`Node`],e=>{var{typed:t,Node:n}=e;function r(e,t,n){var r=pH(e,t,n),i=pH(e.expr,t,n);return t===`all`||i!==null&&i<=r}class i extends n{constructor(e,t,n){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);if(!Array.isArray(t))throw TypeError(`Array containing strings or objects expected for parameter "params"`);if(!pD(n))throw TypeError(`Node expected for parameter "expr"`);if(nH.has(e))throw Error(`Illegal function name, "`+e+`" is a reserved keyword`);var r=new Set;for(var i of t){var a=typeof i==`string`?i:i.name;if(r.has(a))throw Error(`Duplicate parameter name "${a}"`);r.add(a)}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=n}get type(){return NH}get isFunctionAssignmentNode(){return!0}_compile(e,n){var r=Object.create(n);Dj(this.params,function(e){r[e]=!0});var i=this.expr,a=i._compile(e,r),o=this.name,s=this.params,c=Aj(this.types,`,`),l=o+`(`+Aj(this.params,`, `)+`)`;return function(e,n,r){var u={};u[c]=function(){for(var t=Object.create(n),i=0;i`+rj(this.params[i])+``);var a=this.expr.toHTML(e);return r(this,t,e&&e.implicit)&&(a=`(`+a+`)`),``+rj(this.name)+`(`+n.join(`,`)+`)=`+a}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=this.expr.toTex(e);return r(this,t,e&&e.implicit)&&(n=`\\left(${n}\\right)`),`\\mathrm{`+this.name+`}\\left(`+this.params.map(AH).join(`,`)+`\\right)=`+n}}return iR(i,`name`,NH),i},{isClass:!0,isNode:!0}),FH=`IndexNode`,IH=Z(FH,[`Node`,`size`],e=>{var{Node:t,size:n}=e;class r extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(pD))throw TypeError(`Array containing Nodes expected for parameter "dimensions"`);if(this.dotNotation&&!this.isObjectProperty())throw Error(`dotNotation only applicable for object properties`)}get type(){return FH}get isIndexNode(){return!0}_compile(e,t){var r=Ej(this.dimensions,function(r,i){if(r.filter(e=>e.isSymbolNode&&e.name===`end`).length>0){var a=Object.create(t);a.end=!0;var o=r._compile(e,a);return function(e,t,r){if(!zE(r)&&!RE(r)&&!LE(r))throw TypeError(`Cannot resolve "end": context must be a Matrix, Array, or string but is `+xD(r));var a=n(r),s=Object.create(t);return s.end=a[i],o(e,s,r)}}else return r._compile(e,t)}),i=gE(e,`index`);return function(e,t,n){return i(...Ej(r,function(r){return r(e,t,n)}))}}forEach(e){for(var t=0;t.`+rj(this.getObjectProperty())+``:`[`+t.join(`,`)+`]`}_toTex(e){var t=this.dimensions.map(function(t){return t.toTex(e)});return this.dotNotation?`.`+this.getObjectProperty():`_{`+t.join(`,`)+`}`}}return iR(r,`name`,FH),r},{isClass:!0,isNode:!0}),LH=`ObjectNode`,RH=Z(LH,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.properties=e||{},e&&(typeof e!=`object`||!Object.keys(e).every(function(t){return pD(e[t])})))throw TypeError(`Object containing Nodes expected`)}get type(){return LH}get isObjectNode(){return!0}_compile(e,t){var n={};for(var r in this.properties)if(AD(this.properties,r)){var i=tj(r),a=JSON.parse(i);n[a]=gE(this.properties,r)._compile(e,t)}return function(e,t,r){var i={};for(var a in n)AD(n,a)&&(i[a]=n[a](e,t,r));return i}}forEach(e){for(var t in this.properties)AD(this.properties,t)&&e(this.properties[t],`properties[`+tj(t)+`]`,this)}map(e){var t={};for(var r in this.properties)AD(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],`properties[`+tj(r)+`]`,this)));return new n(t)}clone(){var e={};for(var t in this.properties)AD(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)}_toString(e){var t=[];for(var n in this.properties)AD(this.properties,n)&&t.push(tj(n)+`: `+this.properties[n].toString(e));return`{`+t.join(`, `)+`}`}toJSON(){return{mathjs:LH,properties:this.properties}}static fromJSON(e){return new n(e.properties)}_toHTML(e){var t=[];for(var n in this.properties)AD(this.properties,n)&&t.push(``+rj(n)+`:`+this.properties[n].toHTML(e));return`{`+t.join(`,`)+`}`}_toTex(e){var t=[];for(var n in this.properties)AD(this.properties,n)&&t.push(`\\mathbf{`+n+`:} & `+this.properties[n].toTex(e)+`\\\\`);return`\\left\\{\\begin{array}{ll}`+t.join(` `)+`\\end{array}\\right\\}`}}return iR(n,`name`,LH),n},{isClass:!0,isNode:!0});function zH(e,t){return new EE(e,new TE(t),new Set(Object.keys(t)))}var BH=`OperatorNode`,VH=Z(BH,[`Node`],e=>{var{Node:t}=e;function n(e,t){var r=e;if(t===`auto`)for(;gD(r);)r=r.content;return cD(r)?!0:hD(r)?n(r.args[0],t):!1}function r(e,t,r,i,a){var o=pH(e,t,r),s=mH(e,t);if(t===`all`||i.length>2&&e.getIdentifier()!==`OperatorNode:add`&&e.getIdentifier()!==`OperatorNode:multiply`)return i.map(function(e){switch(e.getContent().type){case`ArrayNode`:case`ConstantNode`:case`SymbolNode`:case`ParenthesisNode`:return!1;default:return!0}});var c;switch(i.length){case 0:c=[];break;case 1:var l=pH(i[0],t,r,e);if(a&&l!==null){var u,d;if(t===`keep`?(u=i[0].getIdentifier(),d=e.getIdentifier()):(u=i[0].getContent().getIdentifier(),d=e.getContent().getIdentifier()),dH[o][d].latexLeftParens===!1){c=[!1];break}if(dH[l][u].latexParens===!1){c=[!1];break}}if(l===null){c=[!1];break}if(l<=o){c=[!0];break}c=[!1];break;case 2:var f,p=pH(i[0],t,r,e),m=hH(e,i[0],t);f=p===null?!1:p===o&&s===`right`&&!m?!0:p=2&&e.getIdentifier()===`OperatorNode:multiply`&&e.implicit&&t!==`all`&&r===`hide`)for(var x=1;x2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var d=i.map(function(t,n){return t=t.toString(e),a[n]&&(t=`(`+t+`)`),t});return this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?d.join(` `):d.join(` `+this.op+` `)}else return this.fn+`(`+this.args.join(`, `)+`)`}toJSON(){return{mathjs:BH,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!1);if(i.length===1){var o=mH(this,t),s=i[0].toHTML(e);return a[0]&&(s=`(`+s+`)`),o===`right`?``+rj(this.op)+``+s:s+``+rj(this.op)+``}else if(i.length===2){var c=i[0].toHTML(e),l=i[1].toHTML(e);return a[0]&&(c=`(`+c+`)`),a[1]&&(l=`(`+l+`)`),this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?c+``+l:c+``+rj(this.op)+``+l}else{var u=i.map(function(t,n){return t=t.toHTML(e),a[n]&&(t=`(`+t+`)`),t});return i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)?this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?u.join(``):u.join(``+rj(this.op)+``):``+rj(this.fn)+`(`+u.join(`,`)+`)`}}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!0),o=TH[this.fn];if(o=o===void 0?this.op:o,i.length===1){var s=mH(this,t),c=i[0].toTex(e);return a[0]&&(c=`\\left(${c}\\right)`),s===`right`?o+c:c+o}else if(i.length===2){var l=i[0],u=l.toTex(e);a[0]&&(u=`\\left(${u}\\right)`);var d=i[1].toTex(e);a[1]&&(d=`\\left(${d}\\right)`);var f=t===`keep`?l.getIdentifier():l.getContent().getIdentifier();switch(this.getIdentifier()){case`OperatorNode:divide`:return o+`{`+u+`}{`+d+`}`;case`OperatorNode:pow`:switch(u=`{`+u+`}`,d=`{`+d+`}`,f){case`ConditionalNode`:case`OperatorNode:divide`:u=`\\left(${u}\\right)`}break;case`OperatorNode:multiply`:if(this.implicit&&n===`hide`)return u+`~`+d}return u+o+d}else if(i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var p=i.map(function(t,n){return t=t.toTex(e),a[n]&&(t=`\\left(${t}\\right)`),t});return this.getIdentifier()===`OperatorNode:multiply`&&this.implicit&&n===`hide`?p.join(`~`):p.join(o)}else return`\\mathrm{`+this.fn+`}\\left(`+i.map(function(t){return t.toTex(e)}).join(`,`)+`\\right)`}getIdentifier(){return this.type+`:`+this.fn}}return iR(i,`name`,BH),i},{isClass:!0,isNode:!0}),HH=`ParenthesisNode`,UH=Z(HH,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),!pD(e))throw TypeError(`Node expected for parameter "content"`);this.content=e}get type(){return HH}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){return new n(e(this.content,`content`,this))}clone(){return new n(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toString(e)+`)`:this.content.toString(e)}toJSON(){return{mathjs:HH,content:this.content}}static fromJSON(e){return new n(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toHTML(e)+`)`:this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`\\left(${this.content.toTex(e)}\\right)`:this.content.toTex(e)}}return iR(n,`name`,HH),n},{isClass:!0,isNode:!0}),WH=`RangeNode`,GH=Z(WH,[`Node`],e=>{var{Node:t}=e;function n(e,t,n){var r=pH(e,t,n),i={},a=pH(e.start,t,n);if(i.start=a!==null&&a<=r||t===`all`,e.step){var o=pH(e.step,t,n);i.step=o!==null&&o<=r||t===`all`}var s=pH(e.end,t,n);return i.end=s!==null&&s<=r||t===`all`,i}class r extends t{constructor(e,t,n){if(super(),!pD(e)||!pD(t)||n&&!pD(n))throw TypeError(`Node expected`);if(arguments.length>3)throw Error(`Too many arguments`);this.start=e,this.end=t,this.step=n||null}get type(){return WH}get isRangeNode(){return!0}needsEnd(){return this.filter(function(e){return yD(e)&&e.name===`end`}).length>0}_compile(e,t){var n=e.range,r=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return n(r(e,t,o),i(e,t,o),a(e,t,o))}}else return function(e,t,a){return n(r(e,t,a),i(e,t,a))}}forEach(e){e(this.start,`start`,this),e(this.end,`end`,this),this.step&&e(this.step,`step`,this)}map(e){return new r(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 r(this.start,this.end,this.step&&this.step)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toString(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toString(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toString(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}toJSON(){return{mathjs:WH,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new r(e.start,e.end,e.step)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toHTML(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toHTML(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toHTML(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i=this.start.toTex(e);if(r.start&&(i=`\\left(${i}\\right)`),this.step){var a=this.step.toTex(e);r.step&&(a=`\\left(${a}\\right)`),i+=`:`+a}var o=this.end.toTex(e);return r.end&&(o=`\\left(${o}\\right)`),i+=`:`+o,i}}return iR(r,`name`,WH),r},{isClass:!0,isNode:!0}),KH=`RelationalNode`,qH=Z(KH,[`Node`],e=>{var{Node:t}=e,n={equal:`==`,unequal:`!=`,smaller:`<`,larger:`>`,smallerEq:`<=`,largerEq:`>=`};class r extends t{constructor(e,t){if(super(),!Array.isArray(e))throw TypeError(`Parameter conditionals must be an array`);if(!Array.isArray(t))throw TypeError(`Parameter params must be an array`);if(e.length!==t.length-1)throw TypeError(`Parameter params must contain exactly one more element than parameter conditionals`);this.conditionals=e,this.params=t}get type(){return KH}get isRelationalNode(){return!0}_compile(e,t){var n=this,r=this.params.map(n=>n._compile(e,t));return function(t,i,a){for(var o,s=r[0](t,i,a),c=0;ce(t,`params[`+n+`]`,this),this)}map(e){return new r(this.conditionals.slice(),this.params.map((t,n)=>this._ifNode(e(t,`params[`+n+`]`,this)),this))}clone(){return new r(this.conditionals,this.params)}_toString(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,r=pH(this,t,e&&e.implicit),i=this.params.map(function(n,i){var a=pH(n,t,e&&e.implicit);return t===`all`||a!==null&&a<=r?`(`+n.toString(e)+`)`:n.toString(e)}),a=i[0],o=0;o(`+n.toHTML(e)+`)`:n.toHTML(e)}),a=i[0],o=0;o`+rj(n[this.conditionals[o]])+``+i[o+1];return a}_toTex(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,n=pH(this,t,e&&e.implicit),r=this.params.map(function(r,i){var a=pH(r,t,e&&e.implicit);return t===`all`||a!==null&&a<=n?`\\left(`+r.toTex(e)+`\right)`:r.toTex(e)}),i=r[0],a=0;a{var{math:t,Unit:n,Node:r}=e;function i(e){return n?n.isValuelessUnit(e):!1}class a extends r{constructor(e){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);this.name=e}get type(){return`SymbolNode`}get isSymbolNode(){return!0}_compile(e,t){var r=this.name;if(t[r]===!0)return function(e,t,n){return gE(t,r)};if(r in e)return function(t,n,i){return t.has(r)?t.get(r):gE(e,r)};var o=i(r);return function(e,t,i){return e.has(r)?e.get(r):o?new n(null,r):a.onUndefinedSymbol(r)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw Error(`Undefined symbol `+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var t=rj(this.name);return t===`true`||t===`false`?``+t+``:t===`i`?``+t+``:t===`Infinity`?``+t+``:t===`NaN`?``+t+``:t===`null`?``+t+``:t===`undefined`?``+t+``:``+t+``}toJSON(){return{mathjs:`SymbolNode`,name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var n=!1;t[this.name]===void 0&&i(this.name)&&(n=!0);var r=AH(this.name,n);return r[0]===`\\`?r:` `+r}}return a},{isClass:!0,isNode:!0}),YH=`FunctionNode`,XH=Z(YH,[`math`,`Node`,`SymbolNode`],e=>{var t,{math:n,Node:r,SymbolNode:i}=e,a=e=>$A(e,{truncate:78});function o(e,t,n){for(var r=``,i=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,a=0,o;(o=i.exec(e))!==null;)if(r+=e.substring(a,o.index),a=o.index,o[0]===`$$`)r+=`$`,a++;else{a+=o[0].length;var s=t[o[1]];if(!s)throw ReferenceError(`Template: Property `+o[1]+` does not exist.`);if(o[2]===void 0)switch(typeof s){case`string`:r+=s;break;case`object`:if(pD(s))r+=s.toTex(n);else if(Array.isArray(s))r+=s.map(function(e,t){if(pD(e))return e.toTex(n);throw TypeError(`Template: `+o[1]+`[`+t+`] is not a Node.`)}).join(`,`);else throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`);break;default:throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`)}else if(pD(s[o[2]]&&s[o[2]]))r+=s[o[2]].toTex(n);else throw TypeError(`Template: `+o[1]+`[`+o[2]+`] is not a Node.`)}return r+=e.slice(a),r}class s extends r{constructor(e,t,n){if(super(),typeof e==`string`&&(e=new i(e)),!pD(e))throw TypeError(`Node expected as parameter "fn"`);if(!Array.isArray(t)||!t.every(pD))throw TypeError(`Array containing Nodes expected for parameter "args"`);var r=typeof n;if(!(r===`undefined`||r===`boolean`))throw TypeError(`optional flag, if specified, must be boolean`);this.fn=e,this.args=t||[],this.optional=!!n}get name(){return this.fn.name||``}get type(){return YH}get isFunctionNode(){return!0}_compile(e,t){var n=this.args.map(n=>n._compile(e,t)),r=this.optional||rD(this.fn)&&this.fn.optionalChaining;if(yD(this.fn)){var i=this.fn.name;if(t[i]){var o=this.args;return function(t,s,c){var l=gE(s,i);if(!(r&&l===void 0)){if(typeof l!=`function`)throw TypeError(`Argument '${i}' was not a function; received: ${a(l)}`);if(l.rawArgs)return l(o,e,zH(t,s));var u=n.map(e=>e(t,s,c));return l.apply(l,u)}}}else{var c=i in e?gE(e,i):void 0,l=typeof c==`function`&&c.rawArgs===!0,u=t=>{var n;if(t.has(i))n=t.get(i);else if(i in e)n=gE(e,i);else if(r)n=void 0;else return s.onUndefinedFunction(i);if(typeof n==`function`||r&&n===void 0)return n;throw TypeError(`'${i}' is not a function; its value is: ${a(n)}`)};if(l){var d=this.args;return function(t,r,i){var a=u(t);return a.rawArgs===!0?a(d,e,zH(t,r)):a(...n.map(e=>e(t,r,i)))}}else switch(n.length){case 0:return function(e,t,n){var i=u(e);if(!(r&&i===void 0))return i()};case 1:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0];return a(o(e,t,i))}};case 2:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0],s=n[1];return a(o(e,t,i),s(e,t,i))}};default:return function(e,t,i){var a=u(e);if(!(r&&a===void 0))return a(...n.map(n=>n(e,t,i)))}}}}else if(rD(this.fn)&&fD(this.fn.index)&&this.fn.index.isObjectProperty()){var f=this.fn.object._compile(e,t),p=this.fn.index.getObjectProperty(),m=this.args;return function(t,i,a){var o=f(t,i,a);if(!(r&&(o==null||o[p]===void 0))){var s=xE(o,p);if(s!=null&&s.rawArgs)return s(m,e,zH(t,i));var c=n.map(e=>e(t,i,a));return s.apply(o,c)}}}else{var h=this.fn.toString(),g=this.fn._compile(e,t),_=this.args;return function(t,i,o){var s=g(t,i,o);if(!(r&&s===void 0)){if(typeof s!=`function`)throw TypeError(`Expression '${h}' did not evaluate to a function; value is: ${a(s)}`);if(s.rawArgs)return s(_,e,zH(t,i));var c=n.map(e=>e(t,i,o));return s.apply(s,c)}}}}forEach(e){e(this.fn,`fn`,this);for(var t=0;t`+rj(this.fn)+`(`+t.join(`,`)+`)`}toTex(e){var t;return e&&typeof e.handler==`object`&&AD(e.handler,this.name)&&(t=e.handler[this.name](this,e)),t===void 0?super.toTex(e):t}_toTex(e){var t=this.args.map(function(t){return t.toTex(e)}),r;EH[this.name]&&(r=EH[this.name]),n[this.name]&&(typeof n[this.name].toTex==`function`||typeof n[this.name].toTex==`object`||typeof n[this.name].toTex==`string`)&&(r=n[this.name].toTex);var i;switch(typeof r){case`function`:i=r(this,e);break;case`string`:i=o(r,this,e);break;case`object`:switch(typeof r[t.length]){case`function`:i=r[t.length](this,e);break;case`string`:i=o(r[t.length],this,e);break}}return i===void 0?o(DH,this,e):i}getIdentifier(){return this.type+`:`+this.name}}return t=s,iR(s,`name`,YH),iR(s,`onUndefinedFunction`,function(e){throw Error(`Undefined function `+e)}),iR(s,`fromJSON`,function(e){return new t(e.fn,e.args)}),s},{isClass:!0,isNode:!0}),ZH=`parse`,QH=Z(ZH,[`typed`,`numeric`,`config`,`AccessorNode`,`ArrayNode`,`AssignmentNode`,`BlockNode`,`ConditionalNode`,`ConstantNode`,`FunctionAssignmentNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`RangeNode`,`RelationalNode`,`SymbolNode`],e=>{var{typed:t,numeric:n,config:r,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:s,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:u,FunctionNode:d,IndexNode:f,ObjectNode:p,OperatorNode:m,ParenthesisNode:h,RangeNode:g,RelationalNode:_,SymbolNode:v}=e,y=t(ZH,{string:function(e){return re(e,{})},"Array | Matrix":function(e){return b(e,{})},"string, Object":function(e,t){return re(e,t.nodes===void 0?{}:t.nodes)},"Array | Matrix, Object":b});function b(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.nodes===void 0?{}:t.nodes;return nM(e,function(e){if(typeof e!=`string`)throw TypeError(`String expected`);return re(e,n)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},S={",":!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,">>>":!0},C={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},w={true:!0,false:!1,null:null,undefined:void 0},T=[`NaN`,`Infinity`],E={'"':`"`,"'":`'`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:` `,r:`\r`,t:` `};function D(){return{extraNodes:{},expression:``,comment:``,index:0,token:``,tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function O(e,t){return e.expression.substr(e.index,t)}function k(e){return O(e,1)}function A(e){e.index++}function j(e){return e.expression.charAt(e.index-1)}function M(e){return e.expression.charAt(e.index+1)}function N(e){for(e.tokenType=x.NULL,e.token=``,e.comment=``;;){if(k(e)===`#`)for(;k(e)!==` `&&k(e)!==``;)e.comment+=k(e),A(e);if(y.isWhitespace(k(e),e.nestingLevel))A(e);else break}if(k(e)===``){e.tokenType=x.DELIMITER;return}if(k(e)===` `&&!e.nestingLevel){e.tokenType=x.DELIMITER,e.token=k(e),A(e);return}var t=k(e),n=O(e,2),r=O(e,3);if(r.length===3&&S[r]){e.tokenType=x.DELIMITER,e.token=r,A(e),A(e),A(e);return}if(n.length===2&&S[n]&&(n!==`?.`||!y.isDigit(e.expression.charAt(e.index+2)))){e.tokenType=x.DELIMITER,e.token=n,A(e),A(e);return}if(S[t]){e.tokenType=x.DELIMITER,e.token=t,A(e);return}if(y.isDigitDot(t)){e.tokenType=x.NUMBER;var i=O(e,2);if(i===`0b`||i===`0o`||i===`0x`){for(e.token+=k(e),A(e),e.token+=k(e),A(e);y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);if(k(e)===`.`)for(e.token+=`.`,A(e);y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);else if(k(e)===`i`)for(e.token+=`i`,A(e);y.isDigit(k(e));)e.token+=k(e),A(e);return}if(k(e)===`.`){if(e.token+=k(e),A(e),!y.isDigit(k(e))){e.tokenType=x.DELIMITER;return}}else{for(;y.isDigit(k(e));)e.token+=k(e),A(e);y.isDecimalMark(k(e),M(e))&&(e.token+=k(e),A(e))}for(;y.isDigit(k(e));)e.token+=k(e),A(e);if(k(e)===`E`||k(e)===`e`){if(y.isDigit(M(e))||M(e)===`-`||M(e)===`+`){if(e.token+=k(e),A(e),(k(e)===`+`||k(e)===`-`)&&(e.token+=k(e),A(e)),!y.isDigit(k(e)))throw je(e,`Digit expected, got "`+k(e)+`"`);for(;y.isDigit(k(e));)e.token+=k(e),A(e);if(y.isDecimalMark(k(e),M(e)))throw je(e,`Digit expected, got "`+k(e)+`"`)}else if(y.isDecimalMark(M(e),e.expression.charAt(e.index+2)))throw A(e),je(e,`Digit expected, got "`+k(e)+`"`)}return}if(y.isAlpha(k(e),j(e),M(e))){for(;y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);AD(C,e.token)?e.tokenType=x.DELIMITER:e.tokenType=x.SYMBOL;return}for(e.tokenType=x.UNKNOWN;k(e)!==``;)e.token+=k(e),A(e);throw je(e,`Syntax error in part "`+e.token+`"`)}function ee(e){do N(e);while(e.token===` `)}function te(e){e.nestingLevel++}function ne(e){e.nestingLevel--}y.isAlpha=function(e,t,n){return y.isValidLatinOrGreek(e)||y.isValidMathSymbol(e,n)||y.isValidMathSymbol(t,e)},y.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},y.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)},y.isWhitespace=function(e,t){return e===` `||e===` `||e===`\xA0`||e===` `&&t>0},y.isDecimalMark=function(e,t){return e===`.`&&t!==`/`&&t!==`*`&&t!==`^`},y.isDigitDot=function(e){return e>=`0`&&e<=`9`||e===`.`},y.isDigit=function(e){return e>=`0`&&e<=`9`};function re(e,t){var n=D();mE(n,{expression:e,extraNodes:t}),N(n);var r=P(n);if(n.token!==``)throw n.tokenType===x.DELIMITER?Me(n,`Unexpected operator `+n.token):je(n,`Unexpected part "`+n.token+`"`);return r}function P(e){var t,n=[],r;for(e.token!==``&&e.token!==` `&&e.token!==`;`&&(t=F(e),e.comment&&(t.comment=e.comment));e.token===` `||e.token===`;`;)n.length===0&&t&&(r=e.token!==`;`,n.push({node:t,visible:r})),N(e),e.token!==` `&&e.token!==`;`&&e.token!==``&&(t=F(e),e.comment&&(t.comment=e.comment),r=e.token!==`;`,n.push({node:t,visible:r}));return n.length>0?new s(n):(t||(t=new l(void 0),e.comment&&(t.comment=e.comment)),t)}function F(e){var t,n,r,i,a=I(e);if(e.token===`=`){if(yD(a))return t=a.name,ee(e),r=F(e),new o(new v(t),r);if(rD(a)){if(a.optionalChaining)throw je(e,`Cannot assign to optional chain`);return ee(e),r=F(e),new o(a.object,a.index,r)}else if(dD(a)&&yD(a.fn)&&(i=!0,n=[],t=a.name,a.args.forEach(function(e,t){yD(e)?n[t]=e.name:i=!1}),i))return ee(e),r=F(e),new u(t,n,r);throw je(e,`Invalid left hand side of assignment operator =`)}return a}function I(e){for(var t=L(e);e.token===`?`;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,ee(e);var r=t,i=F(e);if(e.token!==`:`)throw je(e,`False part of conditional expression expected`);e.conditionalLevel=null,ee(e),t=new c(r,i,F(e)),e.conditionalLevel=n}return t}function L(e){for(var t=ie(e);e.token===`or`;)ee(e),t=new m(`or`,`or`,[t,ie(e)]);return t}function ie(e){for(var t=ae(e);e.token===`xor`;)ee(e),t=new m(`xor`,`xor`,[t,ae(e)]);return t}function ae(e){for(var t=R(e);e.token===`and`;)ee(e),t=new m(`and`,`and`,[t,R(e)]);return t}function R(e){for(var t=z(e);e.token===`|`;)ee(e),t=new m(`|`,`bitOr`,[t,z(e)]);return t}function z(e){for(var t=oe(e);e.token===`^|`;)ee(e),t=new m(`^|`,`bitXor`,[t,oe(e)]);return t}function oe(e){for(var t=se(e);e.token===`&`;)ee(e),t=new m(`&`,`bitAnd`,[t,se(e)]);return t}function se(e){for(var t=[ce(e)],n=[],r={"==":`equal`,"!=":`unequal`,"<":`smaller`,">":`larger`,"<=":`smallerEq`,">=":`largerEq`};AD(r,e.token);){var i={name:e.token,fn:r[e.token]};n.push(i),ee(e),t.push(ce(e))}return t.length===1?t[0]:t.length===2?new m(n[0].name,n[0].fn,t):new _(n.map(e=>e.fn),t)}function ce(e){for(var t=le(e),n,r,i,a={"<<":`leftShift`,">>":`rightArithShift`,">>>":`rightLogShift`};AD(a,e.token);)n=e.token,r=a[n],ee(e),i=[t,le(e)],t=new m(n,r,i);return t}function le(e){for(var t=ue(e),n,r,i,a={to:`to`,in:`to`};AD(a,e.token);)n=e.token,r=a[n],ee(e),n===`in`&&`])},;`.includes(e.token)?t=new m(`*`,`multiply`,[t,new v(`in`)],!0):(i=[t,ue(e)],t=new m(n,r,i));return t}function ue(e){var t,n=[];if(e.token===`:`){if(e.conditionalLevel===e.nestingLevel)throw je(e,`The true-expression of a conditional operator may not be empty`);t=new l(1)}else t=de(e);if(e.token===`:`&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);e.token===`:`&&n.length<3;)ee(e),e.token===`)`||e.token===`]`||e.token===`,`||e.token===``?n.push(new v(`end`)):n.push(de(e));t=n.length===3?new g(n[0],n[2],n[1]):new g(n[0],n[1])}return t}function de(e){for(var t=fe(e),n,r,i,a={"+":`add`,"-":`subtract`};AD(a,e.token);){n=e.token,r=a[n],ee(e);var o=fe(e);i=o.isPercentage?[t,new m(`*`,`multiply`,[t,o])]:[t,o],t=new m(n,r,i)}return t}function fe(e){for(var t=pe(e),n=t,r,i,a={"*":`multiply`,".*":`dotMultiply`,"/":`divide`,"./":`dotDivide`,"%":`mod`,mod:`mod`};AD(a,e.token);)r=e.token,i=a[r],ee(e),n=pe(e),t=new m(r,i,[t,n]);return t}function pe(e){for(var t=me(e),n=t;e.tokenType===x.SYMBOL||e.token===`in`&&cD(t)||e.token===`in`&&hD(t)&&t.fn===`unaryMinus`&&cD(t.args[0])||e.tokenType===x.NUMBER&&!cD(n)&&(!hD(n)||n.op===`!`)||e.token===`(`;)n=me(e),t=new m(`*`,`multiply`,[t,n],!0);return t}function me(e){for(var t=B(e),n=t,r=[];e.token===`/`&&lD(n);)if(r.push(mE({},e)),ee(e),e.tokenType===x.NUMBER)if(r.push(mE({},e)),ee(e),e.tokenType===x.SYMBOL||e.token===`(`||e.token===`in`)mE(e,r.pop()),r.pop(),n=B(e),t=new m(`/`,`divide`,[t,n]);else{r.pop(),mE(e,r.pop());break}else{mE(e,r.pop());break}return t}function B(e){var t=he(e);if(e.token===`%`){var n=mE({},e);ee(e);try{he(e),mE(e,n)}catch{t=new m(`/`,`divide`,[t,new l(100)],!1,!0)}}return t}function he(e){var t,n,r,i={"-":`unaryMinus`,"+":`unaryPlus`,"~":`bitNot`,not:`not`};return AD(i,e.token)?(r=i[e.token],t=e.token,ee(e),n=[he(e)],new m(t,r,n)):ge(e)}function ge(e){var t=_e(e),n,r,i;return(e.token===`^`||e.token===`.^`)&&(n=e.token,r=n===`^`?`pow`:`dotPow`,ee(e),i=[t,he(e)],t=new m(n,r,i)),t}function _e(e){for(var t=ve(e);e.token===`??`;)ee(e),t=new m(`??`,`nullish`,[t,ve(e)]);return t}function ve(e){for(var t=ye(e),n,r,i,a={"!":`factorial`,"'":`ctranspose`};AD(a,e.token);)n=e.token,r=a[n],N(e),i=[t],t=new m(n,r,i),t=xe(e,t);return t}function ye(e){var t=[];if(e.tokenType===x.SYMBOL&&AD(e.extraNodes,e.token)){var n=e.extraNodes[e.token];if(N(e),e.token===`(`){if(t=[],te(e),N(e),e.token!==`)`)for(t.push(F(e));e.token===`,`;)N(e),t.push(F(e));if(e.token!==`)`)throw je(e,`Parenthesis ) expected`);ne(e),N(e)}return new n(t)}return be(e)}function be(e){var t,r;return e.tokenType===x.SYMBOL||e.tokenType===x.DELIMITER&&e.token in C?(r=e.token,N(e),t=AD(w,r)?new l(w[r]):T.includes(r)?new l(n(r,`number`)):new v(r),t=xe(e,t),t):Se(e)}function xe(e,t,n){for(var r;;){var a=!1;e.token===`?.`&&(a=!0,N(e));var o=(e.token===`(`||e.token===`[`||e.token===`.`)&&(!n||n.includes(e.token));if(!(a||o))break;if(r=[],e.token===`(`)if(a||yD(t)||rD(t)){if(te(e),N(e),e.token!==`)`)for(r.push(F(e));e.token===`,`;)N(e),r.push(F(e));if(e.token!==`)`)throw je(e,`Parenthesis ) expected`);ne(e),N(e),t=new d(t,r,a)}else return t;else if(e.token===`[`){if(te(e),N(e),e.token!==`]`)for(r.push(F(e));e.token===`,`;)N(e),r.push(F(e));if(e.token!==`]`)throw je(e,`Parenthesis ] expected`);ne(e),N(e),t=new i(t,new f(r),a)}else{if(a||N(e),!(e.tokenType===x.SYMBOL||e.tokenType===x.DELIMITER&&e.token in C)){var s=`Property name expected after `;throw s+=a?`optional chain`:`dot`,je(e,s)}r.push(new l(e.token)),N(e),t=new i(t,new f(r,!0),a)}}return t}function Se(e){var t,n;return e.token===`"`||e.token===`'`?(n=Ce(e,e.token),t=new l(n),t=xe(e,t),t):we(e)}function Ce(e,t){for(var n=``;k(e)!==``&&k(e)!==t;)if(k(e)===`\\`){A(e);var r=k(e),i=E[r];if(i!==void 0)n+=i,e.index+=1;else if(r===`u`){var a=e.expression.slice(e.index+1,e.index+5);if(/^[0-9A-Fa-f]{4}$/.test(a))n+=String.fromCharCode(parseInt(a,16)),e.index+=5;else throw je(e,`Invalid unicode character \\u${a}`)}else throw je(e,`Bad escape character \\${r}`)}else n+=k(e),A(e);if(N(e),e.token!==t)throw je(e,`End of string ${t} expected`);return N(e),n}function we(e){var t,n,r,i;if(e.token===`[`){if(te(e),N(e),e.token!==`]`){var o=Te(e);if(e.token===`;`){for(r=1,n=[o];e.token===`;`;)N(e),e.token!==`]`&&(n[r]=Te(e),r++);if(e.token!==`]`)throw je(e,`End of matrix ] expected`);ne(e),N(e),i=n[0].items.length;for(var s=1;s{var{typed:t,parse:n}=e;return t($H,{string:function(e){return n(e).compile()},"Array | Matrix":function(e){return nM(e,function(e){return n(e).compile()})}})}),tU=`evaluate`,nU=Z(tU,[`typed`,`parse`],e=>{var{typed:t,parse:n}=e;return t(tU,{string:function(e){var t=OE();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=OE();return nM(e,function(e){return n(e).compile().evaluate(t)})},"Array | Matrix, Map | Object":function(e,t){return nM(e,function(e){return n(e).compile().evaluate(t)})}})}),rU=Z(`Parser`,[`evaluate`,`parse`],e=>{var{evaluate:t,parse:n}=e;function r(){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);Object.defineProperty(this,"scope",{value:OE(),writable:!1})}r.prototype.type=`Parser`,r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e,this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return AE(this.scope)},r.prototype.getAllAsMap=function(){return this.scope};function i(e){if(e.length===0)return!1;for(var t=0;t0&&n.isDigit(i)))return!1}return!0}return r.prototype.set=function(e,t){if(!i(e))throw Error(`Invalid variable name: '${e}'. Variable names must follow the specified rules.`);return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r.prototype.toJSON=function(){var e={mathjs:`Parser`,variables:{},functions:{}};for(var[t,n]of this.scope)if(JE(n)){if(!iU(n))throw Error(`Cannot serialize external function ${t}`);e.functions[t]=`${n.syntax} = ${n.expr}`}else e.variables[t]=n;return e},r.fromJSON=function(e){var t=new r;return Object.entries(e.variables).forEach(e=>{var[n,r]=e;return t.set(n,r)}),Object.entries(e.functions).forEach(e=>{var[n,r]=e;return t.evaluate(r)}),t},r},{isClass:!0});function iU(e){return typeof e==`function`&&typeof e.syntax==`string`&&typeof e.expr==`string`}var aU=`parser`,oU=Z(aU,[`typed`,`Parser`],e=>{var{typed:t,Parser:n}=e;return t(aU,{"":function(){return new n}})}),sU=`lup`,cU=Z(sU,[`typed`,`matrix`,`abs`,`addScalar`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`larger`,`equalScalar`,`unaryMinus`,`DenseMatrix`,`SparseMatrix`,`Spa`],e=>{var{typed:t,matrix:n,abs:r,addScalar:i,divideScalar:a,multiplyScalar:o,subtractScalar:s,larger:c,equalScalar:l,unaryMinus:u,DenseMatrix:d,SparseMatrix:f,Spa:p}=e;return t(sU,{DenseMatrix:function(e){return m(e)},SparseMatrix:function(e){return h(e)},Array:function(e){var t=m(n(e));return{L:t.L.valueOf(),U:t.U.valueOf(),p:t.p}}});function m(e){var t=e._size[0],n=e._size[1],u=Math.min(t,n),f=SD(e._data),p=[],m=[t,u],h=[],g=[u,n],_,v,y,b=[];for(_=0;_0)for(_=0;_0&&e.forEach(0,w-1,function(t,n){f._forEachRow(t,h,g,_,function(r,i){r>t&&e.accumulate(r,u(o(i,n)))})});var D=w,k=e.get(w),A=r(k);e.forEach(w+1,t-1,function(e,t){var n=r(t);c(n,A)&&(D=e,A=n,k=t)}),w!==D&&(f._swapRows(w,D,v[1],h,g,_),f._swapRows(w,D,S[1],y,b,x),e.swap(w,D),O(w,D)),e.forEach(0,t-1,function(e,t){e<=w?(y.push(t),b.push(e)):(t=a(t,k),l(t,0)||(h.push(t),g.push(e)))})};for(w=0;w{var{typed:t,matrix:n,zeros:r,identity:i,isZero:a,equal:o,sign:s,sqrt:c,conj:l,unaryMinus:u,addScalar:d,divideScalar:f,multiplyScalar:p,subtractScalar:m,complex:h}=e;return mE(t(lU,{DenseMatrix:function(e){return _(e)},SparseMatrix:function(e){return v(e)},Array:function(e){var t=_(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t=e._size[0],n=e._size[1],h=i([t],`dense`),g=h._data,_=e.clone(),v=_._data,y,b,x,S=r([t],``);for(x=0;x0)for(var r=n[0][0].type===`Complex`?h(0):0,i=0;i=0;){var c=n[o+s],l=n[r+c];l===-1?(s--,a[t++]=c):(n[r+c]=n[i+l],++s,n[o+s]=l)}return t}function pU(e,t){if(!e)return null;var n=0,r,i=[],a=[],o=0,s=t,c=2*t;for(r=0;r=0;r--)e[r]!==-1&&(a[s+r]=a[o+e[r]],a[o+e[r]]=r);for(r=0;r{var{add:t,multiply:n,transpose:r}=e;return function(e,t){if(!t||e<=0||e>3)return null;var n=t._size,r=n[0],l=n[1],u=0,d=Math.max(16,10*Math.sqrt(l));d=Math.min(l-2,d);var f=i(e,t,r,l,d);hU(f,c,null);for(var p=f._index,m=f._ptr,h=m[l],g=[],_=[],v=0,y=l+1,b=2*(l+1),x=3*(l+1),S=4*(l+1),C=5*(l+1),w=6*(l+1),T=7*(l+1),E=g,D=a(l,m,_,v,x,E,b,T,y,w,S,C),O=o(l,m,_,C,S,w,d,y,x,E,b),k=0,A,j,M,N,ee,te,ne,re,P,F,I,L,ie,ae,R,z;Ooe?(te=M,ne=le,re=_[v+M]-oe):(te=p[le++],ne=m[te],re=_[v+te]),ee=1;ee<=re;ee++)A=p[ne++],!((P=_[y+A])<=0)&&(ce+=P,_[y+A]=-P,p[de++]=A,_[b+A]!==-1&&(E[_[b+A]]=E[A]),E[A]===-1?_[x+_[C+A]]=_[b+A]:_[b+E[A]]=_[b+A]);te!==M&&(m[te]=gU(M),_[w+te]=0)}for(oe!==0&&(h=de),_[C+M]=ce,m[M]=ue,_[v+M]=de-ue,_[S+M]=-2,D=s(D,u,_,w,l),F=ue;F=D?_[w+te]-=P:_[w+te]!==0&&(_[w+te]=_[C+te]+fe)}for(F=ue;F0?(z+=pe,p[ae++]=te,R+=te):(m[te]=gU(M),_[w+te]=0)}_[S+A]=ae-L+1;var me=ae,B=L+_[v+A];for(le=ie+1;le=0))for(R=E[A],A=_[T+R],_[T+R]=-1;A!==-1&&_[b+A]!==-1;A=_[b+A],D++){for(re=_[v+A],I=_[S+A],le=m[A]+1;le<=m[A]+re-1;le++)_[w+p[le]]=D;var ge=A;for(j=_[b+A];j!==-1;){var _e=_[v+j]===re&&_[S+j]===I;for(le=m[j]+1;_e&&le<=m[j]+re-1;le++)_[w+p[le]]!==D&&(_e=0);_e?(m[j]=gU(A),_[y+A]+=_[y+j],_[y+j]=0,_[S+j]=-1,j=_[b+j],_[b+ge]=j):(ge=j,j=_[b+j])}}for(le=ue,F=ue;F=0;j--)_[y+j]>0||(_[b+j]=_[x+m[j]],_[x+m[j]]=j);for(te=l;te>=0;te--)_[y+te]<=0||m[te]!==-1&&(_[b+te]=_[x+m[te]],_[x+m[te]]=te);for(M=0,A=0;A<=l;A++)m[A]===-1&&(M=fU(A,M,_,x,b,g,w));return g.splice(g.length-1,1),g};function i(e,i,a,o,s){var c=r(i);if(e===1&&o===a)return t(i,c);if(e===2){for(var l=c._index,u=c._ptr,d=0,f=0;fs))for(var m=u[f+1];po)n[s+f]=0,n[i+f]=-1,d++,t[f]=gU(e),n[s+e]++;else{var m=n[c+p];m!==-1&&(l[m]=f),n[u+f]=n[c+p],n[c+p]=f}}return d}function s(e,t,n,r,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,n,r,i){if(!e||!n||!r)return null;var a=e._size,o=a[0],s=a[1],c,l,u,d,f,p,m,h=4*s+(i?s+o+1:0),g=[],_=0,v=s,y=2*s,b=3*s,x=4*s,S=5*s+1;for(u=0;u=1&&C[l]++,D.jleaf===2&&C[D.q]--}n[l]!==-1&&(g[_+l]=n[l])}for(l=0;l{var{add:t,multiply:n,transpose:r}=e,i=_U({add:t,multiply:n,transpose:r}),a=yU({transpose:r});return function(e,t,n){var r=t._ptr,s=t._size[1],c,l={};if(l.q=i(e,t),e&&!l.q)return null;if(n){var u=e?dU(t,null,l.q,0):t;l.parent=mU(u,1);var d=pU(l.parent,s);if(l.cp=a(u,l.parent,d,1),u&&l.parent&&l.cp&&o(u,l))for(l.unz=0,c=0;c=0;g--)for(v=n[g],y=n[g+1],_=v;_=0;h--)c[h]=-1,g=l[h],g!==-1&&(u[m+g]++===0&&(u[p+g]=h),u[d+h]=u[f+g],u[f+g]=h);for(t.lnz=0,t.m2=a,g=0;g=0;){e=r[d];var f=i?i[e]:e;xU(o,e)||(SU(o,e),r[s+d]=f<0?0:CU(o[f]));var p=1;for(l=r[s+d],u=f<0?0:CU(o[f+1]);l{var{divideScalar:t,multiply:n,subtract:r}=e;return function(e,i,a,o,s,c,l){var u=e._values,d=e._index,f=e._ptr,p=e._size[1],m=i._values,h=i._index,g=i._ptr,_,v,y,b,x=TU(e,i,a,o,c);for(_=x;_{var{abs:t,divideScalar:n,multiply:r,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,c=EU({divideScalar:n,multiply:r,subtract:i});return function(e,i,l){if(!e)return null;var u=e._size[1],d,f=100,p=100;i&&(d=i.q,f=i.lnz||f,p=i.unz||p);var m=[],h=[],g=[],_=new s({values:m,index:h,ptr:g,size:[u,u]}),v=[],y=[],b=[],x=new s({values:v,index:y,ptr:b,size:[u,u]}),S=[],C,w,T=[],E=[];for(C=0;C{var{typed:t,abs:n,add:r,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:c,largerEq:l,SparseMatrix:u}=e,d=bU({add:r,multiply:i,transpose:a}),f=DU({abs:n,divideScalar:o,multiply:i,subtract:s,larger:c,largerEq:l,SparseMatrix:u});return t(OU,{"SparseMatrix, number, number":function(e,t,n){if(!HD(t)||t<0||t>3)throw Error(`Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]`);if(n<0||n>1)throw Error(`Partial pivoting threshold must be a number from 0 to 1`);var r=d(t,e,!1),i=f(e,r,n);return{L:i.L,U:i.U,p:i.pinv,q:r.q,toString:function(){return`L: `+this.L.toString()+` U: `+this.U.toString()+` p: `+this.p.toString()+(this.q?` q: `+this.q.toString():``)+` `}}}})});function AU(e,t){var n,r=t.length,i=[];if(e)for(n=0;n{var{typed:t,matrix:n,lup:r,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,c=az({DenseMatrix:s});return t(jU,{"Array, Array | Matrix":function(e,t){e=n(e);var i=r(e);return u(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return u(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return u(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var a=i(e,n,r);return u(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return u(e.L,e.U,e.p,e.q,t)}});function l(e){if(zE(e))return e;if(RE(e))return n(e);throw TypeError(`Invalid Matrix LU decomposition`)}function u(e,t,n,r,i){e=l(e),t=l(t),n&&(i=c(e,i,!0),i._data=AU(n,i._data));var s=o(e,i),u=a(t,s);return r&&(u._data=AU(r,u._data)),u}}),NU=`polynomialRoot`,PU=Z(NU,[`typed`,`isZero`,`equalScalar`,`add`,`subtract`,`multiply`,`divide`,`sqrt`,`unaryMinus`,`cbrt`,`typeOf`,`im`,`re`],e=>{var{typed:t,isZero:n,equalScalar:r,add:i,subtract:a,multiply:o,divide:s,sqrt:c,unaryMinus:l,cbrt:u,typeOf:d,im:f,re:p}=e;return t(NU,{"number|Complex, ...number|Complex":(e,t)=>{for(var m=[e,...t];m.length>0&&n(m[m.length-1]);)m.pop();if(m.length<2)throw RangeError(`Polynomial [${e}, ${t}] must have a non-zero non-constant coefficient`);switch(m.length){case 2:return[l(s(m[0],m[1]))];case 3:var[h,g,_]=m,v=o(2,_),y=o(g,g),b=o(4,_,h);if(r(y,b))return[s(l(g),v)];var x=c(a(y,b));return[s(a(x,g),v),s(a(l(x),g),v)];case 4:var[S,C,w,T]=m,E=l(o(3,T)),D=o(w,w),O=o(3,T,C),k=i(o(2,w,w,w),o(27,T,T,S)),A=o(9,T,w,C);if(r(D,O)&&r(k,A))return[s(w,E)];var j=a(D,O),M=a(k,A);return r(i(o(18,T,w,C,S),o(w,w,C,C)),i(o(4,w,w,w,S),o(4,T,C,C,C),o(27,T,T,S,S)))?[s(a(o(4,T,w,C),i(o(9,T,T,S),o(w,w,w))),o(T,j)),s(a(o(9,T,S),o(w,C)),o(2,j))]:u(r(D,O)?M:s(i(M,c(a(o(M,M),o(4,j,j,j)))),2),!0).toArray().map(e=>s(i(w,e,s(j,e)),E)).map(e=>d(e)===`Complex`&&r(p(e),p(e)+f(e))?p(e):e);default:throw RangeError(`only implemented for cubic or lower-order polynomials, not ${m}`)}}})}),FU=Z(`Help`,[`evaluate`],e=>{var{evaluate:t}=e;function n(e){if(!(this instanceof n))throw SyntaxError(`Constructor must be called with the new operator`);if(!e)throw Error(`Argument "doc" missing`);this.doc=e}return n.prototype.type=`Help`,n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},n=` `;if(e.name&&(n+=`Name: `+e.name+` `),e.category&&(n+=`Category: `+e.category+` `),e.description&&(n+=`Description: `+e.description+` `),e.syntax&&(n+=`Syntax: `+e.syntax.join(` `)+` `),e.examples){n+=`Examples: `;for(var r=!1,i=t(`config()`),a={config:e=>(r=!0,t(`config(newConfig)`,{newConfig:e}))},o=0;oe!==`mathjs`).forEach(n=>{t[n]=e[n]}),new n(t)},n.prototype.valueOf=n.prototype.toString,n},{isClass:!0}),IU=Z(`Chain`,[`?on`,`math`,`typed`],e=>{var{on:t,math:n,typed:r}=e;function i(e){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);bD(e)?this.value=e.value:this.value=e}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 $A(this.value)},i.prototype.toJSON=function(){return{mathjs:`Chain`,value:this.value}},i.fromJSON=function(e){return new i(e.value)};function a(e,t){typeof t==`function`&&(i.prototype[e]=s(t))}function o(e,t){kD(i.prototype,e,function(){var e=t();if(typeof e==`function`)return s(e)})}function s(e){return function(){if(arguments.length===0)return new i(e(this.value));for(var t=[this.value],n=0;ne[t])};for(var r in e)n(r)}};var c={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return i.createProxy(n),t&&t(`import`,function(e,t,n){n||o(e,t)}),i},{isClass:!0}),LU={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`]},RU={name:`false`,category:`Constants`,syntax:[`false`],description:`Boolean value false`,examples:[`false`],seealso:[`true`]},zU={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:[]},BU={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:[]},VU={name:`LN10`,category:`Constants`,syntax:[`LN10`],description:`Returns the natural logarithm of 10, approximately equal to 2.302`,examples:[`LN10`,`log(10)`],seealso:[]},HU={name:`LN2`,category:`Constants`,syntax:[`LN2`],description:`Returns the natural logarithm of 2, approximately equal to 0.693`,examples:[`LN2`,`log(2)`],seealso:[]},UU={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:[]},WU={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:[]},GU={name:`NaN`,category:`Constants`,syntax:[`NaN`],description:`Not a number`,examples:[`NaN`,`0 / 0`],seealso:[]},KU={name:`null`,category:`Constants`,syntax:[`null`],description:`Value null`,examples:[`null`],seealso:[`true`,`false`]},qU={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:[]},JU={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`]},YU={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:LU,E:LU,false:RU,i:zU,Infinity:BU,LN2:HU,LN10:VU,LOG2E:WU,LOG10E:UU,NaN:GU,null:KU,pi:JU,PI:JU,phi:qU,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`]},num:{name:`num`,category:`Fraction`,syntax:[`num(x)`],description:`Get the numerator of a fraction.`,examples:[`num(fraction(2, 3))`,`num(fraction(5, 8))`],seealso:[`den`,`fraction`]},den:{name:`den`,category:`Fraction`,syntax:[`den(x)`],description:`Get the denominator of a fraction.`,examples:[`den(fraction(2, 3))`,`den(fraction(5, 8))`],seealso:[`num`,`fraction`]},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:"The 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`,`bernoulli`]},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`]},bernoulli:{name:`bernoulli`,category:`Probability`,syntax:[`bernoulli(n)`],description:`The nth Bernoulli number`,examples:[`bernoulli(4)`,`bernoulli(fraction(12))`],seealso:[`combinations`,`gamma`,`stirlingS2`]},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. In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:[`quantileSeq([3, -1, 5, 7], 0.5)`,`quantileSeq([3, -1, 5, 7], [1/3, 2/3])`,`quantileSeq([3, -1, 5, 7], 2)`,`quantileSeq([-1, 3, 5, 7], 0.5, true)`],seealso:[`mean`,`median`,`min`,`max`,`prod`,`std`,`sum`,`variance`]},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`,`isFinite`,`isBounded`]},isBounded:{name:`isBounded`,category:`Utils`,syntax:[`isBounded(x)`],description:`Test whether a value or its entries are bounded.`,examples:[`isBounded(Infinity)`,`isBounded(bigint(3))`,`isBounded([3, -Infinity, -3])`],seealso:[`isFinite`,`isNumeric`,`isNaN`,`isNegative`,`isPositive`]},isFinite:{name:`isFinite`,category:`Utils`,syntax:[`isFinite(x)`],description:`Test whether a value is finite, elementwise on collections.`,examples:[`isFinite(Infinity)`,`isFinite(bigint(3))`,`isFinite([3, -Infinity, -3])`],seealso:[`isBounded`,`isNumeric`,`isNaN`,`isNegative`,`isPositive`]},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`,`isFinite`,`isBounded`]},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`]}},XU=`help`,ZU=Z(XU,[`typed`,`mathWithTransform`,`Help`],e=>{var{typed:t,mathWithTransform:n,Help:r}=e;return t(XU,{any:function(e){var t,i=e;if(typeof e!=`string`){for(t in n)if(AD(n,t)&&e===n[t]){i=t;break}}var a=gE(YU,i);if(!a){var o=typeof i==`function`?i.name:i;throw Error(`No documentation found on "`+o+`"`)}return new r(a)}})}),QU=`chain`,$U=Z(QU,[`typed`,`Chain`],e=>{var{typed:t,Chain:n}=e;return t(QU,{"":function(){return new n},any:function(e){return new n(e)}})}),eW=`det`,tW=Z(eW,[`typed`,`matrix`,`subtractScalar`,`multiply`,`divideScalar`,`isZero`,`unaryMinus`],e=>{var{typed:t,matrix:n,subtractScalar:r,multiply:i,divideScalar:a,isZero:o,unaryMinus:s}=e;return t(eW,{any:function(e){return SD(e)},"Array | Matrix":function(e){var t;switch(zE(e)?t=e.size():Array.isArray(e)?(e=n(e),t=e.size()):t=[],t.length){case 0:return SD(e);case 1:if(t[0]===1)return SD(e.valueOf()[0]);if(t[0]===0)return 1;throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);case 2:var r=t[0],i=t[1];if(r===i)return c(e.clone().valueOf(),r,i);if(i===0)return 1;throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+$A(t)+`)`)}}});function c(e,t,n){if(t===1)return SD(e[0][0]);if(t===2)return r(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var c=!1,l=Array(t).fill(0).map((e,t)=>t),u=0;u{var{typed:t,matrix:n,divideScalar:r,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:c,abs:l}=e;return t(nW,{"Array | Matrix":function(e){var t=zE(e)?e.size():lj(e);switch(t.length){case 1:if(t[0]===1)return zE(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);case 2:var i=t[0],a=t[1];if(i===a)return zE(e)?n(u(e.valueOf(),i,a),e.storage()):u(e,i,a);throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+$A(t)+`)`)}},any:function(e){return r(1,e)}});function u(e,t,n){var u,d,f,p,m;if(t===1){if(p=e[0][0],p===0)throw Error(`Cannot calculate inverse, determinant is zero`);return[[r(1,p)]]}else if(t===2){var h=s(e);if(h===0)throw Error(`Cannot calculate inverse, determinant is zero`);return[[r(e[1][1],h),r(o(e[0][1]),h)],[r(o(e[1][0]),h),r(e[0][0],h)]]}else{var g=e.concat();for(u=0;uy&&(y=l(g[u][v]),b=u),u++;if(y===0)throw Error(`Cannot calculate inverse, determinant is zero`);u=b,u!==v&&(m=g[v],g[v]=g[u],g[u]=m,m=_[v],_[v]=_[u],_[u]=m);var x=g[v],S=_[v];for(u=0;u{var{typed:t,matrix:n,inv:r,deepEqual:i,equal:a,dotDivide:o,dot:s,ctranspose:c,divideScalar:l,multiply:u,add:d,Complex:f}=e;return t(iW,{"Array | Matrix":function(e){var t=zE(e)?e.size():lj(e);switch(t.length){case 1:return _(e)?c(e):t[0]===1?r(e):o(c(e),s(e,e));case 2:if(_(e))return c(e);var i=t[0],a=t[1];if(i===a)try{return r(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return zE(e)?n(p(e.valueOf(),i,a),e.storage()):p(e,i,a);default:throw RangeError(`Matrix must be two dimensional (size: `+$A(t)+`)`)}},any:function(e){return a(e,0)?SD(e):l(1,e)}});function p(e,t,n){var{C:i,F:a}=h(e,t,n),o=u(r(u(c(i),i)),c(i));return u(u(c(a),r(u(a,c(a)))),o)}function m(e,t,n){for(var r=SD(e),i=0,a=0;ae.filter((e,n)=>n!g(s(r[t],r[t])))}}function g(e){return a(d(e,f(1,1)),d(0,f(1,1)))}function _(e){return i(d(e,f(1,1)),d(u(e,0),f(1,1)))}});function oW(e){var{addScalar:t,subtract:n,flatten:r,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:c,bignumber:l,diag:u,size:d,reshape:f,inv:p,qr:m,usolve:h,usolveAll:g,equal:_,complex:v,larger:y,smaller:b,matrixFromColumns:x,dot:S}=e;function C(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=w(e,t,n,r,i);T(e,t,n,r,i,a);var{values:o,C:s}=E(e,t,n,r,i);return i?{values:o,eigenvectors:D(e,t,s,a,o,n,r)}:{values:o}}function w(e,n,r,i,s){var d=i===`BigNumber`,f=i===`Complex`,p=d?l(0):0,m=d?l(1):f?v(1):1,h=d?l(1):1,g=d?l(10):2,x=a(g,g),S;s&&(S=Array(n).fill(m));for(var C=!1;!C;){C=!0;for(var w=0;w1&&(x=u(Array(g-1).fill(f)))),--g,p.pop();for(var M=0;M2&&(x=u(Array(g-2).fill(f)))),g-=2,p.pop(),p.pop();for(var ee=0;ee+n(c(e),c(t))),S>100){var te=Error(`The eigenvalues failed to converge. Only found these eigenvalues: `+h.join(`, `));throw te.values=h,te.vectors=[],te}return{values:h,C:s?i(y,j(_,r)):void 0}}function D(e,t,a,o,s,c,d){var f=i(p(a),e,a),m=d===`BigNumber`,h=d===`Complex`,y=m?l(0):h?v(0):0,b=m?l(1):h?v(1):1,x=[],S=[];for(var C of s){var w=M(x,C,_);w===-1?(x.push(C),S.push(1)):S[w]+=1}for(var T=[],E=x.length,D=Array(t).fill(y),O=u(Array(t).fill(b)),k=function(){var e=x[A],s=n(f,i(e,O)),l=g(s,D);for(l.shift();l.lengthi(m,e)),T.push(...l.map(t=>({value:e,vector:r(t)})))},A=0;A=5)return null;for(s=0;;){var c=h(e,o);if(b(ne(te(o,[c])),r))break;if(++s>=10)return null;o=re(c)}return o}function ee(e,t,n){var r=n===`BigNumber`,i=n===`Complex`,a=Array(e).fill(0).map(e=>2*Math.random()-1);return r&&(a=a.map(e=>l(e))),i&&(a=a.map(e=>v(e))),a=te(a,t),re(a,n)}function te(e,t){var r=d(e);for(var a of t)a=f(a,r),e=n(e,i(o(S(a,e),S(a,a)),a));return e}function ne(e){return c(s(S(e,e)))}function re(e,t){return i(o(t===`BigNumber`?l(1):t===`Complex`?v(1):1,ne(e)),e)}return C}function sW(e){var{config:t,addScalar:n,subtract:r,abs:i,atan:a,cos:o,sin:s,multiplyScalar:c,inv:l,bignumber:u,multiply:d,add:f}=e;function p(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.relTol,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(i===`number`)return m(e,r,a);if(i===`BigNumber`)return h(e,r,a);throw TypeError(`Unsupported data type: `+i)}function m(e,t,n){var r=e.length,i=Math.abs(t/r),a,o;if(n){o=Array(r);for(var s=0;s=Math.abs(i);){var l=c[0][0],u=c[0][1];a=g(e[l][l],e[u][u],e[l][u]),e=x(e,a,l,u),n&&(o=v(o,a,l,u)),c=S(e)}for(var d=Array(r).fill(0),f=0;f=i(a);){var u=l[0][0],d=l[0][1];o=_(e[u][u],e[d][d],e[u][d]),e=b(e,o,u,d),n&&(s=y(s,o,u,d)),l=C(e)}for(var f=Array(r).fill(0),p=0;p({value:a[t],vector:e}))}:{values:a}}return p}var cW=Z(`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`.split(`.`),e=>{var{config:t,typed:n,matrix:r,addScalar:i,subtract:a,equal:o,abs:s,atan:c,cos:l,sin:u,multiplyScalar:d,divideScalar:f,inv:p,bignumber:m,multiply:h,add:g,larger:_,column:v,flatten:y,number:b,complex:x,sqrt:S,diag:C,size:w,reshape:T,qr:E,usolve:D,usolveAll:O,im:k,re:A,smaller:j,matrixFromColumns:M,dot:N}=e,ee=sW({config:t,addScalar:i,subtract:a,column:v,flatten:y,equal:o,abs:s,atan:c,cos:l,sin:u,multiplyScalar:d,inv:p,bignumber:m,complex:x,multiply:h,add:g}),te=oW({config:t,addScalar:i,subtract:a,multiply:h,multiplyScalar:d,flatten:y,divideScalar:f,sqrt:S,abs:s,bignumber:m,diag:C,size:w,reshape:T,qr:E,inv:p,usolve:D,usolveAll:O,equal:o,complex:x,larger:_,smaller:j,matrixFromColumns:M,dot:N});return n(`eigs`,{Array:function(e){return ne(r(e))},"Array, number|BigNumber":function(e,t){return ne(r(e),{precision:t})},"Array, Object"(e,t){return ne(r(e),t)},Matrix:function(e){return ne(e,{matricize:!0})},"Matrix, number|BigNumber":function(e,t){return ne(e,{precision:t,matricize:!0})},"Matrix, Object":function(e,t){var n={matricize:!0};return mE(n,t),ne(e,n)}});function ne(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=`eigenvectors`in n?n.eigenvectors:!0,a=re(e,n.precision??t.relTol,i);return n.matricize&&(a.values=r(a.values),i&&(a.eigenvectors=a.eigenvectors.map(e=>{var{value:t,vector:n}=e;return{value:t,vector:r(n)}}))),i&&Object.defineProperty(a,"vectors",{enumerable:!1,get:()=>{throw Error(`eigs(M).vectors replaced with eigs(M).eigenvectors`)}}),a}function re(e,t,n){var r=e.toArray(),i=e.size();if(i.length!==2||i[0]!==i[1])throw RangeError(`Matrix must be square (size: ${$A(i)})`);var a=i[0];return F(r,a,t)&&(I(r,a),P(r,a,t))?ee(r,a,t,L(e,r,a),n):te(r,a,t,L(e,r,a),n)}function P(e,t,n){for(var r=0;r{var{typed:t,abs:n,add:r,identity:i,inv:a,multiply:o}=e;return t(lW,{Matrix:function(e){var t=e.size();if(t.length!==2||t[0]!==t[1])throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);for(var n=t[0],l=c(s(e),1e-15),u=l.q,d=l.j,f=o(e,2**-d),p=i(n),m=i(n),h=1,g=f,_=-1,v=1;v<=u;v++)v>1&&(g=o(g,f),_=-_),h=h*(u-v+1)/((2*u-v+1)*v),p=r(p,o(h,g)),m=r(m,o(h*_,g));for(var y=o(a(m),p),b=0;b{var{typed:t,abs:n,add:r,multiply:i,map:a,sqrt:o,subtract:s,inv:c,size:l,max:u,identity:d}=e,f=1e3,p=1e-6;function m(e){var t,a=0,o=e,m=d(l(e));do{var h=o;if(o=i(.5,r(h,c(m))),m=i(.5,r(m,c(h))),t=u(n(s(o,h))),t>p&&++a>f)throw Error(`computing square root of matrix: iterative method could not converge`)}while(t>p);return o}return t(dW,{"Array | Matrix":function(e){var t=zE(e)?e.size():lj(e);switch(t.length){case 1:if(t[0]===1)return a(e,o);throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);case 2:if(t[0]===t[1])return m(e);throw RangeError(`Matrix must be square (size: `+$A(t)+`)`);default:throw RangeError(`Matrix must be at most two dimensional (size: `+$A(t)+`)`)}}})}),pW=`sylvester`,mW=Z(pW,[`typed`,`schur`,`matrixFromColumns`,`matrix`,`multiply`,`range`,`concat`,`transpose`,`index`,`subset`,`add`,`subtract`,`identity`,`lusolve`,`abs`],e=>{var{typed:t,schur:n,matrixFromColumns:r,matrix:i,multiply:a,range:o,concat:s,transpose:c,index:l,subset:u,add:d,subtract:f,identity:p,lusolve:m,abs:h,config:g}=e;return t(pW,{"Matrix, Matrix, Matrix":_,"Array, Matrix, Matrix":function(e,t,n){return _(i(e),t,n)},"Array, Array, Matrix":function(e,t,n){return _(i(e),i(t),n)},"Array, Matrix, Array":function(e,t,n){return _(i(e),t,i(n))},"Matrix, Array, Matrix":function(e,t,n){return _(e,i(t),n)},"Matrix, Array, Array":function(e,t,n){return _(e,i(t),i(n))},"Matrix, Matrix, Array":function(e,t,n){return _(e,t,i(n))},"Array, Array, Array":function(e,t,n){return _(i(e),i(t),i(n)).toArray()}});function _(e,t,g){for(var _=t.size()[0],v=e.size()[0],y=n(e),b=y.T,x=y.U,S=n(a(-1,t)),C=S.T,w=S.U,T=a(a(c(x),g),w),E=o(0,v),D=[],O=(e,t)=>s(e,t,1),k=(e,t)=>s(e,t,0),A=0;A<_;A++)if(A<_-1&&h(u(C,l(A+1,A)))>1e-5){for(var j=k(u(T,l(E,[A])),u(T,l(E,[A+1]))),M=0;M{var{typed:t,matrix:n,identity:r,multiply:i,qr:a,norm:o,subtract:s}=e;return t(hW,{Array:function(e){var t=c(n(e));return{U:t.U.valueOf(),T:t.T.valueOf()}},Matrix:function(e){return c(e)}});function c(e){var t=e.size()[0],n=e,c=r(t),l=0,u;do{u=n;var d=a(n),f=d.Q,p=d.R;if(n=i(p,f),c=i(c,f),l++>100)break}while(o(s(n,u))>1e-4);return{U:c,T:n}}}),_W=`lyap`,vW=Z(_W,[`typed`,`matrix`,`sylvester`,`multiply`,`transpose`],e=>{var{typed:t,matrix:n,sylvester:r,multiply:i,transpose:a}=e;return t(_W,{"Matrix, Matrix":function(e,t){return r(e,a(e),i(-1,t))},"Array, Matrix":function(e,t){return r(n(e),a(n(e)),i(-1,t))},"Matrix, Array":function(e,t){return r(e,a(n(e)),n(i(-1,t)))},"Array, Array":function(e,t){return r(n(e),a(n(e)),n(i(-1,t))).toArray()}})}),yW=Z(`divide`,[`typed`,`matrix`,`multiply`,`equalScalar`,`divideScalar`,`inv`],e=>{var{typed:t,matrix:n,multiply:r,equalScalar:i,divideScalar:a,inv:o}=e,s=ZP({typed:t,equalScalar:i}),c=$P({typed:t});return t(`divide`,wD({"Array | Matrix, Array | Matrix":function(e,t){return r(e,o(t))},"DenseMatrix, any":function(e,t){return c(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return c(n(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,o(t))}},a.signatures))}),bW=`distance`,xW=Z(bW,[`typed`,`addScalar`,`subtractScalar`,`divideScalar`,`multiplyScalar`,`deepEqual`,`sqrt`,`abs`],e=>{var{typed:t,addScalar:n,subtractScalar:r,multiplyScalar:i,divideScalar:a,deepEqual:o,sqrt:s,abs:c}=e;return t(bW,{"Array, Array, Array":function(e,t,n){if(e.length===2&&t.length===2&&n.length===2){if(!u(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!u(t))throw TypeError(`Array with 2 numbers or BigNumbers expected for second argument`);if(!u(n))throw TypeError(`Array with 2 numbers or BigNumbers expected for third argument`);if(o(t,n))throw TypeError(`LinePoint1 should not be same with LinePoint2`);var a=r(n[1],t[1]),s=r(t[0],n[0]),c=r(i(n[0],t[1]),i(t[0],n[1]));return g(e[0],e[1],a,s,c)}else throw TypeError(`Invalid Arguments: Try again`)},"Object, Object, Object":function(e,t,n){if(Object.keys(e).length===2&&Object.keys(t).length===2&&Object.keys(n).length===2){if(!u(e))throw TypeError(`Values of pointX and pointY should be numbers or BigNumbers`);if(!u(t))throw TypeError(`Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers`);if(!u(n))throw TypeError(`Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers`);if(o(m(t),m(n)))throw TypeError(`LinePoint1 should not be same with LinePoint2`);if(`pointX`in e&&`pointY`in e&&`lineOnePtX`in t&&`lineOnePtY`in t&&`lineTwoPtX`in n&&`lineTwoPtY`in n){var a=r(n.lineTwoPtY,t.lineOnePtY),s=r(t.lineOnePtX,n.lineTwoPtX),c=r(i(n.lineTwoPtX,t.lineOnePtY),i(t.lineOnePtX,n.lineTwoPtY));return g(e.pointX,e.pointY,a,s,c)}else throw TypeError(`Key names do not match`)}else throw TypeError(`Invalid Arguments: Try again`)},"Array, Array":function(e,t){if(e.length===2&&t.length===3){if(!u(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!d(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);return g(e[0],e[1],t[0],t[1],t[2])}else if(e.length===3&&t.length===6){if(!d(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!p(t))throw TypeError(`Array with 6 numbers or BigNumbers expected for second argument`);return _(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}else if(e.length===t.length&&e.length>0){if(!f(e)||!f(t))throw TypeError(`All values of an array should be numbers or BigNumbers`);return v(e,t)}else throw TypeError(`Invalid Arguments: Try again`)},"Object, Object":function(e,t){if(Object.keys(e).length===2&&Object.keys(t).length===3){if(!u(e))throw TypeError(`Values of pointX and pointY should be numbers or BigNumbers`);if(!d(t))throw 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 g(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===3&&Object.keys(t).length===6){if(!d(e))throw TypeError(`Values of pointX, pointY and pointZ should be numbers or BigNumbers`);if(!p(t))throw 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 _(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===2&&Object.keys(t).length===2){if(!u(e))throw TypeError(`Values of pointOneX and pointOneY should be numbers or BigNumbers`);if(!u(t))throw 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 v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===3&&Object.keys(t).length===3){if(!d(e))throw TypeError(`Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers`);if(!d(t))throw 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 v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw TypeError(`Key names do not match`)}else throw TypeError(`Invalid Arguments: Try again`)},Array:function(e){if(!h(e))throw TypeError(`Incorrect array format entered for pairwise distance calculation`);return y(e)}});function l(e){return typeof e==`number`||ME(e)}function u(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])}function d(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])&&l(e[2])}function f(e){return Array.isArray(e)||(e=m(e)),e.every(l)}function p(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])&&l(e[2])&&l(e[3])&&l(e[4])&&l(e[5])}function m(e){for(var t=Object.keys(e),n=[],r=0;re.length!==2||!l(e[0])||!l(e[1])))return!1}else if(e[0].length===3&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])){if(e.some(e=>e.length!==3||!l(e[0])||!l(e[1])||!l(e[2])))return!1}else return!1;return!0}function g(e,t,r,o,l){return a(c(n(n(i(r,e),i(o,t)),l)),s(n(i(r,r),i(o,o))))}function _(e,t,o,c,l,u,d,f,p){var m=[r(i(r(l,t),p),i(r(u,o),f)),r(i(r(u,o),d),i(r(c,e),p)),r(i(r(c,e),f),i(r(l,t),d))];m=s(n(n(i(m[0],m[0]),i(m[1],m[1])),i(m[2],m[2])));var h=s(n(n(i(d,d),i(f,f)),i(p,p)));return a(m,h)}function v(e,t){for(var a=e.length,o=0,c=0,l=0;l{var{typed:t,config:n,abs:r,add:i,addScalar:a,matrix:o,multiply:s,multiplyScalar:c,divideScalar:l,subtract:u,smaller:d,equalScalar:f,flatten:p,isZero:m,isNumeric:h}=e;return t(`intersect`,{"Array, Array, Array":g,"Array, Array, Array, Array":_,"Matrix, Matrix, Matrix":function(e,t,n){var r=g(e.valueOf(),t.valueOf(),n.valueOf());return r===null?null:o(r)},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){var i=_(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf());return i===null?null:o(i)}});function g(e,t,n){if(e=v(e),t=v(t),n=v(n),!b(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!b(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);if(!x(n))throw TypeError(`Array with 4 numbers expected as third argument`);return T(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])}function _(e,t,n,r){if(e=v(e),t=v(t),n=v(n),r=v(r),e.length===2){if(!y(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!y(t))throw TypeError(`Array with 2 numbers or BigNumbers expected for second argument`);if(!y(n))throw TypeError(`Array with 2 numbers or BigNumbers expected for third argument`);if(!y(r))throw TypeError(`Array with 2 numbers or BigNumbers expected for fourth argument`);return S(e,t,n,r)}else if(e.length===3){if(!b(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!b(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);if(!b(n))throw TypeError(`Array with 3 numbers or BigNumbers expected for third argument`);if(!b(r))throw TypeError(`Array with 3 numbers or BigNumbers expected for fourth argument`);return w(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],r[0],r[1],r[2])}else throw TypeError(`Arrays with two or thee dimensional points expected`)}function v(e){return e.length===1?e[0]:e.length>1&&Array.isArray(e[0])&&e.every(e=>Array.isArray(e)&&e.length===1)?p(e):e}function y(e){return e.length===2&&h(e[0])&&h(e[1])}function b(e){return e.length===3&&h(e[0])&&h(e[1])&&h(e[2])}function x(e){return e.length===4&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}function S(e,t,o,f){var p=e,h=o,g=u(p,t),_=u(h,f),v=u(c(g[0],_[1]),c(_[0],g[1]));if(m(v)||d(r(v),n.relTol))return null;var y=c(_[0],p[1]),b=c(_[1],p[0]),x=c(_[0],h[1]),S=c(_[1],h[0]);return i(s(g,l(a(u(u(y,b),x),S),v)),p)}function C(e,t,n,r,i,o,s,l,d,f,p,m){var h=c(u(e,t),u(n,r)),g=c(u(i,o),u(s,l)),_=c(u(d,f),u(p,m));return a(a(h,g),_)}function w(e,t,n,r,i,o,s,d,p,h,g,_){var v=C(e,s,h,s,t,d,g,d,n,p,_,p),y=C(h,s,r,e,g,d,i,t,_,p,o,n),b=C(e,s,r,e,t,d,i,t,n,p,o,n),x=C(h,s,h,s,g,d,g,d,_,p,_,p),S=C(r,e,r,e,i,t,i,t,o,n,o,n),w=u(c(v,y),c(b,x)),T=u(c(S,x),c(y,y));if(m(T))return null;var E=l(w,T),D=l(a(v,c(E,y)),x),O=a(e,c(E,u(r,e))),k=a(t,c(E,u(i,t))),A=a(n,c(E,u(o,n))),j=a(s,c(D,u(h,s))),M=a(d,c(D,u(g,d))),N=a(p,c(D,u(_,p)));return f(O,j)&&f(k,M)&&f(A,N)?[O,k,A]:null}function T(e,t,n,r,i,o,s,d,f,p){var m=c(e,s),h=c(r,s),g=c(t,d),_=c(i,d),v=c(n,f),y=c(o,f),b=l(u(u(u(p,m),g),v),u(u(u(a(a(h,_),y),m),g),v));return[a(e,c(b,u(r,e))),a(t,c(b,u(i,t))),a(n,c(b,u(o,n)))]}}),CW=`sum`,wW=Z(CW,[`typed`,`config`,`add`,`numeric`],e=>{var{typed:t,config:n,add:r,numeric:i}=e;return t(CW,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":o,"...":function(e){if(eM(e))throw TypeError(`Scalar values expected in function sum`);return a(e)}});function a(e){var t;return tM(e,function(e){try{t=t===void 0?e:r(t,e)}catch(t){throw vR(t,`sum`,e)}}),t===void 0&&(t=i(0,n.number)),typeof t==`string`&&(t=i(t,UD(t,n))),t}function o(e,t){try{return rM(e,t,r)}catch(e){throw vR(e,`sum`)}}}),TW=`cumsum`,EW=Z(TW,[`typed`,`add`,`unaryPlus`],e=>{var{typed:t,add:n,unaryPlus:r}=e;return t(TW,{Array:i,Matrix:function(e){return e.create(i(e.valueOf(),e.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(e,t){return e.create(o(e.valueOf(),t),e.datatype())},"...":function(e){if(eM(e))throw TypeError(`All values expected to be scalar in function cumsum`);return i(e)}});function i(e){try{return a(e)}catch(e){throw vR(e,TW)}}function a(e){if(e.length===0)return[];for(var t=[r(e[0])],i=1;i=n.length)throw new cj(t,n.length);try{return s(e,t)}catch(e){throw vR(e,TW)}}function s(e,t){var n,r,i;if(t<=0){var o=e[0][0];if(Array.isArray(o)){for(i=$j(e),r=[],n=0;n{var{typed:t,add:n,divide:r}=e;return t(DW,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":i,"...":function(e){if(eM(e))throw TypeError(`Scalar values expected in function mean`);return a(e)}});function i(e,t){try{return r(rM(e,t,n),(Array.isArray(e)?lj(e):e.size())[t])}catch(e){throw vR(e,`mean`)}}function a(e){var t,i=0;if(tM(e,function(e){try{t=t===void 0?e:n(t,e),i++}catch(t){throw vR(t,`mean`,e)}}),i===0)throw Error(`Cannot calculate the mean of an empty array`);return r(t,i)}}),kW=`median`,AW=Z(kW,[`typed`,`add`,`divide`,`compare`,`partitionSelect`],e=>{var{typed:t,add:n,divide:r,compare:i,partitionSelect:a}=e;function o(e){try{e=Tj(e.valueOf());var t=e.length;if(t===0)throw Error(`Cannot calculate median of an empty array`);if(t%2==0){for(var n=t/2-1,r=a(e,n+1),o=e[n],l=0;l0&&(o=e[l]);return c(o,r)}else return s(a(e,(t-1)/2))}catch(e){throw vR(e,`median`)}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(kW,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw Error(`median(A, dim) is not yet supported`)},"...":function(e){if(eM(e))throw TypeError(`Scalar values expected in function median`);return o(e)}})}),jW=`mad`,MW=Z(jW,[`typed`,`abs`,`map`,`median`,`subtract`],e=>{var{typed:t,abs:n,map:r,median:i,subtract:a}=e;return t(jW,{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(e=Tj(e.valueOf()),e.length===0)throw Error(`Cannot calculate median absolute deviation (mad) of an empty array`);try{var t=i(e);return i(r(e,function(e){return n(a(e,t))}))}catch(e){throw e instanceof TypeError&&e.message.includes(`median`)?TypeError(e.message.replace(`median`,`mad`)):vR(e,`mad`)}}}),NW=`unbiased`,PW=`variance`,FW=Z(PW,[`typed`,`add`,`subtract`,`multiply`,`divide`,`mapSlices`,`isNaN`],e=>{var{typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s}=e;return t(PW,{"Array | Matrix":function(e){return c(e,NW)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,NW)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,NW)}});function c(e,t){var o,c=0;if(e.length===0)throw SyntaxError(`Function variance requires one or more parameters (0 provided)`);if(tM(e,function(e){try{o=o===void 0?e:n(o,e),c++}catch(t){throw vR(t,`variance`,e)}}),c===0)throw Error(`Cannot calculate variance of an empty array`);var l=a(o,c);if(o=void 0,tM(e,function(e){var t=r(e,l);o=o===void 0?i(t,t):n(o,i(t,t))}),s(o))return o;switch(t){case`uncorrected`:return a(o,c);case`biased`:return a(o,c+1);case`unbiased`:var u=ME(o)?o.mul(0):0;return c===1?u:a(o,c-1);default:throw Error(`Unknown normalization "`+t+`". Choose "unbiased" (default), "uncorrected", or "biased".`)}}function l(e,t,n){try{if(e.length===0)throw SyntaxError(`Function variance requires one or more parameters (0 provided)`);return o(e,t,e=>c(e,n))}catch(e){throw vR(e,`variance`)}}}),IW=`quantileSeq`,LW=Z(IW,[`typed`,`?bignumber`,`add`,`subtract`,`divide`,`multiply`,`partitionSelect`,`compare`,`isInteger`,`smaller`,`smallerEq`,`larger`,`mapSlices`],e=>{var{typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p}=e;return t(IW,{"Array | Matrix, number | BigNumber":(e,t)=>h(e,t,!1),"Array | Matrix, number | BigNumber, number":(e,t,n)=>m(e,t,!1,n,h),"Array | Matrix, number | BigNumber, boolean":h,"Array | Matrix, number | BigNumber, boolean, number":(e,t,n,r)=>m(e,t,n,r,h),"Array | Matrix, Array | Matrix":(e,t)=>g(e,t,!1),"Array | Matrix, Array | Matrix, number":(e,t,n)=>m(e,t,!1,n,g),"Array | Matrix, Array | Matrix, boolean":g,"Array | Matrix, Array | Matrix, boolean, number":(e,t,n,r)=>m(e,t,n,r,g)});function m(e,t,n,r,i){return p(e,r,e=>i(e,t,n))}function h(e,t,i){var o,s=e.valueOf();if(u(t,0))throw Error(`N/prob must be non-negative`);if(d(t,1))return jE(t)?_(s,t,i):n(_(s,t,i));if(f(t,1)){if(!l(t))throw Error(`N must be a positive integer`);if(f(t,4294967295))throw Error(`N must be less than or equal to 2^32-1, as that is the maximum length of an Array`);var c=r(t,1);o=[];for(var p=0;u(p,t);p++){var m=a(p+1,c);o.push(_(s,m,i))}return jE(t)?o:n(o)}}function g(e,t,n){for(var r=e.valueOf(),i=t.valueOf(),a=[],o=0;o0&&(m=a[g])}return r(o(m,i(1,p)),o(h,p))}}),RW=`std`,zW=Z(RW,[`typed`,`map`,`sqrt`,`variance`],e=>{var{typed:t,map:n,sqrt:r,variance:i}=e;return t(RW,{"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(e.length===0)throw SyntaxError(`Function std requires one or more parameters (0 provided)`);try{var a=i.apply(null,arguments);return BE(a)?n(a,r):r(a)}catch(e){throw e instanceof TypeError&&e.message.includes(` variance`)?TypeError(e.message.replace(` variance`,` std`)):e}}}),BW=`corr`,VW=Z(BW,[`typed`,`matrix`,`mean`,`sqrt`,`sum`,`add`,`subtract`,`multiply`,`pow`,`divide`],e=>{var{typed:t,matrix:n,sqrt:r,sum:i,add:a,subtract:o,multiply:s,pow:c,divide:l}=e;return t(BW,{"Array, Array":function(e,t){return u(e,t)},"Matrix, Matrix":function(e,t){var r=u(e.toArray(),t.toArray());return Array.isArray(r)?n(r):r}});function u(e,t){var n=[];if(Array.isArray(e[0])&&Array.isArray(t[0])){if(e.length!==t.length)throw SyntaxError(`Dimension mismatch. Array A and B must have the same length.`);for(var r=0;ra(e,s(n,t[r])),0),p=i(e.map(e=>c(e,2))),m=i(t.map(e=>c(e,2)));return l(o(s(n,f),s(u,d)),r(s(o(s(n,p),c(u,2)),o(s(n,m),c(d,2)))))}}),HW=`bernoulli`,UW=Z(HW,[`typed`,`config`,`isInteger`,`number`,`?BigNumber`,`?Fraction`],e=>{var{typed:t,config:n,number:r,BigNumber:i,Fraction:a}=e,o=[void 0],s=[void 0],c=[void 0],l=50;return t(HW,{number:e=>WW(e,e=>e,o,(e,t)=>e+t,(e,t)=>e*t,(e,t)=>e/t),"bigint | Fraction":e=>WW(r(e),e=>new a(e),s,(e,t)=>e.add(t),(e,t)=>e.mul(t),(e,t)=>e.div(t)),BigNumber:e=>(n.precision!==l&&(c=[void 0],l=n.precision),WW(r(e),e=>new i(e),c,(e,t)=>e.add(t),(e,t)=>e.mul(t),(e,t)=>e.div(t)))})});function WW(e,t,n,r,i,a){if(e<0||!HD(e))throw RangeError(`Bernoulli index must be nonnegative integer`);if(e===0)return t(1);if(e===1)return a(t(-1),t(2));if(e%2==1)return t(0);var o=t(1);n.length===1&&n.push([a(o,t(-3)),a(o,t(-2)),a(o,t(6))]);for(var s=e/2,c=t(0),l=t(2);n.length<=s;){for(var u=n.length,d=Math.floor((u+1)/2),f=c,p=1;p{var{typed:t}=e;return t(GW,{"number, number":KM,"BigNumber, BigNumber":function(e,t){var n=e.constructor,r,i,a=e.minus(t),o=new n(1);if(!qW(e)||!qW(t))throw TypeError(`Positive integer value expected in function combinations`);if(t.gt(e))throw TypeError(`k must be less than n in function combinations`);if(r=o,t.lt(a))for(i=o;i.lte(a);i=i.plus(o))r=r.times(t.plus(i)).dividedBy(i);else for(i=o;i.lte(t);i=i.plus(o))r=r.times(a.plus(i)).dividedBy(i);return r}})});function qW(e){return e.isInteger()&&e.gte(0)}var JW=`combinationsWithRep`,YW=Z(JW,[`typed`],e=>{var{typed:t}=e;return t(JW,{"number, number":function(e,t){if(!HD(e)||e<0||!HD(t)||t<0)throw TypeError(`Positive integer value expected in function combinationsWithRep`);if(e<1)throw TypeError(`k must be less than or equal to n + k - 1`);return t{var{typed:t,config:n,multiplyScalar:r,pow:i,BigNumber:a,Complex:o}=e;function s(e){if(e.im===0)return rN(e.re);if(e.re<.5){var t=new o(1-e.re,-e.im),n=new o(Math.PI*e.re,Math.PI*e.im);return new o(Math.PI).div(n.sin()).div(s(t))}e=new o(e.re-1,e.im);for(var r=new o(aN[0],0),i=1;i2;)i-=2,s+=i,o=o.times(s);return new a(o.toPrecision(a.precision))}}),$W=`lgamma`,eG=Z($W,[`Complex`,`typed`],e=>{var{Complex:t,typed:n}=e,r=7,i=7,a=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n($W,{number:cN,Complex:o,BigNumber:function(){throw Error(`mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber`)}});function o(e){var n=6.283185307179586,a=1.1447298858494002,l=.1;if(e.isNaN())return new t(NaN,NaN);if(e.im===0)return new t(cN(e.re),0);if(e.re>=r||Math.abs(e.im)>=i)return s(e);if(e.re<=l){var u=mO(n,e.im)*Math.floor(.5*e.re+.25),d=e.mul(Math.PI).sin().log(),f=o(new t(1-e.re,-e.im));return new t(a,u).sub(d).sub(f)}else if(e.im>=0)return c(e);else return c(e.conjugate()).conjugate()}function s(e){for(var n=e.sub(.5).mul(e.log()).sub(e).add(oN),r=new t(1,0).div(e),i=r.div(e),o=a[0],s=a[1],c=2*i.re,l=i.re*i.re+i.im*i.im,u=2;u<8;u++){var d=s;s=-l*o+a[u],o=c*o+d}var f=r.mul(i.mul(o).add(s));return n.add(f)}function c(e){var n=0,i=0,a=e;for(e=e.add(1);e.re<=r;){a=a.mul(e);var o=+(a.im<0);o!==0&&i===0&&n++,i=o,e=e.add(1)}return s(e).sub(a.log()).sub(new t(0,n*2*Math.PI*1))}}),tG=`factorial`,nG=Z(tG,[`typed`,`gamma`],e=>{var{typed:t,gamma:n}=e;return t(tG,{number:function(e){if(e<0)throw Error(`Value must be non-negative`);return n(e+1)},BigNumber:function(e){if(e.isNegative())throw Error(`Value must be non-negative`);return n(e.plus(1))},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),rG=`kldivergence`,iG=Z(rG,[`typed`,`matrix`,`divide`,`sum`,`multiply`,`map`,`dotDivide`,`log`,`isNumeric`],e=>{var{typed:t,matrix:n,divide:r,sum:i,multiply:a,map:o,dotDivide:s,log:c,isNumeric:l}=e;return t(rG,{"Array, Array":function(e,t){return u(n(e),n(t))},"Matrix, Array":function(e,t){return u(e,n(t))},"Array, Matrix":function(e,t){return u(n(e),t)},"Matrix, Matrix":function(e,t){return u(e,t)}});function u(e,t){var n=t.size().length,u=e.size().length;if(n>1)throw Error(`first object must be one dimensional`);if(u>1)throw Error(`second object must be one dimensional`);if(n!==u)throw Error(`Length of two vectors must be equal`);if(i(e)===0)throw Error(`Sum of elements in first object must be non zero`);if(i(t)===0)throw Error(`Sum of elements in second object must be non zero`);var d=r(e,i(e)),f=i(a(d,o(s(d,r(t,i(t))),e=>c(e))));return l(f)?f:NaN}}),aG=`multinomial`,oG=Z(aG,[`typed`,`add`,`divide`,`multiply`,`factorial`,`isInteger`,`isPositive`],e=>{var{typed:t,add:n,divide:r,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(aG,{"Array | Matrix":function(e){var t=0,c=1;return tM(e,function(e){if(!o(e)||!s(e))throw TypeError(`Positive integer value expected in function multinomial`);t=n(t,e),c=i(c,a(e))}),r(a(t),c)}})}),sG=`permutations`,cG=Z(sG,[`typed`,`factorial`],e=>{var{typed:t,factorial:n}=e;return t(sG,{"number | BigNumber":n,"number, number":function(e,t){if(!HD(e)||e<0||!HD(t)||t<0)throw TypeError(`Positive integer value expected in function permutations`);if(t>e)throw TypeError(`second argument k must be less than or equal to first argument n`);return GM(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!lG(e)||!lG(t))throw TypeError(`Positive integer value expected in function permutations`);if(t.gt(e))throw TypeError(`second argument k must be less than or equal to first argument n`);for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})});function lG(e){return e.isInteger()&&e.gte(0)}var uG=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=o();t.next=function(){var e=2091639*t.s0+t.c*23283064365386963e-26;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=e|0)},t.c=1,t.s0=n(` `),t.s1=n(` `),t.s2=n(` `),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function i(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function a(e,t){var n=new r(e),a=t&&t.state,o=n.next;return o.int32=function(){return n.next()*4294967296|0},o.double=function(){return o()+(o()*2097152|0)*11102230246251565e-32},o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}function o(){var e=4022871197;return function(t){t=String(t);for(var n=0;n>>0,r-=e,r*=e,e=r>>>0,r-=e,e+=r*4294967296}return(e>>>0)*23283064365386963e-26}}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.alea=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),dG=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;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===(e|0)?t.x=e:n+=e;for(var r=0;r>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor128=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),fG=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;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,t.v=0,e===(e|0)?t.x=e:n+=e;for(var r=0;r>>4),t.next()}function i(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 a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorwow=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),pG=o(((e,t)=>{(function(e,t,n){function r(e){var t=this;t.next=function(){var e=t.x,n=t.i,r=e[n],i;return r^=r>>>7,i=r^r<<24,r=e[n+1&7],i^=r^r>>>10,r=e[n+3&7],i^=r^r>>>3,r=e[n+4&7],i^=r^r<<7,r=e[n+7&7],r^=r<<13,i^=r^r<<9,e[n]=i,t.i=n+1&7,i};function n(e,t){var n,r=[];if(t===(t|0))r[0]=t;else for(t=``+t,n=0;n0;--n)e.next()}n(t,e)}function i(e,t){return t.x=e.x.slice(),t.i=e.i,t}function a(e,t){e??=+new Date;var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(a.x&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorshift7=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),mG=o(((e,t)=>{(function(e,t,n){function r(e){var t=this;t.next=function(){var e=t.w,n=t.X,r=t.i,i,a;return t.w=e=e+1640531527|0,a=n[r+34&127],i=n[r=r+1&127],a^=a<<13,i^=i<<17,a^=a>>>15,i^=i>>>12,a=n[r]=a^i,t.i=r,a+(e^e>>>16)|0};function n(e,t){var n,r,i,a,o,s=[],c=128;for(t===(t|0)?(r=t,t=null):(t+=`\0`,r=0,c=Math.max(c,t.length)),i=0,a=-32;a>>15,r^=r<<4,r^=r>>>13,a>=0&&(o=o+1640531527|0,n=s[a&127]^=r+o,i=n==0?i+1:0);for(i>=128&&(s[(t&&t.length||0)&127]=-1),i=127,a=512;a>0;--a)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;e.w=o,e.X=s,e.i=i}n(t,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function a(e,t){e??=+new Date;var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(a.X&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor4096=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),hG=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;t.next=function(){var e=t.b,n=t.c,r=t.d,i=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=e|0):n+=e;for(var r=0;r>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.tychei=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),gG=o(((e,t)=>{(function(e,n,r){var i=256,a=6,o=52,s=`random`,c=r.pow(i,a),l=r.pow(2,o),u=l*2,d=i-1,f;function p(e,t,o){var d=[];t=t==1?{entropy:!0}:t||{};var f=_(g(t.entropy?[e,y(n)]:e??v(),3),d),p=new m(d),b=function(){for(var e=p.g(a),t=c,n=0;e=u;)e/=2,t/=2,n>>>=1;return(e+n)/t};return b.int32=function(){return p.g(4)|0},b.quick=function(){return p.g(4)/4294967296},b.double=b,_(y(p.S),n),(t.pass||o||function(e,t,n,i){return i&&(i.S&&h(i,p),e.state=function(){return h(p,{})}),n?(r[s]=e,t):e})(b,f,`global`in t?t.global:this==r,t.state)}function m(e){var t,n=e.length,r=this,a=0,o=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{var n=uG(),r=dG(),i=fG(),a=pG(),o=mG(),s=hG(),c=gG();c.alea=n,c.xor128=r,c.xorwow=i,c.xorshift7=a,c.xor4096=o,c.tychei=s,t.exports=c}))(),1),vG=(0,_G.default)(Date.now());function yG(e){var t;function n(e){t=e===null?vG:(0,_G.default)(String(e))}n(e);function r(){return t()}return r}var bG=`pickRandom`,xG=Z(bG,[`typed`,`config`,`?on`],e=>{var{typed:t,config:n,on:r}=e,i=yG(n.randomSeed);return r&&r(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(i=yG(e.randomSeed))}),t(bG,{"Array | Matrix":function(e){return a(e,{})},"Array | Matrix, Object":function(e,t){return a(e,t)},"Array | Matrix, number":function(e,t){return a(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return a(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,n){return a(e,{number:n,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,n){return a(e,{number:t,weights:n})}});function a(e,t){var{number:n,weights:r,elementWise:a=!0}=t,o=n===void 0;o&&(n=1);var s=zE(e)?e.create:zE(r)?r.create:null;e=e.valueOf(),r&&=r.valueOf(),a===!0&&(e=Tj(e),r=Tj(r));var c=0;if(r!==void 0){if(r.length!==e.length)throw Error(`Weights must have the same length as possibles`);for(var l=0,u=r.length;l1)for(var r=0,i=e.shift();r{var{typed:t,config:n,on:r}=e,i=yG(n.randomSeed);return r&&r(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(i=yG(e.randomSeed))}),t(CG,{"":()=>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,n)=>a(e,t,n)});function a(e,t,n){var r=SG(e.valueOf(),()=>o(t,n));return zE(e)?e.create(r,`number`):r}function o(e,t){return e+i()*(t-e)}}),TG=`randomInt`,EG=Z(TG,[`typed`,`config`,`log2`,`?on`],e=>{var{typed:t,config:n,log2:r,on:i}=e,a=yG(n.randomSeed);return i&&i(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(a=yG(e.randomSeed))}),t(TG,{"":()=>s(0,2),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),bigint:e=>c(0n,e),"bigint, bigint":c,"Array | Matrix":e=>o(e,0,1),"Array | Matrix, number":(e,t)=>o(e,0,t),"Array | Matrix, number, number":(e,t,n)=>o(e,t,n)});function o(e,t,n){var r=SG(e.valueOf(),()=>s(t,n));return zE(e)?e.create(r,`number`):r}function s(e,t){return Math.floor(e+a()*(t-e))}function c(e,t){var n=2n**30n,i=t-e;if(i<=n)return e+BigInt(s(0,Number(i)));for(var o=r(i),c=i;c>=i;){c=0n;for(var l=0;l{var{typed:t,addScalar:n,subtractScalar:r,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:c,isNegative:l,isInteger:u,number:d,bignumber:f,larger:p}=e,m=[],h=[];return t(DG,{"number | BigNumber, number | BigNumber":function(e,t){if(!u(e)||l(e)||!u(t)||l(t))throw TypeError(`Non-negative integer value expected in function stirlingS2`);if(p(t,e))throw TypeError(`k must be less than or equal to n in function stirlingS2`);var r=!(jE(e)&&jE(t)),a=r?h:m,o=r?f:d,s=d(e),c=d(t);if(a[s]&&a[s].length>c)return a[s][c];for(var g=0;g<=s;++g)if(a[g]||(a[g]=[o(+(g===0))]),g!==0)for(var _=a[g],v=a[g-1],y=_.length;y<=g&&y<=c;++y)y===g?_[y]=1:_[y]=n(i(o(y),v[y]),v[y-1]);return a[s][c]}})}),kG=`bellNumbers`,AG=Z(kG,[`typed`,`addScalar`,`isNegative`,`isInteger`,`stirlingS2`],e=>{var{typed:t,addScalar:n,isNegative:r,isInteger:i,stirlingS2:a}=e;return t(kG,{"number | BigNumber":function(e){if(!i(e)||r(e))throw TypeError(`Non-negative integer value expected in function bellNumbers`);for(var t=0,o=0;o<=e;o++)t=n(t,a(e,o));return t}})}),jG=`catalan`,MG=Z(jG,[`typed`,`addScalar`,`divideScalar`,`multiplyScalar`,`combinations`,`isNegative`,`isInteger`],e=>{var{typed:t,addScalar:n,divideScalar:r,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(jG,{"number | BigNumber":function(e){if(!s(e)||o(e))throw TypeError(`Non-negative integer value expected in function catalan`);return r(a(i(e,2),e),n(e,1))}})}),NG=`composition`,PG=Z(NG,[`typed`,`addScalar`,`combinations`,`isNegative`,`isPositive`,`isInteger`,`larger`],e=>{var{typed:t,addScalar:n,combinations:r,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(NG,{"number | BigNumber, number | BigNumber":function(e,t){if(!o(e)||!i(e)||!o(t)||!i(t))throw TypeError(`Positive integer value expected in function composition`);if(s(t,e))throw TypeError(`k must be less than or equal to n in function composition`);return r(n(e,-1),n(t,-1))}})}),FG=`leafCount`,IG=Z(FG,[`parse`,`typed`],e=>{var{parse:t,typed:n}=e;function r(e){var t=0;return e.forEach(e=>{t+=r(e)}),t||1}return n(FG,{Node:function(e){return r(e)}})});function LG(e){return cD(e)||hD(e)&&e.isUnary()&&cD(e.args[0])}function RG(e){return!!(cD(e)||(dD(e)||hD(e))&&e.args.every(RG)||gD(e)&&RG(e.content))}function zG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BG(e){for(var t=1;t{var{FunctionNode:t,OperatorNode:n,SymbolNode:r}=e,i=!0,a=!1,o=`defaultF`,s={add:{trivial:i,total:i,commutative:i,associative:i},unaryPlus:{trivial:i,total:i,commutative:i,associative:i},subtract:{trivial:a,total:i,commutative:a,associative:a},multiply:{trivial:i,total:i,commutative:i,associative:i},divide:{trivial:a,total:i,commutative:a,associative:a},paren:{trivial:i,total:i,commutative:i,associative:a},defaultF:{trivial:a,total:i,commutative:a,associative:a}},c={divide:{total:a},log:{total:a}},l={subtract:{total:a},abs:{trivial:i},log:{total:i}};function u(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:s,r=o;if(typeof e==`string`?r=e:hD(e)?r=e.fn.toString():dD(e)?r=e.name:gD(e)&&(r=`paren`),AD(n,r)){var i=n[r];if(AD(i,t))return i[t];if(AD(s,r))return s[r][t]}if(AD(n,o)){var a=n[o];return AD(a,t)?a[t]:s[o][t]}if(AD(s,r)){var c=s[r];if(AD(c,t))return c[t]}return s[o][t]}function d(e){return u(e,`commutative`,arguments.length>1&&arguments[1]!==void 0?arguments[1]:s)}function f(e){return u(e,`associative`,arguments.length>1&&arguments[1]!==void 0?arguments[1]:s)}function p(e,t){var n=BG({},e);for(var r in t)AD(e,r)?n[r]=BG(BG({},t[r]),e[r]):n[r]=t[r];return n}function m(e,t){if(!e.args||e.args.length===0)return e;e.args=h(e,t);for(var n=0;n2&&f(e,t)){for(var a=e.args.pop();e.args.length>0;)a=n([e.args.pop(),a]);e.args=a.args}}}function _(e,t){if(!(!e.args||e.args.length===0)){for(var n=v(e),r=e.args.length,i=0;i2&&f(e,t)){for(var a=e.args.shift();e.args.length>0;)a=n([a,e.args.shift()]);e.args=a.args}}}function v(e){return hD(e)?function(t){try{return new n(e.op,e.fn,t,e.implicit)}catch(e){return console.error(e),[]}}:function(n){return new t(new r(e.name),n)}}return{createMakeNodeFunction:v,hasProperty:u,isCommutative:d,isAssociative:f,mergeContext:p,flatten:m,allChildren:h,unflattenr:g,unflattenl:_,defaultContext:s,realContext:c,positiveContext:l}}),HG=Z(`simplify`,[`typed`,`parse`,`equal`,`resolve`,`simplifyConstant`,`simplifyCore`,`AccessorNode`,`ArrayNode`,`ConstantNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`,`replacer`],e=>{var{typed:t,parse:n,equal:r,resolve:i,simplifyConstant:a,simplifyCore:o,AccessorNode:s,ArrayNode:c,ConstantNode:l,FunctionNode:u,IndexNode:d,ObjectNode:f,OperatorNode:p,ParenthesisNode:m,SymbolNode:h,replacer:g}=e,{hasProperty:_,isCommutative:v,isAssociative:y,mergeContext:b,flatten:x,unflattenr:S,unflattenl:C,createMakeNodeFunction:w,defaultContext:T,realContext:E,positiveContext:D}=VG({FunctionNode:u,OperatorNode:p,SymbolNode:h});t.addConversion({from:`Object`,to:`Map`,convert:kE});var O=t(`simplify`,{Node:te,"Node, Map":(e,t)=>te(e,!1,t),"Node, Map, Object":(e,t,n)=>te(e,!1,t,n),"Node, Array":te,"Node, Array, Map":te,"Node, Array, Map, Object":te});t.removeConversion({from:`Object`,to:`Map`,convert:kE}),O.defaultContext=T,O.realContext=E,O.positiveContext=D;function k(e){return e.transform(function(e){return gD(e)?k(e.content):e})}var A={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};O.rules=[o,{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}}},a,{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}}},a,{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`}];function j(e,t){var r={};if(e.s){var i=e.s.split(`->`);if(i.length===2)r.l=i[0],r.r=i[1];else throw SyntaxError(`Could not parse rule: `+e.s)}else r.l=e.l,r.r=e.r;r.l=k(n(r.l)),r.r=k(n(r.r));for(var a of[`imposeContext`,`repeat`,`assuming`])a in e&&(r[a]=e[a]);if(e.evaluate&&(r.evaluate=n(e.evaluate)),y(r.l,t)){var o=!v(r.l,t),s;o&&(s=ee());var c=w(r.l),l=ee();r.expanded={},r.expanded.l=c([r.l,l]),x(r.expanded.l,t),S(r.expanded.l,t),r.expanded.r=c([r.r,l]),o&&(r.expandedNC1={},r.expandedNC1.l=c([s,r.l]),r.expandedNC1.r=c([s,r.r]),r.expandedNC2={},r.expandedNC2.l=c([s,r.expanded.l]),r.expandedNC2.r=c([s,r.expanded.r]))}return r}function M(e,t){for(var n=[],r=0;r2&&arguments[2]!==void 0?arguments[2]:OE(),r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=r.consoleDebug;t=M(t||O.rules,r.context);var o=i(e,n);o=k(o);for(var s={},c=o.toString({parenthesis:`all`});!s[c];){s[c]=!0,N=0;var l=c;a&&console.log(`Working on: `,c);for(var u=0;u ${t[u].r.toString()}`)),a){var f=o.toString({parenthesis:`all`});f!==l&&(console.log(`Applying`,d,`produced`,f),l=f)}C(o,r.context)}c=o.toString({parenthesis:`all`})}return o}function ne(e,t,n){var r=e;if(e)for(var i=0;i1&&(c=a(e.args.slice(0,s))),i=e.args.slice(s),r=i.length===1?i[0]:a(i),n.push(a([c,r]))}return n}function F(e,t){var n={placeholders:{}};if(!e.placeholders&&!t.placeholders)return n;if(!e.placeholders)return t;if(!t.placeholders)return e;for(var r in e.placeholders)if(AD(e.placeholders,r)&&(n.placeholders[r]=e.placeholders[r],AD(t.placeholders,r)&&!ae(e.placeholders[r],t.placeholders[r])))return null;for(var i in t.placeholders)AD(t.placeholders,i)&&(n.placeholders[i]=t.placeholders[i]);return n}function I(e,t){var n=[];if(e.length===0||t.length===0)return n;for(var r,i=0;i2)throw Error(`permuting >2 commutative non-associative rule arguments not yet implemented`);var d=ie(e.args[0],t.args[1],n);if(d.length===0)return[];var f=ie(e.args[1],t.args[0],n);if(f.length===0)return[];o=[d,f]}a=L(o)}else if(t.args.length>=2&&e.args.length===2){for(var m=P(t,n),g=[],_=0;_2)throw Error(`Unexpected non-binary associative function: `+e.toString());else return[]}else if(e instanceof h){if(e.name.length===0)throw Error(`Symbol in rule has 0 length...!?`);if(A[e.name]){if(e.name!==t.name)return[]}else switch(e.name[1]>=`a`&&e.name[1]<=`z`?e.name.substring(0,2):e.name[0]){case`n`:case`_p`:a[0].placeholders[e.name]=t;break;case`c`:case`cl`:if(cD(t))a[0].placeholders[e.name]=t;else return[];break;case`v`:if(!cD(t))a[0].placeholders[e.name]=t;else return[];break;case`vl`:if(yD(t))a[0].placeholders[e.name]=t;else return[];break;case`cd`:if(LG(t))a[0].placeholders[e.name]=t;else return[];break;case`vd`:if(!LG(t))a[0].placeholders[e.name]=t;else return[];break;case`ce`:if(RG(t))a[0].placeholders[e.name]=t;else return[];break;case`ve`:if(!RG(t))a[0].placeholders[e.name]=t;else return[];break;default:throw Error(`Invalid symbol in rule: `+e.name)}}else if(e instanceof l){if(!r(e.value,t.value))return[]}else return[];return a}function ae(e,t){if(e instanceof l&&t instanceof l){if(!r(e.value,t.value))return!1}else if(e instanceof h&&t instanceof h){if(e.name!==t.name)return!1}else if(e instanceof p&&t instanceof p||e instanceof u&&t instanceof u){if(e instanceof p){if(e.op!==t.op||e.fn!==t.fn)return!1}else if(e instanceof u&&e.name!==t.name)return!1;if(e.args.length!==t.args.length)return!1;for(var n=0;n{var{typed:t,config:n,mathWithTransform:r,matrix:i,isBounded:a,fraction:o,bignumber:s,AccessorNode:c,ArrayNode:l,ConstantNode:u,FunctionNode:d,IndexNode:f,ObjectNode:p,OperatorNode:m,SymbolNode:h}=e,{isCommutative:g,isAssociative:_,allChildren:v,createMakeNodeFunction:y}=VG({FunctionNode:d,OperatorNode:m,SymbolNode:h}),b=t(`simplifyConstant`,{Node:e=>w(j(e,{})),"Node, Object":function(e,t){return w(j(e,t))}});function x(e){return FE(e)?e.valueOf():e instanceof Array?e.map(x):zE(e)?i(x(e.valueOf())):e}function S(e,t,n){try{return r[e].apply(null,t)}catch{return t=t.map(x),E(r[e].apply(null,t),n)}}var C=t({Fraction:O,number:function(e){return e<0?D(new u(-e)):new u(e)},BigNumber:function(e){return e<0?D(new u(-e)):new u(e)},bigint:function(e){return e<0n?D(new u(-e)):new u(e)},Complex:function(e){throw Error(`Cannot convert Complex number to Node`)},string:function(e){return new u(e)},Matrix:function(e){return new l(e.valueOf().map(e=>C(e)))}});function w(e){return pD(e)?e:C(e)}function T(e,t){if(t&&t.exactFractions!==!1&&a(e)&&o){var n=o(e),r=t&&typeof t.fractionsLimit==`number`?t.fractionsLimit:1/0;if(n.valueOf()===e&&n.nn.number===`BigNumber`&&s?s(e):Number(e),r=e.s*e.n,i=r<0n?new m(`-`,`unaryMinus`,[new u(-t(r))]):new u(t(r));return e.d===1n?i:new m(`/`,`divide`,[i,new u(t(e.d))])}function k(e,t,n){if(!fD(t))return new c(w(e),w(t));if(iD(e)||zE(e)){for(var r=Array.from(t.dimensions);r.length>0;)if(cD(r[0])&&typeof r[0].value!=`string`){var a=E(r.shift().value,n);iD(e)?e=e.items[a-1]:(e=e.valueOf()[a-1],e instanceof Array&&(e=i(e)))}else if(r.length>1&&cD(r[1])&&typeof r[1].value!=`string`){var o=E(r[1].value,n),s=[],d=iD(e)?e.items:e.valueOf();for(var p of d)if(iD(p))s.push(p.items[o-1]);else if(zE(e))s.push(p[o-1]);else break;if(s.length===d.length)e=iD(e)?new l(s):i(s),r.splice(1,1);else break}else break;return r.length===t.dimensions.length?new c(w(e),t):r.length>0?(t=new f(r),new c(w(e),t)):e}if(mD(e)&&t.dimensions.length===1&&cD(t.dimensions[0])){var m=t.dimensions[0].value;return m in e.properties?e.properties[m]:new u}return new c(w(e),t)}function A(e,t,n,r){var i=t.shift(),a=t.reduce((t,i)=>{if(!pD(i)){var a=t.pop();if(pD(a))return[a,i];try{return t.push(S(e,[a,i],r)),t}catch{t.push(a)}}return t.push(w(t.pop())),[n([t.length===1?t[0]:n(t),w(i)])]},[i]);return a.length===1?a[0]:n([a[0],C(a[1])])}function j(e,t){switch(e.type){case`SymbolNode`:return e;case`ConstantNode`:switch(typeof e.value){case`number`:return E(e.value,t);case`bigint`:return E(e.value,t);case`string`:return e.value;default:if(!isNaN(e.value))return E(e.value,t)}return e;case`FunctionNode`:if(r[e.name]&&r[e.name].rawArgs)return e;if(![`add`,`multiply`].includes(e.name)){var n=e.args.map(e=>j(e,t));if(!n.some(pD))try{return S(e.name,n,t)}catch{}if(e.name===`size`&&n.length===1&&iD(n[0])){for(var a=[],o=n[0];iD(o);)a.push(o.items.length),o=o.items[0];return i(a)}return new d(e.name,n.map(w))}case`OperatorNode`:var s=e.fn.toString(),c,u,m=y(e);if(hD(e)&&e.isUnary())c=[j(e.args[0],t)],u=pD(c[0])?m(c):S(s,c,t);else if(_(e,t.context))if(c=v(e,t.context),c=c.map(e=>j(e,t)),g(s,t.context)){for(var h=[],x=[],C=0;C1?(u=A(s,h,m,t),x.unshift(u),u=A(s,x,m,t)):u=A(s,c,m,t)}else u=A(s,c,m,t);else c=e.args.map(e=>j(e,t)),u=A(s,c,m,t);return u;case`ParenthesisNode`:return j(e.content,t);case`AccessorNode`:return k(j(e.object,t),j(e.index,t),t);case`ArrayNode`:var T=e.items.map(e=>j(e,t));return T.some(pD)?new l(T.map(w)):i(T);case`IndexNode`:return new f(e.dimensions.map(e=>b(e,t)));case`ObjectNode`:var D={};for(var O in e.properties)D[O]=b(e.properties[O],t);return new p(D);default:throw Error(`Unimplemented node type in simplifyConstant: ${e.type}`)}}return b}),WG=`simplifyCore`,GG=Z(WG,[`typed`,`parse`,`equal`,`isZero`,`add`,`subtract`,`multiply`,`divide`,`pow`,`AccessorNode`,`ArrayNode`,`ConstantNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`],e=>{var{typed:t,parse:n,equal:r,isZero:i,add:a,subtract:o,multiply:s,divide:c,pow:l,AccessorNode:u,ArrayNode:d,ConstantNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:g,ParenthesisNode:_,SymbolNode:v}=e,y=new f(0),b=new f(1),x=new f(!0),S=new f(!1);function C(e){return hD(e)&&[`and`,`not`,`or`].includes(e.op)}var{hasProperty:w,isCommutative:T}=VG({FunctionNode:p,OperatorNode:g,SymbolNode:v});function E(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t?t.context:void 0;if(w(e,`trivial`,n)){if(dD(e)&&e.args.length===1)return E(e.args[0],t);var a=!1,o=0;if(e.forEach(e=>{++o,o===1&&(a=E(e,t))}),o===1)return a}var s=e;if(dD(s)){var c=gH(s.name);if(c){if(s.args.length>2&&w(s,`associative`,n))for(;s.args.length>2;){var l=s.args.pop(),f=s.args.pop();s.args.push(new g(c,s.name,[l,f]))}s=new g(c,s.name,s.args)}else return new p(E(s.fn),s.args.map(e=>E(e,t)))}if(hD(s)&&s.isUnary()){var _=E(s.args[0],t);if(s.op===`~`&&hD(_)&&_.isUnary()&&_.op===`~`||s.op===`not`&&hD(_)&&_.isUnary()&&_.op===`not`&&C(_.args[0]))return _.args[0];var v=!0;if(s.op===`-`&&hD(_)&&(_.isBinary()&&_.fn===`subtract`&&(s=new g(`-`,`subtract`,[_.args[1],_.args[0]]),v=!1),_.isUnary()&&_.op===`-`))return _.args[0];if(v)return new g(s.op,s.fn,[_])}if(hD(s)&&s.isBinary()){var D=E(s.args[0],t),O=E(s.args[1],t);if(s.op===`+`){if(cD(D)&&i(D.value))return O;if(cD(O)&&i(O.value))return D;hD(O)&&O.isUnary()&&O.op===`-`&&(O=O.args[0],s=new g(`-`,`subtract`,[D,O]))}if(s.op===`-`)return hD(O)&&O.isUnary()&&O.op===`-`?E(new g(`+`,`add`,[D,O.args[0]]),t):cD(D)&&i(D.value)?E(new g(`-`,`unaryMinus`,[O])):cD(O)&&i(O.value)?D:new g(s.op,s.fn,[D,O]);if(s.op===`*`){if(cD(D)){if(i(D.value))return y;if(r(D.value,1))return O}if(cD(O)){if(i(O.value))return y;if(r(O.value,1))return D;if(T(s,n))return new g(s.op,s.fn,[O,D],s.implicit)}return new g(s.op,s.fn,[D,O],s.implicit)}if(s.op===`/`)return cD(D)&&i(D.value)?y:cD(O)&&r(O.value,1)?D:new g(s.op,s.fn,[D,O]);if(s.op===`^`&&cD(O)){if(i(O.value))return b;if(r(O.value,1))return D}if(s.op===`and`){if(cD(D))if(D.value){if(C(O))return O;if(cD(O))return O.value?x:S}else return S;if(cD(O))if(O.value){if(C(D))return D}else return S}if(s.op===`or`){if(cD(D)){if(D.value)return x;if(C(O))return O}if(cD(O)){if(O.value)return x;if(C(D))return D}}return new g(s.op,s.fn,[D,O])}if(hD(s))return new g(s.op,s.fn,s.args.map(e=>E(e,t)));if(iD(s))return new d(s.items.map(e=>E(e,t)));if(rD(s))return new u(E(s.object,t),E(s.index,t));if(fD(s))return new m(s.dimensions.map(e=>E(e,t)));if(mD(s)){var k={};for(var A in s.properties)k[A]=E(s.properties[A],t);return new h(k)}return s}return t(WG,{Node:E,"Node,Object":E})}),KG=Z(`resolve`,[`typed`,`parse`,`ConstantNode`,`FunctionNode`,`OperatorNode`,`ParenthesisNode`],e=>{var{typed:t,parse:n,ConstantNode:r,FunctionNode:i,OperatorNode:a,ParenthesisNode:o}=e;function s(e,t){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!t)return e;if(yD(e)){if(c.has(e.name)){var l=Array.from(c).join(`, `);throw ReferenceError(`recursive loop of variable definitions among {${l}}`)}var u=t.get(e.name);if(pD(u)){var d=new Set(c);return d.add(e.name),s(u,t,d)}else if(typeof u==`number`)return n(String(u));else if(u!==void 0)return new r(u);else return e}else if(hD(e)){var f=e.args.map(function(e){return s(e,t,c)});return new a(e.op,e.fn,f,e.implicit)}else if(gD(e))return new o(s(e.content,t,c));else if(dD(e)){var p=e.args.map(function(e){return s(e,t,c)});return new i(e.name,p)}return e.map(e=>s(e,t,c))}return t(`resolve`,{Node:s,"Node, Map | null | undefined":s,"Node, Object":(e,t)=>s(e,kE(t)),"Array | Matrix":t.referToSelf(e=>t=>t.map(t=>e(t))),"Array | Matrix, null | undefined":t.referToSelf(e=>t=>t.map(t=>e(t))),"Array, Object":t.referTo(`Array,Map`,e=>(t,n)=>e(t,kE(n))),"Matrix, Object":t.referTo(`Matrix,Map`,e=>(t,n)=>e(t,kE(n))),"Array | Matrix, Map":t.referToSelf(e=>(t,n)=>t.map(t=>e(t,n)))})}),qG=`symbolicEqual`,JG=Z(qG,[`parse`,`simplify`,`typed`,`OperatorNode`],e=>{var{parse:t,simplify:n,typed:r,OperatorNode:i}=e;function a(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=n(new i(`-`,`subtract`,[e,t]),{},r);return cD(a)&&!a.value}return r(qG,{"Node, Node":a,"Node, Node, Object":a})}),YG=`derivative`,XG=Z(YG,[`typed`,`config`,`parse`,`simplify`,`equal`,`isZero`,`numeric`,`ConstantNode`,`FunctionNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`],e=>{var{typed:t,config:n,parse:r,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:c,FunctionNode:l,OperatorNode:u,ParenthesisNode:d,SymbolNode:f}=e;function p(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},r=new Map,a=t.name;function o(e){var t=r.get(e);if(t!==void 0)return t;var n=_(o,e,a);return r.set(e,n),n}var s=v(e,o);return n.simplify?i(s):s}function m(e){var t=r(e);if(!t.isSymbolNode)throw TypeError(`Invalid variable. Cannot parse ${JSON.stringify(e)} into a variable in function derivative`);return t}var h=t(YG,{"Node, SymbolNode":p,"Node, SymbolNode, Object":p,"Node, string":(e,t)=>p(e,m(t)),"Node, string, Object":(e,t,n)=>p(e,m(t),n)});h._simplify=!0,h.toTex=function(e){return g.apply(null,e.args)};var g=t(`_derivTex`,{"Node, SymbolNode":function(e,t){return cD(e)&&xD(e.value)===`string`?g(r(e.value).toString(),t.toString(),1):g(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if(xD(t.value)===`string`)return g(e,r(t.value));throw Error(`The second parameter to 'derivative' is a non-string constant`)},"Node, SymbolNode, ConstantNode":function(e,t,n){return g(e.toString(),t.name,n.value)},"string, string, number":function(e,t,n){return(n===1?`{d\\over d`+t+`}`:`{d^{`+n+`}\\over d`+t+`^{`+n+`}}`)+`\\left[${e}\\right]`}}),_=t(`_isConst`,{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(e,t,n){return t.name!==n},"function, ParenthesisNode, string":function(e,t,n){return e(t.content,n)},"function, FunctionAssignmentNode, string":function(e,t,n){return t.params.includes(n)?e(t.expr,n):!0},"function, FunctionNode | OperatorNode, string":function(e,t,n){return t.args.every(t=>e(t,n))}}),v=t(`_derivative`,{"ConstantNode, function":function(){return y(0)},"SymbolNode, function":function(e,t){return t(e)?y(0):y(1)},"ParenthesisNode, function":function(e,t){return new d(v(e.content,t))},"FunctionAssignmentNode, function":function(e,t){return t(e)?y(0):v(e.expr,t)},"FunctionNode, function":function(e,t){if(t(e))return y(0);var n=e.args[0],r,i=!1,a=!1,o;switch(e.name){case`cbrt`:i=!0,o=new u(`*`,`multiply`,[y(3),new u(`^`,`pow`,[n,new u(`/`,`divide`,[y(2),y(3)])])]);break;case`sqrt`:case`nthRoot`:if(e.args.length===1)i=!0,o=new u(`*`,`multiply`,[y(2),new l(`sqrt`,[n])]);else if(e.args.length===2)return r=new u(`/`,`divide`,[y(1),e.args[1]]),v(new u(`^`,`pow`,[n,r]),t);break;case`log10`:r=y(10);case`log`:if(!r&&e.args.length===1)o=n.clone(),i=!0;else if(e.args.length===1&&r||e.args.length===2&&t(e.args[1]))o=new u(`*`,`multiply`,[n.clone(),new l(`log`,[r||e.args[1]])]),i=!0;else if(e.args.length===2)return v(new u(`/`,`divide`,[new l(`log`,[n]),new l(`log`,[e.args[1]])]),t);break;case`pow`:if(e.args.length===2)return v(new u(`^`,`pow`,[n,e.args[1]]),t);break;case`exp`:o=new l(`exp`,[n.clone()]);break;case`sin`:o=new l(`cos`,[n.clone()]);break;case`cos`:o=new u(`-`,`unaryMinus`,[new l(`sin`,[n.clone()])]);break;case`tan`:o=new u(`^`,`pow`,[new l(`sec`,[n.clone()]),y(2)]);break;case`sec`:o=new u(`*`,`multiply`,[e,new l(`tan`,[n.clone()])]);break;case`csc`:a=!0,o=new u(`*`,`multiply`,[e,new l(`cot`,[n.clone()])]);break;case`cot`:a=!0,o=new u(`^`,`pow`,[new l(`csc`,[n.clone()]),y(2)]);break;case`asin`:i=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])]);break;case`acos`:i=!0,a=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])]);break;case`atan`:i=!0,o=new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)]);break;case`asec`:i=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acsc`:i=!0,a=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acot`:i=!0,a=!0,o=new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)]);break;case`sinh`:o=new l(`cosh`,[n.clone()]);break;case`cosh`:o=new l(`sinh`,[n.clone()]);break;case`tanh`:o=new u(`^`,`pow`,[new l(`sech`,[n.clone()]),y(2)]);break;case`sech`:a=!0,o=new u(`*`,`multiply`,[e,new l(`tanh`,[n.clone()])]);break;case`csch`:a=!0,o=new u(`*`,`multiply`,[e,new l(`coth`,[n.clone()])]);break;case`coth`:a=!0,o=new u(`^`,`pow`,[new l(`csch`,[n.clone()]),y(2)]);break;case`asinh`:i=!0,o=new l(`sqrt`,[new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])]);break;case`acosh`:i=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])]);break;case`atanh`:i=!0,o=new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])]);break;case`asech`:i=!0,a=!0,o=new u(`*`,`multiply`,[n.clone(),new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])])]);break;case`acsch`:i=!0,a=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acoth`:i=!0,a=!0,o=new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])]);break;case`abs`:o=new u(`/`,`divide`,[new l(new f(`abs`),[n.clone()]),n.clone()]);break;default:throw 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`)}var s,c;i?(s=`/`,c=`divide`):(s=`*`,c=`multiply`);var d=v(n,t);return a&&(d=new u(`-`,`unaryMinus`,[d])),new u(s,c,[d,o])},"OperatorNode, function":function(e,t){if(t(e))return y(0);if(e.op===`+`)return new u(e.op,e.fn,e.args.map(function(e){return v(e,t)}));if(e.op===`-`){if(e.isUnary())return new u(e.op,e.fn,[v(e.args[0],t)]);if(e.isBinary())return new u(e.op,e.fn,[v(e.args[0],t),v(e.args[1],t)])}if(e.op===`*`){var n=e.args.filter(function(e){return t(e)});if(n.length>0){var r=e.args.filter(function(e){return!t(e)}),i=r.length===1?r[0]:new u(`*`,`multiply`,r);return new u(`*`,`multiply`,n.concat(v(i,t)))}return new u(`+`,`add`,e.args.map(function(n){return new u(`*`,`multiply`,e.args.map(function(e){return e===n?v(e,t):e.clone()}))}))}if(e.op===`/`&&e.isBinary()){var s=e.args[0],c=e.args[1];return t(c)?new u(`/`,`divide`,[v(s,t),c]):t(s)?new u(`*`,`multiply`,[new u(`-`,`unaryMinus`,[s]),new u(`/`,`divide`,[v(c,t),new u(`^`,`pow`,[c.clone(),y(2)])])]):new u(`/`,`divide`,[new u(`-`,`subtract`,[new u(`*`,`multiply`,[v(s,t),c.clone()]),new u(`*`,`multiply`,[s.clone(),v(c,t)])]),new u(`^`,`pow`,[c.clone(),y(2)])])}if(e.op===`^`&&e.isBinary()){var d=e.args[0],f=e.args[1];if(t(d))return cD(d)&&(o(d.value)||a(d.value,1))?y(0):new u(`*`,`multiply`,[e,new u(`*`,`multiply`,[new l(`log`,[d.clone()]),v(f.clone(),t)])]);if(t(f)){if(cD(f)){if(o(f.value))return y(0);if(a(f.value,1))return v(d,t)}var p=new u(`^`,`pow`,[d.clone(),new u(`-`,`subtract`,[f,y(1)])]);return new u(`*`,`multiply`,[f.clone(),new u(`*`,`multiply`,[v(d,t),p])])}return new u(`*`,`multiply`,[new u(`^`,`pow`,[d.clone(),f.clone()]),new u(`+`,`add`,[new u(`*`,`multiply`,[v(d,t),new u(`/`,`divide`,[f.clone(),d.clone()])]),new u(`*`,`multiply`,[v(f,t),new l(`log`,[d.clone()])])])])}throw 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 y(e,t){return new c(s(e,t||UD(String(e),n)))}return h}),ZG=`rationalize`,QG=Z(ZG,`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`.split(`.`),e=>{var{config:t,typed:n,equal:r,isZero:i,add:a,subtract:o,multiply:s,divide:c,pow:l,parse:u,simplifyConstant:d,simplifyCore:f,simplify:p,fraction:m,bignumber:h,mathWithTransform:g,matrix:_,AccessorNode:v,ArrayNode:y,ConstantNode:b,FunctionNode:x,IndexNode:S,ObjectNode:C,OperatorNode:w,SymbolNode:T,ParenthesisNode:E}=e;function D(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=k(),i=O(e,t,!0,r.firstRules),a=i.variables.length,o={exactFractions:!1},s={exactFractions:!0};if(e=i.expression,a>=1){e=A(e);var c,l,u=!0,d=!1;e=p(e,r.firstRules,{},o);for(var f;l=u?r.distrDivRules:r.sucDivRules,e=p(e,l,{},s),u=!u,f=e.toString(),f!==c;)d=!0,c=f;d&&(e=p(e,r.firstRulesAgain,{},o)),e=p(e,r.finalRules,{},o)}var m=[],h={};return e.type===`OperatorNode`&&e.isBinary()&&e.op===`/`?(a===1&&(e.args[0]=j(e.args[0],m),e.args[1]=j(e.args[1])),n&&(h.numerator=e.args[0],h.denominator=e.args[1])):(a===1&&(e=j(e,m)),n&&(h.numerator=e,h.denominator=null)),n?(h.coefficients=m,h.variables=i.variables,h.expression=e,h):e}return n(ZG,{Node:D,"Node, boolean":(e,t)=>D(e,{},t),"Node, Object":D,"Node, Object, boolean":D});function O(e,t,n,r){var i=[],a=p(e,r,t,{exactFractions:!1});n=!!n;var o=`+-*`+(n?`/`:``);c(a);var s={};return s.expression=a,s.variables=i,s;function c(e){var t=e.type;if(t===`FunctionNode`)throw Error(`There is an unsolved function call`);if(t===`OperatorNode`)if(e.op===`^`){if(e.args[1].type!==`ConstantNode`||!HD(parseFloat(e.args[1].value)))throw Error(`There is a non-integer exponent`);c(e.args[0])}else{if(!o.includes(e.op))throw Error(`Operator `+e.op+` invalid in polynomial expression`);for(var n=0;n1;if(r===`OperatorNode`&&e.isBinary()){var a=!1,o;if(e.op===`^`&&(e.args[0].type===`ParenthesisNode`||e.args[0].type===`OperatorNode`)&&e.args[1].type===`ConstantNode`&&(o=parseFloat(e.args[1].value),a=o>=2&&HD(o)),a){if(o>2){var s=e.args[0];e=new w(`*`,`multiply`,[s,new w(`^`,`pow`,[e.args[0].cloneDeep(),new b(o-1)])])}else e=new w(`*`,`multiply`,[e.args[0],e.args[0].cloneDeep()]);i&&(n===`content`?t.content=e:t.args[n]=e)}}if(r===`ParenthesisNode`)A(e.content,e,`content`);else if(r!==`ConstantNode`&&r!==`SymbolNode`)for(var c=0;c=0;s--)if(t[s]!==0){var c=new b(a?t[s]:Math.abs(t[s])),l=t[s]<0?`-`:`+`;if(s>0){var u=new T(i);if(s>1){var d=new b(s);u=new w(`^`,`pow`,[u,d])}c=t[s]===-1&&a?new w(`-`,`unaryMinus`,[u]):Math.abs(t[s])===1?u:new w(`*`,`multiply`,[c,u])}o=a?c:l===`+`?new w(`+`,`add`,[o,c]):new w(`-`,`subtract`,[o,c]),a=!1}if(a)return new b(0);return o;function f(e,n,a){var o=e.type;if(o===`FunctionNode`)throw Error(`There is an unsolved function call`);if(o===`OperatorNode`){if(!`+-*^`.includes(e.op))throw Error(`Operator `+e.op+` invalid`);if(n!==null&&((e.fn===`unaryMinus`||e.fn===`pow`)&&n.fn!==`add`&&n.fn!==`subtract`&&n.fn!==`multiply`||(e.fn===`subtract`||e.fn===`add`||e.fn===`multiply`)&&n.fn!==`add`&&n.fn!==`subtract`||(e.fn===`subtract`||e.fn===`add`||e.fn===`unaryMinus`)&&a.noFil!==0))throw Error(`Invalid `+e.op+` placing`);(e.op===`^`||e.op===`*`)&&(a.fire=e.op);for(var s=0;sr&&(t[c]=0),t[c]+=a.cte*(a.oper===`+`?1:-1),r=Math.max(c,r);return}a.cte=c,a.fire===``&&(t[0]+=a.cte*(a.oper===`+`?1:-1))}else throw Error(`Type `+o+` is not allowed`)}}}),$G=`zpk2tf`,eK=Z($G,[`typed`,`add`,`multiply`,`Complex`,`number`],e=>{var{typed:t,add:n,multiply:r,Complex:i,number:a}=e;return t($G,{"Array,Array,number":function(e,t,n){return o(e,t,n)},"Array,Array":function(e,t){return o(e,t,1)},"Matrix,Matrix,number":function(e,t,n){return o(e.valueOf(),t.valueOf(),n)},"Matrix,Matrix":function(e,t){return o(e.valueOf(),t.valueOf(),1)}});function o(e,t,n){e.some(e=>e.type===`BigNumber`)&&(e=e.map(e=>a(e))),t.some(e=>e.type===`BigNumber`)&&(t=t.map(e=>a(e)));for(var o=[i(1,0)],c=[i(1,0)],l=0;l=0&&o-s{var{typed:t,add:n,multiply:r,Complex:i,divide:a,matrix:o}=e;return t(tK,{"Array, Array":function(e,t){return s(e,t,c(512))},"Array, Array, Array":function(e,t,n){return s(e,t,n)},"Array, Array, number":function(e,t,n){if(n<0)throw Error(`w must be a positive number`);return s(e,t,c(n))},"Matrix, Matrix":function(e,t){var n=c(512),{w:r,h:i}=s(e.valueOf(),t.valueOf(),n);return{w:o(r),h:o(i)}},"Matrix, Matrix, Matrix":function(e,t,n){var{h:r}=s(e.valueOf(),t.valueOf(),n.valueOf());return{h:o(r),w:o(n)}},"Matrix, Matrix, number":function(e,t,n){if(n<0)throw Error(`w must be a positive number`);var r=c(n),{h:i}=s(e.valueOf(),t.valueOf(),r);return{h:o(i),w:o(r)}}});function s(e,t,o){for(var s=[],c=[],l=0;l{var{classes:t}=e;return function(e,n){var r=t[n&&n.mathjs];return r&&typeof r.fromJSON==`function`?r.fromJSON(n):n}}),iK=Z(`replacer`,[],()=>function(e,t){return typeof t==`number`&&(!Number.isFinite(t)||isNaN(t))?{mathjs:`number`,value:String(t)}:typeof t==`bigint`?{mathjs:`bigint`,value:String(t)}:t}),aK=`15.2.0`,oK=Z(`true`,[],()=>!0),sK=Z(`false`,[],()=>!1),cK=Z(`null`,[],()=>null),lK=TK(`Infinity`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1/0):1/0}),uK=TK(`NaN`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(NaN):NaN}),dK=TK(`pi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?yB(n):qM}),fK=TK(`tau`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?bB(n):JM}),pK=TK(`e`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?_B(n):YM}),mK=TK(`phi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?vB(n):XM}),hK=TK(`LN2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(2).ln():Math.LN2}),gK=TK(`LN10`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(10).ln():Math.LN10}),_K=TK(`LOG2E`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1).div(new n(2).ln()):Math.LOG2E}),vK=TK(`LOG10E`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1).div(new n(10).ln()):Math.LOG10E}),yK=TK(`SQRT1_2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(`0.5`).sqrt():Math.SQRT1_2}),bK=TK(`SQRT2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(2).sqrt():Math.SQRT2}),xK=TK(`i`,[`Complex`],e=>{var{Complex:t}=e;return t.I}),SK=Z(`PI`,[`pi`],e=>{var{pi:t}=e;return t}),CK=Z(`E`,[`e`],e=>{var{e:t}=e;return t}),wK=Z(`version`,[],()=>aK);function TK(e,t,n){return Z(e,t,n,{recreateOnConfigChange:!0})}var EK=Cq(`speedOfLight`,`299792458`,`m s^-1`),DK=Cq(`gravitationConstant`,`6.67430e-11`,`m^3 kg^-1 s^-2`),OK=Cq(`planckConstant`,`6.62607015e-34`,`J s`),kK=Cq(`reducedPlanckConstant`,`1.0545718176461565e-34`,`J s`),AK=Cq(`magneticConstant`,`1.25663706212e-6`,`N A^-2`),jK=Cq(`electricConstant`,`8.8541878128e-12`,`F m^-1`),MK=Cq(`vacuumImpedance`,`376.730313667`,`ohm`),NK=Cq(`coulomb`,`8.987551792261171e9`,`N m^2 C^-2`),PK=Cq(`coulombConstant`,`8.987551792261171e9`,`N m^2 C^-2`),FK=Cq(`elementaryCharge`,`1.602176634e-19`,`C`),IK=Cq(`bohrMagneton`,`9.2740100783e-24`,`J T^-1`),LK=Cq(`conductanceQuantum`,`7.748091729863649e-5`,`S`),RK=Cq(`inverseConductanceQuantum`,`12906.403729652257`,`ohm`),zK=Cq(`magneticFluxQuantum`,`2.0678338484619295e-15`,`Wb`),BK=Cq(`nuclearMagneton`,`5.0507837461e-27`,`J T^-1`),VK=Cq(`klitzing`,`25812.807459304513`,`ohm`),HK=Cq(`bohrRadius`,`5.29177210903e-11`,`m`),UK=Cq(`classicalElectronRadius`,`2.8179403262e-15`,`m`),WK=Cq(`electronMass`,`9.1093837015e-31`,`kg`),GK=Cq(`fermiCoupling`,`1.1663787e-5`,`GeV^-2`),KK=wq(`fineStructure`,.0072973525693),qK=Cq(`hartreeEnergy`,`4.3597447222071e-18`,`J`),JK=Cq(`protonMass`,`1.67262192369e-27`,`kg`),YK=Cq(`deuteronMass`,`3.3435830926e-27`,`kg`),XK=Cq(`neutronMass`,`1.6749271613e-27`,`kg`),ZK=Cq(`quantumOfCirculation`,`3.6369475516e-4`,`m^2 s^-1`),QK=Cq(`rydberg`,`10973731.568160`,`m^-1`),$K=Cq(`thomsonCrossSection`,`6.6524587321e-29`,`m^2`),eq=wq(`weakMixingAngle`,.2229),tq=wq(`efimovFactor`,22.7),nq=Cq(`atomicMass`,`1.66053906660e-27`,`kg`),rq=Cq(`avogadro`,`6.02214076e23`,`mol^-1`),iq=Cq(`boltzmann`,`1.380649e-23`,`J K^-1`),aq=Cq(`faraday`,`96485.33212331001`,`C mol^-1`),oq=Cq(`firstRadiation`,`3.7417718521927573e-16`,`W m^2`),sq=Cq(`loschmidt`,`2.686780111798444e25`,`m^-3`),cq=Cq(`gasConstant`,`8.31446261815324`,`J K^-1 mol^-1`),lq=Cq(`molarPlanckConstant`,`3.990312712893431e-10`,`J s mol^-1`),uq=Cq(`molarVolume`,`0.022413969545014137`,`m^3 mol^-1`),dq=wq(`sackurTetrode`,-1.16487052358),fq=Cq(`secondRadiation`,`0.014387768775039337`,`m K`),pq=Cq(`stefanBoltzmann`,`5.67037441918443e-8`,`W m^-2 K^-4`),mq=Cq(`wienDisplacement`,`2.897771955e-3`,`m K`),hq=Cq(`molarMass`,`0.99999999965e-3`,`kg mol^-1`),gq=Cq(`molarMassC12`,`11.9999999958e-3`,`kg mol^-1`),_q=Cq(`gravity`,`9.80665`,`m s^-2`),vq=Cq(`planckLength`,`1.616255e-35`,`m`),yq=Cq(`planckMass`,`2.176435e-8`,`kg`),bq=Cq(`planckTime`,`5.391245e-44`,`s`),xq=Cq(`planckCharge`,`1.87554603778e-18`,`C`),Sq=Cq(`planckTemperature`,`1.416785e+32`,`K`);function Cq(e,t,n){return Z(e,[`config`,`Unit`,`BigNumber`],e=>{var{config:r,Unit:i,BigNumber:a}=e,o=new i(r.number===`BigNumber`?new a(t):parseFloat(t),n);return o.fixPrefix=!0,o})}function wq(e,t){return Z(e,[`config`,`BigNumber`],e=>{var{config:n,BigNumber:r}=e;return n.number===`BigNumber`?new r(t):t})}function Tq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Eq(e){for(var t=1;t{var{typed:t,isInteger:n}=e,r=HP({typed:t,isInteger:n});return t(`mapSlices`,{"...any":function(e){var t=e[1];jE(t)?e[1]=t-1:ME(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw iH(e)}}})},Eq({isTransformFunction:!0},HP.meta)),Oq=Z(`column`,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e,a=XI({typed:t,Index:n,matrix:r,range:i});return t(`column`,{"...any":function(e){var t=e.length-1,n=e[t];jE(n)&&(e[t]=n-1);try{return a.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0});function kq(e,t,n){var r=e.filter(function(e){return yD(e)&&!(e.name in t)&&!n.has(e.name)})[0];if(!r)throw Error(`No undefined variable found in inline expression "`+e+`"`);var i=r.name,a=new Map,o=new EE(n,a,new Set([i])),s=e.compile();return function(e){return a.set(i,e),s.evaluate(o)}}var Aq=Z(`transformCallback`,[`typed`],e=>{var{typed:t}=e;return function(e,r){return t.isTypedFunction(e)?n(e,r):jq(e,e.length,r)};function n(e,r){var i=Object.fromEntries(Object.entries(e.signatures).map(e=>{var[i,a]=e,o=i.split(`,`).length;return t.isTypedFunction(a)?[i,n(a,r)]:[i,jq(a,o,r)]}));return typeof e.name==`string`?t(e.name,i):t(i)}});function jq(e,t,n){return t===n?e:t===n+1?function(){for(var t=arguments.length,r=Array(t),i=0;in+1?function(){for(var t=arguments.length,r=Array(t),i=0;ie+1)}var Nq=Z(`filter`,[`typed`],e=>{var{typed:t}=e;function n(e,n,i){var a=rL({typed:t}),o=Aq({typed:t});if(e.length===0)return a();var s=e[0];if(e.length===1)return a(s);var c=e.length-1,l=e[c];return s&&=r(s,i),l&&=yD(l)||uD(l)?r(l,i):kq(l,n,i),a(s,o(l,c))}n.rawArgs=!0;function r(e,t){return e.compile().evaluate(t)}return n},{isTransformFunction:!0}),Pq=Z(`forEach`,[`typed`],e=>{var{typed:t}=e,n=cL({typed:t}),r=Aq({typed:t});function i(e,t,i){if(e.length===0)return n();var o=e[0];if(e.length===1)return n(o);var s=e.length-1,c=e[s];return o&&=a(o,i),c&&=yD(c)||uD(c)?a(c,i):kq(c,t,i),n(o,r(c,s))}i.rawArgs=!0;function a(e,t){return e.compile().evaluate(t)}return i},{isTransformFunction:!0}),Fq=Z(`index`,[`Index`,`getMatrixDataType`],e=>{var{Index:t,getMatrixDataType:n}=e;return function(){for(var e=[],r=0,i=arguments.length;r0?0:2;else if(a&&a.isSet===!0)a=a.map(function(e){return e-1});else if(RE(a)||zE(a))n(a)!==`boolean`&&(a=a.map(function(e){return e-1}));else if(jE(a)||NE(a))a--;else if(ME(a))a=a.toNumber()-1;else if(typeof a!=`string`)throw TypeError(`Dimension must be an Array, Matrix, number, bigint, string, or Range`);e[r]=a}var o=new t;return t.apply(o,e),o}},{isTransformFunction:!0}),Iq=Z(`map`,[`typed`],e=>{var{typed:t}=e,n=_L({typed:t}),r=Aq({typed:t});function i(e,t,i){if(e.length===0)return n();if(e.length===1)return n(e[0]);var a=e.length-1,o=e.slice(0,a),s=e[a];return o=o.map(e=>c(e,i)),s&&=yD(s)||uD(s)?c(s,i):kq(s,t,i),n(...o,r(s,a));function c(e,t){return e.compile().evaluate(t)}}return i.rawArgs=!0,i},{isTransformFunction:!0});function Lq(e){return jE(e)?e-1:ME(e)?e.minus(1):e}function Rq(e){return jE(e)||ME(e)}function zq(e){if(e.length===2&&BE(e[0])){e=e.slice();var t=e[1];Rq(t)&&(e[1]=Lq(t))}return e}var Bq=Z(`max`,[`typed`,`config`,`numeric`,`larger`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,larger:i,isNaN:a}=e,o=sB({typed:t,config:n,numeric:r,larger:i,isNaN:a});return t(`max`,{"...any":function(e){e=zq(e);try{return o.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Vq=Z(`mean`,[`typed`,`add`,`divide`],e=>{var{typed:t,add:n,divide:r}=e,i=OW({typed:t,add:n,divide:r});return t(`mean`,{"...any":function(e){e=zq(e);try{return i.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Hq=Z(`min`,[`typed`,`config`,`numeric`,`smaller`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,smaller:i,isNaN:a}=e,o=lB({typed:t,config:n,numeric:r,smaller:i,isNaN:a});return t(`min`,{"...any":function(e){e=zq(e);try{return o.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Uq=Z(`range`,[`typed`,`config`,`?matrix`,`?bignumber`,`equal`,`smaller`,`smallerEq`,`larger`,`largerEq`,`add`,`isZero`,`isPositive`],e=>{var{typed:t,config:n,matrix:r,bignumber:i,equal:a,smaller:o,smallerEq:s,larger:c,largerEq:l,add:u,isZero:d,isPositive:f}=e,p=TL({typed:t,config:n,matrix:r,bignumber:i,equal:a,smaller:o,smallerEq:s,larger:c,largerEq:l,add:u,isZero:d,isPositive:f});return t(`range`,{"...any":function(e){return typeof e[e.length-1]!=`boolean`&&e.push(!0),p.apply(null,e)}})},{isTransformFunction:!0}),Wq=Z(`row`,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e,a=PL({typed:t,Index:n,matrix:r,range:i});return t(`row`,{"...any":function(e){var t=e.length-1,n=e[t];jE(n)&&(e[t]=n-1);try{return a.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Gq=Z(`subset`,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e,a=BL({typed:t,matrix:n,zeros:r,add:i});return t(`subset`,{"...any":function(e){try{return a.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Kq=Z(`concat`,[`typed`,`matrix`,`isInteger`],e=>{var{typed:t,matrix:n,isInteger:r}=e,i=JI({typed:t,matrix:n,isInteger:r});return t(`concat`,{"...any":function(e){var t=e.length-1,n=e[t];jE(n)?e[t]=n-1:ME(n)&&(e[t]=n.minus(1));try{return i.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),qq=`diff`,Jq=Z(qq,[`typed`,`matrix`,`subtract`,`number`,`bignumber`],e=>{var{typed:t,matrix:n,subtract:r,number:i,bignumber:a}=e,o=yL({typed:t,matrix:n,subtract:r,number:i,bignumber:a});return t(qq,{"...any":function(e){e=zq(e);try{return o.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Yq=Z(`std`,[`typed`,`map`,`sqrt`,`variance`],e=>{var{typed:t,map:n,sqrt:r,variance:i}=e,a=zW({typed:t,map:n,sqrt:r,variance:i});return t(`std`,{"...any":function(e){e=zq(e);try{return a.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Xq=`sum`,Zq=Z(Xq,[`typed`,`config`,`add`,`numeric`],e=>{var{typed:t,config:n,add:r,numeric:i}=e,a=wW({typed:t,config:n,add:r,numeric:i});return t(Xq,{"...any":function(e){e=zq(e);try{return a.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),Qq=Z(`quantileSeq`,[`typed`,`bignumber`,`add`,`subtract`,`divide`,`multiply`,`partitionSelect`,`compare`,`isInteger`,`smaller`,`smallerEq`,`larger`,`mapSlices`],e=>{var{typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p}=e,m=LW({typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p});return t(`quantileSeq`,{"Array | Matrix, number | BigNumber":m,"Array | Matrix, number | BigNumber, number":(e,t,n)=>m(e,t,h(n)),"Array | Matrix, number | BigNumber, boolean":m,"Array | Matrix, number | BigNumber, boolean, number":(e,t,n,r)=>m(e,t,n,h(r)),"Array | Matrix, Array | Matrix":m,"Array | Matrix, Array | Matrix, number":(e,t,n)=>m(e,t,h(n)),"Array | Matrix, Array | Matrix, boolean":m,"Array | Matrix, Array | Matrix, boolean, number":(e,t,n,r)=>m(e,t,n,h(r))});function h(e){return zq([[],e])[1]}},{isTransformFunction:!0}),$q=`cumsum`,eJ=Z($q,[`typed`,`add`,`unaryPlus`],e=>{var{typed:t,add:n,unaryPlus:r}=e,i=EW({typed:t,add:n,unaryPlus:r});return t($q,{"...any":function(e){if(e.length===2&&BE(e[0])){var t=e[1];jE(t)?e[1]=t-1:ME(t)&&(e[1]=t.minus(1))}try{return i.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),tJ=`variance`,nJ=Z(tJ,[`typed`,`add`,`subtract`,`multiply`,`divide`,`mapSlices`,`isNaN`],e=>{var{typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s}=e,c=FW({typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s});return t(tJ,{"...any":function(e){e=zq(e);try{return c.apply(null,e)}catch(e){throw iH(e)}}})},{isTransformFunction:!0}),rJ=`print`,iJ=Z(rJ,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e,a=jR({typed:t,matrix:n,zeros:r,add:i});return t(rJ,{"string, Object | Array":function(e,t){return a(o(e),t)},"string, Object | Array, number | Object":function(e,t,n){return a(o(e),t,n)}});function o(e){return e.replace(kR,e=>`$`+e.slice(1).split(`.`).map(function(e){return!isNaN(e)&&e.length>0?parseInt(e)-1:e}).join(`.`))}},{isTransformFunction:!0}),aJ=Z(`and`,[`typed`,`matrix`,`zeros`,`add`,`equalScalar`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=Cz({typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o});function c(e,t,n){var r=e[0].compile().evaluate(n);return!BE(r)&&!s(r,!0)?!1:s(r,e[1].compile().evaluate(n))}return c.rawArgs=!0,c},{isTransformFunction:!0}),oJ=Z(`or`,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=WI({typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a});function s(e,t,n){var r=e[0].compile().evaluate(n);return!BE(r)&&o(r,!1)?!0:o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),sJ=Z(`nullish`,[`typed`,`matrix`,`size`,`flatten`,`deepEqual`],e=>{var{typed:t,matrix:n,size:r,flatten:i,deepEqual:a}=e,o=HI({typed:t,matrix:n,size:r,flatten:i,deepEqual:a});function s(e,t,n){var r=e[0].compile().evaluate(n);return!BE(r)&&r!=null&&r!==void 0?r:o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),cJ=Z(`bitAnd`,[`typed`,`matrix`,`zeros`,`add`,`equalScalar`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=CI({typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o});function c(e,t,n){var r=e[0].compile().evaluate(n);if(!BE(r)){if(isNaN(r))return NaN;if(r===0||r===!1)return 0}return s(r,e[1].compile().evaluate(n))}return c.rawArgs=!0,c},{isTransformFunction:!0}),lJ=Z(`bitOr`,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=DI({typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a});function s(e,t,n){var r=e[0].compile().evaluate(n);if(!BE(r)){if(isNaN(r))return NaN;if(r===-1)return-1;if(r===!0)return 1}return o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),uJ=`num`,dJ=Z(uJ,[`typed`,`fraction`],e=>{var{typed:t,fraction:n}=e;return t(uJ,{Fraction:e=>e.s*e.n,BigNumber:e=>{var t=n(e);return t.s*t.n},"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),fJ=`den`,pJ=Z(fJ,[`typed`,`fraction`],e=>{var{typed:t,fraction:n}=e;return t(fJ,{Fraction:e=>e.d,BigNumber:e=>n(e).d,"Array | Matrix":t.referToSelf(e=>t=>nM(t,e))})}),mJ=s({createAbs:()=>BP,createAccessorNode:()=>sH,createAcos:()=>MB,createAcosh:()=>PB,createAcot:()=>IB,createAcoth:()=>RB,createAcsc:()=>BB,createAcsch:()=>HB,createAdd:()=>KV,createAddScalar:()=>KP,createAnd:()=>Cz,createAndTransform:()=>aJ,createArg:()=>MI,createArrayNode:()=>lH,createAsec:()=>WB,createAsech:()=>KB,createAsin:()=>JB,createAsinh:()=>YB,createAssignmentNode:()=>vH,createAtan:()=>XB,createAtan2:()=>QB,createAtanh:()=>eV,createAtomicMass:()=>nq,createAvogadro:()=>rq,createBellNumbers:()=>AG,createBernoulli:()=>UW,createBigNumberClass:()=>dA,createBigint:()=>_P,createBignumber:()=>SP,createBin:()=>wR,createBitAnd:()=>CI,createBitAndTransform:()=>cJ,createBitNot:()=>TI,createBitOr:()=>DI,createBitOrTransform:()=>lJ,createBitXor:()=>AI,createBlockNode:()=>bH,createBohrMagneton:()=>IK,createBohrRadius:()=>HK,createBoltzmann:()=>iq,createBoolean:()=>xP,createCatalan:()=>MG,createCbrt:()=>XP,createCeil:()=>iF,createChain:()=>$U,createChainClass:()=>IU,createClassicalElectronRadius:()=>UK,createClone:()=>Qj,createColumn:()=>XI,createColumnTransform:()=>Oq,createCombinations:()=>KW,createCombinationsWithRep:()=>YW,createCompare:()=>Tz,createCompareNatural:()=>kz,createCompareText:()=>Nz,createCompile:()=>eU,createComplex:()=>CP,createComplexClass:()=>bA,createComposition:()=>PG,createConcat:()=>JI,createConcatTransform:()=>Kq,createConditionalNode:()=>SH,createConductanceQuantum:()=>LK,createConj:()=>PI,createConstantNode:()=>MH,createCorr:()=>VW,createCos:()=>rV,createCosh:()=>aV,createCot:()=>sV,createCoth:()=>lV,createCoulomb:()=>NK,createCoulombConstant:()=>PK,createCount:()=>QI,createCreateUnit:()=>AB,createCross:()=>eL,createCsc:()=>dV,createCsch:()=>pV,createCtranspose:()=>JL,createCube:()=>oF,createCumSum:()=>EW,createCumSumTransform:()=>eJ,createDeepEqual:()=>Qz,createDen:()=>pJ,createDenseMatrixClass:()=>Xj,createDerivative:()=>XG,createDet:()=>tW,createDeuteronMass:()=>YK,createDiag:()=>nL,createDiff:()=>yL,createDiffTransform:()=>Jq,createDistance:()=>xW,createDivide:()=>yW,createDivideScalar:()=>VR,createDot:()=>QV,createDotDivide:()=>iz,createDotMultiply:()=>pI,createDotPow:()=>nz,createE:()=>pK,createEfimovFactor:()=>tq,createEigs:()=>cW,createElectricConstant:()=>jK,createElectronMass:()=>WK,createElementaryCharge:()=>FK,createEqual:()=>Fz,createEqualScalar:()=>uP,createEqualText:()=>Rz,createErf:()=>cR,createEvaluate:()=>nU,createExp:()=>cF,createExpm:()=>uW,createExpm1:()=>uF,createFactorial:()=>nG,createFalse:()=>sK,createFaraday:()=>aq,createFermiCoupling:()=>GK,createFft:()=>QL,createFibonacciHeapClass:()=>pB,createFilter:()=>rL,createFilterTransform:()=>Nq,createFineStructure:()=>KK,createFirstRadiation:()=>oq,createFix:()=>mF,createFlatten:()=>oL,createFloor:()=>yF,createForEach:()=>cL,createForEachTransform:()=>Pq,createFormat:()=>SR,createFraction:()=>wP,createFractionClass:()=>UA,createFreqz:()=>nK,createFunctionAssignmentNode:()=>PH,createFunctionNode:()=>XH,createGamma:()=>QW,createGasConstant:()=>cq,createGcd:()=>RF,createGetMatrixDataType:()=>dL,createGravitationConstant:()=>DK,createGravity:()=>_q,createHartreeEnergy:()=>qK,createHasNumericValue:()=>JN,createHelp:()=>ZU,createHelpClass:()=>FU,createHex:()=>OR,createHypot:()=>JV,createI:()=>xK,createIdentity:()=>pL,createIfft:()=>eR,createIm:()=>II,createImmutableDenseMatrixClass:()=>uB,createIndex:()=>tH,createIndexClass:()=>dB,createIndexNode:()=>IH,createIndexTransform:()=>Fq,createInfinity:()=>lK,createIntersect:()=>SW,createInv:()=>rW,createInverseConductanceQuantum:()=>RK,createInvmod:()=>uI,createIsBounded:()=>nP,createIsFinite:()=>iP,createIsInteger:()=>sM,createIsNaN:()=>eP,createIsNegative:()=>WN,createIsNumeric:()=>KN,createIsPositive:()=>XN,createIsPrime:()=>RR,createIsZero:()=>QN,createKldivergence:()=>iG,createKlitzing:()=>VK,createKron:()=>hL,createLN10:()=>gK,createLN2:()=>hK,createLOG10E:()=>vK,createLOG2E:()=>_K,createLarger:()=>Kz,createLargerEq:()=>Yz,createLcm:()=>VF,createLeafCount:()=>IG,createLeftShift:()=>_z,createLgamma:()=>eG,createLog:()=>XR,createLog10:()=>KF,createLog1p:()=>QR,createLog2:()=>JF,createLoschmidt:()=>sq,createLsolve:()=>sz,createLsolveAll:()=>dz,createLup:()=>cU,createLusolve:()=>MU,createLyap:()=>vW,createMad:()=>MW,createMagneticConstant:()=>AK,createMagneticFluxQuantum:()=>zK,createMap:()=>_L,createMapSlices:()=>HP,createMapSlicesTransform:()=>Dq,createMapTransform:()=>Iq,createMatrix:()=>EP,createMatrixClass:()=>GA,createMatrixFromColumns:()=>MP,createMatrixFromFunction:()=>OP,createMatrixFromRows:()=>AP,createMax:()=>sB,createMaxTransform:()=>Bq,createMean:()=>OW,createMeanTransform:()=>Vq,createMedian:()=>AW,createMin:()=>lB,createMinTransform:()=>Hq,createMod:()=>OF,createMode:()=>_R,createMolarMass:()=>hq,createMolarMassC12:()=>gq,createMolarPlanckConstant:()=>lq,createMolarVolume:()=>uq,createMultinomial:()=>oG,createMultiply:()=>ZF,createMultiplyScalar:()=>YF,createNaN:()=>uK,createNeutronMass:()=>XK,createNode:()=>rH,createNorm:()=>XV,createNot:()=>BI,createNthRoot:()=>$F,createNthRoots:()=>ez,createNuclearMagneton:()=>BK,createNull:()=>cK,createNullish:()=>HI,createNullishTransform:()=>sJ,createNum:()=>dJ,createNumber:()=>gP,createNumeric:()=>zR,createObjectNode:()=>RH,createOct:()=>ER,createOnes:()=>bL,createOperatorNode:()=>VH,createOr:()=>WI,createOrTransform:()=>oJ,createParenthesisNode:()=>UH,createParse:()=>QH,createParser:()=>oU,createParserClass:()=>rU,createPartitionSelect:()=>rB,createPermutations:()=>cG,createPhi:()=>mK,createPi:()=>dK,createPickRandom:()=>xG,createPinv:()=>aW,createPlanckCharge:()=>xq,createPlanckConstant:()=>OK,createPlanckLength:()=>vq,createPlanckMass:()=>yq,createPlanckTemperature:()=>Sq,createPlanckTime:()=>bq,createPolynomialRoot:()=>PU,createPow:()=>UR,createPrint:()=>jR,createPrintTransform:()=>iJ,createProd:()=>bR,createProtonMass:()=>JK,createQr:()=>uU,createQuantileSeq:()=>LW,createQuantileSeqTransform:()=>Qq,createQuantumOfCirculation:()=>ZK,createRandom:()=>wG,createRandomInt:()=>EG,createRange:()=>TL,createRangeClass:()=>WA,createRangeNode:()=>GH,createRangeTransform:()=>Uq,createRationalize:()=>QG,createRe:()=>RI,createReducedPlanckConstant:()=>kK,createRelationalNode:()=>qH,createReplacer:()=>iK,createReshape:()=>DL,createResize:()=>OL,createResolve:()=>KG,createResultSet:()=>wO,createReviver:()=>rK,createRightArithShift:()=>yz,createRightLogShift:()=>xz,createRotate:()=>AL,createRotationMatrix:()=>ML,createRound:()=>KR,createRow:()=>PL,createRowTransform:()=>Wq,createRydberg:()=>QK,createSQRT1_2:()=>yK,createSQRT2:()=>bK,createSackurTetrode:()=>dq,createSchur:()=>gW,createSec:()=>hV,createSech:()=>_V,createSecondRadiation:()=>fq,createSetCartesian:()=>EV,createSetDifference:()=>OV,createSetDistinct:()=>AV,createSetIntersect:()=>MV,createSetIsSubset:()=>PV,createSetMultiplicity:()=>IV,createSetPowerset:()=>RV,createSetSize:()=>BV,createSetSymDifference:()=>HV,createSetUnion:()=>WV,createSign:()=>tI,createSimplify:()=>HG,createSimplifyConstant:()=>UG,createSimplifyCore:()=>GG,createSin:()=>yV,createSinh:()=>xV,createSize:()=>IL,createSlu:()=>kU,createSmaller:()=>Bz,createSmallerEq:()=>Uz,createSolveODE:()=>sR,createSort:()=>aB,createSpaClass:()=>mB,createSparse:()=>OB,createSparseMatrixClass:()=>dP,createSpeedOfLight:()=>EK,createSplitUnit:()=>PP,createSqrt:()=>nI,createSqrtm:()=>fW,createSquare:()=>iI,createSqueeze:()=>RL,createStd:()=>zW,createStdTransform:()=>Yq,createStefanBoltzmann:()=>pq,createStirlingS2:()=>OG,createString:()=>yP,createSubset:()=>BL,createSubsetTransform:()=>Gq,createSubtract:()=>oI,createSubtractScalar:()=>JP,createSum:()=>wW,createSumTransform:()=>Zq,createSylvester:()=>mW,createSymbolNode:()=>JH,createSymbolicEqual:()=>JG,createTan:()=>CV,createTanh:()=>wV,createTau:()=>fK,createThomsonCrossSection:()=>$K,createTo:()=>PR,createToBest:()=>IR,createTrace:()=>$V,createTranspose:()=>KL,createTrue:()=>oK,createTypeOf:()=>oP,createTyped:()=>yO,createUnaryMinus:()=>IP,createUnaryPlus:()=>RP,createUnequal:()=>eB,createUnitClass:()=>wB,createUnitFunction:()=>EB,createUppercaseE:()=>CK,createUppercasePi:()=>SK,createUsolve:()=>lz,createUsolveAll:()=>pz,createVacuumImpedance:()=>MK,createVariance:()=>FW,createVarianceTransform:()=>nJ,createVersion:()=>wK,createWeakMixingAngle:()=>eq,createWienDisplacement:()=>mq,createXgcd:()=>cI,createXor:()=>KI,createZeros:()=>XL,createZeta:()=>hR,createZpk2tf:()=>eK}),hJ=l(o(((e,t)=>{function n(){}n.prototype={on:function(e,t,n){var r=this.e||={};return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function i(){r.off(e,i),t.apply(n,arguments)}return i._=t,this.on(e,i,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||={})[e]||[]).slice(),r=0,i=n.length;rr(e,t));else if(ZE(n)||d(n))for(var a in n)AD(n,a)&&r(e,n[a],a);else if(RD(n)||i!==void 0){var o=RD(n)?h(n)?n.fn+`.transform`:n.fn:i;if(AD(e,o)&&e[o]!==n&&!t.silent)throw Error(`Cannot import "`+o+`" twice`);e[o]=n}else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}var i={};for(var o in r(i,e),i)if(AD(i,o)){var s=i[o];if(RD(s))l(s,t);else if(u(s))a(o,s,t);else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}}function a(t,i,a){if(a.wrap&&typeof i==`function`&&(i=c(i)),f(i)&&(i=e(t,{[i.signature]:i})),e.isTypedFunction(n[t])&&e.isTypedFunction(i)){i=a.override?e(t,i.signatures):e(n[t],i),n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}var s=n[t]!==void 0,l=n.Unit?.isValuelessUnit(t);if(!s&&!l||a.override){n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}if(!a.silent)throw Error(`Cannot import "`+t+`": already exists`)}function o(e,t){t&&typeof t.transform==`function`?(n.expression.transform[e]=t.transform,p(e)&&(n.expression.mathWithTransform[e]=t.transform)):(delete n.expression.transform[e],p(e)&&(n.expression.mathWithTransform[e]=t))}function s(e){delete n.expression.transform[e],p(e)?n.expression.mathWithTransform[e]=n[e]:delete n.expression.mathWithTransform[e]}function c(e){var t=function(){for(var t=[],r=0,i=arguments.length;r2&&arguments[2]!==void 0?arguments[2]:t.fn;if(a.includes(`.`))throw Error(`Factory name should not contain a nested path. Name: `+JSON.stringify(a));var o=h(t)?n.expression.transform:n,c=a in n.expression.transform,l=AD(o,a)?o[a]:void 0,u=function(){var r={};t.dependencies.map(VD).forEach(e=>{if(e.includes(`.`))throw Error(`Factory dependency should not contain a nested path. Name: `+JSON.stringify(e));e===`math`?r.math=n:e===`mathWithTransform`?r.mathWithTransform=n.expression.mathWithTransform:e===`classes`?r.classes=n:r[e]=n[e]});var o=t(r);if(o&&typeof o.transform==`function`)throw Error(`Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"`);if(l===void 0||i.override)return o;if(e.isTypedFunction(l)&&e.isTypedFunction(o))return e(l,o);if(i.silent)return l;throw Error(`Cannot import "`+a+`": already exists`)},d=t.meta?.formerly??``,f=h(t)||m(t),p=n.expression.mathWithTransform;!t.meta||t.meta.lazy!==!1?(kD(o,a,u),d&&kD(o,d,u),l&&c?(s(a),d&&s(d)):f&&(kD(p,a,()=>o[a]),d&&kD(p,d,()=>o[a]))):(o[a]=u(),d&&(o[d]=o[a]),l&&c?(s(a),d&&s(d)):f&&(kD(p,a,()=>o[a]),d&&kD(p,d,()=>o[a]))),r[a]=t,n.emit(`import`,a,u)}function u(e){return typeof e==`function`||typeof e==`number`||typeof e==`string`||typeof e==`boolean`||e===null||IE(e)||PE(e)||ME(e)||FE(e)||zE(e)||Array.isArray(e)}function d(e){return typeof e==`object`&&e[Symbol.toStringTag]===`Module`}function f(e){return typeof e==`function`&&typeof e.signature==`string`}function p(e){return!AD(g,e)}function m(e){return!e.fn.includes(`.`)&&!AD(g,e.fn)&&(!e.meta||!e.meta.isClass)}function h(e){return e!==void 0&&e.meta!==void 0&&e.meta.isTransformFunction===!0||!1}var g={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return i}function vJ(e,t){var n=mE({},hE,t);if(typeof Object.create!=`function`)throw Error(`ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.`);var r=gJ({isNumber:jE,isComplex:PE,isBigNumber:ME,isBigInt:NE,isFraction:FE,isUnit:IE,isString:LE,isArray:RE,isMatrix:zE,isCollection:BE,isDenseMatrix:VE,isSparseMatrix:HE,isRange:UE,isIndex:WE,isBoolean:GE,isResultSet:KE,isHelp:qE,isFunction:JE,isDate:YE,isRegExp:XE,isObject:ZE,isMap:QE,isPartitionedMap:$E,isObjectWrappingMap:eD,isNull:tD,isUndefined:nD,isAccessorNode:rD,isArrayNode:iD,isAssignmentNode:aD,isBlockNode:oD,isConditionalNode:sD,isConstantNode:cD,isFunctionAssignmentNode:uD,isFunctionNode:dD,isIndexNode:fD,isNode:pD,isObjectNode:mD,isOperatorNode:hD,isParenthesisNode:gD,isRangeNode:_D,isRelationalNode:vD,isSymbolNode:yD,isChain:bD});r.config=FD(n,r.emit),r.expression={transform:{},mathWithTransform:{config:r.config}};var i=[],a=[];function o(e){if(RD(e))return e(r);var t=e[Object.keys(e)[0]];if(RD(t))return t(r);if(!jD(e))throw console.warn("Factory object with properties `type`, `name`, and `factory` expected",e),Error("Factory object with properties `type`, `name`, and `factory` expected");var s=i.indexOf(e),c;return s===-1?(c=e.math===!0?e.factory(r.type,n,o,r.typed,r):e.factory(r.type,n,o,r.typed),i.push(e),a.push(c)):c=a[s],c}var s={};function c(){for(var e=arguments.length,t=Array(e),n=0;n{Object.values(s).forEach(e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&l(e,{override:!0})})}),r.create=vJ.bind(null,e),r.factory=Z,r.import(Object.values(DD(e))),r.ArgumentsError=MF,r.DimensionError=sj,r.IndexError=cj,r}function yJ(){return vJ(mJ,{})}var bJ=function(e){return e.DEV=`dev`,e.CANARY=`canary`,e.RELEASE=`release`,e}({}),xJ=class{api;internal;file;inputFieldParser;viewFieldParser;jsViewFieldParser;buttonParser;bindTargetParser;syntaxHighlighting;inputFieldFactory;viewFieldFactory;buttonActionRunner;buttonManager;metadataManager;mountableManager;math;build;constructor(){this.inputFieldParser=new XT(this),this.viewFieldParser=new oE(this),this.jsViewFieldParser=new ZT(this),this.buttonParser=new bT(this),this.bindTargetParser=new q_(this),this.syntaxHighlighting=new Ft(this),this.inputFieldFactory=new s_(this),this.viewFieldFactory=new b_(this),this.buttonActionRunner=new wn(this),this.buttonManager=new Dn(this),this.metadataManager=new U_,this.mountableManager=new W_,this.math=yJ(),this.build=`1.4.15`.includes(`canary`)?`canary`:`release`}setComponents(e){Object.assign(this,e)}setSettings(e){this.updateInternalSettings(e),this.saveSettings(e)}updateSettings(e){let t=this.getSettings();e(t),this.setSettings(t)}loadTemplates(){let e=this.getSettings(),t=this.inputFieldParser.parseTemplates(e.inputFieldTemplates);t.hasErrors()&&console.warn(`meta-bind | failed to parse input field templates`,t);let n=this.buttonManager.setButtonTemplates(e.buttonTemplates);n.hasErrors()&&console.warn(`meta-bind | failed to parse button templates`,n)}updateInternalSettings(e){vh.dateFormat=e.preferredDateFormat,lE(e.firstWeekday),this.loadTemplates()}destroy(){this.mountableManager.unload()}},SJ=class{id;manager;cache;constructor(e,t){this.id=e,this.manager=t,this.cache=new Map}validateStoragePath(e,t,n,r){return r.validateStoragePathAsFilePath(e,n)}resolveBindTargetScope(e,t,n){return e}getOrCreateCacheItem(e){let t=this.getCacheItemForStoragePath(e);return t===void 0&&(t=this.getDefaultCacheItem(e),this.cache.set(e,t)),t}subscribe(e){if(e.bindTarget===void 0)throw new _e({errorLevel:B.CRITICAL,effect:`can not subscribe`,cause:`subscription bind target undefined`});let t=this.getOrCreateCacheItem(e.bindTarget.storagePath);return t.subscriptions.push(e),t}unsubscribe(e){if(e.bindTarget===void 0)throw new _e({errorLevel:B.CRITICAL,effect:`can not unsubscribe`,cause:`subscription bind target undefined`});let t=this.cache.get(e.bindTarget.storagePath);if(t===void 0)throw new _e({errorLevel:B.CRITICAL,effect:`can not unsubscribe`,cause:`cache item does not exist`});return t.subscriptions=t.subscriptions.filter(t=>t.uuid!==e.uuid),t}getCacheItemForStoragePath(e){return this.cache.get(e)}onCycle(e){}getCacheItems(){return Array.from(this.cache.values())}shouldDelete(e){return!0}deleteCache(e){this.cache.delete(e.storagePath)}writeCache(e,t){let n=this.getOrCreateCacheItem(t.storagePath);return z_.setAndCreate(n.data,t.storageProp,e),n}writeEntireCache(e,t){t.data=e}readCache(e){if(e.storageType!==this.id)throw new _e({errorLevel:B.ERROR,effect:`can not read cache`,cause:`Source "${e.storageType}" does not match`});let t=this.getCacheItemForStoragePath(e.storagePath);return t===void 0?z_.tryGet(this.readExternal(e.storagePath),e.storageProp):this.readCacheItem(t,e.storageProp)}readCacheItem(e,t){return z_.tryGet(e.data,t)}readEntireCacheItem(e){return e.data}usesStoragePath(){return!0}},CJ=class extends SJ{readExternal(e){return{}}getDefaultCacheItem(e){return{data:{},storagePath:e,...this.manager.constructDefaultCacheItem()}}syncExternal(e){return Promise.resolve()}},wJ=class{id;manager;cache;constructor(e,t){this.id=e,this.manager=t,this.cache={data:{},...this.manager.constructDefaultCacheItem()}}getOrCreateCacheItem(e){return this.cache}validateStoragePath(e,t,n,r){if(t)throw new ke(B.ERROR,`Bind target validator`,`Failed to parse bind target. Bind target storage type 'global_memory' does not support a storage path.`,n,e.position);return``}deleteCache(e){}getCacheItemForStoragePath(e){return this.cache}getCacheItems(){return[this.cache]}onCycle(e){}readCache(e){return this.readCacheItem(this.cache,e.storageProp)}readCacheItem(e,t){return z_.tryGet(e.data,t)}shouldDelete(e){return!1}subscribe(e){return this.cache.subscriptions.push(e),this.cache}syncExternal(e){return Promise.resolve()}unsubscribe(e){return this.cache.subscriptions=this.cache.subscriptions.filter(t=>t.uuid!==e.uuid),this.cache}writeCache(e,t){return z_.setAndCreate(this.cache.data,t.storageProp,e),this.cache}writeEntireCache(e,t){t.data=e}readEntireCacheItem(e){return e.data}usesStoragePath(){return!1}},TJ=class{id;manager;constructor(e,t){this.id=e,this.manager=t}getOrCreateCacheItem(e){throw new _e({errorLevel:B.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}validateStoragePath(e,t,n,r){if(t)throw new ke(B.ERROR,`Bind Target Validator`,`Failed to parse bind target. Bind target storage type 'scope' does not support a storage path.`,n,e.position);return``}deleteCache(e){}getCacheItemForStoragePath(e){}getCacheItems(){return[]}onCycle(e){}readCache(e){}readCacheItem(e,t){}shouldDelete(e){return!0}subscribe(e){throw new _e({errorLevel:B.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}syncExternal(e){return Promise.resolve()}unsubscribe(e){throw new _e({errorLevel:B.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}writeCache(e,t){throw new _e({errorLevel:B.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}writeEntireCache(e,t){}readEntireCacheItem(e){throw new _e({errorLevel:B.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}usesStoragePath(){return!1}};function EJ(e){if(!e.getSettings().enableSyntaxHighlighting)return;window.CodeMirror.defineMode(`meta-bind-button`,e=>window.CodeMirror.getMode(e,`yaml`)),window.CodeMirror.defineMode(`meta-bind-js-view`,e=>window.CodeMirror.getMode(e,`javascript`));let t=/^\s*(```+|~~~+)/;window.CodeMirror.defineMode(`meta-bind`,n=>({startState:()=>({str:void 0,mdrcType:void 0,highlights:void 0,line:1}),token:(n,r)=>{if(r.str===void 0){let i=[n.string],a=1,o=n.lookAhead(a);for(;o!==void 0&&!t.test(o)&&(i.push(o),a+=1,o=n.lookAhead(a),!(a>100)););r.str=i.filter(e=>e.trim()!==``).join(` `);let s=e.api.isInlineFieldDeclarationAndGetType(r.str.trim());s===void 0?r.highlights=new Pt(r.str,[]):(r.fieldType=s,r.highlights=e.syntaxHighlighting.highlight(r.str,r.fieldType,!0))}let i=(r.highlights?.getHighlights().map(e=>({highlight:e,from:r.str?re(r.str,e.range.from):{line:1,column:1},to:r.str?re(r.str,e.range.to):{line:1,column:1}})).filter(e=>e.from.line===r.line))?.find(e=>e.from.column===n.pos+1);return i===void 0?(n.next(),n.eol()&&(r.line+=1),`line-HyperMD-codeblock`):(n.eatWhile(()=>i.to.line===r.line?n.pos+1=t&&r.from<=n)return!0;return!1}static checkRangeOverlap(e,t,n,r){return e<=r&&n<=t}static getContent(e,t,n){return e.sliceDoc(t,n)}static getCurrentFile(e){return e.state.field(f.editorInfoField).file}static existsDecorationBetween(e,t,n){let r=!1;return e.between(t,n,()=>{r=!0}),r}static existsDecorationOfTypeBetween(e,t,n,r){let i=!1;return e.between(n,r,(e,n,r)=>{r.spec.mb_widgetType===t&&(i=!0)}),i}};function kJ(e){return d.ViewPlugin.fromClass(class{decorations;component;constructor(e){this.component=new f.Component,this.component.load(),this.decorations=this.renderWidgets(e)??d.Decoration.none,e.dom.addEventListener(`click`,e=>this.handleClick(e))}handleClick(e){if(e.target instanceof HTMLElement){let t=e.target;for(;t!==null;){if(t.classList.contains(`mb-input`)){e.stopPropagation();break}t=t.parentElement}}}isLivePreview(e){return e.field(f.editorLivePreviewField)}update(e){this.decorations=this.decorations.map(e.changes),this.updateWidgets(e.view)}updateWidgets(e){this.decorations=this.decorations.update({filter:(t,n,r)=>O_(e.visibleRanges,e=>OJ.checkRangeOverlap(t,n,e.from,e.to))?!0:(r.spec.mb_unload?.(),!1)});for(let{from:t,to:n}of e.visibleRanges)(0,u.syntaxTree)(e.state).iterate({from:t,to:n,enter:t=>{let n=t.node,r=this.getRenderInfo(e,n);if(!r.data)return;if(!r.data.widgetType){this.removeDecoration(n);return}let i=r.data;r.shouldRender?(this.removeDecoration(n,DJ.FIELD),this.addDecoration(n,e,DJ.FIELD,i)):r.shouldHighlight?(this.removeDecoration(n),this.addDecoration(n,e,DJ.HIGHLIGHT,i)):this.removeDecoration(n)}})}removeDecoration(e,t){this.decorations=this.decorations.update({filterFrom:e.from-1,filterTo:e.to+1,filter:(e,n,r)=>{let i=r.spec;return!!(!i.mb_widgetType||t&&i.mb_widgetType===t)}})}addDecoration(e,t,n,r){if(OJ.existsDecorationOfTypeBetween(this.decorations,n,e.from,e.to))return;let i=OJ.getCurrentFile(t);if(!i)return;let a=this.renderWidget(e,n,r,i),o=Array.isArray(a)?a:[a];o.length!==0&&(this.decorations=this.decorations.update({add:o}))}getRenderInfo(t,n){let r=new Set(n.type.name?.split(`_`));if(r.has(`inline-code`)&&!r.has(`formatting`)){let r=this.readNode(t,n.from,n.to);if(!r.trulyInline)return{shouldRender:!1,shouldHighlight:!1,data:void 0};let i=OJ.checkSelectionOverlap(t.state.selection,n.from-1,n.to+1),a=this.isLivePreview(t.state),o=!i&&a;return{shouldRender:o,shouldHighlight:!o&&e.getSettings().enableSyntaxHighlighting,data:r}}return{shouldRender:!1,shouldHighlight:!1,data:void 0}}readNode(t,n,r){let i=!1;try{let e=OJ.getContent(t.state,n-1,r+1);i=e.startsWith("`")&&e.endsWith("`")}catch{}let a=OJ.getContent(t.state,n,r);return{content:a,widgetType:e.api.isInlineFieldDeclarationAndGetType(a),trulyInline:i}}renderWidgets(e){let t=OJ.getCurrentFile(e);if(!t)return;let n=[];for(let r of e.visibleRanges)(0,u.syntaxTree)(e.state).iterate({from:r.from,to:r.to,enter:r=>{let i=r.node,a=this.getRenderInfo(e,i);if(!a.data?.widgetType)return;let o=a.data,s;a.shouldRender?s=this.renderWidget(i,DJ.FIELD,o,t):a.shouldHighlight&&(s=this.renderWidget(i,DJ.HIGHLIGHT,o,t)),s&&(Array.isArray(s)?n.push(...s):n.push(s))}});return d.Decoration.set(n,!0)}renderWidget(t,n,r,i){if(n===DJ.FIELD){let n=e.api.constructMDRCWidget(r.widgetType,r.content,i.path,this.component);return d.Decoration.replace({widget:n,mb_widgetType:DJ.FIELD,mb_unload:()=>{n.renderChild?.unload()}}).range(t.from-1,t.to+1)}else return e.syntaxHighlighting.highlight(r.content,r.widgetType,!1).getHighlights().map(e=>d.Decoration.mark({class:`mb-highlight-${e.tokenClass}`,mb_widgetType:DJ.HIGHLIGHT}).range(t.from+e.range.from,t.from+e.range.to))}destroy(){this.component.unload()}},{decorations:e=>e.decorations})}var AJ=P.sequenceMap((e,t,n,r)=>new jJ(parseInt(e),parseInt(t),parseInt(n),r),z.digits().skip(P.string(`.`)),z.digits().skip(P.string(`.`)),z.digits(),P.string(`-`).then(z.remaining()).optional()),jJ=class e{major;minor;patch;prerelease;constructor(e,t,n,r){this.major=e,this.minor=t,this.patch=n,this.prerelease=r}static fromString(e){return De(AJ,e)}static lessThan(e,t){return e.majort.major?!1:e.minort.minor?!1:e.patcht.patch||e.prerelease===void 0?!1:t.prerelease===void 0?!0:e.prereleaset.pluginId===e);if(t===void 0)throw new Ee({errorLevel:B.CRITICAL,effect:`Dependency violation detected`,cause:`Attempted to access dependency ${e} which is not a listed dependency. Please report this error.`});return t}getPlugin(e){return this.mb.app.plugins.getPlugin(e)}throwPluginNotFound(e){this.throwDependencyError(`Plugin ${e} is required, but not installed. Please install the plugin.`)}throwDependencyError(e){throw new f.Notice(`meta-bind | Dependency Error: ${e}`,0),new Ee({errorLevel:B.ERROR,effect:`Dependency violation detected`,cause:e})}checkDependencyVersion(e,t){jJ.lessThan(t,e.minVersion)&&this.throwDependencyError(`Plugin ${e.pluginId} is outdated. Required version is at least ${e.minVersion.toString()}, installed version is ${t.toString()}. Please update the plugin.`),e.maxVersion!==void 0&&(jJ.greaterThan(t,e.maxVersion)||jJ.equals(t,e.maxVersion))&&this.throwDependencyError(`Plugin ${e.pluginId} is too new. Required version is lower than ${e.maxVersion.toString()}, installed version is ${t.toString()}. Please downgrade the plugin.`)}checkDependency(e){let t=this.getDependency(e),n=this.getPlugin(e);if(n==null)throw this.throwPluginNotFound(e),Error(`unreachable`);let r=jJ.fromString(n.manifest.version);return this.checkDependencyVersion(t,r),n}},NJ={date:`date`,datePicker:`datePicker`,dateTime:`dateTime`,editor:`editor`,imageSuggester:`imageSuggester(optionQuery(""))`,imageListSuggester:`imageListSuggester(optionQuery(""))`,inlineList:`inlineList`,inlineListSuggester:`inlineListSuggester(option(apple), option(banana), option(lemon))`,inlineSelect:`inlineSelect(option(apple), option(banana), option(lemon))`,list:`list`,listSuggester:`listSuggester(option(apple), option(banana), option(lemon))`,multiSelect:`multiSelect(option(apple), option(banana), option(lemon))`,number:`number`,progressBar:`progressBar`,select:`select(option(apple), option(banana), option(lemon))`,slider:`slider(addLabels)`,suggester:`suggester(option(apple), option(banana), option(lemon))`,text:`text`,textArea:`textArea`,time:`time`,toggle:`toggle`,invalid:``},PJ={image:[{title:`Image`,declaration:`VIEW[{globalMemory^MB_VF_image_example}][image]`,display:`VIEW[{imageExampleProperty}][image]`,inputField:`INPUT[imageSuggester(optionQuery("")):globalMemory^MB_VF_image_example]`}],link:[{title:`Link`,declaration:`VIEW[{globalMemory^MB_VF_link_example}][link]`,display:`VIEW[{linkExampleProperty}][link]`,inputField:`INPUT[suggester(optionQuery("")):globalMemory^MB_VF_link_example]`}],math:[{title:`Math`,declaration:`VIEW[{globalMemory^MB_VF_math_example} + 2][math]`,display:`VIEW[{mathExampleProperty} + 2][math]`,inputField:`INPUT[number:globalMemory^MB_VF_math_example]`}],text:[{title:`Text`,declaration:`VIEW[some text {globalMemory^MB_VF_text_example}][text]`,display:`VIEW[some text {textExampleProperty}][text]`,inputField:`INPUT[text:globalMemory^MB_VF_text_example]`},{title:`Markdown`,declaration:`VIEW[**some markdown** {globalMemory^MB_VF_text_markdown_example}][text(renderMarkdown)]`,display:`VIEW[**some markdown** {markdownExampleProperty}][text(renderMarkdown)]`,inputField:`INPUT[text:globalMemory^MB_VF_text_markdown_example]`}],invalid:[]};function FJ(e){let t=[];for(let[n,r]of Object.entries(NJ)){if(r===``)continue;let i=e.inputFieldParser.fromString(`INPUT[${r}]`),a=e.inputFieldParser.fromSimpleDeclaration({inputFieldType:void 0,templateName:void 0,bindTarget:void 0,arguments:[{name:kn.SHOWCASE,value:[`true`]},{name:kn.TITLE,value:[n]}]});i=e.inputFieldParser.merge(i,a),i.declarationString=`INPUT[${r}]`;let o=e.inputFieldParser.validate(i,``,void 0);t.push([n,o])}return t}function IJ(e){let t=[];for(let[e,n]of Object.entries(NJ)){if(n===``)continue;let r=e,i;i=An[r].allowInline?`\`INPUT[${n}:exampleProperty]\``:`\n\`\`\`meta-bind\nINPUT[${n}:exampleProperty]\n\`\`\`\n`,t.push([r,i])}return t.sort((e,t)=>e[0].localeCompare(t[0])),t}function LJ(e){let t=[];for(let e of Object.values(PJ))for(let n of e)t.push([n.title,`\`${n.display}\``]);return t.sort((e,t)=>e[0].localeCompare(t[0])),t}function RJ(e,t,n){let r=IJ(n),i=LJ(n);e.addItem(e=>{e.setTitle(`Meta Bind`),e.setIcon(`blocks`);let a=e.setSubmenu();a.addItem(e=>{e.setTitle(`Input field`);let n=e.setSubmenu();for(let[e,i]of r)n.addItem(n=>{n.setTitle(e),n.onClick(()=>zJ(t,i))})}),a.addItem(e=>{e.setTitle(`View field`);let n=e.setSubmenu();for(let[e,r]of i)n.addItem(n=>{n.setTitle(e),n.onClick(()=>zJ(t,r))})}),a.addItem(e=>{e.setTitle(`Inline button`),e.onClick(()=>{zJ(t,"`BUTTON[example-id]`")})}),a.addItem(e=>{e.setTitle(`Button`),e.onClick(()=>{n.internal.openButtonBuilderModal({onOkay:e=>{zJ(t,`\`\`\`meta-bind-button\n${(0,f.stringifyYaml)(e)}\n\`\`\``)},submitText:`Insert`})})})})}function zJ(e,t){e.replaceSelection(t)}var BJ=class extends oc{mb;filePath;uuid;constructor(e,t,n){super(),this.mb=e,this.filePath=n,this.uuid=t}getUuid(){return this.uuid}getFilePath(){return this.filePath}onMount(e){this.mb.mountableManager.registerMountable(this)}onUnmount(e){this.mb.mountableManager.unregisterMountable(this)}},VJ=class{scope;constructor(e){this.scope=e}},HJ=Ww()(xC()),UJ=Ww()(pw(de)),WJ=Ww()(pw(fe)),GJ=Ww()(pw(On)),KJ=Ww()(YC()),qJ=Ww()(Bw(VJ));Ww()(Bw(cc)),Ww()(Hw()),Ww()(Bw(BJ));var JJ=Ww()(Bw(oc)),YJ=Ww()(Bw(pe)),XJ=Ww()(rw({from:UC(),to:UC()})),ZJ=Ww()(rw({value:xC(),position:XJ.optional()})),QJ=Ww()(rw({name:ZJ,value:ZJ.array()})),$J=Ww()(rw({type:pw(ze),prop:ZJ})),eY=Ww()(rw({storageType:ZJ.optional(),storagePath:ZJ.optional(),storageProp:$J.array(),listenToChildren:qC()}));Ww()(rw({declarationString:xC().optional(),inputFieldType:ZJ.optional(),templateName:ZJ.optional(),bindTarget:eY.optional(),arguments:QJ.array(),errorCollection:Bw(Tn)})),Ww()(rw({declarationString:xC().optional(),templateDeclaration:tw(aw([xC(),eY])).optional(),viewFieldType:ZJ.optional(),arguments:QJ.array(),writeToBindTarget:eY.optional(),errorCollection:Bw(Tn)}));var tY=Ww()(rw({storageType:xC(),storagePath:xC(),storageProp:Bw(K_),listenToChildren:qC()})),nY=Ww()(rw({name:xC(),value:xC().array()}));Ww()(rw({type:pw(ze),prop:xC()}));var rY=Ww()(rw({inputFieldType:GJ.optional(),templateName:xC().optional(),bindTarget:tY.optional(),arguments:nY.array().optional()})),iY=Ww()(rw({viewFieldType:GJ.optional(),templateDeclaration:aw([xC(),tY]).array().optional(),arguments:nY.array().optional(),writeToBindTarget:tY.optional()})),aY=Ww()(rw({bindTarget:tY,name:xC()})),oY=Ww()(rw({bindTargetMappings:aY.array(),writeToBindTarget:tY.optional(),code:xC()})),sY=Ww()(rw({referencedButtonIds:xC().array()})),cY=Ww()(rw({renderChildType:UJ,declaration:aw([xC(),rY]),scope:qJ.optional()})),lY=Ww()(rw({renderChildType:UJ,declaration:aw([xC(),iY]),scope:qJ.optional()})),uY=Ww()(rw({declaration:aw([xC(),oY])})),dY=Ww()(rw({bindTarget:tY,tableHead:xC().array(),columns:tw(aw([rY,iY,xC()]))})),fY=Ww()(rw({renderChildType:UJ,declaration:aw([xC(),sY]),position:YJ.optional()})),pY=Ww()(rw({declaration:aw([xC(),vT]),position:YJ.optional(),isPreview:qC()})),mY=Ww()(rw({depth:UC(),content:xC()})),hY=K(``);function gY(e,t){ii(t,!0);let n=tc(t,`variant`,19,()=>It.DEFAULT),r=tc(t,`disabled`,7,!1),i=tc(t,`tooltip`,3,``),a=tc(t,`label`,3,``),o=tc(t,`icon`,3,``),s=tc(t,`cssStyle`,3,``),c=tc(t,`backgroundImage`,3,``),l=tc(t,`error`,3,!1),u=tc(t,`onclick`,3,()=>{}),d=tc(t,`onauxclick`,3,()=>{});async function f(e,t){if(!r()){r(!0);try{t===zt.LEFT?await u()(e):t===zt.MIDDLE&&await d()(e)}catch(e){console.warn(`failed to run button component on click`,e)}finally{r(!1)}}}var p=hY();let m,h;var g=U(p),_=e=>{Ch(e,{get mb(){return t.mb},get iconName(){return o()}})};fs(g,e=>{o()&&e(_)});var v=W(g);V(p),Ya(()=>{m=Ms(p,1,`mb-button-inner`,null,m,{"mod-cta":n()===It.PRIMARY,"mod-warning":n()===It.DESTRUCTIVE,"mod-plain":n()===It.PLAIN,disabled:r(),"mb-error":l()}),h=Ps(p,s(),h,{"background-image":c()?`url("${c()}")`:void 0}),Ks(p,`aria-label`,i()),p.disabled=r(),as(v,` ${a()??``}`)}),qo(`click`,p,e=>f(e,zt.LEFT)),Ko(`auxclick`,p,e=>f(e,zt.MIDDLE)),q(e,p),ai()}Jo([`click`]);var _Y=class extends oc{mb;config;filePath;isInline;position;buttonComponent;isInGroup;isPreview;constructor(e,t,n,r,i,a,o){super(),this.mb=e,this.config=t,this.filePath=n,this.isInline=r===de.INLINE,this.position=i,this.isInGroup=a,this.isPreview=o}onMount(e){k.empty(e),k.removeAllClasses(e),k.addClasses(e,[`mb-button`,this.isInline?`mb-button-inline`:`mb-button-block`]),!(!this.isInline&&!this.isPreview&&!this.isInGroup&&(this.config.id&&this.mb.buttonManager.addButton(this.filePath,this.config),this.config.hidden))&&(this.config.class&&k.addClasses(e,this.config.class.split(` `).filter(e=>e!==``)),this.buttonComponent=os(gY,{target:e,props:{mb:this.mb,icon:this.config.icon,variant:this.config.style,label:this.config.label,tooltip:S(this.config.tooltip)?this.config.tooltip:void 0,cssStyle:this.config.cssStyle,backgroundImage:S(this.config.backgroundImage)?this.mb.internal.imagePathToUri(this.config.backgroundImage):void 0,onclick:async e=>{await this.mb.buttonActionRunner.runButtonActions(this.config,this.filePath,this.getContext(),Rt.fromMouseEvent(e,zt.LEFT))},onauxclick:async e=>{await this.mb.buttonActionRunner.runButtonActions(this.config,this.filePath,this.getContext(),Rt.fromMouseEvent(e,zt.LEFT))}}}))}getContext(){return{position:this.position?.getPosition(),isInGroup:this.isInGroup,isInline:this.isInline}}onUnmount(){this.buttonComponent&&us(this.buttonComponent),!this.isInline&&!this.isPreview&&this.config?.id&&this.mb.buttonManager.removeButton(this.filePath,this.config.id)}},vY=class extends oc{mb;referencedIds;filePath;renderChildType;notePosition;constructor(e,t,n,r,i){super(),this.mb=e,this.referencedIds=t,this.filePath=n,this.renderChildType=r,this.notePosition=i}renderInitialButton(e,t){return k.removeAllClasses(e),k.addClasses(e,[`mb-button`,this.renderChildType===de.INLINE?`mb-button-inline`:`mb-button-block`]),os(gY,{target:e,props:{mb:this.mb,variant:It.DEFAULT,label:`Button ID not Found`,tooltip:`No button with id '${t}' found`,error:!0,onclick:async()=>{}}})}onMount(e){k.empty(e),k.addClasses(e,[`mb-button-group`,this.renderChildType===de.INLINE?`mb-button-group-inline`:`mb-button-group-block`]);for(let t of this.referencedIds){let n=k.createElement(e,`span`),r=this.renderInitialButton(n,t),i,a=this.mb.buttonManager.registerButtonLoadListener(this.filePath,t,e=>{r&&us(r),r=void 0,i=new _Y(this.mb,e,this.filePath,this.renderChildType,this.notePosition,!0,!1),i.mount(n)});this.registerUnmountCb(()=>{r&&us(r),r=void 0,i?.unmount(),a()})}}onUnmount(e){k.empty(e)}},yY=class extends BJ{errorCollection;declaration;buttonField;renderChildType;position;constructor(e,t,n,r,i,a){super(e,t,n),this.declaration=r,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(r.errorCollection),this.renderChildType=i,this.position=a}onMount(e){if(super.onMount(e),k.removeAllClasses(e),this.declaration.errorCollection.isEmpty())try{this.buttonField=new vY(this.mb,this.declaration.referencedButtonIds,this.getFilePath(),this.renderChildType,this.position),this.buttonField.mount(e)}catch(t){this.errorCollection.add(t),this.renderErrorIndicator(e)}else this.renderErrorIndicator(e)}renderErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declaration.declarationString})}onUnmount(e){super.onUnmount(e),this.buttonField?.unmount(),O(e,`inline button`)}},bY=class extends BJ{errorCollection;declaration;position;buttonField;isPreview;constructor(e,t,n,r,i,a){super(e,t,n),this.declaration=r,this.position=i,this.isPreview=a,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(r.errorCollection)}onMount(e){if(super.onMount(e),k.removeAllClasses(e),this.declaration.config&&this.declaration.errorCollection.isEmpty())try{this.buttonField=new _Y(this.mb,this.declaration.config,this.getFilePath(),de.BLOCK,this.position,!1,this.isPreview),this.buttonField.mount(e)}catch(t){this.errorCollection.add(t),this.renderErrorIndicator(e)}else this.renderErrorIndicator(e)}renderErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declaration.declarationString})}onUnmount(e){super.onUnmount(e),this.buttonField?.unmount(),O(e,`button`)}},xY=class extends BJ{depth;content;markdownUnloadCallback;constructor(e,t,n,r,i){super(e,t,n),this.depth=r,this.content=i}async parseContent(){let e=this.content.split(` `).map(e=>e.trim()).filter(e=>e.length>0);if(e.length===0)return{content:``};if(e.length>1)return{error:`Embed may only contain one link`};let t=e[0],n=rn.parseLink(t);if(!n.internal)return{error:`${t} is not an internal link`};let r=this.mb.file.getPathByName(n.target,this.getFilePath());return r===void 0?{error:`"${n.target}" is not created yet`}:{content:await this.mb.file.read(r)}}exceedsMaxDepth(){return this.depth>8}createEmbedMessage(e,t){k.createElement(e,`span`,{text:t,class:`mb-embed-message`})}async renderContent(e){try{if(this.exceedsMaxDepth()){this.createEmbedMessage(e,`Max embed depth exceeded`);return}let t=await this.parseContent();if(t.error){this.createEmbedMessage(e,t.error);return}if(t.content===void 0){this.createEmbedMessage(e,`Embed content not found`);return}let n=t.content.replace(/(```+|~~~+)meta-bind-embed.*/g,`$1meta-bind-embed-internal-${this.depth+1}`);this.markdownUnloadCallback=await this.mb.internal.renderMarkdown(n,e,this.getFilePath())}catch(t){let n=new Tn(`Embed`);n.add(t),this.mb.internal.createErrorIndicator(e,{errorCollection:n})}}onMount(e){super.onMount(e),k.addClass(e,`mb-embed`),this.renderContent(e)}onUnmount(e){super.onUnmount(e),k.removeClass(e,`mb-embed`),this.markdownUnloadCallback?.(),O(e,`Embed`)}},SY=class extends BJ{constructor(e,t,n){super(e,t,n)}onMount(e){super.onMount(e),k.empty(e),k.createElement(e,`span`,{text:`[META_BIND] This folder has been excluded in the settings`,class:`mb-error`})}onUnmount(e){super.onUnmount(e),k.empty(e),O(e,`Excluded`)}},CY=class extends BJ{renderChildType;errorCollection;inputField;declarationString;declaration;constructor(e,t,n,r,i){super(e,t,n),this.renderChildType=r,this.declaration=i,this.declarationString=i.declarationString,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(i.errorCollection)}hasArgument(e){return this.getArguments(e).length>0}getArgument(e){return this.getArguments(e).at(0)}getArguments(e){if(this.declaration.errorCollection.hasErrors())throw new _e({errorLevel:B.CRITICAL,effect:`can not retrieve arguments`,cause:`inputFieldDeclaration has errors`});return this.declaration.argumentContainer.getAll(e)}getBindTarget(){return this.declaration.bindTarget}shouldAddCardContainer(){let e=this.declaration.inputFieldType===On.SELECT||this.declaration.inputFieldType===On.MULTI_SELECT||this.declaration.inputFieldType===On.LIST,t=this.hasArgument(kn.SHOWCASE)||this.hasArgument(kn.TITLE);return this.renderChildType===de.BLOCK&&(e||t)}createContainer(e){if(this.shouldAddCardContainer()){let t=k.createElement(e,`div`);k.addClass(t,`mb-card`);let n=this.getArgument(kn.TITLE);return n&&k.createElement(t,`h3`,{text:n.value}),t}return e}addShowcase(e){if(this.getArgument(kn.SHOWCASE)&&this.shouldAddCardContainer()){let t=k.createElement(e,`code`,{class:`mb-none`}),n=k.createElement(t,`a`,{text:this.declarationString,class:`mb-no-link`});n.href=o_.linkToInputField(this.declaration.inputFieldType)}}createInputField(){if(!this.errorCollection.hasErrors())try{this.inputField=this.mb.inputFieldFactory.createInputField(this)}catch(e){this.errorCollection.add(e)}!this.errorCollection.hasErrors()&&!this.inputField&&this.errorCollection.add(new _e({errorLevel:B.CRITICAL,effect:`can't render input field`,cause:`input field is undefined`}))}createErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declarationString})}onMount(e){if(super.onMount(e),k.empty(e),k.addClass(e,`mb-input`),this.createInputField(),this.errorCollection.hasErrors()){this.createErrorIndicator(e);return}let t=this.createContainer(e);this.createErrorIndicator(t);let n=k.createElement(t,`div`,{class:`mb-input-wrapper`});this.inputField?.mount(n);let r=this.getArguments(kn.CLASS);for(let e of r)k.addClasses(n,e.value);k.addClass(n,`mb-input-type-${this.declaration.inputFieldType}`),this.renderChildType===de.BLOCK?k.addClass(e,`mb-input-block`):k.addClass(e,`mb-input-inline`),this.addShowcase(t)}onUnmount(e){super.onUnmount(e),this.inputField?.unmount(),O(e,`input field`)}};function wY(e){return new K_(e.map(e=>Yt.tryParse(e).success?new Ue(ze.ARRAY,e):new Ue(ze.OBJECT,e)))}var TY=K(`
`);function EY(e,t){ii(t,!0);let n,r;Ua(()=>{r?.unmount(),r=t.mountable,r.mount(n)}),rc(()=>{r?.unmount()});var i=TY();ec(i,e=>n=e,()=>n),q(e,i),ai()}var DY=K(` `),OY=K(``),kY=K(`invalid data`),AY=K(``),jY=K(`
`,1);function MY(e,t){ii(t,!0);let n=tc(t,`tableHead`,19,()=>[]),r=da(va([]));function i(e){pa(r,e,!0)}var a={updateTable:i},o=jY(),s=Oa(o),c=U(s),l=U(c),u=U(l);_s(U(u),17,n,ps,(e,t)=>{var n=DY(),r=U(n,!0);V(n),Ya(()=>as(r,G(t))),q(e,n)}),Gr(),V(u),V(l);var d=W(l);return _s(d,21,()=>G(r),e=>e.index,(e,r)=>{var i=AY(),a=U(i),o=e=>{var t=is();_s(Oa(t),17,()=>G(r).cells,ps,(e,t)=>{var n=OY();EY(U(n),{get mountable(){return G(t)}}),V(n),q(e,n)}),q(e,t)},s=e=>{var t=kY();Ya(()=>Ks(t,`colspan`,n().length)),q(e,t)};fs(a,e=>{G(r).isValid?e(o):e(s,-1)});var c=W(a);Lh(U(c),{onclick:()=>t.table.removeColumn(G(r).index),children:(e,n)=>{Ch(e,{get mb(){return t.table.mb},iconName:`x`})},$$slots:{default:!0}}),V(c),V(i),q(e,i)}),V(d),V(c),V(s),Lh(W(s,2),{onclick:()=>t.table.addColumn(),children:(e,t)=>{Gr(),q(e,rs(`Add Row`))},$$slots:{default:!0}}),q(e,o),ai(a)}var NY=class extends BJ{bindTarget;tableHead;columns;tableComponent;inputSignal;metadataSubscription;constructor(e,t,n,r,i,a){super(e,t,n),this.bindTarget=r,this.tableHead=i,this.columns=a,this.inputSignal=new cc(void 0)}registerSelfToMetadataManager(){this.metadataSubscription=this.mb.metadataManager.subscribe(this.getUuid(),this.inputSignal,this.bindTarget,()=>this.unmount())}unregisterSelfFromMetadataManager(){this.metadataSubscription?.unsubscribe()}updateMetadataManager(e){this.metadataSubscription?.write(e)}getValue(){return this.parseTableData(this.metadataSubscription?.read())}parseTableData(e){return Array.isArray(e)?e:[]}updateDisplayValue(e){e??=[];let t=[];for(let n=0;n{if(typeof e==`string`)return this.mb.api.createInlineFieldFromString(e,this.getFilePath(),r,de.INLINE);if(`inputFieldType`in e)return this.mb.api.createInputFieldMountable(this.getFilePath(),{declaration:e,scope:r,renderChildType:de.INLINE});if(`viewFieldType`in e)return this.mb.api.createViewFieldMountable(this.getFilePath(),{declaration:e,scope:r,renderChildType:de.INLINE});throw Error(`Unknown column type: ${JSON.stringify(e)}`)});t.push({cells:i,index:n,value:e[n],isValid:!0})}else t.push({cells:[],index:n,value:e[n],isValid:!1});this.tableComponent?.updateTable(t)}removeColumn(e){let t=this.getValue();t.splice(e,1),this.updateDisplayValue(t),this.updateMetadataManager(t)}addColumn(){let e=this.getValue();e.push({}),this.updateDisplayValue(e),this.updateMetadataManager(e)}onMount(e){super.onMount(e),this.tableComponent=os(MY,{target:e,props:{table:this,tableHead:this.tableHead}}),this.inputSignal.registerListener({callback:e=>{this.updateDisplayValue(this.parseTableData(e))}}),this.registerSelfToMetadataManager()}onUnmount(e){super.onUnmount(e),this.unregisterSelfFromMetadataManager(),this.tableComponent&&us(this.tableComponent),O(e,`table`)}},PY=class extends BJ{errorCollection;declarationString;declaration;variables;metadataSubscription;jsRenderer;constructor(e,t,n,r){super(e,t,n),this.declaration=r,this.declarationString=r.declarationString,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(r.errorCollection),this.variables=[],this.buildVariables()}buildVariables(){if(this.errorCollection.isEmpty())try{for(let e of this.declaration.bindTargetMappings??[])this.variables.push({bindTargetDeclaration:e.bindTarget,metadataSignal:new cc(void 0),uuid:w(),contextName:e.name})}catch(e){this.errorCollection.add(e)}}buildContext(){let e={};for(let t of this.variables??[])!t.contextName||!t.metadataSignal||(e[t.contextName]=t.metadataSignal.get());return e}async evaluate(){return this.jsRenderer?.evaluate({bound:this.buildContext()})}registerSelfToMetadataManager(){this.metadataSubscription=this.mb.metadataManager.subscribeDerived(this.getUuid(),this.declaration.writeToBindTarget,this.variables.map(e=>e.bindTargetDeclaration),this.variables.map(e=>e.metadataSignal),async()=>await this.evaluate(),()=>this.unmount())}unregisterSelfFromMetadataManager(){this.metadataSubscription?.unsubscribe()}createErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declarationString})}onMount(e){if(super.onMount(e),k.addClass(e,`mb-view`),k.empty(e),this.mb.internal.isJsEngineAvailable()||this.errorCollection.add(new Se({errorLevel:B.ERROR,effect:`can not create js view field`,cause:`The JS Engine plugin is not installed and enabled.`})),this.mb.getSettings().enableJs||this.errorCollection.add(new Se({errorLevel:B.CRITICAL,effect:`Can't evaluate expression.`,cause:`JS evaluation is disabled in the plugin settings.`})),this.createErrorIndicator(e),this.errorCollection.hasErrors())return;let t=document.createElement(`div`);k.addClass(t,`mb-view-wrapper`),k.addClass(e,`mb-view-rendered`),this.jsRenderer=this.mb.internal.createJsRenderer(t,this.getFilePath(),this.declaration.code,this.declaration.hidden),this.registerSelfToMetadataManager(),e.appendChild(t)}onUnmount(e){super.onUnmount(e),this.unregisterSelfFromMetadataManager(),O(e,`js view field`)}},FY=class extends BJ{renderChildType;errorCollection;viewField;declarationString;declaration;constructor(e,t,n,r,i){super(e,t,n),this.renderChildType=r,this.declaration=i,this.declarationString=i.declarationString,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(i.errorCollection)}hasArgument(e){return this.getArguments(e).length>0}getArgument(e){return this.getArguments(e).at(0)}getArguments(e){if(this.declaration.errorCollection.hasErrors())throw new _e({errorLevel:B.ERROR,effect:`an not retrieve arguments`,cause:`viewFieldDeclaration has errors`});return this.declaration.argumentContainer.getAll(e)}getDeclaration(){return this.declaration}createViewField(){if(!this.errorCollection.hasErrors())try{this.viewField=this.mb.viewFieldFactory.createViewField(this)}catch(e){this.errorCollection.add(e)}!this.errorCollection.hasErrors()&&!this.viewField&&this.errorCollection.add(new _e({errorLevel:B.CRITICAL,effect:`can't render view field`,cause:`view field is undefined`}))}createErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declarationString})}onMount(e){if(super.onMount(e),k.empty(e),k.addClass(e,`mb-view`),this.createViewField(),this.errorCollection.hasErrors()){this.createErrorIndicator(e);return}let t=document.createElement(`div`);k.addClass(t,`mb-view-wrapper`),k.addClass(e,`mb-view-rendered`);try{this.viewField?.mount(t)}catch(e){this.errorCollection.add(e)}this.createErrorIndicator(e),e.append(t);let n=this.getArguments(Pn.CLASS);for(let e of n)k.addClasses(t,e.value);k.addClass(t,`mb-view-type-${this.declaration.viewFieldType}`),this.renderChildType===de.BLOCK?k.addClass(e,`mb-view-block`):k.addClass(e,`mb-view-inline`)}onUnmount(e){super.onUnmount(e),this.viewField?.unmount(),O(e,`view field`)}},IY=class{mb;constructor(e){this.mb=e}createField(e,t,n,r=!0){if(Gw(rw({type:WJ,filePath:HJ,options:YC(),honorExcludedSetting:qC()}),{type:e,filePath:t,options:n,honorExcludedSetting:r}),this.mb.file.isExcludedFromRendering(t)&&r)return this.createExcludedMountable(t);if(e===fe.INPUT)return this.createInputFieldMountable(t,n);if(e===fe.VIEW)return this.createViewFieldMountable(t,n);if(e===fe.JS_VIEW)return this.createJsViewFieldMountable(t,n);if(e===fe.TABLE)return this.createTableMountable(t,n);if(e===fe.BUTTON_GROUP)return this.createButtonGroupMountable(t,n);if(e===fe.BUTTON)return this.createButtonMountable(t,n);if(e===fe.EMBED)return this.createEmbedMountable(t,n);if(e===fe.EXCLUDED)return this.createExcludedMountable(t);throw Error(`Unknown field type: ${e}`)}createInlineFieldFromString(e,t,n,r=de.INLINE,i,a=!0){Gw(rw({fieldString:xC(),filePath:HJ,scope:qJ.optional(),renderChildType:UJ,honorExcludedSetting:qC()}),{fieldString:e,filePath:t,scope:n,renderChildType:r,honorExcludedSetting:a});let o=this.isInlineFieldDeclarationAndGetType(e);if(o===void 0)throw new _e({errorLevel:B.CRITICAL,effect:`failed to create inline field`,cause:`Invalid inline mdrc type "${o}"`});return this.createInlineFieldOfTypeFromString(o,e,t,n,r,i,a)}createInlineFieldOfTypeFromString(e,t,n,r,i=de.INLINE,a,o=!0){if(Gw(rw({type:WJ,declaration:xC(),filePath:HJ,scope:qJ.optional(),renderChildType:UJ,honorExcludedSetting:qC()}),{type:e,declaration:t,filePath:n,scope:r,renderChildType:i,honorExcludedSetting:o}),this.mb.file.isExcludedFromRendering(n)&&o)return this.createExcludedMountable(n);if(e===fe.INPUT)return this.createInputFieldMountable(n,{renderChildType:i,declaration:t,scope:r});if(e===fe.VIEW)return this.createViewFieldMountable(n,{renderChildType:i,declaration:t,scope:r});if(e===fe.BUTTON_GROUP)return this.createButtonGroupMountable(n,{renderChildType:i,declaration:t,position:a});throw new _e({errorLevel:B.CRITICAL,effect:`failed to create inline field`,cause:`Invalid inline mdrc type "${e}"`})}createInputFieldMountable(e,t){Gw(rw({filePath:HJ,options:cY}),{filePath:e,options:t});let n=w(),r;return r=typeof t.declaration==`string`?this.mb.inputFieldParser.fromStringAndValidate(t.declaration,e,t.scope):this.mb.inputFieldParser.fromSimpleDeclarationAndValidate(t.declaration,e,t.scope),new CY(this.mb,n,e,t.renderChildType,r)}createViewFieldMountable(e,t){Gw(rw({filePath:HJ,options:lY}),{filePath:e,options:t});let n=w(),r;return r=typeof t.declaration==`string`?this.mb.viewFieldParser.fromStringAndValidate(t.declaration,e,t.scope):this.mb.viewFieldParser.fromSimpleDeclarationAndValidate(t.declaration,e,t.scope),new FY(this.mb,n,e,t.renderChildType,r)}createJsViewFieldMountable(e,t){Gw(rw({filePath:HJ,options:uY}),{filePath:e,options:t});let n=w(),r;return r=typeof t.declaration==`string`?this.mb.jsViewFieldParser.fromStringAndValidate(t.declaration,e):this.mb.jsViewFieldParser.fromSimpleDeclarationAndValidate(t.declaration,e),new PY(this.mb,n,e,r)}createTableMountable(e,t){Gw(rw({filePath:HJ,options:dY}),{filePath:e,options:t});let n=w();return new NY(this.mb,n,e,t.bindTarget,t.tableHead,t.columns)}createButtonGroupMountable(e,t){Gw(rw({filePath:HJ,options:fY}),{filePath:e,options:t});let n=w(),r;return r=typeof t.declaration==`string`?this.mb.buttonParser.fromGroupString(t.declaration):this.mb.buttonParser.validateGroup(t.declaration),new yY(this.mb,n,e,r,t.renderChildType,t.position)}createButtonMountable(e,t){Gw(rw({filePath:HJ,options:pY}),{filePath:e,options:t});let n=w(),r;return r=typeof t.declaration==`string`?this.mb.buttonParser.fromString(t.declaration):this.mb.buttonParser.validate(t.declaration),new bY(this.mb,n,e,r,t.position,t.isPreview)}createEmbedMountable(e,t){Gw(rw({filePath:HJ,options:mY}),{filePath:e,options:t});let n=w();return new xY(this.mb,n,e,t.depth,t.content)}createExcludedMountable(e){Gw(rw({filePath:HJ}),{filePath:e});let t=w();return new SY(this.mb,t,e)}getInlineFieldDeclarationPrefix(e){if(Gw(rw({fieldType:WJ}),{fieldType:e}),e===fe.INPUT)return`INPUT`;if(e===fe.VIEW)return`VIEW`;if(e===fe.BUTTON_GROUP)return`BUTTON`;throw new _e({errorLevel:B.CRITICAL,effect:`failed to get declaration prefix`,cause:`Invalid inline mdrc type "${e}"`})}isInlineFieldDeclaration(e,t){Gw(rw({fieldType:WJ,str:xC()}),{fieldType:e,str:t});let n=this.getInlineFieldDeclarationPrefix(e)+`[`;return t.startsWith(n)&&t.endsWith(`]`)}isInlineFieldDeclarationAndGetType(e){if(Gw(rw({str:xC()}),{str:e}),e.endsWith(`]`))for(let t of Object.values(fe)){if(!me(t))continue;let n=this.getInlineFieldDeclarationPrefix(t)+`[`;if(e.startsWith(n))return t}}createSignal(e){return new cc(e)}createBindTarget(e,t,n,r=!1){return Gw(rw({storageType:xC(),storagePath:xC(),property:xC().array(),listenToChildren:qC()}),{storageType:e,storagePath:t,property:n,listenToChildren:r}),{storageType:e,storagePath:t,storageProp:wY(n),listenToChildren:r}}parseBindTarget(e,t,n){return Gw(rw({declarationString:xC(),filePath:HJ,scope:qJ.optional()}),{declarationString:e,filePath:t,scope:n}),this.mb.bindTargetParser.fromStringAndValidate(e,t,n)}setMetadata(e,t){Gw(rw({bindTarget:tY}),{bindTarget:e}),this.mb.metadataManager.write(t,e)}getMetadata(e){return Gw(rw({bindTarget:tY}),{bindTarget:e}),this.mb.metadataManager.read(e)}updateMetadata(e,t){Gw(rw({bindTarget:tY,updateFn:Hw()}),{bindTarget:e,updateFn:t});let n=t(this.mb.metadataManager.read(e));this.mb.metadataManager.write(n,e)}subscribeToMetadata(e,t,n){Gw(rw({bindTarget:tY,lifecycleHook:this.mb.internal.getLifecycleHookValidator(),callback:Hw()}),{bindTarget:e,lifecycleHook:t,callback:n});let r=w(),i=new cc(void 0);i.registerListener({callback:n});let a=this.mb.metadataManager.subscribe(r,i,e,()=>{i.unregisterAllListeners()});t.register(()=>{a.unsubscribe()})}createNotePosition(e,t){return Gw(rw({lineStart:UC(),lineEnd:UC()}),{lineStart:e,lineEnd:t}),new pe({lineStart:e,lineEnd:t})}mathJSImport(e,t){this.mb.math.import(e,t)}},LY=class extends d.WidgetType{mb;type;content;filePath;parentComponent;renderChild;constructor(e,t,n,r,i){super(),this.type=e,this.content=t,this.filePath=n,this.parentComponent=r,this.mb=i}eq(e){return e.content===this.content}toDOM(e){let t=createSpan();t.addClass(`cm-inline-code`),t.addClass(`mb-inline-widget-rendered`);let n=this.mb.api.createInlineFieldOfTypeFromString(this.type,this.content,this.filePath,void 0);return this.renderChild=this.mb.api.wrapInMDRC(n,t,this.parentComponent),t}destroy(e){this.renderChild?.unload(),super.destroy(e)}},RY=class extends f.MarkdownRenderChild{mb;mountable;constructor(e,t,n){super(n),this.mb=e,this.mountable=t,this.mountable.registerUnmountCb(()=>{this.unload()})}onload(){this.containerEl.addClass(`interactive-child`),this.mountable.mount(this.containerEl),super.onload()}onunload(){this.mountable.isMounted()&&this.mountable.unmount(),super.onunload()}};function zY(e){return e.dependencyManager.checkDependency(`dataview`).api}function BY(e){return e.dependencyManager.checkDependency(`js-engine`).api}var VY=function(e){return e[e.CreateNewFromTemplate=0]=`CreateNewFromTemplate`,e[e.AppendActiveFile=1]=`AppendActiveFile`,e[e.OverwriteFile=2]=`OverwriteFile`,e[e.OverwriteActiveFile=3]=`OverwriteActiveFile`,e[e.DynamicProcessor=4]=`DynamicProcessor`,e[e.StartupTemplate=5]=`StartupTemplate`,e}({});function HY(e){return e.dependencyManager.checkDependency(`templater-obsidian`).templater}var UY=rw({addChild:Hw()}),WY=class extends IY{omb;constructor(e){super(e),this.omb=e}wrapInMDRC(e,t,n){Gw(rw({field:JJ,containerEl:KJ,component:UY}),{field:e,containerEl:t,component:n});let r=new RY(this.omb,e,t);return n.addChild(r),r}constructMDRCWidget(e,t,n,r){if(me(e))return new LY(e,t,n,r,this.omb);throw new _e({errorLevel:B.CRITICAL,effect:`failed to construct mdrc`,cause:`Invalid inline field type "${e}"`})}reactiveMetadata(e,t,n){Gw(rw({bindTargets:tY.array(),lifecycleHook:this.mb.internal.getLifecycleHookValidator(),callback:Hw()}),{bindTargets:e,lifecycleHook:t,callback:n});let r=BY(this.omb),i=w(),a=e.map(()=>new cc(void 0)),o=()=>Promise.resolve(),s=this.mb.metadataManager.subscribeEffect(i,e,a,()=>o(),()=>{});t.register(()=>s.unsubscribe());let c=r.reactive(n,...a.map(e=>e.get()));return o=()=>c.refresh(...a.map(e=>e.get())),c}},GY=class{mb;constructor(e){this.mb=e}getFrontmatterLocation(e){let t=e.split(` `);if(t.at(0)===`---`){for(let e=1;et(e))}async create(e,t,n,r=!1,i=!1){let a=this.app.vault.getAvailablePath((0,f.normalizePath)(e+`/`+t),n),o=await this.app.vault.create(a,``);return r&&await this.openInSourceMode(o,i),o.path}getAllFiles(){return this.app.vault.getAllLoadedFiles().filter(e=>e instanceof f.TFile).map(e=>e.path)}getAllFolders(){return this.app.vault.getAllLoadedFiles().filter(e=>e instanceof f.TFolder).map(e=>e.path)}async open(e,t,n){this.app.workspace.openLinkText(e,t,n)}async openInSourceMode(e,t){let n=this.app.workspace.getLeaf(t?`tab`:!1);n&&await n.openFile(e,{state:{mode:`source`}})}getPathByName(e,t=``){return this.app.metadataCache.getFirstLinkpathDest(e,t)?.path}},qY=class extends oc{modal;setModal(e){this.modal=e}closeModal(){if(this.modal!==void 0)this.modal.close();else throw new _e({errorLevel:B.CRITICAL,effect:`Failed to close modal`,cause:`Modal reference in ModalContent is undefined`})}},JY=K(`
`);function YY(e,t){let n=tc(t,`name`,3,``),r=tc(t,`description`,3,``),i=tc(t,`heading`,3,!1),a=tc(t,`vertical`,3,!1);var o=JY();let s;var c=U(o),l=U(c),u=U(l,!0);V(l);var d=W(l,2),f=U(d,!0);V(d),V(c);var p=W(c,2);let m;var h=U(p),g=e=>{var n=is();Cs(Oa(n),()=>t.children),q(e,n)};fs(h,e=>{t.children&&e(g)}),V(p),V(o),Ya(()=>{s=Ms(o,1,`setting-item`,null,s,{"setting-item-heading":i(),"mb-vertical":a()}),as(u,n()),as(f,r()),m=Ms(p,1,`setting-item-control`,null,m,{"mb-vertical-control":a()})}),q(e,o)}function XY(e,t){ii(t,!0);let n=tc(t,`action`,15);function r(){t.mb.internal.openCommandSelectModal(e=>{n(n().command=e.id,!0)})}{let t=ea(()=>n().command||`none`);YY(e,{get name(){return`Command: ${G(t)??``}`},description:`The command to execute when this action runs.`,children:(e,t)=>{Lh(e,{get variant(){return It.PRIMARY},onclick:()=>r(),children:(e,t)=>{Gr(),q(e,rs(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}ai()}var ZY=K(`
`);function QY(e,t){ii(t,!0);let n=tc(t,`checked`,15),r=ea(()=>n()??!1);var i=ZY();let a;var o=U(i);Us(o),V(i),Ya(()=>{a=Ms(i,1,`checkbox-container`,null,a,{"is-enabled":G(r)}),Ks(i,`aria-checked`,G(r)),Gs(o,G(r))}),qo(`click`,i,()=>n(!G(r))),qo(`keydown`,i,e=>{e.key===` `&&n(!G(r))}),q(e,i),ai()}Jo([`click`,`keydown`]);var $Y=K(``),eX=K(` `,1);function tX(e,t){ii(t,!0);let n=tc(t,`action`,15);function r(){t.mb.internal.openFolderSelectModal(e=>{n(n().folderPath=e,!0)})}var i=eX(),a=Oa(i);{let e=ea(()=>n().folderPath||`none`);YY(a,{get name(){return`Folder: ${G(e)??``}`},description:`The folder to create a new note in.`,children:(e,t)=>{Lh(e,{get variant(){return It.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),q(e,rs(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}var o=W(a,2);{let e=ea(()=>n().fileName||`default`);YY(o,{get name(){return`File name: ${G(e)??``}`},description:`The file name of the new note.`,children:(e,t)=>{var r=$Y();Us(r),Xs(r,()=>n().fileName,e=>n(n().fileName=e,!0)),q(e,r)},$$slots:{default:!0}})}var s=W(o,2);YY(s,{name:`Open note`,description:`Whether to open the new note after this action ran.`,children:(e,t)=>{QY(e,{get checked(){return n().openNote},set checked(e){n(n().openNote=e,!0)}})},$$slots:{default:!0}}),YY(W(s,2),{name:`Open if note already exists`,description:`Whether to open the note instead of creating a new one if the note already exists.`,children:(e,t)=>{QY(e,{get checked(){return n().openIfAlreadyExists},set checked(e){n(n().openIfAlreadyExists=e,!0)}})},$$slots:{default:!0}}),q(e,i),ai()}function nX(e,t){ii(t,!0);let n=tc(t,`action`,15);function r(){t.mb.internal.openMarkdownFileSelectModal(e=>{n(n().templateFile=e,!0)})}{let t=ea(()=>n().templateFile||`default`);YY(e,{get name(){return`File path: ${G(t)??``}`},description:`The path to the templater file, relative to the vault root.`,children:(e,t)=>{Lh(e,{get variant(){return It.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),q(e,rs(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}ai()}var rX=K(`
`,1);function iX(e,t){ii(t,!0);let n=tc(t,`action`,15);var r=rX(),i=Oa(r);YY(i,{name:`JS code`,description:`The JavaScript code to run.`});var a=W(i,2),o=U(a);Na(o),V(a),Xs(o,()=>n().code,e=>n(n().code=e,!0)),q(e,r),ai()}var aX=K(``);function oX(e,t){ii(t,!0);let n=tc(t,`action`,15);YY(e,{name:`Text`,description:`The text to input at the cursor.`,children:(e,t)=>{var r=aX();Us(r),Xs(r,()=>n().str,e=>n(n().str=e,!0)),q(e,r)},$$slots:{default:!0}}),ai()}var sX=K(``),cX=K(`
`,1);function lX(e,t){ii(t,!0);let n=tc(t,`action`,15);var r=cX(),i=Oa(r);YY(i,{name:`Line`,description:`The line number to insert at.`,children:(e,t)=>{var r=sX();Us(r),Xs(r,()=>n().line,e=>n(n().line=e,!0)),q(e,r)},$$slots:{default:!0}});var a=W(i,2);YY(a,{name:`Text to insert`,description:`The text to insert into the note.`});var o=W(a,2),s=U(o);Na(s),V(o),Xs(s,()=>n().value,e=>n(n().value=e,!0)),q(e,r),ai()}function uX(e,t){ii(t,!0);let n=tc(t,`action`,15);function r(){t.mb.internal.openFilteredFileSelectModal(e=>{n(n().file=e,!0)},e=>e.endsWith(`.js`))}YY(e,{name:`JS file`,description:`The JavaScript file to run.`,children:(e,t)=>{Lh(e,{get variant(){return It.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),q(e,rs(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}}),ai()}var dX=K(` `,1),fX=K(` `,1);function pX(e,t){ii(t,!0);let n=tc(t,`action`,15);function r(){t.mb.internal.openMarkdownFileSelectModal(e=>{n(n().link=e,!0)})}var i=fX(),a=Oa(i);YY(a,{name:`Link`,description:`The link to open.`,children:(e,i)=>{var a=dX(),o=Oa(a);Us(o),Lh(W(o,2),{get variant(){return It.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,n)=>{Ch(e,{iconName:`list`,get mb(){return t.mb}})},$$slots:{default:!0}}),Xs(o,()=>n().link,e=>n(n().link=e,!0)),q(e,a)},$$slots:{default:!0}}),YY(W(a,2),{name:`New tab`,description:`Whether to open the link in a new tab.`,children:(e,t)=>{QY(e,{get checked(){return n().newTab},set checked(e){n(n().newTab=e,!0)}})},$$slots:{default:!0}}),q(e,i),ai()}var mX=K(``),hX=K(``),gX=K(`
`,1);function _X(e,t){ii(t,!0);let n=tc(t,`action`,15);var r=gX(),i=Oa(r);YY(i,{name:`Regexp`,description:`The regexp to find replacements.`,children:(e,t)=>{var r=mX();Us(r),Xs(r,()=>n().regexp,e=>n(n().regexp=e,!0)),q(e,r)},$$slots:{default:!0}});var a=W(i,2);YY(a,{name:`Regexp flags`,description:`The regexp flags for this regexp.`,children:(e,t)=>{var r=hX();Us(r),Xs(r,()=>n().regexpFlags,e=>n(n().regexpFlags=e,!0)),q(e,r)},$$slots:{default:!0}});var o=W(a,2);YY(o,{name:`Replacement text`,description:`The text to replace the button with.`});var s=W(o,2),c=U(s);Na(c),V(s),Xs(c,()=>n().replacement,e=>n(n().replacement=e,!0)),q(e,r),ai()}var vX=K(``),yX=K(`
`,1);function bX(e,t){ii(t,!0);let n=tc(t,`action`,15);var r=yX(),i=Oa(r);YY(i,{name:`Line from`,description:`The line that marks the start of the area to replace.`,children:(e,t)=>{var r=vX();Us(r),Xs(r,()=>n().fromLine,e=>n(n().fromLine=e,!0)),q(e,r)},$$slots:{default:!0}});var a=W(i,2);YY(a,{name:`Line to`,description:`The line that marks the end of the area to replace.`,children:(e,t)=>{var r=vX();Us(r),Xs(r,()=>n().toLine,e=>n(n().toLine=e,!0)),q(e,r)},$$slots:{default:!0}});var o=W(a,2);YY(o,{name:`Replacement text`,description:`The text to replace the note section.`});var s=W(o,2),c=U(s);Na(c),V(s),Xs(c,()=>n().replacement,e=>n(n().replacement=e,!0)),q(e,r),ai()}var xX=K(`
`,1);function SX(e,t){ii(t,!0);let n=tc(t,`action`,15);var r=xX(),i=Oa(r);YY(i,{name:`Replacement text`,description:`The text to replace the match with.`});var a=W(i,2),o=U(a);Na(o),V(a),Xs(o,()=>n().replacement,e=>n(n().replacement=e,!0)),q(e,r),ai()}var CX=K(``);function wX(e,t){ii(t,!0);let n=tc(t,`action`,15);YY(e,{name:`Sleep time`,description:`The time to sleep in milliseconds.`,children:(e,t)=>{var r=CX();Us(r),Xs(r,()=>n().ms,e=>n(n().ms=e,!0)),q(e,r)},$$slots:{default:!0}}),ai()}var TX=K(``),EX=K(` `,1);function DX(e,t){ii(t,!0);let n=tc(t,`action`,15);function r(e){t.mb.internal.openFileSelectModal(t=>{e.templateFile=t})}function i(e){t.mb.internal.openFolderSelectModal(t=>{e.folderPath=t})}var a=EX(),o=Oa(a);{let e=ea(()=>n().templateFile||`none`);YY(o,{get name(){return`Template file: ${G(e)??``}`},description:`The template file to create a new note of.`,children:(e,t)=>{Lh(e,{get variant(){return It.PRIMARY},onclick:()=>r(n()),tooltip:`Select from vault`,children:(e,t)=>{Gr(),q(e,rs(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}var s=W(o,2);{let e=ea(()=>n().folderPath||`none`);YY(s,{get name(){return`Folder: ${G(e)??``}`},description:`The folder to create a new note in.`,children:(e,t)=>{Lh(e,{get variant(){return It.PRIMARY},onclick:()=>i(n()),tooltip:`Select from vault`,children:(e,t)=>{Gr(),q(e,rs(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}var c=W(s,2);{let e=ea(()=>n().fileName||`default`);YY(c,{get name(){return`File name: ${G(e)??``}`},description:`The file name of the new note.`,children:(e,t)=>{var r=TX();Us(r),Xs(r,()=>n().fileName,e=>n(n().fileName=e,!0)),q(e,r)},$$slots:{default:!0}})}var l=W(c,2);YY(l,{name:`Open note`,description:`Whether to open the new note after this action ran.`,children:(e,t)=>{QY(e,{get checked(){return n().openNote},set checked(e){n(n().openNote=e,!0)}})},$$slots:{default:!0}}),YY(W(l,2),{name:`Open if note already exists`,description:`Whether to open the note instead of creating a new one if the note already exists.`,children:(e,t)=>{QY(e,{get checked(){return n().openIfAlreadyExists},set checked(e){n(n().openIfAlreadyExists=e,!0)}})},$$slots:{default:!0}}),q(e,a),ai()}var OX=K(``),kX=K(` `,1);function AX(e,t){ii(t,!0);let n=tc(t,`action`,15);var r=kX(),i=Oa(r);YY(i,{name:`Metadata property`,description:`The metadata property in form of a bind target.`,children:(e,t)=>{var r=OX();Us(r),Xs(r,()=>n().bindTarget,e=>n(n().bindTarget=e,!0)),q(e,r)},$$slots:{default:!0}});var a=W(i,2);YY(a,{name:`Value`,description:`The new value.`,children:(e,t)=>{var r=OX();Us(r),Xs(r,()=>n().value,e=>n(n().value=e,!0)),q(e,r)},$$slots:{default:!0}}),YY(W(a,2),{name:`Evaluate`,description:`Whether to evaluate the value as a JS expression.`,children:(e,t)=>{QY(e,{get checked(){return n().evaluate},set checked(e){n(n().evaluate=e,!0)}})},$$slots:{default:!0}}),q(e,r),ai()}var jX=K(`
`);function MX(e,t){ii(t,!0);let n=tc(t,`reverse`,3,!1),r=tc(t,`stretchChildren`,3,!1),i=ea(()=>[n()?`mb-flex-row-reverse`:`mb-flex-row`,r()?`mb-flex-row-stretch`:``].join(` `));var a=jX();Cs(U(a),()=>t.children),V(a),Ya(()=>Ms(a,1,Es(G(i)))),q(e,a),ai()}var NX=K(``);function PX(e,t){var n=NX();Cs(U(n),()=>t.children),V(n),q(e,n)}var FX=K(``),IX=K(``),LX=K(``),RX=K(` `,1),zX=K(`
`,1),BX=K(` `,1),VX=K(` `,1),HX=K(`

Actions

Add action of type

Preview

`,1);function UX(e,t){ii(t,!0);let n=va(t.buttonConfig),r,i,a=da(va(Lt.COMMAND));rc(()=>{i?.unmount()}),Ua(()=>{i?.unmount(),r&&(k.empty(r),i=new _Y(t.mb,ei(n),``,de.BLOCK,void 0,!1,!0),i.mount(r))});function o(){n.actions?.push(t.mb.buttonActionRunner.createDefaultAction(G(a)))}function s(e){n.actions?.splice(e,1)}function c(e){return t.mb.buttonActionRunner.getActionLabel(e)}function l(e,r){if(n.actions===void 0)return;let i=[];e>0&&i.push({name:`Move up`,icon:`arrow-up`,onclick:()=>{if(n.actions===void 0)return;let t=n.actions[e-1];n.actions[e-1]=n.actions[e],n.actions[e]=t}}),e{if(n.actions===void 0)return;let t=n.actions[e+1];n.actions[e+1]=n.actions[e],n.actions[e]=t}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>s(e)}),t.mb.internal.createContextMenu(i).showWithEvent(r)}function u(){t.mb.internal.openImageFileSelectModal(e=>{n.backgroundImage=e})}function d(){n.backgroundImage=void 0}var f=HX(),p=Oa(f);YY(p,{name:`Label`,description:`The label shown on the button.`,children:(e,t)=>{var r=FX();Us(r),Xs(r,()=>n.label,e=>n.label=e),q(e,r)},$$slots:{default:!0}});var m=W(p,2);YY(m,{name:`Icon`,description:`The icon shown on the button. If left empty, no icon will show`,children:(e,t)=>{var r=FX();Us(r),Xs(r,()=>n.icon,e=>n.icon=e),q(e,r)},$$slots:{default:!0}});var h=W(m,2);YY(h,{name:`Style`,description:`The style variant of the button`,children:(e,t)=>{var r=LX();_s(r,21,()=>Object.values(It),ps,(e,t)=>{var n=IX(),r=U(n,!0);V(n);var i={};Ya(()=>{as(r,G(t)),i!==(i=G(t))&&(n.value=(n.__value=G(t))??``)}),q(e,n)}),V(r),Ls(r,()=>n.style,e=>n.style=e),q(e,r)},$$slots:{default:!0}});var g=W(h,2);YY(g,{name:`CSS classes`,description:`A list of CSS classes to add to the button. Multiple classes should be separated by a space.`,children:(e,t)=>{var r=FX();Us(r),Xs(r,()=>n.class,e=>n.class=e),q(e,r)},$$slots:{default:!0}});var _=W(g,2);YY(_,{name:`CSS styles`,description:`CSS styles to directly apply to the button.`,children:(e,t)=>{var r=FX();Us(r),Xs(r,()=>n.cssStyle,e=>n.cssStyle=e),q(e,r)},$$slots:{default:!0}});var v=W(_,2);YY(v,{name:`Background image`,description:`A background image to use in the button.`,children:(e,r)=>{var i=RX(),a=Oa(i),o=U(a,!0);V(a);var s=W(a,2);Lh(s,{get variant(){return It.PRIMARY},onclick:()=>u(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),q(e,rs(`Change`))},$$slots:{default:!0}}),Lh(W(s,2),{get variant(){return It.DEFAULT},onclick:()=>d(),tooltip:`Reset to none`,children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`x`})},$$slots:{default:!0}}),Ya(()=>as(o,n.backgroundImage||`none`)),q(e,i)},$$slots:{default:!0}});var y=W(v,2);YY(y,{name:`Tooltip`,description:`A tooltip to show when hovering the button. If not set, the button label will be shown instead.`,children:(e,t)=>{var r=FX();Us(r),Xs(r,()=>n.tooltip,e=>n.tooltip=e),q(e,r)},$$slots:{default:!0}});var b=W(y,2);YY(b,{name:`ID`,description:`An ID that allows the button to be referenced in inline buttons.`,children:(e,t)=>{var r=FX();Us(r),Xs(r,()=>n.id,e=>n.id=e),q(e,r)},$$slots:{default:!0}});var x=W(b,2);YY(x,{name:`Hidden`,description:`Whether to not render this button. This can be useful when using inline buttons.`,children:(e,t)=>{QY(e,{get checked(){return n.hidden},set checked(e){n.hidden=e}})},$$slots:{default:!0}});var S=W(x,4);_s(S,21,()=>Object.values(Lt),ps,(e,t)=>{var n=IX(),r=U(n,!0);V(n);var i={};Ya(()=>{as(r,G(t)),i!==(i=G(t))&&(n.value=(n.__value=G(t))??``)}),q(e,n)}),V(S);var C=W(S,2);Lh(C,{get variant(){return It.PRIMARY},onclick:()=>o(),children:(e,t)=>{Gr(),q(e,rs(`Add Action`))},$$slots:{default:!0}});var w=W(C,2),T=e=>{var r=is();_s(Oa(r),17,()=>n.actions??[],ps,(e,r,i)=>{var a=BX(),o=Oa(a);MX(o,{children:(e,n)=>{var a=zX(),o=Oa(a),s=U(o,!0);V(o),Lh(W(o,2),{get variant(){return It.PLAIN},onclick:e=>l(i,e),children:(e,n)=>{Ch(e,{iconName:`more-vertical`,get mb(){return t.mb}})},$$slots:{default:!0}}),Ya(e=>as(s,e),[()=>c(G(r).type)]),q(e,a)},$$slots:{default:!0}});var s=W(o,2),u=e=>{XY(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(s,e=>{G(r).type===Lt.COMMAND&&e(u)});var d=W(s,2),f=e=>{pX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(d,e=>{G(r).type===Lt.OPEN&&e(f)});var p=W(d,2),m=e=>{uX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(p,e=>{G(r).type===Lt.JS&&e(m)});var h=W(p,2),g=e=>{oX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(h,e=>{G(r).type===Lt.INPUT&&e(g)});var _=W(h,2),v=e=>{wX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(_,e=>{G(r).type===Lt.SLEEP&&e(v)});var y=W(_,2),b=e=>{DX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(y,e=>{G(r).type===Lt.TEMPLATER_CREATE_NOTE&&e(b)});var x=W(y,2),S=e=>{AX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(x,e=>{G(r).type===Lt.UPDATE_METADATA&&e(S)});var C=W(x,2),w=e=>{tX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(C,e=>{G(r).type===Lt.CREATE_NOTE&&e(w)});var T=W(C,2),E=e=>{nX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(T,e=>{G(r).type===Lt.RUN_TEMPLATER_FILE&&e(E)});var D=W(T,2),O=e=>{bX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(D,e=>{G(r).type===Lt.REPLACE_IN_NOTE&&e(O)});var k=W(D,2),A=e=>{_X(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(k,e=>{G(r).type===Lt.REGEXP_REPLACE_IN_NOTE&&e(A)});var j=W(k,2),M=e=>{SX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(j,e=>{G(r).type===Lt.REPLACE_SELF&&e(M)});var N=W(j,2),ee=e=>{lX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(N,e=>{G(r).type===Lt.INSERT_INTO_NOTE&&e(ee)});var te=W(N,2),ne=e=>{iX(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};fs(te,e=>{G(r).type===Lt.INLINE_JS&&e(ne)}),q(e,a)}),q(e,r)};fs(w,e=>{n.actions&&e(T)});var E=W(w,4);ec(E,e=>r=e,()=>r),PX(W(E,2),{children:(e,r)=>{var i=VX(),a=Oa(i);Lh(a,{get variant(){return It.PRIMARY},onclick:()=>t.modal.okay(ei(n)),children:(e,n)=>{Gr();var r=rs();Ya(()=>as(r,t.modal.options.submitText)),q(e,r)},$$slots:{default:!0}}),Lh(W(a,2),{get variant(){return It.DEFAULT},onclick:()=>t.modal.cancel(),children:(e,t)=>{Gr(),q(e,rs(`Cancel`))},$$slots:{default:!0}}),q(e,i)},$$slots:{default:!0}}),Ls(S,()=>G(a),e=>pa(a,e)),q(e,f),ai()}var WX=class extends qY{mb;component;options;constructor(e,t){super(),this.mb=e,this.options=t}onMount(e){k.empty(e),this.component&&us(this.component),this.component=os(UX,{target:e,props:{mb:this.mb,modal:this,buttonConfig:this.options.config??this.mb.buttonActionRunner.createDefaultButtonConfig()}})}onUnmount(e){k.empty(e),this.component&&us(this.component)}okay(e){this.closeModal(),this.options.onOkay(e)}cancel(){this.closeModal()}},GX=class extends qY{component;createComponent;constructor(e){super(),this.createComponent=e}onMount(e){k.empty(e),this.component=this.createComponent(this,e)}onUnmount(e){this.component&&us(this.component),k.empty(e)}},KX=class{mb;selectCallback;constructor(e,t){this.mb=e,this.selectCallback=t}onSelected(e){this.selectCallback(e)}},qX=class extends KX{getItemText(e){return e.name}getItemDescription(e){}getItems(){return this.mb.internal.getAllCommands()}},JX=class extends KX{filterFunction;constructor(e,t,n){super(e,t),this.filterFunction=n}getItemText(e){return e}getItemDescription(e){}getItems(){return this.filterFunction===void 0?this.mb.file.getAllFiles():this.mb.file.getAllFiles().filter(e=>this.filterFunction(e))}},YX=class extends KX{getItemText(e){return e}getItemDescription(e){}getItems(){return this.mb.file.getAllFolders()}},XX=class extends KX{ipf;constructor(e,t,n){super(e,t),this.ipf=n}getItemText(e){return e.displayValue}getItemDescription(e){return e.displayDescription}getItems(){return this.mb.internal.getSuggesterOptions(this.ipf)}},ZX=K(`
`),QX=K(`
`),$X=K(`
`);function eZ(e,t){ii(t,!0);let n=ea(()=>dE(t.month,t.year));function r(e){e&&t.dateChange(J(new Date(t.year,t.month,e)))}function i(e,t){e.key===` `&&r(t)}var a=$X(),o=U(a);_s(o,21,pE,ps,(e,t)=>{var n=ZX(),r=U(n),i=U(r,!0);V(r),V(n),Ya(()=>as(i,G(t))),q(e,n)}),V(o);var s=W(o,2);_s(s,21,()=>G(n),ps,(e,n)=>{var a=QX();let o;var s=U(a),c=U(s,!0);V(s),V(a),Ya(e=>{o=Ms(a,1,`mb-calendar-cell`,null,o,e),as(c,G(n)||``)},[()=>({"mb-calendar-highlight":G(n),"mb-calendar-content-cell":G(n),"mb-calendar-selected":t.selectedDate?.year()===t.year&&t.selectedDate?.month()===t.month&&t.selectedDate?.date()===G(n)})]),qo(`click`,a,()=>r(G(n))),qo(`keydown`,a,e=>i(e,G(n))),q(e,a)}),V(s),V(a),q(e,a),ai()}Jo([`click`,`keydown`]);var tZ=K(`
`);function nZ(e,t){ii(t,!0);let n=tc(t,`selectedDate`,23,J),r=da(0),i=da(0);Ua(()=>{if(n())pa(r,n().month(),!0),pa(i,n().year(),!0);else{let e=J();pa(r,e.month(),!0),pa(i,e.year(),!0)}});function a(){if(G(r)===11){pa(r,0),pa(i,G(i)+1);return}pa(r,G(r)+1)}function o(){if(G(r)===0){pa(r,11),pa(i,G(i)-1);return}pa(r,G(r)-1)}function s(e){let t=e.target.value,n=Number.parseInt(t);Number.isNaN(n)||pa(i,n,!0)}function c(e){n(e),t.dateChangeCallback(e)}function l(){n(null),t.dateChangeCallback(null)}function u(){n(J()),t.dateChangeCallback(n())}var d=tZ(),f=U(d),p=U(f),m=W(p,2),h=U(m),g=U(h,!0);V(h);var _=W(h,2);Us(_),V(m);var v=W(m,2);V(f);var y=W(f,2);eZ(y,{dateChange:c,get month(){return G(r)},get year(){return G(i)},get selectedDate(){return n()}});var b=W(y,2),x=U(b),S=W(x,2);V(b),V(d),Ya((e,t)=>{as(g,e),Ws(_,t)},[()=>uE(G(r)),()=>G(i).toString()]),qo(`click`,p,o),qo(`input`,_,s),qo(`click`,v,a),qo(`click`,x,l),qo(`click`,S,u),q(e,d),ai()}Jo([`click`,`input`]),new Set([`$$slots`,`$$events`,`$$legacy`]);var rZ=K(`
`);function iZ(e,t){ii(t,!0);function n(e,n){e.key===` `&&t.onSelect(n)}var r=rZ(),i=U(r),a=W(i,2),o=U(a),s=U(o,!0);V(o),V(a),V(r),Ya(e=>{Ks(i,`src`,e),Ks(i,`alt`,t.image),as(s,t.image)},[()=>t.mb.internal.imagePathToUri(t.image)]),qo(`click`,r,()=>t.onSelect(t.image)),qo(`keydown`,r,e=>n(e,t.image)),q(e,r),ai()}Jo([`click`,`keydown`]);var aZ=K(` `,1),oZ=K(`
`,1);function sZ(e,t){ii(t,!0);let n=da(``),r=t.mb.internal.createFuzzySearch(),i=ea(()=>G(n)?(r.setSearch(G(n)),r.filterItems(t.options,e=>e.value)):t.options);var a=oZ(),o=Oa(a),s=U(o);Us(s),V(o);var c=W(o,2);_s(c,21,()=>G(i),ps,(e,n)=>{iZ(e,{get mb(){return t.mb},get image(){return G(n).value},get onSelect(){return t.onSelect}})}),V(c),PX(W(c,2),{children:(e,n)=>{var r=aZ(),i=Oa(r),a=e=>{Lh(e,{get variant(){return It.PRIMARY},onclick:()=>t.onSelect(void 0),children:(e,t)=>{Gr(),q(e,rs(`Select none`))},$$slots:{default:!0}})};fs(i,e=>{t.canSelectNone&&e(a)}),Lh(W(i,2),{onclick:()=>t.onCancel(),children:(e,t)=>{Gr(),q(e,rs(`Cancel`))},$$slots:{default:!0}}),q(e,r)},$$slots:{default:!0}}),Xs(s,()=>G(n),e=>pa(n,e)),q(e,a),ai()}var cZ=K(``),lZ=K(``),uZ=K(` `,1),dZ=K(`

`,1);function fZ(e,t){ii(t,!0);let n=da(va(t.options.value));var r=dZ(),i=Oa(r),a=U(i,!0);V(i);var o=W(i,2),s=U(o),c=e=>{var t=cZ();Na(t),Xs(t,()=>G(n),e=>pa(n,e)),q(e,t)},l=e=>{var t=lZ();Us(t),Xs(t,()=>G(n),e=>pa(n,e)),q(e,t)};fs(s,e=>{t.options.multiline?e(c):e(l,-1)}),V(o),PX(W(o,2),{children:(e,r)=>{var i=uZ(),a=Oa(i);Lh(a,{get variant(){return It.PRIMARY},onclick:()=>t.options.onSubmit(ei(G(n))),children:(e,t)=>{Gr(),q(e,rs(`OK`))},$$slots:{default:!0}}),Lh(W(a,2),{onclick:()=>t.options.onCancel(),children:(e,t)=>{Gr(),q(e,rs(`Cancel`))},$$slots:{default:!0}}),q(e,i)},$$slots:{default:!0}}),Ya(()=>as(a,t.options.subTitle)),q(e,r),ai()}var pZ=K(`
 
`),mZ=K(`Tip `),hZ=K(`
`,1),gZ=K(`Docs`),_Z=K(`Context
 
`),vZ=K(`
Cause
Effect
`),yZ=K(`
 
`);function bZ(e,t){ii(t,!0);var n=is(),r=Oa(n),i=e=>{var n=vZ(),r=U(n),i=U(r),a=U(i);V(i);var o=W(i);V(r);var s=W(r,2),c=e=>{var n=pZ(),r=U(n),i=U(r,!0);V(r),V(n),Ya(()=>as(i,t.error.positionContext)),q(e,n)};fs(s,e=>{t.error.positionContext&&e(c)});var l=W(s,2),u=U(l),d=U(u),f=W(U(d)),p=U(f,!0);V(f),V(d);var m=W(d),h=W(U(m)),g=U(h,!0);V(h),V(m);var _=W(m),v=e=>{var n=mZ(),r=W(U(n)),i=U(r,!0);V(r),V(n),Ya(()=>as(i,t.error.tip)),q(e,n)};fs(_,e=>{t.error.tip&&e(v)});var y=W(_),b=e=>{var n=gZ(),r=W(U(n));_s(r,21,()=>t.error.docs,ps,(e,t)=>{var n=hZ(),r=Oa(n),i=U(r,!0);V(r),Gr(),Ya(()=>{Ks(r,`href`,G(t)),as(i,G(t))}),q(e,n)}),V(r),V(n),q(e,n)};fs(y,e=>{t.error.docs&&e(b)});var x=W(y),S=e=>{var n=_Z(),r=W(U(n)),i=U(r),a=U(i),o=U(a,!0);V(a),V(i),V(r),V(n),Ya(e=>as(o,e),[()=>JSON.stringify(t.error.context,null,4)]),q(e,n)};fs(x,e=>{t.error.context&&e(S)}),V(u),V(l),V(n),Ya(e=>{Ms(i,1,Es(t.error.errorLevel===B.WARNING?`mb-warning-text`:`mb-error-text`)),as(a,`${t.error.errorLevel??``} [${e??``}]`),as(o,` - ${t.error.effect??``}`),as(p,t.error.cause),as(g,t.error.effect)},[()=>t.error.getErrorType()]),q(e,n)},a=e=>{var n=yZ(),r=U(n),i=U(r),a=U(i,!0);V(i),V(r),V(n),Ya(()=>as(a,t.error.stack)),q(e,n)};fs(r,e=>{t.error instanceof ge?e(i):e(a,-1)}),q(e,n),ai()}var xZ=K(`

`),SZ=K(`
 
`),CZ=K(`
Errors
`,1),wZ=K(`
Warnings
`,1),TZ=K(` `,1);function EZ(e,t){ii(t,!0);var n=TZ(),r=Oa(n),i=e=>{var n=xZ(),r=U(n,!0);V(n),Ya(()=>as(r,t.settings.text)),q(e,n)};fs(r,e=>{t.settings.text&&e(i)});var a=W(r,2),o=e=>{var n=SZ(),r=U(n),i=U(r,!0);V(r),V(n),Ya(()=>as(i,t.settings.code)),q(e,n)};fs(a,e=>{t.settings.code&&e(o)});var s=W(a,2),c=e=>{var n=CZ(),r=W(Oa(n),2),i=e=>{var n=xZ(),r=U(n,!0);V(n),Ya(()=>as(r,t.settings.errorText)),q(e,n)};fs(r,e=>{t.settings.errorText&&e(i)}),_s(W(r,2),17,()=>t.settings.errorCollection.getErrors(),ps,(e,t)=>{bZ(e,{get error(){return G(t)}})}),q(e,n)},l=ea(()=>t.settings.errorCollection.hasErrors());fs(s,e=>{G(l)&&e(c)});var u=W(s,2),d=e=>{var n=wZ(),r=W(Oa(n),2),i=e=>{var n=xZ(),r=U(n,!0);V(n),Ya(()=>as(r,t.settings.warningText)),q(e,n)};fs(r,e=>{t.settings.warningText&&e(i)}),_s(W(r,2),17,()=>t.settings.errorCollection.getWarnings(),ps,(e,t)=>{bZ(e,{get error(){return G(t)}})}),q(e,n)},f=ea(()=>t.settings.errorCollection.hasWarnings());fs(u,e=>{G(f)&&e(d)}),q(e,n),ai()}var DZ=K(` [META_BIND_ERROR]`,1),OZ=ns(``),kZ=ns(``),AZ=K(`
`);function jZ(e,t){ii(t,!0);function n(){t.mb.internal.openErrorCollectionViewModal(t.settings)}var r=is(),i=Oa(r),a=e=>{var r=AZ(),i=U(r),a=e=>{var t=DZ();Gr(2),q(e,t)},o=ea(()=>t.settings.errorCollection.hasErrors()),s=e=>{q(e,OZ())},c=ea(()=>t.settings.errorCollection.hasWarnings()),l=e=>{q(e,kZ())};fs(i,e=>{G(o)?e(a):G(c)?e(s,1):e(l,-1)}),V(r),qo(`click`,r,()=>n()),qo(`keydown`,r,e=>{e.key===` `&&n()}),q(e,r)},o=ea(()=>!t.settings.errorCollection.isEmpty());fs(i,e=>{G(o)&&e(a)}),q(e,r),ai()}Jo([`click`,`keydown`]);var MZ=[`apng`,`avif`,`gif`,`jpg`,`jpeg`,`jfif`,`pjpeg`,`pjp`,`png`,`svg`,`webp`],NZ=MZ.map(e=>`.${e}`),PZ=class{mb;constructor(e){this.mb=e}openCommandSelectModal(e){this.createSearchModal(new qX(this.mb,e)).open()}openFileSelectModal(e){this.createSearchModal(new JX(this.mb,e)).open()}openFilteredFileSelectModal(e,t){this.createSearchModal(new JX(this.mb,e,t)).open()}openMarkdownFileSelectModal(e){this.openFilteredFileSelectModal(e,e=>e.endsWith(`.md`))}openImageFileSelectModal(e){this.openFilteredFileSelectModal(e,e=>NZ.some(t=>e.endsWith(t)))}openFolderSelectModal(e){this.createSearchModal(new YX(this.mb,e)).open()}openButtonBuilderModal(e){this.createModal(new WX(this.mb,e),{title:`Meta Bind Button Builder`}).open()}openSuggesterModal(e,t){this.createSearchModal(new XX(this.mb,t,e)).open()}openImageSuggesterModal(e,t,n){this.createModal(new GX((r,i)=>os(sZ,{target:i,props:{mb:this.mb,options:this.getImageSuggesterOptions(e),canSelectNone:t,onSelect:e=>{n(e),r.closeModal()},onCancel:()=>{r.closeModal()}}})),{title:`Select an image from your Vault`,classes:[`mb-image-suggester-modal`]}).open()}openDatePickerModal(e,t){this.createModal(new GX((n,r)=>os(nZ,{target:r,props:{selectedDate:e,dateChangeCallback:e=>{t(e),n.closeModal()}}})),{title:`Meta Bind date picker`}).open()}openTextPromptModal(e){this.createModal(new GX((t,n)=>os(fZ,{target:n,props:{options:{...e,onSubmit:n=>{e.onSubmit(n),t.closeModal()},onCancel:()=>{e.onCancel(),t.closeModal()}}}})),e).open()}openErrorCollectionViewModal(e){this.createModal(new GX((t,n)=>os(EZ,{target:n,props:{settings:e}})),{title:`Meta Bind error overview`,classes:[`mb-error-collection-modal`,`markdown-rendered`]}).open()}createErrorIndicator(e,t){let n=os(jZ,{target:e,props:{mb:this.mb,settings:t}});return()=>{us(n)}}},FZ=class{preparedSearch;constructor(){}setSearch(e){this.preparedSearch=(0,f.prepareFuzzySearch)(e)}filterItems(e,t){return this.preparedSearch?e.filter(e=>this.preparedSearch?.(t(e))?.score!=null):e}},IZ=class{value;displayValue;displayDescription;constructor(e,t,n){this.value=e,this.displayValue=t,this.displayDescription=n}valueAsString(){return this.value?.toString()??`null`}};function LZ(e){let t=[];for(let n of e.children)n instanceof f.TFile&&zZ(n.extension)&&t.push(new IZ(n.path,n.name)),n instanceof f.TFolder&&t.push(...LZ(n));return t}function RZ(e,t,n){let r=[];for(let t of n){let n=t.value;if(n.startsWith(`"`)&&n.endsWith(`"`))n=n.substring(1,n.length-1);else{let e=new xe({errorLevel:B.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option query for image suggester to start and end with double quotation marks`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}let i;if(i=n===``||n===`.`?e.app.vault.getRoot():e.app.vault.getAbstractFileByPath(n),i==null){let e=new xe({errorLevel:B.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option query ${n} for image suggester to exist`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}if(!(i instanceof f.TFolder)){let e=new xe({errorLevel:B.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option query ${t.value} for image suggester to be a folder`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}r.push(...LZ(i))}for(let n of t){let t=pn(n.value);if(!t){let e=new xe({errorLevel:B.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} to be truthy`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}let i=e.app.vault.getAbstractFileByPath(t);if(!i){let e=new xe({errorLevel:B.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} for image suggester to exist`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}if(!(i instanceof f.TFile)){let e=new xe({errorLevel:B.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} for image suggester to be a file`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}if(!zZ(i.extension)){let e=new xe({errorLevel:B.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} for image suggester to be an image file`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}r.push(new IZ(i.path,i.name))}return r}function zZ(e){return MZ.contains(e)}function BZ(e,t){return RZ(e,t.mountable.getArguments(kn.OPTION),t.mountable.getArguments(kn.OPTION_QUERY))}var VZ=class extends f.Modal{content;options;constructor(e,t,n){super(e.app),this.options=n,this.content=t,t.setModal(this)}onOpen(){this.options?.title&&this.titleEl.setText(this.options.title),this.options?.classes&&k.addClasses(this.modalEl,this.options.classes),this.content.mount(this.contentEl)}onClose(){this.content.unmount()}},HZ=class extends f.FuzzySuggestModal{content;constructor(e,t){super(e.app),this.content=t}renderSuggestion(e,t){(0,f.renderResults)(t.createDiv(),this.content.getItemText(e.item),e.match);let n=this.content.getItemDescription(e.item);n&&(0,f.renderResults)(t.createEl(`small`,{cls:`mb-search-modal-element-description`}),n,{score:0,matches:[]})}getItems(){return this.content.getItems()}getItemText(e){return this.content.getItemText(e)}onChooseItem(e,t){this.content.onSelected(e)}};function UZ(e,t,n,r,i){let a=[];for(let e of n)a.push(new IZ(e.value,e.name,`option`));if(r.length>0){let n;try{n=zY(e)}catch(e){return new f.Notice(`meta-bind | Dataview needs to be installed and enabled to use suggest option queries. Check the console for more information.`),console.warn(`meta-bind | failed to get dataview api`,e),a}let o=rw({name:xC().min(1),path:xC().min(1)});for(let e of r)n.pages(e.value,t).forEach(e=>{try{let t=e.file;if(!o.safeParse(t).success)return;let n=VT(t.path,t.name,i);a.push(new IZ(n,t.name,`file: ${t.path}`))}catch(e){console.warn(`meta-bind | error while computing suggest options`,e)}})}return a}function WZ(e,t){let n=t.mountable.getArguments(kn.OPTION),r=t.mountable.getArguments(kn.OPTION_QUERY),i=t.mountable.getArgument(kn.USE_LINKS);return UZ(e,t.mountable.getFilePath(),n,r,i===void 0?jn.TRUE:i.value)}var GZ=class{menu;constructor(){this.menu=new f.Menu}setItems(e){for(let t of e)this.menu.addItem(e=>{e.setTitle(t.name),t.icon&&e.setIcon(t.icon),t.warning&&e.setWarning(t.warning),e.onClick(t.onclick)})}show(e,t){this.menu.showAtPosition({x:e,y:t},activeDocument)}showWithEvent(e){this.menu.showAtMouseEvent(e),e.stopImmediatePropagation(),e.preventDefault()}},KZ=class{mb;containerEl;filePath;jsEngine;code;hidden;renderComponent;constructor(e,t,n,r,i){this.mb=e,this.containerEl=t,this.filePath=n,this.code=r,this.hidden=i,this.jsEngine=BY(this.mb),this.renderComponent=new f.Component}async evaluateCode(e){let t=await this.jsEngine.internal.getContextForMarkdownOther(this.filePath);return this.jsEngine.internal.execute({code:this.code,context:t,container:this.containerEl,component:this.renderComponent,contextOverrides:e})}async evaluate(e){try{k.empty(this.containerEl),k.removeClass(this.containerEl,`mb-error`),this.renderComponent.unload(),this.renderComponent=new f.Component,this.renderComponent.load();let t=await this.evaluateCode(e),n=this.jsEngine.internal.createRenderer(this.containerEl,this.filePath,this.renderComponent);return this.hidden||await n.render(t.result),n.convertToSimpleObject(t.result)}catch(e){e instanceof Error&&(this.containerEl.innerText=e.message,k.addClass(this.containerEl,`mb-error`));return}}unload(){this.renderComponent.unload()}},qZ=class extends PZ{omb;app;constructor(e){super(e),this.omb=e,this.app=e.app}getLifecycleHookValidator(){return Bw(f.Component)}getImageSuggesterOptions(e){return BZ(this.omb,e)}getSuggesterOptions(e){return WZ(this.omb,e)}async renderMarkdown(e,t,n){let r=new f.Component;return r.load(),await f.MarkdownRenderer.render(this.app,e,t,n,r),()=>r.unload()}executeCommandById(e){return this.app.commands.executeCommandById(e)}isJsEngineAvailable(){try{return BY(this.omb),!0}catch{return!1}}async jsEngineRunFile(e,t,n,r){let i=BY(this.omb),a=await i.internal.getContextForMarkdownCallingJSFile(t,e),o=new f.Component;return await i.internal.executeFile(e,{component:o,container:r,context:a,contextOverrides:n}),()=>o.unload()}async jsEngineRunCode(e,t,n,r){let i=BY(this.omb),a=await i.internal.getContextForMarkdownOther(t),o=new f.Component;return await i.internal.execute({code:e,component:o,container:r,context:a,contextOverrides:n}),()=>o.unload()}async jsEngineExecuteCustom(e,t,n){return BY(this.omb).internal.executeCustom(e,t,n)}createJsRenderer(e,t,n,r){return new KZ(this.omb,e,t,n,r)}showNotice(e){new f.Notice(e)}parseYaml(e){return(0,f.parseYaml)(e)}stringifyYaml(e){return(0,f.stringifyYaml)(e)}setIcon(e,t){(0,f.setIcon)(e,t)}imagePathToUri(e){return this.app.vault.adapter.getResourcePath(e)}createModal(e,t){return new VZ(this.omb,e,t)}createSearchModal(e){return new HZ(this.omb,e)}getAllCommands(){return this.app.commands.listCommands().map(e=>({id:e.id,name:e.name}))}createFuzzySearch(){return new FZ}createContextMenu(e){let t=new GZ;return t.setItems(e),t}async evaluateTemplaterTemplate(e,t){let n=HY(this.omb),r=this.app.vault.getAbstractFileByPath(e);if(!r||!(r instanceof f.TFile))throw Error(`Template file not found: ${e}`);let i=this.app.vault.getAbstractFileByPath(t);if(!i||!(i instanceof f.TFile))throw Error(`Target file not found: ${t}`);let a=n.create_running_config(r,i,VY.DynamicProcessor);return await n.read_and_parse_template(a)}async createNoteWithTemplater(e,t,n,r=!1,i=!1){let a=HY(this.omb),o=this.app.vault.getAbstractFileByPath(e);if(!o||!(o instanceof f.TFile))throw Error(`Template file not found: ${e}`);let s;if(t!==void 0){let e=this.app.vault.getAbstractFileByPath(t);if(!e||!(e instanceof f.TFolder))throw Error(`Folder not found: ${t}`);s=e}let c=await a.create_new_note_from_template(o,s,n,!1);return r&&c&&await this.mb.file.openInSourceMode(c,i),c?.path}},JZ=class extends SJ{mb;constructor(e,t,n){super(t,n),this.mb=e,this.mb.plugin.registerEvent(this.mb.app.metadataCache.on(`changed`,(e,t,n)=>{this.manager.onExternalUpdate(this,e.path,structuredClone(n.frontmatter)??{})}))}readExternal(e){let t=this.mb.app.vault.getAbstractFileByPath(e);if(t==null||!(t instanceof f.TFile))throw new _e({errorLevel:B.CRITICAL,effect:`can not get default cache item`,cause:`no file for path "${e}" found or path is not a file`});let n=this.mb.app.metadataCache.getFileCache(t)?.frontmatter;return structuredClone(n)??{}}getDefaultCacheItem(e){let t=this.mb.app.vault.getAbstractFileByPath(e);if(t==null||!(t instanceof f.TFile))throw new _e({errorLevel:B.CRITICAL,effect:`can not get default cache item`,cause:`no file for path "${e}" found or path is not a file`});let n=this.mb.app.metadataCache.getFileCache(t)?.frontmatter;return{data:structuredClone(n)??{},storagePath:e,file:t,...this.manager.constructDefaultCacheItem()}}async syncExternal(e){return this.mb.app.fileManager.processFrontMatter(e.file,t=>{Object.assign(t,e.data)})}},YZ=class extends pe{ctx;element;constructor(e,t){super(void 0),this.ctx=e,this.element=t}getPosition(){let e=this.ctx.getSectionInfo(this.element);if(e)return{lineStart:e.lineStart,lineEnd:e.lineEnd}}};function XZ(e,t){ii(t,!0);let n=new CY(t.mb,w(),``,de.BLOCK,t.declaration);EY(e,{get mountable(){return n}}),ai()}var ZZ=K(`

`);function QZ(e,t){ii(t,!0);let n=t.mb.api.createInlineFieldFromString(t.declaration.inputField,``,void 0,de.BLOCK),r=t.mb.api.createInlineFieldFromString(t.declaration.declaration,``,void 0,de.BLOCK);var i=ZZ(),a=U(i),o=U(a,!0);V(a);var s=W(a,2);EY(s,{get mountable(){return n}});var c=W(s,2);EY(c,{get mountable(){return r}});var l=W(c,2),u=U(l,!0);V(l),V(i),Ya(()=>{as(o,t.declaration.title),as(u,t.declaration.display)}),q(e,i),ai()}var $Z=K(`

Meta Bind Playground

`,1),eQ=K(`

Quick Reference

Error Messages

When creating Input Fields or View Fields warnings ( ) and errors ( ) can occur. These are clickable and will show a modal with detailed information about the error when clicked.

Unloaded Message

A message like this [MB_UNLOADED] ... means that Obsidian told Meta Bind to unload the field that was once displayed there. This usually happens when Meta Bind was disabled, such as after a plugin update, or when another plugin is interfering with Meta Bind.

Usually reopening the note or restarting Obsidian causes the field to display normally again.

Bind Targets

Bind Targets let the plugin know what frontmatter properties to bind Input Fields and View Fields to.

Playground

Input Fields

Input Fields let you change the frontmatter of your notes from inside of notes.

View Fields

View Fields let you view and perform calculations using the frontmatter of your notes from inside of notes. They will update instantly to reflect changes to the frontmatter made by input fields and as fast as obsidian allows it for changes from other sources.

`);function tQ(e,t){ii(t,!0);let n=va(new Tn(`exampleWarningErrorCollection`)),r=va(new Tn(`exampleErrorErrorCollection`));nc(()=>{n.add(new we({errorLevel:B.WARNING,effect:`some example warning`,cause:`some example reason`})),r.add(new we({errorLevel:B.ERROR,effect:`some example error`,cause:`some example reason`}))});var i=eQ(),a=U(i);MX(a,{children:(e,t)=>{var n=$Z(),r=W(Oa(n),2),i=U(r);Lh(i,{get variant(){return It.PRIMARY},onclick:()=>{o_.open(o_.linkToHome())},children:(e,t)=>{Gr(),q(e,rs(`Docs`))},$$slots:{default:!0}});var a=W(i,2);Lh(a,{onclick:()=>{o_.open(o_.linkToGithub())},children:(e,t)=>{Gr(),q(e,rs(`GitHub`))},$$slots:{default:!0}}),Lh(W(a,2),{onclick:()=>{o_.open(o_.linkToIssues())},children:(e,t)=>{Gr(),q(e,rs(`Report Issue`))},$$slots:{default:!0}}),V(r),q(e,n)},$$slots:{default:!0}});var o=W(a,6),s=W(U(o)),c=W(s,2),l=W(c,4);{let e=ea(()=>({errorCollection:n,code:`INPUT[someInputFieldDeclaration]`}));jZ(l,{get mb(){return t.mb},get settings(){return G(e)}})}var u=W(l,4);{let e=ea(()=>({errorCollection:r,code:`INPUT[someInputFieldDeclaration]`}));jZ(u,{get mb(){return t.mb},get settings(){return G(e)}})}Gr(3),V(o);var d=W(o,10),f=W(U(d),2),p=W(f,2);Gr(),V(d);var m=W(d,6),h=U(m);Gr(),V(m);var g=W(m,2);_s(g,17,()=>FJ(t.mb),ps,(e,n)=>{XZ(e,{get declaration(){return G(n)[1]},get mb(){return t.mb}})});var _=W(g,4),v=U(_);Gr(),V(_),_s(W(_,2),17,()=>Object.values(PJ),ps,(e,n)=>{var r=is();_s(Oa(r),17,()=>G(n),ps,(e,n)=>{QZ(e,{get declaration(){return G(n)},get mb(){return t.mb}})}),q(e,r)}),V(i),Ya((e,t,n,r,i,a)=>{Ks(s,`href`,e),Ks(c,`href`,t),Ks(f,`href`,n),Ks(p,`href`,r),Ks(h,`href`,i),Ks(v,`href`,a)},[()=>o_.linkToInputFields(),()=>o_.linkToViewFields(),()=>o_.linkToInputFields(),()=>o_.linkToViewFields(),()=>o_.linkToInputFields(),()=>o_.linkToViewFields()]),q(e,i),ai()}var nQ=`mb-playground-view-type`,rQ=class extends f.ItemView{component;mb;constructor(e,t){super(e),this.mb=t}getViewType(){return nQ}getDisplayText(){return`Meta Bind playground`}async onOpen(){this.contentEl.empty(),this.component=os(tQ,{target:this.contentEl,props:{mb:this.mb}})}async onClose(){this.component&&us(this.component)}},iQ=K(` `,1),aQ=K(`
 
`);function oQ(e,t){ii(t,!0);let n=tc(t,`template`,15);function r(){t.mb.internal.openButtonBuilderModal({submitText:`Submit`,config:ei(n()),onOkay:e=>{n(e)}})}function i(){let e=(0,f.stringifyYaml)(ei(n()));navigator.clipboard.writeText(e),new f.Notice(`meta-bind | Copied to clipboard`)}var a=aQ(),o=U(a);MX(o,{stretchChildren:!0,children:(e,a)=>{var o=iQ(),s=Oa(o),c=U(s,!0);V(s);var l=W(s,2);Lh(l,{onclick:()=>r(),get variant(){return It.PRIMARY},tooltip:`Edit`,children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`pen-line`})},$$slots:{default:!0}});var u=W(l,2);Lh(u,{onclick:()=>i(),get variant(){return It.DEFAULT},tooltip:`Copy`,children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`copy`})},$$slots:{default:!0}}),Lh(W(u,2),{onclick:()=>t.onDelete(n()),get variant(){return It.DESTRUCTIVE},tooltip:`Delete`,children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`x`})},$$slots:{default:!0}}),Ya(()=>as(c,n().id)),q(e,o)},$$slots:{default:!0}});var s=W(o,2),c=U(s),l=U(c,!0);V(c),V(s),V(a),Ya(e=>as(l,e),[()=>(0,f.stringifyYaml)(n())]),q(e,a),ai()}var sQ=K(`

Some Templates Failed to Parse

`),cQ=K(` `,1),lQ=K(`

Meta Bind Button Templates

`);function uQ(e,t){ii(t,!0);let n=da(void 0),r=da(va(t.buttonConfigs));function i(e){pa(r,G(r).filter(t=>t!==e),!0)}function a(){G(r).push(t.modal.mb.buttonActionRunner.createDefaultButtonConfig())}async function o(){let e;try{e=(0,f.parseYaml)(await navigator.clipboard.readText())}catch(e){console.warn(e),new f.Notice(`meta-bind | Can not parse button config. Check your button syntax. See the console for more details.`);return}let t=vT.safeParse(e);if(!t.success){let e=Xw(t.error);console.warn(new Te({errorLevel:B.ERROR,effect:`can not parse button config`,cause:`zod validation failed. Check your button syntax`,positionContext:e,docs:[o_.linkToButtonConfig()]})),new f.Notice(`meta-bind | Can not parse button config. Check your button syntax. See the console for more details.`);return}G(r).push(e)}function s(){pa(n,t.modal.save(ei(G(r))),!0),G(n)===void 0&&t.modal.close()}function c(){t.modal.close()}var l=lQ(),u=W(U(l),2);_s(u,17,()=>G(r),ps,(e,n,a)=>{oQ(e,{get mb(){return t.modal.mb},onDelete:i,get template(){return G(r)[a]},set template(e){G(r)[a]=e}})});var d=W(u,2);Lh(d,{onclick:()=>a(),get variant(){return It.PRIMARY},tooltip:`Create new template`,children:(e,t)=>{Gr(),q(e,rs(`Add Template`))},$$slots:{default:!0}});var p=W(d,2);Lh(p,{onclick:()=>o(),get variant(){return It.DEFAULT},tooltip:`Create new template from YAML in clipboard`,children:(e,t)=>{Gr(),q(e,rs(`Add Template from Clipboard`))},$$slots:{default:!0}});var m=W(p,2),h=e=>{var t=sQ(),r=W(U(t),2);{let e=ea(()=>({errorCollection:G(n)}));EZ(r,{get settings(){return G(e)}})}V(t),q(e,t)};fs(m,e=>{G(n)&&e(h)}),PX(W(m,2),{children:(e,t)=>{var n=cQ(),r=Oa(n);Lh(r,{onclick:()=>s(),get variant(){return It.PRIMARY},tooltip:`Save changes`,children:(e,t)=>{Gr(),q(e,rs(`Save`))},$$slots:{default:!0}}),Lh(W(r,2),{onclick:()=>c(),tooltip:`Revert changes`,children:(e,t)=>{Gr(),q(e,rs(`Cancel`))},$$slots:{default:!0}}),q(e,n)},$$slots:{default:!0}}),V(l),q(e,l),ai()}var dQ=class extends f.Modal{mb;component;constructor(e,t){super(e),this.mb=t}onOpen(){this.contentEl.empty(),this.component&&us(this.component),this.component=os(uQ,{target:this.contentEl,props:{buttonConfigs:structuredClone(this.mb.getSettings().buttonTemplates),modal:this}})}onClose(){this.contentEl.empty(),this.component&&us(this.component)}save(e){let t=this.mb.buttonManager.setButtonTemplates(e);if(t.hasErrors())return t;this.mb.updateSettings(t=>{t.buttonTemplates=e})}},fQ=K(``),pQ=K(`

Some folder paths are invalid

`),mQ=K(` `,1),hQ=K(`
Folder Path
`);function gQ(e,t){ii(t,!0);let n=da(void 0),r=da(va(t.excludedFolders));function i(e){pa(r,G(r).filter(t=>t!==e),!0)}function a(){G(r).push(``)}function o(){pa(n,t.modal.save(ei(G(r))),!0),G(n)===void 0&&t.modal.close()}function s(){t.modal.close()}var c=hQ(),l=U(c),u=W(U(l));_s(u,21,()=>G(r),ps,(e,n,a)=>{var o=fQ(),s=U(o),c=U(s);Us(c),V(s);var l=W(s);Lh(U(l),{onclick:()=>i(G(n)),tooltip:`Delete`,children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`x`})},$$slots:{default:!0}}),V(l),V(o),Xs(c,()=>G(r)[a],e=>G(r)[a]=e),q(e,o)}),V(u),V(l);var d=W(l,2);Lh(d,{onclick:()=>a(),get variant(){return It.PRIMARY},tooltip:`Add new excluded folder`,children:(e,t)=>{Gr(),q(e,rs(`Add folder`))},$$slots:{default:!0}});var f=W(d,2),p=e=>{var t=pQ(),r=W(U(t),2);{let e=ea(()=>({errorCollection:G(n)}));EZ(r,{get settings(){return G(e)}})}V(t),q(e,t)};fs(f,e=>{G(n)&&e(p)}),PX(W(f,2),{children:(e,t)=>{var n=mQ(),r=Oa(n);Lh(r,{onclick:()=>o(),get variant(){return It.PRIMARY},tooltip:`Save changes`,children:(e,t)=>{Gr(),q(e,rs(`Save`))},$$slots:{default:!0}}),Lh(W(r,2),{onclick:()=>s(),tooltip:`Revert changes`,children:(e,t)=>{Gr(),q(e,rs(`Cancel`))},$$slots:{default:!0}}),q(e,n)},$$slots:{default:!0}}),V(c),q(e,c),ai()}var _Q=class extends f.Modal{mb;component;constructor(e,t){super(e),this.mb=t}onOpen(){this.contentEl.empty(),this.component&&us(this.component),this.component=os(gQ,{target:this.contentEl,props:{excludedFolders:structuredClone(this.mb.getSettings().excludedFolders),modal:this,mb:this.mb}})}onClose(){this.contentEl.empty(),this.component&&us(this.component)}save(e){for(let t of e)if(t===``){let e=new Tn(`Excluded folders`);return e.add(Error(`Invalid Folder Path '${t}'. Folder path may not be empty.`)),e}this.mb.updateSettings(t=>{t.excludedFolders=e})}},vQ=K(` `,1),yQ=K(`
`);function bQ(e,t){ii(t,!0);let n=tc(t,`template`,15);var r=yQ(),i=U(r);MX(i,{children:(e,r)=>{var i=vQ(),a=Oa(i);Us(a),Lh(W(a,2),{onclick:()=>t.onDelete(n()),get variant(){return It.DESTRUCTIVE},tooltip:`Delete Template`,children:(e,n)=>{Ch(e,{get mb(){return t.mb},iconName:`x`})},$$slots:{default:!0}}),Xs(a,()=>n().name,e=>n(n().name=e,!0)),q(e,i)},$$slots:{default:!0}});var a=W(i,2);Na(a),V(r),Xs(a,()=>n().declaration,e=>n(n().declaration=e,!0)),q(e,r),ai()}var xQ=K(`

Some Templates Failed to Parse

`),SQ=K(` `,1),CQ=K(`

Meta Bind Input Field Templates

`);function wQ(e,t){ii(t,!0);let n=da(void 0),r=da(va(t.inputFieldTemplates));function i(e){pa(r,G(r).filter(t=>t!==e),!0)}function a(){G(r).push({name:``,declaration:``})}function o(){pa(n,t.modal.save(ei(G(r))),!0),G(n)===void 0&&t.modal.close()}function s(){t.modal.close()}var c=CQ(),l=W(U(c),2);_s(l,17,()=>G(r),ps,(e,n)=>{bQ(e,{get mb(){return t.modal.mb},get template(){return G(n)},onDelete:i})});var u=W(l,2);Lh(u,{onclick:()=>a(),get variant(){return It.PRIMARY},tooltip:`Create New Template`,children:(e,t)=>{Gr(),q(e,rs(`Add Template`))},$$slots:{default:!0}});var d=W(u,2),f=e=>{var t=xQ(),r=W(U(t),2);{let e=ea(()=>({errorCollection:G(n)}));EZ(r,{get settings(){return G(e)}})}V(t),q(e,t)};fs(d,e=>{G(n)&&e(f)}),PX(W(d,2),{children:(e,t)=>{var n=SQ(),r=Oa(n);Lh(r,{onclick:()=>o(),get variant(){return It.PRIMARY},tooltip:`Save Changes`,children:(e,t)=>{Gr(),q(e,rs(`Save`))},$$slots:{default:!0}}),Lh(W(r,2),{onclick:()=>s(),tooltip:`Revert Changes`,children:(e,t)=>{Gr(),q(e,rs(`Cancel`))},$$slots:{default:!0}}),q(e,n)},$$slots:{default:!0}}),V(c),q(e,c),ai()}var TQ=class extends f.Modal{mb;component;constructor(e,t){super(e),this.mb=t}onOpen(){this.contentEl.empty(),this.component&&us(this.component),this.component=os(wQ,{target:this.contentEl,props:{inputFieldTemplates:structuredClone(this.mb.getSettings().inputFieldTemplates),modal:this}})}onClose(){this.contentEl.empty(),this.component&&us(this.component)}save(e){let t=this.mb.inputFieldParser.parseTemplates(e);if(t.hasErrors())return t;this.mb.updateSettings(t=>{t.inputFieldTemplates=e})}},EQ=class extends f.PluginSettingTab{mb;constructor(e,t){super(e,t.plugin),this.mb=t}display(){let{containerEl:e}=this;if(e.empty(),this.mb.build===bJ.DEV||this.mb.build===bJ.CANARY){e.createEl(`p`,{text:`You are using a ${this.mb.build} build (1.4.15). This build is not intended for production use. Use at your own risk.`,cls:`mb-error`});let t=new f.ButtonComponent(e);t.setButtonText(`Learn about canary builds`),t.setCta(),t.onClick(()=>{o_.open(o_.linkToCanaryBuilds())})}new f.Setting(e).setName(`Quick access`).addButton(e=>{e.setCta(),e.setButtonText(`Docs`),e.onClick(()=>{o_.open(o_.linkToHome())})}).addButton(e=>{e.setButtonText(`Open FAQ`),e.onClick(()=>{this.mb.activateView(nQ)})}).addButton(e=>{e.setButtonText(`GitHub`),e.onClick(()=>{o_.open(o_.linkToGithub())})}).addButton(e=>{e.setButtonText(`Report issue`),e.onClick(()=>{o_.open(o_.linkToIssues())})}),new f.Setting(e).setName(`Enable syntax highlighting`).setDesc(`Enable syntax highlighting for meta bind syntax. Restart required.`).addToggle(e=>{e.setValue(this.mb.getSettings().enableSyntaxHighlighting),e.onChange(e=>{this.mb.updateSettings(t=>{t.enableSyntaxHighlighting=e})})}),new f.Setting(e).setName(`Enable editor right-click menu`).setDesc(`Enable a meta bind menu section in the editor right-click menu. Restart required.`).addToggle(e=>{e.setValue(this.mb.getSettings().enableEditorRightClickMenu),e.onChange(e=>{this.mb.updateSettings(t=>{t.enableEditorRightClickMenu=e})})}),new f.Setting(e).setName(`Input field templates`).setDesc("You can specify input field templates here, and access them using `INPUT[template_name][overrides (optional)]` in your notes.").addButton(e=>{e.setButtonText(`Edit templates`),e.onClick(()=>{new TQ(this.app,this.mb).open()})}),new f.Setting(e).setName(`Button templates`).setDesc(`You can specify button field templates here, and access them in inline buttons.`).addButton(e=>{e.setButtonText(`Edit templates`),e.onClick(()=>{new dQ(this.app,this.mb).open()})}),new f.Setting(e).setName(`Excluded folders`).setDesc(`You can specify excluded folders here. The plugin will not work within excluded folders.`).addButton(e=>{e.setButtonText(`Edit excluded folders`),e.onClick(()=>{new _Q(this.app,this.mb).open()})}),new f.Setting(e).setName(`View fields display null as empty`).setDesc(`Display nothing instead of null, if the frontmatter value is empty, in text view fields.`).addToggle(e=>{e.setValue(this.mb.getSettings().viewFieldDisplayNullAsEmpty),e.onChange(e=>{this.mb.updateSettings(t=>{t.viewFieldDisplayNullAsEmpty=e})})}),new f.Setting(e).setName(`Enable JavaScript`).setDesc(`Enable features that run user written JavaScript. This is potentially DANGEROUS, thus it's disabled by default. Restart required.`).addToggle(e=>{e.setValue(this.mb.getSettings().enableJs),e.onChange(e=>{this.mb.updateSettings(t=>{t.enableJs=e})})}),new f.Setting(e).setName(`Date and time`).setHeading(),new f.Setting(e).setName(`Date format`).setDesc(`The date format to be used by this plugin. Changing this setting will break the parsing of existing date inputs. Here is a list of all available date tokes https://momentjs.com/docs/#/displaying/.`).addText(e=>{e.setValue(this.mb.getSettings().preferredDateFormat),e.onChange(e=>{this.mb.updateSettings(t=>{t.preferredDateFormat=e})})}),new f.Setting(e).setName(`First weekday`).setDesc(`Specify the first weekday for the datepicker.`).addDropdown(e=>{for(let t of m)e.addOption(t.name,t.name);e.setValue(this.mb.getSettings().firstWeekday.name),e.onChange(e=>{this.mb.updateSettings(t=>{t.firstWeekday=m.find(t=>t.name===e)})})}),new f.Setting(e).setName(`Advanced`).setHeading(),new f.Setting(e).setName(`Dev mode`).setDesc(`Enable dev mode. Not recommended unless you want to debug this plugin.`).addToggle(e=>{e.setValue(this.mb.getSettings().devMode),e.onChange(e=>{this.mb.updateSettings(t=>{t.devMode=e})})}),new f.Setting(e).setName(`Disable code block restrictions`).setDesc(`Disable restrictions on which input fields can be created in which code blocks. Not recommended unless you know what you are doing.`).addToggle(e=>{e.setValue(this.mb.getSettings().ignoreCodeBlockRestrictions),e.onChange(e=>{this.mb.updateSettings(t=>{t.ignoreCodeBlockRestrictions=e})})}),new f.Setting(e).setName(`Sync interval`).setDesc(`The interval in milli-seconds between disk writes. Changing this number is not recommended except if your hard drive is exceptionally slow. Standard: ${h.syncInterval}; Minimum: 50; Maximum: ${g}`).addText(e=>{e.setValue(this.mb.getSettings().syncInterval.toString()),e.onChange(e=>{this.mb.updateSettings(t=>{t.syncInterval=Number.parseInt(e),Number.isNaN(t.syncInterval)&&(t.syncInterval=h.syncInterval),t.syncInterval<50&&(t.syncInterval=50),t.syncInterval>1e3&&(t.syncInterval=g)})})})}},DQ=class extends xJ{app;plugin;dependencyManager;constructor(e){super(),this.app=e.app,this.plugin=e,this.setComponents({api:new WY(this),internal:new qZ(this),file:new KY(this)}),this.plugin.addSettingTab(new EQ(this.app,this)),this.dependencyManager=new MJ(this,[]),this.setUpDependencies(),this.setUpMetadataManager(),this.loadTemplates(),this.addPostProcessors(),this.plugin.registerEditorExtension(kJ(this)),this.addCommands(),EJ(this),this.plugin.registerView(nQ,e=>new rQ(e,this)),this.addStatusBarBuildIndicator(),this.getSettings().enableEditorRightClickMenu&&this.plugin.registerEvent(this.app.workspace.on(`editor-menu`,(e,t)=>{RJ(e,t,this)}))}setUpDependencies(){this.dependencyManager.dependencies=[{name:`Dataview`,pluginId:`dataview`,minVersion:new jJ(0,5,64)},{name:`JS Engine`,pluginId:`js-engine`,minVersion:new jJ(0,3,5)},{name:`Templater`,pluginId:`templater-obsidian`,minVersion:new jJ(2,2,3)}]}setUpMetadataManager(){this.metadataManager=new U_,this.metadataManager.registerSource(new JZ(this,G_.FRONTMATTER,this.metadataManager)),this.metadataManager.registerSource(new CJ(G_.MEMORY,this.metadataManager)),this.metadataManager.registerSource(new wJ(G_.GLOBAL_MEMORY,this.metadataManager)),this.metadataManager.registerSource(new TJ(G_.SCOPE,this.metadataManager)),this.metadataManager.setDefaultSource(G_.FRONTMATTER),this.plugin.registerEvent(this.app.vault.on(`rename`,(e,t)=>{this.mountableManager.unloadFile(t),this.metadataManager.onStoragePathRenamed(t,e.path)})),this.plugin.registerEvent(this.app.vault.on(`delete`,e=>{this.mountableManager.unloadFile(e.path),this.metadataManager.onStoragePathDeleted(e.path)})),this.plugin.registerInterval(window.setInterval(()=>void this.metadataManager.cycle(),this.getSettings().syncInterval))}addPostProcessors(){this.plugin.registerMarkdownPostProcessor((e,t)=>{let n=e.querySelectorAll(`code`),r=t.sourcePath;for(let e=0;e{await(0,f.loadPrism)();let r=t,i=e.trim(),a=n.sourcePath,o=this.api.isInlineFieldDeclarationAndGetType(i);if(o===void 0)return;let s=this.api.createInlineFieldOfTypeFromString(o,i,a,void 0,de.BLOCK,new YZ(n,t));this.api.wrapInMDRC(s,r,n)}),this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-js-view`,async(e,t,n)=>{await(0,f.loadPrism)();let r=this.api.createJsViewFieldMountable(n.sourcePath,{declaration:e});this.api.wrapInMDRC(r,t,n)}),this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-embed`,async(e,t,n)=>{await(0,f.loadPrism)();let r=this.api.createEmbedMountable(n.sourcePath,{content:e,depth:0});this.api.wrapInMDRC(r,t,n)});for(let e=1;e<=8;e++)this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-embed-internal-${e}`,async(t,n,r)=>{await(0,f.loadPrism)();let i=this.api.createEmbedMountable(r.sourcePath,{content:t,depth:e});this.api.wrapInMDRC(i,n,r)});this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-button`,async(e,t,n)=>{await(0,f.loadPrism)();let r=this.api.createButtonMountable(n.sourcePath,{declaration:e,isPreview:!1,position:new YZ(n,t)});this.api.wrapInMDRC(r,t,n)})}addCommands(){this.plugin.addCommand({id:`open-docs`,name:`Open docs`,callback:()=>{window.open(`https://mprojectscode.github.io/obsidian-meta-bind-plugin-docs/`,`_blank`)}}),this.plugin.addCommand({id:`open-playground`,name:`Open playground`,callback:()=>{this.activateView(nQ)}}),this.plugin.addCommand({id:`open-help`,name:`Open help`,callback:()=>{this.activateView(nQ)}}),this.plugin.addCommand({id:`open-button-builder`,name:`Open button builder`,callback:()=>{this.internal.openButtonBuilderModal({onOkay:e=>{window.navigator.clipboard.writeText(`\`\`\`meta-bind-button\n${(0,f.stringifyYaml)(e)}\n\`\`\``)},submitText:`Copy to clipboard`})}}),this.plugin.addCommand({id:`copy-command-id`,name:`Select and copy command ID`,callback:()=>{this.internal.openCommandSelectModal(e=>{window.navigator.clipboard.writeText(e.id)})}})}addStatusBarBuildIndicator(){if(this.build===bJ.DEV){let e=this.plugin.addStatusBarItem();e.setText(`Meta Bind Dev Build`),e.addClass(`mb-error`),this.plugin.register(()=>e.remove())}if(this.build===bJ.CANARY){let e=this.plugin.addStatusBarItem();e.setText(`Meta Bind Canary Build (1.4.15)`),e.addClass(`mb-error`),this.plugin.register(()=>e.remove())}}async activateView(e){let{workspace:t}=this.app,n,r=t.getLeavesOfType(e);r.length>0?n=r[0]:(n=t.getLeaf(`tab`),await n.setViewState({type:e,active:!0})),await t.revealLeaf(n)}getSettings(){return this.plugin.settings}saveSettings(e){this.plugin.settings=e,this.plugin.saveSettings()}},OQ=class extends f.Plugin{mb;api;settings;async onload(){await this.loadSettings(),this.mb=new DQ(this),this.api=this.mb.api,this.mb.updateInternalSettings(this.settings)}onunload(){this.mb.destroy()}async loadSettings(){let e=await this.loadData()??{};typeof e==`object`&&e&&(delete e.inputTemplates,delete e.useUsDateInputOrder),this.settings=Object.assign({},h,e),x(e,this.settings)||await this.saveSettings()}async saveSettings(){await this.saveData(this.settings)}async onExternalSettingsChange(){await this.loadSettings(),this.mb.updateInternalSettings(this.settings)}};module.exports=OQ; /* nosourcemap */