From 1903c3db4e27d228c5c13af4793292b53168693d Mon Sep 17 00:00:00 2001 From: Valentin Boettcher Date: Sat, 20 Feb 2021 17:04:08 +0100 Subject: [PATCH] init --- index.html | 88 ++++++++++++++++ index.js | 256 +++++++++++++++++++++++++++++++++++++++++++++++ lib/chart.min.js | 13 +++ lib/math.min.js | 1 + main.css | 17 ++++ 5 files changed, 375 insertions(+) create mode 100644 index.html create mode 100644 index.js create mode 100644 lib/chart.min.js create mode 100644 lib/math.min.js create mode 100644 main.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..7a4691c --- /dev/null +++ b/index.html @@ -0,0 +1,88 @@ + + + + Neutrino Oscillations + + + + + + + + + + + +
+ +
+ +
+
+
+ +
+
+
+
+

Current Settings

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Mixing Angles in \(^\circ\) + + +
+ + + +
+ + + +
+ +
+ Squared Mass Differences \([10^{-4}\text{eV}^{2}]\) + + +
+ + +
+
+ +
+
+ Observatory Settings + + +
+ + + +
+
+
+
+
+
+ + + + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..a90397a --- /dev/null +++ b/index.js @@ -0,0 +1,256 @@ +/////////////////////////////////////////////////////////////////////////////// +// Setup/Globals // +/////////////////////////////////////////////////////////////////////////////// + +const ctx = document.getElementById('neutrinorender').getContext('2d'); +const render = new Chart(ctx, { + type: 'line', + options: { + responsive: true, + maintainAspectRatio: false, + tooltips: { + mode: 'index', + intersect: false, + }, + animation: { + duration: 0, + }, + scales: { + x: { + scaleLabel: { + display: true, + labelString: "Distance [km]" + } + }, + y: { + scaleLabel: { + display: true, + labelString: "Survival Probability" + } + } + } + }, +}); + +const controls = document.forms.controls; +const settings = document.getElementById('settings'); + +// Mixing Angle Experimental Values, degrees +const t12 = 33.44; +const t23 = 49; +const t13 = 8.57; + +// squared mass differences, 1e-4 eV^2 +const ms13 = 25.1; +const ms23 = 24.4; + +// default settings +const defaultNeutrinoData = + { + t12, + t23, + t13, + ms13, + ms23, + L_range: [0, 100], + E: 6 // MeV + }; + +/////////////////////////////////////////////////////////////////////////////// +// Util // +/////////////////////////////////////////////////////////////////////////////// +function deg_to_rad(x) { + return (x / 180) * math.pi +} + +/////////////////////////////////////////////////////////////////////////////// +// Neutrino Mixing Specifics // +/////////////////////////////////////////////////////////////////////////////// + +/** + * Compute the PMNS Matrix. + * + * Angle Arguments in Degrees. + */ +function pmns(t12, t23, t13) { + t12 = deg_to_rad(t12); + t13 = deg_to_rad(t13); + t23 = deg_to_rad(t23); + + // Compute all sines, cosines + let c12 = math.cos(t12); + let c13 = math.cos(t13); + let c23 = math.cos(t23); + + let s12 = math.sin(t12); + let s13 = math.sin(t13); + let s23 = math.sin(t23); + + return math.matrix([ + [c12 * c13, s12 * c13, s13], + [-s12 * c23 - c12 * s23 * s13, c12 * c23 - s12 * s23 * s13, s23 * c13], + [s12 * s23 - c12 * c23 * s13, -c12 * s23 - s12 * c23 * s13, c23 * c13] + ]); +} + +function propagation_step(pmns_matrix, ms13, ms23, dL, E) { + E = E / 1000; + ms13 = ms13 * 1e-4; + ms23 = ms23 * 1e-4; + + const propagator = math.matrix([[math.exp(math.complex(0, -ms13 * 2.54 * dL / E)), 0, 0], + [0, math.exp(math.complex(0, -ms23 * 2.54 * dL / E)), 0], + [0, 0, 1]]); + + return math.multiply(pmns_matrix, propagator, math.transpose(pmns_matrix)); +} + +function propagate(initial_state, pmns_matrix, ms13, ms23, L, E) { + const propagator = propagation_step(pmns_matrix, ms13, ms23, L, E); + + return math.multiply(propagation_step, initial_state); +} + +function state_to_probabilies(state) { + return state.map(value => math.multiply(value.conjugate(), value).re); +} + +function plot_propagation(state, neutrino_data) { + const {t12, t23, t13, ms13, ms23, L_range, E} = neutrino_data; + + pmns_matrix = pmns(t12, t23, t13); + + dL = ((L_range[1] - L_range[0]) / 1000); + lengths = math.range(L_range[0], L_range[1], dL); + + common_options = { + pointRadius: 0, + }; + + datasets = [ + { + data: [], + borderColor: 'green', + label: 'electron', + ...common_options + }, + { + data: [], + borderColor: 'blue', + label: 'muon', + ...common_options + }, + { + data: [], + borderColor: 'red', + label: 'tauon', + ...common_options + } + ]; + + propagator = propagation_step(pmns_matrix, ms13, ms23, dL, E) + + for (const length of lengths._data) { + state = math.multiply(propagator, state); + + probs = state_to_probabilies(state); + probs.forEach((p, index) => { + datasets[index[0]].data.push(p); + }) + } + + render.data.labels = lengths.map(l => math.round(l, 2))._data; + render.data.datasets = datasets; + render.update({ + duration: 0, + easing: 'easeInOutBack' + }); +} + +function initForm() { + controls.elements.t13.value = t13; + controls.elements.t12.value = t12; + controls.elements.t23.value = t23; + + controls.elements.L_max.value = defaultNeutrinoData.L_range[1]; + controls.elements.energy.value = defaultNeutrinoData.E; + + controls.elements.ms13.value = ms13; + controls.elements.ms23.value = ms23; +} + +function getNeutrinoData() { + return { + ...defaultNeutrinoData, + t13: controls.elements.t13.value, + t12: controls.elements.t12.value, + t23: controls.elements.t23.value, + ms13: controls.elements.ms13.value, + ms23: controls.elements.ms23.value, + E: controls.elements.energy.value, + L_range: [0, controls.elements.L_max.value], + }; +} + +function renderPmnsMatrix(pmns_matrix) { + let result = "$$U=\\begin{pmatrix}\n"; + + for (let row of pmns_matrix._data) { + for (let val of row) { + result += `${math.round(val, 3)} &` + } + result = result.slice(0, -1); + result += "\\\\\n"; + } + + result += "\\end{pmatrix}$$"; + + return result; +} + +function displayCurrentSettings() { + const {t12, t23, t13, ms13, ms23, L_range, E} = getNeutrinoData(); + pmns_matrix = pmns(t12, t23, t13); + + // render pmns + settings.querySelector("#pmns").textContent = renderPmnsMatrix(pmns_matrix); + + settings.querySelector("#sliders_1").innerHTML = ` +\\(\\theta_{12} = ${t12}^\\circ\\) +
+\\(\\theta_{13} = ${t13}^\\circ\\) +
+\\(\\theta_{23} = ${t23}^\\circ\\) + `; + settings.querySelector("#sliders_2").innerHTML = ` +\\(\\Delta m_{13}^2 = ${ms13}\\cdot 10^{-4}\\text{GeV}\\) +
+\\(\\Delta m_{23}^2 = ${ms23}\\cdot 10^{-4}\\text{GeV}\\) +
+\\(L_\\text{max} = ${L_range[1]}\\text{km}\\) +
+\\(E = ${E}\\text{MeV}\\) + `; + + renderMathInElement(settings); + +}; + +document.addEventListener("DOMContentLoaded", (event) => { + initForm(); + displayCurrentSettings(); + plot_propagation(math.matrix([ + [1], + [0], + [0] + ]), defaultNeutrinoData); +}); + +controls.addEventListener('input', () => { + displayCurrentSettings(); + plot_propagation(math.matrix([ + [1], + [0], + [0] + ]), getNeutrinoData()); +}); diff --git a/lib/chart.min.js b/lib/chart.min.js new file mode 100644 index 0000000..eb499a7 --- /dev/null +++ b/lib/chart.min.js @@ -0,0 +1,13 @@ +/*! + * Chart.js v3.0.0-beta.10 + * https://www.chartjs.org + * (c) 2021 Chart.js Contributors + * Released under the MIT License + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";const t="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function e(e,i,n){const o=n||(t=>Array.prototype.slice.call(t));let s=!1,a=[];return function(...n){a=o(n),s||(s=!0,t.call(window,(()=>{s=!1,e.apply(i,a)})))}}const i=t=>"start"===t?"left":"end"===t?"right":"center",n=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2;var o=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,n){const o=e.listeners[n]||[],s=e.duration;o.forEach((n=>n({chart:t,numSteps:s,currentStep:Math.min(i-e.start,s)})))}_refresh(){const e=this;e._request||(e._running=!0,e._request=t.call(window,(()=>{e._update(),e._request=null,e._running&&e._refresh()})))}_update(){const t=this,e=Date.now();let i=0;t._charts.forEach(((n,o)=>{if(!n.running||!n.items.length)return;const s=n.items;let a,r=s.length-1,l=!1;for(;r>=0;--r)a=s[r],a._active?(a.tick(e),l=!0):(s[r]=s[s.length-1],s.pop());l&&(o.draw(),t._notify(o,n,e,"progress")),o.options.animation.debug&&function(t,e,i,n){const o=1e3/(i-n)|0,s=t.ctx;s.save(),s.clearRect(0,0,50,24),s.fillStyle="black",s.textAlign="right",e&&(s.fillText(e,50,8),s.fillText(o+" fps",50,18)),s.restore()}(o,s.length,e,t._lastDate),s.length||(n.running=!1,t._notify(o,n,e,"complete")),i+=s.length})),t._lastDate=e,0===i&&(t._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let n=i.length-1;for(;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}};function s(){}const a=function(){let t=0;return function(){return t++}}();function r(t){return null==t}function l(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function c(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const h=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function d(t,e){return h(t)?t:e}function u(t,e){return void 0===t?e:t}function g(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function f(t,e,i,n){let o,s,a;if(l(t))if(s=t.length,n)for(o=s-1;o>=0;o--)e.call(i,t[o],o);else for(o=0;ot-e)).pop(),e}const z=Math.log10||function(t){const e=Math.log(t)*Math.LOG10E,i=Math.round(e);return t===Math.pow(10,i)?i:e};function F(t){return!isNaN(parseFloat(t))&&isFinite(t)}function I(t,e,i){return Math.abs(t-e)=t}function V(t,e,i){let n,o,s;for(n=0,o=t.length;n0?1:-1};function N(t){return t*(S/180)}function H(t){return t*(180/S)}function j(t){if(!h(t))return;let e=1,i=0;for(;Math.round(t*e)/e!==t;)e*=10,i++;return i}function Y(t,e){const i=e.x-t.x,n=e.y-t.y,o=Math.sqrt(i*i+n*n);let s=Math.atan2(n,i);return s<-.5*S&&(s+=D),{angle:s,distance:o}}function U(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function $(t,e){return(t-e+O)%D-S}function X(t){return(t%D+D)%D}function K(t,e,i){const n=X(t),o=X(e),s=X(i),a=X(o-n),r=X(s-n),l=X(n-o),c=X(n-s);return n===o||n===s||a>r&&ln&&(n=s),n}function J(t,e,i,n){let o=(n=n||{}).data=n.data||{},s=n.garbageCollect=n.garbageCollect||[];n.font!==e&&(o=n.data={},s=n.garbageCollect=[],n.font=e),t.save(),t.font=e;let a=0;const r=i.length;let c,h,d,u,g;for(c=0;ci.length){for(c=0;c0&&t.stroke()}}function nt(t,e){const i=.5;return t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==s.strokeColor;let h,d;for(t.save(),s.translation&&t.translate(s.translation[0],s.translation[1]),r(s.rotation)||t.rotate(s.rotation),t.font=o.string,s.color&&(t.fillStyle=s.color),s.textAlign&&(t.textAlign=s.textAlign),s.textBaseline&&(t.textBaseline=s.textBaseline),h=0;ht[i]1;)n=s+o>>1,i(n)?s=n:o=n;return{lo:s,hi:o}}const ht=(t,e,i)=>ct(t,i,(n=>t[n][e]ct(t,i,(n=>t[n][e]>=i));function ut(t,e,i){let n=0,o=t.length;for(;nn&&t[o-1]>i;)o--;return n>0||o{const i="_onData"+w(e),n=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const o=n.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),o}})})))}function pt(t,e){const i=t._chartjs;if(!i)return;const n=i.listeners,o=n.indexOf(e);-1!==o&&n.splice(o,1),n.length>0||(gt.forEach((e=>{delete t[e]})),delete t._chartjs)}function mt(t){const e=new Set;let i,n;for(i=0,n=t.length;i{o.push(t)})),o}function xt(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function bt(t,e,i){let n;return"string"==typeof t?(n=parseInt(t,10),-1!==t.indexOf("%")&&(n=n/100*e.parentNode[i])):n=t,n}const _t=t=>window.getComputedStyle(t,null);function yt(t,e){return _t(t).getPropertyValue(e)}const vt=["top","right","bottom","left"];function Mt(t,e,i){const n={};i=i?"-"+i:"";for(let o=0;o<4;o++){const s=vt[o];n[s]=parseFloat(t[e+"-"+s+i])||0}return n.width=n.left+n.right,n.height=n.top+n.bottom,n}function wt(t,e){const{canvas:i,currentDevicePixelRatio:n}=e,o=_t(i),s="border-box"===o.boxSizing,a=Mt(o,"padding"),r=Mt(o,"border","width"),{x:l,y:c,box:h}=function(t,e){const i=t.originalEvent||t,n=i.touches,o=n&&n.length?n[0]:i,{offsetX:s,offsetY:a}=o;let r,l,c=!1;if(((t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot))(s,a,i.target))r=s,l=a;else{const t=e.getBoundingClientRect();r=o.clientX-t.left,l=o.clientY-t.top,c=!0}return{x:r,y:l,box:c}}(t,i),d=a.left+(h&&r.left),u=a.top+(h&&r.top);let{width:g,height:f}=e;return s&&(g-=a.width+r.width,f-=a.height+r.height),{x:Math.round((l-d)/g*i.width/n),y:Math.round((c-u)/f*i.height/n)}}function kt(t,e,i,n){const o=_t(t),s=Mt(o,"margin"),a=bt(o.maxWidth,t,"clientWidth")||C,r=bt(o.maxHeight,t,"clientHeight")||C,l=function(t,e,i){let n,o;if(void 0===e||void 0===i){const s=xt(t);if(s){const t=s.getBoundingClientRect(),a=_t(s),r=Mt(a,"border","width"),l=Mt(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,n=bt(a.maxWidth,s,"clientWidth"),o=bt(a.maxHeight,s,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:n||C,maxHeight:o||C}}(t,e,i);let{width:c,height:h}=l;if("content-box"===o.boxSizing){const t=Mt(o,"border","width"),e=Mt(o,"padding");c-=e.width+t.width,h-=e.height+t.height}return c=Math.max(0,c-s.width),h=Math.max(0,n?Math.floor(c/n):h-s.height),{width:Math.min(c,a,l.maxWidth),height:Math.min(h,r,l.maxHeight)}}function Pt(t,e){const i=t.currentDevicePixelRatio=e||"undefined"!=typeof window&&window.devicePixelRatio||1,{canvas:n,width:o,height:s}=t;n.height=s*i,n.width=o*i,t.ctx.setTransform(i,0,0,i,0,0),!n.style||n.style.height||n.style.width||(n.style.height=s+"px",n.style.width=o+"px")}const St=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function Dt(t,e){const i=yt(t,e),n=i&&i.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}function Ot(t,e){return"native"in t?{x:t.x,y:t.y}:wt(t,e)}function Ct(t,e,i,n){const{controller:o,data:s,_sorted:a}=t,r=o._cachedMeta.iScale;if(r&&e===r.axis&&a&&s.length){const t=r._reversePixels?dt:ht;if(!n)return t(s,e,i);if(o._sharedOptions){const n=s[0],o="function"==typeof n.getRange&&n.getRange(e);if(o){const n=t(s,e,i-o),a=t(s,e,i+o);return{lo:n.lo,hi:a.hi}}}}return{lo:0,hi:s.length-1}}function At(t,e,i,n,o){const s=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=s.length;t{t[r](o[a],n)&&s.push({element:t,datasetIndex:e,index:i}),t.inRange(o.x,o.y,n)&&(l=!0)})),i.intersect&&!l?[]:s}var Et={modes:{index(t,e,i,n){const o=Ot(e,t),s=i.axis||"x",a=i.intersect?Tt(t,o,s,n):Lt(t,o,s,!1,n),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})})),r):[]},dataset(t,e,i,n){const o=Ot(e,t),s=i.axis||"xy";let a=i.intersect?Tt(t,o,s,n):Lt(t,o,s,!1,n);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tTt(t,Ot(e,t),i.axis||"xy",n),nearest:(t,e,i,n)=>Lt(t,Ot(e,t),i.axis||"xy",i.intersect,n),x:(t,e,i,n)=>(i.axis="x",Rt(t,e,i,n)),y:(t,e,i,n)=>(i.axis="y",Rt(t,e,i,n))}};const zt=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);function Ft(t,e){const i=(""+t).match(zt);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const It=t=>+t||0;function Bt(t){let e,i,n,o;return c(t)?(e=It(t.top),i=It(t.right),n=It(t.bottom),o=It(t.left)):e=i=n=o=It(t),{top:e,right:i,bottom:n,left:o}}function Vt(t){let e,i,n,o;return c(t)?(e=It(t.topLeft),i=It(t.topRight),n=It(t.bottomLeft),o=It(t.bottomRight)):e=i=n=o=It(t),{topLeft:e,topRight:i,bottomLeft:n,bottomRight:o}}function Wt(t){const e=Bt(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function Nt(t,e){t=t||{},e=e||P.font;let i=u(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));const n={family:u(t.family,e.family),lineHeight:Ft(u(t.lineHeight,e.lineHeight),i),size:i,style:u(t.style,e.style),weight:u(t.weight,e.weight),string:""};return n.string=Z(n),n}function Ht(t,e,i,n){let o,s,a,r=!0;for(o=0,s=t.length;ot.pos===e))}function Ut(t,e){return t.filter((t=>-1===jt.indexOf(t.pos)&&t.box.axis===e))}function $t(t,e){return t.sort(((t,i)=>{const n=e?i:t,o=e?t:i;return n.weight===o.weight?n.index-o.index:n.weight-o.weight}))}function Xt(t,e,i,n){return Math.max(t[i],e[i])+Math.max(t[n],e[n])}function Kt(t,e,i){const n=i.box,o=t.maxPadding;if(c(i.pos))return;if(i.size&&(t[i.pos]-=i.size),i.size=i.horizontal?Math.min(i.height,n.height):Math.min(i.width,n.width),t[i.pos]+=i.size,n.getPadding){const t=n.getPadding();o.top=Math.max(o.top,t.top),o.left=Math.max(o.left,t.left),o.bottom=Math.max(o.bottom,t.bottom),o.right=Math.max(o.right,t.right)}const s=Math.max(0,e.outerWidth-Xt(o,t,"left","right")),a=Math.max(0,e.outerHeight-Xt(o,t,"top","bottom"));return s!==t.w||a!==t.h?(t.w=s,t.h=a,i.horizontal?s!==t.w:a!==t.h):void 0}function qt(t,e){const i=e.maxPadding;function n(t){const n={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{n[t]=Math.max(e[t],i[t])})),n}return n(t?["left","right"]:["top","bottom"])}function Gt(t,e,i){const n=[];let o,s,a,r,l,c;for(o=0,s=t.length;o{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const d=Object.freeze({outerWidth:e,outerHeight:i,padding:s,availableWidth:a,availableHeight:r,vBoxMaxWidth:a/2/c.length,hBoxMaxHeight:r/2}),u=Object.assign({maxPadding:Object.assign({},s),w:a,h:r,x:s.left,y:s.top},s);!function(t,e){let i,n,o;for(i=0,n=t.length;i{const i=e.box;Object.assign(i,t.chartArea),i.update(u.w,u.h)}))}};class Jt{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,n){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,n?Math.floor(e/n):i)}}isAttached(t){return!0}}class te extends Jt{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}}const ee={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},ie=t=>null===t||""===t;const ne=!!St&&{passive:!0};function oe(t,e,i){t.canvas.removeEventListener(e,i,ne)}function se(t,e,i){const n=t.canvas,o=n&&xt(n)||n,s=new MutationObserver((t=>{const e=xt(o);t.forEach((t=>{for(let n=0;n{t.forEach((t=>{for(let e=0;e{i.currentDevicePixelRatio!==t&&e()})))}function he(t,i,n){const o=t.canvas,s=o&&xt(o);if(!s)return;const a=e(((t,e)=>{const i=s.clientWidth;n(t,e),i{const e=t[0],i=e.contentRect.width,n=e.contentRect.height;0===i&&0===n||a(i,n)}));return r.observe(s),function(t,e){re.size||window.addEventListener("resize",ce),re.set(t,e)}(t,a),r}function de(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){re.delete(t),re.size||window.removeEventListener("resize",ce)}(t)}function ue(t,i,n){const o=t.canvas,s=e((e=>{null!==t.ctx&&n(function(t,e){const i=ee[t.type]||t.type,{x:n,y:o}=wt(t,e);return{type:i,chart:e,native:t,x:void 0!==n?n:null,y:void 0!==o?o:null}}(e,t))}),t,(t=>{const e=t[0];return[e,e.offsetX,e.offsetY]}));return function(t,e,i){t.addEventListener(e,i,ne)}(o,i,s),s}class ge extends Jt{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,n=t.getAttribute("height"),o=t.getAttribute("width");if(t.$chartjs={initial:{height:n,width:o,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",ie(o)){const e=Dt(t,"width");void 0!==e&&(t.width=e)}if(ie(n))if(""===t.style.height)t.height=t.width/(e.options.aspectRatio||2);else{const e=Dt(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const i=e.$chartjs.initial;["height","width"].forEach((t=>{const n=i[t];r(n)?e.removeAttribute(t):e.setAttribute(t,n)}));const n=i.style||{};return Object.keys(n).forEach((t=>{e.style[t]=n[t]})),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const n=t.$proxies||(t.$proxies={}),o={attach:se,detach:ae,resize:he}[e]||ue;n[e]=o(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),n=i[e];if(!n)return;({attach:de,detach:de,resize:de}[e]||oe)(t,e,n),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,n){return kt(t,e,i,n)}isAttached(t){const e=xt(t);return!(!e||!xt(e))}}var fe=Object.freeze({__proto__:null,BasePlatform:Jt,BasicPlatform:te,DomPlatform:ge});const pe={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*T),easeOutSine:t=>Math.sin(t*T),easeInOutSine:t=>-.5*(Math.cos(S*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t)),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic(t){let e=1.70158,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/D*Math.asin(1),-1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*D/i))},easeOutElastic(t){let e=1.70158,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/D*Math.asin(1),1*Math.pow(2,-10*t)*Math.sin((t-e)*D/i)+1)},easeInOutElastic(t){let e=1.70158,i=0;return 0===t?0:2==(t/=.5)?1:(i||(i=.45),e=i/D*Math.asin(1),t<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*D/i)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*D/i)*.5+1)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-pe.easeOutBounce(1-t),easeOutBounce:t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,easeInOutBounce:t=>t<.5?.5*pe.easeInBounce(2*t):.5*pe.easeOutBounce(2*t-1)+.5},me={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},xe="0123456789ABCDEF",be=t=>xe[15&t],_e=t=>xe[(240&t)>>4]+xe[15&t],ye=t=>(240&t)>>4==(15&t); +/*! + * @kurkle/color v0.1.9 + * https://github.com/kurkle/color#readme + * (c) 2020 Jukka Kurkela + * Released under the MIT License + */function ve(t){var e=function(t){return ye(t.r)&&ye(t.g)&&ye(t.b)&&ye(t.a)}(t)?be:_e;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function Me(t){return t+.5|0}const we=(t,e,i)=>Math.max(Math.min(t,i),e);function ke(t){return we(Me(2.55*t),0,255)}function Pe(t){return we(Me(255*t),0,255)}function Se(t){return we(Me(t/2.55)/100,0,1)}function De(t){return we(Me(100*t),0,100)}const Oe=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const Ce=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Ae(t,e,i){const n=e*Math.min(i,1-i),o=(e,o=(e+t/30)%12)=>i-n*Math.max(Math.min(o-3,9-o,1),-1);return[o(0),o(8),o(4)]}function Te(t,e,i){const n=(n,o=(n+t/60)%6)=>i-i*e*Math.max(Math.min(o,4-o,1),0);return[n(5),n(3),n(1)]}function Le(t,e,i){const n=Ae(t,1,.5);let o;for(e+i>1&&(o=1/(e+i),e*=o,i*=o),o=0;o<3;o++)n[o]*=1-e-i,n[o]+=e;return n}function Re(t){const e=t.r/255,i=t.g/255,n=t.b/255,o=Math.max(e,i,n),s=Math.min(e,i,n),a=(o+s)/2;let r,l,c;return o!==s&&(c=o-s,l=a>.5?c/(2-o-s):c/(o+s),r=o===e?(i-n)/c+(i>16&255,s>>8&255,255&s]}return t}(),We.transparent=[0,0,0,0]);const e=We[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function He(t,e,i){if(t){let n=Re(t);n[e]=Math.max(0,Math.min(n[e]+n[e]*i,0===e?360:1)),n=ze(n),t.r=n[0],t.g=n[1],t.b=n[2]}}function je(t,e){return t?Object.assign(e||{},t):t}function Ye(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=Pe(t[3]))):(e=je(t,{r:0,g:0,b:0,a:1})).a=Pe(e.a),e}function Ue(t){return"r"===t.charAt(0)?function(t){const e=Oe.exec(t);let i,n,o,s=255;if(e){if(e[7]!==i){const t=+e[7];s=255&(e[8]?ke(t):255*t)}return i=+e[1],n=+e[3],o=+e[5],i=255&(e[2]?ke(i):i),n=255&(e[4]?ke(n):n),o=255&(e[6]?ke(o):o),{r:i,g:n,b:o,a:s}}}(t):Ie(t)}class $e{constructor(t){if(t instanceof $e)return t;const e=typeof t;let i;var n,o,s;"object"===e?i=Ye(t):"string"===e&&(s=(n=t).length,"#"===n[0]&&(4===s||5===s?o={r:255&17*me[n[1]],g:255&17*me[n[2]],b:255&17*me[n[3]],a:5===s?17*me[n[4]]:255}:7!==s&&9!==s||(o={r:me[n[1]]<<4|me[n[2]],g:me[n[3]]<<4|me[n[4]],b:me[n[5]]<<4|me[n[6]],a:9===s?me[n[7]]<<4|me[n[8]]:255})),i=o||Ne(t)||Ue(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=je(this._rgb);return t&&(t.a=Se(t.a)),t}set rgb(t){this._rgb=Ye(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${Se(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?ve(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=Re(t),i=e[0],n=De(e[1]),o=De(e[2]);return t.a<255?`hsla(${i}, ${n}%, ${o}%, ${Se(t.a)})`:`hsl(${i}, ${n}%, ${o}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const n=i.rgb,o=t.rgb;let s;const a=e===s?.5:e,r=2*a-1,l=n.a-o.a,c=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;s=1-c,n.r=255&c*n.r+s*o.r+.5,n.g=255&c*n.g+s*o.g+.5,n.b=255&c*n.b+s*o.b+.5,n.a=a*n.a+(1-a)*o.a,i.rgb=n}return i}clone(){return new $e(this.rgb)}alpha(t){return this._rgb.a=Pe(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=Me(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return He(this._rgb,2,t),this}darken(t){return He(this._rgb,2,-t),this}saturate(t){return He(this._rgb,1,t),this}desaturate(t){return He(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=Re(t);i[0]=Fe(i[0]+e),i=ze(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function Xe(t){return new $e(t)}const Ke=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function qe(t){return Ke(t)?t:Xe(t)}function Ge(t){return Ke(t)?t:Xe(t).saturate(.5).darken(.1).hexString()}const Ze="transparent",Qe={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const n=qe(t||Ze),o=n.valid&&qe(e||Ze);return o&&o.valid?o.mix(n,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class Je{constructor(t,e,i,n){const o=e[i];n=Ht([t.to,n,o,t.from]);const s=Ht([t.from,o,n]);this._active=!0,this._fn=t.fn||Qe[t.type||typeof s],this._easing=pe[t.easing||"linear"],this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=s,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,i){const n=this;if(n._active){n._notify(!1);const o=n._target[n._prop],s=i-n._start,a=n._duration-s;n._start=i,n._duration=Math.floor(Math.max(a,t.duration)),n._loop=!!t.loop,n._to=Ht([t.to,e,o,t.from]),n._from=Ht([t.from,o,e])}}cancel(){const t=this;t._active&&(t.tick(Date.now()),t._active=!1,t._notify(!1))}tick(t){const e=this,i=t-e._start,n=e._duration,o=e._prop,s=e._from,a=e._loop,r=e._to;let l;if(e._active=s!==r&&(a||i1?2-l:l,l=e._easing(Math.min(1,Math.max(0,l))),e._target[o]=e._fn(s,r,l))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t{const n=t[i];c(n)||(e[i]=n)})),e}(t);Object.keys(t).forEach((n=>{const o=t[n];c(o)&&(o.properties||[n]).forEach((t=>{if(e.has(t)){if(t===n){const{properties:i,...n}=e.get(t);e.set(t,Object.assign({},n,o))}}else e.set(t,Object.assign({},i,o))}))}))}_animateOptions(t,e){const i=e.options,n=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&!e.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!n)return[];const o=this._createAnimations(n,i);return i.$shared&&!n.$shared&&function(t,e){const i=[],n=Object.keys(e);for(let e=0;e{t.options=i}),(()=>{})),o}_createAnimations(t,e){const i=this._properties,n=[],o=t.$animations||(t.$animations={}),s=Object.keys(e),a=Date.now();let r;for(r=s.length-1;r>=0;--r){const l=s[r];if("$"===l.charAt(0))continue;if("options"===l){n.push(...this._animateOptions(t,e));continue}const c=e[l];let h=o[l];const d=i.get(l);if(h){if(d&&h.active()){h.update(d,c,a);continue}h.cancel()}d&&d.duration?(o[l]=h=new Je(d,t,l,c),n.push(h)):t[l]=c}return n}update(t,e){if(0===this._properties.size)return function(t,e){const i=t.options,n=e.options;i&&n&&(i.$shared&&!n.$shared?t.options=Object.assign({},i,n,{$shared:!1}):Object.assign(i,n),delete e.options)}(t,e),void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(o.add(this._chart,i),!0):void 0}}function ii(t,e){const i=t&&t.options||{},n=i.reverse,o=void 0===i.min?e:0,s=void 0===i.max?e:0;return{start:n?s:o,end:n?o:s}}function ni(t,e){const i=[],n=t._getSortedDatasetMetas(e);let o,s;for(o=0,s=n.length;oi[t].axis===e)).shift()}function ci(t,e){(e=e||t._parsed).forEach((e=>{void 0!==e._stacks[t.vScale.id]&&void 0!==e._stacks[t.vScale.id][t.index]&&delete e._stacks[t.vScale.id][t.index]}))}const hi=(t,e)=>e?"hover"+w(t):t,di=t=>"reset"===t||"none"===t;class ui{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedAnimations={},this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this._config=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this.initialize()}initialize(){const t=this,e=t._cachedMeta;t.configure(),t.linkScales(),e._stacked=si(e.vScale,e),t.addElements()}updateIndex(t){this.index=t}linkScales(){const t=this,e=t.chart,i=t._cachedMeta,n=t.getDataset(),o=(t,e,i,n)=>"x"===t?e:"r"===t?n:i,s=i.xAxisID=u(n.xAxisID,li(e,"x")),a=i.yAxisID=u(n.yAxisID,li(e,"y")),r=i.rAxisID=u(n.rAxisID,li(e,"r")),l=i.indexAxis,c=i.iAxisID=o(l,s,a,r),h=i.vAxisID=o(l,a,s,r);i.xScale=t.getScaleForId(s),i.yScale=t.getScaleForId(a),i.rScale=t.getScaleForId(r),i.iScale=t.getScaleForId(c),i.vScale=t.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&pt(this._data,this),t._stacked&&ci(t)}_dataCheck(){const t=this,e=t.getDataset(),i=e.data||(e.data=[]);c(i)?t._data=function(t){const e=Object.keys(t),i=new Array(e.length);let n,o,s;for(n=0,o=e.length;n0&&n._parsed[t-1];if(!1===i._parsing)n._parsed=o,n._sorted=!0;else{u=l(o[t])?i.parseArrayData(n,o,t,e):c(o[t])?i.parseObjectData(n,o,t,e):i.parsePrimitiveData(n,o,t,e);const s=()=>isNaN(d[r])||f&&d[r]p||d=0;--u)if(!m()){i.updateRangeFromParsed(c,t,f,l);break}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let n,o,s;for(n=0,o=e.length;n-1!==t.indexOf("Color")&&!(t in e)));let o,s=n.length-1;for(;s>=0;s--)o=n[s],e[o]=Ge(i[o])}getStyle(t,e){const i=this,n=i._cachedMeta.dataset;i._config||i.configure();const o=n&&void 0===t?i.resolveDatasetElementOptions(e):i.resolveDataElementOptions(t||0,e&&"active");return e&&i._addAutomaticHoverColors(t,o),o}getContext(t,e){const i=this;let n;if(t>=0&&te?t:Object.assign({},t))(s,a);const r={cacheable:!n},l=i._resolveOptions(i.dataElementOptions,{index:t,active:n,info:r,type:i.dataElementType.id});return r.cacheable&&(l.$shared=a,o[e]=Object.freeze(Object.assign({},l))),l}_resolveOptions(t,e){const i=this,{index:n,active:o,type:s,info:a}=e,r=i._config,c=i.chart.options.elements[s]||{},h={},d=i.getContext(n,o),u=(t=>l(t)?t:Object.keys(t))(t);for(let e=0,i=u.length;ei?e._insertElements(i,n-i,t):n{o[t]=n[t]&&n[t].active()?n[t]._to:i[t]})),o}}gi.defaults={},gi.defaultRoutes=void 0;const fi=new Map;function pi(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let n=fi.get(i);return n||(n=new Intl.NumberFormat(t,e),fi.set(i,n)),n}(e,i).format(t)}const mi={values:t=>l(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const n=this.chart.options.locale,o=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));let s;(o<1e-4||o>1e15)&&(s="scientific");let a=i.length>3?i[2].value-i[1].value:i[1].value-i[0].value;Math.abs(a)>1&&t!==Math.floor(t)&&(a=t-Math.floor(t));const r=z(Math.abs(a)),l=Math.max(Math.min(-1*Math.floor(r),20),0),c={notation:s,minimumFractionDigits:l,maximumFractionDigits:l};return Object.assign(c,this.options.ticks.format),pi(t,n,c)},logarithmic:function(t,e,i){if(0===t)return"0";const n=t/Math.pow(10,Math.floor(z(t)));return 1===n||2===n||5===n?mi.numeric.call(this,t,e,i):""}};var xi={formatters:mi};function bi(t,e){const i=[],n=t.length/e,o=t.length;let s=0;for(;sa+r)))return c}function yi(t){return t.drawTicks?t.tickLength:0}function vi(t,e){if(!t.display)return 0;const i=Nt(t.font,e),n=Wt(t.padding);return i.lineHeight+n.height}function Mi(t,e,i,n,o){const s=u(n,0),a=Math.min(u(o,t.length),t.length);let r,l,c,h=0;for(i=Math.ceil(i),o&&(r=o-n,i=r/Math.floor(r/i)),c=s;c<0;)h++,c=Math.round(s+h*i);for(l=Math.max(s,0);l=s||n<=1||!t.isHorizontal())return void(t.labelRotation=o);const h=t._getLabelSizes(),d=h.widest.width,u=h.highest.height-h.highest.offset,g=Math.min(t.maxWidth,t.chart.width-d);a=e.offset?t.maxWidth/n:g/(n-1),d+6>a&&(a=g/(n-(e.offset?.5:1)),r=t.maxHeight-yi(e.gridLines)-i.padding-vi(e.scaleLabel,t.chart.options.font),l=Math.sqrt(d*d+u*u),c=H(Math.min(Math.asin(Math.min((h.highest.height+6)/a,1)),Math.asin(Math.min(r/l,1))-Math.asin(u/l))),c=Math.max(o,Math.min(s,c))),t.labelRotation=c}afterCalculateLabelRotation(){g(this.options.afterCalculateLabelRotation,[this])}beforeFit(){g(this.options.beforeFit,[this])}fit(){const t=this,e={width:0,height:0},i=t.chart,n=t.options,o=n.ticks,s=n.scaleLabel,a=n.gridLines,r=t._isVisible(),l="top"!==n.position&&"x"===t.axis,c=t.isHorizontal(),h=r&&vi(s,i.options.font);if(c?e.width=t.maxWidth:r&&(e.width=yi(a)+h),c?r&&(e.height=yi(a)+h):e.height=t.maxHeight,o.display&&r&&t.ticks.length){const i=t._getLabelSizes(),n=i.first,s=i.last,a=i.widest,r=i.highest,h=.8*r.offset,d=o.padding;if(c){const i=0!==t.labelRotation,c=N(t.labelRotation),u=Math.cos(c),g=Math.sin(c),f=g*a.width+u*(r.height-(i?r.offset:0))+(i?0:h);e.height=Math.min(t.maxHeight,e.height+f+d);const p=t.getPixelForTick(0)-t.left,m=t.right-t.getPixelForTick(t.ticks.length-1);let x,b;i?(x=l?u*n.width+g*n.offset:g*(n.height-n.offset),b=l?g*(s.height-s.offset):u*s.width+g*s.offset):"start"===o.align?(x=0,b=s.width):"end"===o.align?(x=n.width,b=0):(x=n.width/2,b=s.width/2),t.paddingLeft=Math.max((x-p)*t.width/(t.width-p),0)+3,t.paddingRight=Math.max((b-m)*t.width/(t.width-m),0)+3}else{const i=o.mirror?0:a.width+d+h;e.width=Math.min(t.maxWidth,e.width+i);let r=s.height/2,l=n.height/2;"start"===o.align?(r=0,l=n.height):"end"===o.align&&(r=s.height,l=0),t.paddingTop=r,t.paddingBottom=l}}t._handleMargins(),c?(t.width=t._length=i.width-t._margins.left-t._margins.right,t.height=e.height):(t.width=e.width,t.height=t._length=i.height-t._margins.top-t._margins.bottom)}_handleMargins(){const t=this;t._margins&&(t._margins.left=Math.max(t.paddingLeft,t._margins.left),t._margins.top=Math.max(t.paddingTop,t._margins.top),t._margins.right=Math.max(t.paddingRight,t._margins.right),t._margins.bottom=Math.max(t.paddingBottom,t._margins.bottom))}afterFit(){g(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){const e=this;e.beforeTickToLabelConversion(),e.generateTickLabels(t),e.afterTickToLabelConversion()}_getLabelSizes(){const t=this;let e=t._labelSizes;return e||(t._labelSizes=e=t._computeLabelSizes()),e}_computeLabelSizes(){const t=this,e=t.ctx,i=t._longestTextCache,n=t.options.ticks.sampleSize,o=[],s=[],a=[];let c=0,h=0,d=t.ticks;n{const i=t.gc,n=i.length/2;let o;if(n>e){for(o=0;oe.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){const e=this;return e._reversePixels&&(t=1-t),G(e._startPixel+t*e._length)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this,i=e.ticks||[];if(t>=0&&tn)return function(t,e,i,n){let o,s=0,a=i[0];for(n=Math.ceil(n),o=0;oo)return e}return Math.max(o,1)}(o,t,n);if(s>0){let e,i;const n=s>1?Math.round((l-a)/(s-1)):null;for(Mi(t,c,h,r(n)?0:a-n,a),e=0,i=s-1;er*o?r/n:l/o:l*o0}_computeGridLineItems(t){const e=this,i=e.axis,n=e.chart,o=e.options,{gridLines:s,position:a}=o,r=s.offsetGridLines,l=e.isHorizontal(),h=e.ticks.length+(r?1:0),d=yi(s),u=[];let g=this.getContext(0);const f=s.drawBorder?Ht([s.borderWidth,s.lineWidth,0],g,0):0,p=f/2,m=function(t){return tt(n,t,f)};let x,b,_,y,v,M,w,k,P,S,D,O;if("top"===a)x=m(e.bottom),M=e.bottom-d,k=x-p,S=m(t.top)+p,O=t.bottom;else if("bottom"===a)x=m(e.top),S=t.top,O=m(t.bottom)-p,M=x+p,k=e.top+d;else if("left"===a)x=m(e.right),v=e.right-d,w=x-p,P=m(t.left)+p,D=t.right;else if("right"===a)x=m(e.left),P=t.left,D=m(t.right)-p,v=x+p,w=e.left+d;else if("x"===i){if("center"===a)x=m((t.top+t.bottom)/2);else if(c(a)){const t=Object.keys(a)[0],i=a[t];x=m(e.chart.scales[t].getPixelForValue(i))}S=t.top,O=t.bottom,M=x+p,k=M+d}else if("y"===i){if("center"===a)x=m((t.left+t.right)/2);else if(c(a)){const t=Object.keys(a)[0],i=a[t];x=m(e.chart.scales[t].getPixelForValue(i))}v=x-p,w=v-d,P=t.left,D=t.right}for(b=0;b{const n=i.split("."),o=n.pop(),s=[t].concat(n).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");P.route(s,o,l,r)}))}(e,t.defaultRoutes)}(t,a,i)),a}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,n=this.scope;i in e&&delete e[i],n&&i in P[n]&&delete P[n][i]}}var Pi=new class{constructor(){this.controllers=new ki(ui,"controllers"),this.elements=new ki(gi,"elements"),this.plugins=new ki(Object,"plugins"),this.scales=new ki(wi,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){const n=this;[...e].forEach((e=>{const o=i||n._getRegistryForType(e);i||o.isForType(e)||o===n.plugins&&e.id?n._exec(t,o,e):f(e,(e=>{const o=i||n._getRegistryForType(e);n._exec(t,o,e)}))}))}_exec(t,e,i){const n=w(t);g(i["before"+n],[],i),e[t](i),g(i["after"+n],[],i)}_getRegistryForType(t){for(let e=0;e({model:t,deltaK:0,mK:0}))),i=e.length;let n,o,s,a,r,l,c,h,d;for(n=0;n0?e[n-1]:null,a=n0?e[n-1]:null,a=n!t.skip))),"monotone"===e.cubicInterpolationMode)Oi(t);else{let i=n?t[t.length-1]:t[0];for(o=0,s=t.length;o0&&nt(t[i-1],e)&&(o.controlPointPreviousX=Ci(o.controlPointPreviousX,e.left,e.right),o.controlPointPreviousY=Ci(o.controlPointPreviousY,e.top,e.bottom)),i0?e.y:t.y}}function Ri(t,e,i,n){const o={x:t.controlPointNextX,y:t.controlPointNextY},s={x:e.controlPointPreviousX,y:e.controlPointPreviousY},a=Ti(t,o,i),r=Ti(o,s,i),l=Ti(s,e,i),c=Ti(a,r,i),h=Ti(r,l,i);return Ti(c,h,i)}function Ei(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function zi(t,e){let i,n;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,n=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=n)}function Fi(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Ii(t){return"angle"===t?{between:K,compare:$,normalize:X}:{between:(t,e,i)=>t>=e&&t<=i,compare:(t,e)=>t-e,normalize:t=>t}}function Bi(t,e,i,n){return{start:t%n,end:e%n,loop:i&&(e-t+1)%n==0}}function Vi(t,e,i){if(!i)return[t];const{property:n,start:o,end:s}=i,a=e.length,{compare:r,between:l,normalize:c}=Ii(n),{start:h,end:d,loop:u}=function(t,e,i){const{property:n,start:o,end:s}=i,{between:a,normalize:r}=Ii(n),l=e.length;let c,h,{start:d,end:u,loop:g}=t;if(g){for(d+=l,u+=l,c=0,h=l;cx||l(o,m,f)&&0!==r(o,m),y=()=>!x||0===r(s,f)||l(s,m,f);for(let t=h,i=h;t<=d;++t)p=e[t%a],p.skip||(f=c(p[n]),x=l(f,o,s),null===b&&_()&&(b=0===r(f,o)?t:i),null!==b&&y()&&(g.push(Bi(b,t,u,a)),b=null),i=t,m=f);return null!==b&&g.push(Bi(b,d,u,a)),g}function Wi(t,e){const i=[],n=t.segments;for(let o=0;oo&&t[s%e].skip;)s--;return s%=e,{start:o,end:s}}(e,n,o,i);if(!0===i)return[{start:s,end:a,loop:o}];return function(t,e,i,n){const o=t.length,s=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%o];i.skip||i.stop?l.skip||(n=!1,s.push({start:e%o,end:(a-1)%o,loop:n}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&s.push({start:e%o,end:r%o,loop:n}),s}(e,s,at.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(n(e,i),t,"stop"),this._notify(n(i,e),t,"start")}}function Yi(t,e){return e||!1!==t?!0===t?{}:t:null}function Ui(t,e){const i=(P.controllers[t]||{}).datasets||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function $i(t,e){return"x"===t||"y"===t||"r"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Xi(t,e){const i=function(t,e){const i=P.controllers[t.type]||{scales:{}},n=e.scales||{},o=Ui(t.type,e),s=Object.create(null),a=Object.create(null);return Object.keys(n).forEach((t=>{const e=n[t],r=$i(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,o),c=i.scales||{};s[r]=s[r]||t,a[t]=y(Object.create(null),[{axis:r},e,c[r],c[l]])})),e.scale&&(a[e.scale.id||"r"]=y(Object.create(null),[{axis:"r"},e.scale,i.scales.r]),s.r=s.r||e.scale.id||"r"),t.data.datasets.forEach((i=>{const o=i.type||t.type,r=i.indexAxis||Ui(o,e),l=(P.controllers[o]||{}).scales||{};Object.keys(l).forEach((t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),o=i[e+"AxisID"]||s[e]||e;a[o]=a[o]||Object.create(null),y(a[o],[{axis:e},n[o],l[t]])}))})),Object.keys(a).forEach((t=>{const e=a[t];y(e,[P.scales[e.type],P.scale])})),a}(t,e=e||{}),n=!1!==e.interaction&&!1!==e.hover;return(e=function(...t){return _(Object.create(null),t,{merger(t,e,i,n){"scales"!==t&&"scale"!==t&&"controllers"!==t&&b(t,e,i,n)}})}(P,P.controllers[t.type],e)).hover=n&&_(Object.create(null),[P.interaction,P.hover,e.interaction,e.hover]),e.scales=i,!1!==e.plugins&&function(t){t.plugins=t.plugins||{},t.plugins.title=!1!==t.plugins.title&&_(Object.create(null),[P.plugins.title,t.plugins.title]),t.plugins.tooltip=!1!==t.plugins.tooltip&&_(Object.create(null),[P.interaction,P.plugins.tooltip,t.interaction,t.plugins.tooltip])}(e),e}class Ki{constructor(t){this._config=function(t){const e=(t=t||{}).data=t.data||{datasets:[],labels:[]};return e.datasets=e.datasets||[],e.labels=e.labels||[],t.options=Xi(t,t.options),t}(t)}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=t}get options(){return this._config.options}get plugins(){return this._config.plugins}update(t){const e=this._config;e.options=Xi(e,t)}}const qi=["top","bottom","left","right","chartArea"];function Gi(t,e){return"top"===t||"bottom"===t||-1===qi.indexOf(t)&&"x"===e}function Zi(t,e){return function(i,n){return i[t]===n[t]?i[e]-n[e]:i[t]-n[t]}}function Qi(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),g(i&&i.onComplete,[t],e)}function Ji(t){const e=t.chart,i=e.options.animation;g(i&&i.onProgress,[t],e)}function tn(){return"undefined"!=typeof window&&"undefined"!=typeof document}function en(t){return tn()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}class nn{constructor(t,e){const i=this;this.config=e=new Ki(e);const n=en(t),s=nn.getChart(n);if(s)throw new Error("Canvas is already in use. Chart with ID '"+s.id+"' must be destroyed before the canvas can be reused.");this.platform=i._initializePlatform(n,e);const r=i.platform.acquireContext(n,e),l=r&&r.canvas,c=l&&l.height,h=l&&l.width;this.id=a(),this.ctx=r,this.canvas=l,this.width=h,this.height=c,this.aspectRatio=c?h/c:null,this.options=e.options,this._layers=[],this._metasets=[],this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._sortedMetasets=[],this.scales={},this.scale=void 0,this._plugins=new ji,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,nn.instances[i.id]=i,r&&l?(o.listen(i,"complete",Qi),o.listen(i,"progress",Ji),i._initialize(),i.attached&&i.update()):console.error("Failed to create chart: can't acquire context from the given item")}get data(){return this.config.data}set data(t){this.config.data=t}_initialize(){const t=this;return t.notifyPlugins("beforeInit"),t.options.responsive?t.resize():Pt(t,t.options.devicePixelRatio),t.bindEvents(),t.notifyPlugins("afterInit"),t}_initializePlatform(t,e){return e.platform?new e.platform:!tn()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?new te:new ge}clear(){return et(this.canvas,this.ctx),this}stop(){return o.stop(this),this}resize(t,e){o.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this,n=i.options,o=i.canvas,s=n.maintainAspectRatio&&i.aspectRatio,a=i.platform.getMaximumSize(o,t,e,s),r=i.currentDevicePixelRatio,l=n.devicePixelRatio||i.platform.getDevicePixelRatio();i.width===a.width&&i.height===a.height&&r===l||(o.width=i.width=a.width,o.height=i.height=a.height,o.style&&(o.style.width=a.width+"px",o.style.height=a.height+"px"),Pt(i,l),i.notifyPlugins("resize",{size:a}),g(n.onResize,[a],i),i.attached&&i.update("resize"))}ensureScalesHaveIDs(){const t=this.options,e=t.scales||{},i=t.scale;f(e,((t,e)=>{t.id=e})),i&&(i.id=i.id||"scale")}buildOrUpdateScales(){const t=this,e=t.options,i=e.scales,n=t.scales||{},o=Object.keys(n).reduce(((t,e)=>(t[e]=!1,t)),{});let s=[];i&&(s=s.concat(Object.keys(i).map((t=>{const e=i[t],n=$i(t,e),o="r"===n,s="x"===n;return{options:e,dposition:o?"chartArea":s?"bottom":"left",dtype:o?"radialLinear":s?"category":"linear"}})))),f(s,(i=>{const s=i.options,a=s.id,r=$i(a,s),l=u(s.type,i.dtype);void 0!==s.position&&Gi(s.position,r)===Gi(i.dposition)||(s.position=i.dposition),o[a]=!0;let c=null;if(a in n&&n[a].type===l)c=n[a];else{c=new(Pi.getScale(l))({id:a,type:l,ctx:t.ctx,chart:t}),n[c.id]=c}c.init(s,e),i.isDefault&&(t.scale=c)})),f(o,((t,e)=>{t||delete n[e]})),t.scales=n,f(n,(e=>{Qt.configure(t,e,e.options),Qt.addBox(t,e)}))}_updateMetasetIndex(t,e){const i=this._metasets,n=t.index;n!==e&&(i[n]=i[e],i[e]=t,t.index=e)}_updateMetasets(){const t=this,e=t._metasets,i=t.data.datasets.length,n=e.length;if(n>i){for(let e=i;e{0===e.filter((t=>t===i._dataset)).length&&t._destroyDatasetMeta(n)}))}buildOrUpdateControllers(){const t=this,e=[],i=t.data.datasets;let n,o;for(t._removeUnreferencedMetasets(),n=0,o=i.length;n{t.getDatasetMeta(i).controller.reset()}),t)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this;let i,n;f(e.scales,(t=>{Qt.removeBox(e,t)})),e.config.update(e.options),e.options=e.config.options;const o=e._animationsDisabled=!e.options.animation;if(e.ensureScalesHaveIDs(),e.buildOrUpdateScales(),e._plugins.invalidate(),!1===e.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const s=e.buildOrUpdateControllers();for(e.notifyPlugins("beforeElementsUpdate"),i=0,n=e.data.datasets.length;i{t.reset()})),e._updateDatasets(t),e.notifyPlugins("afterUpdate",{mode:t}),e._layers.sort(Zi("z","_idx")),e._lastEvent&&e._eventHandler(e._lastEvent,!0),e.render()}_updateLayout(){const t=this;if(!1===t.notifyPlugins("beforeLayout",{cancelable:!0}))return;Qt.update(t,t.width,t.height);const e=t.chartArea,i=e.width<=0||e.height<=0;t._layers=[],f(t.boxes,(e=>{i&&"chartArea"===e.position||(e.configure&&e.configure(),t._layers.push(...e._layers()))}),t),t._layers.forEach(((t,e)=>{t._idx=e})),t.notifyPlugins("afterLayout")}_updateDatasets(t){const e=this,i="function"==typeof t;if(!1!==e.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let n=0,o=e.data.datasets.length;n=0;--i)t._drawDataset(e[i]);t.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this,i=e.ctx,n=t._clip,o=e.chartArea,s={meta:t,index:t.index,cancelable:!0};!1!==e.notifyPlugins("beforeDatasetDraw",s)&&(ot(i,{left:!1===n.left?0:o.left-n.left,right:!1===n.right?e.width:o.right+n.right,top:!1===n.top?0:o.top-n.top,bottom:!1===n.bottom?e.height:o.bottom+n.bottom}),t.controller.draw(),st(i),s.cancelable=!1,e.notifyPlugins("afterDatasetDraw",s))}getElementsAtEventForMode(t,e,i,n){const o=Et.modes[e];return"function"==typeof o?o(this,t,i,n):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let n=i.filter((t=>t&&t._dataset===e)).pop();return n||(n=i[t]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1}),n}getContext(){return this.$context||(this.$context=Object.create(null,{chart:{value:this},type:{value:"chart"}}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateDatasetVisibility(t,e){const i=this,n=e?"show":"hide",o=i.getDatasetMeta(t),s=o.controller._resolveAnimations(void 0,n);i.setDatasetVisibility(t,e),s.update(o,{visible:e}),i.update((e=>e.datasetIndex===t?n:void 0))}hide(t){this._updateDatasetVisibility(t,!1)}show(t){this._updateDatasetVisibility(t,!0)}_destroyDatasetMeta(t){const e=this,i=e._metasets&&e._metasets[t];i&&i.controller&&(i.controller._destroy(),delete e._metasets[t])}destroy(){const t=this,{canvas:e,ctx:i}=t;let n,s;for(t.stop(),o.remove(t),n=0,s=t.data.datasets.length;n{i.addEventListener(t,n,o),e[n]=o},o=(n,o)=>{e[n]&&(i.removeEventListener(t,n,o),delete e[n])};let s=function(e,i,n){e.offsetX=i,e.offsetY=n,t._eventHandler(e)};if(f(t.options.events,(t=>n(t,s))),t.options.responsive){let e;s=(e,i)=>{t.canvas&&t.resize(e,i)};const a=()=>{o("attach",a),t.attached=!0,t.resize(),n("resize",s),n("detach",e)};e=()=>{t.attached=!1,o("resize",s),n("attach",a)},i.isAttached(t.canvas)?a():e()}else t.attached=!0}unbindEvents(){const t=this,e=t._listeners;e&&(delete t._listeners,f(e,((e,i)=>{t.platform.removeEventListener(t,i,e)})))}updateHoverStyle(t,e,i){const n=i?"set":"remove";let o,s,a,r;for("dataset"===e&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),a=0,r=t.length;a{const n=e.getDatasetMeta(t);if(!n)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:n.data[i],index:i}}));!p(n,i)&&(e._active=n,e._updateHoverStyles(n,i))}notifyPlugins(t,e){return this._plugins.notify(this,t,e)}_updateHoverStyles(t,e,i){const n=this,o=(n.options||{}).hover,s=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),a=s(e,t),r=i?t:s(t,e);a.length&&n.updateHoverStyle(a,o.mode,!1),r.length&&o.mode&&n.updateHoverStyle(r,o.mode,!0)}_eventHandler(t,e){const i=this,n={event:t,replay:e,cancelable:!0};if(!1===i.notifyPlugins("beforeEvent",n))return;const o=i._handleEvent(t,e);return n.cancelable=!1,i.notifyPlugins("afterEvent",n),(o||n.changed)&&i.render(),i}_handleEvent(t,e){const i=this,n=i._active||[],o=i.options,s=o.hover,a=e;let r=[],l=!1;return"mouseout"===t.type?i._lastEvent=null:(r=i.getElementsAtEventForMode(t,s.mode,s,a),i._lastEvent="click"===t.type?i._lastEvent:t),g(o.onHover||o.hover.onHover,[t,r,i],i),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||nt(t,i.chartArea)&&g(o.onClick,[t,r,i],i),l=!p(r,n),(l||e)&&(i._active=r,i._updateHoverStyles(r,n,e)),l}}nn.defaults=P,nn.instances={},nn.registry=Pi,nn.version="3.0.0-beta.10",nn.getChart=t=>{const e=en(t);return Object.values(nn.instances).filter((t=>t.canvas===e)).pop()};const on=()=>f(nn.instances,(t=>t._plugins.invalidate()));function sn(){throw new Error("This method is not implemented: either no adapter can be found or an incomplete integration was provided.")}nn.register=(...t)=>{Pi.add(...t),on()},nn.unregister=(...t)=>{Pi.remove(...t),on()};class an{constructor(t){this.options=t||{}}formats(){return sn()}parse(t,e){return sn()}format(t,e){return sn()}add(t,e,i){return sn()}diff(t,e,i){return sn()}startOf(t,e,i){return sn()}endOf(t,e){return sn()}}an.override=function(t){Object.assign(an.prototype,t)};var rn={_date:an};function ln(t){const e=function(t){if(!t._cache.$bar){const e=t.getMatchingVisibleMetas("bar");let i=[];for(let n=0,o=e.length;nt-e)))}return t._cache.$bar}(t);let i,n,o,s,a=t._length;const r=()=>{a=Math.min(a,i&&Math.abs(o-s)||a),s=o};for(i=0,n=e.length;iMath.abs(r)&&(l=r,c=a),e[i.axis]=c,e._custom={barStart:l,barEnd:c,start:o,end:s,min:a,max:r}}(t,e,i,n):e[i.axis]=i.parse(t,n),e}function hn(t,e,i,n){const o=t.iScale,s=t.vScale,a=o.getLabels(),r=o===s,l=[];let c,h,d,u;for(c=i,h=i+n;c0?o[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size());return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:n}=e,o=this.getParsed(t),s=i.getLabelForValue(o.x),a=n.getLabelForValue(o.y),r=o._custom;return{label:e.label,value:"("+s+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,n){const o=this,s="reset"===n,{xScale:a,yScale:r}=o._cachedMeta,l=o.resolveDataElementOptions(e,n),c=o.getSharedOptions(l),h=o.includeOptions(n,c);for(let l=e;l""}}}};class fn extends ui{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,n=this._cachedMeta;let o,s;for(o=t,s=t+e;o=S?-D:r<-S?D:0;const l=r+e,c=Math.cos(r),h=Math.sin(r),d=Math.cos(l),u=Math.sin(l),g=r<=0&&l>=0||l>=D,f=r<=T&&l>=T||l>=D+T,p=r<=-T&&l>=-T||l>=S+T,m=r===-S||l>=S?-1:Math.min(c,c*i,d,d*i),x=p?-1:Math.min(h,h*i,u,u*i),b=g?1:Math.max(c,c*i,d,d*i),_=f?1:Math.max(h,h*i,u,u*i);n=(b-m)/2,o=(_-x)/2,s=-(b+m)/2,a=-(_+x)/2}return{ratioX:n,ratioY:o,offsetX:s,offsetY:a}}(h,c,r),p=e.getMaxBorderWidth()+e.getMaxOffset(a),m=(n.right-n.left-p)/d,x=(n.bottom-n.top-p)/u,b=Math.max(Math.min(m,x)/2,0),_=(b-Math.max(b*r,0))/e._getVisibleDatasetWeightTotal();e.offsetX=g*b,e.offsetY=f*b,s.total=e.calculateTotal(),e.outerRadius=b-_*e._getRingWeightOffset(e.index),e.innerRadius=Math.max(e.outerRadius-_*l,0),e.updateElements(a,0,a.length,t)}_circumference(t,e){const i=this,n=i.chart.options,o=i._cachedMeta,s=i._getCircumference();return e&&n.animation.animateRotate?0:this.chart.getDataVisibility(t)?i.calculateCircumference(o._parsed[t]*s/D):0}updateElements(t,e,i,n){const o=this,s="reset"===n,a=o.chart,r=a.chartArea,l=a.options.animation,c=(r.left+r.right)/2,h=(r.top+r.bottom)/2,d=s&&l.animateScale,u=d?0:o.innerRadius,g=d?0:o.outerRadius,f=o.resolveDataElementOptions(e,n),p=o.getSharedOptions(f),m=o.includeOptions(n,p);let x,b=o._getRotation();for(x=0;x0&&!isNaN(t)?D*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,n=i.data.labels||[],o=pi(e._parsed[t],i.options.locale);return{label:n[t]||"",value:o}}getMaxBorderWidth(t){const e=this;let i=0;const n=e.chart;let o,s,a,r,l;if(!t)for(o=0,s=n.data.datasets.length;o{const n=t.getDatasetMeta(0).controller.getStyle(i);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,hidden:!t.getDataVisibility(i),index:i}})):[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return l(e)?(e=e.slice(),e[0]+=i):e+=i,e}}}}};class pn extends ui{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this,i=e._cachedMeta,{dataset:n,data:o=[]}=i,s=e.chart._animationsDisabled;let{start:a,count:r}=function(t,e,i){const n=e.length;let o=0,s=n;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:c,max:h,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(o=q(Math.min(ht(r,a.axis,c).lo,i?n:ht(e,l,a.getPixelForValue(c)).lo),0,n-1)),s=u?q(Math.max(ht(r,a.axis,h).hi+1,i?0:ht(e,l,a.getPixelForValue(h)).hi+1),o,n)-o:n-o}return{start:o,count:s}}(i,o,s);e._drawStart=a,e._drawCount=r,function(t){const{xScale:e,yScale:i,_scaleRanges:n}=t,o={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!n)return t._scaleRanges=o,!0;const s=n.xmin!==e.min||n.xmax!==e.max||n.ymin!==i.min||n.ymax!==i.max;return Object.assign(n,o),s}(i)&&!s&&(a=0,r=o.length),n.points=o,"resize"!==t&&e.updateElement(n,void 0,{animated:!s,options:e.resolveDatasetElementOptions()},t),e.updateElements(o,a,r,t)}updateElements(t,e,i,n){const o=this,s="reset"===n,{xScale:a,yScale:r,_stacked:l}=o._cachedMeta,c=o.resolveDataElementOptions(e,n),h=o.getSharedOptions(c),d=o.includeOptions(n,h),g=u(o._config.spanGaps,o.chart.options.spanGaps),f=F(g)?g:Number.POSITIVE_INFINITY,p=o.chart._animationsDisabled||s||"none"===n;let m=e>0&&o.getParsed(e-1);for(let c=e;c0&&i.x-m.x>f,d&&(u.options=h||o.resolveDataElementOptions(c,n)),p||o.updateElement(e,c,u,n),m=i}o.updateSharedOptions(h,n,c)}resolveDatasetElementOptions(t){const e=this._config,i=this.chart.options,n=i.elements.line,o=super.resolveDatasetElementOptions(t),s=u(e.showLine,i.showLine);return o.spanGaps=u(e.spanGaps,i.spanGaps),o.tension=u(e.tension,n.tension),o.stepped=Ht([e.stepped,n.stepped]),s||(o.borderWidth=0),o}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset.options.borderWidth||0,i=t.data||[];if(!i.length)return e;const n=i[0].size(),o=i[i.length-1].size();return Math.max(e,n,o)/2}draw(){this._cachedMeta.dataset.updateControlPoints(this.chart.chartArea),super.draw()}}pn.id="line",pn.defaults={datasetElementType:"line",datasetElementOptions:["backgroundColor","borderCapStyle","borderColor","borderDash","borderDashOffset","borderJoinStyle","borderWidth","capBezierPoints","cubicInterpolationMode","fill"],dataElementType:"point",dataElementOptions:{backgroundColor:"pointBackgroundColor",borderColor:"pointBorderColor",borderWidth:"pointBorderWidth",hitRadius:"pointHitRadius",hoverHitRadius:"pointHitRadius",hoverBackgroundColor:"pointHoverBackgroundColor",hoverBorderColor:"pointHoverBorderColor",hoverBorderWidth:"pointHoverBorderWidth",hoverRadius:"pointHoverRadius",pointStyle:"pointStyle",radius:"pointRadius",rotation:"pointRotation"},showLine:!0,spanGaps:!1,interaction:{mode:"index"},hover:{},scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class mn extends ui{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this,e=t.chart,i=e.chartArea,n=e.options,o=Math.min(i.right-i.left,i.bottom-i.top),s=Math.max(o/2,0),a=(s-Math.max(n.cutoutPercentage?s/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();t.outerRadius=s-a*t.index,t.innerRadius=t.outerRadius-a}updateElements(t,e,i,n){const o=this,s="reset"===n,a=o.chart,r=o.getDataset(),l=a.options,c=l.animation,h=o._cachedMeta.rScale,d=h.xCenter,u=h.yCenter,g=N(l.startAngle)-.5*S;let f,p=g;for(o._cachedMeta.count=o.countVisibleElements(),f=0;f{!isNaN(t.data[n])&&this.chart.getDataVisibility(n)&&i++})),i}_computeAngle(t,e){const i=this,n=i._cachedMeta.count,o=i.getDataset();if(isNaN(o.data[t])||!this.chart.getDataVisibility(t))return 0;const s=i.getContext(t,"active"===e);return N(Ht([i.chart.options.elements.arc.angle,360/n],s,t))}}mn.id="polarArea",mn.defaults={dataElementType:"arc",dataElementOptions:["backgroundColor","borderColor","borderWidth","borderAlign","offset"],animation:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]},animateRotate:!0,animateScale:!0},aspectRatio:1,datasets:{indexAxis:"r"},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,gridLines:{circular:!0},pointLabels:{display:!1}}},startAngle:0,plugins:{legend:{labels:{generateLabels(t){const e=t.data;return e.labels.length&&e.datasets.length?e.labels.map(((e,i)=>{const n=t.getDatasetMeta(0).controller.getStyle(i);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,hidden:!t.getDataVisibility(i),index:i}})):[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}}};class xn extends fn{}xn.id="pie",xn.defaults={cutoutPercentage:0};class bn extends ui{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this,i=e._cachedMeta,n=i.dataset,o=i.data||[],s=i.iScale.getLabels();if(n.points=o,"resize"!==t){const i={_loop:!0,_fullLoop:s.length===o.length,options:e.resolveDatasetElementOptions()};e.updateElement(n,void 0,i,t)}e.updateElements(o,0,o.length,t)}updateElements(t,e,i,n){const o=this,s=o.getDataset(),a=o._cachedMeta.rScale,r="reset"===n;for(let l=e;l"",label:t=>"("+t.label+", "+t.formattedValue+")"}}}};var yn=Object.freeze({__proto__:null,BarController:un,BubbleController:gn,DoughnutController:fn,LineController:pn,PolarAreaController:mn,PieController:xn,RadarController:bn,ScatterController:_n});function vn(t,e){const{startAngle:i,endAngle:n,pixelMargin:o,x:s,y:a,outerRadius:r,innerRadius:l}=e;let c=o/r;t.beginPath(),t.arc(s,a,r,i-c,n+c),l>o?(c=o/l,t.arc(s,a,l,n+c,i-c,!0)):t.arc(s,a,o,n+T,i-T),t.closePath(),t.clip()}function Mn(t,e){const{x:i,y:n,startAngle:o,endAngle:s,pixelMargin:a}=e,r=Math.max(e.outerRadius-a,0),l=e.innerRadius+a;t.beginPath(),t.arc(i,n,r,o,s),t.arc(i,n,l,s,o,!0),t.closePath()}function wn(t,e){const{x:i,y:n,startAngle:o,endAngle:s,pixelMargin:a,options:r}=e,l=e.outerRadius,c=e.innerRadius+a,h="inner"===r.borderAlign;r.borderWidth&&(h?(t.lineWidth=2*r.borderWidth,t.lineJoin="round"):(t.lineWidth=r.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:n,y:o,startAngle:s,endAngle:a,pixelMargin:r}=e,l=Math.max(e.outerRadius-r,0),c=e.innerRadius+r;let h;for(i&&(e.endAngle=e.startAngle+D,vn(t,e),e.endAngle=a,e.endAngle===e.startAngle&&(e.endAngle+=D,e.fullCircles--)),t.beginPath(),t.arc(n,o,c,s+D,s,!0),h=0;h=D||K(o,a,r))&&(s>=l&&s<=c)}getCenterPoint(t){const{x:e,y:i,startAngle:n,endAngle:o,innerRadius:s,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),r=(n+o)/2,l=(s+a)/2;return{x:e+Math.cos(r)*l,y:i+Math.sin(r)*l}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const e=this,i=e.options,n=i.offset||0;if(e.pixelMargin="inner"===i.borderAlign?.33:0,e.fullCircles=Math.floor(e.circumference/D),!(0===e.circumference||e.innerRadius<0||e.outerRadius<0)){if(t.save(),n&&e.circumference(a+(c?r-t:t))%s,_=()=>{g!==f&&(t.lineTo(m,f),t.lineTo(m,g),t.lineTo(m,p))};for(l&&(d=o[b(0)],t.moveTo(d.x,d.y)),h=0;h<=r;++h){if(d=o[b(h)],d.skip)continue;const e=d.x,i=d.y,n=0|e;n===u?(if&&(f=i),m=(x*m+e)/++x):(_(),t.lineTo(e,i),u=n,x=0,g=f=i),p=i}_()}function Cn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._loop||e.tension||e.stepped||i)?On:Dn}kn.id="arc",kn.defaults={borderAlign:"center",borderColor:"#fff",borderWidth:2,offset:0},kn.defaultRoutes={backgroundColor:"backgroundColor"};class An extends gi{constructor(t){super(),this.animated=!0,this.options=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._pointsUpdated=!1,t&&Object.assign(this,t)}updateControlPoints(t){const e=this,i=e.options;if(i.tension&&!i.stepped&&!e._pointsUpdated){const n=i.spanGaps?e._loop:e._fullLoop;Ai(e._points,i,t,n),e._pointsUpdated=!0}}set points(t){const e=this;e._points=t,delete e._segments,delete e._path,e._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Ni(this))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this,n=i.options,o=t[e],s=i.points,a=Wi(i,{property:e,start:o,end:o});if(!a.length)return;const r=[],l=function(t){return t.stepped?Li:t.tension?Ri:Ti}(n);let c,h;for(c=0,h=a.length;ct.x):En(e,"bottom","top",t.base=a.left&&e<=a.right)&&(s||i>=a.top&&i<=a.bottom)}function Vn(t,e){const{x:i,y:n,w:o,h:s,radius:a}=e;t.arc(i+a.topLeft,n+a.topLeft,a.topLeft,-T,S,!0),t.lineTo(i,n+s-a.bottomLeft),t.arc(i+a.bottomLeft,n+s-a.bottomLeft,a.bottomLeft,S,T,!0),t.lineTo(i+o-a.bottomRight,n+s),t.arc(i+o-a.bottomRight,n+s-a.bottomRight,a.bottomRight,T,0,!0),t.lineTo(i+o,n+a.topRight),t.arc(i+o-a.topRight,n+a.topRight,a.topRight,0,-T,!0),t.lineTo(i+a.topLeft,n)}function Wn(t,e){t.rect(e.x,e.y,e.w,e.h)}Tn.id="point",Tn.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3},Tn.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};class Nn extends gi{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,t&&Object.assign(this,t)}draw(t){const e=this.options,{inner:i,outer:n}=In(this),o=(s=n.radius).topLeft||s.topRight||s.bottomLeft||s.bottomRight?Vn:Wn;var s;t.save(),n.w===i.w&&n.h===i.h||(t.beginPath(),o(t,n),t.clip(),o(t,i),t.fillStyle=e.borderColor,t.fill("evenodd")),t.beginPath(),o(t,i),t.fillStyle=e.backgroundColor,t.fill(),t.restore()}inRange(t,e,i){return Bn(this,t,e,i)}inXRange(t,e){return Bn(this,t,null,e)}inYRange(t,e){return Bn(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:n,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(e+n)/2:e,y:o?i:(i+n)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}Nn.id="bar",Nn.defaults={borderSkipped:"start",borderWidth:0,borderRadius:0},Nn.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};var Hn=Object.freeze({__proto__:null,ArcElement:kn,LineElement:An,PointElement:Tn,BarElement:Nn});var jn={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return;const n=t.width;t.data.datasets.forEach(((e,o)=>{const{_data:s,indexAxis:a}=e,l=t.getDatasetMeta(o),c=s||e.data;if("y"===Ht([a,t.options.indexAxis]))return;if("line"!==l.type)return;const h=t.scales[l.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;if(c.length<=4*n)return;let d;switch(r(s)&&(e._data=c,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"min-max":d=function(t,e){let i,n,o,s,a,r,l,c,h;const d=[],u=t[0].x,g=t[t.length-1].x-u;for(i=0;ih&&(h=s,l=i):(r&&l&&d.push(t[r],t[l]),i>0&&d.push(t[i-1]),d.push(n),a=f,c=h=s,r=l=i)}return d}(c,n);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=d}))},destroy(t){t.data.datasets.forEach((t=>{if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{value:e})}}))}};function Yn(t,e,i){const n=function(t){const e=t.options,i=e.fill;let n=u(i&&i.target,i);return void 0===n&&(n=!!e.backgroundColor),!1!==n&&null!==n&&(!0===n?"origin":n)}(t);if(c(n))return!isNaN(n.value)&&n;let o=parseFloat(n);return h(o)&&Math.floor(o)===o?("-"!==n[0]&&"+"!==n[0]||(o=e+o),!(o===e||o<0||o>=i)&&o):["origin","start","end","stack"].indexOf(n)>=0&&n}class Un{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:n,y:o,radius:s}=this;return e=e||{start:0,end:D},i.reverse?t.arc(n,o,s,e.end,e.start,!0):t.arc(n,o,s,e.start,e.end),!i.bounds}interpolate(t,e){const{x:i,y:n,radius:o}=this,s=t.angle;if("angle"===e)return{x:i+Math.cos(s)*o,y:n+Math.sin(s)*o,angle:s}}}function $n(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,n=e.options,o=e.getLabels().length,s=[],a=n.reverse?e.max:e.min,r=n.reverse?e.min:e.max;let l,h,d;if(d="start"===i?a:"end"===i?r:c(i)?i.value:e.getBaseValue(),n.gridLines.circular)return h=e.getPointPositionForValue(0,a),new Un({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(d)});for(l=0;l"line"===t.type&&!t.hidden;function qn(t,e,i){const n=[];for(let o=0;o=n&&o<=c){r=o===n,l=o===c;break}}return{first:r,last:l,point:n}}function Zn(t,e){let i=[],n=!1;return l(t)?(n=!0,i=t):i=function(t,e){const{x:i=null,y:n=null}=t||{},o=e.points,s=[];return e.segments.forEach((t=>{const e=o[t.start],a=o[t.end];null!==n?(s.push({x:e.x,y:n}),s.push({x:a.x,y:n})):null!==i&&(s.push({x:i,y:e.y}),s.push({x:i,y:a.y}))})),s}(t,e),i.length?new An({points:i,options:{tension:0},_loop:n,_fullLoop:n}):null}function Qn(t,e,i){let n=t[e].fill;const o=[e];let s;if(!i)return n;for(;!1!==n&&-1===o.indexOf(n);){if(!h(n))return n;if(s=t[n],!s)return!1;if(s.visible)return n;o.push(n),n=s.fill}return!1}function Jn(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function to(t,e,i,n){if(n)return;let o=e[t],s=i[t];return"angle"===t&&(o=X(o),s=X(s)),{property:t,start:o,end:s}}function eo(t,e,i,n){return t&&e?n(t[i],e[i]):t?t[i]:e?e[i]:0}function io(t,e,i){const{top:n,bottom:o}=e.chart.chartArea,{property:s,start:a,end:r}=i||{};"x"===s&&(t.beginPath(),t.rect(a,n,r-a,o-n),t.clip())}function no(t,e,i,n){const o=e.interpolate(i,n);o&&t.lineTo(o.x,o.y)}function oo(t,e){const{line:i,target:n,property:o,color:s,scale:a}=e,r=function(t,e,i){const n=t.segments,o=t.points,s=e.points,a=[];for(let t=0;t=0;--n)o=e[n].$filler,o&&o.line.updateControlPoints(i)},beforeDatasetDraw(t,e){const i=t.chartArea,n=t.ctx,o=e.meta.$filler;if(!o||!1===o.fill)return;const s=function(t){const{chart:e,fill:i,line:n}=t;if(h(i))return function(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}(e,i);if("stack"===i)return Xn(t);const o=$n(t);return o instanceof Un?o:Zn(o,n)}(o),{line:a,scale:r}=o,l=a.options,c=l.fill,d=l.backgroundColor,{above:u=d,below:g=d}=c||{};s&&a.points.length&&(ot(n,i),function(t,e){const{line:i,target:n,above:o,below:s,area:a,scale:r}=e,l=i._loop?"angle":"x";t.save(),"x"===l&&s!==o&&(Jn(t,n,a.top),oo(t,{line:i,target:n,color:o,scale:r,property:l}),t.restore(),t.save(),Jn(t,n,a.bottom)),oo(t,{line:i,target:n,color:s,scale:r,property:l}),t.restore()}(n,{line:a,target:s,above:u,below:g,area:i,scale:r}),st(n))},defaults:{propagate:!0}};const ao=(t,e)=>{let{boxHeight:i=e,boxWidth:n=e}=t;return t.usePointStyle&&(i=Math.min(i,e),n=Math.min(n,e)),{boxWidth:n,boxHeight:i,itemHeight:Math.max(e,i)}};class ro extends gi{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){const n=this;n.maxWidth=t,n.maxHeight=e,n._margins=i,n.setDimensions(),n.buildLabels(),n.fit()}setDimensions(){const t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height)}buildLabels(){const t=this,e=t.options.labels||{};let i=g(e.generateLabels,[t.chart],t)||[];e.filter&&(i=i.filter((i=>e.filter(i,t.chart.data)))),e.sort&&(i=i.sort(((i,n)=>e.sort(i,n,t.chart.data)))),t.options.reverse&&i.reverse(),t.legendItems=i}fit(){const t=this,{options:e,ctx:i}=t;if(!e.display)return void(t.width=t.height=0);const n=e.labels,o=Nt(n.font,t.chart.options.font),s=o.size,a=t._computeTitleHeight(),{boxWidth:r,itemHeight:l}=ao(n,s);let c,h;i.font=o.string,t.isHorizontal()?(c=t.maxWidth,h=t._fitRows(a,s,r,l)+10):(h=t.maxHeight,c=t._fitCols(a,s,r,l)+10),t.width=Math.min(c,e.maxWidth||t.maxWidth),t.height=Math.min(h,e.maxHeight||t.maxHeight)}_fitRows(t,e,i,n){const o=this,{ctx:s,maxWidth:a}=o,r=o.options.labels.padding,l=o.legendHitBoxes=[],c=o.lineWidths=[0];let h=t;return s.textAlign="left",s.textBaseline="middle",o.legendItems.forEach(((t,o)=>{const d=i+e/2+s.measureText(t.text).width;(0===o||c[c.length-1]+d+2*r>a)&&(h+=n+r,c[c.length-(o>0?0:1)]=0),l[o]={left:0,top:0,width:d,height:n},c[c.length-1]+=d+r})),h}_fitCols(t,e,i,n){const o=this,{ctx:s,maxHeight:a}=o,r=o.options.labels.padding,l=o.legendHitBoxes=[],c=o.columnSizes=[];let h=r,d=0,u=0;const g=a-t;return o.legendItems.forEach(((t,o)=>{const a=i+e/2+s.measureText(t.text).width;o>0&&u+e+2*r>g&&(h+=d+r,c.push({width:d,height:u}),d=u=0),d=Math.max(d,a),u+=e+r,l[o]={left:0,top:0,width:a,height:n}})),h+=d,c.push({width:d,height:u}),h}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){const t=this;if(t.options.display){const e=t.ctx;ot(e,t),t._draw(),st(e)}}_draw(){const t=this,{options:e,columnSizes:i,lineWidths:o,ctx:s,legendHitBoxes:a}=t,{align:r,labels:l}=e,c=P.color,h=Ei(e.rtl,t.left,t.width),d=Nt(l.font,t.chart.options.font),{color:g,padding:f}=l,p=d.size;let m;t.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.strokeStyle=g,s.fillStyle=g,s.font=d.string;const{boxWidth:x,boxHeight:b,itemHeight:_}=ao(l,p),y=t.isHorizontal(),v=this._computeTitleHeight();m=y?{x:n(r,t.left+f,t.right-o[0]),y:t.top+f+v,line:0}:{x:t.left+f,y:n(r,t.top+v+f,t.bottom-i[0].height),line:0},zi(t.ctx,e.textDirection);const M=_+f;t.legendItems.forEach(((e,g)=>{const w=s.measureText(e.text).width,k=x+p/2+w;let P=m.x,S=m.y;h.setWidth(t.width),y?g>0&&P+k+f>t.right&&(S=m.y+=M,m.line++,P=m.x=n(r,t.left+f,t.right-o[m.line])):g>0&&S+M>t.bottom&&(P=m.x=P+i[m.line].width+f,m.line++,S=m.y=n(r,t.top+v+f,t.bottom-i[m.line].height));const D=h.x(P);!function(t,e,i){if(isNaN(x)||x<=0||isNaN(b)||b<0)return;s.save();const n=u(i.lineWidth,1);if(s.fillStyle=u(i.fillStyle,c),s.lineCap=u(i.lineCap,"butt"),s.lineDashOffset=u(i.lineDashOffset,0),s.lineJoin=u(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=u(i.strokeStyle,c),s.setLineDash(u(i.lineDash,[])),l.usePointStyle){const o={radius:x*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=h.xPlus(t,x/2);it(s,o,a,e+p/2)}else{const i=e+Math.max((p-b)/2,0);s.fillRect(h.leftForLtr(t,x),i,x,b),0!==n&&s.strokeRect(h.leftForLtr(t,x),i,x,b)}s.restore()}(D,S,e),a[g].left=h.leftForLtr(D,a[g].width),a[g].top=S,function(t,e,i){const n=p/2,o=h.xPlus(t,x+n);lt(s,i.text,o,e+_/2,d,{strikethrough:i.hidden})}(D,S,e),y?m.x+=k+f:m.y+=M})),Fi(t.ctx,e.textDirection)}drawTitle(){const t=this,e=t.options,o=e.title,s=Nt(o.font,t.chart.options.font),a=Wt(o.padding);if(!o.display)return;const r=Ei(e.rtl,t.left,t.width),l=t.ctx,c=o.position,h=s.size/2,d=a.top+h;let u,g=t.left,f=t.width;if(this.isHorizontal())f=Math.max(...t.lineWidths),u=t.top+d,g=n(e.align,g,t.right-f);else{const i=t.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);u=d+n(e.align,t.top,t.bottom-i-e.labels.padding-t._computeTitleHeight())}const p=n(c,g,g+f);l.textAlign=r.textAlign(i(c)),l.textBaseline="middle",l.strokeStyle=o.color,l.fillStyle=o.color,l.font=s.string,lt(l,o.text,p,u,s)}_computeTitleHeight(){const t=this.options.title,e=Nt(t.font,this.chart.options.font),i=Wt(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){const i=this;let n,o,s;if(t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom)for(s=i.legendHitBoxes,n=0;n=o.left&&t<=o.left+o.width&&e>=o.top&&e<=o.top+o.height)return i.legendItems[n];return null}handleEvent(t){const e=this,i=e.options;if(!function(t,e){if("mousemove"===t&&(e.onHover||e.onLeave))return!0;if(e.onClick&&("click"===t||"mouseup"===t))return!0;return!1}(t.type,i))return;const n=e._getLegendItemAt(t.x,t.y);if("mousemove"===t.type){const o=e._hoveredItem;o&&o!==n&&g(i.onLeave,[t,o,e],e),e._hoveredItem=n,n&&g(i.onHover,[t,n,e],e)}else n&&g(i.onClick,[t,n,e],e)}}var lo={id:"legend",_element:ro,start(t,e,i){const n=t.legend=new ro({ctx:t.ctx,options:i,chart:t});Qt.configure(t,n,i),Qt.addBox(t,n)},stop(t){Qt.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const n=t.legend;Qt.configure(t,n,i),n.options=i},afterUpdate(t){t.legend.buildLabels()},afterEvent(t,e){t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const n=e.datasetIndex,o=i.chart;o.isDatasetVisible(n)?(o.hide(n),e.hidden=!0):(o.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:i}=t.legend.options,n=i.usePointStyle,o=i.pointStyle;return t._getSortedDatasetMetas().map((t=>{const i=t.controller.getStyle(n?0:void 0),s=c(i.borderWidth)?(u(i.borderWidth.top,0)+u(i.borderWidth.left,0)+u(i.borderWidth.bottom,0)+u(i.borderWidth.right,0))/4:i.borderWidth;return{text:e[t.index].label,fillStyle:i.backgroundColor,hidden:!t.visible,lineCap:i.borderCapStyle,lineDash:i.borderDash,lineDashOffset:i.borderDashOffset,lineJoin:i.borderJoinStyle,lineWidth:s,strokeStyle:i.borderColor,pointStyle:o||i.pointStyle,rotation:i.rotation,datasetIndex:t.index}}),this)}},title:{display:!1,position:"center",text:""}},defaultRoutes:{"labels.color":"color","title.color":"color"}};class co extends gi{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this,n=i.options;if(i.left=0,i.top=0,!n.display)return void(i.width=i.height=i.right=i.bottom=0);i.width=i.right=t,i.height=i.bottom=e;const o=l(n.text)?n.text.length:1;i._padding=Wt(n.padding);const s=o*Nt(n.font,i.chart.options.font).lineHeight+i._padding.height;i.isHorizontal()?i.height=s:i.width=s}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:o,right:s,options:a}=this,r=a.align;let l,c,h,d=0;return this.isHorizontal()?(c=n(r,i,s),h=e+t,l=s-i):("left"===a.position?(c=i+t,h=n(r,o,e),d=-.5*S):(c=s-t,h=n(r,e,o),d=.5*S),l=o-e),{titleX:c,titleY:h,maxWidth:l,rotation:d}}draw(){const t=this,e=t.ctx,n=t.options;if(!n.display)return;const o=Nt(n.font,t.chart.options.font),s=o.lineHeight/2+t._padding.top,{titleX:a,titleY:r,maxWidth:l,rotation:c}=t._drawArgs(s);lt(e,n.text,0,0,o,{color:n.color,maxWidth:l,rotation:c,textAlign:i(n.align),textBaseline:"middle",translation:[a,r]})}}function ho(t,e){const i=new co({ctx:t.ctx,options:e,chart:t});Qt.configure(t,i,e),Qt.addBox(t,i),t.titleBlock=i}var uo={id:"title",_element:co,start(t,e,i){ho(t,i)},stop(t){const e=t.titleBlock;Qt.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){!1===i?function(t){const e=t.titleBlock;e&&(Qt.removeBox(t,e),delete t.titleBlock)}(t):function(t,e){const i=t.titleBlock;i?(Qt.configure(t,i,e),i.options=e):ho(t,e)}(t,i)},defaults:{align:"center",display:!1,font:{style:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"}};const go={average(t){if(!t.length)return!1;let e,i,n=0,o=0,s=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function mo(t,e){const{element:i,datasetIndex:n,index:o}=e,s=t.getDatasetMeta(n).controller,{label:a,value:r}=s.getLabelAndValue(o);return{chart:t,label:a,dataPoint:s.getParsed(o),formattedValue:r,dataset:s.getDataset(),dataIndex:o,datasetIndex:n,element:i}}function xo(t){const e=t._chart.ctx,{body:i,footer:n,options:o,title:s}=t,{bodyFont:a,footerFont:r,titleFont:l,boxWidth:c,boxHeight:h}=o,d=s.length,u=n.length,g=i.length;let p=2*o.yPadding,m=0,x=i.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(x+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*l.size+(d-1)*o.titleSpacing+o.titleMarginBottom),x){p+=g*(o.displayColors?Math.max(h,a.size):a.size)+(x-g)*a.size+(x-1)*o.bodySpacing}u&&(p+=o.footerMarginTop+u*r.size+(u-1)*o.footerSpacing);let b=0;const _=function(t){m=Math.max(m,e.measureText(t).width+b)};return e.save(),e.font=Z(l),f(t.title,_),e.font=Z(a),f(t.beforeBody.concat(t.afterBody),_),b=o.displayColors?c+2:0,f(i,(t=>{f(t.before,_),f(t.lines,_),f(t.after,_)})),b=0,e.font=Z(r),f(t.footer,_),e.restore(),m+=2*o.xPadding,{width:m,height:p}}function bo(t,e,i){const{x:n,y:o,width:s,height:a}=i,r=t.chartArea;let l,c,h="center",d="center";ot.height-a/2&&(d="bottom");const u=(r.left+r.right)/2,g=(r.top+r.bottom)/2;"center"===d?(l=t=>t<=u,c=t=>t>u):(l=t=>t<=s/2,c=e=>e>=t.width-s/2);const f=t=>t<=g?"top":"bottom";return l(n)?(h="left",n+s+e.caretSize+e.caretPadding>t.width&&(h="center",d=f(o))):c(n)&&(h="right",(t=>t-s-e.caretSize-e.caretPadding<0)(n)&&(h="center",d=f(o))),{xAlign:e.xAlign?e.xAlign:h,yAlign:e.yAlign?e.yAlign:d}}function _o(t,e,i,n){const{caretSize:o,caretPadding:s,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,c=o+s,h=a+s;let d=function(t,e,i){let{x:n,width:o}=t;return"right"===e?n-=o:"center"===e&&(n-=o/2,n+o>i&&(n=i-o),n<0&&(n=0)),n}(e,r,n.width);return"center"===l?"left"===r?d+=c:"right"===r&&(d-=c):"left"===r?d-=h:"right"===r&&(d+=h),{x:d,y:function(t,e,i){let{y:n,height:o}=t;return"top"===e?n+=i:n-="bottom"===e?o+i:o/2,n}(e,l,c)}}function yo(t,e){const i=t.options;return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.xPadding:t.x+i.xPadding}function vo(t){return fo([],po(t))}class Mo extends gi{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this.$animations=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){const e=t.bodyFont.size;t.boxHeight=u(t.boxHeight,e),t.boxWidth=u(t.boxWidth,e),this.options=t,this._cachedAnimations=void 0}_resolveAnimations(){const t=this,e=t._cachedAnimations;if(e)return e;const i=t._chart,n=t.options,o=n.enabled&&i.options.animation&&n.animation,s=new ei(t._chart,o);return t._cachedAnimations=Object.freeze(s),s}getTitle(t){const e=this,i=e.options.callbacks,n=i.beforeTitle.apply(e,[t]),o=i.title.apply(e,[t]),s=i.afterTitle.apply(e,[t]);let a=[];return a=fo(a,po(n)),a=fo(a,po(o)),a=fo(a,po(s)),a}getBeforeBody(t){return vo(this.options.callbacks.beforeBody.apply(this,[t]))}getBody(t){const e=this,i=e.options.callbacks,n=[];return f(t,(t=>{const o={before:[],lines:[],after:[]};fo(o.before,po(i.beforeLabel.call(e,t))),fo(o.lines,i.label.call(e,t)),fo(o.after,po(i.afterLabel.call(e,t))),n.push(o)})),n}getAfterBody(t){return vo(this.options.callbacks.afterBody.apply(this,[t]))}getFooter(t){const e=this,i=e.options.callbacks,n=i.beforeFooter.apply(e,[t]),o=i.footer.apply(e,[t]),s=i.afterFooter.apply(e,[t]);let a=[];return a=fo(a,po(n)),a=fo(a,po(o)),a=fo(a,po(s)),a}_createItems(){const t=this,e=t._active,i=t.options,n=t._chart.data,o=[],s=[],a=[];let r,l,c=[];for(r=0,l=e.length;ri.filter(t,e,o,n)))),i.itemSort&&(c=c.sort(((t,e)=>i.itemSort(t,e,n)))),f(c,(e=>{o.push(i.callbacks.labelColor.call(t,e)),s.push(i.callbacks.labelPointStyle.call(t,e)),a.push(i.callbacks.labelTextColor.call(t,e))})),t.labelColors=o,t.labelPointStyles=s,t.labelTextColors=a,t.dataPoints=c,c}update(t){const e=this,i=e.options,n=e._active;let o;if(n.length){const t=go[i.position].call(e,n,e._eventPosition),s=e._createItems();e.title=e.getTitle(s),e.beforeBody=e.getBeforeBody(s),e.body=e.getBody(s),e.afterBody=e.getAfterBody(s),e.footer=e.getFooter(s);const a=e._size=xo(e),r=Object.assign({},t,a),l=bo(e._chart,i,r),c=_o(i,r,l,e._chart);e.xAlign=l.xAlign,e.yAlign=l.yAlign,o={opacity:1,x:c.x,y:c.y,width:a.width,height:a.height,caretX:t.x,caretY:t.y}}else 0!==e.opacity&&(o={opacity:0});o&&e._resolveAnimations().update(e,o),t&&i.custom&&i.custom.call(e,{chart:e._chart,tooltip:e})}drawCaret(t,e,i){const n=this.getCaretPosition(t,i);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e){const{xAlign:i,yAlign:n,options:o}=this,{cornerRadius:s,caretSize:a}=o,{x:r,y:l}=t,{width:c,height:h}=e;let d,u,g,f,p,m;return"center"===n?(p=l+h/2,"left"===i?(d=r,u=d-a,f=p+a,m=p-a):(d=r+c,u=d+a,f=p-a,m=p+a),g=d):(u="left"===i?r+s+a:"right"===i?r+c-s-a:this.caretX,"top"===n?(f=l,p=f-a,d=u-a,g=u+a):(f=l+h,p=f+a,d=u+a,g=u-a),m=f),{x1:d,x2:u,x3:g,y1:f,y2:p,y3:m}}drawTitle(t,e){const i=this,n=i.options,o=i.title,s=o.length;let a,r,l;if(s){const c=Ei(n.rtl,i.x,i.width);for(t.x=yo(i,n.titleAlign),e.textAlign=c.textAlign(n.titleAlign),e.textBaseline="middle",a=n.titleFont,r=n.titleSpacing,e.fillStyle=n.titleColor,e.font=Z(a),l=0;l0&&e.stroke()}_updateAnimationTarget(){const t=this,e=t._chart,i=t.options,n=t.$animations,o=n&&n.x,s=n&&n.y;if(o||s){const n=go[i.position].call(t,t._active,t._eventPosition);if(!n)return;const a=t._size=xo(t),r=Object.assign({},n,t._size),l=bo(e,i,r),c=_o(i,r,l,e);o._to===c.x&&s._to===c.y||(t.xAlign=l.xAlign,t.yAlign=l.yAlign,t.width=a.width,t.height=a.height,t.caretX=n.x,t.caretY=n.y,t._resolveAnimations().update(t,c))}}draw(t){const e=this,i=e.options;let n=e.opacity;if(!n)return;e._updateAnimationTarget();const o={width:e.width,height:e.height},s={x:e.x,y:e.y};n=Math.abs(n)<.001?0:n;const a=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;i.enabled&&a&&(t.save(),t.globalAlpha=n,e.drawBackground(s,t,o),zi(t,i.textDirection),s.y+=i.yPadding,e.drawTitle(s,t),e.drawBody(s,t),e.drawFooter(s,t),Fi(t,i.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this,n=i._active,o=t.map((({datasetIndex:t,index:e})=>{const n=i._chart.getDatasetMeta(t);if(!n)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:n.data[e],index:e}})),s=!p(n,o),a=i._positionChanged(o,e);(s||a)&&(i._active=o,i._eventPosition=e,i.update(!0))}handleEvent(t,e){const i=this,n=i.options,o=i._active||[];let s=!1,a=[];"mouseout"!==t.type&&(a=i._chart.getElementsAtEventForMode(t,n.mode,n,e),n.reverse&&a.reverse());const r=i._positionChanged(a,t);return s=e||!p(a,o)||r,s&&(i._active=a,(n.enabled||n.custom)&&(i._eventPosition={x:t.x,y:t.y},i.update(!0))),s}_positionChanged(t,e){const i=this,n=go[i.options.position].call(i,t,e);return i.caretX!==n.x||i.caretY!==n.y}}Mo.positioners=go;var wo={id:"tooltip",_element:Mo,positioners:go,afterInit(t,e,i){i&&(t.tooltip=new Mo({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,custom:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{style:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{style:"bold"},footerAlign:"left",yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart",numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:s,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,n=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(n>0&&e.dataIndex=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){const e=this;return Math.round(e._startValue+e.getDecimalForPixel(t)*e._valueRange)}getBasePixel(){return this.bottom}}function So(t){const e=Math.floor(z(t)),i=t/Math.pow(10,e);let n;return n=i<=1?1:i<=2?2:i<=5?5:10,n*Math.pow(10,e)}Po.id="category",Po.defaults={ticks:{callback:Po.prototype.getLabelForValue}};class Do extends wi{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return r(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?NaN:+t}handleTickRangeOptions(){const t=this,{beginAtZero:e,stacked:i}=t.options,{minDefined:n,maxDefined:o}=t.getUserBounds();let{min:s,max:a}=t;const r=t=>s=n?s:t,l=t=>a=o?a:t;if(e||i){const t=W(s),e=W(a);t<0&&e<0?l(0):t>0&&e>0&&r(0)}s===a&&(l(a+1),e||r(s-1)),t.min=s,t.max=a}getTickLimit(){const t=this,e=t.options.ticks;let i,{maxTicksLimit:n,stepSize:o}=e;return o?i=Math.ceil(t.max/o)-Math.floor(t.min/o)+1:(i=t.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this,e=t.options,i=e.ticks;let n=t.getTickLimit();n=Math.max(2,n);const o=function(t,e){const i=[],{stepSize:n,min:o,max:s,precision:a}=t,l=n||1,c=t.maxTicks-1,{min:h,max:d}=e;let u,g,f,p,m=So((d-h)/c/l)*l;if(m<1e-14&&r(o)&&r(s))return[{value:h},{value:d}];p=Math.ceil(d/m)-Math.floor(h/m),p>c&&(m=So(p*m/c/l)*l),n||r(a)?u=Math.pow(10,j(m)):(u=Math.pow(10,a),m=Math.ceil(m*u)/u),g=Math.floor(h/m)*m,f=Math.ceil(d/m)*m,!n||r(o)||r(s)||B((s-o)/n,m/1e3)&&(g=o,f=s),p=(f-g)/m,p=I(p,Math.round(p),m/1e3)?Math.round(p):Math.ceil(p),g=Math.round(g*u)/u,f=Math.round(f*u)/u,i.push({value:r(o)?g:o});for(let t=1;t0?i:NaN;this._zero=!0}determineDataLimits(){const t=this,{min:e,max:i}=t.getMinMax(!0);t.min=h(e)?Math.max(0,e):null,t.max=h(i)?Math.max(0,i):null,t.options.beginAtZero&&(t._zero=!0),t.handleTickRangeOptions()}handleTickRangeOptions(){const t=this,{minDefined:e,maxDefined:i}=t.getUserBounds();let n=t.min,o=t.max;const s=t=>n=e?n:t,a=t=>o=i?o:t,r=(t,e)=>Math.pow(10,Math.floor(z(t))+e);n===o&&(n<=0?(s(1),a(10)):(s(r(n,-1)),a(r(o,1)))),n<=0&&s(r(o,-1)),o<=0&&a(r(n,1)),t._zero&&t.min!==t._suggestedMin&&n===r(t.min,0)&&s(r(n,-1)),t.min=n,t.max=o}buildTicks(){const t=this,e=t.options,i=function(t,e){const i=Math.floor(z(e.max)),n=Math.ceil(e.max/Math.pow(10,i)),o=[];let s=d(t.min,Math.pow(10,Math.floor(z(e.min)))),a=Math.floor(z(s)),r=Math.floor(s/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{o.push({value:s,major:Co(s)}),++r,10===r&&(r=1,++a,l=a>=0?1:l),s=Math.round(r*Math.pow(10,a)*l)/l}while(ao?{start:e-i,end:e}:{start:e,end:e+i}}function Ro(t){return 0===t||180===t?"center":t<180?"left":"right"}function Eo(t,e,i){90===t||270===t?i.y-=e.h/2:(t>270||t<90)&&(i.y-=e.h)}function zo(t){return F(t)?t:0}Ao.id="logarithmic",Ao.defaults={ticks:{callback:xi.formatters.logarithmic,major:{enabled:!0}}};class Fo extends Do{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this.pointLabels=[]}init(t){super.init(t),this.axis="r"}setDimensions(){const t=this;t.width=t.maxWidth,t.height=t.maxHeight,t.paddingTop=To(t.options)/2,t.xCenter=Math.floor(t.width/2),t.yCenter=Math.floor((t.height-t.paddingTop)/2),t.drawingArea=Math.min(t.height-t.paddingTop,t.width)/2}determineDataLimits(){const t=this,{min:e,max:i}=t.getMinMax(!1);t.min=h(e)&&!isNaN(e)?e:0,t.max=h(i)&&!isNaN(i)?i:0,t.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/To(this.options))}generateTickLabels(t){const e=this;Do.prototype.generateTickLabels.call(e,t),e.pointLabels=e.chart.data.labels.map(((t,i)=>{const n=g(e.options.pointLabels.callback,[t,i],e);return n||0===n?n:""}))}fit(){const t=this,e=t.options;e.display&&e.pointLabels.display?function(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={};let n,o,s;t._pointLabelSizes=[];const a=t.chart.data.labels.length;for(n=0;ne.r&&(e.r=f.end,i.r=u),p.starte.b&&(e.b=p.end,i.b=u)}var r,c,h;t._setReductions(t.drawingArea,e,i)}(t):t.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){const n=this;let o=e.l/Math.sin(i.l),s=Math.max(e.r-n.width,0)/Math.sin(i.r),a=-e.t/Math.cos(i.t),r=-Math.max(e.b-(n.height-n.paddingTop),0)/Math.cos(i.b);o=zo(o),s=zo(s),a=zo(a),r=zo(r),n.drawingArea=Math.min(Math.floor(t-(o+s)/2),Math.floor(t-(a+r)/2)),n.setCenterPoint(o,s,a,r)}setCenterPoint(t,e,i,n){const o=this,s=o.width-e-o.drawingArea,a=t+o.drawingArea,r=i+o.drawingArea,l=o.height-o.paddingTop-n-o.drawingArea;o.xCenter=Math.floor((a+s)/2+o.left),o.yCenter=Math.floor((r+l)/2+o.top+o.paddingTop)}getIndexAngle(t){const e=this.chart;return X(t*(D/e.data.labels.length)+N((e.options||{}).startAngle||0))}getDistanceFromCenterForValue(t){const e=this;if(r(t))return NaN;const i=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*i:(t-e.min)*i}getValueForDistanceFromCenter(t){if(r(t))return NaN;const e=this,i=t/(e.drawingArea/(e.max-e.min));return e.options.reverse?e.max-i:e.min+i}getPointPosition(t,e){const i=this,n=i.getIndexAngle(t)-T;return{x:Math.cos(n)*e+i.xCenter,y:Math.sin(n)*e+i.yCenter,angle:n}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}drawGrid(){const t=this,e=t.ctx,i=t.options,n=i.gridLines,o=i.angleLines;let s,a,r;if(i.pointLabels.display&&function(t){const e=t.ctx,i=t.options,n=i.pointLabels,o=To(i),s=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max);e.save(),e.textBaseline="middle";for(let i=t.chart.data.labels.length-1;i>=0;i--){const a=0===i?o/2:0,r=t.getPointPosition(i,s+a+5),l=t.getContext(i),c=Nt(Ht([n.font],l,i),t.chart.options.font),h=H(t.getIndexAngle(i));Eo(h,t._pointLabelSizes[i],r),lt(e,t.pointLabels[i],r.x,r.y+c.lineHeight/2,c,{color:Ht([n.color],l,i),textAlign:Ro(h)})}e.restore()}(t),n.display&&t.ticks.forEach(((e,i)=>{0!==i&&(a=t.getDistanceFromCenterForValue(t.ticks[i].value),function(t,e,i,n){const o=t.ctx,s=e.circular,a=t.chart.data.labels.length,r=t.getContext(n),l=Ht([e.color],r,n-1),c=Ht([e.lineWidth],r,n-1);let h;if((s||a)&&l&&c&&!(i<0)){if(o.save(),o.strokeStyle=l,o.lineWidth=c,o.setLineDash&&(o.setLineDash(Ht([e.borderDash,[]],r)),o.lineDashOffset=Ht([e.borderDashOffset],r,n-1)),o.beginPath(),s)o.arc(t.xCenter,t.yCenter,i,0,D);else{h=t.getPointPosition(0,i),o.moveTo(h.x,h.y);for(let e=1;e=0;s--){const l=t.getContext(s),c=Ht([o.lineWidth,n.lineWidth],l,s),h=Ht([o.color,n.color],l,s);c&&h&&(e.lineWidth=c,e.strokeStyle=h,e.setLineDash&&(e.setLineDash(Ht([o.borderDash,n.borderDash,[]],l)),e.lineDashOffset=Ht([o.borderDashOffset,n.borderDashOffset,0],l,s)),a=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max),r=t.getPointPosition(s,a),e.beginPath(),e.moveTo(t.xCenter,t.yCenter),e.lineTo(r.x,r.y),e.stroke())}e.restore()}}drawLabels(){const t=this,e=t.ctx,i=t.options,n=i.ticks;if(!n.display)return;const o=t.getIndexAngle(0);let s,a;e.save(),e.translate(t.xCenter,t.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",t.ticks.forEach(((o,r)=>{if(0===r&&!i.reverse)return;const l=t.getContext(r),c=t._resolveTickFontOptions(r);s=t.getDistanceFromCenterForValue(t.ticks[r].value);Ht([n.showLabelBackdrop],l,r)&&(a=e.measureText(o.label).width,e.fillStyle=Ht([n.backdropColor],l,r),e.fillRect(-a/2-n.backdropPaddingX,-s-c.size/2-n.backdropPaddingY,a+2*n.backdropPaddingX,c.size+2*n.backdropPaddingY)),lt(e,o.label,0,-s,c,{color:n.color})})),e.restore()}drawTitle(){}}Fo.id="radialLinear",Fo.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},gridLines:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:xi.formatters.numeric},pointLabels:{display:!0,font:{size:10},callback:t=>t}},Fo.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};const Io=Number.MAX_SAFE_INTEGER||9007199254740991,Bo={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Vo=Object.keys(Bo);function Wo(t,e){return t-e}function No(t,e){if(r(e))return null;const i=t._adapter,n=t.options.time,{parser:o,round:s,isoWeekday:a}=n;let l=e;return"function"==typeof o&&(l=o(l)),h(l)||(l="string"==typeof o?i.parse(l,o):i.parse(l)),null===l?l:(s&&(l="week"!==s||!F(a)&&!0!==a?t._adapter.startOf(l,s):t._adapter.startOf(l,"isoWeek",a)),+l)}function Ho(t,e,i,n){const o=Vo.length;for(let s=Vo.indexOf(t);s=e?i[n]:i[o]]=!0}}else t[e]=!0}function Yo(t,e,i){const n=[],o={},s=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,n,o,i):n}class Uo extends wi{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1}init(t,e){const i=t.time||(t.time={}),n=this._adapter=new rn._date(t.adapters.date);y(i.displayFormats,n.formats()),super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?NaN:No(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this,e=t.options,i=t._adapter,n=e.time.unit||"day";let{min:o,max:s,minDefined:a,maxDefined:r}=t.getUserBounds();function l(t){a||isNaN(t.min)||(o=Math.min(o,t.min)),r||isNaN(t.max)||(s=Math.max(s,t.max))}a&&r||(l(t._getLabelBounds()),"ticks"===e.bounds&&"labels"===e.ticks.source||l(t.getMinMax(!1))),o=h(o)&&!isNaN(o)?o:+i.startOf(Date.now(),n),s=h(s)&&!isNaN(s)?s:+i.endOf(Date.now(),n)+1,t.min=Math.min(o,s),t.max=Math.max(o+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this,e=t.options,i=e.time,n=e.ticks,o="labels"===n.source?t.getLabelTimestamps():t._generate();"ticks"===e.bounds&&o.length&&(t.min=t._userMin||o[0],t.max=t._userMax||o[o.length-1]);const s=t.min,a=ut(o,s,t.max);return t._unit=i.unit||(n.autoSkip?Ho(i.minUnit,t.min,t.max,t._getLabelCapacity(s)):function(t,e,i,n,o){for(let s=Vo.length-1;s>=Vo.indexOf(i);s--){const i=Vo[s];if(Bo[i].common&&t._adapter.diff(o,n,i)>=e-1)return i}return Vo[i?Vo.indexOf(i):0]}(t,a.length,i.minUnit,t.min,t.max)),t._majorUnit=n.major.enabled&&"year"!==t._unit?function(t){for(let e=Vo.indexOf(t)+1,i=Vo.length;e1e5*r)throw new Error(i+" and "+n+" are too far apart with stepSize of "+r+" "+a);const f="data"===o.ticks.source&&t.getDataTimestamps();for(d=g;dt-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,n){const o=this,s=o.options,a=s.time.displayFormats,r=o._unit,l=o._majorUnit,c=r&&a[r],h=l&&a[l],d=i[e],u=l&&h&&d&&d.major,g=o._adapter.format(t,n||(u?h:c)),f=s.ticks.callback;return f?f(g,e,i):g}generateTickLabels(t){let e,i,n;for(e=0,i=t.length;e0?r:1}getDataTimestamps(){const t=this;let e,i,n=t._cache.data||[];if(n.length)return n;const o=t.getMatchingVisibleMetas();if(t._normalized&&o.length)return t._cache.data=o[0].controller.getAllParsedValues(t);for(e=0,i=o.length;ee&&a0&&!r(e)?e/i._maxIndex:i.getDecimalForValue(t);return i.getPixelForDecimal((n.start+o)*n.factor)}getDecimalForValue(t){return $o(this._table,t)/this._maxIndex}getValueForPixel(t){const e=this,i=e._offsets,n=e.getDecimalForPixel(t)/i.factor-i.end;return $o(e._table,n*this._maxIndex,!0)}}Xo.id="timeseries",Xo.defaults=Uo.defaults;var Ko=Object.freeze({__proto__:null,CategoryScale:Po,LinearScale:Oo,LogarithmicScale:Ao,RadialLinearScale:Fo,TimeScale:Uo,TimeSeriesScale:Xo});return nn.register(yn,Ko,Hn,ko),nn.helpers={...Hi},nn._adapters=rn,nn.Animation=Je,nn.Animations=ei,nn.animator=o,nn.controllers=Pi.controllers.items,nn.DatasetController=ui,nn.Element=gi,nn.elements=Hn,nn.Interaction=Et,nn.layouts=Qt,nn.platforms=fe,nn.Scale=wi,nn.Ticks=xi,Object.assign(nn,yn,Ko,Hn,ko,fe),nn.Chart=nn,"undefined"!=typeof window&&(window.Chart=nn),nn})); diff --git a/lib/math.min.js b/lib/math.min.js new file mode 100644 index 0000000..b8248e6 --- /dev/null +++ b/lib/math.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.math=t():e.math=t()}(this,function(){return n={},i.m=r=[,function(e,t,r){var a;!function(){"use strict";function n(e){return.5*(Math.exp(e)+Math.exp(-e))}function i(e){return.5*(Math.exp(e)-Math.exp(-e))}var u=function(){throw SyntaxError("Invalid Param")};function o(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function c(e,t){if(!(this instanceof c))return new c(e,t);t=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return c.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return c.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):u();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&u();for(var o=0;o>=1)1&t&&(n=n*e%r);return n}(10,i,e),n=0;n<300;n++){if(t===r)return n;t=10*t%e,r=10*r%e}return 0}(r),a=-1===this.s?"-":"";if(a+=t/r|0,t%=r,(t*=10)&&(a+="."),i){for(var o=n;o--;)a+=t/r|0,t%=r,t*=10;for(a+="(",o=i;o--;)a+=t/r|0,t%=r,t*=10;a+=")"}else for(o=e;t&&o--;)a+=t/r|0,t%=r,t*=10;return a}},void 0===(a=function(){return u}.apply(i,[]))||(n.exports=a)}()},function(e,t){e.exports=function t(e,r){"use strict";function n(e){return t.insensitive&&(""+e).toLowerCase()||""+e}var i,a,o=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,u=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,c=/^0x[0-9a-f]+$/i,f=/^0/,e=n(e).replace(s,"")||"",s=n(r).replace(s,"")||"",l=e.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=s.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),e=parseInt(e.match(c),16)||1!==l.length&&e.match(u)&&Date.parse(e),s=parseInt(s.match(c),16)||e&&s.match(u)&&Date.parse(s)||null;if(s){if(er-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}v.absoluteValue=v.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),k(e)},v.ceil=function(){return k(new this.constructor(this),this.e+1,2)},v.comparedTo=v.cmp=function(e){var t,r,n=this,i=n.d,a=(e=new n.constructor(e)).d,o=n.s,s=e.s;if(!i||!a)return o&&s?o!==s?o:i===a?0:!i^o<0?1:-1:NaN;if(!i[0]||!a[0])return i[0]?o:a[0]?-s:0;if(o!==s)return o;if(n.e!==e.e)return n.e>e.e^o<0?1:-1;for(t=0,r=(n=i.length)<(e=a.length)?n:e;ta[t]^o<0?1:-1;return n===e?0:ethis.d.length-2},v.isNaN=function(){return!this.s},v.isNegative=v.isNeg=function(){return this.s<0},v.isPositive=v.isPos=function(){return 0(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=l.length))&&(o=n),n=0;n(i=(f=Math.ceil(a/7))>i?f+1:i+1)&&(n=i,r.length=1),r.reverse();n--;)r.push(0);r.reverse()}for((i=s.length)-(n=u.length)<0&&(n=i,r=u,u=s,s=r),t=0;n;)t=(s[--n]=s[n]+u[n]+t)/z|0,s[n]%=z;for(t&&(s.unshift(t),++c),i=s.length;0==s[--i];)s.pop();return e.d=s,e.e=A(s,c),x?k(e,a,o):e},v.precision=v.sd=function(e){var t;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(d+e);return this.d?(t=D(this.d),e&&this.e+1>t&&(t=this.e+1)):t=NaN,t},v.round=function(){var e=this.constructor;return k(new e(this),this.e+1,e.rounding)},v.sine=v.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return $(e,2,t,t);r=16<(r=1.4*Math.sqrt(n))?16:0|r,t=$(e,2,t=t.times(1/G(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,V(n,r)),n.precision=e,n.rounding=t,k(2=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=j(u,s,r,n),e.s<0?new u(1).div(i):k(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t=n.toExpPos):(w(e,1,1e9),void 0===t?t=n.rounding:w(t,0,8),E(r=k(new n(r),e,t),e<=r.e||r.e<=n.toExpNeg,e));return r.isNeg()&&!r.isZero()?"-"+e:e},v.toSignificantDigits=v.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(w(e,1,1e9),void 0===t?t=r.rounding:w(t,0,8)),k(new r(this),e,t)},v.toString=function(){var e=this,t=e.constructor,t=E(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},v.truncated=v.trunc=function(){return k(new this.constructor(this),this.e+1,1)},v.valueOf=v.toJSON=function(){var e=this,t=e.constructor,t=E(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+t:t};var S=function(e,t,r,n,i,a){var o,s,u,c,f,l,p,m,h,d,y,g,v,x,b,w,N,M,S,E=e.constructor,A=e.s==t.s?1:-1,O=e.d,C=t.d;if(!(O&&O[0]&&C&&C[0]))return new E(e.s&&t.s&&(O?!C||O[0]!=C[0]:C)?O&&0==O[0]||!C?0*A:A/0:NaN);for(s=a?(f=1,e.e-t.e):(a=z,f=7,T(e.e/f)-T(t.e/f)),M=C.length,w=O.length,h=(A=new E(A)).d=[],u=0;C[u]==(O[u]||0);u++);if(C[u]>(O[u]||0)&&s--,null==r?(v=r=E.precision,n=E.rounding):v=i?r+(e.e-t.e)+1:r,v<0)h.push(1),l=!0;else{if(v=v/f+2|0,u=0,1==M){for(C=C[c=0],v++;(u=a/2&&++N;c=0,(o=I(C,d,M,y))<0?(g=d[0],M!=y&&(g=g*a+(d[1]||0)),1<(c=g/N|0)?(a<=c&&(c=a-1),1==(o=I(p=q(C,c,a),d,m=p.length,y=d.length))&&(c--,B(p,Mt[i]?1:-1;break}return a}function B(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]=(s=f.length)){if(!n)break e;for(;s++<=l;)f.push(0);c=u=0,o=(a%=7)-7+(i=1)}else{for(c=s=f[l],i=1;10<=s;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:c/y(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[l+1]||(o<0?c:c%y(10,i-o-1)),u=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):5p.maxE?(e.d=null,e.e=NaN):e.ee.constructor.maxE?(e.d=null,e.e=NaN):e.ei-1;)f[r]=0,r||(++a,f.unshift(1));for(s=f.length;!f[s-1];--s);for(o=0,c="";os)for(a-=s;a--;)c+="0";else at&&(e.length=t,1)}function W(e){return new this(e).abs()}function J(e){return new this(e).acos()}function Y(e){return new this(e).acosh()}function X(e,t){return new this(e).plus(t)}function Q(e){return new this(e).asin()}function K(e){return new this(e).asinh()}function ee(e){return new this(e).atan()}function te(e){return new this(e).atanh()}function re(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?C(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=C(this,a,1).times(.5)).s=e.s:r=t.s<0?(this.precision=a,this.rounding=1,r=this.atan(S(e,t,a,1)),t=C(this,a,1),this.precision=n,this.rounding=i,e.s<0?r.minus(t):r.plus(t)):this.atan(S(e,t,a,1)):(r=C(this,a,1).times(0a.maxE?(i.e=NaN,i.d=null):e.et?(n=new TypeError("Too many arguments in function "+a+" (expected: "+t+", actual: "+r.length+")")).data={category:"tooManyArgs",fn:a,index:r.length,expectedLength:t}:(n=new TypeError('Arguments of type "'+r.join(", ")+'" do not match any of the defined signatures of function '+a+".")).data={category:"mismatch",actual:r.map(G)}),n}(t,arguments,i)}function o(e,t){return(arguments.length===B&&d(e)&&w(t)?C:arguments.length===k&&y(e)&&N(t)?_:arguments.length===D&&g(e)&&M(t)?T:arguments.length===R&&v(e)&&S(t)?z:arguments.length===j&&x(e)&&E(t)?q:arguments.length===P&&b(e)&&A(t)?I:a).apply(o,arguments)}var s,e=i[0]&&i[0].params.length<=2&&!Z(i[0].params),u=i[1]&&i[1].params.length<=2&&!Z(i[1].params),c=i[2]&&i[2].params.length<=2&&!Z(i[2].params),f=i[3]&&i[3].params.length<=2&&!Z(i[3].params),l=i[4]&&i[4].params.length<=2&&!Z(i[4].params),p=i[5]&&i[5].params.length<=2&&!Z(i[5].params),m=e&&u&&c&&f&&l&&p,h=i.map(function(e){return function(e){var r,t,n;if(Z(e)){var i=(r=e.slice(0,e.length-1).map(J)).length,a=J(se(e));return function(e){for(var t=0;t=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(t=J(e[0]),function(e){return t(e[0])&&1===e.length}):2===e.length?(t=J(e[0]),n=J(e[1]),function(e){return t(e[0])&&n(e[1])&&2===e.length}):(r=e.map(J),function(e){for(var t=0;t=e.length&&n.slice(0,e.length)===e&&(i+=a[o[t]],n=n.slice(e.length,n.length),r=!0)}),r||(i+=n.slice(0,1),n=n.slice(1,n.length))}();return i}},function(e,n,o){(function(e){var r;!function(e){function i(e){var n,t=this,r=(n=4022871197,function(e){e=String(e);for(var t=0;t>>0,n=(r*=n)>>>0,n+=4294967296*(r-=n)}return 2.3283064365386963e-10*(n>>>0)});t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=r(" "),t.s1=r(" "),t.s2=r(" "),t.s0-=r(e),t.s0<0&&(t.s0+=1),t.s1-=r(e),t.s1<0&&(t.s1+=1),t.s2-=r(e),t.s2<0&&(t.s2+=1),r=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function t(e,t){var r=new i(e),t=t&&t.state,n=r.next;return n.int32=function(){return 4294967296*r.next()|0},n.double=function(){return n()+11102230246251565e-32*(2097152*n()|0)},n.quick=n,t&&("object"==typeof t&&a(t,r),n.state=function(){return a(r,{})}),n}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(n,o,n,e))||(e.exports=r):this.alea=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&("object"==typeof e&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xor128=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,e===((t.v=0)|e)?t.x=e:r+=e;for(var n=0;n>>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 t(e,t){var r=new n(e),e=t&&t.state,t=function(){return(r.next()>>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&("object"==typeof e&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xorwow=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var i=this;i.next=function(){var e=i.x,t=i.i,r=e[t],n=(r^=r>>>7)^r<<24;return n^=(r=e[t+1&7])^r>>>10,n^=(r=e[t+3&7])^r>>>3,n^=(r=e[t+4&7])^r<<7,r=e[t+7&7],n^=(r^=r<<13)^r<<9,e[t]=n,i.i=t+1&7,n},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&(e.x&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xorshift7=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var a=this;a.next=function(){var e,t,r=a.w,n=a.X,i=a.i;return a.w=r=r+1640531527|0,t=n[i+34&127],e=n[i=i+1&127],t^=t<<13,e^=e<<17,t^=t>>>15,e^=e>>>12,t=n[i]=t^e,a.i=i,t+(r^r>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,0<=a&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(128<=i&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;0>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(a,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function t(e,t){null==e&&(e=+new Date);var r=new n(e),e=t&&t.state,t=function(){return(r.next()>>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&(e.X&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xor4096=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var i=this,t="";i.next=function(){var e=(e=i.b)<<25^e>>>7^(t=i.c),t=t-(r=i.d)|0,r=r<<24^r>>>8^(n=i.a),n=n-e|0;return i.b=e=e<<20^e>>>12^t,i.c=t=t-r|0,i.d=r<<16^t>>>16^n,i.a=n-e|0},i.a=0,i.b=0,i.c=-1640531527,i.d=1367130551,e===Math.floor(e)?(i.a=e/4294967296|0,i.b=0|e):t+=e;for(var r=0;r>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&("object"==typeof e&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.tychei=t}(e,o(2))}).call(this,o(5)(e))},function(t,r,n){var i;!function(a,o,s){var u,c=s.pow(256,6),f=s.pow(2,52),l=2*f;function e(e,t,r){var n=[],e=h(function e(t,r){var n,i=[],a=typeof t;if(r&&"object"==a)for(n in t)try{i.push(e(t[n],r-1))}catch(e){}return i.length?i:"string"==a?t:t+"\0"}((t=1==t?{entropy:!0}:t||{}).entropy?[e,d(o)]:null==e?function(){try{var e;return u&&(e=u.randomBytes)?e=e(256):(e=new Uint8Array(256),(a.crypto||a.msCrypto).getRandomValues(e)),d(e)}catch(e){var t=a.navigator,t=t&&t.plugins;return[+new Date,a,t,a.screen,d(o)]}}():e,3),n),i=new p(n),n=function(){for(var e=i.g(6),t=c,r=0;e>>=1;return(e+r)/t};return n.int32=function(){return 0|i.g(4)},n.quick=function(){return i.g(4)/4294967296},n.double=n,h(d(i.S),o),(t.pass||r||function(e,t,r,n){return n&&(n.S&&m(n,i),e.state=function(){return m(i,{})}),r?(s.random=e,t):e})(n,e,"global"in t?t.global:this==s,t.state)}function p(e){var t,r=e.length,o=this,n=0,i=o.i=o.j=0,a=o.S=[];for(r||(e=[r++]);n<256;)a[n]=n++;for(n=0;n<256;n++)a[n]=a[i=255&i+e[n%r]+(t=a[n])],a[i]=t;(o.g=function(e){for(var t,r=0,n=o.i,i=o.j,a=o.S;e--;)t=a[n=255&n+1],r=256*r+a[255&(a[n]=a[i=255&i+t])+(a[i]=t)];return o.i=n,o.j=i,r})(256)}function m(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function h(e,t){for(var r,n=e+"",i=0;iMath.pow(2,r-1)-1||e<-Math.pow(2,r-1))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!L(e))throw new Error("Value must be an integer");e<0&&(e+=Math.pow(2,r)),i="i".concat(r)}r="";return e<0&&(e=-e,r="-"),"".concat(r).concat(n).concat(e.toString(t)).concat(i)}function V(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,i="auto";if(t&&(t.notation&&(i=t.notation),M(t)?r=t:M(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(i){case"fixed":return X(e,r);case"exponential":return Q(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=K(Y(e),t),n=r.exponent,i=r.coefficients,a=n%3==0?n:n<0?n-3-n%3:n-n%3;if(M(t))for(;t>i.length||n-a+1>i.length;)i.push(0);else for(var o=Math.abs(n-a)-(i.length-1),s=0;s=i)return Q(e,t);i=r.coefficients,e=r.exponent;i.lengtht&&5<=n.splice(t,n.length-t)[0]){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function ee(e){for(var t=[],r=0;r/g,">")}function be(e,t){if(!S(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+J(e)+", index: 0)");if(!S(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+J(t)+", index: 1)");return e===t?0:t=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function Me(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Se(e,t){if(0===t.length){if(Array.isArray(e))throw new we(e.length,0)}else!function e(t,r,n){var i=t.length;if(i!==r[n])throw new we(i,r[n]);if(n")}(e,t,0)}function Ee(e,t){if(!M(e)||!L(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&t<=e)throw new Ne(e,t)}function Ae(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach(function(e){if(!M(e)||!L(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ge(t)+")")}),function e(t,r,n,i){var a,o=t.length,s=r[n],u=Math.min(o,s);if(t.length=s,n15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return n||rt(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||rt(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||rt(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||nt(e);var t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(t){r||tt(t);try{return new r(t)}catch(e){throw new Error('Cannot convert "'+t+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(t){i||nt(t);try{return new i(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(t){n||rt(t);try{return new n(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return r||tt(e),new r(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||nt(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return t||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new t(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],e});function tt(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function rt(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function nt(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var it=Ye("ResultSet",[],function(){function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return t.prototype.type="ResultSet",t.prototype.isResultSet=!0,t.prototype.valueOf=function(){return this.entries},t.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},t.fromJSON=function(e){return new t(e.entries)},t},{isClass:!0}),at=r(7),ot=r.n(at),st=Ye("BigNumber",["?on","config"],function(e){var t=e.on,e=e.config,r=ot.a.clone({precision:e.precision,modulo:9});return 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}),a=r(1),ut=r.n(a);function ct(e){return(ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var ft=Ye("Complex",[],function(){return ut.a.prototype.type="Complex",ut.a.prototype.isComplex=!0,ut.a.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},ut.a.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},ut.a.prototype.format=function(e){var t=this.im,r=this.re,n=V(this.re,e),i=V(this.im,e),e=M(e)?e:e?e.precision:null;return null!==e&&(e=Math.pow(10,-e),Math.abs(r/t)t.re?1:e.ret.im?1:e.imn[a]&&(n[a]=t[a],i=!0);i&&s(e,n,r)}return(p.prototype=new e).createDenseMatrix=function(e,t){return new p(e,t)},p.prototype.type="DenseMatrix",p.prototype.isDenseMatrix=!0,p.prototype.getDataType=function(){return Ue(this._data,J)},p.prototype.storage=function(){return"dense"},p.prototype.datatype=function(){return this._datatype},p.prototype.create=function(e,t){return new p(e,t)},p.prototype.subset=function(e,t,r){switch(arguments.length){case 1:return function(e,t){if(!A(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var r=t.size();if(r.length!==e._size.length)throw new we(r.length,e._size.length);for(var n=t.min(),i=t.max(),a=0,o=e._size.length;a");c(e,t.max().map(function(e){return e+1}),n);n=a.length;!function r(n,i,a,o,s){var e=s===o-1,t=i.dimension(s);e?t.forEach(function(e,t){Ee(e),n[e]=a[t[0]]}):t.forEach(function(e,t){Ee(e),r(n[e],i,a[t[0]],o,s+1)})}(e._data,t,r,n,0)}return e}(this,e,t,r);default:throw new SyntaxError("Wrong number of arguments")}},p.prototype.get=function(e){if(!x(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new we(e.length,this._size.length);for(var t=0;t=n.length)throw new Ne(t,n.length);return E(e)?e.create(wt(e.valueOf(),t,r)):wt(e,t,r)}function wt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){for(var t=e.length,r=e[0].length,n=[],i=0;it-1&&(e._values.splice(y,1),e._index.splice(y,1),m++)}e._ptr[f]=e._values.length}return e._size[0]=t,e._size[1]=r,e}function t(e,t,r,n,i){for(var a,o=n[0],s=n[1],u=[],c=0;c");for(var c=t.min()[0],f=t.min()[1],l=i[0],p=i[1],m=0;m "+(this._values?ge(this._values[u],e):"X");return i},N.prototype.toString=function(){return ge(this.toArray())},N.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},N.prototype.diagonal=function(e){if(e){if(I(e)&&(e=e.toNumber()),!M(e)||!L(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=0Math.pow(2,t)-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));n>=Math.pow(2,t-1)&&(n-=Math.pow(2,t))}return n},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return xt(e,this)}});return e.fromJSON=function(e){return parseFloat(e.value)},e}),Pt=Ye("string",["typed"],function(e){return(0,e.typed)("string",{"":function(){return""},number:V,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return xt(e,this)},any:function(e){return String(e)}})}),Ut=Ye("boolean",["typed"],function(e){return(0,e.typed)("boolean",{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;t=Number(e);if(""!==e&&!isNaN(t))return!!t;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return xt(e,this)}})}),Ft=Ye("bignumber",["typed","BigNumber"],function(e){var t=e.typed,i=e.BigNumber;return t("bignumber",{"":function(){return new i(0)},number:function(e){return new i(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],n=i(t[1]),t=new i(2).pow(Number(r));if(n.gt(t.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));r=new i(2).pow(Number(r)-1);return n.gte(r)?n.sub(t):n}return new i(e)},BigNumber:function(e){return e},Fraction:function(e){return new i(e.n).div(e.d).times(e.s)},null:function(e){return new i(0)},"Array | Matrix":function(e){return xt(e,this)}})}),Lt=Ye("complex",["typed","Complex"],function(e){var t=e.typed,r=e.Complex;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return xt(e,this)}})}),Ht=Ye("fraction",["typed","Fraction"],function(e){var t=e.typed,r=e.Fraction;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return xt(e,this)}})}),$t=Ye("matrix",["typed","Matrix","DenseMatrix","SparseMatrix"],function(e){var t=e.typed,n=(e.Matrix,e.DenseMatrix),i=e.SparseMatrix;return t("matrix",{"":function(){return r([])},string:function(e){return r([],e)},"string, string":function(e,t){return r([],e,t)},Array:function(e){return r(e)},Matrix:function(e){return r(e,e.storage())},"Array | Matrix, string":r,"Array | Matrix, string, string":r});function r(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}}),Gt=Ye("splitUnit",["typed"],function(e){return(0,e.typed)("splitUnit",{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),a="number, number";function Vt(e){return Math.abs(e)}function Zt(e,t){return e+t}function Wt(e,t){return e*t}function Jt(e){return-e}function Yt(e){return e}function Xt(e){return H(e)}function Qt(e){return Math.ceil(e)}function Kt(e){return e*e*e}function er(e){return Math.exp(e)}function tr(e){return $(e)}function rr(e,t){if(!L(e)||!L(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function nr(e,t){if(!L(e)||!L(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function ir(e){return Math.log(e)}function ar(e){return c(e)}function or(e){return u(e)}function sr(e,t){if(0=n.length)throw new Ne(t,n.length);return E(e)?e.create(vr(e.valueOf(),t,r)):vr(e,t,r)}})});function vr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){for(var t=e.length,r=e[0].length,n=[],i=0;ie.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);re)for(s-=e;s--;)u+="0";else s>1,c[p]&=1)}return c.reverse()}function fn(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?on(t):t.eq(n)?on(e):e.isFinite()&&t.isFinite()?un(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function ln(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function pn(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?(t.lt(55)?e.div(Math.pow(2,t.toNumber())+""):e.div(new r(2).pow(t))).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}at="number, number";function mn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function bitAnd");return e&t}function hn(e){if(!L(e))throw new Error("Integer expected in function bitNot");return~e}function dn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function bitOr");return e|t}function yn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function bitXor");return e^t}function gn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function leftShift");return e<>t}function xn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}mn.signature=at,hn.signature="number",xn.signature=vn.signature=gn.signature=yn.signature=dn.signature=at;var bn=Ye("bitAnd",["typed","matrix","equalScalar"],function(e){var t=e.typed,r=e.matrix,e=e.equalScalar,n=jr({typed:t,equalScalar:e}),i=Pr({typed:t,equalScalar:e}),a=wr({typed:t,equalScalar:e}),o=Dr({typed:t}),s=Nr({typed:t});return t("bitAnd",{"number, number":mn,"BigNumber, BigNumber":an,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return n(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return n(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return s(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return s(t,e,this,!0)},"Array, any":function(e,t){return s(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return s(r(t),e,this,!0).valueOf()}})}),wn=Ye("bitNot",["typed"],function(e){return(0,e.typed)("bitNot",{number:hn,BigNumber:on,"Array | Matrix":function(e){return xt(e,this)}})}),Nn=Ye("bitOr",["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,r=e.matrix,n=e.equalScalar,e=e.DenseMatrix,i=Ir({typed:t}),a=Br({typed:t,equalScalar:n}),o=kr({typed:t,DenseMatrix:e}),s=Dr({typed:t}),u=Nr({typed:t});return t("bitOr",{"number, number":dn,"BigNumber, BigNumber":sn,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})}),Mn=Ye("algorithm07",["typed","DenseMatrix"],function(e){var N=e.typed,M=e.DenseMatrix;return function(e,t,r){var n=e._size,i=e._datatype,a=t._size,o=t._datatype;if(n.length!==a.length)throw new we(n.length,a.length);if(n[0]!==a[0]||n[1]!==a[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+a+")");var s,u=n[0],c=n[1],f=0,l=r;"string"==typeof i&&i===o&&(s=i,f=N.convert(0,s),l=N.find(r,[s,s]));for(var p=[],m=0;mn)return e.substring(0,n);if(e.lengtha)for(var u=a-1,c=o.length;un&&(n=t[a],r=[a])}return r}});function ji(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=2>=1,i=o(i,i);return n}function l(e,t){return r(f(e.valueOf(),t))}});function Xi(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function Qi(n){for(var e=1;ee.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);rt.re?1:e.ret.im?1:e.imr.length?1:t.length=e.length)throw new Error("k out of bounds");for(var n=0;n=e&&(c(o.value,0)||r(o.key,o.value,this)),(o=n.extractMinimum())&&a.push(o);for(var s=0;se[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(r)}})}),Jo=Ye("setSize",["typed","compareNatural"],function(e){var t=e.typed,a=e.compareNatural;return t("setSize",{"Array | Matrix":function(e){return(Array.isArray(e)?qe(e):qe(e.toArray())).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return(Array.isArray(e)?qe(e):qe(e.toArray())).length;for(var r=qe(Array.isArray(e)?e:e.toArray()).sort(a),n=1,i=1;i)'),t+this.index.toHTML(e)},r.prototype._toTex=function(e){var t=this.object.toTex(e);return n(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(e){return new r(e.object,e.index)},r},{isClass:!0,isNode:!0}),ls=Ye("ArrayNode",["Node"],function(e){e=e.Node;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(R))throw new TypeError("Array containing Nodes expected")}return(n.prototype=new e).type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(t,r){var e=Ie(this.items,function(e){return e._compile(t,r)});if("Array"===t.config.matrix)return function(t,r,n){return Ie(e,function(e){return e(t,r,n)})};var i=t.matrix;return function(t,r,n){return i(Ie(e,function(e){return e(t,r,n)}))}},n.prototype.forEach=function(e){for(var t=0;t['+this.items.map(function(e){return e.toHTML(t)}).join(',')+']'},n.prototype._toTex=function(t){var r="\\begin{bmatrix}";return this.items.forEach(function(e){e.items?r+=e.items.map(function(e){return e.toTex(t)}).join("&"):r+=e.toTex(t),r+="\\\\"}),r+="\\end{bmatrix}"},n},{isClass:!0,isNode:!0});function ps(e){return(ps="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var ms=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function hs(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i)'),t+r+'='+n},a.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return o(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},a},{isClass:!0,isNode:!0}),vs=Ye("BlockNode",["ResultSet","Node"],function(e){var o=e.ResultSet,e=e.Node;function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map(function(e){var t=e&&e.node,e=!e||void 0===e.visible||e.visible;if(!R(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof e)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:e}})}return(a.prototype=new e).type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(t,r){var e=Ie(this.blocks,function(e){return{evaluate:e.node._compile(t,r),visible:e.visible}});return function(r,n,i){var a=[];return Be(e,function(e){var t=e.evaluate(r,n,i);e.visible&&a.push(t)}),new o(a)}},a.prototype.forEach=function(e){for(var t=0;t;')}).join('
')},a.prototype._toTex=function(t){return this.blocks.map(function(e){return e.node.toTex(t)+(e.visible?"":";")}).join("\\;\\;\n")},a},{isClass:!0,isNode:!0}),xs=Ye("ConditionalNode",["Node"],function(e){e=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!R(e))throw new TypeError("Parameter condition must be a Node");if(!R(t))throw new TypeError("Parameter trueExpr must be a Node");if(!R(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return(n.prototype=new e).type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(e,t){var n=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,r){return(function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return e;if(e){if(I(e))return!e.isZero();if(Z(e))return e.re||e.im;if(W(e))return e.value}if(null!=e)throw new TypeError('Unsupported type of condition "'+J(e)+'"')}(n(e,t,r))?i:a)(e,t,r)}},n.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=hs(this,t),n=this.condition.toString(e),i=hs(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),i=hs(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==i&&i<=r)&&(a="("+a+")");i=this.falseExpr.toString(e),e=hs(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==e&&e<=r)&&(i="("+i+")"),n+" ? "+a+" : "+i},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(e){return new n(e.condition,e.trueExpr,e.falseExpr)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=hs(this,t),n=this.condition.toHTML(e),i=hs(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),i=hs(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==i&&i<=r)&&(a='('+a+')');i=this.falseExpr.toHTML(e),e=hs(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==e&&e<=r)&&(i='('+i+')'),n+'?'+a+':'+i},n.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},n},{isClass:!0,isNode:!0}),at=r(11),bs=r.n(at),ws={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{?}"},Ns={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"},Ms={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(Ns.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(Ns.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(Ns.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(Ns.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(Ns.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(Ns.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(Ns.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(Ns.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(Ns.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(Ns.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(Ns.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(Ns.bitAnd,"${args[1]}\\right)")},bitNot:{1:Ns.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(Ns.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(Ns.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(Ns.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(Ns.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(Ns.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(Ns.and,"${args[1]}\\right)")},not:{1:Ns.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(Ns.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(Ns.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(Ns.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}"},sqrtm:{1:"{${args[0]}}".concat(Ns.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(Ns.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(Ns.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(Ns.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(Ns.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(Ns.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(Ns.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(Ns.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(Ns.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(Ns.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(ws.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)"}},Ss={deg:"^\\circ"};function Es(e){return bs()(e,{preserveFormatting:!0})}function As(e,t){return(t=void 0!==t&&t)?We(Ss,e)?Ss[e]:"\\mathrm{"+Es(e)+"}":We(ws,e)?ws[e]:Es(e)}var Os=Ye("ConstantNode",["Node"],function(e){e=e.Node;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return(t.prototype=new e).type="ConstantNode",t.prototype.isConstantNode=!0,t.prototype._compile=function(e,t){var r=this.value;return function(){return r}},t.prototype.forEach=function(e){},t.prototype.map=function(e){return this.clone()},t.prototype.clone=function(){return new t(this.value)},t.prototype._toString=function(e){return ge(this.value,e)},t.prototype.toHTML=function(e){e=this._toString(e);switch(J(this.value)){case"number":case"BigNumber":case"Fraction":return''+e+"";case"string":return''+e+"";case"boolean":return''+e+"";case"null":return''+e+"";case"undefined":return''+e+"";default:return''+e+""}},t.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},t.fromJSON=function(e){return new t(e.value)},t.prototype._toTex=function(e){var t=this._toString(e);switch(J(this.value)){case"string":return"\\mathtt{"+Es(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";e=t.toLowerCase().indexOf("e");return-1!==e?t.substring(0,e)+"\\cdot10^{"+t.substring(e+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},t},{isClass:!0,isNode:!0}),Cs=Ye("FunctionAssignmentNode",["typed","Node"],function(e){var f=e.typed,e=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!R(r))throw new TypeError('Node expected for parameter "expr"');if(e in is)throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||"any"}),this.expr=r}function i(e,t){var r=hs(e,t),e=hs(e.expr,t);return"all"===t||null!==e&&e<=r}return(n.prototype=new e).type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,t){var r=Object.create(t);Be(this.params,function(e){r[e]=!0});var a=this.expr._compile(e,r),o=this.name,s=this.params,u=Re(this.types,","),c=o+"("+Re(this.params,", ")+")";return function(r,n,i){var e={};e[u]=function(){for(var e=Object.create(n),t=0;t'+xe(this.params[n])+"");e=this.expr.toHTML(e);return i(this,t)&&(e='('+e+')'),''+xe(this.name)+'('+r.join(',')+')='+e},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",e=this.expr.toTex(e);return i(this,t)&&(e="\\left(".concat(e,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(As).join(",")+"\\right):="+e},n},{isClass:!0,isNode:!0});function _s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r.'+xe(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(t){var e=this.dimensions.map(function(e){return e.toTex(t)});return this.dotNotation?"."+this.getObjectProperty():"_{"+e.join(",")+"}"},i},{isClass:!0,isNode:!0});function zs(e){return(zs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var qs=Ye("ObjectNode",["Node"],function(e){e=e.Node;function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=t||{},t&&("object"!==zs(t)||!Object.keys(t).every(function(e){return R(t[e])})))throw new TypeError("Object containing Nodes expected")}return(n.prototype=new e).type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var r,a={};for(r in this.properties)if(We(this.properties,r)){var n=ve(r),n=JSON.parse(n);if(!vi(this.properties,n))throw new Error('No access to property "'+n+'"');a[n]=this.properties[r]._compile(e,t)}return function(e,t,r){var n,i={};for(n in a)We(a,n)&&(i[n]=a[n](e,t,r));return i}},n.prototype.forEach=function(e){for(var t in this.properties)We(this.properties,t)&&e(this.properties[t],"properties["+ve(t)+"]",this)},n.prototype.map=function(e){var t,r={};for(t in this.properties)We(this.properties,t)&&(r[t]=this._ifNode(e(this.properties[t],"properties["+ve(t)+"]",this)));return new n(r)},n.prototype.clone=function(){var e,t={};for(e in this.properties)We(this.properties,e)&&(t[e]=this.properties[e]);return new n(t)},n.prototype._toString=function(e){var t,r=[];for(t in this.properties)We(this.properties,t)&&r.push(ve(t)+": "+this.properties[t].toString(e));return"{"+r.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(e){return new n(e.properties)},n.prototype.toHTML=function(e){var t,r=[];for(t in this.properties)We(this.properties,t)&&r.push(''+xe(t)+':'+this.properties[t].toHTML(e));return'{'+r.join(',')+'}'},n.prototype._toTex=function(e){var t,r=[];for(t in this.properties)We(this.properties,t)&&r.push("\\mathbf{"+t+":} & "+this.properties[t].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(r.join("\n"),"\\end{array}\\right\\}")},n},{isClass:!0,isNode:!0}),Is=Ye("OperatorNode",["Node"],function(e){e=e.Node;function i(e,t,r,n){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(R))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.op=e,this.fn=t,this.args=r||[]}function c(n,i,e,t,r){var a,o=hs(n,i),s=ds(n,i);if("all"===i||2)'),"right"===e?''+xe(this.op)+""+a:a+''+xe(this.op)+""}if(2===n.length){var a=n[0].toHTML(r),o=n[1].toHTML(r);return i[0]&&(a='('+a+')'),i[1]&&(o='('+o+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?a+''+o:a+''+xe(this.op)+""+o}o=n.map(function(e,t){return e=e.toHTML(r),i[t]&&(e='('+e+')'),e});return 2'):o.join(''+xe(this.op)+""):''+xe(this.fn)+'('+o.join(',')+')'},i.prototype._toTex=function(r){var e=r&&r.parenthesis?r.parenthesis:"keep",t=r&&r.implicit?r.implicit:"hide",n=this.args,i=c(this,e,t,n,!0),a=void 0===(a=Ns[this.fn])?this.op:a;if(1===n.length){var o=ds(this,e),s=n[0].toTex(r);return i[0]&&(s="\\left(".concat(s,"\\right)")),"right"===o?a+s:s+a}if(2===n.length){o=n[0],s=o.toTex(r);i[0]&&(s="\\left(".concat(s,"\\right)"));var u=n[1].toTex(r);switch(i[1]&&(u="\\left(".concat(u,"\\right)")),o=("keep"===e?o:o.getContent()).getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return a+"{"+s+"}{"+u+"}";case"OperatorNode:pow":switch(s="{"+s+"}",u="{"+u+"}",o){case"ConditionalNode":case"OperatorNode:divide":s="\\left(".concat(s,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===t)return s+"~"+u}return s+a+u}if(2('+this.content.toHTML(e)+')':this.content.toHTML(e)},t.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},t},{isClass:!0,isNode:!0}),ks=Ye("RangeNode",["Node"],function(e){e=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!R(e))throw new TypeError("Node expected");if(!R(t))throw new TypeError("Node expected");if(r&&!R(r))throw new TypeError("Node expected");if(3('+n+')'),t=n,this.step&&(n=this.step.toHTML(e),r.step&&(n='('+n+')'),t+=':'+n);e=this.end.toHTML(e);return r.end&&(e='('+e+')'),t+':'+e},n.prototype._toTex=function(e){var t,r=i(this,e&&e.parenthesis?e.parenthesis:"keep"),n=this.start.toTex(e);r.start&&(n="\\left(".concat(n,"\\right)")),this.step&&(t=this.step.toTex(e),r.step&&(t="\\left(".concat(t,"\\right)")),n+=":"+t);e=this.end.toTex(e);return r.end&&(e="\\left(".concat(e,"\\right)")),n+":"+e},n},{isClass:!0,isNode:!0}),Ds=Ye("RelationalNode",["Node"],function(e){e=e.Node;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return(i.prototype=new e).type="RelationalNode",i.prototype.isRelationalNode=!0,i.prototype._compile=function(o,t){var s=this,u=this.params.map(function(e){return e._compile(o,t)});return function(e,t,r){for(var n,i=u[0](e,t,r),a=0;a",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o('+e.toHTML(n)+')':e.toHTML(n)}),t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o'+xe(t[this.conditionals[o]])+""+e[o+1];return r},i.prototype._toTex=function(n){for(var i=n&&n.parenthesis?n.parenthesis:"keep",a=hs(this,i),e=this.params.map(function(e,t){var r=hs(e,i);return"all"===i||null!==r&&r<=a?"\\left("+e.toTex(n)+"\right)":e.toTex(n)}),t=e[0],r=0;r'+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},t.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},t.fromJSON=function(e){return new t(e.name)},t.prototype._toTex=function(e){var t=!1;void 0===r[this.name]&&s(this.name)&&(t=!0);t=As(this.name,t);return"\\"===t[0]?t:" "+t},t},{isClass:!0,isNode:!0});function js(e){return(js="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ps(){return(Ps=Object.assign||function(e){for(var t=1;t'+xe(this.fn)+'('+e.join(',')+')'};var o=d.prototype.toTex;return d.prototype.toTex=function(e){var t;return e&&"object"===js(e.handler)&&We(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:o.call(this,e)},d.prototype._toTex=function(t){var e,r,n=this.args.map(function(e){return e.toTex(t)});switch(Ms[this.name]&&(e=Ms[this.name]),!i[this.name]||"function"!=typeof i[this.name].toTex&&"object"!==js(i[this.name].toTex)&&"string"!=typeof i[this.name].toTex||(e=i[this.name].toTex),js(e)){case"function":r=e(this,t);break;case"string":r=a(e,this,t);break;case"object":switch(js(e[n.length])){case"function":r=e[n.length](this,t);break;case"string":r=a(e[n.length],this,t)}}return void 0!==r?r:a("\\mathrm{${name}}\\left(${args}\\right)",this,t)},d.prototype.getIdentifier=function(){return this.type+":"+this.name},d},{isClass:!0,isNode:!0});function Fs(){return(Fs=Object.assign||function(e){for(var t=1;t":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},O={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},C={true:!0,false:!1,null:null,undefined:void 0},_=["NaN","Infinity"];function T(e,t){return e.expression.substr(e.index,t)}function z(e){return T(e,1)}function q(e){e.index++}function I(e){return e.expression.charAt(e.index-1)}function B(e){return e.expression.charAt(e.index+1)}function k(e){for(e.tokenType=w,e.token="",e.comment="";b.isWhitespace(z(e),e.nestingLevel);)q(e);if("#"===z(e))for(;"\n"!==z(e)&&""!==z(e);)e.comment+=z(e),q(e);if(""!==z(e)){if("\n"===z(e)&&!e.nestingLevel)return e.tokenType=N,e.token=z(e),q(e),0;var t=z(e),r=T(e,2),n=T(e,3);if(3===n.length&&A[n])return e.tokenType=N,e.token=n,q(e),q(e),q(e),0;if(2===r.length&&A[r])return e.tokenType=N,e.token=r,q(e),q(e),0;if(A[t])return e.tokenType=N,e.token=t,q(e),0;if(b.isDigitDot(t)){e.tokenType=M;t=T(e,2);if("0b"!==t&&"0o"!==t&&"0x"!==t){if("."===z(e))e.token+=z(e),q(e),b.isDigit(z(e))||(e.tokenType=N);else{for(;b.isDigit(z(e));)e.token+=z(e),q(e);b.isDecimalMark(z(e),B(e))&&(e.token+=z(e),q(e))}for(;b.isDigit(z(e));)e.token+=z(e),q(e);if("E"===z(e)||"e"===z(e))if(b.isDigit(B(e))||"-"===B(e)||"+"===B(e)){if(e.token+=z(e),q(e),"+"!==z(e)&&"-"!==z(e)||(e.token+=z(e),q(e)),!b.isDigit(z(e)))throw oe(e,'Digit expected, got "'+z(e)+'"');for(;b.isDigit(z(e));)e.token+=z(e),q(e);if(b.isDecimalMark(z(e),B(e)))throw oe(e,'Digit expected, got "'+z(e)+'"')}else if("."===B(e))throw q(e),oe(e,'Digit expected, got "'+z(e)+'"')}else{for(e.token+=z(e),q(e),e.token+=z(e),q(e);b.isHexDigit(z(e));)e.token+=z(e),q(e);t=z(e);if("i"===t)for(e.token+=t,q(e);b.isDigit(z(e));)e.token+=z(e),q(e)}}else{if(!b.isAlpha(z(e),I(e),B(e))){for(e.tokenType=E;""!==z(e);)e.token+=z(e),q(e);throw oe(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(z(e),I(e),B(e))||b.isDigit(z(e));)e.token+=z(e),q(e);We(O,e.token)?e.tokenType=N:e.tokenType=S}}else e.tokenType=N}function D(e){for(;k(e),"\n"===e.token;);}function R(e){e.nestingLevel++}function j(e){e.nestingLevel--}function P(e,t){var r={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:w,nestingLevel:0,conditionalLevel:null};Fs(r,{expression:e,extraNodes:t}),k(r);t=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=U(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),k(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=U(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return 0":"larger","<=":"smallerEq",">=":"largerEq"};We(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),D(e),t.push(Z(e))}return 1===t.length?t[0]:2===t.length?new y(r[0].name,r[0].fn,t):new v(r.map(function(e){return e.fn}),t)}function Z(e){for(var t,r,n,i=W(e),a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};We(a,e.token);)r=a[t=e.token],D(e),n=[i,W(e)],i=new y(t,r,n);return i}function W(e){for(var t,r,n,i=J(e),a={to:"to",in:"to"};We(a,e.token);)r=a[t=e.token],D(e),i="in"===t&&""===e.token?new y("*","multiply",[i,new x("in")],!0):(n=[i,J(e)],new y(t,r,n));return i}function J(e){var t=[],r=":"===e.token?new l(1):Y(e);if(":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(t.push(r);":"===e.token&&t.length<3;)D(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?t.push(new x("end")):t.push(Y(e));r=3===t.length?new n(t[0],t[2],t[1]):new n(t[0],t[1])}return r}function Y(e){for(var t,r,n,i=X(e),a={"+":"add","-":"subtract"};We(a,e.token);)r=a[t=e.token],D(e),n=[i,X(e)],i=new y(t,r,n);return i}function X(e){for(var t,r,n,i=t=Q(e),a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};We(a,e.token);)n=a[r=e.token],D(e),i=Q(e),t=new y(r,n,[t,i]);return t}function Q(e){for(var t,r=t=K(e);e.tokenType===S||"in"===e.token&&ce(t)||!(e.tokenType!==M||ce(r)||le(r)&&"!"!==r.op)||"("===e.token;)r=K(e),t=new y("*","multiply",[t,r],!0);return t}function K(e){for(var t=ee(e),r=t,n=[];"/"===e.token&&ce(r);){if(n.push(Fs({},e)),D(e),e.tokenType!==M){Fs(e,n.pop());break}if(n.push(Fs({},e)),D(e),e.tokenType!==S&&"("!==e.token){n.pop(),Fs(e,n.pop());break}Fs(e,n.pop()),n.pop(),r=ee(e),t=new y("/","divide",[t,r])}return t}function ee(e){var t,r,n,i={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return We(i,e.token)?(n=i[e.token],t=e.token,D(e),r=[ee(e)],new y(t,n,r)):(n=function(e){for(var t,r,n=function(e){var t,r,n=[];if(e.tokenType===S&&We(e.extraNodes,e.token)){var i=e.extraNodes[e.token];if(k(e),"("===e.token){if(n=[],R(e),k(e),")"!==e.token)for(n.push(U(e));","===e.token;)k(e),n.push(U(e));if(")"!==e.token)throw oe(e,"Parenthesis ) expected");j(e),k(e)}return new i(n)}return(t=e).tokenType===S||t.tokenType===N&&t.token in O?(i=t.token,k(t),te(t,We(C,i)?new l(C[i]):-1!==_.indexOf(i)?new l(s(i,"number")):new x(i))):'"'===(t=t).token?(r=re(t),te(t,new l(r))):"'"===(r=t).token?(t=ne(r),te(r,new l(t))):function(e){var t,r,n,i;if("["!==e.token)return function(e){if("{"!==e.token)return(n=e).tokenType===M?(i=n.token,k(n),new l(s(i,u.number))):function(e){var t;if("("!==e.token)return function(e){throw""===e.token?oe(e,"Unexpected end of expression"):oe(e,"Value expected")}(e);if(R(e),k(e),t=U(e),")"!==e.token)throw oe(e,"Parenthesis ) expected");return j(e),k(e),te(e,t=new g(t))}(n);var t;R(e);var r={};do{if(k(e),"}"!==e.token){if('"'===e.token)t=re(e);else if("'"===e.token)t=ne(e);else{if(!(e.tokenType===S||e.tokenType===N&&e.token in O))throw oe(e,"Symbol or string expected as object key");t=e.token,k(e)}if(":"!==e.token)throw oe(e,"Colon : expected after object key");k(e),r[t]=U(e)}}while(","===e.token);if("}"!==e.token)throw oe(e,"Comma , or bracket } expected after object value");j(e),k(e);var n,i,n=new d(r);return te(e,n)}(e);if(R(e),k(e),"]"!==e.token){var a=ie(e);if(";"===e.token){for(n=1,r=[a];";"===e.token;)k(e),r[n]=ie(e),n++;if("]"!==e.token)throw oe(e,"End of matrix ] expected");j(e),k(e),i=r[0].items.length;for(var o=1;oi))for(var l=s[c+1];f=I?S[T+f]-=m:0!==S[T+f]&&(S[T+f]=S[_+f]+$);for(h=F;h1, -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([[1, 2], [3, 4]])"],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"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=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([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},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:[]},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"]},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"]},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"]},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 indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},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:["forEach([1, 2, 3], function(val) { console.log(val) })"],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"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},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"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},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)'],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")',"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])"],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], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},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"]},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"])',"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 a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",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]"],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"]},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:[]},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.",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.",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 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"]},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:[]},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, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},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, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},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 probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, 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)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},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 hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},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 hyperbolic arccosecant 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:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},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, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},fu=Ye("help",["typed","mathWithTransform","Help"],function(e){var t=e.typed,i=e.mathWithTransform,a=e.Help;return t("help",{any:function(e){var t,r=e;if("string"!=typeof e)for(t in i)if(We(i,t)&&e===i[t]){r=t;break}var n=yi(cu,r);if(n)return new a(n);n="function"==typeof r?r.name:r;throw new Error('No documentation found on "'+n+'"')}})}),lu=Ye("chain",["typed","Chain"],function(e){var t=e.typed,r=e.Chain;return t("chain",{"":function(){return new r},any:function(e){return new r(e)}})}),pu=Ye("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],function(e){var t=e.typed,n=e.matrix,f=e.subtract,l=e.multiply,p=e.unaryMinus,m=e.lup;return t("det",{any:He,"Array | Matrix":function(e){var t;switch((t=E(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return He(e);case 1:if(1===t[0])return He(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+ge(t)+")");case 2:var r=t[0];if(r===t[1])return function(e,t){if(1===t)return He(e[0][0]);if(2===t)return f(l(e[0][0],e[1][1]),l(e[1][0],e[0][1]));for(var r=m(e),n=r.U[0][0],i=1;if&&(f=M(s[p][c]),l=p),p++;if(0===f)throw Error("Cannot calculate inverse, determinant is zero");(p=l)!==c&&(a=s[c],s[c]=s[p],s[p]=a,a=u[c],u[c]=u[p],u[p]=a);var m=s[c],h=u[c];for(p=0;p=l(r);){var o,s=a[0][0],u=a[0][1];e=function(e,t,r,n){for(var i=e.length,a=b(g(t)),o=b(v(t)),s=x(a,a),u=x(o,o),c=A(i,b(0)),f=A(i,b(0)),l=w(b(2),a,o,e[r][n]),t=d(y(x(s,e[r][r]),l),x(u,e[n][n])),s=N(x(u,e[r][r]),l,x(s,e[n][n])),p=0;p=Math.abs(r);){var f=c[0][0],l=c[0][1];e=function(e,t,r,n){for(var i=e.length,a=Math.cos(t),o=Math.sin(t),s=a*a,u=o*o,c=A(i,0),f=A(i,0),t=s*e[r][r]-2*a*o*e[r][n]+u*e[n][n],s=u*e[r][r]+2*a*o*e[r][n]+s*e[n][n],l=0;l>1;return Ou(e,r)*Ou(1+r,t)}function Cu(e,t){if(!L(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!L(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(e");if(2!==o.length)throw SyntaxError("Could not parse rule: "+n);n={l:o[0],r:o[1]};case"object":var s,i={l:A(u(n.l)),r:A(u(n.r))};n.context&&(i.evaluate=n.context),n.evaluate&&(i.evaluate=u(n.evaluate)),w(i.l)&&(s=E(i.l),o=new v("_p"+C++),i.expanded={},i.expanded.l=s([i.l.clone(),o]),N(i.expanded.l),M(i.expanded.l),i.expanded.r=s([i.r,o]));break;case"function":i=n;break;default:throw TypeError("Unsupported type of rule: "+a)}t.push(i)}return t}(t);for(var i=x(e,r),a={},o=(i=A(i)).toString({parenthesis:"all"});!a[o];){a[o]=!0;for(var s=C=0;s